blob: c8f9f2bd6665635207b281e586cbaccadf69d01d [file] [log] [blame]
Yinghai Lu70093f72004-07-01 03:55:03 +00001#include <console/console.h>
2#include <arch/smp/mpspec.h>
Uwe Hermann74d1a6e2010-10-12 17:34:08 +00003#include <arch/ioapic.h>
Yinghai Lu70093f72004-07-01 03:55:03 +00004#include <device/pci.h>
5#include <string.h>
6#include <stdint.h>
7
Myles Watson08e0fb82010-03-22 16:33:25 +00008static void *smp_write_config_table(void *v)
Yinghai Lu70093f72004-07-01 03:55:03 +00009{
Yinghai Lu70093f72004-07-01 03:55:03 +000010 struct mp_config_table *mc;
Patrick Georgi20979582010-09-24 18:42:56 +000011 int isa_bus;
Yinghai Lu70093f72004-07-01 03:55:03 +000012
13 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
Yinghai Lu70093f72004-07-01 03:55:03 +000014
Uwe Hermann55dc2232010-10-25 15:32:07 +000015 mptable_init(mc, "S2735 ", LAPIC_ADDR);
Yinghai Lu70093f72004-07-01 03:55:03 +000016
Yinghai Luccf0bc02004-10-22 18:45:36 +000017 smp_write_processors(mc);
Patrick Georgi20979582010-09-24 18:42:56 +000018 mptable_write_buses(mc, NULL, &isa_bus);
Yinghai Lu70093f72004-07-01 03:55:03 +000019/*I/O APICs: APIC ID Version State Address*/
Uwe Hermann74d1a6e2010-10-12 17:34:08 +000020 smp_write_ioapic(mc, 8, 0x20, IO_APIC_ADDR);
Yinghai Lu70093f72004-07-01 03:55:03 +000021 {
Yinghai Luccf0bc02004-10-22 18:45:36 +000022 device_t dev;
23 struct resource *res;
Yinghai Lu70093f72004-07-01 03:55:03 +000024 dev = dev_find_slot(1, PCI_DEVFN(0x1e,0));
25 if (dev) {
Yinghai Luccf0bc02004-10-22 18:45:36 +000026 res = find_resource(dev, PCI_BASE_ADDRESS_0);
27 if (res) {
28 smp_write_ioapic(mc, 0x09, 0x20, res->base);
Stefan Reinauer14e22772010-04-27 06:56:47 +000029 }
Yinghai Lu70093f72004-07-01 03:55:03 +000030 }
31 dev = dev_find_slot(1, PCI_DEVFN(0x1c,0));
32 if (dev) {
Yinghai Luccf0bc02004-10-22 18:45:36 +000033 res = find_resource(dev, PCI_BASE_ADDRESS_0);
34 if (res) {
35 smp_write_ioapic(mc, 0x0a, 0x20, res->base);
Stefan Reinauer14e22772010-04-27 06:56:47 +000036 }
Yinghai Lu70093f72004-07-01 03:55:03 +000037 }
38 }
Patrick Georgi20979582010-09-24 18:42:56 +000039 mptable_add_isa_interrupts(mc, isa_bus, 0x8, 0);
Patrick Georgic5b87c82010-05-20 15:28:19 +000040
Yinghai Lu70093f72004-07-01 03:55:03 +000041/*I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#
Stefan Reinauer14e22772010-04-27 06:56:47 +000042*/
Yinghai Lu70093f72004-07-01 03:55:03 +000043//USB
44 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7c, 0x8, 0x12);
45 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x7d, 0x8, 0x11);
46 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x74, 0x8, 0x10);
47 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x75, 0x8, 0x13);
48 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x77, 0x8, 0x17);
49
50//onboard ati
51 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, 0x8, 0x8, 0x12);
52
53//onboard intel 82551 10/100
54 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, 0x4, 0x8, 0x11);
55
56// onboard Intel 82547 1000
57 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x2, 0x4, 0xa, 0x0);
58 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x2, 0x5, 0xa, 0x1);
59
60//Slot 4
61 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|0, 0x8, 0x12);
62 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|1, 0x8, 0x13);
63 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|2, 0x8, 0x10);
64 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x3<<2)|3, 0x8, 0x11);
65//Slot 3
66 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|0, 0x8, 0x13);
67 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|1, 0x8, 0x10);
68 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|2, 0x8, 0x11);
69 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x4, (0x4<<2)|3, 0x8, 0x12);
70//Slot 1
71 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|0, 0x9, 0x0);
72 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|1, 0x9, 0x1);
73 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|2, 0x9, 0x2);
74 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x3<<2)|3, 0x9, 0x3);
75//Slot 2
76 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|0, 0x9, 0x4);
77 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|1, 0x9, 0x5);
78 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|2, 0x9, 0x6);
79 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x3, (0x6<<2)|3, 0x9, 0x7);
80
81/*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/
Tobias Diedrichb907d322010-10-26 22:40:16 +000082 smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x0, 0x0, MP_APIC_ALL, 0x0);
83 smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, 0x0, 0x0, MP_APIC_ALL, 0x1);
Yinghai Lu70093f72004-07-01 03:55:03 +000084/*
85MP Config Extended Table Entries:
86
87--
88System Address Space
89 bus ID: 0 address type: I/O address
90 address base: 0x9000
91 address range: 0x6000
92--
93System Address Space
94 bus ID: 0 address type: I/O address
95 address base: 0x0
96 address range: 0x100
97--
98System Address Space
99 bus ID: 0 address type: memory address
100 address base: 0xa0000
101 address range: 0x20000
102--
103System Address Space
104 bus ID: 0 address type: memory address
105 address base: 0xfc700000
106 address range: 0x2500000
107--
108System Address Space
109 bus ID: 0 address type: prefetch address
110 address base: 0xff600000
111 address range: 0x500000
112--
113Bus Heirarchy
114 bus ID: 5 bus info: 0x01 parent bus ID: 0--
115Compatibility Bus Address
116 bus ID: 0 address modifier: add
117 predefined range: 0x00000000--
118Compatibility Bus Address
119 bus ID: 0 address modifier: add
Stefan Reinauer14e22772010-04-27 06:56:47 +0000120 predefined range: 0x00000001 // There is no extension information...
Yinghai Lu70093f72004-07-01 03:55:03 +0000121*/
122 /* Compute the checksums */
123 mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
124 mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000125 printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
Yinghai Lu70093f72004-07-01 03:55:03 +0000126 mc, smp_next_mpe_entry(mc));
127 return smp_next_mpe_entry(mc);
128}
129
Yinghai Luccf0bc02004-10-22 18:45:36 +0000130unsigned long write_smp_table(unsigned long addr)
Yinghai Lu70093f72004-07-01 03:55:03 +0000131{
132 void *v;
133 v = smp_write_floating_table(addr);
Yinghai Luccf0bc02004-10-22 18:45:36 +0000134 return (unsigned long)smp_write_config_table(v);
Yinghai Lu70093f72004-07-01 03:55:03 +0000135}