summaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-05-19 02:09:09 (GMT)
committerSimon Glass <sjg@chromium.org>2017-06-01 13:03:08 (GMT)
commit40bb637dae10abff32ca2d952fd443e0e09fd524 (patch)
tree7fdd59ec0d5a7cb541a3cb0addc4023b485cc577 /include/dm
parent19c8205e6887d5e47c7dac6cd85d0376411b5444 (diff)
downloadu-boot-40bb637dae10abff32ca2d952fd443e0e09fd524.tar.xz
dm: core: Add a way to find a device by ofnode
Add a function which looks up a device by its node (either in live tree or flat tree). Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/uclass-internal.h18
-rw-r--r--include/dm/uclass.h17
2 files changed, 35 insertions, 0 deletions
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index ad284b8..c086004 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -10,6 +10,8 @@
#ifndef _DM_UCLASS_INTERNAL_H
#define _DM_UCLASS_INTERNAL_H
+#include <dm/ofnode.h>
+
/**
* uclass_get_device_tail() - handle the end of a get_device call
*
@@ -115,6 +117,22 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node,
struct udevice **devp);
/**
+ * uclass_find_device_by_of_node() - Find a uclass device by device tree node
+ *
+ * This searches the devices in the uclass for one attached to the given
+ * device tree node.
+ *
+ * The device is NOT probed, it is merely returned.
+ *
+ * @id: ID to look up
+ * @node: Device tree offset to search for (if NULL then -ENODEV is returned)
+ * @devp: Returns pointer to device (there is only one for each node)
+ * @return 0 if OK, -ve on error
+ */
+int uclass_find_device_by_ofnode(enum uclass_id id, ofnode node,
+ struct udevice **devp);
+
+/**
* uclass_bind_device() - Associate device with a uclass
*
* Connect the device into uclass's list of devices.
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index b583aa8..7f5a130 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -10,6 +10,7 @@
#ifndef _DM_UCLASS_H
#define _DM_UCLASS_H
+#include <dm/ofnode.h>
#include <dm/uclass-id.h>
#include <linker_lists.h>
#include <linux/list.h>
@@ -186,6 +187,22 @@ int uclass_get_device_by_of_offset(enum uclass_id id, int node,
struct udevice **devp);
/**
+ * uclass_get_device_by_ofnode() - Get a uclass device by device tree node
+ *
+ * This searches the devices in the uclass for one attached to the given
+ * device tree node.
+ *
+ * The device is probed to activate it ready for use.
+ *
+ * @id: ID to look up
+ * @np: Device tree node to search for (if NULL then -ENODEV is returned)
+ * @devp: Returns pointer to device (there is only one for each node)
+ * @return 0 if OK, -ve on error
+ */
+int uclass_get_device_by_ofnode(enum uclass_id id, ofnode node,
+ struct udevice **devp);
+
+/**
* uclass_get_device_by_phandle() - Get a uclass device by phandle
*
* This searches the devices in the uclass for one with the given phandle.