From: Yinbo Zhu <yinbo.zhu@nxp.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Yinbo Zhu <yinbo.zhu@nxp.com>, Xiaobo Xie <xiaobo.xie@nxp.com>,
Jerry Huang <jerry.huang@nxp.com>, Ran Wang <ran.wang_1@nxp.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Ramneek Mehresh <ramneek.mehresh@freescale.com>,
Nikhil Badola <nikhil.badola@freescale.com>,
Suresh Gupta <suresh.gupta@freescale.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Suresh Gupta <B42813@freescale.com>
Subject: [PATCH v2 2/6] usb: phy: Workaround for USB erratum-A005728
Date: Mon, 21 Jan 2019 10:25:06 +0000 [thread overview]
Message-ID: <20190121102601.4735-2-yinbo.zhu@nxp.com> (raw)
In-Reply-To: <20190121102601.4735-1-yinbo.zhu@nxp.com>
From: Suresh Gupta <B42813@freescale.com>
PHY_CLK_VALID bit for UTMI PHY in USBDR does not set even
if PHY is providing valid clock. Workaround for this
involves resetting of PHY and check PHY_CLK_VALID bit
multiple times. If PHY_CLK_VALID bit is still not set even
after 5 retries, it would be safe to deaclare that PHY
clock is not available.
This erratum is applicable for USBDR less then ver 2.4.
Signed-off-by: Suresh Gupta <B42813@freescale.com>
Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
---
Change in v2:
replace Yinbo.Zhu with Yinbo Zhu
drivers/usb/host/ehci-fsl.c | 37 ++++++++++++++++++++++++++-----------
drivers/usb/host/ehci-fsl.h | 3 +++
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 71c4661..a28ec1e 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -176,6 +176,17 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev)
return retval;
}
+static bool usb_phy_clk_valid(struct usb_hcd *hcd)
+{
+ void __iomem *non_ehci = hcd->regs;
+ bool ret = true;
+
+ if (!(in_be32(non_ehci + FSL_SOC_USB_CTRL) & PHY_CLK_VALID))
+ ret = false;
+
+ return ret;
+}
+
static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
enum fsl_usb2_phy_modes phy_mode,
unsigned int port_offset)
@@ -214,6 +225,16 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
/* fall through */
case FSL_USB2_PHY_UTMI:
case FSL_USB2_PHY_UTMI_DUAL:
+ /* PHY_CLK_VALID bit is de-featured from all controller
+ * versions below 2.4 and is to be checked only for
+ * internal UTMI phy
+ */
+ if (pdata->controller_ver > FSL_USB_VER_2_4 &&
+ pdata->have_sysif_regs && !usb_phy_clk_valid(hcd)) {
+ pr_err("fsl-ehci: USB PHY clock invalid\n");
+ return -EINVAL;
+ }
+
if (pdata->have_sysif_regs && pdata->controller_ver) {
/* controller version 1.6 or above */
clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL,
@@ -232,17 +253,11 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
break;
}
- /*
- * check PHY_CLK_VALID to determine phy clock presence before writing
- * to portsc
- */
- if (pdata->check_phy_clk_valid) {
- if (!(ioread32be(non_ehci + FSL_SOC_USB_CTRL) &
- PHY_CLK_VALID)) {
- dev_warn(hcd->self.controller,
- "USB PHY clock invalid\n");
- return -EINVAL;
- }
+ if (pdata->have_sysif_regs &&
+ pdata->controller_ver > FSL_USB_VER_1_6 &&
+ !usb_phy_clk_valid(hcd)) {
+ dev_warn(hcd->self.controller, "USB PHY clock invalid\n");
+ return -EINVAL;
}
ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]);
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
index cbc4220..9d18c6e 100644
--- a/drivers/usb/host/ehci-fsl.h
+++ b/drivers/usb/host/ehci-fsl.h
@@ -50,4 +50,7 @@
#define UTMI_PHY_EN (1<<9)
#define ULPI_PHY_CLK_SEL (1<<10)
#define PHY_CLK_VALID (1<<17)
+
+/* Retry count for checking UTMI PHY CLK validity */
+#define UTMI_PHY_CLK_VALID_CHK_RETRY 5
#endif /* _EHCI_FSL_H */
--
1.7.1
next prev parent reply other threads:[~2019-01-21 10:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-21 10:25 [PATCH v2 1/6] usb: fsl: Set USB_EN bit to select ULPI phy Yinbo Zhu
2019-01-21 10:25 ` Yinbo Zhu [this message]
2019-01-21 10:25 ` [PATCH v2 3/6] usb: host: Stops USB controller init if PLL fails to lock Yinbo Zhu
2019-01-22 8:04 ` Greg Kroah-Hartman
2019-01-21 10:25 ` [PATCH v2 4/6] usb: linux/fsl_device: Add platform member has_fsl_erratum_a006918 Yinbo Zhu
2019-01-21 10:25 ` [PATCH v2 5/6] usb: linux/fsl_device: Add platform member has_fsl_erratum_14 Yinbo Zhu
2019-01-21 10:25 ` [PATCH v2 6/6] usb :fsl: Change string format for errata property Yinbo Zhu
2019-01-22 8:08 ` [PATCH v2 1/6] usb: fsl: Set USB_EN bit to select ULPI phy Greg Kroah-Hartman
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=20190121102601.4735-2-yinbo.zhu@nxp.com \
--to=yinbo.zhu@nxp.com \
--cc=B42813@freescale.com \
--cc=gregkh@linuxfoundation.org \
--cc=jerry.huang@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nikhil.badola@freescale.com \
--cc=ramneek.mehresh@freescale.com \
--cc=ran.wang_1@nxp.com \
--cc=stern@rowland.harvard.edu \
--cc=suresh.gupta@freescale.com \
--cc=xiaobo.xie@nxp.com \
/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;
as well as URLs for NNTP newsgroup(s).