| 1 |
|
| 2 |
|
| 3 |
#include <device/device.h> |
| 4 |
#include <device/pci.h> |
| 5 |
#include <fsp/api.h> |
| 6 |
#include <fsp/util.h> |
| 7 |
#include <gpio.h> |
| 8 |
#include <intelblocks/acpi.h> |
| 9 |
#include <intelblocks/cfg.h> |
| 10 |
#include <intelblocks/cse.h> |
| 11 |
#include <intelblocks/irq.h> |
| 12 |
#include <intelblocks/itss.h> |
| 13 |
#include <intelblocks/p2sb.h> |
| 14 |
#include <intelblocks/pcie_rp.h> |
| 15 |
#include <intelblocks/systemagent.h> |
| 16 |
#include <intelblocks/tcss.h> |
| 17 |
#include <intelblocks/xdci.h> |
| 18 |
#include <soc/intel/common/reset.h> |
| 19 |
#include <soc/intel/common/vbt.h> |
| 20 |
#include <soc/iomap.h> |
| 21 |
#include <soc/p2sb.h> |
| 22 |
#include <soc/pci_devs.h> |
| 23 |
#include <soc/pcie.h> |
| 24 |
#include <soc/ramstage.h> |
| 25 |
#include <soc/soc_chip.h> |
| 26 |
#include <soc/tcss.h> |
| 27 |
#include <static.h> |
| 28 |
|
| 29 |
#if CONFIG(HAVE_ACPI_TABLES) |
| 30 |
const char *soc_acpi_name(const struct device *dev) |
| 31 |
{ |
| 32 |
if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 33 |
return "PCI0"; |
| 34 |
|
| 35 |
if (dev->path.type == DEVICE_PATH_USB) { |
| 36 |
switch (dev->path.usb.port_type) { |
| 37 |
case 0: |
| 38 |
|
| 39 |
return "RHUB"; |
| 40 |
case 2: |
| 41 |
|
| 42 |
switch (dev->path.usb.port_id) { |
| 43 |
case 0: return "HS01"; |
| 44 |
case 1: return "HS02"; |
| 45 |
case 2: return "HS03"; |
| 46 |
case 3: return "HS04"; |
| 47 |
case 4: return "HS05"; |
| 48 |
case 5: return "HS06"; |
| 49 |
case 6: return "HS07"; |
| 50 |
case 7: return "HS08"; |
| 51 |
case 8: return "HS09"; |
| 52 |
case 9: return "HS10"; |
| 53 |
} |
| 54 |
break; |
| 55 |
case 3: |
| 56 |
|
| 57 |
switch (dev->path.usb.port_id) { |
| 58 |
case 0: return "SS01"; |
| 59 |
case 1: return "SS02"; |
| 60 |
case 2: return "SS03"; |
| 61 |
case 3: return "SS04"; |
| 62 |
} |
| 63 |
break; |
| 64 |
} |
| 65 |
printk(BIOS_DEBUG, "dev->path.type=%x\n", dev->path.usb.port_type); |
| 66 |
return NULL; |
| 67 |
} |
| 68 |
if (dev->path.type != DEVICE_PATH_PCI) { |
| 69 |
printk(BIOS_DEBUG, "dev->path.type=%x\n", dev->path.type); |
| 70 |
return NULL; |
| 71 |
} |
| 72 |
|
| 73 |
switch (dev->path.pci.devfn) { |
| 74 |
case PCI_DEVFN_ROOT: return "MCHC"; |
| 75 |
case PCI_DEVFN_IGD: return "GFX0"; |
| 76 |
case PCI_DEVFN_TCSS_XHCI: return "TXHC"; |
| 77 |
case PCI_DEVFN_TCSS_XDCI: return "TXDC"; |
| 78 |
case PCI_DEVFN_TCSS_DMA0: return "TDM0"; |
| 79 |
case PCI_DEVFN_TCSS_DMA1: return "TDM1"; |
| 80 |
case PCI_DEVFN_TBT0: return "TRP0"; |
| 81 |
case PCI_DEVFN_TBT1: return "TRP1"; |
| 82 |
case PCI_DEVFN_TBT2: return "TRP2"; |
| 83 |
case PCI_DEVFN_TBT3: return "TRP3"; |
| 84 |
case PCI_DEVFN_IPU: return "IPU0"; |
| 85 |
case PCI_DEVFN_ISH: return "ISHB"; |
| 86 |
case PCI_DEVFN_GNA: return "GNA"; |
| 87 |
case PCI_DEVFN_XHCI: return "XHCI"; |
| 88 |
case PCI_DEVFN_I2C0: return "I2C0"; |
| 89 |
case PCI_DEVFN_I2C1: return "I2C1"; |
| 90 |
case PCI_DEVFN_I2C2: return "I2C2"; |
| 91 |
case PCI_DEVFN_I2C3: return "I2C3"; |
| 92 |
case PCI_DEVFN_I2C4: return "I2C4"; |
| 93 |
case PCI_DEVFN_I2C5: return "I2C5"; |
| 94 |
case PCI_DEVFN_SATA: return "SATA"; |
| 95 |
case PCI_DEVFN_PCIE1: return "RP01"; |
| 96 |
case PCI_DEVFN_PCIE2: return "RP02"; |
| 97 |
case PCI_DEVFN_PCIE3: return "RP03"; |
| 98 |
case PCI_DEVFN_PCIE4: return "RP04"; |
| 99 |
case PCI_DEVFN_PCIE5: return "RP05"; |
| 100 |
case PCI_DEVFN_PCIE6: return "RP06"; |
| 101 |
case PCI_DEVFN_PCIE7: return "RP07"; |
| 102 |
case PCI_DEVFN_PCIE8: return "RP08"; |
| 103 |
case PCI_DEVFN_PCIE9: return "RP09"; |
| 104 |
case PCI_DEVFN_PCIE10: return "RP10"; |
| 105 |
case PCI_DEVFN_PCIE11: return "RP11"; |
| 106 |
case PCI_DEVFN_PCIE12: return "RP12"; |
| 107 |
case PCI_DEVFN_PMC: return "PMC"; |
| 108 |
case PCI_DEVFN_UART0: return "UAR0"; |
| 109 |
case PCI_DEVFN_UART1: return "UAR1"; |
| 110 |
case PCI_DEVFN_UART2: return "UAR2"; |
| 111 |
case PCI_DEVFN_GSPI0: return "SPI0"; |
| 112 |
case PCI_DEVFN_GSPI1: return "SPI1"; |
| 113 |
case PCI_DEVFN_GSPI2: return "SPI2"; |
| 114 |
|
| 115 |
case PCI_DEVFN_ESPI: return "LPCB"; |
| 116 |
case PCI_DEVFN_HDA: return "HDAS"; |
| 117 |
case PCI_DEVFN_SMBUS: return "SBUS"; |
| 118 |
case PCI_DEVFN_GBE: return "GLAN"; |
| 119 |
case PCI_DEVFN_SRAM: return "SRAM"; |
| 120 |
case PCI_DEVFN_SPI: return "FSPI"; |
| 121 |
case PCI_DEVFN_CSE: return "HECI"; |
| 122 |
} |
| 123 |
printk(BIOS_DEBUG, "Missing ACPI Name for PCI: 00:%02x.%01x\n", |
| 124 |
PCI_SLOT(dev->path.pci.devfn), PCI_FUNC(dev->path.pci.devfn)); |
| 125 |
return NULL; |
| 126 |
} |
| 127 |
#endif |
| 128 |
|
| 129 |
#if CONFIG(SOC_INTEL_STORE_ISH_FW_VERSION) |
| 130 |
|
| 131 |
bool soc_is_ish_partition_enabled(void) |
| 132 |
{ |
| 133 |
struct device *ish = pcidev_path_on_root(PCI_DEVFN_ISH); |
| 134 |
uint16_t ish_pci_id = ish ? pci_read_config16(ish, PCI_DEVICE_ID) : 0xFFFF; |
| 135 |
|
| 136 |
if (ish_pci_id == 0xFFFF) |
| 137 |
return false; |
| 138 |
|
| 139 |
return true; |
| 140 |
} |
| 141 |
#endif |
| 142 |
|
| 143 |
|
| 144 |
static void soc_fill_gpio_pm_configuration(void) |
| 145 |
{ |
| 146 |
uint8_t value[TOTAL_GPIO_COMM]; |
| 147 |
const config_t *config = config_of_soc(); |
| 148 |
|
| 149 |
if (config->gpio_override_pm) |
| 150 |
memcpy(value, config->gpio_pm, sizeof(value)); |
| 151 |
else |
| 152 |
memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value)); |
| 153 |
|
| 154 |
gpio_pm_configure(value, TOTAL_GPIO_COMM); |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
static void soc_enable_tracehub(void) |
| 159 |
{ |
| 160 |
struct device *dev; |
| 161 |
|
| 162 |
dev = pcidev_path_on_root(PCI_DEVFN_NPK); |
| 163 |
if (dev) { |
| 164 |
dev->enabled = 1; |
| 165 |
printk(BIOS_DEBUG, "Tracehub is enabled.\n"); |
| 166 |
} |
| 167 |
} |
| 168 |
|
| 169 |
void soc_init_pre_device(void *chip_info) |
| 170 |
{ |
| 171 |
config_t *config = config_of_soc(); |
| 172 |
|
| 173 |
|
| 174 |
config->tbt_authentication = ioe_p2sb_sbi_read(PID_IOM, |
| 175 |
IOM_CSME_IMR_TBT_STATUS) & TBT_VALID_AUTHENTICATION; |
| 176 |
|
| 177 |
if (CONFIG(SOC_INTEL_COMMON_BLOCK_TRACEHUB)) |
| 178 |
soc_enable_tracehub(); |
| 179 |
|
| 180 |
|
| 181 |
fsp_silicon_init(); |
| 182 |
|
| 183 |
|
| 184 |
fsp_display_fvi_version_hob(); |
| 185 |
|
| 186 |
soc_fill_gpio_pm_configuration(); |
| 187 |
|
| 188 |
|
| 189 |
pcie_rp_update_devicetree(get_pcie_rp_table()); |
| 190 |
|
| 191 |
|
| 192 |
pcie_rp_update_devicetree(get_tbt_pcie_rp_table()); |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
if (CONFIG(SOC_INTEL_CSE_SEND_EOP_EARLY) || |
| 205 |
CONFIG(SOC_INTEL_CSE_SEND_EOP_ASYNC)) { |
| 206 |
printk(BIOS_INFO, "Sending EOP early from SoC\n"); |
| 207 |
cse_send_end_of_post(); |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
static void cpu_fill_ssdt(const struct device *dev) |
| 212 |
{ |
| 213 |
if (!generate_pin_irq_map()) |
| 214 |
printk(BIOS_ERR, "Failed to generate ACPI _PRT table!\n"); |
| 215 |
|
| 216 |
generate_cpu_entries(dev); |
| 217 |
} |
| 218 |
|
| 219 |
static void cpu_set_north_irqs(struct device *dev) |
| 220 |
{ |
| 221 |
irq_program_non_pch(); |
| 222 |
} |
| 223 |
|
| 224 |
static struct device_operations pci_domain_ops = { |
| 225 |
.read_resources = &pci_domain_read_resources, |
| 226 |
.set_resources = &pci_domain_set_resources, |
| 227 |
.scan_bus = &pci_host_bridge_scan_bus, |
| 228 |
#if CONFIG(HAVE_ACPI_TABLES) |
| 229 |
.acpi_name = &soc_acpi_name, |
| 230 |
.acpi_fill_ssdt = ssdt_set_above_4g_pci, |
| 231 |
#endif |
| 232 |
}; |
| 233 |
|
| 234 |
static struct device_operations cpu_bus_ops = { |
| 235 |
.read_resources = noop_read_resources, |
| 236 |
.set_resources = noop_set_resources, |
| 237 |
.enable_resources = cpu_set_north_irqs, |
| 238 |
#if CONFIG(HAVE_ACPI_TABLES) |
| 239 |
.acpi_fill_ssdt = cpu_fill_ssdt, |
| 240 |
#endif |
| 241 |
}; |
| 242 |
|
| 243 |
static void soc_enable(struct device *dev) |
| 244 |
{ |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 250 |
dev->ops = &pci_domain_ops; |
| 251 |
else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
| 252 |
dev->ops = &cpu_bus_ops; |
| 253 |
else if (dev->path.type == DEVICE_PATH_PCI && |
| 254 |
dev->path.pci.devfn == PCI_DEVFN_PMC) |
| 255 |
dev->ops = &pmc_ops; |
| 256 |
else if (dev->path.type == DEVICE_PATH_PCI && |
| 257 |
dev->path.pci.devfn == PCI_DEVFN_IOE_PMC) |
| 258 |
dev->ops = &ioe_pmc_ops; |
| 259 |
else if (dev->path.type == DEVICE_PATH_PCI && |
| 260 |
dev->path.pci.devfn == PCI_DEVFN_P2SB) |
| 261 |
dev->ops = &soc_p2sb_ops; |
| 262 |
else if (dev->path.type == DEVICE_PATH_PCI && |
| 263 |
dev->path.pci.devfn == PCI_DEVFN_IOE_P2SB) |
| 264 |
dev->ops = &ioe_p2sb_ops; |
| 265 |
else if (dev->path.type == DEVICE_PATH_GPIO) |
| 266 |
block_gpio_enable(dev); |
| 267 |
} |
| 268 |
|
| 269 |
static void soc_init_final_device(void *chip_info) |
| 270 |
{ |
| 271 |
efi_return_status_t reset_status = fsp_get_pch_reset_status(); |
| 272 |
|
| 273 |
if (reset_status == FSP_SUCCESS) |
| 274 |
return; |
| 275 |
|
| 276 |
|
| 277 |
fsp_handle_reset(reset_status); |
| 278 |
|
| 279 |
|
| 280 |
fsp_die_with_post_code(reset_status, POSTCODE_HW_INIT_FAILURE, |
| 281 |
"Failed to handle the FSP reset request with error"); |
| 282 |
} |
| 283 |
|
| 284 |
struct chip_operations soc_intel_meteorlake_ops = { |
| 285 |
.name = "Intel Meteorlake", |
| 286 |
.enable_dev = &soc_enable, |
| 287 |
.init = &soc_init_pre_device, |
| 288 |
.final = &soc_init_final_device, |
| 289 |
}; |