blob: ff63398804bb8936469e3b9ca8a80853e0b0aafd [file] [log] [blame]
Angel Ponsfabfe9d2020-04-05 15:47:07 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aamir Bohradd7acaa2020-03-25 11:36:22 +05302
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/itss.h>
10#include <intelblocks/xdci.h>
11#include <romstage_handoff.h>
12#include <soc/intel/common/vbt.h>
13#include <soc/itss.h>
14#include <soc/pci_devs.h>
15#include <soc/ramstage.h>
16#include <soc/soc_chip.h>
17
18#if CONFIG(HAVE_ACPI_TABLES)
19const char *soc_acpi_name(const struct device *dev)
20{
21 if (dev->path.type == DEVICE_PATH_DOMAIN)
22 return "PCI0";
23
24 if (dev->path.type == DEVICE_PATH_USB) {
25 switch (dev->path.usb.port_type) {
26 case 0:
27 /* Root Hub */
28 return "RHUB";
29 case 2:
30 /* USB2 ports */
31 switch (dev->path.usb.port_id) {
32 case 0: return "HS01";
33 case 1: return "HS02";
34 case 2: return "HS03";
35 case 3: return "HS04";
36 case 4: return "HS05";
37 case 5: return "HS06";
38 case 6: return "HS07";
39 case 7: return "HS08";
40 case 8: return "HS09";
41 case 9: return "HS10";
42 }
43 break;
44 case 3:
45 /* USB3 ports */
46 switch (dev->path.usb.port_id) {
47 case 0: return "SS01";
48 case 1: return "SS02";
49 case 2: return "SS03";
50 case 3: return "SS04";
51 }
52 break;
53 }
54 return NULL;
55 }
56 if (dev->path.type != DEVICE_PATH_PCI)
57 return NULL;
58
59 switch (dev->path.pci.devfn) {
60 case SA_DEVFN_ROOT: return "MCHC";
61 case PCH_DEVFN_ISH: return "ISHB";
62 case PCH_DEVFN_XHCI: return "XHCI";
63 case PCH_DEVFN_I2C0: return "I2C0";
64 case PCH_DEVFN_I2C1: return "I2C1";
65 case PCH_DEVFN_I2C2: return "I2C2";
66 case PCH_DEVFN_I2C3: return "I2C3";
67 case PCH_DEVFN_I2C4: return "I2C4";
68 case PCH_DEVFN_I2C5: return "I2C5";
69 case PCH_DEVFN_SATA: return "SATA";
70 case PCH_DEVFN_PCIE1: return "RP01";
71 case PCH_DEVFN_PCIE2: return "RP02";
72 case PCH_DEVFN_PCIE3: return "RP03";
73 case PCH_DEVFN_PCIE4: return "RP04";
74 case PCH_DEVFN_PCIE5: return "RP05";
75 case PCH_DEVFN_PCIE6: return "RP06";
76 case PCH_DEVFN_PCIE7: return "RP07";
77 case PCH_DEVFN_PCIE8: return "RP08";
78 case PCH_DEVFN_PCIE9: return "RP09";
79 case PCH_DEVFN_PCIE10: return "RP10";
80 case PCH_DEVFN_PCIE11: return "RP11";
81 case PCH_DEVFN_PCIE12: return "RP12";
82 case PCH_DEVFN_UART0: return "UAR0";
83 case PCH_DEVFN_UART1: return "UAR1";
84 case PCH_DEVFN_UART2: return "UAR2";
85 case PCH_DEVFN_GSPI0: return "SPI0";
86 case PCH_DEVFN_GSPI1: return "SPI1";
87 case PCH_DEVFN_GSPI2: return "SPI2";
88 case PCH_DEVFN_GSPI3: return "SPI3";
Karthikeyan Ramasubramaniane5ec91b2020-04-15 14:27:36 -060089 case PCH_DEVFN_EMMC: return "EMMC";
90 case PCH_DEVFN_SDCARD: return "SDXC";
Aamir Bohradd7acaa2020-03-25 11:36:22 +053091 /* Keeping ACPI device name coherent with ec.asl */
92 case PCH_DEVFN_ESPI: return "LPCB";
93 case PCH_DEVFN_HDA: return "HDAS";
94 case PCH_DEVFN_SMBUS: return "SBUS";
95 case PCH_DEVFN_GBE: return "GLAN";
96 }
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
Aamir Bohradd7acaa2020-03-25 11:36:22 +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,
140#if CONFIG(HAVE_ACPI_TABLES)
141 .acpi_name = &soc_acpi_name,
142#endif
143};
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,
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530148#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +0200149 .acpi_fill_ssdt = generate_cpu_entries,
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530150#endif
151};
152
Tim Wawrzynczakc47422d2020-06-01 17:03:41 -0600153extern struct device_operations pmc_ops;
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530154static void soc_enable(struct device *dev)
155{
156 /* Set the operations if it is a special bus type */
157 if (dev->path.type == DEVICE_PATH_DOMAIN)
158 dev->ops = &pci_domain_ops;
159 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
160 dev->ops = &cpu_bus_ops;
Tim Wawrzynczakc47422d2020-06-01 17:03:41 -0600161 else if (dev->path.type == DEVICE_PATH_PCI &&
162 dev->path.pci.devfn == PCH_DEVFN_PMC)
163 dev->ops = &pmc_ops;
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530164}
165
Aamir Bohra512b77a2020-03-25 13:20:34 +0530166struct chip_operations soc_intel_jasperlake_ops = {
167 CHIP_NAME("Intel Jasperlake")
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530168 .enable_dev = &soc_enable,
169 .init = &soc_init_pre_device,
170};