summaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>2017-02-21 19:59:47 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-17 13:24:48 +0900
commit5095cb89c62acc78b4cfaeb9a4072979d010510a (patch)
tree1ce6f59d08f8cd1e4fff9f67f93e6f931aff4233 /drivers/usb/core
parentcfd6ed4537a9e938fa76facecd4b9cd65b6d1563 (diff)
downloadlinux-5095cb89c62acc78b4cfaeb9a4072979d010510a.tar.gz
linux-5095cb89c62acc78b4cfaeb9a4072979d010510a.tar.bz2
linux-5095cb89c62acc78b4cfaeb9a4072979d010510a.zip
usb: of: add functions to bind a companion controller
EHCI controllers will have a companion controller. However, on platform bus, there was difficult to bind them in previous code. So, this patch adds helper functions to bind them using a "companion" property. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/of.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c
index 3de4f8873984..d787f195a9a6 100644
--- a/drivers/usb/core/of.c
+++ b/drivers/usb/core/of.c
@@ -18,6 +18,7 @@
*/
#include <linux/of.h>
+#include <linux/of_platform.h>
#include <linux/usb/of.h>
/**
@@ -46,3 +47,25 @@ struct device_node *usb_of_get_child_node(struct device_node *parent,
}
EXPORT_SYMBOL_GPL(usb_of_get_child_node);
+/**
+ * usb_of_get_companion_dev - Find the companion device
+ * @dev: the device pointer to find a companion
+ *
+ * Find the companion device from platform bus.
+ *
+ * Return: On success, a pointer to the companion device, %NULL on failure.
+ */
+struct device *usb_of_get_companion_dev(struct device *dev)
+{
+ struct device_node *node;
+ struct platform_device *pdev = NULL;
+
+ node = of_parse_phandle(dev->of_node, "companion", 0);
+ if (node)
+ pdev = of_find_device_by_node(node);
+
+ of_node_put(node);
+
+ return pdev ? &pdev->dev : NULL;
+}
+EXPORT_SYMBOL_GPL(usb_of_get_companion_dev);