2019-06-05 05:50:28

by Yinbo Zhu

[permalink] [raw]
Subject: [PATCH v6 1/5] usb: fsl: Set USB_EN bit to select ULPI phy

From: Nikhil Badola <[email protected]>

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

Signed-off-by: Nikhil Badola <[email protected]>
Signed-off-by: Yinbo Zhu <[email protected]>
---
drivers/usb/host/ehci-fsl.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index e3d0c1c25160..38674b7aa51e 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
--
2.17.1


2019-06-05 05:50:28

by Yinbo Zhu

[permalink] [raw]
Subject: [PATCH v6 2/5] usb: phy: Workaround for USB erratum-A005728

From: Suresh Gupta <[email protected]>

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 <[email protected]>
Signed-off-by: Yinbo Zhu <[email protected]>
---
Change in v6:
Indented the code in ehci-fsl.c

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 38674b7aa51e..8f3bf3efb038 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,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)) {
+ dev_err(dev, "USB PHY clock invalid\n");
+ 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 +270,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 cbc422032e50..9d18c6e6ab27 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 */
--
2.17.1

2019-06-05 05:51:19

by Yinbo Zhu

[permalink] [raw]
Subject: [PATCH v6 5/5] usb :fsl: Change string format for errata property

From: Nikhil Badola <[email protected]>

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 <[email protected]>
Signed-off-by: Nikhil Badola <[email protected]>
Signed-off-by: Yinbo Zhu <[email protected]>
---
drivers/usb/host/fsl-mph-dr-of.c | 7 ++-----
1 file 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 762b97600ab0..ae8f60f6e6a5 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
--
2.17.1

2019-06-05 05:52:08

by Yinbo Zhu

[permalink] [raw]
Subject: [PATCH v6 4/5] usb: host: Stops USB controller init if PLL fails to lock

From: Ramneek Mehresh <[email protected]>

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 <[email protected]>
Signed-off-by: Suresh Gupta <[email protected]>
Signed-off-by: Yinbo Zhu <[email protected]>
---
Change in v6:
add a "Fall through" comment

drivers/usb/host/ehci-fsl.c | 10 +++++++++-
drivers/usb/host/fsl-mph-dr-of.c | 3 ++-
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 8f3bf3efb038..86ae37086a74 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -234,8 +234,16 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
break;
case FSL_USB2_PHY_UTMI_WIDE:
portsc |= PORT_PTS_PTW;
- /* fall through */
case FSL_USB2_PHY_UTMI:
+ /* Presence of this node "has_fsl_erratum_a006918"
+ * in device-tree is used to stop USB controller
+ * initialization in Linux
+ */
+ if (pdata->has_fsl_erratum_a006918) {
+ dev_warn(dev, "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 4f8b8a08c914..762b97600ab0 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
--
2.17.1

2019-06-05 14:23:47

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH v6 4/5] usb: host: Stops USB controller init if PLL fails to lock

On Wed, 5 Jun 2019, Yinbo Zhu wrote:

> From: Ramneek Mehresh <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Suresh Gupta <[email protected]>
> Signed-off-by: Yinbo Zhu <[email protected]>
> ---
> Change in v6:
> add a "Fall through" comment
>
> drivers/usb/host/ehci-fsl.c | 10 +++++++++-
> drivers/usb/host/fsl-mph-dr-of.c | 3 ++-
> 2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index 8f3bf3efb038..86ae37086a74 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -234,8 +234,16 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
> break;
> case FSL_USB2_PHY_UTMI_WIDE:
> portsc |= PORT_PTS_PTW;
> - /* fall through */
> case FSL_USB2_PHY_UTMI:
> + /* Presence of this node "has_fsl_erratum_a006918"
> + * in device-tree is used to stop USB controller
> + * initialization in Linux
> + */
> + if (pdata->has_fsl_erratum_a006918) {
> + dev_warn(dev, "USB PHY clock invalid\n");
> + return -EINVAL;
> + }
> +
> case FSL_USB2_PHY_UTMI_DUAL:

This is bad. You got rid of a "fall through" comment that was needed,
and you failed to add another one where it was needed.

Alan Stern

> /* 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 4f8b8a08c914..762b97600ab0 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
>

2019-06-06 06:36:46

by Yinbo Zhu

[permalink] [raw]
Subject: RE: [EXT] Re: [PATCH v6 4/5] usb: host: Stops USB controller init if PLL fails to lock



> -----Original Message-----
> From: Alan Stern [mailto:[email protected]]
> Sent: 2019??6??5?? 22:22
> To: Yinbo Zhu <[email protected]>
> Cc: Xiaobo Xie <[email protected]>; Greg Kroah-Hartman
> <[email protected]>; Ramneek Mehresh
> <[email protected]>; Nikhil Badola
> <[email protected]>; Ran Wang <[email protected]>;
> [email protected]; [email protected]; Jiafei Pan
> <[email protected]>
> Subject: [EXT] Re: [PATCH v6 4/5] usb: host: Stops USB controller init if PLL fails to
> lock
>
> Caution: EXT Email
>
> On Wed, 5 Jun 2019, Yinbo Zhu wrote:
>
> > From: Ramneek Mehresh <[email protected]>
> >
> > 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 <[email protected]>
> > Signed-off-by: Suresh Gupta <[email protected]>
> > Signed-off-by: Yinbo Zhu <[email protected]>
> > ---
> > Change in v6:
> > add a "Fall through" comment
> >
> > drivers/usb/host/ehci-fsl.c | 10 +++++++++-
> > drivers/usb/host/fsl-mph-dr-of.c | 3 ++-
> > 2 files changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> > index 8f3bf3efb038..86ae37086a74 100644
> > --- a/drivers/usb/host/ehci-fsl.c
> > +++ b/drivers/usb/host/ehci-fsl.c
> > @@ -234,8 +234,16 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
> > break;
> > case FSL_USB2_PHY_UTMI_WIDE:
> > portsc |= PORT_PTS_PTW;
> > - /* fall through */
> > case FSL_USB2_PHY_UTMI:
> > + /* Presence of this node "has_fsl_erratum_a006918"
> > + * in device-tree is used to stop USB controller
> > + * initialization in Linux
> > + */
> > + if (pdata->has_fsl_erratum_a006918) {
> > + dev_warn(dev, "USB PHY clock invalid\n");
> > + return -EINVAL;
> > + }
> > +
> > case FSL_USB2_PHY_UTMI_DUAL:
>
>
> You need to add a "Fall through" comment between these two cases.
> > 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
>
> Alan Stern
> Hi Alan Stern,
>
> Your meaning is to remove "/* fall through*/" or add the erratum commont replace "/* fall through*/"
>
> Regards,
> Yinbo
> This is bad. You got rid of a "fall through" comment that was needed, and you
> failed to add another one where it was needed.
>
> Alan Stern
I don't get your meaning.
Yinbo
>
> > /* 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 4f8b8a08c914..762b97600ab0 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
> >

2019-06-11 07:02:07

by Yinbo Zhu

[permalink] [raw]
Subject: RE: [EXT] Re: [PATCH v6 4/5] usb: host: Stops USB controller init if PLL fails to lock



> -----Original Message-----
> From: Yinbo Zhu
> Sent: 2019??6??6?? 14:35
> To: Alan Stern <[email protected]>
> Cc: Xiaobo Xie <[email protected]>; Greg Kroah-Hartman
> <[email protected]>; Ramneek Mehresh
> <[email protected]>; Nikhil Badola
> <[email protected]>; Ran Wang <[email protected]>;
> [email protected]; [email protected]; Jiafei Pan
> <[email protected]>
> Subject: RE: [EXT] Re: [PATCH v6 4/5] usb: host: Stops USB controller init if PLL
> fails to lock
>
>
>
> > -----Original Message-----
> > From: Alan Stern [mailto:[email protected]]
> > Sent: 2019??6??5?? 22:22
> > To: Yinbo Zhu <[email protected]>
> > Cc: Xiaobo Xie <[email protected]>; Greg Kroah-Hartman
> > <[email protected]>; Ramneek Mehresh
> > <[email protected]>; Nikhil Badola
> > <[email protected]>; Ran Wang <[email protected]>;
> > [email protected]; [email protected]; Jiafei Pan
> > <[email protected]>
> > Subject: [EXT] Re: [PATCH v6 4/5] usb: host: Stops USB controller init
> > if PLL fails to lock
> >
> > Caution: EXT Email
> >
> > On Wed, 5 Jun 2019, Yinbo Zhu wrote:
> >
> > > From: Ramneek Mehresh <[email protected]>
> > >
> > > 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 <[email protected]>
> > > Signed-off-by: Suresh Gupta <[email protected]>
> > > Signed-off-by: Yinbo Zhu <[email protected]>
> > > ---
> > > Change in v6:
> > > add a "Fall through" comment
> > >
> > > drivers/usb/host/ehci-fsl.c | 10 +++++++++-
> > > drivers/usb/host/fsl-mph-dr-of.c | 3 ++-
> > > 2 files changed, 11 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/usb/host/ehci-fsl.c
> > > b/drivers/usb/host/ehci-fsl.c index 8f3bf3efb038..86ae37086a74
> > > 100644
> > > --- a/drivers/usb/host/ehci-fsl.c
> > > +++ b/drivers/usb/host/ehci-fsl.c
> > > @@ -234,8 +234,16 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
> > > break;
> > > case FSL_USB2_PHY_UTMI_WIDE:
> > > portsc |= PORT_PTS_PTW;
> > > - /* fall through */
> > > case FSL_USB2_PHY_UTMI:
> > > + /* Presence of this node "has_fsl_erratum_a006918"
> > > + * in device-tree is used to stop USB controller
> > > + * initialization in Linux
> > > + */
> > > + if (pdata->has_fsl_erratum_a006918) {
> > > + dev_warn(dev, "USB PHY clock invalid\n");
> > > + return -EINVAL;
> > > + }
> > > +
> > > case FSL_USB2_PHY_UTMI_DUAL:
> >
> >
> > You need to add a "Fall through" comment between these two cases.
> > > 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
> >
> > Alan Stern
> > Hi Alan Stern,
> >
> > Your meaning is to remove "/* fall through*/" or add the erratum commont
> replace "/* fall through*/"
> >
> > Regards,
> > Yinbo
> > This is bad. You got rid of a "fall through" comment that was needed,
> > and you failed to add another one where it was needed.
> >
> > Alan Stern
> I don't get your meaning.
> Yinbo
Hi Alan,

Your meaning is like following code change, isn't it? if no, could you give a example
portsc |= PORT_PTS_PTW;
/* fall through */
case FSL_USB2_PHY_UTMI:
+ /* Presence of this node "has_fsl_erratum_a006918"
+ * in device-tree is used to stop USB controller
+ * initialization in Linux
+ */
+ if (pdata->has_fsl_erratum_a006918) {
+ dev_warn(dev, "USB PHY clock invalid\n");
+ return -EINVAL;
+ }
+
case FSL_USB2_PHY_UTMI_DUAL:
/* PHY_CLK_VALID bit is de-featured from all controller
Regards,
Yinbo.

> >
> > > /* 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 4f8b8a08c914..762b97600ab0 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
> > >