aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/kernel/prom_parse.c20
-rw-r--r--include/asm-powerpc/prom.h4
2 files changed, 20 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index 6bdfaf3f99ea..90eb3a3e383e 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -419,7 +419,7 @@ static struct of_bus *of_match_bus(struct device_node *np)
419 419
420static int of_translate_one(struct device_node *parent, struct of_bus *bus, 420static int of_translate_one(struct device_node *parent, struct of_bus *bus,
421 struct of_bus *pbus, u32 *addr, 421 struct of_bus *pbus, u32 *addr,
422 int na, int ns, int pna) 422 int na, int ns, int pna, const char *rprop)
423{ 423{
424 const u32 *ranges; 424 const u32 *ranges;
425 unsigned int rlen; 425 unsigned int rlen;
@@ -438,7 +438,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
438 * to translate addresses that aren't supposed to be translated in 438 * to translate addresses that aren't supposed to be translated in
439 * the first place. --BenH. 439 * the first place. --BenH.
440 */ 440 */
441 ranges = of_get_property(parent, "ranges", &rlen); 441 ranges = of_get_property(parent, rprop, &rlen);
442 if (ranges == NULL || rlen == 0) { 442 if (ranges == NULL || rlen == 0) {
443 offset = of_read_number(addr, na); 443 offset = of_read_number(addr, na);
444 memset(addr, 0, pna * 4); 444 memset(addr, 0, pna * 4);
@@ -481,7 +481,8 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
481 * that can be mapped to a cpu physical address). This is not really specified 481 * that can be mapped to a cpu physical address). This is not really specified
482 * that way, but this is traditionally the way IBM at least do things 482 * that way, but this is traditionally the way IBM at least do things
483 */ 483 */
484u64 of_translate_address(struct device_node *dev, const u32 *in_addr) 484u64 __of_translate_address(struct device_node *dev, const u32 *in_addr,
485 const char *rprop)
485{ 486{
486 struct device_node *parent = NULL; 487 struct device_node *parent = NULL;
487 struct of_bus *bus, *pbus; 488 struct of_bus *bus, *pbus;
@@ -540,7 +541,7 @@ u64 of_translate_address(struct device_node *dev, const u32 *in_addr)
540 pbus->name, pna, pns, parent->full_name); 541 pbus->name, pna, pns, parent->full_name);
541 542
542 /* Apply bus translation */ 543 /* Apply bus translation */
543 if (of_translate_one(dev, bus, pbus, addr, na, ns, pna)) 544 if (of_translate_one(dev, bus, pbus, addr, na, ns, pna, rprop))
544 break; 545 break;
545 546
546 /* Complete the move up one level */ 547 /* Complete the move up one level */
@@ -556,8 +557,19 @@ u64 of_translate_address(struct device_node *dev, const u32 *in_addr)
556 557
557 return result; 558 return result;
558} 559}
560
561u64 of_translate_address(struct device_node *dev, const u32 *in_addr)
562{
563 return __of_translate_address(dev, in_addr, "ranges");
564}
559EXPORT_SYMBOL(of_translate_address); 565EXPORT_SYMBOL(of_translate_address);
560 566
567u64 of_translate_dma_address(struct device_node *dev, const u32 *in_addr)
568{
569 return __of_translate_address(dev, in_addr, "dma-ranges");
570}
571EXPORT_SYMBOL(of_translate_dma_address);
572
561const u32 *of_get_address(struct device_node *dev, int index, u64 *size, 573const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
562 unsigned int *flags) 574 unsigned int *flags)
563{ 575{
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index 925e2d384bb3..78b7b0d494c0 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -202,6 +202,10 @@ static inline unsigned long of_read_ulong(const u32 *cell, int size)
202 */ 202 */
203extern u64 of_translate_address(struct device_node *np, const u32 *addr); 203extern u64 of_translate_address(struct device_node *np, const u32 *addr);
204 204
205/* Translate a DMA address from device space to CPU space */
206extern u64 of_translate_dma_address(struct device_node *dev,
207 const u32 *in_addr);
208
205/* Extract an address from a device, returns the region size and 209/* Extract an address from a device, returns the region size and
206 * the address space flags too. The PCI version uses a BAR number 210 * the address space flags too. The PCI version uses a BAR number
207 * instead of an absolute index 211 * instead of an absolute index