blob: 151659018d2ae1df6e7acda4e18b32564c1dc8f7 [file] [log] [blame]
arch import user (historical)ef03afa2005-07-06 17:15:30 +00001#include <console/console.h>
2#include <arch/smp/mpspec.h>
3#include <device/pci.h>
4#include <string.h>
5#include <stdint.h>
Yinghai Lu6d74d762006-10-04 23:57:49 +00006#include <cpu/amd/amdk8_sysconf.h>
7
Yinghai Lu968bbe82005-12-06 23:34:09 +00008extern unsigned char bus_isa;
9extern unsigned char bus_ck804_0; //1
10extern unsigned char bus_ck804_1; //2
11extern unsigned char bus_ck804_2; //3
12extern unsigned char bus_ck804_3; //4
13extern unsigned char bus_ck804_4; //5
14extern unsigned char bus_ck804_5; //6
Myles Watsona67c354c2008-09-18 15:30:42 +000015extern unsigned char bus_8131_0; //7
16extern unsigned char bus_8131_1; //8
17extern unsigned char bus_8131_2; //9
Yinghai Lu968bbe82005-12-06 23:34:09 +000018extern unsigned apicid_ck804;
19extern unsigned apicid_8131_1;
20extern unsigned apicid_8131_2;
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000021
Yinghai Lu968bbe82005-12-06 23:34:09 +000022extern unsigned sbdn3;
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000023
Myles Watson54913b92009-10-13 20:00:09 +000024static void *smp_write_config_table(void *v)
arch import user (historical)ef03afa2005-07-06 17:15:30 +000025{
Myles Watsona67c354c2008-09-18 15:30:42 +000026 struct mp_config_table *mc;
Yinghai Lu6d74d762006-10-04 23:57:49 +000027 unsigned sbdn;
Myles Watsona67c354c2008-09-18 15:30:42 +000028 unsigned char bus_num;
Yinghai Lu968bbe82005-12-06 23:34:09 +000029 int i;
arch import user (historical)ef03afa2005-07-06 17:15:30 +000030
Myles Watsona67c354c2008-09-18 15:30:42 +000031 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
arch import user (historical)ef03afa2005-07-06 17:15:30 +000032
Uwe Hermann55dc2232010-10-25 15:32:07 +000033 mptable_init(mc, "S2892 ", LAPIC_ADDR);
arch import user (historical)ef03afa2005-07-06 17:15:30 +000034
Myles Watsona67c354c2008-09-18 15:30:42 +000035 smp_write_processors(mc);
arch import user (historical)ef03afa2005-07-06 17:15:30 +000036
Yinghai Lu968bbe82005-12-06 23:34:09 +000037 get_bus_conf();
Yinghai Lu6d74d762006-10-04 23:57:49 +000038 sbdn = sysconf.sbdn;
arch import user (historical)ef03afa2005-07-06 17:15:30 +000039
40/*Bus: Bus ID Type*/
41 /* define bus and isa numbers */
Myles Watsona67c354c2008-09-18 15:30:42 +000042 for(bus_num = 0; bus_num < bus_isa; bus_num++) {
43 smp_write_bus(mc, bus_num, "PCI ");
44 }
45 smp_write_bus(mc, bus_isa, "ISA ");
arch import user (historical)ef03afa2005-07-06 17:15:30 +000046
47/*I/O APICs: APIC ID Version State Address*/
Myles Watsona67c354c2008-09-18 15:30:42 +000048 {
49 device_t dev;
arch import user (historical)ef03afa2005-07-06 17:15:30 +000050 struct resource *res;
51 uint32_t dword;
52
Myles Watsona67c354c2008-09-18 15:30:42 +000053 dev = dev_find_slot(bus_ck804_0, PCI_DEVFN(sbdn+ 0x1,0));
54 if (dev) {
arch import user (historical)ef03afa2005-07-06 17:15:30 +000055 res = find_resource(dev, PCI_BASE_ADDRESS_1);
56 if (res) {
57 smp_write_ioapic(mc, apicid_ck804, 0x11, res->base);
58 }
Myles Watson3d1d3b22008-04-23 20:40:55 +000059
Yinghai Lu6d74d762006-10-04 23:57:49 +000060 /* Initialize interrupt mapping*/
61
Myles Watson0eec1a82008-04-23 17:55:25 +000062 dword = 0x0120d218;
Myles Watsona67c354c2008-09-18 15:30:42 +000063 pci_write_config32(dev, 0x7c, dword);
arch import user (historical)ef03afa2005-07-06 17:15:30 +000064
Myles Watsona67c354c2008-09-18 15:30:42 +000065 dword = 0x12008a00;
66 pci_write_config32(dev, 0x80, dword);
arch import user (historical)ef03afa2005-07-06 17:15:30 +000067
Myles Watsona67c354c2008-09-18 15:30:42 +000068 dword = 0x0000007d;
69 pci_write_config32(dev, 0x84, dword);
arch import user (historical)ef03afa2005-07-06 17:15:30 +000070
Myles Watsona67c354c2008-09-18 15:30:42 +000071 }
arch import user (historical)ef03afa2005-07-06 17:15:30 +000072
Myles Watsona67c354c2008-09-18 15:30:42 +000073 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3,1));
74 if (dev) {
arch import user (historical)ef03afa2005-07-06 17:15:30 +000075 res = find_resource(dev, PCI_BASE_ADDRESS_0);
76 if (res) {
77 smp_write_ioapic(mc, apicid_8131_1, 0x11, res->base);
78 }
Myles Watsona67c354c2008-09-18 15:30:42 +000079 }
80 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3+1,1));
81 if (dev) {
arch import user (historical)ef03afa2005-07-06 17:15:30 +000082 res = find_resource(dev, PCI_BASE_ADDRESS_0);
83 if (res) {
84 smp_write_ioapic(mc, apicid_8131_2, 0x11, res->base);
85 }
Myles Watsona67c354c2008-09-18 15:30:42 +000086 }
arch import user (historical)ef03afa2005-07-06 17:15:30 +000087
88 }
Myles Watsona67c354c2008-09-18 15:30:42 +000089
Patrick Georgic5b87c82010-05-20 15:28:19 +000090 mptable_add_isa_interrupts(mc, bus_isa, apicid_ck804, 1);
arch import user (historical)ef03afa2005-07-06 17:15:30 +000091
Patrick Georgic5b87c82010-05-20 15:28:19 +000092/*I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
Yinghai Lu968bbe82005-12-06 23:34:09 +000093// Onboard ck804 smbus
Myles Watson34b1d4e2009-03-10 20:56:54 +000094 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_0, ((sbdn+1)<<2)|1, apicid_ck804, 0xa); // 10
arch import user (historical)ef03afa2005-07-06 17:15:30 +000095
Yinghai Lu968bbe82005-12-06 23:34:09 +000096// Onboard ck804 USB 1.1
Myles Watsona67c354c2008-09-18 15:30:42 +000097 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_0, ((sbdn+2)<<2)|0, apicid_ck804, 0x15); // 21
arch import user (historical)ef03afa2005-07-06 17:15:30 +000098
Yinghai Lu968bbe82005-12-06 23:34:09 +000099// Onboard ck804 USB 2
Myles Watsona67c354c2008-09-18 15:30:42 +0000100 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_0, ((sbdn+2)<<2)|1, apicid_ck804, 0x14); // 20
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000101
Yinghai Lu968bbe82005-12-06 23:34:09 +0000102// Onboard ck804 SATA 0
Myles Watsona67c354c2008-09-18 15:30:42 +0000103 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_0, ((sbdn +7)<<2)|0, apicid_ck804, 0x17); // 23
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000104
Yinghai Lu968bbe82005-12-06 23:34:09 +0000105// Onboard ck804 SATA 1
Myles Watsona67c354c2008-09-18 15:30:42 +0000106 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_0, ((sbdn +8)<<2)|0, apicid_ck804, 0x16); // 22
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000107
Myles Watson34b1d4e2009-03-10 20:56:54 +0000108//Slot PCIE x16
Myles Watsona67c354c2008-09-18 15:30:42 +0000109 for(i=0;i<4;i++) {
110 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_5, (0x00<<2)|i, apicid_ck804, 0x10 + (2+i+4-sbdn%4)%4);
111 }
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000112
Yinghai Lu968bbe82005-12-06 23:34:09 +0000113//Slot PCIE x4
Myles Watsona67c354c2008-09-18 15:30:42 +0000114 for(i=0;i<4;i++) {
115 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_4, (0x00<<2)|i, apicid_ck804, 0x10 + (1+i+4-sbdn%4)%4);
116 }
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000117
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000118
Yinghai Lu968bbe82005-12-06 23:34:09 +0000119//Slot 2 PCI 32
Myles Watsona67c354c2008-09-18 15:30:42 +0000120 for(i=0;i<4;i++) {
Myles Watson34b1d4e2009-03-10 20:56:54 +0000121 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_1, (0x04<<2)|i, apicid_ck804, 0x10 + (0+i)%4); //16
Myles Watsona67c354c2008-09-18 15:30:42 +0000122 }
Yinghai Lu13f1c2a2005-07-08 02:49:49 +0000123
Yinghai Lu968bbe82005-12-06 23:34:09 +0000124
125//Onboard ati
Myles Watsona67c354c2008-09-18 15:30:42 +0000126 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_1, (6<<2)|0, apicid_ck804, 0x12); // 18
Yinghai Lu968bbe82005-12-06 23:34:09 +0000127//Onboard intel 10/100
Myles Watsona67c354c2008-09-18 15:30:42 +0000128 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_ck804_1, (8<<2)|0, apicid_ck804, 0x12); // 18
Yinghai Lu13f1c2a2005-07-08 02:49:49 +0000129
130//Channel B of 8131
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000131
132
Yinghai Lu13f1c2a2005-07-08 02:49:49 +0000133//Onboard Broadcom NIC
Myles Watsona67c354c2008-09-18 15:30:42 +0000134 for(i=0;i<2;i++) {
135 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, (9<<2)|i, apicid_8131_2, (0+i)%4); //28
136 }
Yinghai Lu968bbe82005-12-06 23:34:09 +0000137
Yinghai Lu13f1c2a2005-07-08 02:49:49 +0000138//SO DIMM PCI-X
Myles Watsona67c354c2008-09-18 15:30:42 +0000139 for(i=0;i<2;i++) {
140 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, (7<<2)|i, apicid_8131_2, (0+i)%4); //28
141 }
Yinghai Lu968bbe82005-12-06 23:34:09 +0000142
Yinghai Lu13f1c2a2005-07-08 02:49:49 +0000143//Slot 4 PCIX 133/100/66
Myles Watsona67c354c2008-09-18 15:30:42 +0000144 for(i=0;i<4;i++) {
145 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, (3<<2)|i, apicid_8131_2, (2+i)%4); //30
146 }
Yinghai Lu968bbe82005-12-06 23:34:09 +0000147
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000148
Yinghai Lu13f1c2a2005-07-08 02:49:49 +0000149//Channel A of 8131
150
Myles Watsona67c354c2008-09-18 15:30:42 +0000151//Slot 5 PCIX 133/100/66
152 for(i=0;i<4;i++) {
153 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (3<<2)|i, apicid_8131_1, (3+i)%4); //27
154 }
Yinghai Lu968bbe82005-12-06 23:34:09 +0000155
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000156
Myles Watsona67c354c2008-09-18 15:30:42 +0000157//Slot 6 PCIX 133/100/66
158 for(i=0;i<4;i++) {
159 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (2<<2)|i, apicid_8131_1, (2+i)%4); //26
160 }
Yinghai Lu968bbe82005-12-06 23:34:09 +0000161
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000162/*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/
Tobias Diedrichb907d322010-10-26 22:40:16 +0000163 smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, MP_APIC_ALL, 0x0);
164 smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, MP_APIC_ALL, 0x1);
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000165 /* There is no extension information... */
166
167 /* Compute the checksums */
168 mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
169 mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000170 printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
arch import user (historical)ef03afa2005-07-06 17:15:30 +0000171 mc, smp_next_mpe_entry(mc));
172 return smp_next_mpe_entry(mc);
173}
174
175unsigned long write_smp_table(unsigned long addr)
176{
177 void *v;
178 v = smp_write_floating_table(addr);
179 return (unsigned long)smp_write_config_table(v);
180}