Martin Roth | 433659a | 2014-05-12 21:55:00 -0600 | [diff] [blame] | 1 | /* |
| 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 Roth | 433659a | 2014-05-12 21:55:00 -0600 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <console/console.h> |
| 17 | #include <device/device.h> |
| 18 | #include <device/pci.h> |
Ben Gardner | fa6014a | 2015-12-08 21:20:25 -0600 | [diff] [blame^] | 19 | #include <soc/pci_devs.h> |
| 20 | #include <soc/ramstage.h> |
Marc Jones | 7868797 | 2015-04-22 23:16:31 -0600 | [diff] [blame] | 21 | #include <drivers/intel/fsp1_0/fsp_util.h> |
Martin Roth | 433659a | 2014-05-12 21:55:00 -0600 | [diff] [blame] | 22 | #include "chip.h" |
| 23 | |
| 24 | static void pci_domain_set_resources(device_t dev) |
| 25 | { |
| 26 | assign_resources(dev->link_list); |
| 27 | } |
| 28 | |
Martin Roth | 433659a | 2014-05-12 21:55:00 -0600 | [diff] [blame] | 29 | static 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 Roth | 433659a | 2014-05-12 21:55:00 -0600 | [diff] [blame] | 34 | .scan_bus = pci_domain_scan_bus, |
| 35 | .ops_pci_bus = pci_bus_default_ops, |
| 36 | }; |
| 37 | |
Martin Roth | 433659a | 2014-05-12 21:55:00 -0600 | [diff] [blame] | 38 | static struct device_operations cpu_bus_ops = { |
Edward O'Callaghan | 0625a8b | 2014-10-31 08:03:16 +1100 | [diff] [blame] | 39 | .read_resources = DEVICE_NOOP, |
| 40 | .set_resources = DEVICE_NOOP, |
| 41 | .enable_resources = DEVICE_NOOP, |
Martin Roth | 433659a | 2014-05-12 21:55:00 -0600 | [diff] [blame] | 42 | .init = baytrail_init_cpus, |
| 43 | .scan_bus = NULL, |
| 44 | }; |
| 45 | |
| 46 | static 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 Roth | 433659a | 2014-05-12 21:55:00 -0600 | [diff] [blame] | 65 | /* Called at BS_DEV_INIT_CHIPS time -- very early. Just after BS_PRE_DEVICE. */ |
| 66 | static void soc_init(void *chip_info) |
| 67 | { |
| 68 | baytrail_init_pre_device(); |
| 69 | } |
| 70 | |
| 71 | struct chip_operations soc_intel_fsp_baytrail_ops = { |
| 72 | CHIP_NAME("Intel BayTrail SoC") |
| 73 | .enable_dev = enable_dev, |
| 74 | .init = soc_init, |
Martin Roth | 433659a | 2014-05-12 21:55:00 -0600 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | static 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 | |
| 88 | struct pci_operations soc_pci_ops = { |
| 89 | .set_subsystem = &pci_set_subsystem, |
| 90 | }; |