Lines Matching full:udc
79 struct qe_udc *udc = ep->udc; in done() local
95 dma_unmap_single(udc->gadget.dev.parent, in done()
103 dma_sync_single_for_cpu(udc->gadget.dev.parent, in done()
110 dev_vdbg(udc->dev, "complete %s req %p stat %d len %u/%u\n", in done()
116 spin_unlock(&udc->lock); in done()
120 spin_lock(&udc->lock); in done()
147 struct qe_udc *udc = ep->udc; in qe_eprx_stall_change() local
149 tem_usep = in_be16(&udc->usb_regs->usb_usep[epnum]); in qe_eprx_stall_change()
156 out_be16(&udc->usb_regs->usb_usep[epnum], tem_usep); in qe_eprx_stall_change()
164 struct qe_udc *udc = ep->udc; in qe_eptx_stall_change() local
166 tem_usep = in_be16(&udc->usb_regs->usb_usep[epnum]); in qe_eptx_stall_change()
173 out_be16(&udc->usb_regs->usb_usep[epnum], tem_usep); in qe_eptx_stall_change()
178 static int qe_ep0_stall(struct qe_udc *udc) in qe_ep0_stall() argument
180 qe_eptx_stall_change(&udc->eps[0], 1); in qe_ep0_stall()
181 qe_eprx_stall_change(&udc->eps[0], 1); in qe_ep0_stall()
182 udc->ep0_state = WAIT_FOR_SETUP; in qe_ep0_stall()
183 udc->ep0_dir = 0; in qe_ep0_stall()
190 struct qe_udc *udc = ep->udc; in qe_eprx_nack() local
194 clrsetbits_be16(&udc->usb_regs->usb_usep[epnum], in qe_eprx_nack()
198 clrbits16(&udc->usb_regs->usb_usbmr, in qe_eprx_nack()
208 struct qe_udc *udc = ep->udc; in qe_eprx_normal() local
211 clrsetbits_be16(&udc->usb_regs->usb_usep[ep->epnum], in qe_eprx_normal()
215 out_be16(&udc->usb_regs->usb_usber, in qe_eprx_normal()
217 setbits16(&udc->usb_regs->usb_usbmr, in qe_eprx_normal()
229 if (ep->udc->soc_type == PORT_CPM) in qe_ep_cmd_stoptx()
241 if (ep->udc->soc_type == PORT_CPM) in qe_ep_cmd_restarttx()
253 struct qe_udc *udc = ep->udc; in qe_ep_flushtxfifo() local
259 out_8(&udc->usb_regs->usb_uscom, in qe_ep_flushtxfifo()
261 out_be16(&udc->ep_param[i]->tbptr, in_be16(&udc->ep_param[i]->tbase)); in qe_ep_flushtxfifo()
262 out_be32(&udc->ep_param[i]->tstate, 0); in qe_ep_flushtxfifo()
263 out_be16(&udc->ep_param[i]->tbcnt, 0); in qe_ep_flushtxfifo()
273 struct qe_udc *udc = ep->udc; in qe_ep_filltxfifo() local
275 out_8(&udc->usb_regs->usb_uscom, in qe_ep_filltxfifo()
280 static int qe_epbds_reset(struct qe_udc *udc, int pipe_num) in qe_epbds_reset() argument
287 ep = &udc->eps[pipe_num]; in qe_epbds_reset()
312 static int qe_ep_reset(struct qe_udc *udc, int pipe_num) in qe_ep_reset() argument
317 ep = &udc->eps[pipe_num]; in qe_ep_reset()
318 tmpusep = in_be16(&udc->usb_regs->usb_usep[pipe_num]); in qe_ep_reset()
335 out_be16(&udc->usb_regs->usb_usep[pipe_num], tmpusep); in qe_ep_reset()
337 qe_epbds_reset(udc, pipe_num); in qe_ep_reset()
348 static int qe_ep_bd_init(struct qe_udc *udc, unsigned char pipe_num) in qe_ep_bd_init() argument
350 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_bd_init()
362 epparam = udc->ep_param[pipe_num]; in qe_ep_bd_init()
440 ep->rxbuf_d = dma_map_single(ep->udc->gadget.dev.parent, in qe_ep_rxbd_update()
446 dma_sync_single_for_device(ep->udc->gadget.dev.parent, in qe_ep_rxbd_update()
468 static int qe_ep_register_init(struct qe_udc *udc, unsigned char pipe_num) in qe_ep_register_init() argument
470 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_register_init()
476 epparam = udc->ep_param[pipe_num]; in qe_ep_register_init()
507 out_be16(&udc->usb_regs->usb_usep[pipe_num], usep); in qe_ep_register_init()
521 static int qe_ep_init(struct qe_udc *udc, in qe_ep_init() argument
525 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_init()
541 switch (udc->gadget.speed) { in qe_ep_init()
563 switch (udc->gadget.speed) { in qe_ep_init()
582 switch (udc->gadget.speed) { in qe_ep_init()
599 switch (udc->gadget.speed) { in qe_ep_init()
635 spin_lock_irqsave(&udc->lock, flags); in qe_ep_init()
646 udc->ep0_dir = USB_DIR_OUT; in qe_ep_init()
647 udc->ep0_state = WAIT_FOR_SETUP; in qe_ep_init()
661 qe_ep_bd_init(udc, pipe_num); in qe_ep_init()
675 qe_ep_register_init(udc, pipe_num); in qe_ep_init()
679 spin_unlock_irqrestore(&udc->lock, flags); in qe_ep_init()
686 spin_unlock_irqrestore(&udc->lock, flags); in qe_ep_init()
688 dev_err(udc->dev, "failed to initialize %s\n", ep->ep.name); in qe_ep_init()
692 static inline void qe_usb_enable(struct qe_udc *udc) in qe_usb_enable() argument
694 setbits8(&udc->usb_regs->usb_usmod, USB_MODE_EN); in qe_usb_enable()
697 static inline void qe_usb_disable(struct qe_udc *udc) in qe_usb_disable() argument
699 clrbits8(&udc->usb_regs->usb_usmod, USB_MODE_EN); in qe_usb_disable()
708 UDC transmit and receive process
756 struct qe_udc *udc = ep->udc; in ep_recycle_rxbds() local
761 ((in_be16(&udc->ep_param[epnum]->rbptr) - in ep_recycle_rxbds()
762 in_be16(&udc->ep_param[epnum]->rbase)) in ep_recycle_rxbds()
777 if (in_be16(&udc->usb_regs->usb_usber) & USB_E_BSY_MASK) in ep_recycle_rxbds()
778 out_be16(&udc->usb_regs->usb_usber, USB_E_BSY_MASK); in ep_recycle_rxbds()
786 static void setup_received_handle(struct qe_udc *udc,
789 static void ep0_req_complete(struct qe_udc *udc, struct qe_req *req);
791 static int ep0_setup_handle(struct qe_udc *udc) in ep0_setup_handle() argument
793 struct qe_ep *ep = &udc->eps[0]; in ep0_setup_handle()
800 && (udc->ep0_state == WAIT_FOR_SETUP)) { in ep0_setup_handle()
804 cp = (u8 *)&udc->local_setup_buff; in ep0_setup_handle()
809 setup_received_handle(udc, &udc->local_setup_buff); in ep0_setup_handle()
815 static int qe_ep0_rx(struct qe_udc *udc) in qe_ep0_rx() argument
817 struct qe_ep *ep = &udc->eps[0]; in qe_ep0_rx()
826 dev_err(udc->dev, "ep0 not a control endpoint\n"); in qe_ep0_rx()
838 udc->ep0_state = WAIT_FOR_SETUP; in qe_ep0_rx()
839 dev_vdbg(udc->dev, in qe_ep0_rx()
861 ep0_setup_handle(udc); in qe_ep0_rx()
866 dev_err(udc->dev, "The receive frame with error!\n"); in qe_ep0_rx()
902 dev_err(ep->udc->dev, "the data01 error!\n"); in qe_ep_rxframe_handle()
908 dev_err(ep->udc->dev, "the %s have no requeue!\n", ep->name); in qe_ep_rxframe_handle()
919 ep0_req_complete(ep->udc, req); in qe_ep_rxframe_handle()
935 struct qe_udc *udc = from_tasklet(udc, t, rx_tasklet); in ep_rx_tasklet() local
943 spin_lock_irqsave(&udc->lock, flags); in ep_rx_tasklet()
946 ep = &udc->eps[i]; in ep_rx_tasklet()
949 dev_dbg(udc->dev, in ep_rx_tasklet()
962 dev_dbg(udc->dev, in ep_rx_tasklet()
990 dev_err(udc->dev, in ep_rx_tasklet()
1018 spin_unlock_irqrestore(&udc->lock, flags); in ep_rx_tasklet()
1023 struct qe_udc *udc; in qe_ep_rx() local
1028 udc = ep->udc; in qe_ep_rx()
1032 dev_err(udc->dev, "transmit ep in rx function\n"); in qe_ep_rx()
1039 ucoffs = (u16)((in_be16(&udc->ep_param[ep->epnum]->rbptr) - in qe_ep_rx()
1040 in_be16(&udc->ep_param[ep->epnum]->rbase)) >> 3); in qe_ep_rx()
1049 dev_vdbg(udc->dev, "%d empty bds, send NACK\n", emptybds); in qe_ep_rx()
1055 dev_vdbg(udc->dev, "The rxep have no req queued with %d BDs\n", in qe_ep_rx()
1060 tasklet_schedule(&udc->rx_tasklet); in qe_ep_rx()
1069 struct qe_udc *udc = ep->udc; in qe_ep_tx() local
1076 dev_err(udc->dev, "receive ep passed to tx function\n"); in qe_ep_tx()
1081 saveusbmr = in_be16(&udc->usb_regs->usb_usbmr); in qe_ep_tx()
1082 out_be16(&udc->usb_regs->usb_usbmr, in qe_ep_tx()
1090 frame_set_data(frame, udc->nullbuf); in qe_ep_tx()
1093 dev_vdbg(udc->dev, "the frame size = 0\n"); in qe_ep_tx()
1105 if ((ep->epnum == 0) && (udc->ep0_state == DATA_STATE_NEED_ZLP)) in qe_ep_tx()
1121 out_be16(&udc->usb_regs->usb_usbmr, saveusbmr); in qe_ep_tx()
1131 out_be16(&udc->usb_regs->usb_usbmr, saveusbmr); in qe_ep_tx()
1132 dev_vdbg(udc->dev, "The tx bd is not ready!\n"); in qe_ep_tx()
1213 struct qe_udc *udc = ep->udc; in sendnulldata() local
1219 frame_set_data(frame, (u8 *)udc->nullbuf); in sendnulldata()
1245 * in status phase, udc create a request and gain status */
1246 static int ep0_prime_status(struct qe_udc *udc, int direction) in ep0_prime_status() argument
1249 struct qe_ep *ep = &udc->eps[0]; in ep0_prime_status()
1252 udc->ep0_state = DATA_STATE_NEED_ZLP; in ep0_prime_status()
1253 udc->ep0_dir = USB_DIR_IN; in ep0_prime_status()
1256 udc->ep0_dir = USB_DIR_OUT; in ep0_prime_status()
1257 udc->ep0_state = WAIT_FOR_OUT_STATUS; in ep0_prime_status()
1263 /* a request complete in ep0, whether gadget request or udc request */
1264 static void ep0_req_complete(struct qe_udc *udc, struct qe_req *req) in ep0_req_complete() argument
1266 struct qe_ep *ep = &udc->eps[0]; in ep0_req_complete()
1269 switch (udc->ep0_state) { in ep0_req_complete()
1273 if (ep0_prime_status(udc, USB_DIR_OUT)) in ep0_req_complete()
1274 qe_ep0_stall(udc); in ep0_req_complete()
1279 udc->ep0_state = WAIT_FOR_SETUP; in ep0_req_complete()
1285 if (ep0_prime_status(udc, USB_DIR_IN)) in ep0_req_complete()
1286 qe_ep0_stall(udc); in ep0_req_complete()
1291 udc->ep0_state = WAIT_FOR_SETUP; in ep0_req_complete()
1295 dev_vdbg(udc->dev, "Unexpected interrupt\n"); in ep0_req_complete()
1299 qe_ep0_stall(udc); in ep0_req_complete()
1311 ep->udc->ep0_state = WAIT_FOR_SETUP; in ep0_txcomplete()
1330 ep0_req_complete(ep->udc, ep->tx_req); in ep0_txcomplete()
1336 dev_vdbg(ep->udc->dev, "the ep0_controller have no req\n"); in ep0_txcomplete()
1347 dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); in ep0_txframe_handle()
1402 dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); in ep_txframe_handle()
1472 struct qe_udc *udc = ep->udc; in ep_req_rx() local
1482 dev_vdbg(udc->dev, "the req already finish!\n"); in ep_req_rx()
1515 dev_vdbg(udc->dev, "the data01 error!\n"); in ep_req_rx()
1535 dev_err(udc->dev, "The receive frame with error!\n"); in ep_req_rx()
1585 struct qe_udc *udc; in qe_ep_enable() local
1597 udc = ep->udc; in qe_ep_enable()
1598 if (!udc->driver || (udc->gadget.speed == USB_SPEED_UNKNOWN)) in qe_ep_enable()
1603 retval = qe_ep_init(udc, epnum, desc); in qe_ep_enable()
1606 dev_dbg(udc->dev, "enable ep%d failed\n", ep->epnum); in qe_ep_enable()
1609 dev_dbg(udc->dev, "enable ep%d successful\n", ep->epnum); in qe_ep_enable()
1615 struct qe_udc *udc; in qe_ep_disable() local
1621 udc = ep->udc; in qe_ep_disable()
1624 dev_dbg(udc->dev, "%s not enabled\n", _ep ? ep->ep.name : NULL); in qe_ep_disable()
1628 spin_lock_irqsave(&udc->lock, flags); in qe_ep_disable()
1634 qe_ep_reset(udc, ep->epnum); in qe_ep_disable()
1635 spin_unlock_irqrestore(&udc->lock, flags); in qe_ep_disable()
1649 dma_unmap_single(udc->gadget.dev.parent, in qe_ep_disable()
1655 udc->gadget.dev.parent, in qe_ep_disable()
1665 dev_dbg(udc->dev, "disabled %s OK\n", _ep->name); in qe_ep_disable()
1698 struct qe_udc *udc; in __qe_ep_queue() local
1701 udc = ep->udc; in __qe_ep_queue()
1705 dev_dbg(udc->dev, "bad params\n"); in __qe_ep_queue()
1709 dev_dbg(udc->dev, "bad ep\n"); in __qe_ep_queue()
1713 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) in __qe_ep_queue()
1720 req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, in __qe_ep_queue()
1728 dma_sync_single_for_device(ep->udc->gadget.dev.parent, in __qe_ep_queue()
1740 dev_vdbg(udc->dev, "gadget have request in %s! %d\n", in __qe_ep_queue()
1750 udc->ep0_state = DATA_STATE_XMIT; in __qe_ep_queue()
1752 udc->ep0_state = DATA_STATE_RECV; in __qe_ep_queue()
1766 struct qe_udc *udc = ep->udc; in qe_ep_queue() local
1770 spin_lock_irqsave(&udc->lock, flags); in qe_ep_queue()
1772 spin_unlock_irqrestore(&udc->lock, flags); in qe_ep_queue()
1787 spin_lock_irqsave(&ep->udc->lock, flags); in qe_ep_dequeue()
1798 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_dequeue()
1804 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_dequeue()
1819 struct qe_udc *udc; in qe_ep_set_halt() local
1827 udc = ep->udc; in qe_ep_set_halt()
1836 spin_lock_irqsave(&ep->udc->lock, flags); in qe_ep_set_halt()
1839 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_set_halt()
1842 udc->ep0_state = WAIT_FOR_SETUP; in qe_ep_set_halt()
1843 udc->ep0_dir = 0; in qe_ep_set_halt()
1850 dev_vdbg(udc->dev, "%s %s halt stat %d\n", ep->ep.name, in qe_ep_set_halt()
1876 struct qe_udc *udc = container_of(gadget, struct qe_udc, gadget); in qe_get_frame() local
1879 tmp = in_be16(&udc->usb_param->frame_n); in qe_get_frame()
1899 static int udc_reset_ep_queue(struct qe_udc *udc, u8 pipe) in udc_reset_ep_queue() argument
1901 struct qe_ep *ep = &udc->eps[pipe]; in udc_reset_ep_queue()
1908 static int reset_queues(struct qe_udc *udc) in reset_queues() argument
1913 udc_reset_ep_queue(udc, pipe); in reset_queues()
1916 spin_unlock(&udc->lock); in reset_queues()
1917 usb_gadget_udc_reset(&udc->gadget, udc->driver); in reset_queues()
1918 spin_lock(&udc->lock); in reset_queues()
1923 static void ch9setaddress(struct qe_udc *udc, u16 value, u16 index, in ch9setaddress() argument
1927 udc->device_address = (u8) value; in ch9setaddress()
1929 udc->usb_state = USB_STATE_ADDRESS; in ch9setaddress()
1932 if (ep0_prime_status(udc, USB_DIR_IN)) in ch9setaddress()
1933 qe_ep0_stall(udc); in ch9setaddress()
1944 static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, in ch9getstatus() argument
1952 ep = &udc->eps[0]; in ch9getstatus()
1958 /* We don't have interface information in udc driver */ in ch9getstatus()
1965 struct qe_ep *target_ep = &udc->eps[pipe]; in ch9getstatus()
1972 usep = in_be16(&udc->usb_regs->usb_usep[pipe]); in ch9getstatus()
1989 req->req.buf = udc->statusbuf; in ch9getstatus()
1995 udc->ep0_dir = USB_DIR_IN; in ch9getstatus()
2003 dev_err(udc->dev, "Can't respond to getstatus request \n"); in ch9getstatus()
2004 qe_ep0_stall(udc); in ch9getstatus()
2008 static void setup_received_handle(struct qe_udc *udc, in setup_received_handle() argument
2011 /* Fix Endian (udc->local_setup_buff is cpu Endian now)*/ in setup_received_handle()
2017 udc_reset_ep_queue(udc, 0); in setup_received_handle()
2020 udc->ep0_dir = USB_DIR_IN; in setup_received_handle()
2022 udc->ep0_dir = USB_DIR_OUT; in setup_received_handle()
2026 /* Data+Status phase form udc */ in setup_received_handle()
2030 ch9getstatus(udc, setup->bRequestType, wValue, wIndex, in setup_received_handle()
2035 /* Status phase from udc */ in setup_received_handle()
2039 ch9setaddress(udc, wValue, wIndex, wLength); in setup_received_handle()
2044 /* Requests with no data phase, status phase from udc */ in setup_received_handle()
2057 ep = &udc->eps[pipe]; in setup_received_handle()
2059 spin_unlock(&udc->lock); in setup_received_handle()
2063 spin_lock(&udc->lock); in setup_received_handle()
2066 ep0_prime_status(udc, USB_DIR_IN); in setup_received_handle()
2075 /* Data phase from gadget, status phase from udc */ in setup_received_handle()
2077 udc->ep0_state = DATA_STATE_XMIT; in setup_received_handle()
2078 udc->ep0_dir = USB_DIR_IN; in setup_received_handle()
2080 udc->ep0_state = DATA_STATE_RECV; in setup_received_handle()
2081 udc->ep0_dir = USB_DIR_OUT; in setup_received_handle()
2083 spin_unlock(&udc->lock); in setup_received_handle()
2084 if (udc->driver->setup(&udc->gadget, in setup_received_handle()
2085 &udc->local_setup_buff) < 0) in setup_received_handle()
2086 qe_ep0_stall(udc); in setup_received_handle()
2087 spin_lock(&udc->lock); in setup_received_handle()
2090 udc->ep0_dir = USB_DIR_IN; in setup_received_handle()
2091 spin_unlock(&udc->lock); in setup_received_handle()
2092 if (udc->driver->setup(&udc->gadget, in setup_received_handle()
2093 &udc->local_setup_buff) < 0) in setup_received_handle()
2094 qe_ep0_stall(udc); in setup_received_handle()
2095 spin_lock(&udc->lock); in setup_received_handle()
2096 udc->ep0_state = DATA_STATE_NEED_ZLP; in setup_received_handle()
2103 static void suspend_irq(struct qe_udc *udc) in suspend_irq() argument
2105 udc->resume_state = udc->usb_state; in suspend_irq()
2106 udc->usb_state = USB_STATE_SUSPENDED; in suspend_irq()
2109 if (udc->driver->suspend) in suspend_irq()
2110 udc->driver->suspend(&udc->gadget); in suspend_irq()
2113 static void resume_irq(struct qe_udc *udc) in resume_irq() argument
2115 udc->usb_state = udc->resume_state; in resume_irq()
2116 udc->resume_state = 0; in resume_irq()
2119 if (udc->driver->resume) in resume_irq()
2120 udc->driver->resume(&udc->gadget); in resume_irq()
2123 static void idle_irq(struct qe_udc *udc) in idle_irq() argument
2127 usbs = in_8(&udc->usb_regs->usb_usbs); in idle_irq()
2129 if ((udc->usb_state) != USB_STATE_SUSPENDED) in idle_irq()
2130 suspend_irq(udc); in idle_irq()
2132 if (udc->usb_state == USB_STATE_SUSPENDED) in idle_irq()
2133 resume_irq(udc); in idle_irq()
2137 static int reset_irq(struct qe_udc *udc) in reset_irq() argument
2141 if (udc->usb_state == USB_STATE_DEFAULT) in reset_irq()
2144 qe_usb_disable(udc); in reset_irq()
2145 out_8(&udc->usb_regs->usb_usadr, 0); in reset_irq()
2148 if (udc->eps[i].init) in reset_irq()
2149 qe_ep_reset(udc, i); in reset_irq()
2152 reset_queues(udc); in reset_irq()
2153 udc->usb_state = USB_STATE_DEFAULT; in reset_irq()
2154 udc->ep0_state = WAIT_FOR_SETUP; in reset_irq()
2155 udc->ep0_dir = USB_DIR_OUT; in reset_irq()
2156 qe_usb_enable(udc); in reset_irq()
2160 static int bsy_irq(struct qe_udc *udc) in bsy_irq() argument
2165 static int txe_irq(struct qe_udc *udc) in txe_irq() argument
2171 static int tx_irq(struct qe_udc *udc) in tx_irq() argument
2177 if ((udc->usb_state == USB_STATE_ADDRESS) in tx_irq()
2178 && (in_8(&udc->usb_regs->usb_usadr) == 0)) in tx_irq()
2179 out_8(&udc->usb_regs->usb_usadr, udc->device_address); in tx_irq()
2182 ep = &udc->eps[i]; in tx_irq()
2200 static void rx_irq(struct qe_udc *udc) in rx_irq() argument
2207 ep = &udc->eps[i]; in rx_irq()
2213 qe_ep0_rx(udc); in rx_irq()
2225 struct qe_udc *udc = (struct qe_udc *)_udc; in qe_udc_irq() local
2230 spin_lock_irqsave(&udc->lock, flags); in qe_udc_irq()
2232 irq_src = in_be16(&udc->usb_regs->usb_usber) & in qe_udc_irq()
2233 in_be16(&udc->usb_regs->usb_usbmr); in qe_udc_irq()
2235 out_be16(&udc->usb_regs->usb_usber, irq_src); in qe_udc_irq()
2238 idle_irq(udc); in qe_udc_irq()
2244 tx_irq(udc); in qe_udc_irq()
2250 rx_irq(udc); in qe_udc_irq()
2256 reset_irq(udc); in qe_udc_irq()
2262 bsy_irq(udc); in qe_udc_irq()
2268 txe_irq(udc); in qe_udc_irq()
2273 spin_unlock_irqrestore(&udc->lock, flags); in qe_udc_irq()
2284 struct qe_udc *udc; in fsl_qe_start() local
2287 udc = container_of(gadget, struct qe_udc, gadget); in fsl_qe_start()
2289 spin_lock_irqsave(&udc->lock, flags); in fsl_qe_start()
2292 udc->driver = driver; in fsl_qe_start()
2293 udc->gadget.speed = driver->max_speed; in fsl_qe_start()
2296 qe_usb_enable(udc); in fsl_qe_start()
2298 out_be16(&udc->usb_regs->usb_usber, 0xffff); in fsl_qe_start()
2299 out_be16(&udc->usb_regs->usb_usbmr, USB_E_DEFAULT_DEVICE); in fsl_qe_start()
2300 udc->usb_state = USB_STATE_ATTACHED; in fsl_qe_start()
2301 udc->ep0_state = WAIT_FOR_SETUP; in fsl_qe_start()
2302 udc->ep0_dir = USB_DIR_OUT; in fsl_qe_start()
2303 spin_unlock_irqrestore(&udc->lock, flags); in fsl_qe_start()
2310 struct qe_udc *udc; in fsl_qe_stop() local
2314 udc = container_of(gadget, struct qe_udc, gadget); in fsl_qe_stop()
2316 qe_usb_disable(udc); in fsl_qe_stop()
2319 udc->usb_state = USB_STATE_ATTACHED; in fsl_qe_stop()
2320 udc->ep0_state = WAIT_FOR_SETUP; in fsl_qe_stop()
2321 udc->ep0_dir = 0; in fsl_qe_stop()
2324 spin_lock_irqsave(&udc->lock, flags); in fsl_qe_stop()
2325 udc->gadget.speed = USB_SPEED_UNKNOWN; in fsl_qe_stop()
2326 nuke(&udc->eps[0], -ESHUTDOWN); in fsl_qe_stop()
2327 list_for_each_entry(loop_ep, &udc->gadget.ep_list, ep.ep_list) in fsl_qe_stop()
2329 spin_unlock_irqrestore(&udc->lock, flags); in fsl_qe_stop()
2331 udc->driver = NULL; in fsl_qe_stop()
2336 /* udc structure's alloc and setup, include ep-param alloc */
2339 struct qe_udc *udc; in qe_udc_config() local
2347 udc = kzalloc(sizeof(*udc), GFP_KERNEL); in qe_udc_config()
2348 if (!udc) in qe_udc_config()
2351 udc->dev = &ofdev->dev; in qe_udc_config()
2355 udc->usb_param = cpm_muram_addr(offset); in qe_udc_config()
2356 memset_io(udc->usb_param, 0, size); in qe_udc_config()
2358 usbpram = udc->usb_param; in qe_udc_config()
2370 udc->ep_param[i] = cpm_muram_addr(tmp_addr); in qe_udc_config()
2374 memset_io(udc->ep_param[0], 0, in qe_udc_config()
2377 udc->resume_state = USB_STATE_NOTATTACHED; in qe_udc_config()
2378 udc->usb_state = USB_STATE_POWERED; in qe_udc_config()
2379 udc->ep0_dir = 0; in qe_udc_config()
2381 spin_lock_init(&udc->lock); in qe_udc_config()
2382 return udc; in qe_udc_config()
2385 kfree(udc); in qe_udc_config()
2390 static int qe_udc_reg_init(struct qe_udc *udc) in qe_udc_reg_init() argument
2393 qe_usbregs = udc->usb_regs; in qe_udc_reg_init()
2408 static int qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) in qe_ep_config() argument
2410 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_config()
2412 ep->udc = udc; in qe_ep_config()
2447 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in qe_ep_config()
2449 ep->gadget = &udc->gadget; in qe_ep_config()
2455 * UDC device Driver operation functions *
2459 struct qe_udc *udc = container_of(dev, struct qe_udc, gadget.dev); in qe_udc_release() local
2462 complete(udc->done); in qe_udc_release()
2463 cpm_muram_free(cpm_muram_offset(udc->ep_param[0])); in qe_udc_release()
2465 udc->ep_param[i] = NULL; in qe_udc_release()
2467 kfree(udc); in qe_udc_release()
2474 struct qe_udc *udc; in qe_udc_probe() local
2485 /* Initialize the udc structure including QH member and other member */ in qe_udc_probe()
2486 udc = qe_udc_config(ofdev); in qe_udc_probe()
2487 if (!udc) { in qe_udc_probe()
2492 udc->soc_type = (unsigned long)device_get_match_data(&ofdev->dev); in qe_udc_probe()
2493 udc->usb_regs = of_iomap(np, 0); in qe_udc_probe()
2494 if (!udc->usb_regs) { in qe_udc_probe()
2501 qe_udc_reg_init(udc); in qe_udc_probe()
2505 udc->gadget.ops = &qe_gadget_ops; in qe_udc_probe()
2508 udc->gadget.ep0 = &udc->eps[0].ep; in qe_udc_probe()
2510 INIT_LIST_HEAD(&udc->gadget.ep_list); in qe_udc_probe()
2513 udc->gadget.speed = USB_SPEED_UNKNOWN; in qe_udc_probe()
2516 udc->gadget.name = driver_name; in qe_udc_probe()
2517 udc->gadget.dev.parent = &ofdev->dev; in qe_udc_probe()
2526 qe_ep_config(udc, (unsigned char)i); in qe_udc_probe()
2530 ret = qe_ep_init(udc, 0, &qe_ep0_desc); in qe_udc_probe()
2535 udc->nullbuf = devm_kzalloc(&ofdev->dev, 256, GFP_KERNEL); in qe_udc_probe()
2536 if (udc->nullbuf == NULL) { in qe_udc_probe()
2542 udc->statusbuf = devm_kzalloc(&ofdev->dev, 2, GFP_KERNEL); in qe_udc_probe()
2543 if (udc->statusbuf == NULL) { in qe_udc_probe()
2548 udc->nullp = virt_to_phys((void *)udc->nullbuf); in qe_udc_probe()
2549 if (udc->nullp == DMA_ADDR_INVALID) { in qe_udc_probe()
2550 udc->nullp = dma_map_single( in qe_udc_probe()
2551 udc->gadget.dev.parent, in qe_udc_probe()
2552 udc->nullbuf, in qe_udc_probe()
2555 udc->nullmap = 1; in qe_udc_probe()
2557 dma_sync_single_for_device(udc->gadget.dev.parent, in qe_udc_probe()
2558 udc->nullp, 256, in qe_udc_probe()
2562 tasklet_setup(&udc->rx_tasklet, ep_rx_tasklet); in qe_udc_probe()
2564 udc->usb_irq = irq_of_parse_and_map(np, 0); in qe_udc_probe()
2565 if (!udc->usb_irq) { in qe_udc_probe()
2570 ret = request_irq(udc->usb_irq, qe_udc_irq, 0, in qe_udc_probe()
2571 driver_name, udc); in qe_udc_probe()
2573 dev_err(udc->dev, "cannot request irq %d err %d\n", in qe_udc_probe()
2574 udc->usb_irq, ret); in qe_udc_probe()
2578 ret = usb_add_gadget_udc_release(&ofdev->dev, &udc->gadget, in qe_udc_probe()
2583 platform_set_drvdata(ofdev, udc); in qe_udc_probe()
2584 dev_info(udc->dev, in qe_udc_probe()
2586 (udc->soc_type == PORT_QE) ? "QE" : "CPM"); in qe_udc_probe()
2590 free_irq(udc->usb_irq, udc); in qe_udc_probe()
2592 irq_dispose_mapping(udc->usb_irq); in qe_udc_probe()
2594 if (udc->nullmap) { in qe_udc_probe()
2595 dma_unmap_single(udc->gadget.dev.parent, in qe_udc_probe()
2596 udc->nullp, 256, in qe_udc_probe()
2598 udc->nullp = DMA_ADDR_INVALID; in qe_udc_probe()
2600 dma_sync_single_for_cpu(udc->gadget.dev.parent, in qe_udc_probe()
2601 udc->nullp, 256, in qe_udc_probe()
2605 ep = &udc->eps[0]; in qe_udc_probe()
2611 iounmap(udc->usb_regs); in qe_udc_probe()
2613 kfree(udc); in qe_udc_probe()
2631 struct qe_udc *udc = platform_get_drvdata(ofdev); in qe_udc_remove() local
2636 usb_del_gadget_udc(&udc->gadget); in qe_udc_remove()
2638 udc->done = &done; in qe_udc_remove()
2639 tasklet_disable(&udc->rx_tasklet); in qe_udc_remove()
2641 if (udc->nullmap) { in qe_udc_remove()
2642 dma_unmap_single(udc->gadget.dev.parent, in qe_udc_remove()
2643 udc->nullp, 256, in qe_udc_remove()
2645 udc->nullp = DMA_ADDR_INVALID; in qe_udc_remove()
2647 dma_sync_single_for_cpu(udc->gadget.dev.parent, in qe_udc_remove()
2648 udc->nullp, 256, in qe_udc_remove()
2652 ep = &udc->eps[0]; in qe_udc_remove()
2658 dma_unmap_single(udc->gadget.dev.parent, in qe_udc_remove()
2663 dma_sync_single_for_cpu(udc->gadget.dev.parent, in qe_udc_remove()
2671 free_irq(udc->usb_irq, udc); in qe_udc_remove()
2672 irq_dispose_mapping(udc->usb_irq); in qe_udc_remove()
2674 tasklet_kill(&udc->rx_tasklet); in qe_udc_remove()
2676 iounmap(udc->usb_regs); in qe_udc_remove()
2678 /* wait for release() of gadget.dev to free udc */ in qe_udc_remove()