Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -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> |
| 7 | #include <intelblocks/acpi.h> |
| 8 | #include <intelblocks/cfg.h> |
Michael Niewöhner | 8913b78 | 2020-12-11 22:13:44 +0100 | [diff] [blame] | 9 | #include <intelblocks/gpio.h> |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 10 | #include <intelblocks/itss.h> |
| 11 | #include <intelblocks/pcie_rp.h> |
| 12 | #include <intelblocks/xdci.h> |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 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 | static const struct pcie_rp_group pch_rp_groups[] = { |
Tan, Lean Sheng | 3cf8a03 | 2020-12-07 06:14:47 -0800 | [diff] [blame] | 20 | { .slot = PCH_DEV_SLOT_PCIE, .count = 7 }, |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 21 | { 0 } |
| 22 | }; |
| 23 | |
| 24 | #if CONFIG(HAVE_ACPI_TABLES) |
| 25 | const char *soc_acpi_name(const struct device *dev) |
| 26 | { |
| 27 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 28 | return "PCI0"; |
| 29 | |
| 30 | if (dev->path.type == DEVICE_PATH_USB) { |
| 31 | switch (dev->path.usb.port_type) { |
| 32 | case 0: |
| 33 | /* Root Hub */ |
| 34 | return "RHUB"; |
| 35 | case 2: |
| 36 | /* USB2 ports */ |
| 37 | switch (dev->path.usb.port_id) { |
| 38 | case 0: return "HS01"; |
| 39 | case 1: return "HS02"; |
| 40 | case 2: return "HS03"; |
| 41 | case 3: return "HS04"; |
| 42 | case 4: return "HS05"; |
| 43 | case 5: return "HS06"; |
| 44 | case 6: return "HS07"; |
| 45 | case 7: return "HS08"; |
| 46 | case 8: return "HS09"; |
| 47 | case 9: return "HS10"; |
| 48 | } |
| 49 | break; |
| 50 | case 3: |
| 51 | /* USB3 ports */ |
| 52 | switch (dev->path.usb.port_id) { |
| 53 | case 0: return "SS01"; |
| 54 | case 1: return "SS02"; |
| 55 | case 2: return "SS03"; |
| 56 | case 3: return "SS04"; |
| 57 | } |
| 58 | break; |
| 59 | } |
| 60 | return NULL; |
| 61 | } |
| 62 | if (dev->path.type != DEVICE_PATH_PCI) |
| 63 | return NULL; |
| 64 | |
| 65 | switch (dev->path.pci.devfn) { |
| 66 | case SA_DEVFN_ROOT: return "MCHC"; |
Tan, Lean Sheng | 3cf8a03 | 2020-12-07 06:14:47 -0800 | [diff] [blame] | 67 | case PCH_DEVFN_I2C6: return "I2C6"; |
| 68 | case PCH_DEVFN_I2C7: return "I2C7"; |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 69 | case PCH_DEVFN_XHCI: return "XHCI"; |
| 70 | case PCH_DEVFN_I2C0: return "I2C0"; |
| 71 | case PCH_DEVFN_I2C1: return "I2C1"; |
| 72 | case PCH_DEVFN_I2C2: return "I2C2"; |
| 73 | case PCH_DEVFN_I2C3: return "I2C3"; |
Tan, Lean Sheng | 3cf8a03 | 2020-12-07 06:14:47 -0800 | [diff] [blame] | 74 | case PCH_DEVFN_SATA: return "SATA"; |
| 75 | case PCH_DEVFN_UART2: return "UAR2"; |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 76 | case PCH_DEVFN_I2C4: return "I2C4"; |
| 77 | case PCH_DEVFN_I2C5: return "I2C5"; |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 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"; |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 85 | case PCH_DEVFN_UART0: return "UAR0"; |
| 86 | case PCH_DEVFN_UART1: return "UAR1"; |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 87 | case PCH_DEVFN_GSPI0: return "SPI0"; |
| 88 | case PCH_DEVFN_GSPI1: return "SPI1"; |
Tan, Lean Sheng | 3cf8a03 | 2020-12-07 06:14:47 -0800 | [diff] [blame] | 89 | case PCH_DEVFN_GBE: return "GLAN"; |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 90 | case PCH_DEVFN_GSPI2: return "SPI2"; |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 91 | case PCH_DEVFN_EMMC: return "EMMC"; |
| 92 | case PCH_DEVFN_SDCARD: return "SDXC"; |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 93 | case PCH_DEVFN_HDA: return "HDAS"; |
| 94 | case PCH_DEVFN_SMBUS: return "SBUS"; |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | return NULL; |
| 98 | } |
| 99 | #endif |
| 100 | |
Angel Pons | 73a22ed | 2021-04-05 12:26:51 +0200 | [diff] [blame] | 101 | /* SoC routine to fill GPIO PM mask and value for GPIO_MISCCFG register */ |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 102 | static void soc_fill_gpio_pm_configuration(void) |
| 103 | { |
| 104 | uint8_t value[TOTAL_GPIO_COMM]; |
| 105 | const config_t *config = config_of_soc(); |
| 106 | |
| 107 | if (config->gpio_override_pm) |
Angel Pons | 0c0d492 | 2021-04-05 13:02:45 +0200 | [diff] [blame] | 108 | memcpy(value, config->gpio_pm, sizeof(value)); |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 109 | else |
Angel Pons | 0c0d492 | 2021-04-05 13:02:45 +0200 | [diff] [blame] | 110 | memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value)); |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 111 | |
| 112 | gpio_pm_configure(value, TOTAL_GPIO_COMM); |
| 113 | } |
| 114 | |
| 115 | void soc_init_pre_device(void *chip_info) |
| 116 | { |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 117 | /* Perform silicon specific init. */ |
Kyösti Mälkki | cc93c6e | 2021-01-09 22:53:52 +0200 | [diff] [blame] | 118 | fsp_silicon_init(); |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 119 | |
| 120 | /* Display FIRMWARE_VERSION_INFO_HOB */ |
| 121 | fsp_display_fvi_version_hob(); |
| 122 | |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 123 | soc_fill_gpio_pm_configuration(); |
| 124 | |
| 125 | /* swap enabled PCI ports in device tree if needed */ |
| 126 | pcie_rp_update_devicetree(pch_rp_groups); |
| 127 | } |
| 128 | |
| 129 | static struct device_operations pci_domain_ops = { |
| 130 | .read_resources = &pci_domain_read_resources, |
| 131 | .set_resources = &pci_domain_set_resources, |
| 132 | .scan_bus = &pci_domain_scan_bus, |
| 133 | #if CONFIG(HAVE_ACPI_TABLES) |
| 134 | .acpi_name = &soc_acpi_name, |
| 135 | #endif |
| 136 | }; |
| 137 | |
| 138 | static struct device_operations cpu_bus_ops = { |
| 139 | .read_resources = noop_read_resources, |
| 140 | .set_resources = noop_set_resources, |
| 141 | #if CONFIG(HAVE_ACPI_TABLES) |
| 142 | .acpi_fill_ssdt = generate_cpu_entries, |
| 143 | #endif |
| 144 | }; |
| 145 | |
| 146 | extern struct device_operations pmc_ops; |
| 147 | static void soc_enable(struct device *dev) |
| 148 | { |
| 149 | /* Set the operations if it is a special bus type */ |
| 150 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 151 | dev->ops = &pci_domain_ops; |
| 152 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
| 153 | dev->ops = &cpu_bus_ops; |
| 154 | else if (dev->path.type == DEVICE_PATH_PCI && |
| 155 | dev->path.pci.devfn == PCH_DEVFN_PMC) |
| 156 | dev->ops = &pmc_ops; |
Michael Niewöhner | 8913b78 | 2020-12-11 22:13:44 +0100 | [diff] [blame] | 157 | else if (dev->path.type == DEVICE_PATH_GPIO) |
| 158 | block_gpio_enable(dev); |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | struct chip_operations soc_intel_elkhartlake_ops = { |
| 162 | CHIP_NAME("Intel Elkhartlake") |
| 163 | .enable_dev = &soc_enable, |
| 164 | .init = &soc_init_pre_device, |
| 165 | }; |