Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2019 Intel Corp. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | #include <device/device.h> |
| 17 | #include <device/pci.h> |
| 18 | #include <fsp/api.h> |
| 19 | #include <fsp/util.h> |
| 20 | #include <intelblocks/acpi.h> |
| 21 | #include <intelblocks/cfg.h> |
| 22 | #include <intelblocks/itss.h> |
| 23 | #include <intelblocks/xdci.h> |
| 24 | #include <romstage_handoff.h> |
| 25 | #include <soc/intel/common/vbt.h> |
| 26 | #include <soc/itss.h> |
| 27 | #include <soc/pci_devs.h> |
| 28 | #include <soc/ramstage.h> |
| 29 | #include <soc/soc_chip.h> |
| 30 | |
| 31 | #if CONFIG(HAVE_ACPI_TABLES) |
| 32 | const char *soc_acpi_name(const struct device *dev) |
| 33 | { |
| 34 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 35 | return "PCI0"; |
| 36 | |
Ravi Sarawadi | 2fd4972 | 2019-12-16 23:41:36 -0800 | [diff] [blame] | 37 | if (dev->path.type == DEVICE_PATH_USB) { |
| 38 | switch (dev->path.usb.port_type) { |
| 39 | case 0: |
| 40 | /* Root Hub */ |
| 41 | return "RHUB"; |
| 42 | case 2: |
| 43 | /* USB2 ports */ |
| 44 | switch (dev->path.usb.port_id) { |
| 45 | case 0: return "HS01"; |
| 46 | case 1: return "HS02"; |
| 47 | case 2: return "HS03"; |
| 48 | case 3: return "HS04"; |
| 49 | case 4: return "HS05"; |
| 50 | case 5: return "HS06"; |
| 51 | case 6: return "HS07"; |
| 52 | case 7: return "HS08"; |
| 53 | case 8: return "HS09"; |
| 54 | case 9: return "HS10"; |
| 55 | } |
| 56 | break; |
| 57 | case 3: |
| 58 | /* USB3 ports */ |
| 59 | switch (dev->path.usb.port_id) { |
| 60 | case 0: return "SS01"; |
| 61 | case 1: return "SS02"; |
| 62 | case 2: return "SS03"; |
| 63 | case 3: return "SS04"; |
| 64 | } |
| 65 | break; |
| 66 | } |
| 67 | return NULL; |
| 68 | } |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 69 | if (dev->path.type != DEVICE_PATH_PCI) |
| 70 | return NULL; |
| 71 | |
| 72 | switch (dev->path.pci.devfn) { |
| 73 | case SA_DEVFN_ROOT: return "MCHC"; |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 74 | case PCH_DEVFN_XHCI: return "XHCI"; |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 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"; |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 79 | case PCH_DEVFN_I2C4: return "I2C4"; |
| 80 | case PCH_DEVFN_I2C5: return "I2C5"; |
Ravi Sarawadi | 2fd4972 | 2019-12-16 23:41:36 -0800 | [diff] [blame] | 81 | case PCH_DEVFN_SATA: return "SATA"; |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 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"; |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 94 | case PCH_DEVFN_UART0: return "UAR0"; |
| 95 | case PCH_DEVFN_UART1: return "UAR1"; |
Ravi Sarawadi | 2fd4972 | 2019-12-16 23:41:36 -0800 | [diff] [blame] | 96 | case PCH_DEVFN_UART2: return "UAR2"; |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 97 | case PCH_DEVFN_GSPI0: return "SPI0"; |
| 98 | case PCH_DEVFN_GSPI1: return "SPI1"; |
| 99 | case PCH_DEVFN_GSPI2: return "SPI2"; |
Wonkyu Kim | 69855f2 | 2020-01-09 23:34:03 -0800 | [diff] [blame^] | 100 | case PCH_DEVFN_GSPI3: return "SPI3"; |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 101 | /* Keeping ACPI device name coherent with ec.asl */ |
| 102 | case PCH_DEVFN_ESPI: return "LPCB"; |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 103 | case PCH_DEVFN_HDA: return "HDAS"; |
| 104 | case PCH_DEVFN_SMBUS: return "SBUS"; |
Ravi Sarawadi | 2fd4972 | 2019-12-16 23:41:36 -0800 | [diff] [blame] | 105 | case PCH_DEVFN_GBE: return "GLAN"; |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | return NULL; |
| 109 | } |
| 110 | #endif |
| 111 | |
| 112 | /* SoC rotine to fill GPIO PM mask and value for GPIO_MISCCFG register */ |
| 113 | static 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 | |
| 128 | void 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 | |
| 146 | static void pci_domain_set_resources(struct device *dev) |
| 147 | { |
| 148 | assign_resources(dev->link_list); |
| 149 | } |
| 150 | |
| 151 | static 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, |
Ravi Sarawadi | 2fd4972 | 2019-12-16 23:41:36 -0800 | [diff] [blame] | 155 | #if CONFIG(HAVE_ACPI_TABLES) |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 156 | .acpi_name = &soc_acpi_name, |
Ravi Sarawadi | 2fd4972 | 2019-12-16 23:41:36 -0800 | [diff] [blame] | 157 | #endif |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | static 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, |
Karthikeyan Ramasubramanian | 0e971e1 | 2020-01-09 11:32:16 -0700 | [diff] [blame] | 165 | #if CONFIG(HAVE_ACPI_TABLES) |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 166 | .acpi_fill_ssdt_generator = generate_cpu_entries, |
Karthikeyan Ramasubramanian | 0e971e1 | 2020-01-09 11:32:16 -0700 | [diff] [blame] | 167 | #endif |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | static 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 | |
| 179 | struct chip_operations soc_intel_tigerlake_ops = { |
| 180 | CHIP_NAME("Intel Tigerlake") |
| 181 | .enable_dev = &soc_enable, |
| 182 | .init = &soc_init_pre_device, |
| 183 | }; |