linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/usb: fix issue of CPU halt when missing USB PHY clock
@ 2012-02-01  9:20 Shengzhou Liu
  2012-02-01 10:11 ` Pavan Kondeti
  0 siblings, 1 reply; 5+ messages in thread
From: Shengzhou Liu @ 2012-02-01  9:20 UTC (permalink / raw)
  To: linux-usb; +Cc: linuxppc-dev, Shengzhou Liu

when missing USB PHY clock, kernel booting up will halt during USB
initialization. We should check USBGP[PHY_CLK_VALID] bit to avoid
CPU hang in this case.

Signed-off-by: Shengzhou Liu <Shengzhou.Liu@freescale.com>
---
 drivers/usb/host/ehci-fsl.c |   11 +++++++++--
 drivers/usb/host/ehci-fsl.h |    1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index b556a72..834237e 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -239,7 +239,7 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
 	ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]);
 }
 
-static void ehci_fsl_usb_setup(struct ehci_hcd *ehci)
+static int ehci_fsl_usb_setup(struct ehci_hcd *ehci)
 {
 	struct usb_hcd *hcd = ehci_to_hcd(ehci);
 	struct fsl_usb2_platform_data *pdata;
@@ -299,12 +299,19 @@ static void ehci_fsl_usb_setup(struct ehci_hcd *ehci)
 #endif
 		out_be32(non_ehci + FSL_SOC_USB_SICTRL, 0x00000001);
 	}
+
+	if (!(in_be32(non_ehci + FSL_SOC_USB_CTRL) & CTRL_PHY_CLK_VALID)) {
+		printk(KERN_WARNING "fsl-ehci: USB PHY clock invalid\n");
+		return -1;
+	}
+	return 0;
 }
 
 /* called after powerup, by probe or system-pm "wakeup" */
 static int ehci_fsl_reinit(struct ehci_hcd *ehci)
 {
-	ehci_fsl_usb_setup(ehci);
+	if (ehci_fsl_usb_setup(ehci))
+		return -1;
 	ehci_port_power(ehci, 0);
 
 	return 0;
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
index 4918062..dd3dc47 100644
--- a/drivers/usb/host/ehci-fsl.h
+++ b/drivers/usb/host/ehci-fsl.h
@@ -45,5 +45,6 @@
 #define FSL_SOC_USB_PRICTRL	0x40c	/* NOTE: big-endian */
 #define FSL_SOC_USB_SICTRL	0x410	/* NOTE: big-endian */
 #define FSL_SOC_USB_CTRL	0x500	/* NOTE: big-endian */
+#define CTRL_PHY_CLK_VALID      (1 << 17)
 #define SNOOP_SIZE_2GB		0x1e
 #endif				/* _EHCI_FSL_H */
-- 
1.6.4

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

* Re: [PATCH] powerpc/usb: fix issue of CPU halt when missing USB PHY clock
  2012-02-01  9:20 [PATCH] powerpc/usb: fix issue of CPU halt when missing USB PHY clock Shengzhou Liu
@ 2012-02-01 10:11 ` Pavan Kondeti
  2012-02-02  3:31   ` Liu Shengzhou-B36685
  0 siblings, 1 reply; 5+ messages in thread
From: Pavan Kondeti @ 2012-02-01 10:11 UTC (permalink / raw)
  To: Shengzhou Liu; +Cc: linux-usb, linuxppc-dev

On 2/1/2012 2:50 PM, Shengzhou Liu wrote:
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index b556a72..834237e 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -239,7 +239,7 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
>  	ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]);
>  }
>  
> -static void ehci_fsl_usb_setup(struct ehci_hcd *ehci)
> +static int ehci_fsl_usb_setup(struct ehci_hcd *ehci)
>  {
>  	struct usb_hcd *hcd = ehci_to_hcd(ehci);
>  	struct fsl_usb2_platform_data *pdata;
> @@ -299,12 +299,19 @@ static void ehci_fsl_usb_setup(struct ehci_hcd *ehci)
>  #endif
>  		out_be32(non_ehci + FSL_SOC_USB_SICTRL, 0x00000001);
>  	}
> +
> +	if (!(in_be32(non_ehci + FSL_SOC_USB_CTRL) & CTRL_PHY_CLK_VALID)) {
> +		printk(KERN_WARNING "fsl-ehci: USB PHY clock invalid\n");
> +		return -1;

Please return a proper error code. -ENODEV ?

> +	}
> +	return 0;
>  }
>  


-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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

* RE: [PATCH] powerpc/usb: fix issue of CPU halt when missing USB PHY clock
  2012-02-01 10:11 ` Pavan Kondeti
