Lijian Zhao | 2f764f7 | 2017-07-14 11:09:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Lijian Zhao | b269f87 | 2018-07-31 17:23:32 -0700 | [diff] [blame] | 4 | * Copyright (C) 2016-2018 Intel Corporation. |
Lijian Zhao | 2f764f7 | 2017-07-14 11:09:10 -0700 | [diff] [blame] | 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 <chip.h> |
| 17 | #include <console/console.h> |
Pratik Prajapati | 201fa8f | 2017-08-16 11:42:40 -0700 | [diff] [blame] | 18 | #include <device/device.h> |
Lijian Zhao | 2f764f7 | 2017-07-14 11:09:10 -0700 | [diff] [blame] | 19 | #include <device/pci.h> |
| 20 | #include <fsp/api.h> |
Lijian Zhao | 2f764f7 | 2017-07-14 11:09:10 -0700 | [diff] [blame] | 21 | #include <fsp/util.h> |
Subrata Banik | 98376b8 | 2018-05-22 16:18:16 +0530 | [diff] [blame] | 22 | #include <intelblocks/acpi.h> |
Subrata Banik | f699c14 | 2018-06-08 17:57:37 +0530 | [diff] [blame] | 23 | #include <intelblocks/chip.h> |
Duncan Laurie | 2410cd9 | 2018-03-26 02:25:07 -0700 | [diff] [blame] | 24 | #include <intelblocks/xdci.h> |
Lijian Zhao | 2f764f7 | 2017-07-14 11:09:10 -0700 | [diff] [blame] | 25 | #include <romstage_handoff.h> |
Abhay kumar | fcf8820 | 2017-09-20 15:17:42 -0700 | [diff] [blame] | 26 | #include <soc/intel/common/vbt.h> |
Pratik Prajapati | 9027e1b | 2017-08-23 17:37:43 -0700 | [diff] [blame] | 27 | #include <soc/pci_devs.h> |
Lijian Zhao | 2f764f7 | 2017-07-14 11:09:10 -0700 | [diff] [blame] | 28 | #include <soc/ramstage.h> |
| 29 | #include <string.h> |
| 30 | |
Lijian Zhao | 2b074d9 | 2017-08-17 14:25:24 -0700 | [diff] [blame] | 31 | #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) |
Subrata Banik | 98376b8 | 2018-05-22 16:18:16 +0530 | [diff] [blame] | 32 | const char *soc_acpi_name(const struct device *dev) |
Lijian Zhao | 2b074d9 | 2017-08-17 14:25:24 -0700 | [diff] [blame] | 33 | { |
| 34 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 35 | return "PCI0"; |
| 36 | |
| 37 | if (dev->path.type != DEVICE_PATH_PCI) |
| 38 | return NULL; |
| 39 | |
| 40 | switch (dev->path.pci.devfn) { |
| 41 | case SA_DEVFN_ROOT: return "MCHC"; |
| 42 | case SA_DEVFN_IGD: return "GFX0"; |
| 43 | case PCH_DEVFN_ISH: return "ISHB"; |
| 44 | case PCH_DEVFN_XHCI: return "XHCI"; |
| 45 | case PCH_DEVFN_USBOTG: return "XDCI"; |
| 46 | case PCH_DEVFN_THERMAL: return "THRM"; |
| 47 | case PCH_DEVFN_I2C0: return "I2C0"; |
| 48 | case PCH_DEVFN_I2C1: return "I2C1"; |
| 49 | case PCH_DEVFN_I2C2: return "I2C2"; |
| 50 | case PCH_DEVFN_I2C3: return "I2C3"; |
| 51 | case PCH_DEVFN_CSE: return "CSE1"; |
| 52 | case PCH_DEVFN_CSE_2: return "CSE2"; |
| 53 | case PCH_DEVFN_CSE_IDER: return "CSED"; |
| 54 | case PCH_DEVFN_CSE_KT: return "CSKT"; |
| 55 | case PCH_DEVFN_CSE_3: return "CSE3"; |
| 56 | case PCH_DEVFN_SATA: return "SATA"; |
| 57 | case PCH_DEVFN_UART2: return "UAR2"; |
| 58 | case PCH_DEVFN_I2C4: return "I2C4"; |
| 59 | case PCH_DEVFN_I2C5: return "I2C5"; |
| 60 | case PCH_DEVFN_PCIE1: return "RP01"; |
| 61 | case PCH_DEVFN_PCIE2: return "RP02"; |
| 62 | case PCH_DEVFN_PCIE3: return "RP03"; |
| 63 | case PCH_DEVFN_PCIE4: return "RP04"; |
| 64 | case PCH_DEVFN_PCIE5: return "RP05"; |
| 65 | case PCH_DEVFN_PCIE6: return "RP06"; |
| 66 | case PCH_DEVFN_PCIE7: return "RP07"; |
| 67 | case PCH_DEVFN_PCIE8: return "RP08"; |
| 68 | case PCH_DEVFN_PCIE9: return "RP09"; |
| 69 | case PCH_DEVFN_PCIE10: return "RP10"; |
| 70 | case PCH_DEVFN_PCIE11: return "RP11"; |
| 71 | case PCH_DEVFN_PCIE12: return "RP12"; |
Lijian Zhao | 580bc41 | 2017-10-04 13:43:47 -0700 | [diff] [blame] | 72 | case PCH_DEVFN_PCIE13: return "RP13"; |
| 73 | case PCH_DEVFN_PCIE14: return "RP14"; |
| 74 | case PCH_DEVFN_PCIE15: return "RP15"; |
| 75 | case PCH_DEVFN_PCIE16: return "RP16"; |
Lijian Zhao | 2b074d9 | 2017-08-17 14:25:24 -0700 | [diff] [blame] | 76 | case PCH_DEVFN_UART0: return "UAR0"; |
| 77 | case PCH_DEVFN_UART1: return "UAR1"; |
| 78 | case PCH_DEVFN_GSPI0: return "SPI0"; |
| 79 | case PCH_DEVFN_GSPI1: return "SPI1"; |
| 80 | case PCH_DEVFN_GSPI2: return "SPI2"; |
| 81 | case PCH_DEVFN_EMMC: return "EMMC"; |
| 82 | case PCH_DEVFN_SDCARD: return "SDXC"; |
| 83 | case PCH_DEVFN_LPC: return "LPCB"; |
| 84 | case PCH_DEVFN_P2SB: return "P2SB"; |
| 85 | case PCH_DEVFN_PMC: return "PMC_"; |
| 86 | case PCH_DEVFN_HDA: return "HDAS"; |
| 87 | case PCH_DEVFN_SMBUS: return "SBUS"; |
| 88 | case PCH_DEVFN_SPI: return "FSPI"; |
| 89 | case PCH_DEVFN_GBE: return "IGBE"; |
| 90 | case PCH_DEVFN_TRACEHUB:return "THUB"; |
| 91 | } |
| 92 | |
| 93 | return NULL; |
| 94 | } |
| 95 | #endif |
| 96 | |
Lijian Zhao | 2f764f7 | 2017-07-14 11:09:10 -0700 | [diff] [blame] | 97 | void soc_init_pre_device(void *chip_info) |
| 98 | { |
| 99 | /* Perform silicon specific init. */ |
| 100 | fsp_silicon_init(romstage_handoff_is_resume()); |
Subrata Banik | a8733e3 | 2018-01-23 16:40:56 +0530 | [diff] [blame] | 101 | |
| 102 | /* Display FIRMWARE_VERSION_INFO_HOB */ |
| 103 | fsp_display_fvi_version_hob(); |
Lijian Zhao | 2f764f7 | 2017-07-14 11:09:10 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Elyes HAOUAS | 3c8b5d0 | 2018-05-27 16:57:24 +0200 | [diff] [blame] | 106 | static void pci_domain_set_resources(struct device *dev) |
Pratik Prajapati | 201fa8f | 2017-08-16 11:42:40 -0700 | [diff] [blame] | 107 | { |
| 108 | assign_resources(dev->link_list); |
| 109 | } |
| 110 | |
| 111 | static struct device_operations pci_domain_ops = { |
| 112 | .read_resources = &pci_domain_read_resources, |
| 113 | .set_resources = &pci_domain_set_resources, |
| 114 | .scan_bus = &pci_domain_scan_bus, |
Lijian Zhao | 2b074d9 | 2017-08-17 14:25:24 -0700 | [diff] [blame] | 115 | #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) |
| 116 | .acpi_name = &soc_acpi_name, |
| 117 | #endif |
Pratik Prajapati | 201fa8f | 2017-08-16 11:42:40 -0700 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | static struct device_operations cpu_bus_ops = { |
| 121 | .read_resources = DEVICE_NOOP, |
| 122 | .set_resources = DEVICE_NOOP, |
| 123 | .enable_resources = DEVICE_NOOP, |
| 124 | .init = DEVICE_NOOP, |
Shaunak Saha | 95b6175 | 2017-10-04 23:08:40 -0700 | [diff] [blame] | 125 | .acpi_fill_ssdt_generator = generate_cpu_entries, |
Pratik Prajapati | 201fa8f | 2017-08-16 11:42:40 -0700 | [diff] [blame] | 126 | }; |
| 127 | |
Elyes HAOUAS | 3c8b5d0 | 2018-05-27 16:57:24 +0200 | [diff] [blame] | 128 | static void soc_enable(struct device *dev) |
Pratik Prajapati | 201fa8f | 2017-08-16 11:42:40 -0700 | [diff] [blame] | 129 | { |
| 130 | /* Set the operations if it is a special bus type */ |
| 131 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 132 | dev->ops = &pci_domain_ops; |
| 133 | else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) |
| 134 | dev->ops = &cpu_bus_ops; |
| 135 | } |
| 136 | |
Lijian Zhao | 2f764f7 | 2017-07-14 11:09:10 -0700 | [diff] [blame] | 137 | struct chip_operations soc_intel_cannonlake_ops = { |
| 138 | CHIP_NAME("Intel Cannonlake") |
Pratik Prajapati | 201fa8f | 2017-08-16 11:42:40 -0700 | [diff] [blame] | 139 | .enable_dev = &soc_enable, |
Lijian Zhao | 2f764f7 | 2017-07-14 11:09:10 -0700 | [diff] [blame] | 140 | .init = &soc_init_pre_device, |
| 141 | }; |