blob: b8db3953501b4b6ea14073f91d4620ff7e97b264 [file] [log] [blame]
York Yangd7cba282016-03-09 10:54:26 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
5 * Copyright (C) 2015-2016 Intel Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <lib.h>
18#include <string.h>
19#include <bootstate.h>
20#include <console/console.h>
21#include <device/device.h>
22#include <device/pci.h>
23#include <drivers/intel/fsp1_0/fsp_util.h>
24#include <soc/pci_devs.h>
25#include <soc/ramstage.h>
26#include <chip.h>
27
28static void pci_domain_set_resources(device_t dev)
29{
30 assign_resources(dev->link_list);
31}
32
33static struct device_operations pci_domain_ops = {
34 .read_resources = pci_domain_read_resources,
35 .set_resources = pci_domain_set_resources,
36 .enable_resources = NULL,
37 .init = NULL,
38 .scan_bus = pci_domain_scan_bus,
39 .ops_pci_bus = pci_bus_default_ops,
40};
41
42static struct device_operations cpu_bus_ops = {
43 .read_resources = DEVICE_NOOP,
44 .set_resources = DEVICE_NOOP,
45 .enable_resources = DEVICE_NOOP,
46 .init = broadwell_de_init_cpus,
47 .scan_bus = NULL,
48};
49
50static void enable_dev(device_t dev)
51{
52 printk(BIOS_DEBUG, "enable_dev(%s, %d)\n",
53 dev_name(dev), dev->path.type);
54
55 /* Set the operations if it is a special bus type */
56 if (dev->path.type == DEVICE_PATH_DOMAIN) {
57 dev->ops = &pci_domain_ops;
58 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
59 dev->ops = &cpu_bus_ops;
60 } else if (dev->path.type == DEVICE_PATH_PCI) {
61 /* Handle south cluster enablement. */
62 if (PCI_SLOT(dev->path.pci.devfn) > 0 &&
63 (dev->ops == NULL || dev->ops->enable == NULL)) {
64 southcluster_enable_dev(dev);
65 }
66 }
67}
68
York Yangd7cba282016-03-09 10:54:26 -080069/* Called at BS_DEV_INIT_CHIPS time -- very early. Just after BS_PRE_DEVICE. */
70static void soc_init(void *chip_info)
71{
York Yangd7cba282016-03-09 10:54:26 -080072 broadwell_de_init_pre_device();
73}
74
75struct chip_operations soc_intel_fsp_broadwell_de_ops = {
76 CHIP_NAME("Intel(R) Xeon(R) Processor D-1500 Product Family")
77 .enable_dev = enable_dev,
78 .init = soc_init,
79};
80
81static void pci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
82{
83 if (!vendor || !device) {
84 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
85 pci_read_config32(dev, PCI_VENDOR_ID));
86 } else {
87 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
88 ((device & 0xffff) << 16) | (vendor & 0xffff));
89 }
90}
91
92struct pci_operations soc_pci_ops = {
93 .set_subsystem = &pci_set_subsystem,
94};