blob: 6a3324b7fdc72074e67e03c810b92571a46f1b5e [file] [log] [blame]
Lijian Zhao2f764f72017-07-14 11:09:10 -07001/*
2 * This file is part of the coreboot project.
3 *
Lijian Zhaob269f872018-07-31 17:23:32 -07004 * Copyright (C) 2016-2018 Intel Corporation.
Lijian Zhao2f764f72017-07-14 11:09:10 -07005 *
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 Prajapati201fa8f2017-08-16 11:42:40 -070018#include <device/device.h>
Lijian Zhao2f764f72017-07-14 11:09:10 -070019#include <device/pci.h>
20#include <fsp/api.h>
Lijian Zhao2f764f72017-07-14 11:09:10 -070021#include <fsp/util.h>
Subrata Banik98376b82018-05-22 16:18:16 +053022#include <intelblocks/acpi.h>
Subrata Banikf699c142018-06-08 17:57:37 +053023#include <intelblocks/chip.h>
Duncan Laurie2410cd92018-03-26 02:25:07 -070024#include <intelblocks/xdci.h>
Lijian Zhao2f764f72017-07-14 11:09:10 -070025#include <romstage_handoff.h>
Abhay kumarfcf88202017-09-20 15:17:42 -070026#include <soc/intel/common/vbt.h>
Pratik Prajapati9027e1b2017-08-23 17:37:43 -070027#include <soc/pci_devs.h>
Lijian Zhao2f764f72017-07-14 11:09:10 -070028#include <soc/ramstage.h>
29#include <string.h>
30
Lijian Zhao2b074d92017-08-17 14:25:24 -070031#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
Subrata Banik98376b82018-05-22 16:18:16 +053032const char *soc_acpi_name(const struct device *dev)
Lijian Zhao2b074d92017-08-17 14:25:24 -070033{
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 Zhao580bc412017-10-04 13:43:47 -070072 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 Zhao2b074d92017-08-17 14:25:24 -070076 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 Zhao2f764f72017-07-14 11:09:10 -070097void soc_init_pre_device(void *chip_info)
98{
99 /* Perform silicon specific init. */
100 fsp_silicon_init(romstage_handoff_is_resume());
Subrata Banika8733e32018-01-23 16:40:56 +0530101
102 /* Display FIRMWARE_VERSION_INFO_HOB */
103 fsp_display_fvi_version_hob();
Lijian Zhao2f764f72017-07-14 11:09:10 -0700104}
105
Elyes HAOUAS3c8b5d02018-05-27 16:57:24 +0200106static void pci_domain_set_resources(struct device *dev)
Pratik Prajapati201fa8f2017-08-16 11:42:40 -0700107{
108 assign_resources(dev->link_list);
109}
110
111static 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 Zhao2b074d92017-08-17 14:25:24 -0700115 #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
116 .acpi_name = &soc_acpi_name,
117 #endif
Pratik Prajapati201fa8f2017-08-16 11:42:40 -0700118};
119
120static 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 Saha95b61752017-10-04 23:08:40 -0700125 .acpi_fill_ssdt_generator = generate_cpu_entries,
Pratik Prajapati201fa8f2017-08-16 11:42:40 -0700126};
127
Elyes HAOUAS3c8b5d02018-05-27 16:57:24 +0200128static void soc_enable(struct device *dev)
Pratik Prajapati201fa8f2017-08-16 11:42:40 -0700129{
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 Zhao2f764f72017-07-14 11:09:10 -0700137struct chip_operations soc_intel_cannonlake_ops = {
138 CHIP_NAME("Intel Cannonlake")
Pratik Prajapati201fa8f2017-08-16 11:42:40 -0700139 .enable_dev = &soc_enable,
Lijian Zhao2f764f72017-07-14 11:09:10 -0700140 .init = &soc_init_pre_device,
141};