linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] add soc setup code for USB DR OTG mode
@ 2007-02-05  9:10 Li Yang
  2007-02-05 15:15 ` Kumar Gala
  0 siblings, 1 reply; 5+ messages in thread
From: Li Yang @ 2007-02-05  9:10 UTC (permalink / raw)
  To: Paul; +Cc: linuxppc-dev

Signed-off-by: Li Yang <leoli@freescale.com>
---
 arch/powerpc/sysdev/fsl_soc.c |   76 ++++++++++++++++++++++++++++++----------
 1 files changed, 57 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index ad31e56..d9541aa 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -440,7 +440,8 @@ static int __init fsl_usb_of_init(void)
 {
 	struct device_node *np;
 	unsigned int i;
-	struct platform_device *usb_dev_mph = NULL, *usb_dev_dr = NULL;
+	struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL,
+		*usb_dev_dr_client = NULL;
 	int ret;
 
 	for (np = NULL, i = 0;
@@ -506,33 +507,70 @@ static int __init fsl_usb_of_init(void)
 
 		of_irq_to_resource(np, 0, &r[1]);
 
-		usb_dev_dr =
-		    platform_device_register_simple("fsl-ehci", i, r, 2);
-		if (IS_ERR(usb_dev_dr)) {
-			ret = PTR_ERR(usb_dev_dr);
-			goto err;
-		}
-
-		usb_dev_dr->dev.coherent_dma_mask = 0xffffffffUL;
-		usb_dev_dr->dev.dma_mask = &usb_dev_dr->dev.coherent_dma_mask;
+		prop = get_property(np, "dr_mode", NULL);
 
-		usb_data.operating_mode = FSL_USB2_DR_HOST;
+		if (prop && !strcmp(prop, "host")) {
+			usb_data.operating_mode = FSL_USB2_DR_HOST;
+			usb_dev_dr_host = platform_device_register_simple(
+					"fsl-ehci", i, r, 2);
+			if (IS_ERR(usb_dev_dr_host)) {
+				ret = PTR_ERR(usb_dev_dr_host);
+				goto err;
+			}
+			
+		} else if (prop && !strcmp(prop, "peripheral")) {
+			usb_data.operating_mode = FSL_USB2_DR_DEVICE;
+			usb_dev_dr_client = platform_device_register_simple(
+					"fsl-usb2-udc", i, r, 2);
+			if (IS_ERR(usb_dev_dr_client)) {
+				ret = PTR_ERR(usb_dev_dr_client);
+				goto err;
+			}
+		} else if (!prop || (prop && !strcmp(prop, "otg"))) {
+			usb_data.operating_mode = FSL_USB2_DR_OTG;
+			usb_dev_dr_host = platform_device_register_simple(
+					"fsl-ehci", i, r, 2);
+			if (IS_ERR(usb_dev_dr_host)) {
+				ret = PTR_ERR(usb_dev_dr_host);
+				goto err;
+			}
+			usb_dev_dr_client = platform_device_register_simple(
+					"fsl-usb2-udc", i, r, 2);
+			if (IS_ERR(usb_dev_dr_client)) {
+				ret = PTR_ERR(usb_dev_dr_client);
+				goto err;
+			}
+		}
 
 		prop = get_property(np, "phy_type", NULL);
 		usb_data.phy_mode = determine_usb_phy(prop);
 
-		ret =
-		    platform_device_add_data(usb_dev_dr, &usb_data,
-					     sizeof(struct
-						    fsl_usb2_platform_data));
-		if (ret)
-			goto unreg_dr;
+		if (usb_dev_dr_host) {
+			usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL;
+			usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host->
+				dev.coherent_dma_mask;
+			if ((ret = platform_device_add_data(usb_dev_dr_host,
+						&usb_data, sizeof(struct
+						fsl_usb2_platform_data))))
+				goto unreg_dr;
+		}
+		if (usb_dev_dr_client) {
+			usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL;
+			usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client->
+				dev.coherent_dma_mask;
+			if ((ret = platform_device_add_data(usb_dev_dr_client,
+						&usb_data, sizeof(struct
+						fsl_usb2_platform_data))))
+				goto unreg_dr;
+		}
 	}
 	return 0;
 
 unreg_dr:
-	if (usb_dev_dr)
-		platform_device_unregister(usb_dev_dr);
+	if (usb_dev_dr_host)
+		platform_device_unregister(usb_dev_dr_host);
+	if (usb_dev_dr_client)
+		platform_device_unregister(usb_dev_dr_client);
 unreg_mph:
 	if (usb_dev_mph)
 		platform_device_unregister(usb_dev_mph);

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

* Re: [PATCH 2/3] add soc setup code for USB DR OTG mode
  2007-02-05  9:10 [PATCH 2/3] add soc setup code for USB DR OTG mode Li Yang
@ 2007-02-05 15:15 ` Kumar Gala
  2007-02-06  3:25   ` Li Yang-r58472
  2007-02-06 13:07   ` Arnd Bergmann
  0 siblings, 2 replies; 5+ messages in thread
From: Kumar Gala @ 2007-02-05 15:15 UTC (permalink / raw)
  To: Li Yang; +Cc: linuxppc-dev, Paul


On Feb 5, 2007, at 3:10 AM, Li Yang wrote:

You have no description about what this patch does and why its needed.

Nack.  See comments inline.

> Signed-off-by: Li Yang <leoli@freescale.com>
> ---
> arch/powerpc/sysdev/fsl_soc.c |   76 +++++++++++++++++++++++++++++ 
> +----------
> 1 files changed, 57 insertions(+), 19 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/ 
> fsl_soc.c
> index ad31e56..d9541aa 100644
> --- a/arch/powerpc/sysdev/fsl_soc.c
> +++ b/arch/powerpc/sysdev/fsl_soc.c
> @@ -440,7 +440,8 @@ static int __init fsl_usb_of_init(void)
> {
> 	struct device_node *np;
> 	unsigned int i;
> -	struct platform_device *usb_dev_mph = NULL, *usb_dev_dr = NULL;
> +	struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL,
> +		*usb_dev_dr_client = NULL;
> 	int ret;
> 	for (np = NULL, i = 0;
> @@ -506,33 +507,70 @@ static int __init fsl_usb_of_init(void)
> 		of_irq_to_resource(np, 0, &r[1]);
> -		usb_dev_dr =
> -		    platform_device_register_simple("fsl-ehci", i, r, 2);
> -		if (IS_ERR(usb_dev_dr)) {
> -			ret = PTR_ERR(usb_dev_dr);
> -			goto err;
> -		}
> -
> -		usb_dev_dr->dev.coherent_dma_mask = 0xffffffffUL;
> -		usb_dev_dr->dev.dma_mask = &usb_dev_dr->dev.coherent_dma_mask;
> +		prop = get_property(np, "dr_mode", NULL);
> -		usb_data.operating_mode = FSL_USB2_DR_HOST;
> +		if (prop && !strcmp(prop, "host")) {
> +			usb_data.operating_mode = FSL_USB2_DR_HOST;
> +			usb_dev_dr_host = platform_device_register_simple(
> +					"fsl-ehci", i, r, 2);
> +			if (IS_ERR(usb_dev_dr_host)) {
> +				ret = PTR_ERR(usb_dev_dr_host);
> +				goto err;
> +			}
> +			
> +		} else if (prop && !strcmp(prop, "peripheral")) {
> +			usb_data.operating_mode = FSL_USB2_DR_DEVICE;
> +			usb_dev_dr_client = platform_device_register_simple(
> +					"fsl-usb2-udc", i, r, 2);
> +			if (IS_ERR(usb_dev_dr_client)) {
> +				ret = PTR_ERR(usb_dev_dr_client);
> +				goto err;
> +			}
> +		} else if (!prop || (prop && !strcmp(prop, "otg"))) {

Why do we assume if the prop is not defined we are OTG?  This will  
break existing users and is not acceptable.  If the prop doesn't  
exist we have to assume 'host' support to maintain compatibility.

> +			usb_data.operating_mode = FSL_USB2_DR_OTG;
> +			usb_dev_dr_host = platform_device_register_simple(
> +					"fsl-ehci", i, r, 2);
> +			if (IS_ERR(usb_dev_dr_host)) {
> +				ret = PTR_ERR(usb_dev_dr_host);
> +				goto err;
> +			}
> +			usb_dev_dr_client = platform_device_register_simple(
> +					"fsl-usb2-udc", i, r, 2);
> +			if (IS_ERR(usb_dev_dr_client)) {
> +				ret = PTR_ERR(usb_dev_dr_client);
> +				goto err;
> +			}
> +		}

shouldn't there be an error case if the string doesn't match any of  
the above?

> 		prop = get_property(np, "phy_type", NULL);
> 		usb_data.phy_mode = determine_usb_phy(prop);
> -		ret =
> -		    platform_device_add_data(usb_dev_dr, &usb_data,
> -					     sizeof(struct
> -						    fsl_usb2_platform_data));
> -		if (ret)
> -			goto unreg_dr;
> +		if (usb_dev_dr_host) {
> +			usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL;
> +			usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host->
> +				dev.coherent_dma_mask;
> +			if ((ret = platform_device_add_data(usb_dev_dr_host,
> +						&usb_data, sizeof(struct
> +						fsl_usb2_platform_data))))
> +				goto unreg_dr;
> +		}
> +		if (usb_dev_dr_client) {
> +			usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL;
> +			usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client->
> +				dev.coherent_dma_mask;
> +			if ((ret = platform_device_add_data(usb_dev_dr_client,
> +						&usb_data, sizeof(struct
> +						fsl_usb2_platform_data))))
> +				goto unreg_dr;
> +		}
> 	}
> 	return 0;
> unreg_dr:
> -	if (usb_dev_dr)
> -		platform_device_unregister(usb_dev_dr);
> +	if (usb_dev_dr_host)
> +		platform_device_unregister(usb_dev_dr_host);
> +	if (usb_dev_dr_client)
> +		platform_device_unregister(usb_dev_dr_client);
> unreg_mph:
> 	if (usb_dev_mph)
> 		platform_device_unregister(usb_dev_mph);

- k

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

* RE: [PATCH 2/3] add soc setup code for USB DR OTG mode
  2007-02-05 15:15 ` Kumar Gala
@ 2007-02-06  3:25   ` Li Yang-r58472
  2007-02-06 13:07   ` Arnd Bergmann
  1 sibling, 0 replies; 5+ messages in thread
From: Li Yang-r58472 @ 2007-02-06  3:25 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, Paul

> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> Sent: Monday, February 05, 2007 11:16 PM
> To: Li Yang-r58472
> Cc: Paul; linuxppc-dev@ozlabs.org
> Subject: Re: [PATCH 2/3] add soc setup code for USB DR OTG mode
>=20
>=20
> On Feb 5, 2007, at 3:10 AM, Li Yang wrote:
>=20
> You have no description about what this patch does and why its needed.
>=20

Add platform_device setup code for OTG/client mode of 834x DR.  It is
needed for USB client driver to work.

> Nack.  See comments inline.
>=20
> > Signed-off-by: Li Yang <leoli@freescale.com>
> > ---
> > arch/powerpc/sysdev/fsl_soc.c |   76 +++++++++++++++++++++++++++++
> > +----------
> > 1 files changed, 57 insertions(+), 19 deletions(-)
> >
> > diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/
> > fsl_soc.c
> > index ad31e56..d9541aa 100644
> > --- a/arch/powerpc/sysdev/fsl_soc.c
> > +++ b/arch/powerpc/sysdev/fsl_soc.c
> > @@ -440,7 +440,8 @@ static int __init fsl_usb_of_init(void)
> > {
> > 	struct device_node *np;
> > 	unsigned int i;
> > -	struct platform_device *usb_dev_mph =3D NULL, *usb_dev_dr =3D =
NULL;
> > +	struct platform_device *usb_dev_mph =3D NULL, *usb_dev_dr_host =3D
NULL,
> > +		*usb_dev_dr_client =3D NULL;
> > 	int ret;
> > 	for (np =3D NULL, i =3D 0;
> > @@ -506,33 +507,70 @@ static int __init fsl_usb_of_init(void)
> > 		of_irq_to_resource(np, 0, &r[1]);
> > -		usb_dev_dr =3D
> > -		    platform_device_register_simple("fsl-ehci", i, r,
2);
> > -		if (IS_ERR(usb_dev_dr)) {
> > -			ret =3D PTR_ERR(usb_dev_dr);
> > -			goto err;
> > -		}
> > -
> > -		usb_dev_dr->dev.coherent_dma_mask =3D 0xffffffffUL;
> > -		usb_dev_dr->dev.dma_mask =3D
&usb_dev_dr->dev.coherent_dma_mask;
> > +		prop =3D get_property(np, "dr_mode", NULL);
> > -		usb_data.operating_mode =3D FSL_USB2_DR_HOST;
> > +		if (prop && !strcmp(prop, "host")) {
> > +			usb_data.operating_mode =3D FSL_USB2_DR_HOST;
> > +			usb_dev_dr_host =3D
platform_device_register_simple(
> > +					"fsl-ehci", i, r, 2);
> > +			if (IS_ERR(usb_dev_dr_host)) {
> > +				ret =3D PTR_ERR(usb_dev_dr_host);
> > +				goto err;
> > +			}
> > +
> > +		} else if (prop && !strcmp(prop, "peripheral")) {
> > +			usb_data.operating_mode =3D FSL_USB2_DR_DEVICE;
> > +			usb_dev_dr_client =3D
platform_device_register_simple(
> > +					"fsl-usb2-udc", i, r, 2);
> > +			if (IS_ERR(usb_dev_dr_client)) {
> > +				ret =3D PTR_ERR(usb_dev_dr_client);
> > +				goto err;
> > +			}
> > +		} else if (!prop || (prop && !strcmp(prop, "otg"))) {
>=20
> Why do we assume if the prop is not defined we are OTG?  This will
> break existing users and is not acceptable.  If the prop doesn't
> exist we have to assume 'host' support to maintain compatibility.

No, it doesn't break existing users.  In otg mode, it supports both host
and client feature.  The specific mode to use can be easily selected by
loading the needed driver.

- Leo

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

* Re: [PATCH 2/3] add soc setup code for USB DR OTG mode
  2007-02-05 15:15 ` Kumar Gala
  2007-02-06  3:25   ` Li Yang-r58472
@ 2007-02-06 13:07   ` Arnd Bergmann
  2007-02-06 14:23     ` Kumar Gala
  1 sibling, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2007-02-06 13:07 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Li Yang, Paul

T24gTW9uZGF5IDA1IEZlYnJ1YXJ5IDIwMDcgMTY6MTUsIEt1bWFyIEdhbGEgd3JvdGU6Cj4gPiAr
oKCgoKCgoKCgoKCgoKCgoKCgoKCgdXNiX2RhdGEub3BlcmF0aW5nX21vZGUgPSBGU0xfVVNCMl9E
Ul9IT1NUOwo+ID4gK6CgoKCgoKCgoKCgoKCgoKCgoKCgoHVzYl9kZXZfZHJfaG9zdCA9IHBsYXRm
b3JtX2RldmljZV9yZWdpc3Rlcl9zaW1wbGUoCj4gPiAroKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCg
oKCgoKCgoKCgoKCgoCJmc2wtZWhjaSIsIGksIHIsIDIpOwo+ID4gK6CgoKCgoKCgoKCgoKCgoKCg
oKCgoGlmIChJU19FUlIodXNiX2Rldl9kcl9ob3N0KSkgewo+ID4gK6CgoKCgoKCgoKCgoKCgoKCg
oKCgoKCgoKCgoKCgcmV0ID0gUFRSX0VSUih1c2JfZGV2X2RyX2hvc3QpOwo+ID4gK6CgoKCgoKCg
oKCgoKCgoKCgoKCgoKCgoKCgoKCgZ290byBlcnI7CgpJIGp1c3Qgc2F3IHRoYXQgdGhpcyBmaWxl
IGhhcyBhIG51bWJlciBvZiBjYWxscyB0byAKcGxhdGZvcm1fZGV2aWNlX3JlZ2lzdGVyX3NpbXBs
ZSgpIGZvciBkZXZpY2VzIHRoYXQgY29tZSBmcm9tIHRoZSBPRgpkZXZpY2UgdHJlZS4KCkNhbiB0
aGlzIGJlIGNvbnZlcnRlZCB0byB1c2Ugb2ZfcmVnaXN0ZXJfcGxhdGZvcm1fZHJpdmVyKCkgYW5k
Cm9mX3BsYXRmb3JtX2RldmljZV9wcm9iZSgpIGluc3RlYWQ/CgoJQXJuZCA8PjwK

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

* Re: [PATCH 2/3] add soc setup code for USB DR OTG mode
  2007-02-06 13:07   ` Arnd Bergmann
@ 2007-02-06 14:23     ` Kumar Gala
  0 siblings, 0 replies; 5+ messages in thread
From: Kumar Gala @ 2007-02-06 14:23 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev, Li Yang, Paul


On Feb 6, 2007, at 7:07 AM, Arnd Bergmann wrote:

> On Monday 05 February 2007 16:15, Kumar Gala wrote:
>>> +                     usb_data.operating_mode = FSL_USB2_DR_HOST;
>>> +                     usb_dev_dr_host =  
>>> platform_device_register_simple(
>>> +                                     "fsl-ehci", i, r, 2);
>>> +                     if (IS_ERR(usb_dev_dr_host)) {
>>> +                             ret = PTR_ERR(usb_dev_dr_host);
>>> +                             goto err;
>
> I just saw that this file has a number of calls to
> platform_device_register_simple() for devices that come from the OF
> device tree.
>
> Can this be converted to use of_register_platform_driver() and
> of_platform_device_probe() instead?

This is an ongoing issue and will help once arch/ppc consumers of  
these drivers go away.  Until then we will continue to use  
platform_devices.

- k

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

end of thread, other threads:[~2007-02-06 14:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-05  9:10 [PATCH 2/3] add soc setup code for USB DR OTG mode Li Yang
2007-02-05 15:15 ` Kumar Gala
2007-02-06  3:25   ` Li Yang-r58472
2007-02-06 13:07   ` Arnd Bergmann
2007-02-06 14:23     ` Kumar Gala

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