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 cdnsp_force_l0_go(pdev); in cdnsp_ring_ep_doorbell()
322 static struct cdnsp_ring *cdnsp_get_transfer_ring(struct cdnsp_device *pdev, in cdnsp_get_transfer_ring() argument
330 dev_err(pdev->dev, "ERR: %s ring doesn't exist for SID: %d.\n", in cdnsp_get_transfer_ring()
339 cdnsp_request_to_transfer_ring(struct cdnsp_device *pdev, in cdnsp_request_to_transfer_ring() argument
342 return cdnsp_get_transfer_ring(pdev, preq->pep, in cdnsp_request_to_transfer_ring()
347 void cdnsp_ring_doorbell_for_active_rings(struct cdnsp_device *pdev, in cdnsp_ring_doorbell_for_active_rings() argument
360 cdnsp_ring_ep_doorbell(pdev, pep, 0); in cdnsp_ring_doorbell_for_active_rings()
373 ep_ring = cdnsp_get_transfer_ring(pdev, pep, stream_id); in cdnsp_ring_doorbell_for_active_rings()
385 ret = cdnsp_ring_ep_doorbell(pdev, pep, stream_id); in cdnsp_ring_doorbell_for_active_rings()
398 static u64 cdnsp_get_hw_deq(struct cdnsp_device *pdev, in cdnsp_get_hw_deq() argument
405 pep = &pdev->eps[stream_id]; in cdnsp_get_hw_deq()
430 static void cdnsp_find_new_dequeue_state(struct cdnsp_device *pdev, in cdnsp_find_new_dequeue_state() argument
443 ep_ring = cdnsp_get_transfer_ring(pdev, pep, stream_id); in cdnsp_find_new_dequeue_state()
451 hw_dequeue = cdnsp_get_hw_deq(pdev, pep->idx, stream_id); in cdnsp_find_new_dequeue_state()
479 cdnsp_next_trb(pdev, ep_ring, &new_seg, &new_deq); in cdnsp_find_new_dequeue_state()
483 dev_err(pdev->dev, in cdnsp_find_new_dequeue_state()
503 static void cdnsp_td_to_noop(struct cdnsp_device *pdev, in cdnsp_td_to_noop() argument
521 cdnsp_next_trb(pdev, ep_ring, &seg, &trb); in cdnsp_td_to_noop()
531 static struct cdnsp_segment *cdnsp_trb_in_td(struct cdnsp_device *pdev, in cdnsp_trb_in_td() argument
597 static void cdnsp_unmap_td_bounce_buffer(struct cdnsp_device *pdev, in cdnsp_unmap_td_bounce_buffer() argument
614 dma_unmap_single(pdev->dev, seg->bounce_dma, in cdnsp_unmap_td_bounce_buffer()
619 dma_unmap_single(pdev->dev, seg->bounce_dma, ring->bounce_buf_len, in cdnsp_unmap_td_bounce_buffer()
627 dev_warn(pdev->dev, "WARN Wrong bounce buffer read length: %zu != %d\n", in cdnsp_unmap_td_bounce_buffer()
634 static int cdnsp_cmd_set_deq(struct cdnsp_device *pdev, in cdnsp_cmd_set_deq() argument
642 cdnsp_ring_doorbell_for_active_rings(pdev, pep); in cdnsp_cmd_set_deq()
646 cdnsp_queue_new_dequeue_state(pdev, pep, deq_state); in cdnsp_cmd_set_deq()
647 cdnsp_ring_cmd_db(pdev); in cdnsp_cmd_set_deq()
648 ret = cdnsp_wait_for_cmd_compl(pdev); in cdnsp_cmd_set_deq()
650 trace_cdnsp_handle_cmd_set_deq(cdnsp_get_slot_ctx(&pdev->out_ctx)); in cdnsp_cmd_set_deq()
657 ep_ring = cdnsp_get_transfer_ring(pdev, pep, deq_state->stream_id); in cdnsp_cmd_set_deq()
685 cdnsp_ring_doorbell_for_active_rings(pdev, pep); in cdnsp_cmd_set_deq()
690 int cdnsp_remove_request(struct cdnsp_device *pdev, in cdnsp_remove_request() argument
708 ep_ring = cdnsp_request_to_transfer_ring(pdev, preq); in cdnsp_remove_request()
715 hw_deq = cdnsp_get_hw_deq(pdev, pep->idx, preq->request.stream_id); in cdnsp_remove_request()
718 seg = cdnsp_trb_in_td(pdev, cur_td->start_seg, cur_td->first_trb, in cdnsp_remove_request()
722 cdnsp_find_new_dequeue_state(pdev, pep, preq->request.stream_id, in cdnsp_remove_request()
725 cdnsp_td_to_noop(pdev, ep_ring, cur_td, false); in cdnsp_remove_request()
739 if (pdev->cdnsp_state & CDNSP_STATE_DISCONNECT_PENDING) { in cdnsp_remove_request()
741 ret = cdnsp_cmd_set_deq(pdev, pep, &deq_state); in cdnsp_remove_request()
744 cdnsp_unmap_td_bounce_buffer(pdev, ep_ring, cur_td); in cdnsp_remove_request()
750 static int cdnsp_update_port_id(struct cdnsp_device *pdev, u32 port_id) in cdnsp_update_port_id() argument
752 struct cdnsp_port *port = pdev->active_port; in cdnsp_update_port_id()
761 if (port_id == pdev->usb2_port.port_num) { in cdnsp_update_port_id()
762 port = &pdev->usb2_port; in cdnsp_update_port_id()
763 } else if (port_id == pdev->usb3_port.port_num) { in cdnsp_update_port_id()
764 port = &pdev->usb3_port; in cdnsp_update_port_id()
766 dev_err(pdev->dev, "Port event with invalid port ID %d\n", in cdnsp_update_port_id()
772 cdnsp_disable_slot(pdev); in cdnsp_update_port_id()
773 pdev->active_port = port; in cdnsp_update_port_id()
774 cdnsp_enable_slot(pdev); in cdnsp_update_port_id()
777 if (port_id == pdev->usb2_port.port_num) in cdnsp_update_port_id()
778 cdnsp_set_usb2_hardware_lpm(pdev, NULL, 1); in cdnsp_update_port_id()
781 &pdev->usb3_port.regs->portpmsc); in cdnsp_update_port_id()
786 static void cdnsp_handle_port_status(struct cdnsp_device *pdev, in cdnsp_handle_port_status() argument
797 dev_err(pdev->dev, "ERR: incorrect PSC event\n"); in cdnsp_handle_port_status()
801 if (cdnsp_update_port_id(pdev, port_id)) in cdnsp_handle_port_status()
804 port_regs = pdev->active_port->regs; in cdnsp_handle_port_status()
806 if (port_id == pdev->usb2_port.port_num) in cdnsp_handle_port_status()
814 trace_cdnsp_handle_port_status(pdev->active_port->port_num, portsc); in cdnsp_handle_port_status()
816 pdev->gadget.speed = cdnsp_port_speed(portsc); in cdnsp_handle_port_status()
821 if (!(pdev->cdnsp_state & CDNSP_WAKEUP_PENDING) && in cdnsp_handle_port_status()
823 cmd_regs = readl(&pdev->op_regs->command); in cdnsp_handle_port_status()
828 cdnsp_set_link_state(pdev, &port_regs->portsc, in cdnsp_handle_port_status()
831 cdnsp_resume_gadget(pdev); in cdnsp_handle_port_status()
835 if ((pdev->cdnsp_state & CDNSP_WAKEUP_PENDING) && in cdnsp_handle_port_status()
837 pdev->cdnsp_state &= ~CDNSP_WAKEUP_PENDING; in cdnsp_handle_port_status()
839 cdnsp_force_header_wakeup(pdev, 1); in cdnsp_handle_port_status()
840 cdnsp_ring_cmd_db(pdev); in cdnsp_handle_port_status()
841 cdnsp_wait_for_cmd_compl(pdev); in cdnsp_handle_port_status()
844 if (link_state == XDEV_U0 && pdev->link_state == XDEV_U3 && in cdnsp_handle_port_status()
846 cdnsp_resume_gadget(pdev); in cdnsp_handle_port_status()
848 if (link_state == XDEV_U3 && pdev->link_state != XDEV_U3) in cdnsp_handle_port_status()
849 cdnsp_suspend_gadget(pdev); in cdnsp_handle_port_status()
851 pdev->link_state = link_state; in cdnsp_handle_port_status()
856 if (pdev->gadget.connected && !(portsc & PORT_CONNECT)) in cdnsp_handle_port_status()
857 cdnsp_disconnect_gadget(pdev); in cdnsp_handle_port_status()
862 cdnsp_irq_reset(pdev); in cdnsp_handle_port_status()
864 usb_gadget_set_state(&pdev->gadget, USB_STATE_ATTACHED); in cdnsp_handle_port_status()
870 cdnsp_irq_reset(pdev); in cdnsp_handle_port_status()
871 pdev->u1_allowed = 0; in cdnsp_handle_port_status()
872 pdev->u2_allowed = 0; in cdnsp_handle_port_status()
873 pdev->may_wakeup = 0; in cdnsp_handle_port_status()
877 dev_err(pdev->dev, "Port Over Current detected\n"); in cdnsp_handle_port_status()
880 dev_err(pdev->dev, "Port Configure Error detected\n"); in cdnsp_handle_port_status()
886 cdnsp_inc_deq(pdev, pdev->event_ring); in cdnsp_handle_port_status()
889 static void cdnsp_td_cleanup(struct cdnsp_device *pdev, in cdnsp_td_cleanup() argument
897 cdnsp_unmap_td_bounce_buffer(pdev, ep_ring, td); in cdnsp_td_cleanup()
915 static void cdnsp_finish_td(struct cdnsp_device *pdev, in cdnsp_finish_td() argument
940 cdnsp_inc_deq(pdev, ep_ring); in cdnsp_finish_td()
942 cdnsp_inc_deq(pdev, ep_ring); in cdnsp_finish_td()
944 cdnsp_td_cleanup(pdev, td, ep_ring, status); in cdnsp_finish_td()
948 static int cdnsp_sum_trb_lengths(struct cdnsp_device *pdev, in cdnsp_sum_trb_lengths() argument
956 for (sum = 0; trb != stop_trb; cdnsp_next_trb(pdev, ring, &seg, &trb)) { in cdnsp_sum_trb_lengths()
963 static int cdnsp_giveback_first_trb(struct cdnsp_device *pdev, in cdnsp_giveback_first_trb() argument
986 return cdnsp_ring_ep_doorbell(pdev, pep, stream_id); in cdnsp_giveback_first_trb()
992 static void cdnsp_process_ctrl_td(struct cdnsp_device *pdev, in cdnsp_process_ctrl_td() argument
1021 if (pdev->ep0_stage == CDNSP_DATA_STAGE && pep->number == 0 && in cdnsp_process_ctrl_td()
1022 pdev->three_stage_setup) { in cdnsp_process_ctrl_td()
1025 pdev->ep0_stage = CDNSP_STATUS_STAGE; in cdnsp_process_ctrl_td()
1027 cdnsp_giveback_first_trb(pdev, pep, 0, ep_ring->cycle_state, in cdnsp_process_ctrl_td()
1034 cdnsp_finish_td(pdev, td, event, pep, status); in cdnsp_process_ctrl_td()
1040 static void cdnsp_process_isoc_td(struct cdnsp_device *pdev, in cdnsp_process_isoc_td() argument
1093 td_length = cdnsp_sum_trb_lengths(pdev, ep_ring, ep_trb); in cdnsp_process_isoc_td()
1101 cdnsp_finish_td(pdev, td, event, pep, &status); in cdnsp_process_isoc_td()
1104 static void cdnsp_skip_isoc_td(struct cdnsp_device *pdev, in cdnsp_skip_isoc_td() argument
1118 cdnsp_inc_deq(pdev, ep_ring); in cdnsp_skip_isoc_td()
1120 cdnsp_inc_deq(pdev, ep_ring); in cdnsp_skip_isoc_td()
1122 cdnsp_td_cleanup(pdev, td, ep_ring, &status); in cdnsp_skip_isoc_td()
1128 static void cdnsp_process_bulk_intr_td(struct cdnsp_device *pdev, in cdnsp_process_bulk_intr_td() argument
1163 ep_trb_len = cdnsp_sum_trb_lengths(pdev, ep_ring, ep_trb) + in cdnsp_process_bulk_intr_td()
1170 cdnsp_finish_td(pdev, td, event, ep, status); in cdnsp_process_bulk_intr_td()
1173 static void cdnsp_handle_tx_nrdy(struct cdnsp_device *pdev, in cdnsp_handle_tx_nrdy() argument
1189 pep = &pdev->eps[ep_index]; in cdnsp_handle_tx_nrdy()
1218 cdnsp_ring_doorbell_for_active_rings(pdev, pep); in cdnsp_handle_tx_nrdy()
1225 static int cdnsp_handle_tx_event(struct cdnsp_device *pdev, in cdnsp_handle_tx_event() argument
1246 pep = &pdev->eps[ep_index]; in cdnsp_handle_tx_event()
1254 if (invalidate || !pdev->gadget.connected) in cdnsp_handle_tx_event()
1271 dev_err(pdev->dev, "ERROR: %s event for unknown ring\n", in cdnsp_handle_tx_event()
1332 ep_seg = cdnsp_trb_in_td(pdev, ep_ring->deq_seg, in cdnsp_handle_tx_event()
1354 dev_err(pdev->dev, in cdnsp_handle_tx_event()
1362 cdnsp_skip_isoc_td(pdev, td, event, pep, status); in cdnsp_handle_tx_event()
1373 cdnsp_skip_isoc_td(pdev, td, event, pep, status); in cdnsp_handle_tx_event()
1387 cdnsp_process_ctrl_td(pdev, td, ep_trb, event, pep, in cdnsp_handle_tx_event()
1390 cdnsp_process_isoc_td(pdev, td, ep_trb, event, pep, in cdnsp_handle_tx_event()
1393 cdnsp_process_bulk_intr_td(pdev, td, ep_trb, event, pep, in cdnsp_handle_tx_event()
1403 cdnsp_inc_deq(pdev, pdev->event_ring); in cdnsp_handle_tx_event()
1415 dev_err(pdev->dev, "@%016llx %08x %08x %08x %08x\n", in cdnsp_handle_tx_event()
1417 cdnsp_trb_virt_to_dma(pdev->event_ring->deq_seg, in cdnsp_handle_tx_event()
1418 pdev->event_ring->dequeue), in cdnsp_handle_tx_event()
1431 static bool cdnsp_handle_event(struct cdnsp_device *pdev) in cdnsp_handle_event() argument
1440 event = pdev->event_ring->dequeue; in cdnsp_handle_event()
1445 if (cycle_bit != pdev->event_ring->cycle_state) in cdnsp_handle_event()
1448 trace_cdnsp_handle_event(pdev->event_ring, &event->generic); in cdnsp_handle_event()
1462 cdnsp_inc_deq(pdev, pdev->cmd_ring); in cdnsp_handle_event()
1465 cdnsp_handle_port_status(pdev, event); in cdnsp_handle_event()
1469 ret = cdnsp_handle_tx_event(pdev, &event->trans_event); in cdnsp_handle_event()
1474 pdev->ep0_stage = CDNSP_SETUP_STAGE; in cdnsp_handle_event()
1475 pdev->setup_id = TRB_SETUPID_TO_TYPE(flags); in cdnsp_handle_event()
1476 pdev->setup_speed = TRB_SETUP_SPEEDID(flags); in cdnsp_handle_event()
1477 pdev->setup = *((struct usb_ctrlrequest *) in cdnsp_handle_event()
1480 cdnsp_setup_analyze(pdev); in cdnsp_handle_event()
1483 cdnsp_handle_tx_nrdy(pdev, &event->trans_event); in cdnsp_handle_event()
1490 dev_err(pdev->dev, "Event Ring Full\n"); in cdnsp_handle_event()
1493 dev_err(pdev->dev, "Controller error code 0x%02x\n", in cdnsp_handle_event()
1503 dev_warn(pdev->dev, "ERROR unknown event type %ld\n", in cdnsp_handle_event()
1509 cdnsp_inc_deq(pdev, pdev->event_ring); in cdnsp_handle_event()
1520 struct cdnsp_device *pdev = (struct cdnsp_device *)data; in cdnsp_thread_irq_handler() local
1525 spin_lock_irqsave(&pdev->lock, flags); in cdnsp_thread_irq_handler()
1527 if (pdev->cdnsp_state & (CDNSP_STATE_HALTED | CDNSP_STATE_DYING)) { in cdnsp_thread_irq_handler()
1533 if (pdev->gadget_driver) in cdnsp_thread_irq_handler()
1534 cdnsp_died(pdev); in cdnsp_thread_irq_handler()
1536 spin_unlock_irqrestore(&pdev->lock, flags); in cdnsp_thread_irq_handler()
1540 event_ring_deq = pdev->event_ring->dequeue; in cdnsp_thread_irq_handler()
1542 while (cdnsp_handle_event(pdev)) { in cdnsp_thread_irq_handler()
1544 cdnsp_update_erst_dequeue(pdev, event_ring_deq, 0); in cdnsp_thread_irq_handler()
1545 event_ring_deq = pdev->event_ring->dequeue; in cdnsp_thread_irq_handler()
1550 cdnsp_update_erst_dequeue(pdev, event_ring_deq, 1); in cdnsp_thread_irq_handler()
1552 spin_unlock_irqrestore(&pdev->lock, flags); in cdnsp_thread_irq_handler()
1559 struct cdnsp_device *pdev = (struct cdnsp_device *)priv; in cdnsp_irq_handler() local
1563 status = readl(&pdev->op_regs->status); in cdnsp_irq_handler()
1566 cdnsp_died(pdev); in cdnsp_irq_handler()
1573 writel(status | STS_EINT, &pdev->op_regs->status); in cdnsp_irq_handler()
1574 irq_pending = readl(&pdev->ir_set->irq_pending); in cdnsp_irq_handler()
1576 writel(irq_pending, &pdev->ir_set->irq_pending); in cdnsp_irq_handler()
1579 cdnsp_died(pdev); in cdnsp_irq_handler()
1592 static void cdnsp_queue_trb(struct cdnsp_device *pdev, struct cdnsp_ring *ring, in cdnsp_queue_trb() argument
1606 cdnsp_inc_enq(pdev, ring, more_trbs_coming); in cdnsp_queue_trb()
1613 static int cdnsp_prepare_ring(struct cdnsp_device *pdev, in cdnsp_prepare_ring() argument
1628 dev_err(pdev->dev, "ERROR: incorrect endpoint state\n"); in cdnsp_prepare_ring()
1633 if (cdnsp_room_on_ring(pdev, ep_ring, num_trbs)) in cdnsp_prepare_ring()
1639 if (cdnsp_ring_expansion(pdev, ep_ring, num_trbs_needed, in cdnsp_prepare_ring()
1641 dev_err(pdev->dev, "Ring expansion failed\n"); in cdnsp_prepare_ring()
1661 static int cdnsp_prepare_transfer(struct cdnsp_device *pdev, in cdnsp_prepare_transfer() argument
1668 ep_ring = cdnsp_get_transfer_ring(pdev, preq->pep, in cdnsp_prepare_transfer()
1673 ret = cdnsp_prepare_ring(pdev, ep_ring, in cdnsp_prepare_transfer()
1737 dev_err(preq->pep->pdev->dev, in cdnsp_check_trb_math()
1761 static u32 cdnsp_td_remainder(struct cdnsp_device *pdev, in cdnsp_td_remainder() argument
1782 static int cdnsp_align_td(struct cdnsp_device *pdev, in cdnsp_align_td() argument
1786 struct device *dev = pdev->dev; in cdnsp_align_td()
1830 dev_warn(pdev->dev, in cdnsp_align_td()
1849 int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) in cdnsp_queue_bulk_tx() argument
1866 ring = cdnsp_request_to_transfer_ring(pdev, preq); in cdnsp_queue_bulk_tx()
1893 ret = cdnsp_prepare_transfer(pdev, preq, num_trbs); in cdnsp_queue_bulk_tx()
1933 if (cdnsp_align_td(pdev, preq, enqd_len, in cdnsp_queue_bulk_tx()
1958 remainder = cdnsp_td_remainder(pdev, enqd_len, trb_buff_len, in cdnsp_queue_bulk_tx()
1965 cdnsp_queue_trb(pdev, ring, more_trbs_coming | zero_len_trb, in cdnsp_queue_bulk_tx()
1989 ret = cdnsp_giveback_first_trb(pdev, pep, preq->request.stream_id, in cdnsp_queue_bulk_tx()
1998 int cdnsp_queue_ctrl_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq) in cdnsp_queue_ctrl_tx() argument
2006 ep_ring = cdnsp_request_to_transfer_ring(pdev, preq); in cdnsp_queue_ctrl_tx()
2011 num_trbs = (pdev->three_stage_setup) ? 2 : 1; in cdnsp_queue_ctrl_tx()
2013 ret = cdnsp_prepare_transfer(pdev, preq, num_trbs); in cdnsp_queue_ctrl_tx()
2018 if (pdev->ep0_expect_in) in cdnsp_queue_ctrl_tx()
2024 remainder = cdnsp_td_remainder(pdev, 0, preq->request.length, in cdnsp_queue_ctrl_tx()
2030 if (pdev->ep0_expect_in) in cdnsp_queue_ctrl_tx()
2033 cdnsp_queue_trb(pdev, ep_ring, true, in cdnsp_queue_ctrl_tx()
2037 TRB_SETUPID(pdev->setup_id) | in cdnsp_queue_ctrl_tx()
2038 pdev->setup_speed); in cdnsp_queue_ctrl_tx()
2040 pdev->ep0_stage = CDNSP_DATA_STAGE; in cdnsp_queue_ctrl_tx()
2052 if (preq->request.length > 0 && pdev->ep0_expect_in) in cdnsp_queue_ctrl_tx()
2062 cdnsp_queue_trb(pdev, ep_ring, false, 0, 0, TRB_INTR_TARGET(0), in cdnsp_queue_ctrl_tx()
2063 field | TRB_IOC | TRB_SETUPID(pdev->setup_id) | in cdnsp_queue_ctrl_tx()
2064 TRB_TYPE(TRB_STATUS) | pdev->setup_speed); in cdnsp_queue_ctrl_tx()
2066 cdnsp_ring_ep_doorbell(pdev, pep, preq->request.stream_id); in cdnsp_queue_ctrl_tx()
2071 int cdnsp_cmd_stop_ep(struct cdnsp_device *pdev, struct cdnsp_ep *pep) in cdnsp_cmd_stop_ep() argument
2081 cdnsp_queue_stop_endpoint(pdev, pep->idx); in cdnsp_cmd_stop_ep()
2082 cdnsp_ring_cmd_db(pdev); in cdnsp_cmd_stop_ep()
2083 ret = cdnsp_wait_for_cmd_compl(pdev); in cdnsp_cmd_stop_ep()
2092 int cdnsp_cmd_flush_ep(struct cdnsp_device *pdev, struct cdnsp_ep *pep) in cdnsp_cmd_flush_ep() argument
2096 cdnsp_queue_flush_endpoint(pdev, pep->idx); in cdnsp_cmd_flush_ep()
2097 cdnsp_ring_cmd_db(pdev); in cdnsp_cmd_flush_ep()
2098 ret = cdnsp_wait_for_cmd_compl(pdev); in cdnsp_cmd_flush_ep()
2113 static unsigned int cdnsp_get_burst_count(struct cdnsp_device *pdev, in cdnsp_get_burst_count() argument
2119 if (pdev->gadget.speed < USB_SPEED_SUPER) in cdnsp_get_burst_count()
2135 cdnsp_get_last_burst_packet_count(struct cdnsp_device *pdev, in cdnsp_get_last_burst_packet_count() argument
2142 if (pdev->gadget.speed >= USB_SPEED_SUPER) { in cdnsp_get_last_burst_packet_count()
2163 static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev, in cdnsp_queue_isoc_tx() argument
2193 burst_count = cdnsp_get_burst_count(pdev, preq, total_pkt_count); in cdnsp_queue_isoc_tx()
2194 last_burst_pkt = cdnsp_get_last_burst_packet_count(pdev, preq, in cdnsp_queue_isoc_tx()
2198 ret = cdnsp_prepare_transfer(pdev, preq, trbs_per_td); in cdnsp_queue_isoc_tx()
2223 remainder = cdnsp_td_remainder(pdev, running_total, in cdnsp_queue_isoc_tx()
2251 cdnsp_queue_trb(pdev, ep_ring, more_trbs_coming, in cdnsp_queue_isoc_tx()
2262 dev_err(pdev->dev, "ISOC TD length unmatch\n"); in cdnsp_queue_isoc_tx()
2267 cdnsp_giveback_first_trb(pdev, preq->pep, preq->request.stream_id, in cdnsp_queue_isoc_tx()
2286 cdnsp_td_to_noop(pdev, ep_ring, &preq->td, true); in cdnsp_queue_isoc_tx()
2295 int cdnsp_queue_isoc_tx_prepare(struct cdnsp_device *pdev, in cdnsp_queue_isoc_tx_prepare() argument
2312 ret = cdnsp_prepare_ring(pdev, ep_ring, ep_state, num_trbs, GFP_ATOMIC); in cdnsp_queue_isoc_tx_prepare()
2316 return cdnsp_queue_isoc_tx(pdev, preq); in cdnsp_queue_isoc_tx_prepare()
2324 static void cdnsp_queue_command(struct cdnsp_device *pdev, in cdnsp_queue_command() argument
2330 cdnsp_prepare_ring(pdev, pdev->cmd_ring, EP_STATE_RUNNING, 1, in cdnsp_queue_command()
2333 pdev->cmd.command_trb = pdev->cmd_ring->enqueue; in cdnsp_queue_command()
2335 cdnsp_queue_trb(pdev, pdev->cmd_ring, false, field1, field2, in cdnsp_queue_command()
2336 field3, field4 | pdev->cmd_ring->cycle_state); in cdnsp_queue_command()
2340 void cdnsp_queue_slot_control(struct cdnsp_device *pdev, u32 trb_type) in cdnsp_queue_slot_control() argument
2342 cdnsp_queue_command(pdev, 0, 0, 0, TRB_TYPE(trb_type) | in cdnsp_queue_slot_control()
2343 SLOT_ID_FOR_TRB(pdev->slot_id)); in cdnsp_queue_slot_control()
2347 void cdnsp_queue_address_device(struct cdnsp_device *pdev, in cdnsp_queue_address_device() argument
2351 cdnsp_queue_command(pdev, lower_32_bits(in_ctx_ptr), in cdnsp_queue_address_device()
2354 SLOT_ID_FOR_TRB(pdev->slot_id) | in cdnsp_queue_address_device()
2359 void cdnsp_queue_reset_device(struct cdnsp_device *pdev) in cdnsp_queue_reset_device() argument
2361 cdnsp_queue_command(pdev, 0, 0, 0, TRB_TYPE(TRB_RESET_DEV) | in cdnsp_queue_reset_device()
2362 SLOT_ID_FOR_TRB(pdev->slot_id)); in cdnsp_queue_reset_device()
2366 void cdnsp_queue_configure_endpoint(struct cdnsp_device *pdev, in cdnsp_queue_configure_endpoint() argument
2369 cdnsp_queue_command(pdev, lower_32_bits(in_ctx_ptr), in cdnsp_queue_configure_endpoint()
2372 SLOT_ID_FOR_TRB(pdev->slot_id)); in cdnsp_queue_configure_endpoint()
2379 void cdnsp_queue_stop_endpoint(struct cdnsp_device *pdev, unsigned int ep_index) in cdnsp_queue_stop_endpoint() argument
2381 cdnsp_queue_command(pdev, 0, 0, 0, SLOT_ID_FOR_TRB(pdev->slot_id) | in cdnsp_queue_stop_endpoint()
2386 void cdnsp_queue_new_dequeue_state(struct cdnsp_device *pdev, in cdnsp_queue_new_dequeue_state() argument
2391 u32 trb_slot_id = SLOT_ID_FOR_TRB(pdev->slot_id); in cdnsp_queue_new_dequeue_state()
2402 cdnsp_queue_command(pdev, lower_32_bits(addr) | trb_sct | in cdnsp_queue_new_dequeue_state()
2408 void cdnsp_queue_reset_ep(struct cdnsp_device *pdev, unsigned int ep_index) in cdnsp_queue_reset_ep() argument
2410 return cdnsp_queue_command(pdev, 0, 0, 0, in cdnsp_queue_reset_ep()
2411 SLOT_ID_FOR_TRB(pdev->slot_id) | in cdnsp_queue_reset_ep()
2419 void cdnsp_queue_halt_endpoint(struct cdnsp_device *pdev, unsigned int ep_index) in cdnsp_queue_halt_endpoint() argument
2421 cdnsp_queue_command(pdev, 0, 0, 0, TRB_TYPE(TRB_HALT_ENDPOINT) | in cdnsp_queue_halt_endpoint()
2422 SLOT_ID_FOR_TRB(pdev->slot_id) | in cdnsp_queue_halt_endpoint()
2429 void cdnsp_queue_flush_endpoint(struct cdnsp_device *pdev, in cdnsp_queue_flush_endpoint() argument
2432 cdnsp_queue_command(pdev, 0, 0, 0, TRB_TYPE(TRB_FLUSH_ENDPOINT) | in cdnsp_queue_flush_endpoint()
2433 SLOT_ID_FOR_TRB(pdev->slot_id) | in cdnsp_queue_flush_endpoint()
2437 void cdnsp_force_header_wakeup(struct cdnsp_device *pdev, int intf_num) in cdnsp_force_header_wakeup() argument
2442 TRB_FH_TO_DEVICE_ADDRESS(pdev->device_address); in cdnsp_force_header_wakeup()
2447 cdnsp_queue_command(pdev, lo, mid, 0, in cdnsp_force_header_wakeup()