blob: e1ca607888d1e38c3781707c085b5447b2823c84 [file] [log] [blame]
Ward Vandewege2583dd22009-09-30 14:46:43 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007 AMD
5 * Written by Yinghai Lu <yinghailu@amd.com> for AMD.
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; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Ward Vandewege2583dd22009-09-30 14:46:43 +000016 */
17
18#include <console/console.h>
19#include <arch/smp/mpspec.h>
20#include <device/pci.h>
21#include <string.h>
22#include <stdint.h>
Ward Vandewege2583dd22009-09-30 14:46:43 +000023#include <cpu/amd/amdfam10_sysconf.h>
Ward Vandewege2583dd22009-09-30 14:46:43 +000024#include "mb_sysconf.h"
25
Myles Watson08e0fb82010-03-22 16:33:25 +000026static void *smp_write_config_table(void *v)
Ward Vandewege2583dd22009-09-30 14:46:43 +000027{
Ward Vandewege2583dd22009-09-30 14:46:43 +000028 struct mp_config_table *mc;
29 struct mb_sysconf_t *m;
30 unsigned sbdn;
Patrick Georgi7411eab2010-11-22 14:14:56 +000031 int i, j, bus_isa;
Ward Vandewege2583dd22009-09-30 14:46:43 +000032
33 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Ward Vandewege2583dd22009-09-30 14:46:43 +000034
Patrick Georgic8feedd2012-02-16 18:43:25 +010035 mptable_init(mc, LOCAL_APIC_ADDR);
Ward Vandewege2583dd22009-09-30 14:46:43 +000036
37 smp_write_processors(mc);
38
39 get_bus_conf();
40 sbdn = sysconf.sbdn;
41 m = sysconf.mb;
42
Patrick Georgi7411eab2010-11-22 14:14:56 +000043 mptable_write_buses(mc, NULL, &bus_isa);
Ward Vandewege2583dd22009-09-30 14:46:43 +000044
45/*I/O APICs: APIC ID Version State Address*/
46 {
47 device_t dev;
48 struct resource *res;
49 uint32_t dword;
50
51 dev = dev_find_slot(m->bus_mcp55[0], PCI_DEVFN(sbdn+ 0x1,0));
52 if (dev) {
53 res = find_resource(dev, PCI_BASE_ADDRESS_1);
54 if (res) {
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080055 smp_write_ioapic(mc, m->apicid_mcp55, 0x11,
56 res2mmio(res, 0, 0));
Ward Vandewege2583dd22009-09-30 14:46:43 +000057 }
58
59 dword = 0x43c6c643;
60 pci_write_config32(dev, 0x7c, dword);
61
62 dword = 0x81001a00;
63 pci_write_config32(dev, 0x80, dword);
64
65 dword = 0xd00012d2;
66 pci_write_config32(dev, 0x84, dword);
67
68 }
69
70
71 }
72
Patrick Georgi7411eab2010-11-22 14:14:56 +000073 mptable_add_isa_interrupts(mc, bus_isa, m->apicid_mcp55, 0);
Ward Vandewege2583dd22009-09-30 14:46:43 +000074
Patrick Georgic5b87c82010-05-20 15:28:19 +000075 /*I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
Ward Vandewege2583dd22009-09-30 14:46:43 +000076 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+1)<<2)|1, m->apicid_mcp55, 0xa);
77
78 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+2)<<2)|0, m->apicid_mcp55, 0x16); // 22
79
80 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+2)<<2)|1, m->apicid_mcp55, 0x17); // 23
81
82 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+6)<<2)|1, m->apicid_mcp55, 0x17); // 23
83
84 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+5)<<2)|0, m->apicid_mcp55, 0x14); // 20
85 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+5)<<2)|1, m->apicid_mcp55, 0x17); // 23
86 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+5)<<2)|2, m->apicid_mcp55, 0x15); // 21
87
88 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+8)<<2)|0, m->apicid_mcp55, 0x16); // 22
89 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[0], ((sbdn+9)<<2)|0, m->apicid_mcp55, 0x15); // 21
90
91 for(j=7; j>=2; j--) {
92 if(!m->bus_mcp55[j]) continue;
93 for(i=0;i<4;i++) {
94 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[j], (0x00<<2)|i, m->apicid_mcp55, 0x10 + (2+j+i+4-sbdn%4)%4);
95 }
96 }
97
98 for(j=0; j<1; j++)
99 for(i=0;i<4;i++) {
100 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_mcp55[1], ((0x04+j)<<2)|i, m->apicid_mcp55, 0x10 + (2+i+j)%4);
101 }
102
103/*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/
Patrick Georgi6eb7a532011-10-07 21:42:52 +0200104 mptable_lintsrc(mc, bus_isa);
Ward Vandewege2583dd22009-09-30 14:46:43 +0000105 /* There is no extension information... */
106
107 /* Compute the checksums */
Patrick Georgib0a9c5c2011-10-07 23:01:55 +0200108 return mptable_finalize(mc);
Ward Vandewege2583dd22009-09-30 14:46:43 +0000109}
110
111unsigned long write_smp_table(unsigned long addr)
112{
113 void *v;
Patrick Georgic75c79b2011-10-07 22:41:07 +0200114 v = smp_write_floating_table(addr, 0);
Ward Vandewege2583dd22009-09-30 14:46:43 +0000115 return (unsigned long)smp_write_config_table(v);
116}