Lines Matching refs:qh

176 static void musb_ep_set_qh(struct musb_hw_ep *ep, int is_in, struct musb_qh *qh)  in musb_ep_set_qh()  argument
179 ep->in_qh = qh; in musb_ep_set_qh()
181 ep->out_qh = qh; in musb_ep_set_qh()
196 musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) in musb_start_urb() argument
200 struct urb *urb = next_urb(qh); in musb_start_urb()
203 struct musb_hw_ep *hw_ep = qh->hw_ep; in musb_start_urb()
207 qh->offset = 0; in musb_start_urb()
208 qh->segsize = 0; in musb_start_urb()
211 switch (qh->type) { in musb_start_urb()
220 qh->iso_idx = 0; in musb_start_urb()
221 qh->frame = 0; in musb_start_urb()
234 musb_ep_set_qh(hw_ep, is_in, qh); in musb_start_urb()
242 switch (qh->type) { in musb_start_urb()
253 qh->frame = 0; in musb_start_urb()
256 qh->frame = urb->start_frame; in musb_start_urb()
299 struct musb_qh *qh = musb_ep_get_qh(hw_ep, is_in); in musb_advance_schedule() local
300 struct musb_hw_ep *ep = qh->hw_ep; in musb_advance_schedule()
301 int ready = qh->is_ready; in musb_advance_schedule()
308 switch (qh->type) { in musb_advance_schedule()
311 toggle = musb->io.get_toggle(qh, !is_in); in musb_advance_schedule()
312 usb_settoggle(urb->dev, qh->epnum, !is_in, toggle ? 1 : 0); in musb_advance_schedule()
320 qh->is_ready = 0; in musb_advance_schedule()
322 qh->is_ready = ready; in musb_advance_schedule()
328 qh = musb_ep_get_qh(hw_ep, is_in); in musb_advance_schedule()
333 if (qh && list_empty(&qh->hep->urb_list)) { in musb_advance_schedule()
353 qh->hep->hcpriv = NULL; in musb_advance_schedule()
355 switch (qh->type) { in musb_advance_schedule()
362 if (qh->mux == 1) { in musb_advance_schedule()
363 head = qh->ring.prev; in musb_advance_schedule()
364 list_del(&qh->ring); in musb_advance_schedule()
365 kfree(qh); in musb_advance_schedule()
366 qh = first_qh(head); in musb_advance_schedule()
377 kfree(qh); in musb_advance_schedule()
378 qh = NULL; in musb_advance_schedule()
383 if (qh != NULL && qh->is_ready) { in musb_advance_schedule()
385 hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); in musb_advance_schedule()
386 musb_start_urb(musb, is_in, qh); in musb_advance_schedule()
423 struct musb_qh *qh = hw_ep->in_qh; in musb_host_packet_rx() local
430 urb->transfer_buffer, qh->offset, in musb_host_packet_rx()
443 d = urb->iso_frame_desc + qh->iso_idx; in musb_host_packet_rx()
461 done = (++qh->iso_idx >= urb->number_of_packets); in musb_host_packet_rx()
464 buf = buffer + qh->offset; in musb_host_packet_rx()
465 length = urb->transfer_buffer_length - qh->offset; in musb_host_packet_rx()
474 qh->offset += length; in musb_host_packet_rx()
478 || (rx_count < qh->maxpacket) in musb_host_packet_rx()
514 musb_rx_reinit(struct musb *musb, struct musb_qh *qh, u8 epnum) in musb_rx_reinit() argument
553 musb_write_rxfunaddr(musb, epnum, qh->addr_reg); in musb_rx_reinit()
554 musb_write_rxhubaddr(musb, epnum, qh->h_addr_reg); in musb_rx_reinit()
555 musb_write_rxhubport(musb, epnum, qh->h_port_reg); in musb_rx_reinit()
557 musb_writeb(musb->mregs, MUSB_FADDR, qh->addr_reg); in musb_rx_reinit()
560 musb_writeb(ep->regs, MUSB_RXTYPE, qh->type_reg); in musb_rx_reinit()
561 musb_writeb(ep->regs, MUSB_RXINTERVAL, qh->intv_reg); in musb_rx_reinit()
567 qh->maxpacket | ((qh->hb_mult - 1) << 11)); in musb_rx_reinit()
573 struct musb_qh *qh, in musb_tx_dma_set_mode_mentor() argument
578 u16 pkt_size = qh->maxpacket; in musb_tx_dma_set_mode_mentor()
598 if (qh->hb_mult == 1 || (qh->hb_mult > 1 && in musb_tx_dma_set_mode_mentor()
599 can_bulk_split(hw_ep->musb, qh->type))) in musb_tx_dma_set_mode_mentor()
626 struct musb_hw_ep *hw_ep, struct musb_qh *qh, in musb_tx_dma_program() argument
630 u16 pkt_size = qh->maxpacket; in musb_tx_dma_program()
634 musb_tx_dma_set_mode_mentor(hw_ep, qh, in musb_tx_dma_program()
641 qh->segsize = length; in musb_tx_dma_program()
679 struct musb_qh *qh = musb_ep_get_qh(hw_ep, !is_out); in musb_ep_program() local
680 u16 packet_sz = qh->maxpacket; in musb_ep_program()
688 qh->addr_reg, qh->epnum, is_out ? "out" : "in", in musb_ep_program()
689 qh->h_addr_reg, qh->h_port_reg, in musb_ep_program()
758 csr |= musb->io.set_toggle(qh, is_out, urb); in musb_ep_program()
772 musb_write_txfunaddr(musb, epnum, qh->addr_reg); in musb_ep_program()
773 musb_write_txhubaddr(musb, epnum, qh->h_addr_reg); in musb_ep_program()
774 musb_write_txhubport(musb, epnum, qh->h_port_reg); in musb_ep_program()
777 musb_writeb(mbase, MUSB_FADDR, qh->addr_reg); in musb_ep_program()
781 musb_writeb(epio, MUSB_TXTYPE, qh->type_reg); in musb_ep_program()
782 if (can_bulk_split(musb, qh->type)) { in musb_ep_program()
783 qh->hb_mult = hw_ep->max_packet_sz_tx in musb_ep_program()
786 | ((qh->hb_mult) - 1) << 11); in musb_ep_program()
789 qh->maxpacket | in musb_ep_program()
790 ((qh->hb_mult - 1) << 11)); in musb_ep_program()
792 musb_writeb(epio, MUSB_TXINTERVAL, qh->intv_reg); in musb_ep_program()
794 musb_writeb(epio, MUSB_NAKLIMIT0, qh->intv_reg); in musb_ep_program()
797 qh->type_reg); in musb_ep_program()
800 if (can_bulk_split(musb, qh->type)) in musb_ep_program()
807 hw_ep, qh, urb, offset, len)) in musb_ep_program()
812 qh->segsize = load_count; in musb_ep_program()
814 sg_miter_start(&qh->sg_miter, urb->sg, 1, in musb_ep_program()
817 if (!sg_miter_next(&qh->sg_miter)) { in musb_ep_program()
821 sg_miter_stop(&qh->sg_miter); in musb_ep_program()
824 buf = qh->sg_miter.addr + urb->sg->offset + in musb_ep_program()
827 qh->sg_miter.length); in musb_ep_program()
829 qh->sg_miter.consumed = load_count; in musb_ep_program()
830 sg_miter_stop(&qh->sg_miter); in musb_ep_program()
843 musb_rx_reinit(musb, qh, epnum); in musb_ep_program()
844 csr |= musb->io.set_toggle(qh, is_out, urb); in musb_ep_program()
846 if (qh->type == USB_ENDPOINT_XFER_INT) in musb_ep_program()
867 qh->segsize = len; in musb_ep_program()
881 qh->segsize); in musb_ep_program()
984 struct musb_qh *qh = hw_ep->in_qh; in musb_h_ep0_continue() local
998 if (len < qh->maxpacket) { in musb_h_ep0_continue()
1024 fifo_count = min_t(size_t, qh->maxpacket, in musb_h_ep0_continue()
1062 struct musb_qh *qh = hw_ep->in_qh; in musb_h_ep0_irq() local
1067 urb = next_urb(qh); in musb_h_ep0_irq()
1076 csr, qh, len, urb, musb->ep0_stage); in musb_h_ep0_irq()
1204 struct musb_qh *qh = hw_ep->out_qh; in musb_host_tx() local
1205 struct urb *urb = next_urb(qh); in musb_host_tx()
1241 if (USB_ENDPOINT_XFER_BULK == qh->type && qh->mux == 1 in musb_host_tx()
1362 length = qh->segsize; in musb_host_tx()
1363 qh->offset += length; in musb_host_tx()
1368 d = urb->iso_frame_desc + qh->iso_idx; in musb_host_tx()
1371 if (++qh->iso_idx >= urb->number_of_packets) { in musb_host_tx()
1378 } else if (dma && urb->transfer_buffer_length == qh->offset) { in musb_host_tx()
1382 if (qh->segsize < qh->maxpacket) in musb_host_tx()
1384 else if (qh->offset == urb->transfer_buffer_length in musb_host_tx()
1389 offset = qh->offset; in musb_host_tx()
1408 urb->actual_length = qh->offset; in musb_host_tx()
1412 if (musb_tx_dma_program(musb->dma_controller, hw_ep, qh, urb, in musb_host_tx()
1430 if (length > qh->maxpacket) in musb_host_tx()
1431 length = qh->maxpacket; in musb_host_tx()
1441 if (!sg_miter_next(&qh->sg_miter)) { in musb_host_tx()
1443 sg_miter_stop(&qh->sg_miter); in musb_host_tx()
1447 length = min_t(u32, length, qh->sg_miter.length); in musb_host_tx()
1448 musb_write_fifo(hw_ep, length, qh->sg_miter.addr); in musb_host_tx()
1449 qh->sg_miter.consumed = length; in musb_host_tx()
1450 sg_miter_stop(&qh->sg_miter); in musb_host_tx()
1455 qh->segsize = length; in musb_host_tx()
1466 struct musb_qh *qh, in musb_rx_dma_iso_cppi41() argument
1476 buf = (void *)urb->iso_frame_desc[qh->iso_idx].offset + in musb_rx_dma_iso_cppi41()
1479 length = urb->iso_frame_desc[qh->iso_idx].length; in musb_rx_dma_iso_cppi41()
1485 return dma->channel_program(channel, qh->maxpacket, 0, in musb_rx_dma_iso_cppi41()
1491 struct musb_qh *qh, in musb_rx_dma_iso_cppi41() argument
1537 struct musb_qh *qh, in musb_rx_dma_inventra_cppi41() argument
1552 d = urb->iso_frame_desc + qh->iso_idx; in musb_rx_dma_inventra_cppi41()
1561 if (++qh->iso_idx >= urb->number_of_packets) { in musb_rx_dma_inventra_cppi41()
1566 done = musb_rx_dma_iso_cppi41(dma, hw_ep, qh, in musb_rx_dma_inventra_cppi41()
1575 || channel->actual_len < qh->maxpacket in musb_rx_dma_inventra_cppi41()
1607 struct musb_qh *qh, in musb_rx_dma_in_inventra_cppi41() argument
1626 d = urb->iso_frame_desc + qh->iso_idx; in musb_rx_dma_in_inventra_cppi41()
1657 > qh->maxpacket) in musb_rx_dma_in_inventra_cppi41()
1678 if (qh->hb_mult == 1) in musb_rx_dma_in_inventra_cppi41()
1687 done = dma->channel_program(channel, qh->maxpacket, in musb_rx_dma_in_inventra_cppi41()
1707 struct musb_qh *qh, in musb_rx_dma_inventra_cppi41() argument
1716 struct musb_qh *qh, in musb_rx_dma_in_inventra_cppi41() argument
1735 struct musb_qh *qh = hw_ep->in_qh; in musb_host_rx() local
1747 urb = next_urb(qh); in musb_host_rx()
1793 if (USB_ENDPOINT_XFER_ISOC != qh->type) { in musb_host_rx()
1805 && qh->mux == 1 in musb_host_rx()
1887 done = musb_rx_dma_inventra_cppi41(c, hw_ep, qh, urb, xfer_len); in musb_host_rx()
1921 qh->offset, in musb_host_rx()
1924 if (musb_rx_dma_in_inventra_cppi41(c, hw_ep, qh, urb, in musb_host_rx()
1942 qh->use_sg = true; in musb_host_rx()
1943 sg_miter_start(&qh->sg_miter, urb->sg, 1, in musb_host_rx()
1947 if (qh->use_sg) { in musb_host_rx()
1948 if (!sg_miter_next(&qh->sg_miter)) { in musb_host_rx()
1950 sg_miter_stop(&qh->sg_miter); in musb_host_rx()
1955 urb->transfer_buffer = qh->sg_miter.addr; in musb_host_rx()
1957 qh->offset = 0x0; in musb_host_rx()
1963 qh->sg_miter.consumed = received_len; in musb_host_rx()
1964 sg_miter_stop(&qh->sg_miter); in musb_host_rx()
1975 qh->offset += xfer_len; in musb_host_rx()
1977 if (qh->use_sg) { in musb_host_rx()
1978 qh->use_sg = false; in musb_host_rx()
1995 struct musb_qh *qh, in musb_schedule() argument
2005 struct urb *urb = next_urb(qh); in musb_schedule()
2008 if (qh->type == USB_ENDPOINT_XFER_CONTROL) { in musb_schedule()
2041 diff -= (qh->maxpacket * qh->hb_mult); in musb_schedule()
2058 toggle = usb_gettoggle(urb->dev, qh->epnum, !is_in); in musb_schedule()
2061 if (!is_in && (qh->type == USB_ENDPOINT_XFER_BULK) && in musb_schedule()
2070 if (best_end < 0 && qh->type == USB_ENDPOINT_XFER_BULK) { in musb_schedule()
2084 if (qh->dev) in musb_schedule()
2085 qh->intv_reg = in musb_schedule()
2086 (USB_SPEED_HIGH == qh->dev->speed) ? 8 : 4; in musb_schedule()
2091 musb_ep_xfertype_string(qh->type), in musb_schedule()
2092 qh->hb_mult, qh->maxpacket); in musb_schedule()
2097 qh->mux = 0; in musb_schedule()
2099 musb_dbg(musb, "qh %p periodic slot %d", qh, best_end); in musb_schedule()
2103 list_add_tail(&qh->ring, head); in musb_schedule()
2104 qh->mux = 1; in musb_schedule()
2106 qh->hw_ep = hw_ep; in musb_schedule()
2107 qh->hep->hcpriv = qh; in musb_schedule()
2109 musb_start_urb(musb, is_in, qh); in musb_schedule()
2121 struct musb_qh *qh; in musb_urb_enqueue() local
2135 qh = ret ? NULL : hep->hcpriv; in musb_urb_enqueue()
2136 if (qh) in musb_urb_enqueue()
2137 urb->hcpriv = qh; in musb_urb_enqueue()
2148 if (qh || ret) in musb_urb_enqueue()
2157 qh = kzalloc(sizeof *qh, mem_flags); in musb_urb_enqueue()
2158 if (!qh) { in musb_urb_enqueue()
2165 qh->hep = hep; in musb_urb_enqueue()
2166 qh->dev = urb->dev; in musb_urb_enqueue()
2167 INIT_LIST_HEAD(&qh->ring); in musb_urb_enqueue()
2168 qh->is_ready = 1; in musb_urb_enqueue()
2170 qh->maxpacket = usb_endpoint_maxp(epd); in musb_urb_enqueue()
2171 qh->type = usb_endpoint_type(epd); in musb_urb_enqueue()
2177 qh->hb_mult = usb_endpoint_maxp_mult(epd); in musb_urb_enqueue()
2178 if (qh->hb_mult > 1) { in musb_urb_enqueue()
2179 int ok = (qh->type == USB_ENDPOINT_XFER_ISOC); in musb_urb_enqueue()
2187 musb_ep_xfertype_string(qh->type), in musb_urb_enqueue()
2188 qh->hb_mult, qh->maxpacket & 0x7ff); in musb_urb_enqueue()
2192 qh->maxpacket &= 0x7ff; in musb_urb_enqueue()
2195 qh->epnum = usb_endpoint_num(epd); in musb_urb_enqueue()
2198 qh->addr_reg = (u8) usb_pipedevice(urb->pipe); in musb_urb_enqueue()
2201 type_reg = (qh->type << 4) | qh->epnum; in musb_urb_enqueue()
2212 qh->type_reg = type_reg; in musb_urb_enqueue()
2215 switch (qh->type) { in musb_urb_enqueue()
2247 qh->intv_reg = interval; in musb_urb_enqueue()
2254 qh->h_addr_reg = (u8) parent->devnum; in musb_urb_enqueue()
2258 qh->h_port_reg = (u8) urb->dev->ttport; in musb_urb_enqueue()
2260 qh->h_addr_reg = in musb_urb_enqueue()
2263 qh->h_addr_reg |= 0x80; in musb_urb_enqueue()
2273 if (hep->hcpriv || !next_urb(qh)) { in musb_urb_enqueue()
2277 kfree(qh); in musb_urb_enqueue()
2278 qh = NULL; in musb_urb_enqueue()
2281 ret = musb_schedule(musb, qh, in musb_urb_enqueue()
2285 urb->hcpriv = qh; in musb_urb_enqueue()
2297 kfree(qh); in musb_urb_enqueue()
2308 static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh) in musb_cleanup_urb() argument
2310 struct musb_hw_ep *ep = qh->hw_ep; in musb_cleanup_urb()
2366 struct musb_qh *qh; in musb_urb_dequeue() local
2378 qh = urb->hcpriv; in musb_urb_dequeue()
2379 if (!qh) in musb_urb_dequeue()
2394 if (!qh->is_ready in musb_urb_dequeue()
2395 || urb->urb_list.prev != &qh->hep->urb_list in musb_urb_dequeue()
2396 || musb_ep_get_qh(qh->hw_ep, is_in) != qh) { in musb_urb_dequeue()
2397 int ready = qh->is_ready; in musb_urb_dequeue()
2399 qh->is_ready = 0; in musb_urb_dequeue()
2401 qh->is_ready = ready; in musb_urb_dequeue()
2406 if (ready && list_empty(&qh->hep->urb_list)) { in musb_urb_dequeue()
2407 musb_ep_set_qh(qh->hw_ep, is_in, NULL); in musb_urb_dequeue()
2408 qh->hep->hcpriv = NULL; in musb_urb_dequeue()
2409 list_del(&qh->ring); in musb_urb_dequeue()
2410 kfree(qh); in musb_urb_dequeue()
2413 ret = musb_cleanup_urb(urb, qh); in musb_urb_dequeue()
2426 struct musb_qh *qh; in musb_h_disable() local
2431 qh = hep->hcpriv; in musb_h_disable()
2432 if (qh == NULL) in musb_h_disable()
2438 qh->is_ready = 0; in musb_h_disable()
2439 if (musb_ep_get_qh(qh->hw_ep, is_in) == qh) { in musb_h_disable()
2440 urb = next_urb(qh); in musb_h_disable()
2447 musb_cleanup_urb(urb, qh); in musb_h_disable()
2453 urb = next_urb(qh); in musb_h_disable()
2455 musb_advance_schedule(musb, urb, qh->hw_ep, is_in); in musb_h_disable()
2463 musb_giveback(musb, next_urb(qh), -ESHUTDOWN); in musb_h_disable()
2466 list_del(&qh->ring); in musb_h_disable()
2467 kfree(qh); in musb_h_disable()