Lines Matching refs:udc

85 	struct qe_udc *udc = ep->udc;  in done()  local
101 dma_unmap_single(udc->gadget.dev.parent, in done()
109 dma_sync_single_for_cpu(udc->gadget.dev.parent, in done()
116 dev_vdbg(udc->dev, "complete %s req %p stat %d len %u/%u\n", in done()
122 spin_unlock(&udc->lock); in done()
129 spin_lock(&udc->lock); in done()
156 struct qe_udc *udc = ep->udc; in qe_eprx_stall_change() local
158 tem_usep = in_be16(&udc->usb_regs->usb_usep[epnum]); in qe_eprx_stall_change()
165 out_be16(&udc->usb_regs->usb_usep[epnum], tem_usep); in qe_eprx_stall_change()
173 struct qe_udc *udc = ep->udc; in qe_eptx_stall_change() local
175 tem_usep = in_be16(&udc->usb_regs->usb_usep[epnum]); in qe_eptx_stall_change()
182 out_be16(&udc->usb_regs->usb_usep[epnum], tem_usep); in qe_eptx_stall_change()
187 static int qe_ep0_stall(struct qe_udc *udc) in qe_ep0_stall() argument
189 qe_eptx_stall_change(&udc->eps[0], 1); in qe_ep0_stall()
190 qe_eprx_stall_change(&udc->eps[0], 1); in qe_ep0_stall()
199 struct qe_udc *udc = ep->udc; in qe_eprx_nack() local
203 clrsetbits_be16(&udc->usb_regs->usb_usep[epnum], in qe_eprx_nack()
207 clrbits16(&udc->usb_regs->usb_usbmr, in qe_eprx_nack()
217 struct qe_udc *udc = ep->udc; in qe_eprx_normal() local
220 clrsetbits_be16(&udc->usb_regs->usb_usep[ep->epnum], in qe_eprx_normal()
224 out_be16(&udc->usb_regs->usb_usber, in qe_eprx_normal()
226 setbits16(&udc->usb_regs->usb_usbmr, in qe_eprx_normal()
238 if (ep->udc->soc_type == PORT_CPM) in qe_ep_cmd_stoptx()
250 if (ep->udc->soc_type == PORT_CPM) in qe_ep_cmd_restarttx()
262 struct qe_udc *udc = ep->udc; in qe_ep_flushtxfifo() local
268 out_8(&udc->usb_regs->usb_uscom, in qe_ep_flushtxfifo()
270 out_be16(&udc->ep_param[i]->tbptr, in_be16(&udc->ep_param[i]->tbase)); in qe_ep_flushtxfifo()
271 out_be32(&udc->ep_param[i]->tstate, 0); in qe_ep_flushtxfifo()
272 out_be16(&udc->ep_param[i]->tbcnt, 0); in qe_ep_flushtxfifo()
282 struct qe_udc *udc = ep->udc; in qe_ep_filltxfifo() local
284 out_8(&udc->usb_regs->usb_uscom, in qe_ep_filltxfifo()
289 static int qe_epbds_reset(struct qe_udc *udc, int pipe_num) in qe_epbds_reset() argument
296 ep = &udc->eps[pipe_num]; in qe_epbds_reset()
321 static int qe_ep_reset(struct qe_udc *udc, int pipe_num) in qe_ep_reset() argument
326 ep = &udc->eps[pipe_num]; in qe_ep_reset()
327 tmpusep = in_be16(&udc->usb_regs->usb_usep[pipe_num]); in qe_ep_reset()
344 out_be16(&udc->usb_regs->usb_usep[pipe_num], tmpusep); in qe_ep_reset()
346 qe_epbds_reset(udc, pipe_num); in qe_ep_reset()
357 static int qe_ep_bd_init(struct qe_udc *udc, unsigned char pipe_num) in qe_ep_bd_init() argument
359 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_bd_init()
371 epparam = udc->ep_param[pipe_num]; in qe_ep_bd_init()
431 dev_err(ep->udc->dev, "malloc rxframe failed\n"); in qe_ep_rxbd_update()
445 dev_err(ep->udc->dev, "malloc rxbuffer failed,size=%d\n", in qe_ep_rxbd_update()
481 static int qe_ep_register_init(struct qe_udc *udc, unsigned char pipe_num) in qe_ep_register_init() argument
483 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_register_init()
489 epparam = udc->ep_param[pipe_num]; in qe_ep_register_init()
520 out_be16(&udc->usb_regs->usb_usep[pipe_num], usep); in qe_ep_register_init()
534 static int qe_ep_init(struct qe_udc *udc, in qe_ep_init() argument
538 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_init()
554 switch (udc->gadget.speed) { in qe_ep_init()
575 switch (udc->gadget.speed) { in qe_ep_init()
592 switch (udc->gadget.speed) { in qe_ep_init()
607 switch (udc->gadget.speed) { in qe_ep_init()
642 spin_lock_irqsave(&udc->lock, flags); in qe_ep_init()
653 udc->ep0_dir = USB_DIR_OUT; in qe_ep_init()
654 udc->ep0_state = WAIT_FOR_SETUP; in qe_ep_init()
668 qe_ep_bd_init(udc, pipe_num); in qe_ep_init()
678 dev_err(udc->dev, "malloc txframe failed\n"); in qe_ep_init()
684 qe_ep_register_init(udc, pipe_num); in qe_ep_init()
688 spin_unlock_irqrestore(&udc->lock, flags); in qe_ep_init()
695 spin_unlock_irqrestore(&udc->lock, flags); in qe_ep_init()
697 dev_err(udc->dev, "failed to initialize %s\n", ep->ep.name); in qe_ep_init()
765 struct qe_udc *udc = ep->udc; in ep_recycle_rxbds() local
770 ((in_be16(&udc->ep_param[epnum]->rbptr) - in ep_recycle_rxbds()
771 in_be16(&udc->ep_param[epnum]->rbase)) in ep_recycle_rxbds()
786 if (in_be16(&udc->usb_regs->usb_usber) & USB_E_BSY_MASK) in ep_recycle_rxbds()
787 out_be16(&udc->usb_regs->usb_usber, USB_E_BSY_MASK); in ep_recycle_rxbds()
795 static void setup_received_handle(struct qe_udc *udc,
798 static void ep0_req_complete(struct qe_udc *udc, struct qe_req *req);
800 static int ep0_setup_handle(struct qe_udc *udc) in ep0_setup_handle() argument
802 struct qe_ep *ep = &udc->eps[0]; in ep0_setup_handle()
809 && (udc->ep0_state == WAIT_FOR_SETUP)) { in ep0_setup_handle()
813 cp = (u8 *)&udc->local_setup_buff; in ep0_setup_handle()
818 setup_received_handle(udc, &udc->local_setup_buff); in ep0_setup_handle()
824 static int qe_ep0_rx(struct qe_udc *udc) in qe_ep0_rx() argument
826 struct qe_ep *ep = &udc->eps[0]; in qe_ep0_rx()
835 dev_err(udc->dev, "ep0 not a control endpoint\n"); in qe_ep0_rx()
847 udc->ep0_state = WAIT_FOR_SETUP; in qe_ep0_rx()
848 dev_vdbg(udc->dev, in qe_ep0_rx()
870 ep0_setup_handle(udc); in qe_ep0_rx()
875 dev_err(udc->dev, "The receive frame with error!\n"); in qe_ep0_rx()
911 dev_err(ep->udc->dev, "the data01 error!\n"); in qe_ep_rxframe_handle()
917 dev_err(ep->udc->dev, "the %s have no requeue!\n", ep->name); in qe_ep_rxframe_handle()
928 ep0_req_complete(ep->udc, req); in qe_ep_rxframe_handle()
944 struct qe_udc *udc = (struct qe_udc *)data; in ep_rx_tasklet() local
952 spin_lock_irqsave(&udc->lock, flags); in ep_rx_tasklet()
955 ep = &udc->eps[i]; in ep_rx_tasklet()
958 dev_dbg(udc->dev, in ep_rx_tasklet()
971 dev_dbg(udc->dev, in ep_rx_tasklet()
999 dev_err(udc->dev, in ep_rx_tasklet()
1027 spin_unlock_irqrestore(&udc->lock, flags); in ep_rx_tasklet()
1032 struct qe_udc *udc; in qe_ep_rx() local
1037 udc = ep->udc; in qe_ep_rx()
1041 dev_err(udc->dev, "transmit ep in rx function\n"); in qe_ep_rx()
1048 ucoffs = (u16)((in_be16(&udc->ep_param[ep->epnum]->rbptr) - in qe_ep_rx()
1049 in_be16(&udc->ep_param[ep->epnum]->rbase)) >> 3); in qe_ep_rx()
1058 dev_vdbg(udc->dev, "%d empty bds, send NACK\n", emptybds); in qe_ep_rx()
1064 dev_vdbg(udc->dev, "The rxep have no req queued with %d BDs\n", in qe_ep_rx()
1069 tasklet_schedule(&udc->rx_tasklet); in qe_ep_rx()
1078 struct qe_udc *udc = ep->udc; in qe_ep_tx() local
1085 dev_err(udc->dev, "receive ep passed to tx function\n"); in qe_ep_tx()
1090 saveusbmr = in_be16(&udc->usb_regs->usb_usbmr); in qe_ep_tx()
1091 out_be16(&udc->usb_regs->usb_usbmr, in qe_ep_tx()
1099 frame_set_data(frame, udc->nullbuf); in qe_ep_tx()
1102 dev_vdbg(udc->dev, "the frame size = 0\n"); in qe_ep_tx()
1114 if ((ep->epnum == 0) && (udc->ep0_state == DATA_STATE_NEED_ZLP)) in qe_ep_tx()
1130 out_be16(&udc->usb_regs->usb_usbmr, saveusbmr); in qe_ep_tx()
1140 out_be16(&udc->usb_regs->usb_usbmr, saveusbmr); in qe_ep_tx()
1141 dev_vdbg(udc->dev, "The tx bd is not ready!\n"); in qe_ep_tx()
1222 struct qe_udc *udc = ep->udc; in sendnulldata() local
1228 frame_set_data(frame, (u8 *)udc->nullbuf); in sendnulldata()
1255 static int ep0_prime_status(struct qe_udc *udc, int direction) in ep0_prime_status() argument
1258 struct qe_ep *ep = &udc->eps[0]; in ep0_prime_status()
1261 udc->ep0_state = DATA_STATE_NEED_ZLP; in ep0_prime_status()
1262 udc->ep0_dir = USB_DIR_IN; in ep0_prime_status()
1265 udc->ep0_dir = USB_DIR_OUT; in ep0_prime_status()
1266 udc->ep0_state = WAIT_FOR_OUT_STATUS; in ep0_prime_status()
1273 static void ep0_req_complete(struct qe_udc *udc, struct qe_req *req) in ep0_req_complete() argument
1275 struct qe_ep *ep = &udc->eps[0]; in ep0_req_complete()
1278 switch (udc->ep0_state) { in ep0_req_complete()
1282 if (ep0_prime_status(udc, USB_DIR_OUT)) in ep0_req_complete()
1283 qe_ep0_stall(udc); in ep0_req_complete()
1288 udc->ep0_state = WAIT_FOR_SETUP; in ep0_req_complete()
1294 if (ep0_prime_status(udc, USB_DIR_IN)) in ep0_req_complete()
1295 qe_ep0_stall(udc); in ep0_req_complete()
1300 udc->ep0_state = WAIT_FOR_SETUP; in ep0_req_complete()
1304 dev_vdbg(udc->dev, "Unexpected interrupt\n"); in ep0_req_complete()
1308 qe_ep0_stall(udc); in ep0_req_complete()
1320 ep->udc->ep0_state = WAIT_FOR_SETUP; in ep0_txcomplete()
1339 ep0_req_complete(ep->udc, ep->tx_req); in ep0_txcomplete()
1345 dev_vdbg(ep->udc->dev, "the ep0_controller have no req\n"); in ep0_txcomplete()
1356 dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); in ep0_txframe_handle()
1411 dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); in ep_txframe_handle()
1481 struct qe_udc *udc = ep->udc; in ep_req_rx() local
1491 dev_vdbg(udc->dev, "the req already finish!\n"); in ep_req_rx()
1524 dev_vdbg(udc->dev, "the data01 error!\n"); in ep_req_rx()
1544 dev_err(udc->dev, "The receive frame with error!\n"); in ep_req_rx()
1594 struct qe_udc *udc; in qe_ep_enable() local
1606 udc = ep->udc; in qe_ep_enable()
1607 if (!udc->driver || (udc->gadget.speed == USB_SPEED_UNKNOWN)) in qe_ep_enable()
1612 retval = qe_ep_init(udc, epnum, desc); in qe_ep_enable()
1615 dev_dbg(udc->dev, "enable ep%d failed\n", ep->epnum); in qe_ep_enable()
1618 dev_dbg(udc->dev, "enable ep%d successful\n", ep->epnum); in qe_ep_enable()
1624 struct qe_udc *udc; in qe_ep_disable() local
1630 udc = ep->udc; in qe_ep_disable()
1633 dev_dbg(udc->dev, "%s not enabled\n", _ep ? ep->ep.name : NULL); in qe_ep_disable()
1637 spin_lock_irqsave(&udc->lock, flags); in qe_ep_disable()
1643 qe_ep_reset(udc, ep->epnum); in qe_ep_disable()
1644 spin_unlock_irqrestore(&udc->lock, flags); in qe_ep_disable()
1674 dev_dbg(udc->dev, "disabled %s OK\n", _ep->name); in qe_ep_disable()
1707 struct qe_udc *udc; in __qe_ep_queue() local
1710 udc = ep->udc; in __qe_ep_queue()
1714 dev_dbg(udc->dev, "bad params\n"); in __qe_ep_queue()
1718 dev_dbg(udc->dev, "bad ep\n"); in __qe_ep_queue()
1722 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) in __qe_ep_queue()
1729 req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, in __qe_ep_queue()
1737 dma_sync_single_for_device(ep->udc->gadget.dev.parent, in __qe_ep_queue()
1749 dev_vdbg(udc->dev, "gadget have request in %s! %d\n", in __qe_ep_queue()
1759 udc->ep0_state = DATA_STATE_XMIT; in __qe_ep_queue()
1761 udc->ep0_state = DATA_STATE_RECV; in __qe_ep_queue()
1775 struct qe_udc *udc = ep->udc; in qe_ep_queue() local
1779 spin_lock_irqsave(&udc->lock, flags); in qe_ep_queue()
1781 spin_unlock_irqrestore(&udc->lock, flags); in qe_ep_queue()
1795 spin_lock_irqsave(&ep->udc->lock, flags); in qe_ep_dequeue()
1804 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_dequeue()
1810 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_dequeue()
1825 struct qe_udc *udc; in qe_ep_set_halt() local
1833 udc = ep->udc; in qe_ep_set_halt()
1842 spin_lock_irqsave(&ep->udc->lock, flags); in qe_ep_set_halt()
1845 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_set_halt()
1848 udc->ep0_state = WAIT_FOR_SETUP; in qe_ep_set_halt()
1849 udc->ep0_dir = 0; in qe_ep_set_halt()
1856 dev_vdbg(udc->dev, "%s %s halt stat %d\n", ep->ep.name, in qe_ep_set_halt()
1943 static int udc_reset_ep_queue(struct qe_udc *udc, u8 pipe) in udc_reset_ep_queue() argument
1945 struct qe_ep *ep = &udc->eps[pipe]; in udc_reset_ep_queue()
1952 static int reset_queues(struct qe_udc *udc) in reset_queues() argument
1957 udc_reset_ep_queue(udc, pipe); in reset_queues()
1960 spin_unlock(&udc->lock); in reset_queues()
1961 udc->driver->disconnect(&udc->gadget); in reset_queues()
1962 spin_lock(&udc->lock); in reset_queues()
1967 static void ch9setaddress(struct qe_udc *udc, u16 value, u16 index, in ch9setaddress() argument
1971 udc->device_address = (u8) value; in ch9setaddress()
1973 udc->usb_state = USB_STATE_ADDRESS; in ch9setaddress()
1976 if (ep0_prime_status(udc, USB_DIR_IN)) in ch9setaddress()
1977 qe_ep0_stall(udc); in ch9setaddress()
1988 static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value, in ch9getstatus() argument
1996 ep = &udc->eps[0]; in ch9getstatus()
2007 struct qe_ep *target_ep = &udc->eps[pipe]; in ch9getstatus()
2014 usep = in_be16(&udc->usb_regs->usb_usep[pipe]); in ch9getstatus()
2031 req->req.buf = udc->statusbuf; in ch9getstatus()
2037 udc->ep0_dir = USB_DIR_IN; in ch9getstatus()
2045 dev_err(udc->dev, "Can't respond to getstatus request \n"); in ch9getstatus()
2046 qe_ep0_stall(udc); in ch9getstatus()
2050 static void setup_received_handle(struct qe_udc *udc, in setup_received_handle() argument
2059 udc_reset_ep_queue(udc, 0); in setup_received_handle()
2062 udc->ep0_dir = USB_DIR_IN; in setup_received_handle()
2064 udc->ep0_dir = USB_DIR_OUT; in setup_received_handle()
2072 ch9getstatus(udc, setup->bRequestType, wValue, wIndex, in setup_received_handle()
2081 ch9setaddress(udc, wValue, wIndex, wLength); in setup_received_handle()
2099 ep = &udc->eps[pipe]; in setup_received_handle()
2101 spin_unlock(&udc->lock); in setup_received_handle()
2105 spin_lock(&udc->lock); in setup_received_handle()
2108 ep0_prime_status(udc, USB_DIR_IN); in setup_received_handle()
2119 udc->ep0_state = DATA_STATE_XMIT; in setup_received_handle()
2120 udc->ep0_dir = USB_DIR_IN; in setup_received_handle()
2122 udc->ep0_state = DATA_STATE_RECV; in setup_received_handle()
2123 udc->ep0_dir = USB_DIR_OUT; in setup_received_handle()
2125 spin_unlock(&udc->lock); in setup_received_handle()
2126 if (udc->driver->setup(&udc->gadget, in setup_received_handle()
2127 &udc->local_setup_buff) < 0) in setup_received_handle()
2128 qe_ep0_stall(udc); in setup_received_handle()
2129 spin_lock(&udc->lock); in setup_received_handle()
2132 udc->ep0_dir = USB_DIR_IN; in setup_received_handle()
2133 spin_unlock(&udc->lock); in setup_received_handle()
2134 if (udc->driver->setup(&udc->gadget, in setup_received_handle()
2135 &udc->local_setup_buff) < 0) in setup_received_handle()
2136 qe_ep0_stall(udc); in setup_received_handle()
2137 spin_lock(&udc->lock); in setup_received_handle()
2138 udc->ep0_state = DATA_STATE_NEED_ZLP; in setup_received_handle()
2145 static void suspend_irq(struct qe_udc *udc) in suspend_irq() argument
2147 udc->resume_state = udc->usb_state; in suspend_irq()
2148 udc->usb_state = USB_STATE_SUSPENDED; in suspend_irq()
2151 if (udc->driver->suspend) in suspend_irq()
2152 udc->driver->suspend(&udc->gadget); in suspend_irq()
2155 static void resume_irq(struct qe_udc *udc) in resume_irq() argument
2157 udc->usb_state = udc->resume_state; in resume_irq()
2158 udc->resume_state = 0; in resume_irq()
2161 if (udc->driver->resume) in resume_irq()
2162 udc->driver->resume(&udc->gadget); in resume_irq()
2165 static void idle_irq(struct qe_udc *udc) in idle_irq() argument
2169 usbs = in_8(&udc->usb_regs->usb_usbs); in idle_irq()
2171 if ((udc->usb_state) != USB_STATE_SUSPENDED) in idle_irq()
2172 suspend_irq(udc); in idle_irq()
2174 if (udc->usb_state == USB_STATE_SUSPENDED) in idle_irq()
2175 resume_irq(udc); in idle_irq()
2179 static int reset_irq(struct qe_udc *udc) in reset_irq() argument
2183 if (udc->usb_state == USB_STATE_DEFAULT) in reset_irq()
2187 out_8(&udc->usb_regs->usb_usadr, 0); in reset_irq()
2190 if (udc->eps[i].init) in reset_irq()
2191 qe_ep_reset(udc, i); in reset_irq()
2194 reset_queues(udc); in reset_irq()
2195 udc->usb_state = USB_STATE_DEFAULT; in reset_irq()
2196 udc->ep0_state = WAIT_FOR_SETUP; in reset_irq()
2197 udc->ep0_dir = USB_DIR_OUT; in reset_irq()
2202 static int bsy_irq(struct qe_udc *udc) in bsy_irq() argument
2207 static int txe_irq(struct qe_udc *udc) in txe_irq() argument
2213 static int tx_irq(struct qe_udc *udc) in tx_irq() argument
2219 if ((udc->usb_state == USB_STATE_ADDRESS) in tx_irq()
2220 && (in_8(&udc->usb_regs->usb_usadr) == 0)) in tx_irq()
2221 out_8(&udc->usb_regs->usb_usadr, udc->device_address); in tx_irq()
2224 ep = &udc->eps[i]; in tx_irq()
2242 static void rx_irq(struct qe_udc *udc) in rx_irq() argument
2249 ep = &udc->eps[i]; in rx_irq()
2255 qe_ep0_rx(udc); in rx_irq()
2267 struct qe_udc *udc = (struct qe_udc *)_udc; in qe_udc_irq() local
2272 spin_lock_irqsave(&udc->lock, flags); in qe_udc_irq()
2274 irq_src = in_be16(&udc->usb_regs->usb_usber) & in qe_udc_irq()
2275 in_be16(&udc->usb_regs->usb_usbmr); in qe_udc_irq()
2277 out_be16(&udc->usb_regs->usb_usber, irq_src); in qe_udc_irq()
2280 idle_irq(udc); in qe_udc_irq()
2286 tx_irq(udc); in qe_udc_irq()
2292 rx_irq(udc); in qe_udc_irq()
2298 reset_irq(udc); in qe_udc_irq()
2304 bsy_irq(udc); in qe_udc_irq()
2310 txe_irq(udc); in qe_udc_irq()
2315 spin_unlock_irqrestore(&udc->lock, flags); in qe_udc_irq()
2419 struct qe_udc *udc; in qe_udc_config() local
2427 udc = kzalloc(sizeof(*udc), GFP_KERNEL); in qe_udc_config()
2428 if (udc == NULL) { in qe_udc_config()
2433 udc->dev = &ofdev->dev; in qe_udc_config()
2437 udc->usb_param = cpm_muram_addr(offset); in qe_udc_config()
2438 memset_io(udc->usb_param, 0, size); in qe_udc_config()
2440 usbpram = udc->usb_param; in qe_udc_config()
2452 udc->ep_param[i] = cpm_muram_addr(tmp_addr); in qe_udc_config()
2456 memset_io(udc->ep_param[0], 0, in qe_udc_config()
2459 udc->resume_state = USB_STATE_NOTATTACHED; in qe_udc_config()
2460 udc->usb_state = USB_STATE_POWERED; in qe_udc_config()
2461 udc->ep0_dir = 0; in qe_udc_config()
2463 spin_lock_init(&udc->lock); in qe_udc_config()
2464 return udc; in qe_udc_config()
2467 kfree(udc); in qe_udc_config()
2472 static int __devinit qe_udc_reg_init(struct qe_udc *udc) in qe_udc_reg_init() argument
2475 qe_usbregs = udc->usb_regs; in qe_udc_reg_init()
2490 static int __devinit qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) in qe_ep_config() argument
2492 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_config()
2494 ep->udc = udc; in qe_ep_config()
2518 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in qe_ep_config()
2520 ep->gadget = &udc->gadget; in qe_ep_config()