Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Advanced Micro Devices, Inc. |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 5 | * Copyright (C) 2013-2014 Sage Electronic Engineering, LLC |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [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> |
| 25 | #include <cpu/x86/msr.h> |
| 26 | #include <device/pci_def.h> |
| 27 | #include <southbridge/amd/amd_pci_util.h> |
| 28 | #include <southbridge/amd/cimx/cimx_util.h> |
| 29 | #include <arch/acpi.h> |
| 30 | #include <northbridge/amd/agesa/BiosCallOuts.h> |
| 31 | #include <cpu/amd/agesa/s3_resume.h> |
| 32 | #include <cpu/amd/mtrr.h> |
| 33 | #include "SBPLATFORM.h" |
| 34 | #include <southbridge/amd/cimx/sb800/pci_devs.h> |
| 35 | #include <northbridge/amd/agesa/family14/pci_devs.h> |
Kyösti Mälkki | 7809356 | 2014-11-11 17:22:23 +0200 | [diff] [blame] | 36 | #include "gpio_ftns.h" |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 37 | |
| 38 | void set_pcie_reset(void); |
| 39 | void set_pcie_dereset(void); |
| 40 | |
| 41 | /*********************************************************** |
| 42 | * These arrays set up the FCH PCI_INTR registers 0xC00/0xC01. |
| 43 | * This table is responsible for physically routing the PIC and |
| 44 | * IOAPIC IRQs to the different PCI devices on the system. It |
| 45 | * is read and written via registers 0xC00/0xC01 as an |
| 46 | * Index/Data pair. These values are chipset and mainboard |
| 47 | * dependent and should be updated accordingly. |
| 48 | * |
| 49 | * These values are used by the PCI configuration space, |
| 50 | * MP Tables. TODO: Make ACPI use these values too. |
| 51 | * |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 52 | * The PCI INTA/B/C/D pins are connected to |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 53 | * FCH pins INTE/F/G/H on the schematic so these need |
| 54 | * to be routed as well. |
| 55 | */ |
| 56 | static const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE] = { |
| 57 | /* INTA# - INTH# */ |
| 58 | [0x00] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B, |
| 59 | /* Misc-nil,0,1,2, INT from Serial irq */ |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 60 | [0x08] = 0x00,0xF1,0x00,0x00,0x1F,0x1F,0x1F,0x1F, |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 61 | /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerfMon */ |
| 62 | [0x10] = 0x1F,0x1F,0x1F,0x0A,0x1F,0x1F,0x1F, |
| 63 | /* IMC INT0 - 5 */ |
| 64 | [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, |
| 65 | /* USB Devs 18/19/20/22 INTA-C */ |
Kyösti Mälkki | 5d899c4 | 2015-01-14 12:58:53 +0200 | [diff] [blame^] | 66 | [0x30] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 67 | /* IDE, SATA */ |
| 68 | [0x40] = 0x0B,0x0B, |
| 69 | /* GPPInt0 - 3 */ |
| 70 | [0x50] = 0x0A,0x0B,0x0A,0x0B |
| 71 | }; |
| 72 | |
| 73 | static const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE] = { |
| 74 | /* INTA# - INTH# */ |
| 75 | [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, |
| 76 | /* Misc-nil,0,1,2, INT from Serial irq */ |
| 77 | [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F, |
| 78 | /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon */ |
| 79 | [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x12,0x1F, |
| 80 | /* IMC INT0 - 5 */ |
| 81 | [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, |
| 82 | /* USB Devs 18/19/22/20 INTA-C */ |
| 83 | [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12, |
| 84 | /* IDE, SATA */ |
| 85 | [0x40] = 0x11,0x13, |
| 86 | /* GPPInt0 - 3 */ |
| 87 | [0x50] = 0x10,0x11,0x12,0x13 |
| 88 | }; |
| 89 | |
| 90 | /* |
| 91 | * This table defines the index into the picr/intr_data |
| 92 | * tables for each device. Any enabled device and slot |
| 93 | * that uses hardware interrupts should have an entry |
| 94 | * in this table to define its index into the FCH |
| 95 | * PCI_INTR register 0xC00/0xC01. This index will define |
| 96 | * the interrupt that it should use. Putting PIRQ_A into |
| 97 | * the PIN A index for a device will tell that device to |
| 98 | * use PIC IRQ 10 if it uses PIN A for its hardware INT. |
| 99 | */ |
| 100 | /* |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 101 | * The PCI slot INTA/B/C/D connected to PIRQE/F/G/H |
| 102 | * but because of PCI INT_PIN swizzle isnt implemented to match |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 103 | * the IDSEL (dev 3) of the slot, the table is adjusted for the |
| 104 | * swizzle and INTA is connected to PIRQH so PINA/B/C/D on |
| 105 | * off-chip devices should get mapped to PIRQH/E/F/G. |
| 106 | */ |
| 107 | static const struct pirq_struct mainboard_pirq_data[] = { |
| 108 | /* {PCI_devfn, {PIN A, PIN B, PIN C, PIN D}}, */ |
| 109 | {GFX_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */ |
| 110 | {NB_PCIE_PORT1_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 04.0 */ |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 111 | {NB_PCIE_PORT2_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 05.0 */ |
| 112 | {NB_PCIE_PORT3_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 06.0 */ |
| 113 | {NB_PCIE_PORT4_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* miniPCIe: 07.0 */ |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 114 | {SATA_DEVFN, {PIRQ_SATA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SATA: 11.0 */ |
| 115 | {OHCI1_DEVFN, {PIRQ_OHCI1, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI1: 12.0 */ |
| 116 | {EHCI1_DEVFN, {PIRQ_NC, PIRQ_EHCI1, PIRQ_NC, PIRQ_NC}}, /* EHCI1: 12.2 */ |
| 117 | {OHCI2_DEVFN, {PIRQ_OHCI2, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI2: 13.0 */ |
| 118 | {EHCI2_DEVFN, {PIRQ_NC, PIRQ_EHCI2, PIRQ_NC, PIRQ_NC}}, /* EHCI2: 13.2 */ |
| 119 | {SMBUS_DEVFN, {PIRQ_SMBUS, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SMBUS: 14.0 */ |
| 120 | {IDE_DEVFN, {PIRQ_NC, PIRQ_IDE, PIRQ_NC, PIRQ_NC}}, /* IDE: 14.1 */ |
| 121 | {HDA_DEVFN, {PIRQ_HDA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* HDA: 14.2 */ |
| 122 | {SB_PCI_PORT_DEVFN, {PIRQ_H, PIRQ_E, PIRQ_F, PIRQ_G}}, /* PCI bdg: 14.4 */ |
| 123 | {OHCI4_DEVFN, {PIRQ_NC, PIRQ_NC, PIRQ_OHCI4, PIRQ_NC}}, /* OHCI4: 14.5 */ |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 124 | {SB_PCIE_PORT1_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* miniPCIe: 15.0 */ |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 125 | {OHCI3_DEVFN, {PIRQ_OHCI3, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI3: 16.0 */ |
| 126 | {EHCI3_DEVFN, {PIRQ_NC, PIRQ_EHCI3, PIRQ_NC, PIRQ_NC}}, /* EHCI3: 16.2 */ |
| 127 | }; |
| 128 | |
| 129 | /* PIRQ Setup */ |
| 130 | static void pirq_setup(void) |
| 131 | { |
| 132 | pirq_data_ptr = mainboard_pirq_data; |
| 133 | pirq_data_size = sizeof(mainboard_pirq_data) / sizeof(struct pirq_struct); |
| 134 | intr_data_ptr = mainboard_intr_data; |
| 135 | picr_data_ptr = mainboard_picr_data; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * TODO |
| 140 | * SB CIMx callback |
| 141 | */ |
| 142 | void set_pcie_reset(void) |
| 143 | { |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * TODO |
| 148 | * mainboard specific SB CIMx callback |
| 149 | */ |
| 150 | void set_pcie_dereset(void) |
| 151 | { |
| 152 | } |
| 153 | |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 154 | /********************************************** |
| 155 | * Enable the dedicated functions of the board. |
| 156 | **********************************************/ |
| 157 | static void mainboard_enable(device_t dev) |
| 158 | { |
| 159 | printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n"); |
| 160 | |
| 161 | /* Initialize the PIRQ data structures for consumption */ |
| 162 | pirq_setup(); |
| 163 | } |
| 164 | |
Kyösti Mälkki | 7809356 | 2014-11-11 17:22:23 +0200 | [diff] [blame] | 165 | static void mainboard_final(void *chip_info) |
| 166 | { |
| 167 | u32 mmio_base; |
| 168 | |
| 169 | printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Final.\n"); |
| 170 | |
| 171 | /* |
| 172 | * LED1/D7/GPIO_189 should be 0 |
| 173 | * LED2/D6/GPIO_190 should be 1 |
| 174 | * LED3/D5/GPIO_191 should be 1 |
| 175 | */ |
| 176 | mmio_base = find_gpio_base(); |
| 177 | configure_gpio(mmio_base, GPIO_189, GPIO_FTN_1, GPIO_OUTPUT | GPIO_DATA_LOW); |
| 178 | configure_gpio(mmio_base, GPIO_190, GPIO_FTN_1, GPIO_OUTPUT | GPIO_DATA_HIGH); |
| 179 | configure_gpio(mmio_base, GPIO_191, GPIO_FTN_1, GPIO_OUTPUT | GPIO_DATA_HIGH); |
| 180 | } |
| 181 | |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 182 | struct chip_operations mainboard_ops = { |
| 183 | .enable_dev = mainboard_enable, |
Kyösti Mälkki | 7809356 | 2014-11-11 17:22:23 +0200 | [diff] [blame] | 184 | .final = mainboard_final, |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 185 | }; |