blob: 8219f0c1d5e314072b2be6c5fe0c941e7007e5e9 [file] [log] [blame]
Angel Ponsfabfe9d2020-04-05 15:47:07 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aamir Bohradd7acaa2020-03-25 11:36:22 +05302
Aamir Bohradd7acaa2020-03-25 11:36:22 +05303#include <device/mmio.h>
4#include <bootstate.h>
5#include <console/console.h>
6#include <console/post_codes.h>
7#include <cpu/x86/smm.h>
8#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>
Aamir Bohradd7acaa2020-03-25 11:36:22 +053012#include <intelblocks/tco.h>
13#include <intelblocks/thermal.h>
Aamir Bohradd7acaa2020-03-25 11:36:22 +053014#include <spi-generic.h>
15#include <soc/p2sb.h>
16#include <soc/pci_devs.h>
17#include <soc/pcr_ids.h>
18#include <soc/pm.h>
19#include <soc/smbus.h>
20#include <soc/soc_chip.h>
21#include <soc/systemagent.h>
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
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{
Krishna Prasad Bhat830306c2020-12-30 14:01:40 +053043 uint32_t reg32;
44 uint8_t *pmcbase;
Aamir Bohradd7acaa2020-03-25 11:36:22 +053045 config_t *config;
Aamir Bohradd7acaa2020-03-25 11:36:22 +053046
47 /* TCO Lock down */
48 tco_lockdown();
49
50 /* TODO: Add Thermal Configuration */
51
52 /*
53 * Disable ACPI PM timer based on dt policy
54 *
55 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
56 * Disabling ACPI PM timer also switches off TCO
57 *
58 * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is
59 * just required to get to chip config. PCH_DEV_PMC is hidden by this
60 * point and hence removed from the root bus. pcidev_path_on_root thus
61 * returns NULL for PCH_DEV_PMC device.
62 */
63 config = config_of_soc();
Subrata Banik0359d9d2020-09-28 18:43:47 +053064 if (config->PmTimerDisabled)
65 pmc_disable_acpi_timer();
Aamir Bohradd7acaa2020-03-25 11:36:22 +053066
Krishna Prasad Bhat830306c2020-12-30 14:01:40 +053067 pmcbase = pmc_mmio_regs();
68 if (config->s0ix_enable) {
69 /*
70 * Enable USBSUSPGQDIS qualification to ensure USB2 PHY SUS is power gated
71 * before entering s0ix.
72 */
73 reg32 = read32(pmcbase + CPPMVRIC3);
74 reg32 &= ~USBSUSPGQDIS;
75 write32(pmcbase + CPPMVRIC3, reg32);
76 }
77
Aamir Bohradd7acaa2020-03-25 11:36:22 +053078 pch_handle_sideband(config);
79
80 pmc_clear_pmcon_sts();
81}
82
83static void soc_finalize(void *unused)
84{
85 printk(BIOS_DEBUG, "Finalizing chipset.\n");
86
87 pch_finalize();
Kyösti Mälkkib6585482020-06-01 15:11:14 +030088 apm_control(APM_CNT_FINALIZE);
Aamir Bohradd7acaa2020-03-25 11:36:22 +053089
90 /* Indicate finalize step with post code */
91 post_code(POST_OS_BOOT);
92}
93
94BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
95BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);