blob: 6bdb7b4d287ab9261bb72d28ebf351ff2d42bc4a [file] [log] [blame]
Martin Roth433659a2014-05-12 21:55:00 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
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.
Martin Roth433659a2014-05-12 21:55:00 -060014 */
15
16#include <console/console.h>
17#include <device/device.h>
18#include <device/pci.h>
Ben Gardnerfa6014a2015-12-08 21:20:25 -060019#include <soc/pci_devs.h>
20#include <soc/ramstage.h>
Marc Jones78687972015-04-22 23:16:31 -060021#include <drivers/intel/fsp1_0/fsp_util.h>
Martin Roth433659a2014-05-12 21:55:00 -060022#include "chip.h"
23
24static void pci_domain_set_resources(device_t dev)
25{
26 assign_resources(dev->link_list);
27}
28
Martin Roth433659a2014-05-12 21:55:00 -060029static struct device_operations pci_domain_ops = {
30 .read_resources = pci_domain_read_resources,
31 .set_resources = pci_domain_set_resources,
32 .enable_resources = NULL,
33 .init = NULL,
Martin Roth433659a2014-05-12 21:55:00 -060034 .scan_bus = pci_domain_scan_bus,
35 .ops_pci_bus = pci_bus_default_ops,
36};
37
Martin Roth433659a2014-05-12 21:55:00 -060038static struct device_operations cpu_bus_ops = {
Edward O'Callaghan0625a8b2014-10-31 08:03:16 +110039 .read_resources = DEVICE_NOOP,
40 .set_resources = DEVICE_NOOP,
41 .enable_resources = DEVICE_NOOP,
Martin Roth433659a2014-05-12 21:55:00 -060042 .init = baytrail_init_cpus,
43 .scan_bus = NULL,
44};
45
46static void enable_dev(device_t dev)
47{
48 printk(BIOS_DEBUG, "enable_dev(%s, %d)\n",
49 dev_name(dev), dev->path.type);
50
51 /* Set the operations if it is a special bus type */
52 if (dev->path.type == DEVICE_PATH_DOMAIN) {
53 dev->ops = &pci_domain_ops;
54 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
55 dev->ops = &cpu_bus_ops;
56 } else if (dev->path.type == DEVICE_PATH_PCI) {
57 /* Handle south cluster enablement. */
58 if (PCI_SLOT(dev->path.pci.devfn) > GFX_DEV &&
59 (dev->ops == NULL || dev->ops->enable == NULL)) {
60 southcluster_enable_dev(dev);
61 }
62 }
63}
64
Martin Roth433659a2014-05-12 21:55:00 -060065/* Called at BS_DEV_INIT_CHIPS time -- very early. Just after BS_PRE_DEVICE. */
66static void soc_init(void *chip_info)
67{
68 baytrail_init_pre_device();
69}
70
71struct chip_operations soc_intel_fsp_baytrail_ops = {
72 CHIP_NAME("Intel BayTrail SoC")
73 .enable_dev = enable_dev,
74 .init = soc_init,
Martin Roth433659a2014-05-12 21:55:00 -060075};
76
77static void pci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
78{
79 if (!vendor || !device) {
80 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
81 pci_read_config32(dev, PCI_VENDOR_ID));
82 } else {
83 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
84 ((device & 0xffff) << 16) | (vendor & 0xffff));
85 }
86}
87
88struct pci_operations soc_pci_ops = {
89 .set_subsystem = &pci_set_subsystem,
90};