blob: ba7fc69b5521acdeeeca4cbcf8b9df6a8cda095f [file] [log] [blame]
Angel Ponsf5627e82020-04-05 15:46:52 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lijian Zhao6cf501c2017-10-10 18:26:18 -07002
Lijian Zhao6cf501c2017-10-10 18:26:18 -07003#include <bootstate.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -07004#include <commonlib/console/post_codes.h>
Lijian Zhao6cf501c2017-10-10 18:26:18 -07005#include <console/console.h>
Lijian Zhao6cf501c2017-10-10 18:26:18 -07006#include <cpu/x86/smm.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -07007#include <device/mmio.h>
Lijian Zhao6cf501c2017-10-10 18:26:18 -07008#include <device/pci.h>
Michael Niewöhner305b6482019-09-22 21:56:17 +02009#include <intelblocks/cpulib.h>
Matt DeVillier575a2e52022-02-10 17:01:35 -060010#include <intelblocks/cse.h>
Lijian Zhao6cf501c2017-10-10 18:26:18 -070011#include <intelblocks/lpc_lib.h>
12#include <intelblocks/pcr.h>
Subrata Banik0359d9d2020-09-28 18:43:47 +053013#include <intelblocks/pmclib.h>
Tim Wawrzynczak9f0266c2021-08-26 09:17:53 -060014#include <intelblocks/systemagent.h>
Subrata Banik7bc4dc52018-05-17 18:40:32 +053015#include <intelblocks/tco.h>
Sumeet Pawnikar810527a2019-07-23 22:02:16 +053016#include <intelblocks/thermal.h>
Lijian Zhao6cf501c2017-10-10 18:26:18 -070017#include <soc/p2sb.h>
18#include <soc/pci_devs.h>
19#include <soc/pcr_ids.h>
20#include <soc/pm.h>
21#include <soc/smbus.h>
22#include <soc/systemagent.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070023#include <spi-generic.h>
Lijian Zhao6cf501c2017-10-10 18:26:18 -070024
Elyes HAOUASc3385072019-03-21 15:38:06 +010025#include "chip.h"
26
Lijian Zhao1b64ae12018-01-22 20:08:15 -080027#define CAMERA1_CLK 0x8000 /* Camera 1 Clock */
28#define CAMERA2_CLK 0x8080 /* Camera 2 Clock */
29#define CAM_CLK_EN (1 << 1)
30#define MIPI_CLK (1 << 0)
31#define HDPLL_CLK (0 << 0)
32
Lijian Zhao1b64ae12018-01-22 20:08:15 -080033static void pch_enable_isclk(void)
34{
35 pcr_or32(PID_ISCLK, CAMERA1_CLK, CAM_CLK_EN | MIPI_CLK);
36 pcr_or32(PID_ISCLK, CAMERA2_CLK, CAM_CLK_EN | MIPI_CLK);
37}
38
39static void pch_handle_sideband(config_t *config)
40{
Lijian Zhao1b64ae12018-01-22 20:08:15 -080041 if (config->pch_isclk)
42 pch_enable_isclk();
Lijian Zhao6cf501c2017-10-10 18:26:18 -070043}
44
45static void pch_finalize(void)
46{
Lijian Zhao6cf501c2017-10-10 18:26:18 -070047 uint32_t reg32;
Lijian Zhao6cf501c2017-10-10 18:26:18 -070048 uint8_t *pmcbase;
49 config_t *config;
Lijian Zhao6cf501c2017-10-10 18:26:18 -070050
Subrata Banik7bc4dc52018-05-17 18:40:32 +053051 tco_lockdown();
Sumeet Pawnikar810527a2019-07-23 22:02:16 +053052
53 /*
54 * Set low maximum temp threshold value used for dynamic thermal sensor
55 * shutdown consideration.
56 *
57 * If Dynamic Thermal Shutdown is enabled then PMC logic shuts down the
58 * thermal sensor when CPU is in a C-state and DTS Temp <= LTT.
59 */
60 pch_thermal_configuration();
61
Kyösti Mälkkid5f645c2019-09-28 00:20:27 +030062 config = config_of_soc();
Lijian Zhao6cf501c2017-10-10 18:26:18 -070063 pmcbase = pmc_mmio_regs();
Lijian Zhao6cf501c2017-10-10 18:26:18 -070064
Michael Niewöhner4e8baf92020-10-04 14:34:41 +020065 if (config->s0ix_enable && config->cppmvric2_adsposcdis) {
66 /* Enable Audio DSP OSC qualification for S0ix */
67 reg32 = read32(pmcbase + CPPMVRIC2);
68 reg32 &= ~ADSPOSCDIS;
69 write32(pmcbase + CPPMVRIC2, reg32);
Lijian Zhao6cf501c2017-10-10 18:26:18 -070070 }
71
Lijian Zhao1b64ae12018-01-22 20:08:15 -080072 pch_handle_sideband(config);
Krishna Prasad Bhat2de19032019-03-14 23:23:22 +053073
74 pmc_clear_pmcon_sts();
Michael Niewöhner305b6482019-09-22 21:56:17 +020075
76 /*
77 * Lock chipset memory registers to protect SMM.
78 * When SkipMpInit=0, this is done by FSP.
79 */
80 if (!CONFIG(USE_INTEL_FSP_MP_INIT))
81 cpu_lt_lock_memory();
82
Lijian Zhao6cf501c2017-10-10 18:26:18 -070083}
84
85static void soc_finalize(void *unused)
86{
87 printk(BIOS_DEBUG, "Finalizing chipset.\n");
88
Lijian Zhao6cf501c2017-10-10 18:26:18 -070089 pch_finalize();
Kyösti Mälkkib6585482020-06-01 15:11:14 +030090 apm_control(APM_CNT_FINALIZE);
Matt DeVillier575a2e52022-02-10 17:01:35 -060091 if (CONFIG(DISABLE_HECI1_AT_PRE_BOOT) &&
92 CONFIG(SOC_INTEL_COMMON_BLOCK_HECI1_DISABLE_USING_PMC_IPC))
93 heci1_disable();
Lijian Zhao6cf501c2017-10-10 18:26:18 -070094
95 /* Indicate finalize step with post code */
lilacious40cb3fe2023-06-21 23:24:14 +020096 post_code(POSTCODE_OS_BOOT);
Lijian Zhao6cf501c2017-10-10 18:26:18 -070097}
98
99BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
100BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);