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/pci_devs.h>
16 #include <soc/ramstage.h>
17 
18 #include "chip.h"
19 
20 static const struct pcie_rp_group pch_lp_rp_groups[] = {
21  { .slot = PCH_DEV_SLOT_PCIE, .count = 8, .lcap_port_base = 1 },
22  { .slot = PCH_DEV_SLOT_PCIE_1, .count = 8, .lcap_port_base = 1 },
23  { 0 }
24 };
25 
26 static const struct pcie_rp_group pch_h_rp_groups[] = {
27  { .slot = PCH_DEV_SLOT_PCIE, .count = 8, .lcap_port_base = 1 },
28  { .slot = PCH_DEV_SLOT_PCIE_1, .count = 8, .lcap_port_base = 1 },
29  { .slot = PCH_DEV_SLOT_PCIE_2, .count = 8, .lcap_port_base = 1 },
30  { 0 }
31 };
32 
33 #if CONFIG(HAVE_ACPI_TABLES)
34 const char *soc_acpi_name(const struct device *dev)
35 {
36  if (dev->path.type == DEVICE_PATH_DOMAIN)
37  return "PCI0";
38 
39  if (dev->path.type == DEVICE_PATH_USB) {
40  switch (dev->path.usb.port_type) {
41  case 0:
42  /* Root Hub */
43  return "RHUB";
44  case 2:
45  /* USB2 ports */
46  switch (dev->path.usb.port_id) {
47  case 0: return "HS01";
48  case 1: return "HS02";
49  case 2: return "HS03";
50  case 3: return "HS04";
51  case 4: return "HS05";
52  case 5: return "HS06";
53  case 6: return "HS07";
54  case 7: return "HS08";
55  case 8: return "HS09";
56  case 9: return "HS10";
57  case 10: return "HS11";
58  case 11: return "HS12";
59  }
60  break;
61  case 3:
62  /* USB3 ports */
63  switch (dev->path.usb.port_id) {
64  case 0: return "SS01";
65  case 1: return "SS02";
66  case 2: return "SS03";
67  case 3: return "SS04";
68  case 4: return "SS05";
69  case 5: return "SS06";
70  }
71  break;
72  }
73  return NULL;
74  }
75 
76  if (dev->path.type != DEVICE_PATH_PCI)
77  return NULL;
78 
79  switch (dev->path.pci.devfn) {
80  case SA_DEVFN_ROOT: return "MCHC";
81  case SA_DEVFN_IGD: return "GFX0";
82  case PCH_DEVFN_ISH: return "ISHB";
83  case PCH_DEVFN_XHCI: return "XHCI";
84  case PCH_DEVFN_USBOTG: return "XDCI";
85  case PCH_DEVFN_THERMAL: return "THRM";
86  case PCH_DEVFN_I2C0: return "I2C0";
87  case PCH_DEVFN_I2C1: return "I2C1";
88  case PCH_DEVFN_I2C2: return "I2C2";
89  case PCH_DEVFN_I2C3: return "I2C3";
90  case PCH_DEVFN_CSE: return "CSE1";
91  case PCH_DEVFN_CSE_2: return "CSE2";
92  case PCH_DEVFN_CSE_IDER: return "CSED";
93  case PCH_DEVFN_CSE_KT: return "CSKT";
94  case PCH_DEVFN_CSE_3: return "CSE3";
95  case PCH_DEVFN_SATA: return "SATA";
96  case PCH_DEVFN_UART2: return "UAR2";
97  case PCH_DEVFN_I2C4: return "I2C4";
98  case PCH_DEVFN_I2C5: return "I2C5";
99  case PCH_DEVFN_PCIE1: return "RP01";
100  case PCH_DEVFN_PCIE2: return "RP02";
101  case PCH_DEVFN_PCIE3: return "RP03";
102  case PCH_DEVFN_PCIE4: return "RP04";
103  case PCH_DEVFN_PCIE5: return "RP05";
104  case PCH_DEVFN_PCIE6: return "RP06";
105  case PCH_DEVFN_PCIE7: return "RP07";
106  case PCH_DEVFN_PCIE8: return "RP08";
107  case PCH_DEVFN_PCIE9: return "RP09";
108  case PCH_DEVFN_PCIE10: return "RP10";
109  case PCH_DEVFN_PCIE11: return "RP11";
110  case PCH_DEVFN_PCIE12: return "RP12";
111  case PCH_DEVFN_PCIE13: return "RP13";
112  case PCH_DEVFN_PCIE14: return "RP14";
113  case PCH_DEVFN_PCIE15: return "RP15";
114  case PCH_DEVFN_PCIE16: return "RP16";
115  case PCH_DEVFN_PCIE17: return "RP17";
116  case PCH_DEVFN_PCIE18: return "RP18";
117  case PCH_DEVFN_PCIE19: return "RP19";
118  case PCH_DEVFN_PCIE20: return "RP20";
119  case PCH_DEVFN_PCIE21: return "RP21";
120  case PCH_DEVFN_PCIE22: return "RP22";
121  case PCH_DEVFN_PCIE23: return "RP23";
122  case PCH_DEVFN_PCIE24: return "RP24";
123  case PCH_DEVFN_UART0: return "UAR0";
124  case PCH_DEVFN_UART1: return "UAR1";
125  case PCH_DEVFN_GSPI0: return "SPI0";
126  case PCH_DEVFN_GSPI1: return "SPI1";
127  case PCH_DEVFN_GSPI2: return "SPI2";
128  case PCH_DEVFN_EMMC: return "EMMC";
129  case PCH_DEVFN_SDCARD: return "SDXC";
130  case PCH_DEVFN_P2SB: return "P2SB";
131  case PCH_DEVFN_PMC: return "PMC_";
132  case PCH_DEVFN_HDA: return "HDAS";
133  case PCH_DEVFN_SMBUS: return "SBUS";
134  case PCH_DEVFN_SPI: return "FSPI";
135  case PCH_DEVFN_GBE: return "IGBE";
136  case PCH_DEVFN_TRACEHUB:return "THUB";
137  }
138 
139  return NULL;
140 }
141 #endif
142 
143 void soc_init_pre_device(void *chip_info)
144 {
145  /* Perform silicon specific init. */
147 
148  /* Display FIRMWARE_VERSION_INFO_HOB */
150 
152 
153  /* swap enabled PCI ports in device tree if needed */
154  if (CONFIG(SOC_INTEL_CANNONLAKE_PCH_H))
156  else
158 }
159 
160 static void cpu_fill_ssdt(const struct device *dev)
161 {
163 
164  if (!generate_pin_irq_map())
165  printk(BIOS_ERR, "Failed to generate ACPI _PRT table!\n");
166 }
167 
168 static void cpu_set_north_irqs(struct device *dev)
169 {
171 }
172 
173 static struct device_operations pci_domain_ops = {
175  .set_resources = &pci_domain_set_resources,
176  .scan_bus = &pci_domain_scan_bus,
177 #if CONFIG(HAVE_ACPI_TABLES)
178  .acpi_name = &soc_acpi_name,
179 #endif
180 };
181 
182 static struct device_operations cpu_bus_ops = {
184  .set_resources = noop_set_resources,
185  .enable_resources = cpu_set_north_irqs,
186 #if CONFIG(HAVE_ACPI_TABLES)
187  .acpi_fill_ssdt = cpu_fill_ssdt,
188 #endif
189 };
190 
191 static void soc_enable(struct device *dev)
192 {
193  /* Set the operations if it is a special bus type */
194  if (dev->path.type == DEVICE_PATH_DOMAIN)
195  dev->ops = &pci_domain_ops;
196  else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
197  dev->ops = &cpu_bus_ops;
198  else if (dev->path.type == DEVICE_PATH_GPIO)
199  block_gpio_enable(dev);
200  else if (dev->path.type == DEVICE_PATH_PCI &&
201  dev->path.pci.devfn == PCH_DEVFN_PMC)
202  dev->ops = &pmc_ops;
203 }
204 
206  CHIP_NAME("Intel Cannonlake")
207  .enable_dev = &soc_enable,
208  .init = &soc_init_pre_device,
209 };
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
@ CONFIG
Definition: dsi_common.h:201
void fsp_silicon_init(void)
Definition: silicon_init.c:242
void soc_gpio_pm_configuration(void)
Definition: gpio_common.c:11
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 BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
@ 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
void soc_init_pre_device(void *chip_info)
Definition: chip.c:137
#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_DEV_SLOT_PCIE_1
Definition: pci_devs.h:193
#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_DEV_SLOT_PCIE
Definition: pci_devs.h:175
#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
static void cpu_fill_ssdt(const struct device *dev)
Definition: chip.c:160
static const struct pcie_rp_group pch_lp_rp_groups[]
Definition: chip.c:20
static struct device_operations pci_domain_ops
Definition: chip.c:173
struct chip_operations soc_intel_cannonlake_ops
Definition: chip.c:205
static void soc_enable(struct device *dev)
Definition: chip.c:191
static void cpu_set_north_irqs(struct device *dev)
Definition: chip.c:168
static const struct pcie_rp_group pch_h_rp_groups[]
Definition: chip.c:26
#define PCH_DEVFN_PCIE15
Definition: pci_devs.h:138
#define PCH_DEVFN_PCIE20
Definition: pci_devs.h:153
#define PCH_DEV_SLOT_PCIE_2
Definition: pci_devs.h:149
#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
struct device_operations pmc_ops
Definition: pmc.c:190
#define NULL
Definition: stddef.h:19
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 slot
Definition: pcie_rp.h:84
unsigned int port_type
Definition: path.h:101
unsigned int port_id
Definition: path.h:102