Get mptable OEM/product ID from kconfig variables.
[coreboot.git] / src / mainboard / hp / dl145_g1 / mptable.c
1 #include <console/console.h>
2 #include <arch/smp/mpspec.h>
3 #include <arch/ioapic.h>
4 #include <device/pci.h>
5 #include <string.h>
6 #include <stdint.h>
7 #include <cpu/amd/amdk8_sysconf.h>
8
9 extern  unsigned char bus_8131_0;
10 extern  unsigned char bus_8131_1;
11 extern  unsigned char bus_8131_2;
12 extern  unsigned char bus_8111_0;
13 extern  unsigned char bus_8111_1;
14 extern  unsigned apicid_8111;
15 extern  unsigned apicid_8131_1;
16 extern  unsigned apicid_8131_2;
17
18 extern  unsigned sbdn3;
19
20 static void *smp_write_config_table(void *v)
21 {
22         struct mp_config_table *mc;
23         int bus_isa;
24
25         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
26
27         mptable_init(mc, LAPIC_ADDR);
28
29         smp_write_processors(mc);
30
31         get_bus_conf();
32
33         mptable_write_buses(mc, NULL, &bus_isa);
34
35 /*I/O APICs:    APIC ID Version State           Address*/
36         smp_write_ioapic(mc, apicid_8111, 0x20, IO_APIC_ADDR);
37         {
38                 device_t dev;
39                 struct resource *res;
40                 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3,1));
41                 if (dev) {
42                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
43                         if (res) {
44                                 smp_write_ioapic(mc, apicid_8131_1, 0x20, res->base);
45                         }
46                 }
47                 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3+1,1));
48                 if (dev) {
49                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
50                         if (res) {
51                                 smp_write_ioapic(mc, apicid_8131_2, 0x20, res->base);
52                         }
53                 }
54
55         }
56
57         mptable_add_isa_interrupts(mc, bus_isa, apicid_8111, 0);
58
59         //
60         // The commented-out lines are auto-detected on my servers.
61         //
62 /*I/O Ints:     Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN# */
63         // Integrated SMBus 2.0
64         //smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_0, ( 0x4 <<2)|3, apicid_8111  , 0x15);
65         // Integrated AMD AC97 Audio
66         //smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_0, ( 0x4 <<2)|1, apicid_8111  , 0x11);
67         //smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_0, ( 0x4 <<2)|2, apicid_8111  , 0x12);
68         // Integrated AMD USB
69         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, ( 0x4 <<2)|0, apicid_8111  , 0x10);
70         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, ( 0x0 <<2)|3, apicid_8111  , 0x13);
71         // On board ATI Rage XL
72         //smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, ( 0x5 <<2)|0, apicid_8111  , 0x14);
73         // On board Broadcom nics
74         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, ( 0x3 <<2)|0, apicid_8131_2, 0x03);
75         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, ( 0x3 <<2)|1, apicid_8131_2, 0x00);
76         // On board LSI SCSI
77         //smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, ( 0x2 <<2)|0, apicid_8131_2, 0x02);
78
79         // PCIX-133 Slot
80         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, ( 0x1 <<2)|0, apicid_8131_1, 0x01);
81         //smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, ( 0x1 <<2)|1, apicid_8131_1, 0x02);
82         //smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, ( 0x1 <<2)|2, apicid_8131_1, 0x03);
83         //smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, ( 0x1 <<2)|3, apicid_8131_1, 0x04);
84
85 /*Local Ints:   Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#*/
86         smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, MP_APIC_ALL, 0x0);
87         smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, MP_APIC_ALL, 0x1);
88         /* There is no extension information... */
89
90         /* Compute the checksums */
91         mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
92         mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
93         printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
94                 mc, smp_next_mpe_entry(mc));
95         return smp_next_mpe_entry(mc);
96 }
97
98 unsigned long write_smp_table(unsigned long addr)
99 {
100         void *v;
101         v = smp_write_floating_table(addr);
102         return (unsigned long)smp_write_config_table(v);
103 }