All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/5] usb: fsl: Set USB_EN bit to select ULPI phy
@ 2019-01-25  6:02 ` yinbo.zhu
  0 siblings, 0 replies; 18+ messages in thread
From: Yinbo Zhu @ 2019-01-25  6:02 UTC (permalink / raw)
  To: Alan Stern
  Cc: Yinbo Zhu, Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

From: Nikhil Badola <nikhil.badola@freescale.com>

Set USB_EN bit to select ULPI phy for USB controller version 2.5

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
---
Change in v4:
		Incorrect indentation of the continuation line

 drivers/usb/host/ehci-fsl.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index e3d0c1c..38674b7 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -122,6 +122,12 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev)
 		tmp |= 0x4;
 		iowrite32be(tmp, hcd->regs + FSL_SOC_USB_CTRL);
 	}
+
+	/* Set USB_EN bit to select ULPI phy for USB controller version 2.5 */
+	if (pdata->controller_ver == FSL_USB_VER_2_5 &&
+	    pdata->phy_mode == FSL_USB2_PHY_ULPI)
+		iowrite32be(USB_CTRL_USB_EN, hcd->regs + FSL_SOC_USB_CTRL);
+
 	/*
 	 * Enable UTMI phy and program PTS field in UTMI mode before asserting
 	 * controller reset for USB Controller version 2.5
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [v4,1/5] usb: fsl: Set USB_EN bit to select ULPI phy
@ 2019-01-25  6:02 ` yinbo.zhu
  0 siblings, 0 replies; 18+ messages in thread
From: yinbo.zhu @ 2019-01-25  6:02 UTC (permalink / raw)
  To: Alan Stern
  Cc: Yinbo Zhu, Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

From: Nikhil Badola <nikhil.badola@freescale.com>

Set USB_EN bit to select ULPI phy for USB controller version 2.5

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
---
Change in v4:
		Incorrect indentation of the continuation line

 drivers/usb/host/ehci-fsl.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index e3d0c1c..38674b7 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -122,6 +122,12 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev)
 		tmp |= 0x4;
 		iowrite32be(tmp, hcd->regs + FSL_SOC_USB_CTRL);
 	}
+
+	/* Set USB_EN bit to select ULPI phy for USB controller version 2.5 */
+	if (pdata->controller_ver == FSL_USB_VER_2_5 &&
+	    pdata->phy_mode == FSL_USB2_PHY_ULPI)
+		iowrite32be(USB_CTRL_USB_EN, hcd->regs + FSL_SOC_USB_CTRL);
+
 	/*
 	 * Enable UTMI phy and program PTS field in UTMI mode before asserting
 	 * controller reset for USB Controller version 2.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 2/5] usb: phy: Workaround for USB erratum-A005728
@ 2019-01-25  6:02   ` yinbo.zhu
  0 siblings, 0 replies; 18+ messages in thread
From: Yinbo Zhu @ 2019-01-25  6:02 UTC (permalink / raw)
  To: Alan Stern
  Cc: Yinbo Zhu, Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel, Suresh Gupta

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 v4:
		Incorrect indentation of the continuation line.
		replace pr_err with dev_err.

 drivers/usb/host/ehci-fsl.c |   38 +++++++++++++++++++++++++++-----------
 drivers/usb/host/ehci-fsl.h |    3 +++
 2 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 38674b7..373a816 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -183,6 +183,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 (!(ioread32be(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)
@@ -226,6 +237,17 @@ 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)) {
+			dev_err(dev,
+				"%s: USB PHY clock invalid\n", dev_name(dev));
+			return -EINVAL;
+		}
+
 		if (pdata->have_sysif_regs && pdata->controller_ver) {
 			/* controller version 1.6 or above */
 			tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL);
