blob: 897a077beeae77c957c1cc64a00d58fb2114d06f [file] [log] [blame]
Scott Duplichana649a962011-02-24 05:00:33 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Advanced Micro Devices, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Scott Duplichana649a962011-02-24 05:00:33 +000018 */
19
20
Scott Duplichana649a962011-02-24 05:00:33 +000021#include <arch/io.h>
Kyösti Mälkkib4261072014-07-22 10:24:20 +030022#include <arch/ioapic.h>
Edward O'Callaghanb53b50b2014-04-29 20:26:02 +100023#include <arch/smp/mpspec.h>
24#include <console/console.h>
Paul Menzelcd966dd2013-03-29 20:20:56 +010025#include <cpu/amd/amdfam14.h>
Edward O'Callaghanb53b50b2014-04-29 20:26:02 +100026#include <device/pci.h>
27#include <stdint.h>
28#include <string.h>
29
30#include <southbridge/amd/cimx/sb800/SBPLATFORM.h>
Scott Duplichana649a962011-02-24 05:00:33 +000031
Scott Duplichana649a962011-02-24 05:00:33 +000032
Scott Duplichana649a962011-02-24 05:00:33 +000033u8 intr_data[] = {
34 [0x00] = 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, /* INTA# - INTH# */
35 [0x08] = 0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F, /* Misc-nil,0,1,2, INT from Serial irq */
36 [0x10] = 0x09,0x1F,0x1F,0x10,0x1F,0x12,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
37 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
38 0x12,0x11,0x12,0x11,0x12,0x11,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
39 0x11,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
40 0x10,0x11,0x12,0x13
41};
42
43static void *smp_write_config_table(void *v)
44{
45 struct mp_config_table *mc;
46 int bus_isa;
47
Kyösti Mälkkib4261072014-07-22 10:24:20 +030048 /*
49 * By the time this function gets called, the IOAPIC registers
50 * have been written so they can be read to get the correct
51 * APIC ID and Version
52 */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080053 u8 ioapic_id = (io_apic_read(VIO_APIC_VADDR, 0x00) >> 24);
54 u8 ioapic_ver = (io_apic_read(VIO_APIC_VADDR, 0x01) & 0xFF);
Kyösti Mälkkib4261072014-07-22 10:24:20 +030055
Scott Duplichana649a962011-02-24 05:00:33 +000056 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
57
Patrick Georgic8feedd2012-02-16 18:43:25 +010058 mptable_init(mc, LOCAL_APIC_ADDR);
Scott Duplichan63896e72011-02-26 17:49:49 +000059 memcpy(mc->mpc_oem, "ASROCK ", 8);
Scott Duplichana649a962011-02-24 05:00:33 +000060
61 smp_write_processors(mc);
62
Scott Duplichana649a962011-02-24 05:00:33 +000063 mptable_write_buses(mc, NULL, &bus_isa);
64
65 /* I/O APICs: APIC ID Version State Address */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080066 smp_write_ioapic(mc, ioapic_id, ioapic_ver, VIO_APIC_VADDR);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070067
Scott Duplichana649a962011-02-24 05:00:33 +000068 u8 byte;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070069
Scott Duplichana649a962011-02-24 05:00:33 +000070 for (byte = 0x0; byte < sizeof(intr_data); byte ++) {
71 outb(byte | 0x80, 0xC00);
72 outb(intr_data[byte], 0xC01);
73 }
74
75 /* I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
76#define IO_LOCAL_INT(type, intr, apicid, pin) \
77 smp_write_lintsrc(mc, (type), MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, bus_isa, (intr), (apicid), (pin));
78
Kyösti Mälkkib4261072014-07-22 10:24:20 +030079 mptable_add_isa_interrupts(mc, bus_isa, ioapic_id, 0);
Scott Duplichana649a962011-02-24 05:00:33 +000080
81 /* PCI interrupts are level triggered, and are
82 * associated with a specific bus/device/function tuple.
83 */
Scott Duplichana649a962011-02-24 05:00:33 +000084#define PCI_INT(bus, dev, fn, pin) \
Kyösti Mälkkib4261072014-07-22 10:24:20 +030085 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, (bus), (((dev)<<2)|(fn)), ioapic_id, (pin))
Scott Duplichana649a962011-02-24 05:00:33 +000086
Kerry Sheh28f17102011-12-22 12:18:26 +080087 /* APU Internal Graphic Device*/
88 PCI_INT(0x0, 0x01, 0x0, intr_data[0x02]);
89 PCI_INT(0x0, 0x01, 0x1, intr_data[0x03]);
90
Scott Duplichana649a962011-02-24 05:00:33 +000091 //PCI_INT(0x0, 0x14, 0x1, 0x11); /* IDE. */
92 PCI_INT(0x0, 0x14, 0x0, 0x10);
Kerry Sheh28f17102011-12-22 12:18:26 +080093 /* Southbridge HD Audio: */
Scott Duplichana649a962011-02-24 05:00:33 +000094 PCI_INT(0x0, 0x14, 0x2, 0x12);
95
96 PCI_INT(0x0, 0x12, 0x0, intr_data[0x30]); /* USB */
97 PCI_INT(0x0, 0x12, 0x1, intr_data[0x31]);
98 PCI_INT(0x0, 0x13, 0x0, intr_data[0x32]);
99 PCI_INT(0x0, 0x13, 0x1, intr_data[0x33]);
100 PCI_INT(0x0, 0x16, 0x0, intr_data[0x34]);
101 PCI_INT(0x0, 0x16, 0x1, intr_data[0x35]);
102
103 /* sata */
104 PCI_INT(0x0, 0x11, 0x0, intr_data[0x41]);
105
Scott Duplichana649a962011-02-24 05:00:33 +0000106 /* on board NIC & Slot PCIE. */
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700107
Scott Duplichana649a962011-02-24 05:00:33 +0000108 /* PCI slots */
Kyösti Mälkkicdfb4622014-07-22 15:24:15 +0300109 device_t dev = dev_find_slot(0, PCI_DEVFN(0x14, 4));
110 if (dev && dev->enabled) {
111 u8 bus_pci = dev->link_list->secondary;
112 /* PCI_SLOT 0. */
113 PCI_INT(bus_pci, 0x5, 0x0, 0x14);
114 PCI_INT(bus_pci, 0x5, 0x1, 0x15);
115 PCI_INT(bus_pci, 0x5, 0x2, 0x16);
116 PCI_INT(bus_pci, 0x5, 0x3, 0x17);
Scott Duplichana649a962011-02-24 05:00:33 +0000117
Kyösti Mälkkicdfb4622014-07-22 15:24:15 +0300118 /* PCI_SLOT 1. */
119 PCI_INT(bus_pci, 0x6, 0x0, 0x15);
120 PCI_INT(bus_pci, 0x6, 0x1, 0x16);
121 PCI_INT(bus_pci, 0x6, 0x2, 0x17);
122 PCI_INT(bus_pci, 0x6, 0x3, 0x14);
Scott Duplichana649a962011-02-24 05:00:33 +0000123
Kyösti Mälkkicdfb4622014-07-22 15:24:15 +0300124 /* PCI_SLOT 2. */
125 PCI_INT(bus_pci, 0x7, 0x0, 0x16);
126 PCI_INT(bus_pci, 0x7, 0x1, 0x17);
127 PCI_INT(bus_pci, 0x7, 0x2, 0x14);
128 PCI_INT(bus_pci, 0x7, 0x3, 0x15);
129 }
Scott Duplichana649a962011-02-24 05:00:33 +0000130
131 /* PCIe PortA */
132 PCI_INT(0x0, 0x15, 0x0, 0x10);
133 /* PCIe PortB */
134 PCI_INT(0x0, 0x15, 0x1, 0x11);
135 /* PCIe PortC */
136 PCI_INT(0x0, 0x15, 0x2, 0x12);
137 /* PCIe PortD */
138 PCI_INT(0x0, 0x15, 0x3, 0x13);
139
140 /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
141 IO_LOCAL_INT(mp_ExtINT, 0x0, MP_APIC_ALL, 0x0);
142 IO_LOCAL_INT(mp_NMI, 0x0, MP_APIC_ALL, 0x1);
143 /* There is no extension information... */
144
145 /* Compute the checksums */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +0200146 return mptable_finalize(mc);
Scott Duplichana649a962011-02-24 05:00:33 +0000147}
148
149unsigned long write_smp_table(unsigned long addr)
150{
151 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +0200152 v = smp_write_floating_table(addr, 0);
Scott Duplichana649a962011-02-24 05:00:33 +0000153 return (unsigned long)smp_write_config_table(v);
154}