public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 7/8] usb: musb-new: sunxi: Add proper musb exit support
Date: Tue, 10 Jul 2018 00:47:09 +0530	[thread overview]
Message-ID: <20180709191710.22446-8-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20180709191710.22446-1-jagan@amarulasolutions.com>

musb have platform ops to do proper graceful exit,
so add the exit call and move musb platform exit code
instead of keeping it in driver remove.
This make proper shutdown of musb where .remove will
call disable, exit serially via musb_stop.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/usb/musb-new/sunxi.c | 48 +++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index aa2880eeb9..9f71b84fd1 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -326,6 +326,33 @@ static int sunxi_musb_init(struct musb *musb)
 	return 0;
 }
 
+static int sunxi_musb_exit(struct musb *musb)
+{
+	struct sunxi_glue *glue = to_sunxi_glue(musb->controller);
+	int ret = 0;
+
+	if (generic_phy_valid(&glue->phy)) {
+		ret = generic_phy_exit(&glue->phy);
+		if (ret) {
+			dev_err(dev, "failed to power off usb phy\n");
+			return ret;
+		}
+	}
+
+#ifdef CONFIG_SUNXI_GEN_SUN6I
+	clrbits_le32(&glue->ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_USB0));
+	if (glue->cfg->rst_bit)
+		clrbits_le32(&glue->ccm->ahb_reset0_cfg,
+			     BIT(glue->cfg->rst_bit));
+#endif
+	clrbits_le32(&glue->ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_USB0));
+	if (glue->cfg->clkgate_bit)
+		clrbits_le32(&glue->ccm->ahb_gate0,
+			     BIT(glue->cfg->clkgate_bit));
+
+	return 0;
+}
+
 static void sunxi_musb_pre_root_reset_end(struct musb *musb)
 {
 	struct sunxi_glue *glue = to_sunxi_glue(musb->controller);
@@ -342,6 +369,7 @@ static void sunxi_musb_post_root_reset_end(struct musb *musb)
 
 static const struct musb_platform_ops sunxi_musb_ops = {
 	.init		= sunxi_musb_init,
+	.exit		= sunxi_musb_exit,
 	.enable		= sunxi_musb_enable,
 	.disable	= sunxi_musb_disable,
 	.pre_root_reset_end = sunxi_musb_pre_root_reset_end,
@@ -456,29 +484,9 @@ static int musb_usb_remove(struct udevice *dev)
 {
 	struct sunxi_glue *glue = dev_get_priv(dev);
 	struct musb_host_data *host = &glue->mdata;
-	int ret;
-
-	if (generic_phy_valid(&glue->phy)) {
-		ret = generic_phy_exit(&glue->phy);
-		if (ret) {
-			pr_err("failed to exit %s USB PHY\n", dev->name);
-			return ret;
-		}
-	}
 
 	musb_stop(host->host);
 
-#ifdef CONFIG_SUNXI_GEN_SUN6I
-	clrbits_le32(&glue->ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_USB0));
-	if (glue->cfg->rst_bit)
-		clrbits_le32(&glue->ccm->ahb_reset0_cfg,
-			     BIT(glue->cfg->rst_bit));
-#endif
-	clrbits_le32(&glue->ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_USB0));
-	if (glue->cfg->clkgate_bit)
-		clrbits_le32(&glue->ccm->ahb_gate0,
-			     BIT(glue->cfg->clkgate_bit));
-
 	free(host->host);
 	host->host = NULL;
 
-- 
2.17.1

  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 ` [U-Boot] [PATCH RFC 6/8] dm: usb: Add UCLASS_USB_DEV_GENERIC shutdown Jagan Teki
2018-07-09 19:17 ` Jagan Teki [this message]
2018-07-11  6:57   ` [U-Boot] [PATCH 7/8] usb: musb-new: sunxi: Add proper musb exit support 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-8-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