Lines Matching refs:pkt
22 void usbhs_pkt_init(struct usbhs_pkt *pkt)
24 INIT_LIST_HEAD(&pkt->node);
30 static int usbhsf_null_handle(struct usbhs_pkt *pkt, int *is_done)
32 struct usbhs_priv *priv = usbhs_pipe_to_priv(pkt->pipe);
45 void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
47 struct usbhs_pkt *pkt),
67 list_move_tail(&pkt->node, &pipe->list);
70 * each pkt must hold own handler.
74 pkt->pipe = pipe;
75 pkt->buf = buf;
76 pkt->handler = pipe->handler;
77 pkt->length = len;
78 pkt->zero = zero;
79 pkt->actual = 0;
80 pkt->done = done;
81 pkt->sequence = sequence;
87 static void __usbhsf_pkt_del(struct usbhs_pkt *pkt)
89 list_del_init(&pkt->node);
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)
117 if (!pkt)
118 pkt = __usbhsf_pkt_get(pipe);
120 if (pkt) {
124 chan = usbhsf_dma_chan_get(fifo, pkt);
127 usbhsf_dma_unmap(pkt);
138 __usbhsf_pkt_del(pkt);
147 return pkt;
159 struct usbhs_pkt *pkt;
161 int (*func)(struct usbhs_pkt *pkt, int *is_done);
169 pkt = __usbhsf_pkt_get(pipe);
170 if (!pkt) {
177 func = pkt->handler->prepare;
180 func = pkt->handler->try_run;
183 func = pkt->handler->dma_done;
186 dev_err(dev, "unknown pkt handler\n");
191 ret = func(pkt, &is_done);
194 __usbhsf_pkt_del(pkt);
201 pkt->done(priv, pkt);
357 static int usbhs_dcp_dir_switch_to_write(struct usbhs_pkt *pkt, int *is_done)
359 struct usbhs_pipe *pipe = pkt->pipe;
386 static int usbhs_dcp_dir_switch_to_read(struct usbhs_pkt *pkt, int *is_done)
388 struct usbhs_pipe *pipe = pkt->pipe;
414 static int usbhs_dcp_dir_switch_done(struct usbhs_pkt *pkt, int *is_done)
416 struct usbhs_pipe *pipe = pkt->pipe;
418 if (pkt->handler == &usbhs_dcp_status_stage_in_handler)
423 pkt->actual = pkt->length;
442 static int usbhsf_dcp_data_stage_try_push(struct usbhs_pkt *pkt, int *is_done)
444 struct usbhs_pipe *pipe = pkt->pipe;
451 pkt->handler = &usbhs_fifo_pio_push_handler;
453 return pkt->handler->prepare(pkt, is_done);
463 static int usbhsf_dcp_data_stage_prepare_pop(struct usbhs_pkt *pkt,
466 struct usbhs_pipe *pipe = pkt->pipe;
490 pkt->handler = &usbhs_fifo_pio_pop_handler;
492 return pkt->handler->prepare(pkt, is_done);
502 static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)
504 struct usbhs_pipe *pipe = pkt->pipe;
515 usbhs_pipe_data_sequence(pipe, pkt->sequence);
516 pkt->sequence = -1; /* -1 sequence will be ignored */
518 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length);
535 buf = pkt->buf + pkt->actual;
536 len = pkt->length - pkt->actual;
564 pkt->actual += total_len;
566 if (pkt->actual < pkt->length)
571 *is_done = !pkt->zero; /* send zero packet ? */
585 pkt->length, pkt->actual, *is_done, pkt->zero);
604 static int usbhsf_pio_prepare_push(struct usbhs_pkt *pkt, int *is_done)
606 if (usbhs_pipe_is_running(pkt->pipe))
609 return usbhsf_pio_try_push(pkt, is_done);
620 static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done)
622 struct usbhs_pipe *pipe = pkt->pipe;
635 usbhs_pipe_data_sequence(pipe, pkt->sequence);
636 pkt->sequence = -1; /* -1 sequence will be ignored */
641 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length);
649 static int usbhsf_pio_try_pop(struct usbhs_pkt *pkt, int *is_done)
651 struct usbhs_pipe *pipe = pkt->pipe;
673 buf = pkt->buf + pkt->actual;
674 len = pkt->length - pkt->actual;
683 pkt->actual += total_len;
685 if ((pkt->actual == pkt->length) || /* receive all data */
707 pkt->zero = 1;
734 pkt->length, pkt->actual, *is_done, pkt->zero);
750 static int usbhsf_ctrl_stage_end(struct usbhs_pkt *pkt, int *is_done)
752 usbhs_dcp_control_transfer_done(pkt->pipe);
768 struct usbhs_pkt *pkt)
770 if (&usbhs_fifo_dma_push_handler == pkt->handler)
773 if (&usbhs_fifo_dma_pop_handler == pkt->handler)
780 struct usbhs_pkt *pkt)
786 if (usbhsf_dma_chan_get(fifo, pkt) &&
805 static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map)
807 struct usbhs_pipe *pipe = pkt->pipe;
811 struct dma_chan *chan = usbhsf_dma_chan_get(fifo, pkt);
813 return info->dma_map_ctrl(chan->device->dev, pkt, map);
818 static void usbhsf_dma_xfer_preparing(struct usbhs_pkt *pkt)
820 struct usbhs_pipe *pipe = pkt->pipe;
833 chan = usbhsf_dma_chan_get(fifo, pkt);
836 desc = dmaengine_prep_slave_single(chan, pkt->dma + pkt->actual,
837 pkt->trans, dir,
843 desc->callback_param = pkt;
852 fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero);
855 usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->trans);
863 struct usbhs_pkt *pkt = container_of(work, struct usbhs_pkt, work);
864 struct usbhs_pipe *pipe = pkt->pipe;
869 usbhsf_dma_xfer_preparing(pkt);
876 static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done)
878 struct usbhs_pipe *pipe = pkt->pipe;
881 int len = pkt->length - pkt->actual;
900 if ((uintptr_t)(pkt->buf + pkt->actual) & align_mask)
908 fifo = usbhsf_get_dma_fifo(priv, pkt);
916 if (usbhsf_dma_map(pkt) < 0)
919 pkt->trans = len;
924 usbhsf_dma_xfer_preparing(pkt);
926 INIT_WORK(&pkt->work, xfer_work);
927 schedule_work(&pkt->work);
938 pkt->handler = &usbhs_fifo_pio_push_handler;
940 return pkt->handler->prepare(pkt, is_done);
943 static int usbhsf_dma_push_done(struct usbhs_pkt *pkt, int *is_done)
945 struct usbhs_pipe *pipe = pkt->pipe;
946 int is_short = pkt->trans % usbhs_pipe_get_maxpacket(pipe);
948 pkt->actual += pkt->trans;
950 if (pkt->actual < pkt->length)
955 *is_done = !pkt->zero; /* send zero packet? */
960 usbhsf_dma_unmap(pkt);
965 pkt->handler = &usbhs_fifo_pio_push_handler;
966 return pkt->handler->try_run(pkt, is_done);
981 static int usbhsf_dma_prepare_pop_with_rx_irq(struct usbhs_pkt *pkt,
984 return usbhsf_prepare_pop(pkt, is_done);
987 static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt,
990 struct usbhs_pipe *pipe = pkt->pipe;
999 if ((pkt->length < usbhs_get_dparam(priv, pio_dma_border)) ||
1003 fifo = usbhsf_get_dma_fifo(priv, pkt);
1007 if ((uintptr_t)pkt->buf & (USBHS_USB_DMAC_XFER_SIZE - 1))
1020 if (usbhsf_dma_map(pkt) < 0)
1032 pkt->trans = pkt->length;
1034 usbhsf_dma_xfer_preparing(pkt);
1045 pkt->handler = &usbhs_fifo_pio_pop_handler;
1048 return pkt->handler->prepare(pkt, is_done);
1051 static int usbhsf_dma_prepare_pop(struct usbhs_pkt *pkt, int *is_done)
1053 struct usbhs_priv *priv = usbhs_pipe_to_priv(pkt->pipe);
1056 return usbhsf_dma_prepare_pop_with_usb_dmac(pkt, is_done);
1058 return usbhsf_dma_prepare_pop_with_rx_irq(pkt, is_done);
1061 static int usbhsf_dma_try_pop_with_rx_irq(struct usbhs_pkt *pkt, int *is_done)
1063 struct usbhs_pipe *pipe = pkt->pipe;
1075 fifo = usbhsf_get_dma_fifo(priv, pkt);
1079 if ((uintptr_t)(pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */
1088 len = min(pkt->length - pkt->actual, len);
1099 if (usbhsf_dma_map(pkt) < 0)
1111 pkt->trans = len;
1113 INIT_WORK(&pkt->work, xfer_work);
1114 schedule_work(&pkt->work);
1125 pkt->handler = &usbhs_fifo_pio_pop_handler;
1127 return pkt->handler->try_run(pkt, is_done);
1130 static int usbhsf_dma_try_pop(struct usbhs_pkt *pkt, int *is_done)
1132 struct usbhs_priv *priv = usbhs_pipe_to_priv(pkt->pipe);
1136 return usbhsf_dma_try_pop_with_rx_irq(pkt, is_done);
1139 static int usbhsf_dma_pop_done_with_rx_irq(struct usbhs_pkt *pkt, int *is_done)
1141 struct usbhs_pipe *pipe = pkt->pipe;
1145 usbhsf_dma_unmap(pkt);
1148 pkt->actual += pkt->trans;
1150 if ((pkt->actual == pkt->length) || /* receive all data */
1151 (pkt->trans < maxp)) { /* short packet */
1157 usbhsf_prepare_pop(pkt, is_done);
1163 static size_t usbhs_dma_calc_received_size(struct usbhs_pkt *pkt,
1166 struct usbhs_pipe *pipe = pkt->pipe;
1170 received_size = pkt->length - pkt->dma_result->residue;
1181 static int usbhsf_dma_pop_done_with_usb_dmac(struct usbhs_pkt *pkt,
1184 struct usbhs_pipe *pipe = pkt->pipe;
1187 struct dma_chan *chan = usbhsf_dma_chan_get(fifo, pkt);
1199 pkt->actual = usbhs_dma_calc_received_size(pkt, chan, rcv_len);
1203 usbhsf_dma_unmap(pkt);
1212 static int usbhsf_dma_pop_done(struct usbhs_pkt *pkt, int *is_done)
1214 struct usbhs_priv *priv = usbhs_pipe_to_priv(pkt->pipe);
1217 return usbhsf_dma_pop_done_with_usb_dmac(pkt, is_done);
1219 return usbhsf_dma_pop_done_with_rx_irq(pkt, is_done);
1379 struct usbhs_pkt *pkt = arg;
1380 struct usbhs_pipe *pipe = pkt->pipe;
1385 pkt->dma_result = result;