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 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 9 | #include <bootstate.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 10 | #include <commonlib/console/post_codes.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 11 | #include <console/console.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 12 | #include <cpu/x86/smm.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 13 | #include <device/mmio.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 14 | #include <device/pci.h> |
Subrata Banik | 78e66ad | 2021-09-30 20:32:50 +0530 | [diff] [blame] | 15 | #include <intelblocks/cse.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 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> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 21 | #include <soc/p2sb.h> |
| 22 | #include <soc/pci_devs.h> |
| 23 | #include <soc/pcr_ids.h> |
| 24 | #include <soc/pm.h> |
| 25 | #include <soc/smbus.h> |
| 26 | #include <soc/soc_chip.h> |
| 27 | #include <soc/systemagent.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 28 | #include <spi-generic.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 29 | |
| 30 | #define CAMERA1_CLK 0x8000 /* Camera 1 Clock */ |
| 31 | #define CAMERA2_CLK 0x8080 /* Camera 2 Clock */ |
| 32 | #define CAM_CLK_EN (1 << 1) |
| 33 | #define MIPI_CLK (1 << 0) |
| 34 | #define HDPLL_CLK (0 << 0) |
| 35 | |
| 36 | static void pch_enable_isclk(void) |
| 37 | { |
| 38 | pcr_or32(PID_ISCLK, CAMERA1_CLK, CAM_CLK_EN | MIPI_CLK); |
| 39 | pcr_or32(PID_ISCLK, CAMERA2_CLK, CAM_CLK_EN | MIPI_CLK); |
| 40 | } |
| 41 | |
| 42 | static void pch_handle_sideband(config_t *config) |
| 43 | { |
| 44 | if (config->pch_isclk) |
| 45 | pch_enable_isclk(); |
| 46 | } |
| 47 | |
| 48 | static void pch_finalize(void) |
| 49 | { |
Michael Niewöhner | d2fadda | 2021-09-27 19:26:20 +0200 | [diff] [blame] | 50 | config_t *config = config_of_soc(); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 51 | |
| 52 | /* TCO Lock down */ |
| 53 | tco_lockdown(); |
| 54 | |
| 55 | /* TODO: Add Thermal Configuration */ |
| 56 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 57 | pch_handle_sideband(config); |
| 58 | |
| 59 | pmc_clear_pmcon_sts(); |
| 60 | } |
| 61 | |
| 62 | static void tbt_finalize(void) |
| 63 | { |
| 64 | int i; |
| 65 | const struct device *dev; |
| 66 | |
| 67 | /* Disable Thunderbolt PCIe root ports bus master */ |
| 68 | for (i = 0; i < NUM_TBT_FUNCTIONS; i++) { |
| 69 | dev = pcidev_path_on_root(SA_DEVFN_TBT(i)); |
| 70 | if (dev) |
| 71 | pci_dev_disable_bus_master(dev); |
| 72 | } |
| 73 | } |
| 74 | |
Subrata Banik | 9598616 | 2022-02-10 14:35:37 +0530 | [diff] [blame] | 75 | static void heci_finalize(void) |
| 76 | { |
| 77 | heci_set_to_d0i3(); |
| 78 | if (CONFIG(DISABLE_HECI1_AT_PRE_BOOT)) |
| 79 | heci1_disable(); |
| 80 | } |
| 81 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 82 | static void soc_finalize(void *unused) |
| 83 | { |
| 84 | printk(BIOS_DEBUG, "Finalizing chipset.\n"); |
| 85 | |
| 86 | pch_finalize(); |
| 87 | apm_control(APM_CNT_FINALIZE); |
| 88 | tbt_finalize(); |
Subrata Banik | 9598616 | 2022-02-10 14:35:37 +0530 | [diff] [blame] | 89 | if (CONFIG(USE_FSP_NOTIFY_PHASE_READY_TO_BOOT) && |
| 90 | CONFIG(USE_FSP_NOTIFY_PHASE_END_OF_FIRMWARE)) |
| 91 | heci_finalize(); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 92 | |
| 93 | /* Indicate finalize step with post code */ |
lilacious | 40cb3fe | 2023-06-21 23:24:14 +0200 | [diff] [blame] | 94 | post_code(POSTCODE_OS_BOOT); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | 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] | 98 | /* |
| 99 | * The purpose of this change is to accommodate more time to push out sending |
| 100 | * CSE EOP messages at post. |
| 101 | */ |
| 102 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, soc_finalize, NULL); |