9
0
Fork 0

OF: convert of_translate_address to new API

This converts existing of_translate_address to recently added API. In
contrast to existing behavior, the new function honors ranges properties
properly. It now allows reg properties to be set as offset with respect
to the correspoding parent node.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sebastian Hesselbarth 2013-07-02 20:14:31 +02:00 committed by Sascha Hauer
parent d0a6aaea6a
commit bfc5605e2f
4 changed files with 15 additions and 27 deletions

View File

@ -278,6 +278,12 @@ static u64 __of_translate_address(struct device_node *dev,
return result;
}
u64 of_translate_address(struct device_node *dev, const __be32 *in_addr)
{
return __of_translate_address(dev, in_addr, "ranges");
}
EXPORT_SYMBOL(of_translate_address);
u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr)
{
return __of_translate_address(dev, in_addr, "dma-ranges");

View File

@ -19,6 +19,7 @@
*/
#include <common.h>
#include <of.h>
#include <of_address.h>
#include <errno.h>
#include <malloc.h>
#include <init.h>
@ -242,31 +243,6 @@ const char *of_alias_get(struct device_node *np)
}
EXPORT_SYMBOL_GPL(of_alias_get);
u64 of_translate_address(struct device_node *node, const __be32 *in_addr)
{
struct property *p;
u64 addr = be32_to_cpu(*in_addr);
while (1) {
int na, nc;
if (!node->parent)
return addr;
node = node->parent;
p = of_find_property(node, "ranges", NULL);
if (!p && node->parent)
return OF_BAD_ADDR;
of_bus_count_cells(node, &na, &nc);
if (na != 1 || nc != 1) {
printk("%s: #size-cells != 1 or #address-cells != 1 "
"currently not supported\n", node->name);
return OF_BAD_ADDR;
}
}
}
EXPORT_SYMBOL(of_translate_address);
/*
* of_find_node_by_phandle - Find a node given a phandle
* @handle: phandle of the node to find

View File

@ -101,8 +101,6 @@ int of_get_named_gpio(struct device_node *np,
void of_print_property(const void *data, int len);
void of_print_cmdline(struct device_node *root);
u64 of_translate_address(struct device_node *node, const __be32 *in_addr);
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1

View File

@ -10,6 +10,8 @@ static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
#ifdef CONFIG_OFTREE
extern u64 of_translate_address(struct device_node *dev,
const __be32 *in_addr);
extern u64 of_translate_dma_address(struct device_node *dev,
const __be32 *in_addr);
extern bool of_can_translate_address(struct device_node *dev);
@ -24,6 +26,12 @@ extern void __iomem *of_iomap(struct device_node *np, int index);
#else /* CONFIG_OFTREE */
static inline u64 of_translate_address(struct device_node *dev,
const __be32 *in_addr)
{
return OF_BAD_ADDR;
}
static inline u64 of_translate_dma_address(struct device_node *dev,
const __be32 *in_addr)
{