@ 2012-02-02  3:31   ` Liu Shengzhou-B36685
  2012-02-15  2:31     ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 5+ messages in thread
From: Liu Shengzhou-B36685 @ 2012-02-02  3:31 UTC (permalink / raw)
  To: Pavan Kondeti; +Cc: linux-usb@vger.kernel.org, linuxppc-dev@lists.ozlabs.org


> -----Original Message-----
> From: Pavan Kondeti [mailto:pkondeti@codeaurora.org]
> Sent: Wednesday, February 01, 2012 6:11 PM
> To: Liu Shengzhou-B36685
> Cc: linux-usb@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
> Subject: Re: [PATCH] powerpc/usb: fix issue of CPU halt when missing
> USB PHY clock
>=20
> On 2/1/2012 2:50 PM, Shengzhou Liu wrote:
> > diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-
> fsl.c
> > index b556a72..834237e 100644
> > --- a/drivers/usb/host/ehci-fsl.c
> > +++ b/drivers/usb/host/ehci-fsl.c
> > @@ -239,7 +239,7 @@ static void ehci_fsl_setup_phy(struct ehci_hcd
> *ehci,
> >  	ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]);
> >  }
> >
> > -static void ehci_fsl_usb_setup(struct ehci_hcd *ehci)
> > +static int ehci_fsl_usb_setup(struct ehci_hcd *ehci)
> >  {
> >  	struct usb_hcd *hcd =3D ehci_to_hcd(ehci);
> >  	struct fsl_usb2_platform_data *pdata; @@ -299,12 +299,19 @@
> static
> > void ehci_fsl_usb_setup(struct ehci_hcd *ehci)  #endif
> >  		out_be32(non_ehci + FSL_SOC_USB_SICTRL, 0x00000001);
> >  	}
> > +
> > +	if (!(in_be32(non_ehci + FSL_SOC_USB_CTRL) & CTRL_PHY_CLK_VALID))
> {
> > +		printk(KERN_WARNING "fsl-ehci: USB PHY clock invalid\n");
> > +		return -1;
>=20
> Please return a proper error code. -ENODEV ?

[Shengzhou] Ok, updated in v2, thanks.
>=20
> > +	}
> > +	return 0;
> >  }
> >
> --
> Sent by a consultant of the Qualcomm Innovation Center, Inc.
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
> Forum.

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

* RE: [PATCH] powerpc/usb: fix issue of CPU halt when missing USB PHY clock
  2012-02-02  3:31   ` Liu Shengzhou-B36685
@ 2012-02-15  2:31     ` Benjamin Herrenschmidt
  2012-02-16 10:16       ` Liu Shengzhou-B36685
  0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2012-02-15  2:31 UTC (permalink / raw)
  To: Liu Shengzhou-B36685
  Cc: linuxppc-dev@lists.ozlabs.org, linux-usb@vger.kernel.org,
	Pavan Kondeti


> > > +	if (!(in_be32(non_ehci + FSL_SOC_USB_CTRL) & CTRL_PHY_CLK_VALID))
> > {
> > > +		printk(KERN_WARNING "fsl-ehci: USB PHY clock invalid\n");
> > > +		return -1;
> > 
> > Please return a proper error code. -ENODEV ?
> 
> [Shengzhou] Ok, updated in v2, thanks.
> >

Note that I just got a p5020ds from FSL, and with it's default
configuration, when I build & boot current upstream with FSL USB
support (64-bit kernel) it hangs when initializing USB.

With or without this patch.

It complains about invalid dr-mode (there's two USB nodes in the .dts
coming from uboot, an "mph" and "dr", the former has no dr-mode property
in the device-tree.

Is the current kernel incompatible with old device-tree's ? (that would
be a shame...)

Cheers,
Ben.

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

* RE: [PATCH] powerpc/usb: fix issue of CPU halt when missing USB PHY clock
  2012-02-15  2:31     ` Benjamin Herrenschmidt
@ 2012-02-16 10:16       ` Liu Shengzhou-B36685
  0 siblings, 0 replies; 5+ messages in thread
From: Liu Shengzhou-B36685 @ 2012-02-16 10:16 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: linuxppc-dev@lists.ozlabs.org, linux-usb@vger.kernel.org,
	Pavan Kondeti

DQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IEJlbmphbWluIEhlcnJlbnNj
aG1pZHQgW21haWx0bzpiZW5oQGtlcm5lbC5jcmFzaGluZy5vcmddDQo+IFNlbnQ6IFdlZG5lc2Rh
eSwgRmVicnVhcnkgMTUsIDIwMTIgMTA6MzEgQU0NCj4gVG86IExpdSBTaGVuZ3pob3UtQjM2Njg1
DQo+IENjOiBQYXZhbiBLb25kZXRpOyBsaW51eC11c2JAdmdlci5rZXJuZWwub3JnOyBsaW51eHBw
Yy0NCj4gZGV2QGxpc3RzLm96bGFicy5vcmcNCj4gU3ViamVjdDogUkU6IFtQQVRDSF0gcG93ZXJw
Yy91c2I6IGZpeCBpc3N1ZSBvZiBDUFUgaGFsdCB3aGVuIG1pc3NpbmcNCj4gVVNCIFBIWSBjbG9j
aw0KPiANCj4gDQo+ID4gPiA+ICsJaWYgKCEoaW5fYmUzMihub25fZWhjaSArIEZTTF9TT0NfVVNC
X0NUUkwpICYNCj4gPiA+ID4gK0NUUkxfUEhZX0NMS19WQUxJRCkpDQo+ID4gPiB7DQo+ID4gPiA+
ICsJCXByaW50ayhLRVJOX1dBUk5JTkcgImZzbC1laGNpOiBVU0IgUEhZIGNsb2NrDQo+IGludmFs
aWRcbiIpOw0KPiA+ID4gPiArCQlyZXR1cm4gLTE7DQo+ID4gPg0KPiA+ID4gUGxlYXNlIHJldHVy
biBhIHByb3BlciBlcnJvciBjb2RlLiAtRU5PREVWID8NCj4gPg0KPiA+IFtTaGVuZ3pob3VdIE9r
LCB1cGRhdGVkIGluIHYyLCB0aGFua3MuDQo+ID4gPg0KPiANCj4gTm90ZSB0aGF0IEkganVzdCBn
b3QgYSBwNTAyMGRzIGZyb20gRlNMLCBhbmQgd2l0aCBpdCdzIGRlZmF1bHQNCj4gY29uZmlndXJh
dGlvbiwgd2hlbiBJIGJ1aWxkICYgYm9vdCBjdXJyZW50IHVwc3RyZWFtIHdpdGggRlNMIFVTQg0K
PiBzdXBwb3J0ICg2NC1iaXQga2VybmVsKSBpdCBoYW5ncyB3aGVuIGluaXRpYWxpemluZyBVU0Iu
DQo+IA0KPiBXaXRoIG9yIHdpdGhvdXQgdGhpcyBwYXRjaC4NCj4gDQo+IEl0IGNvbXBsYWlucyBh
Ym91dCBpbnZhbGlkIGRyLW1vZGUgKHRoZXJlJ3MgdHdvIFVTQiBub2RlcyBpbiB0aGUgLmR0cw0K
PiBjb21pbmcgZnJvbSB1Ym9vdCwgYW4gIm1waCIgYW5kICJkciIsIHRoZSBmb3JtZXIgaGFzIG5v
IGRyLW1vZGUNCj4gcHJvcGVydHkgaW4gdGhlIGRldmljZS10cmVlLg0KPiANCj4gSXMgdGhlIGN1
cnJlbnQga2VybmVsIGluY29tcGF0aWJsZSB3aXRoIG9sZCBkZXZpY2UtdHJlZSdzID8gKHRoYXQg
d291bGQNCj4gYmUgYSBzaGFtZS4uLikNCj4gDQo+IENoZWVycywNCj4gQmVuLg0KPiANCj4gDQpM
b29rcyBsaWtlIHRoZXJlIGlzIGEgYnVnLCBwbGVhc2UgdHJ5IHRvIGFkZCB0aGUgcGF0Y2ggaHR0
cDovL3BhdGNod29yay5vemxhYnMub3JnL3BhdGNoLzE0MTU1OA0KLVNoZW5nemhvdQ0KDQoNCg0K

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

end of thread, other threads:[~2012-02-16 10:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-01  9:20 [PATCH] powerpc/usb: fix issue of CPU halt when missing USB PHY clock Shengzhou Liu
2012-02-01 10:11 ` Pavan Kondeti
2012-02-02  3:31   ` Liu Shengzhou-B36685
2012-02-15  2:31     ` Benjamin Herrenschmidt
2012-02-16 10:16       ` Liu Shengzhou-B36685

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).