]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/platforms/iseries/setup.c
[PATCH] powerpc: use a common vio_match_device routine
[linux-2.6-omap-h63xx.git] / arch / powerpc / platforms / iseries / setup.c
index 3ecc4a652d82e55425f6d3c3b8441266e389e316..befd36af7e32ada241b5ed9ffdf7624f2df21423 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/major.h>
 #include <linux/root_dev.h>
 #include <linux/kernel.h>
+#include <linux/if_ether.h>    /* ETH_ALEN */
 
 #include <asm/processor.h>
 #include <asm/machdep.h>
 #include <asm/cache.h>
 #include <asm/sections.h>
 #include <asm/abs_addr.h>
+#include <asm/iseries/hv_types.h>
 #include <asm/iseries/hv_lp_config.h>
 #include <asm/iseries/hv_call_event.h>
 #include <asm/iseries/hv_call_xm.h>
 #include <asm/iseries/it_lp_queue.h>
 #include <asm/iseries/mf.h>
+#include <asm/iseries/it_exp_vpd_panel.h>
 #include <asm/iseries/hv_lp_event.h>
 #include <asm/iseries/lpar_map.h>
 #include <asm/udbg.h>
+#include <asm/irq.h>
 
 #include "naca.h"
 #include "setup.h"
@@ -79,9 +83,6 @@ extern void iSeries_pci_final_fixup(void);
 static void iSeries_pci_final_fixup(void) { }
 #endif
 
-/* Global Variables */
-int piranha_simulator;
-
 extern int rd_size;            /* Defined in drivers/block/rd.c */
 extern unsigned long embedded_sysmap_start;
 extern unsigned long embedded_sysmap_end;
@@ -89,8 +90,6 @@ extern unsigned long embedded_sysmap_end;
 extern unsigned long iSeries_recal_tb;
 extern unsigned long iSeries_recal_titan;
 
