Lines Matching refs:hsotg

68 static void dwc2_dump_channel_info(struct dwc2_hsotg *hsotg,  in dwc2_dump_channel_info()  argument
72 int num_channels = hsotg->core_params->host_channels; in dwc2_dump_channel_info()
83 hcchar = dwc2_readl(hsotg->regs + HCCHAR(chan->hc_num)); in dwc2_dump_channel_info()
84 hcsplt = dwc2_readl(hsotg->regs + HCSPLT(chan->hc_num)); in dwc2_dump_channel_info()
85 hctsiz = dwc2_readl(hsotg->regs + HCTSIZ(chan->hc_num)); in dwc2_dump_channel_info()
86 hc_dma = dwc2_readl(hsotg->regs + HCDMA(chan->hc_num)); in dwc2_dump_channel_info()
88 dev_dbg(hsotg->dev, " Assigned to channel %p:\n", chan); in dwc2_dump_channel_info()
89 dev_dbg(hsotg->dev, " hcchar 0x%08x, hcsplt 0x%08x\n", in dwc2_dump_channel_info()
91 dev_dbg(hsotg->dev, " hctsiz 0x%08x, hc_dma 0x%08x\n", in dwc2_dump_channel_info()
93 dev_dbg(hsotg->dev, " dev_addr: %d, ep_num: %d, ep_is_in: %d\n", in dwc2_dump_channel_info()
95 dev_dbg(hsotg->dev, " ep_type: %d\n", chan->ep_type); in dwc2_dump_channel_info()
96 dev_dbg(hsotg->dev, " max_packet: %d\n", chan->max_packet); in dwc2_dump_channel_info()
97 dev_dbg(hsotg->dev, " data_pid_start: %d\n", chan->data_pid_start); in dwc2_dump_channel_info()
98 dev_dbg(hsotg->dev, " xfer_started: %d\n", chan->xfer_started); in dwc2_dump_channel_info()
99 dev_dbg(hsotg->dev, " halt_status: %d\n", chan->halt_status); in dwc2_dump_channel_info()
100 dev_dbg(hsotg->dev, " xfer_buf: %p\n", chan->xfer_buf); in dwc2_dump_channel_info()
101 dev_dbg(hsotg->dev, " xfer_dma: %08lx\n", in dwc2_dump_channel_info()
103 dev_dbg(hsotg->dev, " xfer_len: %d\n", chan->xfer_len); in dwc2_dump_channel_info()
104 dev_dbg(hsotg->dev, " qh: %p\n", chan->qh); in dwc2_dump_channel_info()
105 dev_dbg(hsotg->dev, " NP inactive sched:\n"); in dwc2_dump_channel_info()
106 list_for_each_entry(qh, &hsotg->non_periodic_sched_inactive, in dwc2_dump_channel_info()
108 dev_dbg(hsotg->dev, " %p\n", qh); in dwc2_dump_channel_info()
109 dev_dbg(hsotg->dev, " NP active sched:\n"); in dwc2_dump_channel_info()
110 list_for_each_entry(qh, &hsotg->non_periodic_sched_active, in dwc2_dump_channel_info()
112 dev_dbg(hsotg->dev, " %p\n", qh); in dwc2_dump_channel_info()
113 dev_dbg(hsotg->dev, " Channels:\n"); in dwc2_dump_channel_info()
115 struct dwc2_host_chan *chan = hsotg->hc_ptr_array[i]; in dwc2_dump_channel_info()
117 dev_dbg(hsotg->dev, " %2d: %p\n", i, chan); in dwc2_dump_channel_info()
128 static void dwc2_kill_urbs_in_qh_list(struct dwc2_hsotg *hsotg, in dwc2_kill_urbs_in_qh_list() argument
137 dwc2_host_complete(hsotg, qtd, -ECONNRESET); in dwc2_kill_urbs_in_qh_list()
138 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_kill_urbs_in_qh_list()
143 static void dwc2_qh_list_free(struct dwc2_hsotg *hsotg, in dwc2_qh_list_free() argument
154 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_qh_list_free()
157 dwc2_kill_urbs_in_qh_list(hsotg, qh_list); in dwc2_qh_list_free()
160 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_qh_list_free()
165 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_qh_list_free()
167 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_qh_list_free()
168 dwc2_hcd_qh_free(hsotg, qh); in dwc2_qh_list_free()
169 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_qh_list_free()
172 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_qh_list_free()
183 static void dwc2_kill_all_urbs(struct dwc2_hsotg *hsotg) in dwc2_kill_all_urbs() argument
185 dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->non_periodic_sched_inactive); in dwc2_kill_all_urbs()
186 dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->non_periodic_sched_active); in dwc2_kill_all_urbs()
187 dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->periodic_sched_inactive); in dwc2_kill_all_urbs()
188 dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->periodic_sched_ready); in dwc2_kill_all_urbs()
189 dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->periodic_sched_assigned); in dwc2_kill_all_urbs()
190 dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->periodic_sched_queued); in dwc2_kill_all_urbs()
198 void dwc2_hcd_start(struct dwc2_hsotg *hsotg) in dwc2_hcd_start() argument
202 if (hsotg->op_state == OTG_STATE_B_HOST) { in dwc2_hcd_start()
208 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_start()
210 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_start()
213 queue_delayed_work(hsotg->wq_otg, &hsotg->start_work, in dwc2_hcd_start()
218 static void dwc2_hcd_cleanup_channels(struct dwc2_hsotg *hsotg) in dwc2_hcd_cleanup_channels() argument
220 int num_channels = hsotg->core_params->host_channels; in dwc2_hcd_cleanup_channels()
225 if (hsotg->core_params->dma_enable <= 0) { in dwc2_hcd_cleanup_channels()
228 channel = hsotg->hc_ptr_array[i]; in dwc2_hcd_cleanup_channels()
231 hcchar = dwc2_readl(hsotg->regs + HCCHAR(i)); in dwc2_hcd_cleanup_channels()
235 dwc2_writel(hcchar, hsotg->regs + HCCHAR(i)); in dwc2_hcd_cleanup_channels()
241 channel = hsotg->hc_ptr_array[i]; in dwc2_hcd_cleanup_channels()
244 hcchar = dwc2_readl(hsotg->regs + HCCHAR(i)); in dwc2_hcd_cleanup_channels()
248 dwc2_writel(hcchar, hsotg->regs + HCCHAR(i)); in dwc2_hcd_cleanup_channels()
251 dwc2_hc_cleanup(hsotg, channel); in dwc2_hcd_cleanup_channels()
252 list_add_tail(&channel->hc_list_entry, &hsotg->free_hc_list); in dwc2_hcd_cleanup_channels()
261 if (hsotg->core_params->uframe_sched > 0) { in dwc2_hcd_cleanup_channels()
262 hsotg->available_host_channels = in dwc2_hcd_cleanup_channels()
263 hsotg->core_params->host_channels; in dwc2_hcd_cleanup_channels()
265 hsotg->non_periodic_channels = 0; in dwc2_hcd_cleanup_channels()
266 hsotg->periodic_channels = 0; in dwc2_hcd_cleanup_channels()
277 void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) in dwc2_hcd_disconnect() argument
282 hsotg->flags.b.port_connect_status_change = 1; in dwc2_hcd_disconnect()
283 hsotg->flags.b.port_connect_status = 0; in dwc2_hcd_disconnect()
290 intr = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_hcd_disconnect()
292 dwc2_writel(intr, hsotg->regs + GINTMSK); in dwc2_hcd_disconnect()
294 dwc2_writel(intr, hsotg->regs + GINTSTS); in dwc2_hcd_disconnect()
301 if (dwc2_is_device_mode(hsotg)) { in dwc2_hcd_disconnect()
302 if (hsotg->op_state != OTG_STATE_A_SUSPEND) { in dwc2_hcd_disconnect()
303 dev_dbg(hsotg->dev, "Disconnect: PortPower off\n"); in dwc2_hcd_disconnect()
304 dwc2_writel(0, hsotg->regs + HPRT0); in dwc2_hcd_disconnect()
307 dwc2_disable_host_interrupts(hsotg); in dwc2_hcd_disconnect()
311 dwc2_kill_all_urbs(hsotg); in dwc2_hcd_disconnect()
313 if (dwc2_is_host_mode(hsotg)) in dwc2_hcd_disconnect()
315 dwc2_hcd_cleanup_channels(hsotg); in dwc2_hcd_disconnect()
317 dwc2_host_disconnect(hsotg); in dwc2_hcd_disconnect()
325 static void dwc2_hcd_rem_wakeup(struct dwc2_hsotg *hsotg) in dwc2_hcd_rem_wakeup() argument
327 if (hsotg->bus_suspended) { in dwc2_hcd_rem_wakeup()
328 hsotg->flags.b.port_suspend_change = 1; in dwc2_hcd_rem_wakeup()
329 usb_hcd_resume_root_hub(hsotg->priv); in dwc2_hcd_rem_wakeup()
332 if (hsotg->lx_state == DWC2_L1) in dwc2_hcd_rem_wakeup()
333 hsotg->flags.b.port_l1_change = 1; in dwc2_hcd_rem_wakeup()
343 void dwc2_hcd_stop(struct dwc2_hsotg *hsotg) in dwc2_hcd_stop() argument
345 dev_dbg(hsotg->dev, "DWC OTG HCD STOP\n"); in dwc2_hcd_stop()
354 dwc2_disable_host_interrupts(hsotg); in dwc2_hcd_stop()
357 dev_dbg(hsotg->dev, "PortPower off\n"); in dwc2_hcd_stop()
358 dwc2_writel(0, hsotg->regs + HPRT0); in dwc2_hcd_stop()
362 static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, in dwc2_hcd_urb_enqueue() argument
370 if (!hsotg->flags.b.port_connect_status) { in dwc2_hcd_urb_enqueue()
372 dev_err(hsotg->dev, "Not connected\n"); in dwc2_hcd_urb_enqueue()
376 dev_speed = dwc2_host_get_speed(hsotg, urb->priv); in dwc2_hcd_urb_enqueue()
380 (hsotg->hw_params.fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED) && in dwc2_hcd_urb_enqueue()
381 (hsotg->hw_params.hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI)) { in dwc2_hcd_urb_enqueue()
382 u32 hprt0 = dwc2_readl(hsotg->regs + HPRT0); in dwc2_hcd_urb_enqueue()
393 retval = dwc2_hcd_qtd_add(hsotg, qtd, qh); in dwc2_hcd_urb_enqueue()
395 dev_err(hsotg->dev, in dwc2_hcd_urb_enqueue()
401 intr_mask = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_hcd_urb_enqueue()
413 tr_type = dwc2_hcd_select_transactions(hsotg); in dwc2_hcd_urb_enqueue()
415 dwc2_hcd_queue_transactions(hsotg, tr_type); in dwc2_hcd_urb_enqueue()
422 static int dwc2_hcd_urb_dequeue(struct dwc2_hsotg *hsotg, in dwc2_hcd_urb_dequeue() argument
430 dev_dbg(hsotg->dev, "## Urb QTD is NULL ##\n"); in dwc2_hcd_urb_dequeue()
436 dev_dbg(hsotg->dev, "## Urb QTD QH is NULL ##\n"); in dwc2_hcd_urb_dequeue()
443 dwc2_dump_channel_info(hsotg, qh->channel); in dwc2_hcd_urb_dequeue()
446 if (hsotg->flags.b.port_connect_status) in dwc2_hcd_urb_dequeue()
454 dwc2_hc_halt(hsotg, qh->channel, in dwc2_hcd_urb_dequeue()
462 if (hsotg->core_params->dma_desc_enable <= 0) { in dwc2_hcd_urb_dequeue()
465 dwc2_hcd_qtd_unlink_and_free(hsotg, urb_qtd, qh); in dwc2_hcd_urb_dequeue()
467 dwc2_hcd_qh_deactivate(hsotg, qh, 0); in dwc2_hcd_urb_dequeue()
470 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_urb_dequeue()
473 dwc2_hcd_qtd_unlink_and_free(hsotg, urb_qtd, qh); in dwc2_hcd_urb_dequeue()
480 static int dwc2_hcd_endpoint_disable(struct dwc2_hsotg *hsotg, in dwc2_hcd_endpoint_disable() argument
488 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hcd_endpoint_disable()
498 dev_err(hsotg->dev, in dwc2_hcd_endpoint_disable()
504 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hcd_endpoint_disable()
506 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hcd_endpoint_disable()
514 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_endpoint_disable()
518 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_hcd_endpoint_disable()
521 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hcd_endpoint_disable()
522 dwc2_hcd_qh_free(hsotg, qh); in dwc2_hcd_endpoint_disable()
528 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hcd_endpoint_disable()
534 static int dwc2_hcd_endpoint_reset(struct dwc2_hsotg *hsotg, in dwc2_hcd_endpoint_reset() argument
552 static void dwc2_hcd_reinit(struct dwc2_hsotg *hsotg) in dwc2_hcd_reinit() argument
558 hsotg->flags.d32 = 0; in dwc2_hcd_reinit()
559 hsotg->non_periodic_qh_ptr = &hsotg->non_periodic_sched_active; in dwc2_hcd_reinit()
561 if (hsotg->core_params->uframe_sched > 0) { in dwc2_hcd_reinit()
562 hsotg->available_host_channels = in dwc2_hcd_reinit()
563 hsotg->core_params->host_channels; in dwc2_hcd_reinit()
565 hsotg->non_periodic_channels = 0; in dwc2_hcd_reinit()
566 hsotg->periodic_channels = 0; in dwc2_hcd_reinit()
573 list_for_each_entry_safe(chan, chan_tmp, &hsotg->free_hc_list, in dwc2_hcd_reinit()
577 num_channels = hsotg->core_params->host_channels; in dwc2_hcd_reinit()
579 chan = hsotg->hc_ptr_array[i]; in dwc2_hcd_reinit()
580 list_add_tail(&chan->hc_list_entry, &hsotg->free_hc_list); in dwc2_hcd_reinit()
581 dwc2_hc_cleanup(hsotg, chan); in dwc2_hcd_reinit()
585 dwc2_core_host_init(hsotg); in dwc2_hcd_reinit()
588 static void dwc2_hc_init_split(struct dwc2_hsotg *hsotg, in dwc2_hc_init_split() argument
597 dwc2_host_hub_info(hsotg, urb->priv, &hub_addr, &hub_port); in dwc2_hc_init_split()
602 static void *dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg, in dwc2_hc_init_xfer() argument
615 dev_vdbg(hsotg->dev, " Control setup transaction\n"); in dwc2_hc_init_xfer()
619 if (hsotg->core_params->dma_enable > 0) in dwc2_hc_init_xfer()
628 dev_vdbg(hsotg->dev, " Control data transaction\n"); in dwc2_hc_init_xfer()
637 dev_vdbg(hsotg->dev, " Control status transaction\n"); in dwc2_hc_init_xfer()
647 if (hsotg->core_params->dma_enable > 0) in dwc2_hc_init_xfer()
648 chan->xfer_dma = hsotg->status_buf_dma; in dwc2_hc_init_xfer()
650 chan->xfer_buf = hsotg->status_buf; in dwc2_hc_init_xfer()
666 if (hsotg->core_params->dma_desc_enable > 0) in dwc2_hc_init_xfer()
672 if (hsotg->core_params->dma_enable > 0) { in dwc2_hc_init_xfer()
685 if (hsotg->core_params->dma_enable > 0 && in dwc2_hc_init_xfer()
704 static int dwc2_hc_setup_align_buf(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_hc_setup_align_buf() argument
714 buf_size = hsotg->core_params->max_transfer_size; in dwc2_hc_setup_align_buf()
726 dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__); in dwc2_hc_setup_align_buf()
733 hcd = dwc2_hsotg_to_hcd(hsotg); in dwc2_hc_setup_align_buf()
740 dev_warn(hsotg->dev, "no URB in dwc2_urb\n"); in dwc2_hc_setup_align_buf()
744 qh->dw_align_buf_dma = dma_map_single(hsotg->dev, in dwc2_hc_setup_align_buf()
747 if (dma_mapping_error(hsotg->dev, qh->dw_align_buf_dma)) { in dwc2_hc_setup_align_buf()
748 dev_err(hsotg->dev, "can't map align_buf\n"); in dwc2_hc_setup_align_buf()
766 static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_assign_and_init_hc() argument
774 dev_vdbg(hsotg->dev, "%s(%p,%p)\n", __func__, hsotg, qh); in dwc2_assign_and_init_hc()
777 dev_dbg(hsotg->dev, "No QTDs in QH list\n"); in dwc2_assign_and_init_hc()
781 if (list_empty(&hsotg->free_hc_list)) { in dwc2_assign_and_init_hc()
782 dev_dbg(hsotg->dev, "No free channel to assign\n"); in dwc2_assign_and_init_hc()
786 chan = list_first_entry(&hsotg->free_hc_list, struct dwc2_host_chan, in dwc2_assign_and_init_hc()
833 if (hsotg->core_params->dma_enable > 0) { in dwc2_assign_and_init_hc()
837 if (hsotg->core_params->dma_desc_enable <= 0 && in dwc2_assign_and_init_hc()
849 dwc2_hc_init_split(hsotg, chan, qtd, urb); in dwc2_assign_and_init_hc()
854 bufptr = dwc2_hc_init_xfer(hsotg, chan, qtd, bufptr); in dwc2_assign_and_init_hc()
858 dev_vdbg(hsotg->dev, "Non-aligned buffer\n"); in dwc2_assign_and_init_hc()
859 if (dwc2_hc_setup_align_buf(hsotg, qh, chan, urb, bufptr)) { in dwc2_assign_and_init_hc()
860 dev_err(hsotg->dev, in dwc2_assign_and_init_hc()
867 &hsotg->free_hc_list); in dwc2_assign_and_init_hc()
884 if (hsotg->core_params->dma_desc_enable > 0) in dwc2_assign_and_init_hc()
887 dwc2_hc_init(hsotg, chan); in dwc2_assign_and_init_hc()
903 struct dwc2_hsotg *hsotg) in dwc2_hcd_select_transactions() argument
911 dev_vdbg(hsotg->dev, " Select Transactions\n"); in dwc2_hcd_select_transactions()
915 qh_ptr = hsotg->periodic_sched_ready.next; in dwc2_hcd_select_transactions()
916 while (qh_ptr != &hsotg->periodic_sched_ready) { in dwc2_hcd_select_transactions()
917 if (list_empty(&hsotg->free_hc_list)) in dwc2_hcd_select_transactions()
919 if (hsotg->core_params->uframe_sched > 0) { in dwc2_hcd_select_transactions()
920 if (hsotg->available_host_channels <= 1) in dwc2_hcd_select_transactions()
922 hsotg->available_host_channels--; in dwc2_hcd_select_transactions()
925 if (dwc2_assign_and_init_hc(hsotg, qh)) in dwc2_hcd_select_transactions()
933 list_move(&qh->qh_list_entry, &hsotg->periodic_sched_assigned); in dwc2_hcd_select_transactions()
942 num_channels = hsotg->core_params->host_channels; in dwc2_hcd_select_transactions()
943 qh_ptr = hsotg->non_periodic_sched_inactive.next; in dwc2_hcd_select_transactions()
944 while (qh_ptr != &hsotg->non_periodic_sched_inactive) { in dwc2_hcd_select_transactions()
945 if (hsotg->core_params->uframe_sched <= 0 && in dwc2_hcd_select_transactions()
946 hsotg->non_periodic_channels >= num_channels - in dwc2_hcd_select_transactions()
947 hsotg->periodic_channels) in dwc2_hcd_select_transactions()
949 if (list_empty(&hsotg->free_hc_list)) in dwc2_hcd_select_transactions()
952 if (hsotg->core_params->uframe_sched > 0) { in dwc2_hcd_select_transactions()
953 if (hsotg->available_host_channels < 1) in dwc2_hcd_select_transactions()
955 hsotg->available_host_channels--; in dwc2_hcd_select_transactions()
958 if (dwc2_assign_and_init_hc(hsotg, qh)) in dwc2_hcd_select_transactions()
967 &hsotg->non_periodic_sched_active); in dwc2_hcd_select_transactions()
974 if (hsotg->core_params->uframe_sched <= 0) in dwc2_hcd_select_transactions()
975 hsotg->non_periodic_channels++; in dwc2_hcd_select_transactions()
1002 static int dwc2_queue_transaction(struct dwc2_hsotg *hsotg, in dwc2_queue_transaction() argument
1008 if (hsotg->core_params->dma_enable > 0) { in dwc2_queue_transaction()
1009 if (hsotg->core_params->dma_desc_enable > 0) { in dwc2_queue_transaction()
1012 dwc2_hcd_start_xfer_ddma(hsotg, chan->qh); in dwc2_queue_transaction()
1016 dwc2_hc_start_transfer(hsotg, chan); in dwc2_queue_transaction()
1022 dwc2_hc_halt(hsotg, chan, chan->halt_status); in dwc2_queue_transaction()
1025 dwc2_hc_start_transfer(hsotg, chan); in dwc2_queue_transaction()
1030 dwc2_hc_start_transfer(hsotg, chan); in dwc2_queue_transaction()
1033 retval = dwc2_hc_continue_transfer(hsotg, chan); in dwc2_queue_transaction()
1040 dwc2_hc_start_transfer(hsotg, chan); in dwc2_queue_transaction()
1043 retval = dwc2_hc_continue_transfer(hsotg, chan); in dwc2_queue_transaction()
1059 static void dwc2_process_periodic_channels(struct dwc2_hsotg *hsotg) in dwc2_process_periodic_channels() argument
1072 dev_vdbg(hsotg->dev, "Queue periodic transactions\n"); in dwc2_process_periodic_channels()
1074 tx_status = dwc2_readl(hsotg->regs + HPTXSTS); in dwc2_process_periodic_channels()
1081 dev_vdbg(hsotg->dev, " P Tx Req Queue Space Avail (before queue): %d\n", in dwc2_process_periodic_channels()
1083 dev_vdbg(hsotg->dev, " P Tx FIFO Space Avail (before queue): %d\n", in dwc2_process_periodic_channels()
1087 qh_ptr = hsotg->periodic_sched_assigned.next; in dwc2_process_periodic_channels()
1088 while (qh_ptr != &hsotg->periodic_sched_assigned) { in dwc2_process_periodic_channels()
1089 tx_status = dwc2_readl(hsotg->regs + HPTXSTS); in dwc2_process_periodic_channels()
1114 if (hsotg->core_params->dma_enable <= 0 && in dwc2_process_periodic_channels()
1116 hsotg->queuing_high_bandwidth = 1; in dwc2_process_periodic_channels()
1120 status = dwc2_queue_transaction(hsotg, qh->channel, fspcavail); in dwc2_process_periodic_channels()
1133 if (hsotg->core_params->dma_enable > 0 || status == 0 || in dwc2_process_periodic_channels()
1141 &hsotg->periodic_sched_queued); in dwc2_process_periodic_channels()
1144 hsotg->queuing_high_bandwidth = 0; in dwc2_process_periodic_channels()
1148 if (hsotg->core_params->dma_enable <= 0) { in dwc2_process_periodic_channels()
1149 tx_status = dwc2_readl(hsotg->regs + HPTXSTS); in dwc2_process_periodic_channels()
1155 dev_vdbg(hsotg->dev, in dwc2_process_periodic_channels()
1158 dev_vdbg(hsotg->dev, in dwc2_process_periodic_channels()
1163 if (!list_empty(&hsotg->periodic_sched_assigned) || in dwc2_process_periodic_channels()
1172 gintmsk = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_process_periodic_channels()
1174 dwc2_writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_process_periodic_channels()
1183 gintmsk = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_process_periodic_channels()
1185 dwc2_writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_process_periodic_channels()
1199 static void dwc2_process_non_periodic_channels(struct dwc2_hsotg *hsotg) in dwc2_process_non_periodic_channels() argument
1212 dev_vdbg(hsotg->dev, "Queue non-periodic transactions\n"); in dwc2_process_non_periodic_channels()
1214 tx_status = dwc2_readl(hsotg->regs + GNPTXSTS); in dwc2_process_non_periodic_channels()
1219 dev_vdbg(hsotg->dev, " NP Tx Req Queue Space Avail (before queue): %d\n", in dwc2_process_non_periodic_channels()
1221 dev_vdbg(hsotg->dev, " NP Tx FIFO Space Avail (before queue): %d\n", in dwc2_process_non_periodic_channels()
1228 if (hsotg->non_periodic_qh_ptr == &hsotg->non_periodic_sched_active) in dwc2_process_non_periodic_channels()
1229 hsotg->non_periodic_qh_ptr = hsotg->non_periodic_qh_ptr->next; in dwc2_process_non_periodic_channels()
1230 orig_qh_ptr = hsotg->non_periodic_qh_ptr; in dwc2_process_non_periodic_channels()
1237 tx_status = dwc2_readl(hsotg->regs + GNPTXSTS); in dwc2_process_non_periodic_channels()
1240 if (hsotg->core_params->dma_enable <= 0 && qspcavail == 0) { in dwc2_process_non_periodic_channels()
1245 qh = list_entry(hsotg->non_periodic_qh_ptr, struct dwc2_qh, in dwc2_process_non_periodic_channels()
1256 status = dwc2_queue_transaction(hsotg, qh->channel, fspcavail); in dwc2_process_non_periodic_channels()
1266 hsotg->non_periodic_qh_ptr = hsotg->non_periodic_qh_ptr->next; in dwc2_process_non_periodic_channels()
1267 if (hsotg->non_periodic_qh_ptr == in dwc2_process_non_periodic_channels()
1268 &hsotg->non_periodic_sched_active) in dwc2_process_non_periodic_channels()
1269 hsotg->non_periodic_qh_ptr = in dwc2_process_non_periodic_channels()
1270 hsotg->non_periodic_qh_ptr->next; in dwc2_process_non_periodic_channels()
1271 } while (hsotg->non_periodic_qh_ptr != orig_qh_ptr); in dwc2_process_non_periodic_channels()
1273 if (hsotg->core_params->dma_enable <= 0) { in dwc2_process_non_periodic_channels()
1274 tx_status = dwc2_readl(hsotg->regs + GNPTXSTS); in dwc2_process_non_periodic_channels()
1279 dev_vdbg(hsotg->dev, in dwc2_process_non_periodic_channels()
1282 dev_vdbg(hsotg->dev, in dwc2_process_non_periodic_channels()
1294 gintmsk = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_process_non_periodic_channels()
1296 dwc2_writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_process_non_periodic_channels()
1305 gintmsk = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_process_non_periodic_channels()
1307 dwc2_writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_process_non_periodic_channels()
1323 void dwc2_hcd_queue_transactions(struct dwc2_hsotg *hsotg, in dwc2_hcd_queue_transactions() argument
1327 dev_vdbg(hsotg->dev, "Queue Transactions\n"); in dwc2_hcd_queue_transactions()
1332 !list_empty(&hsotg->periodic_sched_assigned)) in dwc2_hcd_queue_transactions()
1333 dwc2_process_periodic_channels(hsotg); in dwc2_hcd_queue_transactions()
1338 if (!list_empty(&hsotg->non_periodic_sched_active)) { in dwc2_hcd_queue_transactions()
1339 dwc2_process_non_periodic_channels(hsotg); in dwc2_hcd_queue_transactions()
1345 u32 gintmsk = dwc2_readl(hsotg->regs + GINTMSK); in dwc2_hcd_queue_transactions()
1348 dwc2_writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_hcd_queue_transactions()
1355 struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg, in dwc2_conn_id_status_change() local
1361 dev_dbg(hsotg->dev, "%s()\n", __func__); in dwc2_conn_id_status_change()
1363 gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); in dwc2_conn_id_status_change()
1364 dev_dbg(hsotg->dev, "gotgctl=%0x\n", gotgctl); in dwc2_conn_id_status_change()
1365 dev_dbg(hsotg->dev, "gotgctl.b.conidsts=%d\n", in dwc2_conn_id_status_change()
1371 dev_dbg(hsotg->dev, "connId B\n"); in dwc2_conn_id_status_change()
1372 while (!dwc2_is_device_mode(hsotg)) { in dwc2_conn_id_status_change()
1373 dev_info(hsotg->dev, in dwc2_conn_id_status_change()
1375 dwc2_is_host_mode(hsotg) ? "Host" : in dwc2_conn_id_status_change()
1382 dev_err(hsotg->dev, in dwc2_conn_id_status_change()
1384 hsotg->op_state = OTG_STATE_B_PERIPHERAL; in dwc2_conn_id_status_change()
1385 dwc2_core_init(hsotg, false, -1); in dwc2_conn_id_status_change()
1386 dwc2_enable_global_interrupts(hsotg); in dwc2_conn_id_status_change()
1387 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_conn_id_status_change()
1388 dwc2_hsotg_core_init_disconnected(hsotg, false); in dwc2_conn_id_status_change()
1389 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_conn_id_status_change()
1390 dwc2_hsotg_core_connect(hsotg); in dwc2_conn_id_status_change()
1393 dev_dbg(hsotg->dev, "connId A\n"); in dwc2_conn_id_status_change()
1394 while (!dwc2_is_host_mode(hsotg)) { in dwc2_conn_id_status_change()
1395 dev_info(hsotg->dev, "Waiting for Host Mode, Mode=%s\n", in dwc2_conn_id_status_change()
1396 dwc2_is_host_mode(hsotg) ? in dwc2_conn_id_status_change()
1403 dev_err(hsotg->dev, in dwc2_conn_id_status_change()
1405 hsotg->op_state = OTG_STATE_A_HOST; in dwc2_conn_id_status_change()
1408 dwc2_core_init(hsotg, false, -1); in dwc2_conn_id_status_change()
1409 dwc2_enable_global_interrupts(hsotg); in dwc2_conn_id_status_change()
1410 dwc2_hcd_start(hsotg); in dwc2_conn_id_status_change()
1416 struct dwc2_hsotg *hsotg = (struct dwc2_hsotg *)data; in dwc2_wakeup_detected() local
1419 dev_dbg(hsotg->dev, "%s()\n", __func__); in dwc2_wakeup_detected()
1425 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_wakeup_detected()
1426 dev_dbg(hsotg->dev, "Resume: HPRT0=%0x\n", hprt0); in dwc2_wakeup_detected()
1428 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_wakeup_detected()
1429 dev_dbg(hsotg->dev, "Clear Resume: HPRT0=%0x\n", in dwc2_wakeup_detected()
1430 dwc2_readl(hsotg->regs + HPRT0)); in dwc2_wakeup_detected()
1432 dwc2_hcd_rem_wakeup(hsotg); in dwc2_wakeup_detected()
1433 hsotg->bus_suspended = 0; in dwc2_wakeup_detected()
1436 hsotg->lx_state = DWC2_L0; in dwc2_wakeup_detected()
1439 static int dwc2_host_is_b_hnp_enabled(struct dwc2_hsotg *hsotg) in dwc2_host_is_b_hnp_enabled() argument
1441 struct usb_hcd *hcd = dwc2_hsotg_to_hcd(hsotg); in dwc2_host_is_b_hnp_enabled()
1447 static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, u16 windex) in dwc2_port_suspend() argument
1454 dev_dbg(hsotg->dev, "%s()\n", __func__); in dwc2_port_suspend()
1456 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_port_suspend()
1458 if (windex == hsotg->otg_port && dwc2_host_is_b_hnp_enabled(hsotg)) { in dwc2_port_suspend()
1459 gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); in dwc2_port_suspend()
1461 dwc2_writel(gotgctl, hsotg->regs + GOTGCTL); in dwc2_port_suspend()
1462 hsotg->op_state = OTG_STATE_A_SUSPEND; in dwc2_port_suspend()
1465 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_port_suspend()
1467 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_port_suspend()
1469 hsotg->bus_suspended = 1; in dwc2_port_suspend()
1475 if (!hsotg->core_params->hibernation) { in dwc2_port_suspend()
1477 pcgctl = dwc2_readl(hsotg->regs + PCGCTL); in dwc2_port_suspend()
1479 dwc2_writel(pcgctl, hsotg->regs + PCGCTL); in dwc2_port_suspend()
1484 if (dwc2_host_is_b_hnp_enabled(hsotg)) { in dwc2_port_suspend()
1485 pcgctl = dwc2_readl(hsotg->regs + PCGCTL); in dwc2_port_suspend()
1487 dwc2_writel(pcgctl, hsotg->regs + PCGCTL); in dwc2_port_suspend()
1489 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_port_suspend()
1493 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_port_suspend()
1498 static void dwc2_port_resume(struct dwc2_hsotg *hsotg) in dwc2_port_resume() argument
1504 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_port_resume()
1510 if (!hsotg->core_params->hibernation) { in dwc2_port_resume()
1511 pcgctl = dwc2_readl(hsotg->regs + PCGCTL); in dwc2_port_resume()
1513 dwc2_writel(pcgctl, hsotg->regs + PCGCTL); in dwc2_port_resume()
1514 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_port_resume()
1516 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_port_resume()
1519 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_port_resume()
1522 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_port_resume()
1523 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_port_resume()
1527 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_port_resume()
1528 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_port_resume()
1530 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_port_resume()
1531 hsotg->bus_suspended = 0; in dwc2_port_resume()
1532 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_port_resume()
1536 static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq, in dwc2_hcd_hub_control() argument
1548 dev_dbg(hsotg->dev, "ClearHubFeature %1xh\n", wvalue); in dwc2_hcd_hub_control()
1558 dev_err(hsotg->dev, in dwc2_hcd_hub_control()
1570 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1572 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1574 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1578 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1581 if (hsotg->bus_suspended) in dwc2_hcd_hub_control()
1582 dwc2_port_resume(hsotg); in dwc2_hcd_hub_control()
1586 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1588 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1590 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1594 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1603 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1605 hsotg->flags.b.port_connect_status_change = 0; in dwc2_hcd_hub_control()
1610 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1612 hsotg->flags.b.port_reset_change = 0; in dwc2_hcd_hub_control()
1620 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1622 hsotg->flags.b.port_enable_change = 0; in dwc2_hcd_hub_control()
1631 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1633 hsotg->flags.b.port_suspend_change = 0; in dwc2_hcd_hub_control()
1637 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1639 hsotg->flags.b.port_l1_change = 0; in dwc2_hcd_hub_control()
1643 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1645 hsotg->flags.b.port_over_current_change = 0; in dwc2_hcd_hub_control()
1650 dev_err(hsotg->dev, in dwc2_hcd_hub_control()
1657 dev_dbg(hsotg->dev, "GetHubDescriptor\n"); in dwc2_hcd_hub_control()
1672 dev_dbg(hsotg->dev, "GetHubStatus\n"); in dwc2_hcd_hub_control()
1677 dev_vdbg(hsotg->dev, in dwc2_hcd_hub_control()
1679 hsotg->flags.d32); in dwc2_hcd_hub_control()
1684 if (hsotg->flags.b.port_connect_status_change) in dwc2_hcd_hub_control()
1686 if (hsotg->flags.b.port_enable_change) in dwc2_hcd_hub_control()
1688 if (hsotg->flags.b.port_suspend_change) in dwc2_hcd_hub_control()
1690 if (hsotg->flags.b.port_l1_change) in dwc2_hcd_hub_control()
1692 if (hsotg->flags.b.port_reset_change) in dwc2_hcd_hub_control()
1694 if (hsotg->flags.b.port_over_current_change) { in dwc2_hcd_hub_control()
1695 dev_warn(hsotg->dev, "Overcurrent change detected\n"); in dwc2_hcd_hub_control()
1699 if (!hsotg->flags.b.port_connect_status) { in dwc2_hcd_hub_control()
1711 hprt0 = dwc2_readl(hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1712 dev_vdbg(hsotg->dev, " HPRT0: 0x%08x\n", hprt0); in dwc2_hcd_hub_control()
1737 dev_vdbg(hsotg->dev, "port_status=%08x\n", port_status); in dwc2_hcd_hub_control()
1742 dev_dbg(hsotg->dev, "SetHubFeature\n"); in dwc2_hcd_hub_control()
1747 dev_dbg(hsotg->dev, "SetPortFeature\n"); in dwc2_hcd_hub_control()
1751 if (!hsotg->flags.b.port_connect_status) { in dwc2_hcd_hub_control()
1764 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1766 if (windex != hsotg->otg_port) in dwc2_hcd_hub_control()
1768 dwc2_port_suspend(hsotg, windex); in dwc2_hcd_hub_control()
1772 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1774 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1776 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1780 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1781 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1783 pcgctl = dwc2_readl(hsotg->regs + PCGCTL); in dwc2_hcd_hub_control()
1785 dwc2_writel(pcgctl, hsotg->regs + PCGCTL); in dwc2_hcd_hub_control()
1787 dwc2_writel(0, hsotg->regs + PCGCTL); in dwc2_hcd_hub_control()
1789 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1798 if (!dwc2_hcd_is_b_host(hsotg)) { in dwc2_hcd_hub_control()
1800 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1802 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1808 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1809 hsotg->lx_state = DWC2_L0; /* Now back to On state */ in dwc2_hcd_hub_control()
1813 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1819 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1820 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1824 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1829 dev_err(hsotg->dev, in dwc2_hcd_hub_control()
1839 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1848 static int dwc2_hcd_is_status_changed(struct dwc2_hsotg *hsotg, int port) in dwc2_hcd_is_status_changed() argument
1855 retval = (hsotg->flags.b.port_connect_status_change || in dwc2_hcd_is_status_changed()
1856 hsotg->flags.b.port_reset_change || in dwc2_hcd_is_status_changed()
1857 hsotg->flags.b.port_enable_change || in dwc2_hcd_is_status_changed()
1858 hsotg->flags.b.port_suspend_change || in dwc2_hcd_is_status_changed()
1859 hsotg->flags.b.port_over_current_change); in dwc2_hcd_is_status_changed()
1862 dev_dbg(hsotg->dev, in dwc2_hcd_is_status_changed()
1864 dev_dbg(hsotg->dev, " port_connect_status_change: %d\n", in dwc2_hcd_is_status_changed()
1865 hsotg->flags.b.port_connect_status_change); in dwc2_hcd_is_status_changed()
1866 dev_dbg(hsotg->dev, " port_reset_change: %d\n", in dwc2_hcd_is_status_changed()
1867 hsotg->flags.b.port_reset_change); in dwc2_hcd_is_status_changed()
1868 dev_dbg(hsotg->dev, " port_enable_change: %d\n", in dwc2_hcd_is_status_changed()
1869 hsotg->flags.b.port_enable_change); in dwc2_hcd_is_status_changed()
1870 dev_dbg(hsotg->dev, " port_suspend_change: %d\n", in dwc2_hcd_is_status_changed()
1871 hsotg->flags.b.port_suspend_change); in dwc2_hcd_is_status_changed()
1872 dev_dbg(hsotg->dev, " port_over_current_change: %d\n", in dwc2_hcd_is_status_changed()
1873 hsotg->flags.b.port_over_current_change); in dwc2_hcd_is_status_changed()
1879 int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg) in dwc2_hcd_get_frame_number() argument
1881 u32 hfnum = dwc2_readl(hsotg->regs + HFNUM); in dwc2_hcd_get_frame_number()
1884 dev_vdbg(hsotg->dev, "DWC OTG HCD GET FRAME NUMBER %d\n", in dwc2_hcd_get_frame_number()
1890 int dwc2_hcd_is_b_host(struct dwc2_hsotg *hsotg) in dwc2_hcd_is_b_host() argument
1892 return hsotg->op_state == OTG_STATE_B_HOST; in dwc2_hcd_is_b_host()
1895 static struct dwc2_hcd_urb *dwc2_hcd_urb_alloc(struct dwc2_hsotg *hsotg, in dwc2_hcd_urb_alloc() argument
1909 static void dwc2_hcd_urb_set_pipeinfo(struct dwc2_hsotg *hsotg, in dwc2_hcd_urb_set_pipeinfo() argument
1916 dev_vdbg(hsotg->dev, in dwc2_hcd_urb_set_pipeinfo()
1930 void dwc2_hcd_dump_state(struct dwc2_hsotg *hsotg) in dwc2_hcd_dump_state() argument
1941 num_channels = hsotg->core_params->host_channels; in dwc2_hcd_dump_state()
1942 dev_dbg(hsotg->dev, "\n"); in dwc2_hcd_dump_state()
1943 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
1945 dev_dbg(hsotg->dev, "HCD State:\n"); in dwc2_hcd_dump_state()
1946 dev_dbg(hsotg->dev, " Num channels: %d\n", num_channels); in dwc2_hcd_dump_state()
1949 chan = hsotg->hc_ptr_array[i]; in dwc2_hcd_dump_state()
1950 dev_dbg(hsotg->dev, " Channel %d:\n", i); in dwc2_hcd_dump_state()
1951 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
1954 dev_dbg(hsotg->dev, " speed: %d\n", chan->speed); in dwc2_hcd_dump_state()
1955 dev_dbg(hsotg->dev, " ep_type: %d\n", chan->ep_type); in dwc2_hcd_dump_state()
1956 dev_dbg(hsotg->dev, " max_packet: %d\n", chan->max_packet); in dwc2_hcd_dump_state()
1957 dev_dbg(hsotg->dev, " data_pid_start: %d\n", in dwc2_hcd_dump_state()
1959 dev_dbg(hsotg->dev, " multi_count: %d\n", chan->multi_count); in dwc2_hcd_dump_state()
1960 dev_dbg(hsotg->dev, " xfer_started: %d\n", in dwc2_hcd_dump_state()
1962 dev_dbg(hsotg->dev, " xfer_buf: %p\n", chan->xfer_buf); in dwc2_hcd_dump_state()
1963 dev_dbg(hsotg->dev, " xfer_dma: %08lx\n", in dwc2_hcd_dump_state()
1965 dev_dbg(hsotg->dev, " xfer_len: %d\n", chan->xfer_len); in dwc2_hcd_dump_state()
1966 dev_dbg(hsotg->dev, " xfer_count: %d\n", chan->xfer_count); in dwc2_hcd_dump_state()
1967 dev_dbg(hsotg->dev, " halt_on_queue: %d\n", in dwc2_hcd_dump_state()
1969 dev_dbg(hsotg->dev, " halt_pending: %d\n", in dwc2_hcd_dump_state()
1971 dev_dbg(hsotg->dev, " halt_status: %d\n", chan->halt_status); in dwc2_hcd_dump_state()
1972 dev_dbg(hsotg->dev, " do_split: %d\n", chan->do_split); in dwc2_hcd_dump_state()
1973 dev_dbg(hsotg->dev, " complete_split: %d\n", in dwc2_hcd_dump_state()
1975 dev_dbg(hsotg->dev, " hub_addr: %d\n", chan->hub_addr); in dwc2_hcd_dump_state()
1976 dev_dbg(hsotg->dev, " hub_port: %d\n", chan->hub_port); in dwc2_hcd_dump_state()
1977 dev_dbg(hsotg->dev, " xact_pos: %d\n", chan->xact_pos); in dwc2_hcd_dump_state()
1978 dev_dbg(hsotg->dev, " requests: %d\n", chan->requests); in dwc2_hcd_dump_state()
1979 dev_dbg(hsotg->dev, " qh: %p\n", chan->qh); in dwc2_hcd_dump_state()
1984 hfnum = dwc2_readl(hsotg->regs + HFNUM); in dwc2_hcd_dump_state()
1985 hcchar = dwc2_readl(hsotg->regs + HCCHAR(i)); in dwc2_hcd_dump_state()
1986 hctsiz = dwc2_readl(hsotg->regs + HCTSIZ(i)); in dwc2_hcd_dump_state()
1987 hcint = dwc2_readl(hsotg->regs + HCINT(i)); in dwc2_hcd_dump_state()
1988 hcintmsk = dwc2_readl(hsotg->regs + HCINTMSK(i)); in dwc2_hcd_dump_state()
1989 dev_dbg(hsotg->dev, " hfnum: 0x%08x\n", hfnum); in dwc2_hcd_dump_state()
1990 dev_dbg(hsotg->dev, " hcchar: 0x%08x\n", hcchar); in dwc2_hcd_dump_state()
1991 dev_dbg(hsotg->dev, " hctsiz: 0x%08x\n", hctsiz); in dwc2_hcd_dump_state()
1992 dev_dbg(hsotg->dev, " hcint: 0x%08x\n", hcint); in dwc2_hcd_dump_state()
1993 dev_dbg(hsotg->dev, " hcintmsk: 0x%08x\n", hcintmsk); in dwc2_hcd_dump_state()
2003 dev_dbg(hsotg->dev, " URB Info:\n"); in dwc2_hcd_dump_state()
2004 dev_dbg(hsotg->dev, " qtd: %p, urb: %p\n", in dwc2_hcd_dump_state()
2007 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
2013 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
2016 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
2019 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
2022 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
2025 dev_dbg(hsotg->dev, " actual_length: %d\n", in dwc2_hcd_dump_state()
2031 dev_dbg(hsotg->dev, " non_periodic_channels: %d\n", in dwc2_hcd_dump_state()
2032 hsotg->non_periodic_channels); in dwc2_hcd_dump_state()
2033 dev_dbg(hsotg->dev, " periodic_channels: %d\n", in dwc2_hcd_dump_state()
2034 hsotg->periodic_channels); in dwc2_hcd_dump_state()
2035 dev_dbg(hsotg->dev, " periodic_usecs: %d\n", hsotg->periodic_usecs); in dwc2_hcd_dump_state()
2036 np_tx_status = dwc2_readl(hsotg->regs + GNPTXSTS); in dwc2_hcd_dump_state()
2037 dev_dbg(hsotg->dev, " NP Tx Req Queue Space Avail: %d\n", in dwc2_hcd_dump_state()
2039 dev_dbg(hsotg->dev, " NP Tx FIFO Space Avail: %d\n", in dwc2_hcd_dump_state()
2041 p_tx_status = dwc2_readl(hsotg->regs + HPTXSTS); in dwc2_hcd_dump_state()
2042 dev_dbg(hsotg->dev, " P Tx Req Queue Space Avail: %d\n", in dwc2_hcd_dump_state()
2044 dev_dbg(hsotg->dev, " P Tx FIFO Space Avail: %d\n", in dwc2_hcd_dump_state()
2046 dwc2_hcd_dump_frrem(hsotg); in dwc2_hcd_dump_state()
2047 dwc2_dump_global_registers(hsotg); in dwc2_hcd_dump_state()
2048 dwc2_dump_host_registers(hsotg); in dwc2_hcd_dump_state()
2049 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
2051 dev_dbg(hsotg->dev, "\n"); in dwc2_hcd_dump_state()
2059 void dwc2_hcd_dump_frrem(struct dwc2_hsotg *hsotg) in dwc2_hcd_dump_frrem() argument
2062 dev_dbg(hsotg->dev, "Frame remaining at SOF:\n"); in dwc2_hcd_dump_frrem()
2063 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2064 hsotg->frrem_samples, hsotg->frrem_accum, in dwc2_hcd_dump_frrem()
2065 hsotg->frrem_samples > 0 ? in dwc2_hcd_dump_frrem()
2066 hsotg->frrem_accum / hsotg->frrem_samples : 0); in dwc2_hcd_dump_frrem()
2067 dev_dbg(hsotg->dev, "\n"); in dwc2_hcd_dump_frrem()
2068 dev_dbg(hsotg->dev, "Frame remaining at start_transfer (uframe 7):\n"); in dwc2_hcd_dump_frrem()
2069 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2070 hsotg->hfnum_7_samples, in dwc2_hcd_dump_frrem()
2071 hsotg->hfnum_7_frrem_accum, in dwc2_hcd_dump_frrem()
2072 hsotg->hfnum_7_samples > 0 ? in dwc2_hcd_dump_frrem()
2073 hsotg->hfnum_7_frrem_accum / hsotg->hfnum_7_samples : 0); in dwc2_hcd_dump_frrem()
2074 dev_dbg(hsotg->dev, "Frame remaining at start_transfer (uframe 0):\n"); in dwc2_hcd_dump_frrem()
2075 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2076 hsotg->hfnum_0_samples, in dwc2_hcd_dump_frrem()
2077 hsotg->hfnum_0_frrem_accum, in dwc2_hcd_dump_frrem()
2078 hsotg->hfnum_0_samples > 0 ? in dwc2_hcd_dump_frrem()
2079 hsotg->hfnum_0_frrem_accum / hsotg->hfnum_0_samples : 0); in dwc2_hcd_dump_frrem()
2080 dev_dbg(hsotg->dev, "Frame remaining at start_transfer (uframe 1-6):\n"); in dwc2_hcd_dump_frrem()
2081 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2082 hsotg->hfnum_other_samples, in dwc2_hcd_dump_frrem()
2083 hsotg->hfnum_other_frrem_accum, in dwc2_hcd_dump_frrem()
2084 hsotg->hfnum_other_samples > 0 ? in dwc2_hcd_dump_frrem()
2085 hsotg->hfnum_other_frrem_accum / hsotg->hfnum_other_samples : in dwc2_hcd_dump_frrem()
2087 dev_dbg(hsotg->dev, "\n"); in dwc2_hcd_dump_frrem()
2088 dev_dbg(hsotg->dev, "Frame remaining at sample point A (uframe 7):\n"); in dwc2_hcd_dump_frrem()
2089 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2090 hsotg->hfnum_7_samples_a, hsotg->hfnum_7_frrem_accum_a, in dwc2_hcd_dump_frrem()
2091 hsotg->hfnum_7_samples_a > 0 ? in dwc2_hcd_dump_frrem()
2092 hsotg->hfnum_7_frrem_accum_a / hsotg->hfnum_7_samples_a : 0); in dwc2_hcd_dump_frrem()
2093 dev_dbg(hsotg->dev, "Frame remaining at sample point A (uframe 0):\n"); in dwc2_hcd_dump_frrem()
2094 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2095 hsotg->hfnum_0_samples_a, hsotg->hfnum_0_frrem_accum_a, in dwc2_hcd_dump_frrem()
2096 hsotg->hfnum_0_samples_a > 0 ? in dwc2_hcd_dump_frrem()
2097 hsotg->hfnum_0_frrem_accum_a / hsotg->hfnum_0_samples_a : 0); in dwc2_hcd_dump_frrem()
2098 dev_dbg(hsotg->dev, "Frame remaining at sample point A (uframe 1-6):\n"); in dwc2_hcd_dump_frrem()
2099 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2100 hsotg->hfnum_other_samples_a, hsotg->hfnum_other_frrem_accum_a, in dwc2_hcd_dump_frrem()
2101 hsotg->hfnum_other_samples_a > 0 ? in dwc2_hcd_dump_frrem()
2102 hsotg->hfnum_other_frrem_accum_a / hsotg->hfnum_other_samples_a in dwc2_hcd_dump_frrem()
2104 dev_dbg(hsotg->dev, "\n"); in dwc2_hcd_dump_frrem()
2105 dev_dbg(hsotg->dev, "Frame remaining at sample point B (uframe 7):\n"); in dwc2_hcd_dump_frrem()
2106 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2107 hsotg->hfnum_7_samples_b, hsotg->hfnum_7_frrem_accum_b, in dwc2_hcd_dump_frrem()
2108 hsotg->hfnum_7_samples_b > 0 ? in dwc2_hcd_dump_frrem()
2109 hsotg->hfnum_7_frrem_accum_b / hsotg->hfnum_7_samples_b : 0); in dwc2_hcd_dump_frrem()
2110 dev_dbg(hsotg->dev, "Frame remaining at sample point B (uframe 0):\n"); in dwc2_hcd_dump_frrem()
2111 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2112 hsotg->hfnum_0_samples_b, hsotg->hfnum_0_frrem_accum_b, in dwc2_hcd_dump_frrem()
2113 (hsotg->hfnum_0_samples_b > 0) ? in dwc2_hcd_dump_frrem()
2114 hsotg->hfnum_0_frrem_accum_b / hsotg->hfnum_0_samples_b : 0); in dwc2_hcd_dump_frrem()
2115 dev_dbg(hsotg->dev, "Frame remaining at sample point B (uframe 1-6):\n"); in dwc2_hcd_dump_frrem()
2116 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2117 hsotg->hfnum_other_samples_b, hsotg->hfnum_other_frrem_accum_b, in dwc2_hcd_dump_frrem()
2118 (hsotg->hfnum_other_samples_b > 0) ? in dwc2_hcd_dump_frrem()
2119 hsotg->hfnum_other_frrem_accum_b / hsotg->hfnum_other_samples_b in dwc2_hcd_dump_frrem()
2125 struct dwc2_hsotg *hsotg; member
2134 return p->hsotg; in dwc2_hcd_to_hsotg()
2139 void dwc2_host_start(struct dwc2_hsotg *hsotg) in dwc2_host_start() argument
2141 struct usb_hcd *hcd = dwc2_hsotg_to_hcd(hsotg); in dwc2_host_start()
2143 hcd->self.is_b_host = dwc2_hcd_is_b_host(hsotg); in dwc2_host_start()
2147 void dwc2_host_disconnect(struct dwc2_hsotg *hsotg) in dwc2_host_disconnect() argument
2149 struct usb_hcd *hcd = dwc2_hsotg_to_hcd(hsotg); in dwc2_host_disconnect()
2154 void dwc2_host_hub_info(struct dwc2_hsotg *hsotg, void *context, int *hub_addr, in dwc2_host_hub_info() argument
2166 int dwc2_host_get_speed(struct dwc2_hsotg *hsotg, void *context) in dwc2_host_get_speed() argument
2205 void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, in dwc2_host_complete() argument
2212 dev_dbg(hsotg->dev, "## %s: qtd is NULL ##\n", __func__); in dwc2_host_complete()
2217 dev_dbg(hsotg->dev, "## %s: qtd->urb is NULL ##\n", __func__); in dwc2_host_complete()
2223 dev_dbg(hsotg->dev, "## %s: urb->priv is NULL ##\n", __func__); in dwc2_host_complete()
2230 dev_vdbg(hsotg->dev, in dwc2_host_complete()
2251 dev_vdbg(hsotg->dev, " ISO Desc %d status %d\n", in dwc2_host_complete()
2267 dwc2_free_bus_bandwidth(dwc2_hsotg_to_hcd(hsotg), in dwc2_host_complete()
2268 dwc2_hcd_get_ep_bandwidth(hsotg, ep), in dwc2_host_complete()
2272 usb_hcd_unlink_urb_from_ep(dwc2_hsotg_to_hcd(hsotg), urb); in dwc2_host_complete()
2277 spin_unlock(&hsotg->lock); in dwc2_host_complete()
2278 usb_hcd_giveback_urb(dwc2_hsotg_to_hcd(hsotg), urb, status); in dwc2_host_complete()
2279 spin_lock(&hsotg->lock); in dwc2_host_complete()
2287 struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg, in dwc2_hcd_start_func() local
2290 dev_dbg(hsotg->dev, "%s() %p\n", __func__, hsotg); in dwc2_hcd_start_func()
2291 dwc2_host_start(hsotg); in dwc2_hcd_start_func()
2299 struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg, in dwc2_hcd_reset_func() local
2303 dev_dbg(hsotg->dev, "USB RESET function called\n"); in dwc2_hcd_reset_func()
2304 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_reset_func()
2306 dwc2_writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_reset_func()
2307 hsotg->flags.b.port_reset_change = 1; in dwc2_hcd_reset_func()
2323 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_start() local
2327 dev_dbg(hsotg->dev, "DWC OTG HCD START\n"); in _dwc2_hcd_start()
2329 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_start()
2330 hsotg->lx_state = DWC2_L0; in _dwc2_hcd_start()
2334 if (dwc2_is_device_mode(hsotg)) { in _dwc2_hcd_start()
2335 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_start()
2339 dwc2_hcd_reinit(hsotg); in _dwc2_hcd_start()
2343 dev_dbg(hsotg->dev, "DWC OTG HCD Has Root Hub\n"); in _dwc2_hcd_start()
2348 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_start()
2358 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_stop() local
2362 dwc2_disable_host_interrupts(hsotg); in _dwc2_hcd_stop()
2367 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_stop()
2369 dwc2_hcd_disconnect(hsotg); in _dwc2_hcd_stop()
2370 dwc2_hcd_stop(hsotg); in _dwc2_hcd_stop()
2371 hsotg->lx_state = DWC2_L3; in _dwc2_hcd_stop()
2374 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_stop()
2381 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_suspend() local
2386 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_suspend()
2388 if (hsotg->lx_state != DWC2_L0) in _dwc2_hcd_suspend()
2394 if (!hsotg->core_params->hibernation) in _dwc2_hcd_suspend()
2401 if (!hsotg->bus_suspended) { in _dwc2_hcd_suspend()
2402 hprt0 = dwc2_read_hprt0(hsotg); in _dwc2_hcd_suspend()
2405 dwc2_writel(hprt0, hsotg->regs + HPRT0); in _dwc2_hcd_suspend()
2409 ret = dwc2_enter_hibernation(hsotg); in _dwc2_hcd_suspend()
2412 dev_err(hsotg->dev, in _dwc2_hcd_suspend()
2418 if (!IS_ERR_OR_NULL(hsotg->uphy)) { in _dwc2_hcd_suspend()
2419 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_suspend()
2420 usb_phy_set_suspend(hsotg->uphy, true); in _dwc2_hcd_suspend()
2421 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_suspend()
2428 hsotg->lx_state = DWC2_L2; in _dwc2_hcd_suspend()
2430 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_suspend()
2437 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_resume() local
2441 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_resume()
2443 if (hsotg->lx_state != DWC2_L2) in _dwc2_hcd_resume()
2446 if (!hsotg->core_params->hibernation) { in _dwc2_hcd_resume()
2447 hsotg->lx_state = DWC2_L0; in _dwc2_hcd_resume()
2462 if (!IS_ERR_OR_NULL(hsotg->uphy)) { in _dwc2_hcd_resume()
2463 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_resume()
2464 usb_phy_set_suspend(hsotg->uphy, false); in _dwc2_hcd_resume()
2465 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_resume()
2469 ret = dwc2_exit_hibernation(hsotg, true); in _dwc2_hcd_resume()
2471 dev_err(hsotg->dev, "exit hibernation failed\n"); in _dwc2_hcd_resume()
2473 hsotg->lx_state = DWC2_L0; in _dwc2_hcd_resume()
2475 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_resume()
2477 if (hsotg->bus_suspended) { in _dwc2_hcd_resume()
2478 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_resume()
2479 hsotg->flags.b.port_suspend_change = 1; in _dwc2_hcd_resume()
2480 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_resume()
2481 dwc2_port_resume(hsotg); in _dwc2_hcd_resume()
2491 HPRT0_ENACHG, hsotg->regs + HPRT0); in _dwc2_hcd_resume()
2498 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_resume()
2506 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_get_frame_number() local
2508 return dwc2_hcd_get_frame_number(hsotg); in _dwc2_hcd_get_frame_number()
2515 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in dwc2_dump_urb_info() local
2519 dev_vdbg(hsotg->dev, "%s, urb %p\n", fn_name, urb); in dwc2_dump_urb_info()
2520 dev_vdbg(hsotg->dev, " Device address: %d\n", in dwc2_dump_urb_info()
2522 dev_vdbg(hsotg->dev, " Endpoint: %d, %s\n", in dwc2_dump_urb_info()
2544 dev_vdbg(hsotg->dev, " Endpoint type: %s %s (%s)\n", pipetype, in dwc2_dump_urb_info()
2563 dev_vdbg(hsotg->dev, " Speed: %s\n", speed); in dwc2_dump_urb_info()
2564 dev_vdbg(hsotg->dev, " Max packet size: %d\n", in dwc2_dump_urb_info()
2566 dev_vdbg(hsotg->dev, " Data buffer length: %d\n", in dwc2_dump_urb_info()
2568 dev_vdbg(hsotg->dev, " Transfer buffer: %p, Transfer DMA: %08lx\n", in dwc2_dump_urb_info()
2570 dev_vdbg(hsotg->dev, " Setup buffer: %p, Setup DMA: %08lx\n", in dwc2_dump_urb_info()
2572 dev_vdbg(hsotg->dev, " Interval: %d\n", urb->interval); in dwc2_dump_urb_info()
2578 dev_vdbg(hsotg->dev, " ISO Desc %d:\n", i); in dwc2_dump_urb_info()
2579 dev_vdbg(hsotg->dev, " offset: %d, length %d\n", in dwc2_dump_urb_info()
2595 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_urb_enqueue() local
2610 dev_vdbg(hsotg->dev, "DWC OTG HCD URB Enqueue\n"); in _dwc2_hcd_urb_enqueue()
2619 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2620 if (!dwc2_hcd_is_bandwidth_allocated(hsotg, ep)) in _dwc2_hcd_urb_enqueue()
2622 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2639 dev_warn(hsotg->dev, "Wrong ep type\n"); in _dwc2_hcd_urb_enqueue()
2642 dwc2_urb = dwc2_hcd_urb_alloc(hsotg, urb->number_of_packets, in _dwc2_hcd_urb_enqueue()
2647 dwc2_hcd_urb_set_pipeinfo(hsotg, dwc2_urb, usb_pipedevice(urb->pipe), in _dwc2_hcd_urb_enqueue()
2657 dev_err(hsotg->dev, in _dwc2_hcd_urb_enqueue()
2689 qh = dwc2_hcd_qh_create(hsotg, dwc2_urb, mem_flags); in _dwc2_hcd_urb_enqueue()
2704 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2709 retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, qh, qtd); in _dwc2_hcd_urb_enqueue()
2715 dwc2_hcd_get_ep_bandwidth(hsotg, ep), in _dwc2_hcd_urb_enqueue()
2719 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2727 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2735 dwc2_hcd_qh_unlink(hsotg, qh); in _dwc2_hcd_urb_enqueue()
2739 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd2, qh); in _dwc2_hcd_urb_enqueue()
2740 dwc2_hcd_qh_free(hsotg, qh); in _dwc2_hcd_urb_enqueue()
2754 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_urb_dequeue() local
2758 dev_dbg(hsotg->dev, "DWC OTG HCD URB Dequeue\n"); in _dwc2_hcd_urb_dequeue()
2761 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_urb_dequeue()
2768 dev_dbg(hsotg->dev, "## urb->hcpriv is NULL ##\n"); in _dwc2_hcd_urb_dequeue()
2772 rc = dwc2_hcd_urb_dequeue(hsotg, urb->hcpriv); in _dwc2_hcd_urb_dequeue()
2780 spin_unlock(&hsotg->lock); in _dwc2_hcd_urb_dequeue()
2782 spin_lock(&hsotg->lock); in _dwc2_hcd_urb_dequeue()
2784 dev_dbg(hsotg->dev, "Called usb_hcd_giveback_urb()\n"); in _dwc2_hcd_urb_dequeue()
2785 dev_dbg(hsotg->dev, " urb->status = %d\n", urb->status); in _dwc2_hcd_urb_dequeue()
2787 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_urb_dequeue()
2800 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_endpoint_disable() local
2802 dev_dbg(hsotg->dev, in _dwc2_hcd_endpoint_disable()
2805 dwc2_hcd_endpoint_disable(hsotg, ep, 250); in _dwc2_hcd_endpoint_disable()
2816 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_endpoint_reset() local
2819 dev_dbg(hsotg->dev, in _dwc2_hcd_endpoint_reset()
2823 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_endpoint_reset()
2824 dwc2_hcd_endpoint_reset(hsotg, ep); in _dwc2_hcd_endpoint_reset()
2825 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_endpoint_reset()
2837 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_irq() local
2839 return dwc2_handle_hcd_intr(hsotg); in _dwc2_hcd_irq()
2850 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_hub_status_data() local
2852 buf[0] = dwc2_hcd_is_status_changed(hsotg, 1) << 1; in _dwc2_hcd_hub_status_data()
2869 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_clear_tt_buffer_complete() local
2877 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_clear_tt_buffer_complete()
2880 if (hsotg->flags.b.port_connect_status) in _dwc2_hcd_clear_tt_buffer_complete()
2881 dwc2_hcd_queue_transactions(hsotg, DWC2_TRANSACTION_ALL); in _dwc2_hcd_clear_tt_buffer_complete()
2883 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_clear_tt_buffer_complete()
2914 static void dwc2_hcd_free(struct dwc2_hsotg *hsotg) in dwc2_hcd_free() argument
2920 dev_dbg(hsotg->dev, "DWC OTG HCD FREE\n"); in dwc2_hcd_free()
2923 dwc2_qh_list_free(hsotg, &hsotg->non_periodic_sched_inactive); in dwc2_hcd_free()
2924 dwc2_qh_list_free(hsotg, &hsotg->non_periodic_sched_active); in dwc2_hcd_free()
2925 dwc2_qh_list_free(hsotg, &hsotg->periodic_sched_inactive); in dwc2_hcd_free()
2926 dwc2_qh_list_free(hsotg, &hsotg->periodic_sched_ready); in dwc2_hcd_free()
2927 dwc2_qh_list_free(hsotg, &hsotg->periodic_sched_assigned); in dwc2_hcd_free()
2928 dwc2_qh_list_free(hsotg, &hsotg->periodic_sched_queued); in dwc2_hcd_free()
2932 struct dwc2_host_chan *chan = hsotg->hc_ptr_array[i]; in dwc2_hcd_free()
2935 dev_dbg(hsotg->dev, "HCD Free channel #%i, chan=%p\n", in dwc2_hcd_free()
2937 hsotg->hc_ptr_array[i] = NULL; in dwc2_hcd_free()
2942 if (hsotg->core_params->dma_enable > 0) { in dwc2_hcd_free()
2943 if (hsotg->status_buf) { in dwc2_hcd_free()
2944 dma_free_coherent(hsotg->dev, DWC2_HCD_STATUS_BUF_SIZE, in dwc2_hcd_free()
2945 hsotg->status_buf, in dwc2_hcd_free()
2946 hsotg->status_buf_dma); in dwc2_hcd_free()
2947 hsotg->status_buf = NULL; in dwc2_hcd_free()
2950 kfree(hsotg->status_buf); in dwc2_hcd_free()
2951 hsotg->status_buf = NULL; in dwc2_hcd_free()
2954 ahbcfg = dwc2_readl(hsotg->regs + GAHBCFG); in dwc2_hcd_free()
2958 dwc2_writel(ahbcfg, hsotg->regs + GAHBCFG); in dwc2_hcd_free()
2959 dwc2_writel(0, hsotg->regs + GINTMSK); in dwc2_hcd_free()
2961 if (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a) { in dwc2_hcd_free()
2962 dctl = dwc2_readl(hsotg->regs + DCTL); in dwc2_hcd_free()
2964 dwc2_writel(dctl, hsotg->regs + DCTL); in dwc2_hcd_free()
2967 if (hsotg->wq_otg) { in dwc2_hcd_free()
2968 if (!cancel_work_sync(&hsotg->wf_otg)) in dwc2_hcd_free()
2969 flush_workqueue(hsotg->wq_otg); in dwc2_hcd_free()
2970 destroy_workqueue(hsotg->wq_otg); in dwc2_hcd_free()
2973 del_timer(&hsotg->wkp_timer); in dwc2_hcd_free()
2976 static void dwc2_hcd_release(struct dwc2_hsotg *hsotg) in dwc2_hcd_release() argument
2979 dwc2_disable_host_interrupts(hsotg); in dwc2_hcd_release()
2981 dwc2_hcd_free(hsotg); in dwc2_hcd_release()
2990 int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) in dwc2_hcd_init() argument
3001 dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n"); in dwc2_hcd_init()
3005 hcfg = dwc2_readl(hsotg->regs + HCFG); in dwc2_hcd_init()
3006 dev_dbg(hsotg->dev, "hcfg=%08x\n", hcfg); in dwc2_hcd_init()
3009 hsotg->frame_num_array = kzalloc(sizeof(*hsotg->frame_num_array) * in dwc2_hcd_init()
3011 if (!hsotg->frame_num_array) in dwc2_hcd_init()
3013 hsotg->last_frame_num_array = kzalloc( in dwc2_hcd_init()
3014 sizeof(*hsotg->last_frame_num_array) * in dwc2_hcd_init()
3016 if (!hsotg->last_frame_num_array) in dwc2_hcd_init()
3018 hsotg->last_frame_num = HFNUM_MAX_FRNUM; in dwc2_hcd_init()
3022 if (hsotg->core_params->dma_enable > 0 && in dwc2_hcd_init()
3023 hsotg->dev->dma_mask == NULL) { in dwc2_hcd_init()
3024 dev_warn(hsotg->dev, in dwc2_hcd_init()
3026 hsotg->core_params->dma_enable = 0; in dwc2_hcd_init()
3027 hsotg->core_params->dma_desc_enable = 0; in dwc2_hcd_init()
3031 if (hsotg->core_params->dma_enable > 0) { in dwc2_hcd_init()
3032 if (dma_set_mask(hsotg->dev, DMA_BIT_MASK(32)) < 0) in dwc2_hcd_init()
3033 dev_warn(hsotg->dev, "can't set DMA mask\n"); in dwc2_hcd_init()
3034 if (dma_set_coherent_mask(hsotg->dev, DMA_BIT_MASK(32)) < 0) in dwc2_hcd_init()
3035 dev_warn(hsotg->dev, "can't set coherent DMA mask\n"); in dwc2_hcd_init()
3038 hcd = usb_create_hcd(&dwc2_hc_driver, hsotg->dev, dev_name(hsotg->dev)); in dwc2_hcd_init()
3042 if (hsotg->core_params->dma_enable <= 0) in dwc2_hcd_init()
3047 ((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg; in dwc2_hcd_init()
3048 hsotg->priv = hcd; in dwc2_hcd_init()
3054 dwc2_disable_global_interrupts(hsotg); in dwc2_hcd_init()
3057 retval = dwc2_core_init(hsotg, true, irq); in dwc2_hcd_init()
3063 hsotg->wq_otg = create_singlethread_workqueue("dwc2"); in dwc2_hcd_init()
3064 if (!hsotg->wq_otg) { in dwc2_hcd_init()
3065 dev_err(hsotg->dev, "Failed to create workqueue\n"); in dwc2_hcd_init()
3068 INIT_WORK(&hsotg->wf_otg, dwc2_conn_id_status_change); in dwc2_hcd_init()
3070 setup_timer(&hsotg->wkp_timer, dwc2_wakeup_detected, in dwc2_hcd_init()
3071 (unsigned long)hsotg); in dwc2_hcd_init()
3074 INIT_LIST_HEAD(&hsotg->non_periodic_sched_inactive); in dwc2_hcd_init()
3075 INIT_LIST_HEAD(&hsotg->non_periodic_sched_active); in dwc2_hcd_init()
3078 INIT_LIST_HEAD(&hsotg->periodic_sched_inactive); in dwc2_hcd_init()
3079 INIT_LIST_HEAD(&hsotg->periodic_sched_ready); in dwc2_hcd_init()
3080 INIT_LIST_HEAD(&hsotg->periodic_sched_assigned); in dwc2_hcd_init()
3081 INIT_LIST_HEAD(&hsotg->periodic_sched_queued); in dwc2_hcd_init()
3087 INIT_LIST_HEAD(&hsotg->free_hc_list); in dwc2_hcd_init()
3088 num_channels = hsotg->core_params->host_channels; in dwc2_hcd_init()
3089 memset(&hsotg->hc_ptr_array[0], 0, sizeof(hsotg->hc_ptr_array)); in dwc2_hcd_init()
3096 hsotg->hc_ptr_array[i] = channel; in dwc2_hcd_init()
3099 if (hsotg->core_params->uframe_sched > 0) in dwc2_hcd_init()
3100 dwc2_hcd_init_usecs(hsotg); in dwc2_hcd_init()
3103 INIT_DELAYED_WORK(&hsotg->start_work, dwc2_hcd_start_func); in dwc2_hcd_init()
3106 INIT_DELAYED_WORK(&hsotg->reset_work, dwc2_hcd_reset_func); in dwc2_hcd_init()
3114 if (hsotg->core_params->dma_enable > 0) in dwc2_hcd_init()
3115 hsotg->status_buf = dma_alloc_coherent(hsotg->dev, in dwc2_hcd_init()
3117 &hsotg->status_buf_dma, GFP_KERNEL); in dwc2_hcd_init()
3119 hsotg->status_buf = kzalloc(DWC2_HCD_STATUS_BUF_SIZE, in dwc2_hcd_init()
3122 if (!hsotg->status_buf) in dwc2_hcd_init()
3125 hsotg->otg_port = 1; in dwc2_hcd_init()
3126 hsotg->frame_list = NULL; in dwc2_hcd_init()
3127 hsotg->frame_list_dma = 0; in dwc2_hcd_init()
3128 hsotg->periodic_qh_count = 0; in dwc2_hcd_init()
3131 hsotg->lx_state = DWC2_L3; in dwc2_hcd_init()
3133 hcd->self.otg_port = hsotg->otg_port; in dwc2_hcd_init()
3138 if (!IS_ERR_OR_NULL(hsotg->uphy)) in dwc2_hcd_init()
3139 otg_set_host(hsotg->uphy->otg, &hcd->self); in dwc2_hcd_init()
3152 dwc2_hcd_dump_state(hsotg); in dwc2_hcd_init()
3154 dwc2_enable_global_interrupts(hsotg); in dwc2_hcd_init()
3159 dwc2_hcd_release(hsotg); in dwc2_hcd_init()
3163 kfree(hsotg->core_params); in dwc2_hcd_init()
3166 kfree(hsotg->last_frame_num_array); in dwc2_hcd_init()
3167 kfree(hsotg->frame_num_array); in dwc2_hcd_init()
3170 dev_err(hsotg->dev, "%s() FAILED, returning %d\n", __func__, retval); in dwc2_hcd_init()
3178 void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) in dwc2_hcd_remove() argument
3182 dev_dbg(hsotg->dev, "DWC OTG HCD REMOVE\n"); in dwc2_hcd_remove()
3184 hcd = dwc2_hsotg_to_hcd(hsotg); in dwc2_hcd_remove()
3185 dev_dbg(hsotg->dev, "hsotg->hcd = %p\n", hcd); in dwc2_hcd_remove()
3188 dev_dbg(hsotg->dev, "%s: dwc2_hsotg_to_hcd(hsotg) NULL!\n", in dwc2_hcd_remove()
3193 if (!IS_ERR_OR_NULL(hsotg->uphy)) in dwc2_hcd_remove()
3194 otg_set_host(hsotg->uphy->otg, NULL); in dwc2_hcd_remove()
3197 hsotg->priv = NULL; in dwc2_hcd_remove()
3198 dwc2_hcd_release(hsotg); in dwc2_hcd_remove()
3202 kfree(hsotg->last_frame_num_array); in dwc2_hcd_remove()
3203 kfree(hsotg->frame_num_array); in dwc2_hcd_remove()