@@ -249,17 +271,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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [v4,2/5] usb: phy: Workaround for USB erratum-A005728
@ 2019-01-25  6:02   ` yinbo.zhu
  0 siblings, 0 replies; 18+ messages in thread
From: yinbo.zhu @ 2019-01-25  6:02 UTC (permalink / raw)
  To: Alan Stern
  Cc: Yinbo Zhu, Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel, Suresh Gupta

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 v4:
		Incorrect indentation of the continuation line.
		replace pr_err with dev_err.

 drivers/usb/host/ehci-fsl.c |   38 +++++++++++++++++++++++++++-----------
 drivers/usb/host/ehci-fsl.h |    3 +++
 2 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 38674b7..373a816 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -183,6 +183,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 (!(ioread32be(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)
@@ -226,6 +237,17 @@ 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)) {
+			dev_err(dev,
+				"%s: USB PHY clock invalid\n", dev_name(dev));
+			return -EINVAL;
+		}
+
 		if (pdata->have_sysif_regs && pdata->controller_ver) {
 			/* controller version 1.6 or above */
 			tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL);
@@ -249,17 +271,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 */

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 3/5] usb: linux/fsl_device: Add platform member has_fsl_erratum_a006918
@ 2019-01-25  6:03   ` yinbo.zhu
  0 siblings, 0 replies; 18+ messages in thread
From: Yinbo Zhu @ 2019-01-25  6:03 UTC (permalink / raw)
  To: Alan Stern
  Cc: Yinbo Zhu, Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

From: Yinbo Zhu <yinbo.zhu@nxp.com>

