blob: b636ccbec0251d96416cfad52e14eb138d774fea [file] [log] [blame]
Subrata Banik91e89c52019-11-01 18:30:01 +05301/*
2 * This file is part of the coreboot project.
3 *
Subrata Banik91e89c52019-11-01 18:30:01 +05304 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15/*
16 * This file is created based on Intel Tiger Lake Processor PCH Datasheet
17 * Document number: 575857
18 * Chapter number: 4, 29
19 */
20
21#include <arch/io.h>
22#include <device/mmio.h>
23#include <bootstate.h>
24#include <console/console.h>
25#include <console/post_codes.h>
26#include <cpu/x86/smm.h>
27#include <device/pci.h>
28#include <intelblocks/lpc_lib.h>
29#include <intelblocks/pcr.h>
30#include <intelblocks/tco.h>
31#include <intelblocks/thermal.h>
32#include <reg_script.h>
33#include <spi-generic.h>
34#include <soc/p2sb.h>
35#include <soc/pci_devs.h>
36#include <soc/pcr_ids.h>
37#include <soc/pm.h>
38#include <soc/smbus.h>
39#include <soc/soc_chip.h>
40#include <soc/systemagent.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053041
42#define CAMERA1_CLK 0x8000 /* Camera 1 Clock */
43#define CAMERA2_CLK 0x8080 /* Camera 2 Clock */
44#define CAM_CLK_EN (1 << 1)
45#define MIPI_CLK (1 << 0)
46#define HDPLL_CLK (0 << 0)
47
48static void pch_enable_isclk(void)
49{
50 pcr_or32(PID_ISCLK, CAMERA1_CLK, CAM_CLK_EN | MIPI_CLK);
51 pcr_or32(PID_ISCLK, CAMERA2_CLK, CAM_CLK_EN | MIPI_CLK);
52}
53
54static void pch_handle_sideband(config_t *config)
55{
56 if (config->pch_isclk)
57 pch_enable_isclk();
58}
59
60static void pch_finalize(void)
61{
62 uint32_t reg32;
63 uint8_t *pmcbase;
64 config_t *config;
65 uint8_t reg8;
66
67 /* TCO Lock down */
68 tco_lockdown();
69
Subrata Banik2fff3912020-01-16 10:13:28 +053070 /* TODO: Add Thermal Configuration */
Subrata Banik91e89c52019-11-01 18:30:01 +053071
72 /*
73 * Disable ACPI PM timer based on dt policy
74 *
75 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
76 * Disabling ACPI PM timer also switches off TCO
77 *
78 * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is
79 * just required to get to chip config. PCH_DEV_PMC is hidden by this
80 * point and hence removed from the root bus. pcidev_path_on_root thus
81 * returns NULL for PCH_DEV_PMC device.
82 */
83 config = config_of_soc();
84 pmcbase = pmc_mmio_regs();
85 if (config->PmTimerDisabled) {
86 reg8 = read8(pmcbase + PCH_PWRM_ACPI_TMR_CTL);
87 reg8 |= (1 << 1);
88 write8(pmcbase + PCH_PWRM_ACPI_TMR_CTL, reg8);
89 }
90
91 /* Disable XTAL shutdown qualification for low power idle. */
92 if (config->s0ix_enable) {
93 reg32 = read32(pmcbase + CPPMVRIC);
94 reg32 |= XTALSDQDIS;
95 write32(pmcbase + CPPMVRIC, reg32);
96 }
97
98 pch_handle_sideband(config);
99
100 pmc_clear_pmcon_sts();
101}
102
103static void soc_finalize(void *unused)
104{
105 printk(BIOS_DEBUG, "Finalizing chipset.\n");
106
107 pch_finalize();
108
109 printk(BIOS_DEBUG, "Finalizing SMM.\n");
110 outb(APM_CNT_FINALIZE, APM_CNT);
111
112 /* Indicate finalize step with post code */
113 post_code(POST_OS_BOOT);
114}
115
116BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
117BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);