Lines Matching refs:pdev

129 static void cdnsp_next_trb(struct cdnsp_device *pdev,  in cdnsp_next_trb()  argument
146 void cdnsp_inc_deq(struct cdnsp_device *pdev, struct cdnsp_ring *ring) in cdnsp_inc_deq() argument
187 static void cdnsp_inc_enq(struct cdnsp_device *pdev, in cdnsp_inc_enq() argument
236 static bool cdnsp_room_on_ring(struct cdnsp_device *pdev, in cdnsp_room_on_ring() argument
260 static void cdnsp_force_l0_go(struct cdnsp_device *pdev) in cdnsp_force_l0_go() argument
262 if (pdev->active_port == &pdev->usb2_port && pdev->gadget.lpm_capable) in cdnsp_force_l0_go()
263 cdnsp_set_link_state(pdev, &pdev->active_port->regs->portsc, XDEV_U0); in cdnsp_force_l0_go()
267 void cdnsp_ring_cmd_db(struct cdnsp_device *pdev) in cdnsp_ring_cmd_db() argument
269 writel(DB_VALUE_CMD, &pdev->dba->cmd_db); in cdnsp_ring_cmd_db()
276 static bool cdnsp_ring_ep_doorbell(struct cdnsp_device *pdev, in cdnsp_ring_ep_doorbell() argument
280 __le32 __iomem *reg_addr = &pdev->dba->ep_db; in cdnsp_ring_ep_doorbell()
301 if (pep->idx == 0 && pdev->ep0_stage == CDNSP_DATA_STAGE && in cdnsp_ring_ep_doorbell()
302 !pdev->ep0_expect_in) in cdnsp_ring_ep_doorbell()
311 if (pdev->rtl_revision < RTL_REVISION_NEW_LPM) in cdnsp_ring_ep_doorbell()
312 cdnsp_force_l0_go(pdev); in cdnsp_ring_ep_doorbell()
323 static struct cdnsp_ring *cdnsp_get_transfer_ring(struct cdnsp_device *pdev, in cdnsp_get_transfer_ring() argument
331 dev_err(pdev->dev, "ERR: %s ring doesn't exist for SID: %d.\n", in cdnsp_get_transfer_ring()
340 cdnsp_request_to_transfer_ring(struct cdnsp_device *pdev, in cdnsp_request_to_transfer_ring() argument
343 return cdnsp_get_transfer_ring(pdev, preq->pep, in cdnsp_request_to_transfer_ring()
348 void cdnsp_ring_doorbell_for_active_rings(struct cdnsp_device *pdev, in cdnsp_ring_doorbell_for_active_rings() argument
361 cdnsp_ring_ep_doorbell(pdev, pep, 0); in cdnsp_ring_doorbell_for_active_rings()
374 ep_ring = cdnsp_get_transfer_ring(pdev, pep, stream_id); in cdnsp_ring_doorbell_for_active_rings()
386 ret = cdnsp_ring_ep_doorbell(pdev, pep, stream_id); in cdnsp_ring_doorbell_for_active_rings()
399 static u64 cdnsp_get_hw_deq(struct cdnsp_device *pdev, in cdnsp_get_hw_deq() argument
406 pep = &pdev->eps[ep_index]; in cdnsp_get_hw_deq()
431 static void cdnsp_find_new_dequeue_state(struct cdnsp_device *pdev, in cdnsp_find_new_dequeue_state() argument
444 ep_ring = cdnsp_get_transfer_ring(pdev, pep, stream_id); in cdnsp_find_new_dequeue_state()
452 hw_dequeue = cdnsp_get_hw_deq(pdev, pep->idx, stream_id); in cdnsp_find_new_dequeue_state()
480 cdnsp_next_trb(pdev, ep_ring, &new_seg, &new_deq); in cdnsp_find_new_dequeue_state()
484 dev_err(pdev->dev, in cdnsp_find_new_dequeue_state()
504 static void cdnsp_td_to_noop(struct cdnsp_device *pdev, in cdnsp_td_to_noop() argument
522 cdnsp_next_trb(pdev, ep_ring, &seg, &trb); in cdnsp_td_to_noop()
532 static struct cdnsp_segment *cdnsp_trb_in_td(struct cdnsp_device *pdev, in cdnsp_trb_in_td() argument
598 static void cdnsp_unmap_td_bounce_buffer(struct cdnsp_device *pdev, in cdnsp_unmap_td_bounce_buffer() argument
615 dma_unmap_single(pdev->dev, seg->bounce_dma, in cdnsp_unmap_td_bounce_buffer()
620 dma_unmap_single(pdev->dev, seg->bounce_dma, ring->bounce_buf_len, in cdnsp_unmap_td_bounce_buffer()
628 dev_warn(pdev->dev, "WARN Wrong bounce buffer read length: %zu != %d\n", in cdnsp_unmap_td_bounce_buffer()
635 static int cdnsp_cmd_set_deq(struct cdnsp_device *pdev, in cdnsp_cmd_set_deq() argument
643 cdnsp_ring_doorbell_for_active_rings(pdev, pep); in cdnsp_cmd_set_deq()
647 cdnsp_queue_new_dequeue_state(pdev, pep, deq_state); in cdnsp_cmd_set_deq()
648 cdnsp_ring_cmd_db(pdev); in cdnsp_cmd_set_deq()
649 ret = cdnsp_wait_for_cmd_compl(pdev); in cdnsp_cmd_set_deq()
651 trace_cdnsp_handle_cmd_set_deq(cdnsp_get_slot_ctx(&pdev->out_ctx)); in cdnsp_cmd_set_deq()
658 ep_ring = cdnsp_get_transfer_ring(pdev, pep, deq_state->stream_id); in cdnsp_cmd_set_deq()
686 cdnsp_ring_doorbell_for_active_rings(pdev, pep); in cdnsp_cmd_set_deq()
691 int cdnsp_remove_request(struct cdnsp_device *pdev, in cdnsp_remove_request() argument
709 ep_ring = cdnsp_request_to_transfer_ring(pdev, preq); in cdnsp_remove_request()
716 hw_deq = cdnsp_get_hw_deq(pdev, pep->idx, preq->request.stream_id); in cdnsp_remove_request()
719 seg = cdnsp_trb_in_td(pdev, cur_td->start_seg, cur_td->first_trb, in cdnsp_remove_request()
724 cdnsp_find_new_dequeue_state(pdev, pep, preq->request.stream_id, in cdnsp_remove_request()
727 cdnsp_td_to_noop(pdev, ep_ring, cur_td, false); in cdnsp_remove_request()
741 if (pdev->cdnsp_state & CDNSP_STATE_DISCONNECT_PENDING || in cdnsp_remove_request()
744 ret = cdnsp_cmd_set_deq(pdev, pep, &deq_state); in cdnsp_remove_request()
747 cdnsp_unmap_td_bounce_buffer(pdev, ep_ring, cur_td); in cdnsp_remove_request()
753 static int cdnsp_update_port_id(struct cdnsp_device *pdev, u32 port_id) in cdnsp_update_port_id() argument
755 struct cdnsp_port *port = pdev->active_port; in cdnsp_update_port_id()
764 if (port_id == pdev->usb2_port.port_num) { in cdnsp_update_port_id()
765 port = &pdev->usb2_port; in cdnsp_update_port_id()
766 } else if (port_id == pdev->usb3_port.port_num) { in cdnsp_update_port_id()
767 port = &pdev->usb3_port; in cdnsp_update_port_id()
769 dev_err(pdev->dev, "Port event with invalid port ID %d\n", in cdnsp_update_port_id()
775 if (pdev->slot_id) in cdnsp_update_port_id()
776 cdnsp_disable_slot(pdev); in cdnsp_update_port_id()
778 pdev->active_port = port; in cdnsp_update_port_id()
779 cdnsp_enable_slot(pdev); in cdnsp_update_port_id()
782 if (port_id == pdev->usb2_port.port_num) in cdnsp_update_port_id()
783 cdnsp_set_usb2_hardware_lpm(pdev, NULL, 1); in cdnsp_update_port_id()
786 &pdev->usb3_port.regs->portpmsc); in cdnsp_update_port_id()
791 static void cdnsp_handle_port_status(struct cdnsp_device *pdev, in cdnsp_handle_port_status() argument
802 dev_err(pdev->dev, "ERR: incorrect PSC event\n"); in cdnsp_handle_port_status()
806 if (cdnsp_update_port_id(pdev, port_id)) in cdnsp_handle_port_status()
809 port_regs = pdev->active_port->regs; in cdnsp_handle_port_status()
811 if (port_id == pdev->usb2_port.port_num) in cdnsp_handle_port_status()
819 trace_cdnsp_handle_port_status(pdev->active_port->port_num, portsc); in cdnsp_handle_port_status()
821 pdev->gadget.speed = cdnsp_port_speed(portsc); in cdnsp_handle_port_status()
826 if (!(pdev->cdnsp_state & CDNSP_WAKEUP_PENDING) && in cdnsp_handle_port_status()
828 cmd_regs = readl(&pdev->op_regs->command); in cdnsp_handle_port_status()
833 cdnsp_set_link_state(pdev, &port_regs->portsc, in cdnsp_handle_port_status()
836 cdnsp_resume_gadget(pdev); in cdnsp_handle_port_status()
840 if ((pdev->cdnsp_state & CDNSP_WAKEUP_PENDING) && in cdnsp_handle_port_status()
842 pdev->cdnsp_state &= ~CDNSP_WAKEUP_PENDING; in cdnsp_handle_port_status()
844 cdnsp_force_header_wakeup(pdev, 1); in cdnsp_handle_port_status()
845 cdnsp_ring_cmd_db(pdev); in cdnsp_handle_port_status()
846 cdnsp_wait_for_cmd_compl(pdev); in cdnsp_handle_port_status()
849 if (link_state == XDEV_U0 && pdev->link_state == XDEV_U3 && in cdnsp_handle_port_status()
851 cdnsp_resume_gadget(pdev); in cdnsp_handle_port_status()
853 if (link_state == XDEV_U3 && pdev->link_state != XDEV_U3) in cdnsp_handle_port_status()
854 cdnsp_suspend_gadget(pdev); in cdnsp_handle_port_status()
856 pdev->link_state = link_state; in cdnsp_handle_port_status()
861 if (pdev->gadget.connected && !(portsc & PORT_CONNECT)) in cdnsp_handle_port_status()
862 cdnsp_disconnect_gadget(pdev); in cdnsp_handle_port_status()
867 cdnsp_irq_reset(pdev); in cdnsp_handle_port_status()
869 usb_gadget_set_state(&pdev->gadget, USB_STATE_ATTACHED); in cdnsp_handle_port_status()
875 cdnsp_irq_reset(pdev); in cdnsp_handle_port_status()
876 pdev->u1_allowed = 0; in cdnsp_handle_port_status()
877 pdev->u2_allowed = 0; in cdnsp_handle_port_status()
878 pdev->may_wakeup = 0; in cdnsp_handle_port_status()
882 dev_err(pdev->dev, "Port Over Current detected\n"); in cdnsp_handle_port_status()
885 dev_err(pdev->dev, "Port Configure Error detected\n"); in cdnsp_handle_port_status()
891 cdnsp_inc_deq(pdev, pdev->event_ring); in cdnsp_handle_port_status()
894 static void cdnsp_td_cleanup(struct cdnsp_device *pdev, in cdnsp_td_cleanup() argument
902 cdnsp_unmap_td_bounce_buffer(pdev, ep_ring, td); in cdnsp_td_cleanup()
920 static void cdnsp_finish_td(struct cdnsp_device *pdev, in cdnsp_finish_td() argument
945 cdnsp_inc_deq(pdev, ep_ring); in cdnsp_finish_td()
947 cdnsp_inc_deq(pdev, ep_ring); in cdnsp_finish_td()
949 cdnsp_td_cleanup(pdev, td, ep_ring, status); in cdnsp_finish_td()
953 static int cdnsp_sum_trb_lengths(struct cdnsp_device *pdev, in cdnsp_sum_trb_lengths() argument
961 for (sum = 0; trb != stop_trb; cdnsp_next_trb(pdev, ring, &seg, &trb)) { in cdnsp_sum_trb_lengths()
968 static int cdnsp_giveback_first_trb(struct cdnsp_device *pdev, in cdnsp_giveback_first_trb() argument
991 return cdnsp_ring_ep_doorbell(pdev, pep, stream_id); in cdnsp_giveback_first_trb()
997 static void cdnsp_process_ctrl_td(struct cdnsp_device *pdev, in cdnsp_process_ctrl_td() argument
1026 if (pdev->ep0_stage == CDNSP_DATA_STAGE && pep->number == 0 && in cdnsp_process_ctrl_td()
1027 pdev->three_stage_setup) { in cdnsp_process_ctrl_td()
1030 pdev->ep0_stage = CDNSP_STATUS_STAGE; in cdnsp_process_ctrl_td()
1032 cdnsp_giveback_first_trb(pdev, pep, 0, ep_ring->cycle_state, in cdnsp_process_ctrl_td()
1039 cdnsp_finish_td(pdev, td, event, pep, status); in cdnsp_process_ctrl_td()
1045 static void cdnsp_process_isoc_td(struct cdnsp_device *pdev, in cdnsp_process_isoc_td() argument
1098 td_length = cdnsp_sum_trb_lengths(pdev, ep_ring, ep_trb); in cdnsp_process_isoc_td()
1106 cdnsp_finish_td(pdev, td, event, pep, &status); in cdnsp_process_isoc_td()
1109 static void cdnsp_skip_isoc_td(struct cdnsp_device *pdev, in cdnsp_skip_isoc_td() argument
1123 cdnsp_inc_deq(pdev, ep_ring); in cdnsp_skip_isoc_td()
1125 cdnsp_inc_deq(pdev, ep_ring); in cdnsp_skip_isoc_td()
1127 cdnsp_td_cleanup(pdev, td, ep_ring, &status); in cdnsp_skip_isoc_td()
1133 static void cdnsp_process_bulk_intr_td(struct cdnsp_device *pdev, in cdnsp_process_bulk_intr_td() argument
1168 ep_trb_len = cdnsp_sum_trb_lengths(pdev, ep_ring, ep_trb) + in cdnsp_process_bulk_intr_td()
1175 cdnsp_finish_td(pdev, td, event, ep, status); in cdnsp_process_bulk_intr_td()
1178 static void cdnsp_handle_tx_nrdy(struct cdnsp_device *pdev, in cdnsp_handle_tx_nrdy() argument
1194 pep = &pdev->eps[ep_index]; in cdnsp_handle_tx_nrdy()
1223 cdnsp_ring_doorbell_for_active_rings(pdev, pep); in cdnsp_handle_tx_nrdy()
1230 static int cdnsp_handle_tx_event(struct cdnsp_device *pdev, in cdnsp_handle_tx_event() argument
1251 pep = &pdev->eps[ep_index]; in cdnsp_handle_tx_event()
1259 if (invalidate || !pdev->gadget.connected) in cdnsp_handle_tx_event()
1276 dev_err(pdev->dev, "ERROR: %s event for unknown ring\n", in cdnsp_handle_tx_event()
1337 ep_seg = cdnsp_trb_in_td(pdev, ep_ring->deq_seg, in cdnsp_handle_tx_event()
1372 dev_err(pdev->dev, in cdnsp_handle_tx_event()
1380 cdnsp_skip_isoc_td(pdev, td, event, pep, status); in cdnsp_handle_tx_event()
1391 cdnsp_skip_isoc_td(pdev, td, event, pep, status); in cdnsp_handle_tx_event()
1399 cdnsp_process_ctrl_td(pdev, td, ep_trb, event, pep, in cdnsp_handle_tx_event()
1402 cdnsp_process_isoc_td(pdev, td, ep_trb, event, pep, in cdnsp_handle_tx_event()
1405 cdnsp_process_bulk_intr_td(pdev, td, ep_trb, event, pep, in cdnsp_handle_tx_event()
1415 cdnsp_inc_deq(pdev, pdev->event_ring); in cdnsp_handle_tx_event()
1427 dev_err(pdev->dev, "@%016llx %08x %08x %08x %08x\n", in cdnsp_handle_tx_event()
1429 cdnsp_trb_virt_to_dma(pdev->event_ring->deq_seg, in cdnsp_handle_tx_event()
1430 pdev->event_ring->dequeue), in cdnsp_handle_tx_event()
1443 static bool cdnsp_handle_event(struct cdnsp_device *pdev) in cdnsp_handle_event() argument
1452 event = pdev->event_ring->dequeue; in cdnsp_handle_event()
1457 if (cycle_bit != pdev->event_ring->cycle_state) in cdnsp_handle_event()
1460 trace_cdnsp_handle_event(pdev->event_ring, &event->generic); in cdnsp_handle_event()
1474 cdnsp_inc_deq(pdev, pdev->cmd_ring); in cdnsp_handle_event()
1477 cdnsp_handle_port_status(pdev, event); in cdnsp_handle_event()
1481 ret = cdnsp_handle_tx_event(pdev, &event->trans_event); in cdnsp_handle_event()
1486 pdev->ep0_stage = CDNSP_SETUP_STAGE; in cdnsp_handle_event()
1487 pdev->setup_id = TRB_SETUPID_TO_TYPE(flags); in cdnsp_handle_event()
1488 pdev->setup_speed = TRB_SETUP_SPEEDID(flags); in cdnsp_handle_event()
1489 pdev->setup = *((struct usb_ctrlrequest *) in cdnsp_handle_event()
1492 cdnsp_setup_analyze(pdev); in cdnsp_handle_event()
1495 cdnsp_handle_tx_nrdy(pdev, &event->trans_event); in cdnsp_handle_event()
1502 dev_err(pdev->dev, "Event Ring Full\n"); in cdnsp_handle_event()
1505 dev_err(pdev->dev, "Controller error code 0x%02x\n", in cdnsp_handle_event()
1515 dev_warn(pdev->dev, "ERROR unknown event type %ld\n", in cdnsp_handle_event()
1521 cdnsp_inc_deq(pdev, pdev->event_ring); in cdnsp_handle_event()
1532 struct cdnsp_device *pdev = (struct cdnsp_device *)data; in cdnsp_thread_irq_handler() local
1538 spin_lock_irqsave(&pdev->lock, flags); in cdnsp_thread_irq_handler()
1540 if (pdev->cdnsp_state & (CDNSP_STATE_HALTED | CDNSP_STATE_DYING)) { in cdnsp_thread_irq_handler()
1546 if (pdev->gadget_driver) in cdnsp_thread_irq_handler()
1547 cdnsp_died(pdev); in cdnsp_thread_irq_handler()
1549 spin_unlock_irqrestore(&pdev->lock, flags); in cdnsp_thread_irq_handler()
1554 event_ring_deq = pdev->event_ring->dequeue; in cdnsp_thread_irq_handler()
1556 while (cdnsp_handle_event(pdev)) { in cdnsp_thread_irq_handler()
1558 cdnsp_update_erst_dequeue(pdev, event_ring_deq, 0); in cdnsp_thread_irq_handler()
1559 event_ring_deq = pdev->event_ring->dequeue; in cdnsp_thread_irq_handler()
1564 cdnsp_update_erst_dequeue(pdev, event_ring_deq, 1); in cdnsp_thread_irq_handler()
1566 spin_unlock_irqrestore(&pdev->lock, flags); in cdnsp_thread_irq_handler()
1574 struct cdnsp_device *pdev = (struct cdnsp_device *)priv; in cdnsp_irq_handler() local
1578 status = readl(&pdev->op_regs->status); in cdnsp_irq_handler()
1581 cdnsp_died(pdev); in cdnsp_irq_handler()
1588 writel(status | STS_EINT, &pdev->op_regs->status); in cdnsp_irq_handler()
1589 irq_pending = readl(&pdev->ir_set->irq_pending); in cdnsp_irq_handler()
1591 writel(irq_pending, &pdev->ir_set->irq_pending); in cdnsp_irq_handler()
1594 cdnsp_died(pdev); in cdnsp_irq_handler()
1607 static void cdnsp_queue_trb(struct cdnsp_device *pdev, struct cdnsp_ring *ring, in cdnsp_queue_trb() argument
1621 cdnsp_inc_enq(pdev, ring, more_trbs_coming); in cdnsp_queue_trb()
1628 static int cdnsp_prepare_ring(struct cdnsp_device *pdev, in cdnsp_prepare_ring() argument
1643 dev_err(pdev->dev, "ERROR: incorrect endpoint state\n"); in cdnsp_prepare_ring()
1648 if (cdnsp_room_on_ring(pdev, ep_ring, num_trbs)) in cdnsp_prepare_ring()
1654 if (cdnsp_ring_expansion(pdev, ep_ring, num_trbs_needed, in cdnsp_prepare_ring()
1656 dev_err(pdev->dev, "Ring expansion failed\n"); in cdnsp_prepare_ring()
1676 static int cdnsp_prepare_transfer(struct cdnsp_device *pdev, in cdnsp_prepare_transfer() argument
1683 ep_ring = cdnsp_get_transfer_ring(pdev, preq->pep, in cdnsp_prepare_transfer()
1688 ret = cdnsp_prepare_ring(pdev, ep_ring, in cdnsp_prepare_transfer()
1747 dev_err(preq->pep->pdev->dev, in cdnsp_check_trb_math()
1771 static u32 cdnsp_td_remainder(struct cdnsp_device *pdev, in cdnsp_td_remainder() argument
1797 static int cdnsp_align_td(struct cdnsp_device *pdev, in cdnsp_align_td() argument
1801 struct device *dev = pdev->dev; in cdnsp_align_td()
1845 dev_warn(pdev->dev, in cdnsp_align_td()
1864 int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) in cdnsp_queue_bulk_tx() argument
1881 ring = cdnsp_request_to_transfer_ring(pdev, preq); in cdnsp_queue_bulk_tx()
1908 ret = cdnsp_prepare_transfer(pdev, preq, num_trbs); in cdnsp_queue_bulk_tx()
1965 if (cdnsp_align_td(pdev, preq, enqd_len, in cdnsp_queue_bulk_tx()
1993 remainder = cdnsp_td_remainder(pdev, enqd_len, trb_buff_len, in cdnsp_queue_bulk_tx()
2001 cdnsp_queue_trb(pdev, ring, more_trbs_coming, in cdnsp_queue_bulk_tx()
2031 cdnsp_queue_trb(pdev, ring, 0, 0x0, 0x0, in cdnsp_queue_bulk_tx()
2036 ret = cdnsp_giveback_first_trb(pdev, pep, preq->request.stream_id, in cdnsp_queue_bulk_tx()
2045 int cdnsp_queue_ctrl_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) in cdnsp_queue_ctrl_tx() argument
2054 ep_ring = cdnsp_request_to_transfer_ring(pdev, preq); in cdnsp_queue_ctrl_tx()
2059 num_trbs = (pdev->three_stage_setup) ? 2 : 1; in cdnsp_queue_ctrl_tx()
2069 ret = cdnsp_prepare_transfer(pdev, preq, num_trbs); in cdnsp_queue_ctrl_tx()
2080 field |= TRB_IOC | (pdev->ep0_expect_in ? 0 : TRB_ISP); in cdnsp_queue_ctrl_tx()
2082 if (pdev->ep0_expect_in) in cdnsp_queue_ctrl_tx()
2088 cdnsp_queue_trb(pdev, ep_ring, true, in cdnsp_queue_ctrl_tx()
2092 TRB_SETUPID(pdev->setup_id) | in cdnsp_queue_ctrl_tx()
2093 pdev->setup_speed); in cdnsp_queue_ctrl_tx()
2098 if (!pdev->ep0_expect_in) in cdnsp_queue_ctrl_tx()
2101 cdnsp_queue_trb(pdev, ep_ring, true, in cdnsp_queue_ctrl_tx()
2105 TRB_SETUPID(pdev->setup_id) | in cdnsp_queue_ctrl_tx()
2106 pdev->setup_speed); in cdnsp_queue_ctrl_tx()
2109 pdev->ep0_stage = CDNSP_DATA_STAGE; in cdnsp_queue_ctrl_tx()
2121 if (preq->request.length > 0 && pdev->ep0_expect_in) in cdnsp_queue_ctrl_tx()
2131 cdnsp_queue_trb(pdev, ep_ring, false, 0, 0, TRB_INTR_TARGET(0), in cdnsp_queue_ctrl_tx()
2132 field | TRB_IOC | TRB_SETUPID(pdev->setup_id) | in cdnsp_queue_ctrl_tx()
2133 TRB_TYPE(TRB_STATUS) | pdev->setup_speed); in cdnsp_queue_ctrl_tx()
2135 cdnsp_ring_ep_doorbell(pdev, pep, preq->request.stream_id); in cdnsp_queue_ctrl_tx()
2140 int cdnsp_cmd_stop_ep(struct cdnsp_device *pdev, struct cdnsp_ep *pep) in cdnsp_cmd_stop_ep() argument
2151 cdnsp_queue_stop_endpoint(pdev, pep->idx); in cdnsp_cmd_stop_ep()
2152 cdnsp_ring_cmd_db(pdev); in cdnsp_cmd_stop_ep()
2153 ret = cdnsp_wait_for_cmd_compl(pdev); in cdnsp_cmd_stop_ep()
2170 static unsigned int cdnsp_get_burst_count(struct cdnsp_device *pdev, in cdnsp_get_burst_count() argument
2176 if (pdev->gadget.speed < USB_SPEED_SUPER) in cdnsp_get_burst_count()
2192 cdnsp_get_last_burst_packet_count(struct cdnsp_device *pdev, in cdnsp_get_last_burst_packet_count() argument
2199 if (pdev->gadget.speed >= USB_SPEED_SUPER) { in cdnsp_get_last_burst_packet_count()
2220 int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev, in cdnsp_queue_isoc_tx() argument
2254 ret = cdnsp_prepare_transfer(pdev, preq, trbs_per_td); in cdnsp_queue_isoc_tx()
2270 burst_count = cdnsp_get_burst_count(pdev, preq, total_pkt_count); in cdnsp_queue_isoc_tx()
2271 last_burst_pkt = cdnsp_get_last_burst_packet_count(pdev, preq, in cdnsp_queue_isoc_tx()
2296 remainder = cdnsp_td_remainder(pdev, running_total, in cdnsp_queue_isoc_tx()
2325 cdnsp_queue_trb(pdev, ep_ring, more_trbs_coming, in cdnsp_queue_isoc_tx()
2351 dev_err(pdev->dev, "ISOC TD length unmatch\n"); in cdnsp_queue_isoc_tx()
2356 cdnsp_giveback_first_trb(pdev, preq->pep, preq->request.stream_id, in cdnsp_queue_isoc_tx()
2375 cdnsp_td_to_noop(pdev, ep_ring, &preq->td, true); in cdnsp_queue_isoc_tx()
2389 static void cdnsp_queue_command(struct cdnsp_device *pdev, in cdnsp_queue_command() argument
2395 cdnsp_prepare_ring(pdev, pdev->cmd_ring, EP_STATE_RUNNING, 1, in cdnsp_queue_command()
2398 pdev->cmd.command_trb = pdev->cmd_ring->enqueue; in cdnsp_queue_command()
2400 cdnsp_queue_trb(pdev, pdev->cmd_ring, false, field1, field2, in cdnsp_queue_command()
2401 field3, field4 | pdev->cmd_ring->cycle_state); in cdnsp_queue_command()
2405 void cdnsp_queue_slot_control(struct cdnsp_device *pdev, u32 trb_type) in cdnsp_queue_slot_control() argument
2407 cdnsp_queue_command(pdev, 0, 0, 0, TRB_TYPE(trb_type) | in cdnsp_queue_slot_control()
2408 SLOT_ID_FOR_TRB(pdev->slot_id)); in cdnsp_queue_slot_control()
2412 void cdnsp_queue_address_device(struct cdnsp_device *pdev, in cdnsp_queue_address_device() argument
2416 cdnsp_queue_command(pdev, lower_32_bits(in_ctx_ptr), in cdnsp_queue_address_device()
2419 SLOT_ID_FOR_TRB(pdev->slot_id) | in cdnsp_queue_address_device()
2424 void cdnsp_queue_reset_device(struct cdnsp_device *pdev) in cdnsp_queue_reset_device() argument
2426 cdnsp_queue_command(pdev, 0, 0, 0, TRB_TYPE(TRB_RESET_DEV) | in cdnsp_queue_reset_device()
2427 SLOT_ID_FOR_TRB(pdev->slot_id)); in cdnsp_queue_reset_device()
2431 void cdnsp_queue_configure_endpoint(struct cdnsp_device *pdev, in cdnsp_queue_configure_endpoint() argument
2434 cdnsp_queue_command(pdev, lower_32_bits(in_ctx_ptr), in cdnsp_queue_configure_endpoint()
2437 SLOT_ID_FOR_TRB(pdev->slot_id)); in cdnsp_queue_configure_endpoint()
2444 void cdnsp_queue_stop_endpoint(struct cdnsp_device *pdev, unsigned int ep_index) in cdnsp_queue_stop_endpoint() argument
2446 cdnsp_queue_command(pdev, 0, 0, 0, SLOT_ID_FOR_TRB(pdev->slot_id) | in cdnsp_queue_stop_endpoint()
2451 void cdnsp_queue_new_dequeue_state(struct cdnsp_device *pdev, in cdnsp_queue_new_dequeue_state() argument
2456 u32 trb_slot_id = SLOT_ID_FOR_TRB(pdev->slot_id); in cdnsp_queue_new_dequeue_state()
2467 cdnsp_queue_command(pdev, lower_32_bits(addr) | trb_sct | in cdnsp_queue_new_dequeue_state()
2473 void cdnsp_queue_reset_ep(struct cdnsp_device *pdev, unsigned int ep_index) in cdnsp_queue_reset_ep() argument
2475 return cdnsp_queue_command(pdev, 0, 0, 0, in cdnsp_queue_reset_ep()
2476 SLOT_ID_FOR_TRB(pdev->slot_id) | in cdnsp_queue_reset_ep()
2484 void cdnsp_queue_halt_endpoint(struct cdnsp_device *pdev, unsigned int ep_index) in cdnsp_queue_halt_endpoint() argument
2486 cdnsp_queue_command(pdev, 0, 0, 0, TRB_TYPE(TRB_HALT_ENDPOINT) | in cdnsp_queue_halt_endpoint()
2487 SLOT_ID_FOR_TRB(pdev->slot_id) | in cdnsp_queue_halt_endpoint()
2492 void cdnsp_force_header_wakeup(struct cdnsp_device *pdev, int intf_num) in cdnsp_force_header_wakeup() argument
2497 TRB_FH_TO_DEVICE_ADDRESS(pdev->device_address); in cdnsp_force_header_wakeup()
2502 cdnsp_queue_command(pdev, lo, mid, 0, in cdnsp_force_header_wakeup()