Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 1 | #include <console/console.h> |
| 2 | #include <arch/smp/mpspec.h> |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 3 | #include <arch/ioapic.h> |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 4 | #include <device/pci.h> |
| 5 | #include <string.h> |
| 6 | #include <stdint.h> |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame^] | 7 | #if CONFIG_LOGICAL_CPUS |
Stefan Reinauer | 9a16e3e | 2010-03-29 14:45:36 +0000 | [diff] [blame] | 8 | #include <cpu/amd/multicore.h> |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 9 | #endif |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 10 | #include <cpu/amd/amdk8_sysconf.h> |
| 11 | #include "mb_sysconf.h" |
| 12 | |
Stefan Reinauer | 50776fa | 2010-03-17 04:40:15 +0000 | [diff] [blame] | 13 | static void *smp_write_config_table(void *v) |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 14 | { |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 15 | struct mp_config_table *mc; |
Patrick Georgi | 5244e1b | 2010-11-21 14:41:07 +0000 | [diff] [blame] | 16 | int i, j, bus_isa; |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 17 | struct mb_sysconf_t *m; |
| 18 | |
| 19 | mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 20 | |
Patrick Georgi | c8feedd | 2012-02-16 18:43:25 +0100 | [diff] [blame] | 21 | mptable_init(mc, LOCAL_APIC_ADDR); |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 22 | |
| 23 | smp_write_processors(mc); |
| 24 | |
| 25 | get_bus_conf(); |
| 26 | |
| 27 | m = sysconf.mb; |
| 28 | |
Patrick Georgi | 5244e1b | 2010-11-21 14:41:07 +0000 | [diff] [blame] | 29 | mptable_write_buses(mc, NULL, &bus_isa); |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 30 | |
| 31 | /*I/O APICs: APIC ID Version State Address*/ |
Uwe Hermann | 74d1a6e | 2010-10-12 17:34:08 +0000 | [diff] [blame] | 32 | smp_write_ioapic(mc, m->apicid_8111, 0x11, IO_APIC_ADDR); //8111 |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 33 | { |
| 34 | device_t dev; |
| 35 | struct resource *res; |
| 36 | dev = dev_find_slot(m->bus_8132_0, PCI_DEVFN(m->sbdn3, 1)); |
| 37 | if (dev) { |
| 38 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 39 | if (res) { |
| 40 | smp_write_ioapic(mc, m->apicid_8132_1, 0x11, res->base); |
| 41 | } |
| 42 | } |
| 43 | dev = dev_find_slot(m->bus_8132_0, PCI_DEVFN(m->sbdn3+1, 1)); |
| 44 | if (dev) { |
| 45 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 46 | if (res) { |
| 47 | smp_write_ioapic(mc, m->apicid_8132_2, 0x11, res->base); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | j = 0; |
| 52 | |
| 53 | for(i=1; i< sysconf.hc_possible_num; i++) { |
| 54 | if(!(sysconf.pci1234[i] & 0x1) ) continue; |
| 55 | |
| 56 | switch(sysconf.hcid[i]) { |
| 57 | case 1: // 8132 |
| 58 | case 3: // 8131 |
| 59 | dev = dev_find_slot(m->bus_8132a[j][0], PCI_DEVFN(m->sbdn3a[j], 1)); |
| 60 | if (dev) { |
| 61 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 62 | if (res) { |
| 63 | smp_write_ioapic(mc, m->apicid_8132a[j][0], 0x11, res->base); |
| 64 | } |
| 65 | } |
| 66 | dev = dev_find_slot(m->bus_8132a[j][0], PCI_DEVFN(m->sbdn3a[j]+1, 1)); |
| 67 | if (dev) { |
| 68 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 69 | if (res) { |
| 70 | smp_write_ioapic(mc, m->apicid_8132a[j][1], 0x11, res->base); |
| 71 | } |
| 72 | } |
| 73 | break; |
| 74 | } |
| 75 | j++; |
| 76 | } |
| 77 | |
| 78 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 79 | |
Patrick Georgi | 5244e1b | 2010-11-21 14:41:07 +0000 | [diff] [blame] | 80 | mptable_add_isa_interrupts(mc, bus_isa, m->apicid_8111, 0); |
Patrick Georgi | c5b87c8 | 2010-05-20 15:28:19 +0000 | [diff] [blame] | 81 | |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 82 | //??? What |
| 83 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8111_0, ((sysconf.sbdn+1)<<2)|3, m->apicid_8111, 0x13); |
| 84 | |
| 85 | // Onboard AMD USB |
| 86 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8111_1, (0<<2)|3, m->apicid_8111, 0x13); |
| 87 | |
| 88 | // Onboard VGA |
| 89 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8111_1, (6<<2)|0, m->apicid_8111, 0x12); |
| 90 | |
| 91 | //Slot 5 PCI 32 |
| 92 | for(i=0;i<4;i++) { |
| 93 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8111_1, (5<<2)|i, m->apicid_8111, 0x10 + (1+i)%4); //16 |
| 94 | } |
| 95 | |
| 96 | //Slot 6 PCI 32 |
| 97 | for(i=0;i<4;i++) { |
| 98 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8111_1, (4<<2)|i, m->apicid_8111, 0x10 + (0+i)%4); //16 |
| 99 | } |
| 100 | //Slot 1: HTX |
| 101 | |
| 102 | //Slot 2 PCI-X 133/100/66 |
| 103 | for(i=0;i<4;i++) { |
| 104 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8132_2, (2<<2)|i, m->apicid_8132_2, (2+i)%4); //30 |
| 105 | } |
| 106 | |
| 107 | //Slot 3 PCI-X 133/100/66 |
| 108 | for(i=0;i<4;i++) { |
| 109 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8132_1, (1<<2)|i, m->apicid_8132_1, (1+i)%4); //25 |
| 110 | } |
| 111 | |
| 112 | //Slot 4 PCI-X 133/100/66 |
| 113 | for(i=0;i<4;i++) { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 114 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8132_1, (2<<2)|i, m->apicid_8132_1, (2+i)%4); //26 |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | //Onboard NICS |
| 118 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8132_1, (3<<2)|0, m->apicid_8132_1, 3); //27 |
| 119 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8132_1, (4<<2)|0, m->apicid_8132_1, 0); //24 |
| 120 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 121 | //Onboard SATA |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 122 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8132_1, (5<<2)|0, m->apicid_8132_1, 1); //25 |
| 123 | |
| 124 | j = 0; |
| 125 | |
| 126 | for(i=1; i< sysconf.hc_possible_num; i++) { |
| 127 | if(!(sysconf.pci1234[i] & 0x1) ) continue; |
| 128 | int ii; |
| 129 | device_t dev; |
| 130 | struct resource *res; |
| 131 | switch(sysconf.hcid[i]) { |
| 132 | case 1: |
| 133 | case 3: |
| 134 | dev = dev_find_slot(m->bus_8132a[j][0], PCI_DEVFN(m->sbdn3a[j], 1)); |
| 135 | if (dev) { |
| 136 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 137 | if (res) { |
| 138 | //Slot 1 PCI-X 133/100/66 |
| 139 | for(ii=0;ii<4;ii++) { |
| 140 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8132a[j][1], (0<<2)|ii, m->apicid_8132a[j][0], (0+ii)%4); // |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | dev = dev_find_slot(m->bus_8132a[j][0], PCI_DEVFN(m->sbdn3a[j]+1, 1)); |
| 146 | if (dev) { |
| 147 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 148 | if (res) { |
| 149 | //Slot 2 PCI-X 133/100/66 |
| 150 | for(ii=0;ii<4;ii++) { |
| 151 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8132a[j][2], (0<<2)|ii, m->apicid_8132a[j][1], (0+ii)%4); //25 |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | break; |
| 157 | case 2: |
| 158 | |
| 159 | // Slot AGP |
| 160 | smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8151[j][1], 0x0, m->apicid_8111, 0x11); |
| 161 | break; |
| 162 | } |
| 163 | |
| 164 | j++; |
| 165 | } |
| 166 | |
| 167 | |
| 168 | |
| 169 | /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/ |
Patrick Georgi | 6eb7a53 | 2011-10-07 21:42:52 +0200 | [diff] [blame] | 170 | mptable_lintsrc(mc, bus_isa); |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 171 | /* There is no extension information... */ |
| 172 | |
| 173 | /* Compute the checksums */ |
Patrick Georgi | b0a9c5c | 2011-10-07 23:01:55 +0200 | [diff] [blame] | 174 | return mptable_finalize(mc); |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | unsigned long write_smp_table(unsigned long addr) |
| 178 | { |
| 179 | void *v; |
Patrick Georgi | c75c79b | 2011-10-07 22:41:07 +0200 | [diff] [blame] | 180 | v = smp_write_floating_table(addr, 0); |
Yinghai Lu | c34e3ab | 2006-10-12 00:58:20 +0000 | [diff] [blame] | 181 | return (unsigned long)smp_write_config_table(v); |
| 182 | } |