Sergej Ivanov | d777c78 | 2015-04-03 18:10:27 +0300 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 Advanced Micro Devices, Inc. |
| 5 | * Copyright (C) 2014 Sage Electronic Engineering, LLC |
| 6 | * Copyright (C) 2015 Sergej Ivanov <getinaks@gmail.com> |
| 7 | * All Rights Reserved |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; version 2 of the License. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ |
| 22 | |
| 23 | #include <console/console.h> |
| 24 | #include <device/device.h> |
| 25 | #include <device/pci.h> |
| 26 | #include <arch/io.h> |
| 27 | #include <cpu/x86/msr.h> |
| 28 | #include <cpu/amd/mtrr.h> |
| 29 | #include <device/pci_def.h> |
| 30 | #include <arch/acpi.h> |
| 31 | #include <northbridge/amd/agesa/BiosCallOuts.h> |
| 32 | #include <cpu/amd/agesa/s3_resume.h> |
| 33 | #include <northbridge/amd/agesa/agesawrapper.h> |
| 34 | #include <southbridge/amd/agesa/hudson/pci_devs.h> |
| 35 | #include <southbridge/amd/agesa/hudson/amd_pci_int_defs.h> |
| 36 | #include <southbridge/amd/amd_pci_util.h> |
| 37 | #include <northbridge/amd/agesa/family16kb/pci_devs.h> |
| 38 | |
| 39 | const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE] = { |
| 40 | /* INTA# - INTH# */ |
| 41 | [0x00] = 0x03,0x04,0x05,0x07,0x0B,0x0A,0x1F,0x1F, |
| 42 | /* Misc-nil,0,1,2, INT from Serial irq */ |
| 43 | [0x08] = 0x5A,0xF1,0x00,0x00,0x1F,0x1F,0x1F,0x1F, |
| 44 | /* SCI, SMBUS0, ASF, HDA, FC, RSVD, PerMon, SD */ |
| 45 | [0x10] = 0x1F,0x1F,0x1F,0x03,0x1F,0x1F,0x1F,0x1F, // HDA was 1F - now 03 |
| 46 | /* IMC INT0 - 5 */ |
| 47 | [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, |
| 48 | /* USB Devs 18/19/22 INTA-C */ |
| 49 | [0x30] = 0x05,0x04,0x05,0x04,0x04,0x05,0x04,0x05, |
| 50 | /* SATA & MISSING IDE */ |
| 51 | [0x40] = 0x04, 0x04 |
| 52 | }; |
| 53 | |
| 54 | const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE] = { |
| 55 | /* INTA# - INTH# */ |
| 56 | [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, |
| 57 | /* Misc-nil,0,1,2, INT from Serial irq */ |
| 58 | [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F, |
| 59 | /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon, SD */ |
| 60 | [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x10,0x1F,0x10,0x1F,0x1F, |
| 61 | /* IMC INT0 - 5 */ |
| 62 | [0x20] = 0x05,0x1F,0x1F,0x1F,0x1F,0x1F, |
| 63 | /* USB Devs 18/19/20/22 INTA-C */ |
| 64 | [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12, |
| 65 | /* SATA & MISSING IDE*/ |
| 66 | [0x40] = 0x11, 0x11 |
| 67 | }; |
| 68 | |
| 69 | /* |
| 70 | * This table defines the index into the picr/intr_data |
| 71 | * tables for each device. Any enabled device and slot |
| 72 | * that uses hardware interrupts should have an entry |
| 73 | * in this table to define its index into the FCH |
| 74 | * PCI_INTR register 0xC00/0xC01. This index will define |
| 75 | * the interrupt that it should use. Putting PIRQ_A into |
| 76 | * the PIN A index for a device will tell that device to |
| 77 | * use PIC IRQ 10 if it uses PIN A for its hardware INT. |
| 78 | */ |
| 79 | static const struct pirq_struct mainboard_pirq_data[] = { |
| 80 | /* {PCI_devfn, {PIN A, PIN B, PIN C, PIN D}}, */ |
| 81 | {GFX_DEVFN, {PIRQ_A, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */ |
| 82 | {ACTL_DEVFN,{PIRQ_NC, PIRQ_B, PIRQ_NC, PIRQ_NC}}, /* Audio: 01.1 */ |
| 83 | {NB_PCIE_PORT1_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* x4 PCIe: 02.1 */ |
| 84 | {NB_PCIE_PORT2_DEVFN, {PIRQ_B, PIRQ_C, PIRQ_D, PIRQ_A}}, /* mPCIe: 02.2 */ |
| 85 | {NB_PCIE_PORT3_DEVFN, {PIRQ_C, PIRQ_D, PIRQ_A, PIRQ_B}}, /* NIC: 02.3 */ |
| 86 | {NB_PCIE_PORT4_DEVFN, {PIRQ_D, PIRQ_A, PIRQ_B, PIRQ_C}}, /* Edge: 02.4 */ |
| 87 | {NB_PCIE_PORT5_DEVFN, {PIRQ_E, PIRQ_F, PIRQ_G, PIRQ_H}}, /* Edge: 02.5 */ |
| 88 | {XHCI_DEVFN, {PIRQ_C, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* XHCI: 10.0 */ |
| 89 | {SATA_DEVFN, {PIRQ_SATA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SATA: 11.0 */ |
| 90 | {OHCI1_DEVFN, {PIRQ_OHCI1, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI1: 12.0 */ |
| 91 | {EHCI1_DEVFN, {PIRQ_NC, PIRQ_EHCI1, PIRQ_NC, PIRQ_NC}}, /* EHCI1: 12.2 */ |
| 92 | {OHCI2_DEVFN, {PIRQ_OHCI2, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI2: 13.0 */ |
| 93 | {EHCI2_DEVFN, {PIRQ_NC, PIRQ_EHCI2, PIRQ_NC, PIRQ_NC}}, /* EHCI2: 13.2 */ |
| 94 | {SMBUS_DEVFN, {PIRQ_SMBUS, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SMBUS: 14.0 */ |
| 95 | {HDA_DEVFN, {PIRQ_HDA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* HDA: 14.2 */ |
| 96 | {LPC_DEVFN, {PIRQ_C, PIRQ_NC, PIRQ_NC, PIRQ_NC }}, /* LPC: 14.3 */ |
| 97 | {SD_DEVFN, {PIRQ_SD, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SD: 14.7 */ |
| 98 | }; |
| 99 | |
| 100 | const u8 *picr_data = mainboard_picr_data; |
| 101 | const u8 *intr_data = mainboard_intr_data; |
| 102 | |
| 103 | /* PIRQ Setup */ |
| 104 | static void pirq_setup(void) |
| 105 | { |
| 106 | pirq_data_ptr = mainboard_pirq_data; |
| 107 | pirq_data_size = sizeof(mainboard_pirq_data) / sizeof(struct pirq_struct); |
| 108 | intr_data_ptr = mainboard_intr_data; |
| 109 | picr_data_ptr = mainboard_picr_data; |
| 110 | } |
| 111 | |
| 112 | /********************************************** |
| 113 | * enable the dedicated function in mainboard. |
| 114 | **********************************************/ |
| 115 | static void mainboard_enable(device_t dev) |
| 116 | { |
| 117 | printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n"); |
| 118 | |
| 119 | if (acpi_is_wakeup_s3()) |
| 120 | agesawrapper_fchs3earlyrestore(); |
| 121 | |
| 122 | /* Initialize the PIRQ data structures for consumption */ |
| 123 | pirq_setup(); |
| 124 | } |
| 125 | |
| 126 | struct chip_operations mainboard_ops = { |
| 127 | .enable_dev = mainboard_enable, |
| 128 | }; |