blob: f801960a1263e15f42fb1c2e5b31cadb72722839 [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 <arch/io.h>
4#include <device/mmio.h>
5#include <bootstate.h>
6#include <console/console.h>
7#include <console/post_codes.h>
8#include <cpu/x86/smm.h>
9#include <device/pci.h>
10#include <intelblocks/lpc_lib.h>
11#include <intelblocks/pcr.h>
12#include <intelblocks/tco.h>
13#include <intelblocks/thermal.h>
14#include <reg_script.h>
15#include <spi-generic.h>
16#include <soc/p2sb.h>
17#include <soc/pci_devs.h>
18#include <soc/pcr_ids.h>
19#include <soc/pm.h>
20#include <soc/smbus.h>
21#include <soc/soc_chip.h>
22#include <soc/systemagent.h>
23
24#define CAMERA1_CLK 0x8000 /* Camera 1 Clock */
25#define CAMERA2_CLK 0x8080 /* Camera 2 Clock */
26#define CAM_CLK_EN (1 << 1)
27#define MIPI_CLK (1 << 0)
28#define HDPLL_CLK (0 << 0)
29
30static void pch_enable_isclk(void)
31{
32 pcr_or32(PID_ISCLK, CAMERA1_CLK, CAM_CLK_EN | MIPI_CLK);
33 pcr_or32(PID_ISCLK, CAMERA2_CLK, CAM_CLK_EN | MIPI_CLK);
34}
35
36static void pch_handle_sideband(config_t *config)
37{
38 if (config->pch_isclk)
39 pch_enable_isclk();
40}
41
42static void pch_finalize(void)
43{
44 uint32_t reg32;
45 uint8_t *pmcbase;
46 config_t *config;
47 uint8_t reg8;
48
49 /* TCO Lock down */
50 tco_lockdown();
51
52 /* TODO: Add Thermal Configuration */
53
54 /*
55 * Disable ACPI PM timer based on dt policy
56 *
57 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
58 * Disabling ACPI PM timer also switches off TCO
59 *
60 * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is
61 * just required to get to chip config. PCH_DEV_PMC is hidden by this
62 * point and hence removed from the root bus. pcidev_path_on_root thus
63 * returns NULL for PCH_DEV_PMC device.
64 */
65 config = config_of_soc();
66 pmcbase = pmc_mmio_regs();
67 if (config->PmTimerDisabled) {
68 reg8 = read8(pmcbase + PCH_PWRM_ACPI_TMR_CTL);
69 reg8 |= (1 << 1);
70 write8(pmcbase + PCH_PWRM_ACPI_TMR_CTL, reg8);
71 }
72
73 /* Disable XTAL shutdown qualification for low power idle. */
74 if (config->s0ix_enable) {
75 reg32 = read32(pmcbase + CPPMVRIC);
76 reg32 |= XTALSDQDIS;
77 write32(pmcbase + CPPMVRIC, reg32);
78 }
79
80 pch_handle_sideband(config);
81
82 pmc_clear_pmcon_sts();
83}
84
85static void soc_finalize(void *unused)
86{
87 printk(BIOS_DEBUG, "Finalizing chipset.\n");
88
89 pch_finalize();
90
91 printk(BIOS_DEBUG, "Finalizing SMM.\n");
92 outb(APM_CNT_FINALIZE, APM_CNT);
93
94 /* Indicate finalize step with post code */
95 post_code(POST_OS_BOOT);
96}
97
98BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
99BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);