This patch is to add member has_fsl_erratum_a006918 in platform data

Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
---
 include/linux/fsl_devices.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 5da56a6..4c613da 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -102,6 +102,7 @@ struct fsl_usb2_platform_data {
 	unsigned	has_fsl_erratum_14:1;
 	unsigned	has_fsl_erratum_a005275:1;
 	unsigned	has_fsl_erratum_a005697:1;
+	unsigned        has_fsl_erratum_a006918:1;
 	unsigned	check_phy_clk_valid:1;
 
 	/* register save area for suspend/resume */
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [v4,3/5] usb: linux/fsl_device: Add platform member has_fsl_erratum_a006918
@ 2019-01-25  6:03   ` yinbo.zhu
  0 siblings, 0 replies; 18+ messages in thread
From: yinbo.zhu @ 2019-01-25  6:03 UTC (permalink / raw)
  To: Alan Stern
  Cc: Yinbo Zhu, Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

From: Yinbo Zhu <yinbo.zhu@nxp.com>

This patch is to add member has_fsl_erratum_a006918 in platform data

Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
---
 include/linux/fsl_devices.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 5da56a6..4c613da 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -102,6 +102,7 @@ struct fsl_usb2_platform_data {
 	unsigned	has_fsl_erratum_14:1;
 	unsigned	has_fsl_erratum_a005275:1;
 	unsigned	has_fsl_erratum_a005697:1;
+	unsigned        has_fsl_erratum_a006918:1;
 	unsigned	check_phy_clk_valid:1;
 
 	/* register save area for suspend/resume */

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 4/5] usb: host: Stops USB controller init if PLL fails to lock
@ 2019-01-25  6:03   ` yinbo.zhu
  0 siblings, 0 replies; 18+ messages in thread
From: Yinbo Zhu @ 2019-01-25  6:03 UTC (permalink / raw)
  To: Alan Stern
  Cc: Yinbo Zhu, Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

From: Ramneek Mehresh <ramneek.mehresh@freescale.com>

USB erratum-A006918 workaround tries to start internal PHY inside
uboot (when PLL fails to lock). However, if the workaround also
fails, then USB initialization is also stopped inside Linux.
Erratum-A006918 workaround failure creates "fsl,erratum_a006918"
node in device-tree. Presence of this node in device-tree is
used to stop USB controller initialization in Linux

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
Signed-off-by: Suresh Gupta <suresh.gupta@freescale.com>
Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
---
 drivers/usb/host/ehci-fsl.c      |    5 +++++
 drivers/usb/host/fsl-mph-dr-of.c |    3 ++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 373a816..8b47277 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -236,6 +236,11 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
 		portsc |= PORT_PTS_PTW;
 		/* fall through */
 	case FSL_USB2_PHY_UTMI:
+		if (pdata->has_fsl_erratum_a006918) {
+			pr_warn("fsl-ehci: USB PHY clock invalid\n");
+			return -EINVAL;
+		}
+
 	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
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 4f8b8a0..762b976 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -224,13 +224,14 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
 		of_property_read_bool(np, "fsl,usb-erratum-a005275");
 	pdata->has_fsl_erratum_a005697 =
 		of_property_read_bool(np, "fsl,usb_erratum-a005697");
+	pdata->has_fsl_erratum_a006918 =
+		of_property_read_bool(np, "fsl,usb_erratum-a006918");
 
 	if (of_get_property(np, "fsl,usb_erratum_14", NULL))
 		pdata->has_fsl_erratum_14 = 1;
 	else
 		pdata->has_fsl_erratum_14 = 0;
 
-
 	/*
 	 * Determine whether phy_clk_valid needs to be checked
 	 * by reading property in device tree
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [v4,4/5] usb: host: Stops USB controller init if PLL fails to lock
@ 2019-01-25  6:03   ` yinbo.zhu
  0 siblings, 0 replies; 18+ messages in thread
From: yinbo.zhu @ 2019-01-25  6:03 UTC (permalink / raw)
  To: Alan Stern
  Cc: Yinbo Zhu, Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

From: Ramneek Mehresh <ramneek.mehresh@freescale.com>

USB erratum-A006918 workaround tries to start internal PHY inside
uboot (when PLL fails to lock). However, if the workaround also
fails, then USB initialization is also stopped inside Linux.
Erratum-A006918 workaround failure creates "fsl,erratum_a006918"
node in device-tree. Presence of this node in device-tree is
used to stop USB controller initialization in Linux

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
Signed-off-by: Suresh Gupta <suresh.gupta@freescale.com>
Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
---
 drivers/usb/host/ehci-fsl.c      |    5 +++++
 drivers/usb/host/fsl-mph-dr-of.c |    3 ++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 373a816..8b47277 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -236,6 +236,11 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
 		portsc |= PORT_PTS_PTW;
 		/* fall through */
 	case FSL_USB2_PHY_UTMI:
+		if (pdata->has_fsl_erratum_a006918) {
+			pr_warn("fsl-ehci: USB PHY clock invalid\n");
+			return -EINVAL;
+		}
+
 	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
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 4f8b8a0..762b976 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -224,13 +224,14 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
 		of_property_read_bool(np, "fsl,usb-erratum-a005275");
 	pdata->has_fsl_erratum_a005697 =
 		of_property_read_bool(np, "fsl,usb_erratum-a005697");
+	pdata->has_fsl_erratum_a006918 =
+		of_property_read_bool(np, "fsl,usb_erratum-a006918");
 
 	if (of_get_property(np, "fsl,usb_erratum_14", NULL))
 		pdata->has_fsl_erratum_14 = 1;
 	else
 		pdata->has_fsl_erratum_14 = 0;
 
-
 	/*
 	 * Determine whether phy_clk_valid needs to be checked
 	 * by reading property in device tree

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 5/5] usb :fsl: Change string format for errata property
@ 2019-01-25  6:03   ` yinbo.zhu
  0 siblings, 0 replies; 18+ messages in thread
From: Yinbo Zhu @ 2019-01-25  6:03 UTC (permalink / raw)
  To: Alan Stern
  Cc: Yinbo Zhu, Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

From: Nikhil Badola <nikhil.badola@freescale.com>

Remove USB errata checking code from driver. Applicability of erratum
is retrieved by reading corresponding property in device tree.
This property is written during device tree fixup.

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
---
 drivers/usb/host/fsl-mph-dr-of.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 762b976..ae8f60f 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -226,11 +226,8 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
 		of_property_read_bool(np, "fsl,usb_erratum-a005697");
 	pdata->has_fsl_erratum_a006918 =
 		of_property_read_bool(np, "fsl,usb_erratum-a006918");
-
-	if (of_get_property(np, "fsl,usb_erratum_14", NULL))
-		pdata->has_fsl_erratum_14 = 1;
-	else
-		pdata->has_fsl_erratum_14 = 0;
+	pdata->has_fsl_erratum_14 =
+		of_property_read_bool(np, "fsl,usb_erratum-14");
 
 	/*
 	 * Determine whether phy_clk_valid needs to be checked
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [v4,5/5] usb :fsl: Change string format for errata property
@ 2019-01-25  6:03   ` yinbo.zhu
  0 siblings, 0 replies; 18+ messages in thread
From: yinbo.zhu @ 2019-01-25  6:03 UTC (permalink / raw)
  To: Alan Stern
  Cc: Yinbo Zhu, Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

From: Nikhil Badola <nikhil.badola@freescale.com>

Remove USB errata checking code from driver. Applicability of erratum
is retrieved by reading corresponding property in device tree.
This property is written during device tree fixup.

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
---
 drivers/usb/host/fsl-mph-dr-of.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 762b976..ae8f60f 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -226,11 +226,8 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
 		of_property_read_bool(np, "fsl,usb_erratum-a005697");
 	pdata->has_fsl_erratum_a006918 =
 		of_property_read_bool(np, "fsl,usb_erratum-a006918");
-
-	if (of_get_property(np, "fsl,usb_erratum_14", NULL))
-		pdata->has_fsl_erratum_14 = 1;
-	else
-		pdata->has_fsl_erratum_14 = 0;
+	pdata->has_fsl_erratum_14 =
+		of_property_read_bool(np, "fsl,usb_erratum-14");
 
 	/*
 	 * Determine whether phy_clk_valid needs to be checked

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 1/5] usb: fsl: Set USB_EN bit to select ULPI phy
@ 2019-01-28 15:33   ` Alan Stern
  0 siblings, 0 replies; 18+ messages in thread
From: Alan Stern @ 2019-01-28 15:33 UTC (permalink / raw)
  To: Yinbo Zhu
  Cc: Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

On Fri, 25 Jan 2019, Yinbo Zhu wrote:

> From: Nikhil Badola <nikhil.badola@freescale.com>
> 
> Set USB_EN bit to select ULPI phy for USB controller version 2.5
> 
> Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
> Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
> ---

Acked-by: Alan Stern <stern@rowland.harvard.edu>

> Change in v4:
> 		Incorrect indentation of the continuation line
> 
>  drivers/usb/host/ehci-fsl.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index e3d0c1c..38674b7 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -122,6 +122,12 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev)
>  		tmp |= 0x4;
>  		iowrite32be(tmp, hcd->regs + FSL_SOC_USB_CTRL);
>  	}
> +
> +	/* Set USB_EN bit to select ULPI phy for USB controller version 2.5 */
> +	if (pdata->controller_ver == FSL_USB_VER_2_5 &&
> +	    pdata->phy_mode == FSL_USB2_PHY_ULPI)
> +		iowrite32be(USB_CTRL_USB_EN, hcd->regs + FSL_SOC_USB_CTRL);
> +
>  	/*
>  	 * Enable UTMI phy and program PTS field in UTMI mode before asserting
>  	 * controller reset for USB Controller version 2.5
> 


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [v4,1/5] usb: fsl: Set USB_EN bit to select ULPI phy
@ 2019-01-28 15:33   ` Alan Stern
  0 siblings, 0 replies; 18+ messages in thread
From: Alan Stern @ 2019-01-28 15:33 UTC (permalink / raw)
  To: Yinbo Zhu
  Cc: Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

On Fri, 25 Jan 2019, Yinbo Zhu wrote:

> From: Nikhil Badola <nikhil.badola@freescale.com>
> 
> Set USB_EN bit to select ULPI phy for USB controller version 2.5
> 
> Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
> Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
> ---

Acked-by: Alan Stern <stern@rowland.harvard.edu>

> Change in v4:
> 		Incorrect indentation of the continuation line
> 
>  drivers/usb/host/ehci-fsl.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index e3d0c1c..38674b7 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -122,6 +122,12 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev)
>  		tmp |= 0x4;
>  		iowrite32be(tmp, hcd->regs + FSL_SOC_USB_CTRL);
>  	}
> +
> +	/* Set USB_EN bit to select ULPI phy for USB controller version 2.5 */
> +	if (pdata->controller_ver == FSL_USB_VER_2_5 &&
> +	    pdata->phy_mode == FSL_USB2_PHY_ULPI)
> +		iowrite32be(USB_CTRL_USB_EN, hcd->regs + FSL_SOC_USB_CTRL);
> +
>  	/*
>  	 * Enable UTMI phy and program PTS field in UTMI mode before asserting
>  	 * controller reset for USB Controller version 2.5
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 2/5] usb: phy: Workaround for USB erratum-A005728
@ 2019-01-28 15:36     ` Alan Stern
  0 siblings, 0 replies; 18+ messages in thread
From: Alan Stern @ 2019-01-28 15:36 UTC (permalink / raw)
  To: Yinbo Zhu
  Cc: Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel, Suresh Gupta

On Fri, 25 Jan 2019, Yinbo Zhu wrote:

> 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 v4:
> 		Incorrect indentation of the continuation line.
> 		replace pr_err with dev_err.
> 
>  drivers/usb/host/ehci-fsl.c |   38 +++++++++++++++++++++++++++-----------
>  drivers/usb/host/ehci-fsl.h |    3 +++
>  2 files changed, 30 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index 38674b7..373a816 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -183,6 +183,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 (!(ioread32be(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)
> @@ -226,6 +237,17 @@ 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)) {
> +			dev_err(dev,
> +				"%s: USB PHY clock invalid\n", dev_name(dev));

This looks silly; it prints the device name twice (once because that's
what dev_err() does, and then again because you explicitly told it to
print the device name).

Look at how dev_err() is used in other parts of the driver and do the 
same thing.

> +			return -EINVAL;
> +		}
> +
>  		if (pdata->have_sysif_regs && pdata->controller_ver) {
>  			/* controller version 1.6 or above */
>  			tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL);
> @@ -249,17 +271,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");

