blob: dc98382107297e25748565ee83cea63629149550 [file] [log] [blame]
Josef Kellermannbfa7ee52011-05-11 07:47:43 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 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
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <console/console.h>
21#include <arch/smp/mpspec.h>
22#include <device/pci.h>
23#include <arch/io.h>
24#include <string.h>
25#include <stdint.h>
26
27#include <cpu/amd/amdk8_sysconf.h>
28
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000029extern u8 bus_rs690[8];
30extern u8 bus_sb600[2];
31
32extern u32 apicid_sb600;
33
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000034extern u32 sbdn_rs690;
35extern u32 sbdn_sb600;
36
37static void *smp_write_config_table(void *v)
38{
39 struct mp_config_table *mc;
40 int isa_bus;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070041
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000042 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Patrick Georgic8feedd2012-02-16 18:43:25 +010043 mptable_init(mc, LOCAL_APIC_ADDR);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000044 smp_write_processors(mc);
45
46 get_bus_conf();
Patrick Georgic5ae3062011-10-06 14:34:22 +020047 printk(BIOS_DEBUG, "%s: apic_id=0x%x\n", __func__, apicid_sb600);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000048
49 mptable_write_buses(mc, NULL, &isa_bus);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000050 /* I/O APICs: APIC ID Version State Address */
51 {
52 device_t dev;
53
54 dev = dev_find_slot(bus_sb600[0], PCI_DEVFN(sbdn_sb600 + 0x14, 0));
55 if (dev) {
56 struct resource *res;
57 res = find_resource(dev, 0x74);
58 smp_write_ioapic(mc, apicid_sb600, 0x20, res->base);
59 }
60 }
Patrick Georgic5ae3062011-10-06 14:34:22 +020061 mptable_add_isa_interrupts(mc, isa_bus, apicid_sb600, 0);
62
Patrick Georgi5ed8cc02011-10-06 14:36:08 +020063#define PCI_INT(bus, dev, fn, pin) \
64 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, (bus), (((dev)<<2)|(fn)), apicid_sb600, (pin))
65
66 /* usb */
67 PCI_INT(0x0, 0x13, 0x0, 0x10);
68 PCI_INT(0x0, 0x13, 0x1, 0x11);
69 PCI_INT(0x0, 0x13, 0x2, 0x12);
70 PCI_INT(0x0, 0x13, 0x3, 0x13);
71
72 /* sata */
73 PCI_INT(0x0, 0x12, 0x1, 0x16);
74
75 /* SMBus/ACPI */
76 PCI_INT(0x0, 0x14, 0x0, 0x10);
77 /* IDE */
78 PCI_INT(0x0, 0x14, 0x1, 0x11);
79 /* HDA */
80 PCI_INT(0x0, 0x14, 0x2, 0x12);
81 /* LPC */
82 PCI_INT(0x0, 0x14, 0x3, 0x13);
83
84 /* GFX ? */
85 PCI_INT(bus_rs690[1], 0x5, 0x0, 0x12);
86 PCI_INT(bus_rs690[1], 0x5, 0x1, 0x13);
87
88 /* PCIe slots */
89 PCI_INT(0x2, 0x00, 0x00, 0x10);
90 PCI_INT(0x2, 0x00, 0x01, 0x11);
91 PCI_INT(0x2, 0x00, 0x02, 0x12);
92 PCI_INT(0x2, 0x00, 0x03, 0x13);
93
94 /* PCIe slots */
95 PCI_INT(0x3, 0x00, 0x00, 0x11);
96 PCI_INT(0x3, 0x00, 0x01, 0x12);
97 PCI_INT(0x3, 0x00, 0x02, 0x13);
98 PCI_INT(0x3, 0x00, 0x03, 0x10);
99
100 /* PCIe slots */
101 PCI_INT(0x4, 0x00, 0x00, 0x12);
102 PCI_INT(0x4, 0x00, 0x01, 0x13);
103 PCI_INT(0x4, 0x00, 0x02, 0x10);
104 PCI_INT(0x4, 0x00, 0x03, 0x11);
105
106 /* PCIe slots */
107 PCI_INT(0x5, 0x00, 0x00, 0x13);
108 PCI_INT(0x5, 0x00, 0x01, 0x10);
109 PCI_INT(0x5, 0x00, 0x02, 0x11);
110 PCI_INT(0x5, 0x00, 0x03, 0x12);
111
112 /* onboard NIC ? */
113 PCI_INT(bus_sb600[1], 0x7, 0x0, 0x13);
114 PCI_INT(bus_sb600[1], 0x7, 0x1, 0x10);
115 PCI_INT(bus_sb600[1], 0x7, 0x2, 0x11);
116 PCI_INT(bus_sb600[1], 0x7, 0x3, 0x12);
117
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000118 /* I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
Patrick Georgic5ae3062011-10-06 14:34:22 +0200119 mptable_lintsrc(mc, isa_bus);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000120
121 /* Compute the checksums */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +0200122 return mptable_finalize(mc);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000123}
124
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000125unsigned long write_smp_table(unsigned long addr)
126{
127 void *v;
Patrick Georgi4e2d5422011-10-06 15:24:08 +0200128 v = smp_write_floating_table(addr, 0);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000129 return (unsigned long)smp_write_config_table(v);
130}