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/pcie_rp.h>
12 #include <intelblocks/xdci.h>
13 #include <soc/intel/common/vbt.h>
14 #include <soc/itss.h>
15 #include <soc/pci_devs.h>
16 #include <soc/ramstage.h>
17 #include <soc/soc_chip.h>
18 
19 static const struct pcie_rp_group pch_rp_groups[] = {
20  { .slot = PCH_DEV_SLOT_PCIE, .count = 8, .lcap_port_base = 1 },
21  { 0 }
22 };
23 
24 #if CONFIG(HAVE_ACPI_TABLES)
25 const char *soc_acpi_name(const struct device *dev)
26 {
27  if (dev->path.type == DEVICE_PATH_DOMAIN)
28  return "PCI0";
29 
30  if (dev->path.type == DEVICE_PATH_USB) {
31  switch (dev->path.usb.port_type) {
32  case 0:
33  /* Root Hub */
34  return "RHUB";
35  case 2:
36  /* USB2 ports */
37  switch (dev->path.usb.port_id) {
38  case 0: return "HS01";
39  case 1: return "HS02";
40  case 2: return "HS03";
41  case 3: return "HS04";
42  case 4: return "HS05";
43  case 5: return "HS06";
44  case 6: return "HS07";
45  case 7: return "HS08";
46  case 8: return "HS09";
47  case 9: return "HS10";
48  }
49  break;
50  case 3:
51  /* USB3 ports */
52  switch (dev->path.usb.port_id) {
53  case 0: return "SS01";
54  case 1: return "SS02";
55  case 2: return "SS03";
56  case 3: return "SS04";
57  }
58  break;
59  }
60  return NULL;
61  }
62  if (dev->path.type != DEVICE_PATH_PCI)
63  return NULL;
64 
65  switch (dev->path.pci.devfn) {
66  case SA_DEVFN_ROOT: return "MCHC";
67  case SA_DEVFN_IPU: return "IPU0";
68  case PCH_DEVFN_ISH: return "ISHB";
69  case PCH_DEVFN_XHCI: return "XHCI";
70  case PCH_DEVFN_I2C0: return "I2C0";
71  case PCH_DEVFN_I2C1: return "I2C1";
72  case PCH_DEVFN_I2C2: return "I2C2";
73  case PCH_DEVFN_I2C3: return "I2C3";
74  case PCH_DEVFN_I2C4: return "I2C4";
75  case PCH_DEVFN_I2C5: return "I2C5";
76  case PCH_DEVFN_SATA: return "SATA";
77  case PCH_DEVFN_PCIE1: return "RP01";
78  case PCH_DEVFN_PCIE2: return "RP02";
79  case PCH_DEVFN_PCIE3: return "RP03";
80  case PCH_DEVFN_PCIE4: return "RP04";
81  case PCH_DEVFN_PCIE5: return "RP05";
82  case PCH_DEVFN_PCIE6: return "RP06";
83  case PCH_DEVFN_PCIE7: return "RP07";
84  case PCH_DEVFN_PCIE8: return "RP08";
85  case PCH_DEVFN_PCIE9: return "RP09";
86  case PCH_DEVFN_PCIE10: return "RP10";
87  case PCH_DEVFN_PCIE11: return "RP11";
88  case PCH_DEVFN_PCIE12: return "RP12";
89  case PCH_DEVFN_UART0: return "UAR0";
90  case PCH_DEVFN_UART1: return "UAR1";
91  case PCH_DEVFN_UART2: return "UAR2";
92  case PCH_DEVFN_GSPI0: return "SPI0";
93  case PCH_DEVFN_GSPI1: return "SPI1";
94  case PCH_DEVFN_GSPI2: return "SPI2";
95  case PCH_DEVFN_GSPI3: return "SPI3";
96  case PCH_DEVFN_EMMC: return "EMMC";
97  case PCH_DEVFN_SDCARD: return "SDXC";
98  case PCH_DEVFN_HDA: return "HDAS";
99  case PCH_DEVFN_SMBUS: return "SBUS";
100  case PCH_DEVFN_GBE: return "GLAN";
101  }
102 
103  return NULL;
104 }
105 #endif
106 
107 /* SoC routine to fill GPIO PM mask and value for GPIO_MISCCFG register */
109 {
111  const config_t *config = config_of_soc();
112 
113  if (config->gpio_override_pm)
114  memcpy(value, config->gpio_pm, sizeof(value));
115  else
117 
119 }
120 
121 void soc_init_pre_device(void *chip_info)
122 {
123  /* Perform silicon specific init. */
125 
126  /* Display FIRMWARE_VERSION_INFO_HOB */
128 
130 
131  /* swap enabled PCI ports in device tree if needed */
133 }
134 
135 static struct device_operations pci_domain_ops = {
137  .set_resources = &pci_domain_set_resources,
138  .scan_bus = &pci_domain_scan_bus,
139 #if CONFIG(HAVE_ACPI_TABLES)
140  .acpi_name = &soc_acpi_name,
141 #endif
142 };
143 
144 static struct device_operations cpu_bus_ops = {
146  .set_resources = noop_set_resources,
147 #if CONFIG(HAVE_ACPI_TABLES)
148  .acpi_fill_ssdt = generate_cpu_entries,
149 #endif
150 };
151 
152 extern struct device_operations pmc_ops;
153 static void soc_enable(struct device *dev)
154 {
155  /* Set the operations if it is a special bus type */
156  if (dev->path.type == DEVICE_PATH_DOMAIN)
157  dev->ops = &pci_domain_ops;
158  else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
159  dev->ops = &cpu_bus_ops;
160  else if (dev->path.type == DEVICE_PATH_PCI &&
161  dev->path.pci.devfn == PCH_DEVFN_PMC)
162  dev->ops = &pmc_ops;
163  else if (dev->path.type == DEVICE_PATH_GPIO)
164  block_gpio_enable(dev);
165 }
166 
168  CHIP_NAME("Intel Jasperlake")
169  .enable_dev = &soc_enable,
170  .init = &soc_init_pre_device,
171 };
#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
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
@ 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 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 PCH_DEVFN_SATA
Definition: pci_devs.h:158
#define PCH_DEVFN_UART1
Definition: pci_devs.h:205
#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 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_SDCARD
Definition: pci_devs.h:144
#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
static const struct pcie_rp_group pch_rp_groups[]
Definition: chip.c:19
static struct device_operations pci_domain_ops
Definition: chip.c:135
static void soc_fill_gpio_pm_configuration(void)
Definition: chip.c:108
struct chip_operations soc_intel_jasperlake_ops
Definition: chip.c:167
static void soc_enable(struct device *dev)
Definition: chip.c:153
#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 slot
Definition: pcie_rp.h:84
unsigned int port_type
Definition: path.h:101
unsigned int port_id
Definition: path.h:102