Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Advanced Micro Devices, Inc. |
Mike Loptien | c93a75a | 2014-06-06 15:16:29 -0600 | [diff] [blame] | 5 | * Copyright (C) 2014 Sage Electronic Engineering, LLC. |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [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. |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <console/console.h> |
| 18 | #include <device/device.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <arch/io.h> |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 21 | #include <cpu/x86/msr.h> |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 22 | #include <device/pci_def.h> |
Stefan Reinauer | 13e4182 | 2015-04-27 14:02:36 -0700 | [diff] [blame] | 23 | #include <southbridge/amd/common/amd_pci_util.h> |
Mike Loptien | c93a75a | 2014-06-06 15:16:29 -0600 | [diff] [blame] | 24 | #include <southbridge/amd/cimx/cimx_util.h> |
zbao | f543c7b | 2012-04-13 13:42:46 +0800 | [diff] [blame] | 25 | #include <arch/acpi.h> |
Kyösti Mälkki | 26f297e | 2014-05-26 11:27:54 +0300 | [diff] [blame] | 26 | #include <northbridge/amd/agesa/BiosCallOuts.h> |
zbao | f543c7b | 2012-04-13 13:42:46 +0800 | [diff] [blame] | 27 | #include <cpu/amd/agesa/s3_resume.h> |
| 28 | #include <cpu/amd/mtrr.h> |
Dave Frodin | 73be43a | 2012-11-16 14:16:33 -0700 | [diff] [blame] | 29 | #include "SBPLATFORM.h" |
Mike Loptien | c93a75a | 2014-06-06 15:16:29 -0600 | [diff] [blame] | 30 | #include <southbridge/amd/cimx/sb800/pci_devs.h> |
| 31 | #include <northbridge/amd/agesa/family14/pci_devs.h> |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 32 | |
efdesign98 | d7a696d | 2011-09-15 15:24:26 -0600 | [diff] [blame] | 33 | void set_pcie_reset(void); |
| 34 | void set_pcie_dereset(void); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 35 | |
Mike Loptien | c93a75a | 2014-06-06 15:16:29 -0600 | [diff] [blame] | 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 | * The Persimmon PCI INTA/B/C/D pins are connected to |
| 48 | * FCH pins INTE/F/G/H on the schematic so these need |
| 49 | * to be routed as well. |
| 50 | */ |
| 51 | static const u8 mainboard_picr_data[FCH_INT_TABLE_SIZE] = { |
| 52 | /* INTA# - INTH# */ |
| 53 | [0x00] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B, |
| 54 | /* Misc-nil,0,1,2, INT from Serial irq */ |
| 55 | [0x08] = 0x00,0xF0,0x00,0x00,0x1F,0x1F,0x1F,0x1F, |
| 56 | /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerfMon */ |
| 57 | [0x10] = 0x1F,0x1F,0x1F,0x0A,0x1F,0x1F,0x1F, |
| 58 | /* IMC INT0 - 5 */ |
| 59 | [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, |
| 60 | /* USB Devs 18/19/20/22 INTA-C */ |
| 61 | [0x30] = 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A, |
| 62 | /* IDE, SATA */ |
| 63 | [0x40] = 0x0B,0x0B, |
| 64 | /* GPPInt0 - 3 */ |
| 65 | [0x50] = 0x0A,0x0B,0x0A,0x0B |
| 66 | }; |
| 67 | |
| 68 | static const u8 mainboard_intr_data[FCH_INT_TABLE_SIZE] = { |
| 69 | /* INTA# - INTH# */ |
| 70 | [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, |
| 71 | /* Misc-nil,0,1,2, INT from Serial irq */ |
| 72 | [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F, |
| 73 | /* SCI, SMBUS0, ASF, HDA, FC, GEC, PerMon */ |
| 74 | [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x12,0x1F, |
| 75 | /* IMC INT0 - 5 */ |
| 76 | [0x20] = 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, |
| 77 | /* USB Devs 18/19/22/20 INTA-C */ |
| 78 | [0x30] = 0x12,0x11,0x12,0x11,0x12,0x11,0x12, |
| 79 | /* IDE, SATA */ |
| 80 | [0x40] = 0x11,0x13, |
| 81 | /* GPPInt0 - 3 */ |
| 82 | [0x50] = 0x10,0x11,0x12,0x13 |
| 83 | }; |
| 84 | |
| 85 | /* |
| 86 | * This table defines the index into the picr/intr_data |
| 87 | * tables for each device. Any enabled device and slot |
| 88 | * that uses hardware interrupts should have an entry |
| 89 | * in this table to define its index into the FCH |
| 90 | * PCI_INTR register 0xC00/0xC01. This index will define |
| 91 | * the interrupt that it should use. Putting PIRQ_A into |
| 92 | * the PIN A index for a device will tell that device to |
| 93 | * use PIC IRQ 10 if it uses PIN A for its hardware INT. |
| 94 | */ |
| 95 | /* |
| 96 | * Persimmon has PCI slot INTA/B/C/D connected to PIRQE/F/G/H |
| 97 | * but because PCI INT_PIN swizzling isnt implemented to match |
| 98 | * the IDSEL (dev 3) of the slot, the table is adjusted for the |
| 99 | * swizzle and INTA is connected to PIRQH so PINA/B/C/D on |
| 100 | * off-chip devices should get mapped to PIRQH/E/F/G. |
| 101 | */ |
| 102 | static const struct pirq_struct mainboard_pirq_data[] = { |
Kyösti Mälkki | faaa253 | 2014-06-26 07:11:22 +0300 | [diff] [blame] | 103 | /* {PCI_devfn, {PIN A, PIN B, PIN C, PIN D}}, */ |
| 104 | {GFX_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_NC, PIRQ_NC}}, /* VGA: 01.0 */ |
| 105 | {NB_PCIE_PORT1_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* NIC: 04.0 */ |
| 106 | {NB_PCIE_PORT3_DEVFN, {PIRQ_A, PIRQ_B, PIRQ_C, PIRQ_D}}, /* PCIe bdg: 06.0 */ |
| 107 | {SATA_DEVFN, {PIRQ_SATA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SATA: 11.0 */ |
| 108 | {OHCI1_DEVFN, {PIRQ_OHCI1, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI1: 12.0 */ |
| 109 | {EHCI1_DEVFN, {PIRQ_NC, PIRQ_EHCI1, PIRQ_NC, PIRQ_NC}}, /* EHCI1: 12.2 */ |
| 110 | {OHCI2_DEVFN, {PIRQ_OHCI2, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI2: 13.0 */ |
| 111 | {EHCI2_DEVFN, {PIRQ_NC, PIRQ_EHCI2, PIRQ_NC, PIRQ_NC}}, /* EHCI2: 13.2 */ |
| 112 | {SMBUS_DEVFN, {PIRQ_SMBUS, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* SMBUS: 14.0 */ |
| 113 | {IDE_DEVFN, {PIRQ_NC, PIRQ_IDE, PIRQ_NC, PIRQ_NC}}, /* IDE: 14.1 */ |
| 114 | {HDA_DEVFN, {PIRQ_HDA, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* HDA: 14.2 */ |
| 115 | {SB_PCI_PORT_DEVFN, {PIRQ_H, PIRQ_E, PIRQ_F, PIRQ_G}}, /* PCI bdg: 14.4 */ |
| 116 | {OHCI4_DEVFN, {PIRQ_NC, PIRQ_NC, PIRQ_OHCI4, PIRQ_NC}}, /* OHCI4: 14.5 */ |
| 117 | {OHCI3_DEVFN, {PIRQ_OHCI3, PIRQ_NC, PIRQ_NC, PIRQ_NC}}, /* OHCI3: 16.0 */ |
| 118 | {EHCI3_DEVFN, {PIRQ_NC, PIRQ_EHCI3, PIRQ_NC, PIRQ_NC}}, /* EHCI3: 16.2 */ |
Mike Loptien | c93a75a | 2014-06-06 15:16:29 -0600 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | /* PIRQ Setup */ |
| 122 | static void pirq_setup(void) |
| 123 | { |
| 124 | pirq_data_ptr = mainboard_pirq_data; |
| 125 | pirq_data_size = sizeof(mainboard_pirq_data) / sizeof(struct pirq_struct); |
| 126 | intr_data_ptr = mainboard_intr_data; |
| 127 | picr_data_ptr = mainboard_picr_data; |
| 128 | } |
| 129 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 130 | /** |
| 131 | * TODO |
| 132 | * SB CIMx callback |
| 133 | */ |
| 134 | void set_pcie_reset(void) |
| 135 | { |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * TODO |
| 140 | * mainboard specific SB CIMx callback |
| 141 | */ |
| 142 | void set_pcie_dereset(void) |
| 143 | { |
| 144 | } |
| 145 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 146 | |
Jens Rottmann | 5e70766 | 2013-02-26 15:56:11 +0100 | [diff] [blame] | 147 | /********************************************** |
| 148 | * Enable the dedicated functions of the board. |
| 149 | **********************************************/ |
Paul Menzel | 528640d | 2013-02-23 21:31:23 +0100 | [diff] [blame] | 150 | static void mainboard_enable(device_t dev) |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 151 | { |
Scott Duplichan | 8c46263 | 2011-05-15 22:10:15 +0000 | [diff] [blame] | 152 | printk(BIOS_INFO, "Mainboard " CONFIG_MAINBOARD_PART_NUMBER " Enable.\n"); |
| 153 | |
Dave Frodin | 73be43a | 2012-11-16 14:16:33 -0700 | [diff] [blame] | 154 | /* enable GPP CLK0 thru CLK1 */ |
| 155 | /* disable GPP CLK2 thru SLT_GFX_CLK */ |
| 156 | u8 *misc_mem_clk_cntrl = (u8 *)(ACPI_MMIO_BASE + MISC_BASE); |
Felix Held | 421b47e | 2015-10-17 13:16:27 +0200 | [diff] [blame] | 157 | write8(misc_mem_clk_cntrl + 0, 0xFF); |
| 158 | write8(misc_mem_clk_cntrl + 1, 0x00); |
| 159 | write8(misc_mem_clk_cntrl + 2, 0x00); |
| 160 | write8(misc_mem_clk_cntrl + 3, 0x00); |
| 161 | write8(misc_mem_clk_cntrl + 4, 0x00); |
Martin Roth | 45f72ce | 2013-02-24 12:58:33 -0700 | [diff] [blame] | 162 | |
| 163 | /* |
| 164 | * Initialize ASF registers to an arbitrary address because someone |
| 165 | * long ago set things up this way inside the SPD read code. The |
Paul Menzel | b55b74f | 2013-03-07 22:41:25 +0100 | [diff] [blame] | 166 | * SPD read code has been made generic and moved out of the board |
Martin Roth | 45f72ce | 2013-02-24 12:58:33 -0700 | [diff] [blame] | 167 | * directory, so the ASF init is being done here. |
| 168 | */ |
| 169 | pm_iowrite(0x29, 0x80); |
| 170 | pm_iowrite(0x28, 0x61); |
Mike Loptien | c93a75a | 2014-06-06 15:16:29 -0600 | [diff] [blame] | 171 | |
| 172 | /* Initialize the PIRQ data structures for consumption */ |
| 173 | pirq_setup(); |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 176 | struct chip_operations mainboard_ops = { |
Paul Menzel | 528640d | 2013-02-23 21:31:23 +0100 | [diff] [blame] | 177 | .enable_dev = mainboard_enable, |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 178 | }; |