soc/mediatek/mt8196: Initialize SSPM
[coreboot2.git] / src / soc / intel / tigerlake / bootblock / pch.c
blob084bd7fc6e5f95f837094eb78e707744f6af1b61
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 /*
4 * This file is created based on Intel Tiger Lake Processor PCH Datasheet
5 * Document number: 575857
6 * Chapter number: 2, 3, 4, 27, 28
7 */
9 #include <commonlib/console/post_codes.h>
10 #include <console/console.h>
11 #include <device/device.h>
12 #include <device/mmio.h>
13 #include <device/pci_ops.h>
14 #include <intelblocks/fast_spi.h>
15 #include <intelblocks/gspi.h>
16 #include <intelblocks/lpc_lib.h>
17 #include <intelblocks/p2sb.h>
18 #include <intelblocks/pcr.h>
19 #include <intelblocks/pmclib.h>
20 #include <intelblocks/rtc.h>
21 #include <intelpch/espi.h>
22 #include <soc/bootblock.h>
23 #include <soc/soc_chip.h>
24 #include <soc/iomap.h>
25 #include <soc/p2sb.h>
26 #include <soc/pch.h>
27 #include <soc/pci_devs.h>
28 #include <soc/pcr_ids.h>
29 #include <soc/pm.h>
30 #include <static.h>
32 #if CONFIG(SOC_INTEL_TIGERLAKE_PCH_H)
33 #define PCR_PSF3_TO_SHDW_PMC_REG_BASE 0x1000
34 #else
35 #define PCR_PSF3_TO_SHDW_PMC_REG_BASE 0x1100
36 #endif
37 #define PCR_PSFX_TO_SHDW_BAR0 0
38 #define PCR_PSFX_TO_SHDW_BAR1 0x4
39 #define PCR_PSFX_TO_SHDW_BAR2 0x8
40 #define PCR_PSFX_TO_SHDW_BAR3 0xC
41 #define PCR_PSFX_TO_SHDW_BAR4 0x10
42 #define PCR_PSFX_TO_SHDW_PCIEN_IOEN 0x01
43 #define PCR_PSFX_T0_SHDW_PCIEN 0x1C
45 static void soc_config_pwrmbase(void)
48 * Assign Resources to PWRMBASE
49 * Clear BIT 1-2 Command Register
51 pci_and_config16(PCH_DEV_PMC, PCI_COMMAND, ~(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER));
53 /* Program PWRM Base */
54 pci_write_config32(PCH_DEV_PMC, PWRMBASE, PCH_PWRM_BASE_ADDRESS);
56 /* Enable Bus Master and MMIO Space */
57 pci_or_config16(PCH_DEV_PMC, PCI_COMMAND, (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER));
59 /* Enable PWRM in PMC */
60 setbits32((void *)PCH_PWRM_BASE_ADDRESS + ACTL, PWRM_EN);
63 void bootblock_pch_early_init(void)
66 * Perform P2SB configuration before any another controller initialization as the
67 * controller might want to perform PCR settings.
69 p2sb_enable_bar();
70 p2sb_configure_hpet();
72 fast_spi_early_init(SPI_BASE_ADDRESS);
73 gspi_early_bar_init();
76 * Enabling PWRM Base for accessing
77 * Global Reset Cause Register.
79 soc_config_pwrmbase();
82 static void soc_config_acpibase(void)
84 uint32_t pmc_reg_value;
85 uint32_t pmc_base_reg = PCR_PSF3_TO_SHDW_PMC_REG_BASE;
87 pmc_reg_value = pcr_read32(PID_PSF3, pmc_base_reg + PCR_PSFX_TO_SHDW_BAR4);
89 if (pmc_reg_value != 0xffffffff) {
90 /* Disable Io Space before changing the address */
91 pcr_rmw32(PID_PSF3, pmc_base_reg + PCR_PSFX_T0_SHDW_PCIEN,
92 ~PCR_PSFX_TO_SHDW_PCIEN_IOEN, 0);
93 /* Program ABASE in PSF3 PMC space BAR4*/
94 pcr_write32(PID_PSF3, pmc_base_reg + PCR_PSFX_TO_SHDW_BAR4,
95 ACPI_BASE_ADDRESS);
96 /* Enable IO Space */
97 pcr_rmw32(PID_PSF3, pmc_base_reg + PCR_PSFX_T0_SHDW_PCIEN,
98 ~0, PCR_PSFX_TO_SHDW_PCIEN_IOEN);
102 void pch_early_iorange_init(void)
104 uint16_t io_enables = LPC_IOE_SUPERIO_2E_2F | LPC_IOE_KBC_60_64 |
105 LPC_IOE_EC_62_66 | LPC_IOE_LGE_200;
107 const uint16_t lpc_ioe_enable_mask = LPC_IOE_COMA_EN | LPC_IOE_COMB_EN |
108 LPC_IOE_LPT_EN | LPC_IOE_FDD_EN |
109 LPC_IOE_LGE_200 | LPC_IOE_HGE_208 |
110 LPC_IOE_KBC_60_64 | LPC_IOE_EC_62_66 |
111 LPC_IOE_SUPERIO_2E_2F | LPC_IOE_EC_4E_4F;
113 const config_t *config = config_of_soc();
115 if (config->lpc_ioe) {
116 io_enables = config->lpc_ioe & lpc_ioe_enable_mask;
117 } else {
118 /* IO Decode Range */
119 if (CONFIG(DRIVERS_UART_8250IO))
120 lpc_io_setup_comm_a_b();
123 /* IO Decode Enable */
124 lpc_enable_fixed_io_ranges(io_enables);
126 /* Program generic IO Decode Range */
127 pch_enable_lpc();
130 void bootblock_pch_init(void)
133 * Enabling ABASE for accessing PM1_STS, PM1_EN, PM1_CNT,
134 * GPE0_STS, GPE0_EN registers.
136 soc_config_acpibase();
138 /* Set up GPE configuration */
139 pmc_gpe_init();
141 enable_rtc_upper_bank();