blob: e8f316a1dd91b6caa286405c5fff1f574e01cef9 [file] [log] [blame]
zbao246e84b2012-07-13 18:47:03 +08001/*
2 * This file is part of the coreboot project.
3 *
zbao246e84b2012-07-13 18:47:03 +08004 *
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.
zbao246e84b2012-07-13 18:47:03 +080013 */
14
zbao246e84b2012-07-13 18:47:03 +080015#include <device/device.h>
16#include <device/pci.h>
17#include <device/pci_ids.h>
zbao246e84b2012-07-13 18:47:03 +080018#include "hudson.h"
Stefan Reinauer13e41822015-04-27 14:02:36 -070019#include <southbridge/amd/common/amd_pci_util.h>
Dave Frodin2093c4f2014-06-13 08:12:48 -060020#include <bootstate.h>
zbao246e84b2012-07-13 18:47:03 +080021
zbao246e84b2012-07-13 18:47:03 +080022
Dave Frodin2093c4f2014-06-13 08:12:48 -060023/*
24 * Update the PCI devices with a valid IRQ number
25 * that is set in the mainboard PCI_IRQ structures.
26 */
27static 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 Durbin9ef9d852015-03-16 17:30:09 -050040BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, set_pci_irqs, NULL);
Dave Frodin2093c4f2014-06-13 08:12:48 -060041
zbao246e84b2012-07-13 18:47:03 +080042static struct pci_operations lops_pci = {
43 .set_subsystem = 0,
44};
45
46static 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'Callaghan8be82e12014-11-27 14:36:13 +110050 .init = DEVICE_NOOP,
zbao246e84b2012-07-13 18:47:03 +080051 .scan_bus = pci_scan_bridge,
52 .reset_bus = pci_bus_reset,
53 .ops_pci = &lops_pci,
54};
55
56static const struct pci_driver pci_driver __pci_driver = {
57 .ops = &pci_ops,
58 .vendor = PCI_VENDOR_ID_AMD,
Kyösti Mälkki9d9a5522016-11-19 22:14:59 +020059 .device = PCI_DEVICE_ID_AMD_SB900_PCI,
zbao246e84b2012-07-13 18:47:03 +080060};