Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | /* |
| 4 | * This file is created based on Intel Alder Lake Processor PCH Datasheet |
| 5 | * Document number: 621483 |
| 6 | * Chapter number: 4, 29 |
| 7 | */ |
| 8 | |
| 9 | #include <arch/io.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 10 | #include <bootstate.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 11 | #include <commonlib/console/post_codes.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 12 | #include <console/console.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 13 | #include <cpu/x86/smm.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 14 | #include <device/mmio.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 15 | #include <device/pci.h> |
| 16 | #include <intelblocks/lpc_lib.h> |
| 17 | #include <intelblocks/pcr.h> |
| 18 | #include <intelblocks/pmclib.h> |
Tim Wawrzynczak | 091dfa1 | 2021-08-24 09:32:09 -0600 | [diff] [blame] | 19 | #include <intelblocks/systemagent.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 20 | #include <intelblocks/tco.h> |
| 21 | #include <intelblocks/thermal.h> |
Tim Wawrzynczak | 091dfa1 | 2021-08-24 09:32:09 -0600 | [diff] [blame] | 22 | #include <intelpch/lockdown.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 23 | #include <soc/p2sb.h> |
| 24 | #include <soc/pci_devs.h> |
| 25 | #include <soc/pcr_ids.h> |
| 26 | #include <soc/pm.h> |
| 27 | #include <soc/smbus.h> |
| 28 | #include <soc/soc_chip.h> |
| 29 | #include <soc/systemagent.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 30 | #include <spi-generic.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 31 | |
| 32 | #define CAMERA1_CLK 0x8000 /* Camera 1 Clock */ |
| 33 | #define CAMERA2_CLK 0x8080 /* Camera 2 Clock */ |
| 34 | #define CAM_CLK_EN (1 << 1) |
| 35 | #define MIPI_CLK (1 << 0) |
| 36 | #define HDPLL_CLK (0 << 0) |
| 37 | |
| 38 | static void pch_enable_isclk(void) |
| 39 | { |
| 40 | pcr_or32(PID_ISCLK, CAMERA1_CLK, CAM_CLK_EN | MIPI_CLK); |
| 41 | pcr_or32(PID_ISCLK, CAMERA2_CLK, CAM_CLK_EN | MIPI_CLK); |
| 42 | } |
| 43 | |
| 44 | static void pch_handle_sideband(config_t *config) |
| 45 | { |
| 46 | if (config->pch_isclk) |
| 47 | pch_enable_isclk(); |
| 48 | } |
| 49 | |
| 50 | static void pch_finalize(void) |
| 51 | { |
| 52 | config_t *config; |
| 53 | |
| 54 | /* TCO Lock down */ |
| 55 | tco_lockdown(); |
| 56 | |
| 57 | /* TODO: Add Thermal Configuration */ |
| 58 | |
| 59 | /* |
| 60 | * Disable ACPI PM timer based on dt policy |
| 61 | * |
| 62 | * Disabling ACPI PM timer is necessary for XTAL OSC shutdown. |
| 63 | * Disabling ACPI PM timer also switches off TCO |
| 64 | */ |
| 65 | config = config_of_soc(); |
| 66 | if (config->PmTimerDisabled) |
| 67 | pmc_disable_acpi_timer(); |
| 68 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 69 | pch_handle_sideband(config); |
| 70 | |
| 71 | pmc_clear_pmcon_sts(); |
| 72 | } |
| 73 | |
| 74 | static void tbt_finalize(void) |
| 75 | { |
| 76 | int i; |
| 77 | const struct device *dev; |
| 78 | |
| 79 | /* Disable Thunderbolt PCIe root ports bus master */ |
| 80 | for (i = 0; i < NUM_TBT_FUNCTIONS; i++) { |
| 81 | dev = pcidev_path_on_root(SA_DEVFN_TBT(i)); |
| 82 | if (dev) |
| 83 | pci_dev_disable_bus_master(dev); |
| 84 | } |
| 85 | } |
| 86 | |
Tim Wawrzynczak | 091dfa1 | 2021-08-24 09:32:09 -0600 | [diff] [blame] | 87 | static void sa_finalize(void) |
| 88 | { |
| 89 | if (get_lockdown_config() == CHIPSET_LOCKDOWN_COREBOOT) |
| 90 | sa_lock_pam(); |
| 91 | } |
| 92 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 93 | static void soc_finalize(void *unused) |
| 94 | { |
| 95 | printk(BIOS_DEBUG, "Finalizing chipset.\n"); |
| 96 | |
| 97 | pch_finalize(); |
| 98 | apm_control(APM_CNT_FINALIZE); |
| 99 | tbt_finalize(); |
Tim Wawrzynczak | 091dfa1 | 2021-08-24 09:32:09 -0600 | [diff] [blame] | 100 | sa_finalize(); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 101 | |
| 102 | /* Indicate finalize step with post code */ |
| 103 | post_code(POST_OS_BOOT); |
| 104 | } |
| 105 | |
| 106 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL); |
Subrata Banik | a834a6e | 2021-09-21 20:12:06 +0530 | [diff] [blame^] | 107 | /* |
| 108 | * The purpose of this change is to accommodate more time to push out sending |
| 109 | * CSE EOP messages at post. |
| 110 | */ |
| 111 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, soc_finalize, NULL); |