Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 3 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 4 | #include <device/device.h> |
| 5 | #include <device/pci.h> |
| 6 | #include <device/pci_ids.h> |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 7 | #include "hudson.h" |
Stefan Reinauer | 13e4182 | 2015-04-27 14:02:36 -0700 | [diff] [blame] | 8 | #include <southbridge/amd/common/amd_pci_util.h> |
Dave Frodin | 2093c4f | 2014-06-13 08:12:48 -0600 | [diff] [blame] | 9 | #include <bootstate.h> |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 10 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 11 | |
Dave Frodin | 2093c4f | 2014-06-13 08:12:48 -0600 | [diff] [blame] | 12 | /* |
| 13 | * Update the PCI devices with a valid IRQ number |
| 14 | * that is set in the mainboard PCI_IRQ structures. |
| 15 | */ |
| 16 | static void set_pci_irqs(void *unused) |
| 17 | { |
| 18 | /* Write PCI_INTR regs 0xC00/0xC01 */ |
| 19 | write_pci_int_table(); |
| 20 | |
| 21 | /* Write IRQs for all devicetree enabled devices */ |
| 22 | write_pci_cfg_irqs(); |
| 23 | } |
| 24 | |
| 25 | /* |
| 26 | * Hook this function into the PCI state machine |
| 27 | * on entry into BS_DEV_ENABLE. |
| 28 | */ |
Aaron Durbin | 9ef9d85 | 2015-03-16 17:30:09 -0500 | [diff] [blame] | 29 | 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] | 30 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 31 | static struct pci_operations lops_pci = { |
| 32 | .set_subsystem = 0, |
| 33 | }; |
| 34 | |
| 35 | static struct device_operations pci_ops = { |
| 36 | .read_resources = pci_bus_read_resources, |
| 37 | .set_resources = pci_dev_set_resources, |
| 38 | .enable_resources = pci_bus_enable_resources, |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 39 | .scan_bus = pci_scan_bridge, |
| 40 | .reset_bus = pci_bus_reset, |
| 41 | .ops_pci = &lops_pci, |
| 42 | }; |
| 43 | |
| 44 | static const struct pci_driver pci_driver __pci_driver = { |
| 45 | .ops = &pci_ops, |
| 46 | .vendor = PCI_VENDOR_ID_AMD, |
Kyösti Mälkki | 9d9a552 | 2016-11-19 22:14:59 +0200 | [diff] [blame] | 47 | .device = PCI_DEVICE_ID_AMD_SB900_PCI, |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 48 | }; |