aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-09-22 20:10:23 -0400
committerJeff Garzik <jeff@garzik.org>2006-09-22 20:10:23 -0400
commit28eb177dfa5982d132edceed891cb3885df258bb (patch)
tree5f8fdc37ad1d8d0793e9c47da7d908b97c814ffb /arch/powerpc/platforms
parentfd8ae94eea9bb4269d6dff1b47b9dc741bd70d0b (diff)
parentdb392219c5f572610645696e3672f6ea38783a65 (diff)
Merge branch 'master' into upstream
Conflicts: net/ieee80211/ieee80211_crypt_tkip.c net/ieee80211/ieee80211_crypt_wep.c
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_itx.c4
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_sys.c4
-rw-r--r--arch/powerpc/platforms/83xx/pci.c4
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ads.c4
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_cds.c4
-rw-r--r--arch/powerpc/platforms/85xx/pci.c4
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_hpcn.c4
-rw-r--r--arch/powerpc/platforms/86xx/pci.c4
-rw-r--r--arch/powerpc/platforms/Makefile1
-rw-r--r--arch/powerpc/platforms/cell/cbe_regs.c8
-rw-r--r--arch/powerpc/platforms/cell/interrupt.c25
-rw-r--r--arch/powerpc/platforms/cell/iommu.c22
-rw-r--r--arch/powerpc/platforms/cell/setup.c4
-rw-r--r--arch/powerpc/platforms/cell/smp.c4
-rw-r--r--arch/powerpc/platforms/cell/spider-pic.c10
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c18
-rw-r--r--arch/powerpc/platforms/chrp/nvram.c5
-rw-r--r--arch/powerpc/platforms/chrp/pci.c53
-rw-r--r--arch/powerpc/platforms/chrp/setup.c48
-rw-r--r--arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c8
-rw-r--r--arch/powerpc/platforms/iseries/Kconfig8
-rw-r--r--arch/powerpc/platforms/iseries/dt.c45
-rw-r--r--arch/powerpc/platforms/iseries/hvlpconfig.c13
-rw-r--r--arch/powerpc/platforms/iseries/iommu.c19
-rw-r--r--arch/powerpc/platforms/iseries/it_exp_vpd_panel.h51
-rw-r--r--arch/powerpc/platforms/iseries/it_lp_naca.h80
-rw-r--r--arch/powerpc/platforms/iseries/lpardata.c6
-rw-r--r--arch/powerpc/platforms/iseries/lpevents.c2
-rw-r--r--arch/powerpc/platforms/iseries/main_store.h126
-rw-r--r--arch/powerpc/platforms/iseries/pci.c289
-rw-r--r--arch/powerpc/platforms/iseries/setup.c1
-rw-r--r--arch/powerpc/platforms/iseries/viopath.c28
-rw-r--r--arch/powerpc/platforms/iseries/vpdinfo.c22
-rw-r--r--arch/powerpc/platforms/maple/pci.c70
-rw-r--r--arch/powerpc/platforms/maple/setup.c27
-rw-r--r--arch/powerpc/platforms/pasemi/Makefile1
-rw-r--r--arch/powerpc/platforms/pasemi/pasemi.h8
-rw-r--r--arch/powerpc/platforms/pasemi/pci.c198
-rw-r--r--arch/powerpc/platforms/pasemi/setup.c188
-rw-r--r--arch/powerpc/platforms/pasemi/time.c29
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c3
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_32.c23
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_64.c27
-rw-r--r--arch/powerpc/platforms/powermac/feature.c30
-rw-r--r--arch/powerpc/platforms/powermac/low_i2c.c24
-rw-r--r--arch/powerpc/platforms/powermac/pci.c37
-rw-r--r--arch/powerpc/platforms/powermac/pfunc_base.c2
-rw-r--r--arch/powerpc/platforms/powermac/pfunc_core.c5
-rw-r--r--arch/powerpc/platforms/powermac/setup.c18
-rw-r--r--arch/powerpc/platforms/powermac/smp.c7
-rw-r--r--arch/powerpc/platforms/powermac/udbg_scc.c10
-rw-r--r--arch/powerpc/platforms/pseries/Makefile1
-rw-r--r--arch/powerpc/platforms/pseries/eeh.c96
-rw-r--r--arch/powerpc/platforms/pseries/eeh_cache.c17
-rw-r--r--arch/powerpc/platforms/pseries/eeh_driver.c112
-rw-r--r--arch/powerpc/platforms/pseries/eeh_event.c4
-rw-r--r--arch/powerpc/platforms/pseries/firmware.c2
-rw-r--r--arch/powerpc/platforms/pseries/hvCall.S273
-rw-r--r--arch/powerpc/platforms/pseries/hvCall_inst.c129
-rw-r--r--arch/powerpc/platforms/pseries/hvconsole.c5
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c13
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c46
-rw-r--r--arch/powerpc/platforms/pseries/nvram.c5
-rw-r--r--arch/powerpc/platforms/pseries/pci.c2
-rw-r--r--arch/powerpc/platforms/pseries/plpar_wrappers.h107
-rw-r--r--arch/powerpc/platforms/pseries/ras.c4
-rw-r--r--arch/powerpc/platforms/pseries/rtasd.c4
-rw-r--r--arch/powerpc/platforms/pseries/setup.c42
-rw-r--r--arch/powerpc/platforms/pseries/smp.c12
-rw-r--r--arch/powerpc/platforms/pseries/xics.c44
70 files changed, 1837 insertions, 716 deletions
diff --git a/arch/powerpc/platforms/83xx/mpc834x_itx.c b/arch/powerpc/platforms/83xx/mpc834x_itx.c
index cf3967a66fb5..969fbb6d8c46 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_itx.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_itx.c
@@ -60,8 +60,8 @@ static void __init mpc834x_itx_setup_arch(void)
60 60
61 np = of_find_node_by_type(NULL, "cpu"); 61 np = of_find_node_by_type(NULL, "cpu");
62 if (np != 0) { 62 if (np != 0) {
63 unsigned int *fp = 63 const unsigned int *fp =
64 (int *)get_property(np, "clock-frequency", NULL); 64 get_property(np, "clock-frequency", NULL);
65 if (fp != 0) 65 if (fp != 0)
66 loops_per_jiffy = *fp / HZ; 66 loops_per_jiffy = *fp / HZ;
67 else 67 else
diff --git a/arch/powerpc/platforms/83xx/mpc834x_sys.c b/arch/powerpc/platforms/83xx/mpc834x_sys.c
index 32df239d1c48..677196187a4e 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_sys.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_sys.c
@@ -57,8 +57,8 @@ static void __init mpc834x_sys_setup_arch(void)
57 57
58 np = of_find_node_by_type(NULL, "cpu"); 58 np = of_find_node_by_type(NULL, "cpu");
59 if (np != 0) { 59 if (np != 0) {
60 unsigned int *fp = 60 const unsigned int *fp =
61 (int *)get_property(np, "clock-frequency", NULL); 61 get_property(np, "clock-frequency", NULL);
62 if (fp != 0) 62 if (fp != 0)
63 loops_per_jiffy = *fp / HZ; 63 loops_per_jiffy = *fp / HZ;
64 else 64 else
diff --git a/arch/powerpc/platforms/83xx/pci.c b/arch/powerpc/platforms/83xx/pci.c
index 5d84a9ccd103..4557ac5255c1 100644
--- a/arch/powerpc/platforms/83xx/pci.c
+++ b/arch/powerpc/platforms/83xx/pci.c
@@ -59,7 +59,7 @@ int __init add_bridge(struct device_node *dev)
59 int len; 59 int len;
60 struct pci_controller *hose; 60 struct pci_controller *hose;
61 struct resource rsrc; 61 struct resource rsrc;
62 int *bus_range; 62 const int *bus_range;
63 int primary = 1, has_address = 0; 63 int primary = 1, has_address = 0;
64 phys_addr_t immr = get_immrbase(); 64 phys_addr_t immr = get_immrbase();
65 65
@@ -69,7 +69,7 @@ int __init add_bridge(struct device_node *dev)
69 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 69 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
70 70
71 /* Get bus range if any */ 71 /* Get bus range if any */
72 bus_range = (int *)get_property(dev, "bus-range", &len); 72 bus_range = get_property(dev, "bus-range", &len);
73 if (bus_range == NULL || len < 2 * sizeof(int)) { 73 if (bus_range == NULL || len < 2 * sizeof(int)) {
74 printk(KERN_WARNING "Can't get bus-range for %s, assume" 74 printk(KERN_WARNING "Can't get bus-range for %s, assume"
75 " bus 0\n", dev->full_name); 75 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 9d2acfbbeccd..cae6b73357d5 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -121,9 +121,9 @@ static void __init mpc85xx_ads_setup_arch(void)
121 121
122 cpu = of_find_node_by_type(NULL, "cpu"); 122 cpu = of_find_node_by_type(NULL, "cpu");
123 if (cpu != 0) { 123 if (cpu != 0) {
124 unsigned int *fp; 124 const unsigned int *fp;
125 125
126 fp = (int *)get_property(cpu, "clock-frequency", NULL); 126 fp = get_property(cpu, "clock-frequency", NULL);
127 if (fp != 0) 127 if (fp != 0)
128 loops_per_jiffy = *fp / HZ; 128 loops_per_jiffy = *fp / HZ;
129 else 129 else
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 1d357d32a29f..4c1fede6470e 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -241,9 +241,9 @@ mpc85xx_cds_setup_arch(void)
241 241
242 cpu = of_find_node_by_type(NULL, "cpu"); 242 cpu = of_find_node_by_type(NULL, "cpu");
243 if (cpu != 0) { 243 if (cpu != 0) {
244 unsigned int *fp; 244 const unsigned int *fp;
245 245
246 fp = (int *)get_property(cpu, "clock-frequency", NULL); 246 fp = get_property(cpu, "clock-frequency", NULL);
247 if (fp != 0) 247 if (fp != 0)
248 loops_per_jiffy = *fp / HZ; 248 loops_per_jiffy = *fp / HZ;
249 else 249 else
diff --git a/arch/powerpc/platforms/85xx/pci.c b/arch/powerpc/platforms/85xx/pci.c
index 1d51f3242ab1..05930eeb6e7f 100644
--- a/arch/powerpc/platforms/85xx/pci.c
+++ b/arch/powerpc/platforms/85xx/pci.c
@@ -41,7 +41,7 @@ int __init add_bridge(struct device_node *dev)
41 int len; 41 int len;
42 struct pci_controller *hose; 42 struct pci_controller *hose;
43 struct resource rsrc; 43 struct resource rsrc;
44 int *bus_range; 44 const int *bus_range;
45 int primary = 1, has_address = 0; 45 int primary = 1, has_address = 0;
46 phys_addr_t immr = get_immrbase(); 46 phys_addr_t immr = get_immrbase();
47 47
@@ -51,7 +51,7 @@ int __init add_bridge(struct device_node *dev)
51 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 51 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
52 52
53 /* Get bus range if any */ 53 /* Get bus range if any */
54 bus_range = (int *) get_property(dev, "bus-range", &len); 54 bus_range = get_property(dev, "bus-range", &len);
55 if (bus_range == NULL || len < 2 * sizeof(int)) { 55 if (bus_range == NULL || len < 2 * sizeof(int)) {
56 printk(KERN_WARNING "Can't get bus-range for %s, assume" 56 printk(KERN_WARNING "Can't get bus-range for %s, assume"
57 " bus 0\n", dev->full_name); 57 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 5e583cf38786..b637e8157f7b 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -347,9 +347,9 @@ mpc86xx_hpcn_setup_arch(void)
347 347
348 np = of_find_node_by_type(NULL, "cpu"); 348 np = of_find_node_by_type(NULL, "cpu");
349 if (np != 0) { 349 if (np != 0) {
350 unsigned int *fp; 350 const unsigned int *fp;
351 351
352 fp = (int *)get_property(np, "clock-frequency", NULL); 352 fp = get_property(np, "clock-frequency", NULL);
353 if (fp != 0) 353 if (fp != 0)
354 loops_per_jiffy = *fp / HZ; 354 loops_per_jiffy = *fp / HZ;
355 else 355 else
diff --git a/arch/powerpc/platforms/86xx/pci.c b/arch/powerpc/platforms/86xx/pci.c
index a8c8f0a44055..481e18ed5be9 100644
--- a/arch/powerpc/platforms/86xx/pci.c
+++ b/arch/powerpc/platforms/86xx/pci.c
@@ -153,7 +153,7 @@ int __init add_bridge(struct device_node *dev)
153 int len; 153 int len;
154 struct pci_controller *hose; 154 struct pci_controller *hose;
155 struct resource rsrc; 155 struct resource rsrc;
156 int *bus_range; 156 const int *bus_range;
157 int has_address = 0; 157 int has_address = 0;
158 int primary = 0; 158 int primary = 0;
159 159
@@ -163,7 +163,7 @@ int __init add_bridge(struct device_node *dev)
163 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 163 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
164 164
165 /* Get bus range if any */ 165 /* Get bus range if any */
166 bus_range = (int *) get_property(dev, "bus-range", &len); 166 bus_range = get_property(dev, "bus-range", &len);
167 if (bus_range == NULL || len < 2 * sizeof(int)) 167 if (bus_range == NULL || len < 2 * sizeof(int))
168 printk(KERN_WARNING "Can't get bus-range for %s, assume" 168 printk(KERN_WARNING "Can't get bus-range for %s, assume"
169 " bus 0\n", dev->full_name); 169 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 5cf46dc57895..e58fa953a50b 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -13,5 +13,6 @@ obj-$(CONFIG_PPC_86xx) += 86xx/
13obj-$(CONFIG_PPC_PSERIES) += pseries/ 13obj-$(CONFIG_PPC_PSERIES) += pseries/
14obj-$(CONFIG_PPC_ISERIES) += iseries/ 14obj-$(CONFIG_PPC_ISERIES) += iseries/
15obj-$(CONFIG_PPC_MAPLE) += maple/ 15obj-$(CONFIG_PPC_MAPLE) += maple/
16obj-$(CONFIG_PPC_PASEMI) += pasemi/
16obj-$(CONFIG_PPC_CELL) += cell/ 17obj-$(CONFIG_PPC_CELL) += cell/
17obj-$(CONFIG_EMBEDDED6xx) += embedded6xx/ 18obj-$(CONFIG_EMBEDDED6xx) += embedded6xx/
diff --git a/arch/powerpc/platforms/cell/cbe_regs.c b/arch/powerpc/platforms/cell/cbe_regs.c
index ce696c1cca75..3f3859d12e00 100644
--- a/arch/powerpc/platforms/cell/cbe_regs.c
+++ b/arch/powerpc/platforms/cell/cbe_regs.c
@@ -97,7 +97,7 @@ void __init cbe_regs_init(void)
97 struct cbe_regs_map *map = &cbe_regs_maps[cbe_regs_map_count++]; 97 struct cbe_regs_map *map = &cbe_regs_maps[cbe_regs_map_count++];
98 98
99 /* That hack must die die die ! */ 99 /* That hack must die die die ! */
100 struct address_prop { 100 const struct address_prop {
101 unsigned long address; 101 unsigned long address;
102 unsigned int len; 102 unsigned int len;
103 } __attribute__((packed)) *prop; 103 } __attribute__((packed)) *prop;
@@ -114,13 +114,11 @@ void __init cbe_regs_init(void)
114 if (cbe_thread_map[i].cpu_node == cpu) 114 if (cbe_thread_map[i].cpu_node == cpu)
115 cbe_thread_map[i].regs = map; 115 cbe_thread_map[i].regs = map;
116 116
117 prop = (struct address_prop *)get_property(cpu, "pervasive", 117 prop = get_property(cpu, "pervasive", NULL);
118 NULL);
119 if (prop != NULL) 118 if (prop != NULL)
120 map->pmd_regs = ioremap(prop->address, prop->len); 119 map->pmd_regs = ioremap(prop->address, prop->len);
121 120
122 prop = (struct address_prop *)get_property(cpu, "iic", 121 prop = get_property(cpu, "iic", NULL);
123 NULL);
124 if (prop != NULL) 122 if (prop != NULL)
125 map->iic_regs = ioremap(prop->address, prop->len); 123 map->iic_regs = ioremap(prop->address, prop->len);
126 } 124 }
diff --git a/arch/powerpc/platforms/cell/interrupt.c b/arch/powerpc/platforms/cell/interrupt.c
index d7bbb61109f9..6b57a47c5d37 100644
--- a/arch/powerpc/platforms/cell/interrupt.c
+++ b/arch/powerpc/platforms/cell/interrupt.c
@@ -89,17 +89,17 @@ static struct irq_chip iic_chip = {
89/* Get an IRQ number from the pending state register of the IIC */ 89/* Get an IRQ number from the pending state register of the IIC */
90static unsigned int iic_get_irq(struct pt_regs *regs) 90static unsigned int iic_get_irq(struct pt_regs *regs)
91{ 91{
92 struct cbe_iic_pending_bits pending; 92 struct cbe_iic_pending_bits pending;
93 struct iic *iic; 93 struct iic *iic;
94 94
95 iic = &__get_cpu_var(iic); 95 iic = &__get_cpu_var(iic);
96 *(unsigned long *) &pending = 96 *(unsigned long *) &pending =
97 in_be64((unsigned long __iomem *) &iic->regs->pending_destr); 97 in_be64((unsigned long __iomem *) &iic->regs->pending_destr);
98 iic->eoi_stack[++iic->eoi_ptr] = pending.prio; 98 iic->eoi_stack[++iic->eoi_ptr] = pending.prio;
99 BUG_ON(iic->eoi_ptr > 15); 99 BUG_ON(iic->eoi_ptr > 15);
100 if (pending.flags & CBE_IIC_IRQ_VALID) 100 if (pending.flags & CBE_IIC_IRQ_VALID)
101 return irq_linear_revmap(iic->host, 101 return irq_linear_revmap(iic->host,
102 iic_pending_to_hwnum(pending)); 102 iic_pending_to_hwnum(pending));
103 return NO_IRQ; 103 return NO_IRQ;
104} 104}
105 105
@@ -250,16 +250,15 @@ static int __init setup_iic(void)
250 struct resource r0, r1; 250 struct resource r0, r1;
251 struct irq_host *host; 251 struct irq_host *host;
252 int found = 0; 252 int found = 0;
253 u32 *np; 253 const u32 *np;
254 254
255 for (dn = NULL; 255 for (dn = NULL;
256 (dn = of_find_node_by_name(dn,"interrupt-controller")) != NULL;) { 256 (dn = of_find_node_by_name(dn,"interrupt-controller")) != NULL;) {
257 if (!device_is_compatible(dn, 257 if (!device_is_compatible(dn,
258 "IBM,CBEA-Internal-Interrupt-Controller")) 258 "IBM,CBEA-Internal-Interrupt-Controller"))
259 continue; 259 continue;
260 np = (u32 *)get_property(dn, "ibm,interrupt-server-ranges", 260 np = get_property(dn, "ibm,interrupt-server-ranges", NULL);
261 NULL); 261 if (np == NULL) {
262 if (np == NULL) {
263 printk(KERN_WARNING "IIC: CPU association not found\n"); 262 printk(KERN_WARNING "IIC: CPU association not found\n");
264 of_node_put(dn); 263 of_node_put(dn);
265 return -ENODEV; 264 return -ENODEV;
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index a35004e14c69..d2b20eba5b87 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -308,15 +308,16 @@ static void cell_do_map_iommu(struct cell_iommu *iommu,
308 308
309static void iommu_devnode_setup(struct device_node *d) 309static void iommu_devnode_setup(struct device_node *d)
310{ 310{
311 unsigned int *ioid; 311 const unsigned int *ioid;
312 unsigned long *dma_window, map_start, map_size, token; 312 unsigned long map_start, map_size, token;
313 const unsigned long *dma_window;
313 struct cell_iommu *iommu; 314 struct cell_iommu *iommu;
314 315
315 ioid = (unsigned int *)get_property(d, "ioid", NULL); 316 ioid = get_property(d, "ioid", NULL);
316 if (!ioid) 317 if (!ioid)
317 pr_debug("No ioid entry found !\n"); 318 pr_debug("No ioid entry found !\n");
318 319
319 dma_window = (unsigned long *)get_property(d, "ibm,dma-window", NULL); 320 dma_window = get_property(d, "ibm,dma-window", NULL);
320 if (!dma_window) 321 if (!dma_window)
321 pr_debug("No ibm,dma-window entry found !\n"); 322 pr_debug("No ibm,dma-window entry found !\n");
322 323
@@ -371,8 +372,9 @@ static int cell_map_iommu_hardcoded(int num_nodes)
371 372
372static int cell_map_iommu(void) 373static int cell_map_iommu(void)
373{ 374{
374 unsigned int num_nodes = 0, *node_id; 375 unsigned int num_nodes = 0;
375 unsigned long *base, *mmio_base; 376 const unsigned int *node_id;
377 const unsigned long *base, *mmio_base;
376 struct device_node *dn; 378 struct device_node *dn;
377 struct cell_iommu *iommu = NULL; 379 struct cell_iommu *iommu = NULL;
378 380
@@ -381,7 +383,7 @@ static int cell_map_iommu(void)
381 for(dn = of_find_node_by_type(NULL, "cpu"); 383 for(dn = of_find_node_by_type(NULL, "cpu");
382 dn; 384 dn;
383 dn = of_find_node_by_type(dn, "cpu")) { 385 dn = of_find_node_by_type(dn, "cpu")) {
384 node_id = (unsigned int *)get_property(dn, "node-id", NULL); 386 node_id = get_property(dn, "node-id", NULL);
385 387
386 if (num_nodes < *node_id) 388 if (num_nodes < *node_id)
387 num_nodes = *node_id; 389 num_nodes = *node_id;
@@ -396,9 +398,9 @@ static int cell_map_iommu(void)
396 dn; 398 dn;
397 dn = of_find_node_by_type(dn, "cpu")) { 399 dn = of_find_node_by_type(dn, "cpu")) {
398 400
399 node_id = (unsigned int *)get_property(dn, "node-id", NULL); 401 node_id = get_property(dn, "node-id", NULL);
400 base = (unsigned long *)get_property(dn, "ioc-cache", NULL); 402 base = get_property(dn, "ioc-cache", NULL);
401 mmio_base = (unsigned long *)get_property(dn, "ioc-translation", NULL); 403 mmio_base = get_property(dn, "ioc-translation", NULL);
402 404
403 if (!base || !mmio_base || !node_id) 405 if (!base || !mmio_base || !node_id)
404 return cell_map_iommu_hardcoded(num_nodes); 406 return cell_map_iommu_hardcoded(num_nodes);
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 282987d6d4a2..22c228a49c33 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -150,10 +150,6 @@ static int __init cell_probe(void)
150 !of_flat_dt_is_compatible(root, "IBM,CPBW-1.0")) 150 !of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
151 return 0; 151 return 0;
152 152
153#ifdef CONFIG_UDBG_RTAS_CONSOLE
154 udbg_init_rtas_console();
155#endif
156
157 hpte_init_native(); 153 hpte_init_native();
158 154
159 return 1; 155 return 1;
diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
index 46aef0640742..1c0acbad7425 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -57,7 +57,7 @@
57 */ 57 */
58static cpumask_t of_spin_map; 58static cpumask_t of_spin_map;
59 59
60extern void pSeries_secondary_smp_init(unsigned long); 60extern void generic_secondary_smp_init(unsigned long);
61 61
62/** 62/**
63 * smp_startup_cpu() - start the given cpu 63 * smp_startup_cpu() - start the given cpu
@@ -74,7 +74,7 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
74{ 74{
75 int status; 75 int status;
76 unsigned long start_here = __pa((u32)*((unsigned long *) 76 unsigned long start_here = __pa((u32)*((unsigned long *)
77 pSeries_secondary_smp_init)); 77 generic_secondary_smp_init));
78 unsigned int pcpu; 78 unsigned int pcpu;
79 int start_cpu; 79 int start_cpu;
80 80
diff --git a/arch/powerpc/platforms/cell/spider-pic.c b/arch/powerpc/platforms/cell/spider-pic.c
index 15217bb0402f..742a03282b44 100644
--- a/arch/powerpc/platforms/cell/spider-pic.c
+++ b/arch/powerpc/platforms/cell/spider-pic.c
@@ -240,7 +240,7 @@ static void spider_irq_cascade(unsigned int irq, struct irq_desc *desc,
240static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic) 240static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic)
241{ 241{
242 unsigned int virq; 242 unsigned int virq;
243 u32 *imap, *tmp; 243 const u32 *imap, *tmp;
244 int imaplen, intsize, unit; 244 int imaplen, intsize, unit;
245 struct device_node *iic; 245 struct device_node *iic;
246 struct irq_host *iic_host; 246 struct irq_host *iic_host;
@@ -258,25 +258,25 @@ static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic)
258#endif 258#endif
259 259
260 /* Now do the horrible hacks */ 260 /* Now do the horrible hacks */
261 tmp = (u32 *)get_property(pic->of_node, "#interrupt-cells", NULL); 261 tmp = get_property(pic->of_node, "#interrupt-cells", NULL);
262 if (tmp == NULL) 262 if (tmp == NULL)
263 return NO_IRQ; 263 return NO_IRQ;
264 intsize = *tmp; 264 intsize = *tmp;
265 imap = (u32 *)get_property(pic->of_node, "interrupt-map", &imaplen); 265 imap = get_property(pic->of_node, "interrupt-map", &imaplen);
266 if (imap == NULL || imaplen < (intsize + 1)) 266 if (imap == NULL || imaplen < (intsize + 1))
267 return NO_IRQ; 267 return NO_IRQ;
268 iic = of_find_node_by_phandle(imap[intsize]); 268 iic = of_find_node_by_phandle(imap[intsize]);
269 if (iic == NULL) 269 if (iic == NULL)
270 return NO_IRQ; 270 return NO_IRQ;
271 imap += intsize + 1; 271 imap += intsize + 1;
272 tmp = (u32 *)get_property(iic, "#interrupt-cells", NULL); 272 tmp = get_property(iic, "#interrupt-cells", NULL);
273 if (tmp == NULL) 273 if (tmp == NULL)
274 return NO_IRQ; 274 return NO_IRQ;
275 intsize = *tmp; 275 intsize = *tmp;
276 /* Assume unit is last entry of interrupt specifier */ 276 /* Assume unit is last entry of interrupt specifier */
277 unit = imap[intsize - 1]; 277 unit = imap[intsize - 1];
278 /* Ok, we have a unit, now let's try to get the node */ 278 /* Ok, we have a unit, now let's try to get the node */
279 tmp = (u32 *)get_property(iic, "ibm,interrupt-server-ranges", NULL); 279 tmp = get_property(iic, "ibm,interrupt-server-ranges", NULL);
280 if (tmp == NULL) { 280 if (tmp == NULL) {
281 of_node_put(iic); 281 of_node_put(iic);
282 return NO_IRQ; 282 return NO_IRQ;
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index d06042deb021..3bd36d46ab4a 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -488,10 +488,10 @@ int spu_irq_class_1_bottom(struct spu *spu)
488 488
489static int __init find_spu_node_id(struct device_node *spe) 489static int __init find_spu_node_id(struct device_node *spe)
490{ 490{
491 unsigned int *id; 491 const unsigned int *id;
492 struct device_node *cpu; 492 struct device_node *cpu;
493 cpu = spe->parent->parent; 493 cpu = spe->parent->parent;
494 id = (unsigned int *)get_property(cpu, "node-id", NULL); 494 id = get_property(cpu, "node-id", NULL);
495 return id ? *id : 0; 495 return id ? *id : 0;
496} 496}
497 497
@@ -500,7 +500,7 @@ static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
500{ 500{
501 static DEFINE_MUTEX(add_spumem_mutex); 501 static DEFINE_MUTEX(add_spumem_mutex);
502 502
503 struct address_prop { 503 const struct address_prop {
504 unsigned long address; 504 unsigned long address;
505 unsigned int len; 505 unsigned int len;
506 } __attribute__((packed)) *p; 506 } __attribute__((packed)) *p;
@@ -511,7 +511,7 @@ static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
511 struct zone *zone; 511 struct zone *zone;
512 int ret; 512 int ret;
513 513
514 p = (void*)get_property(spe, prop, &proplen); 514 p = get_property(spe, prop, &proplen);
515 WARN_ON(proplen != sizeof (*p)); 515 WARN_ON(proplen != sizeof (*p));
516 516
517 start_pfn = p->address >> PAGE_SHIFT; 517 start_pfn = p->address >> PAGE_SHIFT;
@@ -531,12 +531,12 @@ static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
531static void __iomem * __init map_spe_prop(struct spu *spu, 531static void __iomem * __init map_spe_prop(struct spu *spu,
532 struct device_node *n, const char *name) 532 struct device_node *n, const char *name)
533{ 533{
534 struct address_prop { 534 const struct address_prop {
535 unsigned long address; 535 unsigned long address;
536 unsigned int len; 536 unsigned int len;
537 } __attribute__((packed)) *prop; 537 } __attribute__((packed)) *prop;
538 538
539 void *p; 539 const void *p;
540 int proplen; 540 int proplen;
541 void* ret = NULL; 541 void* ret = NULL;
542 int err = 0; 542 int err = 0;
@@ -570,14 +570,14 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np)
570{ 570{
571 struct irq_host *host; 571 struct irq_host *host;
572 unsigned int isrc; 572 unsigned int isrc;
573 u32 *tmp; 573 const u32 *tmp;
574 574
575 host = iic_get_irq_host(spu->node); 575 host = iic_get_irq_host(spu->node);
576 if (host == NULL) 576 if (host == NULL)
577 return -ENODEV; 577 return -ENODEV;
578 578
579 /* Get the interrupt source from the device-tree */ 579 /* Get the interrupt source from the device-tree */
580 tmp = (u32 *)get_property(np, "isrc", NULL); 580 tmp = get_property(np, "isrc", NULL);
581 if (!tmp) 581 if (!tmp)
582 return -ENODEV; 582 return -ENODEV;
583 spu->isrc = isrc = tmp[0]; 583 spu->isrc = isrc = tmp[0];
@@ -593,7 +593,7 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np)
593 593
594static int __init spu_map_device(struct spu *spu, struct device_node *node) 594static int __init spu_map_device(struct spu *spu, struct device_node *node)
595{ 595{
596 char *prop; 596 const char *prop;
597 int ret; 597 int ret;
598 598
599 ret = -ENODEV; 599 ret = -ENODEV;
diff --git a/arch/powerpc/platforms/chrp/nvram.c b/arch/powerpc/platforms/chrp/nvram.c
index 150f67d6f90c..0dd4a64757d9 100644
--- a/arch/powerpc/platforms/chrp/nvram.c
+++ b/arch/powerpc/platforms/chrp/nvram.c
@@ -67,13 +67,14 @@ static void chrp_nvram_write(int addr, unsigned char val)
67void __init chrp_nvram_init(void) 67void __init chrp_nvram_init(void)
68{ 68{
69 struct device_node *nvram; 69 struct device_node *nvram;
70 unsigned int *nbytes_p, proplen; 70 const unsigned int *nbytes_p;
71 unsigned int proplen;
71 72
72 nvram = of_find_node_by_type(NULL, "nvram"); 73 nvram = of_find_node_by_type(NULL, "nvram");
73 if (nvram == NULL) 74 if (nvram == NULL)
74 return; 75 return;
75 76
76 nbytes_p = (unsigned int *)get_property(nvram, "#bytes", &proplen); 77 nbytes_p = get_property(nvram, "#bytes", &proplen);
77 if (nbytes_p == NULL || proplen != sizeof(unsigned int)) 78 if (nbytes_p == NULL || proplen != sizeof(unsigned int))
78 return; 79 return;
79 80
diff --git a/arch/powerpc/platforms/chrp/pci.c b/arch/powerpc/platforms/chrp/pci.c
index 6802cdc3168a..0f4340506c75 100644
--- a/arch/powerpc/platforms/chrp/pci.c
+++ b/arch/powerpc/platforms/chrp/pci.c
@@ -214,11 +214,11 @@ void __init
214chrp_find_bridges(void) 214chrp_find_bridges(void)
215{ 215{
216 struct device_node *dev; 216 struct device_node *dev;
217 int *bus_range; 217 const int *bus_range;
218 int len, index = -1; 218 int len, index = -1;
219 struct pci_controller *hose; 219 struct pci_controller *hose;
220 unsigned int *dma; 220 const unsigned int *dma;
221 char *model, *machine; 221 const char *model, *machine;
222 int is_longtrail = 0, is_mot = 0, is_pegasos = 0; 222 int is_longtrail = 0, is_mot = 0, is_pegasos = 0;
223 struct device_node *root = find_path_device("/"); 223 struct device_node *root = find_path_device("/");
224 struct resource r; 224 struct resource r;
@@ -246,7 +246,7 @@ chrp_find_bridges(void)
246 dev->full_name); 246 dev->full_name);
247 continue; 247 continue;
248 } 248 }
249 bus_range = (int *) get_property(dev, "bus-range", &len); 249 bus_range = get_property(dev, "bus-range", &len);
250 if (bus_range == NULL || len < 2 * sizeof(int)) { 250 if (bus_range == NULL || len < 2 * sizeof(int)) {
251 printk(KERN_WARNING "Can't get bus-range for %s\n", 251 printk(KERN_WARNING "Can't get bus-range for %s\n",
252 dev->full_name); 252 dev->full_name);
@@ -257,7 +257,7 @@ chrp_find_bridges(void)
257 else 257 else
258 printk(KERN_INFO "PCI buses %d..%d", 258 printk(KERN_INFO "PCI buses %d..%d",
259 bus_range[0], bus_range[1]); 259 bus_range[0], bus_range[1]);
260 printk(" controlled by %s", dev->type); 260 printk(" controlled by %s", dev->full_name);
261 if (!is_longtrail) 261 if (!is_longtrail)
262 printk(" at %llx", (unsigned long long)r.start); 262 printk(" at %llx", (unsigned long long)r.start);
263 printk("\n"); 263 printk("\n");
@@ -289,6 +289,19 @@ chrp_find_bridges(void)
289 setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc); 289 setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc);
290 } else if (is_pegasos == 2) { 290 } else if (is_pegasos == 2) {
291 setup_peg2(hose, dev); 291 setup_peg2(hose, dev);
292 } else if (!strncmp(model, "IBM,CPC710", 10)) {
293 setup_indirect_pci(hose,
294 r.start + 0x000f8000,
295 r.start + 0x000f8010);
296 if (index == 0) {
297 dma = get_property(dev, "system-dma-base",&len);
298 if (dma && len >= sizeof(*dma)) {
299 dma = (unsigned int *)
300 (((unsigned long)dma) +
301 len - sizeof(*dma));
302 pci_dram_offset = *dma;
303 }
304 }
292 } else { 305 } else {
293 printk("No methods for %s (model %s), using RTAS\n", 306 printk("No methods for %s (model %s), using RTAS\n",
294 dev->full_name, model); 307 dev->full_name, model);
@@ -299,15 +312,35 @@ chrp_find_bridges(void)
299 312
300 /* check the first bridge for a property that we can 313 /* check the first bridge for a property that we can
301 use to set pci_dram_offset */ 314 use to set pci_dram_offset */
302 dma = (unsigned int *) 315 dma = get_property(dev, "ibm,dma-ranges", &len);
303 get_property(dev, "ibm,dma-ranges", &len);
304 if (index == 0 && dma != NULL && len >= 6 * sizeof(*dma)) { 316 if (index == 0 && dma != NULL && len >= 6 * sizeof(*dma)) {
305 pci_dram_offset = dma[2] - dma[3]; 317 pci_dram_offset = dma[2] - dma[3];
306 printk("pci_dram_offset = %lx\n", pci_dram_offset); 318 printk("pci_dram_offset = %lx\n", pci_dram_offset);
307 } 319 }
308 } 320 }
321}
322
323/* SL82C105 IDE Control/Status Register */
324#define SL82C105_IDECSR 0x40
325
326/* Fixup for Winbond ATA quirk, required for briq */
327void chrp_pci_fixup_winbond_ata(struct pci_dev *sl82c105)
328{
329 u8 progif;
309 330
310 /* Do not fixup interrupts from OF tree on pegasos */ 331 /* If non-briq machines need that fixup too, please speak up */
311 if (is_pegasos) 332 if (!machine_is(chrp) || _chrp_type != _CHRP_briq)
312 ppc_md.pcibios_fixup = NULL; 333 return;
334
335 if ((sl82c105->class & 5) != 5) {
336 printk("W83C553: Switching SL82C105 IDE to PCI native mode\n");
337 /* Enable SL82C105 PCI native IDE mode */
338 pci_read_config_byte(sl82c105, PCI_CLASS_PROG, &progif);
339 pci_write_config_byte(sl82c105, PCI_CLASS_PROG, progif | 0x05);
340 sl82c105->class |= 0x05;
341 /* Disable SL82C105 second port */
342 pci_write_config_word(sl82c105, SL82C105_IDECSR, 0x0003);
343 }
313} 344}
345DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
346 chrp_pci_fixup_winbond_ata);
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index 9c08ff322290..488dbd9b51ae 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -74,6 +74,9 @@ extern irqreturn_t xmon_irq(int, void *, struct pt_regs *);
74 74
75extern unsigned long loops_per_jiffy; 75extern unsigned long loops_per_jiffy;
76 76
77/* To be replaced by RTAS when available */
78static unsigned int *briq_SPOR;
79
77#ifdef CONFIG_SMP 80#ifdef CONFIG_SMP
78extern struct smp_ops_t chrp_smp_ops; 81extern struct smp_ops_t chrp_smp_ops;
79#endif 82#endif
@@ -92,6 +95,15 @@ static const char *gg2_cachemodes[4] = {
92 "Disabled", "Write-Through", "Copy-Back", "Transparent Mode" 95 "Disabled", "Write-Through", "Copy-Back", "Transparent Mode"
93}; 96};
94 97
98static const char *chrp_names[] = {
99 "Unknown",
100 "","","",
101 "Motorola",
102 "IBM or Longtrail",
103 "Genesi Pegasos",
104 "Total Impact Briq"
105};
106
95void chrp_show_cpuinfo(struct seq_file *m) 107void chrp_show_cpuinfo(struct seq_file *m)
96{ 108{
97 int i, sdramen; 109 int i, sdramen;
@@ -214,8 +226,7 @@ static void __init pegasos_set_l2cr(void)
214 /* Enable L2 cache if needed */ 226 /* Enable L2 cache if needed */
215 np = find_type_devices("cpu"); 227 np = find_type_devices("cpu");
216 if (np != NULL) { 228 if (np != NULL) {
217 unsigned int *l2cr = (unsigned int *) 229 const unsigned int *l2cr = get_property(np, "l2cr", NULL);
218 get_property (np, "l2cr", NULL);
219 if (l2cr == NULL) { 230 if (l2cr == NULL) {
220 printk ("Pegasos l2cr : no cpu l2cr property found\n"); 231 printk ("Pegasos l2cr : no cpu l2cr property found\n");
221 return; 232 return;
@@ -229,10 +240,18 @@ static void __init pegasos_set_l2cr(void)
229 } 240 }
230} 241}
231 242
243static void briq_restart(char *cmd)
244{
245 local_irq_disable();
246 if (briq_SPOR)
247 out_be32(briq_SPOR, 0);
248 for(;;);
249}
250
232void __init chrp_setup_arch(void) 251void __init chrp_setup_arch(void)
233{ 252{
234 struct device_node *root = find_path_device ("/"); 253 struct device_node *root = find_path_device ("/");
235 char *machine = NULL; 254 const char *machine = NULL;
236 255
237 /* init to some ~sane value until calibrate_delay() runs */ 256 /* init to some ~sane value until calibrate_delay() runs */
238 loops_per_jiffy = 50000000/HZ; 257 loops_per_jiffy = 50000000/HZ;
@@ -245,11 +264,16 @@ void __init chrp_setup_arch(void)
245 _chrp_type = _CHRP_IBM; 264 _chrp_type = _CHRP_IBM;
246 } else if (machine && strncmp(machine, "MOT", 3) == 0) { 265 } else if (machine && strncmp(machine, "MOT", 3) == 0) {
247 _chrp_type = _CHRP_Motorola; 266 _chrp_type = _CHRP_Motorola;
267 } else if (machine && strncmp(machine, "TotalImpact,BRIQ-1", 18) == 0) {
268 _chrp_type = _CHRP_briq;
269 /* Map the SPOR register on briq and change the restart hook */
270 briq_SPOR = (unsigned int *)ioremap(0xff0000e8, 4);
271 ppc_md.restart = briq_restart;
248 } else { 272 } else {
249 /* Let's assume it is an IBM chrp if all else fails */ 273 /* Let's assume it is an IBM chrp if all else fails */
250 _chrp_type = _CHRP_IBM; 274 _chrp_type = _CHRP_IBM;
251 } 275 }
252 printk("chrp type = %x\n", _chrp_type); 276 printk("chrp type = %x [%s]\n", _chrp_type, chrp_names[_chrp_type]);
253 277
254 rtas_initialize(); 278 rtas_initialize();
255 if (rtas_token("display-character") >= 0) 279 if (rtas_token("display-character") >= 0)
@@ -328,7 +352,7 @@ static void __init chrp_find_openpic(void)
328 struct device_node *np, *root; 352 struct device_node *np, *root;
329 int len, i, j; 353 int len, i, j;
330 int isu_size, idu_size; 354 int isu_size, idu_size;
331 unsigned int *iranges, *opprop = NULL; 355 const unsigned int *iranges, *opprop = NULL;
332 int oplen = 0; 356 int oplen = 0;
333 unsigned long opaddr; 357 unsigned long opaddr;
334 int na = 1; 358 int na = 1;
@@ -338,8 +362,7 @@ static void __init chrp_find_openpic(void)
338 return; 362 return;
339 root = of_find_node_by_path("/"); 363 root = of_find_node_by_path("/");
340 if (root) { 364 if (root) {
341 opprop = (unsigned int *) get_property 365 opprop = get_property(root, "platform-open-pic", &oplen);
342 (root, "platform-open-pic", &oplen);
343 na = prom_n_addr_cells(root); 366 na = prom_n_addr_cells(root);
344 } 367 }
345 if (opprop && oplen >= na * sizeof(unsigned int)) { 368 if (opprop && oplen >= na * sizeof(unsigned int)) {
@@ -356,7 +379,7 @@ static void __init chrp_find_openpic(void)
356 379
357 printk(KERN_INFO "OpenPIC at %lx\n", opaddr); 380 printk(KERN_INFO "OpenPIC at %lx\n", opaddr);
358 381
359 iranges = (unsigned int *) get_property(np, "interrupt-ranges", &len); 382 iranges = get_property(np, "interrupt-ranges", &len);
360 if (iranges == NULL) 383 if (iranges == NULL)
361 len = 0; /* non-distributed mpic */ 384 len = 0; /* non-distributed mpic */
362 else 385 else
@@ -442,8 +465,8 @@ static void __init chrp_find_8259(void)
442 * from anyway 465 * from anyway
443 */ 466 */
444 for (np = find_devices("pci"); np != NULL; np = np->next) { 467 for (np = find_devices("pci"); np != NULL; np = np->next) {
445 unsigned int *addrp = (unsigned int *) 468 const unsigned int *addrp = get_property(np,
446 get_property(np, "8259-interrupt-acknowledge", NULL); 469 "8259-interrupt-acknowledge", NULL);
447 470
448 if (addrp == NULL) 471 if (addrp == NULL)
449 continue; 472 continue;
@@ -502,7 +525,7 @@ void __init
502chrp_init2(void) 525chrp_init2(void)
503{ 526{
504 struct device_node *device; 527 struct device_node *device;
505 unsigned int *p = NULL; 528 const unsigned int *p = NULL;
506 529
507#ifdef CONFIG_NVRAM 530#ifdef CONFIG_NVRAM
508 chrp_nvram_init(); 531 chrp_nvram_init();
@@ -520,8 +543,7 @@ chrp_init2(void)
520 */ 543 */
521 device = find_devices("rtas"); 544 device = find_devices("rtas");
522 if (device) 545 if (device)
523 p = (unsigned int *) get_property 546 p = get_property(device, "rtas-event-scan-rate", NULL);
524 (device, "rtas-event-scan-rate", NULL);
525 if (p && *p) { 547 if (p && *p) {
526 /* 548 /*
527 * Arrange to call chrp_event_scan at least *p times 549 * Arrange to call chrp_event_scan at least *p times
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index 5d393eb94935..e4f2b9df5e17 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -95,7 +95,7 @@ void mpc7448_hpc2_fixup_irq(struct pci_dev *dev)
95{ 95{
96 struct pci_controller *hose; 96 struct pci_controller *hose;
97 struct device_node *node; 97 struct device_node *node;
98 unsigned int *interrupt; 98 const unsigned int *interrupt;
99 int busnr; 99 int busnr;
100 int len; 100 int len;
101 u8 slot; 101 u8 slot;
@@ -112,7 +112,7 @@ void mpc7448_hpc2_fixup_irq(struct pci_dev *dev)
112 if (!node) 112 if (!node)
113 printk(KERN_ERR "No pci node found\n"); 113 printk(KERN_ERR "No pci node found\n");
114 114
115 interrupt = (unsigned int *) get_property(node, "interrupt-map", &len); 115 interrupt = get_property(node, "interrupt-map", &len);
116 slot = find_slot_by_devfn(interrupt, dev->devfn); 116 slot = find_slot_by_devfn(interrupt, dev->devfn);
117 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 117 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
118 if (pin == 0 || pin > 4) 118 if (pin == 0 || pin > 4)
@@ -141,9 +141,9 @@ static void __init mpc7448_hpc2_setup_arch(void)
141 141
142 cpu = of_find_node_by_type(NULL, "cpu"); 142 cpu = of_find_node_by_type(NULL, "cpu");
143 if (cpu != 0) { 143 if (cpu != 0) {
144 unsigned int *fp; 144 const unsigned int *fp;
145 145
146 fp = (int *)get_property(cpu, "clock-frequency", NULL); 146 fp = get_property(cpu, "clock-frequency", NULL);
147 if (fp != 0) 147 if (fp != 0)
148 loops_per_jiffy = *fp / HZ; 148 loops_per_jiffy = *fp / HZ;
149 else 149 else
diff --git a/arch/powerpc/platforms/iseries/Kconfig b/arch/powerpc/platforms/iseries/Kconfig
index 3d957a30c8c2..887b68804e6d 100644
--- a/arch/powerpc/platforms/iseries/Kconfig
+++ b/arch/powerpc/platforms/iseries/Kconfig
@@ -3,13 +3,17 @@ menu "iSeries device drivers"
3 depends on PPC_ISERIES 3 depends on PPC_ISERIES
4 4
5config VIOCONS 5config VIOCONS
6 tristate "iSeries Virtual Console Support" 6 tristate "iSeries Virtual Console Support (Obsolete)"
7 help
8 This is the old virtual console driver for legacy iSeries.
9 You should use the iSeries Hypervisor Virtual Console
10 support instead.
7 11
8config VIODASD 12config VIODASD
9 tristate "iSeries Virtual I/O disk support" 13 tristate "iSeries Virtual I/O disk support"
10 help 14 help
11 If you are running on an iSeries system and you want to use 15 If you are running on an iSeries system and you want to use
12 virtual disks created and managed by OS/400, say Y. 16 virtual disks created and managed by OS/400, say Y.
13 17
14config VIOCD 18config VIOCD
15 tristate "iSeries Virtual I/O CD support" 19 tristate "iSeries Virtual I/O CD support"
diff --git a/arch/powerpc/platforms/iseries/dt.c b/arch/powerpc/platforms/iseries/dt.c
index d194140c1ebf..e305deee7f44 100644
--- a/arch/powerpc/platforms/iseries/dt.c
+++ b/arch/powerpc/platforms/iseries/dt.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2005-2006 Michael Ellerman, IBM Corporation 2 * Copyright (C) 2005-2006 Michael Ellerman, IBM Corporation
3 * Copyright (C) 2000-2004, IBM Corporation
3 * 4 *
4 * Description: 5 * Description:
5 * This file contains all the routines to build a flattened device 6 * This file contains all the routines to build a flattened device
@@ -33,13 +34,13 @@
33#include <asm/iseries/hv_types.h> 34#include <asm/iseries/hv_types.h>
34#include <asm/iseries/hv_lp_config.h> 35#include <asm/iseries/hv_lp_config.h>
35#include <asm/iseries/hv_call_xm.h> 36#include <asm/iseries/hv_call_xm.h>
36#include <asm/iseries/it_exp_vpd_panel.h>
37#include <asm/udbg.h> 37#include <asm/udbg.h>
38 38
39#include "processor_vpd.h" 39#include "processor_vpd.h"
40#include "call_hpt.h" 40#include "call_hpt.h"
41#include "call_pci.h" 41#include "call_pci.h"
42#include "pci.h" 42#include "pci.h"
43#include "it_exp_vpd_panel.h"
43 44
44#ifdef DEBUG 45#ifdef DEBUG
45#define DBG(fmt...) udbg_printf(fmt) 46#define DBG(fmt...) udbg_printf(fmt)
@@ -76,6 +77,43 @@ static char __initdata device_type_pci[] = "pci";
76static char __initdata device_type_vdevice[] = "vdevice"; 77static char __initdata device_type_vdevice[] = "vdevice";
77static char __initdata device_type_vscsi[] = "vscsi"; 78static char __initdata device_type_vscsi[] = "vscsi";
78 79
80
81/* EBCDIC to ASCII conversion routines */
82
83static unsigned char __init e2a(unsigned char x)
84{
85 switch (x) {
86 case 0x81 ... 0x89:
87 return x - 0x81 + 'a';
88 case 0x91 ... 0x99:
89 return x - 0x91 + 'j';
90 case 0xA2 ... 0xA9:
91 return x - 0xA2 + 's';
92 case 0xC1 ... 0xC9:
93 return x - 0xC1 + 'A';
94 case 0xD1 ... 0xD9:
95 return x - 0xD1 + 'J';
96 case 0xE2 ... 0xE9:
97 return x - 0xE2 + 'S';
98 case 0xF0 ... 0xF9:
99 return x - 0xF0 + '0';
100 }
101 return ' ';
102}
103
104static unsigned char * __init strne2a(unsigned char *dest,
105 const unsigned char *src, size_t n)
106{
107 int i;
108
109 n = strnlen(src, n);
110
111 for (i = 0; i < n; i++)
112 dest[i] = e2a(src[i]);
113
114 return dest;
115}
116
79static struct iseries_flat_dt * __init dt_init(void) 117static struct iseries_flat_dt * __init dt_init(void)
80{ 118{
81 struct iseries_flat_dt *dt; 119 struct iseries_flat_dt *dt;
@@ -298,7 +336,8 @@ static void __init dt_vdevices(struct iseries_flat_dt *dt)
298 dt_prop_u32(dt, "#address-cells", 1); 336 dt_prop_u32(dt, "#address-cells", 1);
299 dt_prop_u32(dt, "#size-cells", 0); 337 dt_prop_u32(dt, "#size-cells", 0);
300 338
301 dt_do_vdevice(dt, "vty", reg, -1, device_type_serial, NULL, 1); 339 dt_do_vdevice(dt, "vty", reg, -1, device_type_serial,
340 "IBM,iSeries-vty", 1);
302 reg++; 341 reg++;
303 342
304 dt_do_vdevice(dt, "v-scsi", reg, -1, device_type_vscsi, 343 dt_do_vdevice(dt, "v-scsi", reg, -1, device_type_vscsi,
diff --git a/arch/powerpc/platforms/iseries/hvlpconfig.c b/arch/powerpc/platforms/iseries/hvlpconfig.c
index 663a1affb4bb..f0475f0b1853 100644
--- a/arch/powerpc/platforms/iseries/hvlpconfig.c
+++ b/arch/powerpc/platforms/iseries/hvlpconfig.c
@@ -18,9 +18,22 @@
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <asm/iseries/hv_lp_config.h> 20#include <asm/iseries/hv_lp_config.h>
21#include "it_lp_naca.h"
21 22
22HvLpIndex HvLpConfig_getLpIndex_outline(void) 23HvLpIndex HvLpConfig_getLpIndex_outline(void)
23{ 24{
24 return HvLpConfig_getLpIndex(); 25 return HvLpConfig_getLpIndex();
25} 26}
26EXPORT_SYMBOL(HvLpConfig_getLpIndex_outline); 27EXPORT_SYMBOL(HvLpConfig_getLpIndex_outline);
28
29HvLpIndex HvLpConfig_getLpIndex(void)
30{
31 return itLpNaca.xLpIndex;
32}
33EXPORT_SYMBOL(HvLpConfig_getLpIndex);
34
35HvLpIndex HvLpConfig_getPrimaryLpIndex(void)
36{
37 return itLpNaca.xPrimaryLpIndex;
38}
39EXPORT_SYMBOL_GPL(HvLpConfig_getPrimaryLpIndex);
diff --git a/arch/powerpc/platforms/iseries/iommu.c b/arch/powerpc/platforms/iseries/iommu.c
index e3bd2015f2c9..f4cbbcf8773a 100644
--- a/arch/powerpc/platforms/iseries/iommu.c
+++ b/arch/powerpc/platforms/iseries/iommu.c
@@ -88,6 +88,23 @@ static void tce_free_iSeries(struct iommu_table *tbl, long index, long npages)
88} 88}
89 89
90/* 90/*
91 * Structure passed to HvCallXm_getTceTableParms
92 */
93struct iommu_table_cb {
94 unsigned long itc_busno; /* Bus number for this tce table */
95 unsigned long itc_start; /* Will be NULL for secondary */
96 unsigned long itc_totalsize; /* Size (in pages) of whole table */
97 unsigned long itc_offset; /* Index into real tce table of the
98 start of our section */
99 unsigned long itc_size; /* Size (in pages) of our section */
100 unsigned long itc_index; /* Index of this tce table */
101 unsigned short itc_maxtables; /* Max num of tables for partition */
102 unsigned char itc_virtbus; /* Flag to indicate virtual bus */
103 unsigned char itc_slotno; /* IOA Tce Slot Index */
104 unsigned char itc_rsvd[4];
105};
106
107/*
91 * Call Hv with the architected data structure to get TCE table info. 108 * Call Hv with the architected data structure to get TCE table info.
92 * info. Put the returned data into the Linux representation of the 109 * info. Put the returned data into the Linux representation of the
93 * TCE table data. 110 * TCE table data.
@@ -162,7 +179,7 @@ void iommu_devnode_init_iSeries(struct device_node *dn)
162{ 179{
163 struct iommu_table *tbl; 180 struct iommu_table *tbl;
164 struct pci_dn *pdn = PCI_DN(dn); 181 struct pci_dn *pdn = PCI_DN(dn);
165 u32 *lsn = (u32 *)get_property(dn, "linux,logical-slot-number", NULL); 182 const u32 *lsn = get_property(dn, "linux,logical-slot-number", NULL);
166 183
167 BUG_ON(lsn == NULL); 184 BUG_ON(lsn == NULL);
168 185
diff --git a/arch/powerpc/platforms/iseries/it_exp_vpd_panel.h b/arch/powerpc/platforms/iseries/it_exp_vpd_panel.h
new file mode 100644
index 000000000000..6de9097b7f57
--- /dev/null
+++ b/arch/powerpc/platforms/iseries/it_exp_vpd_panel.h
@@ -0,0 +1,51 @@
1/*
2 * Copyright (C) 2002 Dave Boutcher IBM Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _PLATFORMS_ISERIES_IT_EXT_VPD_PANEL_H
19#define _PLATFORMS_ISERIES_IT_EXT_VPD_PANEL_H
20
21/*
22 * This struct maps the panel information
23 *
24 * Warning:
25 * This data must match the architecture for the panel information
26 */
27
28#include <asm/types.h>
29
30struct ItExtVpdPanel {
31 /* Definition of the Extended Vpd On Panel Data Area */
32 char systemSerial[8];
33 char mfgID[4];
34 char reserved1[24];
35 char machineType[4];
36 char systemID[6];
37 char somUniqueCnt[4];
38 char serialNumberCount;
39 char reserved2[7];
40 u16 bbu3;
41 u16 bbu2;
42 u16 bbu1;
43 char xLocationLabel[8];
44 u8 xRsvd1[6];
45 u16 xFrameId;
46 u8 xRsvd2[48];
47};
48
49extern struct ItExtVpdPanel xItExtVpdPanel;
50
51#endif /* _PLATFORMS_ISERIES_IT_EXT_VPD_PANEL_H */
diff --git a/arch/powerpc/platforms/iseries/it_lp_naca.h b/arch/powerpc/platforms/iseries/it_lp_naca.h
new file mode 100644
index 000000000000..9bbf58986819
--- /dev/null
+++ b/arch/powerpc/platforms/iseries/it_lp_naca.h
@@ -0,0 +1,80 @@
1/*
2 * Copyright (C) 2001 Mike Corrigan IBM Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _PLATFORMS_ISERIES_IT_LP_NACA_H
19#define _PLATFORMS_ISERIES_IT_LP_NACA_H
20
21#include <linux/types.h>
22
23/*
24 * This control block contains the data that is shared between the
25 * hypervisor (PLIC) and the OS.
26 */
27
28struct ItLpNaca {
29// CACHE_LINE_1 0x0000 - 0x007F Contains read-only data
30 u32 xDesc; // Eye catcher x00-x03
31 u16 xSize; // Size of this class x04-x05
32 u16 xIntHdlrOffset; // Offset to IntHdlr array x06-x07
33 u8 xMaxIntHdlrEntries; // Number of entries in array x08-x08
34 u8 xPrimaryLpIndex; // LP Index of Primary x09-x09
35 u8 xServiceLpIndex; // LP Ind of Service Focal Pointx0A-x0A
36 u8 xLpIndex; // LP Index x0B-x0B
37 u16 xMaxLpQueues; // Number of allocated queues x0C-x0D
38 u16 xLpQueueOffset; // Offset to start of LP queues x0E-x0F
39 u8 xPirEnvironMode; // Piranha or hardware x10-x10
40 u8 xPirConsoleMode; // Piranha console indicator x11-x11
41 u8 xPirDasdMode; // Piranha dasd indicator x12-x12
42 u8 xRsvd1_0[5]; // Reserved for Piranha related x13-x17
43 u8 flags; // flags, see below x18-x1F
44 u8 xSpVpdFormat; // VPD areas are in CSP format ...
45 u8 xIntProcRatio; // Ratio of int procs to procs ...
46 u8 xRsvd1_2[5]; // Reserved ...
47 u16 xRsvd1_3; // Reserved x20-x21
48 u16 xPlicVrmIndex; // VRM index of PLIC x22-x23
49 u16 xMinSupportedSlicVrmInd;// Min supported OS VRM index x24-x25
50 u16 xMinCompatableSlicVrmInd;// Min compatible OS VRM index x26-x27
51 u64 xLoadAreaAddr; // ER address of load area x28-x2F
52 u32 xLoadAreaChunks; // Chunks for the load area x30-x33
53 u32 xPaseSysCallCRMask; // Mask used to test CR before x34-x37
54 // doing an ASR switch on PASE
55 // system call.
56 u64 xSlicSegmentTablePtr; // Pointer to Slic seg table. x38-x3f
57 u8 xRsvd1_4[64]; // x40-x7F
58
59// CACHE_LINE_2 0x0080 - 0x00FF Contains local read-write data
60 u8 xRsvd2_0[128]; // Reserved x00-x7F
61
62// CACHE_LINE_3-6 0x0100 - 0x02FF Contains LP Queue indicators
63// NB: Padding required to keep xInterrruptHdlr at x300 which is required
64// for v4r4 PLIC.
65 u8 xOldLpQueue[128]; // LP Queue needed for v4r4 100-17F
66 u8 xRsvd3_0[384]; // Reserved 180-2FF
67
68// CACHE_LINE_7-8 0x0300 - 0x03FF Contains the address of the OS interrupt
69// handlers
70 u64 xInterruptHdlr[32]; // Interrupt handlers 300-x3FF
71};
72
73extern struct ItLpNaca itLpNaca;
74
75#define ITLPNACA_LPAR 0x80 /* Is LPAR installed on the system */
76#define ITLPNACA_PARTITIONED 0x40 /* Is the system partitioned */
77#define ITLPNACA_HWSYNCEDTBS 0x20 /* Hardware synced TBs */
78#define ITLPNACA_HMTINT 0x10 /* Utilize MHT for interrupts */
79
80#endif /* _PLATFORMS_ISERIES_IT_LP_NACA_H */
diff --git a/arch/powerpc/platforms/iseries/lpardata.c b/arch/powerpc/platforms/iseries/lpardata.c
index a7769445d6c7..8162049bb04d 100644
--- a/arch/powerpc/platforms/iseries/lpardata.c
+++ b/arch/powerpc/platforms/iseries/lpardata.c
@@ -13,12 +13,10 @@
13#include <asm/processor.h> 13#include <asm/processor.h>
14#include <asm/ptrace.h> 14#include <asm/ptrace.h>
15#include <asm/abs_addr.h> 15#include <asm/abs_addr.h>
16#include <asm/iseries/it_lp_naca.h>
17#include <asm/lppaca.h> 16#include <asm/lppaca.h>
18#include <asm/iseries/it_lp_reg_save.h> 17#include <asm/iseries/it_lp_reg_save.h>
19#include <asm/paca.h> 18#include <asm/paca.h>
20#include <asm/iseries/lpar_map.h> 19#include <asm/iseries/lpar_map.h>
21#include <asm/iseries/it_exp_vpd_panel.h>
22#include <asm/iseries/it_lp_queue.h> 20#include <asm/iseries/it_lp_queue.h>
23 21
24#include "naca.h" 22#include "naca.h"
@@ -27,6 +25,8 @@
27#include "ipl_parms.h" 25#include "ipl_parms.h"
28#include "processor_vpd.h" 26#include "processor_vpd.h"
29#include "release_data.h" 27#include "release_data.h"
28#include "it_exp_vpd_panel.h"
29#include "it_lp_naca.h"
30 30
31/* The HvReleaseData is the root of the information shared between 31/* The HvReleaseData is the root of the information shared between
32 * the hypervisor and Linux. 32 * the hypervisor and Linux.
@@ -127,14 +127,12 @@ struct ItLpNaca itLpNaca = {
127 (u64)instruction_access_slb_iSeries /* 0x480 I-SLB */ 127 (u64)instruction_access_slb_iSeries /* 0x480 I-SLB */
128 } 128 }
129}; 129};
130EXPORT_SYMBOL(itLpNaca);
131 130
132/* May be filled in by the hypervisor so cannot end up in the BSS */ 131/* May be filled in by the hypervisor so cannot end up in the BSS */
133struct ItIplParmsReal xItIplParmsReal __attribute__((__section__(".data"))); 132struct ItIplParmsReal xItIplParmsReal __attribute__((__section__(".data")));
134 133
135/* May be filled in by the hypervisor so cannot end up in the BSS */ 134/* May be filled in by the hypervisor so cannot end up in the BSS */
136struct ItExtVpdPanel xItExtVpdPanel __attribute__((__section__(".data"))); 135struct ItExtVpdPanel xItExtVpdPanel __attribute__((__section__(".data")));
137EXPORT_SYMBOL(xItExtVpdPanel);
138 136
139#define maxPhysicalProcessors 32 137#define maxPhysicalProcessors 32
140 138
diff --git a/arch/powerpc/platforms/iseries/lpevents.c b/arch/powerpc/platforms/iseries/lpevents.c
index 2a9f81ea27d6..98c1c2440aad 100644
--- a/arch/powerpc/platforms/iseries/lpevents.c
+++ b/arch/powerpc/platforms/iseries/lpevents.c
@@ -20,7 +20,7 @@
20#include <asm/iseries/it_lp_queue.h> 20#include <asm/iseries/it_lp_queue.h>
21#include <asm/iseries/hv_lp_event.h> 21#include <asm/iseries/hv_lp_event.h>
22#include <asm/iseries/hv_call_event.h> 22#include <asm/iseries/hv_call_event.h>
23#include <asm/iseries/it_lp_naca.h> 23#include "it_lp_naca.h"
24 24
25/* 25/*
26 * The LpQueue is used to pass event data from the hypervisor to 26 * The LpQueue is used to pass event data from the hypervisor to
diff --git a/arch/powerpc/platforms/iseries/main_store.h b/arch/powerpc/platforms/iseries/main_store.h
index 74f6889f834f..1a7a3f50e40b 100644
--- a/arch/powerpc/platforms/iseries/main_store.h
+++ b/arch/powerpc/platforms/iseries/main_store.h
@@ -61,9 +61,9 @@ struct IoHriMainStoreSegment4 {
61}; 61};
62 62
63/* Main Store VPD for Power4 */ 63/* Main Store VPD for Power4 */
64struct IoHriMainStoreChipInfo1 { 64struct __attribute((packed)) IoHriMainStoreChipInfo1 {
65 u32 chipMfgID __attribute((packed)); 65 u32 chipMfgID;
66 char chipECLevel[4] __attribute((packed)); 66 char chipECLevel[4];
67}; 67};
68 68
69struct IoHriMainStoreVpdIdData { 69struct IoHriMainStoreVpdIdData {
@@ -73,72 +73,72 @@ struct IoHriMainStoreVpdIdData {
73 char serialNumber[12]; 73 char serialNumber[12];
74}; 74};
75 75
76struct IoHriMainStoreVpdFruData { 76struct __attribute((packed)) IoHriMainStoreVpdFruData {
77 char fruLabel[8] __attribute((packed)); 77 char fruLabel[8];
78 u8 numberOfSlots __attribute((packed)); 78 u8 numberOfSlots;
79 u8 pluggingType __attribute((packed)); 79 u8 pluggingType;
80 u16 slotMapIndex __attribute((packed)); 80 u16 slotMapIndex;
81}; 81};
82 82
83struct IoHriMainStoreAdrRangeBlock { 83struct __attribute((packed)) IoHriMainStoreAdrRangeBlock {
84 void *blockStart __attribute((packed)); 84 void *blockStart;
85 void *blockEnd __attribute((packed)); 85 void *blockEnd;
86 u32 blockProcChipId __attribute((packed)); 86 u32 blockProcChipId;
87}; 87};
88 88
89#define MaxAreaAdrRangeBlocks 4 89#define MaxAreaAdrRangeBlocks 4
90 90
91struct IoHriMainStoreArea4 { 91struct __attribute((packed)) IoHriMainStoreArea4 {
92 u32 msVpdFormat __attribute((packed)); 92 u32 msVpdFormat;
93 u8 containedVpdType __attribute((packed)); 93 u8 containedVpdType;
94 u8 reserved1 __attribute((packed)); 94 u8 reserved1;
95 u16 reserved2 __attribute((packed)); 95 u16 reserved2;
96 96
97 u64 msExists __attribute((packed)); 97 u64 msExists;
98 u64 msFunctional __attribute((packed)); 98 u64 msFunctional;
99 99
100 u32 memorySize __attribute((packed)); 100 u32 memorySize;
101 u32 procNodeId __attribute((packed)); 101 u32 procNodeId;
102 102
103 u32 numAdrRangeBlocks __attribute((packed)); 103 u32 numAdrRangeBlocks;
104 struct IoHriMainStoreAdrRangeBlock xAdrRangeBlock[MaxAreaAdrRangeBlocks] __attribute((packed)); 104 struct IoHriMainStoreAdrRangeBlock xAdrRangeBlock[MaxAreaAdrRangeBlocks];
105 105
106 struct IoHriMainStoreChipInfo1 chipInfo0 __attribute((packed)); 106 struct IoHriMainStoreChipInfo1 chipInfo0;
107 struct IoHriMainStoreChipInfo1 chipInfo1 __attribute((packed)); 107 struct IoHriMainStoreChipInfo1 chipInfo1;
108 struct IoHriMainStoreChipInfo1 chipInfo2 __attribute((packed)); 108 struct IoHriMainStoreChipInfo1 chipInfo2;
109 struct IoHriMainStoreChipInfo1 chipInfo3 __attribute((packed)); 109 struct IoHriMainStoreChipInfo1 chipInfo3;
110 struct IoHriMainStoreChipInfo1 chipInfo4 __attribute((packed)); 110 struct IoHriMainStoreChipInfo1 chipInfo4;
111 struct IoHriMainStoreChipInfo1 chipInfo5 __attribute((packed)); 111 struct IoHriMainStoreChipInfo1 chipInfo5;
112 struct IoHriMainStoreChipInfo1 chipInfo6 __attribute((packed)); 112 struct IoHriMainStoreChipInfo1 chipInfo6;
113 struct IoHriMainStoreChipInfo1 chipInfo7 __attribute((packed)); 113 struct IoHriMainStoreChipInfo1 chipInfo7;
114 114
115 void *msRamAreaArray __attribute((packed)); 115 void *msRamAreaArray;
116 u32 msRamAreaArrayNumEntries __attribute((packed)); 116 u32 msRamAreaArrayNumEntries;
117 u32 msRamAreaArrayEntrySize __attribute((packed)); 117 u32 msRamAreaArrayEntrySize;
118 118
119 u32 numaDimmExists __attribute((packed)); 119 u32 numaDimmExists;
120 u32 numaDimmFunctional __attribute((packed)); 120 u32 numaDimmFunctional;
121 void *numaDimmArray __attribute((packed)); 121 void *numaDimmArray;
122 u32 numaDimmArrayNumEntries __attribute((packed)); 122 u32 numaDimmArrayNumEntries;
123 u32 numaDimmArrayEntrySize __attribute((packed)); 123 u32 numaDimmArrayEntrySize;
124 124
125 struct IoHriMainStoreVpdIdData idData __attribute((packed)); 125 struct IoHriMainStoreVpdIdData idData;
126 126
127 u64 powerData __attribute((packed)); 127 u64 powerData;
128 u64 cardAssemblyPartNum __attribute((packed)); 128 u64 cardAssemblyPartNum;
129 u64 chipSerialNum __attribute((packed)); 129 u64 chipSerialNum;
130 130
131 u64 reserved3 __attribute((packed)); 131 u64 reserved3;
132 char reserved4[16] __attribute((packed)); 132 char reserved4[16];
133 133
134 struct IoHriMainStoreVpdFruData fruData __attribute((packed)); 134 struct IoHriMainStoreVpdFruData fruData;
135 135
136 u8 vpdPortNum __attribute((packed)); 136 u8 vpdPortNum;
137 u8 reserved5 __attribute((packed)); 137 u8 reserved5;
138 u8 frameId __attribute((packed)); 138 u8 frameId;
139 u8 rackUnit __attribute((packed)); 139 u8 rackUnit;
140 char asciiKeywordVpd[256] __attribute((packed)); 140 char asciiKeywordVpd[256];
141 u32 reserved6 __attribute((packed)); 141 u32 reserved6;
142}; 142};
143 143
144 144
diff --git a/arch/powerpc/platforms/iseries/pci.c b/arch/powerpc/platforms/iseries/pci.c
index 35bcc98111f5..3eb12065df23 100644
--- a/arch/powerpc/platforms/iseries/pci.c
+++ b/arch/powerpc/platforms/iseries/pci.c
@@ -34,6 +34,7 @@
34#include <asm/pci-bridge.h> 34#include <asm/pci-bridge.h>
35#include <asm/iommu.h> 35#include <asm/iommu.h>
36#include <asm/abs_addr.h> 36#include <asm/abs_addr.h>
37#include <asm/firmware.h>
37 38
38#include <asm/iseries/hv_call_xm.h> 39#include <asm/iseries/hv_call_xm.h>
39#include <asm/iseries/mf.h> 40#include <asm/iseries/mf.h>
@@ -176,12 +177,12 @@ void iSeries_pcibios_init(void)
176 } 177 }
177 while ((node = of_get_next_child(root, node)) != NULL) { 178 while ((node = of_get_next_child(root, node)) != NULL) {
178 HvBusNumber bus; 179 HvBusNumber bus;
179 u32 *busp; 180 const u32 *busp;
180 181
181 if ((node->type == NULL) || (strcmp(node->type, "pci") != 0)) 182 if ((node->type == NULL) || (strcmp(node->type, "pci") != 0))
182 continue; 183 continue;
183 184
184 busp = (u32 *)get_property(node, "bus-range", NULL); 185 busp = get_property(node, "bus-range", NULL);
185 if (busp == NULL) 186 if (busp == NULL)
186 continue; 187 continue;
187 bus = *busp; 188 bus = *busp;
@@ -221,10 +222,9 @@ void __init iSeries_pci_final_fixup(void)
221 222
222 if (node != NULL) { 223 if (node != NULL) {
223 struct pci_dn *pdn = PCI_DN(node); 224 struct pci_dn *pdn = PCI_DN(node);
224 u32 *agent; 225 const u32 *agent;
225 226
226 agent = (u32 *)get_property(node, "linux,agent-id", 227 agent = get_property(node, "linux,agent-id", NULL);
227 NULL);
228 if ((pdn != NULL) && (agent != NULL)) { 228 if ((pdn != NULL) && (agent != NULL)) {
229 u8 irq = iSeries_allocate_IRQ(pdn->busno, 0, 229 u8 irq = iSeries_allocate_IRQ(pdn->busno, 0,
230 pdn->bussubno); 230 pdn->bussubno);
@@ -271,46 +271,6 @@ void pcibios_fixup_resources(struct pci_dev *pdev)
271} 271}
272 272
273/* 273/*
274 * I/0 Memory copy MUST use mmio commands on iSeries
275 * To do; For performance, include the hv call directly
276 */
277void iSeries_memset_io(volatile void __iomem *dest, char c, size_t Count)
278{
279 u8 ByteValue = c;
280 long NumberOfBytes = Count;
281
282 while (NumberOfBytes > 0) {
283 iSeries_Write_Byte(ByteValue, dest++);
284 -- NumberOfBytes;
285 }
286}
287EXPORT_SYMBOL(iSeries_memset_io);
288
289void iSeries_memcpy_toio(volatile void __iomem *dest, void *source, size_t count)
290{
291 char *src = source;
292 long NumberOfBytes = count;
293
294 while (NumberOfBytes > 0) {
295 iSeries_Write_Byte(*src++, dest++);
296 -- NumberOfBytes;
297 }
298}
299EXPORT_SYMBOL(iSeries_memcpy_toio);
300
301void iSeries_memcpy_fromio(void *dest, const volatile void __iomem *src, size_t count)
302{
303 char *dst = dest;
304 long NumberOfBytes = count;
305
306 while (NumberOfBytes > 0) {
307 *dst++ = iSeries_Read_Byte(src++);
308 -- NumberOfBytes;
309 }
310}
311EXPORT_SYMBOL(iSeries_memcpy_fromio);
312
313/*
314 * Look down the chain to find the matching Device Device 274 * Look down the chain to find the matching Device Device
315 */ 275 */
316static struct device_node *find_Device_Node(int bus, int devfn) 276static struct device_node *find_Device_Node(int bus, int devfn)
@@ -492,7 +452,7 @@ static inline struct device_node *xlate_iomm_address(
492 * iSeries_Read_Word = Read Word (16 bit) 452 * iSeries_Read_Word = Read Word (16 bit)
493 * iSeries_Read_Long = Read Long (32 bit) 453 * iSeries_Read_Long = Read Long (32 bit)
494 */ 454 */
495u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress) 455static u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress)
496{ 456{
497 u64 BarOffset; 457 u64 BarOffset;
498 u64 dsa; 458 u64 dsa;
@@ -519,9 +479,8 @@ u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress)
519 479
520 return (u8)ret.value; 480 return (u8)ret.value;
521} 481}
522EXPORT_SYMBOL(iSeries_Read_Byte);
523 482
524u16 iSeries_Read_Word(const volatile void __iomem *IoAddress) 483static u16 iSeries_Read_Word(const volatile void __iomem *IoAddress)
525{ 484{
526 u64 BarOffset; 485 u64 BarOffset;
527 u64 dsa; 486 u64 dsa;
@@ -549,9 +508,8 @@ u16 iSeries_Read_Word(const volatile void __iomem *IoAddress)
549 508
550 return swab16((u16)ret.value); 509 return swab16((u16)ret.value);
551} 510}
552EXPORT_SYMBOL(iSeries_Read_Word);
553 511
554u32 iSeries_Read_Long(const volatile void __iomem *IoAddress) 512static u32 iSeries_Read_Long(const volatile void __iomem *IoAddress)
555{ 513{
556 u64 BarOffset; 514 u64 BarOffset;
557 u64 dsa; 515 u64 dsa;
@@ -579,7 +537,6 @@ u32 iSeries_Read_Long(const volatile void __iomem *IoAddress)
579 537
580 return swab32((u32)ret.value); 538 return swab32((u32)ret.value);
581} 539}
582EXPORT_SYMBOL(iSeries_Read_Long);
583 540
584/* 541/*
585 * Write MM I/O Instructions for the iSeries 542 * Write MM I/O Instructions for the iSeries
@@ -588,7 +545,7 @@ EXPORT_SYMBOL(iSeries_Read_Long);
588 * iSeries_Write_Word = Write Word(16 bit) 545 * iSeries_Write_Word = Write Word(16 bit)
589 * iSeries_Write_Long = Write Long(32 bit) 546 * iSeries_Write_Long = Write Long(32 bit)
590 */ 547 */
591void iSeries_Write_Byte(u8 data, volatile void __iomem *IoAddress) 548static void iSeries_Write_Byte(u8 data, volatile void __iomem *IoAddress)
592{ 549{
593 u64 BarOffset; 550 u64 BarOffset;
594 u64 dsa; 551 u64 dsa;
@@ -613,9 +570,8 @@ void iSeries_Write_Byte(u8 data, volatile void __iomem *IoAddress)
613 rc = HvCall4(HvCallPciBarStore8, dsa, BarOffset, data, 0); 570 rc = HvCall4(HvCallPciBarStore8, dsa, BarOffset, data, 0);
614 } while (CheckReturnCode("WWB", DevNode, &retry, rc) != 0); 571 } while (CheckReturnCode("WWB", DevNode, &retry, rc) != 0);
615} 572}
616EXPORT_SYMBOL(iSeries_Write_Byte);
617 573
618void iSeries_Write_Word(u16 data, volatile void __iomem *IoAddress) 574static void iSeries_Write_Word(u16 data, volatile void __iomem *IoAddress)
619{ 575{
620 u64 BarOffset; 576 u64 BarOffset;
621 u64 dsa; 577 u64 dsa;
@@ -640,9 +596,8 @@ void iSeries_Write_Word(u16 data, volatile void __iomem *IoAddress)
640 rc = HvCall4(HvCallPciBarStore16, dsa, BarOffset, swab16(data), 0); 596 rc = HvCall4(HvCallPciBarStore16, dsa, BarOffset, swab16(data), 0);
641 } while (CheckReturnCode("WWW", DevNode, &retry, rc) != 0); 597 } while (CheckReturnCode("WWW", DevNode, &retry, rc) != 0);
642} 598}
643EXPORT_SYMBOL(iSeries_Write_Word);
644 599
645void iSeries_Write_Long(u32 data, volatile void __iomem *IoAddress) 600static void iSeries_Write_Long(u32 data, volatile void __iomem *IoAddress)
646{ 601{
647 u64 BarOffset; 602 u64 BarOffset;
648 u64 dsa; 603 u64 dsa;
@@ -667,4 +622,224 @@ void iSeries_Write_Long(u32 data, volatile void __iomem *IoAddress)
667 rc = HvCall4(HvCallPciBarStore32, dsa, BarOffset, swab32(data), 0); 622 rc = HvCall4(HvCallPciBarStore32, dsa, BarOffset, swab32(data), 0);
668 } while (CheckReturnCode("WWL", DevNode, &retry, rc) != 0); 623 } while (CheckReturnCode("WWL", DevNode, &retry, rc) != 0);
669} 624}
670EXPORT_SYMBOL(iSeries_Write_Long); 625
626extern unsigned char __raw_readb(const volatile void __iomem *addr)
627{
628 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
629
630 return *(volatile unsigned char __force *)addr;
631}
632EXPORT_SYMBOL(__raw_readb);
633
634extern unsigned short __raw_readw(const volatile void __iomem *addr)
635{
636 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
637
638 return *(volatile unsigned short __force *)addr;
639}
640EXPORT_SYMBOL(__raw_readw);
641
642extern unsigned int __raw_readl(const volatile void __iomem *addr)
643{
644 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
645
646 return *(volatile unsigned int __force *)addr;
647}
648EXPORT_SYMBOL(__raw_readl);
649
650extern unsigned long __raw_readq(const volatile void __iomem *addr)
651{
652 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
653
654 return *(volatile unsigned long __force *)addr;
655}
656EXPORT_SYMBOL(__raw_readq);
657
658extern void __raw_writeb(unsigned char v, volatile void __iomem *addr)
659{
660 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
661
662 *(volatile unsigned char __force *)addr = v;
663}
664EXPORT_SYMBOL(__raw_writeb);
665
666extern void __raw_writew(unsigned short v, volatile void __iomem *addr)
667{
668 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
669
670 *(volatile unsigned short __force *)addr = v;
671}
672EXPORT_SYMBOL(__raw_writew);
673
674extern void __raw_writel(unsigned int v, volatile void __iomem *addr)
675{
676 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
677
678 *(volatile unsigned int __force *)addr = v;
679}
680EXPORT_SYMBOL(__raw_writel);
681
682extern void __raw_writeq(unsigned long v, volatile void __iomem *addr)
683{
684 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
685
686 *(volatile unsigned long __force *)addr = v;
687}
688EXPORT_SYMBOL(__raw_writeq);
689
690int in_8(const volatile unsigned char __iomem *addr)
691{
692 if (firmware_has_feature(FW_FEATURE_ISERIES))
693 return iSeries_Read_Byte(addr);
694 return __in_8(addr);
695}
696EXPORT_SYMBOL(in_8);
697
698void out_8(volatile unsigned char __iomem *addr, int val)
699{
700 if (firmware_has_feature(FW_FEATURE_ISERIES))
701 iSeries_Write_Byte(val, addr);
702 else
703 __out_8(addr, val);
704}
705EXPORT_SYMBOL(out_8);
706
707int in_le16(const volatile unsigned short __iomem *addr)
708{
709 if (firmware_has_feature(FW_FEATURE_ISERIES))
710 return iSeries_Read_Word(addr);
711 return __in_le16(addr);
712}
713EXPORT_SYMBOL(in_le16);
714
715int in_be16(const volatile unsigned short __iomem *addr)
716{
717 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
718
719 return __in_be16(addr);
720}
721EXPORT_SYMBOL(in_be16);
722
723void out_le16(volatile unsigned short __iomem *addr, int val)
724{
725 if (firmware_has_feature(FW_FEATURE_ISERIES))
726 iSeries_Write_Word(val, addr);
727 else
728 __out_le16(addr, val);
729}
730EXPORT_SYMBOL(out_le16);
731
732void out_be16(volatile unsigned short __iomem *addr, int val)
733{
734 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
735
736 __out_be16(addr, val);
737}
738EXPORT_SYMBOL(out_be16);
739
740unsigned in_le32(const volatile unsigned __iomem *addr)
741{
742 if (firmware_has_feature(FW_FEATURE_ISERIES))
743 return iSeries_Read_Long(addr);
744 return __in_le32(addr);
745}
746EXPORT_SYMBOL(in_le32);
747
748unsigned in_be32(const volatile unsigned __iomem *addr)
749{
750 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
751
752 return __in_be32(addr);
753}
754EXPORT_SYMBOL(in_be32);
755
756void out_le32(volatile unsigned __iomem *addr, int val)
757{
758 if (firmware_has_feature(FW_FEATURE_ISERIES))
759 iSeries_Write_Long(val, addr);
760 else
761 __out_le32(addr, val);
762}
763EXPORT_SYMBOL(out_le32);
764
765void out_be32(volatile unsigned __iomem *addr, int val)
766{
767 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
768
769 __out_be32(addr, val);
770}
771EXPORT_SYMBOL(out_be32);
772
773unsigned long in_le64(const volatile unsigned long __iomem *addr)
774{
775 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
776
777 return __in_le64(addr);
778}
779EXPORT_SYMBOL(in_le64);
780
781unsigned long in_be64(const volatile unsigned long __iomem *addr)
782{
783 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
784
785 return __in_be64(addr);
786}
787EXPORT_SYMBOL(in_be64);
788
789void out_le64(volatile unsigned long __iomem *addr, unsigned long val)
790{
791 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
792
793 __out_le64(addr, val);
794}
795EXPORT_SYMBOL(out_le64);
796
797void out_be64(volatile unsigned long __iomem *addr, unsigned long val)
798{
799 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
800
801 __out_be64(addr, val);
802}
803EXPORT_SYMBOL(out_be64);
804
805void memset_io(volatile void __iomem *addr, int c, unsigned long n)
806{
807 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
808 volatile char __iomem *d = addr;
809
810 while (n-- > 0) {
811 iSeries_Write_Byte(c, d++);
812 }
813 } else
814 eeh_memset_io(addr, c, n);
815}
816EXPORT_SYMBOL(memset_io);
817
818void memcpy_fromio(void *dest, const volatile void __iomem *src,
819 unsigned long n)
820{
821 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
822 char *d = dest;
823 const volatile char __iomem *s = src;
824
825 while (n-- > 0) {
826 *d++ = iSeries_Read_Byte(s++);
827 }
828 } else
829 eeh_memcpy_fromio(dest, src, n);
830}
831EXPORT_SYMBOL(memcpy_fromio);
832
833void memcpy_toio(volatile void __iomem *dest, const void *src, unsigned long n)
834{
835 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
836 const char *s = src;
837 volatile char __iomem *d = dest;
838
839 while (n-- > 0) {
840 iSeries_Write_Byte(*s++, d++);
841 }
842 } else
843 eeh_memcpy_toio(dest, src, n);
844}
845EXPORT_SYMBOL(memcpy_toio);
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index c9605d773a77..7f1953066ff8 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -59,6 +59,7 @@
59#include "irq.h" 59#include "irq.h"
60#include "vpd_areas.h" 60#include "vpd_areas.h"
61#include "processor_vpd.h" 61#include "processor_vpd.h"
62#include "it_lp_naca.h"
62#include "main_store.h" 63#include "main_store.h"
63#include "call_sm.h" 64#include "call_sm.h"
64#include "call_hpt.h" 65#include "call_hpt.h"
diff --git a/arch/powerpc/platforms/iseries/viopath.c b/arch/powerpc/platforms/iseries/viopath.c
index 622a30149b48..9baa4ee82592 100644
--- a/arch/powerpc/platforms/iseries/viopath.c
+++ b/arch/powerpc/platforms/iseries/viopath.c
@@ -41,8 +41,8 @@
41 41
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44#include <asm/prom.h>
44#include <asm/iseries/hv_types.h> 45#include <asm/iseries/hv_types.h>
45#include <asm/iseries/it_exp_vpd_panel.h>
46#include <asm/iseries/hv_lp_event.h> 46#include <asm/iseries/hv_lp_event.h>
47#include <asm/iseries/hv_lp_config.h> 47#include <asm/iseries/hv_lp_config.h>
48#include <asm/iseries/mf.h> 48#include <asm/iseries/mf.h>
@@ -116,6 +116,8 @@ static int proc_viopath_show(struct seq_file *m, void *v)
116 dma_addr_t handle; 116 dma_addr_t handle;
117 HvLpEvent_Rc hvrc; 117 HvLpEvent_Rc hvrc;
118 DECLARE_MUTEX_LOCKED(Semaphore); 118 DECLARE_MUTEX_LOCKED(Semaphore);
119 struct device_node *node;
120 const char *sysid;
119 121
120 buf = kmalloc(HW_PAGE_SIZE, GFP_KERNEL); 122 buf = kmalloc(HW_PAGE_SIZE, GFP_KERNEL);
121 if (!buf) 123 if (!buf)
@@ -143,20 +145,26 @@ static int proc_viopath_show(struct seq_file *m, void *v)
143 145
144 buf[HW_PAGE_SIZE-1] = '\0'; 146 buf[HW_PAGE_SIZE-1] = '\0';
145 seq_printf(m, "%s", buf); 147 seq_printf(m, "%s", buf);
146 seq_printf(m, "AVAILABLE_VETH=%x\n", vlanMap);
147 seq_printf(m, "SRLNBR=%c%c%c%c%c%c%c\n",
148 e2a(xItExtVpdPanel.mfgID[2]),
149 e2a(xItExtVpdPanel.mfgID[3]),
150 e2a(xItExtVpdPanel.systemSerial[1]),
151 e2a(xItExtVpdPanel.systemSerial[2]),
152 e2a(xItExtVpdPanel.systemSerial[3]),
153 e2a(xItExtVpdPanel.systemSerial[4]),
154 e2a(xItExtVpdPanel.systemSerial[5]));
155 148
156 dma_unmap_single(iSeries_vio_dev, handle, HW_PAGE_SIZE, 149 dma_unmap_single(iSeries_vio_dev, handle, HW_PAGE_SIZE,
157 DMA_FROM_DEVICE); 150 DMA_FROM_DEVICE);
158 kfree(buf); 151 kfree(buf);
159 152
153 seq_printf(m, "AVAILABLE_VETH=%x\n", vlanMap);
154
155 node = of_find_node_by_path("/");
156 sysid = NULL;
157 if (node != NULL)
158 sysid = get_property(node, "system-id", NULL);
159
160 if (sysid == NULL)
161 seq_printf(m, "SRLNBR=<UNKNOWN>\n");
162 else
163 /* Skip "IBM," on front of serial number, see dt.c */
164 seq_printf(m, "SRLNBR=%s\n", sysid + 4);
165
166 of_node_put(node);
167
160 return 0; 168 return 0;
161} 169}
162 170
diff --git a/arch/powerpc/platforms/iseries/vpdinfo.c b/arch/powerpc/platforms/iseries/vpdinfo.c
index 23a6d1e5b429..9f83878a0c2e 100644
--- a/arch/powerpc/platforms/iseries/vpdinfo.c
+++ b/arch/powerpc/platforms/iseries/vpdinfo.c
@@ -188,7 +188,7 @@ static void __init iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen,
188{ 188{
189 u8 *TagPtr = VpdData; 189 u8 *TagPtr = VpdData;
190 int DataLen = VpdDataLen - 3; 190 int DataLen = VpdDataLen - 3;
191 u8 PhbId; 191 u8 PhbId = 0xff;
192 192
193 while ((*TagPtr != VpdEndOfAreaTag) && (DataLen > 0)) { 193 while ((*TagPtr != VpdEndOfAreaTag) && (DataLen > 0)) {
194 int AreaLen = *(TagPtr + 1) + (*(TagPtr + 2) * 256); 194 int AreaLen = *(TagPtr + 1) + (*(TagPtr + 2) * 256);
@@ -205,15 +205,16 @@ static void __init iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen,
205 } 205 }
206} 206}
207 207
208static void __init iSeries_Get_Location_Code(u16 bus, HvAgentId agent, 208static int __init iSeries_Get_Location_Code(u16 bus, HvAgentId agent,
209 u8 *frame, char card[4]) 209 u8 *frame, char card[4])
210{ 210{
211 int status = 0;
211 int BusVpdLen = 0; 212 int BusVpdLen = 0;
212 u8 *BusVpdPtr = kmalloc(BUS_VPDSIZE, GFP_KERNEL); 213 u8 *BusVpdPtr = kmalloc(BUS_VPDSIZE, GFP_KERNEL);
213 214
214 if (BusVpdPtr == NULL) { 215 if (BusVpdPtr == NULL) {
215 printk("PCI: Bus VPD Buffer allocation failure.\n"); 216 printk("PCI: Bus VPD Buffer allocation failure.\n");
216 return; 217 return 0;
217 } 218 }
218 BusVpdLen = HvCallPci_getBusVpd(bus, iseries_hv_addr(BusVpdPtr), 219 BusVpdLen = HvCallPci_getBusVpd(bus, iseries_hv_addr(BusVpdPtr),
219 BUS_VPDSIZE); 220 BUS_VPDSIZE);
@@ -228,8 +229,10 @@ static void __init iSeries_Get_Location_Code(u16 bus, HvAgentId agent,
228 goto out_free; 229 goto out_free;
229 } 230 }
230 iSeries_Parse_Vpd(BusVpdPtr, BusVpdLen, agent, frame, card); 231 iSeries_Parse_Vpd(BusVpdPtr, BusVpdLen, agent, frame, card);
232 status = 1;
231out_free: 233out_free:
232 kfree(BusVpdPtr); 234 kfree(BusVpdPtr);
235 return status;
233} 236}
234 237
235/* 238/*
@@ -246,7 +249,7 @@ void __init iSeries_Device_Information(struct pci_dev *PciDev, int count)
246 struct device_node *DevNode = PciDev->sysdata; 249 struct device_node *DevNode = PciDev->sysdata;
247 struct pci_dn *pdn; 250 struct pci_dn *pdn;
248 u16 bus; 251 u16 bus;
249 u8 frame; 252 u8 frame = 0;
250 char card[4]; 253 char card[4];
251 HvSubBusNumber subbus; 254 HvSubBusNumber subbus;
252 HvAgentId agent; 255 HvAgentId agent;
@@ -262,10 +265,11 @@ void __init iSeries_Device_Information(struct pci_dev *PciDev, int count)
262 subbus = pdn->bussubno; 265 subbus = pdn->bussubno;
263 agent = ISERIES_PCI_AGENTID(ISERIES_GET_DEVICE_FROM_SUBBUS(subbus), 266 agent = ISERIES_PCI_AGENTID(ISERIES_GET_DEVICE_FROM_SUBBUS(subbus),
264 ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus)); 267 ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus));
265 iSeries_Get_Location_Code(bus, agent, &frame, card);
266 268
267 printk("%d. PCI: Bus%3d, Device%3d, Vendor %04X Frame%3d, Card %4s ", 269 if (iSeries_Get_Location_Code(bus, agent, &frame, card)) {
268 count, bus, PCI_SLOT(PciDev->devfn), PciDev->vendor, 270 printk("%d. PCI: Bus%3d, Device%3d, Vendor %04X Frame%3d, "
269 frame, card); 271 "Card %4s 0x%04X\n", count, bus,
270 printk("0x%04X\n", (int)(PciDev->class >> 8)); 272 PCI_SLOT(PciDev->devfn), PciDev->vendor, frame,
273 card, (int)(PciDev->class >> 8));
274 }
271} 275}
diff --git a/arch/powerpc/platforms/maple/pci.c b/arch/powerpc/platforms/maple/pci.c
index 63a1670d3bfd..c3aa46b8e2b9 100644
--- a/arch/powerpc/platforms/maple/pci.c
+++ b/arch/powerpc/platforms/maple/pci.c
@@ -38,16 +38,16 @@ static struct pci_controller *u3_agp, *u3_ht;
38static int __init fixup_one_level_bus_range(struct device_node *node, int higher) 38static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
39{ 39{
40 for (; node != 0;node = node->sibling) { 40 for (; node != 0;node = node->sibling) {
41 int * bus_range; 41 const int *bus_range;
42 unsigned int *class_code; 42 const unsigned int *class_code;
43 int len; 43 int len;
44 44
45 /* For PCI<->PCI bridges or CardBus bridges, we go down */ 45 /* For PCI<->PCI bridges or CardBus bridges, we go down */
46 class_code = (unsigned int *) get_property(node, "class-code", NULL); 46 class_code = get_property(node, "class-code", NULL);
47 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 47 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
48 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) 48 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
49 continue; 49 continue;
50 bus_range = (int *) get_property(node, "bus-range", &len); 50 bus_range = get_property(node, "bus-range", &len);
51 if (bus_range != NULL && len > 2 * sizeof(int)) { 51 if (bus_range != NULL && len > 2 * sizeof(int)) {
52 if (bus_range[1] > higher) 52 if (bus_range[1] > higher)
53 higher = bus_range[1]; 53 higher = bus_range[1];
@@ -65,30 +65,36 @@ static int __init fixup_one_level_bus_range(struct device_node *node, int higher
65 */ 65 */
66static void __init fixup_bus_range(struct device_node *bridge) 66static void __init fixup_bus_range(struct device_node *bridge)
67{ 67{
68 int * bus_range; 68 int *bus_range;
69 struct property *prop;
69 int len; 70 int len;
70 71
71 /* Lookup the "bus-range" property for the hose */ 72 /* Lookup the "bus-range" property for the hose */
72 bus_range = (int *) get_property(bridge, "bus-range", &len); 73 prop = of_find_property(bridge, "bus-range", &len);
73 if (bus_range == NULL || len < 2 * sizeof(int)) { 74 if (prop == NULL || prop->value == NULL || len < 2 * sizeof(int)) {
74 printk(KERN_WARNING "Can't get bus-range for %s\n", 75 printk(KERN_WARNING "Can't get bus-range for %s\n",
75 bridge->full_name); 76 bridge->full_name);
76 return; 77 return;
77 } 78 }
79 bus_range = (int *)prop->value;
78 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]); 80 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
79} 81}
80 82
81 83
82#define U3_AGP_CFA0(devfn, off) \ 84static unsigned long u3_agp_cfa0(u8 devfn, u8 off)
83 ((1 << (unsigned long)PCI_SLOT(dev_fn)) \ 85{
84 | (((unsigned long)PCI_FUNC(dev_fn)) << 8) \ 86 return (1 << (unsigned long)PCI_SLOT(devfn)) |
85 | (((unsigned long)(off)) & 0xFCUL)) 87 ((unsigned long)PCI_FUNC(devfn) << 8) |
88 ((unsigned long)off & 0xFCUL);
89}
86 90
87#define U3_AGP_CFA1(bus, devfn, off) \ 91static unsigned long u3_agp_cfa1(u8 bus, u8 devfn, u8 off)
88 ((((unsigned long)(bus)) << 16) \ 92{
89 |(((unsigned long)(devfn)) << 8) \ 93 return ((unsigned long)bus << 16) |
90 |(((unsigned long)(off)) & 0xFCUL) \ 94 ((unsigned long)devfn << 8) |
91 |1UL) 95 ((unsigned long)off & 0xFCUL) |
96 1UL;
97}
92 98
93static unsigned long u3_agp_cfg_access(struct pci_controller* hose, 99static unsigned long u3_agp_cfg_access(struct pci_controller* hose,
94 u8 bus, u8 dev_fn, u8 offset) 100 u8 bus, u8 dev_fn, u8 offset)
@@ -98,9 +104,9 @@ static unsigned long u3_agp_cfg_access(struct pci_controller* hose,
98 if (bus == hose->first_busno) { 104 if (bus == hose->first_busno) {
99 if (dev_fn < (11 << 3)) 105 if (dev_fn < (11 << 3))
100 return 0; 106 return 0;
101 caddr = U3_AGP_CFA0(dev_fn, offset); 107 caddr = u3_agp_cfa0(dev_fn, offset);
102 } else 108 } else
103 caddr = U3_AGP_CFA1(bus, dev_fn, offset); 109 caddr = u3_agp_cfa1(bus, dev_fn, offset);
104 110
105 /* Uninorth will return garbage if we don't read back the value ! */ 111 /* Uninorth will return garbage if we don't read back the value ! */
106 do { 112 do {
@@ -182,13 +188,15 @@ static struct pci_ops u3_agp_pci_ops =
182 u3_agp_write_config 188 u3_agp_write_config
183}; 189};
184 190
191static unsigned long u3_ht_cfa0(u8 devfn, u8 off)
192{
193 return (devfn << 8) | off;
194}
185 195
186#define U3_HT_CFA0(devfn, off) \ 196static unsigned long u3_ht_cfa1(u8 bus, u8 devfn, u8 off)
187 ((((unsigned long)devfn) << 8) | offset) 197{
188#define U3_HT_CFA1(bus, devfn, off) \ 198 return u3_ht_cfa0(devfn, off) + (bus << 16) + 0x01000000UL;
189 (U3_HT_CFA0(devfn, off) \ 199}
190 + (((unsigned long)bus) << 16) \
191 + 0x01000000UL)
192 200
193static unsigned long u3_ht_cfg_access(struct pci_controller* hose, 201static unsigned long u3_ht_cfg_access(struct pci_controller* hose,
194 u8 bus, u8 devfn, u8 offset) 202 u8 bus, u8 devfn, u8 offset)
@@ -196,9 +204,9 @@ static unsigned long u3_ht_cfg_access(struct pci_controller* hose,
196 if (bus == hose->first_busno) { 204 if (bus == hose->first_busno) {
197 if (PCI_SLOT(devfn) == 0) 205 if (PCI_SLOT(devfn) == 0)
198 return 0; 206 return 0;
199 return ((unsigned long)hose->cfg_data) + U3_HT_CFA0(devfn, offset); 207 return ((unsigned long)hose->cfg_data) + u3_ht_cfa0(devfn, offset);
200 } else 208 } else
201 return ((unsigned long)hose->cfg_data) + U3_HT_CFA1(bus, devfn, offset); 209 return ((unsigned long)hose->cfg_data) + u3_ht_cfa1(bus, devfn, offset);
202} 210}
203 211
204static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn, 212static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,
@@ -211,6 +219,9 @@ static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,
211 if (hose == NULL) 219 if (hose == NULL)
212 return PCIBIOS_DEVICE_NOT_FOUND; 220 return PCIBIOS_DEVICE_NOT_FOUND;
213 221
222 if (offset > 0xff)
223 return PCIBIOS_BAD_REGISTER_NUMBER;
224
214 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset); 225 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
215 if (!addr) 226 if (!addr)
216 return PCIBIOS_DEVICE_NOT_FOUND; 227 return PCIBIOS_DEVICE_NOT_FOUND;
@@ -243,6 +254,9 @@ static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn,
243 if (hose == NULL) 254 if (hose == NULL)
244 return PCIBIOS_DEVICE_NOT_FOUND; 255 return PCIBIOS_DEVICE_NOT_FOUND;
245 256
257 if (offset > 0xff)
258 return PCIBIOS_BAD_REGISTER_NUMBER;
259
246 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset); 260 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
247 if (!addr) 261 if (!addr)
248 return PCIBIOS_DEVICE_NOT_FOUND; 262 return PCIBIOS_DEVICE_NOT_FOUND;
@@ -314,12 +328,12 @@ static int __init add_bridge(struct device_node *dev)
314 int len; 328 int len;
315 struct pci_controller *hose; 329 struct pci_controller *hose;
316 char* disp_name; 330 char* disp_name;
317 int *bus_range; 331 const int *bus_range;
318 int primary = 1; 332 int primary = 1;
319 333
320 DBG("Adding PCI host bridge %s\n", dev->full_name); 334 DBG("Adding PCI host bridge %s\n", dev->full_name);
321 335
322 bus_range = (int *) get_property(dev, "bus-range", &len); 336 bus_range = get_property(dev, "bus-range", &len);
323 if (bus_range == NULL || len < 2 * sizeof(int)) { 337 if (bus_range == NULL || len < 2 * sizeof(int)) {
324 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n", 338 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",
325 dev->full_name); 339 dev->full_name);
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 57567dfb9819..fe6b9bff61b9 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -99,8 +99,7 @@ static unsigned long maple_find_nvram_base(void)
99static void maple_restart(char *cmd) 99static void maple_restart(char *cmd)
100{ 100{
101 unsigned int maple_nvram_base; 101 unsigned int maple_nvram_base;
102 unsigned int maple_nvram_offset; 102 const unsigned int *maple_nvram_offset, *maple_nvram_command;
103 unsigned int maple_nvram_command;
104 struct device_node *sp; 103 struct device_node *sp;
105 104
106 maple_nvram_base = maple_find_nvram_base(); 105 maple_nvram_base = maple_find_nvram_base();
@@ -113,14 +112,12 @@ static void maple_restart(char *cmd)
113 printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); 112 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
114 goto fail; 113 goto fail;
115 } 114 }
116 maple_nvram_offset = *(unsigned int*) get_property(sp, 115 maple_nvram_offset = get_property(sp, "restart-addr", NULL);
117 "restart-addr", NULL); 116 maple_nvram_command = get_property(sp, "restart-value", NULL);
118 maple_nvram_command = *(unsigned int*) get_property(sp,
119 "restart-value", NULL);
120 of_node_put(sp); 117 of_node_put(sp);
121 118
122 /* send command */ 119 /* send command */
123 outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset); 120 outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset);
124 for (;;) ; 121 for (;;) ;
125 fail: 122 fail:
126 printk(KERN_EMERG "Maple: Manual Restart Required\n"); 123 printk(KERN_EMERG "Maple: Manual Restart Required\n");
@@ -129,8 +126,7 @@ static void maple_restart(char *cmd)
129static void maple_power_off(void) 126static void maple_power_off(void)
130{ 127{
131 unsigned int maple_nvram_base; 128 unsigned int maple_nvram_base;
132 unsigned int maple_nvram_offset; 129 const unsigned int *maple_nvram_offset, *maple_nvram_command;
133 unsigned int maple_nvram_command;
134 struct device_node *sp; 130 struct device_node *sp;
135 131
136 maple_nvram_base = maple_find_nvram_base(); 132 maple_nvram_base = maple_find_nvram_base();
@@ -143,14 +139,12 @@ static void maple_power_off(void)
143 printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); 139 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
144 goto fail; 140 goto fail;
145 } 141 }
146 maple_nvram_offset = *(unsigned int*) get_property(sp, 142 maple_nvram_offset = get_property(sp, "power-off-addr", NULL);
147 "power-off-addr", NULL); 143 maple_nvram_command = get_property(sp, "power-off-value", NULL);
148 maple_nvram_command = *(unsigned int*) get_property(sp,
149 "power-off-value", NULL);
150 of_node_put(sp); 144 of_node_put(sp);
151 145
152 /* send command */ 146 /* send command */
153 outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset); 147 outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset);
154 for (;;) ; 148 for (;;) ;
155 fail: 149 fail:
156 printk(KERN_EMERG "Maple: Manual Power-Down Required\n"); 150 printk(KERN_EMERG "Maple: Manual Power-Down Required\n");
@@ -211,7 +205,7 @@ static void __init maple_init_early(void)
211static void __init maple_init_IRQ(void) 205static void __init maple_init_IRQ(void)
212{ 206{
213 struct device_node *root, *np, *mpic_node = NULL; 207 struct device_node *root, *np, *mpic_node = NULL;
214 unsigned int *opprop; 208 const unsigned int *opprop;
215 unsigned long openpic_addr = 0; 209 unsigned long openpic_addr = 0;
216 int naddr, n, i, opplen, has_isus = 0; 210 int naddr, n, i, opplen, has_isus = 0;
217 struct mpic *mpic; 211 struct mpic *mpic;
@@ -241,8 +235,7 @@ static void __init maple_init_IRQ(void)
241 /* Find address list in /platform-open-pic */ 235 /* Find address list in /platform-open-pic */
242 root = of_find_node_by_path("/"); 236 root = of_find_node_by_path("/");
243 naddr = prom_n_addr_cells(root); 237 naddr = prom_n_addr_cells(root);
244 opprop = (unsigned int *) get_property(root, "platform-open-pic", 238 opprop = get_property(root, "platform-open-pic", &opplen);
245 &opplen);
246 if (opprop != 0) { 239 if (opprop != 0) {
247 openpic_addr = of_read_number(opprop, naddr); 240 openpic_addr = of_read_number(opprop, naddr);
248 has_isus = (opplen > naddr); 241 has_isus = (opplen > naddr);
diff --git a/arch/powerpc/platforms/pasemi/Makefile b/arch/powerpc/platforms/pasemi/Makefile
new file mode 100644
index 000000000000..1be1a993c5f5
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/Makefile
@@ -0,0 +1 @@
obj-y += setup.o pci.o time.o
diff --git a/arch/powerpc/platforms/pasemi/pasemi.h b/arch/powerpc/platforms/pasemi/pasemi.h
new file mode 100644
index 000000000000..fd71d72736b2
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/pasemi.h
@@ -0,0 +1,8 @@
1#ifndef _PASEMI_PASEMI_H
2#define _PASEMI_PASEMI_H
3
4extern unsigned long pas_get_boot_time(void);
5extern void pas_pci_init(void);
6extern void pas_pcibios_fixup(void);
7
8#endif /* _PASEMI_PASEMI_H */
diff --git a/arch/powerpc/platforms/pasemi/pci.c b/arch/powerpc/platforms/pasemi/pci.c
new file mode 100644
index 000000000000..4679c5230413
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/pci.c
@@ -0,0 +1,198 @@
1/*
2 * Copyright (C) 2006 PA Semi, Inc
3 *
4 * Authors: Kip Walker, PA Semi
5 * Olof Johansson, PA Semi
6 *
7 * Maintained by: Olof Johansson <olof@lixom.net>
8 *
9 * Based on arch/powerpc/platforms/maple/pci.c
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25
26#include <linux/kernel.h>
27#include <linux/pci.h>
28
29#include <asm/pci-bridge.h>
30#include <asm/machdep.h>
31
32#include <asm/ppc-pci.h>
33
34#define PA_PXP_CFA(bus, devfn, off) (((bus) << 20) | ((devfn) << 12) | (off))
35
36#define CONFIG_OFFSET_VALID(off) ((off) < 4096)
37
38static unsigned long pa_pxp_cfg_addr(struct pci_controller *hose,
39 u8 bus, u8 devfn, int offset)
40{
41 return ((unsigned long)hose->cfg_data) + PA_PXP_CFA(bus, devfn, offset);
42}
43
44static int pa_pxp_read_config(struct pci_bus *bus, unsigned int devfn,
45 int offset, int len, u32 *val)
46{
47 struct pci_controller *hose;
48 unsigned long addr;
49
50 hose = pci_bus_to_host(bus);
51 if (!hose)
52 return PCIBIOS_DEVICE_NOT_FOUND;
53
54 if (!CONFIG_OFFSET_VALID(offset))
55 return PCIBIOS_BAD_REGISTER_NUMBER;
56
57 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset);
58
59 /*
60 * Note: the caller has already checked that offset is
61 * suitably aligned and that len is 1, 2 or 4.
62 */
63 switch (len) {
64 case 1:
65 *val = in_8((u8 *)addr);
66 break;
67 case 2:
68 *val = in_le16((u16 *)addr);
69 break;
70 default:
71 *val = in_le32((u32 *)addr);
72 break;
73 }
74
75 return PCIBIOS_SUCCESSFUL;
76}
77
78static int pa_pxp_write_config(struct pci_bus *bus, unsigned int devfn,
79 int offset, int len, u32 val)
80{
81 struct pci_controller *hose;
82 unsigned long addr;
83
84 hose = pci_bus_to_host(bus);
85 if (!hose)
86 return PCIBIOS_DEVICE_NOT_FOUND;
87
88 if (!CONFIG_OFFSET_VALID(offset))
89 return PCIBIOS_BAD_REGISTER_NUMBER;
90
91 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset);
92
93 /*
94 * Note: the caller has already checked that offset is
95 * suitably aligned and that len is 1, 2 or 4.
96 */
97 switch (len) {
98 case 1:
99 out_8((u8 *)addr, val);
100 (void) in_8((u8 *)addr);
101 break;
102 case 2:
103 out_le16((u16 *)addr, val);
104 (void) in_le16((u16 *)addr);
105 break;
106 default:
107 out_le32((u32 *)addr, val);
108 (void) in_le32((u32 *)addr);
109 break;
110 }
111 return PCIBIOS_SUCCESSFUL;
112}
113
114static struct pci_ops pa_pxp_ops = {
115 pa_pxp_read_config,
116 pa_pxp_write_config,
117};
118
119static void __init setup_pa_pxp(struct pci_controller *hose)
120{
121 hose->ops = &pa_pxp_ops;
122 hose->cfg_data = ioremap(0xe0000000, 0x10000000);
123}
124
125static int __init add_bridge(struct device_node *dev)
126{
127 struct pci_controller *hose;
128
129 pr_debug("Adding PCI host bridge %s\n", dev->full_name);
130
131 hose = pcibios_alloc_controller(dev);
132 if (!hose)
133 return -ENOMEM;
134
135 hose->first_busno = 0;
136 hose->last_busno = 0xff;
137
138 setup_pa_pxp(hose);
139
140 printk(KERN_INFO "Found PA-PXP PCI host bridge.\n");
141
142 /* Interpret the "ranges" property */
143 /* This also maps the I/O region and sets isa_io/mem_base */
144 pci_process_bridge_OF_ranges(hose, dev, 1);
145 pci_setup_phb_io(hose, 1);
146
147 return 0;
148}
149
150
151void __init pas_pcibios_fixup(void)
152{
153 struct pci_dev *dev = NULL;
154
155 for_each_pci_dev(dev)
156 pci_read_irq_line(dev);
157}
158
159static void __init pas_fixup_phb_resources(void)
160{
161 struct pci_controller *hose, *tmp;
162
163 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
164 unsigned long offset = (unsigned long)hose->io_base_virt - pci_io_base;
165 hose->io_resource.start += offset;
166 hose->io_resource.end += offset;
167 printk(KERN_INFO "PCI Host %d, io start: %lx; io end: %lx\n",
168 hose->global_number,
169 hose->io_resource.start, hose->io_resource.end);
170 }
171}
172
173
174void __init pas_pci_init(void)
175{
176 struct device_node *np, *root;
177
178 root = of_find_node_by_path("/");
179 if (!root) {
180 printk(KERN_CRIT "pas_pci_init: can't find root "
181 "of device tree\n");
182 return;
183 }
184
185 for (np = NULL; (np = of_get_next_child(root, np)) != NULL;)
186 if (np->name && !strcmp(np->name, "pxp") && !add_bridge(np))
187 of_node_get(np);
188
189 of_node_put(root);
190
191 pas_fixup_phb_resources();
192
193 /* Setup the linkage between OF nodes and PHBs */
194 pci_devs_phb_init();
195
196 /* Use the common resource allocation mechanism */
197 pci_probe_only = 1;
198}
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
new file mode 100644
index 000000000000..628482671c15
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -0,0 +1,188 @@
1/*
2 * Copyright (C) 2006 PA Semi, Inc
3 *
4 * Authors: Kip Walker, PA Semi
5 * Olof Johansson, PA Semi
6 *
7 * Maintained by: Olof Johansson <olof@lixom.net>
8 *
9 * Based on arch/powerpc/platforms/maple/setup.c
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#include <linux/config.h>
26#include <linux/errno.h>
27#include <linux/kernel.h>
28#include <linux/delay.h>
29#include <linux/console.h>
30
31#include <asm/prom.h>
32#include <asm/system.h>
33#include <asm/iommu.h>
34#include <asm/machdep.h>
35#include <asm/mpic.h>
36#include <asm/smp.h>
37#include <asm/time.h>
38
39#include "pasemi.h"
40
41static void pas_restart(char *cmd)
42{
43 printk("restart unimplemented, looping...\n");
44 for (;;) ;
45}
46
47static void pas_power_off(void)
48{
49 printk("power off unimplemented, looping...\n");
50 for (;;) ;
51}
52
53static void pas_halt(void)
54{
55 pas_power_off();
56}
57
58#ifdef CONFIG_SMP
59struct smp_ops_t pas_smp_ops = {
60 .probe = smp_mpic_probe,
61 .message_pass = smp_mpic_message_pass,
62 .kick_cpu = smp_generic_kick_cpu,
63 .setup_cpu = smp_mpic_setup_cpu,
64 .give_timebase = smp_generic_give_timebase,
65 .take_timebase = smp_generic_take_timebase,
66};
67#endif /* CONFIG_SMP */
68
69void __init pas_setup_arch(void)
70{
71#ifdef CONFIG_SMP
72 /* Setup SMP callback */
73 smp_ops = &pas_smp_ops;
74#endif
75 /* Lookup PCI hosts */
76 pas_pci_init();
77
78#ifdef CONFIG_DUMMY_CONSOLE
79 conswitchp = &dummy_con;
80#endif
81
82 printk(KERN_DEBUG "Using default idle loop\n");
83}
84
85static void iommu_dev_setup_null(struct pci_dev *dev) { }
86static void iommu_bus_setup_null(struct pci_bus *bus) { }
87
88static void __init pas_init_early(void)
89{
90 /* No iommu code yet */
91 ppc_md.iommu_dev_setup = iommu_dev_setup_null;
92 ppc_md.iommu_bus_setup = iommu_bus_setup_null;
93 pci_direct_iommu_init();
94}
95
96/* No legacy IO on our parts */
97static int pas_check_legacy_ioport(unsigned int baseport)
98{
99 return -ENODEV;
100}
101
102static __init void pas_init_IRQ(void)
103{
104 struct device_node *np;
105 struct device_node *root, *mpic_node;
106 unsigned long openpic_addr;
107 const unsigned int *opprop;
108 int naddr, opplen;
109 struct mpic *mpic;
110
111 mpic_node = NULL;
112
113 for_each_node_by_type(np, "interrupt-controller")
114 if (device_is_compatible(np, "open-pic")) {
115 mpic_node = np;
116 break;
117 }
118 if (!mpic_node)
119 for_each_node_by_type(np, "open-pic") {
120 mpic_node = np;
121 break;
122 }
123 if (!mpic_node) {
124 printk(KERN_ERR
125 "Failed to locate the MPIC interrupt controller\n");
126 return;
127 }
128
129 /* Find address list in /platform-open-pic */
130 root = of_find_node_by_path("/");
131 naddr = prom_n_addr_cells(root);
132 opprop = get_property(root, "platform-open-pic", &opplen);
133 if (!opprop) {
134 printk(KERN_ERR "No platform-open-pic property.\n");
135 of_node_put(root);
136 return;
137 }
138 openpic_addr = of_read_number(opprop, naddr);
139 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
140 of_node_put(root);
141
142 mpic = mpic_alloc(mpic_node, openpic_addr, MPIC_PRIMARY, 0, 0,
143 " PAS-OPIC ");
144 BUG_ON(!mpic);
145
146 mpic_assign_isu(mpic, 0, openpic_addr + 0x10000);
147 mpic_init(mpic);
148 of_node_put(mpic_node);
149 of_node_put(root);
150}
151
152static void __init pas_progress(char *s, unsigned short hex)
153{
154 printk("[%04x] : %s\n", hex, s ? s : "");
155}
156
157
158/*
159 * Called very early, MMU is off, device-tree isn't unflattened
160 */
161static int __init pas_probe(void)
162{
163 unsigned long root = of_get_flat_dt_root();
164
165 if (!of_flat_dt_is_compatible(root, "PA6T-1682M"))
166 return 0;
167
168 hpte_init_native();
169
170 return 1;
171}
172
173define_machine(pas) {
174 .name = "PA Semi PA6T-1682M",
175 .probe = pas_probe,
176 .setup_arch = pas_setup_arch,
177 .init_early = pas_init_early,
178 .init_IRQ = pas_init_IRQ,
179 .get_irq = mpic_get_irq,
180 .pcibios_fixup = pas_pcibios_fixup,
181 .restart = pas_restart,
182 .power_off = pas_power_off,
183 .halt = pas_halt,
184 .get_boot_time = pas_get_boot_time,
185 .calibrate_decr = generic_calibrate_decr,
186 .check_legacy_ioport = pas_check_legacy_ioport,
187 .progress = pas_progress,
188};
diff --git a/arch/powerpc/platforms/pasemi/time.c b/arch/powerpc/platforms/pasemi/time.c
new file mode 100644
index 000000000000..9bd410b8fec6
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/time.c
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2006 PA Semi, Inc
3 *
4 * Maintained by: Olof Johansson <olof@lixom.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/config.h>
21#include <linux/time.h>
22
23#include <asm/time.h>
24
25unsigned long __init pas_get_boot_time(void)
26{
27 /* Let's just return a fake date right now */
28 return mktime(2006, 1, 1, 12, 0, 0);
29}
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index d66415491055..afa593a8544a 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -60,7 +60,8 @@ int pmac_has_backlight_type(const char *type)
60 struct device_node* bk_node = find_devices("backlight"); 60 struct device_node* bk_node = find_devices("backlight");
61 61
62 if (bk_node) { 62 if (bk_node) {
63 char *prop = get_property(bk_node, "backlight-control", NULL); 63 const char *prop = get_property(bk_node,
64 "backlight-control", NULL);
64 if (prop && strncmp(prop, type, strlen(type)) == 0) 65 if (prop && strncmp(prop, type, strlen(type)) == 0)
65 return 1; 66 return 1;
66 } 67 }
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/arch/powerpc/platforms/powermac/cpufreq_32.c
index 62926248bdb8..c2b6b4134f68 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_32.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_32.c
@@ -421,7 +421,7 @@ static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy)
421 421
422static u32 read_gpio(struct device_node *np) 422static u32 read_gpio(struct device_node *np)
423{ 423{
424 u32 *reg = (u32 *)get_property(np, "reg", NULL); 424 const u32 *reg = get_property(np, "reg", NULL);
425 u32 offset; 425 u32 offset;
426 426
427 if (reg == NULL) 427 if (reg == NULL)
@@ -497,7 +497,7 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
497 "frequency-gpio"); 497 "frequency-gpio");
498 struct device_node *slew_done_gpio_np = of_find_node_by_name(NULL, 498 struct device_node *slew_done_gpio_np = of_find_node_by_name(NULL,
499 "slewing-done"); 499 "slewing-done");
500 u32 *value; 500 const u32 *value;
501 501
502 /* 502 /*
503 * Check to see if it's GPIO driven or PMU only 503 * Check to see if it's GPIO driven or PMU only
@@ -519,15 +519,15 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
519 */ 519 */
520 if (frequency_gpio && slew_done_gpio) { 520 if (frequency_gpio && slew_done_gpio) {
521 int lenp, rc; 521 int lenp, rc;
522 u32 *freqs, *ratio; 522 const u32 *freqs, *ratio;
523 523
524 freqs = (u32 *)get_property(cpunode, "bus-frequencies", &lenp); 524 freqs = get_property(cpunode, "bus-frequencies", &lenp);
525 lenp /= sizeof(u32); 525 lenp /= sizeof(u32);
526 if (freqs == NULL || lenp != 2) { 526 if (freqs == NULL || lenp != 2) {
527 printk(KERN_ERR "cpufreq: bus-frequencies incorrect or missing\n"); 527 printk(KERN_ERR "cpufreq: bus-frequencies incorrect or missing\n");
528 return 1; 528 return 1;
529 } 529 }
530 ratio = (u32 *)get_property(cpunode, "processor-to-bus-ratio*2", NULL); 530 ratio = get_property(cpunode, "processor-to-bus-ratio*2", NULL);
531 if (ratio == NULL) { 531 if (ratio == NULL) {
532 printk(KERN_ERR "cpufreq: processor-to-bus-ratio*2 missing\n"); 532 printk(KERN_ERR "cpufreq: processor-to-bus-ratio*2 missing\n");
533 return 1; 533 return 1;
@@ -562,7 +562,7 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
562 /* If we use the PMU, look for the min & max frequencies in the 562 /* If we use the PMU, look for the min & max frequencies in the
563 * device-tree 563 * device-tree
564 */ 564 */
565 value = (u32 *)get_property(cpunode, "min-clock-frequency", NULL); 565 value = get_property(cpunode, "min-clock-frequency", NULL);
566 if (!value) 566 if (!value)
567 return 1; 567 return 1;
568 low_freq = (*value) / 1000; 568 low_freq = (*value) / 1000;
@@ -571,7 +571,7 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
571 if (low_freq < 100000) 571 if (low_freq < 100000)
572 low_freq *= 10; 572 low_freq *= 10;
573 573
574 value = (u32 *)get_property(cpunode, "max-clock-frequency", NULL); 574 value = get_property(cpunode, "max-clock-frequency", NULL);
575 if (!value) 575 if (!value)
576 return 1; 576 return 1;
577 hi_freq = (*value) / 1000; 577 hi_freq = (*value) / 1000;
@@ -611,13 +611,14 @@ static int pmac_cpufreq_init_7447A(struct device_node *cpunode)
611static int pmac_cpufreq_init_750FX(struct device_node *cpunode) 611static int pmac_cpufreq_init_750FX(struct device_node *cpunode)
612{ 612{
613 struct device_node *volt_gpio_np; 613 struct device_node *volt_gpio_np;
614 u32 pvr, *value; 614 u32 pvr;
615 const u32 *value;
615 616
616 if (get_property(cpunode, "dynamic-power-step", NULL) == NULL) 617 if (get_property(cpunode, "dynamic-power-step", NULL) == NULL)
617 return 1; 618 return 1;
618 619
619 hi_freq = cur_freq; 620 hi_freq = cur_freq;
620 value = (u32 *)get_property(cpunode, "reduced-clock-frequency", NULL); 621 value = get_property(cpunode, "reduced-clock-frequency", NULL);
621 if (!value) 622 if (!value)
622 return 1; 623 return 1;
623 low_freq = (*value) / 1000; 624 low_freq = (*value) / 1000;
@@ -650,7 +651,7 @@ static int pmac_cpufreq_init_750FX(struct device_node *cpunode)
650static int __init pmac_cpufreq_setup(void) 651static int __init pmac_cpufreq_setup(void)
651{ 652{
652 struct device_node *cpunode; 653 struct device_node *cpunode;
653 u32 *value; 654 const u32 *value;
654 655
655 if (strstr(cmd_line, "nocpufreq")) 656 if (strstr(cmd_line, "nocpufreq"))
656 return 0; 657 return 0;
@@ -661,7 +662,7 @@ static int __init pmac_cpufreq_setup(void)
661 goto out; 662 goto out;
662 663
663 /* Get current cpu clock freq */ 664 /* Get current cpu clock freq */
664 value = (u32 *)get_property(cpunode, "clock-frequency", NULL); 665 value = get_property(cpunode, "clock-frequency", NULL);
665 if (!value) 666 if (!value)
666 goto out; 667 goto out;
667 cur_freq = (*value) / 1000; 668 cur_freq = (*value) / 1000;
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/arch/powerpc/platforms/powermac/cpufreq_64.c
index 7b1156ea5341..d30466d74194 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_64.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_64.c
@@ -89,7 +89,7 @@ static DEFINE_MUTEX(g5_switch_mutex);
89 89
90#ifdef CONFIG_PMAC_SMU 90#ifdef CONFIG_PMAC_SMU
91 91
92static u32 *g5_pmode_data; 92static const u32 *g5_pmode_data;
93static int g5_pmode_max; 93static int g5_pmode_max;
94 94
95static struct smu_sdbp_fvt *g5_fvt_table; /* table of op. points */ 95static struct smu_sdbp_fvt *g5_fvt_table; /* table of op. points */
@@ -391,7 +391,8 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
391 unsigned int psize, ssize; 391 unsigned int psize, ssize;
392 unsigned long max_freq; 392 unsigned long max_freq;
393 char *freq_method, *volt_method; 393 char *freq_method, *volt_method;
394 u32 *valp, pvr_hi; 394 const u32 *valp;
395 u32 pvr_hi;
395 int use_volts_vdnap = 0; 396 int use_volts_vdnap = 0;
396 int use_volts_smu = 0; 397 int use_volts_smu = 0;
397 int rc = -ENODEV; 398 int rc = -ENODEV;
@@ -409,8 +410,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
409 /* Get first CPU node */ 410 /* Get first CPU node */
410 for (cpunode = NULL; 411 for (cpunode = NULL;
411 (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) { 412 (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) {
412 u32 *reg = 413 const u32 *reg = get_property(cpunode, "reg", NULL);
413 (u32 *)get_property(cpunode, "reg", NULL);
414 if (reg == NULL || (*reg) != 0) 414 if (reg == NULL || (*reg) != 0)
415 continue; 415 continue;
416 if (!strcmp(cpunode->type, "cpu")) 416 if (!strcmp(cpunode->type, "cpu"))
@@ -422,7 +422,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
422 } 422 }
423 423
424 /* Check 970FX for now */ 424 /* Check 970FX for now */
425 valp = (u32 *)get_property(cpunode, "cpu-version", NULL); 425 valp = get_property(cpunode, "cpu-version", NULL);
426 if (!valp) { 426 if (!valp) {
427 DBG("No cpu-version property !\n"); 427 DBG("No cpu-version property !\n");
428 goto bail_noprops; 428 goto bail_noprops;
@@ -434,7 +434,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
434 } 434 }
435 435
436 /* Look for the powertune data in the device-tree */ 436 /* Look for the powertune data in the device-tree */
437 g5_pmode_data = (u32 *)get_property(cpunode, "power-mode-data",&psize); 437 g5_pmode_data = get_property(cpunode, "power-mode-data",&psize);
438 if (!g5_pmode_data) { 438 if (!g5_pmode_data) {
439 DBG("No power-mode-data !\n"); 439 DBG("No power-mode-data !\n");
440 goto bail_noprops; 440 goto bail_noprops;
@@ -442,7 +442,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
442 g5_pmode_max = psize / sizeof(u32) - 1; 442 g5_pmode_max = psize / sizeof(u32) - 1;
443 443
444 if (use_volts_smu) { 444 if (use_volts_smu) {
445 struct smu_sdbp_header *shdr; 445 const struct smu_sdbp_header *shdr;
446 446
447 /* Look for the FVT table */ 447 /* Look for the FVT table */
448 shdr = smu_get_sdb_partition(SMU_SDB_FVT_ID, NULL); 448 shdr = smu_get_sdb_partition(SMU_SDB_FVT_ID, NULL);
@@ -493,7 +493,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
493 * half freq in this version. So far, I haven't yet seen a machine 493 * half freq in this version. So far, I haven't yet seen a machine
494 * supporting anything else. 494 * supporting anything else.
495 */ 495 */
496 valp = (u32 *)get_property(cpunode, "clock-frequency", NULL); 496 valp = get_property(cpunode, "clock-frequency", NULL);
497 if (!valp) 497 if (!valp)
498 return -ENODEV; 498 return -ENODEV;
499 max_freq = (*valp)/1000; 499 max_freq = (*valp)/1000;
@@ -541,8 +541,8 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
541static int __init g5_pm72_cpufreq_init(struct device_node *cpus) 541static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
542{ 542{
543 struct device_node *cpuid = NULL, *hwclock = NULL, *cpunode = NULL; 543 struct device_node *cpuid = NULL, *hwclock = NULL, *cpunode = NULL;
544 u8 *eeprom = NULL; 544 const u8 *eeprom = NULL;
545 u32 *valp; 545 const u32 *valp;
546 u64 max_freq, min_freq, ih, il; 546 u64 max_freq, min_freq, ih, il;
547 int has_volt = 1, rc = 0; 547 int has_volt = 1, rc = 0;
548 548
@@ -563,7 +563,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
563 /* Lookup the cpuid eeprom node */ 563 /* Lookup the cpuid eeprom node */
564 cpuid = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/cpuid@a0"); 564 cpuid = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/cpuid@a0");
565 if (cpuid != NULL) 565 if (cpuid != NULL)
566 eeprom = (u8 *)get_property(cpuid, "cpuid", NULL); 566 eeprom = get_property(cpuid, "cpuid", NULL);
567 if (eeprom == NULL) { 567 if (eeprom == NULL) {
568 printk(KERN_ERR "cpufreq: Can't find cpuid EEPROM !\n"); 568 printk(KERN_ERR "cpufreq: Can't find cpuid EEPROM !\n");
569 rc = -ENODEV; 569 rc = -ENODEV;
@@ -573,7 +573,8 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
573 /* Lookup the i2c hwclock */ 573 /* Lookup the i2c hwclock */
574 for (hwclock = NULL; 574 for (hwclock = NULL;
575 (hwclock = of_find_node_by_name(hwclock, "i2c-hwclock")) != NULL;){ 575 (hwclock = of_find_node_by_name(hwclock, "i2c-hwclock")) != NULL;){
576 char *loc = get_property(hwclock, "hwctrl-location", NULL); 576 const char *loc = get_property(hwclock,
577 "hwctrl-location", NULL);
577 if (loc == NULL) 578 if (loc == NULL)
578 continue; 579 continue;
579 if (strcmp(loc, "CPU CLOCK")) 580 if (strcmp(loc, "CPU CLOCK"))
@@ -637,7 +638,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
637 */ 638 */
638 639
639 /* Get max frequency from device-tree */ 640 /* Get max frequency from device-tree */
640 valp = (u32 *)get_property(cpunode, "clock-frequency", NULL); 641 valp = get_property(cpunode, "clock-frequency", NULL);
641 if (!valp) { 642 if (!valp) {
642 printk(KERN_ERR "cpufreq: Can't find CPU frequency !\n"); 643 printk(KERN_ERR "cpufreq: Can't find CPU frequency !\n");
643 rc = -ENODEV; 644 rc = -ENODEV;
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index f8313bf9a9f7..13fcaf5b1796 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -1058,8 +1058,8 @@ core99_reset_cpu(struct device_node *node, long param, long value)
1058 if (np == NULL) 1058 if (np == NULL)
1059 return -ENODEV; 1059 return -ENODEV;
1060 for (np = np->child; np != NULL; np = np->sibling) { 1060 for (np = np->child; np != NULL; np = np->sibling) {
1061 u32 *num = (u32 *)get_property(np, "reg", NULL); 1061 u32 *num = get_property(np, "reg", NULL);
1062 u32 *rst = (u32 *)get_property(np, "soft-reset", NULL); 1062 u32 *rst = get_property(np, "soft-reset", NULL);
1063 if (num == NULL || rst == NULL) 1063 if (num == NULL || rst == NULL)
1064 continue; 1064 continue;
1065 if (param == *num) { 1065 if (param == *num) {
@@ -1087,7 +1087,7 @@ core99_usb_enable(struct device_node *node, long param, long value)
1087{ 1087{
1088 struct macio_chip *macio; 1088 struct macio_chip *macio;
1089 unsigned long flags; 1089 unsigned long flags;
1090 char *prop; 1090 const char *prop;
1091 int number; 1091 int number;
1092 u32 reg; 1092 u32 reg;
1093 1093
@@ -1096,7 +1096,7 @@ core99_usb_enable(struct device_node *node, long param, long value)
1096 macio->type != macio_intrepid) 1096 macio->type != macio_intrepid)
1097 return -ENODEV; 1097 return -ENODEV;
1098 1098
1099 prop = (char *)get_property(node, "AAPL,clock-id", NULL); 1099 prop = get_property(node, "AAPL,clock-id", NULL);
1100 if (!prop) 1100 if (!prop)
1101 return -ENODEV; 1101 return -ENODEV;
1102 if (strncmp(prop, "usb0u048", 8) == 0) 1102 if (strncmp(prop, "usb0u048", 8) == 0)
@@ -1507,8 +1507,8 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
1507 if (np == NULL) 1507 if (np == NULL)
1508 return -ENODEV; 1508 return -ENODEV;
1509 for (np = np->child; np != NULL; np = np->sibling) { 1509 for (np = np->child; np != NULL; np = np->sibling) {
1510 u32 *num = (u32 *)get_property(np, "reg", NULL); 1510 const u32 *num = get_property(np, "reg", NULL);
1511 u32 *rst = (u32 *)get_property(np, "soft-reset", NULL); 1511 const u32 *rst = get_property(np, "soft-reset", NULL);
1512 if (num == NULL || rst == NULL) 1512 if (num == NULL || rst == NULL)
1513 continue; 1513 continue;
1514 if (param == *num) { 1514 if (param == *num) {
@@ -2408,7 +2408,7 @@ static int __init probe_motherboard(void)
2408 */ 2408 */
2409 dt = find_devices("device-tree"); 2409 dt = find_devices("device-tree");
2410 if (dt != NULL) 2410 if (dt != NULL)
2411 model = (const char *) get_property(dt, "model", NULL); 2411 model = get_property(dt, "model", NULL);
2412 for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { 2412 for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) {
2413 if (strcmp(model, pmac_mb_defs[i].model_string) == 0) { 2413 if (strcmp(model, pmac_mb_defs[i].model_string) == 0) {
2414 pmac_mb = pmac_mb_defs[i]; 2414 pmac_mb = pmac_mb_defs[i];
@@ -2536,7 +2536,7 @@ found:
2536 */ 2536 */
2537static void __init probe_uninorth(void) 2537static void __init probe_uninorth(void)
2538{ 2538{
2539 u32 *addrp; 2539 const u32 *addrp;
2540 phys_addr_t address; 2540 phys_addr_t address;
2541 unsigned long actrl; 2541 unsigned long actrl;
2542 2542
@@ -2555,7 +2555,7 @@ static void __init probe_uninorth(void)
2555 if (uninorth_node == NULL) 2555 if (uninorth_node == NULL)
2556 return; 2556 return;
2557 2557
2558 addrp = (u32 *)get_property(uninorth_node, "reg", NULL); 2558 addrp = get_property(uninorth_node, "reg", NULL);
2559 if (addrp == NULL) 2559 if (addrp == NULL)
2560 return; 2560 return;
2561 address = of_translate_address(uninorth_node, addrp); 2561 address = of_translate_address(uninorth_node, addrp);
@@ -2596,7 +2596,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
2596 struct device_node* node; 2596 struct device_node* node;
2597 int i; 2597 int i;
2598 volatile u32 __iomem *base; 2598 volatile u32 __iomem *base;
2599 u32 *addrp, *revp; 2599 const u32 *addrp, *revp;
2600 phys_addr_t addr; 2600 phys_addr_t addr;
2601 u64 size; 2601 u64 size;
2602 2602
@@ -2639,7 +2639,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
2639 return; 2639 return;
2640 } 2640 }
2641 if (type == macio_keylargo || type == macio_keylargo2) { 2641 if (type == macio_keylargo || type == macio_keylargo2) {
2642 u32 *did = (u32 *)get_property(node, "device-id", NULL); 2642 const u32 *did = get_property(node, "device-id", NULL);
2643 if (*did == 0x00000025) 2643 if (*did == 0x00000025)
2644 type = macio_pangea; 2644 type = macio_pangea;
2645 if (*did == 0x0000003e) 2645 if (*did == 0x0000003e)
@@ -2652,7 +2652,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
2652 macio_chips[i].base = base; 2652 macio_chips[i].base = base;
2653 macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON; 2653 macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON;
2654 macio_chips[i].name = macio_names[type]; 2654 macio_chips[i].name = macio_names[type];
2655 revp = (u32 *)get_property(node, "revision-id", NULL); 2655 revp = get_property(node, "revision-id", NULL);
2656 if (revp) 2656 if (revp)
2657 macio_chips[i].rev = *revp; 2657 macio_chips[i].rev = *revp;
2658 printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n", 2658 printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
@@ -2695,15 +2695,15 @@ static void __init
2695initial_serial_shutdown(struct device_node *np) 2695initial_serial_shutdown(struct device_node *np)
2696{ 2696{
2697 int len; 2697 int len;
2698 struct slot_names_prop { 2698 const struct slot_names_prop {
2699 int count; 2699 int count;
2700 char name[1]; 2700 char name[1];
2701 } *slots; 2701 } *slots;
2702 char *conn; 2702 const char *conn;
2703 int port_type = PMAC_SCC_ASYNC; 2703 int port_type = PMAC_SCC_ASYNC;
2704 int modem = 0; 2704 int modem = 0;
2705 2705
2706 slots = (struct slot_names_prop *)get_property(np, "slot-names", &len); 2706 slots = get_property(np, "slot-names", &len);
2707 conn = get_property(np, "AAPL,connector", &len); 2707 conn = get_property(np, "AAPL,connector", &len);
2708 if (conn && (strcmp(conn, "infrared") == 0)) 2708 if (conn && (strcmp(conn, "infrared") == 0))
2709 port_type = PMAC_SCC_IRDA; 2709 port_type = PMAC_SCC_IRDA;
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index 8677f50c2586..c2c7cf75dd5f 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -477,7 +477,8 @@ static int kw_i2c_xfer(struct pmac_i2c_bus *bus, u8 addrdir, int subsize,
477static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np) 477static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
478{ 478{
479 struct pmac_i2c_host_kw *host; 479 struct pmac_i2c_host_kw *host;
480 u32 *psteps, *prate, *addrp, steps; 480 const u32 *psteps, *prate, *addrp;
481 u32 steps;
481 482
482 host = kzalloc(sizeof(struct pmac_i2c_host_kw), GFP_KERNEL); 483 host = kzalloc(sizeof(struct pmac_i2c_host_kw), GFP_KERNEL);
483 if (host == NULL) { 484 if (host == NULL) {
@@ -490,7 +491,7 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
490 * on all i2c keywest nodes so far ... we would have to fallback 491 * on all i2c keywest nodes so far ... we would have to fallback
491 * to macio parsing if that wasn't the case 492 * to macio parsing if that wasn't the case
492 */ 493 */
493 addrp = (u32 *)get_property(np, "AAPL,address", NULL); 494 addrp = get_property(np, "AAPL,address", NULL);
494 if (addrp == NULL) { 495 if (addrp == NULL) {
495 printk(KERN_ERR "low_i2c: Can't find address for %s\n", 496 printk(KERN_ERR "low_i2c: Can't find address for %s\n",
496 np->full_name); 497 np->full_name);
@@ -504,13 +505,13 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
504 host->timeout_timer.function = kw_i2c_timeout; 505 host->timeout_timer.function = kw_i2c_timeout;
505 host->timeout_timer.data = (unsigned long)host; 506 host->timeout_timer.data = (unsigned long)host;
506 507
507 psteps = (u32 *)get_property(np, "AAPL,address-step", NULL); 508 psteps = get_property(np, "AAPL,address-step", NULL);
508 steps = psteps ? (*psteps) : 0x10; 509 steps = psteps ? (*psteps) : 0x10;
509 for (host->bsteps = 0; (steps & 0x01) == 0; host->bsteps++) 510 for (host->bsteps = 0; (steps & 0x01) == 0; host->bsteps++)
510 steps >>= 1; 511 steps >>= 1;
511 /* Select interface rate */ 512 /* Select interface rate */
512 host->speed = KW_I2C_MODE_25KHZ; 513 host->speed = KW_I2C_MODE_25KHZ;
513 prate = (u32 *)get_property(np, "AAPL,i2c-rate", NULL); 514 prate = get_property(np, "AAPL,i2c-rate", NULL);
514 if (prate) switch(*prate) { 515 if (prate) switch(*prate) {
515 case 100: 516 case 100:
516 host->speed = KW_I2C_MODE_100KHZ; 517 host->speed = KW_I2C_MODE_100KHZ;
@@ -618,8 +619,8 @@ static void __init kw_i2c_probe(void)
618 } else { 619 } else {
619 for (child = NULL; 620 for (child = NULL;
620 (child = of_get_next_child(np, child)) != NULL;) { 621 (child = of_get_next_child(np, child)) != NULL;) {
621 u32 *reg = 622 const u32 *reg = get_property(child,
622 (u32 *)get_property(child, "reg", NULL); 623 "reg", NULL);
623 if (reg == NULL) 624 if (reg == NULL)
624 continue; 625 continue;
625 kw_i2c_add(host, np, child, *reg); 626 kw_i2c_add(host, np, child, *reg);
@@ -881,7 +882,7 @@ static void __init smu_i2c_probe(void)
881{ 882{
882 struct device_node *controller, *busnode; 883 struct device_node *controller, *busnode;
883 struct pmac_i2c_bus *bus; 884 struct pmac_i2c_bus *bus;
884 u32 *reg; 885 const u32 *reg;
885 int sz; 886 int sz;
886 887
887 if (!smu_present()) 888 if (!smu_present())
@@ -904,7 +905,7 @@ static void __init smu_i2c_probe(void)
904 if (strcmp(busnode->type, "i2c") && 905 if (strcmp(busnode->type, "i2c") &&
905 strcmp(busnode->type, "i2c-bus")) 906 strcmp(busnode->type, "i2c-bus"))
906 continue; 907 continue;
907 reg = (u32 *)get_property(busnode, "reg", NULL); 908 reg = get_property(busnode, "reg", NULL);
908 if (reg == NULL) 909 if (reg == NULL)
909 continue; 910 continue;
910 911
@@ -948,9 +949,8 @@ struct pmac_i2c_bus *pmac_i2c_find_bus(struct device_node *node)
948 list_for_each_entry(bus, &pmac_i2c_busses, link) { 949 list_for_each_entry(bus, &pmac_i2c_busses, link) {
949 if (p == bus->busnode) { 950 if (p == bus->busnode) {
950 if (prev && bus->flags & pmac_i2c_multibus) { 951 if (prev && bus->flags & pmac_i2c_multibus) {
951 u32 *reg; 952 const u32 *reg;
952 reg = (u32 *)get_property(prev, "reg", 953 reg = get_property(prev, "reg", NULL);
953 NULL);
954 if (!reg) 954 if (!reg)
955 continue; 955 continue;
956 if (((*reg) >> 8) != bus->channel) 956 if (((*reg) >> 8) != bus->channel)
@@ -971,7 +971,7 @@ EXPORT_SYMBOL_GPL(pmac_i2c_find_bus);
971 971
972u8 pmac_i2c_get_dev_addr(struct device_node *device) 972u8 pmac_i2c_get_dev_addr(struct device_node *device)
973{ 973{
974 u32 *reg = (u32 *)get_property(device, "reg", NULL); 974 const u32 *reg = get_property(device, "reg", NULL);
975 975
976 if (reg == NULL) 976 if (reg == NULL)
977 return 0; 977 return 0;
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 205d04471161..9923adc5248e 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -66,16 +66,16 @@ struct device_node *k2_skiplist[2];
66static int __init fixup_one_level_bus_range(struct device_node *node, int higher) 66static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
67{ 67{
68 for (; node != 0;node = node->sibling) { 68 for (; node != 0;node = node->sibling) {
69 int * bus_range; 69 const int * bus_range;
70 unsigned int *class_code; 70 const unsigned int *class_code;
71 int len; 71 int len;
72 72
73 /* For PCI<->PCI bridges or CardBus bridges, we go down */ 73 /* For PCI<->PCI bridges or CardBus bridges, we go down */
74 class_code = (unsigned int *) get_property(node, "class-code", NULL); 74 class_code = get_property(node, "class-code", NULL);
75 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 75 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
76 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) 76 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
77 continue; 77 continue;
78 bus_range = (int *) get_property(node, "bus-range", &len); 78 bus_range = get_property(node, "bus-range", &len);
79 if (bus_range != NULL && len > 2 * sizeof(int)) { 79 if (bus_range != NULL && len > 2 * sizeof(int)) {
80 if (bus_range[1] > higher) 80 if (bus_range[1] > higher)
81 higher = bus_range[1]; 81 higher = bus_range[1];
@@ -93,13 +93,15 @@ static int __init fixup_one_level_bus_range(struct device_node *node, int higher
93 */ 93 */
94static void __init fixup_bus_range(struct device_node *bridge) 94static void __init fixup_bus_range(struct device_node *bridge)
95{ 95{
96 int * bus_range; 96 int *bus_range, len;
97 int len; 97 struct property *prop;
98 98
99 /* Lookup the "bus-range" property for the hose */ 99 /* Lookup the "bus-range" property for the hose */
100 bus_range = (int *) get_property(bridge, "bus-range", &len); 100 prop = of_find_property(bridge, "bus-range", &len);
101 if (bus_range == NULL || len < 2 * sizeof(int)) 101 if (prop == NULL || prop->length < 2 * sizeof(int))
102 return; 102 return;
103
104 bus_range = (int *)prop->value;
103 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]); 105 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
104} 106}
105 107
@@ -237,7 +239,7 @@ static struct pci_ops macrisc_pci_ops =
237static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset) 239static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset)
238{ 240{
239 struct device_node *np; 241 struct device_node *np;
240 u32 *vendor, *device; 242 const u32 *vendor, *device;
241 243
242 if (offset >= 0x100) 244 if (offset >= 0x100)
243 return PCIBIOS_BAD_REGISTER_NUMBER; 245 return PCIBIOS_BAD_REGISTER_NUMBER;
@@ -245,8 +247,8 @@ static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset)
245 if (np == NULL) 247 if (np == NULL)
246 return PCIBIOS_DEVICE_NOT_FOUND; 248 return PCIBIOS_DEVICE_NOT_FOUND;
247 249
248 vendor = (u32 *)get_property(np, "vendor-id", NULL); 250 vendor = get_property(np, "vendor-id", NULL);
249 device = (u32 *)get_property(np, "device-id", NULL); 251 device = get_property(np, "device-id", NULL);
250 if (vendor == NULL || device == NULL) 252 if (vendor == NULL || device == NULL)
251 return PCIBIOS_DEVICE_NOT_FOUND; 253 return PCIBIOS_DEVICE_NOT_FOUND;
252 254
@@ -686,20 +688,21 @@ static void __init fixup_nec_usb2(void)
686 688
687 for (nec = NULL; (nec = of_find_node_by_name(nec, "usb")) != NULL;) { 689 for (nec = NULL; (nec = of_find_node_by_name(nec, "usb")) != NULL;) {
688 struct pci_controller *hose; 690 struct pci_controller *hose;
689 u32 data, *prop; 691 u32 data;
692 const u32 *prop;
690 u8 bus, devfn; 693 u8 bus, devfn;
691 694
692 prop = (u32 *)get_property(nec, "vendor-id", NULL); 695 prop = get_property(nec, "vendor-id", NULL);
693 if (prop == NULL) 696 if (prop == NULL)
694 continue; 697 continue;
695 if (0x1033 != *prop) 698 if (0x1033 != *prop)
696 continue; 699 continue;
697 prop = (u32 *)get_property(nec, "device-id", NULL); 700 prop = get_property(nec, "device-id", NULL);
698 if (prop == NULL) 701 if (prop == NULL)
699 continue; 702 continue;
700 if (0x0035 != *prop) 703 if (0x0035 != *prop)
701 continue; 704 continue;
702 prop = (u32 *)get_property(nec, "reg", NULL); 705 prop = get_property(nec, "reg", NULL);
703 if (prop == NULL) 706 if (prop == NULL)
704 continue; 707 continue;
705 devfn = (prop[0] >> 8) & 0xff; 708 devfn = (prop[0] >> 8) & 0xff;
@@ -898,7 +901,7 @@ static int __init add_bridge(struct device_node *dev)
898 struct pci_controller *hose; 901 struct pci_controller *hose;
899 struct resource rsrc; 902 struct resource rsrc;
900 char *disp_name; 903 char *disp_name;
901 int *bus_range; 904 const int *bus_range;
902 int primary = 1, has_address = 0; 905 int primary = 1, has_address = 0;
903 906
904 DBG("Adding PCI host bridge %s\n", dev->full_name); 907 DBG("Adding PCI host bridge %s\n", dev->full_name);
@@ -907,7 +910,7 @@ static int __init add_bridge(struct device_node *dev)
907 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 910 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
908 911
909 /* Get bus range if any */ 912 /* Get bus range if any */
910 bus_range = (int *) get_property(dev, "bus-range", &len); 913 bus_range = get_property(dev, "bus-range", &len);
911 if (bus_range == NULL || len < 2 * sizeof(int)) { 914 if (bus_range == NULL || len < 2 * sizeof(int)) {
912 printk(KERN_WARNING "Can't get bus-range for %s, assume" 915 printk(KERN_WARNING "Can't get bus-range for %s, assume"
913 " bus 0\n", dev->full_name); 916 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/platforms/powermac/pfunc_base.c b/arch/powerpc/platforms/powermac/pfunc_base.c
index aacfa59595d1..ee3b223ab17a 100644
--- a/arch/powerpc/platforms/powermac/pfunc_base.c
+++ b/arch/powerpc/platforms/powermac/pfunc_base.c
@@ -114,7 +114,7 @@ static void macio_gpio_init_one(struct macio_chip *macio)
114 * we just create them all 114 * we just create them all
115 */ 115 */
116 for (gp = NULL; (gp = of_get_next_child(gparent, gp)) != NULL;) { 116 for (gp = NULL; (gp = of_get_next_child(gparent, gp)) != NULL;) {
117 u32 *reg = (u32 *)get_property(gp, "reg", NULL); 117 const u32 *reg = get_property(gp, "reg", NULL);
118 unsigned long offset; 118 unsigned long offset;
119 if (reg == NULL) 119 if (reg == NULL)
120 continue; 120 continue;
diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c
index b117adbf9571..7651f278615a 100644
--- a/arch/powerpc/platforms/powermac/pfunc_core.c
+++ b/arch/powerpc/platforms/powermac/pfunc_core.c
@@ -813,14 +813,15 @@ struct pmf_function *__pmf_find_function(struct device_node *target,
813 struct pmf_device *dev; 813 struct pmf_device *dev;
814 struct pmf_function *func, *result = NULL; 814 struct pmf_function *func, *result = NULL;
815 char fname[64]; 815 char fname[64];
816 u32 *prop, ph; 816 const u32 *prop;
817 u32 ph;
817 818
818 /* 819 /*
819 * Look for a "platform-*" function reference. If we can't find 820 * Look for a "platform-*" function reference. If we can't find
820 * one, then we fallback to a direct call attempt 821 * one, then we fallback to a direct call attempt
821 */ 822 */
822 snprintf(fname, 63, "platform-%s", name); 823 snprintf(fname, 63, "platform-%s", name);
823 prop = (u32 *)get_property(target, fname, NULL); 824 prop = get_property(target, fname, NULL);
824 if (prop == NULL) 825 if (prop == NULL)
825 goto find_it; 826 goto find_it;
826 ph = *prop; 827 ph = *prop;
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 31a9da769fa2..824a618396ab 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -116,7 +116,7 @@ extern struct smp_ops_t core99_smp_ops;
116static void pmac_show_cpuinfo(struct seq_file *m) 116static void pmac_show_cpuinfo(struct seq_file *m)
117{ 117{
118 struct device_node *np; 118 struct device_node *np;
119 char *pp; 119 const char *pp;
120 int plen; 120 int plen;
121 int mbmodel; 121 int mbmodel;
122 unsigned int mbflags; 122 unsigned int mbflags;
@@ -134,12 +134,12 @@ static void pmac_show_cpuinfo(struct seq_file *m)
134 seq_printf(m, "machine\t\t: "); 134 seq_printf(m, "machine\t\t: ");
135 np = of_find_node_by_path("/"); 135 np = of_find_node_by_path("/");
136 if (np != NULL) { 136 if (np != NULL) {
137 pp = (char *) get_property(np, "model", NULL); 137 pp = get_property(np, "model", NULL);
138 if (pp != NULL) 138 if (pp != NULL)
139 seq_printf(m, "%s\n", pp); 139 seq_printf(m, "%s\n", pp);
140 else 140 else
141 seq_printf(m, "PowerMac\n"); 141 seq_printf(m, "PowerMac\n");
142 pp = (char *) get_property(np, "compatible", &plen); 142 pp = get_property(np, "compatible", &plen);
143 if (pp != NULL) { 143 if (pp != NULL) {
144 seq_printf(m, "motherboard\t:"); 144 seq_printf(m, "motherboard\t:");
145 while (plen > 0) { 145 while (plen > 0) {
@@ -163,10 +163,8 @@ static void pmac_show_cpuinfo(struct seq_file *m)
163 if (np == NULL) 163 if (np == NULL)
164 np = of_find_node_by_type(NULL, "cache"); 164 np = of_find_node_by_type(NULL, "cache");
165 if (np != NULL) { 165 if (np != NULL) {
166 unsigned int *ic = (unsigned int *) 166 const unsigned int *ic = get_property(np, "i-cache-size", NULL);
167 get_property(np, "i-cache-size", NULL); 167 const unsigned int *dc = get_property(np, "d-cache-size", NULL);
168 unsigned int *dc = (unsigned int *)
169 get_property(np, "d-cache-size", NULL);
170 seq_printf(m, "L2 cache\t:"); 168 seq_printf(m, "L2 cache\t:");
171 has_l2cache = 1; 169 has_l2cache = 1;
172 if (get_property(np, "cache-unified", NULL) != 0 && dc) { 170 if (get_property(np, "cache-unified", NULL) != 0 && dc) {
@@ -254,7 +252,7 @@ static void __init l2cr_init(void)
254 if (np == 0) 252 if (np == 0)
255 np = find_type_devices("cpu"); 253 np = find_type_devices("cpu");
256 if (np != 0) { 254 if (np != 0) {
257 unsigned int *l2cr = (unsigned int *) 255 const unsigned int *l2cr =
258 get_property(np, "l2cr-value", NULL); 256 get_property(np, "l2cr-value", NULL);
259 if (l2cr != 0) { 257 if (l2cr != 0) {
260 ppc_override_l2cr = 1; 258 ppc_override_l2cr = 1;
@@ -277,7 +275,7 @@ static void __init l2cr_init(void)
277static void __init pmac_setup_arch(void) 275static void __init pmac_setup_arch(void)
278{ 276{
279 struct device_node *cpu, *ic; 277 struct device_node *cpu, *ic;
280 int *fp; 278 const int *fp;
281 unsigned long pvr; 279 unsigned long pvr;
282 280
283 pvr = PVR_VER(mfspr(SPRN_PVR)); 281 pvr = PVR_VER(mfspr(SPRN_PVR));
@@ -287,7 +285,7 @@ static void __init pmac_setup_arch(void)
287 loops_per_jiffy = 50000000 / HZ; 285 loops_per_jiffy = 50000000 / HZ;
288 cpu = of_find_node_by_type(NULL, "cpu"); 286 cpu = of_find_node_by_type(NULL, "cpu");
289 if (cpu != NULL) { 287 if (cpu != NULL) {
290 fp = (int *) get_property(cpu, "clock-frequency", NULL); 288 fp = get_property(cpu, "clock-frequency", NULL);
291 if (fp != NULL) { 289 if (fp != NULL) {
292 if (pvr >= 0x30 && pvr < 0x80) 290 if (pvr >= 0x30 && pvr < 0x80)
293 /* PPC970 etc. */ 291 /* PPC970 etc. */
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index 827b7121ffb8..653eeb64d1e2 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -548,7 +548,7 @@ static void __init smp_core99_setup_i2c_hwsync(int ncpus)
548 struct device_node *cc = NULL; 548 struct device_node *cc = NULL;
549 struct device_node *p; 549 struct device_node *p;
550 const char *name = NULL; 550 const char *name = NULL;
551 u32 *reg; 551 const u32 *reg;
552 int ok; 552 int ok;
553 553
554 /* Look for the clock chip */ 554 /* Look for the clock chip */
@@ -562,7 +562,7 @@ static void __init smp_core99_setup_i2c_hwsync(int ncpus)
562 pmac_tb_clock_chip_host = pmac_i2c_find_bus(cc); 562 pmac_tb_clock_chip_host = pmac_i2c_find_bus(cc);
563 if (pmac_tb_clock_chip_host == NULL) 563 if (pmac_tb_clock_chip_host == NULL)
564 continue; 564 continue;
565 reg = (u32 *)get_property(cc, "reg", NULL); 565 reg = get_property(cc, "reg", NULL);
566 if (reg == NULL) 566 if (reg == NULL)
567 continue; 567 continue;
568 switch (*reg) { 568 switch (*reg) {
@@ -707,8 +707,7 @@ static void __init smp_core99_setup(int ncpus)
707 core99_tb_gpio = KL_GPIO_TB_ENABLE; /* default value */ 707 core99_tb_gpio = KL_GPIO_TB_ENABLE; /* default value */
708 cpu = of_find_node_by_type(NULL, "cpu"); 708 cpu = of_find_node_by_type(NULL, "cpu");
709 if (cpu != NULL) { 709 if (cpu != NULL) {
710 tbprop = (u32 *)get_property(cpu, "timebase-enable", 710 tbprop = get_property(cpu, "timebase-enable", NULL);
711 NULL);
712 if (tbprop) 711 if (tbprop)
713 core99_tb_gpio = *tbprop; 712 core99_tb_gpio = *tbprop;
714 of_node_put(cpu); 713 of_node_put(cpu);
diff --git a/arch/powerpc/platforms/powermac/udbg_scc.c b/arch/powerpc/platforms/powermac/udbg_scc.c
index 37e5b1eff911..ce1a235855f7 100644
--- a/arch/powerpc/platforms/powermac/udbg_scc.c
+++ b/arch/powerpc/platforms/powermac/udbg_scc.c
@@ -68,11 +68,11 @@ static unsigned char scc_inittab[] = {
68 68
69void udbg_scc_init(int force_scc) 69void udbg_scc_init(int force_scc)
70{ 70{
71 u32 *reg; 71 const u32 *reg;
72 unsigned long addr; 72 unsigned long addr;
73 struct device_node *stdout = NULL, *escc = NULL, *macio = NULL; 73 struct device_node *stdout = NULL, *escc = NULL, *macio = NULL;
74 struct device_node *ch, *ch_def = NULL, *ch_a = NULL; 74 struct device_node *ch, *ch_def = NULL, *ch_a = NULL;
75 char *path; 75 const char *path;
76 int i, x; 76 int i, x;
77 77
78 escc = of_find_node_by_name(NULL, "escc"); 78 escc = of_find_node_by_name(NULL, "escc");
@@ -81,7 +81,7 @@ void udbg_scc_init(int force_scc)
81 macio = of_get_parent(escc); 81 macio = of_get_parent(escc);
82 if (macio == NULL) 82 if (macio == NULL)
83 goto bail; 83 goto bail;
84 path = (char *)get_property(of_chosen, "linux,stdout-path", NULL); 84 path = get_property(of_chosen, "linux,stdout-path", NULL);
85 if (path != NULL) 85 if (path != NULL)
86 stdout = of_find_node_by_path(path); 86 stdout = of_find_node_by_path(path);
87 for (ch = NULL; (ch = of_get_next_child(escc, ch)) != NULL;) { 87 for (ch = NULL; (ch = of_get_next_child(escc, ch)) != NULL;) {
@@ -96,13 +96,13 @@ void udbg_scc_init(int force_scc)
96 ch = ch_def ? ch_def : ch_a; 96 ch = ch_def ? ch_def : ch_a;
97 97
98 /* Get address within mac-io ASIC */ 98 /* Get address within mac-io ASIC */
99 reg = (u32 *)get_property(escc, "reg", NULL); 99 reg = get_property(escc, "reg", NULL);
100 if (reg == NULL) 100 if (reg == NULL)
101 goto bail; 101 goto bail;
102 addr = reg[0]; 102 addr = reg[0];
103 103
104 /* Get address of mac-io PCI itself */ 104 /* Get address of mac-io PCI itself */
105 reg = (u32 *)get_property(macio, "assigned-addresses", NULL); 105 reg = get_property(macio, "assigned-addresses", NULL);
106 if (reg == NULL) 106 if (reg == NULL)
107 goto bail; 107 goto bail;
108 addr += reg[2]; 108 addr += reg[2];
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index e5e0ff466904..997243a91be8 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_EEH) += eeh.o eeh_cache.o eeh_driver.o eeh_event.o
12 12
13obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o 13obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o
14obj-$(CONFIG_HVCS) += hvcserver.o 14obj-$(CONFIG_HVCS) += hvcserver.o
15obj-$(CONFIG_HCALL_STATS) += hvCall_inst.o
diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
index 32eaddfa5470..84bc8f7e17ef 100644
--- a/arch/powerpc/platforms/pseries/eeh.c
+++ b/arch/powerpc/platforms/pseries/eeh.c
@@ -449,7 +449,11 @@ EXPORT_SYMBOL(eeh_check_failure);
449/* ------------------------------------------------------------- */ 449/* ------------------------------------------------------------- */
450/* The code below deals with error recovery */ 450/* The code below deals with error recovery */
451 451
452/** Return negative value if a permanent error, else return 452/**
453 * eeh_slot_availability - returns error status of slot
454 * @pdn pci device node
455 *
456 * Return negative value if a permanent error, else return
453 * a number of milliseconds to wait until the PCI slot is 457 * a number of milliseconds to wait until the PCI slot is
454 * ready to be used. 458 * ready to be used.
455 */ 459 */
@@ -474,11 +478,42 @@ eeh_slot_availability(struct pci_dn *pdn)
474 478
475 printk (KERN_ERR "EEH: Slot unavailable: rc=%d, rets=%d %d %d\n", 479 printk (KERN_ERR "EEH: Slot unavailable: rc=%d, rets=%d %d %d\n",
476 rc, rets[0], rets[1], rets[2]); 480 rc, rets[0], rets[1], rets[2]);
477 return -1; 481 return -2;
482}
483
484/**
485 * rtas_pci_enable - enable MMIO or DMA transfers for this slot
486 * @pdn pci device node
487 */
488
489int
490rtas_pci_enable(struct pci_dn *pdn, int function)
491{
492 int config_addr;
493 int rc;
494
495 /* Use PE configuration address, if present */
496 config_addr = pdn->eeh_config_addr;
497 if (pdn->eeh_pe_config_addr)
498 config_addr = pdn->eeh_pe_config_addr;
499
500 rc = rtas_call(ibm_set_eeh_option, 4, 1, NULL,
501 config_addr,
502 BUID_HI(pdn->phb->buid),
503 BUID_LO(pdn->phb->buid),
504 function);
505
506 if (rc)
507 printk(KERN_WARNING "EEH: Cannot enable function %d, err=%d dn=%s\n",
508 function, rc, pdn->node->full_name);
509
510 return rc;
478} 511}
479 512
480/** rtas_pci_slot_reset raises/lowers the pci #RST line 513/**
481 * state: 1/0 to raise/lower the #RST 514 * rtas_pci_slot_reset - raises/lowers the pci #RST line
515 * @pdn pci device node
516 * @state: 1/0 to raise/lower the #RST
482 * 517 *
483 * Clear the EEH-frozen condition on a slot. This routine 518 * Clear the EEH-frozen condition on a slot. This routine
484 * asserts the PCI #RST line if the 'state' argument is '1', 519 * asserts the PCI #RST line if the 'state' argument is '1',
@@ -511,24 +546,21 @@ rtas_pci_slot_reset(struct pci_dn *pdn, int state)
511 BUID_HI(pdn->phb->buid), 546 BUID_HI(pdn->phb->buid),
512 BUID_LO(pdn->phb->buid), 547 BUID_LO(pdn->phb->buid),
513 state); 548 state);
514 if (rc) { 549 if (rc)
515 printk (KERN_WARNING "EEH: Unable to reset the failed slot, (%d) #RST=%d dn=%s\n", 550 printk (KERN_WARNING "EEH: Unable to reset the failed slot,"
551 " (%d) #RST=%d dn=%s\n",
516 rc, state, pdn->node->full_name); 552 rc, state, pdn->node->full_name);
517 return;
518 }
519} 553}
520 554
521/** rtas_set_slot_reset -- assert the pci #RST line for 1/4 second 555/**
522 * dn -- device node to be reset. 556 * rtas_set_slot_reset -- assert the pci #RST line for 1/4 second
557 * @pdn: pci device node to be reset.
523 * 558 *
524 * Return 0 if success, else a non-zero value. 559 * Return 0 if success, else a non-zero value.
525 */ 560 */
526 561
527int 562static void __rtas_set_slot_reset(struct pci_dn *pdn)
528rtas_set_slot_reset(struct pci_dn *pdn)
529{ 563{
530 int i, rc;
531
532 rtas_pci_slot_reset (pdn, 1); 564 rtas_pci_slot_reset (pdn, 1);
533 565
534 /* The PCI bus requires that the reset be held high for at least 566 /* The PCI bus requires that the reset be held high for at least
@@ -549,17 +581,33 @@ rtas_set_slot_reset(struct pci_dn *pdn)
549 * up traffic. */ 581 * up traffic. */
550#define PCI_BUS_SETTLE_TIME_MSEC 1800 582#define PCI_BUS_SETTLE_TIME_MSEC 1800
551 msleep (PCI_BUS_SETTLE_TIME_MSEC); 583 msleep (PCI_BUS_SETTLE_TIME_MSEC);
584}
585
586int rtas_set_slot_reset(struct pci_dn *pdn)
587{
588 int i, rc;
589
590 __rtas_set_slot_reset(pdn);
552 591
553 /* Now double check with the firmware to make sure the device is 592 /* Now double check with the firmware to make sure the device is
554 * ready to be used; if not, wait for recovery. */ 593 * ready to be used; if not, wait for recovery. */
555 for (i=0; i<10; i++) { 594 for (i=0; i<10; i++) {
556 rc = eeh_slot_availability (pdn); 595 rc = eeh_slot_availability (pdn);
557 if (rc < 0)
558 printk (KERN_ERR "EEH: failed (%d) to reset slot %s\n", rc, pdn->node->full_name);
559 if (rc == 0) 596 if (rc == 0)
560 return 0; 597 return 0;
561 if (rc < 0) 598
599 if (rc == -2) {
600 printk (KERN_ERR "EEH: failed (%d) to reset slot %s\n",
601 i, pdn->node->full_name);
602 __rtas_set_slot_reset(pdn);
603 continue;
604 }
605
606 if (rc < 0) {
607 printk (KERN_ERR "EEH: unrecoverable slot failure %s\n",
608 pdn->node->full_name);
562 return -1; 609 return -1;
610 }
563 611
564 msleep (rc+100); 612 msleep (rc+100);
565 } 613 }
@@ -582,6 +630,8 @@ rtas_set_slot_reset(struct pci_dn *pdn)
582 630
583/** 631/**
584 * __restore_bars - Restore the Base Address Registers 632 * __restore_bars - Restore the Base Address Registers
633 * @pdn: pci device node
634 *
585 * Loads the PCI configuration space base address registers, 635 * Loads the PCI configuration space base address registers,
586 * the expansion ROM base address, the latency timer, and etc. 636 * the expansion ROM base address, the latency timer, and etc.
587 * from the saved values in the device node. 637 * from the saved values in the device node.
@@ -691,11 +741,11 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
691{ 741{
692 struct eeh_early_enable_info *info = data; 742 struct eeh_early_enable_info *info = data;
693 int ret; 743 int ret;
694 char *status = get_property(dn, "status", NULL); 744 const char *status = get_property(dn, "status", NULL);
695 u32 *class_code = (u32 *)get_property(dn, "class-code", NULL); 745 const u32 *class_code = get_property(dn, "class-code", NULL);
696 u32 *vendor_id = (u32 *)get_property(dn, "vendor-id", NULL); 746 const u32 *vendor_id = get_property(dn, "vendor-id", NULL);
697 u32 *device_id = (u32 *)get_property(dn, "device-id", NULL); 747 const u32 *device_id = get_property(dn, "device-id", NULL);
698 u32 *regs; 748 const u32 *regs;
699 int enable; 749 int enable;
700 struct pci_dn *pdn = PCI_DN(dn); 750 struct pci_dn *pdn = PCI_DN(dn);
701 751
@@ -737,7 +787,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
737 787
738 /* Ok... see if this device supports EEH. Some do, some don't, 788 /* Ok... see if this device supports EEH. Some do, some don't,
739 * and the only way to find out is to check each and every one. */ 789 * and the only way to find out is to check each and every one. */
740 regs = (u32 *)get_property(dn, "reg", NULL); 790 regs = get_property(dn, "reg", NULL);
741 if (regs) { 791 if (regs) {
742 /* First register entry is addr (00BBSS00) */ 792 /* First register entry is addr (00BBSS00) */
743 /* Try to enable eeh */ 793 /* Try to enable eeh */
diff --git a/arch/powerpc/platforms/pseries/eeh_cache.c b/arch/powerpc/platforms/pseries/eeh_cache.c
index c37a8497c60f..b6b462d3c604 100644
--- a/arch/powerpc/platforms/pseries/eeh_cache.c
+++ b/arch/powerpc/platforms/pseries/eeh_cache.c
@@ -157,6 +157,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
157 if (!piar) 157 if (!piar)
158 return NULL; 158 return NULL;
159 159
160 pci_dev_get(dev);
160 piar->addr_lo = alo; 161 piar->addr_lo = alo;
161 piar->addr_hi = ahi; 162 piar->addr_hi = ahi;
162 piar->pcidev = dev; 163 piar->pcidev = dev;
@@ -178,7 +179,6 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev)
178 struct device_node *dn; 179 struct device_node *dn;
179 struct pci_dn *pdn; 180 struct pci_dn *pdn;
180 int i; 181 int i;
181 int inserted = 0;
182 182
183 dn = pci_device_to_OF_node(dev); 183 dn = pci_device_to_OF_node(dev);
184 if (!dn) { 184 if (!dn) {
@@ -197,9 +197,6 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev)
197 return; 197 return;
198 } 198 }
199 199
200 /* The cache holds a reference to the device... */
201 pci_dev_get(dev);
202
203 /* Walk resources on this device, poke them into the tree */ 200 /* Walk resources on this device, poke them into the tree */
204 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 201 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
205 unsigned long start = pci_resource_start(dev,i); 202 unsigned long start = pci_resource_start(dev,i);
@@ -212,12 +209,7 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev)
212 if (start == 0 || ~start == 0 || end == 0 || ~end == 0) 209 if (start == 0 || ~start == 0 || end == 0 || ~end == 0)
213 continue; 210 continue;
214 pci_addr_cache_insert(dev, start, end, flags); 211 pci_addr_cache_insert(dev, start, end, flags);
215 inserted = 1;
216 } 212 }
217
218 /* If there was nothing to add, the cache has no reference... */
219 if (!inserted)
220 pci_dev_put(dev);
221} 213}
222 214
223/** 215/**
@@ -240,7 +232,6 @@ void pci_addr_cache_insert_device(struct pci_dev *dev)
240static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) 232static inline void __pci_addr_cache_remove_device(struct pci_dev *dev)
241{ 233{
242 struct rb_node *n; 234 struct rb_node *n;
243 int removed = 0;
244 235
245restart: 236restart:
246 n = rb_first(&pci_io_addr_cache_root.rb_root); 237 n = rb_first(&pci_io_addr_cache_root.rb_root);
@@ -250,16 +241,12 @@ restart:
250 241
251 if (piar->pcidev == dev) { 242 if (piar->pcidev == dev) {
252 rb_erase(n, &pci_io_addr_cache_root.rb_root); 243 rb_erase(n, &pci_io_addr_cache_root.rb_root);
253 removed = 1; 244 pci_dev_put(piar->pcidev);
254 kfree(piar); 245 kfree(piar);
255 goto restart; 246 goto restart;
256 } 247 }
257 n = rb_next(n); 248 n = rb_next(n);
258 } 249 }
259
260 /* The cache no longer holds its reference to this device... */
261 if (removed)
262 pci_dev_put(dev);
263} 250}
264 251
265/** 252/**
diff --git a/arch/powerpc/platforms/pseries/eeh_driver.c b/arch/powerpc/platforms/pseries/eeh_driver.c
index aaad2c0afcbf..c2bc9904f1cb 100644
--- a/arch/powerpc/platforms/pseries/eeh_driver.c
+++ b/arch/powerpc/platforms/pseries/eeh_driver.c
@@ -77,8 +77,12 @@ static int irq_in_use(unsigned int irq)
77} 77}
78 78
79/* ------------------------------------------------------- */ 79/* ------------------------------------------------------- */
80/** eeh_report_error - report an EEH error to each device, 80/**
81 * collect up and merge the device responses. 81 * eeh_report_error - report pci error to each device driver
82 *
83 * Report an EEH error to each device driver, collect up and
84 * merge the device driver responses. Cumulative response
85 * passed back in "userdata".
82 */ 86 */
83 87
84static void eeh_report_error(struct pci_dev *dev, void *userdata) 88static void eeh_report_error(struct pci_dev *dev, void *userdata)
@@ -96,24 +100,49 @@ static void eeh_report_error(struct pci_dev *dev, void *userdata)
96 PCI_DN(dn)->eeh_mode |= EEH_MODE_IRQ_DISABLED; 100 PCI_DN(dn)->eeh_mode |= EEH_MODE_IRQ_DISABLED;
97 disable_irq_nosync(dev->irq); 101 disable_irq_nosync(dev->irq);
98 } 102 }
99 if (!driver->err_handler) 103 if (!driver->err_handler ||
100 return; 104 !driver->err_handler->error_detected)
101 if (!driver->err_handler->error_detected)
102 return; 105 return;
103 106
104 rc = driver->err_handler->error_detected (dev, pci_channel_io_frozen); 107 rc = driver->err_handler->error_detected (dev, pci_channel_io_frozen);
105 if (*res == PCI_ERS_RESULT_NONE) *res = rc; 108 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
106 if (*res == PCI_ERS_RESULT_NEED_RESET) return;
107 if (*res == PCI_ERS_RESULT_DISCONNECT && 109 if (*res == PCI_ERS_RESULT_DISCONNECT &&
108 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; 110 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
109} 111}
110 112
111/** eeh_report_reset -- tell this device that the pci slot 113/**
112 * has been reset. 114 * eeh_report_mmio_enabled - tell drivers that MMIO has been enabled
115 *
116 * Report an EEH error to each device driver, collect up and
117 * merge the device driver responses. Cumulative response
118 * passed back in "userdata".
119 */
120
121static void eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata)
122{
123 enum pci_ers_result rc, *res = userdata;
124 struct pci_driver *driver = dev->driver;
125
126 // dev->error_state = pci_channel_mmio_enabled;
127
128 if (!driver ||
129 !driver->err_handler ||
130 !driver->err_handler->mmio_enabled)
131 return;
132
133 rc = driver->err_handler->mmio_enabled (dev);
134 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
135 if (*res == PCI_ERS_RESULT_DISCONNECT &&
136 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
137}
138
139/**
140 * eeh_report_reset - tell device that slot has been reset
113 */ 141 */
114 142
115static void eeh_report_reset(struct pci_dev *dev, void *userdata) 143static void eeh_report_reset(struct pci_dev *dev, void *userdata)
116{ 144{
145 enum pci_ers_result rc, *res = userdata;
117 struct pci_driver *driver = dev->driver; 146 struct pci_driver *driver = dev->driver;
118 struct device_node *dn = pci_device_to_OF_node(dev); 147 struct device_node *dn = pci_device_to_OF_node(dev);
119 148
@@ -124,14 +153,20 @@ static void eeh_report_reset(struct pci_dev *dev, void *userdata)
124 PCI_DN(dn)->eeh_mode &= ~EEH_MODE_IRQ_DISABLED; 153 PCI_DN(dn)->eeh_mode &= ~EEH_MODE_IRQ_DISABLED;
125 enable_irq(dev->irq); 154 enable_irq(dev->irq);
126 } 155 }
127 if (!driver->err_handler) 156 if (!driver->err_handler ||
128 return; 157 !driver->err_handler->slot_reset)
129 if (!driver->err_handler->slot_reset)
130 return; 158 return;
131 159
132 driver->err_handler->slot_reset(dev); 160 rc = driver->err_handler->slot_reset(dev);
161 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
162 if (*res == PCI_ERS_RESULT_DISCONNECT &&
163 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
133} 164}
134 165
166/**
167 * eeh_report_resume - tell device to resume normal operations
168 */
169
135static void eeh_report_resume(struct pci_dev *dev, void *userdata) 170static void eeh_report_resume(struct pci_dev *dev, void *userdata)
136{ 171{
137 struct pci_driver *driver = dev->driver; 172 struct pci_driver *driver = dev->driver;
@@ -148,6 +183,13 @@ static void eeh_report_resume(struct pci_dev *dev, void *userdata)
148 driver->err_handler->resume(dev); 183 driver->err_handler->resume(dev);
149} 184}
150 185
186/**
187 * eeh_report_failure - tell device driver that device is dead.
188 *
189 * This informs the device driver that the device is permanently
190 * dead, and that no further recovery attempts will be made on it.
191 */
192
151static void eeh_report_failure(struct pci_dev *dev, void *userdata) 193static void eeh_report_failure(struct pci_dev *dev, void *userdata)
152{ 194{
153 struct pci_driver *driver = dev->driver; 195 struct pci_driver *driver = dev->driver;
@@ -190,11 +232,11 @@ static void eeh_report_failure(struct pci_dev *dev, void *userdata)
190 232
191/** 233/**
192 * eeh_reset_device() -- perform actual reset of a pci slot 234 * eeh_reset_device() -- perform actual reset of a pci slot
193 * Args: bus: pointer to the pci bus structure corresponding 235 * @bus: pointer to the pci bus structure corresponding
194 * to the isolated slot. A non-null value will 236 * to the isolated slot. A non-null value will
195 * cause all devices under the bus to be removed 237 * cause all devices under the bus to be removed
196 * and then re-added. 238 * and then re-added.
197 * pe_dn: pointer to a "Partionable Endpoint" device node. 239 * @pe_dn: pointer to a "Partionable Endpoint" device node.
198 * This is the top-level structure on which pci 240 * This is the top-level structure on which pci
199 * bus resets can be performed. 241 * bus resets can be performed.
200 */ 242 */
@@ -268,14 +310,14 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event)
268 310
269 if (!frozen_dn) { 311 if (!frozen_dn) {
270 312
271 location = (char *) get_property(event->dn, "ibm,loc-code", NULL); 313 location = get_property(event->dn, "ibm,loc-code", NULL);
272 location = location ? location : "unknown"; 314 location = location ? location : "unknown";
273 printk(KERN_ERR "EEH: Error: Cannot find partition endpoint " 315 printk(KERN_ERR "EEH: Error: Cannot find partition endpoint "
274 "for location=%s pci addr=%s\n", 316 "for location=%s pci addr=%s\n",
275 location, pci_name(event->dev)); 317 location, pci_name(event->dev));
276 return NULL; 318 return NULL;
277 } 319 }
278 location = (char *) get_property(frozen_dn, "ibm,loc-code", NULL); 320 location = get_property(frozen_dn, "ibm,loc-code", NULL);
279 location = location ? location : "unknown"; 321 location = location ? location : "unknown";
280 322
281 /* There are two different styles for coming up with the PE. 323 /* There are two different styles for coming up with the PE.
@@ -347,23 +389,43 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event)
347 goto hard_fail; 389 goto hard_fail;
348 } 390 }
349 391
350 /* If any device called out for a reset, then reset the slot */ 392 /* If all devices reported they can proceed, then re-enable MMIO */
351 if (result == PCI_ERS_RESULT_NEED_RESET) { 393 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
352 rc = eeh_reset_device(frozen_pdn, NULL); 394 rc = rtas_pci_enable(frozen_pdn, EEH_THAW_MMIO);
353 if (rc) 395
354 goto hard_fail; 396 if (rc) {
355 pci_walk_bus(frozen_bus, eeh_report_reset, NULL); 397 result = PCI_ERS_RESULT_NEED_RESET;
398 } else {
399 result = PCI_ERS_RESULT_NONE;
400 pci_walk_bus(frozen_bus, eeh_report_mmio_enabled, &result);
401 }
356 } 402 }
357 403
358 /* If all devices reported they can proceed, the re-enable PIO */ 404 /* If all devices reported they can proceed, then re-enable DMA */
359 if (result == PCI_ERS_RESULT_CAN_RECOVER) { 405 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
360 /* XXX Not supported; we brute-force reset the device */ 406 rc = rtas_pci_enable(frozen_pdn, EEH_THAW_DMA);
407
408 if (rc)
409 result = PCI_ERS_RESULT_NEED_RESET;
410 }
411
412 /* If any device has a hard failure, then shut off everything. */
413 if (result == PCI_ERS_RESULT_DISCONNECT)
414 goto hard_fail;
415
416 /* If any device called out for a reset, then reset the slot */
417 if (result == PCI_ERS_RESULT_NEED_RESET) {
361 rc = eeh_reset_device(frozen_pdn, NULL); 418 rc = eeh_reset_device(frozen_pdn, NULL);
362 if (rc) 419 if (rc)
363 goto hard_fail; 420 goto hard_fail;
364 pci_walk_bus(frozen_bus, eeh_report_reset, NULL); 421 result = PCI_ERS_RESULT_NONE;
422 pci_walk_bus(frozen_bus, eeh_report_reset, &result);
365 } 423 }
366 424
425 /* All devices should claim they have recovered by now. */
426 if (result != PCI_ERS_RESULT_RECOVERED)
427 goto hard_fail;
428
367 /* Tell all device drivers that they can resume operations */ 429 /* Tell all device drivers that they can resume operations */
368 pci_walk_bus(frozen_bus, eeh_report_resume, NULL); 430 pci_walk_bus(frozen_bus, eeh_report_resume, NULL);
369 431
diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c
index 45ccc687e57c..137077451316 100644
--- a/arch/powerpc/platforms/pseries/eeh_event.c
+++ b/arch/powerpc/platforms/pseries/eeh_event.c
@@ -124,11 +124,11 @@ int eeh_send_failure_event (struct device_node *dn,
124{ 124{
125 unsigned long flags; 125 unsigned long flags;
126 struct eeh_event *event; 126 struct eeh_event *event;
127 char *location; 127 const char *location;
128 128
129 if (!mem_init_done) { 129 if (!mem_init_done) {
130 printk(KERN_ERR "EEH: event during early boot not handled\n"); 130 printk(KERN_ERR "EEH: event during early boot not handled\n");
131 location = (char *) get_property(dn, "ibm,loc-code", NULL); 131 location = get_property(dn, "ibm,loc-code", NULL);
132 printk(KERN_ERR "EEH: device node = %s\n", dn->full_name); 132 printk(KERN_ERR "EEH: device node = %s\n", dn->full_name);
133 printk(KERN_ERR "EEH: PCI location = %s\n", location); 133 printk(KERN_ERR "EEH: PCI location = %s\n", location);
134 return 1; 134 return 1;
diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c
index c01d8f0cbe6d..1c7b2baa5f73 100644
--- a/arch/powerpc/platforms/pseries/firmware.c
+++ b/arch/powerpc/platforms/pseries/firmware.c
@@ -68,7 +68,7 @@ firmware_features_table[FIRMWARE_MAX_FEATURES] = {
68void __init fw_feature_init(void) 68void __init fw_feature_init(void)
69{ 69{
70 struct device_node *dn; 70 struct device_node *dn;
71 char *hypertas, *s; 71 const char *hypertas, *s;
72 int len, i; 72 int len, i;
73 73
74 DBG(" -> fw_feature_init()\n"); 74 DBG(" -> fw_feature_init()\n");
diff --git a/arch/powerpc/platforms/pseries/hvCall.S b/arch/powerpc/platforms/pseries/hvCall.S
index c9ff547f9d25..c00cfed7af2c 100644
--- a/arch/powerpc/platforms/pseries/hvCall.S
+++ b/arch/powerpc/platforms/pseries/hvCall.S
@@ -1,7 +1,6 @@
1/* 1/*
2 * This file contains the generic code to perform a call to the 2 * This file contains the generic code to perform a call to the
3 * pSeries LPAR hypervisor. 3 * pSeries LPAR hypervisor.
4 * NOTE: this file will go away when we move to inline this work.
5 * 4 *
6 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
@@ -11,217 +10,153 @@
11#include <asm/hvcall.h> 10#include <asm/hvcall.h>
12#include <asm/processor.h> 11#include <asm/processor.h>
13#include <asm/ppc_asm.h> 12#include <asm/ppc_asm.h>
13#include <asm/asm-offsets.h>
14 14
15#define STK_PARM(i) (48 + ((i)-3)*8) 15#define STK_PARM(i) (48 + ((i)-3)*8)
16 16
17 .text 17#ifdef CONFIG_HCALL_STATS
18 18/*
19/* long plpar_hcall(unsigned long opcode, R3 19 * precall must preserve all registers. use unused STK_PARM()
20 unsigned long arg1, R4 20 * areas to save snapshots and opcode.
21 unsigned long arg2, R5
22 unsigned long arg3, R6
23 unsigned long arg4, R7
24 unsigned long *out1, R8
25 unsigned long *out2, R9
26 unsigned long *out3); R10
27 */ 21 */
28_GLOBAL(plpar_hcall) 22#define HCALL_INST_PRECALL \
29 HMT_MEDIUM 23 std r3,STK_PARM(r3)(r1); /* save opcode */ \
30 24 mftb r0; /* get timebase and */ \
31 mfcr r0 25 std r0,STK_PARM(r5)(r1); /* save for later */ \
32 26BEGIN_FTR_SECTION; \
33 std r8,STK_PARM(r8)(r1) /* Save out ptrs */ 27 mfspr r0,SPRN_PURR; /* get PURR and */ \
34 std r9,STK_PARM(r9)(r1) 28 std r0,STK_PARM(r6)(r1); /* save for later */ \
35 std r10,STK_PARM(r10)(r1) 29END_FTR_SECTION_IFCLR(CPU_FTR_PURR);
36 30
37 stw r0,8(r1) 31/*
38 32 * postcall is performed immediately before function return which
39 HVSC /* invoke the hypervisor */ 33 * allows liberal use of volatile registers.
40 34 */
41 lwz r0,8(r1) 35#define HCALL_INST_POSTCALL \
42 36 ld r4,STK_PARM(r3)(r1); /* validate opcode */ \
43 ld r8,STK_PARM(r8)(r1) /* Fetch r4-r6 ret args */ 37 cmpldi cr7,r4,MAX_HCALL_OPCODE; \
44 ld r9,STK_PARM(r9)(r1) 38 bgt- cr7,1f; \
45 ld r10,STK_PARM(r10)(r1) 39 \
46 std r4,0(r8) 40 /* get time and PURR snapshots after hcall */ \
47 std r5,0(r9) 41 mftb r7; /* timebase after */ \
48 std r6,0(r10) 42BEGIN_FTR_SECTION; \
49 43 mfspr r8,SPRN_PURR; /* PURR after */ \
50 mtcrf 0xff,r0 44 ld r6,STK_PARM(r6)(r1); /* PURR before */ \
51 blr /* return r3 = status */ 45 subf r6,r6,r8; /* delta */ \
46END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
47 ld r5,STK_PARM(r5)(r1); /* timebase before */ \
48 subf r5,r5,r7; /* time delta */ \
49 \
50 /* calculate address of stat structure r4 = opcode */ \
51 srdi r4,r4,2; /* index into array */ \
52 mulli r4,r4,HCALL_STAT_SIZE; \
53 LOAD_REG_ADDR(r7, per_cpu__hcall_stats); \
54 add r4,r4,r7; \
55 ld r7,PACA_DATA_OFFSET(r13); /* per cpu offset */ \
56 add r4,r4,r7; \
57 \
58 /* update stats */ \
59 ld r7,HCALL_STAT_CALLS(r4); /* count */ \
60 addi r7,r7,1; \
61 std r7,HCALL_STAT_CALLS(r4); \
62 ld r7,HCALL_STAT_TB(r4); /* timebase */ \
63 add r7,r7,r5; \
64 std r7,HCALL_STAT_TB(r4); \
65BEGIN_FTR_SECTION; \
66 ld r7,HCALL_STAT_PURR(r4); /* PURR */ \
67 add r7,r7,r6; \
68 std r7,HCALL_STAT_PURR(r4); \
69END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
701:
71#else
72#define HCALL_INST_PRECALL
73#define HCALL_INST_POSTCALL
74#endif
52 75
76 .text
53 77
54/* Simple interface with no output values (other than status) */
55_GLOBAL(plpar_hcall_norets) 78_GLOBAL(plpar_hcall_norets)
56 HMT_MEDIUM 79 HMT_MEDIUM
57 80
58 mfcr r0 81 mfcr r0
59 stw r0,8(r1) 82 stw r0,8(r1)
60 83
61 HVSC /* invoke the hypervisor */ 84 HCALL_INST_PRECALL
62
63 lwz r0,8(r1)
64 mtcrf 0xff,r0
65 blr /* return r3 = status */
66
67
68/* long plpar_hcall_8arg_2ret(unsigned long opcode, R3
69 unsigned long arg1, R4
70 unsigned long arg2, R5
71 unsigned long arg3, R6
72 unsigned long arg4, R7
73 unsigned long arg5, R8
74 unsigned long arg6, R9
75 unsigned long arg7, R10
76 unsigned long arg8, 112(R1)
77 unsigned long *out1); 120(R1)
78 */
79_GLOBAL(plpar_hcall_8arg_2ret)
80 HMT_MEDIUM
81
82 mfcr r0
83 ld r11,STK_PARM(r11)(r1) /* put arg8 in R11 */
84 stw r0,8(r1)
85 85
86 HVSC /* invoke the hypervisor */ 86 HVSC /* invoke the hypervisor */
87 87
88 HCALL_INST_POSTCALL
89
88 lwz r0,8(r1) 90 lwz r0,8(r1)
89 ld r10,STK_PARM(r12)(r1) /* Fetch r4 ret arg */
90 std r4,0(r10)
91 mtcrf 0xff,r0 91 mtcrf 0xff,r0
92 blr /* return r3 = status */ 92 blr /* return r3 = status */
93 93
94 94_GLOBAL(plpar_hcall)
95/* long plpar_hcall_4out(unsigned long opcode, R3
96 unsigned long arg1, R4
97 unsigned long arg2, R5
98 unsigned long arg3, R6
99 unsigned long arg4, R7
100 unsigned long *out1, R8
101 unsigned long *out2, R9
102 unsigned long *out3, R10
103 unsigned long *out4); 112(R1)
104 */
105_GLOBAL(plpar_hcall_4out)
106 HMT_MEDIUM 95 HMT_MEDIUM
107 96
108 mfcr r0 97 mfcr r0
109 stw r0,8(r1) 98 stw r0,8(r1)
110 99
111 std r8,STK_PARM(r8)(r1) /* Save out ptrs */ 100 HCALL_INST_PRECALL
112 std r9,STK_PARM(r9)(r1)
113 std r10,STK_PARM(r10)(r1)
114
115 HVSC /* invoke the hypervisor */
116
117 lwz r0,8(r1)
118 101
119 ld r8,STK_PARM(r8)(r1) /* Fetch r4-r7 ret args */ 102 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
120 ld r9,STK_PARM(r9)(r1)
121 ld r10,STK_PARM(r10)(r1)
122 ld r11,STK_PARM(r11)(r1)
123 std r4,0(r8)
124 std r5,0(r9)
125 std r6,0(r10)
126 std r7,0(r11)
127 103
128 mtcrf 0xff,r0 104 mr r4,r5
129 blr /* return r3 = status */ 105 mr r5,r6
130 106 mr r6,r7
131/* plpar_hcall_7arg_7ret(unsigned long opcode, R3 107 mr r7,r8
132 unsigned long arg1, R4 108 mr r8,r9
133 unsigned long arg2, R5 109 mr r9,r10
134 unsigned long arg3, R6
135 unsigned long arg4, R7
136 unsigned long arg5, R8
137 unsigned long arg6, R9
138 unsigned long arg7, R10
139 unsigned long *out1, 112(R1)
140 unsigned long *out2, 110(R1)
141 unsigned long *out3, 108(R1)
142 unsigned long *out4, 106(R1)
143 unsigned long *out5, 104(R1)
144 unsigned long *out6, 102(R1)
145 unsigned long *out7); 100(R1)
146*/
147_GLOBAL(plpar_hcall_7arg_7ret)
148 HMT_MEDIUM
149
150 mfcr r0
151 stw r0,8(r1)
152 110
153 HVSC /* invoke the hypervisor */ 111 HVSC /* invoke the hypervisor */
154 112
155 lwz r0,8(r1) 113 ld r12,STK_PARM(r4)(r1)
114 std r4, 0(r12)
115 std r5, 8(r12)
116 std r6, 16(r12)
117 std r7, 24(r12)
156 118
157 ld r11,STK_PARM(r11)(r1) /* Fetch r4 ret arg */ 119 HCALL_INST_POSTCALL
158 std r4,0(r11)
159 ld r11,STK_PARM(r12)(r1) /* Fetch r5 ret arg */
160 std r5,0(r11)
161 ld r11,STK_PARM(r13)(r1) /* Fetch r6 ret arg */
162 std r6,0(r11)
163 ld r11,STK_PARM(r14)(r1) /* Fetch r7 ret arg */
164 std r7,0(r11)
165 ld r11,STK_PARM(r15)(r1) /* Fetch r8 ret arg */
166 std r8,0(r11)
167 ld r11,STK_PARM(r16)(r1) /* Fetch r9 ret arg */
168 std r9,0(r11)
169 ld r11,STK_PARM(r17)(r1) /* Fetch r10 ret arg */
170 std r10,0(r11)
171 120
121 lwz r0,8(r1)
172 mtcrf 0xff,r0 122 mtcrf 0xff,r0
173 123
174 blr /* return r3 = status */ 124 blr /* return r3 = status */
175 125
176/* plpar_hcall_9arg_9ret(unsigned long opcode, R3 126_GLOBAL(plpar_hcall9)
177 unsigned long arg1, R4
178 unsigned long arg2, R5
179 unsigned long arg3, R6
180 unsigned long arg4, R7
181 unsigned long arg5, R8
182 unsigned long arg6, R9
183 unsigned long arg7, R10
184 unsigned long arg8, 112(R1)
185 unsigned long arg9, 110(R1)
186 unsigned long *out1, 108(R1)
187 unsigned long *out2, 106(R1)
188 unsigned long *out3, 104(R1)
189 unsigned long *out4, 102(R1)
190 unsigned long *out5, 100(R1)
191 unsigned long *out6, 98(R1)
192 unsigned long *out7); 96(R1)
193 unsigned long *out8, 94(R1)
194 unsigned long *out9, 92(R1)
195*/
196_GLOBAL(plpar_hcall_9arg_9ret)
197 HMT_MEDIUM 127 HMT_MEDIUM
198 128
199 mfcr r0 129 mfcr r0
200 stw r0,8(r1) 130 stw r0,8(r1)
201 131
202 ld r11,STK_PARM(r11)(r1) /* put arg8 in R11 */ 132 HCALL_INST_PRECALL
203 ld r12,STK_PARM(r12)(r1) /* put arg9 in R12 */ 133
134 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
135
136 mr r4,r5
137 mr r5,r6
138 mr r6,r7
139 mr r7,r8
140 mr r8,r9
141 mr r9,r10
142 ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */
143 ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */
144 ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */
204 145
205 HVSC /* invoke the hypervisor */ 146 HVSC /* invoke the hypervisor */
206 147
207 ld r0,STK_PARM(r13)(r1) /* Fetch r4 ret arg */ 148 ld r12,STK_PARM(r4)(r1)
208 stdx r4,r0,r0 149 std r4, 0(r12)
209 ld r0,STK_PARM(r14)(r1) /* Fetch r5 ret arg */ 150 std r5, 8(r12)
210 stdx r5,r0,r0 151 std r6, 16(r12)
211 ld r0,STK_PARM(r15)(r1) /* Fetch r6 ret arg */ 152 std r7, 24(r12)
212 stdx r6,r0,r0 153 std r8, 32(r12)
213 ld r0,STK_PARM(r16)(r1) /* Fetch r7 ret arg */ 154 std r9, 40(r12)
214 stdx r7,r0,r0 155 std r10,48(r12)
215 ld r0,STK_PARM(r17)(r1) /* Fetch r8 ret arg */ 156 std r11,56(r12)
216 stdx r8,r0,r0 157 std r12,64(r12)
217 ld r0,STK_PARM(r18)(r1) /* Fetch r9 ret arg */ 158
218 stdx r9,r0,r0 159 HCALL_INST_POSTCALL
219 ld r0,STK_PARM(r19)(r1) /* Fetch r10 ret arg */
220 stdx r10,r0,r0
221 ld r0,STK_PARM(r20)(r1) /* Fetch r11 ret arg */
222 stdx r11,r0,r0
223 ld r0,STK_PARM(r21)(r1) /* Fetch r12 ret arg */
224 stdx r12,r0,r0
225 160
226 lwz r0,8(r1) 161 lwz r0,8(r1)
227 mtcrf 0xff,r0 162 mtcrf 0xff,r0
diff --git a/arch/powerpc/platforms/pseries/hvCall_inst.c b/arch/powerpc/platforms/pseries/hvCall_inst.c
new file mode 100644
index 000000000000..641e6511cf06
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/hvCall_inst.c
@@ -0,0 +1,129 @@
1/*
2 * Copyright (C) 2006 Mike Kravetz IBM Corporation
3 *
4 * Hypervisor Call Instrumentation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/percpu.h>
23#include <linux/debugfs.h>
24#include <linux/seq_file.h>
25#include <linux/cpumask.h>
26#include <asm/hvcall.h>
27#include <asm/firmware.h>
28#include <asm/cputable.h>
29
30DEFINE_PER_CPU(struct hcall_stats[HCALL_STAT_ARRAY_SIZE], hcall_stats);
31
32/*
33 * Routines for displaying the statistics in debugfs
34 */
35static void *hc_start(struct seq_file *m, loff_t *pos)
36{
37 if ((int)*pos < HCALL_STAT_ARRAY_SIZE)
38 return (void *)(unsigned long)(*pos + 1);
39
40 return NULL;
41}
42
43static void *hc_next(struct seq_file *m, void *p, loff_t * pos)
44{
45 ++*pos;
46
47 return hc_start(m, pos);
48}
49
50static void hc_stop(struct seq_file *m, void *p)
51{
52}
53
54static int hc_show(struct seq_file *m, void *p)
55{
56 unsigned long h_num = (unsigned long)p;
57 struct hcall_stats *hs = (struct hcall_stats *)m->private;
58
59 if (hs[h_num].num_calls) {
60 if (!cpu_has_feature(CPU_FTR_PURR))
61 seq_printf(m, "%lu %lu %lu %lu\n", h_num<<2,
62 hs[h_num].num_calls,
63 hs[h_num].tb_total,
64 hs[h_num].purr_total);
65 else
66 seq_printf(m, "%lu %lu %lu\n", h_num<<2,
67 hs[h_num].num_calls,
68 hs[h_num].tb_total);
69 }
70
71 return 0;
72}
73
74static struct seq_operations hcall_inst_seq_ops = {
75 .start = hc_start,
76 .next = hc_next,
77 .stop = hc_stop,
78 .show = hc_show
79};
80
81static int hcall_inst_seq_open(struct inode *inode, struct file *file)
82{
83 int rc;
84 struct seq_file *seq;
85
86 rc = seq_open(file, &hcall_inst_seq_ops);
87 seq = file->private_data;
88 seq->private = file->f_dentry->d_inode->u.generic_ip;
89
90 return rc;
91}
92
93static struct file_operations hcall_inst_seq_fops = {
94 .open = hcall_inst_seq_open,
95 .read = seq_read,
96 .llseek = seq_lseek,
97 .release = seq_release,
98};
99
100#define HCALL_ROOT_DIR "hcall_inst"
101#define CPU_NAME_BUF_SIZE 32
102
103static int __init hcall_inst_init(void)
104{
105 struct dentry *hcall_root;
106 struct dentry *hcall_file;
107 char cpu_name_buf[CPU_NAME_BUF_SIZE];
108 int cpu;
109
110 if (!firmware_has_feature(FW_FEATURE_LPAR))
111 return 0;
112
113 hcall_root = debugfs_create_dir(HCALL_ROOT_DIR, NULL);
114 if (!hcall_root)
115 return -ENOMEM;
116
117 for_each_possible_cpu(cpu) {
118 snprintf(cpu_name_buf, CPU_NAME_BUF_SIZE, "cpu%d", cpu);
119 hcall_file = debugfs_create_file(cpu_name_buf, S_IRUGO,
120 hcall_root,
121 per_cpu(hcall_stats, cpu),
122 &hcall_inst_seq_fops);
123 if (!hcall_file)
124 return -ENOMEM;
125 }
126
127 return 0;
128}
129__initcall(hcall_inst_init);
diff --git a/arch/powerpc/platforms/pseries/hvconsole.c b/arch/powerpc/platforms/pseries/hvconsole.c
index a72a987f1d4d..3f6a89b09816 100644
--- a/arch/powerpc/platforms/pseries/hvconsole.c
+++ b/arch/powerpc/platforms/pseries/hvconsole.c
@@ -27,6 +27,7 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <asm/hvcall.h> 28#include <asm/hvcall.h>
29#include <asm/hvconsole.h> 29#include <asm/hvconsole.h>
30#include "plpar_wrappers.h"
30 31
31/** 32/**
32 * hvc_get_chars - retrieve characters from firmware for denoted vterm adatper 33 * hvc_get_chars - retrieve characters from firmware for denoted vterm adatper
@@ -40,9 +41,9 @@ int hvc_get_chars(uint32_t vtermno, char *buf, int count)
40{ 41{
41 unsigned long got; 42 unsigned long got;
42 43
43 if (plpar_hcall(H_GET_TERM_CHAR, vtermno, 0, 0, 0, &got, 44 if (plpar_get_term_char(vtermno, &got, buf) == H_SUCCESS)
44 (unsigned long *)buf, (unsigned long *)buf+1) == H_SUCCESS)
45 return got; 45 return got;
46
46 return 0; 47 return 0;
47} 48}
48 49
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index d67af2c65754..bbf2e34dc358 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -267,13 +267,12 @@ static void iommu_table_setparms(struct pci_controller *phb,
267 struct iommu_table *tbl) 267 struct iommu_table *tbl)
268{ 268{
269 struct device_node *node; 269 struct device_node *node;
270 unsigned long *basep; 270 const unsigned long *basep, *sizep;
271 unsigned int *sizep;
272 271
273 node = (struct device_node *)phb->arch_data; 272 node = (struct device_node *)phb->arch_data;
274 273
275 basep = (unsigned long *)get_property(node, "linux,tce-base", NULL); 274 basep = get_property(node, "linux,tce-base", NULL);
276 sizep = (unsigned int *)get_property(node, "linux,tce-size", NULL); 275 sizep = get_property(node, "linux,tce-size", NULL);
277 if (basep == NULL || sizep == NULL) { 276 if (basep == NULL || sizep == NULL) {
278 printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has " 277 printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has "
279 "missing tce entries !\n", dn->full_name); 278 "missing tce entries !\n", dn->full_name);
@@ -315,7 +314,7 @@ static void iommu_table_setparms(struct pci_controller *phb,
315static void iommu_table_setparms_lpar(struct pci_controller *phb, 314static void iommu_table_setparms_lpar(struct pci_controller *phb,
316 struct device_node *dn, 315 struct device_node *dn,
317 struct iommu_table *tbl, 316 struct iommu_table *tbl,
318 unsigned char *dma_window) 317 const void *dma_window)
319{ 318{
320 unsigned long offset, size; 319 unsigned long offset, size;
321 320
@@ -415,7 +414,7 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus)
415 struct iommu_table *tbl; 414 struct iommu_table *tbl;
416 struct device_node *dn, *pdn; 415 struct device_node *dn, *pdn;
417 struct pci_dn *ppci; 416 struct pci_dn *ppci;
418 unsigned char *dma_window = NULL; 417 const void *dma_window = NULL;
419 418
420 DBG("iommu_bus_setup_pSeriesLP, bus %p, bus->self %p\n", bus, bus->self); 419 DBG("iommu_bus_setup_pSeriesLP, bus %p, bus->self %p\n", bus, bus->self);
421 420
@@ -519,7 +518,7 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
519{ 518{
520 struct device_node *pdn, *dn; 519 struct device_node *pdn, *dn;
521 struct iommu_table *tbl; 520 struct iommu_table *tbl;
522 unsigned char *dma_window = NULL; 521 const void *dma_window = NULL;
523 struct pci_dn *pci; 522 struct pci_dn *pci;
524 523
525 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, pci_name(dev)); 524 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, pci_name(dev));
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 3aeb40699042..1820a0b0a8c6 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -48,13 +48,11 @@
48#define DBG_LOW(fmt...) do { } while(0) 48#define DBG_LOW(fmt...) do { } while(0)
49#endif 49#endif
50 50
51/* in pSeries_hvCall.S */ 51/* in hvCall.S */
52EXPORT_SYMBOL(plpar_hcall); 52EXPORT_SYMBOL(plpar_hcall);
53EXPORT_SYMBOL(plpar_hcall_4out); 53EXPORT_SYMBOL(plpar_hcall9);
54EXPORT_SYMBOL(plpar_hcall_norets); 54EXPORT_SYMBOL(plpar_hcall_norets);
55EXPORT_SYMBOL(plpar_hcall_8arg_2ret); 55
56EXPORT_SYMBOL(plpar_hcall_7arg_7ret);
57EXPORT_SYMBOL(plpar_hcall_9arg_9ret);
58extern void pSeries_find_serial_port(void); 56extern void pSeries_find_serial_port(void);
59 57
60 58
@@ -204,20 +202,20 @@ void __init udbg_init_debug_lpar(void)
204void __init find_udbg_vterm(void) 202void __init find_udbg_vterm(void)
205{ 203{
206 struct device_node *stdout_node; 204 struct device_node *stdout_node;
207 u32 *termno; 205 const u32 *termno;
208 char *name; 206 const char *name;
209 int add_console; 207 int add_console;
210 208
211 /* find the boot console from /chosen/stdout */ 209 /* find the boot console from /chosen/stdout */
212 if (!of_chosen) 210 if (!of_chosen)
213 return; 211 return;
214 name = (char *)get_property(of_chosen, "linux,stdout-path", NULL); 212 name = get_property(of_chosen, "linux,stdout-path", NULL);
215 if (name == NULL) 213 if (name == NULL)
216 return; 214 return;
217 stdout_node = of_find_node_by_path(name); 215 stdout_node = of_find_node_by_path(name);
218 if (!stdout_node) 216 if (!stdout_node)
219 return; 217 return;
220 name = (char *)get_property(stdout_node, "name", NULL); 218 name = get_property(stdout_node, "name", NULL);
221 if (!name) { 219 if (!name) {
222 printk(KERN_WARNING "stdout node missing 'name' property!\n"); 220 printk(KERN_WARNING "stdout node missing 'name' property!\n");
223 goto out; 221 goto out;
@@ -228,7 +226,7 @@ void __init find_udbg_vterm(void)
228 /* Check if it's a virtual terminal */ 226 /* Check if it's a virtual terminal */
229 if (strncmp(name, "vty", 3) != 0) 227 if (strncmp(name, "vty", 3) != 0)
230 goto out; 228 goto out;
231 termno = (u32 *)get_property(stdout_node, "reg", NULL); 229 termno = get_property(stdout_node, "reg", NULL);
232 if (termno == NULL) 230 if (termno == NULL)
233 goto out; 231 goto out;
234 vtermno = termno[0]; 232 vtermno = termno[0];
@@ -254,18 +252,34 @@ out:
254void vpa_init(int cpu) 252void vpa_init(int cpu)
255{ 253{
256 int hwcpu = get_hard_smp_processor_id(cpu); 254 int hwcpu = get_hard_smp_processor_id(cpu);
257 unsigned long vpa = __pa(&lppaca[cpu]); 255 unsigned long addr;
258 long ret; 256 long ret;
259 257
260 if (cpu_has_feature(CPU_FTR_ALTIVEC)) 258 if (cpu_has_feature(CPU_FTR_ALTIVEC))
261 lppaca[cpu].vmxregs_in_use = 1; 259 lppaca[cpu].vmxregs_in_use = 1;
262 260
263 ret = register_vpa(hwcpu, vpa); 261 addr = __pa(&lppaca[cpu]);
262 ret = register_vpa(hwcpu, addr);
264 263
265 if (ret) 264 if (ret) {
266 printk(KERN_ERR "WARNING: vpa_init: VPA registration for " 265 printk(KERN_ERR "WARNING: vpa_init: VPA registration for "
267 "cpu %d (hw %d) of area %lx returns %ld\n", 266 "cpu %d (hw %d) of area %lx returns %ld\n",
268 cpu, hwcpu, vpa, ret); 267 cpu, hwcpu, addr, ret);
268 return;
269 }
270 /*
271 * PAPR says this feature is SLB-Buffer but firmware never
272 * reports that. All SPLPAR support SLB shadow buffer.
273 */
274 addr = __pa(&slb_shadow[cpu]);
275 if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
276 ret = register_slb_shadow(hwcpu, addr);
277 if (ret)
278 printk(KERN_ERR
279 "WARNING: vpa_init: SLB shadow buffer "
280 "registration for cpu %d (hw %d) of area %lx "
281 "returns %ld\n", cpu, hwcpu, addr, ret);
282 }
269} 283}
270 284
271long pSeries_lpar_hpte_insert(unsigned long hpte_group, 285long pSeries_lpar_hpte_insert(unsigned long hpte_group,
@@ -277,7 +291,6 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group,
277 unsigned long flags; 291 unsigned long flags;
278 unsigned long slot; 292 unsigned long slot;
279 unsigned long hpte_v, hpte_r; 293 unsigned long hpte_v, hpte_r;
280 unsigned long dummy0, dummy1;
281 294
282 if (!(vflags & HPTE_V_BOLTED)) 295 if (!(vflags & HPTE_V_BOLTED))
283 DBG_LOW("hpte_insert(group=%lx, va=%016lx, pa=%016lx, " 296 DBG_LOW("hpte_insert(group=%lx, va=%016lx, pa=%016lx, "
@@ -302,8 +315,7 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group,
302 if (rflags & (_PAGE_GUARDED|_PAGE_NO_CACHE)) 315 if (rflags & (_PAGE_GUARDED|_PAGE_NO_CACHE))
303 hpte_r &= ~_PAGE_COHERENT; 316 hpte_r &= ~_PAGE_COHERENT;
304 317
305 lpar_rc = plpar_hcall(H_ENTER, flags, hpte_group, hpte_v, 318 lpar_rc = plpar_pte_enter(flags, hpte_group, hpte_v, hpte_r, &slot);
306 hpte_r, &slot, &dummy0, &dummy1);
307 if (unlikely(lpar_rc == H_PTEG_FULL)) { 319 if (unlikely(lpar_rc == H_PTEG_FULL)) {
308 if (!(vflags & HPTE_V_BOLTED)) 320 if (!(vflags & HPTE_V_BOLTED))
309 DBG_LOW(" full\n"); 321 DBG_LOW(" full\n");
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index 18abfb1f4e24..64163cecdf93 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -123,13 +123,14 @@ static ssize_t pSeries_nvram_get_size(void)
123int __init pSeries_nvram_init(void) 123int __init pSeries_nvram_init(void)
124{ 124{
125 struct device_node *nvram; 125 struct device_node *nvram;
126 unsigned int *nbytes_p, proplen; 126 const unsigned int *nbytes_p;
127 unsigned int proplen;
127 128
128 nvram = of_find_node_by_type(NULL, "nvram"); 129 nvram = of_find_node_by_type(NULL, "nvram");
129 if (nvram == NULL) 130 if (nvram == NULL)
130 return -ENODEV; 131 return -ENODEV;
131 132
132 nbytes_p = (unsigned int *)get_property(nvram, "#bytes", &proplen); 133 nbytes_p = get_property(nvram, "#bytes", &proplen);
133 if (nbytes_p == NULL || proplen != sizeof(unsigned int)) 134 if (nbytes_p == NULL || proplen != sizeof(unsigned int))
134 return -EIO; 135 return -EIO;
135 136
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index e97e67f5e079..410a6bcc4ca0 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -60,7 +60,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_name_device);
60static void __devinit check_s7a(void) 60static void __devinit check_s7a(void)
61{ 61{
62 struct device_node *root; 62 struct device_node *root;
63 char *model; 63 const char *model;
64 64
65 s7a_workaround = 0; 65 s7a_workaround = 0;
66 root = of_find_node_by_path("/"); 66 root = of_find_node_by_path("/");
diff --git a/arch/powerpc/platforms/pseries/plpar_wrappers.h b/arch/powerpc/platforms/pseries/plpar_wrappers.h
index 3bd1b3e06003..3eb7b294d92f 100644
--- a/arch/powerpc/platforms/pseries/plpar_wrappers.h
+++ b/arch/powerpc/platforms/pseries/plpar_wrappers.h
@@ -5,20 +5,17 @@
5 5
6static inline long poll_pending(void) 6static inline long poll_pending(void)
7{ 7{
8 unsigned long dummy; 8 return plpar_hcall_norets(H_POLL_PENDING);
9 return plpar_hcall(H_POLL_PENDING, 0, 0, 0, 0, &dummy, &dummy, &dummy);
10} 9}
11 10
12static inline long prod_processor(void) 11static inline long prod_processor(void)
13{ 12{
14 plpar_hcall_norets(H_PROD); 13 return plpar_hcall_norets(H_PROD);
15 return 0;
16} 14}
17 15
18static inline long cede_processor(void) 16static inline long cede_processor(void)
19{ 17{
20 plpar_hcall_norets(H_CEDE); 18 return plpar_hcall_norets(H_CEDE);
21 return 0;
22} 19}
23 20
24static inline long vpa_call(unsigned long flags, unsigned long cpu, 21static inline long vpa_call(unsigned long flags, unsigned long cpu,
@@ -40,23 +37,59 @@ static inline long register_vpa(unsigned long cpu, unsigned long vpa)
40 return vpa_call(0x1, cpu, vpa); 37 return vpa_call(0x1, cpu, vpa);
41} 38}
42 39
40static inline long unregister_slb_shadow(unsigned long cpu, unsigned long vpa)
41{
42 return vpa_call(0x7, cpu, vpa);
43}
44
45static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
46{
47 return vpa_call(0x3, cpu, vpa);
48}
49
43extern void vpa_init(int cpu); 50extern void vpa_init(int cpu);
44 51
52static inline long plpar_pte_enter(unsigned long flags,
53 unsigned long hpte_group, unsigned long hpte_v,
54 unsigned long hpte_r, unsigned long *slot)
55{
56 long rc;
57 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
58
59 rc = plpar_hcall(H_ENTER, retbuf, flags, hpte_group, hpte_v, hpte_r);
60
61 *slot = retbuf[0];
62
63 return rc;
64}
65
45static inline long plpar_pte_remove(unsigned long flags, unsigned long ptex, 66static inline long plpar_pte_remove(unsigned long flags, unsigned long ptex,
46 unsigned long avpn, unsigned long *old_pteh_ret, 67 unsigned long avpn, unsigned long *old_pteh_ret,
47 unsigned long *old_ptel_ret) 68 unsigned long *old_ptel_ret)
48{ 69{
49 unsigned long dummy; 70 long rc;
50 return plpar_hcall(H_REMOVE, flags, ptex, avpn, 0, old_pteh_ret, 71 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
51 old_ptel_ret, &dummy); 72
73 rc = plpar_hcall(H_REMOVE, retbuf, flags, ptex, avpn);
74
75 *old_pteh_ret = retbuf[0];
76 *old_ptel_ret = retbuf[1];
77
78 return rc;
52} 79}
53 80
54static inline long plpar_pte_read(unsigned long flags, unsigned long ptex, 81static inline long plpar_pte_read(unsigned long flags, unsigned long ptex,
55 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret) 82 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret)
56{ 83{
57 unsigned long dummy; 84 long rc;
58 return plpar_hcall(H_READ, flags, ptex, 0, 0, old_pteh_ret, 85 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
59 old_ptel_ret, &dummy); 86
87 rc = plpar_hcall(H_READ, retbuf, flags, ptex);
88
89 *old_pteh_ret = retbuf[0];
90 *old_ptel_ret = retbuf[1];
91
92 return rc;
60} 93}
61 94
62static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex, 95static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex,
@@ -68,9 +101,14 @@ static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex,
68static inline long plpar_tce_get(unsigned long liobn, unsigned long ioba, 101static inline long plpar_tce_get(unsigned long liobn, unsigned long ioba,
69 unsigned long *tce_ret) 102 unsigned long *tce_ret)
70{ 103{
71 unsigned long dummy; 104 long rc;
72 return plpar_hcall(H_GET_TCE, liobn, ioba, 0, 0, tce_ret, &dummy, 105 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
73 &dummy); 106
107 rc = plpar_hcall(H_GET_TCE, retbuf, liobn, ioba);
108
109 *tce_ret = retbuf[0];
110
111 return rc;
74} 112}
75 113
76static inline long plpar_tce_put(unsigned long liobn, unsigned long ioba, 114static inline long plpar_tce_put(unsigned long liobn, unsigned long ioba,
@@ -94,9 +132,17 @@ static inline long plpar_tce_stuff(unsigned long liobn, unsigned long ioba,
94static inline long plpar_get_term_char(unsigned long termno, 132static inline long plpar_get_term_char(unsigned long termno,
95 unsigned long *len_ret, char *buf_ret) 133 unsigned long *len_ret, char *buf_ret)
96{ 134{
135 long rc;
136 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
97 unsigned long *lbuf = (unsigned long *)buf_ret; /* TODO: alignment? */ 137 unsigned long *lbuf = (unsigned long *)buf_ret; /* TODO: alignment? */
98 return plpar_hcall(H_GET_TERM_CHAR, termno, 0, 0, 0, len_ret, 138
99 lbuf + 0, lbuf + 1); 139 rc = plpar_hcall(H_GET_TERM_CHAR, retbuf, termno);
140
141 *len_ret = retbuf[0];
142 lbuf[0] = retbuf[1];
143 lbuf[1] = retbuf[2];
144
145 return rc;
100} 146}
101 147
102static inline long plpar_put_term_char(unsigned long termno, unsigned long len, 148static inline long plpar_put_term_char(unsigned long termno, unsigned long len,
@@ -107,4 +153,31 @@ static inline long plpar_put_term_char(unsigned long termno, unsigned long len,
107 lbuf[1]); 153 lbuf[1]);
108} 154}
109 155
156static inline long plpar_eoi(unsigned long xirr)
157{
158 return plpar_hcall_norets(H_EOI, xirr);
159}
160
161static inline long plpar_cppr(unsigned long cppr)
162{
163 return plpar_hcall_norets(H_CPPR, cppr);
164}
165
166static inline long plpar_ipi(unsigned long servernum, unsigned long mfrr)
167{
168 return plpar_hcall_norets(H_IPI, servernum, mfrr);
169}
170
171static inline long plpar_xirr(unsigned long *xirr_ret)
172{
173 long rc;
174 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
175
176 rc = plpar_hcall(H_XIRR, retbuf);
177
178 *xirr_ret = retbuf[0];
179
180 return rc;
181}
182
110#endif /* _PSERIES_PLPAR_WRAPPERS_H */ 183#endif /* _PSERIES_PLPAR_WRAPPERS_H */
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index c7ffde1a614e..903115d67fdc 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -79,7 +79,7 @@ static void request_ras_irqs(struct device_node *np,
79{ 79{
80 int i, index, count = 0; 80 int i, index, count = 0;
81 struct of_irq oirq; 81 struct of_irq oirq;
82 u32 *opicprop; 82 const u32 *opicprop;
83 unsigned int opicplen; 83 unsigned int opicplen;
84 unsigned int virqs[16]; 84 unsigned int virqs[16];
85 85
@@ -87,7 +87,7 @@ static void request_ras_irqs(struct device_node *np,
87 * map those interrupts using the default interrupt host and default 87 * map those interrupts using the default interrupt host and default
88 * trigger 88 * trigger
89 */ 89 */
90 opicprop = (u32 *)get_property(np, "open-pic-interrupt", &opicplen); 90 opicprop = get_property(np, "open-pic-interrupt", &opicplen);
91 if (opicprop) { 91 if (opicprop) {
92 opicplen /= sizeof(u32); 92 opicplen /= sizeof(u32);
93 for (i = 0; i < opicplen; i++) { 93 for (i = 0; i < opicplen; i++) {
diff --git a/arch/powerpc/platforms/pseries/rtasd.c b/arch/powerpc/platforms/pseries/rtasd.c
index 2e4e04042d85..8ca2612221d6 100644
--- a/arch/powerpc/platforms/pseries/rtasd.c
+++ b/arch/powerpc/platforms/pseries/rtasd.c
@@ -359,11 +359,11 @@ static int enable_surveillance(int timeout)
359static int get_eventscan_parms(void) 359static int get_eventscan_parms(void)
360{ 360{
361 struct device_node *node; 361 struct device_node *node;
362 int *ip; 362 const int *ip;
363 363
364 node = of_find_node_by_path("/rtas"); 364 node = of_find_node_by_path("/rtas");
365 365
366 ip = (int *)get_property(node, "rtas-event-scan-rate", NULL); 366 ip = get_property(node, "rtas-event-scan-rate", NULL);
367 if (ip == NULL) { 367 if (ip == NULL) {
368 printk(KERN_ERR "rtasd: no rtas-event-scan-rate\n"); 368 printk(KERN_ERR "rtasd: no rtas-event-scan-rate\n");
369 of_node_put(node); 369 of_node_put(node);
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 31867a701fcb..a6398fbe530d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -133,9 +133,9 @@ void pseries_8259_cascade(unsigned int irq, struct irq_desc *desc,
133static void __init pseries_mpic_init_IRQ(void) 133static void __init pseries_mpic_init_IRQ(void)
134{ 134{
135 struct device_node *np, *old, *cascade = NULL; 135 struct device_node *np, *old, *cascade = NULL;
136 unsigned int *addrp; 136 const unsigned int *addrp;
137 unsigned long intack = 0; 137 unsigned long intack = 0;
138 unsigned int *opprop; 138 const unsigned int *opprop;
139 unsigned long openpic_addr = 0; 139 unsigned long openpic_addr = 0;
140 unsigned int cascade_irq; 140 unsigned int cascade_irq;
141 int naddr, n, i, opplen; 141 int naddr, n, i, opplen;
@@ -143,7 +143,7 @@ static void __init pseries_mpic_init_IRQ(void)
143 143
144 np = of_find_node_by_path("/"); 144 np = of_find_node_by_path("/");
145 naddr = prom_n_addr_cells(np); 145 naddr = prom_n_addr_cells(np);
146 opprop = (unsigned int *) get_property(np, "platform-open-pic", &opplen); 146 opprop = get_property(np, "platform-open-pic", &opplen);
147 if (opprop != 0) { 147 if (opprop != 0) {
148 openpic_addr = of_read_number(opprop, naddr); 148 openpic_addr = of_read_number(opprop, naddr);
149 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr); 149 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
@@ -192,7 +192,7 @@ static void __init pseries_mpic_init_IRQ(void)
192 break; 192 break;
193 if (strcmp(np->name, "pci") != 0) 193 if (strcmp(np->name, "pci") != 0)
194 continue; 194 continue;
195 addrp = (u32 *)get_property(np, "8259-interrupt-acknowledge", 195 addrp = get_property(np, "8259-interrupt-acknowledge",
196 NULL); 196 NULL);
197 if (addrp == NULL) 197 if (addrp == NULL)
198 continue; 198 continue;
@@ -223,23 +223,37 @@ static void pseries_lpar_enable_pmcs(void)
223} 223}
224 224
225#ifdef CONFIG_KEXEC 225#ifdef CONFIG_KEXEC
226static void pseries_kexec_cpu_down_mpic(int crash_shutdown, int secondary) 226static void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
227{
228 mpic_teardown_this_cpu(secondary);
229}
230
231static void pseries_kexec_cpu_down_xics(int crash_shutdown, int secondary)
232{ 227{
233 /* Don't risk a hypervisor call if we're crashing */ 228 /* Don't risk a hypervisor call if we're crashing */
234 if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) { 229 if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) {
235 unsigned long vpa = __pa(get_lppaca()); 230 unsigned long addr;
236 231
237 if (unregister_vpa(hard_smp_processor_id(), vpa)) { 232 addr = __pa(get_slb_shadow());
233 if (unregister_slb_shadow(hard_smp_processor_id(), addr))
234 printk("SLB shadow buffer deregistration of "
235 "cpu %u (hw_cpu_id %d) failed\n",
236 smp_processor_id(),
237 hard_smp_processor_id());
238
239 addr = __pa(get_lppaca());
240 if (unregister_vpa(hard_smp_processor_id(), addr)) {
238 printk("VPA deregistration of cpu %u (hw_cpu_id %d) " 241 printk("VPA deregistration of cpu %u (hw_cpu_id %d) "
239 "failed\n", smp_processor_id(), 242 "failed\n", smp_processor_id(),
240 hard_smp_processor_id()); 243 hard_smp_processor_id());
241 } 244 }
242 } 245 }
246}
247
248static void pseries_kexec_cpu_down_mpic(int crash_shutdown, int secondary)
249{
250 pseries_kexec_cpu_down(crash_shutdown, secondary);
251 mpic_teardown_this_cpu(secondary);
252}
253
254static void pseries_kexec_cpu_down_xics(int crash_shutdown, int secondary)
255{
256 pseries_kexec_cpu_down(crash_shutdown, secondary);
243 xics_teardown_cpu(secondary); 257 xics_teardown_cpu(secondary);
244} 258}
245#endif /* CONFIG_KEXEC */ 259#endif /* CONFIG_KEXEC */
@@ -247,11 +261,11 @@ static void pseries_kexec_cpu_down_xics(int crash_shutdown, int secondary)
247static void __init pseries_discover_pic(void) 261static void __init pseries_discover_pic(void)
248{ 262{
249 struct device_node *np; 263 struct device_node *np;
250 char *typep; 264 const char *typep;
251 265
252 for (np = NULL; (np = of_find_node_by_name(np, 266 for (np = NULL; (np = of_find_node_by_name(np,
253 "interrupt-controller"));) { 267 "interrupt-controller"));) {
254 typep = (char *)get_property(np, "compatible", NULL); 268 typep = get_property(np, "compatible", NULL);
255 if (strstr(typep, "open-pic")) { 269 if (strstr(typep, "open-pic")) {
256 pSeries_mpic_node = of_node_get(np); 270 pSeries_mpic_node = of_node_get(np);
257 ppc_md.init_IRQ = pseries_mpic_init_IRQ; 271 ppc_md.init_IRQ = pseries_mpic_init_IRQ;
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index ac61098ff401..c6624b8a0e77 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -62,7 +62,7 @@
62 */ 62 */
63static cpumask_t of_spin_map; 63static cpumask_t of_spin_map;
64 64
65extern void pSeries_secondary_smp_init(unsigned long); 65extern void generic_secondary_smp_init(unsigned long);
66 66
67#ifdef CONFIG_HOTPLUG_CPU 67#ifdef CONFIG_HOTPLUG_CPU
68 68
@@ -145,9 +145,9 @@ static int pSeries_add_processor(struct device_node *np)
145 unsigned int cpu; 145 unsigned int cpu;
146 cpumask_t candidate_map, tmp = CPU_MASK_NONE; 146 cpumask_t candidate_map, tmp = CPU_MASK_NONE;
147 int err = -ENOSPC, len, nthreads, i; 147 int err = -ENOSPC, len, nthreads, i;
148 u32 *intserv; 148 const u32 *intserv;
149 149
150 intserv = (u32 *)get_property(np, "ibm,ppc-interrupt-server#s", &len); 150 intserv = get_property(np, "ibm,ppc-interrupt-server#s", &len);
151 if (!intserv) 151 if (!intserv)
152 return 0; 152 return 0;
153 153
@@ -205,9 +205,9 @@ static void pSeries_remove_processor(struct device_node *np)
205{ 205{
206 unsigned int cpu; 206 unsigned int cpu;
207 int len, nthreads, i; 207 int len, nthreads, i;
208 u32 *intserv; 208 const u32 *intserv;
209 209
210 intserv = (u32 *)get_property(np, "ibm,ppc-interrupt-server#s", &len); 210 intserv = get_property(np, "ibm,ppc-interrupt-server#s", &len);
211 if (!intserv) 211 if (!intserv)
212 return; 212 return;
213 213
@@ -270,7 +270,7 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
270{ 270{
271 int status; 271 int status;
272 unsigned long start_here = __pa((u32)*((unsigned long *) 272 unsigned long start_here = __pa((u32)*((unsigned long *)
273 pSeries_secondary_smp_init)); 273 generic_secondary_smp_init));
274 unsigned int pcpu; 274 unsigned int pcpu;
275 int start_cpu; 275 int start_cpu;
276 276
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index e98863025721..253972e5479f 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -34,6 +34,7 @@
34#include <asm/i8259.h> 34#include <asm/i8259.h>
35 35
36#include "xics.h" 36#include "xics.h"
37#include "plpar_wrappers.h"
37 38
38#define XICS_IPI 2 39#define XICS_IPI 2
39#define XICS_IRQ_SPURIOUS 0 40#define XICS_IRQ_SPURIOUS 0
@@ -110,27 +111,6 @@ static inline void direct_qirr_info(int n_cpu, u8 value)
110/* LPAR low level accessors */ 111/* LPAR low level accessors */
111 112
112 113
113static inline long plpar_eoi(unsigned long xirr)
114{
115 return plpar_hcall_norets(H_EOI, xirr);
116}
117
118static inline long plpar_cppr(unsigned long cppr)
119{
120 return plpar_hcall_norets(H_CPPR, cppr);
121}
122
123static inline long plpar_ipi(unsigned long servernum, unsigned long mfrr)
124{
125 return plpar_hcall_norets(H_IPI, servernum, mfrr);
126}
127
128static inline long plpar_xirr(unsigned long *xirr_ret)
129{
130 unsigned long dummy;
131 return plpar_hcall(H_XIRR, 0, 0, 0, 0, xirr_ret, &dummy, &dummy);
132}
133
134static inline unsigned int lpar_xirr_info_get(int n_cpu) 114static inline unsigned int lpar_xirr_info_get(int n_cpu)
135{ 115{
136 unsigned long lpar_rc; 116 unsigned long lpar_rc;
@@ -590,14 +570,14 @@ static void __init xics_init_one_node(struct device_node *np,
590 unsigned int *indx) 570 unsigned int *indx)
591{ 571{
592 unsigned int ilen; 572 unsigned int ilen;
593 u32 *ireg; 573 const u32 *ireg;
594 574
595 /* This code does the theorically broken assumption that the interrupt 575 /* This code does the theorically broken assumption that the interrupt
596 * server numbers are the same as the hard CPU numbers. 576 * server numbers are the same as the hard CPU numbers.
597 * This happens to be the case so far but we are playing with fire... 577 * This happens to be the case so far but we are playing with fire...
598 * should be fixed one of these days. -BenH. 578 * should be fixed one of these days. -BenH.
599 */ 579 */
600 ireg = (u32 *)get_property(np, "ibm,interrupt-server-ranges", NULL); 580 ireg = get_property(np, "ibm,interrupt-server-ranges", NULL);
601 581
602 /* Do that ever happen ? we'll know soon enough... but even good'old 582 /* Do that ever happen ? we'll know soon enough... but even good'old
603 * f80 does have that property .. 583 * f80 does have that property ..
@@ -609,7 +589,7 @@ static void __init xics_init_one_node(struct device_node *np,
609 */ 589 */
610 *indx = *ireg; 590 *indx = *ireg;
611 } 591 }
612 ireg = (u32 *)get_property(np, "reg", &ilen); 592 ireg = get_property(np, "reg", &ilen);
613 if (!ireg) 593 if (!ireg)
614 panic("xics_init_IRQ: can't find interrupt reg property"); 594 panic("xics_init_IRQ: can't find interrupt reg property");
615 595
@@ -635,7 +615,7 @@ static void __init xics_setup_8259_cascade(void)
635{ 615{
636 struct device_node *np, *old, *found = NULL; 616 struct device_node *np, *old, *found = NULL;
637 int cascade, naddr; 617 int cascade, naddr;
638 u32 *addrp; 618 const u32 *addrp;
639 unsigned long intack = 0; 619 unsigned long intack = 0;
640 620
641 for_each_node_by_type(np, "interrupt-controller") 621 for_each_node_by_type(np, "interrupt-controller")
@@ -661,7 +641,7 @@ static void __init xics_setup_8259_cascade(void)
661 break; 641 break;
662 if (strcmp(np->name, "pci") != 0) 642 if (strcmp(np->name, "pci") != 0)
663 continue; 643 continue;
664 addrp = (u32 *)get_property(np, "8259-interrupt-acknowledge", NULL); 644 addrp = get_property(np, "8259-interrupt-acknowledge", NULL);
665 if (addrp == NULL) 645 if (addrp == NULL)
666 continue; 646 continue;
667 naddr = prom_n_addr_cells(np); 647 naddr = prom_n_addr_cells(np);
@@ -680,7 +660,8 @@ void __init xics_init_IRQ(void)
680{ 660{
681 int i; 661 int i;
682 struct device_node *np; 662 struct device_node *np;
683 u32 *ireg, ilen, indx = 0; 663 u32 ilen, indx = 0;
664 const u32 *ireg;
684 int found = 0; 665 int found = 0;
685 666
686 ppc64_boot_msg(0x20, "XICS Init"); 667 ppc64_boot_msg(0x20, "XICS Init");
@@ -705,18 +686,17 @@ void __init xics_init_IRQ(void)
705 for (np = of_find_node_by_type(NULL, "cpu"); 686 for (np = of_find_node_by_type(NULL, "cpu");
706 np; 687 np;
707 np = of_find_node_by_type(np, "cpu")) { 688 np = of_find_node_by_type(np, "cpu")) {
708 ireg = (u32 *)get_property(np, "reg", &ilen); 689 ireg = get_property(np, "reg", &ilen);
709 if (ireg && ireg[0] == get_hard_smp_processor_id(boot_cpuid)) { 690 if (ireg && ireg[0] == get_hard_smp_processor_id(boot_cpuid)) {
710 ireg = (u32 *)get_property(np, 691 ireg = get_property(np,
711 "ibm,ppc-interrupt-gserver#s", 692 "ibm,ppc-interrupt-gserver#s", &ilen);
712 &ilen);
713 i = ilen / sizeof(int); 693 i = ilen / sizeof(int);
714 if (ireg && i > 0) { 694 if (ireg && i > 0) {
715 default_server = ireg[0]; 695 default_server = ireg[0];
716 /* take last element */ 696 /* take last element */
717 default_distrib_server = ireg[i-1]; 697 default_distrib_server = ireg[i-1];
718 } 698 }
719 ireg = (u32 *)get_property(np, 699 ireg = get_property(np,
720 "ibm,interrupt-server#-size", NULL); 700 "ibm,interrupt-server#-size", NULL);
721 if (ireg) 701 if (ireg)
722 interrupt_server_size = *ireg; 702 interrupt_server_size = *ireg;