aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sparc/kernel/of_device.c19
-rw-r--r--arch/sparc64/kernel/of_device.c20
2 files changed, 28 insertions, 11 deletions
diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c
index cc4c235c4f59..c481d45f97b7 100644
--- a/arch/sparc/kernel/of_device.c
+++ b/arch/sparc/kernel/of_device.c
@@ -70,7 +70,7 @@ struct of_bus {
70 int *addrc, int *sizec); 70 int *addrc, int *sizec);
71 int (*map)(u32 *addr, const u32 *range, 71 int (*map)(u32 *addr, const u32 *range,
72 int na, int ns, int pna); 72 int na, int ns, int pna);
73 unsigned int (*get_flags)(const u32 *addr); 73 unsigned long (*get_flags)(const u32 *addr, unsigned long);
74}; 74};
75 75
76/* 76/*
@@ -130,8 +130,10 @@ static int of_bus_default_map(u32 *addr, const u32 *range,
130 return 0; 130 return 0;
131} 131}
132 132
133static unsigned int of_bus_default_get_flags(const u32 *addr) 133static unsigned long of_bus_default_get_flags(const u32 *addr, unsigned long flags)
134{ 134{
135 if (flags)
136 return flags;
135 return IORESOURCE_MEM; 137 return IORESOURCE_MEM;
136} 138}
137 139
@@ -194,17 +196,21 @@ static int of_bus_pci_map(u32 *addr, const u32 *range,
194 return 0; 196 return 0;
195} 197}
196 198
197static unsigned int of_bus_pci_get_flags(const u32 *addr) 199static unsigned long of_bus_pci_get_flags(const u32 *addr, unsigned long flags)
198{ 200{
199 unsigned int flags = 0;
200 u32 w = addr[0]; 201 u32 w = addr[0];
201 202
203 /* For PCI, we override whatever child busses may have used. */
204 flags = 0;
202 switch((w >> 24) & 0x03) { 205 switch((w >> 24) & 0x03) {
203 case 0x01: 206 case 0x01:
204 flags |= IORESOURCE_IO; 207 flags |= IORESOURCE_IO;
208 break;
209
205 case 0x02: /* 32 bits */ 210 case 0x02: /* 32 bits */
206 case 0x03: /* 64 bits */ 211 case 0x03: /* 64 bits */
207 flags |= IORESOURCE_MEM; 212 flags |= IORESOURCE_MEM;
213 break;
208 } 214 }
209 if (w & 0x40000000) 215 if (w & 0x40000000)
210 flags |= IORESOURCE_PREFETCH; 216 flags |= IORESOURCE_PREFETCH;
@@ -362,10 +368,11 @@ static void __init build_device_resources(struct of_device *op,
362 int pna, pns; 368 int pna, pns;
363 369
364 size = of_read_addr(reg + na, ns); 370 size = of_read_addr(reg + na, ns);
365 flags = bus->get_flags(reg);
366 371
367 memcpy(addr, reg, na * 4); 372 memcpy(addr, reg, na * 4);
368 373
374 flags = bus->get_flags(reg, 0);
375
369 /* If the immediate parent has no ranges property to apply, 376 /* If the immediate parent has no ranges property to apply,
370 * just use a 1<->1 mapping. 377 * just use a 1<->1 mapping.
371 */ 378 */
@@ -393,6 +400,8 @@ static void __init build_device_resources(struct of_device *op,
393 dna, dns, pna)) 400 dna, dns, pna))
394 break; 401 break;
395 402
403 flags = pbus->get_flags(addr, flags);
404
396 dna = pna; 405 dna = pna;
397 dns = pns; 406 dns = pns;
398 dbus = pbus; 407 dbus = pbus;
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c
index f8b50cbf4bf7..f845f150f565 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
@@ -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;
@@ -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;