printk_foo -> printk(BIOS_FOO, ...)
[coreboot.git] / src / southbridge / amd / sb600 / sb600_sm.c
index b0f99533a2119ece97b832b5596441fd47424789..6a18bfeea5c2039d80f94097e82b2507b38fd9fb 100644 (file)
@@ -27,6 +27,7 @@
 #include <bitops.h>
 #include <arch/io.h>
 #include <cpu/x86/lapic.h>
+#include <arch/ioapic.h>
 #include <stdlib.h>
 #include "sb600.h"
 #include "sb600_smbus.c"
 #define CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL MAINBOARD_POWER_ON
 #endif
 
-struct ioapicreg {
-       u32 reg;
-       u32 value_low, value_high;
-};
-
-static struct ioapicreg ioapicregvalues[] = {
-#define ALL            (0xff << 24)
-#define NONE           (0)
-#define DISABLED       (1 << 16)
-#define ENABLED                (0 << 16)
-#define TRIGGER_EDGE   (0 << 15)
-#define TRIGGER_LEVEL  (1 << 15)
-#define POLARITY_HIGH  (0 << 13)
-#define POLARITY_LOW   (1 << 13)
-#define PHYSICAL_DEST  (0 << 11)
-#define LOGICAL_DEST   (1 << 11)
-#define ExtINT         (7 << 8)
-#define NMI            (4 << 8)
-#define SMI            (2 << 8)
-#define INT            (1 << 8)
-       /* IO-APIC virtual wire mode configuration */
-       /* mask, trigger, polarity, destination, delivery, vector */
-       {0, DISABLED, NONE},
-       {1, DISABLED, NONE},
-       {2, DISABLED, NONE},
-       {3, DISABLED, NONE},
-       {4, DISABLED, NONE},
-       {5, DISABLED, NONE},
-       {6, DISABLED, NONE},
-       {7, DISABLED, NONE},
-       {8, DISABLED, NONE},
-       {9, DISABLED, NONE},
-       {10, DISABLED, NONE},
-       {11, DISABLED, NONE},
-       {12, DISABLED, NONE},
-       {13, DISABLED, NONE},
-       {14, DISABLED, NONE},
-       {15, DISABLED, NONE},
-       {16, DISABLED, NONE},
-       {17, DISABLED, NONE},
-       {18, DISABLED, NONE},
-       {19, DISABLED, NONE},
-       {20, DISABLED, NONE},
-       {21, DISABLED, NONE},
-       {22, DISABLED, NONE},
-       {23, DISABLED, NONE},
-       /* Be careful and don't write past the end... */
-};
-
-static void setup_ioapic(u32 ioapic_base)
-{
-       int i;
-       u32 value_low, value_high;
-       volatile u32 *l;
-       struct ioapicreg *a = ioapicregvalues;
-
-       ioapicregvalues[0].value_high = lapicid() << (56 - 32);
-
-       printk_debug("lapicid = %016x\n", ioapicregvalues[0].value_high);
-
-       l = (u32 *)ioapic_base;
-
-       for (i = 0; i < ARRAY_SIZE(ioapicregvalues);
-            i++, a++) {
-               l[0] = (a->reg * 2) + 0x10;
-               l[4] = a->value_low;
-               value_low = l[4];
-               l[0] = (a->reg * 2) + 0x11;
-               l[4] = a->value_high;
-               value_high = l[4];
-               if ((i == 0) && (value_low == 0xffffffff)) {
-                       printk_warning("IO APIC not responding.\n");
-                       return;
-               }
-       }
-}
-
 /*
 * SB600 enables all USB controllers by default in SMBUS Control.
 * SB600 enables SATA by default in SMBUS Control.
@@ -130,10 +54,11 @@ static void sm_init(device_t dev)
        u32 on;
        u32 nmi_option;
 
-       printk_info("sm_init().\n");
+       printk(BIOS_INFO, "sm_init().\n");
 
        ioapic_base = pci_read_config32(dev, 0x74) & (0xffffffe0);      /* some like mem resource, but does not have  enable bit */
-       setup_ioapic(ioapic_base);
+       /* Don't rename APIC ID */
+       clear_ioapic(ioapic_base);
 
        dword = pci_read_config8(dev, 0x62);
        dword |= 1 << 2;
@@ -173,7 +98,7 @@ static void sm_init(device_t dev)
        }
        byte |= 1 << 2;
        pm_iowrite(0x74, byte);
-       printk_info("set power %s after power fail\n", on ? "on" : "off");
+       printk(BIOS_INFO, "set power %s after power fail\n", on ? "on" : "off");
 
        /* sb600 rpr:2.3.3: */
        byte = pm_ioread(0x9A);
@@ -229,10 +154,10 @@ static void sm_init(device_t dev)
        get_option(&nmi_option, "nmi");
        if (nmi_option) {
                byte &= ~(1 << 7);      /* set NMI */
-               printk_info("++++++++++set NMI+++++\n");
+               printk(BIOS_INFO, "++++++++++set NMI+++++\n");
        } else {
                byte |= (1 << 7);       /* Can not mask NMI from PCI-E and NMI_NOW */
-               printk_info("++++++++++no set NMI+++++\n");
+               printk(BIOS_INFO, "++++++++++no set NMI+++++\n");
        }
        byte &= ~(1 << 7);
        if (byte != byte_old) {
@@ -272,9 +197,9 @@ static void sm_init(device_t dev)
        /* 3.12: Enabling AB and BIF Clock Gating */
        abcfg_reg(0x10054, 0xFFFF0000, 0x1040000);
        abcfg_reg(0x54, 0xFF << 16, 4 << 16);
-       printk_info("3.11, ABCFG:0x54\n");
+       printk(BIOS_INFO, "3.11, ABCFG:0x54\n");
        abcfg_reg(0x54, 1 << 24, 1 << 24);
-       printk_info("3.12, ABCFG:0x54\n");
+       printk(BIOS_INFO, "3.12, ABCFG:0x54\n");
        abcfg_reg(0x98, 0x0000FF00, 0x00004700);
 
        /* 3.13:Enabling AB Int_Arbiter Enhancement (for All Revisions) */
@@ -286,7 +211,7 @@ static void sm_init(device_t dev)
 
        abcfg_reg(0x10098, 0xFFFFFFFF, 0x4000);
        abcfg_reg(0x04, 0xFFFFFFFF, 0x6);
-       printk_info("sm_init() end\n");
+       printk(BIOS_INFO, "sm_init() end\n");
 
        /* Enable NbSb virtual channel */
        axcfg_reg(0x114, 0x3f << 1, 0 << 1);
@@ -442,7 +367,7 @@ static struct device_operations smbus_ops = {
        .ops_pci = &lops_pci,
        .ops_smbus_bus = &lops_smbus_bus,
 };
-static struct pci_driver smbus_driver __pci_driver = {
+static const struct pci_driver smbus_driver __pci_driver = {
        .ops = &smbus_ops,
        .vendor = PCI_VENDOR_ID_ATI,
        .device = PCI_DEVICE_ID_ATI_SB600_SM,