diff options
author | Simon Glass <sjg@chromium.org> | 2017-06-12 06:21:29 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2017-07-11 10:08:20 -0600 |
commit | a44810123f9ef069587beacdce7d6f488cf42973 (patch) | |
tree | 1eb3689993eba842e0663321193653d75dfa01d3 /include | |
parent | 8c293d6ac9c9f698a2b5db8def9d1cef725b5011 (diff) |
dm: core: Add dev_read_resource() to read device resources
Add a function which reads resources from a device, such as the device
hardware address. This uses the "reg" property in the device.
Unlike other functions there is little sense in inlining this when
livetree is not being used because it has some logic in it and this would
just bloat the code size.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Diffstat (limited to 'include')
-rw-r--r-- | include/dm/read.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/dm/read.h b/include/dm/read.h index 8c9846eaf2..65d5d1f357 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -14,6 +14,8 @@ #include <dm/ofnode.h> #include <dm/uclass.h> +struct resource; + #if CONFIG_IS_ENABLED(OF_LIVE) static inline const struct device_node *dev_np(struct udevice *dev) { @@ -42,6 +44,16 @@ static inline bool dev_of_valid(struct udevice *dev) return ofnode_valid(dev_ofnode(dev)); } +/** + * dev_read_resource() - obtain an indexed resource from a device. + * + * @dev: devuce to examine + * @index index of the resource to retrieve (0 = first) + * @res returns the resource + * @return 0 if ok, negative on error + */ +int dev_read_resource(struct udevice *dev, uint index, struct resource *res); + #ifndef CONFIG_DM_DEV_READ_INLINE /** * dev_read_u32_default() - read a 32-bit integer from a device's DT property |