]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00174242 usb: device: Improve discharge dp operation
authorPeter Chen <peter.chen@freescale.com>
Thu, 9 Feb 2012 09:04:59 +0000 (17:04 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:33:59 +0000 (08:33 +0200)
The discharge dp function needs to be added at below situation:
- USB cable is disconnected from the PC
- When the usb mode switchs to device mode

Signed-off-by: Peter Chen <peter.chen@freescale.com>
drivers/usb/gadget/arcotg_udc.c

index fc49aaa15c441527be86d61629b10bb4cebf3252..1cc50da4c9c2f086d43680b5ed3706385ba53660 100755 (executable)
@@ -102,6 +102,7 @@ static int udc_suspend(struct fsl_udc *udc);
 static int fsl_udc_suspend(struct platform_device *pdev, pm_message_t state);
 static int fsl_udc_resume(struct platform_device *pdev);
 static void fsl_ep_fifo_flush(struct usb_ep *_ep);
+static void gadget_wait_line_to_se0(void);
 
 #ifdef CONFIG_USB_OTG
 /* Get platform resource from OTG driver */
@@ -294,6 +295,23 @@ static void nuke(struct fsl_ep *ep, int status)
 /*------------------------------------------------------------------
        Internal Hardware related function
  ------------------------------------------------------------------*/
+static void dr_discharge_dp(struct fsl_usb2_platform_data *pdata)
+{
+       /* enable pulldown dp */
+       if (pdata->gadget_discharge_dp)
+               pdata->gadget_discharge_dp(true);
+       /*
+        * Some boards are very slow change line state from J to SE0 for DP,
+        * So, we need to discharge DP, otherwise there is a wakeup interrupt
+        * after we enable the wakeup function.
+        */
+       gadget_wait_line_to_se0();
+
+       /* Disable pulldown dp */
+       if (pdata->gadget_discharge_dp)
+               pdata->gadget_discharge_dp(false);
+}
+
 static inline void
 dr_wake_up_enable(struct fsl_udc *udc, bool enable)
 {
@@ -381,6 +399,8 @@ static int dr_controller_setup(struct fsl_udc *udc)
        if (pdata->es)
                tmp |= USB_MODE_ES;
        fsl_writel(tmp, &dr_regs->usbmode);
+       /* wait dp to 0v */
+       dr_discharge_dp(pdata);
 
        fsl_platform_set_device_mode(pdata);
 
@@ -2149,19 +2169,8 @@ static void fsl_gadget_disconnect_event(struct work_struct *work)
 
        pdata = udc->pdata;
 
-       /* enable pulldown dp */
-       if (pdata->gadget_discharge_dp)
-               pdata->gadget_discharge_dp(true);
-       /*
-        * Some boards are very slow change line state from J to SE0 for DP,
-        * So, we need to discharge DP, otherwise there is a wakeup interrupt
-        * after we enable the wakeup function.
-        */
-       gadget_wait_line_to_se0();
-
-       /* Disable pulldown dp */
-       if (pdata->gadget_discharge_dp)
-               pdata->gadget_discharge_dp(false);
+       /* wait dp to 0v */
+       dr_discharge_dp(pdata);
 
        /*
         * Wait class drivers finish, an well-behaviour class driver should