blob: dc54845600677647b9fbd62e4ee5377ec54e7490 [file] [log] [blame]
Subrata Banik2871e0e2020-09-27 11:30:58 +05301/* 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>
Michael Niewöhner8913b782020-12-11 22:13:44 +01009#include <intelblocks/gpio.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053010#include <intelblocks/itss.h>
11#include <intelblocks/pcie_rp.h>
12#include <intelblocks/xdci.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053013#include <soc/intel/common/vbt.h>
14#include <soc/itss.h>
15#include <soc/pci_devs.h>
Eric Laif8248f32020-12-31 11:43:29 +080016#include <soc/pcie.h>
Subrata Banik2871e0e2020-09-27 11:30:58 +053017#include <soc/ramstage.h>
18#include <soc/soc_chip.h>
19
Subrata Banik2871e0e2020-09-27 11:30:58 +053020#if CONFIG(HAVE_ACPI_TABLES)
21const char *soc_acpi_name(const struct device *dev)
22{
23 if (dev->path.type == DEVICE_PATH_DOMAIN)
24 return "PCI0";
25
26 if (dev->path.type == DEVICE_PATH_USB) {
27 switch (dev->path.usb.port_type) {
28 case 0:
29 /* Root Hub */
30 return "RHUB";
31 case 2:
32 /* USB2 ports */
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";
44 }
45 break;
46 case 3:
47 /* USB3 ports */
48 switch (dev->path.usb.port_id) {
49 case 0: return "SS01";
50 case 1: return "SS02";
51 case 2: return "SS03";
52 case 3: return "SS04";
53 }
54 break;
55 }
56 return NULL;
57 }
58 if (dev->path.type != DEVICE_PATH_PCI)
59 return NULL;
60
61 switch (dev->path.pci.devfn) {
62 case SA_DEVFN_ROOT: return "MCHC";
63 case SA_DEVFN_TCSS_XHCI: return "TXHC";
64 case SA_DEVFN_TCSS_XDCI: return "TXDC";
65 case SA_DEVFN_TCSS_DMA0: return "TDM0";
66 case SA_DEVFN_TCSS_DMA1: return "TDM1";
67 case SA_DEVFN_TBT0: return "TRP0";
68 case SA_DEVFN_TBT1: return "TRP1";
69 case SA_DEVFN_TBT2: return "TRP2";
70 case SA_DEVFN_TBT3: return "TRP3";
71 case SA_DEVFN_IPU: return "IPU0";
72 case PCH_DEVFN_ISH: return "ISHB";
73 case PCH_DEVFN_XHCI: return "XHCI";
74 case PCH_DEVFN_I2C0: return "I2C0";
75 case PCH_DEVFN_I2C1: return "I2C1";
76 case PCH_DEVFN_I2C2: return "I2C2";
77 case PCH_DEVFN_I2C3: return "I2C3";
78 case PCH_DEVFN_I2C4: return "I2C4";
79 case PCH_DEVFN_I2C5: return "I2C5";
80 case PCH_DEVFN_SATA: return "SATA";
81 case PCH_DEVFN_PCIE1: return "RP01";
82 case PCH_DEVFN_PCIE2: return "RP02";
83 case PCH_DEVFN_PCIE3: return "RP03";
84 case PCH_DEVFN_PCIE4: return "RP04";
85 case PCH_DEVFN_PCIE5: return "RP05";
86 case PCH_DEVFN_PCIE6: return "RP06";
87 case PCH_DEVFN_PCIE7: return "RP07";
88 case PCH_DEVFN_PCIE8: return "RP08";
89 case PCH_DEVFN_PCIE9: return "RP09";
90 case PCH_DEVFN_PCIE10: return "RP10";
91 case PCH_DEVFN_PCIE11: return "RP11";
92 case PCH_DEVFN_PCIE12: return "RP12";
93 case PCH_DEVFN_PMC: return "PMC";
94 case PCH_DEVFN_UART0: return "UAR0";
95 case PCH_DEVFN_UART1: return "UAR1";
96 case PCH_DEVFN_UART2: return "UAR2";
97 case PCH_DEVFN_GSPI0: return "SPI0";
98 case PCH_DEVFN_GSPI1: return "SPI1";
99 case PCH_DEVFN_GSPI2: return "SPI2";
100 case PCH_DEVFN_GSPI3: return "SPI3";
101 /* Keeping ACPI device name coherent with ec.asl */
102 case PCH_DEVFN_ESPI: return "LPCB";
103 case PCH_DEVFN_HDA: return "HDAS";
104 case PCH_DEVFN_SMBUS: return "SBUS";
105 case PCH_DEVFN_GBE: return "GLAN";
106 }
107
108 return NULL;
109}
110#endif
111
112/* SoC routine to fill GPIO PM mask and value for GPIO_MISCCFG register */
113static void soc_fill_gpio_pm_configuration(void)
114{
115 uint8_t value[TOTAL_GPIO_COMM];
116 const config_t *config = config_of_soc();
117
118 if (config->gpio_override_pm)
119 memcpy(value, config->gpio_pm, sizeof(uint8_t) *
120 TOTAL_GPIO_COMM);
121 else
Subrata Banik2ccc0a42021-03-25 20:01:47 +0530122 memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(uint8_t) *
Subrata Banik2871e0e2020-09-27 11:30:58 +0530123 TOTAL_GPIO_COMM);
124
125 gpio_pm_configure(value, TOTAL_GPIO_COMM);
126}
127
128void soc_init_pre_device(void *chip_info)
129{
Subrata Banik2871e0e2020-09-27 11:30:58 +0530130 /* Perform silicon specific init. */
Kyösti Mälkkicc93c6e2021-01-09 22:53:52 +0200131 fsp_silicon_init();
Subrata Banik2871e0e2020-09-27 11:30:58 +0530132
133 /* Display FIRMWARE_VERSION_INFO_HOB */
134 fsp_display_fvi_version_hob();
135
Subrata Banik2871e0e2020-09-27 11:30:58 +0530136 soc_fill_gpio_pm_configuration();
137
138 /* Swap enabled PCI ports in device tree if needed. */
Eric Laif8248f32020-12-31 11:43:29 +0800139 pcie_rp_update_devicetree(get_pch_pcie_rp_table());
Subrata Banik2871e0e2020-09-27 11:30:58 +0530140}
141
142static struct device_operations pci_domain_ops = {
143 .read_resources = &pci_domain_read_resources,
144 .set_resources = &pci_domain_set_resources,
145 .scan_bus = &pci_domain_scan_bus,
146#if CONFIG(HAVE_ACPI_TABLES)
147 .acpi_name = &soc_acpi_name,
148#endif
149};
150
151static struct device_operations cpu_bus_ops = {
152 .read_resources = noop_read_resources,
153 .set_resources = noop_set_resources,
154#if CONFIG(HAVE_ACPI_TABLES)
155 .acpi_fill_ssdt = generate_cpu_entries,
156#endif
157};
158
159static void soc_enable(struct device *dev)
160{
161 /*
162 * Set the operations if it is a special bus type or a hidden PCI
163 * device.
164 */
165 if (dev->path.type == DEVICE_PATH_DOMAIN)
166 dev->ops = &pci_domain_ops;
167 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
168 dev->ops = &cpu_bus_ops;
169 else if (dev->path.type == DEVICE_PATH_PCI &&
170 dev->path.pci.devfn == PCH_DEVFN_PMC)
171 dev->ops = &pmc_ops;
Michael Niewöhner8913b782020-12-11 22:13:44 +0100172 else if (dev->path.type == DEVICE_PATH_GPIO)
173 block_gpio_enable(dev);
Subrata Banik2871e0e2020-09-27 11:30:58 +0530174}
175
176struct chip_operations soc_intel_alderlake_ops = {
177 CHIP_NAME("Intel Alderlake")
178 .enable_dev = &soc_enable,
179 .init = &soc_init_pre_device,
180};