Debian Codegraph @

src/soc/intel/xeon_sp/lbg/soc_pch.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <device/pci_ops.h>
4 #include <intelblocks/pcr.h>
5 #include <intelblocks/pmclib.h>
6 #include <intelblocks/rtc.h>
7 #include <intelblocks/p2sb.h>
8 #include <soc/azalia_device.h>
9 #include <soc/bootblock.h>
10 #include <soc/soc_pch.h>
11 #include <soc/pch_pci_devs.h>
12 #include <soc/pci_devs.h>
13 #include <soc/pcr_ids.h>
14 #include <soc/pmc.h>
15 #include <console/console.h>
16
17 #define PCR_DMI_ACPIBA 0x27B4
18 #define PCR_DMI_ACPIBDID 0x27B8
19 #define PCR_DMI_DMICTL 0x2234
20 #define PCR_DMI_DMICTL_SRLOCK (1 << 31)
21 #define PCR_DMI_PMBASEA 0x27AC
22 #define PCR_DMI_PMBASEC 0x27B0
23
24 static void soc_config_acpibase(void)
25 {
26 uint32_t reg32;
27
28 /* Disable ABASE in PMC Device first before changing Base Address */
29 reg32 = pci_read_config32(PCH_DEV_PMC, ACTL);
30 pci_write_config32(PCH_DEV_PMC, ACTL, reg32 & ~ACPI_EN);
31
32 /* Program ACPI Base */
33 pci_write_config32(PCH_DEV_PMC, ABASE, ACPI_BASE_ADDRESS);
34
35 /* Enable ACPI in PMC */
36 pci_write_config32(PCH_DEV_PMC, ACTL, reg32 | ACPI_EN);
37
38 uint32_t data = pci_read_config32(PCH_DEV_PMC, ABASE);
39 printk(BIOS_INFO, "%s : pmbase = %x\n", __func__, (int)data);
40 /*
41 * Program "ACPI Base Address" PCR[DMI] + 27B4h[23:18, 15:2, 0]
42 * to [0x3F, PMC PCI Offset 40h bit[15:2], 1]
43 */
44 reg32 = (0x3f << 18) | ACPI_BASE_ADDRESS | 1;
45 pcr_write32(PID_DMI, PCR_DMI_ACPIBA, reg32);
46 pcr_write32(PID_DMI, PCR_DMI_ACPIBDID, 0x23a8);
47 }
48
49 void bootblock_pch_init(void)
50 {
51 /*
52 * Enabling ABASE for accessing PM1_STS, PM1_EN, PM1_CNT
53 */
54 soc_config_acpibase();
55 }
56
57 void pch_lock_dmictl(void)
58 {
59 uint32_t reg32 = pcr_read32(PID_DMI, PCR_DMI_DMICTL);
60 pcr_write32(PID_DMI, PCR_DMI_DMICTL, reg32 | PCR_DMI_DMICTL_SRLOCK);
61 }
62
63 #define PCR_PSFX_T0_SHDW_PCIEN 0x1C
64 #define PCR_PSFX_T0_SHDW_PCIEN_FUNDIS (1 << 8)
65 #define PSF3_HDA_BASE_ADDRESS 0x1800
66
67 static void pch_disable_hda(void)
68 {
69 /* Ensure memory, io, and bus master are all disabled */
70 pci_and_config16(PCH_DEV_HDA, PCI_COMMAND, ~(PCI_COMMAND_MASTER |
71 PCI_COMMAND_MEMORY | PCI_COMMAND_IO));
72 /* Put controller to D3 */
73 pci_or_config32(PCH_DEV_HDA, HDA_PCS, HDA_PCS_PS_D3HOT);
74 /* Lock and disable everything */
75 pci_write_config8(PCH_DEV_HDA, HDA_FNCFG, 0x15);
76
77 /* Disable DSP in PMC */
78 pmc_or_mmio32(NST_PG_FDIS1, NST_FDIS_DSP);
79 /* Hide PCI function */
80 pcr_or32(PID_PSF3, PSF3_HDA_BASE_ADDRESS + PCR_PSFX_T0_SHDW_PCIEN,
81 PCR_PSFX_T0_SHDW_PCIEN_FUNDIS);
82
83 printk(BIOS_INFO, "%s: Disabled HDA device 00:1f.3\n", __func__);
84 }
85
86 void early_pch_init(void)
87 {
88 /* FSP has no UPD to disable HDA, so do it manually here... */
89 if (!is_devfn_enabled(PCH_DEVFN_HDA))
90 pch_disable_hda();
91 }