blob: a923074acc0e1571520119d3bfafe6ccdb98ac17 [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>
11#include <intelblocks/xdci.h>
12#include <romstage_handoff.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#if CONFIG(HAVE_ACPI_TABLES)
20const char *soc_acpi_name(const struct device *dev)
21{
22 if (dev->path.type == DEVICE_PATH_DOMAIN)
23 return "PCI0";
24
Ravi Sarawadi2fd49722019-12-16 23:41:36 -080025 if (dev->path.type == DEVICE_PATH_USB) {
26 switch (dev->path.usb.port_type) {
27 case 0:
28 /* Root Hub */
29 return "RHUB";
30 case 2:
31 /* USB2 ports */
32 switch (dev->path.usb.port_id) {
33 case 0: return "HS01";
34 case 1: return "HS02";
35 case 2: return "HS03";
36 case 3: return "HS04";
37 case 4: return "HS05";
38 case 5: return "HS06";
39 case 6: return "HS07";
40 case 7: return "HS08";
41 case 8: return "HS09";
42 case 9: return "HS10";
43 }
44 break;
45 case 3:
46 /* USB3 ports */
47 switch (dev->path.usb.port_id) {
48 case 0: return "SS01";
49 case 1: return "SS02";
50 case 2: return "SS03";
51 case 3: return "SS04";
52 }
53 break;
54 }
55 return NULL;
56 }
Subrata Banik91e89c52019-11-01 18:30:01 +053057 if (dev->path.type != DEVICE_PATH_PCI)
58 return NULL;
59
60 switch (dev->path.pci.devfn) {
61 case SA_DEVFN_ROOT: return "MCHC";
li feng2cf9d382020-03-12 16:09:53 -070062 case PCH_DEVFN_ISH: return "ISHB";
Subrata Banik91e89c52019-11-01 18:30:01 +053063 case PCH_DEVFN_XHCI: return "XHCI";
Subrata Banik91e89c52019-11-01 18:30:01 +053064 case PCH_DEVFN_I2C0: return "I2C0";
65 case PCH_DEVFN_I2C1: return "I2C1";
66 case PCH_DEVFN_I2C2: return "I2C2";
67 case PCH_DEVFN_I2C3: return "I2C3";
Subrata Banik91e89c52019-11-01 18:30:01 +053068 case PCH_DEVFN_I2C4: return "I2C4";
69 case PCH_DEVFN_I2C5: return "I2C5";
Ravi Sarawadi2fd49722019-12-16 23:41:36 -080070 case PCH_DEVFN_SATA: return "SATA";
Subrata Banik91e89c52019-11-01 18:30:01 +053071 case PCH_DEVFN_PCIE1: return "RP01";
72 case PCH_DEVFN_PCIE2: return "RP02";
73 case PCH_DEVFN_PCIE3: return "RP03";
74 case PCH_DEVFN_PCIE4: return "RP04";
75 case PCH_DEVFN_PCIE5: return "RP05";
76 case PCH_DEVFN_PCIE6: return "RP06";
77 case PCH_DEVFN_PCIE7: return "RP07";
78 case PCH_DEVFN_PCIE8: return "RP08";
79 case PCH_DEVFN_PCIE9: return "RP09";
80 case PCH_DEVFN_PCIE10: return "RP10";
81 case PCH_DEVFN_PCIE11: return "RP11";
82 case PCH_DEVFN_PCIE12: return "RP12";
John Zhaoad2d73b2020-05-05 13:08:21 -070083 case PCH_DEVFN_PMC: return "PMC";
Subrata Banik91e89c52019-11-01 18:30:01 +053084 case PCH_DEVFN_UART0: return "UAR0";
85 case PCH_DEVFN_UART1: return "UAR1";
Ravi Sarawadi2fd49722019-12-16 23:41:36 -080086 case PCH_DEVFN_UART2: return "UAR2";
Subrata Banik91e89c52019-11-01 18:30:01 +053087 case PCH_DEVFN_GSPI0: return "SPI0";
88 case PCH_DEVFN_GSPI1: return "SPI1";
89 case PCH_DEVFN_GSPI2: return "SPI2";
Wonkyu Kim69855f22020-01-09 23:34:03 -080090 case PCH_DEVFN_GSPI3: return "SPI3";
Subrata Banik91e89c52019-11-01 18:30:01 +053091 /* Keeping ACPI device name coherent with ec.asl */
92 case PCH_DEVFN_ESPI: return "LPCB";
Subrata Banik91e89c52019-11-01 18:30:01 +053093 case PCH_DEVFN_HDA: return "HDAS";
94 case PCH_DEVFN_SMBUS: return "SBUS";
Ravi Sarawadi2fd49722019-12-16 23:41:36 -080095 case PCH_DEVFN_GBE: return "GLAN";
Subrata Banik91e89c52019-11-01 18:30:01 +053096 }
97
98 return NULL;
99}
100#endif
101
102/* SoC rotine to fill GPIO PM mask and value for GPIO_MISCCFG register */
103static void soc_fill_gpio_pm_configuration(void)
104{
105 uint8_t value[TOTAL_GPIO_COMM];
106 const config_t *config = config_of_soc();
107
108 if (config->gpio_override_pm)
109 memcpy(value, config->gpio_pm, sizeof(uint8_t) *
110 TOTAL_GPIO_COMM);
111 else
112 memset(value, MISCCFG_ENABLE_GPIO_PM_CONFIG, sizeof(uint8_t) *
113 TOTAL_GPIO_COMM);
114
115 gpio_pm_configure(value, TOTAL_GPIO_COMM);
116}
117
118void soc_init_pre_device(void *chip_info)
119{
120 /* Snapshot the current GPIO IRQ polarities. FSP is setting a
121 * default policy that doesn't honor boards' requirements. */
122 itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
123
124 /* Perform silicon specific init. */
125 fsp_silicon_init(romstage_handoff_is_resume());
126
127 /* Display FIRMWARE_VERSION_INFO_HOB */
128 fsp_display_fvi_version_hob();
129
130 /* Restore GPIO IRQ polarities back to previous settings. */
131 itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
132
133 soc_fill_gpio_pm_configuration();
134}
135
Subrata Banik91e89c52019-11-01 18:30:01 +0530136static struct device_operations pci_domain_ops = {
137 .read_resources = &pci_domain_read_resources,
138 .set_resources = &pci_domain_set_resources,
139 .scan_bus = &pci_domain_scan_bus,
Ravi Sarawadi2fd49722019-12-16 23:41:36 -0800140#if CONFIG(HAVE_ACPI_TABLES)
Subrata Banik91e89c52019-11-01 18:30:01 +0530141 .acpi_name = &soc_acpi_name,
Ravi Sarawadi2fd49722019-12-16 23:41:36 -0800142#endif
Subrata Banik91e89c52019-11-01 18:30:01 +0530143};
144
145static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +0200146 .read_resources = noop_read_resources,
147 .set_resources = noop_set_resources,
Karthikeyan Ramasubramanian0e971e12020-01-09 11:32:16 -0700148#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +0200149 .acpi_fill_ssdt = generate_cpu_entries,
Karthikeyan Ramasubramanian0e971e12020-01-09 11:32:16 -0700150#endif
Subrata Banik91e89c52019-11-01 18:30:01 +0530151};
152
153static void soc_enable(struct device *dev)
154{
Tim Wawrzynczak6d20d0c2020-05-13 17:00:33 -0600155 /*
156 * Set the operations if it is a special bus type or a hidden PCI
157 * device.
158 */
Subrata Banik91e89c52019-11-01 18:30:01 +0530159 if (dev->path.type == DEVICE_PATH_DOMAIN)
160 dev->ops = &pci_domain_ops;
161 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
162 dev->ops = &cpu_bus_ops;
Tim Wawrzynczak6d20d0c2020-05-13 17:00:33 -0600163 else if (dev->path.type == DEVICE_PATH_PCI &&
164 dev->path.pci.devfn == PCH_DEVFN_PMC)
165 dev->ops = &pmc_ops;
Subrata Banik91e89c52019-11-01 18:30:01 +0530166}
167
168struct chip_operations soc_intel_tigerlake_ops = {
169 CHIP_NAME("Intel Tigerlake")
170 .enable_dev = &soc_enable,
171 .init = &soc_init_pre_device,
172};