summaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-07-25 08:29:55 -0600
committerSimon Glass <sjg@chromium.org>2017-07-28 12:02:47 -0600
commitdcf988525f6e2045b9122ba7c3bf6a9bf44f146e (patch)
tree066e1e3e7a3f2aaceb5e407f85cf2a39ff1b486d /include/dm
parentc61d0009feb966e0e93254a8c435a1889085e6b8 (diff)
downloadu-boot-dcf988525f6e2045b9122ba7c3bf6a9bf44f146e.tar.gz
u-boot-dcf988525f6e2045b9122ba7c3bf6a9bf44f146e.tar.bz2
u-boot-dcf988525f6e2045b9122ba7c3bf6a9bf44f146e.zip
dm: core: Add ofnode_read_resource()
We sometimes need to read a resource from an arbitrary node. In any case for consistency we should not put the live-tree switching code in a dev_read_...() function. Update this to suit. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1 Tested-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/ofnode.h4
-rw-r--r--include/dm/read.h26
2 files changed, 20 insertions, 10 deletions
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 15ad5199c2..966ca9309a 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -15,6 +15,8 @@
/* Enable checks to protect against invalid calls */
#undef OF_CHECKS
+struct resource;
+
/**
* ofnode - reference to a device tree node
*
@@ -605,4 +607,6 @@ int ofnode_read_simple_size_cells(ofnode node);
*/
bool ofnode_pre_reloc(ofnode node);
+int ofnode_read_resource(ofnode node, uint index, struct resource *res);
+
#endif
diff --git a/include/dm/read.h b/include/dm/read.h
index edf468fdd1..c2ca7ae34d 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -44,16 +44,6 @@ 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
@@ -348,6 +338,16 @@ const uint8_t *dev_read_u8_array_ptr(struct udevice *dev, const char *propname,
*/
int dev_read_enabled(struct udevice *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);
+
#else /* CONFIG_DM_DEV_READ_INLINE is enabled */
static inline int dev_read_u32_default(struct udevice *dev,
@@ -482,6 +482,12 @@ static inline int dev_read_enabled(struct udevice *dev)
return fdtdec_get_is_enabled(gd->fdt_blob, dev_of_offset(dev));
}
+static inline int dev_read_resource(struct udevice *dev, uint index,
+ struct resource *res)
+{
+ return ofnode_read_resource(dev_ofnode(dev), index, res);
+}
+
#endif /* CONFIG_DM_DEV_READ_INLINE */
/**