blob: 2b00f96e1eeb070968733d826725f75f5e95e1f7 [file] [log] [blame]
Aamir Bohradd7acaa2020-03-25 11:36:22 +05301/*
2 * This file is part of the coreboot project.
3 *
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <device/device.h>
16#include <device/pci.h>
17#include <fsp/api.h>
18#include <fsp/util.h>
19#include <intelblocks/acpi.h>
20#include <intelblocks/cfg.h>
21#include <intelblocks/itss.h>
22#include <intelblocks/xdci.h>
23#include <romstage_handoff.h>
24#include <soc/intel/common/vbt.h>
25#include <soc/itss.h>
26#include <soc/pci_devs.h>
27#include <soc/ramstage.h>
28#include <soc/soc_chip.h>
29
30#if CONFIG(HAVE_ACPI_TABLES)
31const char *soc_acpi_name(const struct device *dev)
32{
33 if (dev->path.type == DEVICE_PATH_DOMAIN)
34 return "PCI0";
35
36 if (dev->path.type == DEVICE_PATH_USB) {
37 switch (dev->path.usb.port_type) {
38 case 0:
39 /* Root Hub */
40 return "RHUB";
41 case 2:
42 /* USB2 ports */
43 switch (dev->path.usb.port_id) {
44 case 0: return "HS01";
45 case 1: return "HS02";
46 case 2: return "HS03";
47 case 3: return "HS04";
48 case 4: return "HS05";
49 case 5: return "HS06";
50 case 6: return "HS07";
51 case 7: return "HS08";
52 case 8: return "HS09";
53 case 9: return "HS10";
54 }
55 break;
56 case 3:
57 /* USB3 ports */
58 switch (dev->path.usb.port_id) {
59 case 0: return "SS01";
60 case 1: return "SS02";
61 case 2: return "SS03";
62 case 3: return "SS04";
63 }
64 break;
65 }
66 return NULL;
67 }
68 if (dev->path.type != DEVICE_PATH_PCI)
69 return NULL;
70
71 switch (dev->path.pci.devfn) {
72 case SA_DEVFN_ROOT: return "MCHC";
73 case PCH_DEVFN_ISH: return "ISHB";
74 case PCH_DEVFN_XHCI: return "XHCI";
75 case PCH_DEVFN_I2C0: return "I2C0";
76 case PCH_DEVFN_I2C1: return "I2C1";
77 case PCH_DEVFN_I2C2: return "I2C2";
78 case PCH_DEVFN_I2C3: return "I2C3";
79 case PCH_DEVFN_I2C4: return "I2C4";
80 case PCH_DEVFN_I2C5: return "I2C5";
81 case PCH_DEVFN_SATA: return "SATA";
82 case PCH_DEVFN_PCIE1: return "RP01";
83 case PCH_DEVFN_PCIE2: return "RP02";
84 case PCH_DEVFN_PCIE3: return "RP03";
85 case PCH_DEVFN_PCIE4: return "RP04";
86 case PCH_DEVFN_PCIE5: return "RP05";
87 case PCH_DEVFN_PCIE6: return "RP06";
88 case PCH_DEVFN_PCIE7: return "RP07";
89 case PCH_DEVFN_PCIE8: return "RP08";
90 case PCH_DEVFN_PCIE9: return "RP09";
91 case PCH_DEVFN_PCIE10: return "RP10";
92 case PCH_DEVFN_PCIE11: return "RP11";
93 case PCH_DEVFN_PCIE12: return "RP12";
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 rotine 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
122 memset(value, MISCCFG_ENABLE_GPIO_PM_CONFIG, sizeof(uint8_t) *
123 TOTAL_GPIO_COMM);
124
125 gpio_pm_configure(value, TOTAL_GPIO_COMM);
126}
127
128void soc_init_pre_device(void *chip_info)
129{
130 /* Snapshot the current GPIO IRQ polarities. FSP is setting a
131 * default policy that doesn't honor boards' requirements. */
132 itss_snapshot_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
133
134 /* Perform silicon specific init. */
135 fsp_silicon_init(romstage_handoff_is_resume());
136
137 /* Display FIRMWARE_VERSION_INFO_HOB */
138 fsp_display_fvi_version_hob();
139
140 /* Restore GPIO IRQ polarities back to previous settings. */
141 itss_restore_irq_polarities(GPIO_IRQ_START, GPIO_IRQ_END);
142
143 soc_fill_gpio_pm_configuration();
144}
145
146static void pci_domain_set_resources(struct device *dev)
147{
148 assign_resources(dev->link_list);
149}
150
151static struct device_operations pci_domain_ops = {
152 .read_resources = &pci_domain_read_resources,
153 .set_resources = &pci_domain_set_resources,
154 .scan_bus = &pci_domain_scan_bus,
155#if CONFIG(HAVE_ACPI_TABLES)
156 .acpi_name = &soc_acpi_name,
157#endif
158};
159
160static struct device_operations cpu_bus_ops = {
161 .read_resources = DEVICE_NOOP,
162 .set_resources = DEVICE_NOOP,
163 .enable_resources = DEVICE_NOOP,
164 .init = DEVICE_NOOP,
165#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +0200166 .acpi_fill_ssdt = generate_cpu_entries,
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530167#endif
168};
169
170static void soc_enable(struct device *dev)
171{
172 /* Set the operations if it is a special bus type */
173 if (dev->path.type == DEVICE_PATH_DOMAIN)
174 dev->ops = &pci_domain_ops;
175 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
176 dev->ops = &cpu_bus_ops;
177}
178
Aamir Bohra512b77a2020-03-25 13:20:34 +0530179struct chip_operations soc_intel_jasperlake_ops = {
180 CHIP_NAME("Intel Jasperlake")
Aamir Bohradd7acaa2020-03-25 11:36:22 +0530181 .enable_dev = &soc_enable,
182 .init = &soc_init_pre_device,
183};