mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 3/5] usb: imx-usb-phy: Use stmp_reset_block() to reset PHY
Date: Mon, 20 May 2019 11:24:00 -0700	[thread overview]
Message-ID: <20190520182402.12753-4-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20190520182402.12753-1-andrew.smirnov@gmail.com>

Upstream kernel driver uses stmp_reset_block() to reset the PHY, so
convert the code to do so as well to save some code and sync both
drivers.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/imx/imx-usb-phy.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/imx/imx-usb-phy.c b/drivers/usb/imx/imx-usb-phy.c
index 01bf04b67..306f84374 100644
--- a/drivers/usb/imx/imx-usb-phy.c
+++ b/drivers/usb/imx/imx-usb-phy.c
@@ -23,6 +23,7 @@
 #include <linux/phy/phy.h>
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <stmp-device.h>
 
 #define HW_USBPHY_PWD				0x00
 #define HW_USBPHY_TX				0x10
@@ -30,8 +31,6 @@
 #define HW_USBPHY_CTRL_SET			0x34
 #define HW_USBPHY_CTRL_CLR			0x38
 
-#define USBPHY_CTRL_SFTRST		(1 << 31)
-#define USBPHY_CTRL_CLKGATE		(1 << 30)
 #define BM_USBPHY_CTRL_ENUTMILEVEL3		BIT(15)
 #define BM_USBPHY_CTRL_ENUTMILEVEL2		BIT(14)
 #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	BIT(1)
@@ -47,17 +46,13 @@ struct imx_usbphy {
 static int imx_usbphy_phy_init(struct phy *phy)
 {
 	struct imx_usbphy *imxphy = phy_get_drvdata(phy);
+	int ret;
 
 	clk_enable(imxphy->clk);
 
-	/* reset usbphy */
-	writel(USBPHY_CTRL_SFTRST, imxphy->base + HW_USBPHY_CTRL_SET);
-
-	udelay(10);
-
-	/* clr reset and clkgate */
-	writel(USBPHY_CTRL_SFTRST | USBPHY_CTRL_CLKGATE,
-			imxphy->base + HW_USBPHY_CTRL_CLR);
+	ret = stmp_reset_block(imxphy->base + HW_USBPHY_CTRL, false);
+	if (ret)
+		return ret;
 
 	/* Power up the PHY */
 	writel(0, imxphy->base + HW_USBPHY_PWD);
-- 
2.21.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-05-20 18:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20 18:23 [PATCH 0/5] i.MX USB PHY fixes Andrey Smirnov
2019-05-20 18:23 ` [PATCH 1/5] usb: imx-usb-phy: Import register definitions from Linux driver Andrey Smirnov
2019-05-20 18:23 ` [PATCH 2/5] usb: imx-usb-phy: Wrap lines to silence checkpatch Andrey Smirnov
2019-05-20 18:24 ` Andrey Smirnov [this message]
2019-05-20 18:24 ` [PATCH 4/5] usb: imx-usb-phy: Disable charger detect during initialization Andrey Smirnov
2019-05-20 18:24 ` [PATCH 5/5] ARM: i.MX: Drop unused usb-imx6.c Andrey Smirnov
2019-05-21  9:37   ` Sascha Hauer
2019-05-21  9:50     ` Sascha Hauer
2019-05-22  2:01       ` Andrey Smirnov

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=20190520182402.12753-4-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@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