diff options
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/address.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/drivers/of/address.c b/drivers/of/address.c index 3a1c7e70b192..b4559c58c095 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c | |||
@@ -12,13 +12,13 @@ | |||
12 | (ns) > 0) | 12 | (ns) > 0) |
13 | 13 | ||
14 | static struct of_bus *of_match_bus(struct device_node *np); | 14 | static struct of_bus *of_match_bus(struct device_node *np); |
15 | static int __of_address_to_resource(struct device_node *dev, const u32 *addrp, | 15 | static int __of_address_to_resource(struct device_node *dev, |
16 | u64 size, unsigned int flags, | 16 | const __be32 *addrp, u64 size, unsigned int flags, |
17 | struct resource *r); | 17 | struct resource *r); |
18 | 18 | ||
19 | /* Debug utility */ | 19 | /* Debug utility */ |
20 | #ifdef DEBUG | 20 | #ifdef DEBUG |
21 | static void of_dump_addr(const char *s, const u32 *addr, int na) | 21 | static void of_dump_addr(const char *s, const __be32 *addr, int na) |
22 | { | 22 | { |
23 | printk(KERN_DEBUG "%s", s); | 23 | printk(KERN_DEBUG "%s", s); |
24 | while (na--) | 24 | while (na--) |
@@ -26,7 +26,7 @@ static void of_dump_addr(const char *s, const u32 *addr, int na) | |||
26 | printk("\n"); | 26 | printk("\n"); |
27 | } | 27 | } |
28 | #else | 28 | #else |
29 | static void of_dump_addr(const char *s, const u32 *addr, int na) { } | 29 | static void of_dump_addr(const char *s, const __be32 *addr, int na) { } |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | /* Callbacks for bus specific translators */ | 32 | /* Callbacks for bus specific translators */ |
@@ -36,10 +36,10 @@ struct of_bus { | |||
36 | int (*match)(struct device_node *parent); | 36 | int (*match)(struct device_node *parent); |
37 | void (*count_cells)(struct device_node *child, | 37 | void (*count_cells)(struct device_node *child, |
38 | int *addrc, int *sizec); | 38 | int *addrc, int *sizec); |
39 | u64 (*map)(u32 *addr, const u32 *range, | 39 | u64 (*map)(u32 *addr, const __be32 *range, |
40 | int na, int ns, int pna); | 40 | int na, int ns, int pna); |
41 | int (*translate)(u32 *addr, u64 offset, int na); | 41 | int (*translate)(u32 *addr, u64 offset, int na); |
42 | unsigned int (*get_flags)(const u32 *addr); | 42 | unsigned int (*get_flags)(const __be32 *addr); |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /* | 45 | /* |
@@ -55,7 +55,7 @@ static void of_bus_default_count_cells(struct device_node *dev, | |||
55 | *sizec = of_n_size_cells(dev); | 55 | *sizec = of_n_size_cells(dev); |
56 | } | 56 | } |
57 | 57 | ||
58 | static u64 of_bus_default_map(u32 *addr, const u32 *range, | 58 | static u64 of_bus_default_map(u32 *addr, const __be32 *range, |
59 | int na, int ns, int pna) | 59 | int na, int ns, int pna) |
60 | { | 60 | { |
61 | u64 cp, s, da; | 61 | u64 cp, s, da; |
@@ -85,7 +85,7 @@ static int of_bus_default_translate(u32 *addr, u64 offset, int na) | |||
85 | return 0; | 85 | return 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | static unsigned int of_bus_default_get_flags(const u32 *addr) | 88 | static unsigned int of_bus_default_get_flags(const __be32 *addr) |
89 | { | 89 | { |
90 | return IORESOURCE_MEM; | 90 | return IORESOURCE_MEM; |
91 | } | 91 | } |
@@ -110,10 +110,10 @@ static void of_bus_pci_count_cells(struct device_node *np, | |||
110 | *sizec = 2; | 110 | *sizec = 2; |
111 | } | 111 | } |
112 | 112 | ||
113 | static unsigned int of_bus_pci_get_flags(const u32 *addr) | 113 | static unsigned int of_bus_pci_get_flags(const __be32 *addr) |
114 | { | 114 | { |
115 | unsigned int flags = 0; | 115 | unsigned int flags = 0; |
116 | u32 w = addr[0]; | 116 | u32 w = be32_to_cpup(addr); |
117 | 117 | ||
118 | switch((w >> 24) & 0x03) { | 118 | switch((w >> 24) & 0x03) { |
119 | case 0x01: | 119 | case 0x01: |
@@ -129,7 +129,8 @@ static unsigned int of_bus_pci_get_flags(const u32 *addr) | |||
129 | return flags; | 129 | return flags; |
130 | } | 130 | } |
131 | 131 | ||
132 | static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna) | 132 | static u64 of_bus_pci_map(u32 *addr, const __be32 *range, int na, int ns, |
133 | int pna) | ||
133 | { | 134 | { |
134 | u64 cp, s, da; | 135 | u64 cp, s, da; |
135 | unsigned int af, rf; | 136 | unsigned int af, rf; |
@@ -160,7 +161,7 @@ static int of_bus_pci_translate(u32 *addr, u64 offset, int na) | |||
160 | return of_bus_default_translate(addr + 1, offset, na - 1); | 161 | return of_bus_default_translate(addr + 1, offset, na - 1); |
161 | } | 162 | } |
162 | 163 | ||
163 | const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, | 164 | const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, |
164 | unsigned int *flags) | 165 | unsigned int *flags) |
165 | { | 166 | { |
166 | const __be32 *prop; | 167 | const __be32 *prop; |
@@ -207,7 +208,7 @@ EXPORT_SYMBOL(of_get_pci_address); | |||
207 | int of_pci_address_to_resource(struct device_node *dev, int bar, | 208 | int of_pci_address_to_resource(struct device_node *dev, int bar, |
208 | struct resource *r) | 209 | struct resource *r) |
209 | { | 210 | { |
210 | const u32 *addrp; | 211 | const __be32 *addrp; |
211 | u64 size; | 212 | u64 size; |
212 | unsigned int flags; | 213 | unsigned int flags; |
213 | 214 | ||
@@ -237,12 +238,13 @@ static void of_bus_isa_count_cells(struct device_node *child, | |||
237 | *sizec = 1; | 238 | *sizec = 1; |
238 | } | 239 | } |
239 | 240 | ||
240 | static u64 of_bus_isa_map(u32 *addr, const u32 *range, int na, int ns, int pna) | 241 | static u64 of_bus_isa_map(u32 *addr, const __be32 *range, int na, int ns, |
242 | int pna) | ||
241 | { | 243 | { |
242 | u64 cp, s, da; | 244 | u64 cp, s, da; |
243 | 245 | ||
244 | /* Check address type match */ | 246 | /* Check address type match */ |
245 | if ((addr[0] ^ range[0]) & 0x00000001) | 247 | if ((addr[0] ^ range[0]) & cpu_to_be32(1)) |
246 | return OF_BAD_ADDR; | 248 | return OF_BAD_ADDR; |
247 | 249 | ||
248 | /* Read address values, skipping high cell */ | 250 | /* Read address values, skipping high cell */ |
@@ -264,10 +266,10 @@ static int of_bus_isa_translate(u32 *addr, u64 offset, int na) | |||
264 | return of_bus_default_translate(addr + 1, offset, na - 1); | 266 | return of_bus_default_translate(addr + 1, offset, na - 1); |
265 | } | 267 | } |
266 | 268 | ||
267 | static unsigned int of_bus_isa_get_flags(const u32 *addr) | 269 | static unsigned int of_bus_isa_get_flags(const __be32 *addr) |
268 | { | 270 | { |
269 | unsigned int flags = 0; | 271 | unsigned int flags = 0; |
270 | u32 w = addr[0]; | 272 | u32 w = be32_to_cpup(addr); |
271 | 273 | ||
272 | if (w & 1) | 274 | if (w & 1) |
273 | flags |= IORESOURCE_IO; | 275 | flags |= IORESOURCE_IO; |
@@ -330,7 +332,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, | |||
330 | struct of_bus *pbus, u32 *addr, | 332 | struct of_bus *pbus, u32 *addr, |
331 | int na, int ns, int pna, const char *rprop) | 333 | int na, int ns, int pna, const char *rprop) |
332 | { | 334 | { |
333 | const u32 *ranges; | 335 | const __be32 *ranges; |
334 | unsigned int rlen; | 336 | unsigned int rlen; |
335 | int rone; | 337 | int rone; |
336 | u64 offset = OF_BAD_ADDR; | 338 | u64 offset = OF_BAD_ADDR; |
@@ -398,7 +400,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, | |||
398 | * that can be mapped to a cpu physical address). This is not really specified | 400 | * that can be mapped to a cpu physical address). This is not really specified |
399 | * that way, but this is traditionally the way IBM at least do things | 401 | * that way, but this is traditionally the way IBM at least do things |
400 | */ | 402 | */ |
401 | u64 __of_translate_address(struct device_node *dev, const u32 *in_addr, | 403 | u64 __of_translate_address(struct device_node *dev, const __be32 *in_addr, |
402 | const char *rprop) | 404 | const char *rprop) |
403 | { | 405 | { |
404 | struct device_node *parent = NULL; | 406 | struct device_node *parent = NULL; |
@@ -475,22 +477,22 @@ u64 __of_translate_address(struct device_node *dev, const u32 *in_addr, | |||
475 | return result; | 477 | return result; |
476 | } | 478 | } |
477 | 479 | ||
478 | u64 of_translate_address(struct device_node *dev, const u32 *in_addr) | 480 | u64 of_translate_address(struct device_node *dev, const __be32 *in_addr) |
479 | { | 481 | { |
480 | return __of_translate_address(dev, in_addr, "ranges"); | 482 | return __of_translate_address(dev, in_addr, "ranges"); |
481 | } | 483 | } |
482 | EXPORT_SYMBOL(of_translate_address); | 484 | EXPORT_SYMBOL(of_translate_address); |
483 | 485 | ||
484 | u64 of_translate_dma_address(struct device_node *dev, const u32 *in_addr) | 486 | u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr) |
485 | { | 487 | { |
486 | return __of_translate_address(dev, in_addr, "dma-ranges"); | 488 | return __of_translate_address(dev, in_addr, "dma-ranges"); |
487 | } | 489 | } |
488 | EXPORT_SYMBOL(of_translate_dma_address); | 490 | EXPORT_SYMBOL(of_translate_dma_address); |
489 | 491 | ||
490 | const u32 *of_get_address(struct device_node *dev, int index, u64 *size, | 492 | const __be32 *of_get_address(struct device_node *dev, int index, u64 *size, |
491 | unsigned int *flags) | 493 | unsigned int *flags) |
492 | { | 494 | { |
493 | const u32 *prop; | 495 | const __be32 *prop; |
494 | unsigned int psize; | 496 | unsigned int psize; |
495 | struct device_node *parent; | 497 | struct device_node *parent; |
496 | struct of_bus *bus; | 498 | struct of_bus *bus; |
@@ -525,8 +527,8 @@ const u32 *of_get_address(struct device_node *dev, int index, u64 *size, | |||
525 | } | 527 | } |
526 | EXPORT_SYMBOL(of_get_address); | 528 | EXPORT_SYMBOL(of_get_address); |
527 | 529 | ||
528 | static int __of_address_to_resource(struct device_node *dev, const u32 *addrp, | 530 | static int __of_address_to_resource(struct device_node *dev, |
529 | u64 size, unsigned int flags, | 531 | const __be32 *addrp, u64 size, unsigned int flags, |
530 | struct resource *r) | 532 | struct resource *r) |
531 | { | 533 | { |
532 | u64 taddr; | 534 | u64 taddr; |
@@ -564,7 +566,7 @@ static int __of_address_to_resource(struct device_node *dev, const u32 *addrp, | |||
564 | int of_address_to_resource(struct device_node *dev, int index, | 566 | int of_address_to_resource(struct device_node *dev, int index, |
565 | struct resource *r) | 567 | struct resource *r) |
566 | { | 568 | { |
567 | const u32 *addrp; | 569 | const __be32 *addrp; |
568 | u64 size; | 570 | u64 size; |
569 | unsigned int flags; | 571 | unsigned int flags; |
570 | 572 | ||