diff options
Diffstat (limited to 'drivers/staging/emxx_udc/emxx_udc.c')
-rw-r--r-- | drivers/staging/emxx_udc/emxx_udc.c | 168 |
1 files changed, 82 insertions, 86 deletions
diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 4be646c..fbf82bc 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -115,7 +115,7 @@ static void _nbu2ss_dump_register(struct nbu2ss_udc *udc) pr_info("=== %s()\n", __func__); if (udc == NULL) { - ERR("%s udc == NULL\n", __func__); + pr_err("%s udc == NULL\n", __func__); return; } @@ -201,7 +201,7 @@ static u32 _nbu2ss_get_begin_ram_address(struct nbu2ss_udc *udc) u32 num, buf_type; u32 data, last_ram_adr, use_ram_size; - PT_EP_REGS p_ep_regs; + struct ep_regs *p_ep_regs; last_ram_adr = (D_RAM_SIZE_CTRL / sizeof(u32)) * 2; use_ram_size = 0; @@ -394,7 +394,7 @@ static void _nbu2ss_ep_dma_exit(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) { u32 num; u32 data; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if (udc->vbus_active == 0) return; /* VBUS OFF */ @@ -425,7 +425,7 @@ static void _nbu2ss_ep_dma_exit(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) /* Abort DMA */ static void _nbu2ss_ep_dma_abort(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) { - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; _nbu2ss_bitclr(&preg->EP_DCR[ep->epnum-1].EP_DCR1, DCR1_EPn_REQEN); mdelay(DMA_DISABLE_TIME); /* DCR1_EPn_REQEN Clear */ @@ -443,7 +443,7 @@ static void _nbu2ss_ep_in_end( { u32 data; u32 num; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if (length >= sizeof(u32)) return; @@ -567,7 +567,7 @@ static int EP0_out_PIO(struct nbu2ss_udc *udc, u8 *pBuf, u32 length) u32 i; int nret = 0; u32 iWordLength = 0; - USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf; + union usb_reg_access *pBuf32 = (union usb_reg_access *)pBuf; /*------------------------------------------------------------*/ /* Read Length */ @@ -592,8 +592,8 @@ static int EP0_out_OverBytes(struct nbu2ss_udc *udc, u8 *pBuf, u32 length) { u32 i; u32 iReadSize = 0; - USB_REG_ACCESS Temp32; - USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf; + union usb_reg_access Temp32; + union usb_reg_access *pBuf32 = (union usb_reg_access *)pBuf; if ((0 < length) && (length < sizeof(u32))) { Temp32.dw = _nbu2ss_readl(&udc->p_regs->EP0_READ); @@ -613,7 +613,7 @@ static int EP0_in_PIO(struct nbu2ss_udc *udc, u8 *pBuf, u32 length) u32 iMaxLength = EP0_PACKETSIZE; u32 iWordLength = 0; u32 iWriteLength = 0; - USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf; + union usb_reg_access *pBuf32 = (union usb_reg_access *)pBuf; /*------------------------------------------------------------*/ /* Transfer Length */ @@ -638,8 +638,8 @@ static int EP0_in_PIO(struct nbu2ss_udc *udc, u8 *pBuf, u32 length) static int EP0_in_OverBytes(struct nbu2ss_udc *udc, u8 *pBuf, u32 iRemainSize) { u32 i; - USB_REG_ACCESS Temp32; - USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf; + union usb_reg_access Temp32; + union usb_reg_access *pBuf32 = (union usb_reg_access *)pBuf; if ((0 < iRemainSize) && (iRemainSize < sizeof(u32))) { for (i = 0 ; i < iRemainSize ; i++) @@ -808,7 +808,7 @@ static int _nbu2ss_ep0_out_transfer( return 0; /* Short Packet Transfer End */ if (req->req.actual > req->req.length) { - ERR(" *** Overrun Error\n"); + dev_err(udc->dev, " *** Overrun Error\n"); return -EOVERFLOW; } @@ -840,7 +840,7 @@ static int _nbu2ss_out_dma( u32 burst = 1; u32 data; int result = -EINVAL; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if (req->dma_flag) return 1; /* DMA is forwarded */ @@ -900,10 +900,10 @@ static int _nbu2ss_epn_out_pio( u32 i; u32 data; u32 iWordLength; - USB_REG_ACCESS Temp32; - USB_REG_ACCESS *pBuf32; + union usb_reg_access Temp32; + union usb_reg_access *pBuf32; int result = 0; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if (req->dma_flag) return 1; /* DMA is forwarded */ @@ -912,7 +912,7 @@ static int _nbu2ss_epn_out_pio( return 0; pBuffer = (u8 *)req->req.buf; - pBuf32 = (USB_REG_ACCESS *)(pBuffer + req->req.actual); + pBuf32 = (union usb_reg_access *)(pBuffer + req->req.actual); iWordLength = length / sizeof(u32); if (iWordLength > 0) { @@ -988,7 +988,7 @@ static int _nbu2ss_epn_out_transfer( u32 num; u32 iRecvLength; int result = 1; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if (ep->epnum == 0) return -EINVAL; @@ -1026,8 +1026,8 @@ static int _nbu2ss_epn_out_transfer( } if (req->req.actual > req->req.length) { - ERR(" *** Overrun Error\n"); - ERR(" *** actual = %d, length = %d\n", + dev_err(udc->dev, " Overrun Error\n"); + dev_err(udc->dev, " actual = %d, length = %d\n", req->req.actual, req->req.length); result = -EOVERFLOW; } @@ -1051,7 +1051,7 @@ static int _nbu2ss_in_dma( u32 iWriteLength; u32 data; int result = -EINVAL; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if (req->dma_flag) return 1; /* DMA is forwarded */ @@ -1123,17 +1123,17 @@ static int _nbu2ss_epn_in_pio( u32 i; u32 data; u32 iWordLength; - USB_REG_ACCESS Temp32; - USB_REG_ACCESS *pBuf32 = NULL; + union usb_reg_access Temp32; + union usb_reg_access *pBuf32 = NULL; int result = 0; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if (req->dma_flag) return 1; /* DMA is forwarded */ if (length > 0) { pBuffer = (u8 *)req->req.buf; - pBuf32 = (USB_REG_ACCESS *)(pBuffer + req->req.actual); + pBuf32 = (union usb_reg_access *)(pBuffer + req->req.actual); iWordLength = length / sizeof(u32); if (iWordLength > 0) { @@ -1347,7 +1347,7 @@ static void _nbu2ss_set_endpoint_stall( u8 num, epnum; u32 data; struct nbu2ss_ep *ep; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if ((ep_adrs == 0) || (ep_adrs == 0x80)) { if (bstall) { @@ -1426,7 +1426,7 @@ static void _nbu2ss_set_test_mode(struct nbu2ss_udc *udc, u32 mode) if (mode > MAX_TEST_MODE_NUM) return; - pr_info("SET FEATURE : test mode = %d\n", mode); + dev_info(udc->dev, "SET FEATURE : test mode = %d\n", mode); data = _nbu2ss_readl(&udc->p_regs->USB_CONTROL); data &= ~TEST_FORCE_ENABLE; @@ -1454,7 +1454,7 @@ static int _nbu2ss_set_feature_device( break; case USB_DEVICE_TEST_MODE: - wIndex = wIndex >> 8; + wIndex >>= 8; if (wIndex <= MAX_TEST_MODE_NUM) result = 0; break; @@ -1471,7 +1471,7 @@ static int _nbu2ss_get_ep_stall(struct nbu2ss_udc *udc, u8 ep_adrs) { u8 epnum; u32 data = 0, bit_data; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; epnum = ep_adrs & ~USB_ENDPOINT_DIR_MASK; if (epnum == 0) { @@ -1566,7 +1566,7 @@ static void _nbu2ss_epn_set_stall( u32 regdata; int limit_cnt = 0; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if (ep->direct == USB_DIR_IN) { for (limit_cnt = 0 @@ -1638,7 +1638,7 @@ static int std_req_get_status(struct nbu2ss_udc *udc) _nbu2ss_ep0_in_transfer(udc, &udc->ep[0], &udc->ep0_req); } else { - ERR("*** Error GET_STATUS\n"); + dev_err(udc->dev, " Error GET_STATUS\n"); } return result; @@ -1671,7 +1671,7 @@ static int std_req_set_address(struct nbu2ss_udc *udc) if (wValue != (wValue & 0x007F)) return -EINVAL; - wValue = wValue << USB_ADRS_SHIFT; + wValue <<= USB_ADRS_SHIFT; _nbu2ss_writel(&udc->p_regs->USB_ADDRESS, wValue); _nbu2ss_create_ep0_packet(udc, udc->ep0_buf, 0); @@ -1885,8 +1885,8 @@ static inline void _nbu2ss_ep0_int(struct nbu2ss_udc *udc) | STG_END_INT | EP0_OUT_NULL_INT); if (status == 0) { - pr_info("--- %s Not Decode Interrupt\n", __func__); - pr_info("--- EP0_STATUS = 0x%08x\n", intr); + dev_info(udc->dev, "%s Not Decode Interrupt\n", __func__); + dev_info(udc->dev, "EP0_STATUS = 0x%08x\n", intr); return; } @@ -1994,7 +1994,7 @@ static inline void _nbu2ss_epn_in_int( int result = 0; u32 status; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if (req->dma_flag) return; /* DMA is forwarded */ @@ -2090,7 +2090,7 @@ static inline void _nbu2ss_epn_out_dma_int( u32 num; u32 dmacnt, ep_dmacnt; u32 mpkt; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; num = ep->epnum - 1; @@ -2229,8 +2229,7 @@ static int _nbu2ss_nuke(struct nbu2ss_udc *udc, return 0; /* called with irqs blocked */ - while (!list_empty(&ep->queue)) { - req = list_entry(ep->queue.next, struct nbu2ss_req, queue); + list_for_each_entry(req, &ep->queue, queue) { _nbu2ss_ep_done(ep, req, status); } @@ -2257,11 +2256,6 @@ static int _nbu2ss_pullup(struct nbu2ss_udc *udc, int is_on) { u32 reg_dt; - if (!udc) { - ERR("%s, bad param\n", __func__); - return -EINVAL; - } - if (udc->vbus_active == 0) return -ESHUTDOWN; @@ -2293,7 +2287,7 @@ static int _nbu2ss_pullup(struct nbu2ss_udc *udc, int is_on) /*-------------------------------------------------------------------------*/ static void _nbu2ss_fifo_flush(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) { - PT_FC_REGS p = udc->p_regs; + struct fc_regs *p = udc->p_regs; if (udc->vbus_active == 0) return; @@ -2350,7 +2344,7 @@ static int _nbu2ss_enable_controller(struct nbu2ss_udc *udc) waitcnt++; udelay(1); /* 1us wait */ if (waitcnt == EPC_PLL_LOCK_COUNT) { - ERR("*** Reset Cancel failed\n"); + dev_err(udc->dev, "*** Reset Cancel failed\n"); return -EINVAL; } }; @@ -2412,7 +2406,7 @@ static inline void _nbu2ss_check_vbus(struct nbu2ss_udc *udc) udc->linux_suspended = 0; _nbu2ss_reset_controller(udc); - pr_info(" ----- VBUS OFF\n"); + dev_info(udc->dev, " ----- VBUS OFF\n"); if (udc->vbus_active == 1) { /* VBUS OFF */ @@ -2438,7 +2432,7 @@ static inline void _nbu2ss_check_vbus(struct nbu2ss_udc *udc) if (reg_dt == 0) return; - pr_info(" ----- VBUS ON\n"); + dev_info(udc->dev, " ----- VBUS ON\n"); if (udc->linux_suspended) return; @@ -2536,7 +2530,7 @@ static irqreturn_t _nbu2ss_udc_irq(int irq, void *_udc) u32 epnum, int_bit; struct nbu2ss_udc *udc = (struct nbu2ss_udc *)_udc; - PT_FC_REGS preg = udc->p_regs; + struct fc_regs *preg = udc->p_regs; if (gpio_get_value(VBUS_VALUE) == 0) { _nbu2ss_writel(&preg->USB_INT_STA, ~USB_INT_STA_RW); @@ -2612,13 +2606,13 @@ static int nbu2ss_ep_enable( struct nbu2ss_udc *udc; if ((_ep == NULL) || (desc == NULL)) { - ERR(" *** %s, bad param\n", __func__); + pr_err(" *** %s, bad param\n", __func__); return -EINVAL; } ep = container_of(_ep, struct nbu2ss_ep, ep); if ((ep == NULL) || (ep->udc == NULL)) { - ERR(" *** %s, ep == NULL !!\n", __func__); + pr_err(" *** %s, ep == NULL !!\n", __func__); return -EINVAL; } @@ -2626,7 +2620,7 @@ static int nbu2ss_ep_enable( if ((ep_type == USB_ENDPOINT_XFER_CONTROL) || (ep_type == USB_ENDPOINT_XFER_ISOC)) { - ERR(" *** %s, bat bmAttributes\n", __func__); + pr_err(" *** %s, bat bmAttributes\n", __func__); return -EINVAL; } @@ -2637,7 +2631,7 @@ static int nbu2ss_ep_enable( if ((udc->driver == NULL) || (udc->gadget.speed == USB_SPEED_UNKNOWN)) { - ERR(" *** %s, udc !!\n", __func__); + dev_err(ep->udc->dev, " *** %s, udc !!\n", __func__); return -ESHUTDOWN; } @@ -2672,13 +2666,13 @@ static int nbu2ss_ep_disable(struct usb_ep *_ep) unsigned long flags; if (_ep == NULL) { - ERR(" *** %s, bad param\n", __func__); + pr_err(" *** %s, bad param\n", __func__); return -EINVAL; } ep = container_of(_ep, struct nbu2ss_ep, ep); if ((ep == NULL) || (ep->udc == NULL)) { - ERR(" *** %s, ep == NULL !!\n", __func__); + pr_err("udc: *** %s, ep == NULL !!\n", __func__); return -EINVAL; } @@ -2742,10 +2736,10 @@ static int nbu2ss_ep_queue( /* catch various bogus parameters */ if ((_ep == NULL) || (_req == NULL)) { if (_ep == NULL) - ERR("*** %s --- _ep == NULL\n", __func__); + pr_err("udc: %s --- _ep == NULL\n", __func__); if (_req == NULL) - ERR("*** %s --- _req == NULL\n", __func__); + pr_err("udc: %s --- _req == NULL\n", __func__); return -EINVAL; } @@ -2756,13 +2750,13 @@ static int nbu2ss_ep_queue( || !list_empty(&req->queue))) { if (!_req->complete) - ERR("*** %s --- !_req->complete\n", __func__); + pr_err("udc: %s --- !_req->complete\n", __func__); if (!_req->buf) - ERR("*** %s --- !_req->buf\n", __func__); + pr_err("udc:%s --- !_req->buf\n", __func__); if (!list_empty(&req->queue)) - ERR("*** %s --- !list_empty(&req->queue)\n", __func__); + pr_err("%s --- !list_empty(&req->queue)\n", __func__); return -EINVAL; } @@ -2773,12 +2767,13 @@ static int nbu2ss_ep_queue( /* INFO("=== %s(ep%d), zero=%d\n", __func__, ep->epnum, _req->zero); */ if (udc->vbus_active == 0) { - pr_info("Can't ep_queue (VBUS OFF)\n"); + dev_info(udc->dev, "Can't ep_queue (VBUS OFF)\n"); return -ESHUTDOWN; } if (unlikely(!udc->driver)) { - ERR("%s, bogus device state %p\n", __func__, udc->driver); + dev_err(udc->dev, "%s, bogus device state %p\n", __func__, + udc->driver); return -ESHUTDOWN; } @@ -2794,7 +2789,7 @@ static int nbu2ss_ep_queue( if (ep->virt_buf == NULL) ep->virt_buf = (u8 *)dma_alloc_coherent( NULL, PAGE_SIZE, - &ep->phys_buf, GFP_KERNEL | GFP_DMA); + &ep->phys_buf, GFP_ATOMIC | GFP_DMA); if (ep->epnum > 0) { if (ep->direct == USB_DIR_IN) memcpy(ep->virt_buf, req->req.buf, @@ -2817,7 +2812,8 @@ static int nbu2ss_ep_queue( result = _nbu2ss_start_transfer(udc, ep, req, FALSE); if (result < 0) { - ERR(" *** %s, result = %d\n", __func__, result); + dev_err(udc->dev, " *** %s, result = %d\n", __func__, + result); list_del(&req->queue); } else if ((ep->epnum > 0) && (ep->direct == USB_DIR_OUT)) { #ifdef USE_DMA @@ -2849,13 +2845,13 @@ static int nbu2ss_ep_dequeue( /* catch various bogus parameters */ if ((_ep == NULL) || (_req == NULL)) { - /* ERR("%s, bad param(1)\n", __func__); */ + /* pr_err("%s, bad param(1)\n", __func__); */ return -EINVAL; } ep = container_of(_ep, struct nbu2ss_ep, ep); if (!ep) { - ERR("%s, ep == NULL !!\n", __func__); + pr_err("%s, ep == NULL !!\n", __func__); return -EINVAL; } @@ -2895,19 +2891,19 @@ static int nbu2ss_ep_set_halt(struct usb_ep *_ep, int value) /* INFO("=== %s()\n", __func__); */ if (!_ep) { - ERR("%s, bad param\n", __func__); + pr_err("%s, bad param\n", __func__); return -EINVAL; } ep = container_of(_ep, struct nbu2ss_ep, ep); if (!ep) { - ERR("%s, bad ep\n", __func__); + pr_err("%s, bad ep\n", __func__); return -EINVAL; } udc = ep->udc; if (!udc) { - ERR(" *** %s, bad udc\n", __func__); + dev_err(ep->udc->dev, " *** %s, bad udc\n", __func__); return -EINVAL; } @@ -2944,24 +2940,24 @@ static int nbu2ss_ep_fifo_status(struct usb_ep *_ep) struct nbu2ss_ep *ep; struct nbu2ss_udc *udc; unsigned long flags; - PT_FC_REGS preg; + struct fc_regs *preg; /* INFO("=== %s()\n", __func__); */ if (!_ep) { - ERR("%s, bad param\n", __func__); + pr_err("%s, bad param\n", __func__); return -EINVAL; } ep = container_of(_ep, struct nbu2ss_ep, ep); if (!ep) { - ERR("%s, bad ep\n", __func__); + pr_err("%s, bad ep\n", __func__); return -EINVAL; } udc = ep->udc; if (!udc) { - ERR("%s, bad udc\n", __func__); + dev_err(ep->udc->dev, "%s, bad udc\n", __func__); return -EINVAL; } @@ -2997,19 +2993,19 @@ static void nbu2ss_ep_fifo_flush(struct usb_ep *_ep) /* INFO("=== %s()\n", __func__); */ if (!_ep) { - ERR("%s, bad param\n", __func__); + pr_err("udc: %s, bad param\n", __func__); return; } ep = container_of(_ep, struct nbu2ss_ep, ep); if (!_ep) { - ERR("%s, bad ep\n", __func__); + pr_err("udc: %s, bad ep\n", __func__); return; } udc = ep->udc; if (!udc) { - ERR("%s, bad udc\n", __func__); + dev_err(ep->udc->dev, "%s, bad udc\n", __func__); return; } @@ -3053,13 +3049,13 @@ static int nbu2ss_gad_get_frame(struct usb_gadget *pgadget) /* INFO("=== %s()\n", __func__); */ if (pgadget == NULL) { - ERR("%s, bad param\n", __func__); + pr_err("udc: %s, bad param\n", __func__); return -EINVAL; } udc = container_of(pgadget, struct nbu2ss_udc, gadget); if (udc == NULL) { - ERR("%s, udc == NULL\n", __func__); + dev_err(&pgadget->dev, "%s, udc == NULL\n", __func__); return -EINVAL; } @@ -3083,19 +3079,19 @@ static int nbu2ss_gad_wakeup(struct usb_gadget *pgadget) /* INFO("=== %s()\n", __func__); */ if (pgadget == NULL) { - ERR("%s, bad param\n", __func__); + pr_err("%s, bad param\n", __func__); return -EINVAL; } udc = container_of(pgadget, struct nbu2ss_udc, gadget); if (udc == NULL) { - ERR("%s, udc == NULL\n", __func__); + dev_err(&pgadget->dev, "%s, udc == NULL\n", __func__); return -EINVAL; } data = gpio_get_value(VBUS_VALUE); if (data == 0) { - pr_warn("VBUS LEVEL = %d\n", data); + dev_warn(&pgadget->dev, "VBUS LEVEL = %d\n", data); return -EINVAL; } @@ -3123,7 +3119,7 @@ static int nbu2ss_gad_set_selfpowered(struct usb_gadget *pgadget, /* INFO("=== %s()\n", __func__); */ if (pgadget == NULL) { - ERR("%s, bad param\n", __func__); + pr_err("%s, bad param\n", __func__); return -EINVAL; } @@ -3152,7 +3148,7 @@ static int nbu2ss_gad_vbus_draw(struct usb_gadget *pgadget, unsigned mA) /* INFO("=== %s()\n", __func__); */ if (pgadget == NULL) { - ERR("%s, bad param\n", __func__); + pr_err("%s, bad param\n", __func__); return -EINVAL; } @@ -3174,7 +3170,7 @@ static int nbu2ss_gad_pullup(struct usb_gadget *pgadget, int is_on) /* INFO("=== %s()\n", __func__); */ if (pgadget == NULL) { - ERR("%s, bad param\n", __func__); + pr_err("%s, bad param\n", __func__); return -EINVAL; } @@ -3341,11 +3337,11 @@ static int nbu2ss_drv_probe(struct platform_device *pdev) 0, driver_name, udc); /* IO Memory */ - udc->p_regs = (PT_FC_REGS)mmio_base; + udc->p_regs = (struct fc_regs *)mmio_base; /* USB Function Controller Interrupt */ if (status != 0) { - ERR("request_irq(USB_UDC_IRQ_1) failed\n"); + dev_err(udc->dev, "request_irq(USB_UDC_IRQ_1) failed\n"); goto cleanup1; } @@ -3365,7 +3361,7 @@ static int nbu2ss_drv_probe(struct platform_device *pdev) udc); if (status != 0) { - ERR("request_irq(INT_VBUS) failed\n"); + dev_err(udc->dev, "request_irq(INT_VBUS) failed\n"); goto cleanup1; } |