From: peter.chen@freescale.com (Peter Chen)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/5] usb: hub: add device tree support for populating onboard usb device
Date: Fri, 18 Dec 2015 17:33:55 +0800 [thread overview]
Message-ID: <1450431239-16439-2-git-send-email-peter.chen@freescale.com> (raw)
In-Reply-To: <1450431239-16439-1-git-send-email-peter.chen@freescale.com>
Although most of USB device is hot-plug's, there are still some
USB devices are soldered on the board, and these kinds of devices
maybe the upstream device at 1st or 2nd level hub's, so in order to
detect all onboard devices, we put the detect device node code
at hub's driver, and it will populate platform device under this HUB.
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/core/hub.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5e32ce7..889f188 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -26,6 +26,7 @@
#include <linux/mutex.h>
#include <linux/random.h>
#include <linux/pm_qos.h>
+#include <linux/of_platform.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h>
@@ -1334,6 +1335,34 @@ static int hub_post_reset(struct usb_interface *intf)
return 0;
}
+static int hub_of_children_register(struct usb_device *hdev)
+{
+ struct device *dev;
+
+ if (hdev->parent)
+ dev = &hdev->dev;
+ else
+ dev = bus_to_hcd(hdev->bus)->self.controller;
+
+ if (!dev->of_node)
+ return 0;
+
+ return of_platform_populate(dev->of_node, NULL, NULL, dev);
+}
+
+static void hub_of_children_unregister(struct usb_device *hdev)
+{
+ struct device *dev;
+
+ if (hdev->parent)
+ dev = &hdev->dev;
+ else
+ dev = bus_to_hcd(hdev->bus)->self.controller;
+
+ if (dev->of_node)
+ of_platform_depopulate(dev);
+}
+
static int hub_configure(struct usb_hub *hub,
struct usb_endpoint_descriptor *endpoint)
{
@@ -1677,6 +1706,7 @@ static void hub_disconnect(struct usb_interface *intf)
usb_set_intfdata(intf, NULL);
spin_unlock_irq(&device_state_lock);
+ hub_of_children_unregister(hdev);
for (; port1 > 0; --port1)
usb_hub_remove_port_device(hub, port1);
@@ -1701,6 +1731,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
struct usb_endpoint_descriptor *endpoint;
struct usb_device *hdev;
struct usb_hub *hub;
+ int ret;
desc = intf->cur_altsetting;
hdev = interface_to_usbdev(intf);
@@ -1820,6 +1851,12 @@ descriptor_error:
if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND)
hub->quirk_check_port_auto_suspend = 1;
+ ret = hub_of_children_register(hdev);
+ if (ret) {
+ dev_err(&hdev->dev, "Failed to register child device\n");
+ return ret;
+ }
+
if (hub_configure(hub, endpoint) >= 0)
return 0;
--
1.9.1
next prev parent reply other threads:[~2015-12-18 9:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-18 9:33 [RFC PATCH 0/5] USB: add generic onboard USB driver Peter Chen
2015-12-18 9:33 ` Peter Chen [this message]
2015-12-18 9:33 ` [RFC PATCH 2/5] doc: dt-binding: generic onboard USB device Peter Chen
2015-12-19 4:15 ` Rob Herring
2015-12-21 8:52 ` Peter Chen
2015-12-18 9:33 ` [RFC PATCH 3/5] usb: misc: generic_onboard_hub: add generic onboard USB device driver Peter Chen
2015-12-18 9:33 ` [RFC PATCH 4/5] usb: chipidea: host: let the hcd know's parent device node Peter Chen
2015-12-18 9:33 ` [RFC PATCH 5/5] ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property Peter Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450431239-16439-2-git-send-email-peter.chen@freescale.com \
--to=peter.chen@freescale.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).