public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH]: fsl usb gadget driver pullup fix
@ 2009-07-24 20:00 Stefani Seibold
  2009-07-25 19:44 ` Guennadi Liakhovetski
  0 siblings, 1 reply; 3+ messages in thread
From: Stefani Seibold @ 2009-07-24 20:00 UTC (permalink / raw)
  To: linux-kernel, leoli, tanya.jiang

Attached is a small fix for the fsl usb gadget driver. This fix the
driver in a way that the usb device will be only "pulled up" on request,
like other usb gadget drivers do. 

This is necessary, because the device information is not always
available until an application is up and running which provides this
datas.

Hope you like it.

 fsl_udc_core.c |   41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)
Signed-off-by: Stefani Seibold <stefani@seibold.net>

--- linux-2.6.31-rc4.orig/drivers/usb/gadget/fsl_udc_core.c	2009-07-24
20:35:29.000000000 +0200
+++ linux-2.6.31-rc4/drivers/usb/gadget/fsl_udc_core.c	2009-07-24
21:44:10.000000000 +0200
@@ -171,6 +171,21 @@
 	}
 }
 
+static int can_pullup(struct fsl_udc *udc)
+{
+	return udc->driver && udc->softconnect && udc->vbus_active;
+}
+
+static void set_pullup(struct fsl_udc *udc)
+{
+	if (can_pullup(udc))
+		fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),
+				&dr_regs->usbcmd);
+	else
+		fsl_writel((fsl_readl(&dr_regs->usbcmd) & ~USB_CMD_RUN_STOP),
+				&dr_regs->usbcmd);
+}
+
 /*------------------------------------------------------------------
 	Internal Hardware related function
  ------------------------------------------------------------------*/
@@ -283,10 +298,7 @@
 	temp |= USB_MODE_CTRL_MODE_DEVICE;
 	fsl_writel(temp, &dr_regs->usbmode);
 
-	/* Set controller to Run */
-	temp = fsl_readl(&dr_regs->usbcmd);
-	temp |= USB_CMD_RUN_STOP;
-	fsl_writel(temp, &dr_regs->usbcmd);
+	set_pullup(udc);
 
 	return;
 }
@@ -1059,11 +1071,6 @@
 	return 0;
 }
 
-static int can_pullup(struct fsl_udc *udc)
-{
-	return udc->driver && udc->softconnect && udc->vbus_active;
-}
-
 /* Notify controller that VBUS is powered, Called by whatever
    detects VBUS sessions */
 static int fsl_vbus_session(struct usb_gadget *gadget, int is_active)
@@ -1075,12 +1082,7 @@
 	spin_lock_irqsave(&udc->lock, flags);
 	VDBG("VBUS %s", is_active ? "on" : "off");
 	udc->vbus_active = (is_active != 0);
-	if (can_pullup(udc))
-		fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),
-				&dr_regs->usbcmd);
-	else
-		fsl_writel((fsl_readl(&dr_regs->usbcmd) & ~USB_CMD_RUN_STOP),
-				&dr_regs->usbcmd);
+	set_pullup(udc);
 	spin_unlock_irqrestore(&udc->lock, flags);
 	return 0;
 }
@@ -1111,12 +1113,7 @@
 
 	udc = container_of(gadget, struct fsl_udc, gadget);
 	udc->softconnect = (is_on != 0);
-	if (can_pullup(udc))
-		fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),
-				&dr_regs->usbcmd);
-	else
-		fsl_writel((fsl_readl(&dr_regs->usbcmd) & ~USB_CMD_RUN_STOP),
-				&dr_regs->usbcmd);
+	set_pullup(udc);
 
 	return 0;
 }
@@ -2194,6 +2191,8 @@
 
 	udc->resume_state = USB_STATE_NOTATTACHED;
 	udc->usb_state = USB_STATE_POWERED;
+	udc->vbus_active = 1;
+	udc->softconnect = 1;
 	udc->ep0_dir = 0;
 	udc->remote_wakeup = 0;	/* default to 0 on reset */
 



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

* Re: [PATCH]: fsl usb gadget driver pullup fix
  2009-07-24 20:00 [PATCH]: fsl usb gadget driver pullup fix Stefani Seibold
@ 2009-07-25 19:44 ` Guennadi Liakhovetski
  2009-07-25 20:12   ` Stefani Seibold
  0 siblings, 1 reply; 3+ messages in thread
From: Guennadi Liakhovetski @ 2009-07-25 19:44 UTC (permalink / raw)
  To: Stefani Seibold; +Cc: linux-kernel, leoli, tanya.jiang

Hi Stefani

On Fri, 24 Jul 2009, Stefani Seibold wrote:

> Attached is a small fix for the fsl usb gadget driver. This fix the
> driver in a way that the usb device will be only "pulled up" on request,
> like other usb gadget drivers do. 
> 
> This is necessary, because the device information is not always
> available until an application is up and running which provides this
> datas.

I can confirm (as well as some others), that there indeed is a problem 
with the fsl_usb2_udc driver pullup control. If this patch fixes it - 
great! I cannot verify its correctness by just looking at it, but I might 
be able to test it on an i.MX31. On which hardware did you test it?

Thanks
Guennadi

> 
> Hope you like it.
> 
>  fsl_udc_core.c |   41 ++++++++++++++++++++---------------------
>  1 file changed, 20 insertions(+), 21 deletions(-)
> Signed-off-by: Stefani Seibold <stefani@seibold.net>
> 
> --- linux-2.6.31-rc4.orig/drivers/usb/gadget/fsl_udc_core.c	2009-07-24
> 20:35:29.000000000 +0200
> +++ linux-2.6.31-rc4/drivers/usb/gadget/fsl_udc_core.c	2009-07-24
> 21:44:10.000000000 +0200
> @@ -171,6 +171,21 @@
>  	}
>  }
>  
> +static int can_pullup(struct fsl_udc *udc)
> +{
> +	return udc->driver && udc->softconnect && udc->vbus_active;
> +}
> +
> +static void set_pullup(struct fsl_udc *udc)
> +{
> +	if (can_pullup(udc))
> +		fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),
> +				&dr_regs->usbcmd);
> +	else
> +		fsl_writel((fsl_readl(&dr_regs->usbcmd) & ~USB_CMD_RUN_STOP),
> +				&dr_regs->usbcmd);
> +}
> +
>  /*------------------------------------------------------------------
>  	Internal Hardware related function
>   ------------------------------------------------------------------*/
> @@ -283,10 +298,7 @@
>  	temp |= USB_MODE_CTRL_MODE_DEVICE;
>  	fsl_writel(temp, &dr_regs->usbmode);
>  
> -	/* Set controller to Run */
> -	temp = fsl_readl(&dr_regs->usbcmd);
> -	temp |= USB_CMD_RUN_STOP;
> -	fsl_writel(temp, &dr_regs->usbcmd);
> +	set_pullup(udc);
>  
>  	return;
>  }
> @@ -1059,11 +1071,6 @@
>  	return 0;
>  }
>  
> -static int can_pullup(struct fsl_udc *udc)
> -{
> -	return udc->driver && udc->softconnect && udc->vbus_active;
> -}
> -
>  /* Notify controller that VBUS is powered, Called by whatever
>     detects VBUS sessions */
>  static int fsl_vbus_session(struct usb_gadget *gadget, int is_active)
> @@ -1075,12 +1082,7 @@
>  	spin_lock_irqsave(&udc->lock, flags);
>  	VDBG("VBUS %s", is_active ? "on" : "off");
>  	udc->vbus_active = (is_active != 0);
> -	if (can_pullup(udc))
> -		fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),
> -				&dr_regs->usbcmd);
> -	else
> -		fsl_writel((fsl_readl(&dr_regs->usbcmd) & ~USB_CMD_RUN_STOP),
> -				&dr_regs->usbcmd);
> +	set_pullup(udc);
>  	spin_unlock_irqrestore(&udc->lock, flags);
>  	return 0;
>  }
> @@ -1111,12 +1113,7 @@
>  
>  	udc = container_of(gadget, struct fsl_udc, gadget);
>  	udc->softconnect = (is_on != 0);
> -	if (can_pullup(udc))
> -		fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),
> -				&dr_regs->usbcmd);
> -	else
> -		fsl_writel((fsl_readl(&dr_regs->usbcmd) & ~USB_CMD_RUN_STOP),
> -				&dr_regs->usbcmd);
> +	set_pullup(udc);
>  
>  	return 0;
>  }
> @@ -2194,6 +2191,8 @@
>  
>  	udc->resume_state = USB_STATE_NOTATTACHED;
>  	udc->usb_state = USB_STATE_POWERED;
> +	udc->vbus_active = 1;
> +	udc->softconnect = 1;
>  	udc->ep0_dir = 0;
>  	udc->remote_wakeup = 0;	/* default to 0 on reset */
>  
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* Re: [PATCH]: fsl usb gadget driver pullup fix
  2009-07-25 19:44 ` Guennadi Liakhovetski
