[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 7/8] xen/device_tree: Add dt_device_get_address_raw
Allow to read untranslated address from device node. Signed-off-by: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx> --- xen/common/device_tree.c | 34 ++++++++++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 11 +++++++++++ 2 files changed, 45 insertions(+) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 1a886c0..4186a24 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -711,6 +711,40 @@ int dt_device_get_address(const struct dt_device_node *dev, int index, return 0; } +/* dt_device_get_address_raw - Returns address not translated */ +int dt_device_get_address_raw(const struct dt_device_node *dev, int index, + u64 *addr) +{ + const __be32 *addrp; + const struct dt_device_node *parent; + const struct dt_bus *bus; + int na, ns; + + if ( !addr ) + return -EINVAL; + + addrp = dt_get_address(dev, index, NULL, NULL); + if ( addrp == NULL ) + return -EINVAL; + + /* Get parent & match bus type */ + parent = dt_get_parent(dev); + if ( parent == NULL ) + return -EINVAL; + bus = dt_match_bus(parent); + if ( !bus ) + return -EINVAL; + + /* Count address cells & copy address locally */ + bus->count_cells(dev, &na, &ns); + if ( !DT_CHECK_ADDR_COUNT(na) ) + return -EINVAL; + + *addr = dt_read_number(addrp, na); + return 0; +} + + /** * dt_find_node_by_phandle - Find a node given a phandle * @handle: phandle of the node to find diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 629bfb2..3d2a4ae 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -475,6 +475,17 @@ int dt_device_get_address(const struct dt_device_node *dev, int index, u64 *addr, u64 *size); /** + * dt_device_get_address_raw - Get an address for a device + * @device: the device whose address is to be resolved + * @index: index of the address to resolve + * @addr: address filled by this function + * + * This function get a raw (unresolved) address. It returns 0 on success. + */ +int dt_device_get_address_raw(const struct dt_device_node *dev, int index, + u64 *addr); + +/** * dt_number_of_irq - Get the number of IRQ for a device * @device: the device whose number of interrupt is to be retrieved * -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |