fix pcd connect and disconnect bug
authoryangkai <yk@rock-chips.com>
Mon, 23 Jul 2012 09:39:01 +0000 (17:39 +0800)
committeryangkai <yk@rock-chips.com>
Mon, 23 Jul 2012 09:39:01 +0000 (17:39 +0800)
drivers/usb/dwc_otg/dwc_otg_driver.c
drivers/usb/dwc_otg/dwc_otg_hcd.c
drivers/usb/dwc_otg/dwc_otg_pcd.c
drivers/usb/dwc_otg/dwc_otg_pcd_intr.c

index 34af78a3a4dd40562c61808a339fd03c5b746307..5efdecdd4705fb3f86aeab2f1813ca2ab2eb5ae9 100755 (executable)
@@ -1498,6 +1498,9 @@ static __devinit int dwc_otg_driver_probe(struct platform_device *pdev)
         dwc_otg_device->core_if->usb_mode = USB_MODE_FORCE_HOST;
 #else 
         dwc_otg_device->core_if->usb_mode = USB_MODE_NORMAL;
+#ifdef CONFIG_DWC_OTG_DEFAULT_DEVICE
+        dwc_otg_device->core_if->usb_mode = USB_MODE_FORCE_DEVICE;
+#endif
 #endif
 
 #endif
@@ -2044,16 +2047,17 @@ static __devinit int host20_driver_probe(struct platform_device *pdev)
         */
 #ifdef CONFIG_ARCH_RK29    
     unsigned int * otg_phy_con1 = (unsigned int*)(USB_GRF_CON);
-#endif
-#ifdef CONFIG_ARCH_RK30
-    unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC1_CON2);
-#endif
-        
     otgreg = * otg_phy_con1;
     otgreg |= (0x01<<13);    // software control
     otgreg |= (0x01<<14);    // exit suspend.
     otgreg &= ~(0x01<<13);    // software control
     *otg_phy_con1 = otgreg;
+#endif
+#ifdef CONFIG_ARCH_RK30
+    unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC1_CON2);
+    *otg_phy_con1 = ((0x01<<2)<<16);    // exit suspend.
+#endif
+        
     #if 0
     *otg_phy_con1 |= (0x01<<2);
     *otg_phy_con1 |= (0x01<<3);    // exit suspend.
index e85ada78ead6c841e295e274f5b6866b2cf8ef07..bef6e0db01d9d8dc8eac6f668e801430c09174e2 100755 (executable)
@@ -1267,6 +1267,7 @@ int __devinit host20_hcd_init(struct device *dev)
        }
     
 #ifdef CONFIG_ARCH_RK30        
+    dwc_otg_hcd->host_setenable = 1;
     dwc_otg_hcd->connect_detect_timer.function = dwc_otg_hcd_connect_detect;
     dwc_otg_hcd->connect_detect_timer.data = (unsigned long)(dwc_otg_hcd);
     init_timer( &dwc_otg_hcd->connect_detect_timer);
index c89715f0e4dce123566d69c63e7f9cf1723e58df..35b8a9e08d679195301618f5957e22b3ee8a8152 100755 (executable)
@@ -1845,7 +1845,7 @@ static void dwc_otg_pcd_check_vbus_timer( unsigned long pdata )
              dwc_otg_msc_unlock(_pcd);
         }
         /* every 500 ms open usb phy power and start 1 jiffies timer to get vbus */
-        if( _pcd->phy_suspend == 0 ) 
+        else if( _pcd->phy_suspend == 0 ) 
                 /* no vbus detect here , close usb phy  */
              dwc_otg20phy_suspend( 0 );
     }
index 991ff028339f3fed9ace44e1c5bc9141fdb463fd..e514b558a7d7be7e14c3ae6021fbc85ae5e35de3 100755 (executable)
@@ -1053,10 +1053,8 @@ static inline void do_gadget_setup( dwc_otg_pcd_t *_pcd,
        {
                SPIN_UNLOCK(&_pcd->lock);
                ret = _pcd->driver->setup(&_pcd->gadget, _ctrl);
-               if(spin_is_locked(&_pcd->lock)){
+               if(spin_is_locked(&_pcd->lock))
                    DWC_PRINT("%s warning: pcd->lock locked without unlock\n", __func__);
-                   SPIN_UNLOCK(&_pcd->lock);
-               }
                SPIN_LOCK(&_pcd->lock);
                if (ret < 0) 
                {