detect usb id
authoryangkai <yk@rock-chips.com>
Wed, 25 Apr 2012 03:49:56 +0000 (11:49 +0800)
committeryangkai <yk@rock-chips.com>
Wed, 25 Apr 2012 03:49:56 +0000 (11:49 +0800)
drivers/usb/dwc_otg/dwc_otg_cil.c
drivers/usb/dwc_otg/dwc_otg_cil_intr.c
drivers/usb/dwc_otg/dwc_otg_pcd.c
drivers/usb/dwc_otg/dwc_otg_pcd_intr.c

index 36c52a8ea9ce4fbf7225d55a1e7e32c790e6279a..7a95aaeb0d1b3115a5f4098529c5e059e32f59fa 100755 (executable)
@@ -3068,28 +3068,28 @@ void dwc_otg_dump_dev_registers(dwc_otg_core_if_t *_core_if)
            if(hwcfg1 & (2<<(i<<1))){
                DWC_PRINT("Device IN EP %d Registers\n", i);
                addr=&_core_if->dev_if->in_ep_regs[i]->diepctl;
-               DWC_PRINT("DIEPCTL5      @0x%08X : 0x%08X\n",(uint32_t)addr,dwc_read_reg32(addr));
+               DWC_PRINT("DIEPCTL%d     @0x%08X : 0x%08X\n", i, (uint32_t)addr,dwc_read_reg32(addr));
                addr=&_core_if->dev_if->in_ep_regs[i]->diepint;
-               DWC_PRINT("DIEPINT5      @0x%08X : 0x%08X\n",(uint32_t)addr,dwc_read_reg32(addr));
+               DWC_PRINT("DIEPINT%d     @0x%08X : 0x%08X\n", i, (uint32_t)addr,dwc_read_reg32(addr));
                addr=&_core_if->dev_if->in_ep_regs[i]->dieptsiz;
-               DWC_PRINT("DIETSIZ5      @0x%08X : 0x%08X\n",(uint32_t)addr,dwc_read_reg32(addr));
+               DWC_PRINT("DIETSIZ%d     @0x%08X : 0x%08X\n", i, (uint32_t)addr,dwc_read_reg32(addr));
                addr=&_core_if->dev_if->in_ep_regs[i]->diepdma;
-               DWC_PRINT("DIEPDMA5      @0x%08X : 0x%08X\n",(uint32_t)addr,dwc_read_reg32(addr));
+               DWC_PRINT("DIEPDMA%d     @0x%08X : 0x%08X\n", i, (uint32_t)addr,dwc_read_reg32(addr));
                addr=&_core_if->dev_if->in_ep_regs[i]->dtxfsts;
-               DWC_PRINT("DTXFSTS5      @0x%08X : 0x%08X\n",(uint32_t)addr,dwc_read_reg32(addr));
+               DWC_PRINT("DTXFSTS%d     @0x%08X : 0x%08X\n", i, (uint32_t)addr,dwc_read_reg32(addr));
            }
            if(hwcfg1 & (1<<(i<<1))){
                DWC_PRINT("Device OUT EP %d Registers\n", i);
                addr=&_core_if->dev_if->out_ep_regs[i]->doepctl;
-               DWC_PRINT("DOEPCTL6      @0x%08X : 0x%08X\n",(uint32_t)addr,dwc_read_reg32(addr));
+               DWC_PRINT("DOEPCTL%d     @0x%08X : 0x%08X\n", i, (uint32_t)addr,dwc_read_reg32(addr));
                addr=&_core_if->dev_if->out_ep_regs[i]->doepfn;
-               DWC_PRINT("DOEPFN6       @0x%08X : 0x%08X\n",(uint32_t)addr,dwc_read_reg32(addr));
+               DWC_PRINT("DOEPFN%d      @0x%08X : 0x%08X\n", i, (uint32_t)addr,dwc_read_reg32(addr));
                addr=&_core_if->dev_if->out_ep_regs[i]->doepint;
-               DWC_PRINT("DOEPINT6      @0x%08X : 0x%08X\n",(uint32_t)addr,dwc_read_reg32(addr));
+               DWC_PRINT("DOEPINT%d     @0x%08X : 0x%08X\n", i, (uint32_t)addr,dwc_read_reg32(addr));
                addr=&_core_if->dev_if->out_ep_regs[i]->doeptsiz;
-               DWC_PRINT("DOETSIZ6      @0x%08X : 0x%08X\n",(uint32_t)addr,dwc_read_reg32(addr));
+               DWC_PRINT("DOETSIZ%d     @0x%08X : 0x%08X\n", i, (uint32_t)addr,dwc_read_reg32(addr));
                addr=&_core_if->dev_if->out_ep_regs[i]->doepdma;
-               DWC_PRINT("DOEPDMA6      @0x%08X : 0x%08X\n",(uint32_t)addr,dwc_read_reg32(addr));
+               DWC_PRINT("DOEPDMA%d     @0x%08X : 0x%08X\n", i, (uint32_t)addr,dwc_read_reg32(addr));
            }
        }
 
index a4a07b42b27ab296b33a4128c6dbc8c97f2da374..9558706e89e17fb48b7705a15d28676686ede3ac 100755 (executable)
@@ -362,7 +362,7 @@ int32_t dwc_otg_handle_conn_id_status_change_intr(dwc_otg_core_if_t *_core_if)
        * ×¢Òâ,Èç¹ûhostÉ豸Èç¹û¿ìËٰβ壬»áµ±³ÉUSB_IDΪµÍµÄ³äµçÆ÷´¦Àí
     */
     gotgctl.d32 = dwc_read_reg32( &_core_if->core_global_regs->gotgctl );
