1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <device/device.h>
4 #include <device/pci.h>
5 #include <device/pci_ids.h>
6 #include "hudson.h"
7 #include <southbridge/amd/common/amd_pci_util.h>
8 #include <bootstate.h>
9
10 /*
11 * Update the PCI devices with a valid IRQ number
12 * that is set in the mainboard PCI_IRQ structures.
13 */
set_pci_irqs(void * unused)14 static void set_pci_irqs(void *unused)
15 {
16 /* Write PCI_INTR regs 0xC00/0xC01 */
17 write_pci_int_table();
18
19 /* Write IRQs for all devicetree enabled devices */
20 write_pci_cfg_irqs();
21 }
22
23 /*
24 * Hook this function into the PCI state machine
25 * on entry into BS_DEV_ENABLE.
26 */
27 BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, set_pci_irqs, NULL);
28
29 static struct pci_operations lops_pci = {
30 .set_subsystem = 0,
31 };
32
33 static struct device_operations pci_ops = {
34 .read_resources = pci_bus_read_resources,
35 .set_resources = pci_dev_set_resources,
36 .enable_resources = pci_bus_enable_resources,
37 .scan_bus = pci_scan_bridge,
38 .reset_bus = pci_bus_reset,
39 .ops_pci = &lops_pci,
40 };
41
42 static const struct pci_driver pci_driver __pci_driver = {
43 .ops = &pci_ops,
44 .vendor = PCI_VID_AMD,
45 .device = PCI_DID_AMD_SB900_PCI,
46 };
47