Merge remote-tracking branch 'origin/develop-3.0-rk2928' into develop-3.0
[firefly-linux-kernel-4.4.55.git] / drivers / usb / dwc_otg / dwc_otg_pcd.c
index 5b962bf8657e3bde8b74d13134060e32b7ce7303..f2f62ef70cc8b69681c39df0886b7bf8b25f34e5 100755 (executable)
@@ -1047,6 +1047,7 @@ static int dwc_otg_pcd_pullup(struct usb_gadget *_gadget, int is_on)
         dctl.d32 = dwc_read_reg32( &core_if->dev_if->dev_global_regs->dctl );
         dctl.b.sftdiscon = 1;
         dwc_write_reg32( &core_if->dev_if->dev_global_regs->dctl, dctl.d32 );
+        pcd->conn_status = 3;
     }
     return 0;
 }
@@ -1352,7 +1353,11 @@ void dwc_otg_pcd_reinit(dwc_otg_pcd_t *_pcd)
                        "ep2in",        
                        "ep3in",        
                        "ep4in",        
+#ifdef CONFIG_ARCH_RK29
+                       "ep5in-int",    
+#else
                        "ep5in",        
+#endif
                        "ep6in",        
                        "ep7in",        
                        "ep8in",        
@@ -1678,6 +1683,7 @@ int dwc_otg20phy_suspend( int exitsuspend )
     if( !exitsuspend && (pcd->phy_suspend == 0)) {
         pcd->phy_suspend = 1;
         *otg_phy_con1 = 0x55 |(0x7f<<16);   // enter suspend.
+      //  *otg_phy_con1 = 0x1D5 |(0x1ff<<16);   // enter suspend.   enable dm,dp  debug_wlf @2012.8.10
         udelay(3);
         clk_disable(pcd->otg_dev->phyclk);
         clk_disable(pcd->otg_dev->ahbclk);
@@ -1845,12 +1851,12 @@ static void dwc_otg_pcd_check_vbus_timer( unsigned long pdata )
         /* if usb not connect before ,then start connect */
          if( _pcd->vbus_status == 0 ) {
             DWC_PRINT("********vbus detect*********************************************\n");
-            dwc_otg_msc_lock(_pcd);
            _pcd->vbus_status = 1;
             if(_pcd->conn_en)
                 goto connect;
             else
-                dwc_otg20phy_suspend( 0 );
+                // not connect, suspend phy
+                dwc_otg20phy_suspend(0);
         } 
         else if((_pcd->conn_en)&&(_pcd->conn_status>=0)&&(_pcd->conn_status <3)){
             DWC_PRINT("********soft reconnect******************************************\n");
@@ -1862,16 +1868,18 @@ static void dwc_otg_pcd_check_vbus_timer( unsigned long pdata )
             _pcd->conn_status++;
             if((dwc_read_reg32((uint32_t*)((uint8_t *)_pcd->otg_dev->base + DWC_OTG_HOST_PORT_REGS_OFFSET))&0xc00) == 0xc00)
                 _pcd->vbus_status = 2;
+                
+            // not connect, suspend phy
+            dwc_otg20phy_suspend(0);
         }
        }else {
         _pcd->vbus_status = 0;
-        if(_pcd->conn_status)
-        {
+        if(_pcd->conn_status){
              _pcd->conn_status = 0;
              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 );
     }
@@ -1880,6 +1888,8 @@ static void dwc_otg_pcd_check_vbus_timer( unsigned long pdata )
     return;
 
 connect:
+    if(_pcd->conn_status==0)
+        dwc_otg_msc_lock(_pcd);
     if( _pcd->phy_suspend  == 1 )
          dwc_otg20phy_suspend( 1 );
     schedule_delayed_work( &_pcd->reconnect , 8 ); /* delay 1 jiffies */