coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
chip.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/device.h>
4 #include <device/pci.h>
5 #include <fsp/api.h>
6 #include <fsp/util.h>
7 #include <intelblocks/acpi.h>
8 #include <intelblocks/cfg.h>
9 #include <intelblocks/gpio.h>
10 #include <intelblocks/itss.h>
11 #include <intelblocks/xdci.h>
12 #include <soc/intel/common/vbt.h>
13 #include <soc/itss.h>
14 #include <soc/pci_devs.h>
15 #include <soc/ramstage.h>
16 #include <soc/soc_chip.h>
17 
18 #if CONFIG(HAVE_ACPI_TABLES)
19 const char *soc_acpi_name(const struct device *dev)
20 {
21  if (dev->path.type == DEVICE_PATH_DOMAIN)
22  return "PCI0";
23 
24  if (dev->path.type != DEVICE_PATH_PCI)
25  return NULL;
26 
27  switch (dev->path.pci.devfn) {
28  case SA_DEVFN_ROOT: return "MCHC";
29  case SA_DEVFN_IGD: return "GFX0";
30  case PCH_DEVFN_ISH: return "ISHB";
31  case PCH_DEVFN_XHCI: return "XHCI";
32  case PCH_DEVFN_USBOTG: return "XDCI";
33  case PCH_DEVFN_THERMAL: return "THRM";
34  case PCH_DEVFN_I2C0: return "I2C0";
35  case PCH_DEVFN_I2C1: return "I2C1";
36  case PCH_DEVFN_I2C2: return "I2C2";
37  case PCH_DEVFN_I2C3: return "I2C3";
38  case PCH_DEVFN_CSE: return "CSE1";
39  case PCH_DEVFN_CSE_2: return "CSE2";
40  case PCH_DEVFN_CSE_IDER: return "CSED";
41  case PCH_DEVFN_CSE_KT: return "CSKT";
42  case PCH_DEVFN_CSE_3: return "CSE3";
43  case PCH_DEVFN_SATA: return "SATA";
44  case PCH_DEVFN_UART2: return "UAR2";
45  case PCH_DEVFN_I2C4: return "I2C4";
46  case PCH_DEVFN_I2C5: return "I2C5";
47  case PCH_DEVFN_PCIE1: return "RP01";
48  case PCH_DEVFN_PCIE2: return "RP02";
49  case PCH_DEVFN_PCIE3: return "RP03";
50  case PCH_DEVFN_PCIE4: return "RP04";
51  case PCH_DEVFN_PCIE5: return "RP05";
52  case PCH_DEVFN_PCIE6: return "RP06";
53  case PCH_DEVFN_PCIE7: return "RP07";
54  case PCH_DEVFN_PCIE8: return "RP08";
55  case PCH_DEVFN_PCIE9: return "RP09";
56  case PCH_DEVFN_PCIE10: return "RP10";
57  case PCH_DEVFN_PCIE11: return "RP11";
58  case PCH_DEVFN_PCIE12: return "RP12";
59  case PCH_DEVFN_PCIE13: return "RP13";
60  case PCH_DEVFN_PCIE14: return "RP14";
61  case PCH_DEVFN_PCIE15: return "RP15";
62  case PCH_DEVFN_PCIE16: return "RP16";
63  case PCH_DEVFN_PCIE17: return "RP17";
64  case PCH_DEVFN_PCIE18: return "RP18";
65  case PCH_DEVFN_PCIE19: return "RP19";
66  case PCH_DEVFN_PCIE20: return "RP20";
67  case PCH_DEVFN_PCIE21: return "RP21";
68  case PCH_DEVFN_PCIE22: return "RP22";
69  case PCH_DEVFN_PCIE23: return "RP23";
70  case PCH_DEVFN_PCIE24: return "RP24";
71  case PCH_DEVFN_UART0: return "UAR0";
72  case PCH_DEVFN_UART1: return "UAR1";
73  case PCH_DEVFN_GSPI0: return "SPI0";
74  case PCH_DEVFN_GSPI1: return "SPI1";
75  case PCH_DEVFN_GSPI2: return "SPI2";
76  case PCH_DEVFN_EMMC: return "EMMC";
77  case PCH_DEVFN_SDCARD: return "SDXC";
78  case PCH_DEVFN_P2SB: return "P2SB";
79  case PCH_DEVFN_PMC: return "PMC_";
80  case PCH_DEVFN_HDA: return "HDAS";
81  case PCH_DEVFN_SMBUS: return "SBUS";
82  case PCH_DEVFN_SPI: return "FSPI";
83  case PCH_DEVFN_GBE: return "IGBE";
84  case PCH_DEVFN_TRACEHUB:return "THUB";
85  }
86 
87  return NULL;
88 }
89 #endif
90 
91 /* SoC routine to fill GPIO PM mask and value for GPIO_MISCCFG register */
93 {
95  const config_t *config = config_of_soc();
96 
97  if (config->gpio_override_pm)
98  memcpy(value, config->gpio_pm, sizeof(value));
99  else
101 
103 }
104 
105 void soc_init_pre_device(void *chip_info)
106 {
107  /* Snapshot the current GPIO IRQ polarities. FSP is setting a
108  * default policy that doesn't honor boards' requirements. */
110 
111  /* Perform silicon specific init. */
113 
114  /* Display FIRMWARE_VERSION_INFO_HOB */
116 
117  /* Restore GPIO IRQ polarities back to previous settings. */
119 
121 }
122 
123 static struct device_operations pci_domain_ops = {
125  .set_resources = &pci_domain_set_resources,
126  .scan_bus = &pci_domain_scan_bus,
127  #if CONFIG(HAVE_ACPI_TABLES)
128  .acpi_name = &soc_acpi_name,
129  #endif
130 };
131 
132 static struct device_operations cpu_bus_ops = {
134  .set_resources = noop_set_resources,
135  .acpi_fill_ssdt = generate_cpu_entries,
136 };
137 
138 static void soc_enable(struct device *dev)
139 {
140  /* Set the operations if it is a special bus type */
141  if (dev->path.type == DEVICE_PATH_DOMAIN)
142  dev->ops = &pci_domain_ops;
143  else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
144  dev->ops = &cpu_bus_ops;
145  else if (dev->path.type == DEVICE_PATH_GPIO)
146  block_gpio_enable(dev);
147 }
148 
150  CHIP_NAME("Intel Icelake")
151  .enable_dev = &soc_enable,
152  .init = &soc_init_pre_device,
153 };
#define TOTAL_GPIO_COMM
#define GPIO_IRQ_START
Definition: itss.h:6
#define GPIO_IRQ_END
Definition: itss.h:7
pte_t value
Definition: mmu.c:91
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
void * memset(void *dstpp, int c, size_t len)
Definition: memset.c:12
void itss_snapshot_irq_polarities(int start, int end)
Definition: itss.c:62
void itss_restore_irq_polarities(int start, int end)
Definition: itss.c:94
void generate_cpu_entries(const struct device *device)
Definition: acpi.c:334
void fsp_silicon_init(void)
Definition: silicon_init.c:242
void block_gpio_enable(struct device *dev)
Definition: gpio_dev.c:24
void fsp_display_fvi_version_hob(void)
#define CHIP_NAME(X)
Definition: device.h:32
static void noop_read_resources(struct device *dev)
Standard device operations function pointers shims.
Definition: device.h:73
static void noop_set_resources(struct device *dev)
Definition: device.h:74
#define config_of_soc()
Definition: device.h:394
enum board_config config
Definition: memory.c:448
@ DEVICE_PATH_GPIO
Definition: path.h:22
@ DEVICE_PATH_PCI
Definition: path.h:9
@ DEVICE_PATH_CPU_CLUSTER
Definition: path.h:14
@ DEVICE_PATH_DOMAIN
Definition: path.h:13
void pci_domain_read_resources(struct device *dev)
Definition: pci_device.c:547
void pci_domain_set_resources(struct device *dev)
Definition: pci_device.c:564
void pci_domain_scan_bus(struct device *dev)
Scan a PCI domain.
Definition: pci_device.c:1610
struct device_operations cpu_bus_ops
Definition: chip.c:22
const char * soc_acpi_name(const struct device *dev)
Definition: chip.c:31
void soc_init_pre_device(void *chip_info)
Definition: chip.c:137
#define MISCCFG_GPIO_PM_CONFIG_BITS
Definition: gpio.h:18
#define PCH_DEVFN_CSE_IDER
Definition: pci_devs.h:146
#define PCH_DEVFN_I2C5
Definition: pci_devs.h:163
#define PCH_DEVFN_CSE_3
Definition: pci_devs.h:148
#define PCH_DEVFN_GSPI0
Definition: pci_devs.h:206
#define SA_DEVFN_ROOT
Definition: pci_devs.h:23
#define PCH_DEVFN_CSE_2
Definition: pci_devs.h:145
#define PCH_DEVFN_CSE_KT
Definition: pci_devs.h:147
#define PCH_DEVFN_PCIE12
Definition: pci_devs.h:197
#define PCH_DEVFN_TRACEHUB
Definition: pci_devs.h:222
#define PCH_DEVFN_PMC
Definition: pci_devs.h:217
#define PCH_DEVFN_I2C0
Definition: pci_devs.h:134
#define PCH_DEVFN_PCIE2
Definition: pci_devs.h:177
#define PCH_DEVFN_PCIE11
Definition: pci_devs.h:196
#define PCH_DEVFN_UART0
Definition: pci_devs.h:204
#define PCH_DEVFN_PCIE5
Definition: pci_devs.h:180
#define PCH_DEVFN_P2SB
Definition: pci_devs.h:216
#define PCH_DEVFN_I2C3
Definition: pci_devs.h:137
#define PCH_DEVFN_I2C4
Definition: pci_devs.h:162
#define PCH_DEVFN_I2C2
Definition: pci_devs.h:136
#define PCH_DEVFN_PCIE9
Definition: pci_devs.h:194
#define PCH_DEVFN_USBOTG
Definition: pci_devs.h:125
#define PCH_DEVFN_SATA
Definition: pci_devs.h:158
#define PCH_DEVFN_UART1
Definition: pci_devs.h:205
#define PCH_DEVFN_SPI
Definition: pci_devs.h:220
#define PCH_DEVFN_GBE
Definition: pci_devs.h:221
#define PCH_DEVFN_XHCI
Definition: pci_devs.h:124
#define PCH_DEVFN_HDA
Definition: pci_devs.h:218
#define PCH_DEVFN_SMBUS
Definition: pci_devs.h:219
#define PCH_DEVFN_I2C1
Definition: pci_devs.h:135
#define PCH_DEVFN_PCIE6
Definition: pci_devs.h:181
#define PCH_DEVFN_PCIE3
Definition: pci_devs.h:178
#define SA_DEVFN_IGD
Definition: pci_devs.h:32
#define PCH_DEVFN_ISH
Definition: pci_devs.h:106
#define PCH_DEVFN_GSPI2
Definition: pci_devs.h:107
#define PCH_DEVFN_UART2
Definition: pci_devs.h:164
#define PCH_DEVFN_PCIE7
Definition: pci_devs.h:182
#define PCH_DEVFN_PCIE4
Definition: pci_devs.h:179
#define PCH_DEVFN_PCIE10
Definition: pci_devs.h:195
#define PCH_DEVFN_PCIE8
Definition: pci_devs.h:183
#define PCH_DEVFN_GSPI1
Definition: pci_devs.h:207
#define PCH_DEVFN_PCIE1
Definition: pci_devs.h:176
#define PCH_DEVFN_CSE
Definition: pci_devs.h:144
#define PCH_DEVFN_SDCARD
Definition: pci_devs.h:144
#define PCH_DEVFN_EMMC
Definition: pci_devs.h:148
#define PCH_DEVFN_THERMAL
Definition: pci_devs.h:77
#define PCH_DEVFN_PCIE15
Definition: pci_devs.h:138
#define PCH_DEVFN_PCIE20
Definition: pci_devs.h:153
#define PCH_DEVFN_PCIE22
Definition: pci_devs.h:155
#define PCH_DEVFN_PCIE14
Definition: pci_devs.h:137
#define PCH_DEVFN_PCIE19
Definition: pci_devs.h:152
#define PCH_DEVFN_PCIE21
Definition: pci_devs.h:154
#define PCH_DEVFN_PCIE13
Definition: pci_devs.h:136
#define PCH_DEVFN_PCIE23
Definition: pci_devs.h:156
#define PCH_DEVFN_PCIE17
Definition: pci_devs.h:150
#define PCH_DEVFN_PCIE16
Definition: pci_devs.h:139
#define PCH_DEVFN_PCIE18
Definition: pci_devs.h:151
#define PCH_DEVFN_PCIE24
Definition: pci_devs.h:157
void gpio_pm_configure(const uint8_t *misccfg_pm_values, size_t num)
Definition: gpio.c:844
static struct device_operations pci_domain_ops
Definition: chip.c:123
struct chip_operations soc_intel_icelake_ops
Definition: chip.c:149
static void soc_fill_gpio_pm_configuration(void)
Definition: chip.c:92
static void soc_enable(struct device *dev)
Definition: chip.c:138
#define NULL
Definition: stddef.h:19
unsigned char uint8_t
Definition: stdint.h:8
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct pci_path pci
Definition: path.h:116
enum device_path_type type
Definition: path.h:114
Definition: device.h:107
struct device_path path
Definition: device.h:115
struct device_operations * ops
Definition: device.h:143
unsigned int devfn
Definition: path.h:54