summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-05-20 11:24:01 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2019-05-27 10:02:39 +0200
commitb904eca92f26f8c72afa16ca35de6601450a14db (patch)
treee76e0458cbc9f5d7c09f755353e16f1752497e78 /drivers/usb
parentcc8baa7dc6ee9e83d2dd0bca0c421789bcd5eb05 (diff)
downloadbarebox-b904eca92f26f8c72afa16ca35de6601450a14db.tar.gz
barebox-b904eca92f26f8c72afa16ca35de6601450a14db.tar.xz
usb: imx-usb-phy: Disable charger detect during initialization
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/imx/imx-usb-phy.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/usb/imx/imx-usb-phy.c b/drivers/usb/imx/imx-usb-phy.c
index 306f843746..d4562285c0 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);