Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[pandora-kernel.git] / arch / powerpc / platforms / iseries / setup.c
index 901acbc..c9605d7 100644 (file)
@@ -16,7 +16,6 @@
 
 #undef DEBUG
 
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/threads.h>
 #include <linux/smp.h>
@@ -28,7 +27,6 @@
 #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>
@@ -84,14 +80,10 @@ static void iSeries_pci_final_fixup(void) { }
 #endif
 
 extern int rd_size;            /* Defined in drivers/block/rd.c */
-extern unsigned long embedded_sysmap_start;
-extern unsigned long embedded_sysmap_end;
 
 extern unsigned long iSeries_recal_tb;
 extern unsigned long iSeries_recal_titan;
 
-static unsigned long cmd_mem_limit;
-
 struct MemoryBlock {
        unsigned long absStart;
        unsigned long absEnd;
@@ -302,8 +294,6 @@ static void __init iSeries_init_early(void)
 {
        DBG(" -> iSeries_init_early()\n");
 
-       ppc64_interrupt_controller = IC_ISERIES;
-
 #if defined(CONFIG_BLK_DEV_INITRD)
        /*
         * If the init RAM disk has been configured and there is
@@ -325,11 +315,6 @@ static void __init iSeries_init_early(void)
        iSeries_recal_tb = get_tb();
        iSeries_recal_titan = HvCallXm_loadTod();
 
-       /*
-        * Initialize the hash table management pointers
-        */
-       hpte_init_iSeries();
-
        /*
         * Initialize the DMA/TCE management
         */
@@ -568,16 +553,6 @@ static void __init iSeries_fixup_klimit(void)
        if (naca.xRamDisk)
                klimit = KERNELBASE + (u64)naca.xRamDisk +
                        (naca.xRamDiskSize * HW_PAGE_SIZE);
-       else {
-               /*
-                * No ram disk was included - check and see if there
-                * was an embedded system map.  Change klimit to take
-                * into account any embedded system map
-                */
-               if (embedded_sysmap_end)
-                       klimit = KERNELBASE + ((embedded_sysmap_end + 4095) &
-                                       0xfffffffffffff000);
-       }
 }
 
 static int __init iSeries_src_init(void)
@@ -682,11 +657,7 @@ static int __init iseries_probe(void)
        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;
+       hpte_init_iSeries();
 
        return 1;
 }
@@ -711,331 +682,6 @@ define_machine(iseries) {
        /* XXX Implement enable_pmcs for iSeries */
 };
 
