Lines Matching refs:hsotg

87 static int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,  in dwc2_desc_list_alloc()  argument
90 qh->desc_list = dma_alloc_coherent(hsotg->dev, in dwc2_desc_list_alloc()
103 dma_free_coherent(hsotg->dev, sizeof(struct dwc2_hcd_dma_desc) in dwc2_desc_list_alloc()
113 static void dwc2_desc_list_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_desc_list_free() argument
116 dma_free_coherent(hsotg->dev, sizeof(struct dwc2_hcd_dma_desc) in dwc2_desc_list_free()
126 static int dwc2_frame_list_alloc(struct dwc2_hsotg *hsotg, gfp_t mem_flags) in dwc2_frame_list_alloc() argument
128 if (hsotg->frame_list) in dwc2_frame_list_alloc()
131 hsotg->frame_list = dma_alloc_coherent(hsotg->dev, in dwc2_frame_list_alloc()
133 &hsotg->frame_list_dma, in dwc2_frame_list_alloc()
135 if (!hsotg->frame_list) in dwc2_frame_list_alloc()
138 memset(hsotg->frame_list, 0, 4 * FRLISTEN_64_SIZE); in dwc2_frame_list_alloc()
142 static void dwc2_frame_list_free(struct dwc2_hsotg *hsotg) in dwc2_frame_list_free() argument
148 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_frame_list_free()
150 if (!hsotg->frame_list) { in dwc2_frame_list_free()
151 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_frame_list_free()
155 frame_list = hsotg->frame_list; in dwc2_frame_list_free()
156 frame_list_dma = hsotg->frame_list_dma; in dwc2_frame_list_free()
157 hsotg->frame_list = NULL; in dwc2_frame_list_free()
159 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_frame_list_free()
161 dma_free_coherent(hsotg->dev, 4 * FRLISTEN_64_SIZE, frame_list, in dwc2_frame_list_free()
165 static void dwc2_per_sched_enable(struct dwc2_hsotg *hsotg, u32 fr_list_en) in dwc2_per_sched_enable() argument
170 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_per_sched_enable()
172 hcfg = dwc2_readl(hsotg->regs + HCFG); in dwc2_per_sched_enable()
175 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_enable()
179 dwc2_writel(hsotg->frame_list_dma, hsotg->regs + HFLBADDR); in dwc2_per_sched_enable()
183 dev_vdbg(hsotg->dev, "Enabling Periodic schedule\n"); in dwc2_per_sched_enable()
184 dwc2_writel(hcfg, hsotg->regs + HCFG); in dwc2_per_sched_enable()
186 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_enable()
189 static void dwc2_per_sched_disable(struct dwc2_hsotg *hsotg) in dwc2_per_sched_disable() argument
194 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_per_sched_disable()
196 hcfg = dwc2_readl(hsotg->regs + HCFG); in dwc2_per_sched_disable()
199 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_disable()
204 dev_vdbg(hsotg->dev, "Disabling Periodic schedule\n"); in dwc2_per_sched_disable()
205 dwc2_writel(hcfg, hsotg->regs + HCFG); in dwc2_per_sched_disable()
207 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_disable()
214 static void dwc2_update_frame_list(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_update_frame_list() argument
220 if (!hsotg) { in dwc2_update_frame_list()
221 pr_err("hsotg = %p\n", hsotg); in dwc2_update_frame_list()
226 dev_err(hsotg->dev, "qh->channel = %p\n", qh->channel); in dwc2_update_frame_list()
230 if (!hsotg->frame_list) { in dwc2_update_frame_list()
231 dev_err(hsotg->dev, "hsotg->frame_list = %p\n", in dwc2_update_frame_list()
232 hsotg->frame_list); in dwc2_update_frame_list()
246 hsotg->frame_list[j] |= 1 << chan->hc_num; in dwc2_update_frame_list()
248 hsotg->frame_list[j] &= ~(1 << chan->hc_num); in dwc2_update_frame_list()
269 static void dwc2_release_channel_ddma(struct dwc2_hsotg *hsotg, in dwc2_release_channel_ddma() argument
275 if (hsotg->core_params->uframe_sched > 0) in dwc2_release_channel_ddma()
276 hsotg->available_host_channels++; in dwc2_release_channel_ddma()
278 hsotg->non_periodic_channels--; in dwc2_release_channel_ddma()
280 dwc2_update_frame_list(hsotg, qh, 0); in dwc2_release_channel_ddma()
290 dwc2_hc_cleanup(hsotg, chan); in dwc2_release_channel_ddma()
291 list_add_tail(&chan->hc_list_entry, &hsotg->free_hc_list); in dwc2_release_channel_ddma()
315 int dwc2_hcd_qh_init_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_hcd_qh_init_ddma() argument
321 dev_err(hsotg->dev, in dwc2_hcd_qh_init_ddma()
327 retval = dwc2_desc_list_alloc(hsotg, qh, mem_flags); in dwc2_hcd_qh_init_ddma()
333 if (!hsotg->frame_list) { in dwc2_hcd_qh_init_ddma()
334 retval = dwc2_frame_list_alloc(hsotg, mem_flags); in dwc2_hcd_qh_init_ddma()
338 dwc2_per_sched_enable(hsotg, HCFG_FRLISTEN_64); in dwc2_hcd_qh_init_ddma()
346 dwc2_desc_list_free(hsotg, qh); in dwc2_hcd_qh_init_ddma()
361 void dwc2_hcd_qh_free_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_hcd_qh_free_ddma() argument
363 dwc2_desc_list_free(hsotg, qh); in dwc2_hcd_qh_free_ddma()
373 dwc2_release_channel_ddma(hsotg, qh); in dwc2_hcd_qh_free_ddma()
377 (hsotg->core_params->uframe_sched > 0 || in dwc2_hcd_qh_free_ddma()
378 !hsotg->periodic_channels) && hsotg->frame_list) { in dwc2_hcd_qh_free_ddma()
379 dwc2_per_sched_disable(hsotg); in dwc2_hcd_qh_free_ddma()
380 dwc2_frame_list_free(hsotg); in dwc2_hcd_qh_free_ddma()
397 static u16 dwc2_calc_starting_frame(struct dwc2_hsotg *hsotg, in dwc2_calc_starting_frame() argument
402 hsotg->frame_number = dwc2_hcd_get_frame_number(hsotg); in dwc2_calc_starting_frame()
428 if (dwc2_micro_frame_num(hsotg->frame_number) >= 5) { in dwc2_calc_starting_frame()
430 frame = dwc2_frame_num_inc(hsotg->frame_number, in dwc2_calc_starting_frame()
434 frame = dwc2_frame_num_inc(hsotg->frame_number, in dwc2_calc_starting_frame()
446 frame = dwc2_frame_num_inc(hsotg->frame_number, 2); in dwc2_calc_starting_frame()
456 static u16 dwc2_recalc_initial_desc_idx(struct dwc2_hsotg *hsotg, in dwc2_recalc_initial_desc_idx() argument
480 frame = dwc2_calc_starting_frame(hsotg, qh, &skip_frames); in dwc2_recalc_initial_desc_idx()
491 qh->sched_frame = dwc2_calc_starting_frame(hsotg, qh, in dwc2_recalc_initial_desc_idx()
507 static void dwc2_fill_host_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_fill_host_isoc_dma_desc() argument
537 static void dwc2_init_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_init_isoc_dma_desc() argument
563 dwc2_fill_host_isoc_dma_desc(hsotg, qtd, qh, in dwc2_init_isoc_dma_desc()
616 static void dwc2_fill_host_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_fill_host_dma_desc() argument
662 static void dwc2_init_non_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_init_non_isoc_dma_desc() argument
669 dev_vdbg(hsotg->dev, "%s(): qh=%p dma=%08lx len=%d\n", __func__, qh, in dwc2_init_non_isoc_dma_desc()
680 dev_vdbg(hsotg->dev, "qtd=%p\n", qtd); in dwc2_init_non_isoc_dma_desc()
688 dev_vdbg(hsotg->dev, "buf=%08lx len=%d\n", in dwc2_init_non_isoc_dma_desc()
696 dev_vdbg(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
701 dwc2_fill_host_dma_desc(hsotg, chan, qtd, qh, n_desc); in dwc2_init_non_isoc_dma_desc()
702 dev_vdbg(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
712 dev_vdbg(hsotg->dev, "n_desc=%d\n", n_desc); in dwc2_init_non_isoc_dma_desc()
723 dev_vdbg(hsotg->dev, "set IOC/EOL/A bits in desc %d (%p)\n", in dwc2_init_non_isoc_dma_desc()
727 dev_vdbg(hsotg->dev, "set A bit in desc 0 (%p)\n", in dwc2_init_non_isoc_dma_desc()
753 void dwc2_hcd_start_xfer_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_hcd_start_xfer_ddma() argument
762 dwc2_init_non_isoc_dma_desc(hsotg, qh); in dwc2_hcd_start_xfer_ddma()
763 dwc2_hc_start_transfer_ddma(hsotg, chan); in dwc2_hcd_start_xfer_ddma()
766 dwc2_init_non_isoc_dma_desc(hsotg, qh); in dwc2_hcd_start_xfer_ddma()
767 dwc2_update_frame_list(hsotg, qh, 1); in dwc2_hcd_start_xfer_ddma()
768 dwc2_hc_start_transfer_ddma(hsotg, chan); in dwc2_hcd_start_xfer_ddma()
772 skip_frames = dwc2_recalc_initial_desc_idx(hsotg, qh); in dwc2_hcd_start_xfer_ddma()
773 dwc2_init_isoc_dma_desc(hsotg, qh, skip_frames); in dwc2_hcd_start_xfer_ddma()
776 dwc2_update_frame_list(hsotg, qh, 1); in dwc2_hcd_start_xfer_ddma()
786 dwc2_hc_start_transfer_ddma(hsotg, chan); in dwc2_hcd_start_xfer_ddma()
798 static int dwc2_cmpl_host_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_cmpl_host_isoc_dma_desc() argument
837 dwc2_host_complete(hsotg, qtd, 0); in dwc2_cmpl_host_isoc_dma_desc()
838 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_cmpl_host_isoc_dma_desc()
860 static void dwc2_complete_isoc_xfer_ddma(struct dwc2_hsotg *hsotg, in dwc2_complete_isoc_xfer_ddma() argument
902 dwc2_host_complete(hsotg, qtd, err); in dwc2_complete_isoc_xfer_ddma()
905 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_complete_isoc_xfer_ddma()
915 rc = dwc2_cmpl_host_isoc_dma_desc(hsotg, chan, qtd, qh, in dwc2_complete_isoc_xfer_ddma()
932 static int dwc2_update_non_isoc_urb_state_ddma(struct dwc2_hsotg *hsotg, in dwc2_update_non_isoc_urb_state_ddma() argument
946 dev_vdbg(hsotg->dev, "remain=%d dwc2_urb=%p\n", remain, urb); in dwc2_update_non_isoc_urb_state_ddma()
949 dev_err(hsotg->dev, "EIO\n"); in dwc2_update_non_isoc_urb_state_ddma()
957 dev_vdbg(hsotg->dev, "Stall\n"); in dwc2_update_non_isoc_urb_state_ddma()
961 dev_err(hsotg->dev, "Babble\n"); in dwc2_update_non_isoc_urb_state_ddma()
965 dev_err(hsotg->dev, "XactErr\n"); in dwc2_update_non_isoc_urb_state_ddma()
969 dev_err(hsotg->dev, in dwc2_update_non_isoc_urb_state_ddma()
978 dev_vdbg(hsotg->dev, in dwc2_update_non_isoc_urb_state_ddma()
1003 dev_vdbg(hsotg->dev, "length=%d actual=%d\n", urb->length, in dwc2_update_non_isoc_urb_state_ddma()
1014 static int dwc2_process_non_isoc_desc(struct dwc2_hsotg *hsotg, in dwc2_process_non_isoc_desc() argument
1027 dev_vdbg(hsotg->dev, "%s()\n", __func__); in dwc2_process_non_isoc_desc()
1034 dev_vdbg(hsotg->dev, in dwc2_process_non_isoc_desc()
1037 failed = dwc2_update_non_isoc_urb_state_ddma(hsotg, chan, qtd, dma_desc, in dwc2_process_non_isoc_desc()
1041 dwc2_host_complete(hsotg, qtd, urb->status); in dwc2_process_non_isoc_desc()
1042 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_process_non_isoc_desc()
1043 dev_vdbg(hsotg->dev, "failed=%1x xfer_done=%1x status=%08x\n", in dwc2_process_non_isoc_desc()
1055 dev_vdbg(hsotg->dev, in dwc2_process_non_isoc_desc()
1061 dev_vdbg(hsotg->dev, in dwc2_process_non_isoc_desc()
1068 dwc2_hcd_save_data_toggle(hsotg, chan, chnum, in dwc2_process_non_isoc_desc()
1080 static void dwc2_complete_non_isoc_xfer_ddma(struct dwc2_hsotg *hsotg, in dwc2_complete_non_isoc_xfer_ddma() argument
1104 if (dwc2_process_non_isoc_desc(hsotg, chan, chnum, qtd, in dwc2_complete_non_isoc_xfer_ddma()
1122 dwc2_hcd_save_data_toggle(hsotg, chan, chnum, qtd); in dwc2_complete_non_isoc_xfer_ddma()
1154 void dwc2_hcd_complete_xfer_ddma(struct dwc2_hsotg *hsotg, in dwc2_hcd_complete_xfer_ddma() argument
1163 dwc2_complete_isoc_xfer_ddma(hsotg, chan, halt_status); in dwc2_hcd_complete_xfer_ddma()
1170 dwc2_hc_halt(hsotg, chan, halt_status); in dwc2_hcd_complete_xfer_ddma()
1171 dwc2_release_channel_ddma(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1172 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1176 &hsotg->periodic_sched_assigned); in dwc2_hcd_complete_xfer_ddma()
1188 dwc2_complete_non_isoc_xfer_ddma(hsotg, chan, chnum, in dwc2_hcd_complete_xfer_ddma()
1190 dwc2_release_channel_ddma(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1191 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1198 dwc2_hcd_qh_add(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1202 tr_type = dwc2_hcd_select_transactions(hsotg); in dwc2_hcd_complete_xfer_ddma()
1210 dwc2_hcd_queue_transactions(hsotg, tr_type); in dwc2_hcd_complete_xfer_ddma()