Angel Pons | 32abdd6 | 2020-04-05 15:47:03 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 2 | |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 3 | #include <bootstate.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 4 | #include <commonlib/console/post_codes.h> |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 5 | #include <console/console.h> |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 6 | #include <cpu/x86/smm.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 7 | #include <device/mmio.h> |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 8 | #include <device/pci.h> |
| 9 | #include <intelblocks/lpc_lib.h> |
| 10 | #include <intelblocks/pcr.h> |
Subrata Banik | 0359d9d | 2020-09-28 18:43:47 +0530 | [diff] [blame] | 11 | #include <intelblocks/pmclib.h> |
Subrata Banik | 7bc4dc5 | 2018-05-17 18:40:32 +0530 | [diff] [blame] | 12 | #include <intelblocks/tco.h> |
Subrata Banik | d19b3ca | 2019-08-01 11:00:17 +0530 | [diff] [blame] | 13 | #include <intelblocks/thermal.h> |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 14 | #include <soc/p2sb.h> |
| 15 | #include <soc/pci_devs.h> |
| 16 | #include <soc/pcr_ids.h> |
| 17 | #include <soc/pm.h> |
| 18 | #include <soc/smbus.h> |
Subrata Banik | df29d23 | 2019-07-05 16:00:38 +0530 | [diff] [blame] | 19 | #include <soc/soc_chip.h> |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 20 | #include <soc/systemagent.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 21 | #include <spi-generic.h> |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 22 | |
| 23 | #define CAMERA1_CLK 0x8000 /* Camera 1 Clock */ |
| 24 | #define CAMERA2_CLK 0x8080 /* Camera 2 Clock */ |
| 25 | #define CAM_CLK_EN (1 << 1) |
| 26 | #define MIPI_CLK (1 << 0) |
| 27 | #define HDPLL_CLK (0 << 0) |
| 28 | |
| 29 | static void pch_enable_isclk(void) |
| 30 | { |
| 31 | pcr_or32(PID_ISCLK, CAMERA1_CLK, CAM_CLK_EN | MIPI_CLK); |
| 32 | pcr_or32(PID_ISCLK, CAMERA2_CLK, CAM_CLK_EN | MIPI_CLK); |
| 33 | } |
| 34 | |
| 35 | static void pch_handle_sideband(config_t *config) |
| 36 | { |
| 37 | if (config->pch_isclk) |
| 38 | pch_enable_isclk(); |
| 39 | } |
| 40 | |
| 41 | static void pch_finalize(void) |
| 42 | { |
Michael Niewöhner | d2fadda | 2021-09-27 19:26:20 +0200 | [diff] [blame] | 43 | config_t *config = config_of_soc(); |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 44 | |
| 45 | /* TCO Lock down */ |
Subrata Banik | 7bc4dc5 | 2018-05-17 18:40:32 +0530 | [diff] [blame] | 46 | tco_lockdown(); |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 47 | |
| 48 | /* |
Subrata Banik | d19b3ca | 2019-08-01 11:00:17 +0530 | [diff] [blame] | 49 | * Set low maximum temp threshold value used for dynamic thermal sensor |
| 50 | * shutdown consideration. |
| 51 | * |
| 52 | * If Dynamic Thermal Shutdown is enabled then PMC logic shuts down the |
| 53 | * thermal sensor when CPU is in a C-state and DTS Temp <= LTT. |
| 54 | */ |
| 55 | pch_thermal_configuration(); |
| 56 | |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 57 | pch_handle_sideband(config); |
Subrata Banik | ff9104e | 2019-04-29 12:37:27 +0530 | [diff] [blame] | 58 | |
| 59 | pmc_clear_pmcon_sts(); |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static void soc_finalize(void *unused) |
| 63 | { |
| 64 | printk(BIOS_DEBUG, "Finalizing chipset.\n"); |
| 65 | |
| 66 | pch_finalize(); |
Kyösti Mälkki | b658548 | 2020-06-01 15:11:14 +0300 | [diff] [blame] | 67 | apm_control(APM_CNT_FINALIZE); |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 68 | |
| 69 | /* Indicate finalize step with post code */ |
| 70 | post_code(POST_OS_BOOT); |
| 71 | } |
| 72 | |
| 73 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL); |
| 74 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL); |