Once again, you have a continuation line that is indented by the same 
amount as the code in the inner block.  Please fix this properly.

> +		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 */

Alan Stern


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [v4,2/5] usb: phy: Workaround for USB erratum-A005728
@ 2019-01-28 15:36     ` Alan Stern
  0 siblings, 0 replies; 18+ messages in thread
From: Alan Stern @ 2019-01-28 15:36 UTC (permalink / raw)
  To: Yinbo Zhu
  Cc: Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel, Suresh Gupta

On Fri, 25 Jan 2019, Yinbo Zhu wrote:

> 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 v4:
> 		Incorrect indentation of the continuation line.
> 		replace pr_err with dev_err.
> 
>  drivers/usb/host/ehci-fsl.c |   38 +++++++++++++++++++++++++++-----------
>  drivers/usb/host/ehci-fsl.h |    3 +++
>  2 files changed, 30 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index 38674b7..373a816 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -183,6 +183,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 (!(ioread32be(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)
> @@ -226,6 +237,17 @@ 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)) {
> +			dev_err(dev,
> +				"%s: USB PHY clock invalid\n", dev_name(dev));

This looks silly; it prints the device name twice (once because that's
what dev_err() does, and then again because you explicitly told it to
print the device name).

Look at how dev_err() is used in other parts of the driver and do the 
same thing.

> +			return -EINVAL;
> +		}
> +
>  		if (pdata->have_sysif_regs && pdata->controller_ver) {
>  			/* controller version 1.6 or above */
>  			tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL);
> @@ -249,17 +271,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");

Once again, you have a continuation line that is indented by the same 
amount as the code in the inner block.  Please fix this properly.

> +		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 */

Alan Stern

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 4/5] usb: host: Stops USB controller init if PLL fails to lock
@ 2019-01-28 15:38     ` Alan Stern
  0 siblings, 0 replies; 18+ messages in thread
