Lines Matching +full:big +full:- +full:endian +full:- +full:desc

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2006-2007 Renesas Solutions Corp.
20 #include "m66592-udc.h"
43 /*-------------------------------------------------------------------------*/
84 __releases(m66592->lock) in m66592_usb_disconnect()
85 __acquires(m66592->lock) in m66592_usb_disconnect()
93 m66592->gadget.speed = USB_SPEED_UNKNOWN; in m66592_usb_disconnect()
94 spin_unlock(&m66592->lock); in m66592_usb_disconnect()
95 m66592->driver->disconnect(&m66592->gadget); in m66592_usb_disconnect()
96 spin_lock(&m66592->lock); in m66592_usb_disconnect()
99 INIT_LIST_HEAD(&m66592->ep[0].queue); in m66592_usb_disconnect()
208 struct m66592_ep *ep = m66592->pipenum2ep[pipenum]; in pipe_change()
211 if (ep->use_dma) in pipe_change()
214 m66592_mdfy(m66592, pipenum, M66592_CURPIPE, ep->fifosel); in pipe_change()
218 if (m66592->pdata->on_chip) in pipe_change()
223 m66592_bset(m66592, mbw, ep->fifosel); in pipe_change()
232 if (info->pipe == 0) in pipe_buffer_setting()
233 return -EINVAL; in pipe_buffer_setting()
235 m66592_write(m66592, info->pipe, M66592_PIPESEL); in pipe_buffer_setting()
237 if (info->dir_in) in pipe_buffer_setting()
239 pipecfg |= info->type; in pipe_buffer_setting()
240 pipecfg |= info->epnum; in pipe_buffer_setting()
241 switch (info->type) { in pipe_buffer_setting()
243 bufnum = 4 + (info->pipe - M66592_BASE_PIPENUM_INT); in pipe_buffer_setting()
248 if (info->pipe >= M66592_BASE_PIPENUM_BULK) in pipe_buffer_setting()
249 bufnum = info->pipe - M66592_BASE_PIPENUM_BULK; in pipe_buffer_setting()
251 bufnum = info->pipe - M66592_BASE_PIPENUM_ISOC; in pipe_buffer_setting()
256 if (!info->dir_in) in pipe_buffer_setting()
261 (info->pipe - M66592_BASE_PIPENUM_ISOC) * 16; in pipe_buffer_setting()
268 return -ENOMEM; in pipe_buffer_setting()
273 m66592_write(m66592, info->maxpacket, M66592_PIPEMAXP); in pipe_buffer_setting()
274 if (info->interval) in pipe_buffer_setting()
275 info->interval--; in pipe_buffer_setting()
276 m66592_write(m66592, info->interval, M66592_PIPEPERI); in pipe_buffer_setting()
284 if (info->pipe == 0) in pipe_buffer_release()
287 if (is_bulk_pipe(info->pipe)) { in pipe_buffer_release()
288 m66592->bulk--; in pipe_buffer_release()
289 } else if (is_interrupt_pipe(info->pipe)) in pipe_buffer_release()
290 m66592->interrupt--; in pipe_buffer_release()
291 else if (is_isoc_pipe(info->pipe)) { in pipe_buffer_release()
292 m66592->isochronous--; in pipe_buffer_release()
293 if (info->type == M66592_BULK) in pipe_buffer_release()
294 m66592->bulk--; in pipe_buffer_release()
297 info->pipe); in pipe_buffer_release()
302 struct m66592 *m66592 = ep->m66592; in pipe_initialize()
305 m66592_mdfy(m66592, 0, M66592_CURPIPE, ep->fifosel); in pipe_initialize()
307 m66592_write(m66592, M66592_ACLRM, ep->pipectr); in pipe_initialize()
308 m66592_write(m66592, 0, ep->pipectr); in pipe_initialize()
309 m66592_write(m66592, M66592_SQCLR, ep->pipectr); in pipe_initialize()
310 if (ep->use_dma) { in pipe_initialize()
311 m66592_mdfy(m66592, ep->pipenum, M66592_CURPIPE, ep->fifosel); in pipe_initialize()
315 if (m66592->pdata->on_chip) in pipe_initialize()
320 m66592_bset(m66592, mbw, ep->fifosel); in pipe_initialize()
325 const struct usb_endpoint_descriptor *desc, in m66592_ep_setting() argument
329 if (m66592->num_dma == 0) { in m66592_ep_setting()
330 m66592->num_dma++; in m66592_ep_setting()
331 ep->use_dma = 1; in m66592_ep_setting()
332 ep->fifoaddr = M66592_D0FIFO; in m66592_ep_setting()
333 ep->fifosel = M66592_D0FIFOSEL; in m66592_ep_setting()
334 ep->fifoctr = M66592_D0FIFOCTR; in m66592_ep_setting()
335 ep->fifotrn = M66592_D0FIFOTRN; in m66592_ep_setting()
336 } else if (!m66592->pdata->on_chip && m66592->num_dma == 1) { in m66592_ep_setting()
337 m66592->num_dma++; in m66592_ep_setting()
338 ep->use_dma = 1; in m66592_ep_setting()
339 ep->fifoaddr = M66592_D1FIFO; in m66592_ep_setting()
340 ep->fifosel = M66592_D1FIFOSEL; in m66592_ep_setting()
341 ep->fifoctr = M66592_D1FIFOCTR; in m66592_ep_setting()
342 ep->fifotrn = M66592_D1FIFOTRN; in m66592_ep_setting()
344 ep->use_dma = 0; in m66592_ep_setting()
345 ep->fifoaddr = M66592_CFIFO; in m66592_ep_setting()
346 ep->fifosel = M66592_CFIFOSEL; in m66592_ep_setting()
347 ep->fifoctr = M66592_CFIFOCTR; in m66592_ep_setting()
348 ep->fifotrn = 0; in m66592_ep_setting()
351 ep->use_dma = 0; in m66592_ep_setting()
352 ep->fifoaddr = M66592_CFIFO; in m66592_ep_setting()
353 ep->fifosel = M66592_CFIFOSEL; in m66592_ep_setting()
354 ep->fifoctr = M66592_CFIFOCTR; in m66592_ep_setting()
355 ep->fifotrn = 0; in m66592_ep_setting()
358 ep->pipectr = get_pipectr_addr(pipenum); in m66592_ep_setting()
359 ep->pipenum = pipenum; in m66592_ep_setting()
360 ep->ep.maxpacket = usb_endpoint_maxp(desc); in m66592_ep_setting()
361 m66592->pipenum2ep[pipenum] = ep; in m66592_ep_setting()
362 m66592->epaddr2ep[desc->bEndpointAddress&USB_ENDPOINT_NUMBER_MASK] = ep; in m66592_ep_setting()
363 INIT_LIST_HEAD(&ep->queue); in m66592_ep_setting()
368 struct m66592 *m66592 = ep->m66592; in m66592_ep_release()
369 u16 pipenum = ep->pipenum; in m66592_ep_release()
374 if (ep->use_dma) in m66592_ep_release()
375 m66592->num_dma--; in m66592_ep_release()
376 ep->pipenum = 0; in m66592_ep_release()
377 ep->busy = 0; in m66592_ep_release()
378 ep->use_dma = 0; in m66592_ep_release()
382 const struct usb_endpoint_descriptor *desc) in alloc_pipe_config() argument
384 struct m66592 *m66592 = ep->m66592; in alloc_pipe_config()
390 ep->ep.desc = desc; in alloc_pipe_config()
392 BUG_ON(ep->pipenum); in alloc_pipe_config()
394 switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { in alloc_pipe_config()
396 if (m66592->bulk >= M66592_MAX_NUM_BULK) { in alloc_pipe_config()
397 if (m66592->isochronous >= M66592_MAX_NUM_ISOC) { in alloc_pipe_config()
399 return -ENODEV; in alloc_pipe_config()
402 + m66592->isochronous; in alloc_pipe_config()
403 counter = &m66592->isochronous; in alloc_pipe_config()
406 info.pipe = M66592_BASE_PIPENUM_BULK + m66592->bulk; in alloc_pipe_config()
407 counter = &m66592->bulk; in alloc_pipe_config()
413 if (m66592->interrupt >= M66592_MAX_NUM_INT) { in alloc_pipe_config()
415 return -ENODEV; in alloc_pipe_config()
417 info.pipe = M66592_BASE_PIPENUM_INT + m66592->interrupt; in alloc_pipe_config()
419 counter = &m66592->interrupt; in alloc_pipe_config()
422 if (m66592->isochronous >= M66592_MAX_NUM_ISOC) { in alloc_pipe_config()
424 return -ENODEV; in alloc_pipe_config()
426 info.pipe = M66592_BASE_PIPENUM_ISOC + m66592->isochronous; in alloc_pipe_config()
428 counter = &m66592->isochronous; in alloc_pipe_config()
432 return -EINVAL; in alloc_pipe_config()
434 ep->type = info.type; in alloc_pipe_config()
436 info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; in alloc_pipe_config()
437 info.maxpacket = usb_endpoint_maxp(desc); in alloc_pipe_config()
438 info.interval = desc->bInterval; in alloc_pipe_config()
439 if (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) in alloc_pipe_config()
451 if ((counter == &m66592->isochronous) && info.type == M66592_BULK) in alloc_pipe_config()
452 m66592->bulk++; in alloc_pipe_config()
454 m66592_ep_setting(m66592, ep, desc, info.pipe, dma); in alloc_pipe_config()
462 struct m66592 *m66592 = ep->m66592; in free_pipe_config()
465 info.pipe = ep->pipenum; in free_pipe_config()
466 info.type = ep->type; in free_pipe_config()
473 /*-------------------------------------------------------------------------*/
489 m66592->ep[0].internal_ccpl = ccpl; in control_end()
496 struct m66592 *m66592 = ep->m66592; in start_ep0_write()
498 pipe_change(m66592, ep->pipenum); in start_ep0_write()
502 m66592_write(m66592, M66592_BCLR, ep->fifoctr); in start_ep0_write()
503 if (req->req.length == 0) { in start_ep0_write()
504 m66592_bset(m66592, M66592_BVAL, ep->fifoctr); in start_ep0_write()
515 struct m66592 *m66592 = ep->m66592; in start_packet_write()
518 pipe_change(m66592, ep->pipenum); in start_packet_write()
519 disable_irq_empty(m66592, ep->pipenum); in start_packet_write()
520 pipe_start(m66592, ep->pipenum); in start_packet_write()
522 tmp = m66592_read(m66592, ep->fifoctr); in start_packet_write()
524 pipe_irq_enable(m66592, ep->pipenum); in start_packet_write()
531 struct m66592 *m66592 = ep->m66592; in start_packet_read()
532 u16 pipenum = ep->pipenum; in start_packet_read()
534 if (ep->pipenum == 0) { in start_packet_read()
538 m66592_write(m66592, M66592_BCLR, ep->fifoctr); in start_packet_read()
542 if (ep->use_dma) { in start_packet_read()
543 m66592_bset(m66592, M66592_TRCLR, ep->fifosel); in start_packet_read()
545 m66592_bset(m66592, M66592_TRENB, ep->fifosel); in start_packet_read()
547 (req->req.length + ep->ep.maxpacket - 1) in start_packet_read()
548 / ep->ep.maxpacket, in start_packet_read()
549 ep->fifotrn); in start_packet_read()
558 if (ep->ep.desc->bEndpointAddress & USB_DIR_IN) in start_packet()
568 ctsq = m66592_read(ep->m66592, M66592_INTSTS0) & M66592_CTSQ; in start_ep0()
579 control_end(ep->m66592, 0); in start_ep0()
589 unsigned int endian; in init_controller() local
591 if (m66592->pdata->on_chip) { in init_controller()
592 if (m66592->pdata->endian) in init_controller()
593 endian = 0; /* big endian */ in init_controller()
595 endian = M66592_LITTLE; /* little endian */ in init_controller()
611 m66592_bset(m66592, endian, M66592_CFBCFG); in init_controller()
612 m66592_bset(m66592, endian, M66592_D0FBCFG); in init_controller()
616 if (m66592->pdata->endian) in init_controller()
617 endian = M66592_BIGEND; /* big endian */ in init_controller()
619 endian = 0; /* little endian */ in init_controller()
621 if (m66592->pdata->vif) in init_controller()
626 switch (m66592->pdata->xtal) { in init_controller()
637 pr_warn("m66592-udc: xtal configuration error\n"); in init_controller()
641 switch (m66592->irq_trigger) { in init_controller()
649 pr_warn("m66592-udc: irq trigger config error\n"); in init_controller()
654 (vif & M66592_LDRV) | (endian & M66592_BIGEND), in init_controller()
682 if (!m66592->pdata->on_chip) { in disable_controller()
697 if (!m66592->pdata->on_chip) { in m66592_start_xclock()
704 /*-------------------------------------------------------------------------*/
707 __releases(m66592->lock) in transfer_complete()
708 __acquires(m66592->lock) in transfer_complete()
712 if (unlikely(ep->pipenum == 0)) { in transfer_complete()
713 if (ep->internal_ccpl) { in transfer_complete()
714 ep->internal_ccpl = 0; in transfer_complete()
719 list_del_init(&req->queue); in transfer_complete()
720 if (ep->m66592->gadget.speed == USB_SPEED_UNKNOWN) in transfer_complete()
721 req->req.status = -ESHUTDOWN; in transfer_complete()
723 req->req.status = status; in transfer_complete()
725 if (!list_empty(&ep->queue)) in transfer_complete()
728 spin_unlock(&ep->m66592->lock); in transfer_complete()
729 usb_gadget_giveback_request(&ep->ep, &req->req); in transfer_complete()
730 spin_lock(&ep->m66592->lock); in transfer_complete()
733 req = list_entry(ep->queue.next, struct m66592_request, queue); in transfer_complete()
734 if (ep->ep.desc) in transfer_complete()
746 u16 pipenum = ep->pipenum; in irq_ep0_write()
747 struct m66592 *m66592 = ep->m66592; in irq_ep0_write()
750 m66592_bset(m66592, M66592_ISEL, ep->fifosel); in irq_ep0_write()
754 tmp = m66592_read(m66592, ep->fifoctr); in irq_ep0_write()
765 buf = req->req.buf + req->req.actual; in irq_ep0_write()
766 size = min(bufsize, req->req.length - req->req.actual); in irq_ep0_write()
769 if (req->req.buf) { in irq_ep0_write()
772 if ((size == 0) || ((size % ep->ep.maxpacket) != 0)) in irq_ep0_write()
773 m66592_bset(m66592, M66592_BVAL, ep->fifoctr); in irq_ep0_write()
777 req->req.actual += size; in irq_ep0_write()
780 if ((!req->req.zero && (req->req.actual == req->req.length)) in irq_ep0_write()
781 || (size % ep->ep.maxpacket) in irq_ep0_write()
798 u16 pipenum = ep->pipenum; in irq_packet_write()
799 struct m66592 *m66592 = ep->m66592; in irq_packet_write()
802 tmp = m66592_read(m66592, ep->fifoctr); in irq_packet_write()
812 buf = req->req.buf + req->req.actual; in irq_packet_write()
813 size = min(bufsize, req->req.length - req->req.actual); in irq_packet_write()
816 if (req->req.buf) { in irq_packet_write()
819 || ((size % ep->ep.maxpacket) != 0) in irq_packet_write()
820 || ((bufsize != ep->ep.maxpacket) in irq_packet_write()
822 m66592_bset(m66592, M66592_BVAL, ep->fifoctr); in irq_packet_write()
826 req->req.actual += size; in irq_packet_write()
828 if ((!req->req.zero && (req->req.actual == req->req.length)) in irq_packet_write()
829 || (size % ep->ep.maxpacket) in irq_packet_write()
845 u16 pipenum = ep->pipenum; in irq_packet_read()
846 struct m66592 *m66592 = ep->m66592; in irq_packet_read()
850 tmp = m66592_read(m66592, ep->fifoctr); in irq_packet_read()
852 req->req.status = -EPIPE; in irq_packet_read()
863 buf = req->req.buf + req->req.actual; in irq_packet_read()
864 req_len = req->req.length - req->req.actual; in irq_packet_read()
871 req->req.actual += size; in irq_packet_read()
874 if ((!req->req.zero && (req->req.actual == req->req.length)) in irq_packet_read()
875 || (size % ep->ep.maxpacket) in irq_packet_read()
883 if (req->req.buf) { in irq_packet_read()
885 m66592_write(m66592, M66592_BCLR, ep->fifoctr); in irq_packet_read()
887 m66592_read_fifo(m66592, ep->fifoaddr, buf, size); in irq_packet_read()
890 if ((ep->pipenum != 0) && finish) in irq_packet_read()
906 ep = &m66592->ep[0]; in irq_pipe_ready()
907 req = list_entry(ep->queue.next, struct m66592_request, queue); in irq_pipe_ready()
914 ep = m66592->pipenum2ep[pipenum]; in irq_pipe_ready()
915 req = list_entry(ep->queue.next, in irq_pipe_ready()
917 if (ep->ep.desc->bEndpointAddress & USB_DIR_IN) in irq_pipe_ready()
937 ep = &m66592->ep[0]; in irq_pipe_empty()
938 req = list_entry(ep->queue.next, struct m66592_request, queue); in irq_pipe_empty()
950 ep = m66592->pipenum2ep[pipenum]; in irq_pipe_empty()
951 req = list_entry(ep->queue.next, in irq_pipe_empty()
954 if (!list_empty(&ep->queue)) in irq_pipe_empty()
963 __releases(m66592->lock) in get_status()
964 __acquires(m66592->lock) in get_status()
969 u16 w_index = le16_to_cpu(ctrl->wIndex); in get_status()
971 switch (ctrl->bRequestType & USB_RECIP_MASK) { in get_status()
979 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK]; in get_status()
980 pid = control_reg_get_pid(m66592, ep->pipenum); in get_status()
991 m66592->ep0_data = cpu_to_le16(status); in get_status()
992 m66592->ep0_req->buf = &m66592->ep0_data; in get_status()
993 m66592->ep0_req->length = 2; in get_status()
995 spin_unlock(&m66592->lock); in get_status()
996 m66592_queue(m66592->gadget.ep0, m66592->ep0_req, GFP_KERNEL); in get_status()
997 spin_lock(&m66592->lock); in get_status()
1002 switch (ctrl->bRequestType & USB_RECIP_MASK) { in clear_feature()
1012 u16 w_index = le16_to_cpu(ctrl->wIndex); in clear_feature()
1014 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK]; in clear_feature()
1015 pipe_stop(m66592, ep->pipenum); in clear_feature()
1016 control_reg_sqclr(m66592, ep->pipenum); in clear_feature()
1020 req = list_entry(ep->queue.next, in clear_feature()
1022 if (ep->busy) { in clear_feature()
1023 ep->busy = 0; in clear_feature()
1024 if (list_empty(&ep->queue)) in clear_feature()
1027 } else if (!list_empty(&ep->queue)) in clear_feature()
1028 pipe_start(m66592, ep->pipenum); in clear_feature()
1042 switch (ctrl->bRequestType & USB_RECIP_MASK) { in set_feature()
1044 switch (le16_to_cpu(ctrl->wValue)) { in set_feature()
1052 } while (tmp != M66592_CS_IDST && timeout-- > 0); in set_feature()
1056 le16_to_cpu(ctrl->wIndex >> 8), in set_feature()
1069 u16 w_index = le16_to_cpu(ctrl->wIndex); in set_feature()
1071 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK]; in set_feature()
1072 pipe_stall(m66592, ep->pipenum); in set_feature()
1097 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) { in setup_packet()
1098 switch (ctrl->bRequest) { in setup_packet()
1123 m66592->gadget.speed = USB_SPEED_HIGH; in m66592_update_usb_speed()
1126 m66592->gadget.speed = USB_SPEED_FULL; in m66592_update_usb_speed()
1129 m66592->gadget.speed = USB_SPEED_UNKNOWN; in m66592_update_usb_speed()
1142 usb_gadget_udc_reset(&m66592->gadget, m66592->driver); in irq_device_state()
1145 if (m66592->old_dvsq == M66592_DS_CNFG && dvsq != M66592_DS_CNFG) in irq_device_state()
1148 && m66592->gadget.speed == USB_SPEED_UNKNOWN) in irq_device_state()
1151 m66592->old_dvsq = dvsq; in irq_device_state()
1155 __releases(m66592->lock) in irq_control_stage()
1156 __acquires(m66592->lock) in irq_control_stage()
1168 ep = &m66592->ep[0]; in irq_control_stage()
1169 req = list_entry(ep->queue.next, struct m66592_request, queue); in irq_control_stage()
1178 spin_unlock(&m66592->lock); in irq_control_stage()
1179 if (m66592->driver->setup(&m66592->gadget, &ctrl) < 0) in irq_control_stage()
1181 spin_lock(&m66592->lock); in irq_control_stage()
1202 spin_lock(&m66592->lock); in m66592_irq()
1207 if (m66592->pdata->on_chip && !intsts0 && !intenb0) { in m66592_irq()
1211 * a clock by this timing and do re-reading of register. in m66592_irq()
1233 m66592->old_vbus = m66592_read(m66592, M66592_INTSTS0) in m66592_irq()
1235 m66592->scount = M66592_MAX_SAMPLING; in m66592_irq()
1237 mod_timer(&m66592->timer, in m66592_irq()
1258 spin_unlock(&m66592->lock); in m66592_irq()
1268 spin_lock_irqsave(&m66592->lock, flags); in m66592_timer()
1275 if (m66592->scount > 0) { in m66592_timer()
1277 if (tmp == m66592->old_vbus) { in m66592_timer()
1278 m66592->scount--; in m66592_timer()
1279 if (m66592->scount == 0) { in m66592_timer()
1285 mod_timer(&m66592->timer, in m66592_timer()
1289 m66592->scount = M66592_MAX_SAMPLING; in m66592_timer()
1290 m66592->old_vbus = tmp; in m66592_timer()
1291 mod_timer(&m66592->timer, in m66592_timer()
1295 spin_unlock_irqrestore(&m66592->lock, flags); in m66592_timer()
1298 /*-------------------------------------------------------------------------*/
1300 const struct usb_endpoint_descriptor *desc) in m66592_enable() argument
1305 return alloc_pipe_config(ep, desc); in m66592_enable()
1317 while (!list_empty(&ep->queue)) { in m66592_disable()
1318 req = list_entry(ep->queue.next, struct m66592_request, queue); in m66592_disable()
1319 spin_lock_irqsave(&ep->m66592->lock, flags); in m66592_disable()
1320 transfer_complete(ep, req, -ECONNRESET); in m66592_disable()
1321 spin_unlock_irqrestore(&ep->m66592->lock, flags); in m66592_disable()
1324 pipe_irq_disable(ep->m66592, ep->pipenum); in m66592_disable()
1337 INIT_LIST_HEAD(&req->queue); in m66592_alloc_request()
1339 return &req->req; in m66592_alloc_request()
1361 if (ep->m66592->gadget.speed == USB_SPEED_UNKNOWN) in m66592_queue()
1362 return -ESHUTDOWN; in m66592_queue()
1364 spin_lock_irqsave(&ep->m66592->lock, flags); in m66592_queue()
1366 if (list_empty(&ep->queue)) in m66592_queue()
1369 list_add_tail(&req->queue, &ep->queue); in m66592_queue()
1370 req->req.actual = 0; in m66592_queue()
1371 req->req.status = -EINPROGRESS; in m66592_queue()
1373 if (ep->ep.desc == NULL) /* control */ in m66592_queue()
1376 if (request && !ep->busy) in m66592_queue()
1380 spin_unlock_irqrestore(&ep->m66592->lock, flags); in m66592_queue()
1394 spin_lock_irqsave(&ep->m66592->lock, flags); in m66592_dequeue()
1395 if (!list_empty(&ep->queue)) in m66592_dequeue()
1396 transfer_complete(ep, req, -ECONNRESET); in m66592_dequeue()
1397 spin_unlock_irqrestore(&ep->m66592->lock, flags); in m66592_dequeue()
1408 spin_lock_irqsave(&ep->m66592->lock, flags); in m66592_set_halt()
1409 if (!list_empty(&ep->queue)) { in m66592_set_halt()
1410 ret = -EAGAIN; in m66592_set_halt()
1412 ep->busy = 1; in m66592_set_halt()
1413 pipe_stall(ep->m66592, ep->pipenum); in m66592_set_halt()
1415 ep->busy = 0; in m66592_set_halt()
1416 pipe_stop(ep->m66592, ep->pipenum); in m66592_set_halt()
1418 spin_unlock_irqrestore(&ep->m66592->lock, flags); in m66592_set_halt()
1428 spin_lock_irqsave(&ep->m66592->lock, flags); in m66592_fifo_flush()
1429 if (list_empty(&ep->queue) && !ep->busy) { in m66592_fifo_flush()
1430 pipe_stop(ep->m66592, ep->pipenum); in m66592_fifo_flush()
1431 m66592_bclr(ep->m66592, M66592_BCLR, ep->fifoctr); in m66592_fifo_flush()
1433 spin_unlock_irqrestore(&ep->m66592->lock, flags); in m66592_fifo_flush()
1450 /*-------------------------------------------------------------------------*/
1457 m66592->driver = driver; in m66592_udc_start()
1463 m66592->old_vbus = m66592_read(m66592, in m66592_udc_start()
1465 m66592->scount = M66592_MAX_SAMPLING; in m66592_udc_start()
1466 mod_timer(&m66592->timer, jiffies + msecs_to_jiffies(50)); in m66592_udc_start()
1481 m66592->driver = NULL; in m66592_udc_stop()
1486 /*-------------------------------------------------------------------------*/
1498 spin_lock_irqsave(&m66592->lock, flags); in m66592_pullup()
1503 spin_unlock_irqrestore(&m66592->lock, flags); in m66592_pullup()
1519 usb_del_gadget_udc(&m66592->gadget); in m66592_remove()
1521 timer_shutdown_sync(&m66592->timer); in m66592_remove()
1522 iounmap(m66592->reg); in m66592_remove()
1524 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); in m66592_remove()
1525 if (m66592->pdata->on_chip) { in m66592_remove()
1526 clk_disable(m66592->clk); in m66592_remove()
1527 clk_put(m66592->clk); in m66592_remove()
1547 ret = -ENODEV; in m66592_probe()
1554 ret = -ENODEV; in m66592_probe()
1555 dev_err(&pdev->dev, in m66592_probe()
1560 reg = ioremap(res->start, resource_size(res)); in m66592_probe()
1562 ret = -ENOMEM; in m66592_probe()
1567 if (dev_get_platdata(&pdev->dev) == NULL) { in m66592_probe()
1568 dev_err(&pdev->dev, "no platform data\n"); in m66592_probe()
1569 ret = -ENODEV; in m66592_probe()
1576 ret = -ENOMEM; in m66592_probe()
1580 m66592->pdata = dev_get_platdata(&pdev->dev); in m66592_probe()
1581 m66592->irq_trigger = ires->flags & IRQF_TRIGGER_MASK; in m66592_probe()
1583 spin_lock_init(&m66592->lock); in m66592_probe()
1586 m66592->gadget.ops = &m66592_gadget_ops; in m66592_probe()
1587 m66592->gadget.max_speed = USB_SPEED_HIGH; in m66592_probe()
1588 m66592->gadget.name = udc_name; in m66592_probe()
1590 timer_setup(&m66592->timer, m66592_timer, 0); in m66592_probe()
1591 m66592->reg = reg; in m66592_probe()
1593 ret = request_irq(ires->start, m66592_irq, IRQF_SHARED, in m66592_probe()
1600 if (m66592->pdata->on_chip) { in m66592_probe()
1601 snprintf(clk_name, sizeof(clk_name), "usbf%d", pdev->id); in m66592_probe()
1602 m66592->clk = clk_get(&pdev->dev, clk_name); in m66592_probe()
1603 if (IS_ERR(m66592->clk)) { in m66592_probe()
1604 dev_err(&pdev->dev, "cannot get clock \"%s\"\n", in m66592_probe()
1606 ret = PTR_ERR(m66592->clk); in m66592_probe()
1609 clk_enable(m66592->clk); in m66592_probe()
1612 INIT_LIST_HEAD(&m66592->gadget.ep_list); in m66592_probe()
1613 m66592->gadget.ep0 = &m66592->ep[0].ep; in m66592_probe()
1614 INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list); in m66592_probe()
1616 struct m66592_ep *ep = &m66592->ep[i]; in m66592_probe()
1619 INIT_LIST_HEAD(&m66592->ep[i].ep.ep_list); in m66592_probe()
1620 list_add_tail(&m66592->ep[i].ep.ep_list, in m66592_probe()
1621 &m66592->gadget.ep_list); in m66592_probe()
1623 ep->m66592 = m66592; in m66592_probe()
1624 INIT_LIST_HEAD(&ep->queue); in m66592_probe()
1625 ep->ep.name = m66592_ep_name[i]; in m66592_probe()
1626 ep->ep.ops = &m66592_ep_ops; in m66592_probe()
1627 usb_ep_set_maxpacket_limit(&ep->ep, 512); in m66592_probe()
1630 ep->ep.caps.type_control = true; in m66592_probe()
1632 ep->ep.caps.type_iso = true; in m66592_probe()
1633 ep->ep.caps.type_bulk = true; in m66592_probe()
1634 ep->ep.caps.type_int = true; in m66592_probe()
1637 ep->ep.caps.dir_in = true; in m66592_probe()
1638 ep->ep.caps.dir_out = true; in m66592_probe()
1640 usb_ep_set_maxpacket_limit(&m66592->ep[0].ep, 64); in m66592_probe()
1641 m66592->ep[0].pipenum = 0; in m66592_probe()
1642 m66592->ep[0].fifoaddr = M66592_CFIFO; in m66592_probe()
1643 m66592->ep[0].fifosel = M66592_CFIFOSEL; in m66592_probe()
1644 m66592->ep[0].fifoctr = M66592_CFIFOCTR; in m66592_probe()
1645 m66592->ep[0].fifotrn = 0; in m66592_probe()
1646 m66592->ep[0].pipectr = get_pipectr_addr(0); in m66592_probe()
1647 m66592->pipenum2ep[0] = &m66592->ep[0]; in m66592_probe()
1648 m66592->epaddr2ep[0] = &m66592->ep[0]; in m66592_probe()
1650 m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL); in m66592_probe()
1651 if (m66592->ep0_req == NULL) { in m66592_probe()
1652 ret = -ENOMEM; in m66592_probe()
1655 m66592->ep0_req->complete = nop_completion; in m66592_probe()
1659 ret = usb_add_gadget_udc(&pdev->dev, &m66592->gadget); in m66592_probe()
1663 dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION); in m66592_probe()
1667 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); in m66592_probe()
1668 m66592->ep0_req = NULL; in m66592_probe()
1670 if (m66592->pdata->on_chip) { in m66592_probe()
1671 clk_disable(m66592->clk); in m66592_probe()
1672 clk_put(m66592->clk); in m66592_probe()
1675 free_irq(ires->start, m66592); in m66592_probe()
1678 if (m66592->ep0_req) in m66592_probe()
1679 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); in m66592_probe()
1688 /*-------------------------------------------------------------------------*/