Lines Matching refs:hsotg

88 static int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,  in dwc2_desc_list_alloc()  argument
95 desc_cache = hsotg->desc_hsisoc_cache; in dwc2_desc_list_alloc()
97 desc_cache = hsotg->desc_gen_cache; in dwc2_desc_list_alloc()
106 qh->desc_list_dma = dma_map_single(hsotg->dev, qh->desc_list, in dwc2_desc_list_alloc()
112 dma_unmap_single(hsotg->dev, qh->desc_list_dma, in dwc2_desc_list_alloc()
123 static void dwc2_desc_list_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_desc_list_free() argument
129 desc_cache = hsotg->desc_hsisoc_cache; in dwc2_desc_list_free()
131 desc_cache = hsotg->desc_gen_cache; in dwc2_desc_list_free()
134 dma_unmap_single(hsotg->dev, qh->desc_list_dma, in dwc2_desc_list_free()
144 static int dwc2_frame_list_alloc(struct dwc2_hsotg *hsotg, gfp_t mem_flags) in dwc2_frame_list_alloc() argument
146 if (hsotg->frame_list) in dwc2_frame_list_alloc()
149 hsotg->frame_list_sz = 4 * FRLISTEN_64_SIZE; in dwc2_frame_list_alloc()
150 hsotg->frame_list = kzalloc(hsotg->frame_list_sz, GFP_ATOMIC | GFP_DMA); in dwc2_frame_list_alloc()
151 if (!hsotg->frame_list) in dwc2_frame_list_alloc()
154 hsotg->frame_list_dma = dma_map_single(hsotg->dev, hsotg->frame_list, in dwc2_frame_list_alloc()
155 hsotg->frame_list_sz, in dwc2_frame_list_alloc()
161 static void dwc2_frame_list_free(struct dwc2_hsotg *hsotg) in dwc2_frame_list_free() argument
165 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_frame_list_free()
167 if (!hsotg->frame_list) { in dwc2_frame_list_free()
168 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_frame_list_free()
172 dma_unmap_single(hsotg->dev, hsotg->frame_list_dma, in dwc2_frame_list_free()
173 hsotg->frame_list_sz, DMA_FROM_DEVICE); in dwc2_frame_list_free()
175 kfree(hsotg->frame_list); in dwc2_frame_list_free()
176 hsotg->frame_list = NULL; in dwc2_frame_list_free()
178 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_frame_list_free()
181 static void dwc2_per_sched_enable(struct dwc2_hsotg *hsotg, u32 fr_list_en) in dwc2_per_sched_enable() argument
186 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_per_sched_enable()
188 hcfg = dwc2_readl(hsotg, HCFG); in dwc2_per_sched_enable()
191 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_enable()
195 dwc2_writel(hsotg, hsotg->frame_list_dma, HFLBADDR); in dwc2_per_sched_enable()
199 dev_vdbg(hsotg->dev, "Enabling Periodic schedule\n"); in dwc2_per_sched_enable()
200 dwc2_writel(hsotg, hcfg, HCFG); in dwc2_per_sched_enable()
202 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_enable()
205 static void dwc2_per_sched_disable(struct dwc2_hsotg *hsotg) in dwc2_per_sched_disable() argument
210 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_per_sched_disable()
212 hcfg = dwc2_readl(hsotg, HCFG); in dwc2_per_sched_disable()
215 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_disable()
220 dev_vdbg(hsotg->dev, "Disabling Periodic schedule\n"); in dwc2_per_sched_disable()
221 dwc2_writel(hsotg, hcfg, HCFG); in dwc2_per_sched_disable()
223 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_disable()
230 static void dwc2_update_frame_list(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_update_frame_list() argument
236 if (!hsotg) { in dwc2_update_frame_list()
237 pr_err("hsotg = %p\n", hsotg); in dwc2_update_frame_list()
242 dev_err(hsotg->dev, "qh->channel = %p\n", qh->channel); in dwc2_update_frame_list()
246 if (!hsotg->frame_list) { in dwc2_update_frame_list()
247 dev_err(hsotg->dev, "hsotg->frame_list = %p\n", in dwc2_update_frame_list()
248 hsotg->frame_list); in dwc2_update_frame_list()
262 hsotg->frame_list[j] |= 1 << chan->hc_num; in dwc2_update_frame_list()
264 hsotg->frame_list[j] &= ~(1 << chan->hc_num); in dwc2_update_frame_list()
272 dma_sync_single_for_device(hsotg->dev, in dwc2_update_frame_list()
273 hsotg->frame_list_dma, in dwc2_update_frame_list()
274 hsotg->frame_list_sz, in dwc2_update_frame_list()
294 static void dwc2_release_channel_ddma(struct dwc2_hsotg *hsotg, in dwc2_release_channel_ddma() argument
300 if (hsotg->params.uframe_sched) in dwc2_release_channel_ddma()
301 hsotg->available_host_channels++; in dwc2_release_channel_ddma()
303 hsotg->non_periodic_channels--; in dwc2_release_channel_ddma()
305 dwc2_update_frame_list(hsotg, qh, 0); in dwc2_release_channel_ddma()
306 hsotg->available_host_channels++; in dwc2_release_channel_ddma()
316 dwc2_hc_cleanup(hsotg, chan); in dwc2_release_channel_ddma()
317 list_add_tail(&chan->hc_list_entry, &hsotg->free_hc_list); in dwc2_release_channel_ddma()
342 int dwc2_hcd_qh_init_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_hcd_qh_init_ddma() argument
348 dev_err(hsotg->dev, in dwc2_hcd_qh_init_ddma()
354 retval = dwc2_desc_list_alloc(hsotg, qh, mem_flags); in dwc2_hcd_qh_init_ddma()
360 if (!hsotg->frame_list) { in dwc2_hcd_qh_init_ddma()
361 retval = dwc2_frame_list_alloc(hsotg, mem_flags); in dwc2_hcd_qh_init_ddma()
365 dwc2_per_sched_enable(hsotg, HCFG_FRLISTEN_64); in dwc2_hcd_qh_init_ddma()
373 dwc2_desc_list_free(hsotg, qh); in dwc2_hcd_qh_init_ddma()
388 void dwc2_hcd_qh_free_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_hcd_qh_free_ddma() argument
392 dwc2_desc_list_free(hsotg, qh); in dwc2_hcd_qh_free_ddma()
401 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hcd_qh_free_ddma()
403 dwc2_release_channel_ddma(hsotg, qh); in dwc2_hcd_qh_free_ddma()
404 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hcd_qh_free_ddma()
408 (hsotg->params.uframe_sched || in dwc2_hcd_qh_free_ddma()
409 !hsotg->periodic_channels) && hsotg->frame_list) { in dwc2_hcd_qh_free_ddma()
410 dwc2_per_sched_disable(hsotg); in dwc2_hcd_qh_free_ddma()
411 dwc2_frame_list_free(hsotg); in dwc2_hcd_qh_free_ddma()
428 static u16 dwc2_calc_starting_frame(struct dwc2_hsotg *hsotg, in dwc2_calc_starting_frame() argument
433 hsotg->frame_number = dwc2_hcd_get_frame_number(hsotg); in dwc2_calc_starting_frame()
462 if (dwc2_micro_frame_num(hsotg->frame_number) >= 5) { in dwc2_calc_starting_frame()
464 frame = dwc2_frame_num_inc(hsotg->frame_number, in dwc2_calc_starting_frame()
468 frame = dwc2_frame_num_inc(hsotg->frame_number, in dwc2_calc_starting_frame()
480 frame = dwc2_frame_num_inc(hsotg->frame_number, 2); in dwc2_calc_starting_frame()
490 static u16 dwc2_recalc_initial_desc_idx(struct dwc2_hsotg *hsotg, in dwc2_recalc_initial_desc_idx() argument
514 frame = dwc2_calc_starting_frame(hsotg, qh, &skip_frames); in dwc2_recalc_initial_desc_idx()
525 qh->next_active_frame = dwc2_calc_starting_frame(hsotg, qh, in dwc2_recalc_initial_desc_idx()
541 static void dwc2_fill_host_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_fill_host_isoc_dma_desc() argument
573 dma_sync_single_for_device(hsotg->dev, in dwc2_fill_host_isoc_dma_desc()
580 static void dwc2_init_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_init_isoc_dma_desc() argument
591 hsotg->frame_number = dwc2_hcd_get_frame_number(hsotg); in dwc2_init_isoc_dma_desc()
592 cur_idx = dwc2_frame_list_idx(hsotg->frame_number); in dwc2_init_isoc_dma_desc()
604 dev_vdbg(hsotg->dev, in dwc2_init_isoc_dma_desc()
631 dwc2_fill_host_isoc_dma_desc(hsotg, qtd, qh, in dwc2_init_isoc_dma_desc()
647 dma_sync_single_for_device(hsotg->dev, in dwc2_init_isoc_dma_desc()
681 dma_sync_single_for_device(hsotg->dev, in dwc2_init_isoc_dma_desc()
689 static void dwc2_fill_host_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_fill_host_dma_desc() argument
723 dma_sync_single_for_device(hsotg->dev, in dwc2_fill_host_dma_desc()
741 static void dwc2_init_non_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_init_non_isoc_dma_desc() argument
748 dev_vdbg(hsotg->dev, "%s(): qh=%p dma=%08lx len=%d\n", __func__, qh, in dwc2_init_non_isoc_dma_desc()
759 dev_vdbg(hsotg->dev, "qtd=%p\n", qtd); in dwc2_init_non_isoc_dma_desc()
767 dev_vdbg(hsotg->dev, "buf=%08lx len=%d\n", in dwc2_init_non_isoc_dma_desc()
775 dev_vdbg(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
779 dma_sync_single_for_device(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
786 dwc2_fill_host_dma_desc(hsotg, chan, qtd, qh, n_desc); in dwc2_init_non_isoc_dma_desc()
787 dev_vdbg(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
797 dev_vdbg(hsotg->dev, "n_desc=%d\n", n_desc); in dwc2_init_non_isoc_dma_desc()
808 dev_vdbg(hsotg->dev, "set IOC/EOL/A bits in desc %d (%p)\n", in dwc2_init_non_isoc_dma_desc()
810 dma_sync_single_for_device(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
817 dev_vdbg(hsotg->dev, "set A bit in desc 0 (%p)\n", in dwc2_init_non_isoc_dma_desc()
819 dma_sync_single_for_device(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
847 void dwc2_hcd_start_xfer_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_hcd_start_xfer_ddma() argument
856 dwc2_init_non_isoc_dma_desc(hsotg, qh); in dwc2_hcd_start_xfer_ddma()
857 dwc2_hc_start_transfer_ddma(hsotg, chan); in dwc2_hcd_start_xfer_ddma()
860 dwc2_init_non_isoc_dma_desc(hsotg, qh); in dwc2_hcd_start_xfer_ddma()
861 dwc2_update_frame_list(hsotg, qh, 1); in dwc2_hcd_start_xfer_ddma()
862 dwc2_hc_start_transfer_ddma(hsotg, chan); in dwc2_hcd_start_xfer_ddma()
866 skip_frames = dwc2_recalc_initial_desc_idx(hsotg, qh); in dwc2_hcd_start_xfer_ddma()
867 dwc2_init_isoc_dma_desc(hsotg, qh, skip_frames); in dwc2_hcd_start_xfer_ddma()
870 dwc2_update_frame_list(hsotg, qh, 1); in dwc2_hcd_start_xfer_ddma()
880 dwc2_hc_start_transfer_ddma(hsotg, chan); in dwc2_hcd_start_xfer_ddma()
892 static int dwc2_cmpl_host_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_cmpl_host_isoc_dma_desc() argument
905 dma_sync_single_for_cpu(hsotg->dev, qh->desc_list_dma + (idx * in dwc2_cmpl_host_isoc_dma_desc()
938 dwc2_host_complete(hsotg, qtd, 0); in dwc2_cmpl_host_isoc_dma_desc()
939 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_cmpl_host_isoc_dma_desc()
961 static void dwc2_complete_isoc_xfer_ddma(struct dwc2_hsotg *hsotg, in dwc2_complete_isoc_xfer_ddma() argument
1003 dwc2_host_complete(hsotg, qtd, err); in dwc2_complete_isoc_xfer_ddma()
1006 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_complete_isoc_xfer_ddma()
1022 dev_vdbg(hsotg->dev, in dwc2_complete_isoc_xfer_ddma()
1032 rc = dwc2_cmpl_host_isoc_dma_desc(hsotg, chan, qtd, qh, in dwc2_complete_isoc_xfer_ddma()
1050 cur_idx = dwc2_frame_list_idx(hsotg->frame_number); in dwc2_complete_isoc_xfer_ddma()
1067 static int dwc2_update_non_isoc_urb_state_ddma(struct dwc2_hsotg *hsotg, in dwc2_update_non_isoc_urb_state_ddma() argument
1081 dev_vdbg(hsotg->dev, "remain=%d dwc2_urb=%p\n", remain, urb); in dwc2_update_non_isoc_urb_state_ddma()
1084 dev_err(hsotg->dev, "EIO\n"); in dwc2_update_non_isoc_urb_state_ddma()
1092 dev_vdbg(hsotg->dev, "Stall\n"); in dwc2_update_non_isoc_urb_state_ddma()
1096 dev_err(hsotg->dev, "Babble\n"); in dwc2_update_non_isoc_urb_state_ddma()
1100 dev_err(hsotg->dev, "XactErr\n"); in dwc2_update_non_isoc_urb_state_ddma()
1104 dev_err(hsotg->dev, in dwc2_update_non_isoc_urb_state_ddma()
1113 dev_vdbg(hsotg->dev, in dwc2_update_non_isoc_urb_state_ddma()
1138 dev_vdbg(hsotg->dev, "length=%d actual=%d\n", urb->length, in dwc2_update_non_isoc_urb_state_ddma()
1149 static int dwc2_process_non_isoc_desc(struct dwc2_hsotg *hsotg, in dwc2_process_non_isoc_desc() argument
1162 dev_vdbg(hsotg->dev, "%s()\n", __func__); in dwc2_process_non_isoc_desc()
1167 dma_sync_single_for_cpu(hsotg->dev, in dwc2_process_non_isoc_desc()
1175 dev_vdbg(hsotg->dev, in dwc2_process_non_isoc_desc()
1178 failed = dwc2_update_non_isoc_urb_state_ddma(hsotg, chan, qtd, dma_desc, in dwc2_process_non_isoc_desc()
1182 dwc2_host_complete(hsotg, qtd, urb->status); in dwc2_process_non_isoc_desc()
1183 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_process_non_isoc_desc()
1184 dev_vdbg(hsotg->dev, "failed=%1x xfer_done=%1x\n", in dwc2_process_non_isoc_desc()
1196 dev_vdbg(hsotg->dev, in dwc2_process_non_isoc_desc()
1202 dev_vdbg(hsotg->dev, in dwc2_process_non_isoc_desc()
1209 dwc2_hcd_save_data_toggle(hsotg, chan, chnum, in dwc2_process_non_isoc_desc()
1221 static void dwc2_complete_non_isoc_xfer_ddma(struct dwc2_hsotg *hsotg, in dwc2_complete_non_isoc_xfer_ddma() argument
1247 if (dwc2_process_non_isoc_desc(hsotg, chan, chnum, qtd, in dwc2_complete_non_isoc_xfer_ddma()
1267 dwc2_hcd_save_data_toggle(hsotg, chan, chnum, NULL); in dwc2_complete_non_isoc_xfer_ddma()
1299 void dwc2_hcd_complete_xfer_ddma(struct dwc2_hsotg *hsotg, in dwc2_hcd_complete_xfer_ddma() argument
1308 dwc2_complete_isoc_xfer_ddma(hsotg, chan, halt_status); in dwc2_hcd_complete_xfer_ddma()
1322 dwc2_host_complete(hsotg, qtd, in dwc2_hcd_complete_xfer_ddma()
1324 dwc2_hcd_qtd_unlink_and_free(hsotg, in dwc2_hcd_complete_xfer_ddma()
1330 dwc2_hc_halt(hsotg, chan, halt_status); in dwc2_hcd_complete_xfer_ddma()
1331 dwc2_release_channel_ddma(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1332 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1336 &hsotg->periodic_sched_assigned); in dwc2_hcd_complete_xfer_ddma()
1353 dwc2_complete_non_isoc_xfer_ddma(hsotg, chan, chnum, in dwc2_hcd_complete_xfer_ddma()
1355 dwc2_release_channel_ddma(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1356 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1363 dwc2_hcd_qh_add(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1367 tr_type = dwc2_hcd_select_transactions(hsotg); in dwc2_hcd_complete_xfer_ddma()
1375 dwc2_hcd_queue_transactions(hsotg, tr_type); in dwc2_hcd_complete_xfer_ddma()