From: Alan Stern @ 2019-01-28 15:38 UTC (permalink / raw)
  To: Yinbo Zhu
  Cc: Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

On Fri, 25 Jan 2019, Yinbo Zhu wrote:

> From: Ramneek Mehresh <ramneek.mehresh@freescale.com>
> 
> USB erratum-A006918 workaround tries to start internal PHY inside
> uboot (when PLL fails to lock). However, if the workaround also
> fails, then USB initialization is also stopped inside Linux.
> Erratum-A006918 workaround failure creates "fsl,erratum_a006918"
> node in device-tree. Presence of this node in device-tree is
> used to stop USB controller initialization in Linux
> 
> Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
> Signed-off-by: Suresh Gupta <suresh.gupta@freescale.com>
> Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
> ---
>  drivers/usb/host/ehci-fsl.c      |    5 +++++
>  drivers/usb/host/fsl-mph-dr-of.c |    3 ++-
>  2 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index 373a816..8b47277 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -236,6 +236,11 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
>  		portsc |= PORT_PTS_PTW;
>  		/* fall through */
>  	case FSL_USB2_PHY_UTMI:
> +		if (pdata->has_fsl_erratum_a006918) {
> +			pr_warn("fsl-ehci: USB PHY clock invalid\n");

Again, you should use dev_warn() instead of pr_warn().

Alan Stern

> +			return -EINVAL;
> +		}
> +
>  	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
> diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
> index 4f8b8a0..762b976 100644
> --- a/drivers/usb/host/fsl-mph-dr-of.c
> +++ b/drivers/usb/host/fsl-mph-dr-of.c
> @@ -224,13 +224,14 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
>  		of_property_read_bool(np, "fsl,usb-erratum-a005275");
>  	pdata->has_fsl_erratum_a005697 =
>  		of_property_read_bool(np, "fsl,usb_erratum-a005697");
> +	pdata->has_fsl_erratum_a006918 =
> +		of_property_read_bool(np, "fsl,usb_erratum-a006918");
>  
>  	if (of_get_property(np, "fsl,usb_erratum_14", NULL))
>  		pdata->has_fsl_erratum_14 = 1;
>  	else
>  		pdata->has_fsl_erratum_14 = 0;
>  
> -
>  	/*
>  	 * Determine whether phy_clk_valid needs to be checked
>  	 * by reading property in device tree
> 


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [v4,4/5] usb: host: Stops USB controller init if PLL fails to lock
@ 2019-01-28 15:38     ` Alan Stern
  0 siblings, 0 replies; 18+ messages in thread
From: Alan Stern @ 2019-01-28 15:38 UTC (permalink / raw)
  To: Yinbo Zhu
  Cc: Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel

On Fri, 25 Jan 2019, Yinbo Zhu wrote:

> From: Ramneek Mehresh <ramneek.mehresh@freescale.com>
> 
> USB erratum-A006918 workaround tries to start internal PHY inside
> uboot (when PLL fails to lock). However, if the workaround also
> fails, then USB initialization is also stopped inside Linux.
> Erratum-A006918 workaround failure creates "fsl,erratum_a006918"
> node in device-tree. Presence of this node in device-tree is
> used to stop USB controller initialization in Linux
> 
> Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
> Signed-off-by: Suresh Gupta <suresh.gupta@freescale.com>
> Signed-off-by: Yinbo Zhu <yinbo.zhu@nxp.com>
> ---
>  drivers/usb/host/ehci-fsl.c      |    5 +++++
>  drivers/usb/host/fsl-mph-dr-of.c |    3 ++-
>  2 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index 373a816..8b47277 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -236,6 +236,11 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
>  		portsc |= PORT_PTS_PTW;
>  		/* fall through */
>  	case FSL_USB2_PHY_UTMI:
> +		if (pdata->has_fsl_erratum_a006918) {
> +			pr_warn("fsl-ehci: USB PHY clock invalid\n");

Again, you should use dev_warn() instead of pr_warn().

Alan Stern

> +			return -EINVAL;
> +		}
> +
>  	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
> diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
> index 4f8b8a0..762b976 100644
> --- a/drivers/usb/host/fsl-mph-dr-of.c
> +++ b/drivers/usb/host/fsl-mph-dr-of.c
> @@ -224,13 +224,14 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
>  		of_property_read_bool(np, "fsl,usb-erratum-a005275");
>  	pdata->has_fsl_erratum_a005697 =
>  		of_property_read_bool(np, "fsl,usb_erratum-a005697");
> +	pdata->has_fsl_erratum_a006918 =
> +		of_property_read_bool(np, "fsl,usb_erratum-a006918");
>  
>  	if (of_get_property(np, "fsl,usb_erratum_14", NULL))
>  		pdata->has_fsl_erratum_14 = 1;
>  	else
>  		pdata->has_fsl_erratum_14 = 0;
>  
> -
>  	/*
>  	 * Determine whether phy_clk_valid needs to be checked
>  	 * by reading property in device tree
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [PATCH v4 2/5] usb: phy: Workaround for USB erratum-A005728
  2019-01-28 15:36     ` [v4,2/5] " Alan Stern
  (?)
@ 2019-05-08  3:26     ` Yinbo Zhu
  2019-05-08  6:41       ` Greg Kroah-Hartman
  -1 siblings, 1 reply; 18+ messages in thread
From: Yinbo Zhu @ 2019-05-08  3:26 UTC (permalink / raw)
  To: Alan Stern
  Cc: Xiaobo Xie, Jerry Huang, Ran Wang, Greg Kroah-Hartman,
	Ramneek Mehresh, Nikhil Badola, Suresh Gupta, linux-usb,
	linux-kernel, Suresh Gupta



> -----Original Message-----
> From: Alan Stern [mailto:stern@rowland.harvard.edu]
> Sent: 2019年1月28日 23:37
> To: Yinbo Zhu <yinbo.zhu@nxp.com>
> Cc: 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-kernel@vger.kernel.org; Suresh Gupta
> <B42813@freescale.com>
> Subject: Re: [PATCH v4 2/5] usb: phy: Workaround for USB erratum-A005728
> 
> On Fri, 25 Jan 2019, Yinbo Zhu wrote:
> 
> > 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 v4:
> > 		Incorrect indentation of the continuation line.
> > 		replace pr_err with dev_err.
> >
> >  drivers/usb/host/ehci-fsl.c |   38
> +++++++++++++++++++++++++++-----------
> >  drivers/usb/host/ehci-fsl.h |    3 +++
> >  2 files changed, 30 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> > index 38674b7..373a816 100644
> > --- a/drivers/usb/host/ehci-fsl.c
> > +++ b/drivers/usb/host/ehci-fsl.c
> > @@ -183,6 +183,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 (!(ioread32be(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)
> > @@ -226,6 +237,17 @@ 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)) {
> > +			dev_err(dev,
> > +				"%s: USB PHY clock invalid\n", dev_name(dev));
> 
> This looks silly; it prints the device name twice (once because that's what
> dev_err() does, and then again because you explicitly told it to print the device
> name).
> 
> Look at how dev_err() is used in other parts of the driver and do the same thing.
> 
> > +			return -EINVAL;
> > +		}
> > +
> >  		if (pdata->have_sysif_regs && pdata->controller_ver) {
> >  			/* controller version 1.6 or above */
> >  			tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL); @@ -249,17
> +271,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");
> 
> Once again, you have a continuation line that is indented by the same amount as
> the code in the inner block.  Please fix this properly.
Hi Alan stern,

