Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [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. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <console/console.h> |
| 21 | #include <device/device.h> |
| 22 | #include <device/pci.h> |
| 23 | #include <arch/pci_ops.h> |
| 24 | |
| 25 | #include <baytrail/pci_devs.h> |
| 26 | #include <baytrail/ramstage.h> |
| 27 | #include "chip.h" |
| 28 | |
| 29 | static void pci_domain_set_resources(device_t dev) |
| 30 | { |
| 31 | assign_resources(dev->link_list); |
| 32 | } |
| 33 | |
| 34 | static struct device_operations pci_domain_ops = { |
| 35 | .read_resources = pci_domain_read_resources, |
| 36 | .set_resources = pci_domain_set_resources, |
| 37 | .enable_resources = NULL, |
| 38 | .init = NULL, |
| 39 | .scan_bus = pci_domain_scan_bus, |
| 40 | .ops_pci_bus = pci_bus_default_ops, |
| 41 | }; |
| 42 | |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 43 | static struct device_operations cpu_bus_ops = { |
Edward O'Callaghan | 0625a8b | 2014-10-31 08:03:16 +1100 | [diff] [blame^] | 44 | .read_resources = DEVICE_NOOP, |
| 45 | .set_resources = DEVICE_NOOP, |
| 46 | .enable_resources = DEVICE_NOOP, |
Aaron Durbin | 302cbd6 | 2013-10-21 12:36:17 -0500 | [diff] [blame] | 47 | .init = baytrail_init_cpus, |
Aaron Durbin | fda56a6 | 2013-09-24 12:29:57 -0500 | [diff] [blame] | 48 | .scan_bus = NULL, |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | |
| 52 | static void enable_dev(device_t dev) |
| 53 | { |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 54 | /* Set the operations if it is a special bus type */ |
| 55 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
| 56 | dev->ops = &pci_domain_ops; |
| 57 | } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
| 58 | dev->ops = &cpu_bus_ops; |
Aaron Durbin | d7bc23a | 2013-10-29 16:37:10 -0500 | [diff] [blame] | 59 | } else if (dev->path.type == DEVICE_PATH_PCI) { |
| 60 | /* Handle south cluster enablement. */ |
| 61 | if (PCI_SLOT(dev->path.pci.devfn) > GFX_DEV && |
| 62 | (dev->ops == NULL || dev->ops->enable == NULL)) { |
| 63 | southcluster_enable_dev(dev); |
| 64 | } |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | |
Aaron Durbin | 452d31a | 2013-09-24 16:47:49 -0500 | [diff] [blame] | 68 | /* Called at BS_DEV_INIT_CHIPS time -- very early. Just after BS_PRE_DEVICE. */ |
| 69 | static void soc_init(void *chip_info) |
| 70 | { |
Kein Yuan | 3511023 | 2014-02-22 12:26:55 -0800 | [diff] [blame] | 71 | baytrail_init_pre_device(chip_info); |
Aaron Durbin | 452d31a | 2013-09-24 16:47:49 -0500 | [diff] [blame] | 72 | } |
| 73 | |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 74 | struct chip_operations soc_intel_baytrail_ops = { |
| 75 | CHIP_NAME("Intel BayTrail SoC") |
| 76 | .enable_dev = enable_dev, |
Aaron Durbin | 452d31a | 2013-09-24 16:47:49 -0500 | [diff] [blame] | 77 | .init = soc_init, |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 78 | }; |
Aaron Durbin | fda56a6 | 2013-09-24 12:29:57 -0500 | [diff] [blame] | 79 | |
| 80 | static void pci_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 81 | { |
| 82 | if (!vendor || !device) { |
| 83 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 84 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 85 | } else { |
| 86 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 87 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | struct pci_operations soc_pci_ops = { |
| 92 | .set_subsystem = &pci_set_subsystem, |
| 93 | }; |