Get mptable OEM/product ID from kconfig variables.
[coreboot.git] / src / mainboard / hp / dl145_g3 / mptable.c
index 22715394ab044dac4001b31102c6ab814c2f63bc..f23121e634823221256002861698d598dbcb8b6d 100644 (file)
 #include <string.h>
 #include <stdint.h>
 #if CONFIG_LOGICAL_CPUS==1
-#include <cpu/amd/dualcore.h>
+#include <cpu/amd/multicore.h>
 #endif
-
 #include <cpu/amd/amdk8_sysconf.h>
-
 #include "mb_sysconf.h"
 
-extern void get_bus_conf(void);
-
-void *smp_write_config_table(void *v)
+static void *smp_write_config_table(void *v)
 {
-       static const char sig[4] = "PCMP";
-       static const char oem[8] = "HP      ";
-       static const char productid[12] = "TREX        ";
        struct mp_config_table *mc;
-
-       unsigned char bus_num;
-       int i;
        struct mb_sysconf_t *m;
+       int bus_isa;
 
        mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
-       memset(mc, 0, sizeof(*mc));
-
-       memcpy(mc->mpc_signature, sig, sizeof(sig));
-       mc->mpc_length = sizeof(*mc); /* initially just the header */
-       mc->mpc_spec = 0x04;
-       mc->mpc_checksum = 0; /* not yet computed */
-       memcpy(mc->mpc_oem, oem, sizeof(oem));
-       memcpy(mc->mpc_productid, productid, sizeof(productid));
-       mc->mpc_oemptr = 0;
-       mc->mpc_oemsize = 0;
-       mc->mpc_entry_count = 0; /* No entries yet... */
-       mc->mpc_lapic = LAPIC_ADDR;
-       mc->mpe_length = 0;
-       mc->mpe_checksum = 0;
-       mc->reserved = 0;
+
+       mptable_init(mc, LAPIC_ADDR);
 
        smp_write_processors(mc);
 
        get_bus_conf();
        m = sysconf.mb;
 
-       /*Bus:         Bus ID  Type*/
-       /* define bus and isa numbers */
-/*     for(bus_num = 0; bus_num < m->bus_isa; bus_num++) {
-               smp_write_bus(mc, bus_num, "PCI   ");
-               printk_debug("writing bus %d as PCI...\n",bus_num);
-       }
-       */
-       smp_write_bus(mc, 0, "PCI   ");
-       smp_write_bus(mc, 1, "PCI   ");
-       smp_write_bus(mc, 7, "PCI   ");
-       smp_write_bus(mc, 8, "PCI   ");
-
-       smp_write_bus(mc,m->bus_isa, "ISA   ");
-       printk_debug("writing %d as ISA...\n",m->bus_isa);
+       mptable_write_buses(mc, NULL, &bus_isa);
 
        /*I/O APICs:   APIC ID Version State           Address*/
        {
@@ -101,7 +66,7 @@ void *smp_write_config_table(void *v)
                        if (dev) {
                                res = find_resource(dev, PCI_BASE_ADDRESS_0);
                                if (res) {
-                                       printk_debug("APIC %d base address: %x\n",m->apicid_bcm5785[i],  res->base);
+                                       printk(BIOS_DEBUG, "APIC %d base address: %llx\n",m->apicid_bcm5785[i],  res->base);
                                        smp_write_ioapic(mc, m->apicid_bcm5785[i], 0x11, res->base);
                                }
                        }
@@ -151,31 +116,17 @@ void *smp_write_config_table(void *v)
                }
        }
 
-/*I/O Ints:    Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN# */
-       smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x0, m->apicid_bcm5785[0], 0x0);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0x1, m->apicid_bcm5785[0], 0x1);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0x0, m->apicid_bcm5785[0], 0x2);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0x3, m->apicid_bcm5785[0], 0x3);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0x4, m->apicid_bcm5785[0], 0x4);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0x5, m->apicid_bcm5785[0], 0x5);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0x6, m->apicid_bcm5785[0], 0x6);
+       mptable_add_isa_interrupts(mc, bus_isa, m->apicid_bcm5785[0], 0);
+
        //SATA
