Merge tag 'xilinx-for-v2019.01' of git://git.denx.de/u-boot-microblaze
[oweals/u-boot.git] / include / dm / uclass-internal.h
index ad284b8445ac411c65f6778f643a82e77d02d098..8a4839ee882830484195974e96a3924cb4d11c8b 100644 (file)
@@ -1,15 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 2013 Google, Inc
  *
  * (C) Copyright 2012
  * Pavel Herrmann <morpheus.ibis@gmail.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #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
  *
  */
 int uclass_get_device_tail(struct udevice *dev, int ret, struct udevice **devp);
 
+/**
+ * dev_get_uclass_index() - Get uclass and index of device
+ * @dev:       - in - Device that we want the uclass/index of
+ * @ucp:       - out - A pointer to the uclass the device belongs to
+ *
+ * The device is not prepared for use - this is an internal function.
+ *
+ * @return the index of the device in the uclass list or -ENODEV if not found.
+ */
+int dev_get_uclass_index(struct udevice *dev, struct uclass **ucp);
+
 /**
  * uclass_find_device() - Return n-th child of uclass
  * @id:                Id number of the uclass
@@ -114,6 +126,39 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
 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_find_device_by_phandle() - Find a uclass device by phandle
+ *
+ * This searches the devices in the uclass for one with the given phandle.
+ *
+ * The device is NOT probed, it is merely returned.
+ *
+ * @id: ID to look up
+ * @parent: Parent device containing the phandle pointer
+ * @name: Name of property in the parent device node
+ * @devp: Returns pointer to device (there is only one for each node)
+ * @return 0 if OK, -ENOENT if there is no @name present in the node, other
+ *     -ve on error
+ */
+int uclass_find_device_by_phandle(enum uclass_id id, struct udevice *parent,
+                                 const char *name, struct udevice **devp);
+
 /**
  * uclass_bind_device() - Associate device with a uclass
  *