-struct blob {
-       unsigned char data[PAGE_SIZE * 2];
-       unsigned long next;
-};
-
-struct iseries_flat_dt {
-       struct boot_param_header header;
-       u64 reserve_map[2];
-       struct blob dt;
-       struct blob strings;
-};
-
-struct iseries_flat_dt iseries_dt;
-
-void dt_init(struct iseries_flat_dt *dt)
-{
-       dt->header.off_mem_rsvmap =
-               offsetof(struct iseries_flat_dt, reserve_map);
-       dt->header.off_dt_struct = offsetof(struct iseries_flat_dt, dt);
-       dt->header.off_dt_strings = offsetof(struct iseries_flat_dt, strings);
-       dt->header.totalsize = sizeof(struct iseries_flat_dt);
-       dt->header.dt_strings_size = sizeof(struct blob);
-
-       /* There is no notion of hardware cpu id on iSeries */
-       dt->header.boot_cpuid_phys = smp_processor_id();
-
-       dt->dt.next = (unsigned long)&dt->dt.data;
-       dt->strings.next = (unsigned long)&dt->strings.data;
-
-       dt->header.magic = OF_DT_HEADER;
-       dt->header.version = 0x10;
-       dt->header.last_comp_version = 0x10;
-
-       dt->reserve_map[0] = 0;
-       dt->reserve_map[1] = 0;
-}
-
-void dt_check_blob(struct blob *b)
-{
-       if (b->next >= (unsigned long)&b->next) {
-               DBG("Ran out of space in flat device tree blob!\n");
-               BUG();
-       }
-}
-
-void dt_push_u32(struct iseries_flat_dt *dt, u32 value)
-{
-       *((u32*)dt->dt.next) = value;
-       dt->dt.next += sizeof(u32);
-
-       dt_check_blob(&dt->dt);
-}
-
-void dt_push_u64(struct iseries_flat_dt *dt, u64 value)
-{
-       *((u64*)dt->dt.next) = value;
-       dt->dt.next += sizeof(u64);
-
-       dt_check_blob(&dt->dt);
-}
-
-unsigned long dt_push_bytes(struct blob *blob, char *data, int len)
-{
-       unsigned long start = blob->next - (unsigned long)blob->data;
-
-       memcpy((char *)blob->next, data, len);
-       blob->next = _ALIGN(blob->next + len, 4);
-
-       dt_check_blob(blob);
-
-       return start;
-}
-
-void dt_start_node(struct iseries_flat_dt *dt, char *name)
-{
-       dt_push_u32(dt, OF_DT_BEGIN_NODE);
-       dt_push_bytes(&dt->dt, name, strlen(name) + 1);
-}
-
-#define dt_end_node(dt) dt_push_u32(dt, OF_DT_END_NODE)
-
-void dt_prop(struct iseries_flat_dt *dt, char *name, char *data, int len)
-{
-       unsigned long offset;
-
-       dt_push_u32(dt, OF_DT_PROP);
-
-       /* Length of the data */
-       dt_push_u32(dt, len);
-
-       /* Put the property name in the string blob. */
-       offset = dt_push_bytes(&dt->strings, name, strlen(name) + 1);
-
-       /* The offset of the properties name in the string blob. */
-       dt_push_u32(dt, (u32)offset);
-
-       /* The actual data. */
-       dt_push_bytes(&dt->dt, data, len);
-}
-
-void dt_prop_str(struct iseries_flat_dt *dt, char *name, char *data)
-{
-       dt_prop(dt, name, data, strlen(data) + 1); /* + 1 for NULL */
-}
-
-void dt_prop_u32(struct iseries_flat_dt *dt, char *name, u32 data)
-{
-       dt_prop(dt, name, (char *)&data, sizeof(u32));
-}
-
-void dt_prop_u64(struct iseries_flat_dt *dt, char *name, u64 data)
-{
-       dt_prop(dt, name, (char *)&data, sizeof(u64));
-}
-
-void dt_prop_u64_list(struct iseries_flat_dt *dt, char *name, u64 *data, int n)
-{
-       dt_prop(dt, name, (char *)data, sizeof(u64) * n);
-}
-
-void dt_prop_u32_list(struct iseries_flat_dt *dt, char *name, u32 *data, int n)
-{
-       dt_prop(dt, name, (char *)data, sizeof(u32) * n);
-}
-
-void dt_prop_empty(struct iseries_flat_dt *dt, char *name)
-{
-       dt_prop(dt, name, NULL, 0);
-}
-
-void dt_cpus(struct iseries_flat_dt *dt)
-{
-       unsigned char buf[32];
-       unsigned char *p;
-       unsigned int i, index;
-       struct IoHriProcessorVpd *d;
-       u32 pft_size[2];
-
-       /* yuck */
-       snprintf(buf, 32, "PowerPC,%s", cur_cpu_spec->cpu_name);
-       p = strchr(buf, ' ');
-       if (!p) p = buf + strlen(buf);
-
-       dt_start_node(dt, "cpus");
-       dt_prop_u32(dt, "#address-cells", 1);
-       dt_prop_u32(dt, "#size-cells", 0);
-
-       pft_size[0] = 0; /* NUMA CEC cookie, 0 for non NUMA  */
-       pft_size[1] = __ilog2(HvCallHpt_getHptPages() * HW_PAGE_SIZE);
-
-       for (i = 0; i < NR_CPUS; i++) {
-               if (lppaca[i].dyn_proc_status >= 2)
-                       continue;
-
-               snprintf(p, 32 - (p - buf), "@%d", i);
-               dt_start_node(dt, buf);
-
-               dt_prop_str(dt, "device_type", "cpu");
-
-               index = lppaca[i].dyn_hv_phys_proc_index;
-               d = &xIoHriProcessorVpd[index];
-
-               dt_prop_u32(dt, "i-cache-size", d->xInstCacheSize * 1024);
-               dt_prop_u32(dt, "i-cache-line-size", d->xInstCacheOperandSize);
-
-               dt_prop_u32(dt, "d-cache-size", d->xDataL1CacheSizeKB * 1024);
-               dt_prop_u32(dt, "d-cache-line-size", d->xDataCacheOperandSize);
-
-               /* magic conversions to Hz copied from old code */
-               dt_prop_u32(dt, "clock-frequency",
-                       ((1UL << 34) * 1000000) / d->xProcFreq);
-               dt_prop_u32(dt, "timebase-frequency",
-                       ((1UL << 32) * 1000000) / d->xTimeBaseFreq);
-
-               dt_prop_u32(dt, "reg", i);
-
-               dt_prop_u32_list(dt, "ibm,pft-size", pft_size, 2);
-
-               dt_end_node(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_empty(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_empty(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_empty(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_empty(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_empty(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];
-
-       dt_init(dt);
-
-       dt_start_node(dt, "");
-
-       dt_prop_u32(dt, "#address-cells", 2);
-       dt_prop_u32(dt, "#size-cells", 2);
-       dt_model(dt);
-
-       /* /memory */
-       dt_start_node(dt, "memory@0");
-       dt_prop_str(dt, "name", "memory");
-       dt_prop_str(dt, "device_type", "memory");
-       tmp[0] = 0;
-       tmp[1] = phys_mem_size;
-       dt_prop_u64_list(dt, "reg", tmp, 2);
-       dt_end_node(dt);
-
-       /* /chosen */
-       dt_start_node(dt, "chosen");
-       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);
-}
-
 void * __init iSeries_early_setup(void)
 {
        unsigned long phys_mem_size;
@@ -1050,28 +696,8 @@ void * __init iSeries_early_setup(void)
 
        iSeries_get_cmdline();
 
-       /* Save unparsed command line copy for /proc/cmdline */
-       strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
-
-       /* Parse early parameters, in particular mem=x */
-       parse_early_param();
-
-       build_flat_dt(&iseries_dt, phys_mem_size);
-
-       return (void *) __pa(&iseries_dt);
-}
-
-/*
- * On iSeries we just parse the mem=X option from the command line.
- * On pSeries it's a bit more complicated, see prom_init_mem()
- */
-static int __init early_parsemem(char *p)
-{
-       if (p)
-               cmd_mem_limit = ALIGN(memparse(p, &p), PAGE_SIZE);
-       return 0;
+       return (void *) __pa(build_flat_dt(phys_mem_size));
 }
-early_param("mem", early_parsemem);
 
 static void hvputc(char c)
 {