Lines Matching refs:pkt
22 void usbhs_pkt_init(struct usbhs_pkt *pkt) in usbhs_pkt_init() argument
24 INIT_LIST_HEAD(&pkt->node); in usbhs_pkt_init()
30 static int usbhsf_null_handle(struct usbhs_pkt *pkt, int *is_done) in usbhsf_null_handle() argument
32 struct usbhs_priv *priv = usbhs_pipe_to_priv(pkt->pipe); in usbhsf_null_handle()
45 void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, in usbhs_pkt_push() argument
47 struct usbhs_pkt *pkt), in usbhs_pkt_push() argument
67 list_move_tail(&pkt->node, &pipe->list); in usbhs_pkt_push()
74 pkt->pipe = pipe; in usbhs_pkt_push()
75 pkt->buf = buf; in usbhs_pkt_push()
76 pkt->handler = pipe->handler; in usbhs_pkt_push()
77 pkt->length = len; in usbhs_pkt_push()
78 pkt->zero = zero; in usbhs_pkt_push()
79 pkt->actual = 0; in usbhs_pkt_push()
80 pkt->done = done; in usbhs_pkt_push()
81 pkt->sequence = sequence; in usbhs_pkt_push()
87 static void __usbhsf_pkt_del(struct usbhs_pkt *pkt) in __usbhsf_pkt_del() argument
89 list_del_init(&pkt->node); in __usbhsf_pkt_del()
100 struct usbhs_pkt *pkt);
103 static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map);
106 struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt) in usbhs_pkt_pop() argument
117 if (!pkt) in usbhs_pkt_pop()
118 pkt = __usbhsf_pkt_get(pipe); in usbhs_pkt_pop()
120 if (pkt) { in usbhs_pkt_pop()
124 chan = usbhsf_dma_chan_get(fifo, pkt); in usbhs_pkt_pop()
127 usbhsf_dma_unmap(pkt); in usbhs_pkt_pop()
138 __usbhsf_pkt_del(pkt); in usbhs_pkt_pop()
147 return pkt; in usbhs_pkt_pop()
159 struct usbhs_pkt *pkt; in usbhsf_pkt_handler() local
161 int (*func)(struct usbhs_pkt *pkt, int *is_done); in usbhsf_pkt_handler()
169 pkt = __usbhsf_pkt_get(pipe); in usbhsf_pkt_handler()
170 if (!pkt) in usbhsf_pkt_handler()
175 func = pkt->handler->prepare; in usbhsf_pkt_handler()
178 func = pkt->handler->try_run; in usbhsf_pkt_handler()
181 func = pkt->handler->dma_done; in usbhsf_pkt_handler()
189 ret = func(pkt, &is_done); in usbhsf_pkt_handler()
192 __usbhsf_pkt_del(pkt); in usbhsf_pkt_handler()
199 pkt->done(priv, pkt); in usbhsf_pkt_handler()
355 static int usbhs_dcp_dir_switch_to_write(struct usbhs_pkt *pkt, int *is_done) in usbhs_dcp_dir_switch_to_write() argument
357 struct usbhs_pipe *pipe = pkt->pipe; in usbhs_dcp_dir_switch_to_write()
384 static int usbhs_dcp_dir_switch_to_read(struct usbhs_pkt *pkt, int *is_done) in usbhs_dcp_dir_switch_to_read() argument
386 struct usbhs_pipe *pipe = pkt->pipe; in usbhs_dcp_dir_switch_to_read()
412 static int usbhs_dcp_dir_switch_done(struct usbhs_pkt *pkt, int *is_done) in usbhs_dcp_dir_switch_done() argument
414 struct usbhs_pipe *pipe = pkt->pipe; in usbhs_dcp_dir_switch_done()
416 if (pkt->handler == &usbhs_dcp_status_stage_in_handler) in usbhs_dcp_dir_switch_done()
421 pkt->actual = pkt->length; in usbhs_dcp_dir_switch_done()
440 static int usbhsf_dcp_data_stage_try_push(struct usbhs_pkt *pkt, int *is_done) in usbhsf_dcp_data_stage_try_push() argument
442 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_dcp_data_stage_try_push()
449 pkt->handler = &usbhs_fifo_pio_push_handler; in usbhsf_dcp_data_stage_try_push()
451 return pkt->handler->prepare(pkt, is_done); in usbhsf_dcp_data_stage_try_push()
461 static int usbhsf_dcp_data_stage_prepare_pop(struct usbhs_pkt *pkt, in usbhsf_dcp_data_stage_prepare_pop() argument
464 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_dcp_data_stage_prepare_pop()
488 pkt->handler = &usbhs_fifo_pio_pop_handler; in usbhsf_dcp_data_stage_prepare_pop()
490 return pkt->handler->prepare(pkt, is_done); in usbhsf_dcp_data_stage_prepare_pop()
500 static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done) in usbhsf_pio_try_push() argument
502 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_pio_try_push()
513 usbhs_pipe_data_sequence(pipe, pkt->sequence); in usbhsf_pio_try_push()
514 pkt->sequence = -1; /* -1 sequence will be ignored */ in usbhsf_pio_try_push()
516 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length); in usbhsf_pio_try_push()
533 buf = pkt->buf + pkt->actual; in usbhsf_pio_try_push()
534 len = pkt->length - pkt->actual; in usbhsf_pio_try_push()
562 pkt->actual += total_len; in usbhsf_pio_try_push()
564 if (pkt->actual < pkt->length) in usbhsf_pio_try_push()
569 *is_done = !pkt->zero; /* send zero packet ? */ in usbhsf_pio_try_push()
583 pkt->length, pkt->actual, *is_done, pkt->zero); in usbhsf_pio_try_push()
602 static int usbhsf_pio_prepare_push(struct usbhs_pkt *pkt, int *is_done) in usbhsf_pio_prepare_push() argument
604 if (usbhs_pipe_is_running(pkt->pipe)) in usbhsf_pio_prepare_push()
607 return usbhsf_pio_try_push(pkt, is_done); in usbhsf_pio_prepare_push()
618 static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done) in usbhsf_prepare_pop() argument
620 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_prepare_pop()
633 usbhs_pipe_data_sequence(pipe, pkt->sequence); in usbhsf_prepare_pop()
634 pkt->sequence = -1; /* -1 sequence will be ignored */ in usbhsf_prepare_pop()
639 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length); in usbhsf_prepare_pop()
647 static int usbhsf_pio_try_pop(struct usbhs_pkt *pkt, int *is_done) in usbhsf_pio_try_pop() argument
649 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_pio_try_pop()
671 buf = pkt->buf + pkt->actual; in usbhsf_pio_try_pop()
672 len = pkt->length - pkt->actual; in usbhsf_pio_try_pop()
681 pkt->actual += total_len; in usbhsf_pio_try_pop()
683 if ((pkt->actual == pkt->length) || /* receive all data */ in usbhsf_pio_try_pop()
705 pkt->zero = 1; in usbhsf_pio_try_pop()
732 pkt->length, pkt->actual, *is_done, pkt->zero); in usbhsf_pio_try_pop()
748 static int usbhsf_ctrl_stage_end(struct usbhs_pkt *pkt, int *is_done) in usbhsf_ctrl_stage_end() argument
750 usbhs_dcp_control_transfer_done(pkt->pipe); in usbhsf_ctrl_stage_end()
766 struct usbhs_pkt *pkt) in usbhsf_dma_chan_get() argument
768 if (&usbhs_fifo_dma_push_handler == pkt->handler) in usbhsf_dma_chan_get()
771 if (&usbhs_fifo_dma_pop_handler == pkt->handler) in usbhsf_dma_chan_get()
778 struct usbhs_pkt *pkt) in usbhsf_get_dma_fifo() argument
784 if (usbhsf_dma_chan_get(fifo, pkt) && in usbhsf_get_dma_fifo()
803 static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map) in __usbhsf_dma_map_ctrl() argument
805 struct usbhs_pipe *pipe = pkt->pipe; in __usbhsf_dma_map_ctrl()
809 struct dma_chan *chan = usbhsf_dma_chan_get(fifo, pkt); in __usbhsf_dma_map_ctrl()
811 return info->dma_map_ctrl(chan->device->dev, pkt, map); in __usbhsf_dma_map_ctrl()
816 static void usbhsf_dma_xfer_preparing(struct usbhs_pkt *pkt) in usbhsf_dma_xfer_preparing() argument
818 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_dma_xfer_preparing()
831 chan = usbhsf_dma_chan_get(fifo, pkt); in usbhsf_dma_xfer_preparing()
834 desc = dmaengine_prep_slave_single(chan, pkt->dma + pkt->actual, in usbhsf_dma_xfer_preparing()
835 pkt->trans, dir, in usbhsf_dma_xfer_preparing()
841 desc->callback_param = pkt; in usbhsf_dma_xfer_preparing()
850 fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero); in usbhsf_dma_xfer_preparing()
853 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->trans); in usbhsf_dma_xfer_preparing()
861 struct usbhs_pkt *pkt = container_of(work, struct usbhs_pkt, work); in xfer_work() local
862 struct usbhs_pipe *pipe = pkt->pipe; in xfer_work()
867 usbhsf_dma_xfer_preparing(pkt); in xfer_work()
874 static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done) in usbhsf_dma_prepare_push() argument
876 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_dma_prepare_push()
879 int len = pkt->length - pkt->actual; in usbhsf_dma_prepare_push()
898 if ((uintptr_t)(pkt->buf + pkt->actual) & align_mask) in usbhsf_dma_prepare_push()
906 fifo = usbhsf_get_dma_fifo(priv, pkt); in usbhsf_dma_prepare_push()
914 if (usbhsf_dma_map(pkt) < 0) in usbhsf_dma_prepare_push()
917 pkt->trans = len; in usbhsf_dma_prepare_push()
922 usbhsf_dma_xfer_preparing(pkt); in usbhsf_dma_prepare_push()
924 INIT_WORK(&pkt->work, xfer_work); in usbhsf_dma_prepare_push()
925 schedule_work(&pkt->work); in usbhsf_dma_prepare_push()
936 pkt->handler = &usbhs_fifo_pio_push_handler; in usbhsf_dma_prepare_push()
938 return pkt->handler->prepare(pkt, is_done); in usbhsf_dma_prepare_push()
941 static int usbhsf_dma_push_done(struct usbhs_pkt *pkt, int *is_done) in usbhsf_dma_push_done() argument
943 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_dma_push_done()
944 int is_short = pkt->trans % usbhs_pipe_get_maxpacket(pipe); in usbhsf_dma_push_done()
946 pkt->actual += pkt->trans; in usbhsf_dma_push_done()
948 if (pkt->actual < pkt->length) in usbhsf_dma_push_done()
953 *is_done = !pkt->zero; /* send zero packet? */ in usbhsf_dma_push_done()
958 usbhsf_dma_unmap(pkt); in usbhsf_dma_push_done()
963 pkt->handler = &usbhs_fifo_pio_push_handler; in usbhsf_dma_push_done()
964 return pkt->handler->try_run(pkt, is_done); in usbhsf_dma_push_done()
979 static int usbhsf_dma_prepare_pop_with_rx_irq(struct usbhs_pkt *pkt, in usbhsf_dma_prepare_pop_with_rx_irq() argument
982 return usbhsf_prepare_pop(pkt, is_done); in usbhsf_dma_prepare_pop_with_rx_irq()
985 static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt, in usbhsf_dma_prepare_pop_with_usb_dmac() argument
988 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_dma_prepare_pop_with_usb_dmac()
997 if ((pkt->length < usbhs_get_dparam(priv, pio_dma_border)) || in usbhsf_dma_prepare_pop_with_usb_dmac()
1001 fifo = usbhsf_get_dma_fifo(priv, pkt); in usbhsf_dma_prepare_pop_with_usb_dmac()
1005 if ((uintptr_t)pkt->buf & (USBHS_USB_DMAC_XFER_SIZE - 1)) in usbhsf_dma_prepare_pop_with_usb_dmac()
1018 if (usbhsf_dma_map(pkt) < 0) in usbhsf_dma_prepare_pop_with_usb_dmac()
1030 pkt->trans = pkt->length; in usbhsf_dma_prepare_pop_with_usb_dmac()
1032 usbhsf_dma_xfer_preparing(pkt); in usbhsf_dma_prepare_pop_with_usb_dmac()
1043 pkt->handler = &usbhs_fifo_pio_pop_handler; in usbhsf_dma_prepare_pop_with_usb_dmac()
1046 return pkt->handler->prepare(pkt, is_done); in usbhsf_dma_prepare_pop_with_usb_dmac()
1049 static int usbhsf_dma_prepare_pop(struct usbhs_pkt *pkt, int *is_done) in usbhsf_dma_prepare_pop() argument
1051 struct usbhs_priv *priv = usbhs_pipe_to_priv(pkt->pipe); in usbhsf_dma_prepare_pop()
1054 return usbhsf_dma_prepare_pop_with_usb_dmac(pkt, is_done); in usbhsf_dma_prepare_pop()
1056 return usbhsf_dma_prepare_pop_with_rx_irq(pkt, is_done); in usbhsf_dma_prepare_pop()
1059 static int usbhsf_dma_try_pop_with_rx_irq(struct usbhs_pkt *pkt, int *is_done) in usbhsf_dma_try_pop_with_rx_irq() argument
1061 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_dma_try_pop_with_rx_irq()
1073 fifo = usbhsf_get_dma_fifo(priv, pkt); in usbhsf_dma_try_pop_with_rx_irq()
1077 if ((uintptr_t)(pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */ in usbhsf_dma_try_pop_with_rx_irq()
1086 len = min(pkt->length - pkt->actual, len); in usbhsf_dma_try_pop_with_rx_irq()
1097 if (usbhsf_dma_map(pkt) < 0) in usbhsf_dma_try_pop_with_rx_irq()
1109 pkt->trans = len; in usbhsf_dma_try_pop_with_rx_irq()
1111 INIT_WORK(&pkt->work, xfer_work); in usbhsf_dma_try_pop_with_rx_irq()
1112 schedule_work(&pkt->work); in usbhsf_dma_try_pop_with_rx_irq()
1123 pkt->handler = &usbhs_fifo_pio_pop_handler; in usbhsf_dma_try_pop_with_rx_irq()
1125 return pkt->handler->try_run(pkt, is_done); in usbhsf_dma_try_pop_with_rx_irq()
1128 static int usbhsf_dma_try_pop(struct usbhs_pkt *pkt, int *is_done) in usbhsf_dma_try_pop() argument
1130 struct usbhs_priv *priv = usbhs_pipe_to_priv(pkt->pipe); in usbhsf_dma_try_pop()
1134 return usbhsf_dma_try_pop_with_rx_irq(pkt, is_done); in usbhsf_dma_try_pop()
1137 static int usbhsf_dma_pop_done_with_rx_irq(struct usbhs_pkt *pkt, int *is_done) in usbhsf_dma_pop_done_with_rx_irq() argument
1139 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_dma_pop_done_with_rx_irq()
1143 usbhsf_dma_unmap(pkt); in usbhsf_dma_pop_done_with_rx_irq()
1146 pkt->actual += pkt->trans; in usbhsf_dma_pop_done_with_rx_irq()
1148 if ((pkt->actual == pkt->length) || /* receive all data */ in usbhsf_dma_pop_done_with_rx_irq()
1149 (pkt->trans < maxp)) { /* short packet */ in usbhsf_dma_pop_done_with_rx_irq()
1155 usbhsf_prepare_pop(pkt, is_done); in usbhsf_dma_pop_done_with_rx_irq()
1161 static size_t usbhs_dma_calc_received_size(struct usbhs_pkt *pkt, in usbhs_dma_calc_received_size() argument
1164 struct usbhs_pipe *pipe = pkt->pipe; in usbhs_dma_calc_received_size()
1168 received_size = pkt->length - pkt->dma_result->residue; in usbhs_dma_calc_received_size()
1179 static int usbhsf_dma_pop_done_with_usb_dmac(struct usbhs_pkt *pkt, in usbhsf_dma_pop_done_with_usb_dmac() argument
1182 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_dma_pop_done_with_usb_dmac()
1185 struct dma_chan *chan = usbhsf_dma_chan_get(fifo, pkt); in usbhsf_dma_pop_done_with_usb_dmac()
1197 pkt->actual = usbhs_dma_calc_received_size(pkt, chan, rcv_len); in usbhsf_dma_pop_done_with_usb_dmac()
1201 usbhsf_dma_unmap(pkt); in usbhsf_dma_pop_done_with_usb_dmac()
1210 static int usbhsf_dma_pop_done(struct usbhs_pkt *pkt, int *is_done) in usbhsf_dma_pop_done() argument
1212 struct usbhs_priv *priv = usbhs_pipe_to_priv(pkt->pipe); in usbhsf_dma_pop_done()
1215 return usbhsf_dma_pop_done_with_usb_dmac(pkt, is_done); in usbhsf_dma_pop_done()
1217 return usbhsf_dma_pop_done_with_rx_irq(pkt, is_done); in usbhsf_dma_pop_done()
1377 struct usbhs_pkt *pkt = arg; in usbhsf_dma_complete() local
1378 struct usbhs_pipe *pipe = pkt->pipe; in usbhsf_dma_complete()
1383 pkt->dma_result = result; in usbhsf_dma_complete()