blob: 3464399405a6176fbed53da8e033fef8f629cefe [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>
Michael Niewöhner8913b782020-12-11 22:13:44 +01009#include <intelblocks/gpio.h>
Aamir Bohradd7acaa2020-03-25 11:36:22 +053010#include <intelblocks/itss.h>
Karthikeyan Ramasubramanianf8712782020-07-24 15:57:50 -060011#include <intelblocks/pcie_rp.h>
Arthur Heymans08769c62022-05-09 14:33:15 +020012#include <intelblocks/systemagent.h>
Aamir Bohradd7acaa2020-03-25 11:36:22 +053013#include <intelblocks/xdci.h>
Aamir Bohradd7acaa2020-03-25 11:36:22 +053014#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
Karthikeyan Ramasubramanianf8712782020-07-24 15:57:50 -060020static const struct pcie_rp_group pch_rp_groups[] = {
MAULIK V VAGHELAd9c5b142022-02-14 22:04:03 +053021 { .slot = PCH_DEV_SLOT_PCIE, .count = 8, .lcap_port_base = 1 },
Karthikeyan Ramasubramanianf8712782020-07-24 15:57:50 -060022 { 0 }
23};
24
Aamir Bohradd7acaa2020-03-25 11:36:22 +053025#if CONFIG(HAVE_ACPI_TABLES)
26const char *soc_acpi_name(const struct device *dev)
27{
28 if (dev->path.type == DEVICE_PATH_DOMAIN)
29 return "PCI0";
30
31 if (dev->path.type == DEVICE_PATH_USB) {
32 switch (dev->path.usb.port_type) {
33 case 0:
34 /* Root Hub */
35 return "RHUB";
36 case 2:
37 /* USB2 ports */
38 switch (dev->path.usb.port_id) {
39 case 0: return "HS01";
40 case 1: return "HS02";
41 case 2: return "HS03";
42 case 3: return "HS04";
43 case 4: return "HS05";
44 case 5: return "HS06";
45 case 6: return "HS07";
46 case 7: return "HS08";
47 case 8: return "HS09";
48 case 9: return "HS10";
49 }
50 break;
51 case 3:
52 /* USB3 ports */
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";
58 }
59 break;
60 }
61 return NULL;
62 }
63 if (dev->path.type != DEVICE_PATH_PCI)
64 return NULL;
65
66 switch (dev->path.pci.devfn) {
67 case SA_DEVFN_ROOT: return "MCHC";
Tim Wawrzynczak4b748142020-06-29 12:34:55 -060068 case SA_DEVFN_IPU: return "IPU0";
Aamir Bohradd7acaa2020-03-25 11:36:22 +053069 case PCH_DEVFN_ISH: return "ISHB";
70 case PCH_DEVFN_XHCI: return "XHCI";
71 case PCH_DEVFN_I2C0: return "I2C0";
72 case PCH_DEVFN_I2C1: return "I2C1";
73 case PCH_DEVFN_I2C2: return "I2C2";
74 case PCH_DEVFN_I2C3: return "I2C3";
75 case PCH_DEVFN_I2C4: return "I2C4";
76 case PCH_DEVFN_I2C5: return "I2C5";
77 case PCH_DEVFN_SATA: return "SATA";
78 case PCH_DEVFN_PCIE1: return "RP01";
79 case PCH_DEVFN_PCIE2: return "RP02";
80 case PCH_DEVFN_PCIE3: return "RP03";
81 case PCH_DEVFN_PCIE4: return "RP04";
82 case PCH_DEVFN_PCIE5: return "RP05";
83 case PCH_DEVFN_PCIE6: return "RP06";
84 case PCH_DEVFN_PCIE7: return "RP07";
85 case PCH_DEVFN_PCIE8: return "RP08";
86 case PCH_DEVFN_PCIE9: return "RP09";
87 case PCH_DEVFN_PCIE10: return "RP10";
88 case PCH_DEVFN_PCIE11: return "RP11";
89 case PCH_DEVFN_PCIE12: return "RP12";
90 case PCH_DEVFN_UART0: return "UAR0";
91 case PCH_DEVFN_UART1: return "UAR1";
92 case PCH_DEVFN_UART2: return "UAR2";
93 case PCH_DEVFN_GSPI0: return "SPI0";
94 case PCH_DEVFN_GSPI1: return "SPI1";
95 case PCH_DEVFN_GSPI2: return "SPI2";
96 case PCH_DEVFN_GSPI3: return "SPI3";
Karthikeyan Ramasubramaniane5ec91b2020-04-15 14:27:36 -060097 case PCH_DEVFN_EMMC: return "EMMC";
98 case PCH_DEVFN_SDCARD: return "SDXC";
Aamir Bohradd7acaa2020-03-25 11:36:22 +053099 case PCH_DEVFN_HDA: return "HDAS";
100 case PCH_DEVFN_SMBUS: return "SBUS";
101 case PCH_DEVFN_GBE: return "GLAN";
102 }
103
104 return NULL;
105}
106#endif
107
Angel Pons73a22ed2021-04-05 12:26:51 +0200108/* SoC routine to fill GPIO PM mask and value for GPIO_MISCCFG register */
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530109static void soc_fill_gpio_pm_configuration(void)
110{
111 uint8_t value[TOTAL_GPIO_COMM];
112 const config_t *config = config_of_soc();
113
114 if (config->gpio_override_pm)
Angel Pons0c0d4922021-04-05 13:02:45 +0200115 memcpy(value, config->gpio_pm, sizeof(value));
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530116 else
Angel Pons0c0d4922021-04-05 13:02:45 +0200117 memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value));
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530118
119 gpio_pm_configure(value, TOTAL_GPIO_COMM);
120}
121
122void soc_init_pre_device(void *chip_info)
123{
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530124 /* Perform silicon specific init. */
Kyösti Mälkkicc93c6e2021-01-09 22:53:52 +0200125 fsp_silicon_init();
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530126
127 /* Display FIRMWARE_VERSION_INFO_HOB */
128 fsp_display_fvi_version_hob();
129
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530130 soc_fill_gpio_pm_configuration();
Karthikeyan Ramasubramanianf8712782020-07-24 15:57:50 -0600131
132 /* swap enabled PCI ports in device tree if needed */
133 pcie_rp_update_devicetree(pch_rp_groups);
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530134}
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,
Arthur Heymans08769c62022-05-09 14:33:15 +0200142 .acpi_fill_ssdt = ssdt_set_above_4g_pci,
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530143#endif
144};
145
146static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +0200147 .read_resources = noop_read_resources,
148 .set_resources = noop_set_resources,
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530149#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +0200150 .acpi_fill_ssdt = generate_cpu_entries,
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530151#endif
152};
153
Tim Wawrzynczakc47422d2020-06-01 17:03:41 -0600154extern struct device_operations pmc_ops;
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530155static void soc_enable(struct device *dev)
156{
157 /* Set the operations if it is a special bus type */
158 if (dev->path.type == DEVICE_PATH_DOMAIN)
159 dev->ops = &pci_domain_ops;
160 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
161 dev->ops = &cpu_bus_ops;
Tim Wawrzynczakc47422d2020-06-01 17:03:41 -0600162 else if (dev->path.type == DEVICE_PATH_PCI &&
163 dev->path.pci.devfn == PCH_DEVFN_PMC)
164 dev->ops = &pmc_ops;
Michael Niewöhner8913b782020-12-11 22:13:44 +0100165 else if (dev->path.type == DEVICE_PATH_GPIO)
166 block_gpio_enable(dev);
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530167}
168
Aamir Bohra512b77a2020-03-25 13:20:34 +0530169struct chip_operations soc_intel_jasperlake_ops = {
170 CHIP_NAME("Intel Jasperlake")
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530171 .enable_dev = &soc_enable,
172 .init = &soc_init_pre_device,
173};