blob: 1badad3425f8b8abf327890734f5e25ac106004d [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>
Subrata Banik0359d9d2020-09-28 18:43:47 +053012#include <intelblocks/pmclib.h>
Aamir Bohradd7acaa2020-03-25 11:36:22 +053013#include <intelblocks/tco.h>
14#include <intelblocks/thermal.h>
Aamir Bohradd7acaa2020-03-25 11:36:22 +053015#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{
Aamir Bohradd7acaa2020-03-25 11:36:22 +053044 config_t *config;
Aamir Bohradd7acaa2020-03-25 11:36:22 +053045
46 /* TCO Lock down */
47 tco_lockdown();
48
49 /* TODO: Add Thermal Configuration */
50
51 /*
52 * Disable ACPI PM timer based on dt policy
53 *
54 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
55 * Disabling ACPI PM timer also switches off TCO
56 *
57 * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is
58 * just required to get to chip config. PCH_DEV_PMC is hidden by this
59 * point and hence removed from the root bus. pcidev_path_on_root thus
60 * returns NULL for PCH_DEV_PMC device.
61 */
62 config = config_of_soc();
Subrata Banik0359d9d2020-09-28 18:43:47 +053063 if (config->PmTimerDisabled)
64 pmc_disable_acpi_timer();
Aamir Bohradd7acaa2020-03-25 11:36:22 +053065
66 /* Disable XTAL shutdown qualification for low power idle. */
Subrata Banik0359d9d2020-09-28 18:43:47 +053067 if (config->s0ix_enable)
68 pmc_ignore_xtal_shutdown();
Aamir Bohradd7acaa2020-03-25 11:36:22 +053069
70 pch_handle_sideband(config);
71
72 pmc_clear_pmcon_sts();
73}
74
75static void soc_finalize(void *unused)
76{
77 printk(BIOS_DEBUG, "Finalizing chipset.\n");
78
79 pch_finalize();
Kyösti Mälkkib6585482020-06-01 15:11:14 +030080 apm_control(APM_CNT_FINALIZE);
Aamir Bohradd7acaa2020-03-25 11:36:22 +053081
82 /* Indicate finalize step with post code */
83 post_code(POST_OS_BOOT);
84}
85
86BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
87BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);