-       #if 1
+       #if 0
     if((!gotgctl.b.conidsts)&&( gotgctl.b.bsesvld ))
     {
        if(pcd &&(pcd->vbus_status == 0))
index 8ea6354e68ed885797d71ddde9d057b5320d7784..e46b36934f6b999e966fa2bd68e568a9dd8205f3 100755 (executable)
@@ -106,10 +106,10 @@ void request_done(dwc_otg_pcd_ep_t *_ep, dwc_otg_pcd_request_t *_req,
                                  int _status)
 {
        unsigned stopped = _ep->stopped;
-
+    
        DWC_DEBUGPL(DBG_PCDV, "%s(%p)\n", __func__, _ep);
        list_del_init(&_req->queue);
-             
+
        if (_req->req.status == -EINPROGRESS) 
        {
                _req->req.status = _status;
@@ -119,6 +119,7 @@ void request_done(dwc_otg_pcd_ep_t *_ep, dwc_otg_pcd_request_t *_req,
                _status = _req->req.status;
        }
 #if 1
+    if (_req->req.dma != DMA_ADDR_INVALID){
        if (_req->mapped) {
                dma_unmap_single(_ep->pcd->gadget.dev.parent,
                        _req->req.dma, _req->req.length,
@@ -133,6 +134,7 @@ void request_done(dwc_otg_pcd_ep_t *_ep, dwc_otg_pcd_request_t *_req,
                        _ep->dwc_ep.is_in
                                ? DMA_TO_DEVICE
                                : DMA_FROM_DEVICE);
+       }
 #endif
        /* don't modify queue heads during completion callback */
        _ep->stopped = 1;
@@ -578,9 +580,11 @@ static int dwc_otg_pcd_ep_queue(struct usb_ep *_ep,
        }
        
        ep = container_of(_ep, dwc_otg_pcd_ep_t, ep);
+       SPIN_LOCK_IRQSAVE(&ep->pcd->lock, flags);
        if (!_ep || (!ep->desc && ep->dwc_ep.num != 0)) 
        {
                DWC_WARN("%s, bad ep\n", __func__);
+                               SPIN_UNLOCK_IRQRESTORE(&ep->pcd->lock, flags);
                return -EINVAL;
        }
        pcd = ep->pcd;
@@ -588,6 +592,7 @@ static int dwc_otg_pcd_ep_queue(struct usb_ep *_ep,
        {
                DWC_DEBUGPL(DBG_PCDV, "gadget.speed=%d\n", pcd->gadget.speed);
                DWC_WARN("%s, bogus device state\n", __func__);
+                               SPIN_UNLOCK_IRQRESTORE(&pcd->lock, flags);
                return -ESHUTDOWN;
        }
 
@@ -604,7 +609,6 @@ static int dwc_otg_pcd_ep_queue(struct usb_ep *_ep,
                }
        }
 
-       SPIN_LOCK_IRQSAVE(&ep->pcd->lock, flags);
 
 #if defined(DEBUG) & defined(VERBOSE)
        dump_msg(_req->buf, _req->length);
@@ -1622,7 +1626,7 @@ int dwc_otg20phy_suspend( int exitsuspend )
     }
     if( !exitsuspend && (pcd->phy_suspend == 0)) {
         pcd->phy_suspend = 1;
-        *otg_phy_con1 |= (0x01<<2);
+        *otg_phy_con1 |= ((0x01<<2)|(0x05<<6));
         *otg_phy_con1 &= ~(0x01<<3);    // enter suspend.
         udelay(3);
         clk_disable(pcd->otg_dev->phyclk);
@@ -1815,7 +1819,12 @@ static void dwc_otg_pcd_check_vbus_timer( unsigned long pdata )
     unsigned int usbgrf_status = *(unsigned int*)(USBGRF_SOC_STATUS0);
 #endif
     _pcd->check_vbus_timer.expires = jiffies + (HZ); /* 1 s */
-       if(usbgrf_status &0x20000){  // bvalid
+    if((usbgrf_status &(1<<20)) == 0){  // id low
+    
+        if( _pcd->phy_suspend) 
+             dwc_otg20phy_suspend( 1 );
+    }
+       else if(usbgrf_status &0x20000){  // bvalid
         /* if usb not connect before ,then start connect */
          if( _pcd->vbus_status == 0 ) {
             DWC_PRINT("********vbus detect*********************************************\n");
index 85bd8491128110056f94f702214faff189032fc6..60cf52d1e21e9ab81d5bc7d09e84bac5b74a43a1 100755 (executable)
@@ -181,10 +181,7 @@ void start_next_request( dwc_otg_pcd_ep_t *_ep )
                _ep->dwc_ep.dma_addr = req->req.dma;
                _ep->dwc_ep.sent_zlp = 0;
                _ep->dwc_ep.total_len = _ep->dwc_ep.xfer_len;
-                       
-               //DWC_ERROR(" -> starting transfer (start_next_req) %s %s\n",
-               //_ep->ep.name, _ep->dwc_ep.is_in?"IN":"OUT");
-                       
+       
                dwc_otg_ep_start_transfer( GET_CORE_IF(_ep->pcd), &_ep->dwc_ep );
        }
 }
@@ -1779,7 +1776,7 @@ static void complete_ep( dwc_otg_pcd_ep_t *_ep )
                        }
                        request_done(_ep, req, 0);
         } else {
-//            DWC_PRINT("\n++++++FIND NULL req,ep=%s++++++++++\n" , _ep->ep.name );
+            DWC_PRINT("\n++++++FIND NULL req,ep=%s++++++++++\n" , _ep->ep.name );
             _ep->pcd->request_pending = 0;
         }
                _ep->dwc_ep.start_xfer_buff = 0;