-static int mf_initialized;
-
 static unsigned long cmd_mem_limit;
 
 struct MemoryBlock {
@@ -303,8 +302,6 @@ static void __init iSeries_init_early(void)
 {
        DBG(" -> iSeries_init_early()\n");
 
-       ppc64_firmware_features = FW_FEATURE_ISERIES;
-
        ppc64_interrupt_controller = IC_ISERIES;
 
 #if defined(CONFIG_BLK_DEV_INITRD)
@@ -342,15 +339,11 @@ static void __init iSeries_init_early(void)
 #ifdef CONFIG_SMP
        smp_init_iSeries();
 #endif
-       if (itLpNaca.xPirEnvironMode == 0)
-               piranha_simulator = 1;
 
        /* Associate Lp Event Queue 0 with processor 0 */
        HvCallEvent_setLpEventQueueInterruptProc(0, 0);
 
        mf_init();
-       mf_initialized = 1;
-       mb();
 
        /* If we were passed an initrd, set the ROOT_DEV properly if the values
         * look sensible. If not, clear initrd reference.
@@ -540,10 +533,10 @@ static void __init iSeries_setup_arch(void)
 {
        if (get_lppaca()->shared_proc) {
                ppc_md.idle_loop = iseries_shared_idle;
-               printk(KERN_INFO "Using shared processor idle loop\n");
+               printk(KERN_DEBUG "Using shared processor idle loop\n");
        } else {
                ppc_md.idle_loop = iseries_dedicated_idle;
-               printk(KERN_INFO "Using dedicated idle loop\n");
+               printk(KERN_DEBUG "Using dedicated idle loop\n");
        }
 
        /* Setup the Lp Event Queue */
@@ -560,39 +553,10 @@ static void iSeries_show_cpuinfo(struct seq_file *m)
        seq_printf(m, "machine\t\t: 64-bit iSeries Logical Partition\n");
 }
 
-/*
- * Document me.
- */
-static void iSeries_restart(char *cmd)
-{
-       mf_reboot();
-}
-
-/*
- * Document me.
- */
-static void iSeries_power_off(void)
-{
-       mf_power_off();
-}
-
-/*
- * Document me.
- */
-static void iSeries_halt(void)
-{
-       mf_power_off();
-}
-
 static void __init iSeries_progress(char * st, unsigned short code)
 {
        printk("Progress: [%04x] - %s\n", (unsigned)code, st);
-       if (!piranha_simulator && mf_initialized) {
-               if (code != 0xffff)
-                       mf_display_progress(code);
-               else
-                       mf_clear_src();
-       }
+       mf_display_progress(code);
 }
 
 static void __init iSeries_fixup_klimit(void)
@@ -709,21 +673,35 @@ static void iseries_dedicated_idle(void)
 void __init iSeries_init_IRQ(void) { }
 #endif
 
-static int __init iseries_probe(int platform)
+static int __init iseries_probe(void)
 {
-       return PLATFORM_ISERIES_LPAR == platform;
+       unsigned long root = of_get_flat_dt_root();
+       if (!of_flat_dt_is_compatible(root, "IBM,iSeries"))
+               return 0;
+
+       powerpc_firmware_features |= FW_FEATURE_ISERIES;
+       powerpc_firmware_features |= FW_FEATURE_LPAR;
+
+       /*
+        * The Hypervisor only allows us up to 256 interrupt
+        * sources (the irq number is passed in a u8).
+        */
+       virt_irq_max = 255;
+
+       return 1;
 }
 
-struct machdep_calls __initdata iseries_md = {
+define_machine(iseries) {
+       .name           = "iSeries",
        .setup_arch     = iSeries_setup_arch,
        .show_cpuinfo   = iSeries_show_cpuinfo,
        .init_IRQ       = iSeries_init_IRQ,
        .get_irq        = iSeries_get_irq,
        .init_early     = iSeries_init_early,
        .pcibios_fixup  = iSeries_pci_final_fixup,
-       .restart        = iSeries_restart,
-       .power_off      = iSeries_power_off,
-       .halt           = iSeries_halt,
+       .restart        = mf_reboot,
+       .power_off      = mf_power_off,
+       .halt           = mf_power_off,
        .get_boot_time  = iSeries_get_boot_time,
        .set_rtc_time   = iSeries_set_rtc_time,
        .get_rtc_time   = iSeries_get_rtc_time,
@@ -734,7 +712,7 @@ struct machdep_calls __initdata iseries_md = {
 };
 
 struct blob {
-       unsigned char data[PAGE_SIZE];
+       unsigned char data[PAGE_SIZE * 2];
        unsigned long next;
 };
 
@@ -917,6 +895,110 @@ void dt_cpus(struct iseries_flat_dt *dt)
        dt_end_node(dt);
 }
 
+void dt_model(struct iseries_flat_dt *dt)
+{
+       char buf[16] = "IBM,";
+
+       /* "IBM," + mfgId[2:3] + systemSerial[1:5] */
+       strne2a(buf + 4, xItExtVpdPanel.mfgID + 2, 2);
+       strne2a(buf + 6, xItExtVpdPanel.systemSerial + 1, 5);
+       buf[11] = '\0';
+       dt_prop_str(dt, "system-id", buf);
+
+       /* "IBM," + machineType[0:4] */
+       strne2a(buf + 4, xItExtVpdPanel.machineType, 4);
+       buf[8] = '\0';
+       dt_prop_str(dt, "model", buf);
+
+       dt_prop_str(dt, "compatible", "IBM,iSeries");
+}
+
+void dt_vdevices(struct iseries_flat_dt *dt)
+{
+       u32 reg = 0;
+       HvLpIndexMap vlan_map;
+       int i;
+       char buf[32];
+
+       dt_start_node(dt, "vdevice");
+       dt_prop_u32(dt, "#address-cells", 1);
+       dt_prop_u32(dt, "#size-cells", 0);
+
+       snprintf(buf, sizeof(buf), "viocons@%08x", reg);
+       dt_start_node(dt, buf);
+       dt_prop_str(dt, "device_type", "serial");
+       dt_prop_str(dt, "compatible", "");
+       dt_prop_u32(dt, "reg", reg);
+       dt_end_node(dt);
+       reg++;
+
+       snprintf(buf, sizeof(buf), "v-scsi@%08x", reg);
+       dt_start_node(dt, buf);
+       dt_prop_str(dt, "device_type", "vscsi");
+       dt_prop_str(dt, "compatible", "IBM,v-scsi");
+       dt_prop_u32(dt, "reg", reg);
+       dt_end_node(dt);
+       reg++;
+
+       vlan_map = HvLpConfig_getVirtualLanIndexMap();
+       for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++) {
+               unsigned char mac_addr[ETH_ALEN];
+
+               if ((vlan_map & (0x8000 >> i)) == 0)
+                       continue;
+               snprintf(buf, 32, "vlan@%08x", reg + i);
+               dt_start_node(dt, buf);
+               dt_prop_str(dt, "device_type", "vlan");
+               dt_prop_str(dt, "compatible", "");
+               dt_prop_u32(dt, "reg", reg + i);
+               dt_prop_u32(dt, "linux,unit_address", i);
+
+               mac_addr[0] = 0x02;
+               mac_addr[1] = 0x01;
+               mac_addr[2] = 0xff;
+               mac_addr[3] = i;
+               mac_addr[4] = 0xff;
+               mac_addr[5] = HvLpConfig_getLpIndex_outline();
+               dt_prop(dt, "local-mac-address", (char *)mac_addr, ETH_ALEN);
+               dt_prop(dt, "mac-address", (char *)mac_addr, ETH_ALEN);
+
+               dt_end_node(dt);
+       }
+       reg += HVMAXARCHITECTEDVIRTUALLANS;
+
+       for (i = 0; i < HVMAXARCHITECTEDVIRTUALDISKS; i++) {
+               snprintf(buf, 32, "viodasd@%08x", reg + i);
+               dt_start_node(dt, buf);
+               dt_prop_str(dt, "device_type", "viodasd");
+               dt_prop_str(dt, "compatible", "");
+               dt_prop_u32(dt, "reg", reg + i);
+               dt_prop_u32(dt, "linux,unit_address", i);
+               dt_end_node(dt);
+       }
+       reg += HVMAXARCHITECTEDVIRTUALDISKS;
+       for (i = 0; i < HVMAXARCHITECTEDVIRTUALCDROMS; i++) {
+               snprintf(buf, 32, "viocd@%08x", reg + i);
+               dt_start_node(dt, buf);
+               dt_prop_str(dt, "device_type", "viocd");
+               dt_prop_str(dt, "compatible", "");
+               dt_prop_u32(dt, "reg", reg + i);
+               dt_prop_u32(dt, "linux,unit_address", i);
+               dt_end_node(dt);
+       }
+       reg += HVMAXARCHITECTEDVIRTUALCDROMS;
+       for (i = 0; i < HVMAXARCHITECTEDVIRTUALTAPES; i++) {
+               snprintf(buf, 32, "viotape@%08x", reg + i);
+               dt_start_node(dt, buf);
+               dt_prop_str(dt, "device_type", "viotape");
+               dt_prop_str(dt, "compatible", "");
+               dt_prop_u32(dt, "reg", reg + i);
+               dt_prop_u32(dt, "linux,unit_address", i);
+               dt_end_node(dt);
+       }
+
+       dt_end_node(dt);
+}
+
 void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size)
 {
        u64 tmp[2];
@@ -927,6 +1009,7 @@ void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size)
 
        dt_prop_u32(dt, "#address-cells", 2);
        dt_prop_u32(dt, "#size-cells", 2);
+       dt_model(dt);
 
        /* /memory */
        dt_start_node(dt, "memory@0");
@@ -939,13 +1022,15 @@ void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size)
 
        /* /chosen */
        dt_start_node(dt, "chosen");
-       dt_prop_u32(dt, "linux,platform", PLATFORM_ISERIES_LPAR);
+       dt_prop_str(dt, "bootargs", cmd_line);
        if (cmd_mem_limit)
                dt_prop_u64(dt, "linux,memory-limit", cmd_mem_limit);
        dt_end_node(dt);
 
        dt_cpus(dt);
 
+       dt_vdevices(dt);
+
        dt_end_node(dt);
 
        dt_push_u32(dt, OF_DT_END);