Kyösti Mälkki | e75deb6 | 2014-06-26 09:12:54 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 Advanced Micro Devices, Inc. |
Dave Frodin | 83405a1 | 2014-06-05 11:49:04 -0600 | [diff] [blame^] | 5 | * Copyright (C) 2014 Sage Electronic Engineering, LLC |
Kyösti Mälkki | e75deb6 | 2014-06-26 09:12:54 +0300 | [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 |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include <console/console.h> |
| 22 | #include <device/device.h> |
| 23 | #include <device/pci.h> |
| 24 | #include <arch/io.h> |
Kyösti Mälkki | e75deb6 | 2014-06-26 09:12:54 +0300 | [diff] [blame] | 25 | #include <arch/acpi.h> |
| 26 | #include <northbridge/amd/agesa/BiosCallOuts.h> |
| 27 | #include <cpu/amd/agesa/s3_resume.h> |
| 28 | #include <northbridge/amd/agesa/agesawrapper.h> |
Dave Frodin | 83405a1 | 2014-06-05 11:49:04 -0600 | [diff] [blame^] | 29 | #include <southbridge/amd/amd_pci_util.h> |
| 30 | #include <southbridge/amd/agesa/hudson/pci_devs.h> |
| 31 | #include <northbridge/amd/agesa/family16kb/pci_devs.h> |
| 32 | |
| 33 | void set_pcie_reset(void); |
| 34 | void set_pcie_dereset(void); |
| 35 | |
| 36 | /*********************************************************** |
| 37 | * These arrays set up the FCH PCI_INTR registers 0xC00/0xC01. |
| 38 | * This table is responsible for physically routing the PIC and |
| 39 | * IOAPIC IRQs to the different PCI devices on the system. It |
| 40 | * is read and written via registers 0xC00/0xC01 as an |
| 41 | * Index/Data pair. These values are chipset and mainboard |
| 42 | * dependent and should be updated accordingly. |
| 43 | * |
| 44 | * These values are used by the PCI configuration space, |
| 45 | * MP Tables. TODO: Make ACPI use these values too. |
| 46 | */ |
| 47 | static const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE] = { |
| 48 | [0x00] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B, /* INTA# - INTH# */ |
| 49 | [0x08] = 0x00,0xF1,0x00,0x00,0x1F,0x1F,0x1F,0x1F, /* Misc-nil,0,1,2, INT from Serial irq */ |
| 50 | [0x10] = 0x1F,0x1F,0x1F,0x0A,0x1F,0x1F,0x1F,0x0A, /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerfMon, SD */ |
| 51 | [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, /* IMC INT0 - 5 */ |
| 52 | [0x30] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, /* USB Devs 18/19/20/22 INTA-C */ |
| 53 | [0x40] = 0x0B,0x0B, /* IDE, SATA */ |
| 54 | }; |
| 55 | |
| 56 | static const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE] = { |
| 57 | [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, /* INTA# - INTH# */ |
| 58 | [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F, /* Misc-nil,0,1,2, INT from Serial irq */ |
| 59 | [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x12,0x1F,0x10, /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon, SD */ |
| 60 | [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, /* IMC INT0 - 5 */ |
| 61 | [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12, /* USB Devs 18/19/22/20 INTA-C */ |
| 62 | [0x40] = 0x11,0x13, /* IDE, SATA */ |
| 63 | }; |
| 64 | |
| 65 | /* |
| 66 | * This table defines the index into the picr/intr_data |
| 67 | * tables for each device. Any enabled device and slot |
| 68 | * that uses hardware interrupts should have an entry |
| 69 | * in this table to define its index into the FCH |
| 70 | * PCI_INTR register 0xC00/0xC01. This index will define |
| 71 | * the interrupt that it should use. Putting PIRQ_A into |
| 72 | * the PIN A index for a device will tell that device to |
| 73 | * use PIC IRQ 10 if it uses PIN A for its hardware INT. |
| 74 | */ |
| 75 | static const struct pirq_struct mainboard_pirq_data[] = { |
| 76 | /* {PCI_devfn, {PIN A, PIN B, PIN C, PIN D}}, */ |
| 77 | {GFX_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */ |
| 78 | {NB_PCIE_PORT2_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.2 */ |
| 79 | {NB_PCIE_PORT3_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.3 */ |
| 80 | {NB_PCIE_PORT4_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.4 */ |
| 81 | {NB_PCIE_PORT5_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 02.5 */ |
| 82 | {SATA_DEVFN, {PIRQ_SATA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SATA: 11.0 */ |
| 83 | {OHCI1_DEVFN, {PIRQ_OHCI1, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI1: 12.0 */ |
| 84 | {EHCI1_DEVFN, {PIRQ_NC, PIRQ_EHCI1, PIRQ_NC, PIRQ_NC}}, /* EHCI1: 12.2 */ |
| 85 | {OHCI2_DEVFN, {PIRQ_OHCI2, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI2: 13.0 */ |
| 86 | {EHCI2_DEVFN, {PIRQ_NC, PIRQ_EHCI2, PIRQ_NC, PIRQ_NC}}, /* EHCI2: 13.2 */ |
| 87 | {SMBUS_DEVFN, {PIRQ_SMBUS, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SMBUS: 14.0 */ |
| 88 | {HDA_DEVFN, {PIRQ_HDA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* HDA: 14.2 */ |
| 89 | {SB_PCI_PORT_DEVFN, {PIRQ_H, PIRQ_E, PIRQ_F, PIRQ_G}}, /* PCIB: 14.4 */ |
| 90 | {SD_DEVFN, {PIRQ_SD, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SD: 14.7 */ |
| 91 | {OHCI3_DEVFN, {PIRQ_OHCI3, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI3: 16.0 */ |
| 92 | {EHCI3_DEVFN, {PIRQ_NC, PIRQ_EHCI3, PIRQ_NC, PIRQ_NC}}, /* EHCI3: 16.2 */ |
| 93 | }; |
| 94 | |
| 95 | /* PIRQ Setup */ |
| 96 | static void pirq_setup(void) |
| 97 | { |
| 98 | pirq_data_ptr = mainboard_pirq_data; |
| 99 | pirq_data_size = sizeof(mainboard_pirq_data) / sizeof(struct pirq_struct); |
| 100 | intr_data_ptr = mainboard_intr_data; |
| 101 | picr_data_ptr = mainboard_picr_data; |
| 102 | } |
| 103 | |
| 104 | /* TODO: mainboard specific SB AGESA callback */ |
| 105 | void set_pcie_reset(void) |
| 106 | { |
| 107 | } |
| 108 | |
| 109 | /* TODO: mainboard specific SB AGESA callback */ |
| 110 | void set_pcie_dereset(void) |
| 111 | { |
| 112 | } |
Kyösti Mälkki | e75deb6 | 2014-06-26 09:12:54 +0300 | [diff] [blame] | 113 | |
| 114 | /********************************************** |
Dave Frodin | 83405a1 | 2014-06-05 11:49:04 -0600 | [diff] [blame^] | 115 | * Enable the dedicated functions of the board. |
Kyösti Mälkki | e75deb6 | 2014-06-26 09:12:54 +0300 | [diff] [blame] | 116 | **********************************************/ |
| 117 | static void mainboard_enable(device_t dev) |
| 118 | { |
| 119 | printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n"); |
| 120 | |
| 121 | if (acpi_is_wakeup_s3()) |
| 122 | agesawrapper_fchs3earlyrestore(); |
Dave Frodin | 83405a1 | 2014-06-05 11:49:04 -0600 | [diff] [blame^] | 123 | |
| 124 | /* Initialize the PIRQ data structures for consumption */ |
| 125 | pirq_setup(); |
Kyösti Mälkki | e75deb6 | 2014-06-26 09:12:54 +0300 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | struct chip_operations mainboard_ops = { |
| 129 | .enable_dev = mainboard_enable, |
| 130 | }; |