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/cse.h>
10 #include <intelblocks/gpio.h>
11 #include <intelblocks/irq.h>
12 #include <intelblocks/itss.h>
13 #include <intelblocks/pcie_rp.h>
14 #include <intelblocks/xdci.h>
15 #include <soc/intel/common/vbt.h>
16 #include <soc/itss.h>
17 #include <soc/pci_devs.h>
18 #include <soc/pcie.h>
19 #include <soc/ramstage.h>
20 #include <soc/soc_chip.h>
21 
22 #if CONFIG(HAVE_ACPI_TABLES)
23 const char *soc_acpi_name(const struct device *dev)
24 {
25  if (dev->path.type == DEVICE_PATH_DOMAIN)
26  return "PCI0";
27 
28  if (dev->path.type == DEVICE_PATH_USB) {
29  switch (dev->path.usb.port_type) {
30  case 0:
31  /* Root Hub */
32  return "RHUB";
33  case 2:
34  /* USB2 ports */
35  switch (dev->path.usb.port_id) {
36  case 0: return "HS01";
37  case 1: return "HS02";
38  case 2: return "HS03";
39  case 3: return "HS04";
40  case 4: return "HS05";
41  case 5: return "HS06";
42  case 6: return "HS07";
43  case 7: return "HS08";
44  case 8: return "HS09";
45  case 9: return "HS10";
46  }
47  break;
48  case 3:
49  /* USB3 ports */
50  switch (dev->path.usb.port_id) {
51  case 0: return "SS01";
52  case 1: return "SS02";
53  case 2: return "SS03";
54  case 3: return "SS04";
55  }
56  break;
57  }
58  return NULL;
59  }
60  if (dev->path.type != DEVICE_PATH_PCI)
61  return NULL;
62 
63  switch (dev->path.pci.devfn) {
64  case SA_DEVFN_ROOT: return "MCHC";
65  case SA_DEVFN_CPU_PCIE1_0: return "PEG2";
66  case SA_DEVFN_CPU_PCIE6_0: return "PEG0";
67  case SA_DEVFN_CPU_PCIE6_2: return "PEG1";
68  case SA_DEVFN_IGD: return "GFX0";
69  case SA_DEVFN_TCSS_XHCI: return "TXHC";
70  case SA_DEVFN_TCSS_XDCI: return "TXDC";
71  case SA_DEVFN_TCSS_DMA0: return "TDM0";
72  case SA_DEVFN_TCSS_DMA1: return "TDM1";
73  case SA_DEVFN_TBT0: return "TRP0";
74  case SA_DEVFN_TBT1: return "TRP1";
75  case SA_DEVFN_TBT2: return "TRP2";
76  case SA_DEVFN_TBT3: return "TRP3";
77  case SA_DEVFN_IPU: return "IPU0";
78  case PCH_DEVFN_ISH: return "ISHB";
79  case PCH_DEVFN_XHCI: return "XHCI";
80  case PCH_DEVFN_I2C0: return "I2C0";
81  case PCH_DEVFN_I2C1: return "I2C1";
82  case PCH_DEVFN_I2C2: return "I2C2";
83  case PCH_DEVFN_I2C3: return "I2C3";
84  case PCH_DEVFN_I2C4: return "I2C4";
85  case PCH_DEVFN_I2C5: return "I2C5";
86  case PCH_DEVFN_I2C6: return "I2C6";
87  case PCH_DEVFN_I2C7: return "I2C7";
88  case PCH_DEVFN_SATA: return "SATA";
89  case PCH_DEVFN_PCIE1: return "RP01";
90  case PCH_DEVFN_PCIE2: return "RP02";
91  case PCH_DEVFN_PCIE3: return "RP03";
92  case PCH_DEVFN_PCIE4: return "RP04";
93  case PCH_DEVFN_PCIE5: return "RP05";
94  case PCH_DEVFN_PCIE6: return "RP06";
95  case PCH_DEVFN_PCIE7: return "RP07";
96  case PCH_DEVFN_PCIE8: return "RP08";
97  case PCH_DEVFN_PCIE9: return "RP09";
98  case PCH_DEVFN_PCIE10: return "RP10";
99  case PCH_DEVFN_PCIE11: return "RP11";
100  case PCH_DEVFN_PCIE12: return "RP12";
101  case PCH_DEVFN_PMC: return "PMC";
102  case PCH_DEVFN_UART0: return "UAR0";
103  case PCH_DEVFN_UART1: return "UAR1";
104  case PCH_DEVFN_UART2: return "UAR2";
105  case PCH_DEVFN_GSPI0: return "SPI0";
106  case PCH_DEVFN_GSPI1: return "SPI1";
107  case PCH_DEVFN_GSPI2: return "SPI2";
108  case PCH_DEVFN_GSPI3: return "SPI3";
109  /* Keeping ACPI device name coherent with ec.asl */
110  case PCH_DEVFN_ESPI: return "LPCB";
111  case PCH_DEVFN_HDA: return "HDAS";
112  case PCH_DEVFN_SMBUS: return "SBUS";
113  case PCH_DEVFN_GBE: return "GLAN";
114 #if CONFIG(SOC_INTEL_ALDERLAKE_PCH_N)
115  case PCH_DEVFN_EMMC: return "EMMC";
116 #endif
117  }
118 
119  return NULL;
120 }
121 #endif
122 
123 /* SoC routine to fill GPIO PM mask and value for GPIO_MISCCFG register */
125 {
127  const config_t *config = config_of_soc();
128 
129  if (config->gpio_override_pm)
130  memcpy(value, config->gpio_pm, sizeof(value));
131  else
133 
135 }
136 
137 void soc_init_pre_device(void *chip_info)
138 {
139  /* Perform silicon specific init. */
141 
142  /* Display FIRMWARE_VERSION_INFO_HOB */
144 
146 
147  /* Swap enabled PCI ports in device tree if needed. */
149 
150  /* Swap enabled TBT root ports in device tree if needed. */
152 
153  /*
154  * Earlier when coreboot used to send EOP at late as possible caused
155  * issue of delayed response from CSE since CSE was busy loading payload.
156  * To resolve the issue, EOP should be sent earlier than current sequence
157  * in the boot sequence at BS_DEV_INIT.
158  * Intel CSE team recommends to send EOP close to FW init (between FSP-S exit and
159  * current boot sequence) to reduce message response time from CSE hence moving
160  * sending EOP to earlier stage.
161  */
162  if (CONFIG(SOC_INTEL_CSE_SEND_EOP_EARLY)) {
163  printk(BIOS_INFO, "Sending EOP early from SoC\n");
165  }
166 }
167 
168 static void cpu_fill_ssdt(const struct device *dev)
169 {
170  if (!generate_pin_irq_map())
171  printk(BIOS_ERR, "Failed to generate ACPI _PRT table!\n");
172 
174 }
175 
176 static void cpu_set_north_irqs(struct device *dev)
177 {
179 }
180 
181 static struct device_operations pci_domain_ops = {
183  .set_resources = &pci_domain_set_resources,
184  .scan_bus = &pci_domain_scan_bus,
185 #if CONFIG(HAVE_ACPI_TABLES)
186  .acpi_name = &soc_acpi_name,
187 #endif
188 };
189 
190 static struct device_operations cpu_bus_ops = {
192  .set_resources = noop_set_resources,
193  .enable_resources = cpu_set_north_irqs,
194 #if CONFIG(HAVE_ACPI_TABLES)
195  .acpi_fill_ssdt = cpu_fill_ssdt,
196 #endif
197 };
198 
199 static void soc_enable(struct device *dev)
200 {
201  /*
202  * Set the operations if it is a special bus type or a hidden PCI
203  * device.
204  */
205  if (dev->path.type == DEVICE_PATH_DOMAIN)
206  dev->ops = &pci_domain_ops;
207  else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
208  dev->ops = &cpu_bus_ops;
209  else if (dev->path.type == DEVICE_PATH_PCI &&
210  dev->path.pci.devfn == PCH_DEVFN_PMC)
211  dev->ops = &pmc_ops;
212  else if (dev->path.type == DEVICE_PATH_GPIO)
213  block_gpio_enable(dev);
214 }
215 
217  CHIP_NAME("Intel Alderlake")
218  .enable_dev = &soc_enable,
219  .init = &soc_init_pre_device,
220 };
#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 cse_send_end_of_post(void)
Definition: cse_eop.c:236
@ CONFIG
Definition: dsi_common.h:201
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
const struct pcie_rp_group * get_tbt_pcie_rp_table(void)
Definition: pcie_rp.c:75
const struct pcie_rp_group * get_pch_pcie_rp_table(void)
Definition: pcie_rp.c:23
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#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
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
static void cpu_fill_ssdt(const struct device *dev)
Definition: chip.c:168
static struct device_operations pci_domain_ops
Definition: chip.c:181
void soc_init_pre_device(void *chip_info)
Definition: chip.c:137
static void soc_fill_gpio_pm_configuration(void)
Definition: chip.c:124
static void soc_enable(struct device *dev)
Definition: chip.c:199
static void cpu_set_north_irqs(struct device *dev)
Definition: chip.c:176
struct chip_operations soc_intel_alderlake_ops
Definition: chip.c:216
#define MISCCFG_GPIO_PM_CONFIG_BITS
Definition: gpio.h:18
#define PCH_DEVFN_I2C7
Definition: pci_devs.h:87
#define PCH_DEVFN_I2C5
Definition: pci_devs.h:163
#define PCH_DEVFN_GSPI0
Definition: pci_devs.h:206
#define PCH_DEVFN_I2C6
Definition: pci_devs.h:86
#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 SA_DEVFN_TCSS_XHCI
Definition: pci_devs.h:70
#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_ESPI
Definition: pci_devs.h:215
#define PCH_DEVFN_XHCI
Definition: pci_devs.h:124
#define SA_DEVFN_TCSS_DMA0
Definition: pci_devs.h:72
#define SA_DEVFN_TBT1
Definition: pci_devs.h:51
#define PCH_DEVFN_HDA
Definition: pci_devs.h:218
#define SA_DEVFN_CPU_PCIE6_2
Definition: pci_devs.h:45
#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 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 SA_DEVFN_TCSS_DMA1
Definition: pci_devs.h:73
#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 SA_DEVFN_CPU_PCIE6_0
Definition: pci_devs.h:44
#define SA_DEVFN_CPU_PCIE1_0
Definition: pci_devs.h:29
#define PCH_DEVFN_EMMC
Definition: pci_devs.h:148
void gpio_pm_configure(const uint8_t *misccfg_pm_values, size_t num)
Definition: gpio.c:844
struct device_operations pmc_ops
Definition: pmc.c:190
#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