linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] add platform_device for USB DR pheripheral driver
@ 2007-02-06  9:05 Li Yang
  2007-02-06 16:33 ` Kumar Gala
  0 siblings, 1 reply; 4+ messages in thread
From: Li Yang @ 2007-02-06  9:05 UTC (permalink / raw)
  To: Paul; +Cc: linuxppc-dev

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

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

diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index ad31e56..8e4837a 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,72 @@ 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);
+		prop = get_property(np, "dr_mode", NULL);
+
+		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;
+			}
+		} else {
+			ret = -EINVAL;
 			goto err;
 		}
 
-		usb_dev_dr->dev.coherent_dma_mask = 0xffffffffUL;
-		usb_dev_dr->dev.dma_mask = &usb_dev_dr->dev.coherent_dma_mask;
-
-		usb_data.operating_mode = FSL_USB2_DR_HOST;
-
 		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] 4+ messages in thread

* Re: [PATCH 2/3] add platform_device for USB DR pheripheral driver
  2007-02-06  9:05 [PATCH 2/3] add platform_device for USB DR pheripheral driver Li Yang
@ 2007-02-06 16:33 ` Kumar Gala
  0 siblings, 0 replies; 4+ messages in thread
From: Kumar Gala @ 2007-02-06 16:33 UTC (permalink / raw)
  To: Li Yang; +Cc: linuxppc-dev, Paul


On Feb 6, 2007, at 3:05 AM, Li Yang wrote:

> Add platform_device setup code for OTG/peripheral mode of
> 834x DR module.  It is needed for USB client driver to work.
>
> Signed-off-by: Li Yang <leoli@freescale.com>
> ---
> arch/powerpc/sysdev/fsl_soc.c |   76 ++++++++++++++++++++++++++++++ 
> +----------
> 1 files changed, 58 insertions(+), 18 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/ 
> fsl_soc.c
> index ad31e56..8e4837a 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,72 @@ 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);
> +		prop = get_property(np, "dr_mode", NULL);
> +

We should handle the !prop case as equivalent to "host".  The reason  
is that if I accept this patch its going to break people until the  
usb side is also in.  I'd prefer to maintain the exact meaning of  
'dr_mode' not existing as '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;
> +			}
> +		} else {

- k

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

* [PATCH 2/3] add platform_device for USB DR pheripheral driver
@ 2007-02-07  5:49 Li Yang
  2007-02-08  6:47 ` Kumar Gala
  0 siblings, 1 reply; 4+ messages in thread
From: Li Yang @ 2007-02-07  5:49 UTC (permalink / raw)
  To: Paul; +Cc: linuxppc-dev

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

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

diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index ad31e56..357cac3 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,72 @@ 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);
+		prop = get_property(np, "dr_mode", NULL);
+
+		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 && !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;
+			}
+		} else {
+			ret = -EINVAL;
 			goto err;
 		}
 
-		usb_dev_dr->dev.coherent_dma_mask = 0xffffffffUL;
-		usb_dev_dr->dev.dma_mask = &usb_dev_dr->dev.coherent_dma_mask;
-
-		usb_data.operating_mode = FSL_USB2_DR_HOST;
-
 		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] 4+ messages in thread

* Re: [PATCH 2/3] add platform_device for USB DR pheripheral driver
  2007-02-07  5:49 Li Yang
@ 2007-02-08  6:47 ` Kumar Gala
  0 siblings, 0 replies; 4+ messages in thread
From: Kumar Gala @ 2007-02-08  6:47 UTC (permalink / raw)
  To: Li Yang; +Cc: linuxppc-dev, Paul


On Feb 6, 2007, at 11:49 PM, Li Yang wrote:

> Add platform_device setup code for OTG/peripheral mode of
> 834x DR module.  It is needed for USB client driver to work.
>
> Signed-off-by: Li Yang <leoli@freescale.com>
> ---
> arch/powerpc/sysdev/fsl_soc.c |   76 ++++++++++++++++++++++++++++++ 
> +----------
> 1 files changed, 58 insertions(+), 18 deletions(-)

applied.

- k

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

end of thread, other threads:[~2007-02-08  6:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-06  9:05 [PATCH 2/3] add platform_device for USB DR pheripheral driver Li Yang
2007-02-06 16:33 ` Kumar Gala
  -- strict thread matches above, loose matches on Subject: below --
2007-02-07  5:49 Li Yang
2007-02-08  6:47 ` 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).