-/*     printk_debug("MPTABLE_SATA: bus_id:%d irq:%d apic_id:%d pin:%d\n",m->bus_bcm5785_1, (0x0e<<2)|0, m->apicid_bcm5785[0], 0x7); */
+/*     printk(BIOS_DEBUG, "MPTABLE_SATA: bus_id:%d irq:%d apic_id:%d pin:%d\n",m->bus_bcm5785_1, (0x0e<<2)|0, m->apicid_bcm5785[0], 0x7); */
 /*     smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_bcm5785_1, (0x0e<<2)|0, m->apicid_bcm5785[0], 0x7); */
-       printk_debug("MPTABLE_SATA: bus_id:%d irq:%d apic_id:%d pin:%d\n",m->bus_bcm5785_1, (0x0e<<2)|0, m->apicid_bcm5785[0], 0xb);
+       printk(BIOS_DEBUG, "MPTABLE_SATA: bus_id:%d irq:%d apic_id:%d pin:%d\n",m->bus_bcm5785_1, (0x0e<<2)|0, m->apicid_bcm5785[0], 0xb);
        smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_bcm5785_1, (0x0e<<2)|0, m->apicid_bcm5785[0], 0xb);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0x8, m->apicid_bcm5785[0], 0x8);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0x9, m->apicid_bcm5785[0], 0x9);
        //USB
-       printk_debug("sysconf.sbdn: %d on bus: %x \n",sysconf.sbdn, m->bus_bcm5785_0);
+       printk(BIOS_DEBUG, "sysconf.sbdn: %d on bus: %x \n",sysconf.sbdn, m->bus_bcm5785_0);
        smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_bcm5785_0, (0x03<<2)|0, m->apicid_bcm5785[0], 0xa);
 
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0xb, m->apicid_bcm5785[0], 0xb);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0xc, m->apicid_bcm5785[0], 0xc);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0xd, m->apicid_bcm5785[0], 0xd);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0xe, m->apicid_bcm5785[0], 0xe);
-       smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_isa, 0xf, m->apicid_bcm5785[0], 0xf);
-
        //VGA
        smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_bcm5785_0, (0x4<<2)|0, m->apicid_bcm5785[1], 0x7);
 
@@ -188,7 +139,7 @@ void *smp_write_config_table(void *v)
 
        //IDE
 //             outb(0x02, 0xc00); outb(0x0e, 0xc01);
-//     printk_debug("MPTABLE_IDE: bus_id:%d irq:%d apic_id:%d pin:%d\n",m->bus_bcm5785_0, ((1+sysconf.sbdn)<<2)|1, m->apicid_bcm5785[0], 0xe);
+//     printk(BIOS_DEBUG, "MPTABLE_IDE: bus_id:%d irq:%d apic_id:%d pin:%d\n",m->bus_bcm5785_0, ((1+sysconf.sbdn)<<2)|1, m->apicid_bcm5785[0], 0xe);
 //             smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,  m->bus_bcm5785_0, (0x02<<2)|1, m->apicid_bcm5785[0], 0xe);
 
        //onboard Broadcom GbE
@@ -206,15 +157,15 @@ void *smp_write_config_table(void *v)
                        uint32_t dword;
                        dword = pci_read_config32(dev, 0x6c);
                        dword |= (1<<4); // enable interrupts
-                       printk_debug("6ch: %x\n",dword);
+                       printk(BIOS_DEBUG, "6ch: %x\n",dword);
                        pci_write_config32(dev, 0x6c, dword);
                }
        }
 
 /*Local Ints:  Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#*/
-       printk_debug("m->bus_isa is: %x\n",m->bus_isa);
-       smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x0, MP_APIC_ALL, 0x0);
-       smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa , 0x0, MP_APIC_ALL, 0x1);
+       printk(BIOS_DEBUG, "bus_isa is: %x\n", bus_isa);
+       smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, MP_APIC_ALL, 0x0);
+       smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa , 0x0, MP_APIC_ALL, 0x1);
 
        //extended table entries
        smp_write_address_space(mc,0 , ADDRESS_TYPE_IO, 0x0, 0x0, 0x0, 0x0001);
@@ -231,7 +182,7 @@ void *smp_write_config_table(void *v)
        /* Compute the checksums */
        mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
        mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
-       printk_debug("Wrote the mp table end at: %p - %p\n",
+       printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
                mc, smp_next_mpe_entry(mc));
        return smp_next_mpe_entry(mc);
 }