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-or-later */
2 
3 #include <acpi/acpi.h>
4 #include <bootstate.h>
5 #include <cbfs.h>
6 #include <console/console.h>
7 #include <device/device.h>
8 #include <device/pci.h>
9 #include <fsp/api.h>
10 #include <fsp/util.h>
11 #include <intelblocks/fast_spi.h>
12 #include <intelblocks/acpi.h>
13 #include <intelblocks/gpio.h>
14 #include <soc/iomap.h>
15 #include <soc/intel/common/vbt.h>
16 #include <soc/pci_devs.h>
17 #include <soc/ramstage.h>
18 #include <soc/fiamux.h>
19 #include <spi-generic.h>
20 #include <soc/hob_mem.h>
21 
22 const char *soc_acpi_name(const struct device *dev)
23 {
24  if (dev->path.type == DEVICE_PATH_DOMAIN)
25  return "PCI0";
26 
27  if (dev->path.type == DEVICE_PATH_USB) {
28  switch (dev->path.usb.port_type) {
29  case 0:
30  /* Root Hub */
31  return "RHUB";
32  case 2:
33  /* USB2 ports */
34  switch (dev->path.usb.port_id) {
35  case 0: return "HS01";
36  case 1: return "HS02";
37  case 2: return "HS03";
38  case 3: return "HS04";
39  }
40  break;
41  case 3:
42  /* USB3 ports */
43  switch (dev->path.usb.port_id) {
44  case 4: return "SS01";
45  case 5: return "SS02";
46  case 6: return "SS03";
47  case 7: return "SS04";
48  }
49  break;
50  }
51  return NULL;
52  }
53 
54  if (dev->path.type != DEVICE_PATH_PCI)
55  return NULL;
56 
57  switch (dev->path.pci.devfn) {
58  case SA_DEVFN_ROOT:
59  return "MCHC";
60  case PCH_DEVFN_XHCI:
61  return "XHCI";
62  case PCH_DEVFN_UART0:
63  return "UAR0";
64  case PCH_DEVFN_UART1:
65  return "UAR1";
66  case PCH_DEVFN_UART2:
67  return "UAR2";
68  case PCH_DEVFN_PCIE1:
69  return "RP01";
70  case PCH_DEVFN_PCIE2:
71  return "RP02";
72  case PCH_DEVFN_PCIE3:
73  return "RP03";
74  case PCH_DEVFN_PCIE4:
75  return "RP04";
76  case PCH_DEVFN_PCIE5:
77  return "RP05";
78  case PCH_DEVFN_PCIE6:
79  return "RP06";
80  case PCH_DEVFN_PCIE7:
81  return "RP07";
82  case PCH_DEVFN_PCIE8:
83  return "RP08";
84  case PCH_DEVFN_LPC:
85  return "LPCB";
86  case PCH_DEVFN_SMBUS:
87  return "SBUS";
88  case PCH_DEVFN_SATA_0:
89  return "SAT0";
90  case PCH_DEVFN_SATA_1:
91  return "SAT1";
92  case PCH_DEVFN_EMMC:
93  return "EMMC";
94  case PCH_DEVFN_SPI:
95  return "SPI0";
96  case PCH_DEVFN_PMC:
97  return "PMC_";
98  case PCH_DEVFN_QAT:
99  return "QAT_";
100  case PCH_DEVFN_LAN0:
101  return "LAN0";
102  case PCH_DEVFN_LAN1:
103  return "LAN1";
104  }
105 
106  return NULL;
107 }
108 
109 static struct device_operations pci_domain_ops = {
111  .set_resources = &pci_domain_set_resources,
112  .scan_bus = &pci_domain_scan_bus,
113 #if CONFIG(HAVE_ACPI_TABLES)
114  .acpi_name = &soc_acpi_name,
115 #endif
116 };
117 
118 static struct device_operations cpu_bus_ops = {
120  .set_resources = noop_set_resources,
121  .init = mp_cpu_bus_init,
122 #if CONFIG(HAVE_ACPI_TABLES)
123  .acpi_fill_ssdt = generate_cpu_entries,
124 #endif
125 };
126 
127 static void soc_enable_dev(struct device *dev)
128 {
129  /* Set the operations if it is a special bus type */
130  if (dev->path.type == DEVICE_PATH_DOMAIN)
131  dev->ops = &pci_domain_ops;
132  else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
133  dev->ops = &cpu_bus_ops;
134  else if (dev->path.type == DEVICE_PATH_GPIO)
135  block_gpio_enable(dev);
136 }
137 
138 static void soc_init(void *data)
139 {
142 }
143 
144 static void soc_final(void *data) {}
145 
146 static void soc_silicon_init_params(FSPS_UPD *silupd)
147 {
148  size_t num;
149  uint16_t supported_hsio_lanes;
150  BL_HSIO_INFORMATION *hsio_config;
151  BL_FIA_MUX_CONFIG_HOB *fiamux_hob_data = get_fiamux_hob_data();
152 
153  /* Configure FIA MUX PCD */
154  supported_hsio_lanes =
155  (uint16_t)fiamux_hob_data->FiaMuxConfig.SkuNumLanesAllowed;
156 
157  num = mainboard_get_hsio_config(&hsio_config);
158 
159  if (get_fiamux_hsio_info(supported_hsio_lanes, num, &hsio_config))
160  die("HSIO Configuration is invalid, please correct it!");
161 
162  /* Check the requested FIA MUX Configuration */
163  if (!(&hsio_config->FiaConfig)) {
164  die("Requested FIA MUX Configuration is invalid,"
165  " please correct it!");
166  }
167 
168  /* Initialize PCIE Bifurcation & HSIO configuration */
169  silupd->FspsConfig.PcdBifurcationPcie0 = hsio_config->PcieBifCtr[0];
170  silupd->FspsConfig.PcdBifurcationPcie1 = hsio_config->PcieBifCtr[1];
171 
172  silupd->FspsConfig.PcdFiaMuxConfigRequestPtr =
173  (uint32_t)&hsio_config->FiaConfig;
174 }
175 
177 {
178  const struct microcode *microcode_file;
179  size_t microcode_len;
180 
181  microcode_file = cbfs_map("cpu_microcode_blob.bin", &microcode_len);
182 
183  if ((microcode_file != NULL) && (microcode_len != 0)) {
184  /* Update CPU Microcode patch base address/size */
185  silupd->FspsConfig.PcdCpuMicrocodePatchBase =
186  (uint32_t)microcode_file;
187  silupd->FspsConfig.PcdCpuMicrocodePatchSize =
188  (uint32_t)microcode_len;
189  }
190 
191  soc_silicon_init_params(silupd);
193 }
194 
196  CHIP_NAME("Intel Denverton-NS SOC")
197  .enable_dev = soc_enable_dev,
198  .init = soc_init,
199  .final = soc_final
200 };
201 
202 struct pci_operations soc_pci_ops = {
203  .set_subsystem = pci_dev_set_subsystem,
204 };
205 
206 /*
207  * spi_flash init() needs to run unconditionally on every boot (including
208  * resume) to allow write protect to be disabled for eventlog and nvram
209  * updates. This needs to be done as early as possible in ramstage. Thus, add a
210  * callback for entry into BS_PRE_DEVICE.
211  */
212 static void spi_flash_init_cb(void *unused)
213 {
214  fast_spi_init();
215 }
216 
@ BS_PRE_DEVICE
Definition: bootstate.h:78
@ BS_ON_ENTRY
Definition: bootstate.h:95
static void * cbfs_map(const char *name, size_t *size_out)
Definition: cbfs.h:246
void __noreturn die(const char *fmt,...)
Definition: die.c:17
void generate_cpu_entries(const struct device *device)
Definition: acpi.c:334
BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, wilco_ec_post_complete, NULL)
void fast_spi_init(void)
Definition: fast_spi.c:41
BL_FIA_MUX_CONFIG_HOB * get_fiamux_hob_data(void)
Definition: fiamux.c:103
int get_fiamux_hsio_info(uint16_t num_of_lanes, size_t num_of_entry, BL_HSIO_INFORMATION **config)
Definition: fiamux.c:14
void fsp_silicon_init(void)
Definition: silicon_init.c:242
void block_gpio_enable(struct device *dev)
Definition: gpio_dev.c:24
void soc_save_dimm_info(void)
Definition: hob_mem.c:14
#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
static void mp_cpu_bus_init(struct device *dev)
Definition: device.h:240
size_t mainboard_get_hsio_config(BL_HSIO_INFORMATION **p_hsio_config)
Definition: hsio.c:7
@ 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_dev_set_subsystem(struct device *dev, unsigned int vendor, unsigned int device)
Definition: pci_device.c:791
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
#define SA_DEVFN_ROOT
Definition: pci_devs.h:23
#define PCH_DEVFN_PMC
Definition: pci_devs.h:217
#define PCH_DEVFN_PCIE2
Definition: pci_devs.h:177
#define PCH_DEVFN_UART0
Definition: pci_devs.h:204
#define PCH_DEVFN_PCIE5
Definition: pci_devs.h:180
#define PCH_DEVFN_UART1
Definition: pci_devs.h:205
#define PCH_DEVFN_SPI
Definition: pci_devs.h:220
#define PCH_DEVFN_XHCI
Definition: pci_devs.h:124
#define PCH_DEVFN_SMBUS
Definition: pci_devs.h:219
#define PCH_DEVFN_PCIE6
Definition: pci_devs.h:181
#define PCH_DEVFN_PCIE3
Definition: pci_devs.h:178
#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_PCIE8
Definition: pci_devs.h:183
#define PCH_DEVFN_PCIE1
Definition: pci_devs.h:176
void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd)
Definition: chip.c:628
__weak void mainboard_silicon_init_params(FSP_S_CONFIG *silconfig)
Definition: chip.c:875
#define PCH_DEVFN_LPC
Definition: pci_devs.h:156
#define PCH_DEVFN_EMMC
Definition: pci_devs.h:148
struct pci_operations soc_pci_ops
Definition: chip.c:51
void soc_silicon_init_params(SILICON_INIT_UPD *params)
Definition: chip.c:47
static void soc_final(void *data)
Definition: chip.c:144
static struct device_operations pci_domain_ops
Definition: chip.c:109
static void soc_enable_dev(struct device *dev)
Definition: chip.c:127
static void soc_init(void *data)
Definition: chip.c:138
static void spi_flash_init_cb(void *unused)
Definition: chip.c:212
struct chip_operations soc_intel_denverton_ns_ops
Definition: chip.c:195
#define PCH_DEVFN_LAN0
Definition: pci_devs.h:124
#define PCH_DEVFN_LAN1
Definition: pci_devs.h:131
#define PCH_DEVFN_QAT
Definition: pci_devs.h:46
#define PCH_DEVFN_SATA_0
Definition: pci_devs.h:105
#define PCH_DEVFN_SATA_1
Definition: pci_devs.h:108
#define NULL
Definition: stddef.h:19
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
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