From 4baaf0cfda7279e1adaedc203d7a09e8e44597ab Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Wed, 12 Apr 2006 15:23:22 -0500 Subject: [PATCH] powerpc: Don't print chosen idle loop at every boot No need to write out what idle loop is used on every boot. Signed-off-by: Olof Johansson Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index a6fd9bedb074..0f5110659e60 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -536,10 +536,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 */ -- cgit v1.2.1 From 4bd174fe1cca738f53cf8bb9ac3cb327b1f516ed Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Tue, 18 Apr 2006 11:25:53 -0500 Subject: [PATCH] powerpc: Remove stale iseries global Not even the iSeries maintainer seems to have access to this legendary piranha simulator. It adds a bit of ugliness in the common time init code, and if it's no longer used we might as well be done with it and remove the bloat. Signed-off-by: Olof Johansson Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index 0f5110659e60..3c51448a1855 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -81,9 +81,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; @@ -340,8 +337,6 @@ 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); -- cgit v1.2.1 From 95a1ca6cd8e702a19ee56efae522a5816a56a205 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Thu, 27 Apr 2006 17:09:02 +1000 Subject: [PATCH] powerpc: add all the iSeries virtual devices to the device tree We do this by putting them in the flattened device tree at setup time. This required the flattened device tree blob to be made bigger. Currenly we don't do anything with these. Also make a function static. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 88 +++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index 3c51448a1855..4862b8e7c78c 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -28,6 +28,7 @@ #include #include #include +#include /* ETH_ALEN */ #include #include @@ -45,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -710,7 +712,7 @@ define_machine(iseries) { }; struct blob { - unsigned char data[PAGE_SIZE]; + unsigned char data[PAGE_SIZE * 2]; unsigned long next; }; @@ -911,6 +913,88 @@ void dt_model(struct iseries_flat_dt *dt) 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); + + 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_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_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_end_node(dt); + } + + dt_end_node(dt); +} + void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size) { u64 tmp[2]; @@ -941,6 +1025,8 @@ void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size) dt_cpus(dt); + dt_vdevices(dt); + dt_end_node(dt); dt_push_u32(dt, OF_DT_END); -- cgit v1.2.1 From e10fa77368dff31140451fac04d78d9f51f0f3ac Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Thu, 27 Apr 2006 17:18:21 +1000 Subject: [PATCH] powerpc: use the device tree for the iSeries vio bus probe As an added bonus, since every vio_dev now has a device_node associated with it, hotplug now works. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index 4862b8e7c78c..901acbcc0888 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -951,6 +951,7 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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; @@ -971,6 +972,7 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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; @@ -980,6 +982,7 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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; @@ -989,6 +992,7 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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); } -- cgit v1.2.1 From dd721ffd95d5e1516380da0b254ef737582a258f Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Thu, 27 Apr 2006 17:21:46 +1000 Subject: [PATCH] powerpc: use a common vio_match_device routine This requires the compatible properties having vaules that are empty strings instead of just being empty properties. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index 901acbcc0888..befd36af7e32 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -927,7 +927,7 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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_str(dt, "compatible", ""); dt_prop_u32(dt, "reg", reg); dt_end_node(dt); reg++; @@ -949,7 +949,7 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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_str(dt, "compatible", ""); dt_prop_u32(dt, "reg", reg + i); dt_prop_u32(dt, "linux,unit_address", i); @@ -970,7 +970,7 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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_str(dt, "compatible", ""); dt_prop_u32(dt, "reg", reg + i); dt_prop_u32(dt, "linux,unit_address", i); dt_end_node(dt); @@ -980,7 +980,7 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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_str(dt, "compatible", ""); dt_prop_u32(dt, "reg", reg + i); dt_prop_u32(dt, "linux,unit_address", i); dt_end_node(dt); @@ -990,7 +990,7 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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_str(dt, "compatible", ""); dt_prop_u32(dt, "reg", reg + i); dt_prop_u32(dt, "linux,unit_address", i); dt_end_node(dt); -- cgit v1.2.1 From 07fb3f454cc9e0f656e378a6feb5bdd6cac4bd41 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 15 May 2006 13:39:47 +1000 Subject: [PATCH] powerpc: update iseries_veth device-tree information Make the device-tree information more generic and more like the pSeries virtual lan device. Also use the MAC address from the device tree. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index befd36af7e32..0a0825781937 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -946,10 +946,10 @@ void dt_vdevices(struct iseries_flat_dt *dt) if ((vlan_map & (0x8000 >> i)) == 0) continue; - snprintf(buf, 32, "vlan@%08x", reg + i); + snprintf(buf, 32, "l-lan@%08x", reg + i); dt_start_node(dt, buf); - dt_prop_str(dt, "device_type", "vlan"); - dt_prop_str(dt, "compatible", ""); + dt_prop_str(dt, "device_type", "network"); + dt_prop_str(dt, "compatible", "IBM,iSeries-l-lan"); dt_prop_u32(dt, "reg", reg + i); dt_prop_u32(dt, "linux,unit_address", i); @@ -961,6 +961,8 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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_prop_u32(dt, "max-frame-size", 9000); + dt_prop_u32(dt, "address-bits", 48); dt_end_node(dt); } -- cgit v1.2.1 From fbabeb60ba783bf7a43858ecefc5066ac1f07162 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 15 May 2006 13:41:22 +1000 Subject: [PATCH] powerpc: update iSeries viodasd device-tree entries These devices should have device_type block and a unique compatible entry. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index 0a0825781937..285f2b2e7d83 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -971,8 +971,8 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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_str(dt, "device_type", "block"); + dt_prop_str(dt, "compatible", "IBM,iSeries-viodasd"); dt_prop_u32(dt, "reg", reg + i); dt_prop_u32(dt, "linux,unit_address", i); dt_end_node(dt); -- cgit v1.2.1 From dc3c9b8ca2ec15cf56d071b85f3734a07bf5f808 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 15 May 2006 13:42:29 +1000 Subject: [PATCH] powerpc: update iSeries vdevice Make it look more like the pSeries vdevice tree. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index 285f2b2e7d83..d3f94b4f28a8 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -921,13 +921,14 @@ void dt_vdevices(struct iseries_flat_dt *dt) char buf[32]; dt_start_node(dt, "vdevice"); + dt_prop_str(dt, "device_type", "vdevice"); + dt_prop_str(dt, "compatible", "IBM,iSeries-vdevice"); dt_prop_u32(dt, "#address-cells", 1); dt_prop_u32(dt, "#size-cells", 0); - snprintf(buf, sizeof(buf), "viocons@%08x", reg); + snprintf(buf, sizeof(buf), "vty@%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++; -- cgit v1.2.1 From de0fe3b83f4bb47a0a6b47897bb3800862194016 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 15 May 2006 13:44:01 +1000 Subject: [PATCH] powerpc: update iSeries viocd and viotape device-tree Make their device_type entries more generic and their compatible entries more specific. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index d3f94b4f28a8..074d1d949708 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -982,8 +982,8 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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_str(dt, "device_type", "block"); + dt_prop_str(dt, "compatible", "IBM,iSeries-viocd"); dt_prop_u32(dt, "reg", reg + i); dt_prop_u32(dt, "linux,unit_address", i); dt_end_node(dt); @@ -992,8 +992,8 @@ void dt_vdevices(struct iseries_flat_dt *dt) 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_str(dt, "device_type", "byte"); + dt_prop_str(dt, "compatible", "IBM,iSeries-viotape"); dt_prop_u32(dt, "reg", reg + i); dt_prop_u32(dt, "linux,unit_address", i); dt_end_node(dt); -- cgit v1.2.1 From 2babf5c2ec2f2d5de3e38d20f7df7fd815fd10c9 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Wed, 17 May 2006 18:00:46 +1000 Subject: [PATCH] powerpc: Unify mem= handling We currently do mem= handling in three seperate places. And as benh pointed out I wrote two of them. Now that we parse command line parameters earlier we can clean this mess up. Moving the parsing out of prom_init means the device tree might be allocated above the memory limit. If that happens we'd have to move it. As it happens we already have logic to do that for kdump, so just genericise it. This also means we might have reserved regions above the memory limit, if we do the bootmem allocator will blow up, so we have to modify lmb_enforce_memory_limit() to truncate the reserves as well. Tested on P5 LPAR, iSeries, F50, 44p. Tested moving device tree on P5 and 44p and F50. Signed-off-by: Michael Ellerman Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index 074d1d949708..fd6d0ebe8ddd 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -90,8 +90,6 @@ 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; @@ -1026,8 +1024,6 @@ void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size) /* /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); @@ -1053,29 +1049,11 @@ 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; -} -early_param("mem", early_parsemem); - static void hvputc(char c) { if (c == '\n') -- cgit v1.2.1 From 0d177df15d12926dc2ef7c814f317f02de52ce17 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 19 May 2006 16:46:28 +1000 Subject: [PATCH] powerpc: move iSeries PCI devices to the device tree Move the probing of PCI devices to setup.c and put them all into the flattened device tree. The later probing is now done by traversing the device tree. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 204 +++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index fd6d0ebe8ddd..d83f5ed4ec1f 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -66,6 +66,8 @@ #include "main_store.h" #include "call_sm.h" #include "call_hpt.h" +#include "call_pci.h" +#include "pci.h" #ifdef DEBUG #define DBG(fmt...) udbg_printf(fmt) @@ -1000,6 +1002,207 @@ void dt_vdevices(struct iseries_flat_dt *dt) dt_end_node(dt); } +/* + * This assumes that the node slot is always on the primary bus! + */ +static void scan_bridge_slot(struct iseries_flat_dt *dt, HvBusNumber bus, + struct HvCallPci_BridgeInfo *bridge_info) +{ + HvSubBusNumber sub_bus = bridge_info->subBusNumber; + u16 vendor_id; + u16 device_id; + u32 class_id; + int err; + char buf[32]; + u32 reg[5]; + int id_sel = ISERIES_GET_DEVICE_FROM_SUBBUS(sub_bus); + int function = ISERIES_GET_FUNCTION_FROM_SUBBUS(sub_bus); + HvAgentId eads_id_sel = ISERIES_PCI_AGENTID(id_sel, function); + + /* + * Connect all functions of any device found. + */ + for (id_sel = 1; id_sel <= bridge_info->maxAgents; id_sel++) { + for (function = 0; function < 8; function++) { + u8 devfn; + + HvAgentId agent_id = ISERIES_PCI_AGENTID(id_sel, + function); + err = HvCallXm_connectBusUnit(bus, sub_bus, + agent_id, 0); + if (err) { + if (err != 0x302) + printk(KERN_DEBUG + "connectBusUnit(%x, %x, %x) " + "== %x\n", + bus, sub_bus, agent_id, err); + continue; + } + + err = HvCallPci_configLoad16(bus, sub_bus, agent_id, + PCI_VENDOR_ID, &vendor_id); + if (err) { + printk(KERN_DEBUG + "ReadVendor(%x, %x, %x) == %x\n", + bus, sub_bus, agent_id, err); + continue; + } + err = HvCallPci_configLoad16(bus, sub_bus, agent_id, + PCI_DEVICE_ID, &device_id); + if (err) { + printk(KERN_DEBUG + "ReadDevice(%x, %x, %x) == %x\n", + bus, sub_bus, agent_id, err); + continue; + } + err = HvCallPci_configLoad32(bus, sub_bus, agent_id, + PCI_CLASS_REVISION , &class_id); + if (err) { + printk(KERN_DEBUG + "ReadClass(%x, %x, %x) == %x\n", + bus, sub_bus, agent_id, err); + continue; + } + + devfn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(eads_id_sel), + function); + if (function == 0) + snprintf(buf, sizeof(buf), "pci@%x", + PCI_SLOT(devfn)); + else + snprintf(buf, sizeof(buf), "pci@%x,%d", + PCI_SLOT(devfn), function); + dt_start_node(dt, buf); + reg[0] = (bus << 18) | (devfn << 8); + reg[1] = 0; + reg[2] = 0; + reg[3] = 0; + reg[4] = 0; + dt_prop_u32_list(dt, "reg", reg, 5); + dt_prop_u32(dt, "vendor-id", vendor_id); + dt_prop_u32(dt, "device-id", device_id); + dt_prop_u32(dt, "class-code", class_id >> 8); + dt_prop_u32(dt, "revision-id", class_id & 0xff); + dt_prop_u32(dt, "linux,subbus", sub_bus); + dt_prop_u32(dt, "linux,agent-id", agent_id); + dt_prop_u32(dt, "linux,logical-slot-number", + bridge_info->logicalSlotNumber); + dt_end_node(dt); + + } + } +} + +static void scan_bridge(struct iseries_flat_dt *dt, HvBusNumber bus, + HvSubBusNumber sub_bus, int id_sel) +{ + struct HvCallPci_BridgeInfo bridge_info; + HvAgentId agent_id; + int function; + int ret; + + /* Note: hvSubBus and irq is always be 0 at this level! */ + for (function = 0; function < 8; ++function) { + agent_id = ISERIES_PCI_AGENTID(id_sel, function); + ret = HvCallXm_connectBusUnit(bus, sub_bus, agent_id, 0); + if (ret != 0) { + if (ret != 0xb) + printk(KERN_DEBUG "connectBusUnit(%x, %x, %x) " + "== %x\n", + bus, sub_bus, agent_id, ret); + continue; + } + printk("found device at bus %d idsel %d func %d (AgentId %x)\n", + bus, id_sel, function, agent_id); + ret = HvCallPci_getBusUnitInfo(bus, sub_bus, agent_id, + iseries_hv_addr(&bridge_info), + sizeof(struct HvCallPci_BridgeInfo)); + if (ret != 0) + continue; + printk("bridge info: type %x subbus %x " + "maxAgents %x maxsubbus %x logslot %x\n", + bridge_info.busUnitInfo.deviceType, + bridge_info.subBusNumber, + bridge_info.maxAgents, + bridge_info.maxSubBusNumber, + bridge_info.logicalSlotNumber); + if (bridge_info.busUnitInfo.deviceType == + HvCallPci_BridgeDevice) + scan_bridge_slot(dt, bus, &bridge_info); + else + printk("PCI: Invalid Bridge Configuration(0x%02X)", + bridge_info.busUnitInfo.deviceType); + } +} + +static void scan_phb(struct iseries_flat_dt *dt, HvBusNumber bus) +{ + struct HvCallPci_DeviceInfo dev_info; + const HvSubBusNumber sub_bus = 0; /* EADs is always 0. */ + int err; + int id_sel; + const int max_agents = 8; + + /* + * Probe for EADs Bridges + */ + for (id_sel = 1; id_sel < max_agents; ++id_sel) { + err = HvCallPci_getDeviceInfo(bus, sub_bus, id_sel, + iseries_hv_addr(&dev_info), + sizeof(struct HvCallPci_DeviceInfo)); + if (err) { + if (err != 0x302) + printk(KERN_DEBUG "getDeviceInfo(%x, %x, %x) " + "== %x\n", + bus, sub_bus, id_sel, err); + continue; + } + if (dev_info.deviceType != HvCallPci_NodeDevice) { + printk(KERN_DEBUG "PCI: Invalid System Configuration" + "(0x%02X) for bus 0x%02x id 0x%02x.\n", + dev_info.deviceType, bus, id_sel); + continue; + } + scan_bridge(dt, bus, sub_bus, id_sel); + } +} + +static void dt_pci_devices(struct iseries_flat_dt *dt) +{ + HvBusNumber bus; + char buf[32]; + u32 buses[2]; + int phb_num = 0; + + /* Check all possible buses. */ + for (bus = 0; bus < 256; bus++) { + int err = HvCallXm_testBus(bus); + + if (err) { + /* + * Check for Unexpected Return code, a clue that + * something has gone wrong. + */ + if (err != 0x0301) + printk(KERN_ERR "Unexpected Return on Probe" + "(0x%02X): 0x%04X", bus, err); + continue; + } + printk("bus %d appears to exist\n", bus); + snprintf(buf, 32, "pci@%d", phb_num); + dt_start_node(dt, buf); + dt_prop_str(dt, "device_type", "pci"); + dt_prop_str(dt, "compatible", "IBM,iSeries-Logical-PHB"); + dt_prop_u32(dt, "#address-cells", 3); + dt_prop_u32(dt, "#size-cells", 2); + buses[0] = buses[1] = bus; + dt_prop_u32_list(dt, "bus-range", buses, 2); + scan_phb(dt, bus); + dt_end_node(dt); + phb_num++; + } +} + void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size) { u64 tmp[2]; @@ -1029,6 +1232,7 @@ void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size) dt_cpus(dt); dt_vdevices(dt); + dt_pci_devices(dt); dt_end_node(dt); -- cgit v1.2.1 From 095eed4f8d0be13a7934031434b6e9ceddb87ff6 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 19 May 2006 16:54:42 +1000 Subject: [PATCH] powerpc: clean up iSeries PCI probe Only scan the host bridges and then use the existing pci_devs_phb_init() routine. Also fix typo in setup of reg property. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index d83f5ed4ec1f..0f49412b438e 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -1073,7 +1073,7 @@ static void scan_bridge_slot(struct iseries_flat_dt *dt, HvBusNumber bus, snprintf(buf, sizeof(buf), "pci@%x,%d", PCI_SLOT(devfn), function); dt_start_node(dt, buf); - reg[0] = (bus << 18) | (devfn << 8); + reg[0] = (bus << 16) | (devfn << 8); reg[1] = 0; reg[2] = 0; reg[3] = 0; -- cgit v1.2.1 From 29629b2972467f6cc00427a89008c09d010074c8 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 19 May 2006 16:55:53 +1000 Subject: [PATCH] powerpc: make iSeries flat device tree stuff static Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 40 +++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index 0f49412b438e..95864146b8f0 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -723,9 +723,9 @@ struct iseries_flat_dt { struct blob strings; }; -struct iseries_flat_dt iseries_dt; +static struct iseries_flat_dt iseries_dt; -void dt_init(struct iseries_flat_dt *dt) +static void dt_init(struct iseries_flat_dt *dt) { dt->header.off_mem_rsvmap = offsetof(struct iseries_flat_dt, reserve_map); @@ -748,7 +748,7 @@ void dt_init(struct iseries_flat_dt *dt) dt->reserve_map[1] = 0; } -void dt_check_blob(struct blob *b) +static 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"); @@ -756,7 +756,7 @@ void dt_check_blob(struct blob *b) } } -void dt_push_u32(struct iseries_flat_dt *dt, u32 value) +static void dt_push_u32(struct iseries_flat_dt *dt, u32 value) { *((u32*)dt->dt.next) = value; dt->dt.next += sizeof(u32); @@ -764,15 +764,17 @@ void dt_push_u32(struct iseries_flat_dt *dt, u32 value) dt_check_blob(&dt->dt); } -void dt_push_u64(struct iseries_flat_dt *dt, u64 value) +#ifdef notyet +static 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); } +#endif -unsigned long dt_push_bytes(struct blob *blob, char *data, int len) +static unsigned long dt_push_bytes(struct blob *blob, char *data, int len) { unsigned long start = blob->next - (unsigned long)blob->data; @@ -784,7 +786,7 @@ unsigned long dt_push_bytes(struct blob *blob, char *data, int len) return start; } -void dt_start_node(struct iseries_flat_dt *dt, char *name) +static 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); @@ -792,7 +794,7 @@ void dt_start_node(struct iseries_flat_dt *dt, char *name) #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) +static void dt_prop(struct iseries_flat_dt *dt, char *name, char *data, int len) { unsigned long offset; @@ -811,37 +813,39 @@ void dt_prop(struct iseries_flat_dt *dt, char *name, char *data, int len) dt_push_bytes(&dt->dt, data, len); } -void dt_prop_str(struct iseries_flat_dt *dt, char *name, char *data) +static 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) +static 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) +static 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) +static 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) +static 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) +#ifdef notyet +static void dt_prop_empty(struct iseries_flat_dt *dt, char *name) { dt_prop(dt, name, NULL, 0); } +#endif -void dt_cpus(struct iseries_flat_dt *dt) +static void dt_cpus(struct iseries_flat_dt *dt) { unsigned char buf[32]; unsigned char *p; @@ -895,7 +899,7 @@ void dt_cpus(struct iseries_flat_dt *dt) dt_end_node(dt); } -void dt_model(struct iseries_flat_dt *dt) +static void dt_model(struct iseries_flat_dt *dt) { char buf[16] = "IBM,"; @@ -913,7 +917,7 @@ void dt_model(struct iseries_flat_dt *dt) dt_prop_str(dt, "compatible", "IBM,iSeries"); } -void dt_vdevices(struct iseries_flat_dt *dt) +static void dt_vdevices(struct iseries_flat_dt *dt) { u32 reg = 0; HvLpIndexMap vlan_map; @@ -1203,7 +1207,7 @@ static void dt_pci_devices(struct iseries_flat_dt *dt) } } -void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size) +static void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size) { u64 tmp[2]; -- cgit v1.2.1 From 9ceb19093b5e5f037c6b47df0607dd567283287d Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 19 May 2006 16:58:13 +1000 Subject: [PATCH] powerpc: give iSeries device tree nodes better names Use the PCI class code to choose a name for the PCI device nodes and to guess a device_type. Failing that, base the name on the vendor and device ids as specified in the spec. Mark just about everything __init{data}. Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 95 +++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 29 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index 95864146b8f0..5661bd0d4279 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -725,7 +725,7 @@ struct iseries_flat_dt { static struct iseries_flat_dt iseries_dt; -static void dt_init(struct iseries_flat_dt *dt) +static void __init dt_init(struct iseries_flat_dt *dt) { dt->header.off_mem_rsvmap = offsetof(struct iseries_flat_dt, reserve_map); @@ -748,7 +748,7 @@ static void dt_init(struct iseries_flat_dt *dt) dt->reserve_map[1] = 0; } -static void dt_check_blob(struct blob *b) +static void __init dt_check_blob(struct blob *b) { if (b->next >= (unsigned long)&b->next) { DBG("Ran out of space in flat device tree blob!\n"); @@ -756,7 +756,7 @@ static void dt_check_blob(struct blob *b) } } -static void dt_push_u32(struct iseries_flat_dt *dt, u32 value) +static void __init dt_push_u32(struct iseries_flat_dt *dt, u32 value) { *((u32*)dt->dt.next) = value; dt->dt.next += sizeof(u32); @@ -765,7 +765,7 @@ static void dt_push_u32(struct iseries_flat_dt *dt, u32 value) } #ifdef notyet -static void dt_push_u64(struct iseries_flat_dt *dt, u64 value) +static void __init dt_push_u64(struct iseries_flat_dt *dt, u64 value) { *((u64*)dt->dt.next) = value; dt->dt.next += sizeof(u64); @@ -774,7 +774,7 @@ static void dt_push_u64(struct iseries_flat_dt *dt, u64 value) } #endif -static unsigned long dt_push_bytes(struct blob *blob, char *data, int len) +static unsigned long __init dt_push_bytes(struct blob *blob, char *data, int len) { unsigned long start = blob->next - (unsigned long)blob->data; @@ -786,7 +786,7 @@ static unsigned long dt_push_bytes(struct blob *blob, char *data, int len) return start; } -static void dt_start_node(struct iseries_flat_dt *dt, char *name) +static void __init 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); @@ -794,7 +794,8 @@ static void dt_start_node(struct iseries_flat_dt *dt, char *name) #define dt_end_node(dt) dt_push_u32(dt, OF_DT_END_NODE) -static void dt_prop(struct iseries_flat_dt *dt, char *name, char *data, int len) +static void __init dt_prop(struct iseries_flat_dt *dt, char *name, + char *data, int len) { unsigned long offset; @@ -813,39 +814,42 @@ static void dt_prop(struct iseries_flat_dt *dt, char *name, char *data, int len) dt_push_bytes(&dt->dt, data, len); } -static void dt_prop_str(struct iseries_flat_dt *dt, char *name, char *data) +static void __init dt_prop_str(struct iseries_flat_dt *dt, char *name, + char *data) { dt_prop(dt, name, data, strlen(data) + 1); /* + 1 for NULL */ } -static void dt_prop_u32(struct iseries_flat_dt *dt, char *name, u32 data) +static void __init dt_prop_u32(struct iseries_flat_dt *dt, char *name, u32 data) { dt_prop(dt, name, (char *)&data, sizeof(u32)); } -static void dt_prop_u64(struct iseries_flat_dt *dt, char *name, u64 data) +static void __init dt_prop_u64(struct iseries_flat_dt *dt, char *name, u64 data) { dt_prop(dt, name, (char *)&data, sizeof(u64)); } -static void dt_prop_u64_list(struct iseries_flat_dt *dt, char *name, u64 *data, int n) +static void __init dt_prop_u64_list(struct iseries_flat_dt *dt, char *name, + u64 *data, int n) { dt_prop(dt, name, (char *)data, sizeof(u64) * n); } -static void dt_prop_u32_list(struct iseries_flat_dt *dt, char *name, u32 *data, int n) +static void __init dt_prop_u32_list(struct iseries_flat_dt *dt, char *name, + u32 *data, int n) { dt_prop(dt, name, (char *)data, sizeof(u32) * n); } #ifdef notyet -static void dt_prop_empty(struct iseries_flat_dt *dt, char *name) +static void __init dt_prop_empty(struct iseries_flat_dt *dt, char *name) { dt_prop(dt, name, NULL, 0); } #endif -static void dt_cpus(struct iseries_flat_dt *dt) +static void __init dt_cpus(struct iseries_flat_dt *dt) { unsigned char buf[32]; unsigned char *p; @@ -899,7 +903,7 @@ static void dt_cpus(struct iseries_flat_dt *dt) dt_end_node(dt); } -static void dt_model(struct iseries_flat_dt *dt) +static void __init dt_model(struct iseries_flat_dt *dt) { char buf[16] = "IBM,"; @@ -917,7 +921,7 @@ static void dt_model(struct iseries_flat_dt *dt) dt_prop_str(dt, "compatible", "IBM,iSeries"); } -static void dt_vdevices(struct iseries_flat_dt *dt) +static void __init dt_vdevices(struct iseries_flat_dt *dt) { u32 reg = 0; HvLpIndexMap vlan_map; @@ -1006,11 +1010,32 @@ static void dt_vdevices(struct iseries_flat_dt *dt) dt_end_node(dt); } +struct pci_class_name { + u16 code; + char *name; + char *type; +}; + +static struct pci_class_name __initdata pci_class_name[] = { + { PCI_CLASS_NETWORK_ETHERNET, "ethernet", "network" }, +}; + +static struct pci_class_name * __init dt_find_pci_class_name(u16 class_code) +{ + struct pci_class_name *cp; + + for (cp = pci_class_name; + cp < &pci_class_name[ARRAY_SIZE(pci_class_name)]; cp++) + if (cp->code == class_code) + return cp; + return NULL; +} + /* * This assumes that the node slot is always on the primary bus! */ -static void scan_bridge_slot(struct iseries_flat_dt *dt, HvBusNumber bus, - struct HvCallPci_BridgeInfo *bridge_info) +static void __init scan_bridge_slot(struct iseries_flat_dt *dt, + HvBusNumber bus, struct HvCallPci_BridgeInfo *bridge_info) { HvSubBusNumber sub_bus = bridge_info->subBusNumber; u16 vendor_id; @@ -1022,14 +1047,14 @@ static void scan_bridge_slot(struct iseries_flat_dt *dt, HvBusNumber bus, int id_sel = ISERIES_GET_DEVICE_FROM_SUBBUS(sub_bus); int function = ISERIES_GET_FUNCTION_FROM_SUBBUS(sub_bus); HvAgentId eads_id_sel = ISERIES_PCI_AGENTID(id_sel, function); + u8 devfn; + struct pci_class_name *cp; /* * Connect all functions of any device found. */ for (id_sel = 1; id_sel <= bridge_info->maxAgents; id_sel++) { for (function = 0; function < 8; function++) { - u8 devfn; - HvAgentId agent_id = ISERIES_PCI_AGENTID(id_sel, function); err = HvCallXm_connectBusUnit(bus, sub_bus, @@ -1070,12 +1095,20 @@ static void scan_bridge_slot(struct iseries_flat_dt *dt, HvBusNumber bus, devfn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(eads_id_sel), function); - if (function == 0) - snprintf(buf, sizeof(buf), "pci@%x", - PCI_SLOT(devfn)); + cp = dt_find_pci_class_name(class_id >> 16); + if (cp && cp->name) + strncpy(buf, cp->name, sizeof(buf) - 1); else - snprintf(buf, sizeof(buf), "pci@%x,%d", - PCI_SLOT(devfn), function); + snprintf(buf, sizeof(buf), "pci%x,%x", + vendor_id, device_id); + buf[sizeof(buf) - 1] = '\0'; + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "@%x", PCI_SLOT(devfn)); + buf[sizeof(buf) - 1] = '\0'; + if (function != 0) + snprintf(buf + strlen(buf), + sizeof(buf) - strlen(buf), + ",%x", function); dt_start_node(dt, buf); reg[0] = (bus << 16) | (devfn << 8); reg[1] = 0; @@ -1083,6 +1116,9 @@ static void scan_bridge_slot(struct iseries_flat_dt *dt, HvBusNumber bus, reg[3] = 0; reg[4] = 0; dt_prop_u32_list(dt, "reg", reg, 5); + if (cp && (cp->type || cp->name)) + dt_prop_str(dt, "device_type", + cp->type ? cp->type : cp->name); dt_prop_u32(dt, "vendor-id", vendor_id); dt_prop_u32(dt, "device-id", device_id); dt_prop_u32(dt, "class-code", class_id >> 8); @@ -1097,7 +1133,7 @@ static void scan_bridge_slot(struct iseries_flat_dt *dt, HvBusNumber bus, } } -static void scan_bridge(struct iseries_flat_dt *dt, HvBusNumber bus, +static void __init scan_bridge(struct iseries_flat_dt *dt, HvBusNumber bus, HvSubBusNumber sub_bus, int id_sel) { struct HvCallPci_BridgeInfo bridge_info; @@ -1139,7 +1175,7 @@ static void scan_bridge(struct iseries_flat_dt *dt, HvBusNumber bus, } } -static void scan_phb(struct iseries_flat_dt *dt, HvBusNumber bus) +static void __init scan_phb(struct iseries_flat_dt *dt, HvBusNumber bus) { struct HvCallPci_DeviceInfo dev_info; const HvSubBusNumber sub_bus = 0; /* EADs is always 0. */ @@ -1171,7 +1207,7 @@ static void scan_phb(struct iseries_flat_dt *dt, HvBusNumber bus) } } -static void dt_pci_devices(struct iseries_flat_dt *dt) +static void __init dt_pci_devices(struct iseries_flat_dt *dt) { HvBusNumber bus; char buf[32]; @@ -1207,7 +1243,8 @@ static void dt_pci_devices(struct iseries_flat_dt *dt) } } -static void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size) +static void __init build_flat_dt(struct iseries_flat_dt *dt, + unsigned long phys_mem_size) { u64 tmp[2]; -- cgit v1.2.1 From c81014f603db26e1ed818decebd3b594606e20a6 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 19 May 2006 17:00:04 +1000 Subject: [PATCH] powerpc: split device tree stuff out of iseries/setup.c Signed-off-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- arch/powerpc/platforms/iseries/setup.c | 578 +-------------------------------- 1 file changed, 1 insertion(+), 577 deletions(-) (limited to 'arch/powerpc/platforms/iseries/setup.c') diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c index 5661bd0d4279..617c724c4590 100644 --- a/arch/powerpc/platforms/iseries/setup.c +++ b/arch/powerpc/platforms/iseries/setup.c @@ -28,7 +28,6 @@ #include #include #include -#include /* ETH_ALEN */ #include #include @@ -46,13 +45,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -66,8 +63,6 @@ #include "main_store.h" #include "call_sm.h" #include "call_hpt.h" -#include "call_pci.h" -#include "pci.h" #ifdef DEBUG #define DBG(fmt...) udbg_printf(fmt) @@ -711,575 +706,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; -}; - -static struct iseries_flat_dt iseries_dt; - -static void __init 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; -} - -static void __init 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(); - } -} - -static void __init 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); -} - -#ifdef notyet -static void __init 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); -} -#endif - -static unsigned long __init 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; -} - -static void __init 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) - -static void __init 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); -} - -static void __init dt_prop_str(struct iseries_flat_dt *dt, char *name, - char *data) -{ - dt_prop(dt, name, data, strlen(data) + 1); /* + 1 for NULL */ -} - -static void __init dt_prop_u32(struct iseries_flat_dt *dt, char *name, u32 data) -{ - dt_prop(dt, name, (char *)&data, sizeof(u32)); -} - -static void __init dt_prop_u64(struct iseries_flat_dt *dt, char *name, u64 data) -{ - dt_prop(dt, name, (char *)&data, sizeof(u64)); -} - -static void __init dt_prop_u64_list(struct iseries_flat_dt *dt, char *name, - u64 *data, int n) -{ - dt_prop(dt, name, (char *)data, sizeof(u64) * n); -} - -static void __init dt_prop_u32_list(struct iseries_flat_dt *dt, char *name, - u32 *data, int n) -{ - dt_prop(dt, name, (char *)data, sizeof(u32) * n); -} - -#ifdef notyet -static void __init dt_prop_empty(struct iseries_flat_dt *dt, char *name) -{ - dt_prop(dt, name, NULL, 0); -} -#endif - -static void __init 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); -} - -static void __init 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"); -} - -static void __init 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_str(dt, "device_type", "vdevice"); - dt_prop_str(dt, "compatible", "IBM,iSeries-vdevice"); - dt_prop_u32(dt, "#address-cells", 1); - dt_prop_u32(dt, "#size-cells", 0); - - snprintf(buf, sizeof(buf), "vty@%08x", reg); - dt_start_node(dt, buf); - dt_prop_str(dt, "device_type", "serial"); - 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, "l-lan@%08x", reg + i); - dt_start_node(dt, buf); - dt_prop_str(dt, "device_type", "network"); - dt_prop_str(dt, "compatible", "IBM,iSeries-l-lan"); - 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_prop_u32(dt, "max-frame-size", 9000); - dt_prop_u32(dt, "address-bits", 48); - - 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", "block"); - dt_prop_str(dt, "compatible", "IBM,iSeries-viodasd"); - 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", "block"); - dt_prop_str(dt, "compatible", "IBM,iSeries-viocd"); - 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", "byte"); - dt_prop_str(dt, "compatible", "IBM,iSeries-viotape"); - dt_prop_u32(dt, "reg", reg + i); - dt_prop_u32(dt, "linux,unit_address", i); - dt_end_node(dt); - } - - dt_end_node(dt); -} - -struct pci_class_name { - u16 code; - char *name; - char *type; -}; - -static struct pci_class_name __initdata pci_class_name[] = { - { PCI_CLASS_NETWORK_ETHERNET, "ethernet", "network" }, -}; - -static struct pci_class_name * __init dt_find_pci_class_name(u16 class_code) -{ - struct pci_class_name *cp; - - for (cp = pci_class_name; - cp < &pci_class_name[ARRAY_SIZE(pci_class_name)]; cp++) - if (cp->code == class_code) - return cp; - return NULL; -} - -/* - * This assumes that the node slot is always on the primary bus! - */ -static void __init scan_bridge_slot(struct iseries_flat_dt *dt, - HvBusNumber bus, struct HvCallPci_BridgeInfo *bridge_info) -{ - HvSubBusNumber sub_bus = bridge_info->subBusNumber; - u16 vendor_id; - u16 device_id; - u32 class_id; - int err; - char buf[32]; - u32 reg[5]; - int id_sel = ISERIES_GET_DEVICE_FROM_SUBBUS(sub_bus); - int function = ISERIES_GET_FUNCTION_FROM_SUBBUS(sub_bus); - HvAgentId eads_id_sel = ISERIES_PCI_AGENTID(id_sel, function); - u8 devfn; - struct pci_class_name *cp; - - /* - * Connect all functions of any device found. - */ - for (id_sel = 1; id_sel <= bridge_info->maxAgents; id_sel++) { - for (function = 0; function < 8; function++) { - HvAgentId agent_id = ISERIES_PCI_AGENTID(id_sel, - function); - err = HvCallXm_connectBusUnit(bus, sub_bus, - agent_id, 0); - if (err) { - if (err != 0x302) - printk(KERN_DEBUG - "connectBusUnit(%x, %x, %x) " - "== %x\n", - bus, sub_bus, agent_id, err); - continue; - } - - err = HvCallPci_configLoad16(bus, sub_bus, agent_id, - PCI_VENDOR_ID, &vendor_id); - if (err) { - printk(KERN_DEBUG - "ReadVendor(%x, %x, %x) == %x\n", - bus, sub_bus, agent_id, err); - continue; - } - err = HvCallPci_configLoad16(bus, sub_bus, agent_id, - PCI_DEVICE_ID, &device_id); - if (err) { - printk(KERN_DEBUG - "ReadDevice(%x, %x, %x) == %x\n", - bus, sub_bus, agent_id, err); - continue; - } - err = HvCallPci_configLoad32(bus, sub_bus, agent_id, - PCI_CLASS_REVISION , &class_id); - if (err) { - printk(KERN_DEBUG - "ReadClass(%x, %x, %x) == %x\n", - bus, sub_bus, agent_id, err); - continue; - } - - devfn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(eads_id_sel), - function); - cp = dt_find_pci_class_name(class_id >> 16); - if (cp && cp->name) - strncpy(buf, cp->name, sizeof(buf) - 1); - else - snprintf(buf, sizeof(buf), "pci%x,%x", - vendor_id, device_id); - buf[sizeof(buf) - 1] = '\0'; - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - "@%x", PCI_SLOT(devfn)); - buf[sizeof(buf) - 1] = '\0'; - if (function != 0) - snprintf(buf + strlen(buf), - sizeof(buf) - strlen(buf), - ",%x", function); - dt_start_node(dt, buf); - reg[0] = (bus << 16) | (devfn << 8); - reg[1] = 0; - reg[2] = 0; - reg[3] = 0; - reg[4] = 0; - dt_prop_u32_list(dt, "reg", reg, 5); - if (cp && (cp->type || cp->name)) - dt_prop_str(dt, "device_type", - cp->type ? cp->type : cp->name); - dt_prop_u32(dt, "vendor-id", vendor_id); - dt_prop_u32(dt, "device-id", device_id); - dt_prop_u32(dt, "class-code", class_id >> 8); - dt_prop_u32(dt, "revision-id", class_id & 0xff); - dt_prop_u32(dt, "linux,subbus", sub_bus); - dt_prop_u32(dt, "linux,agent-id", agent_id); - dt_prop_u32(dt, "linux,logical-slot-number", - bridge_info->logicalSlotNumber); - dt_end_node(dt); - - } - } -} - -static void __init scan_bridge(struct iseries_flat_dt *dt, HvBusNumber bus, - HvSubBusNumber sub_bus, int id_sel) -{ - struct HvCallPci_BridgeInfo bridge_info; - HvAgentId agent_id; - int function; - int ret; - - /* Note: hvSubBus and irq is always be 0 at this level! */ - for (function = 0; function < 8; ++function) { - agent_id = ISERIES_PCI_AGENTID(id_sel, function); - ret = HvCallXm_connectBusUnit(bus, sub_bus, agent_id, 0); - if (ret != 0) { - if (ret != 0xb) - printk(KERN_DEBUG "connectBusUnit(%x, %x, %x) " - "== %x\n", - bus, sub_bus, agent_id, ret); - continue; - } - printk("found device at bus %d idsel %d func %d (AgentId %x)\n", - bus, id_sel, function, agent_id); - ret = HvCallPci_getBusUnitInfo(bus, sub_bus, agent_id, - iseries_hv_addr(&bridge_info), - sizeof(struct HvCallPci_BridgeInfo)); - if (ret != 0) - continue; - printk("bridge info: type %x subbus %x " - "maxAgents %x maxsubbus %x logslot %x\n", - bridge_info.busUnitInfo.deviceType, - bridge_info.subBusNumber, - bridge_info.maxAgents, - bridge_info.maxSubBusNumber, - bridge_info.logicalSlotNumber); - if (bridge_info.busUnitInfo.deviceType == - HvCallPci_BridgeDevice) - scan_bridge_slot(dt, bus, &bridge_info); - else - printk("PCI: Invalid Bridge Configuration(0x%02X)", - bridge_info.busUnitInfo.deviceType); - } -} - -static void __init scan_phb(struct iseries_flat_dt *dt, HvBusNumber bus) -{ - struct HvCallPci_DeviceInfo dev_info; - const HvSubBusNumber sub_bus = 0; /* EADs is always 0. */ - int err; - int id_sel; - const int max_agents = 8; - - /* - * Probe for EADs Bridges - */ - for (id_sel = 1; id_sel < max_agents; ++id_sel) { - err = HvCallPci_getDeviceInfo(bus, sub_bus, id_sel, - iseries_hv_addr(&dev_info), - sizeof(struct HvCallPci_DeviceInfo)); - if (err) { - if (err != 0x302) - printk(KERN_DEBUG "getDeviceInfo(%x, %x, %x) " - "== %x\n", - bus, sub_bus, id_sel, err); - continue; - } - if (dev_info.deviceType != HvCallPci_NodeDevice) { - printk(KERN_DEBUG "PCI: Invalid System Configuration" - "(0x%02X) for bus 0x%02x id 0x%02x.\n", - dev_info.deviceType, bus, id_sel); - continue; - } - scan_bridge(dt, bus, sub_bus, id_sel); - } -} - -static void __init dt_pci_devices(struct iseries_flat_dt *dt) -{ - HvBusNumber bus; - char buf[32]; - u32 buses[2]; - int phb_num = 0; - - /* Check all possible buses. */ - for (bus = 0; bus < 256; bus++) { - int err = HvCallXm_testBus(bus); - - if (err) { - /* - * Check for Unexpected Return code, a clue that - * something has gone wrong. - */ - if (err != 0x0301) - printk(KERN_ERR "Unexpected Return on Probe" - "(0x%02X): 0x%04X", bus, err); - continue; - } - printk("bus %d appears to exist\n", bus); - snprintf(buf, 32, "pci@%d", phb_num); - dt_start_node(dt, buf); - dt_prop_str(dt, "device_type", "pci"); - dt_prop_str(dt, "compatible", "IBM,iSeries-Logical-PHB"); - dt_prop_u32(dt, "#address-cells", 3); - dt_prop_u32(dt, "#size-cells", 2); - buses[0] = buses[1] = bus; - dt_prop_u32_list(dt, "bus-range", buses, 2); - scan_phb(dt, bus); - dt_end_node(dt); - phb_num++; - } -} - -static void __init 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); - dt_end_node(dt); - - dt_cpus(dt); - - dt_vdevices(dt); - dt_pci_devices(dt); - - dt_end_node(dt); - - dt_push_u32(dt, OF_DT_END); -} - void * __init iSeries_early_setup(void) { unsigned long phys_mem_size; @@ -1294,9 +720,7 @@ void * __init iSeries_early_setup(void) iSeries_get_cmdline(); - build_flat_dt(&iseries_dt, phys_mem_size); - - return (void *) __pa(&iseries_dt); + return (void *) __pa(build_flat_dt(phys_mem_size)); } static void hvputc(char c) -- cgit v1.2.1