[PATCH v2 10/11] usb: musb: use musb->port_mode

2013-04-05 Thread Daniel Mack
Initialize the host and gagdet subsystems of the musb driver only when
the appropriate mode is selected from platform data, or device-tree
information, respectively.

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/musb_core.c| 22 +-
 drivers/usb/musb/musb_virthub.c |  3 ++-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 2640d25..b3b9873 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1912,11 +1912,23 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb->xceiv->state = OTG_STATE_B_IDLE;
}
 
-   status = musb_host_setup(musb, plat->power);
-   if (status < 0)
-   goto fail3;
-
-   status = musb_gadget_setup(musb);
+   switch (musb->port_mode) {
+   case MUSB_PORT_MODE_HOST:
+   status = musb_host_setup(musb, plat->power);
+   break;
+   case MUSB_PORT_MODE_GADGET:
+   status = musb_gadget_setup(musb);
+   break;
+   case MUSB_PORT_MODE_DUAL_ROLE:
+   status = musb_host_setup(musb, plat->power);
+   if (status < 0)
+   goto fail3;
+   status = musb_gadget_setup(musb);
+   break;
+   default:
+   dev_err(dev, "unsupported port mode %d\n", musb->port_mode);
+   break;
+   }
 
if (status < 0)
goto fail3;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 1e17c20..8d92ba2 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -79,7 +79,8 @@ static void musb_start(struct musb *musb)
 * (b) vbus present/connect IRQ, peripheral mode;
 * (c) peripheral initiates, using SRP
 */
-   if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
+   if (musb->port_mode != MUSB_PORT_MODE_HOST &&
+   (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
musb->is_active = 1;
} else {
devctl |= MUSB_DEVCTL_SESSION;
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 10/11] usb: musb: use musb->port_mode

2013-04-10 Thread Peter Korsgaard
> "Daniel" == Daniel Mack  writes:

 Daniel> Initialize the host and gagdet subsystems of the musb driver only when
 Daniel> the appropriate mode is selected from platform data, or device-tree
 Daniel> information, respectively.

 Daniel> Signed-off-by: Daniel Mack 

Acked-by: Peter Korsgaard 


 Daniel> ---
 Daniel>  drivers/usb/musb/musb_core.c| 22 +-
 Daniel>  drivers/usb/musb/musb_virthub.c |  3 ++-
 Daniel>  2 files changed, 19 insertions(+), 6 deletions(-)

 Daniel> diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel> index 2640d25..b3b9873 100644
 Daniel> --- a/drivers/usb/musb/musb_core.c
 Daniel> +++ b/drivers/usb/musb/musb_core.c
 Daniel> @@ -1912,11 +1912,23 @@ musb_init_controller(struct device *dev, int 
nIrq, void __iomem *ctrl)
 musb-> xceiv->state = OTG_STATE_B_IDLE;
 Daniel>}
 
 Daniel> -  status = musb_host_setup(musb, plat->power);
 Daniel> -  if (status < 0)
 Daniel> -  goto fail3;
 Daniel> -
 Daniel> -  status = musb_gadget_setup(musb);
 Daniel> +  switch (musb->port_mode) {
 Daniel> +  case MUSB_PORT_MODE_HOST:
 Daniel> +  status = musb_host_setup(musb, plat->power);
 Daniel> +  break;
 Daniel> +  case MUSB_PORT_MODE_GADGET:
 Daniel> +  status = musb_gadget_setup(musb);
 Daniel> +  break;
 Daniel> +  case MUSB_PORT_MODE_DUAL_ROLE:
 Daniel> +  status = musb_host_setup(musb, plat->power);
 Daniel> +  if (status < 0)
 Daniel> +  goto fail3;
 Daniel> +  status = musb_gadget_setup(musb);
 Daniel> +  break;
 Daniel> +  default:
 Daniel> +  dev_err(dev, "unsupported port mode %d\n", 
musb->port_mode);
 Daniel> +  break;
 Daniel> +  }
 
 Daniel>if (status < 0)
 Daniel>goto fail3;
 Daniel> diff --git a/drivers/usb/musb/musb_virthub.c 
b/drivers/usb/musb/musb_virthub.c
 Daniel> index 1e17c20..8d92ba2 100644
 Daniel> --- a/drivers/usb/musb/musb_virthub.c
 Daniel> +++ b/drivers/usb/musb/musb_virthub.c
 Daniel> @@ -79,7 +79,8 @@ static void musb_start(struct musb *musb)
 Daniel> * (b) vbus present/connect IRQ, peripheral mode;
 Daniel> * (c) peripheral initiates, using SRP
 Daniel> */
 Daniel> -  if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
 Daniel> +  if (musb->port_mode != MUSB_PORT_MODE_HOST &&
 Daniel> +  (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
 musb-> is_active = 1;
 Daniel>} else {
 Daniel>devctl |= MUSB_DEVCTL_SESSION;
 Daniel> -- 
 Daniel> 1.8.1.4



-- 
Bye, Peter Korsgaard
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html