Lines Matching refs:ctrl

56 static int last_trb(struct xhci_ctrl *ctrl, struct xhci_ring *ring,  in last_trb()  argument
59 if (ring == ctrl->event_ring) in last_trb()
75 static bool last_trb_on_last_seg(struct xhci_ctrl *ctrl, in last_trb_on_last_seg() argument
80 if (ring == ctrl->event_ring) in last_trb_on_last_seg()
109 static void inc_enq(struct xhci_ctrl *ctrl, struct xhci_ring *ring, in inc_enq() argument
122 while (last_trb(ctrl, ring, ring->enq_seg, next)) { in inc_enq()
123 if (ring != ctrl->event_ring) { in inc_enq()
149 if (last_trb_on_last_seg(ctrl, ring, in inc_enq()
167 static void inc_deq(struct xhci_ctrl *ctrl, struct xhci_ring *ring) in inc_deq() argument
175 if (last_trb(ctrl, ring, ring->deq_seg, ring->dequeue)) { in inc_deq()
176 if (ring == ctrl->event_ring && in inc_deq()
177 last_trb_on_last_seg(ctrl, ring, in inc_deq()
186 } while (last_trb(ctrl, ring, ring->deq_seg, ring->dequeue)); in inc_deq()
201 static dma_addr_t queue_trb(struct xhci_ctrl *ctrl, struct xhci_ring *ring, in queue_trb() argument
217 inc_enq(ctrl, ring, more_trbs_coming); in queue_trb()
231 static int prepare_ring(struct xhci_ctrl *ctrl, struct xhci_ring *ep_ring, in prepare_ring() argument
260 while (last_trb(ctrl, ep_ring, ep_ring->enq_seg, next)) { in prepare_ring()
272 if (last_trb_on_last_seg(ctrl, ep_ring, in prepare_ring()
294 void xhci_queue_command(struct xhci_ctrl *ctrl, dma_addr_t addr, u32 slot_id, in xhci_queue_command() argument
299 BUG_ON(prepare_ring(ctrl, ctrl->cmd_ring, EP_STATE_RUNNING)); in xhci_queue_command()
305 ctrl->cmd_ring->cycle_state; in xhci_queue_command()
314 queue_trb(ctrl, ctrl->cmd_ring, false, fields); in xhci_queue_command()
317 xhci_writel(&ctrl->dba->doorbell[0], DB_VALUE_HOST); in xhci_queue_command()
348 static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred, in xhci_td_remainder() argument
355 if (ctrl->hci_version < 0x100 && !(ctrl->quirks & XHCI_MTK_HOST)) in xhci_td_remainder()
364 if ((ctrl->quirks & XHCI_MTK_HOST) && (ctrl->hci_version < 0x100)) in xhci_td_remainder()
386 struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); in giveback_first_trb() local
400 xhci_writel(&ctrl->dba->doorbell[udev->slot_id], in giveback_first_trb()
416 void xhci_acknowledge_event(struct xhci_ctrl *ctrl) in xhci_acknowledge_event() argument
421 inc_deq(ctrl, ctrl->event_ring); in xhci_acknowledge_event()
424 deq = xhci_trb_virt_to_dma(ctrl->event_ring->deq_seg, in xhci_acknowledge_event()
425 ctrl->event_ring->dequeue); in xhci_acknowledge_event()
426 xhci_writeq(&ctrl->ir_set->erst_dequeue, deq | ERST_EHB); in xhci_acknowledge_event()
435 static int event_ready(struct xhci_ctrl *ctrl) in event_ready() argument
439 xhci_inval_cache((uintptr_t)ctrl->event_ring->dequeue, in event_ready()
442 event = ctrl->event_ring->dequeue; in event_ready()
446 ctrl->event_ring->cycle_state) in event_ready()
461 union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected) in xhci_wait_for_event() argument
467 union xhci_trb *event = ctrl->event_ring->dequeue; in xhci_wait_for_event()
469 if (!event_ready(ctrl)) in xhci_wait_for_event()
494 xhci_acknowledge_event(ctrl); in xhci_wait_for_event()
511 struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); in reset_ep() local
512 struct xhci_ring *ring = ctrl->devs[udev->slot_id]->eps[ep_index].ring; in reset_ep()
518 xhci_queue_command(ctrl, 0, udev->slot_id, ep_index, TRB_RESET_EP); in reset_ep()
519 event = xhci_wait_for_event(ctrl, TRB_COMPLETION); in reset_ep()
525 xhci_acknowledge_event(ctrl); in reset_ep()
529 xhci_queue_command(ctrl, addr, udev->slot_id, ep_index, TRB_SET_DEQ); in reset_ep()
530 event = xhci_wait_for_event(ctrl, TRB_COMPLETION); in reset_ep()
536 xhci_acknowledge_event(ctrl); in reset_ep()
549 struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); in abort_td() local
550 struct xhci_ring *ring = ctrl->devs[udev->slot_id]->eps[ep_index].ring; in abort_td()
557 xhci_queue_command(ctrl, 0, udev->slot_id, ep_index, TRB_STOP_RING); in abort_td()
559 event = xhci_wait_for_event(ctrl, TRB_NONE); in abort_td()
569 xhci_acknowledge_event(ctrl); in abort_td()
571 event = xhci_wait_for_event(ctrl, TRB_COMPLETION); in abort_td()
584 xhci_acknowledge_event(ctrl); in abort_td()
588 xhci_queue_command(ctrl, addr, udev->slot_id, ep_index, TRB_SET_DEQ); in abort_td()
589 event = xhci_wait_for_event(ctrl, TRB_COMPLETION); in abort_td()
595 xhci_acknowledge_event(ctrl); in abort_td()
645 struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); in xhci_bulk_tx() local
659 u64 buf_64 = xhci_dma_map(ctrl, buffer, length); in xhci_bulk_tx()
668 virt_dev = ctrl->devs[slot_id]; in xhci_bulk_tx()
673 ep_ctx = xhci_get_ep_ctx(ctrl, virt_dev->out_ctx, ep_index); in xhci_bulk_tx()
716 ret = prepare_ring(ctrl, ring, in xhci_bulk_tx()
778 remainder = xhci_td_remainder(ctrl, running_total, trb_buff_len, in xhci_bulk_tx()
791 last_transfer_trb_addr = queue_trb(ctrl, ring, (num_trbs > 1), trb_fields); in xhci_bulk_tx()
807 event = xhci_wait_for_event(ctrl, TRB_TRANSFER); in xhci_bulk_tx()
820 xhci_acknowledge_event(ctrl); in xhci_bulk_tx()
829 xhci_acknowledge_event(ctrl); in xhci_bulk_tx()
831 xhci_dma_unmap(ctrl, buf_64, length); in xhci_bulk_tx()
857 struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); in xhci_ctrl_tx() local
861 struct xhci_virt_device *virt_dev = ctrl->devs[slot_id]; in xhci_ctrl_tx()
892 ep_ctx = xhci_get_ep_ctx(ctrl, virt_dev->out_ctx, ep_index); in xhci_ctrl_tx()
909 ret = prepare_ring(ctrl, ep_ring, in xhci_ctrl_tx()
933 if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) { in xhci_ctrl_tx()
954 queue_trb(ctrl, ep_ring, true, trb_fields); in xhci_ctrl_tx()
965 remainder = xhci_td_remainder(ctrl, 0, length, length, in xhci_ctrl_tx()
977 buf_64 = xhci_dma_map(ctrl, buffer, length); in xhci_ctrl_tx()
985 queue_trb(ctrl, ep_ring, true, trb_fields); in xhci_ctrl_tx()
1007 queue_trb(ctrl, ep_ring, false, trb_fields); in xhci_ctrl_tx()
1011 event = xhci_wait_for_event(ctrl, TRB_TRANSFER); in xhci_ctrl_tx()
1020 xhci_acknowledge_event(ctrl); in xhci_ctrl_tx()
1029 xhci_dma_unmap(ctrl, buf_64, length); in xhci_ctrl_tx()
1035 event = xhci_wait_for_event(ctrl, TRB_TRANSFER); in xhci_ctrl_tx()
1040 xhci_acknowledge_event(ctrl); in xhci_ctrl_tx()