aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/kernel/of_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc64/kernel/of_device.c')
-rw-r--r--arch/sparc64/kernel/of_device.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c
index f8b50cbf4bf..100ebd52749 100644
--- a/arch/sparc64/kernel/of_device.c
+++ b/arch/sparc64/kernel/of_device.c
@@ -96,7 +96,7 @@ struct of_bus {
96 int *addrc, int *sizec); 96 int *addrc, int *sizec);
97 int (*map)(u32 *addr, const u32 *range, 97 int (*map)(u32 *addr, const u32 *range,
98 int na, int ns, int pna); 98 int na, int ns, int pna);
99 unsigned int (*get_flags)(const u32 *addr); 99 unsigned long (*get_flags)(const u32 *addr, unsigned long);
100}; 100};
101 101
102/* 102/*
@@ -156,8 +156,10 @@ static int of_bus_default_map(u32 *addr, const u32 *range,
156 return 0; 156 return 0;
157} 157}
158 158
159static unsigned int of_bus_default_get_flags(const u32 *addr) 159static unsigned long of_bus_default_get_flags(const u32 *addr, unsigned long flags)
160{ 160{
161 if (flags)
162 return flags;
161 return IORESOURCE_MEM; 163 return IORESOURCE_MEM;
162} 164}
163 165
@@ -167,7 +169,7 @@ static unsigned int of_bus_default_get_flags(const u32 *addr)
167 169
168static int of_bus_pci_match(struct device_node *np) 170static int of_bus_pci_match(struct device_node *np)
169{ 171{
170 if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) { 172 if (!strcmp(np->name, "pci")) {
171 const char *model = of_get_property(np, "model", NULL); 173 const char *model = of_get_property(np, "model", NULL);
172 174
173 if (model && !strcmp(model, "SUNW,simba")) 175 if (model && !strcmp(model, "SUNW,simba"))
@@ -198,7 +200,7 @@ static int of_bus_simba_match(struct device_node *np)
198 /* Treat PCI busses lacking ranges property just like 200 /* Treat PCI busses lacking ranges property just like
199 * simba. 201 * simba.
200 */ 202 */
201 if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) { 203 if (!strcmp(np->name, "pci")) {
202 if (!of_find_property(np, "ranges", NULL)) 204 if (!of_find_property(np, "ranges", NULL))
203 return 1; 205 return 1;
204 } 206 }
@@ -249,17 +251,21 @@ static int of_bus_pci_map(u32 *addr, const u32 *range,
249 return 0; 251 return 0;
250} 252}
251 253
252static unsigned int of_bus_pci_get_flags(const u32 *addr) 254static unsigned long of_bus_pci_get_flags(const u32 *addr, unsigned long flags)
253{ 255{
254 unsigned int flags = 0;
255 u32 w = addr[0]; 256 u32 w = addr[0];
256 257
258 /* For PCI, we override whatever child busses may have used. */
259 flags = 0;
257 switch((w >> 24) & 0x03) { 260 switch((w >> 24) & 0x03) {
258 case 0x01: 261 case 0x01:
259 flags |= IORESOURCE_IO; 262 flags |= IORESOURCE_IO;
263 break;
264
260 case 0x02: /* 32 bits */ 265 case 0x02: /* 32 bits */
261 case 0x03: /* 64 bits */ 266 case 0x03: /* 64 bits */
262 flags |= IORESOURCE_MEM; 267 flags |= IORESOURCE_MEM;
268 break;
263 } 269 }
264 if (w & 0x40000000) 270 if (w & 0x40000000)
265 flags |= IORESOURCE_PREFETCH; 271 flags |= IORESOURCE_PREFETCH;
@@ -423,7 +429,7 @@ static int __init use_1to1_mapping(struct device_node *pp)
423 * it lacks a ranges property, and this will include 429 * it lacks a ranges property, and this will include
424 * cases like Simba. 430 * cases like Simba.
425 */ 431 */
426 if (!strcmp(pp->type, "pci") || !strcmp(pp->type, "pciex")) 432 if (!strcmp(pp->name, "pci"))
427 return 0; 433 return 0;
428 434
429 return 1; 435 return 1;
@@ -478,10 +484,10 @@ static void __init build_device_resources(struct of_device *op,
478 int pna, pns; 484 int pna, pns;
479 485
480 size = of_read_addr(reg + na, ns); 486 size = of_read_addr(reg + na, ns);
481 flags = bus->get_flags(reg);
482
483 memcpy(addr, reg, na * 4); 487 memcpy(addr, reg, na * 4);
484 488
489 flags = bus->get_flags(addr, 0);
490
485 if (use_1to1_mapping(pp)) { 491 if (use_1to1_mapping(pp)) {
486 result = of_read_addr(addr, na); 492 result = of_read_addr(addr, na);
487 goto build_res; 493 goto build_res;
@@ -506,6 +512,8 @@ static void __init build_device_resources(struct of_device *op,
506 dna, dns, pna)) 512 dna, dns, pna))
507 break; 513 break;
508 514
515 flags = pbus->get_flags(addr, flags);
516
509 dna = pna; 517 dna = pna;
510 dns = pns; 518 dns = pns;
511 dbus = pbus; 519 dbus = pbus;
@@ -706,8 +714,7 @@ static unsigned int __init build_one_device_irq(struct of_device *op,
706 break; 714 break;
707 } 715 }
708 } else { 716 } else {
709 if (!strcmp(pp->type, "pci") || 717 if (!strcmp(pp->name, "pci")) {
710 !strcmp(pp->type, "pciex")) {
711 unsigned int this_orig_irq = irq; 718 unsigned int this_orig_irq = irq;
712 719
713 irq = pci_irq_swizzle(dp, pp, irq); 720 irq = pci_irq_swizzle(dp, pp, irq);