blob: 08a6babcfb9a5c19bc67b9e40a7f27e8f4c6f17f [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>
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{
43 uint32_t reg32;
44 uint8_t *pmcbase;
45 config_t *config;
46 uint8_t reg8;
47
48 /* TCO Lock down */
49 tco_lockdown();
50
51 /* TODO: Add Thermal Configuration */
52
53 /*
54 * Disable ACPI PM timer based on dt policy
55 *
56 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
57 * Disabling ACPI PM timer also switches off TCO
58 *
59 * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is
60 * just required to get to chip config. PCH_DEV_PMC is hidden by this
61 * point and hence removed from the root bus. pcidev_path_on_root thus
62 * returns NULL for PCH_DEV_PMC device.
63 */
64 config = config_of_soc();
65 pmcbase = pmc_mmio_regs();
66 if (config->PmTimerDisabled) {
67 reg8 = read8(pmcbase + PCH_PWRM_ACPI_TMR_CTL);
68 reg8 |= (1 << 1);
69 write8(pmcbase + PCH_PWRM_ACPI_TMR_CTL, reg8);
70 }
71
72 /* Disable XTAL shutdown qualification for low power idle. */
73 if (config->s0ix_enable) {
74 reg32 = read32(pmcbase + CPPMVRIC);
75 reg32 |= XTALSDQDIS;
76 write32(pmcbase + CPPMVRIC, reg32);
77 }
78
79 pch_handle_sideband(config);
80
81 pmc_clear_pmcon_sts();
82}
83
84static void soc_finalize(void *unused)
85{
86 printk(BIOS_DEBUG, "Finalizing chipset.\n");
87
88 pch_finalize();
Kyösti Mälkkib6585482020-06-01 15:11:14 +030089 apm_control(APM_CNT_FINALIZE);
Aamir Bohradd7acaa2020-03-25 11:36:22 +053090
91 /* Indicate finalize step with post code */
92 post_code(POST_OS_BOOT);
93}
94
95BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
96BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);