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