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/irq.h>
11 #include <intelblocks/itss.h>
12 #include <intelblocks/pcie_rp.h>
13 #include <intelblocks/xdci.h>
14 #include <soc/intel/common/vbt.h>
15 #include <soc/itss.h>
16 #include <soc/pci_devs.h>
17 #include <soc/ramstage.h>
18 #include <soc/soc_chip.h>
19 
20 #if CONFIG(HAVE_ACPI_TABLES)
21 const char *soc_acpi_name(const struct device *dev)
22 {
23  if (dev->path.type == DEVICE_PATH_DOMAIN)
24  return "PCI0";
25 
26  if (dev->path.type == DEVICE_PATH_USB) {
27  switch (dev->path.usb.port_type) {
28  case 0:
29  /* Root Hub */
30  return "RHUB";
31  case 2:
32  /* USB2 ports */
33  switch (dev->path.usb.port_id) {
34  case 0: return "HS01";
35  case 1: return "HS02";
36  case 2: return "HS03";
37  case 3: return "HS04";
38  case 4: return "HS05";
39  case 5: return "HS06";
40  case 6: return "HS07";
41  case 7: return "HS08";
42  case 8: return "HS09";
43  case 9: return "HS10";
44  /* PCH-H only */
45  case 10: return "HS11";
46  case 11: return "HS12";
47  case 12: return "HS13";
48  case 13: return "HS14";
49  }
50  break;
51  case 3:
52  /* USB3 ports */
53  switch (dev->path.usb.port_id) {
54  case 0: return "SS01";
55  case 1: return "SS02";
56  case 2: return "SS03";
57  case 3: return "SS04";
58  /* PCH-H only */
59  case 4: return "SS05";
60  case 5: return "SS06";
61  case 6: return "SS07";
62  case 7: return "SS08";
63  case 8: return "SS09";
64  case 9: return "SS10";
65  }
66  break;
67  }
68  return NULL;
69  }
70  if (dev->path.type != DEVICE_PATH_PCI)
71  return NULL;
72 
73  switch (dev->path.pci.devfn) {
74  case SA_DEVFN_ROOT: return "MCHC";
75  case SA_DEVFN_CPU_PCIE: return "PEG0";
76  case SA_DEVFN_PEG1: return "PEG1";
77  case SA_DEVFN_PEG2: return "PEG2";
78  case SA_DEVFN_PEG3: return "PEG3";
79  case SA_DEVFN_TCSS_XDCI: return "TXDC";
80  case SA_DEVFN_TBT0: return "TRP0";
81  case SA_DEVFN_TBT1: return "TRP1";
82  case SA_DEVFN_TBT2: return "TRP2";
83  case SA_DEVFN_TBT3: return "TRP3";
84  case SA_DEVFN_IPU: return "IPU0";
85  case PCH_DEVFN_ISH: return "ISHB";
86  case PCH_DEVFN_XHCI: return "XHCI";
87  case PCH_DEVFN_I2C0: return "I2C0";
88  case PCH_DEVFN_I2C1: return "I2C1";
89  case PCH_DEVFN_I2C2: return "I2C2";
90  case PCH_DEVFN_I2C3: return "I2C3";
91  case PCH_DEVFN_I2C4: return "I2C4";
92  case PCH_DEVFN_I2C5: return "I2C5";
93  case PCH_DEVFN_SATA: return "SATA";
94  case PCH_DEVFN_PCIE1: return "RP01";
95  case PCH_DEVFN_PCIE2: return "RP02";
96  case PCH_DEVFN_PCIE3: return "RP03";
97  case PCH_DEVFN_PCIE4: return "RP04";
98  case PCH_DEVFN_PCIE5: return "RP05";
99  case PCH_DEVFN_PCIE6: return "RP06";
100  case PCH_DEVFN_PCIE7: return "RP07";
101  case PCH_DEVFN_PCIE8: return "RP08";
102  case PCH_DEVFN_PCIE9: return "RP09";
103  case PCH_DEVFN_PCIE10: return "RP10";
104  case PCH_DEVFN_PCIE11: return "RP11";
105  case PCH_DEVFN_PCIE12: return "RP12";
106  case PCH_DEVFN_PCIE13: return "RP13";
107  case PCH_DEVFN_PCIE14: return "RP14";
108  case PCH_DEVFN_PCIE15: return "RP15";
109  case PCH_DEVFN_PCIE16: return "RP16";
110  case PCH_DEVFN_PCIE17: return "RP17";
111  case PCH_DEVFN_PCIE18: return "RP18";
112  case PCH_DEVFN_PCIE19: return "RP19";
113  case PCH_DEVFN_PCIE20: return "RP20";
114  case PCH_DEVFN_PCIE21: return "RP21";
115  case PCH_DEVFN_PCIE22: return "RP22";
116  case PCH_DEVFN_PCIE23: return "RP23";
117  case PCH_DEVFN_PCIE24: return "RP24";
118  case PCH_DEVFN_PMC: return "PMC";
119  case PCH_DEVFN_UART0: return "UAR0";
120  case PCH_DEVFN_UART1: return "UAR1";
121  case PCH_DEVFN_UART2: return "UAR2";
122  case PCH_DEVFN_GSPI0: return "SPI0";
123  case PCH_DEVFN_GSPI1: return "SPI1";
124  case PCH_DEVFN_GSPI2: return "SPI2";
125  case PCH_DEVFN_GSPI3: return "SPI3";
126  case PCH_DEVFN_HDA: return "HDAS";
127  case PCH_DEVFN_SMBUS: return "SBUS";
128  case PCH_DEVFN_GBE: return "GLAN";
129  }
130 
131  return NULL;
132 }
133 #endif
134 
135 /* SoC routine to fill GPIO PM mask and value for GPIO_MISCCFG register */
137 {
139  const config_t *config = config_of_soc();
140 
141  if (config->gpio_override_pm)
142  memcpy(value, config->gpio_pm, sizeof(value));
143  else
145 
147 }
148 
149 void soc_init_pre_device(void *chip_info)
150 {
151  /* Perform silicon specific init. */
153 
154  /* Display FIRMWARE_VERSION_INFO_HOB */
156 
158 
159  /* Swap enabled PCI ports in device tree if needed. */
162 }
163 
164 static void cpu_fill_ssdt(const struct device *dev)
165 {
166  if (!generate_pin_irq_map())
167  printk(BIOS_ERR, "Failed to generate ACPI _PRT table!\n");
168 
170 }
171 
172 static void cpu_set_north_irqs(struct device *dev)
173 {
175 }
176 
177 static struct device_operations pci_domain_ops = {
179  .set_resources = &pci_domain_set_resources,
180  .scan_bus = &pci_domain_scan_bus,
181 #if CONFIG(HAVE_ACPI_TABLES)
182  .acpi_name = &soc_acpi_name,
183 #endif
184 };
185 
186 static struct device_operations cpu_bus_ops = {
188  .set_resources = noop_set_resources,
189  .enable_resources = cpu_set_north_irqs,
190 #if CONFIG(HAVE_ACPI_TABLES)
191  .acpi_fill_ssdt = cpu_fill_ssdt,
192 #endif
193 };
194 
195 static void soc_enable(struct device *dev)
196 {
197  /*
198  * Set the operations if it is a special bus type or a hidden PCI
199  * device.
200  */
201  if (dev->path.type == DEVICE_PATH_DOMAIN)
202  dev->ops = &pci_domain_ops;
203  else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
204  dev->ops = &cpu_bus_ops;
205  else if (dev->path.type == DEVICE_PATH_PCI &&
206  dev->path.pci.devfn == PCH_DEVFN_PMC)
207  dev->ops = &pmc_ops;
208  else if (dev->path.type == DEVICE_PATH_GPIO)
209  block_gpio_enable(dev);
210 }
211 
213  CHIP_NAME("Intel Tigerlake")
214  .enable_dev = &soc_enable,
215  .init = &soc_init_pre_device,
216 };
#define TOTAL_GPIO_COMM
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
bool generate_pin_irq_map(void)
Definition: irq.c:365
bool irq_program_non_pch(void)
Definition: irq.c:407
#define printk(level,...)
Definition: stdlib.h:16
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
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
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
@ DEVICE_PATH_USB
Definition: path.h:20
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
const struct pcie_rp_group * soc_get_pch_rp_groups(void)
Definition: pcie_rp.c:50
void pcie_rp_update_devicetree(const struct pcie_rp_group *groups)
Definition: pcie_rp.c:131
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_I2C5
Definition: pci_devs.h:163
#define PCH_DEVFN_GSPI0
Definition: pci_devs.h:206
#define SA_DEVFN_ROOT
Definition: pci_devs.h:23
#define PCH_DEVFN_GSPI3
Definition: pci_devs.h:114
#define PCH_DEVFN_PCIE12
Definition: pci_devs.h:197
#define SA_DEVFN_IPU
Definition: pci_devs.h:40
#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_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 SA_DEVFN_TCSS_XDCI
Definition: pci_devs.h:71
#define PCH_DEVFN_SATA
Definition: pci_devs.h:158
#define PCH_DEVFN_UART1
Definition: pci_devs.h:205
#define SA_DEVFN_TBT3
Definition: pci_devs.h:53
#define SA_DEVFN_TBT2
Definition: pci_devs.h:52
#define PCH_DEVFN_GBE
Definition: pci_devs.h:221
#define PCH_DEVFN_XHCI
Definition: pci_devs.h:124
#define SA_DEVFN_TBT1
Definition: pci_devs.h:51
#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 PCH_DEVFN_ISH
Definition: pci_devs.h:106
#define SA_DEVFN_TBT0
Definition: pci_devs.h:50
#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_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 SA_DEVFN_PEG1
Definition: pci_devs.h:27
#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 SA_DEVFN_PEG2
Definition: pci_devs.h:28
#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 const struct pcie_rp_group pch_rp_groups[]
Definition: chip.c:19
struct device_operations pmc_ops
Definition: pmc.c:190
static void cpu_fill_ssdt(const struct device *dev)
Definition: chip.c:164
static struct device_operations pci_domain_ops
Definition: chip.c:177
struct chip_operations soc_intel_tigerlake_ops
Definition: chip.c:212
static void soc_fill_gpio_pm_configuration(void)
Definition: chip.c:136
static void soc_enable(struct device *dev)
Definition: chip.c:195
static void cpu_set_north_irqs(struct device *dev)
Definition: chip.c:172
#define SA_DEVFN_PEG3
Definition: pci_devs.h:31
#define SA_DEVFN_CPU_PCIE
Definition: pci_devs.h:46
#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 usb_path usb
Definition: path.h:127
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
unsigned int port_type
Definition: path.h:101
unsigned int port_id
Definition: path.h:102