Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [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. |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 13 | */ |
| 14 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 15 | #include <device/device.h> |
| 16 | #include <device/pci.h> |
| 17 | #include <device/pci_ids.h> |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [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> |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 20 | #include <bootstate.h> |
| 21 | |
| 22 | static void pci_init(struct device *dev) |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | /* |
| 27 | * Update the PCI devices with a valid IRQ number |
| 28 | * that is set in the mainboard PCI_IRQ structures. |
| 29 | */ |
| 30 | static void set_pci_irqs(void *unused) |
| 31 | { |
| 32 | /* Write PCI_INTR regs 0xC00/0xC01 */ |
| 33 | write_pci_int_table(); |
| 34 | |
| 35 | /* Write IRQs for all devicetree enabled devices */ |
| 36 | write_pci_cfg_irqs(); |
| 37 | } |
| 38 | |
| 39 | /* |
| 40 | * Hook this function into the PCI state machine |
| 41 | * on entry into BS_DEV_ENABLE. |
| 42 | */ |
Aaron Durbin | 9ef9d85 | 2015-03-16 17:30:09 -0500 | [diff] [blame] | 43 | BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, set_pci_irqs, NULL); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 44 | |
| 45 | static struct pci_operations lops_pci = { |
| 46 | .set_subsystem = 0, |
| 47 | }; |
| 48 | |
| 49 | static struct device_operations pci_ops = { |
| 50 | .read_resources = pci_bus_read_resources, |
| 51 | .set_resources = pci_dev_set_resources, |
| 52 | .enable_resources = pci_bus_enable_resources, |
| 53 | .init = pci_init, |
| 54 | .scan_bus = pci_scan_bridge, |
| 55 | .reset_bus = pci_bus_reset, |
| 56 | .ops_pci = &lops_pci, |
| 57 | }; |
| 58 | |
| 59 | static const struct pci_driver pci_driver __pci_driver = { |
| 60 | .ops = &pci_ops, |
| 61 | .vendor = PCI_VENDOR_ID_AMD, |
Kyösti Mälkki | 9d9a552 | 2016-11-19 22:14:59 +0200 | [diff] [blame] | 62 | .device = PCI_DEVICE_ID_AMD_SB900_PCI, |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 63 | }; |