From cb756892ab2fa33de9a658b31c7c6d31f3d8d673 Mon Sep 17 00:00:00 2001 From: yangkai Date: Wed, 25 Apr 2012 11:49:56 +0800 Subject: [PATCH] detect usb id --- drivers/usb/dwc_otg/dwc_otg_cil.c | 20 ++++++++++---------- drivers/usb/dwc_otg/dwc_otg_cil_intr.c | 2 +- drivers/usb/dwc_otg/dwc_otg_pcd.c | 19 ++++++++++++++----- drivers/usb/dwc_otg/dwc_otg_pcd_intr.c | 7 ++----- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/drivers/usb/dwc_otg/dwc_otg_cil.c b/drivers/usb/dwc_otg/dwc_otg_cil.c index 36c52a8ea9ce..7a95aaeb0d1b 100755 --- a/drivers/usb/dwc_otg/dwc_otg_cil.c +++ b/drivers/usb/dwc_otg/dwc_otg_cil.c @@ -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)); } } diff --git a/drivers/usb/dwc_otg/dwc_otg_cil_intr.c b/drivers/usb/dwc_otg/dwc_otg_cil_intr.c index a4a07b42b27a..9558706e89e1 100755 --- a/drivers/usb/dwc_otg/dwc_otg_cil_intr.c +++ b/drivers/usb/dwc_otg/dwc_otg_cil_intr.c @@ -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)) diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd.c b/drivers/usb/dwc_otg/dwc_otg_pcd.c index 8ea6354e68ed..e46b36934f6b 100755 --- a/drivers/usb/dwc_otg/dwc_otg_pcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_pcd.c @@ -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"); diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c b/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c index 85bd84911281..60cf52d1e21e 100755 --- a/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c +++ b/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c @@ -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; -- 2.34.1