Lines Matching +full:dma +full:- +full:controller
5 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation
9 * SPDX-License-Identifier: GPL-2.0
20 #include <linux/dma-mapping.h>
25 #include "linux-compat.h"
31 /* MUSB PERIPHERAL status 3-mar-2006:
33 * - EP0 seems solid. It passes both USBCV and usbtest control cases.
38 * + endpoint halt tests -- in both usbtest and usbcv -- seem
39 * to break when dma is enabled ... is something wrongly
42 * - Mass storage behaved ok when last tested. Network traffic patterns
44 * worst cases of the DMA, since short packets are typical but are not
47 * - TX/IN
48 * + both pio and dma behave in with network and g_zero tests
49 * + no cppi throughput issues other than no-hw-queueing
51 * + seems to behave with double buffering, PIO -and- CPPI
54 * - RX/OUT
55 * + both pio and dma behave in with network and g_zero tests
56 * + dma is slow in typical case (short_not_ok is clear)
61 * - ISO not tested ... might work, but only weakly isochronous
63 * - Gadget driver disabling of softconnect during bind() is ignored; so
67 * - PORTABILITY (assumes PIO works):
68 * + DaVinci, basically works with cppi dma
69 * + OMAP 2430, ditto with mentor dma
70 * + TUSB 6010, platform-specific dma in the works
73 /* ----------------------------------------------------------------------- */
76 (req->map_state != UN_MAPPED))
79 /* Maps the buffer to dma */
85 struct dma_controller *dma = musb->dma_controller; in map_dma_buffer() local
87 request->map_state = UN_MAPPED; in map_dma_buffer()
89 if (!is_dma_capable() || !musb_ep->dma) in map_dma_buffer()
92 /* Check if DMA engine can handle this request. in map_dma_buffer()
93 * DMA code must reject the USB request explicitly. in map_dma_buffer()
96 if (dma->is_compatible) in map_dma_buffer()
97 compatible = dma->is_compatible(musb_ep->dma, in map_dma_buffer()
98 musb_ep->packet_sz, request->request.buf, in map_dma_buffer()
99 request->request.length); in map_dma_buffer()
103 if (request->request.dma == DMA_ADDR_INVALID) { in map_dma_buffer()
104 request->request.dma = dma_map_single( in map_dma_buffer()
105 musb->controller, in map_dma_buffer()
106 request->request.buf, in map_dma_buffer()
107 request->request.length, in map_dma_buffer()
108 request->tx in map_dma_buffer()
111 request->map_state = MUSB_MAPPED; in map_dma_buffer()
113 dma_sync_single_for_device(musb->controller, in map_dma_buffer()
114 request->request.dma, in map_dma_buffer()
115 request->request.length, in map_dma_buffer()
116 request->tx in map_dma_buffer()
119 request->map_state = PRE_MAPPED; in map_dma_buffer()
123 /* Unmap the buffer from dma and maps it back to cpu */
130 if (request->request.dma == DMA_ADDR_INVALID) { in unmap_dma_buffer()
131 dev_vdbg(musb->controller, in unmap_dma_buffer()
135 if (request->map_state == MUSB_MAPPED) { in unmap_dma_buffer()
136 dma_unmap_single(musb->controller, in unmap_dma_buffer()
137 request->request.dma, in unmap_dma_buffer()
138 request->request.length, in unmap_dma_buffer()
139 request->tx in unmap_dma_buffer()
142 request->request.dma = DMA_ADDR_INVALID; in unmap_dma_buffer()
144 dma_sync_single_for_cpu(musb->controller, in unmap_dma_buffer()
145 request->request.dma, in unmap_dma_buffer()
146 request->request.length, in unmap_dma_buffer()
147 request->tx in unmap_dma_buffer()
151 request->map_state = UN_MAPPED; in unmap_dma_buffer()
170 * Context: controller locked, IRQs blocked.
176 __releases(ep->musb->lock) in musb_g_giveback()
177 __acquires(ep->musb->lock) in musb_g_giveback()
181 int busy = ep->busy; in musb_g_giveback()
185 list_del(&req->list); in musb_g_giveback()
186 if (req->request.status == -EINPROGRESS) in musb_g_giveback()
187 req->request.status = status; in musb_g_giveback()
188 musb = req->musb; in musb_g_giveback()
190 ep->busy = 1; in musb_g_giveback()
191 spin_unlock(&musb->lock); in musb_g_giveback()
193 if (request->status == 0) in musb_g_giveback()
194 dev_dbg(musb->controller, "%s done request %p, %d/%d\n", in musb_g_giveback()
195 ep->end_point.name, request, in musb_g_giveback()
196 req->request.actual, req->request.length); in musb_g_giveback()
198 dev_dbg(musb->controller, "%s request %p, %d/%d fault %d\n", in musb_g_giveback()
199 ep->end_point.name, request, in musb_g_giveback()
200 req->request.actual, req->request.length, in musb_g_giveback()
201 request->status); in musb_g_giveback()
202 req->request.complete(&req->ep->end_point, &req->request); in musb_g_giveback()
203 spin_lock(&musb->lock); in musb_g_giveback()
204 ep->busy = busy; in musb_g_giveback()
207 /* ----------------------------------------------------------------------- */
211 * caller locked controller and blocked irqs, and selected this ep.
215 struct musb *musb = ep->musb; in nuke()
217 void __iomem *epio = ep->musb->endpoints[ep->current_epnum].regs; in nuke()
219 ep->busy = 1; in nuke()
221 if (is_dma_capable() && ep->dma) { in nuke()
222 struct dma_controller *c = ep->musb->dma_controller; in nuke()
225 if (ep->is_in) { in nuke()
242 value = c->channel_abort(ep->dma); in nuke()
243 dev_dbg(musb->controller, "%s: abort DMA --> %d\n", in nuke()
244 ep->name, value); in nuke()
245 c->channel_release(ep->dma); in nuke()
246 ep->dma = NULL; in nuke()
249 while (!list_empty(&ep->req_list)) { in nuke()
250 req = list_first_entry(&ep->req_list, struct musb_request, list); in nuke()
251 musb_g_giveback(ep, &req->request, status); in nuke()
255 /* ----------------------------------------------------------------------- */
257 /* Data transfers - pure PIO, pure DMA, or mixed mode */
260 * This assumes the separate CPPI engine is responding to DMA requests
261 * from the usb core ... sequenced a bit differently from mentor dma.
266 if (can_bulk_split(musb, ep->type)) in max_ep_writesize()
267 return ep->hw_ep->max_packet_sz_tx; in max_ep_writesize()
269 return ep->packet_sz; in max_ep_writesize()
275 /* Peripheral tx (IN) using Mentor DMA works as follows:
280 - Host sends IN token which causes an endpoint interrupt
281 -> TxAvail
282 -> if DMA is currently busy, exit.
283 -> if queue is non-empty, txstate().
285 - Request is queued by the gadget driver.
286 -> if queue was previously empty, txstate()
289 -> start
290 /\ -> setup DMA
293 | -> DMA interrupt on completion
295 | -> stop DMA, ~DMAENAB,
296 | -> set TxPktRdy for last short pkt or zlp
297 | -> Complete Request
298 | -> Continue next request (call txstate)
301 * Non-Mentor DMA engines can of course work differently, such as by
302 * upleveling from irq-per-packet to irq-per-buffer.
312 * Context: controller locked, IRQs blocked, endpoint selected
316 u8 epnum = req->epnum; in txstate()
318 void __iomem *epio = musb->endpoints[epnum].regs; in txstate()
323 musb_ep = req->ep; in txstate()
326 if (!musb_ep->desc) { in txstate()
327 dev_dbg(musb->controller, "ep:%s disabled - ignore request\n", in txstate()
328 musb_ep->end_point.name); in txstate()
332 /* we shouldn't get here while DMA is active ... but we do ... */ in txstate()
333 if (dma_channel_status(musb_ep->dma) == MUSB_DMA_STATUS_BUSY) { in txstate()
334 dev_dbg(musb->controller, "dma pending...\n"); in txstate()
341 request = &req->request; in txstate()
343 (int)(request->length - request->actual)); in txstate()
346 dev_dbg(musb->controller, "%s old packet still ready , txcsr %03x\n", in txstate()
347 musb_ep->end_point.name, csr); in txstate()
352 dev_dbg(musb->controller, "%s stalling, txcsr %03x\n", in txstate()
353 musb_ep->end_point.name, csr); in txstate()
357 dev_dbg(musb->controller, "hw_ep%d, maxpacket %d, fifo count %d, txcsr %03x\n", in txstate()
358 epnum, musb_ep->packet_sz, fifo_count, in txstate()
363 struct dma_controller *c = musb->dma_controller; in txstate()
366 /* setup DMA, then program endpoint CSR */ in txstate()
367 request_size = min_t(size_t, request->length - request->actual, in txstate()
368 musb_ep->dma->max_len); in txstate()
370 use_dma = (request->dma != DMA_ADDR_INVALID); in txstate()
376 if (request_size < musb_ep->packet_sz) in txstate()
377 musb_ep->dma->desired_mode = 0; in txstate()
379 musb_ep->dma->desired_mode = 1; in txstate()
381 use_dma = use_dma && c->channel_program( in txstate()
382 musb_ep->dma, musb_ep->packet_sz, in txstate()
383 musb_ep->dma->desired_mode, in txstate()
384 request->dma + request->actual, request_size); in txstate()
386 if (musb_ep->dma->desired_mode == 0) { in txstate()
389 * before the DMAENAB bit -- and the in txstate()
405 if (!musb_ep->hb_mult) in txstate()
415 /* program endpoint CSR first, then setup DMA */ in txstate()
427 * OK since the transfer dma glue (between CPPI and Mentor in txstate()
434 * except for the last-packet-is-already-short case. in txstate()
436 use_dma = use_dma && c->channel_program( in txstate()
437 musb_ep->dma, musb_ep->packet_sz, in txstate()
439 request->dma + request->actual, in txstate()
442 c->channel_release(musb_ep->dma); in txstate()
443 musb_ep->dma = NULL; in txstate()
446 /* invariant: prequest->buf is non-null */ in txstate()
449 use_dma = use_dma && c->channel_program( in txstate()
450 musb_ep->dma, musb_ep->packet_sz, in txstate()
451 request->zero, in txstate()
452 request->dma + request->actual, in txstate()
460 * Unmap the dma buffer back to cpu if dma channel in txstate()
465 musb_write_fifo(musb_ep->hw_ep, fifo_count, in txstate()
466 (u8 *) (request->buf + request->actual)); in txstate()
467 request->actual += fifo_count; in txstate()
474 dev_dbg(musb->controller, "%s TX/IN %s len %d/%d, txcsr %04x, fifo %d/%d\n", in txstate()
475 musb_ep->end_point.name, use_dma ? "dma" : "pio", in txstate()
476 request->actual, request->length, in txstate()
484 * Called from IRQ, with controller locked.
491 u8 __iomem *mbase = musb->mregs; in musb_g_tx()
492 struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_in; in musb_g_tx()
493 void __iomem *epio = musb->endpoints[epnum].regs; in musb_g_tx()
494 struct dma_channel *dma; in musb_g_tx() local
498 request = &req->request; in musb_g_tx()
501 dev_dbg(musb->controller, "<== %s, txcsr %04x\n", musb_ep->end_point.name, csr); in musb_g_tx()
503 dma = is_dma_capable() ? musb_ep->dma : NULL; in musb_g_tx()
521 dev_vdbg(musb->controller, "underrun on ep%d, req %p\n", in musb_g_tx()
525 if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { in musb_g_tx()
530 dev_dbg(musb->controller, "%s dma still busy?\n", musb_ep->end_point.name); in musb_g_tx()
537 if (dma && (csr & MUSB_TXCSR_DMAENAB)) { in musb_g_tx()
545 request->actual += musb_ep->dma->actual_len; in musb_g_tx()
546 dev_dbg(musb->controller, "TXCSR%d %04x, DMA off, len %zu, req %p\n", in musb_g_tx()
547 epnum, csr, musb_ep->dma->actual_len, request); in musb_g_tx()
551 * First, maybe a terminating short packet. Some DMA in musb_g_tx()
554 if ((request->zero && request->length in musb_g_tx()
555 && (request->length % musb_ep->packet_sz == 0) in musb_g_tx()
556 && (request->actual == request->length)) in musb_g_tx()
558 || (is_dma && (!dma->desired_mode || in musb_g_tx()
559 (request->actual & in musb_g_tx()
560 (musb_ep->packet_sz - 1)))) in musb_g_tx()
564 * On DMA completion, FIFO may not be in musb_g_tx()
570 dev_dbg(musb->controller, "sending zero pkt\n"); in musb_g_tx()
573 request->zero = 0; in musb_g_tx()
576 if (request->actual == request->length) { in musb_g_tx()
587 req = musb_ep->desc ? next_request(musb_ep) : NULL; in musb_g_tx()
589 dev_dbg(musb->controller, "%s idle now\n", in musb_g_tx()
590 musb_ep->end_point.name); in musb_g_tx()
599 /* ------------------------------------------------------------ */
603 /* Peripheral rx (OUT) using Mentor DMA works as follows:
604 - Only mode 0 is used.
606 - Request is queued by the gadget class driver.
607 -> if queue was previously empty, rxstate()
609 - Host sends OUT token which causes an endpoint interrupt
610 /\ -> RxReady
611 | -> if request queued, call rxstate
612 | /\ -> setup DMA
613 | | -> DMA interrupt on completion
614 | | -> RxReady
615 | | -> stop DMA
616 | | -> ack the read
617 | | -> if data recd = max expected
627 * Non-Mentor DMA engines can of course work differently.
633 * Context: controller locked, IRQs blocked, endpoint selected
637 const u8 epnum = req->epnum; in rxstate()
638 struct usb_request *request = &req->request; in rxstate()
640 void __iomem *epio = musb->endpoints[epnum].regs; in rxstate()
644 struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; in rxstate()
647 if (hw_ep->is_shared_fifo) in rxstate()
648 musb_ep = &hw_ep->ep_in; in rxstate()
650 musb_ep = &hw_ep->ep_out; in rxstate()
652 len = musb_ep->packet_sz; in rxstate()
655 if (!musb_ep->desc) { in rxstate()
656 dev_dbg(musb->controller, "ep:%s disabled - ignore request\n", in rxstate()
657 musb_ep->end_point.name); in rxstate()
661 /* We shouldn't get here while DMA is active, but we do... */ in rxstate()
662 if (dma_channel_status(musb_ep->dma) == MUSB_DMA_STATUS_BUSY) { in rxstate()
663 dev_dbg(musb->controller, "DMA pending...\n"); in rxstate()
668 dev_dbg(musb->controller, "%s stalling, RXCSR %04x\n", in rxstate()
669 musb_ep->end_point.name, csr); in rxstate()
674 struct dma_controller *c = musb->dma_controller; in rxstate()
675 struct dma_channel *channel = musb_ep->dma; in rxstate()
677 /* NOTE: CPPI won't actually stop advancing the DMA in rxstate()
679 * always going to run as IRQ-per-packet DMA so that in rxstate()
682 if (c->channel_program(channel, in rxstate()
683 musb_ep->packet_sz, in rxstate()
684 !request->short_not_ok, in rxstate()
685 request->dma + request->actual, in rxstate()
686 request->length - request->actual)) { in rxstate()
690 * as DMA is enabled in rxstate()
709 if (request->short_not_ok && len == musb_ep->packet_sz) in rxstate()
714 if (request->actual < request->length) { in rxstate()
721 c = musb->dma_controller; in rxstate()
722 channel = musb_ep->dma; in rxstate()
724 /* We use DMA Req mode 0 in rx_csr, and DMA controller operates in in rxstate()
725 * mode 0 only. So we do not get endpoint interrupts due to DMA in rxstate()
726 * completion. We only get interrupts from DMA controller. in rxstate()
728 * We could operate in DMA mode 1 if we knew the size of the tranfer in rxstate()
729 * in advance. For mass storage class, request->length = what the host in rxstate()
731 * request->length is routinely more than what the host sends. For in rxstate()
735 * we don't get DMA completion interrupt for short packets. in rxstate()
738 * to get endpoint interrupt on every DMA req, but that didn't seem in rxstate()
741 * REVISIT an updated g_file_storage can set req->short_not_ok, which in rxstate()
762 if (!musb_ep->hb_mult && in rxstate()
763 musb_ep->hw_ep->rx_double_buffered) in rxstate()
769 if (request->actual < request->length) { in rxstate()
772 transfer_size = min(request->length - request->actual, in rxstate()
773 channel->max_len); in rxstate()
774 musb_ep->dma->desired_mode = 1; in rxstate()
776 transfer_size = min(request->length - request->actual, in rxstate()
778 musb_ep->dma->desired_mode = 0; in rxstate()
781 use_dma = c->channel_program( in rxstate()
783 musb_ep->packet_sz, in rxstate()
784 channel->desired_mode, in rxstate()
785 request->dma in rxstate()
786 + request->actual, in rxstate()
795 (request->actual < request->length)) { in rxstate()
801 c = musb->dma_controller; in rxstate()
802 channel = musb_ep->dma; in rxstate()
805 if (len < musb_ep->packet_sz) in rxstate()
807 else if (request->short_not_ok) in rxstate()
808 transfer_size = min(request->length - in rxstate()
809 request->actual, in rxstate()
810 channel->max_len); in rxstate()
812 transfer_size = min(request->length - in rxstate()
813 request->actual, in rxstate()
822 if (transfer_size <= musb_ep->packet_sz) { in rxstate()
823 musb_ep->dma->desired_mode = 0; in rxstate()
825 musb_ep->dma->desired_mode = 1; in rxstate()
831 if (c->channel_program(channel, in rxstate()
832 musb_ep->packet_sz, in rxstate()
833 channel->desired_mode, in rxstate()
834 request->dma in rxstate()
835 + request->actual, in rxstate()
840 #endif /* Mentor's DMA */ in rxstate()
842 fifo_count = request->length - request->actual; in rxstate()
843 dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n", in rxstate()
844 musb_ep->end_point.name, in rxstate()
846 musb_ep->packet_sz); in rxstate()
852 struct dma_controller *c = musb->dma_controller; in rxstate()
853 struct dma_channel *channel = musb_ep->dma; in rxstate()
854 u32 dma_addr = request->dma + request->actual; in rxstate()
857 ret = c->channel_program(channel, in rxstate()
858 musb_ep->packet_sz, in rxstate()
859 channel->desired_mode, in rxstate()
867 * Unmap the dma buffer back to cpu if dma channel in rxstate()
882 musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *) in rxstate()
883 (request->buf + request->actual)); in rxstate()
884 request->actual += fifo_count; in rxstate()
887 * it and report -EOVERFLOW in rxstate()
898 if (request->actual == request->length || len < musb_ep->packet_sz) in rxstate()
910 void __iomem *mbase = musb->mregs; in musb_g_rx()
912 void __iomem *epio = musb->endpoints[epnum].regs; in musb_g_rx()
913 struct dma_channel *dma; in musb_g_rx() local
914 struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; in musb_g_rx()
916 if (hw_ep->is_shared_fifo) in musb_g_rx()
917 musb_ep = &hw_ep->ep_in; in musb_g_rx()
919 musb_ep = &hw_ep->ep_out; in musb_g_rx()
927 request = &req->request; in musb_g_rx()
930 dma = is_dma_capable() ? musb_ep->dma : NULL; in musb_g_rx()
932 dev_dbg(musb->controller, "<== %s, rxcsr %04x%s %p\n", musb_ep->end_point.name, in musb_g_rx()
933 csr, dma ? " (dma)" : "", request); in musb_g_rx()
947 dev_dbg(musb->controller, "%s iso overrun on %p\n", musb_ep->name, request); in musb_g_rx()
948 if (request->status == -EINPROGRESS) in musb_g_rx()
949 request->status = -EOVERFLOW; in musb_g_rx()
953 dev_dbg(musb->controller, "%s, incomprx\n", musb_ep->end_point.name); in musb_g_rx()
956 if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { in musb_g_rx()
957 /* "should not happen"; likely RXPKTRDY pending for DMA */ in musb_g_rx()
958 dev_dbg(musb->controller, "%s busy, csr %04x\n", in musb_g_rx()
959 musb_ep->end_point.name, csr); in musb_g_rx()
963 if (dma && (csr & MUSB_RXCSR_DMAENAB)) { in musb_g_rx()
970 request->actual += musb_ep->dma->actual_len; in musb_g_rx()
972 dev_dbg(musb->controller, "RXCSR%d %04x, dma off, %04x, len %zu, req %p\n", in musb_g_rx()
975 musb_ep->dma->actual_len, request); in musb_g_rx()
980 if ((dma->desired_mode == 0 && !hw_ep->rx_double_buffered) in musb_g_rx()
981 || (dma->actual_len in musb_g_rx()
982 & (musb_ep->packet_sz - 1))) { in musb_g_rx()
989 if ((request->actual < request->length) in musb_g_rx()
990 && (musb_ep->dma->actual_len in musb_g_rx()
991 == musb_ep->packet_sz)) { in musb_g_rx()
997 hw_ep->rx_double_buffered) in musb_g_rx()
1025 /* ------------------------------------------------------------ */
1039 int status = -EINVAL; in musb_gadget_enable()
1042 return -EINVAL; in musb_gadget_enable()
1045 hw_ep = musb_ep->hw_ep; in musb_gadget_enable()
1046 regs = hw_ep->regs; in musb_gadget_enable()
1047 musb = musb_ep->musb; in musb_gadget_enable()
1048 mbase = musb->mregs; in musb_gadget_enable()
1049 epnum = musb_ep->current_epnum; in musb_gadget_enable()
1051 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_enable()
1053 if (musb_ep->desc) { in musb_gadget_enable()
1054 status = -EBUSY; in musb_gadget_enable()
1057 musb_ep->type = usb_endpoint_type(desc); in musb_gadget_enable()
1069 ok = musb->hb_iso_tx; in musb_gadget_enable()
1071 ok = musb->hb_iso_rx; in musb_gadget_enable()
1074 dev_dbg(musb->controller, "no support for high bandwidth ISO\n"); in musb_gadget_enable()
1077 musb_ep->hb_mult = (tmp >> 11) & 3; in musb_gadget_enable()
1079 musb_ep->hb_mult = 0; in musb_gadget_enable()
1082 musb_ep->packet_sz = tmp & 0x7ff; in musb_gadget_enable()
1083 tmp = musb_ep->packet_sz * (musb_ep->hb_mult + 1); in musb_gadget_enable()
1092 if (hw_ep->is_shared_fifo) in musb_gadget_enable()
1093 musb_ep->is_in = 1; in musb_gadget_enable()
1094 if (!musb_ep->is_in) in musb_gadget_enable()
1097 if (tmp > hw_ep->max_packet_sz_tx) { in musb_gadget_enable()
1098 dev_dbg(musb->controller, "packet size beyond hardware FIFO size\n"); in musb_gadget_enable()
1111 if (musb->double_buffer_not_ok) in musb_gadget_enable()
1112 musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx); in musb_gadget_enable()
1114 musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz in musb_gadget_enable()
1115 | (musb_ep->hb_mult << 11)); in musb_gadget_enable()
1121 if (musb_ep->type == USB_ENDPOINT_XFER_ISOC) in musb_gadget_enable()
1132 if (hw_ep->is_shared_fifo) in musb_gadget_enable()
1133 musb_ep->is_in = 0; in musb_gadget_enable()
1134 if (musb_ep->is_in) in musb_gadget_enable()
1137 if (tmp > hw_ep->max_packet_sz_rx) { in musb_gadget_enable()
1138 dev_dbg(musb->controller, "packet size beyond hardware FIFO size\n"); in musb_gadget_enable()
1151 if (musb->double_buffer_not_ok) in musb_gadget_enable()
1152 musb_writew(regs, MUSB_RXMAXP, hw_ep->max_packet_sz_tx); in musb_gadget_enable()
1154 musb_writew(regs, MUSB_RXMAXP, musb_ep->packet_sz in musb_gadget_enable()
1155 | (musb_ep->hb_mult << 11)); in musb_gadget_enable()
1157 /* force shared fifo to OUT-only mode */ in musb_gadget_enable()
1158 if (hw_ep->is_shared_fifo) { in musb_gadget_enable()
1165 if (musb_ep->type == USB_ENDPOINT_XFER_ISOC) in musb_gadget_enable()
1167 else if (musb_ep->type == USB_ENDPOINT_XFER_INT) in musb_gadget_enable()
1175 /* NOTE: all the I/O code _should_ work fine without DMA, in case in musb_gadget_enable()
1178 if (is_dma_capable() && musb->dma_controller) { in musb_gadget_enable()
1179 struct dma_controller *c = musb->dma_controller; in musb_gadget_enable()
1181 musb_ep->dma = c->channel_alloc(c, hw_ep, in musb_gadget_enable()
1182 (desc->bEndpointAddress & USB_DIR_IN)); in musb_gadget_enable()
1184 musb_ep->dma = NULL; in musb_gadget_enable()
1186 musb_ep->desc = desc; in musb_gadget_enable()
1187 musb_ep->busy = 0; in musb_gadget_enable()
1188 musb_ep->wedged = 0; in musb_gadget_enable()
1192 musb_driver_name, musb_ep->end_point.name, in musb_gadget_enable()
1193 ({ char *s; switch (musb_ep->type) { in musb_gadget_enable()
1198 musb_ep->is_in ? "IN" : "OUT", in musb_gadget_enable()
1199 musb_ep->dma ? "dma, " : "", in musb_gadget_enable()
1200 musb_ep->packet_sz); in musb_gadget_enable()
1202 schedule_work(&musb->irq_work); in musb_gadget_enable()
1205 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_enable()
1222 musb = musb_ep->musb; in musb_gadget_disable()
1223 epnum = musb_ep->current_epnum; in musb_gadget_disable()
1224 epio = musb->endpoints[epnum].regs; in musb_gadget_disable()
1226 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_disable()
1227 musb_ep_select(musb->mregs, epnum); in musb_gadget_disable()
1230 if (musb_ep->is_in) { in musb_gadget_disable()
1231 u16 int_txe = musb_readw(musb->mregs, MUSB_INTRTXE); in musb_gadget_disable()
1233 musb_writew(musb->mregs, MUSB_INTRTXE, int_txe); in musb_gadget_disable()
1236 u16 int_rxe = musb_readw(musb->mregs, MUSB_INTRRXE); in musb_gadget_disable()
1238 musb_writew(musb->mregs, MUSB_INTRRXE, int_rxe); in musb_gadget_disable()
1242 musb_ep->desc = NULL; in musb_gadget_disable()
1244 musb_ep->end_point.desc = NULL; in musb_gadget_disable()
1247 /* abort all pending DMA and requests */ in musb_gadget_disable()
1248 nuke(musb_ep, -ESHUTDOWN); in musb_gadget_disable()
1250 schedule_work(&musb->irq_work); in musb_gadget_disable()
1252 spin_unlock_irqrestore(&(musb->lock), flags); in musb_gadget_disable()
1254 dev_dbg(musb->controller, "%s\n", musb_ep->end_point.name); in musb_gadget_disable()
1266 struct musb *musb = musb_ep->musb; in musb_alloc_request()
1271 dev_dbg(musb->controller, "not enough memory\n"); in musb_alloc_request()
1275 request->request.dma = DMA_ADDR_INVALID; in musb_alloc_request()
1276 request->epnum = musb_ep->current_epnum; in musb_alloc_request()
1277 request->ep = musb_ep; in musb_alloc_request()
1279 return &request->request; in musb_alloc_request()
1297 dma_addr_t dma; member
1301 * Context: controller locked, IRQs blocked.
1305 dev_dbg(musb->controller, "<== %s request %p len %u on hw_ep%d\n", in musb_ep_restart()
1306 req->tx ? "TX/IN" : "RX/OUT", in musb_ep_restart()
1307 &req->request, req->request.length, req->epnum); in musb_ep_restart()
1309 musb_ep_select(musb->mregs, req->epnum); in musb_ep_restart()
1310 if (req->tx) in musb_ep_restart()
1326 return -EINVAL; in musb_gadget_queue()
1327 if (!req->buf) in musb_gadget_queue()
1328 return -ENODATA; in musb_gadget_queue()
1331 musb = musb_ep->musb; in musb_gadget_queue()
1334 request->musb = musb; in musb_gadget_queue()
1336 if (request->ep != musb_ep) in musb_gadget_queue()
1337 return -EINVAL; in musb_gadget_queue()
1339 dev_dbg(musb->controller, "<== to %s request=%p\n", ep->name, req); in musb_gadget_queue()
1342 request->request.actual = 0; in musb_gadget_queue()
1343 request->request.status = -EINPROGRESS; in musb_gadget_queue()
1344 request->epnum = musb_ep->current_epnum; in musb_gadget_queue()
1345 request->tx = musb_ep->is_in; in musb_gadget_queue()
1349 spin_lock_irqsave(&musb->lock, lockflags); in musb_gadget_queue()
1352 if (!musb_ep->desc) { in musb_gadget_queue()
1353 dev_dbg(musb->controller, "req %p queued to %s while ep %s\n", in musb_gadget_queue()
1354 req, ep->name, "disabled"); in musb_gadget_queue()
1355 status = -ESHUTDOWN; in musb_gadget_queue()
1360 list_add_tail(&request->list, &musb_ep->req_list); in musb_gadget_queue()
1363 if (!musb_ep->busy && &request->list == musb_ep->req_list.next) in musb_gadget_queue()
1367 spin_unlock_irqrestore(&musb->lock, lockflags); in musb_gadget_queue()
1378 struct musb *musb = musb_ep->musb; in musb_gadget_dequeue()
1380 if (!ep || !request || to_musb_request(request)->ep != musb_ep) in musb_gadget_dequeue()
1381 return -EINVAL; in musb_gadget_dequeue()
1383 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_dequeue()
1385 list_for_each_entry(r, &musb_ep->req_list, list) { in musb_gadget_dequeue()
1390 dev_dbg(musb->controller, "request %p not queued to %s\n", request, ep->name); in musb_gadget_dequeue()
1391 status = -EINVAL; in musb_gadget_dequeue()
1396 if (musb_ep->req_list.next != &req->list || musb_ep->busy) in musb_gadget_dequeue()
1397 musb_g_giveback(musb_ep, request, -ECONNRESET); in musb_gadget_dequeue()
1399 /* ... else abort the dma transfer ... */ in musb_gadget_dequeue()
1400 else if (is_dma_capable() && musb_ep->dma) { in musb_gadget_dequeue()
1401 struct dma_controller *c = musb->dma_controller; in musb_gadget_dequeue()
1403 musb_ep_select(musb->mregs, musb_ep->current_epnum); in musb_gadget_dequeue()
1404 if (c->channel_abort) in musb_gadget_dequeue()
1405 status = c->channel_abort(musb_ep->dma); in musb_gadget_dequeue()
1407 status = -EBUSY; in musb_gadget_dequeue()
1409 musb_g_giveback(musb_ep, request, -ECONNRESET); in musb_gadget_dequeue()
1412 * we leave counting of in-flight packets imprecise. in musb_gadget_dequeue()
1414 musb_g_giveback(musb_ep, request, -ECONNRESET); in musb_gadget_dequeue()
1418 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_dequeue()
1431 u8 epnum = musb_ep->current_epnum; in musb_gadget_set_halt()
1432 struct musb *musb = musb_ep->musb; in musb_gadget_set_halt()
1433 void __iomem *epio = musb->endpoints[epnum].regs; in musb_gadget_set_halt()
1441 return -EINVAL; in musb_gadget_set_halt()
1442 mbase = musb->mregs; in musb_gadget_set_halt()
1444 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_set_halt()
1446 if ((USB_ENDPOINT_XFER_ISOC == musb_ep->type)) { in musb_gadget_set_halt()
1447 status = -EINVAL; in musb_gadget_set_halt()
1456 dev_dbg(musb->controller, "request in progress, cannot halt %s\n", in musb_gadget_set_halt()
1457 ep->name); in musb_gadget_set_halt()
1458 status = -EAGAIN; in musb_gadget_set_halt()
1461 /* Cannot portably stall with non-empty FIFO */ in musb_gadget_set_halt()
1462 if (musb_ep->is_in) { in musb_gadget_set_halt()
1465 dev_dbg(musb->controller, "FIFO busy, cannot halt %s\n", ep->name); in musb_gadget_set_halt()
1466 status = -EAGAIN; in musb_gadget_set_halt()
1471 musb_ep->wedged = 0; in musb_gadget_set_halt()
1474 dev_dbg(musb->controller, "%s: %s stall\n", ep->name, value ? "set" : "clear"); in musb_gadget_set_halt()
1475 if (musb_ep->is_in) { in musb_gadget_set_halt()
1500 if (!musb_ep->busy && !value && request) { in musb_gadget_set_halt()
1501 dev_dbg(musb->controller, "restarting the request\n"); in musb_gadget_set_halt()
1506 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_set_halt()
1519 return -EINVAL; in musb_gadget_set_wedge()
1521 musb_ep->wedged = 1; in musb_gadget_set_wedge()
1530 void __iomem *epio = musb_ep->hw_ep->regs; in musb_gadget_fifo_status()
1531 int retval = -EINVAL; in musb_gadget_fifo_status()
1533 if (musb_ep->desc && !musb_ep->is_in) { in musb_gadget_fifo_status()
1534 struct musb *musb = musb_ep->musb; in musb_gadget_fifo_status()
1535 int epnum = musb_ep->current_epnum; in musb_gadget_fifo_status()
1536 void __iomem *mbase = musb->mregs; in musb_gadget_fifo_status()
1539 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_fifo_status()
1545 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_fifo_status()
1553 struct musb *musb = musb_ep->musb; in musb_gadget_fifo_flush()
1554 u8 epnum = musb_ep->current_epnum; in musb_gadget_fifo_flush()
1555 void __iomem *epio = musb->endpoints[epnum].regs; in musb_gadget_fifo_flush()
1560 mbase = musb->mregs; in musb_gadget_fifo_flush()
1562 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_fifo_flush()
1569 if (musb_ep->is_in) { in musb_gadget_fifo_flush()
1574 * Setting both TXPKTRDY and FLUSHFIFO makes controller in musb_gadget_fifo_flush()
1590 /* re-enable interrupt */ in musb_gadget_fifo_flush()
1592 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_fifo_flush()
1610 /* ----------------------------------------------------------------------- */
1616 return (int)musb_readw(musb->mregs, MUSB_FRAME); in musb_gadget_get_frame()
1623 void __iomem *mregs = musb->mregs; in musb_gadget_wakeup()
1625 int status = -EINVAL; in musb_gadget_wakeup()
1629 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_wakeup()
1631 switch (musb->xceiv->state) { in musb_gadget_wakeup()
1637 if (musb->may_wakeup && musb->is_suspended) in musb_gadget_wakeup()
1643 dev_dbg(musb->controller, "Sending SRP: devctl: %02x\n", devctl); in musb_gadget_wakeup()
1650 if (retries-- < 1) in musb_gadget_wakeup()
1656 if (retries-- < 1) in musb_gadget_wakeup()
1660 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_wakeup()
1661 otg_start_srp(musb->xceiv->otg); in musb_gadget_wakeup()
1662 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_wakeup()
1671 dev_dbg(musb->controller, "Unhandled wake: %s\n", in musb_gadget_wakeup()
1672 otg_state_string(musb->xceiv->state)); in musb_gadget_wakeup()
1681 dev_dbg(musb->controller, "issue wakeup\n"); in musb_gadget_wakeup()
1690 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_wakeup()
1702 musb->is_self_powered = !!is_selfpowered; in musb_gadget_set_self_powered()
1710 power = musb_readb(musb->mregs, MUSB_POWER); in musb_pullup()
1718 dev_dbg(musb->controller, "gadget D+ pullup %s\n", in musb_pullup()
1720 musb_writeb(musb->mregs, MUSB_POWER, power); in musb_pullup()
1726 dev_dbg(musb->controller, "<= %s =>\n", __func__);
1733 return -EINVAL;
1742 if (!musb->xceiv->set_power) in musb_gadget_vbus_draw()
1743 return -EOPNOTSUPP; in musb_gadget_vbus_draw()
1744 return usb_phy_set_power(musb->xceiv, mA); in musb_gadget_vbus_draw()
1757 pm_runtime_get_sync(musb->controller); in musb_gadget_pullup()
1760 * not pullup unless the B-session is active. in musb_gadget_pullup()
1762 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_pullup()
1763 if (is_on != musb->softconnect) { in musb_gadget_pullup()
1764 musb->softconnect = is_on; in musb_gadget_pullup()
1767 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_pullup()
1769 pm_runtime_put(musb->controller); in musb_gadget_pullup()
1794 /* ----------------------------------------------------------------------- */
1815 struct musb_hw_ep *hw_ep = musb->endpoints + epnum; in init_peripheral_ep()
1819 ep->current_epnum = epnum; in init_peripheral_ep()
1820 ep->musb = musb; in init_peripheral_ep()
1821 ep->hw_ep = hw_ep; in init_peripheral_ep()
1822 ep->is_in = is_in; in init_peripheral_ep()
1824 INIT_LIST_HEAD(&ep->req_list); in init_peripheral_ep()
1826 sprintf(ep->name, "ep%d%s", epnum, in init_peripheral_ep()
1827 (!epnum || hw_ep->is_shared_fifo) ? "" : ( in init_peripheral_ep()
1829 ep->end_point.name = ep->name; in init_peripheral_ep()
1830 INIT_LIST_HEAD(&ep->end_point.ep_list); in init_peripheral_ep()
1832 ep->end_point.maxpacket = 64; in init_peripheral_ep()
1833 ep->end_point.ops = &musb_g_ep0_ops; in init_peripheral_ep()
1834 musb->g.ep0 = &ep->end_point; in init_peripheral_ep()
1837 ep->end_point.maxpacket = hw_ep->max_packet_sz_tx; in init_peripheral_ep()
1839 ep->end_point.maxpacket = hw_ep->max_packet_sz_rx; in init_peripheral_ep()
1840 ep->end_point.ops = &musb_ep_ops; in init_peripheral_ep()
1841 list_add_tail(&ep->end_point.ep_list, &musb->g.ep_list); in init_peripheral_ep()
1856 INIT_LIST_HEAD(&(musb->g.ep_list)); in musb_g_init_endpoints()
1858 for (epnum = 0, hw_ep = musb->endpoints; in musb_g_init_endpoints()
1859 epnum < musb->nr_endpoints; in musb_g_init_endpoints()
1861 if (hw_ep->is_shared_fifo /* || !epnum */) { in musb_g_init_endpoints()
1862 init_peripheral_ep(musb, &hw_ep->ep_in, epnum, 0); in musb_g_init_endpoints()
1865 if (hw_ep->max_packet_sz_tx) { in musb_g_init_endpoints()
1866 init_peripheral_ep(musb, &hw_ep->ep_in, in musb_g_init_endpoints()
1870 if (hw_ep->max_packet_sz_rx) { in musb_g_init_endpoints()
1871 init_peripheral_ep(musb, &hw_ep->ep_out, in musb_g_init_endpoints()
1891 musb->g.ops = &musb_gadget_operations; in musb_gadget_setup()
1893 musb->g.max_speed = USB_SPEED_HIGH; in musb_gadget_setup()
1895 musb->g.speed = USB_SPEED_UNKNOWN; in musb_gadget_setup()
1898 /* this "gadget" abstracts/virtualizes the controller */ in musb_gadget_setup()
1899 dev_set_name(&musb->g.dev, "gadget"); in musb_gadget_setup()
1900 musb->g.dev.parent = musb->controller; in musb_gadget_setup()
1901 musb->g.dev.dma_mask = musb->controller->dma_mask; in musb_gadget_setup()
1902 musb->g.dev.release = musb_gadget_release; in musb_gadget_setup()
1904 musb->g.name = musb_driver_name; in musb_gadget_setup()
1908 musb->g.is_otg = 1; in musb_gadget_setup()
1913 musb->is_active = 0; in musb_gadget_setup()
1917 status = device_register(&musb->g.dev); in musb_gadget_setup()
1919 put_device(&musb->g.dev); in musb_gadget_setup()
1922 status = usb_add_gadget_udc(musb->controller, &musb->g); in musb_gadget_setup()
1930 musb->g.dev.parent = NULL; in musb_gadget_setup()
1931 device_unregister(&musb->g.dev); in musb_gadget_setup()
1939 usb_del_gadget_udc(&musb->g); in musb_gadget_cleanup()
1940 if (musb->g.dev.parent) in musb_gadget_cleanup()
1941 device_unregister(&musb->g.dev); in musb_gadget_cleanup()
1947 * registering themselves with the controller.
1949 * -EINVAL something went wrong (not driver)
1950 * -EBUSY another gadget is already using the controller
1951 * -ENOMEM no memory to perform the operation
1966 struct usb_otg *otg = musb->xceiv->otg; in musb_gadget_start()
1969 int retval = -EINVAL; in musb_gadget_start()
1972 if (driver->max_speed < USB_SPEED_HIGH) in musb_gadget_start()
1976 pm_runtime_get_sync(musb->controller); in musb_gadget_start()
1979 dev_dbg(musb->controller, "registering driver %s\n", driver->function); in musb_gadget_start()
1982 musb->softconnect = 0; in musb_gadget_start()
1983 musb->gadget_driver = driver; in musb_gadget_start()
1985 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_start()
1986 musb->is_active = 1; in musb_gadget_start()
1989 otg_set_peripheral(otg, &musb->g); in musb_gadget_start()
1990 musb->xceiv->state = OTG_STATE_B_IDLE; in musb_gadget_start()
2003 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_start()
2009 dev_dbg(musb->controller, "OTG startup...\n"); in musb_gadget_start()
2017 dev_dbg(musb->controller, "add_hcd failed, %d\n", retval); in musb_gadget_start()
2021 if ((musb->xceiv->last_event == USB_EVENT_ID) in musb_gadget_start()
2022 && otg->set_vbus) in musb_gadget_start()
2025 hcd->self.uses_pio_for_control = 1; in musb_gadget_start()
2027 if (musb->xceiv->last_event == USB_EVENT_NONE) in musb_gadget_start()
2028 pm_runtime_put(musb->controller); in musb_gadget_start()
2049 if (musb->g.speed == USB_SPEED_UNKNOWN) in stop_activity()
2052 musb->g.speed = USB_SPEED_UNKNOWN; in stop_activity()
2055 if (musb->softconnect) { in stop_activity()
2056 musb->softconnect = 0; in stop_activity()
2065 for (i = 0, hw_ep = musb->endpoints; in stop_activity()
2066 i < musb->nr_endpoints; in stop_activity()
2068 musb_ep_select(musb->mregs, i); in stop_activity()
2069 if (hw_ep->is_shared_fifo /* || !epnum */) { in stop_activity()
2070 nuke(&hw_ep->ep_in, -ESHUTDOWN); in stop_activity()
2072 if (hw_ep->max_packet_sz_tx) in stop_activity()
2073 nuke(&hw_ep->ep_in, -ESHUTDOWN); in stop_activity()
2074 if (hw_ep->max_packet_sz_rx) in stop_activity()
2075 nuke(&hw_ep->ep_out, -ESHUTDOWN); in stop_activity()
2083 * unregistering themselves from the controller.
2093 if (musb->xceiv->last_event == USB_EVENT_NONE) in musb_gadget_stop()
2094 pm_runtime_get_sync(musb->controller); in musb_gadget_stop()
2101 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_stop()
2105 (void) musb_gadget_vbus_draw(&musb->g, 0); in musb_gadget_stop()
2107 musb->xceiv->state = OTG_STATE_UNDEFINED; in musb_gadget_stop()
2109 otg_set_peripheral(musb->xceiv->otg, NULL); in musb_gadget_stop()
2111 dev_dbg(musb->controller, "unregistering driver %s\n", driver->function); in musb_gadget_stop()
2113 musb->is_active = 0; in musb_gadget_stop()
2115 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_stop()
2128 pm_runtime_put(musb->controller); in musb_gadget_stop()
2134 /* ----------------------------------------------------------------------- */
2141 musb->is_suspended = 0; in musb_g_resume()
2142 switch (musb->xceiv->state) { in musb_g_resume()
2147 musb->is_active = 1; in musb_g_resume()
2148 if (musb->gadget_driver && musb->gadget_driver->resume) { in musb_g_resume()
2149 spin_unlock(&musb->lock); in musb_g_resume()
2150 musb->gadget_driver->resume(&musb->g); in musb_g_resume()
2151 spin_lock(&musb->lock); in musb_g_resume()
2156 otg_state_string(musb->xceiv->state)); in musb_g_resume()
2167 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); in musb_g_suspend()
2168 dev_dbg(musb->controller, "devctl %02x\n", devctl); in musb_g_suspend()
2170 switch (musb->xceiv->state) { in musb_g_suspend()
2173 musb->xceiv->state = OTG_STATE_B_PERIPHERAL; in musb_g_suspend()
2176 musb->is_suspended = 1; in musb_g_suspend()
2177 if (musb->gadget_driver && musb->gadget_driver->suspend) { in musb_g_suspend()
2178 spin_unlock(&musb->lock); in musb_g_suspend()
2179 musb->gadget_driver->suspend(&musb->g); in musb_g_suspend()
2180 spin_lock(&musb->lock); in musb_g_suspend()
2188 otg_state_string(musb->xceiv->state)); in musb_g_suspend()
2196 musb_gadget_wakeup(&musb->g); in musb_g_wakeup()
2202 void __iomem *mregs = musb->mregs; in musb_g_disconnect()
2205 dev_dbg(musb->controller, "devctl %02x\n", devctl); in musb_g_disconnect()
2210 /* don't draw vbus until new b-default session */ in musb_g_disconnect()
2211 (void) musb_gadget_vbus_draw(&musb->g, 0); in musb_g_disconnect()
2213 musb->g.speed = USB_SPEED_UNKNOWN; in musb_g_disconnect()
2214 if (musb->gadget_driver && musb->gadget_driver->disconnect) { in musb_g_disconnect()
2215 spin_unlock(&musb->lock); in musb_g_disconnect()
2216 musb->gadget_driver->disconnect(&musb->g); in musb_g_disconnect()
2217 spin_lock(&musb->lock); in musb_g_disconnect()
2221 switch (musb->xceiv->state) { in musb_g_disconnect()
2223 dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n", in musb_g_disconnect()
2224 otg_state_string(musb->xceiv->state)); in musb_g_disconnect()
2225 musb->xceiv->state = OTG_STATE_A_IDLE; in musb_g_disconnect()
2229 musb->xceiv->state = OTG_STATE_A_WAIT_BCON; in musb_g_disconnect()
2236 musb->xceiv->state = OTG_STATE_B_IDLE; in musb_g_disconnect()
2243 musb->is_active = 0; in musb_g_disconnect()
2247 __releases(musb->lock) in musb_g_reset()
2248 __acquires(musb->lock) in musb_g_reset()
2250 void __iomem *mbase = musb->mregs; in musb_g_reset()
2255 dev_dbg(musb->controller, "<== %s addr=%x driver '%s'\n", in musb_g_reset()
2257 ? "B-Device" : "A-Device", in musb_g_reset()
2259 musb->gadget_driver in musb_g_reset()
2260 ? musb->gadget_driver->driver.name in musb_g_reset()
2266 if (musb->g.speed != USB_SPEED_UNKNOWN) in musb_g_reset()
2276 musb->g.speed = (power & MUSB_POWER_HSMODE) in musb_g_reset()
2280 musb->is_active = 1; in musb_g_reset()
2281 musb->is_suspended = 0; in musb_g_reset()
2283 musb->address = 0; in musb_g_reset()
2284 musb->ep0_state = MUSB_EP0_STAGE_SETUP; in musb_g_reset()
2286 musb->may_wakeup = 0; in musb_g_reset()
2287 musb->g.b_hnp_enable = 0; in musb_g_reset()
2288 musb->g.a_alt_hnp_support = 0; in musb_g_reset()
2289 musb->g.a_hnp_support = 0; in musb_g_reset()
2292 /* Normal reset, as B-Device; in musb_g_reset()
2293 * or else after HNP, as A-Device in musb_g_reset()
2296 musb->xceiv->state = OTG_STATE_B_PERIPHERAL; in musb_g_reset()
2297 musb->g.is_a_peripheral = 0; in musb_g_reset()
2299 musb->xceiv->state = OTG_STATE_A_PERIPHERAL; in musb_g_reset()
2300 musb->g.is_a_peripheral = 1; in musb_g_reset()
2305 (void) musb_gadget_vbus_draw(&musb->g, in musb_g_reset()