blob: d3c3c62761cd8f101cd59a191c5f999087c92bb5 [file] [log] [blame]
Angel Pons16f6aa82020-04-05 15:47:21 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Subrata Banik91e89c52019-11-01 18:30:01 +05302
Tim Wawrzynczak6d20d0c2020-05-13 17:00:33 -06003#include <console/console.h>
Subrata Banik91e89c52019-11-01 18:30:01 +05304#include <device/device.h>
5#include <device/pci.h>
6#include <fsp/api.h>
7#include <fsp/util.h>
8#include <intelblocks/acpi.h>
9#include <intelblocks/cfg.h>
10#include <intelblocks/itss.h>
Caveh Jalali7eaac6c2020-07-24 21:57:10 -070011#include <intelblocks/pcie_rp.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053012#include <intelblocks/xdci.h>
13#include <romstage_handoff.h>
14#include <soc/intel/common/vbt.h>
15#include <soc/itss.h>
16#include <soc/pci_devs.h>
17#include <soc/ramstage.h>
18#include <soc/soc_chip.h>
19
Caveh Jalali7eaac6c2020-07-24 21:57:10 -070020static const struct pcie_rp_group pch_lp_rp_groups[] = {
21 { .slot = PCH_DEV_SLOT_PCIE, .count = 8 },
22 { .slot = PCH_DEV_SLOT_PCIE_1, .count = 4 },
23 { 0 }
24};
25
Subrata Banik91e89c52019-11-01 18:30:01 +053026#if CONFIG(HAVE_ACPI_TABLES)
27const char *soc_acpi_name(const struct device *dev)
28{
29 if (dev->path.type == DEVICE_PATH_DOMAIN)
30 return "PCI0";
31
Ravi Sarawadi2fd49722019-12-16 23:41:36 -080032 if (dev->path.type == DEVICE_PATH_USB) {
33 switch (dev->path.usb.port_type) {
34 case 0:
35 /* Root Hub */
36 return "RHUB";
37 case 2:
38 /* USB2 ports */
39 switch (dev->path.usb.port_id) {
40 case 0: return "HS01";
41 case 1: return "HS02";
42 case 2: return "HS03";
43 case 3: return "HS04";
44 case 4: return "HS05";
45 case 5: return "HS06";
46 case 6: return "HS07";
47 case 7: return "HS08";
48 case 8: return "HS09";
49 case 9: return "HS10";
50 }
51 break;
52 case 3:
53 /* USB3 ports */
54 switch (dev->path.usb.port_id) {
55 case 0: return "SS01";
56 case 1: return "SS02";
57 case 2: return "SS03";
58 case 3: return "SS04";
59 }
60 break;
61 }
62 return NULL;
63 }
Subrata Banik91e89c52019-11-01 18:30:01 +053064 if (dev->path.type != DEVICE_PATH_PCI)
65 return NULL;
66
67 switch (dev->path.pci.devfn) {
Duncan Laurie32585de2020-05-18 13:21:44 -070068 case SA_DEVFN_ROOT: return "MCHC";
69 case SA_DEVFN_TCSS_XHCI: return "TXHC";
70 case SA_DEVFN_TCSS_XDCI: return "TXDC";
71 case SA_DEVFN_TCSS_DMA0: return "TDM0";
72 case SA_DEVFN_TCSS_DMA1: return "TDM1";
73 case SA_DEVFN_TBT0: return "TRP0";
74 case SA_DEVFN_TBT1: return "TRP1";
75 case SA_DEVFN_TBT2: return "TRP2";
76 case SA_DEVFN_TBT3: return "TRP3";
Tim Wawrzynczak4b748142020-06-29 12:34:55 -060077 case SA_DEVFN_IPU: return "IPU0";
Duncan Laurie32585de2020-05-18 13:21:44 -070078 case PCH_DEVFN_ISH: return "ISHB";
79 case PCH_DEVFN_XHCI: return "XHCI";
80 case PCH_DEVFN_I2C0: return "I2C0";
81 case PCH_DEVFN_I2C1: return "I2C1";
82 case PCH_DEVFN_I2C2: return "I2C2";
83 case PCH_DEVFN_I2C3: return "I2C3";
84 case PCH_DEVFN_I2C4: return "I2C4";
85 case PCH_DEVFN_I2C5: return "I2C5";
86 case PCH_DEVFN_SATA: return "SATA";
87 case PCH_DEVFN_PCIE1: return "RP01";
88 case PCH_DEVFN_PCIE2: return "RP02";
89 case PCH_DEVFN_PCIE3: return "RP03";
90 case PCH_DEVFN_PCIE4: return "RP04";
91 case PCH_DEVFN_PCIE5: return "RP05";
92 case PCH_DEVFN_PCIE6: return "RP06";
93 case PCH_DEVFN_PCIE7: return "RP07";
94 case PCH_DEVFN_PCIE8: return "RP08";
95 case PCH_DEVFN_PCIE9: return "RP09";
96 case PCH_DEVFN_PCIE10: return "RP10";
97 case PCH_DEVFN_PCIE11: return "RP11";
98 case PCH_DEVFN_PCIE12: return "RP12";
99 case PCH_DEVFN_PMC: return "PMC";
100 case PCH_DEVFN_UART0: return "UAR0";
101 case PCH_DEVFN_UART1: return "UAR1";
102 case PCH_DEVFN_UART2: return "UAR2";
103 case PCH_DEVFN_GSPI0: return "SPI0";
104 case PCH_DEVFN_GSPI1: return "SPI1";
105 case PCH_DEVFN_GSPI2: return "SPI2";
106 case PCH_DEVFN_GSPI3: return "SPI3";
Subrata Banik91e89c52019-11-01 18:30:01 +0530107 /* Keeping ACPI device name coherent with ec.asl */
Duncan Laurie32585de2020-05-18 13:21:44 -0700108 case PCH_DEVFN_ESPI: return "LPCB";
109 case PCH_DEVFN_HDA: return "HDAS";
110 case PCH_DEVFN_SMBUS: return "SBUS";
111 case PCH_DEVFN_GBE: return "GLAN";
Subrata Banik91e89c52019-11-01 18:30:01 +0530112 }
113
114 return NULL;
115}
116#endif
117
118/* SoC rotine to fill GPIO PM mask and value for GPIO_MISCCFG register */
119static void soc_fill_gpio_pm_configuration(void)
120{
121 uint8_t value[TOTAL_GPIO_COMM];
122 const config_t *config = config_of_soc();
123
124 if (config->gpio_override_pm)
125 memcpy(value, config->gpio_pm, sizeof(uint8_t) *
126 TOTAL_GPIO_COMM);
127 else
128 memset(value, MISCCFG_ENABLE_GPIO_PM_CONFIG, sizeof(uint8_t) *
129 TOTAL_GPIO_COMM);
130
131 gpio_pm_configure(value, TOTAL_GPIO_COMM);
132}
133
134void soc_init_pre_device(void *chip_info)
135{
136 /* Snapshot the current GPIO IRQ polarities. FSP is setting a
137 * default policy that doesn't honor boards' requirements. */
138 itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
139
140 /* Perform silicon specific init. */
141 fsp_silicon_init(romstage_handoff_is_resume());
142
143 /* Display FIRMWARE_VERSION_INFO_HOB */
144 fsp_display_fvi_version_hob();
145
146 /* Restore GPIO IRQ polarities back to previous settings. */
147 itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
148
149 soc_fill_gpio_pm_configuration();
Caveh Jalali7eaac6c2020-07-24 21:57:10 -0700150
151 /* Swap enabled PCI ports in device tree if needed. */
152 pcie_rp_update_devicetree(pch_lp_rp_groups);
Subrata Banik91e89c52019-11-01 18:30:01 +0530153}
154
Subrata Banik91e89c52019-11-01 18:30:01 +0530155static struct device_operations pci_domain_ops = {
156 .read_resources = &pci_domain_read_resources,
157 .set_resources = &pci_domain_set_resources,
158 .scan_bus = &pci_domain_scan_bus,
Ravi Sarawadi2fd49722019-12-16 23:41:36 -0800159#if CONFIG(HAVE_ACPI_TABLES)
Subrata Banik91e89c52019-11-01 18:30:01 +0530160 .acpi_name = &soc_acpi_name,
Ravi Sarawadi2fd49722019-12-16 23:41:36 -0800161#endif
Subrata Banik91e89c52019-11-01 18:30:01 +0530162};
163
164static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +0200165 .read_resources = noop_read_resources,
166 .set_resources = noop_set_resources,
Karthikeyan Ramasubramanian0e971e12020-01-09 11:32:16 -0700167#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +0200168 .acpi_fill_ssdt = generate_cpu_entries,
Karthikeyan Ramasubramanian0e971e12020-01-09 11:32:16 -0700169#endif
Subrata Banik91e89c52019-11-01 18:30:01 +0530170};
171
172static void soc_enable(struct device *dev)
173{
Tim Wawrzynczak6d20d0c2020-05-13 17:00:33 -0600174 /*
175 * Set the operations if it is a special bus type or a hidden PCI
176 * device.
177 */
Subrata Banik91e89c52019-11-01 18:30:01 +0530178 if (dev->path.type == DEVICE_PATH_DOMAIN)
179 dev->ops = &pci_domain_ops;
180 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
181 dev->ops = &cpu_bus_ops;
Tim Wawrzynczak6d20d0c2020-05-13 17:00:33 -0600182 else if (dev->path.type == DEVICE_PATH_PCI &&
183 dev->path.pci.devfn == PCH_DEVFN_PMC)
184 dev->ops = &pmc_ops;
Subrata Banik91e89c52019-11-01 18:30:01 +0530185}
186
187struct chip_operations soc_intel_tigerlake_ops = {
188 CHIP_NAME("Intel Tigerlake")
189 .enable_dev = &soc_enable,
190 .init = &soc_init_pre_device,
191};