Lines Matching +full:dma +full:- +full:controller
1 // SPDX-License-Identifier: GPL-2.0
6 * Copyright (C) 2005-2006 by Texas Instruments
7 * Copyright (C) 2006-2007 Nokia Corporation
19 #include <linux/dma-mapping.h>
24 #include "linux-compat.h"
30 /* MUSB PERIPHERAL status 3-mar-2006:
32 * - EP0 seems solid. It passes both USBCV and usbtest control cases.
37 * + endpoint halt tests -- in both usbtest and usbcv -- seem
38 * to break when dma is enabled ... is something wrongly
41 * - Mass storage behaved ok when last tested. Network traffic patterns
43 * worst cases of the DMA, since short packets are typical but are not
46 * - TX/IN
47 * + both pio and dma behave in with network and g_zero tests
48 * + no cppi throughput issues other than no-hw-queueing
50 * + seems to behave with double buffering, PIO -and- CPPI
53 * - RX/OUT
54 * + both pio and dma behave in with network and g_zero tests
55 * + dma is slow in typical case (short_not_ok is clear)
60 * - ISO not tested ... might work, but only weakly isochronous
62 * - Gadget driver disabling of softconnect during bind() is ignored; so
66 * - PORTABILITY (assumes PIO works):
67 * + DaVinci, basically works with cppi dma
68 * + OMAP 2430, ditto with mentor dma
69 * + TUSB 6010, platform-specific dma in the works
72 /* ----------------------------------------------------------------------- */
75 (req->map_state != UN_MAPPED))
78 /* Maps the buffer to dma */
84 struct dma_controller *dma = musb->dma_controller; in map_dma_buffer() local
86 request->map_state = UN_MAPPED; in map_dma_buffer()
88 if (!is_dma_capable() || !musb_ep->dma) in map_dma_buffer()
91 /* Check if DMA engine can handle this request. in map_dma_buffer()
92 * DMA code must reject the USB request explicitly. in map_dma_buffer()
95 if (dma->is_compatible) in map_dma_buffer()
96 compatible = dma->is_compatible(musb_ep->dma, in map_dma_buffer()
97 musb_ep->packet_sz, request->request.buf, in map_dma_buffer()
98 request->request.length); in map_dma_buffer()
102 if (request->request.dma == DMA_ADDR_INVALID) { in map_dma_buffer()
103 request->request.dma = dma_map_single( in map_dma_buffer()
104 musb->controller, in map_dma_buffer()
105 request->request.buf, in map_dma_buffer()
106 request->request.length, in map_dma_buffer()
107 request->tx in map_dma_buffer()
110 request->map_state = MUSB_MAPPED; in map_dma_buffer()
112 dma_sync_single_for_device(musb->controller, in map_dma_buffer()
113 request->request.dma, in map_dma_buffer()
114 request->request.length, in map_dma_buffer()
115 request->tx in map_dma_buffer()
118 request->map_state = PRE_MAPPED; in map_dma_buffer()
122 /* Unmap the buffer from dma and maps it back to cpu */
129 if (request->request.dma == DMA_ADDR_INVALID) { in unmap_dma_buffer()
130 dev_vdbg(musb->controller, in unmap_dma_buffer()
134 if (request->map_state == MUSB_MAPPED) { in unmap_dma_buffer()
135 dma_unmap_single(musb->controller, in unmap_dma_buffer()
136 request->request.dma, in unmap_dma_buffer()
137 request->request.length, in unmap_dma_buffer()
138 request->tx in unmap_dma_buffer()
141 request->request.dma = DMA_ADDR_INVALID; in unmap_dma_buffer()
143 dma_sync_single_for_cpu(musb->controller, in unmap_dma_buffer()
144 request->request.dma, in unmap_dma_buffer()
145 request->request.length, in unmap_dma_buffer()
146 request->tx in unmap_dma_buffer()
150 request->map_state = UN_MAPPED; in unmap_dma_buffer()
169 * Context: controller locked, IRQs blocked.
175 __releases(ep->musb->lock) in musb_g_giveback()
176 __acquires(ep->musb->lock) in musb_g_giveback()
180 int busy = ep->busy; in musb_g_giveback()
184 list_del(&req->list); in musb_g_giveback()
185 if (req->request.status == -EINPROGRESS) in musb_g_giveback()
186 req->request.status = status; in musb_g_giveback()
187 musb = req->musb; in musb_g_giveback()
189 ep->busy = 1; in musb_g_giveback()
190 spin_unlock(&musb->lock); in musb_g_giveback()
192 if (request->status == 0) in musb_g_giveback()
193 dev_dbg(musb->controller, "%s done request %p, %d/%d\n", in musb_g_giveback()
194 ep->end_point.name, request, in musb_g_giveback()
195 req->request.actual, req->request.length); in musb_g_giveback()
197 dev_dbg(musb->controller, "%s request %p, %d/%d fault %d\n", in musb_g_giveback()
198 ep->end_point.name, request, in musb_g_giveback()
199 req->request.actual, req->request.length, in musb_g_giveback()
200 request->status); in musb_g_giveback()
201 req->request.complete(&req->ep->end_point, &req->request); in musb_g_giveback()
202 spin_lock(&musb->lock); in musb_g_giveback()
203 ep->busy = busy; in musb_g_giveback()
206 /* ----------------------------------------------------------------------- */
210 * caller locked controller and blocked irqs, and selected this ep.
214 struct musb *musb = ep->musb; in nuke()
216 void __iomem *epio = ep->musb->endpoints[ep->current_epnum].regs; in nuke()
218 ep->busy = 1; in nuke()
220 if (is_dma_capable() && ep->dma) { in nuke()
221 struct dma_controller *c = ep->musb->dma_controller; in nuke()
224 if (ep->is_in) { in nuke()
241 value = c->channel_abort(ep->dma); in nuke()
242 dev_dbg(musb->controller, "%s: abort DMA --> %d\n", in nuke()
243 ep->name, value); in nuke()
244 c->channel_release(ep->dma); in nuke()
245 ep->dma = NULL; in nuke()
248 while (!list_empty(&ep->req_list)) { in nuke()
249 req = list_first_entry(&ep->req_list, struct musb_request, list); in nuke()
250 musb_g_giveback(ep, &req->request, status); in nuke()
254 /* ----------------------------------------------------------------------- */
256 /* Data transfers - pure PIO, pure DMA, or mixed mode */
259 * This assumes the separate CPPI engine is responding to DMA requests
260 * from the usb core ... sequenced a bit differently from mentor dma.
265 if (can_bulk_split(musb, ep->type)) in max_ep_writesize()
266 return ep->hw_ep->max_packet_sz_tx; in max_ep_writesize()
268 return ep->packet_sz; in max_ep_writesize()
274 /* Peripheral tx (IN) using Mentor DMA works as follows:
279 - Host sends IN token which causes an endpoint interrupt
280 -> TxAvail
281 -> if DMA is currently busy, exit.
282 -> if queue is non-empty, txstate().
284 - Request is queued by the gadget driver.
285 -> if queue was previously empty, txstate()
288 -> start
289 /\ -> setup DMA
292 | -> DMA interrupt on completion
294 | -> stop DMA, ~DMAENAB,
295 | -> set TxPktRdy for last short pkt or zlp
296 | -> Complete Request
297 | -> Continue next request (call txstate)
300 * Non-Mentor DMA engines can of course work differently, such as by
301 * upleveling from irq-per-packet to irq-per-buffer.
311 * Context: controller locked, IRQs blocked, endpoint selected
315 u8 epnum = req->epnum; in txstate()
317 void __iomem *epio = musb->endpoints[epnum].regs; in txstate()
322 musb_ep = req->ep; in txstate()
325 if (!musb_ep->desc) { in txstate()
326 dev_dbg(musb->controller, "ep:%s disabled - ignore request\n", in txstate()
327 musb_ep->end_point.name); in txstate()
331 /* we shouldn't get here while DMA is active ... but we do ... */ in txstate()
332 if (dma_channel_status(musb_ep->dma) == MUSB_DMA_STATUS_BUSY) { in txstate()
333 dev_dbg(musb->controller, "dma pending...\n"); in txstate()
340 request = &req->request; in txstate()
342 (int)(request->length - request->actual)); in txstate()
345 dev_dbg(musb->controller, "%s old packet still ready , txcsr %03x\n", in txstate()
346 musb_ep->end_point.name, csr); in txstate()
351 dev_dbg(musb->controller, "%s stalling, txcsr %03x\n", in txstate()
352 musb_ep->end_point.name, csr); in txstate()
356 dev_dbg(musb->controller, "hw_ep%d, maxpacket %d, fifo count %d, txcsr %03x\n", in txstate()
357 epnum, musb_ep->packet_sz, fifo_count, in txstate()
362 struct dma_controller *c = musb->dma_controller; in txstate()
365 /* setup DMA, then program endpoint CSR */ in txstate()
366 request_size = min_t(size_t, request->length - request->actual, in txstate()
367 musb_ep->dma->max_len); in txstate()
369 use_dma = (request->dma != DMA_ADDR_INVALID); in txstate()
375 if (request_size < musb_ep->packet_sz) in txstate()
376 musb_ep->dma->desired_mode = 0; in txstate()
378 musb_ep->dma->desired_mode = 1; in txstate()
380 use_dma = use_dma && c->channel_program( in txstate()
381 musb_ep->dma, musb_ep->packet_sz, in txstate()
382 musb_ep->dma->desired_mode, in txstate()
383 request->dma + request->actual, request_size); in txstate()
385 if (musb_ep->dma->desired_mode == 0) { in txstate()
388 * before the DMAENAB bit -- and the in txstate()
404 if (!musb_ep->hb_mult) in txstate()
414 /* program endpoint CSR first, then setup DMA */ in txstate()
426 * OK since the transfer dma glue (between CPPI and Mentor in txstate()
433 * except for the last-packet-is-already-short case. in txstate()
435 use_dma = use_dma && c->channel_program( in txstate()
436 musb_ep->dma, musb_ep->packet_sz, in txstate()
438 request->dma + request->actual, in txstate()
441 c->channel_release(musb_ep->dma); in txstate()
442 musb_ep->dma = NULL; in txstate()
445 /* invariant: prequest->buf is non-null */ in txstate()
448 use_dma = use_dma && c->channel_program( in txstate()
449 musb_ep->dma, musb_ep->packet_sz, in txstate()
450 request->zero, in txstate()
451 request->dma + request->actual, in txstate()
459 * Unmap the dma buffer back to cpu if dma channel in txstate()
464 musb_write_fifo(musb_ep->hw_ep, fifo_count, in txstate()
465 (u8 *) (request->buf + request->actual)); in txstate()
466 request->actual += fifo_count; in txstate()
473 dev_dbg(musb->controller, "%s TX/IN %s len %d/%d, txcsr %04x, fifo %d/%d\n", in txstate()
474 musb_ep->end_point.name, use_dma ? "dma" : "pio", in txstate()
475 request->actual, request->length, in txstate()
483 * Called from IRQ, with controller locked.
490 u8 __iomem *mbase = musb->mregs; in musb_g_tx()
491 struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_in; in musb_g_tx()
492 void __iomem *epio = musb->endpoints[epnum].regs; in musb_g_tx()
493 struct dma_channel *dma; in musb_g_tx() local
497 request = &req->request; in musb_g_tx()
500 dev_dbg(musb->controller, "<== %s, txcsr %04x\n", musb_ep->end_point.name, csr); in musb_g_tx()
502 dma = is_dma_capable() ? musb_ep->dma : NULL; in musb_g_tx()
520 dev_vdbg(musb->controller, "underrun on ep%d, req %p\n", in musb_g_tx()
524 if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { in musb_g_tx()
529 dev_dbg(musb->controller, "%s dma still busy?\n", musb_ep->end_point.name); in musb_g_tx()
536 if (dma && (csr & MUSB_TXCSR_DMAENAB)) { in musb_g_tx()
544 request->actual += musb_ep->dma->actual_len; in musb_g_tx()
545 dev_dbg(musb->controller, "TXCSR%d %04x, DMA off, len %zu, req %p\n", in musb_g_tx()
546 epnum, csr, musb_ep->dma->actual_len, request); in musb_g_tx()
550 * First, maybe a terminating short packet. Some DMA in musb_g_tx()
553 if ((request->zero && request->length in musb_g_tx()
554 && (request->length % musb_ep->packet_sz == 0) in musb_g_tx()
555 && (request->actual == request->length)) in musb_g_tx()
557 || (is_dma && (!dma->desired_mode || in musb_g_tx()
558 (request->actual & in musb_g_tx()
559 (musb_ep->packet_sz - 1)))) in musb_g_tx()
563 * On DMA completion, FIFO may not be in musb_g_tx()
569 dev_dbg(musb->controller, "sending zero pkt\n"); in musb_g_tx()
572 request->zero = 0; in musb_g_tx()
575 if (request->actual == request->length) { in musb_g_tx()
586 req = musb_ep->desc ? next_request(musb_ep) : NULL; in musb_g_tx()
588 dev_dbg(musb->controller, "%s idle now\n", in musb_g_tx()
589 musb_ep->end_point.name); in musb_g_tx()
598 /* ------------------------------------------------------------ */
602 /* Peripheral rx (OUT) using Mentor DMA works as follows:
603 - Only mode 0 is used.
605 - Request is queued by the gadget class driver.
606 -> if queue was previously empty, rxstate()
608 - Host sends OUT token which causes an endpoint interrupt
609 /\ -> RxReady
610 | -> if request queued, call rxstate
611 | /\ -> setup DMA
612 | | -> DMA interrupt on completion
613 | | -> RxReady
614 | | -> stop DMA
615 | | -> ack the read
616 | | -> if data recd = max expected
626 * Non-Mentor DMA engines can of course work differently.
632 * Context: controller locked, IRQs blocked, endpoint selected
636 const u8 epnum = req->epnum; in rxstate()
637 struct usb_request *request = &req->request; in rxstate()
639 void __iomem *epio = musb->endpoints[epnum].regs; in rxstate()
643 struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; in rxstate()
646 if (hw_ep->is_shared_fifo) in rxstate()
647 musb_ep = &hw_ep->ep_in; in rxstate()
649 musb_ep = &hw_ep->ep_out; in rxstate()
651 len = musb_ep->packet_sz; in rxstate()
654 if (!musb_ep->desc) { in rxstate()
655 dev_dbg(musb->controller, "ep:%s disabled - ignore request\n", in rxstate()
656 musb_ep->end_point.name); in rxstate()
660 /* We shouldn't get here while DMA is active, but we do... */ in rxstate()
661 if (dma_channel_status(musb_ep->dma) == MUSB_DMA_STATUS_BUSY) { in rxstate()
662 dev_dbg(musb->controller, "DMA pending...\n"); in rxstate()
667 dev_dbg(musb->controller, "%s stalling, RXCSR %04x\n", in rxstate()
668 musb_ep->end_point.name, csr); in rxstate()
673 struct dma_controller *c = musb->dma_controller; in rxstate()
674 struct dma_channel *channel = musb_ep->dma; in rxstate()
676 /* NOTE: CPPI won't actually stop advancing the DMA in rxstate()
678 * always going to run as IRQ-per-packet DMA so that in rxstate()
681 if (c->channel_program(channel, in rxstate()
682 musb_ep->packet_sz, in rxstate()
683 !request->short_not_ok, in rxstate()
684 request->dma + request->actual, in rxstate()
685 request->length - request->actual)) { in rxstate()
689 * as DMA is enabled in rxstate()
708 if (request->short_not_ok && len == musb_ep->packet_sz) in rxstate()
713 if (request->actual < request->length) { in rxstate()
720 c = musb->dma_controller; in rxstate()
721 channel = musb_ep->dma; in rxstate()
723 /* We use DMA Req mode 0 in rx_csr, and DMA controller operates in in rxstate()
724 * mode 0 only. So we do not get endpoint interrupts due to DMA in rxstate()
725 * completion. We only get interrupts from DMA controller. in rxstate()
727 * We could operate in DMA mode 1 if we knew the size of the tranfer in rxstate()
728 * in advance. For mass storage class, request->length = what the host in rxstate()
730 * request->length is routinely more than what the host sends. For in rxstate()
734 * we don't get DMA completion interrupt for short packets. in rxstate()
737 * to get endpoint interrupt on every DMA req, but that didn't seem in rxstate()
740 * REVISIT an updated g_file_storage can set req->short_not_ok, which in rxstate()
761 if (!musb_ep->hb_mult && in rxstate()
762 musb_ep->hw_ep->rx_double_buffered) in rxstate()
768 if (request->actual < request->length) { in rxstate()
771 transfer_size = min(request->length - request->actual, in rxstate()
772 channel->max_len); in rxstate()
773 musb_ep->dma->desired_mode = 1; in rxstate()
775 transfer_size = min(request->length - request->actual, in rxstate()
777 musb_ep->dma->desired_mode = 0; in rxstate()
780 use_dma = c->channel_program( in rxstate()
782 musb_ep->packet_sz, in rxstate()
783 channel->desired_mode, in rxstate()
784 request->dma in rxstate()
785 + request->actual, in rxstate()
794 (request->actual < request->length)) { in rxstate()
800 c = musb->dma_controller; in rxstate()
801 channel = musb_ep->dma; in rxstate()
804 if (len < musb_ep->packet_sz) in rxstate()
806 else if (request->short_not_ok) in rxstate()
807 transfer_size = min(request->length - in rxstate()
808 request->actual, in rxstate()
809 channel->max_len); in rxstate()
811 transfer_size = min(request->length - in rxstate()
812 request->actual, in rxstate()
821 if (transfer_size <= musb_ep->packet_sz) { in rxstate()
822 musb_ep->dma->desired_mode = 0; in rxstate()
824 musb_ep->dma->desired_mode = 1; in rxstate()
830 if (c->channel_program(channel, in rxstate()
831 musb_ep->packet_sz, in rxstate()
832 channel->desired_mode, in rxstate()
833 request->dma in rxstate()
834 + request->actual, in rxstate()
839 #endif /* Mentor's DMA */ in rxstate()
841 fifo_count = request->length - request->actual; in rxstate()
842 dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n", in rxstate()
843 musb_ep->end_point.name, in rxstate()
845 musb_ep->packet_sz); in rxstate()
851 struct dma_controller *c = musb->dma_controller; in rxstate()
852 struct dma_channel *channel = musb_ep->dma; in rxstate()
853 u32 dma_addr = request->dma + request->actual; in rxstate()
856 ret = c->channel_program(channel, in rxstate()
857 musb_ep->packet_sz, in rxstate()
858 channel->desired_mode, in rxstate()
866 * Unmap the dma buffer back to cpu if dma channel in rxstate()
881 musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *) in rxstate()
882 (request->buf + request->actual)); in rxstate()
883 request->actual += fifo_count; in rxstate()
886 * it and report -EOVERFLOW in rxstate()
897 if (request->actual == request->length || len < musb_ep->packet_sz) in rxstate()
909 void __iomem *mbase = musb->mregs; in musb_g_rx()
911 void __iomem *epio = musb->endpoints[epnum].regs; in musb_g_rx()
912 struct dma_channel *dma; in musb_g_rx() local
913 struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; in musb_g_rx()
915 if (hw_ep->is_shared_fifo) in musb_g_rx()
916 musb_ep = &hw_ep->ep_in; in musb_g_rx()
918 musb_ep = &hw_ep->ep_out; in musb_g_rx()
926 request = &req->request; in musb_g_rx()
929 dma = is_dma_capable() ? musb_ep->dma : NULL; in musb_g_rx()
931 dev_dbg(musb->controller, "<== %s, rxcsr %04x%s %p\n", musb_ep->end_point.name, in musb_g_rx()
932 csr, dma ? " (dma)" : "", request); in musb_g_rx()
946 dev_dbg(musb->controller, "%s iso overrun on %p\n", musb_ep->name, request); in musb_g_rx()
947 if (request->status == -EINPROGRESS) in musb_g_rx()
948 request->status = -EOVERFLOW; in musb_g_rx()
952 dev_dbg(musb->controller, "%s, incomprx\n", musb_ep->end_point.name); in musb_g_rx()
955 if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { in musb_g_rx()
956 /* "should not happen"; likely RXPKTRDY pending for DMA */ in musb_g_rx()
957 dev_dbg(musb->controller, "%s busy, csr %04x\n", in musb_g_rx()
958 musb_ep->end_point.name, csr); in musb_g_rx()
962 if (dma && (csr & MUSB_RXCSR_DMAENAB)) { in musb_g_rx()
969 request->actual += musb_ep->dma->actual_len; in musb_g_rx()
971 dev_dbg(musb->controller, "RXCSR%d %04x, dma off, %04x, len %zu, req %p\n", in musb_g_rx()
974 musb_ep->dma->actual_len, request); in musb_g_rx()
979 if ((dma->desired_mode == 0 && !hw_ep->rx_double_buffered) in musb_g_rx()
980 || (dma->actual_len in musb_g_rx()
981 & (musb_ep->packet_sz - 1))) { in musb_g_rx()
988 if ((request->actual < request->length) in musb_g_rx()
989 && (musb_ep->dma->actual_len in musb_g_rx()
990 == musb_ep->packet_sz)) { in musb_g_rx()
996 hw_ep->rx_double_buffered) in musb_g_rx()
1024 /* ------------------------------------------------------------ */
1038 int status = -EINVAL; in musb_gadget_enable()
1041 return -EINVAL; in musb_gadget_enable()
1044 hw_ep = musb_ep->hw_ep; in musb_gadget_enable()
1045 regs = hw_ep->regs; in musb_gadget_enable()
1046 musb = musb_ep->musb; in musb_gadget_enable()
1047 mbase = musb->mregs; in musb_gadget_enable()
1048 epnum = musb_ep->current_epnum; in musb_gadget_enable()
1050 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_enable()
1052 if (musb_ep->desc) { in musb_gadget_enable()
1053 status = -EBUSY; in musb_gadget_enable()
1056 musb_ep->type = usb_endpoint_type(desc); in musb_gadget_enable()
1068 ok = musb->hb_iso_tx; in musb_gadget_enable()
1070 ok = musb->hb_iso_rx; in musb_gadget_enable()
1073 dev_dbg(musb->controller, "no support for high bandwidth ISO\n"); in musb_gadget_enable()
1076 musb_ep->hb_mult = (tmp >> 11) & 3; in musb_gadget_enable()
1078 musb_ep->hb_mult = 0; in musb_gadget_enable()
1081 musb_ep->packet_sz = tmp & 0x7ff; in musb_gadget_enable()
1082 tmp = musb_ep->packet_sz * (musb_ep->hb_mult + 1); in musb_gadget_enable()
1091 if (hw_ep->is_shared_fifo) in musb_gadget_enable()
1092 musb_ep->is_in = 1; in musb_gadget_enable()
1093 if (!musb_ep->is_in) in musb_gadget_enable()
1096 if (tmp > hw_ep->max_packet_sz_tx) { in musb_gadget_enable()
1097 dev_dbg(musb->controller, "packet size beyond hardware FIFO size\n"); in musb_gadget_enable()
1110 if (musb->double_buffer_not_ok) in musb_gadget_enable()
1111 musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx); in musb_gadget_enable()
1113 musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz in musb_gadget_enable()
1114 | (musb_ep->hb_mult << 11)); in musb_gadget_enable()
1120 if (musb_ep->type == USB_ENDPOINT_XFER_ISOC) in musb_gadget_enable()
1131 if (hw_ep->is_shared_fifo) in musb_gadget_enable()
1132 musb_ep->is_in = 0; in musb_gadget_enable()
1133 if (musb_ep->is_in) in musb_gadget_enable()
1136 if (tmp > hw_ep->max_packet_sz_rx) { in musb_gadget_enable()
1137 dev_dbg(musb->controller, "packet size beyond hardware FIFO size\n"); in musb_gadget_enable()
1150 if (musb->double_buffer_not_ok) in musb_gadget_enable()
1151 musb_writew(regs, MUSB_RXMAXP, hw_ep->max_packet_sz_tx); in musb_gadget_enable()
1153 musb_writew(regs, MUSB_RXMAXP, musb_ep->packet_sz in musb_gadget_enable()
1154 | (musb_ep->hb_mult << 11)); in musb_gadget_enable()
1156 /* force shared fifo to OUT-only mode */ in musb_gadget_enable()
1157 if (hw_ep->is_shared_fifo) { in musb_gadget_enable()
1164 if (musb_ep->type == USB_ENDPOINT_XFER_ISOC) in musb_gadget_enable()
1166 else if (musb_ep->type == USB_ENDPOINT_XFER_INT) in musb_gadget_enable()
1174 /* NOTE: all the I/O code _should_ work fine without DMA, in case in musb_gadget_enable()
1177 if (is_dma_capable() && musb->dma_controller) { in musb_gadget_enable()
1178 struct dma_controller *c = musb->dma_controller; in musb_gadget_enable()
1180 musb_ep->dma = c->channel_alloc(c, hw_ep, in musb_gadget_enable()
1181 (desc->bEndpointAddress & USB_DIR_IN)); in musb_gadget_enable()
1183 musb_ep->dma = NULL; in musb_gadget_enable()
1185 musb_ep->desc = desc; in musb_gadget_enable()
1186 musb_ep->busy = 0; in musb_gadget_enable()
1187 musb_ep->wedged = 0; in musb_gadget_enable()
1191 musb_driver_name, musb_ep->end_point.name, in musb_gadget_enable()
1192 ({ char *s; switch (musb_ep->type) { in musb_gadget_enable()
1197 musb_ep->is_in ? "IN" : "OUT", in musb_gadget_enable()
1198 musb_ep->dma ? "dma, " : "", in musb_gadget_enable()
1199 musb_ep->packet_sz); in musb_gadget_enable()
1201 schedule_work(&musb->irq_work); in musb_gadget_enable()
1204 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_enable()
1221 musb = musb_ep->musb; in musb_gadget_disable()
1222 epnum = musb_ep->current_epnum; in musb_gadget_disable()
1223 epio = musb->endpoints[epnum].regs; in musb_gadget_disable()
1225 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_disable()
1226 musb_ep_select(musb->mregs, epnum); in musb_gadget_disable()
1229 if (musb_ep->is_in) { in musb_gadget_disable()
1230 u16 int_txe = musb_readw(musb->mregs, MUSB_INTRTXE); in musb_gadget_disable()
1232 musb_writew(musb->mregs, MUSB_INTRTXE, int_txe); in musb_gadget_disable()
1235 u16 int_rxe = musb_readw(musb->mregs, MUSB_INTRRXE); in musb_gadget_disable()
1237 musb_writew(musb->mregs, MUSB_INTRRXE, int_rxe); in musb_gadget_disable()
1241 musb_ep->desc = NULL; in musb_gadget_disable()
1243 musb_ep->end_point.desc = NULL; in musb_gadget_disable()
1246 /* abort all pending DMA and requests */ in musb_gadget_disable()
1247 nuke(musb_ep, -ESHUTDOWN); in musb_gadget_disable()
1249 schedule_work(&musb->irq_work); in musb_gadget_disable()
1251 spin_unlock_irqrestore(&(musb->lock), flags); in musb_gadget_disable()
1253 dev_dbg(musb->controller, "%s\n", musb_ep->end_point.name); in musb_gadget_disable()
1265 struct musb *musb = musb_ep->musb; in musb_alloc_request()
1270 dev_dbg(musb->controller, "not enough memory\n"); in musb_alloc_request()
1274 request->request.dma = DMA_ADDR_INVALID; in musb_alloc_request()
1275 request->epnum = musb_ep->current_epnum; in musb_alloc_request()
1276 request->ep = musb_ep; in musb_alloc_request()
1278 return &request->request; in musb_alloc_request()
1296 dma_addr_t dma; member
1300 * Context: controller locked, IRQs blocked.
1304 dev_dbg(musb->controller, "<== %s request %p len %u on hw_ep%d\n", in musb_ep_restart()
1305 req->tx ? "TX/IN" : "RX/OUT", in musb_ep_restart()
1306 &req->request, req->request.length, req->epnum); in musb_ep_restart()
1308 musb_ep_select(musb->mregs, req->epnum); in musb_ep_restart()
1309 if (req->tx) in musb_ep_restart()
1325 return -EINVAL; in musb_gadget_queue()
1326 if (!req->buf) in musb_gadget_queue()
1327 return -ENODATA; in musb_gadget_queue()
1330 musb = musb_ep->musb; in musb_gadget_queue()
1333 request->musb = musb; in musb_gadget_queue()
1335 if (request->ep != musb_ep) in musb_gadget_queue()
1336 return -EINVAL; in musb_gadget_queue()
1338 dev_dbg(musb->controller, "<== to %s request=%p\n", ep->name, req); in musb_gadget_queue()
1341 request->request.actual = 0; in musb_gadget_queue()
1342 request->request.status = -EINPROGRESS; in musb_gadget_queue()
1343 request->epnum = musb_ep->current_epnum; in musb_gadget_queue()
1344 request->tx = musb_ep->is_in; in musb_gadget_queue()
1348 spin_lock_irqsave(&musb->lock, lockflags); in musb_gadget_queue()
1351 if (!musb_ep->desc) { in musb_gadget_queue()
1352 dev_dbg(musb->controller, "req %p queued to %s while ep %s\n", in musb_gadget_queue()
1353 req, ep->name, "disabled"); in musb_gadget_queue()
1354 status = -ESHUTDOWN; in musb_gadget_queue()
1359 list_add_tail(&request->list, &musb_ep->req_list); in musb_gadget_queue()
1362 if (!musb_ep->busy && &request->list == musb_ep->req_list.next) in musb_gadget_queue()
1366 spin_unlock_irqrestore(&musb->lock, lockflags); in musb_gadget_queue()
1377 struct musb *musb = musb_ep->musb; in musb_gadget_dequeue()
1379 if (!ep || !request || to_musb_request(request)->ep != musb_ep) in musb_gadget_dequeue()
1380 return -EINVAL; in musb_gadget_dequeue()
1382 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_dequeue()
1384 list_for_each_entry(r, &musb_ep->req_list, list) { in musb_gadget_dequeue()
1389 dev_dbg(musb->controller, "request %p not queued to %s\n", request, ep->name); in musb_gadget_dequeue()
1390 status = -EINVAL; in musb_gadget_dequeue()
1395 if (musb_ep->req_list.next != &req->list || musb_ep->busy) in musb_gadget_dequeue()
1396 musb_g_giveback(musb_ep, request, -ECONNRESET); in musb_gadget_dequeue()
1398 /* ... else abort the dma transfer ... */ in musb_gadget_dequeue()
1399 else if (is_dma_capable() && musb_ep->dma) { in musb_gadget_dequeue()
1400 struct dma_controller *c = musb->dma_controller; in musb_gadget_dequeue()
1402 musb_ep_select(musb->mregs, musb_ep->current_epnum); in musb_gadget_dequeue()
1403 if (c->channel_abort) in musb_gadget_dequeue()
1404 status = c->channel_abort(musb_ep->dma); in musb_gadget_dequeue()
1406 status = -EBUSY; in musb_gadget_dequeue()
1408 musb_g_giveback(musb_ep, request, -ECONNRESET); in musb_gadget_dequeue()
1411 * we leave counting of in-flight packets imprecise. in musb_gadget_dequeue()
1413 musb_g_giveback(musb_ep, request, -ECONNRESET); in musb_gadget_dequeue()
1417 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_dequeue()
1430 u8 epnum = musb_ep->current_epnum; in musb_gadget_set_halt()
1431 struct musb *musb = musb_ep->musb; in musb_gadget_set_halt()
1432 void __iomem *epio = musb->endpoints[epnum].regs; in musb_gadget_set_halt()
1440 return -EINVAL; in musb_gadget_set_halt()
1441 mbase = musb->mregs; in musb_gadget_set_halt()
1443 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_set_halt()
1445 if ((USB_ENDPOINT_XFER_ISOC == musb_ep->type)) { in musb_gadget_set_halt()
1446 status = -EINVAL; in musb_gadget_set_halt()
1455 dev_dbg(musb->controller, "request in progress, cannot halt %s\n", in musb_gadget_set_halt()
1456 ep->name); in musb_gadget_set_halt()
1457 status = -EAGAIN; in musb_gadget_set_halt()
1460 /* Cannot portably stall with non-empty FIFO */ in musb_gadget_set_halt()
1461 if (musb_ep->is_in) { in musb_gadget_set_halt()
1464 dev_dbg(musb->controller, "FIFO busy, cannot halt %s\n", ep->name); in musb_gadget_set_halt()
1465 status = -EAGAIN; in musb_gadget_set_halt()
1470 musb_ep->wedged = 0; in musb_gadget_set_halt()
1473 dev_dbg(musb->controller, "%s: %s stall\n", ep->name, value ? "set" : "clear"); in musb_gadget_set_halt()
1474 if (musb_ep->is_in) { in musb_gadget_set_halt()
1499 if (!musb_ep->busy && !value && request) { in musb_gadget_set_halt()
1500 dev_dbg(musb->controller, "restarting the request\n"); in musb_gadget_set_halt()
1505 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_set_halt()
1518 return -EINVAL; in musb_gadget_set_wedge()
1520 musb_ep->wedged = 1; in musb_gadget_set_wedge()
1529 void __iomem *epio = musb_ep->hw_ep->regs; in musb_gadget_fifo_status()
1530 int retval = -EINVAL; in musb_gadget_fifo_status()
1532 if (musb_ep->desc && !musb_ep->is_in) { in musb_gadget_fifo_status()
1533 struct musb *musb = musb_ep->musb; in musb_gadget_fifo_status()
1534 int epnum = musb_ep->current_epnum; in musb_gadget_fifo_status()
1535 void __iomem *mbase = musb->mregs; in musb_gadget_fifo_status()
1538 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_fifo_status()
1544 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_fifo_status()
1552 struct musb *musb = musb_ep->musb; in musb_gadget_fifo_flush()
1553 u8 epnum = musb_ep->current_epnum; in musb_gadget_fifo_flush()
1554 void __iomem *epio = musb->endpoints[epnum].regs; in musb_gadget_fifo_flush()
1559 mbase = musb->mregs; in musb_gadget_fifo_flush()
1561 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_fifo_flush()
1568 if (musb_ep->is_in) { in musb_gadget_fifo_flush()
1573 * Setting both TXPKTRDY and FLUSHFIFO makes controller in musb_gadget_fifo_flush()
1589 /* re-enable interrupt */ in musb_gadget_fifo_flush()
1591 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_fifo_flush()
1609 /* ----------------------------------------------------------------------- */
1615 return (int)musb_readw(musb->mregs, MUSB_FRAME); in musb_gadget_get_frame()
1622 void __iomem *mregs = musb->mregs; in musb_gadget_wakeup()
1624 int status = -EINVAL; in musb_gadget_wakeup()
1628 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_wakeup()
1630 switch (musb->xceiv->state) { in musb_gadget_wakeup()
1636 if (musb->may_wakeup && musb->is_suspended) in musb_gadget_wakeup()
1642 dev_dbg(musb->controller, "Sending SRP: devctl: %02x\n", devctl); in musb_gadget_wakeup()
1649 if (retries-- < 1) in musb_gadget_wakeup()
1655 if (retries-- < 1) in musb_gadget_wakeup()
1659 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_wakeup()
1660 otg_start_srp(musb->xceiv->otg); in musb_gadget_wakeup()
1661 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_wakeup()
1670 dev_dbg(musb->controller, "Unhandled wake: %s\n", in musb_gadget_wakeup()
1671 otg_state_string(musb->xceiv->state)); in musb_gadget_wakeup()
1680 dev_dbg(musb->controller, "issue wakeup\n"); in musb_gadget_wakeup()
1689 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_wakeup()
1701 musb->is_self_powered = !!is_selfpowered; in musb_gadget_set_self_powered()
1709 power = musb_readb(musb->mregs, MUSB_POWER); in musb_pullup()
1717 dev_dbg(musb->controller, "gadget D+ pullup %s\n", in musb_pullup()
1719 musb_writeb(musb->mregs, MUSB_POWER, power); in musb_pullup()
1725 dev_dbg(musb->controller, "<= %s =>\n", __func__);
1732 return -EINVAL;
1741 if (!musb->xceiv->set_power) in musb_gadget_vbus_draw()
1742 return -EOPNOTSUPP; in musb_gadget_vbus_draw()
1743 return usb_phy_set_power(musb->xceiv, mA); in musb_gadget_vbus_draw()
1756 pm_runtime_get_sync(musb->controller); in musb_gadget_pullup()
1759 * not pullup unless the B-session is active. in musb_gadget_pullup()
1761 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_pullup()
1762 if (is_on != musb->softconnect) { in musb_gadget_pullup()
1763 musb->softconnect = is_on; in musb_gadget_pullup()
1766 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_pullup()
1768 pm_runtime_put(musb->controller); in musb_gadget_pullup()
1804 /* ----------------------------------------------------------------------- */
1825 struct musb_hw_ep *hw_ep = musb->endpoints + epnum; in init_peripheral_ep()
1829 ep->current_epnum = epnum; in init_peripheral_ep()
1830 ep->musb = musb; in init_peripheral_ep()
1831 ep->hw_ep = hw_ep; in init_peripheral_ep()
1832 ep->is_in = is_in; in init_peripheral_ep()
1834 INIT_LIST_HEAD(&ep->req_list); in init_peripheral_ep()
1836 sprintf(ep->name, "ep%d%s", epnum, in init_peripheral_ep()
1837 (!epnum || hw_ep->is_shared_fifo) ? "" : ( in init_peripheral_ep()
1839 ep->end_point.name = ep->name; in init_peripheral_ep()
1840 INIT_LIST_HEAD(&ep->end_point.ep_list); in init_peripheral_ep()
1842 ep->end_point.maxpacket = 64; in init_peripheral_ep()
1843 ep->end_point.ops = &musb_g_ep0_ops; in init_peripheral_ep()
1844 musb->g.ep0 = &ep->end_point; in init_peripheral_ep()
1847 ep->end_point.maxpacket = hw_ep->max_packet_sz_tx; in init_peripheral_ep()
1849 ep->end_point.maxpacket = hw_ep->max_packet_sz_rx; in init_peripheral_ep()
1850 ep->end_point.ops = &musb_ep_ops; in init_peripheral_ep()
1851 list_add_tail(&ep->end_point.ep_list, &musb->g.ep_list); in init_peripheral_ep()
1866 INIT_LIST_HEAD(&(musb->g.ep_list)); in musb_g_init_endpoints()
1868 for (epnum = 0, hw_ep = musb->endpoints; in musb_g_init_endpoints()
1869 epnum < musb->nr_endpoints; in musb_g_init_endpoints()
1871 if (hw_ep->is_shared_fifo /* || !epnum */) { in musb_g_init_endpoints()
1872 init_peripheral_ep(musb, &hw_ep->ep_in, epnum, 0); in musb_g_init_endpoints()
1875 if (hw_ep->max_packet_sz_tx) { in musb_g_init_endpoints()
1876 init_peripheral_ep(musb, &hw_ep->ep_in, in musb_g_init_endpoints()
1880 if (hw_ep->max_packet_sz_rx) { in musb_g_init_endpoints()
1881 init_peripheral_ep(musb, &hw_ep->ep_out, in musb_g_init_endpoints()
1901 musb->g.ops = &musb_gadget_operations; in musb_gadget_setup()
1903 musb->g.max_speed = USB_SPEED_HIGH; in musb_gadget_setup()
1905 musb->g.speed = USB_SPEED_UNKNOWN; in musb_gadget_setup()
1908 /* this "gadget" abstracts/virtualizes the controller */ in musb_gadget_setup()
1909 dev_set_name(&musb->g.dev, "gadget"); in musb_gadget_setup()
1910 musb->g.dev.parent = musb->controller; in musb_gadget_setup()
1911 musb->g.dev.dma_mask = musb->controller->dma_mask; in musb_gadget_setup()
1912 musb->g.dev.release = musb_gadget_release; in musb_gadget_setup()
1914 musb->g.name = musb_driver_name; in musb_gadget_setup()
1918 musb->g.is_otg = 1; in musb_gadget_setup()
1923 musb->is_active = 0; in musb_gadget_setup()
1927 status = device_register(&musb->g.dev); in musb_gadget_setup()
1929 put_device(&musb->g.dev); in musb_gadget_setup()
1932 status = usb_add_gadget_udc(musb->controller, &musb->g); in musb_gadget_setup()
1940 musb->g.dev.parent = NULL; in musb_gadget_setup()
1941 device_unregister(&musb->g.dev); in musb_gadget_setup()
1949 usb_del_gadget_udc(&musb->g); in musb_gadget_cleanup()
1950 if (musb->g.dev.parent) in musb_gadget_cleanup()
1951 device_unregister(&musb->g.dev); in musb_gadget_cleanup()
1957 * registering themselves with the controller.
1959 * -EINVAL something went wrong (not driver)
1960 * -EBUSY another gadget is already using the controller
1961 * -ENOMEM no memory to perform the operation
1976 struct usb_otg *otg = musb->xceiv->otg; in musb_gadget_start()
1979 int retval = -EINVAL; in musb_gadget_start()
1982 if (driver->max_speed < USB_SPEED_HIGH) in musb_gadget_start()
1986 pm_runtime_get_sync(musb->controller); in musb_gadget_start()
1989 dev_dbg(musb->controller, "registering driver %s\n", driver->function); in musb_gadget_start()
1992 musb->softconnect = 0; in musb_gadget_start()
1993 musb->gadget_driver = driver; in musb_gadget_start()
1995 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_start()
1996 musb->is_active = 1; in musb_gadget_start()
1999 otg_set_peripheral(otg, &musb->g); in musb_gadget_start()
2000 musb->xceiv->state = OTG_STATE_B_IDLE; in musb_gadget_start()
2013 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_start()
2019 dev_dbg(musb->controller, "OTG startup...\n"); in musb_gadget_start()
2027 dev_dbg(musb->controller, "add_hcd failed, %d\n", retval); in musb_gadget_start()
2031 if ((musb->xceiv->last_event == USB_EVENT_ID) in musb_gadget_start()
2032 && otg->set_vbus) in musb_gadget_start()
2035 hcd->self.uses_pio_for_control = 1; in musb_gadget_start()
2037 if (musb->xceiv->last_event == USB_EVENT_NONE) in musb_gadget_start()
2038 pm_runtime_put(musb->controller); in musb_gadget_start()
2059 if (musb->g.speed == USB_SPEED_UNKNOWN) in stop_activity()
2062 musb->g.speed = USB_SPEED_UNKNOWN; in stop_activity()
2065 if (musb->softconnect) { in stop_activity()
2066 musb->softconnect = 0; in stop_activity()
2075 for (i = 0, hw_ep = musb->endpoints; in stop_activity()
2076 i < musb->nr_endpoints; in stop_activity()
2078 musb_ep_select(musb->mregs, i); in stop_activity()
2079 if (hw_ep->is_shared_fifo /* || !epnum */) { in stop_activity()
2080 nuke(&hw_ep->ep_in, -ESHUTDOWN); in stop_activity()
2082 if (hw_ep->max_packet_sz_tx) in stop_activity()
2083 nuke(&hw_ep->ep_in, -ESHUTDOWN); in stop_activity()
2084 if (hw_ep->max_packet_sz_rx) in stop_activity()
2085 nuke(&hw_ep->ep_out, -ESHUTDOWN); in stop_activity()
2093 * unregistering themselves from the controller.
2103 if (musb->xceiv->last_event == USB_EVENT_NONE) in musb_gadget_stop()
2104 pm_runtime_get_sync(musb->controller); in musb_gadget_stop()
2111 spin_lock_irqsave(&musb->lock, flags); in musb_gadget_stop()
2115 (void) musb_gadget_vbus_draw(&musb->g, 0); in musb_gadget_stop()
2117 musb->xceiv->state = OTG_STATE_UNDEFINED; in musb_gadget_stop()
2119 otg_set_peripheral(musb->xceiv->otg, NULL); in musb_gadget_stop()
2121 dev_dbg(musb->controller, "unregistering driver %s\n", driver->function); in musb_gadget_stop()
2123 musb->is_active = 0; in musb_gadget_stop()
2125 spin_unlock_irqrestore(&musb->lock, flags); in musb_gadget_stop()
2138 pm_runtime_put(musb->controller); in musb_gadget_stop()
2144 /* ----------------------------------------------------------------------- */
2151 musb->is_suspended = 0; in musb_g_resume()
2152 switch (musb->xceiv->state) { in musb_g_resume()
2157 musb->is_active = 1; in musb_g_resume()
2158 if (musb->gadget_driver && musb->gadget_driver->resume) { in musb_g_resume()
2159 spin_unlock(&musb->lock); in musb_g_resume()
2160 musb->gadget_driver->resume(&musb->g); in musb_g_resume()
2161 spin_lock(&musb->lock); in musb_g_resume()
2166 otg_state_string(musb->xceiv->state)); in musb_g_resume()
2177 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); in musb_g_suspend()
2178 dev_dbg(musb->controller, "devctl %02x\n", devctl); in musb_g_suspend()
2180 switch (musb->xceiv->state) { in musb_g_suspend()
2183 musb->xceiv->state = OTG_STATE_B_PERIPHERAL; in musb_g_suspend()
2186 musb->is_suspended = 1; in musb_g_suspend()
2187 if (musb->gadget_driver && musb->gadget_driver->suspend) { in musb_g_suspend()
2188 spin_unlock(&musb->lock); in musb_g_suspend()
2189 musb->gadget_driver->suspend(&musb->g); in musb_g_suspend()
2190 spin_lock(&musb->lock); in musb_g_suspend()
2198 otg_state_string(musb->xceiv->state)); in musb_g_suspend()
2206 musb_gadget_wakeup(&musb->g); in musb_g_wakeup()
2212 void __iomem *mregs = musb->mregs; in musb_g_disconnect()
2215 dev_dbg(musb->controller, "devctl %02x\n", devctl); in musb_g_disconnect()
2220 /* don't draw vbus until new b-default session */ in musb_g_disconnect()
2221 (void) musb_gadget_vbus_draw(&musb->g, 0); in musb_g_disconnect()
2223 musb->g.speed = USB_SPEED_UNKNOWN; in musb_g_disconnect()
2224 if (musb->gadget_driver && musb->gadget_driver->disconnect) { in musb_g_disconnect()
2225 spin_unlock(&musb->lock); in musb_g_disconnect()
2226 musb->gadget_driver->disconnect(&musb->g); in musb_g_disconnect()
2227 spin_lock(&musb->lock); in musb_g_disconnect()
2231 switch (musb->xceiv->state) { in musb_g_disconnect()
2233 dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n", in musb_g_disconnect()
2234 otg_state_string(musb->xceiv->state)); in musb_g_disconnect()
2235 musb->xceiv->state = OTG_STATE_A_IDLE; in musb_g_disconnect()
2239 musb->xceiv->state = OTG_STATE_A_WAIT_BCON; in musb_g_disconnect()
2246 musb->xceiv->state = OTG_STATE_B_IDLE; in musb_g_disconnect()
2253 musb->is_active = 0; in musb_g_disconnect()
2257 __releases(musb->lock) in musb_g_reset()
2258 __acquires(musb->lock) in musb_g_reset()
2260 void __iomem *mbase = musb->mregs; in musb_g_reset()
2265 dev_dbg(musb->controller, "<== %s addr=%x driver '%s'\n", in musb_g_reset()
2267 ? "B-Device" : "A-Device", in musb_g_reset()
2269 musb->gadget_driver in musb_g_reset()
2270 ? musb->gadget_driver->driver.name in musb_g_reset()
2276 if (musb->g.speed != USB_SPEED_UNKNOWN) in musb_g_reset()
2286 musb->g.speed = (power & MUSB_POWER_HSMODE) in musb_g_reset()
2290 musb->is_active = 1; in musb_g_reset()
2291 musb->is_suspended = 0; in musb_g_reset()
2293 musb->address = 0; in musb_g_reset()
2294 musb->ep0_state = MUSB_EP0_STAGE_SETUP; in musb_g_reset()
2296 musb->may_wakeup = 0; in musb_g_reset()
2297 musb->g.b_hnp_enable = 0; in musb_g_reset()
2298 musb->g.a_alt_hnp_support = 0; in musb_g_reset()
2299 musb->g.a_hnp_support = 0; in musb_g_reset()
2302 /* Normal reset, as B-Device; in musb_g_reset()
2303 * or else after HNP, as A-Device in musb_g_reset()
2306 musb->xceiv->state = OTG_STATE_B_PERIPHERAL; in musb_g_reset()
2307 musb->g.is_a_peripheral = 0; in musb_g_reset()
2309 musb->xceiv->state = OTG_STATE_A_PERIPHERAL; in musb_g_reset()
2310 musb->g.is_a_peripheral = 1; in musb_g_reset()
2315 (void) musb_gadget_vbus_draw(&musb->g, in musb_g_reset()