blob: 4ef572b5f690ad0d6685c3780caa88029bde8925 [file] [log] [blame]
Subrata Banik2871e0e2020-09-27 11:30:58 +05301/* SPDX-License-Identifier: GPL-2.0-only */
2
3/*
4 * This file is created based on Intel Alder Lake Processor PCH Datasheet
5 * Document number: 621483
6 * Chapter number: 4, 29
7 */
8
9#include <arch/io.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053010#include <bootstate.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070011#include <commonlib/console/post_codes.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053012#include <console/console.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053013#include <cpu/x86/smm.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070014#include <device/mmio.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053015#include <device/pci.h>
Subrata Banik78e66ad2021-09-30 20:32:50 +053016#include <intelblocks/cse.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053017#include <intelblocks/lpc_lib.h>
18#include <intelblocks/pcr.h>
19#include <intelblocks/pmclib.h>
Tim Wawrzynczak091dfa12021-08-24 09:32:09 -060020#include <intelblocks/systemagent.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053021#include <intelblocks/tco.h>
22#include <intelblocks/thermal.h>
Tim Wawrzynczak091dfa12021-08-24 09:32:09 -060023#include <intelpch/lockdown.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053024#include <soc/p2sb.h>
25#include <soc/pci_devs.h>
26#include <soc/pcr_ids.h>
27#include <soc/pm.h>
28#include <soc/smbus.h>
29#include <soc/soc_chip.h>
30#include <soc/systemagent.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070031#include <spi-generic.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053032
33#define CAMERA1_CLK 0x8000 /* Camera 1 Clock */
34#define CAMERA2_CLK 0x8080 /* Camera 2 Clock */
35#define CAM_CLK_EN (1 << 1)
36#define MIPI_CLK (1 << 0)
37#define HDPLL_CLK (0 << 0)
38
39static void pch_enable_isclk(void)
40{
41 pcr_or32(PID_ISCLK, CAMERA1_CLK, CAM_CLK_EN | MIPI_CLK);
42 pcr_or32(PID_ISCLK, CAMERA2_CLK, CAM_CLK_EN | MIPI_CLK);
43}
44
45static void pch_handle_sideband(config_t *config)
46{
47 if (config->pch_isclk)
48 pch_enable_isclk();
49}
50
51static void pch_finalize(void)
52{
Michael Niewöhnerd2fadda2021-09-27 19:26:20 +020053 config_t *config = config_of_soc();
Subrata Banik2871e0e2020-09-27 11:30:58 +053054
55 /* TCO Lock down */
56 tco_lockdown();
57
58 /* TODO: Add Thermal Configuration */
59
60 /*
Michael Niewöhnerd2fadda2021-09-27 19:26:20 +020061 * Disable ACPI PM timer based on Kconfig
Subrata Banik2871e0e2020-09-27 11:30:58 +053062 *
63 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
64 * Disabling ACPI PM timer also switches off TCO
65 */
Michael Niewöhnerd2fadda2021-09-27 19:26:20 +020066 if (!CONFIG(USE_PM_ACPI_TIMER))
Subrata Banik2871e0e2020-09-27 11:30:58 +053067 pmc_disable_acpi_timer();
68
Subrata Banik2871e0e2020-09-27 11:30:58 +053069 pch_handle_sideband(config);
70
71 pmc_clear_pmcon_sts();
72}
73
74static void tbt_finalize(void)
75{
76 int i;
77 const struct device *dev;
78
79 /* Disable Thunderbolt PCIe root ports bus master */
80 for (i = 0; i < NUM_TBT_FUNCTIONS; i++) {
81 dev = pcidev_path_on_root(SA_DEVFN_TBT(i));
82 if (dev)
83 pci_dev_disable_bus_master(dev);
84 }
85}
86
Tim Wawrzynczak091dfa12021-08-24 09:32:09 -060087static void sa_finalize(void)
88{
89 if (get_lockdown_config() == CHIPSET_LOCKDOWN_COREBOOT)
90 sa_lock_pam();
91}
92
Subrata Banik78e66ad2021-09-30 20:32:50 +053093static void heci_finalize(void)
94{
95 unsigned int cse_dev[] = {
96 PCH_DEVFN_CSE,
97 PCH_DEVFN_CSE_2,
98 PCH_DEVFN_CSE_3,
99 PCH_DEVFN_CSE_4
100 };
101
102 for (int i = 0; i < ARRAY_SIZE(cse_dev); i++) {
103 if (!is_cse_devfn_visible(cse_dev[i]))
104 continue;
105
106 set_cse_device_state(cse_dev[i], DEV_IDLE);
107 }
108}
109
Subrata Banik2871e0e2020-09-27 11:30:58 +0530110static void soc_finalize(void *unused)
111{
112 printk(BIOS_DEBUG, "Finalizing chipset.\n");
113
114 pch_finalize();
115 apm_control(APM_CNT_FINALIZE);
116 tbt_finalize();
Tim Wawrzynczak091dfa12021-08-24 09:32:09 -0600117 sa_finalize();
Subrata Banik78e66ad2021-09-30 20:32:50 +0530118 heci_finalize();
Subrata Banik2871e0e2020-09-27 11:30:58 +0530119
120 /* Indicate finalize step with post code */
121 post_code(POST_OS_BOOT);
122}
123
124BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
Subrata Banika834a6e2021-09-21 20:12:06 +0530125/*
126 * The purpose of this change is to accommodate more time to push out sending
127 * CSE EOP messages at post.
128 */
129BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, soc_finalize, NULL);