From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 4/5] usb: imx-usb-phy: Disable charger detect during initialization
Date: Mon, 20 May 2019 11:24:01 -0700 [thread overview]
Message-ID: <20190520182402.12753-5-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20190520182402.12753-1-andrew.smirnov@gmail.com>
I can't find any erratas this is in refernce to, but apparently
external changer detector needs to be disabled to prevent poor USB
data signal quality. The problem manifest itself as a intermittent USB
transfer corruption that happens to some device under and only under
specific circumstances.
In my case the failure was observed with Transcent SD/micro-SD card
reader (05e3:0745 Genesys Logic, Inc. Logilink CR0012) when connected
directly to front panel USB of ZII RDU2 board (the problem would go
away if device was conntecte via a hub/USB-analyzer/male-female
type A extender cable).
Note that this fix is present in Linux kernel as well as some
abandoned Barebox code removed in the next patch.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/usb/imx/imx-usb-phy.c | 37 +++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/usb/imx/imx-usb-phy.c b/drivers/usb/imx/imx-usb-phy.c
index 306f84374..d4562285c 100644
--- a/drivers/usb/imx/imx-usb-phy.c
+++ b/drivers/usb/imx/imx-usb-phy.c
@@ -24,6 +24,7 @@
#include <linux/clk.h>
#include <linux/err.h>
#include <stmp-device.h>
+#include <mfd/syscon.h>
#define HW_USBPHY_PWD 0x00
#define HW_USBPHY_TX 0x10
@@ -35,12 +36,19 @@
#define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14)
#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1)
+#define ANADIG_USB1_CHRG_DETECT_SET 0x1b4
+#define ANADIG_USB2_CHRG_DETECT_SET 0x214
+#define ANADIG_USB1_CHRG_DETECT_EN_B BIT(20)
+#define ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B BIT(19)
+
struct imx_usbphy {
struct usb_phy usb_phy;
struct phy *phy;
void __iomem *base;
+ void __iomem *anatop;
struct clk *clk;
struct phy_provider *provider;
+ int port_id;
};
static int imx_usbphy_phy_init(struct phy *phy)
@@ -61,6 +69,19 @@ static int imx_usbphy_phy_init(struct phy *phy)
writel(BM_USBPHY_CTRL_ENUTMILEVEL3 | BM_USBPHY_CTRL_ENUTMILEVEL2,
imxphy->base + HW_USBPHY_CTRL_SET);
+ if (imxphy->anatop) {
+ unsigned int reg = imxphy->port_id ?
+ ANADIG_USB1_CHRG_DETECT_SET :
+ ANADIG_USB2_CHRG_DETECT_SET;
+ /*
+ * The external charger detector needs to be disabled,
+ * or the signal at DP will be poor
+ */
+ writel(ANADIG_USB1_CHRG_DETECT_EN_B |
+ ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B,
+ imxphy->anatop + reg);
+ }
+
return 0;
}
@@ -113,11 +134,27 @@ static const struct phy_ops imx_phy_ops = {
static int imx_usbphy_probe(struct device_d *dev)
{
struct resource *iores;
+ struct device_node *np = dev->device_node;
int ret;
struct imx_usbphy *imxphy;
imxphy = xzalloc(sizeof(*imxphy));
+ ret = of_alias_get_id(np, "usbphy");
+ if (ret < 0) {
+ dev_dbg(dev, "failed to get alias id, errno %d\n", ret);
+ goto err_free;
+ }
+ imxphy->port_id = ret;
+
+ if (of_get_property(np, "fsl,anatop", NULL)) {
+ imxphy->anatop =
+ syscon_base_lookup_by_phandle(np, "fsl,anatop");
+ ret = PTR_ERR_OR_ZERO(imxphy->anatop);
+ if (ret)
+ goto err_free;
+ }
+
iores = dev_request_mem_resource(dev, 0);
if (IS_ERR(iores)) {
ret = PTR_ERR(iores);
--
2.21.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev 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 ` [PATCH 3/5] usb: imx-usb-phy: Use stmp_reset_block() to reset PHY Andrey Smirnov
2019-05-20 18:24 ` Andrey Smirnov [this message]
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-5-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