zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; version 2 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 13 | */ |
| 14 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 15 | #include <device/device.h> |
| 16 | #include <device/pci.h> |
| 17 | #include <device/pci_ids.h> |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 18 | #include "hudson.h" |
Stefan Reinauer | 13e4182 | 2015-04-27 14:02:36 -0700 | [diff] [blame] | 19 | #include <southbridge/amd/common/amd_pci_util.h> |
Dave Frodin | 2093c4f | 2014-06-13 08:12:48 -0600 | [diff] [blame] | 20 | #include <bootstate.h> |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 21 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 22 | |
Dave Frodin | 2093c4f | 2014-06-13 08:12:48 -0600 | [diff] [blame] | 23 | /* |
| 24 | * Update the PCI devices with a valid IRQ number |
| 25 | * that is set in the mainboard PCI_IRQ structures. |
| 26 | */ |
| 27 | static void set_pci_irqs(void *unused) |
| 28 | { |
| 29 | /* Write PCI_INTR regs 0xC00/0xC01 */ |
| 30 | write_pci_int_table(); |
| 31 | |
| 32 | /* Write IRQs for all devicetree enabled devices */ |
| 33 | write_pci_cfg_irqs(); |
| 34 | } |
| 35 | |
| 36 | /* |
| 37 | * Hook this function into the PCI state machine |
| 38 | * on entry into BS_DEV_ENABLE. |
| 39 | */ |
Aaron Durbin | 9ef9d85 | 2015-03-16 17:30:09 -0500 | [diff] [blame] | 40 | BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, set_pci_irqs, NULL); |
Dave Frodin | 2093c4f | 2014-06-13 08:12:48 -0600 | [diff] [blame] | 41 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 42 | static struct pci_operations lops_pci = { |
| 43 | .set_subsystem = 0, |
| 44 | }; |
| 45 | |
| 46 | static struct device_operations pci_ops = { |
| 47 | .read_resources = pci_bus_read_resources, |
| 48 | .set_resources = pci_dev_set_resources, |
| 49 | .enable_resources = pci_bus_enable_resources, |
Edward O'Callaghan | 8be82e1 | 2014-11-27 14:36:13 +1100 | [diff] [blame] | 50 | .init = DEVICE_NOOP, |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 51 | .scan_bus = pci_scan_bridge, |
| 52 | .reset_bus = pci_bus_reset, |
| 53 | .ops_pci = &lops_pci, |
| 54 | }; |
| 55 | |
| 56 | static const struct pci_driver pci_driver __pci_driver = { |
| 57 | .ops = &pci_ops, |
| 58 | .vendor = PCI_VENDOR_ID_AMD, |
Kyösti Mälkki | 9d9a552 | 2016-11-19 22:14:59 +0200 | [diff] [blame] | 59 | .device = PCI_DEVICE_ID_AMD_SB900_PCI, |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 60 | }; |