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 1/5] usb: imx-usb-phy: Import register definitions from Linux driver
Date: Mon, 20 May 2019 11:23:58 -0700	[thread overview]
Message-ID: <20190520182402.12753-2-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20190520182402.12753-1-andrew.smirnov@gmail.com>

Import register definitions from Linux driver to simplify
comparing/sharing code a bit. No functional change intended.

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

diff --git a/drivers/usb/imx/imx-usb-phy.c b/drivers/usb/imx/imx-usb-phy.c
index 274153bd5..df7e192d3 100644
--- a/drivers/usb/imx/imx-usb-phy.c
+++ b/drivers/usb/imx/imx-usb-phy.c
@@ -24,16 +24,17 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 
-#define SET				0x4
-#define CLR				0x8
-
-#define USBPHY_CTRL			0x30
+#define HW_USBPHY_PWD				0x00
+#define HW_USBPHY_TX				0x10
+#define HW_USBPHY_CTRL				0x30
+#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 USBPHY_CTRL_ENUTMILEVEL3	(1 << 15)
-#define USBPHY_CTRL_ENUTMILEVEL2	(1 << 14)
-#define USBPHY_CTRL_ENHOSTDISCONDETECT	(1 << 1)
+#define BM_USBPHY_CTRL_ENUTMILEVEL3		BIT(15)
+#define BM_USBPHY_CTRL_ENUTMILEVEL2		BIT(14)
+#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	BIT(1)
 
 struct imx_usbphy {
 	struct usb_phy usb_phy;
@@ -50,20 +51,20 @@ static int imx_usbphy_phy_init(struct phy *phy)
 	clk_enable(imxphy->clk);
 
 	/* reset usbphy */
-	writel(USBPHY_CTRL_SFTRST, imxphy->base + USBPHY_CTRL + SET);
+	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 + USBPHY_CTRL + CLR);
+			imxphy->base + HW_USBPHY_CTRL_CLR);
 
-	/* clr all pwd bits => power up phy */
-	writel(0xffffffff, imxphy->base + CLR);
+	/* Power up the PHY */
+	writel(0, imxphy->base + HW_USBPHY_PWD);
 
 	/* set utmilvl2/3 */
-	writel(USBPHY_CTRL_ENUTMILEVEL3 | USBPHY_CTRL_ENUTMILEVEL2,
-	       imxphy->base + USBPHY_CTRL + SET);
+	writel(BM_USBPHY_CTRL_ENUTMILEVEL3 | BM_USBPHY_CTRL_ENUTMILEVEL2,
+	       imxphy->base + HW_USBPHY_CTRL_SET);
 
 	return 0;
 }
@@ -74,8 +75,8 @@ static int imx_usbphy_notify_connect(struct usb_phy *phy,
 	struct imx_usbphy *imxphy = container_of(phy, struct imx_usbphy, usb_phy);
 
 	if (speed == USB_SPEED_HIGH) {
-		writel(USBPHY_CTRL_ENHOSTDISCONDETECT,
-		       imxphy->base + USBPHY_CTRL + SET);
+		writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+		       imxphy->base + HW_USBPHY_CTRL_SET);
 	}
 
 	return 0;
@@ -86,8 +87,8 @@ static int imx_usbphy_notify_disconnect(struct usb_phy *phy,
 {
 	struct imx_usbphy *imxphy = container_of(phy, struct imx_usbphy, usb_phy);
 
-	writel(USBPHY_CTRL_ENHOSTDISCONDETECT,
-	       imxphy->base + USBPHY_CTRL + CLR);
+	writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+	       imxphy->base + HW_USBPHY_CTRL_CLR);
 
 	return 0;
 }
-- 
2.21.0


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

  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 ` Andrey Smirnov [this message]
2019-05-20 18:23 ` [PATCH 2/5] usb: imx-usb-phy: Wrap lines to silence checkpatch Andrey Smirnov
2019-05-20 18:24 ` [PATCH 3/5] usb: imx-usb-phy: Use stmp_reset_block() to reset PHY Andrey Smirnov
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-2-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