From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH RFC 6/8] dm: usb: Add UCLASS_USB_DEV_GENERIC shutdown
Date: Tue, 10 Jul 2018 00:47:08 +0530 [thread overview]
Message-ID: <20180709191710.22446-7-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20180709191710.22446-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.
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-09 19:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-09 19:17 [U-Boot] [PATCH 0/8] musb: sunxi: Few fixes/improvements Jagan Teki
2018-07-09 19:17 ` [U-Boot] [PATCH 1/8] usb: musb-new: Fix improper musb host pointer Jagan Teki
2018-07-17 12:45 ` [U-Boot] [linux-sunxi] " Julian Calaby
2018-07-17 12:48 ` Julian Calaby
2018-07-09 19:17 ` [U-Boot] [PATCH 2/8] usb: musb-new: sunxi: Allocate struct phy in private Jagan Teki
2018-07-09 19:17 ` [U-Boot] [PATCH 3/8] phy: sun4i-usb: Call phy_passby even for PHY#0 Jagan Teki
2018-07-10 2:30 ` Chen-Yu Tsai
2018-07-09 19:17 ` [U-Boot] [PATCH 4/8] phy: sun4i-usb: Remove usb_clk_cfg set in probe Jagan Teki
2018-07-09 19:17 ` [U-Boot] [PATCH 5/8] phy: sun4i-usb: Update PHY#3 rst_mask only for H3_H5 Jagan Teki
2018-07-11 6:53 ` Vasily Khoruzhick
2018-07-11 7:07 ` Jagan Teki
2018-07-11 7:14 ` Maxime Ripard
2018-07-11 7:22 ` Jagan Teki
2018-07-11 9:59 ` Maxime Ripard
2018-07-09 19:17 ` Jagan Teki [this message]
2018-07-09 19:17 ` [U-Boot] [PATCH 7/8] usb: musb-new: sunxi: Add proper musb exit support Jagan Teki
2018-07-11 6:57 ` Vasily Khoruzhick
2018-07-09 19:17 ` [U-Boot] [PATCH 8/8] usb: musb-new: core: Call musb_platform_exit from musb_stop 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=20180709191710.22446-7-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox