Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <device/device.h> |
| 4 | #include <device/pci.h> |
| 5 | #include <fsp/api.h> |
| 6 | #include <fsp/util.h> |
Dinesh Gehlot | 166c75c7 | 2023-01-03 05:26:19 +0000 | [diff] [blame] | 7 | #include <gpio.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 8 | #include <intelblocks/acpi.h> |
| 9 | #include <intelblocks/cfg.h> |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 10 | #include <intelblocks/irq.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 11 | #include <intelblocks/itss.h> |
John Zhao | 54a03e4 | 2022-08-03 20:07:03 -0700 | [diff] [blame] | 12 | #include <intelblocks/p2sb.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 13 | #include <intelblocks/pcie_rp.h> |
| 14 | #include <intelblocks/systemagent.h> |
John Zhao | 54a03e4 | 2022-08-03 20:07:03 -0700 | [diff] [blame] | 15 | #include <intelblocks/tcss.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 16 | #include <intelblocks/xdci.h> |
| 17 | #include <soc/intel/common/vbt.h> |
John Zhao | 54a03e4 | 2022-08-03 20:07:03 -0700 | [diff] [blame] | 18 | #include <soc/iomap.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 19 | #include <soc/itss.h> |
| 20 | #include <soc/p2sb.h> |
| 21 | #include <soc/pci_devs.h> |
| 22 | #include <soc/pcie.h> |
| 23 | #include <soc/ramstage.h> |
| 24 | #include <soc/soc_chip.h> |
John Zhao | 54a03e4 | 2022-08-03 20:07:03 -0700 | [diff] [blame] | 25 | #include <soc/tcss.h> |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 26 | |
| 27 | #if CONFIG(HAVE_ACPI_TABLES) |
| 28 | const char *soc_acpi_name(const struct device *dev) |
| 29 | { |
| 30 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 31 | return "PCI0"; |
| 32 | |
| 33 | if (dev->path.type == DEVICE_PATH_USB) { |
| 34 | switch (dev->path.usb.port_type) { |
| 35 | case 0: |
| 36 | /* Root Hub */ |
| 37 | return "RHUB"; |
| 38 | case 2: |
| 39 | /* USB2 ports */ |
| 40 | switch (dev->path.usb.port_id) { |
| 41 | case 0: return "HS01"; |
| 42 | case 1: return "HS02"; |
| 43 | case 2: return "HS03"; |
| 44 | case 3: return "HS04"; |
| 45 | case 4: return "HS05"; |
| 46 | case 5: return "HS06"; |
| 47 | case 6: return "HS07"; |
| 48 | case 7: return "HS08"; |
| 49 | case 8: return "HS09"; |
| 50 | case 9: return "HS10"; |
| 51 | } |
| 52 | break; |
| 53 | case 3: |
| 54 | /* USB3 ports */ |
| 55 | switch (dev->path.usb.port_id) { |
| 56 | case 0: return "SS01"; |
| 57 | case 1: return "SS02"; |
| 58 | case 2: return "SS03"; |
| 59 | case 3: return "SS04"; |
| 60 | } |
| 61 | break; |
| 62 | } |
| 63 | printk(BIOS_DEBUG, "dev->path.type=%x\n", dev->path.usb.port_type); |
| 64 | return NULL; |
| 65 | } |
| 66 | if (dev->path.type != DEVICE_PATH_PCI) { |
| 67 | printk(BIOS_DEBUG, "dev->path.type=%x\n", dev->path.type); |
| 68 | return NULL; |
| 69 | } |
| 70 | |
| 71 | switch (dev->path.pci.devfn) { |
| 72 | case PCI_DEVFN_ROOT: return "MCHC"; |
| 73 | case PCI_DEVFN_TCSS_XHCI: return "TXHC"; |
| 74 | case PCI_DEVFN_TCSS_XDCI: return "TXDC"; |
| 75 | case PCI_DEVFN_TCSS_DMA0: return "TDM0"; |
| 76 | case PCI_DEVFN_TCSS_DMA1: return "TDM1"; |
| 77 | case PCI_DEVFN_TBT0: return "TRP0"; |
| 78 | case PCI_DEVFN_TBT1: return "TRP1"; |
| 79 | case PCI_DEVFN_TBT2: return "TRP2"; |
| 80 | case PCI_DEVFN_TBT3: return "TRP3"; |
| 81 | case PCI_DEVFN_IPU: return "IPU0"; |
| 82 | case PCI_DEVFN_ISH: return "ISHB"; |
| 83 | case PCI_DEVFN_XHCI: return "XHCI"; |
| 84 | case PCI_DEVFN_I2C0: return "I2C0"; |
| 85 | case PCI_DEVFN_I2C1: return "I2C1"; |
| 86 | case PCI_DEVFN_I2C2: return "I2C2"; |
| 87 | case PCI_DEVFN_I2C3: return "I2C3"; |
| 88 | case PCI_DEVFN_I2C4: return "I2C4"; |
| 89 | case PCI_DEVFN_I2C5: return "I2C5"; |
| 90 | case PCI_DEVFN_SATA: return "SATA"; |
| 91 | case PCI_DEVFN_PCIE1: return "RP01"; |
| 92 | case PCI_DEVFN_PCIE2: return "RP02"; |
| 93 | case PCI_DEVFN_PCIE3: return "RP03"; |
| 94 | case PCI_DEVFN_PCIE4: return "RP04"; |
| 95 | case PCI_DEVFN_PCIE5: return "RP05"; |
| 96 | case PCI_DEVFN_PCIE6: return "RP06"; |
| 97 | case PCI_DEVFN_PCIE7: return "RP07"; |
| 98 | case PCI_DEVFN_PCIE8: return "RP08"; |
| 99 | case PCI_DEVFN_PCIE9: return "RP09"; |
| 100 | case PCI_DEVFN_PCIE10: return "RP10"; |
| 101 | case PCI_DEVFN_PCIE11: return "RP11"; |
| 102 | case PCI_DEVFN_PCIE12: return "RP12"; |
| 103 | case PCI_DEVFN_PMC: return "PMC"; |
| 104 | case PCI_DEVFN_UART0: return "UAR0"; |
| 105 | case PCI_DEVFN_UART1: return "UAR1"; |
| 106 | case PCI_DEVFN_UART2: return "UAR2"; |
| 107 | case PCI_DEVFN_GSPI0: return "SPI0"; |
| 108 | case PCI_DEVFN_GSPI1: return "SPI1"; |
Angel Pons | c7c746c | 2022-07-16 12:37:38 +0200 | [diff] [blame] | 109 | case PCI_DEVFN_GSPI2: return "SPI2"; |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 110 | /* Keeping ACPI device name coherent with ec.asl */ |
| 111 | case PCI_DEVFN_ESPI: return "LPCB"; |
| 112 | case PCI_DEVFN_HDA: return "HDAS"; |
| 113 | case PCI_DEVFN_SMBUS: return "SBUS"; |
| 114 | case PCI_DEVFN_GBE: return "GLAN"; |
| 115 | } |
Subrata Banik | e70bc42 | 2023-02-17 03:18:50 +0530 | [diff] [blame] | 116 | printk(BIOS_DEBUG, "Missing ACPI Name for PCI: 00:%02x.%01x\n", |
| 117 | PCI_SLOT(dev->path.pci.devfn), PCI_FUNC(dev->path.pci.devfn)); |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 118 | return NULL; |
| 119 | } |
| 120 | #endif |
| 121 | |
| 122 | /* SoC routine to fill GPIO PM mask and value for GPIO_MISCCFG register */ |
| 123 | static void soc_fill_gpio_pm_configuration(void) |
| 124 | { |
| 125 | uint8_t value[TOTAL_GPIO_COMM]; |
| 126 | const config_t *config = config_of_soc(); |
| 127 | |
| 128 | if (config->gpio_override_pm) |
| 129 | memcpy(value, config->gpio_pm, sizeof(value)); |
| 130 | else |
| 131 | memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value)); |
| 132 | |
| 133 | gpio_pm_configure(value, TOTAL_GPIO_COMM); |
| 134 | } |
| 135 | |
| 136 | void soc_init_pre_device(void *chip_info) |
| 137 | { |
John Zhao | 54a03e4 | 2022-08-03 20:07:03 -0700 | [diff] [blame] | 138 | config_t *config = config_of_soc(); |
| 139 | |
| 140 | /* Validate TBT image authentication */ |
| 141 | config->tbt_authentication = ioe_p2sb_sbi_read(PID_IOM, |
| 142 | IOM_CSME_IMR_TBT_STATUS) & TBT_VALID_AUTHENTICATION; |
| 143 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 144 | /* Perform silicon specific init. */ |
| 145 | fsp_silicon_init(); |
| 146 | |
| 147 | /* Display FIRMWARE_VERSION_INFO_HOB */ |
| 148 | fsp_display_fvi_version_hob(); |
| 149 | |
| 150 | soc_fill_gpio_pm_configuration(); |
| 151 | |
| 152 | /* Swap enabled PCI ports in device tree if needed. */ |
| 153 | pcie_rp_update_devicetree(get_pcie_rp_table()); |
| 154 | } |
| 155 | |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 156 | static void cpu_fill_ssdt(const struct device *dev) |
| 157 | { |
| 158 | if (!generate_pin_irq_map()) |
| 159 | printk(BIOS_ERR, "Failed to generate ACPI _PRT table!\n"); |
| 160 | |
| 161 | generate_cpu_entries(dev); |
| 162 | } |
| 163 | |
| 164 | static void cpu_set_north_irqs(struct device *dev) |
| 165 | { |
| 166 | irq_program_non_pch(); |
| 167 | } |
| 168 | |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 169 | static struct device_operations pci_domain_ops = { |
| 170 | .read_resources = &pci_domain_read_resources, |
| 171 | .set_resources = &pci_domain_set_resources, |
| 172 | .scan_bus = &pci_domain_scan_bus, |
| 173 | #if CONFIG(HAVE_ACPI_TABLES) |
| 174 | .acpi_name = &soc_acpi_name, |
| 175 | .acpi_fill_ssdt = ssdt_set_above_4g_pci, |
| 176 | #endif |
| 177 | }; |
| 178 | |
| 179 | static struct device_operations cpu_bus_ops = { |
| 180 | .read_resources = noop_read_resources, |
| 181 | .set_resources = noop_set_resources, |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 182 | .enable_resources = cpu_set_north_irqs, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 183 | #if CONFIG(HAVE_ACPI_TABLES) |
Kapil Porwal | cca3c90 | 2022-12-19 23:57:15 +0530 | [diff] [blame] | 184 | .acpi_fill_ssdt = cpu_fill_ssdt, |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 185 | #endif |
| 186 | }; |
| 187 | |
| 188 | static void soc_enable(struct device *dev) |
| 189 | { |
| 190 | /* |
| 191 | * Set the operations if it is a special bus type or a hidden PCI |
| 192 | * device. |
| 193 | */ |
| 194 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 195 | dev->ops = &pci_domain_ops; |
| 196 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
| 197 | dev->ops = &cpu_bus_ops; |
| 198 | else if (dev->path.type == DEVICE_PATH_PCI && |
| 199 | dev->path.pci.devfn == PCI_DEVFN_PMC) |
| 200 | dev->ops = &pmc_ops; |
| 201 | else if (dev->path.type == DEVICE_PATH_PCI && |
Subrata Banik | 4ed30ca | 2022-10-27 15:44:54 +0530 | [diff] [blame] | 202 | dev->path.pci.devfn == PCI_DEVFN_P2SB) |
| 203 | dev->ops = &soc_p2sb_ops; |
| 204 | else if (dev->path.type == DEVICE_PATH_PCI && |
Ravi Sarawadi | 91ffac8 | 2022-05-07 16:37:09 -0700 | [diff] [blame] | 205 | dev->path.pci.devfn == PCI_DEVFN_IOE_P2SB) |
| 206 | dev->ops = &ioe_p2sb_ops; |
| 207 | else if (dev->path.type == DEVICE_PATH_GPIO) |
| 208 | block_gpio_enable(dev); |
| 209 | } |
| 210 | |
| 211 | struct chip_operations soc_intel_meteorlake_ops = { |
| 212 | CHIP_NAME("Intel Meteorlake") |
| 213 | .enable_dev = &soc_enable, |
| 214 | .init = &soc_init_pre_device, |
| 215 | }; |