blob: eb7ac10f2eb199ef2db673df9ec1ae76e2e2bf3c [file] [log] [blame]
Angel Pons32abdd62020-04-05 15:47:03 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aamir Bohra3ee54bb2018-10-17 11:55:01 +05302
Aamir Bohra3ee54bb2018-10-17 11:55:01 +05303#include <bootstate.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -07004#include <commonlib/console/post_codes.h>
Aamir Bohra3ee54bb2018-10-17 11:55:01 +05305#include <console/console.h>
Aamir Bohra3ee54bb2018-10-17 11:55:01 +05306#include <cpu/x86/smm.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -07007#include <device/mmio.h>
Aamir Bohra3ee54bb2018-10-17 11:55:01 +05308#include <device/pci.h>
9#include <intelblocks/lpc_lib.h>
10#include <intelblocks/pcr.h>
Subrata Banik0359d9d2020-09-28 18:43:47 +053011#include <intelblocks/pmclib.h>
Subrata Banik7bc4dc52018-05-17 18:40:32 +053012#include <intelblocks/tco.h>
Subrata Banikd19b3ca2019-08-01 11:00:17 +053013#include <intelblocks/thermal.h>
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053014#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 Banikdf29d232019-07-05 16:00:38 +053019#include <soc/soc_chip.h>
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053020#include <soc/systemagent.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070021#include <spi-generic.h>
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053022
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
29static 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
35static void pch_handle_sideband(config_t *config)
36{
37 if (config->pch_isclk)
38 pch_enable_isclk();
39}
40
41static void pch_finalize(void)
42{
Michael Niewöhnerd2fadda2021-09-27 19:26:20 +020043 config_t *config = config_of_soc();
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053044
45 /* TCO Lock down */
Subrata Banik7bc4dc52018-05-17 18:40:32 +053046 tco_lockdown();
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053047
48 /*
Subrata Banikd19b3ca2019-08-01 11:00:17 +053049 * 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 Bohra3ee54bb2018-10-17 11:55:01 +053057 pch_handle_sideband(config);
Subrata Banikff9104e2019-04-29 12:37:27 +053058
59 pmc_clear_pmcon_sts();
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053060}
61
62static void soc_finalize(void *unused)
63{
64 printk(BIOS_DEBUG, "Finalizing chipset.\n");
65
66 pch_finalize();
Kyösti Mälkkib6585482020-06-01 15:11:14 +030067 apm_control(APM_CNT_FINALIZE);
Aamir Bohra3ee54bb2018-10-17 11:55:01 +053068
69 /* Indicate finalize step with post code */
70 post_code(POST_OS_BOOT);
71}
72
73BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
74BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);