blob: 6e2406ae53e52c3348d49ffcf563c89ddef8b64d [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>
16#include <intelblocks/lpc_lib.h>
17#include <intelblocks/pcr.h>
18#include <intelblocks/pmclib.h>
Tim Wawrzynczak091dfa12021-08-24 09:32:09 -060019#include <intelblocks/systemagent.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053020#include <intelblocks/tco.h>
21#include <intelblocks/thermal.h>
Tim Wawrzynczak091dfa12021-08-24 09:32:09 -060022#include <intelpch/lockdown.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053023#include <soc/p2sb.h>
24#include <soc/pci_devs.h>
25#include <soc/pcr_ids.h>
26#include <soc/pm.h>
27#include <soc/smbus.h>
28#include <soc/soc_chip.h>
29#include <soc/systemagent.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070030#include <spi-generic.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053031
32#define CAMERA1_CLK 0x8000 /* Camera 1 Clock */
33#define CAMERA2_CLK 0x8080 /* Camera 2 Clock */
34#define CAM_CLK_EN (1 << 1)
35#define MIPI_CLK (1 << 0)
36#define HDPLL_CLK (0 << 0)
37
38static void pch_enable_isclk(void)
39{
40 pcr_or32(PID_ISCLK, CAMERA1_CLK, CAM_CLK_EN | MIPI_CLK);
41 pcr_or32(PID_ISCLK, CAMERA2_CLK, CAM_CLK_EN | MIPI_CLK);
42}
43
44static void pch_handle_sideband(config_t *config)
45{
46 if (config->pch_isclk)
47 pch_enable_isclk();
48}
49
50static void pch_finalize(void)
51{
52 config_t *config;
53
54 /* TCO Lock down */
55 tco_lockdown();
56
57 /* TODO: Add Thermal Configuration */
58
59 /*
60 * Disable ACPI PM timer based on dt policy
61 *
62 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
63 * Disabling ACPI PM timer also switches off TCO
64 */
65 config = config_of_soc();
66 if (config->PmTimerDisabled)
67 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 Banik2871e0e2020-09-27 11:30:58 +053093static void soc_finalize(void *unused)
94{
95 printk(BIOS_DEBUG, "Finalizing chipset.\n");
96
97 pch_finalize();
98 apm_control(APM_CNT_FINALIZE);
99 tbt_finalize();
Tim Wawrzynczak091dfa12021-08-24 09:32:09 -0600100 sa_finalize();
Subrata Banik2871e0e2020-09-27 11:30:58 +0530101
102 /* Indicate finalize step with post code */
103 post_code(POST_OS_BOOT);
104}
105
106BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
Subrata Banika834a6e2021-09-21 20:12:06 +0530107/*
108 * The purpose of this change is to accommodate more time to push out sending
109 * CSE EOP messages at post.
110 */
111BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, soc_finalize, NULL);