Above code indented is in oder to ensure that every line less than 80 characters,
Otherwise, check-patch tool to check patch that will has error.

Regards,
Yinbo
> > +		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 */
> 
> Alan Stern


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 2/5] usb: phy: Workaround for USB erratum-A005728
  2019-05-08  3:26     ` [PATCH v4 2/5] " Yinbo Zhu
@ 2019-05-08  6:41       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 18+ messages in thread
From: Greg Kroah-Hartman @ 2019-05-08  6:41 UTC (permalink / raw)
  To: Yinbo Zhu
  Cc: Alan Stern, Xiaobo Xie, Jerry Huang, Ran Wang, Ramneek Mehresh,
	Nikhil Badola, Suresh Gupta, linux-usb, linux-kernel,
	Suresh Gupta

On Wed, May 08, 2019 at 03:26:09AM +0000, Yinbo Zhu wrote:
> 
> 
> > -----Original Message-----
> > From: Alan Stern [mailto:stern@rowland.harvard.edu]
> > Sent: 2019年1月28日 23:37
> > To: Yinbo Zhu <yinbo.zhu@nxp.com>
> > Cc: 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-kernel@vger.kernel.org; Suresh Gupta
> > <B42813@freescale.com>
> > Subject: Re: [PATCH v4 2/5] usb: phy: Workaround for USB erratum-A005728
> > 
> > On Fri, 25 Jan 2019, Yinbo Zhu wrote:
> > 
> > > 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 v4:
> > > 		Incorrect indentation of the continuation line.
> > > 		replace pr_err with dev_err.
> > >
> > >  drivers/usb/host/ehci-fsl.c |   38
> > +++++++++++++++++++++++++++-----------
> > >  drivers/usb/host/ehci-fsl.h |    3 +++
> > >  2 files changed, 30 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> > > index 38674b7..373a816 100644
> > > --- a/drivers/usb/host/ehci-fsl.c
> > > +++ b/drivers/usb/host/ehci-fsl.c
> > > @@ -183,6 +183,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 (!(ioread32be(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)
> > > @@ -226,6 +237,17 @@ 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)) {
> > > +			dev_err(dev,
> > > +				"%s: USB PHY clock invalid\n", dev_name(dev));
> > 
> > This looks silly; it prints the device name twice (once because that's what
> > dev_err() does, and then again because you explicitly told it to print the device
> > name).
> > 
> > Look at how dev_err() is used in other parts of the driver and do the same thing.
> > 
> > > +			return -EINVAL;
> > > +		}
> > > +
> > >  		if (pdata->have_sysif_regs && pdata->controller_ver) {
> > >  			/* controller version 1.6 or above */
> > >  			tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL); @@ -249,17
> > +271,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");
> > 
> > Once again, you have a continuation line that is indented by the same amount as
> > the code in the inner block.  Please fix this properly.
> Hi Alan stern,
> 
> Above code indented is in oder to ensure that every line less than 80 characters,
> Otherwise, check-patch tool to check patch that will has error.

No, that's is not what Alan is asking you to do here.  Please fix this
up to match other multi-line if statements.

greg k-h

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-05-08  6:41 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-25  6:02 [PATCH v4 1/5] usb: fsl: Set USB_EN bit to select ULPI phy Yinbo Zhu
2019-01-25  6:02 ` [v4,1/5] " yinbo.zhu
2019-01-25  6:02 ` [PATCH v4 2/5] usb: phy: Workaround for USB erratum-A005728 Yinbo Zhu
2019-01-25  6:02   ` [v4,2/5] " yinbo.zhu
2019-01-28 15:36   ` [PATCH v4 2/5] " Alan Stern
2019-01-28 15:36     ` [v4,2/5] " Alan Stern
2019-05-08  3:26     ` [PATCH v4 2/5] " Yinbo Zhu
2019-05-08  6:41       ` Greg Kroah-Hartman
2019-01-25  6:03 ` [PATCH v4 3/5] usb: linux/fsl_device: Add platform member has_fsl_erratum_a006918 Yinbo Zhu
2019-01-25  6:03   ` [v4,3/5] " yinbo.zhu
2019-01-25  6:03 ` [PATCH v4 4/5] usb: host: Stops USB controller init if PLL fails to lock Yinbo Zhu
2019-01-25  6:03   ` [v4,4/5] " yinbo.zhu
2019-01-28 15:38   ` [PATCH v4 4/5] " Alan Stern
2019-01-28 15:38     ` [v4,4/5] " Alan Stern
2019-01-25  6:03 ` [PATCH v4 5/5] usb :fsl: Change string format for errata property Yinbo Zhu
2019-01-25  6:03   ` [v4,5/5] " yinbo.zhu
2019-01-28 15:33 ` [PATCH v4 1/5] usb: fsl: Set USB_EN bit to select ULPI phy Alan Stern
2019-01-28 15:33   ` [v4,1/5] " Alan Stern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.