zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2010 Advanced Micro Devices, Inc. |
Dave Frodin | 2093c4f | 2014-06-13 08:12:48 -0600 | [diff] [blame] | 5 | * Copyright (C) 2014 Sage Electronic Engineering, LLC. |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
Paul Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include <console/console.h> |
| 22 | #include <device/device.h> |
| 23 | #include <device/pci.h> |
| 24 | #include <device/pci_ids.h> |
| 25 | #include <device/pci_ops.h> |
| 26 | #include "hudson.h" |
Stefan Reinauer | 13e4182 | 2015-04-27 14:02:36 -0700 | [diff] [blame^] | 27 | #include <southbridge/amd/common/amd_pci_util.h> |
Dave Frodin | 2093c4f | 2014-06-13 08:12:48 -0600 | [diff] [blame] | 28 | #include <bootstate.h> |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 29 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 30 | |
Dave Frodin | 2093c4f | 2014-06-13 08:12:48 -0600 | [diff] [blame] | 31 | /* |
| 32 | * Update the PCI devices with a valid IRQ number |
| 33 | * that is set in the mainboard PCI_IRQ structures. |
| 34 | */ |
| 35 | static void set_pci_irqs(void *unused) |
| 36 | { |
| 37 | /* Write PCI_INTR regs 0xC00/0xC01 */ |
| 38 | write_pci_int_table(); |
| 39 | |
| 40 | /* Write IRQs for all devicetree enabled devices */ |
| 41 | write_pci_cfg_irqs(); |
| 42 | } |
| 43 | |
| 44 | /* |
| 45 | * Hook this function into the PCI state machine |
| 46 | * on entry into BS_DEV_ENABLE. |
| 47 | */ |
Aaron Durbin | 9ef9d85 | 2015-03-16 17:30:09 -0500 | [diff] [blame] | 48 | 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] | 49 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 50 | static struct pci_operations lops_pci = { |
| 51 | .set_subsystem = 0, |
| 52 | }; |
| 53 | |
| 54 | static struct device_operations pci_ops = { |
| 55 | .read_resources = pci_bus_read_resources, |
| 56 | .set_resources = pci_dev_set_resources, |
| 57 | .enable_resources = pci_bus_enable_resources, |
Edward O'Callaghan | 8be82e1 | 2014-11-27 14:36:13 +1100 | [diff] [blame] | 58 | .init = DEVICE_NOOP, |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 59 | .scan_bus = pci_scan_bridge, |
| 60 | .reset_bus = pci_bus_reset, |
| 61 | .ops_pci = &lops_pci, |
| 62 | }; |
| 63 | |
| 64 | static const struct pci_driver pci_driver __pci_driver = { |
| 65 | .ops = &pci_ops, |
| 66 | .vendor = PCI_VENDOR_ID_AMD, |
| 67 | .device = PCI_DEVICE_ID_ATI_SB900_PCI, |
| 68 | }; |