1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/device.h>
4 #include <device/pci.h>
8 #include <intelblocks/acpi.h>
9 #include <intelblocks/cfg.h>
10 #include <intelblocks/irq.h>
11 #include <intelblocks/itss.h>
12 #include <intelblocks/pcie_rp.h>
13 #include <intelblocks/systemagent.h>
14 #include <intelblocks/xdci.h>
15 #include <soc/intel/common/vbt.h>
16 #include <soc/pci_devs.h>
17 #include <soc/ramstage.h>
18 #include <soc/soc_chip.h>
20 #if CONFIG(HAVE_ACPI_TABLES)
21 const char *soc_acpi_name(const struct device
*dev
)
23 if (dev
->path
.type
== DEVICE_PATH_DOMAIN
)
26 if (dev
->path
.type
== DEVICE_PATH_USB
) {
27 switch (dev
->path
.usb
.port_type
) {
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";
45 case 10: return "HS11";
46 case 11: return "HS12";
47 case 12: return "HS13";
48 case 13: return "HS14";
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";
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";
70 if (dev
->path
.type
!= DEVICE_PATH_PCI
)
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_IGD
: return "GFX0";
80 case SA_DEVFN_TCSS_XHCI
: return "TXHC";
81 case SA_DEVFN_TCSS_XDCI
: return "TXDC";
82 case SA_DEVFN_TCSS_DMA0
: return "TDM0";
83 case SA_DEVFN_TCSS_DMA1
: return "TDM1";
84 case SA_DEVFN_TBT0
: return "TRP0";
85 case SA_DEVFN_TBT1
: return "TRP1";
86 case SA_DEVFN_TBT2
: return "TRP2";
87 case SA_DEVFN_TBT3
: return "TRP3";
88 case SA_DEVFN_IPU
: return "IPU0";
89 case SA_DEVFN_GNA
: return "GNA";
90 case SA_DEVFN_DPTF
: return "TCPU";
91 case PCH_DEVFN_ISH
: return "ISHB";
92 case PCH_DEVFN_XHCI
: return "XHCI";
93 case PCH_DEVFN_I2C0
: return "I2C0";
94 case PCH_DEVFN_I2C1
: return "I2C1";
95 case PCH_DEVFN_I2C2
: return "I2C2";
96 case PCH_DEVFN_I2C3
: return "I2C3";
97 case PCH_DEVFN_I2C4
: return "I2C4";
98 case PCH_DEVFN_I2C5
: return "I2C5";
99 case PCH_DEVFN_SATA
: return "SATA";
100 case PCH_DEVFN_PCIE1
: return "RP01";
101 case PCH_DEVFN_PCIE2
: return "RP02";
102 case PCH_DEVFN_PCIE3
: return "RP03";
103 case PCH_DEVFN_PCIE4
: return "RP04";
104 case PCH_DEVFN_PCIE5
: return "RP05";
105 case PCH_DEVFN_PCIE6
: return "RP06";
106 case PCH_DEVFN_PCIE7
: return "RP07";
107 case PCH_DEVFN_PCIE8
: return "RP08";
108 case PCH_DEVFN_PCIE9
: return "RP09";
109 case PCH_DEVFN_PCIE10
: return "RP10";
110 case PCH_DEVFN_PCIE11
: return "RP11";
111 case PCH_DEVFN_PCIE12
: return "RP12";
112 case PCH_DEVFN_PCIE13
: return "RP13";
113 case PCH_DEVFN_PCIE14
: return "RP14";
114 case PCH_DEVFN_PCIE15
: return "RP15";
115 case PCH_DEVFN_PCIE16
: return "RP16";
116 case PCH_DEVFN_PCIE17
: return "RP17";
117 case PCH_DEVFN_PCIE18
: return "RP18";
118 case PCH_DEVFN_PCIE19
: return "RP19";
119 case PCH_DEVFN_PCIE20
: return "RP20";
120 case PCH_DEVFN_PCIE21
: return "RP21";
121 case PCH_DEVFN_PCIE22
: return "RP22";
122 case PCH_DEVFN_PCIE23
: return "RP23";
123 case PCH_DEVFN_PCIE24
: return "RP24";
124 case PCH_DEVFN_PMC
: return "PMC";
125 case PCH_DEVFN_UART0
: return "UAR0";
126 case PCH_DEVFN_UART1
: return "UAR1";
127 case PCH_DEVFN_UART2
: return "UAR2";
128 case PCH_DEVFN_GSPI0
: return "SPI0";
129 case PCH_DEVFN_GSPI1
: return "SPI1";
130 case PCH_DEVFN_GSPI2
: return "SPI2";
131 case PCH_DEVFN_GSPI3
: return "SPI3";
132 case PCH_DEVFN_ESPI
: return "LPCB";
133 case PCH_DEVFN_HDA
: return "HDAS";
134 case PCH_DEVFN_SMBUS
: return "SBUS";
135 case PCH_DEVFN_GBE
: return "GLAN";
136 case PCH_DEVFN_SRAM
: return "SRAM";
137 case PCH_DEVFN_SPI
: return "FSPI";
138 case PCH_DEVFN_CSE
: return "HEC1";
145 /* SoC routine to fill GPIO PM mask and value for GPIO_MISCCFG register */
146 static void soc_fill_gpio_pm_configuration(void)
148 uint8_t value
[TOTAL_GPIO_COMM
];
149 const config_t
*config
= config_of_soc();
151 if (config
->gpio_override_pm
)
152 memcpy(value
, config
->gpio_pm
, sizeof(value
));
154 memset(value
, MISCCFG_GPIO_PM_CONFIG_BITS
, sizeof(value
));
156 gpio_pm_configure(value
, TOTAL_GPIO_COMM
);
159 void soc_init_pre_device(void *chip_info
)
161 /* Perform silicon specific init. */
164 /* Display FIRMWARE_VERSION_INFO_HOB */
165 fsp_display_fvi_version_hob();
167 soc_fill_gpio_pm_configuration();
169 /* Swap enabled PCI ports in device tree if needed. */
170 const struct pcie_rp_group
*pch_rp_groups
= soc_get_pch_rp_groups();
171 pcie_rp_update_devicetree(pch_rp_groups
);
174 static void cpu_fill_ssdt(const struct device
*dev
)
176 if (!generate_pin_irq_map())
177 printk(BIOS_ERR
, "Failed to generate ACPI _PRT table!\n");
179 generate_cpu_entries(dev
);
182 static void cpu_set_north_irqs(struct device
*dev
)
184 irq_program_non_pch();
187 static struct device_operations pci_domain_ops
= {
188 .read_resources
= &pci_domain_read_resources
,
189 .set_resources
= &pci_domain_set_resources
,
190 .scan_bus
= &pci_host_bridge_scan_bus
,
191 #if CONFIG(HAVE_ACPI_TABLES)
192 .acpi_name
= &soc_acpi_name
,
193 .acpi_fill_ssdt
= ssdt_set_above_4g_pci
,
197 static struct device_operations cpu_bus_ops
= {
198 .read_resources
= noop_read_resources
,
199 .set_resources
= noop_set_resources
,
200 .enable_resources
= cpu_set_north_irqs
,
201 #if CONFIG(HAVE_ACPI_TABLES)
202 .acpi_fill_ssdt
= cpu_fill_ssdt
,
206 static void soc_enable(struct device
*dev
)
209 * Set the operations if it is a special bus type or a hidden PCI
212 if (dev
->path
.type
== DEVICE_PATH_DOMAIN
)
213 dev
->ops
= &pci_domain_ops
;
214 else if (dev
->path
.type
== DEVICE_PATH_CPU_CLUSTER
)
215 dev
->ops
= &cpu_bus_ops
;
216 else if (dev
->path
.type
== DEVICE_PATH_PCI
&&
217 dev
->path
.pci
.devfn
== PCH_DEVFN_PMC
)
219 else if (dev
->path
.type
== DEVICE_PATH_GPIO
)
220 block_gpio_enable(dev
);
223 struct chip_operations soc_intel_tigerlake_ops
= {
224 .name
= "Intel Tigerlake",
225 .enable_dev
= &soc_enable
,
226 .init
= &soc_init_pre_device
,