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 = readl(hsotg->regs + HCCHAR(chan->hc_num)); in dwc2_dump_channel_info()
84 hcsplt = readl(hsotg->regs + HCSPLT(chan->hc_num)); in dwc2_dump_channel_info()
85 hctsiz = readl(hsotg->regs + HCTSIZ(chan->hc_num)); in dwc2_dump_channel_info()
86 hc_dma = 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, -ETIMEDOUT); 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 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 = readl(hsotg->regs + HCCHAR(i)); in dwc2_hcd_cleanup_channels()
235 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 = readl(hsotg->regs + HCCHAR(i)); in dwc2_hcd_cleanup_channels()
248 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 = readl(hsotg->regs + GINTMSK); in dwc2_hcd_disconnect()
292 writel(intr, hsotg->regs + GINTMSK); in dwc2_hcd_disconnect()
294 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 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->lx_state == DWC2_L2) { 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()
331 hsotg->flags.b.port_l1_change = 1; in dwc2_hcd_rem_wakeup()
342 void dwc2_hcd_stop(struct dwc2_hsotg *hsotg) in dwc2_hcd_stop() argument
344 dev_dbg(hsotg->dev, "DWC OTG HCD STOP\n"); in dwc2_hcd_stop()
353 dwc2_disable_host_interrupts(hsotg); in dwc2_hcd_stop()
356 dev_dbg(hsotg->dev, "PortPower off\n"); in dwc2_hcd_stop()
357 writel(0, hsotg->regs + HPRT0); in dwc2_hcd_stop()
360 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 = readl(hsotg->regs + HPRT0); in dwc2_hcd_urb_enqueue()
394 retval = dwc2_hcd_qtd_add(hsotg, qtd, (struct dwc2_qh **)ep_handle, in dwc2_hcd_urb_enqueue()
397 dev_err(hsotg->dev, in dwc2_hcd_urb_enqueue()
404 intr_mask = readl(hsotg->regs + GINTMSK); in dwc2_hcd_urb_enqueue()
416 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hcd_urb_enqueue()
417 tr_type = dwc2_hcd_select_transactions(hsotg); in dwc2_hcd_urb_enqueue()
419 dwc2_hcd_queue_transactions(hsotg, tr_type); in dwc2_hcd_urb_enqueue()
420 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hcd_urb_enqueue()
427 static int dwc2_hcd_urb_dequeue(struct dwc2_hsotg *hsotg, in dwc2_hcd_urb_dequeue() argument
435 dev_dbg(hsotg->dev, "## Urb QTD is NULL ##\n"); in dwc2_hcd_urb_dequeue()
441 dev_dbg(hsotg->dev, "## Urb QTD QH is NULL ##\n"); in dwc2_hcd_urb_dequeue()
448 dwc2_dump_channel_info(hsotg, qh->channel); in dwc2_hcd_urb_dequeue()
451 if (hsotg->flags.b.port_connect_status) in dwc2_hcd_urb_dequeue()
459 dwc2_hc_halt(hsotg, qh->channel, in dwc2_hcd_urb_dequeue()
467 if (hsotg->core_params->dma_desc_enable <= 0) { in dwc2_hcd_urb_dequeue()
470 dwc2_hcd_qtd_unlink_and_free(hsotg, urb_qtd, qh); in dwc2_hcd_urb_dequeue()
472 dwc2_hcd_qh_deactivate(hsotg, qh, 0); in dwc2_hcd_urb_dequeue()
475 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_urb_dequeue()
478 dwc2_hcd_qtd_unlink_and_free(hsotg, urb_qtd, qh); in dwc2_hcd_urb_dequeue()
485 static int dwc2_hcd_endpoint_disable(struct dwc2_hsotg *hsotg, in dwc2_hcd_endpoint_disable() argument
493 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hcd_endpoint_disable()
503 dev_err(hsotg->dev, in dwc2_hcd_endpoint_disable()
509 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hcd_endpoint_disable()
511 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hcd_endpoint_disable()
519 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_endpoint_disable()
523 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_hcd_endpoint_disable()
526 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hcd_endpoint_disable()
527 dwc2_hcd_qh_free(hsotg, qh); in dwc2_hcd_endpoint_disable()
533 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hcd_endpoint_disable()
539 static int dwc2_hcd_endpoint_reset(struct dwc2_hsotg *hsotg, in dwc2_hcd_endpoint_reset() argument
557 static void dwc2_hcd_reinit(struct dwc2_hsotg *hsotg) in dwc2_hcd_reinit() argument
563 hsotg->flags.d32 = 0; in dwc2_hcd_reinit()
564 hsotg->non_periodic_qh_ptr = &hsotg->non_periodic_sched_active; in dwc2_hcd_reinit()
566 if (hsotg->core_params->uframe_sched > 0) { in dwc2_hcd_reinit()
567 hsotg->available_host_channels = in dwc2_hcd_reinit()
568 hsotg->core_params->host_channels; in dwc2_hcd_reinit()
570 hsotg->non_periodic_channels = 0; in dwc2_hcd_reinit()
571 hsotg->periodic_channels = 0; in dwc2_hcd_reinit()
578 list_for_each_entry_safe(chan, chan_tmp, &hsotg->free_hc_list, in dwc2_hcd_reinit()
582 num_channels = hsotg->core_params->host_channels; in dwc2_hcd_reinit()
584 chan = hsotg->hc_ptr_array[i]; in dwc2_hcd_reinit()
585 list_add_tail(&chan->hc_list_entry, &hsotg->free_hc_list); in dwc2_hcd_reinit()
586 dwc2_hc_cleanup(hsotg, chan); in dwc2_hcd_reinit()
590 dwc2_core_host_init(hsotg); in dwc2_hcd_reinit()
593 static void dwc2_hc_init_split(struct dwc2_hsotg *hsotg, in dwc2_hc_init_split() argument
602 dwc2_host_hub_info(hsotg, urb->priv, &hub_addr, &hub_port); in dwc2_hc_init_split()
607 static void *dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg, in dwc2_hc_init_xfer() argument
620 dev_vdbg(hsotg->dev, " Control setup transaction\n"); in dwc2_hc_init_xfer()
624 if (hsotg->core_params->dma_enable > 0) in dwc2_hc_init_xfer()
633 dev_vdbg(hsotg->dev, " Control data transaction\n"); in dwc2_hc_init_xfer()
642 dev_vdbg(hsotg->dev, " Control status transaction\n"); in dwc2_hc_init_xfer()
652 if (hsotg->core_params->dma_enable > 0) in dwc2_hc_init_xfer()
653 chan->xfer_dma = hsotg->status_buf_dma; in dwc2_hc_init_xfer()
655 chan->xfer_buf = hsotg->status_buf; in dwc2_hc_init_xfer()
671 if (hsotg->core_params->dma_desc_enable > 0) in dwc2_hc_init_xfer()
677 if (hsotg->core_params->dma_enable > 0) { in dwc2_hc_init_xfer()
690 if (hsotg->core_params->dma_enable > 0 && in dwc2_hc_init_xfer()
709 static int dwc2_hc_setup_align_buf(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_hc_setup_align_buf() argument
719 buf_size = hsotg->core_params->max_transfer_size; in dwc2_hc_setup_align_buf()
724 qh->dw_align_buf = dma_alloc_coherent(hsotg->dev, buf_size, in dwc2_hc_setup_align_buf()
733 dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__); in dwc2_hc_setup_align_buf()
740 hcd = dwc2_hsotg_to_hcd(hsotg); in dwc2_hc_setup_align_buf()
747 dev_warn(hsotg->dev, "no URB in dwc2_urb\n"); in dwc2_hc_setup_align_buf()
764 static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_assign_and_init_hc() argument
772 dev_vdbg(hsotg->dev, "%s(%p,%p)\n", __func__, hsotg, qh); in dwc2_assign_and_init_hc()
775 dev_dbg(hsotg->dev, "No QTDs in QH list\n"); in dwc2_assign_and_init_hc()
779 if (list_empty(&hsotg->free_hc_list)) { in dwc2_assign_and_init_hc()
780 dev_dbg(hsotg->dev, "No free channel to assign\n"); in dwc2_assign_and_init_hc()
784 chan = list_first_entry(&hsotg->free_hc_list, struct dwc2_host_chan, in dwc2_assign_and_init_hc()
831 if (hsotg->core_params->dma_enable > 0) { in dwc2_assign_and_init_hc()
835 if (hsotg->core_params->dma_desc_enable <= 0 && in dwc2_assign_and_init_hc()
847 dwc2_hc_init_split(hsotg, chan, qtd, urb); in dwc2_assign_and_init_hc()
852 bufptr = dwc2_hc_init_xfer(hsotg, chan, qtd, bufptr); in dwc2_assign_and_init_hc()
856 dev_vdbg(hsotg->dev, "Non-aligned buffer\n"); in dwc2_assign_and_init_hc()
857 if (dwc2_hc_setup_align_buf(hsotg, qh, chan, urb, bufptr)) { in dwc2_assign_and_init_hc()
858 dev_err(hsotg->dev, in dwc2_assign_and_init_hc()
865 &hsotg->free_hc_list); in dwc2_assign_and_init_hc()
882 if (hsotg->core_params->dma_desc_enable > 0) in dwc2_assign_and_init_hc()
885 dwc2_hc_init(hsotg, chan); in dwc2_assign_and_init_hc()
901 struct dwc2_hsotg *hsotg) in dwc2_hcd_select_transactions() argument
909 dev_vdbg(hsotg->dev, " Select Transactions\n"); in dwc2_hcd_select_transactions()
913 qh_ptr = hsotg->periodic_sched_ready.next; in dwc2_hcd_select_transactions()
914 while (qh_ptr != &hsotg->periodic_sched_ready) { in dwc2_hcd_select_transactions()
915 if (list_empty(&hsotg->free_hc_list)) in dwc2_hcd_select_transactions()
917 if (hsotg->core_params->uframe_sched > 0) { in dwc2_hcd_select_transactions()
918 if (hsotg->available_host_channels <= 1) in dwc2_hcd_select_transactions()
920 hsotg->available_host_channels--; in dwc2_hcd_select_transactions()
923 if (dwc2_assign_and_init_hc(hsotg, qh)) in dwc2_hcd_select_transactions()
931 list_move(&qh->qh_list_entry, &hsotg->periodic_sched_assigned); in dwc2_hcd_select_transactions()
940 num_channels = hsotg->core_params->host_channels; in dwc2_hcd_select_transactions()
941 qh_ptr = hsotg->non_periodic_sched_inactive.next; in dwc2_hcd_select_transactions()
942 while (qh_ptr != &hsotg->non_periodic_sched_inactive) { in dwc2_hcd_select_transactions()
943 if (hsotg->core_params->uframe_sched <= 0 && in dwc2_hcd_select_transactions()
944 hsotg->non_periodic_channels >= num_channels - in dwc2_hcd_select_transactions()
945 hsotg->periodic_channels) in dwc2_hcd_select_transactions()
947 if (list_empty(&hsotg->free_hc_list)) in dwc2_hcd_select_transactions()
950 if (hsotg->core_params->uframe_sched > 0) { in dwc2_hcd_select_transactions()
951 if (hsotg->available_host_channels < 1) in dwc2_hcd_select_transactions()
953 hsotg->available_host_channels--; in dwc2_hcd_select_transactions()
956 if (dwc2_assign_and_init_hc(hsotg, qh)) in dwc2_hcd_select_transactions()
965 &hsotg->non_periodic_sched_active); in dwc2_hcd_select_transactions()
972 if (hsotg->core_params->uframe_sched <= 0) in dwc2_hcd_select_transactions()
973 hsotg->non_periodic_channels++; in dwc2_hcd_select_transactions()
1000 static int dwc2_queue_transaction(struct dwc2_hsotg *hsotg, in dwc2_queue_transaction() argument
1006 if (hsotg->core_params->dma_enable > 0) { in dwc2_queue_transaction()
1007 if (hsotg->core_params->dma_desc_enable > 0) { in dwc2_queue_transaction()
1010 dwc2_hcd_start_xfer_ddma(hsotg, chan->qh); in dwc2_queue_transaction()
1014 dwc2_hc_start_transfer(hsotg, chan); in dwc2_queue_transaction()
1020 dwc2_hc_halt(hsotg, chan, chan->halt_status); in dwc2_queue_transaction()
1023 dwc2_hc_start_transfer(hsotg, chan); in dwc2_queue_transaction()
1028 dwc2_hc_start_transfer(hsotg, chan); in dwc2_queue_transaction()
1031 retval = dwc2_hc_continue_transfer(hsotg, chan); in dwc2_queue_transaction()
1038 dwc2_hc_start_transfer(hsotg, chan); in dwc2_queue_transaction()
1041 retval = dwc2_hc_continue_transfer(hsotg, chan); in dwc2_queue_transaction()
1057 static void dwc2_process_periodic_channels(struct dwc2_hsotg *hsotg) in dwc2_process_periodic_channels() argument
1070 dev_vdbg(hsotg->dev, "Queue periodic transactions\n"); in dwc2_process_periodic_channels()
1072 tx_status = readl(hsotg->regs + HPTXSTS); in dwc2_process_periodic_channels()
1079 dev_vdbg(hsotg->dev, " P Tx Req Queue Space Avail (before queue): %d\n", in dwc2_process_periodic_channels()
1081 dev_vdbg(hsotg->dev, " P Tx FIFO Space Avail (before queue): %d\n", in dwc2_process_periodic_channels()
1085 qh_ptr = hsotg->periodic_sched_assigned.next; in dwc2_process_periodic_channels()
1086 while (qh_ptr != &hsotg->periodic_sched_assigned) { in dwc2_process_periodic_channels()
1087 tx_status = readl(hsotg->regs + HPTXSTS); in dwc2_process_periodic_channels()
1112 if (hsotg->core_params->dma_enable <= 0 && in dwc2_process_periodic_channels()
1114 hsotg->queuing_high_bandwidth = 1; in dwc2_process_periodic_channels()
1118 status = dwc2_queue_transaction(hsotg, qh->channel, fspcavail); in dwc2_process_periodic_channels()
1131 if (hsotg->core_params->dma_enable > 0 || status == 0 || in dwc2_process_periodic_channels()
1139 &hsotg->periodic_sched_queued); in dwc2_process_periodic_channels()
1142 hsotg->queuing_high_bandwidth = 0; in dwc2_process_periodic_channels()
1146 if (hsotg->core_params->dma_enable <= 0) { in dwc2_process_periodic_channels()
1147 tx_status = readl(hsotg->regs + HPTXSTS); in dwc2_process_periodic_channels()
1153 dev_vdbg(hsotg->dev, in dwc2_process_periodic_channels()
1156 dev_vdbg(hsotg->dev, in dwc2_process_periodic_channels()
1161 if (!list_empty(&hsotg->periodic_sched_assigned) || in dwc2_process_periodic_channels()
1170 gintmsk = readl(hsotg->regs + GINTMSK); in dwc2_process_periodic_channels()
1172 writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_process_periodic_channels()
1181 gintmsk = readl(hsotg->regs + GINTMSK); in dwc2_process_periodic_channels()
1183 writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_process_periodic_channels()
1197 static void dwc2_process_non_periodic_channels(struct dwc2_hsotg *hsotg) in dwc2_process_non_periodic_channels() argument
1210 dev_vdbg(hsotg->dev, "Queue non-periodic transactions\n"); in dwc2_process_non_periodic_channels()
1212 tx_status = readl(hsotg->regs + GNPTXSTS); in dwc2_process_non_periodic_channels()
1217 dev_vdbg(hsotg->dev, " NP Tx Req Queue Space Avail (before queue): %d\n", in dwc2_process_non_periodic_channels()
1219 dev_vdbg(hsotg->dev, " NP Tx FIFO Space Avail (before queue): %d\n", in dwc2_process_non_periodic_channels()
1226 if (hsotg->non_periodic_qh_ptr == &hsotg->non_periodic_sched_active) in dwc2_process_non_periodic_channels()
1227 hsotg->non_periodic_qh_ptr = hsotg->non_periodic_qh_ptr->next; in dwc2_process_non_periodic_channels()
1228 orig_qh_ptr = hsotg->non_periodic_qh_ptr; in dwc2_process_non_periodic_channels()
1235 tx_status = readl(hsotg->regs + GNPTXSTS); in dwc2_process_non_periodic_channels()
1238 if (hsotg->core_params->dma_enable <= 0 && qspcavail == 0) { in dwc2_process_non_periodic_channels()
1243 qh = list_entry(hsotg->non_periodic_qh_ptr, struct dwc2_qh, in dwc2_process_non_periodic_channels()
1254 status = dwc2_queue_transaction(hsotg, qh->channel, fspcavail); in dwc2_process_non_periodic_channels()
1264 hsotg->non_periodic_qh_ptr = hsotg->non_periodic_qh_ptr->next; in dwc2_process_non_periodic_channels()
1265 if (hsotg->non_periodic_qh_ptr == in dwc2_process_non_periodic_channels()
1266 &hsotg->non_periodic_sched_active) in dwc2_process_non_periodic_channels()
1267 hsotg->non_periodic_qh_ptr = in dwc2_process_non_periodic_channels()
1268 hsotg->non_periodic_qh_ptr->next; in dwc2_process_non_periodic_channels()
1269 } while (hsotg->non_periodic_qh_ptr != orig_qh_ptr); in dwc2_process_non_periodic_channels()
1271 if (hsotg->core_params->dma_enable <= 0) { in dwc2_process_non_periodic_channels()
1272 tx_status = readl(hsotg->regs + GNPTXSTS); in dwc2_process_non_periodic_channels()
1277 dev_vdbg(hsotg->dev, in dwc2_process_non_periodic_channels()
1280 dev_vdbg(hsotg->dev, in dwc2_process_non_periodic_channels()
1292 gintmsk = readl(hsotg->regs + GINTMSK); in dwc2_process_non_periodic_channels()
1294 writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_process_non_periodic_channels()
1303 gintmsk = readl(hsotg->regs + GINTMSK); in dwc2_process_non_periodic_channels()
1305 writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_process_non_periodic_channels()
1321 void dwc2_hcd_queue_transactions(struct dwc2_hsotg *hsotg, in dwc2_hcd_queue_transactions() argument
1325 dev_vdbg(hsotg->dev, "Queue Transactions\n"); in dwc2_hcd_queue_transactions()
1330 !list_empty(&hsotg->periodic_sched_assigned)) in dwc2_hcd_queue_transactions()
1331 dwc2_process_periodic_channels(hsotg); in dwc2_hcd_queue_transactions()
1336 if (!list_empty(&hsotg->non_periodic_sched_active)) { in dwc2_hcd_queue_transactions()
1337 dwc2_process_non_periodic_channels(hsotg); in dwc2_hcd_queue_transactions()
1343 u32 gintmsk = readl(hsotg->regs + GINTMSK); in dwc2_hcd_queue_transactions()
1346 writel(gintmsk, hsotg->regs + GINTMSK); in dwc2_hcd_queue_transactions()
1353 struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg, in dwc2_conn_id_status_change() local
1358 dev_dbg(hsotg->dev, "%s()\n", __func__); in dwc2_conn_id_status_change()
1360 gotgctl = readl(hsotg->regs + GOTGCTL); in dwc2_conn_id_status_change()
1361 dev_dbg(hsotg->dev, "gotgctl=%0x\n", gotgctl); in dwc2_conn_id_status_change()
1362 dev_dbg(hsotg->dev, "gotgctl.b.conidsts=%d\n", in dwc2_conn_id_status_change()
1368 dev_dbg(hsotg->dev, "connId B\n"); in dwc2_conn_id_status_change()
1369 while (!dwc2_is_device_mode(hsotg)) { in dwc2_conn_id_status_change()
1370 dev_info(hsotg->dev, in dwc2_conn_id_status_change()
1372 dwc2_is_host_mode(hsotg) ? "Host" : in dwc2_conn_id_status_change()
1379 dev_err(hsotg->dev, in dwc2_conn_id_status_change()
1381 hsotg->op_state = OTG_STATE_B_PERIPHERAL; in dwc2_conn_id_status_change()
1382 dwc2_core_init(hsotg, false, -1); in dwc2_conn_id_status_change()
1383 dwc2_enable_global_interrupts(hsotg); in dwc2_conn_id_status_change()
1384 s3c_hsotg_core_init_disconnected(hsotg, false); in dwc2_conn_id_status_change()
1385 s3c_hsotg_core_connect(hsotg); in dwc2_conn_id_status_change()
1388 dev_dbg(hsotg->dev, "connId A\n"); in dwc2_conn_id_status_change()
1389 while (!dwc2_is_host_mode(hsotg)) { in dwc2_conn_id_status_change()
1390 dev_info(hsotg->dev, "Waiting for Host Mode, Mode=%s\n", in dwc2_conn_id_status_change()
1391 dwc2_is_host_mode(hsotg) ? in dwc2_conn_id_status_change()
1398 dev_err(hsotg->dev, in dwc2_conn_id_status_change()
1400 hsotg->op_state = OTG_STATE_A_HOST; in dwc2_conn_id_status_change()
1403 dwc2_core_init(hsotg, false, -1); in dwc2_conn_id_status_change()
1404 dwc2_enable_global_interrupts(hsotg); in dwc2_conn_id_status_change()
1405 dwc2_hcd_start(hsotg); in dwc2_conn_id_status_change()
1411 struct dwc2_hsotg *hsotg = (struct dwc2_hsotg *)data; in dwc2_wakeup_detected() local
1414 dev_dbg(hsotg->dev, "%s()\n", __func__); in dwc2_wakeup_detected()
1420 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_wakeup_detected()
1421 dev_dbg(hsotg->dev, "Resume: HPRT0=%0x\n", hprt0); in dwc2_wakeup_detected()
1423 writel(hprt0, hsotg->regs + HPRT0); in dwc2_wakeup_detected()
1424 dev_dbg(hsotg->dev, "Clear Resume: HPRT0=%0x\n", in dwc2_wakeup_detected()
1425 readl(hsotg->regs + HPRT0)); in dwc2_wakeup_detected()
1427 dwc2_hcd_rem_wakeup(hsotg); in dwc2_wakeup_detected()
1430 hsotg->lx_state = DWC2_L0; in dwc2_wakeup_detected()
1433 static int dwc2_host_is_b_hnp_enabled(struct dwc2_hsotg *hsotg) in dwc2_host_is_b_hnp_enabled() argument
1435 struct usb_hcd *hcd = dwc2_hsotg_to_hcd(hsotg); in dwc2_host_is_b_hnp_enabled()
1441 static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, u16 windex) in dwc2_port_suspend() argument
1448 dev_dbg(hsotg->dev, "%s()\n", __func__); in dwc2_port_suspend()
1450 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_port_suspend()
1452 if (windex == hsotg->otg_port && dwc2_host_is_b_hnp_enabled(hsotg)) { in dwc2_port_suspend()
1453 gotgctl = readl(hsotg->regs + GOTGCTL); in dwc2_port_suspend()
1455 writel(gotgctl, hsotg->regs + GOTGCTL); in dwc2_port_suspend()
1456 hsotg->op_state = OTG_STATE_A_SUSPEND; in dwc2_port_suspend()
1459 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_port_suspend()
1461 writel(hprt0, hsotg->regs + HPRT0); in dwc2_port_suspend()
1464 hsotg->lx_state = DWC2_L2; in dwc2_port_suspend()
1467 pcgctl = readl(hsotg->regs + PCGCTL); in dwc2_port_suspend()
1469 writel(pcgctl, hsotg->regs + PCGCTL); in dwc2_port_suspend()
1473 if (dwc2_host_is_b_hnp_enabled(hsotg)) { in dwc2_port_suspend()
1474 pcgctl = readl(hsotg->regs + PCGCTL); in dwc2_port_suspend()
1476 writel(pcgctl, hsotg->regs + PCGCTL); in dwc2_port_suspend()
1478 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_port_suspend()
1482 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_port_suspend()
1487 static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq, in dwc2_hcd_hub_control() argument
1499 dev_dbg(hsotg->dev, "ClearHubFeature %1xh\n", wvalue); in dwc2_hcd_hub_control()
1509 dev_err(hsotg->dev, in dwc2_hcd_hub_control()
1521 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1523 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1525 writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1529 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1531 writel(0, hsotg->regs + PCGCTL); in dwc2_hcd_hub_control()
1534 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1536 writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1541 writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1545 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1547 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1549 writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1553 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1562 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1564 hsotg->flags.b.port_connect_status_change = 0; in dwc2_hcd_hub_control()
1569 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1571 hsotg->flags.b.port_reset_change = 0; in dwc2_hcd_hub_control()
1579 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1581 hsotg->flags.b.port_enable_change = 0; in dwc2_hcd_hub_control()
1590 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1592 hsotg->flags.b.port_suspend_change = 0; in dwc2_hcd_hub_control()
1596 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1598 hsotg->flags.b.port_l1_change = 0; in dwc2_hcd_hub_control()
1602 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1604 hsotg->flags.b.port_over_current_change = 0; in dwc2_hcd_hub_control()
1609 dev_err(hsotg->dev, in dwc2_hcd_hub_control()
1616 dev_dbg(hsotg->dev, "GetHubDescriptor\n"); in dwc2_hcd_hub_control()
1631 dev_dbg(hsotg->dev, "GetHubStatus\n"); in dwc2_hcd_hub_control()
1636 dev_vdbg(hsotg->dev, in dwc2_hcd_hub_control()
1638 hsotg->flags.d32); in dwc2_hcd_hub_control()
1643 if (hsotg->flags.b.port_connect_status_change) in dwc2_hcd_hub_control()
1645 if (hsotg->flags.b.port_enable_change) in dwc2_hcd_hub_control()
1647 if (hsotg->flags.b.port_suspend_change) in dwc2_hcd_hub_control()
1649 if (hsotg->flags.b.port_l1_change) in dwc2_hcd_hub_control()
1651 if (hsotg->flags.b.port_reset_change) in dwc2_hcd_hub_control()
1653 if (hsotg->flags.b.port_over_current_change) { in dwc2_hcd_hub_control()
1654 dev_warn(hsotg->dev, "Overcurrent change detected\n"); in dwc2_hcd_hub_control()
1658 if (!hsotg->flags.b.port_connect_status) { in dwc2_hcd_hub_control()
1670 hprt0 = readl(hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1671 dev_vdbg(hsotg->dev, " HPRT0: 0x%08x\n", hprt0); in dwc2_hcd_hub_control()
1696 dev_vdbg(hsotg->dev, "port_status=%08x\n", port_status); in dwc2_hcd_hub_control()
1701 dev_dbg(hsotg->dev, "SetHubFeature\n"); in dwc2_hcd_hub_control()
1706 dev_dbg(hsotg->dev, "SetPortFeature\n"); in dwc2_hcd_hub_control()
1710 if (!hsotg->flags.b.port_connect_status) { in dwc2_hcd_hub_control()
1723 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1725 if (windex != hsotg->otg_port) in dwc2_hcd_hub_control()
1727 dwc2_port_suspend(hsotg, windex); in dwc2_hcd_hub_control()
1731 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1733 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1735 writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1739 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1740 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1742 pcgctl = readl(hsotg->regs + PCGCTL); in dwc2_hcd_hub_control()
1744 writel(pcgctl, hsotg->regs + PCGCTL); in dwc2_hcd_hub_control()
1746 writel(0, hsotg->regs + PCGCTL); in dwc2_hcd_hub_control()
1748 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_hub_control()
1757 if (!dwc2_hcd_is_b_host(hsotg)) { in dwc2_hcd_hub_control()
1759 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1761 writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1767 writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_hub_control()
1768 hsotg->lx_state = DWC2_L0; /* Now back to On state */ in dwc2_hcd_hub_control()
1772 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1779 dev_err(hsotg->dev, in dwc2_hcd_hub_control()
1789 dev_dbg(hsotg->dev, in dwc2_hcd_hub_control()
1798 static int dwc2_hcd_is_status_changed(struct dwc2_hsotg *hsotg, int port) in dwc2_hcd_is_status_changed() argument
1805 retval = (hsotg->flags.b.port_connect_status_change || in dwc2_hcd_is_status_changed()
1806 hsotg->flags.b.port_reset_change || in dwc2_hcd_is_status_changed()
1807 hsotg->flags.b.port_enable_change || in dwc2_hcd_is_status_changed()
1808 hsotg->flags.b.port_suspend_change || in dwc2_hcd_is_status_changed()
1809 hsotg->flags.b.port_over_current_change); in dwc2_hcd_is_status_changed()
1812 dev_dbg(hsotg->dev, in dwc2_hcd_is_status_changed()
1814 dev_dbg(hsotg->dev, " port_connect_status_change: %d\n", in dwc2_hcd_is_status_changed()
1815 hsotg->flags.b.port_connect_status_change); in dwc2_hcd_is_status_changed()
1816 dev_dbg(hsotg->dev, " port_reset_change: %d\n", in dwc2_hcd_is_status_changed()
1817 hsotg->flags.b.port_reset_change); in dwc2_hcd_is_status_changed()
1818 dev_dbg(hsotg->dev, " port_enable_change: %d\n", in dwc2_hcd_is_status_changed()
1819 hsotg->flags.b.port_enable_change); in dwc2_hcd_is_status_changed()
1820 dev_dbg(hsotg->dev, " port_suspend_change: %d\n", in dwc2_hcd_is_status_changed()
1821 hsotg->flags.b.port_suspend_change); in dwc2_hcd_is_status_changed()
1822 dev_dbg(hsotg->dev, " port_over_current_change: %d\n", in dwc2_hcd_is_status_changed()
1823 hsotg->flags.b.port_over_current_change); in dwc2_hcd_is_status_changed()
1829 int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg) in dwc2_hcd_get_frame_number() argument
1831 u32 hfnum = readl(hsotg->regs + HFNUM); in dwc2_hcd_get_frame_number()
1834 dev_vdbg(hsotg->dev, "DWC OTG HCD GET FRAME NUMBER %d\n", in dwc2_hcd_get_frame_number()
1840 int dwc2_hcd_is_b_host(struct dwc2_hsotg *hsotg) in dwc2_hcd_is_b_host() argument
1842 return hsotg->op_state == OTG_STATE_B_HOST; in dwc2_hcd_is_b_host()
1845 static struct dwc2_hcd_urb *dwc2_hcd_urb_alloc(struct dwc2_hsotg *hsotg, in dwc2_hcd_urb_alloc() argument
1859 static void dwc2_hcd_urb_set_pipeinfo(struct dwc2_hsotg *hsotg, in dwc2_hcd_urb_set_pipeinfo() argument
1866 dev_vdbg(hsotg->dev, in dwc2_hcd_urb_set_pipeinfo()
1880 void dwc2_hcd_dump_state(struct dwc2_hsotg *hsotg) in dwc2_hcd_dump_state() argument
1891 num_channels = hsotg->core_params->host_channels; in dwc2_hcd_dump_state()
1892 dev_dbg(hsotg->dev, "\n"); in dwc2_hcd_dump_state()
1893 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
1895 dev_dbg(hsotg->dev, "HCD State:\n"); in dwc2_hcd_dump_state()
1896 dev_dbg(hsotg->dev, " Num channels: %d\n", num_channels); in dwc2_hcd_dump_state()
1899 chan = hsotg->hc_ptr_array[i]; in dwc2_hcd_dump_state()
1900 dev_dbg(hsotg->dev, " Channel %d:\n", i); in dwc2_hcd_dump_state()
1901 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
1904 dev_dbg(hsotg->dev, " speed: %d\n", chan->speed); in dwc2_hcd_dump_state()
1905 dev_dbg(hsotg->dev, " ep_type: %d\n", chan->ep_type); in dwc2_hcd_dump_state()
1906 dev_dbg(hsotg->dev, " max_packet: %d\n", chan->max_packet); in dwc2_hcd_dump_state()
1907 dev_dbg(hsotg->dev, " data_pid_start: %d\n", in dwc2_hcd_dump_state()
1909 dev_dbg(hsotg->dev, " multi_count: %d\n", chan->multi_count); in dwc2_hcd_dump_state()
1910 dev_dbg(hsotg->dev, " xfer_started: %d\n", in dwc2_hcd_dump_state()
1912 dev_dbg(hsotg->dev, " xfer_buf: %p\n", chan->xfer_buf); in dwc2_hcd_dump_state()
1913 dev_dbg(hsotg->dev, " xfer_dma: %08lx\n", in dwc2_hcd_dump_state()
1915 dev_dbg(hsotg->dev, " xfer_len: %d\n", chan->xfer_len); in dwc2_hcd_dump_state()
1916 dev_dbg(hsotg->dev, " xfer_count: %d\n", chan->xfer_count); in dwc2_hcd_dump_state()
1917 dev_dbg(hsotg->dev, " halt_on_queue: %d\n", in dwc2_hcd_dump_state()
1919 dev_dbg(hsotg->dev, " halt_pending: %d\n", in dwc2_hcd_dump_state()
1921 dev_dbg(hsotg->dev, " halt_status: %d\n", chan->halt_status); in dwc2_hcd_dump_state()
1922 dev_dbg(hsotg->dev, " do_split: %d\n", chan->do_split); in dwc2_hcd_dump_state()
1923 dev_dbg(hsotg->dev, " complete_split: %d\n", in dwc2_hcd_dump_state()
1925 dev_dbg(hsotg->dev, " hub_addr: %d\n", chan->hub_addr); in dwc2_hcd_dump_state()
1926 dev_dbg(hsotg->dev, " hub_port: %d\n", chan->hub_port); in dwc2_hcd_dump_state()
1927 dev_dbg(hsotg->dev, " xact_pos: %d\n", chan->xact_pos); in dwc2_hcd_dump_state()
1928 dev_dbg(hsotg->dev, " requests: %d\n", chan->requests); in dwc2_hcd_dump_state()
1929 dev_dbg(hsotg->dev, " qh: %p\n", chan->qh); in dwc2_hcd_dump_state()
1934 hfnum = readl(hsotg->regs + HFNUM); in dwc2_hcd_dump_state()
1935 hcchar = readl(hsotg->regs + HCCHAR(i)); in dwc2_hcd_dump_state()
1936 hctsiz = readl(hsotg->regs + HCTSIZ(i)); in dwc2_hcd_dump_state()
1937 hcint = readl(hsotg->regs + HCINT(i)); in dwc2_hcd_dump_state()
1938 hcintmsk = readl(hsotg->regs + HCINTMSK(i)); in dwc2_hcd_dump_state()
1939 dev_dbg(hsotg->dev, " hfnum: 0x%08x\n", hfnum); in dwc2_hcd_dump_state()
1940 dev_dbg(hsotg->dev, " hcchar: 0x%08x\n", hcchar); in dwc2_hcd_dump_state()
1941 dev_dbg(hsotg->dev, " hctsiz: 0x%08x\n", hctsiz); in dwc2_hcd_dump_state()
1942 dev_dbg(hsotg->dev, " hcint: 0x%08x\n", hcint); in dwc2_hcd_dump_state()
1943 dev_dbg(hsotg->dev, " hcintmsk: 0x%08x\n", hcintmsk); in dwc2_hcd_dump_state()
1953 dev_dbg(hsotg->dev, " URB Info:\n"); in dwc2_hcd_dump_state()
1954 dev_dbg(hsotg->dev, " qtd: %p, urb: %p\n", in dwc2_hcd_dump_state()
1957 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
1963 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
1966 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
1969 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
1972 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
1975 dev_dbg(hsotg->dev, " actual_length: %d\n", in dwc2_hcd_dump_state()
1981 dev_dbg(hsotg->dev, " non_periodic_channels: %d\n", in dwc2_hcd_dump_state()
1982 hsotg->non_periodic_channels); in dwc2_hcd_dump_state()
1983 dev_dbg(hsotg->dev, " periodic_channels: %d\n", in dwc2_hcd_dump_state()
1984 hsotg->periodic_channels); in dwc2_hcd_dump_state()
1985 dev_dbg(hsotg->dev, " periodic_usecs: %d\n", hsotg->periodic_usecs); in dwc2_hcd_dump_state()
1986 np_tx_status = readl(hsotg->regs + GNPTXSTS); in dwc2_hcd_dump_state()
1987 dev_dbg(hsotg->dev, " NP Tx Req Queue Space Avail: %d\n", in dwc2_hcd_dump_state()
1989 dev_dbg(hsotg->dev, " NP Tx FIFO Space Avail: %d\n", in dwc2_hcd_dump_state()
1991 p_tx_status = readl(hsotg->regs + HPTXSTS); in dwc2_hcd_dump_state()
1992 dev_dbg(hsotg->dev, " P Tx Req Queue Space Avail: %d\n", in dwc2_hcd_dump_state()
1994 dev_dbg(hsotg->dev, " P Tx FIFO Space Avail: %d\n", in dwc2_hcd_dump_state()
1996 dwc2_hcd_dump_frrem(hsotg); in dwc2_hcd_dump_state()
1997 dwc2_dump_global_registers(hsotg); in dwc2_hcd_dump_state()
1998 dwc2_dump_host_registers(hsotg); in dwc2_hcd_dump_state()
1999 dev_dbg(hsotg->dev, in dwc2_hcd_dump_state()
2001 dev_dbg(hsotg->dev, "\n"); in dwc2_hcd_dump_state()
2009 void dwc2_hcd_dump_frrem(struct dwc2_hsotg *hsotg) in dwc2_hcd_dump_frrem() argument
2012 dev_dbg(hsotg->dev, "Frame remaining at SOF:\n"); in dwc2_hcd_dump_frrem()
2013 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2014 hsotg->frrem_samples, hsotg->frrem_accum, in dwc2_hcd_dump_frrem()
2015 hsotg->frrem_samples > 0 ? in dwc2_hcd_dump_frrem()
2016 hsotg->frrem_accum / hsotg->frrem_samples : 0); in dwc2_hcd_dump_frrem()
2017 dev_dbg(hsotg->dev, "\n"); in dwc2_hcd_dump_frrem()
2018 dev_dbg(hsotg->dev, "Frame remaining at start_transfer (uframe 7):\n"); in dwc2_hcd_dump_frrem()
2019 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2020 hsotg->hfnum_7_samples, in dwc2_hcd_dump_frrem()
2021 hsotg->hfnum_7_frrem_accum, in dwc2_hcd_dump_frrem()
2022 hsotg->hfnum_7_samples > 0 ? in dwc2_hcd_dump_frrem()
2023 hsotg->hfnum_7_frrem_accum / hsotg->hfnum_7_samples : 0); in dwc2_hcd_dump_frrem()
2024 dev_dbg(hsotg->dev, "Frame remaining at start_transfer (uframe 0):\n"); in dwc2_hcd_dump_frrem()
2025 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2026 hsotg->hfnum_0_samples, in dwc2_hcd_dump_frrem()
2027 hsotg->hfnum_0_frrem_accum, in dwc2_hcd_dump_frrem()
2028 hsotg->hfnum_0_samples > 0 ? in dwc2_hcd_dump_frrem()
2029 hsotg->hfnum_0_frrem_accum / hsotg->hfnum_0_samples : 0); in dwc2_hcd_dump_frrem()
2030 dev_dbg(hsotg->dev, "Frame remaining at start_transfer (uframe 1-6):\n"); in dwc2_hcd_dump_frrem()
2031 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2032 hsotg->hfnum_other_samples, in dwc2_hcd_dump_frrem()
2033 hsotg->hfnum_other_frrem_accum, in dwc2_hcd_dump_frrem()
2034 hsotg->hfnum_other_samples > 0 ? in dwc2_hcd_dump_frrem()
2035 hsotg->hfnum_other_frrem_accum / hsotg->hfnum_other_samples : in dwc2_hcd_dump_frrem()
2037 dev_dbg(hsotg->dev, "\n"); in dwc2_hcd_dump_frrem()
2038 dev_dbg(hsotg->dev, "Frame remaining at sample point A (uframe 7):\n"); in dwc2_hcd_dump_frrem()
2039 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2040 hsotg->hfnum_7_samples_a, hsotg->hfnum_7_frrem_accum_a, in dwc2_hcd_dump_frrem()
2041 hsotg->hfnum_7_samples_a > 0 ? in dwc2_hcd_dump_frrem()
2042 hsotg->hfnum_7_frrem_accum_a / hsotg->hfnum_7_samples_a : 0); in dwc2_hcd_dump_frrem()
2043 dev_dbg(hsotg->dev, "Frame remaining at sample point A (uframe 0):\n"); in dwc2_hcd_dump_frrem()
2044 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2045 hsotg->hfnum_0_samples_a, hsotg->hfnum_0_frrem_accum_a, in dwc2_hcd_dump_frrem()
2046 hsotg->hfnum_0_samples_a > 0 ? in dwc2_hcd_dump_frrem()
2047 hsotg->hfnum_0_frrem_accum_a / hsotg->hfnum_0_samples_a : 0); in dwc2_hcd_dump_frrem()
2048 dev_dbg(hsotg->dev, "Frame remaining at sample point A (uframe 1-6):\n"); in dwc2_hcd_dump_frrem()
2049 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2050 hsotg->hfnum_other_samples_a, hsotg->hfnum_other_frrem_accum_a, in dwc2_hcd_dump_frrem()
2051 hsotg->hfnum_other_samples_a > 0 ? in dwc2_hcd_dump_frrem()
2052 hsotg->hfnum_other_frrem_accum_a / hsotg->hfnum_other_samples_a in dwc2_hcd_dump_frrem()
2054 dev_dbg(hsotg->dev, "\n"); in dwc2_hcd_dump_frrem()
2055 dev_dbg(hsotg->dev, "Frame remaining at sample point B (uframe 7):\n"); in dwc2_hcd_dump_frrem()
2056 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2057 hsotg->hfnum_7_samples_b, hsotg->hfnum_7_frrem_accum_b, in dwc2_hcd_dump_frrem()
2058 hsotg->hfnum_7_samples_b > 0 ? in dwc2_hcd_dump_frrem()
2059 hsotg->hfnum_7_frrem_accum_b / hsotg->hfnum_7_samples_b : 0); in dwc2_hcd_dump_frrem()
2060 dev_dbg(hsotg->dev, "Frame remaining at sample point B (uframe 0):\n"); in dwc2_hcd_dump_frrem()
2061 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2062 hsotg->hfnum_0_samples_b, hsotg->hfnum_0_frrem_accum_b, in dwc2_hcd_dump_frrem()
2063 (hsotg->hfnum_0_samples_b > 0) ? in dwc2_hcd_dump_frrem()
2064 hsotg->hfnum_0_frrem_accum_b / hsotg->hfnum_0_samples_b : 0); in dwc2_hcd_dump_frrem()
2065 dev_dbg(hsotg->dev, "Frame remaining at sample point B (uframe 1-6):\n"); in dwc2_hcd_dump_frrem()
2066 dev_dbg(hsotg->dev, " samples %u, accum %llu, avg %llu\n", in dwc2_hcd_dump_frrem()
2067 hsotg->hfnum_other_samples_b, hsotg->hfnum_other_frrem_accum_b, in dwc2_hcd_dump_frrem()
2068 (hsotg->hfnum_other_samples_b > 0) ? in dwc2_hcd_dump_frrem()
2069 hsotg->hfnum_other_frrem_accum_b / hsotg->hfnum_other_samples_b in dwc2_hcd_dump_frrem()
2075 struct dwc2_hsotg *hsotg; member
2084 return p->hsotg; in dwc2_hcd_to_hsotg()
2089 void dwc2_host_start(struct dwc2_hsotg *hsotg) in dwc2_host_start() argument
2091 struct usb_hcd *hcd = dwc2_hsotg_to_hcd(hsotg); in dwc2_host_start()
2093 hcd->self.is_b_host = dwc2_hcd_is_b_host(hsotg); in dwc2_host_start()
2097 void dwc2_host_disconnect(struct dwc2_hsotg *hsotg) in dwc2_host_disconnect() argument
2099 struct usb_hcd *hcd = dwc2_hsotg_to_hcd(hsotg); in dwc2_host_disconnect()
2104 void dwc2_host_hub_info(struct dwc2_hsotg *hsotg, void *context, int *hub_addr, in dwc2_host_hub_info() argument
2116 int dwc2_host_get_speed(struct dwc2_hsotg *hsotg, void *context) in dwc2_host_get_speed() argument
2155 void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, in dwc2_host_complete() argument
2162 dev_dbg(hsotg->dev, "## %s: qtd is NULL ##\n", __func__); in dwc2_host_complete()
2167 dev_dbg(hsotg->dev, "## %s: qtd->urb is NULL ##\n", __func__); in dwc2_host_complete()
2173 dev_dbg(hsotg->dev, "## %s: urb->priv is NULL ##\n", __func__); in dwc2_host_complete()
2180 dev_vdbg(hsotg->dev, in dwc2_host_complete()
2189 dev_vdbg(hsotg->dev, " ISO Desc %d status %d\n", in dwc2_host_complete()
2216 dwc2_free_bus_bandwidth(dwc2_hsotg_to_hcd(hsotg), in dwc2_host_complete()
2217 dwc2_hcd_get_ep_bandwidth(hsotg, ep), in dwc2_host_complete()
2221 usb_hcd_unlink_urb_from_ep(dwc2_hsotg_to_hcd(hsotg), urb); in dwc2_host_complete()
2226 spin_unlock(&hsotg->lock); in dwc2_host_complete()
2227 usb_hcd_giveback_urb(dwc2_hsotg_to_hcd(hsotg), urb, status); in dwc2_host_complete()
2228 spin_lock(&hsotg->lock); in dwc2_host_complete()
2236 struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg, in dwc2_hcd_start_func() local
2239 dev_dbg(hsotg->dev, "%s() %p\n", __func__, hsotg); in dwc2_hcd_start_func()
2240 dwc2_host_start(hsotg); in dwc2_hcd_start_func()
2248 struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg, in dwc2_hcd_reset_func() local
2252 dev_dbg(hsotg->dev, "USB RESET function called\n"); in dwc2_hcd_reset_func()
2253 hprt0 = dwc2_read_hprt0(hsotg); in dwc2_hcd_reset_func()
2255 writel(hprt0, hsotg->regs + HPRT0); in dwc2_hcd_reset_func()
2256 hsotg->flags.b.port_reset_change = 1; in dwc2_hcd_reset_func()
2272 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_start() local
2276 dev_dbg(hsotg->dev, "DWC OTG HCD START\n"); in _dwc2_hcd_start()
2278 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_start()
2282 if (dwc2_is_device_mode(hsotg)) { in _dwc2_hcd_start()
2283 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_start()
2287 dwc2_hcd_reinit(hsotg); in _dwc2_hcd_start()
2291 dev_dbg(hsotg->dev, "DWC OTG HCD Has Root Hub\n"); in _dwc2_hcd_start()
2296 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_start()
2306 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_stop() local
2309 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_stop()
2310 dwc2_hcd_stop(hsotg); in _dwc2_hcd_stop()
2311 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_stop()
2319 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_get_frame_number() local
2321 return dwc2_hcd_get_frame_number(hsotg); in _dwc2_hcd_get_frame_number()
2328 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in dwc2_dump_urb_info() local
2332 dev_vdbg(hsotg->dev, "%s, urb %p\n", fn_name, urb); in dwc2_dump_urb_info()
2333 dev_vdbg(hsotg->dev, " Device address: %d\n", in dwc2_dump_urb_info()
2335 dev_vdbg(hsotg->dev, " Endpoint: %d, %s\n", in dwc2_dump_urb_info()
2357 dev_vdbg(hsotg->dev, " Endpoint type: %s %s (%s)\n", pipetype, in dwc2_dump_urb_info()
2376 dev_vdbg(hsotg->dev, " Speed: %s\n", speed); in dwc2_dump_urb_info()
2377 dev_vdbg(hsotg->dev, " Max packet size: %d\n", in dwc2_dump_urb_info()
2379 dev_vdbg(hsotg->dev, " Data buffer length: %d\n", in dwc2_dump_urb_info()
2381 dev_vdbg(hsotg->dev, " Transfer buffer: %p, Transfer DMA: %08lx\n", in dwc2_dump_urb_info()
2383 dev_vdbg(hsotg->dev, " Setup buffer: %p, Setup DMA: %08lx\n", in dwc2_dump_urb_info()
2385 dev_vdbg(hsotg->dev, " Interval: %d\n", urb->interval); in dwc2_dump_urb_info()
2391 dev_vdbg(hsotg->dev, " ISO Desc %d:\n", i); in dwc2_dump_urb_info()
2392 dev_vdbg(hsotg->dev, " offset: %d, length %d\n", in dwc2_dump_urb_info()
2408 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_urb_enqueue() local
2420 dev_vdbg(hsotg->dev, "DWC OTG HCD URB Enqueue\n"); in _dwc2_hcd_urb_enqueue()
2429 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2430 if (!dwc2_hcd_is_bandwidth_allocated(hsotg, ep)) in _dwc2_hcd_urb_enqueue()
2432 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2449 dev_warn(hsotg->dev, "Wrong ep type\n"); in _dwc2_hcd_urb_enqueue()
2452 dwc2_urb = dwc2_hcd_urb_alloc(hsotg, urb->number_of_packets, in _dwc2_hcd_urb_enqueue()
2457 dwc2_hcd_urb_set_pipeinfo(hsotg, dwc2_urb, usb_pipedevice(urb->pipe), in _dwc2_hcd_urb_enqueue()
2467 dev_err(hsotg->dev, in _dwc2_hcd_urb_enqueue()
2497 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2499 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2503 retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, &ep->hcpriv, mem_flags); in _dwc2_hcd_urb_enqueue()
2508 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2510 dwc2_hcd_get_ep_bandwidth(hsotg, ep), in _dwc2_hcd_urb_enqueue()
2512 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2518 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2521 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_urb_enqueue()
2535 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_urb_dequeue() local
2539 dev_dbg(hsotg->dev, "DWC OTG HCD URB Dequeue\n"); in _dwc2_hcd_urb_dequeue()
2542 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_urb_dequeue()
2549 dev_dbg(hsotg->dev, "## urb->hcpriv is NULL ##\n"); in _dwc2_hcd_urb_dequeue()
2553 rc = dwc2_hcd_urb_dequeue(hsotg, urb->hcpriv); in _dwc2_hcd_urb_dequeue()
2561 spin_unlock(&hsotg->lock); in _dwc2_hcd_urb_dequeue()
2563 spin_lock(&hsotg->lock); in _dwc2_hcd_urb_dequeue()
2565 dev_dbg(hsotg->dev, "Called usb_hcd_giveback_urb()\n"); in _dwc2_hcd_urb_dequeue()
2566 dev_dbg(hsotg->dev, " urb->status = %d\n", urb->status); in _dwc2_hcd_urb_dequeue()
2568 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_urb_dequeue()
2581 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_endpoint_disable() local
2583 dev_dbg(hsotg->dev, in _dwc2_hcd_endpoint_disable()
2586 dwc2_hcd_endpoint_disable(hsotg, ep, 250); in _dwc2_hcd_endpoint_disable()
2597 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_endpoint_reset() local
2600 dev_dbg(hsotg->dev, in _dwc2_hcd_endpoint_reset()
2604 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_endpoint_reset()
2605 dwc2_hcd_endpoint_reset(hsotg, ep); in _dwc2_hcd_endpoint_reset()
2606 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_endpoint_reset()
2618 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_irq() local
2620 return dwc2_handle_hcd_intr(hsotg); in _dwc2_hcd_irq()
2631 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_hub_status_data() local
2633 buf[0] = dwc2_hcd_is_status_changed(hsotg, 1) << 1; in _dwc2_hcd_hub_status_data()
2650 struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); in _dwc2_hcd_clear_tt_buffer_complete() local
2658 spin_lock_irqsave(&hsotg->lock, flags); in _dwc2_hcd_clear_tt_buffer_complete()
2661 if (hsotg->flags.b.port_connect_status) in _dwc2_hcd_clear_tt_buffer_complete()
2662 dwc2_hcd_queue_transactions(hsotg, DWC2_TRANSACTION_ALL); in _dwc2_hcd_clear_tt_buffer_complete()
2664 spin_unlock_irqrestore(&hsotg->lock, flags); in _dwc2_hcd_clear_tt_buffer_complete()
2692 static void dwc2_hcd_free(struct dwc2_hsotg *hsotg) in dwc2_hcd_free() argument
2698 dev_dbg(hsotg->dev, "DWC OTG HCD FREE\n"); in dwc2_hcd_free()
2701 dwc2_qh_list_free(hsotg, &hsotg->non_periodic_sched_inactive); in dwc2_hcd_free()
2702 dwc2_qh_list_free(hsotg, &hsotg->non_periodic_sched_active); in dwc2_hcd_free()
2703 dwc2_qh_list_free(hsotg, &hsotg->periodic_sched_inactive); in dwc2_hcd_free()
2704 dwc2_qh_list_free(hsotg, &hsotg->periodic_sched_ready); in dwc2_hcd_free()
2705 dwc2_qh_list_free(hsotg, &hsotg->periodic_sched_assigned); in dwc2_hcd_free()
2706 dwc2_qh_list_free(hsotg, &hsotg->periodic_sched_queued); in dwc2_hcd_free()
2710 struct dwc2_host_chan *chan = hsotg->hc_ptr_array[i]; in dwc2_hcd_free()
2713 dev_dbg(hsotg->dev, "HCD Free channel #%i, chan=%p\n", in dwc2_hcd_free()
2715 hsotg->hc_ptr_array[i] = NULL; in dwc2_hcd_free()
2720 if (hsotg->core_params->dma_enable > 0) { in dwc2_hcd_free()
2721 if (hsotg->status_buf) { in dwc2_hcd_free()
2722 dma_free_coherent(hsotg->dev, DWC2_HCD_STATUS_BUF_SIZE, in dwc2_hcd_free()
2723 hsotg->status_buf, in dwc2_hcd_free()
2724 hsotg->status_buf_dma); in dwc2_hcd_free()
2725 hsotg->status_buf = NULL; in dwc2_hcd_free()
2728 kfree(hsotg->status_buf); in dwc2_hcd_free()
2729 hsotg->status_buf = NULL; in dwc2_hcd_free()
2732 ahbcfg = readl(hsotg->regs + GAHBCFG); in dwc2_hcd_free()
2736 writel(ahbcfg, hsotg->regs + GAHBCFG); in dwc2_hcd_free()
2737 writel(0, hsotg->regs + GINTMSK); in dwc2_hcd_free()
2739 if (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a) { in dwc2_hcd_free()
2740 dctl = readl(hsotg->regs + DCTL); in dwc2_hcd_free()
2742 writel(dctl, hsotg->regs + DCTL); in dwc2_hcd_free()
2745 if (hsotg->wq_otg) { in dwc2_hcd_free()
2746 if (!cancel_work_sync(&hsotg->wf_otg)) in dwc2_hcd_free()
2747 flush_workqueue(hsotg->wq_otg); in dwc2_hcd_free()
2748 destroy_workqueue(hsotg->wq_otg); in dwc2_hcd_free()
2751 kfree(hsotg->core_params); in dwc2_hcd_free()
2752 hsotg->core_params = NULL; in dwc2_hcd_free()
2753 del_timer(&hsotg->wkp_timer); in dwc2_hcd_free()
2756 static void dwc2_hcd_release(struct dwc2_hsotg *hsotg) in dwc2_hcd_release() argument
2759 dwc2_disable_host_interrupts(hsotg); in dwc2_hcd_release()
2761 dwc2_hcd_free(hsotg); in dwc2_hcd_release()
2786 int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, in dwc2_hcd_init() argument
2798 dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n"); in dwc2_hcd_init()
2801 retval = dwc2_get_hwparams(hsotg); in dwc2_hcd_init()
2808 hcfg = readl(hsotg->regs + HCFG); in dwc2_hcd_init()
2809 dev_dbg(hsotg->dev, "hcfg=%08x\n", hcfg); in dwc2_hcd_init()
2812 hsotg->frame_num_array = kzalloc(sizeof(*hsotg->frame_num_array) * in dwc2_hcd_init()
2814 if (!hsotg->frame_num_array) in dwc2_hcd_init()
2816 hsotg->last_frame_num_array = kzalloc( in dwc2_hcd_init()
2817 sizeof(*hsotg->last_frame_num_array) * in dwc2_hcd_init()
2819 if (!hsotg->last_frame_num_array) in dwc2_hcd_init()
2821 hsotg->last_frame_num = HFNUM_MAX_FRNUM; in dwc2_hcd_init()
2824 hsotg->core_params = kzalloc(sizeof(*hsotg->core_params), GFP_KERNEL); in dwc2_hcd_init()
2825 if (!hsotg->core_params) in dwc2_hcd_init()
2828 dwc2_set_all_params(hsotg->core_params, -1); in dwc2_hcd_init()
2831 dwc2_set_parameters(hsotg, params); in dwc2_hcd_init()
2834 if (hsotg->core_params->dma_enable > 0 && in dwc2_hcd_init()
2835 hsotg->dev->dma_mask == NULL) { in dwc2_hcd_init()
2836 dev_warn(hsotg->dev, in dwc2_hcd_init()
2838 hsotg->core_params->dma_enable = 0; in dwc2_hcd_init()
2839 hsotg->core_params->dma_desc_enable = 0; in dwc2_hcd_init()
2843 if (hsotg->core_params->dma_enable > 0) { in dwc2_hcd_init()
2844 if (dma_set_mask(hsotg->dev, DMA_BIT_MASK(32)) < 0) in dwc2_hcd_init()
2845 dev_warn(hsotg->dev, "can't set DMA mask\n"); in dwc2_hcd_init()
2846 if (dma_set_coherent_mask(hsotg->dev, DMA_BIT_MASK(32)) < 0) in dwc2_hcd_init()
2847 dev_warn(hsotg->dev, "can't set coherent DMA mask\n"); in dwc2_hcd_init()
2850 hcd = usb_create_hcd(&dwc2_hc_driver, hsotg->dev, dev_name(hsotg->dev)); in dwc2_hcd_init()
2854 if (hsotg->core_params->dma_enable <= 0) in dwc2_hcd_init()
2859 ((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg; in dwc2_hcd_init()
2860 hsotg->priv = hcd; in dwc2_hcd_init()
2866 dwc2_disable_global_interrupts(hsotg); in dwc2_hcd_init()
2869 retval = dwc2_core_init(hsotg, true, irq); in dwc2_hcd_init()
2875 hsotg->wq_otg = create_singlethread_workqueue("dwc2"); in dwc2_hcd_init()
2876 if (!hsotg->wq_otg) { in dwc2_hcd_init()
2877 dev_err(hsotg->dev, "Failed to create workqueue\n"); in dwc2_hcd_init()
2880 INIT_WORK(&hsotg->wf_otg, dwc2_conn_id_status_change); in dwc2_hcd_init()
2882 setup_timer(&hsotg->wkp_timer, dwc2_wakeup_detected, in dwc2_hcd_init()
2883 (unsigned long)hsotg); in dwc2_hcd_init()
2886 INIT_LIST_HEAD(&hsotg->non_periodic_sched_inactive); in dwc2_hcd_init()
2887 INIT_LIST_HEAD(&hsotg->non_periodic_sched_active); in dwc2_hcd_init()
2890 INIT_LIST_HEAD(&hsotg->periodic_sched_inactive); in dwc2_hcd_init()
2891 INIT_LIST_HEAD(&hsotg->periodic_sched_ready); in dwc2_hcd_init()
2892 INIT_LIST_HEAD(&hsotg->periodic_sched_assigned); in dwc2_hcd_init()
2893 INIT_LIST_HEAD(&hsotg->periodic_sched_queued); in dwc2_hcd_init()
2899 INIT_LIST_HEAD(&hsotg->free_hc_list); in dwc2_hcd_init()
2900 num_channels = hsotg->core_params->host_channels; in dwc2_hcd_init()
2901 memset(&hsotg->hc_ptr_array[0], 0, sizeof(hsotg->hc_ptr_array)); in dwc2_hcd_init()
2908 hsotg->hc_ptr_array[i] = channel; in dwc2_hcd_init()
2911 if (hsotg->core_params->uframe_sched > 0) in dwc2_hcd_init()
2912 dwc2_hcd_init_usecs(hsotg); in dwc2_hcd_init()
2915 INIT_DELAYED_WORK(&hsotg->start_work, dwc2_hcd_start_func); in dwc2_hcd_init()
2918 INIT_DELAYED_WORK(&hsotg->reset_work, dwc2_hcd_reset_func); in dwc2_hcd_init()
2926 if (hsotg->core_params->dma_enable > 0) in dwc2_hcd_init()
2927 hsotg->status_buf = dma_alloc_coherent(hsotg->dev, in dwc2_hcd_init()
2929 &hsotg->status_buf_dma, GFP_KERNEL); in dwc2_hcd_init()
2931 hsotg->status_buf = kzalloc(DWC2_HCD_STATUS_BUF_SIZE, in dwc2_hcd_init()
2934 if (!hsotg->status_buf) in dwc2_hcd_init()
2937 hsotg->otg_port = 1; in dwc2_hcd_init()
2938 hsotg->frame_list = NULL; in dwc2_hcd_init()
2939 hsotg->frame_list_dma = 0; in dwc2_hcd_init()
2940 hsotg->periodic_qh_count = 0; in dwc2_hcd_init()
2943 hsotg->lx_state = DWC2_L3; in dwc2_hcd_init()
2945 hcd->self.otg_port = hsotg->otg_port; in dwc2_hcd_init()
2961 dwc2_hcd_dump_state(hsotg); in dwc2_hcd_init()
2963 dwc2_enable_global_interrupts(hsotg); in dwc2_hcd_init()
2968 dwc2_hcd_release(hsotg); in dwc2_hcd_init()
2972 kfree(hsotg->core_params); in dwc2_hcd_init()
2975 kfree(hsotg->last_frame_num_array); in dwc2_hcd_init()
2976 kfree(hsotg->frame_num_array); in dwc2_hcd_init()
2979 dev_err(hsotg->dev, "%s() FAILED, returning %d\n", __func__, retval); in dwc2_hcd_init()
2988 void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) in dwc2_hcd_remove() argument
2992 dev_dbg(hsotg->dev, "DWC OTG HCD REMOVE\n"); in dwc2_hcd_remove()
2994 hcd = dwc2_hsotg_to_hcd(hsotg); in dwc2_hcd_remove()
2995 dev_dbg(hsotg->dev, "hsotg->hcd = %p\n", hcd); in dwc2_hcd_remove()
2998 dev_dbg(hsotg->dev, "%s: dwc2_hsotg_to_hcd(hsotg) NULL!\n", in dwc2_hcd_remove()
3004 hsotg->priv = NULL; in dwc2_hcd_remove()
3005 dwc2_hcd_release(hsotg); in dwc2_hcd_remove()
3009 kfree(hsotg->last_frame_num_array); in dwc2_hcd_remove()
3010 kfree(hsotg->frame_num_array); in dwc2_hcd_remove()