Debian Codegraph @

src/soc/intel/xeon_sp/sad.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 #include <device/pci.h>
4 #include <device/pci_ids.h>
5 #include <intelblocks/cfg.h>
6 #include <intelpch/lockdown.h>
7 #include <soc/pci_devs.h>
8
9 /*
10 * Driver for SAD device (SKX and CPX only), now called CHA dev.
11 * SKX/CPX [B(31), D:29, F:0/F:1]
12 * SPR/GNR [B(31), D:29, F:0/F:1]
13 */
14
15 static void sad_enable_resources(struct device *dev)
16 {
17 pci_dev_enable_resources(dev);
18
19 if (!CONFIG(SOC_INTEL_SKYLAKE_SP) && !CONFIG(SOC_INTEL_COOPERLAKE_SP))
20 return;
21
22 /*
23 * Enables the C-F segment as DRAM. Only necessary on SKX and CPX, that do
24 * not unconditionally enable those segments in FSP.
25 * The assumption here is that FSP-S does not need to access the C-F segment,
26 * and nothing in coreboot should access those segments before writing tables.
27 */
28
29 uint32_t pam0123_unlock_dram = 0x33333330;
30 uint32_t pam456_unlock_dram = 0x00333333;
31
32 pci_write_config32(dev, SAD_ALL_PAM0123_CSR, pam0123_unlock_dram);
33 pci_write_config32(dev, SAD_ALL_PAM456_CSR, pam456_unlock_dram);
34
35 uint32_t reg1 = pci_read_config32(dev, SAD_ALL_PAM0123_CSR);
36 uint32_t reg2 = pci_read_config32(dev, SAD_ALL_PAM456_CSR);
37 printk(BIOS_DEBUG, "%s:%s pam0123_csr: 0x%x, pam456_csr: 0x%x\n",
38 __FILE__, __func__, reg1, reg2);
39 }
40
41 static void sad_final(struct device *dev)
42 {
43 if (!CONFIG(SOC_INTEL_COMMON_PCH_LOCKDOWN))
44 return;
45
46 if (get_lockdown_config() != CHIPSET_LOCKDOWN_COREBOOT)
47 return;
48
49 pci_or_config32(dev, SAD_ALL_PAM0123_CSR, PAM_LOCK);
50 }
51
52 static const unsigned short sad_ids[] = {
53 SAD_ALL_DEVID,
54 0
55 };
56
57 static struct device_operations sad_ops = {
58 .read_resources = pci_dev_read_resources,
59 .set_resources = pci_dev_set_resources,
60 .enable_resources = sad_enable_resources,
61 .final = sad_final,
62 };
63
64 static const struct pci_driver sad_driver __pci_driver = {
65 .ops = &sad_ops,
66 .vendor = PCI_VID_INTEL,
67 .devices = sad_ids,
68 };