@ 2009-07-25 20:12   ` Stefani Seibold
  0 siblings, 0 replies; 3+ messages in thread
From: Stefani Seibold @ 2009-07-25 20:12 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: linux-kernel, leoli, tanya.jiang

Hi Guennadi,

 
Am Samstag, den 25.07.2009, 21:44 +0200 schrieb Guennadi Liakhovetski:
> Hi Stefani
> 
> On Fri, 24 Jul 2009, Stefani Seibold wrote:
> 
> > Attached is a small fix for the fsl usb gadget driver. This fix the
> > driver in a way that the usb device will be only "pulled up" on request,
> > like other usb gadget drivers do. 
> > 
> > This is necessary, because the device information is not always
> > available until an application is up and running which provides this
> > datas.
> 
> I can confirm (as well as some others), that there indeed is a problem 
> with the fsl_usb2_udc driver pullup control. If this patch fixes it - 
> great! I cannot verify its correctness by just looking at it, but I might 
> be able to test it on an i.MX31. On which hardware did you test it?
> 

i used it on a self designed mpc834x system, with is build in signal
generators from rohde & schwarz, namely the smb100a, smc100a and
smbv100a.

Regards,
Stefani



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

end of thread, other threads:[~2009-07-25 20:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-24 20:00 [PATCH]: fsl usb gadget driver pullup fix Stefani Seibold
2009-07-25 19:44 ` Guennadi Liakhovetski
2009-07-25 20:12   ` Stefani Seibold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox