From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH v2 3/6] dm: usb: Add UCLASS_USB_DEV_GENERIC shutdown
Date: Fri, 20 Jul 2018 12:43:58 +0530 [thread overview]
Message-ID: <20180720071401.12952-4-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20180720071401.12952-1-jagan@amarulasolutions.com>
Some OTG controllers which operates on Peripheral
mode are registered as UCLASS_USB_DEV_GENERIC.
So add support to shutdown them as well. shutdown
happened during 'usb reset' and U-Boot handoff code
for Linux boot.
controller restarting in 'usb reset' like probing
again is still missing for this type of UCLASS.
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
Note:
I tried of traversing for multiple UCLASS in removal
code in usb_stop, but couldn't come with proper solutions.
I don't think any other area of code need a requirement like
this, or may be I'm missing. any help would appreciate.
Changes for v2:
- none
drivers/usb/host/usb-uclass.c | 43 +++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 611ea97a72..99cf3d2b49 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -158,6 +158,45 @@ int usb_get_max_xfer_size(struct usb_device *udev, size_t *size)
return ops->get_max_xfer_size(bus, size);
}
+int __usb_stop(void)
+{
+ struct udevice *bus;
+ struct udevice *rh;
+ struct uclass *uc;
+ struct usb_uclass_priv *uc_priv;
+ int err = 0, ret;
+
+ /* De-activate any devices that have been activated */
+ ret = uclass_get(UCLASS_USB_DEV_GENERIC, &uc);
+ if (ret)
+ return ret;
+
+ uc_priv = uc->priv;
+
+ uclass_foreach_dev(bus, uc) {
+ ret = device_remove(bus, DM_REMOVE_NORMAL);
+ if (ret && !err)
+ err = ret;
+
+ /* Locate root hub device */
+ device_find_first_child(bus, &rh);
+ if (rh) {
+ /*
+ * All USB devices are children of root hub.
+ * Unbinding root hub will unbind all of its children.
+ */
+ ret = device_unbind(rh);
+ if (ret && !err)
+ err = ret;
+ }
+ }
+
+ uc_priv->companion_device_count = 0;
+ usb_started = 0;
+
+ return err;
+}
+
int usb_stop(void)
{
struct udevice *bus;
@@ -166,6 +205,10 @@ int usb_stop(void)
struct usb_uclass_priv *uc_priv;
int err = 0, ret;
+ ret = __usb_stop();
+ if (ret)
+ return ret;
+
/* De-activate any devices that have been activated */
ret = uclass_get(UCLASS_USB, &uc);
if (ret)
--
2.17.1
next prev parent reply other threads:[~2018-07-20 7:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-20 7:13 [U-Boot] [PATCH v2 0/6] musb-new: Improve shutdown code Jagan Teki
2018-07-20 7:13 ` [U-Boot] [PATCH v2 1/6] usb: musb-new: Fix improper musb host pointer Jagan Teki
2018-07-20 7:13 ` [U-Boot] [PATCH v2 2/6] usb: musb-new: sunxi: Allocate struct phy in private Jagan Teki
2018-07-20 7:13 ` Jagan Teki [this message]
2018-07-23 23:48 ` [U-Boot] [RFC PATCH v2 3/6] dm: usb: Add UCLASS_USB_DEV_GENERIC shutdown Simon Glass
2018-08-07 7:03 ` Jagan Teki
2018-08-17 12:48 ` Simon Glass
2018-08-17 13:37 ` Jagan Teki
2018-08-21 17:31 ` Simon Glass
2018-07-20 7:13 ` [U-Boot] [PATCH v2 4/6] musb-new: sunxi: Access ahb_reset0_cfg via ccm offset Jagan Teki
2018-07-20 7:14 ` [U-Boot] [PATCH v2 5/6] usb: musb-new: sunxi: Add proper musb exit support Jagan Teki
2018-07-20 7:14 ` [U-Boot] [PATCH v2 6/6] usb: musb-new: Call musb_platform_exit from musb_stop Jagan Teki
2018-07-20 9:42 ` [U-Boot] [PATCH v2 0/6] musb-new: Improve shutdown code Marek Vasut
2018-08-13 11:03 ` Chen-Yu Tsai
2018-08-20 17:04 ` Jagan Teki
2018-08-21 13:04 ` Jagan Teki
2018-08-22 2:41 ` [U-Boot] [linux-sunxi] " Chen-Yu Tsai
2018-08-23 12:05 ` Jagan Teki
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=20180720071401.12952-4-jagan@amarulasolutions.com \
--to=jagan@amarulasolutions.com \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.