Lines Matching refs:hsotg
58 static int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_desc_list_alloc() argument
65 desc_cache = hsotg->desc_hsisoc_cache; in dwc2_desc_list_alloc()
67 desc_cache = hsotg->desc_gen_cache; in dwc2_desc_list_alloc()
76 qh->desc_list_dma = dma_map_single(hsotg->dev, qh->desc_list, in dwc2_desc_list_alloc()
82 dma_unmap_single(hsotg->dev, qh->desc_list_dma, in dwc2_desc_list_alloc()
93 static void dwc2_desc_list_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_desc_list_free() argument
99 desc_cache = hsotg->desc_hsisoc_cache; in dwc2_desc_list_free()
101 desc_cache = hsotg->desc_gen_cache; in dwc2_desc_list_free()
104 dma_unmap_single(hsotg->dev, qh->desc_list_dma, in dwc2_desc_list_free()
114 static int dwc2_frame_list_alloc(struct dwc2_hsotg *hsotg, gfp_t mem_flags) in dwc2_frame_list_alloc() argument
116 if (hsotg->frame_list) in dwc2_frame_list_alloc()
119 hsotg->frame_list_sz = 4 * FRLISTEN_64_SIZE; in dwc2_frame_list_alloc()
120 hsotg->frame_list = kzalloc(hsotg->frame_list_sz, GFP_ATOMIC | GFP_DMA); in dwc2_frame_list_alloc()
121 if (!hsotg->frame_list) in dwc2_frame_list_alloc()
124 hsotg->frame_list_dma = dma_map_single(hsotg->dev, hsotg->frame_list, in dwc2_frame_list_alloc()
125 hsotg->frame_list_sz, in dwc2_frame_list_alloc()
131 static void dwc2_frame_list_free(struct dwc2_hsotg *hsotg) in dwc2_frame_list_free() argument
135 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_frame_list_free()
137 if (!hsotg->frame_list) { in dwc2_frame_list_free()
138 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_frame_list_free()
142 dma_unmap_single(hsotg->dev, hsotg->frame_list_dma, in dwc2_frame_list_free()
143 hsotg->frame_list_sz, DMA_FROM_DEVICE); in dwc2_frame_list_free()
145 kfree(hsotg->frame_list); in dwc2_frame_list_free()
146 hsotg->frame_list = NULL; in dwc2_frame_list_free()
148 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_frame_list_free()
151 static void dwc2_per_sched_enable(struct dwc2_hsotg *hsotg, u32 fr_list_en) in dwc2_per_sched_enable() argument
156 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_per_sched_enable()
158 hcfg = dwc2_readl(hsotg, HCFG); in dwc2_per_sched_enable()
161 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_enable()
165 dwc2_writel(hsotg, hsotg->frame_list_dma, HFLBADDR); in dwc2_per_sched_enable()
169 dev_vdbg(hsotg->dev, "Enabling Periodic schedule\n"); in dwc2_per_sched_enable()
170 dwc2_writel(hsotg, hcfg, HCFG); in dwc2_per_sched_enable()
172 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_enable()
175 static void dwc2_per_sched_disable(struct dwc2_hsotg *hsotg) in dwc2_per_sched_disable() argument
180 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_per_sched_disable()
182 hcfg = dwc2_readl(hsotg, HCFG); in dwc2_per_sched_disable()
185 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_disable()
190 dev_vdbg(hsotg->dev, "Disabling Periodic schedule\n"); in dwc2_per_sched_disable()
191 dwc2_writel(hsotg, hcfg, HCFG); in dwc2_per_sched_disable()
193 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_per_sched_disable()
200 static void dwc2_update_frame_list(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_update_frame_list() argument
206 if (!hsotg) { in dwc2_update_frame_list()
207 pr_err("hsotg = %p\n", hsotg); in dwc2_update_frame_list()
212 dev_err(hsotg->dev, "qh->channel = %p\n", qh->channel); in dwc2_update_frame_list()
216 if (!hsotg->frame_list) { in dwc2_update_frame_list()
217 dev_err(hsotg->dev, "hsotg->frame_list = %p\n", in dwc2_update_frame_list()
218 hsotg->frame_list); in dwc2_update_frame_list()
232 hsotg->frame_list[j] |= 1 << chan->hc_num; in dwc2_update_frame_list()
234 hsotg->frame_list[j] &= ~(1 << chan->hc_num); in dwc2_update_frame_list()
242 dma_sync_single_for_device(hsotg->dev, in dwc2_update_frame_list()
243 hsotg->frame_list_dma, in dwc2_update_frame_list()
244 hsotg->frame_list_sz, in dwc2_update_frame_list()
264 static void dwc2_release_channel_ddma(struct dwc2_hsotg *hsotg, in dwc2_release_channel_ddma() argument
270 if (hsotg->params.uframe_sched) in dwc2_release_channel_ddma()
271 hsotg->available_host_channels++; in dwc2_release_channel_ddma()
273 hsotg->non_periodic_channels--; in dwc2_release_channel_ddma()
275 dwc2_update_frame_list(hsotg, qh, 0); in dwc2_release_channel_ddma()
276 hsotg->available_host_channels++; in dwc2_release_channel_ddma()
286 dwc2_hc_cleanup(hsotg, chan); in dwc2_release_channel_ddma()
287 list_add_tail(&chan->hc_list_entry, &hsotg->free_hc_list); in dwc2_release_channel_ddma()
312 int dwc2_hcd_qh_init_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, in dwc2_hcd_qh_init_ddma() argument
318 dev_err(hsotg->dev, in dwc2_hcd_qh_init_ddma()
324 retval = dwc2_desc_list_alloc(hsotg, qh, mem_flags); in dwc2_hcd_qh_init_ddma()
330 if (!hsotg->frame_list) { in dwc2_hcd_qh_init_ddma()
331 retval = dwc2_frame_list_alloc(hsotg, mem_flags); in dwc2_hcd_qh_init_ddma()
335 dwc2_per_sched_enable(hsotg, HCFG_FRLISTEN_64); in dwc2_hcd_qh_init_ddma()
343 dwc2_desc_list_free(hsotg, qh); in dwc2_hcd_qh_init_ddma()
358 void dwc2_hcd_qh_free_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_hcd_qh_free_ddma() argument
362 dwc2_desc_list_free(hsotg, qh); in dwc2_hcd_qh_free_ddma()
371 spin_lock_irqsave(&hsotg->lock, flags); in dwc2_hcd_qh_free_ddma()
373 dwc2_release_channel_ddma(hsotg, qh); in dwc2_hcd_qh_free_ddma()
374 spin_unlock_irqrestore(&hsotg->lock, flags); in dwc2_hcd_qh_free_ddma()
378 (hsotg->params.uframe_sched || in dwc2_hcd_qh_free_ddma()
379 !hsotg->periodic_channels) && hsotg->frame_list) { in dwc2_hcd_qh_free_ddma()
380 dwc2_per_sched_disable(hsotg); in dwc2_hcd_qh_free_ddma()
381 dwc2_frame_list_free(hsotg); in dwc2_hcd_qh_free_ddma()
398 static u16 dwc2_calc_starting_frame(struct dwc2_hsotg *hsotg, in dwc2_calc_starting_frame() argument
403 hsotg->frame_number = dwc2_hcd_get_frame_number(hsotg); in dwc2_calc_starting_frame()
432 if (dwc2_micro_frame_num(hsotg->frame_number) >= 5) { in dwc2_calc_starting_frame()
434 frame = dwc2_frame_num_inc(hsotg->frame_number, in dwc2_calc_starting_frame()
438 frame = dwc2_frame_num_inc(hsotg->frame_number, in dwc2_calc_starting_frame()
450 frame = dwc2_frame_num_inc(hsotg->frame_number, 2); in dwc2_calc_starting_frame()
460 static u16 dwc2_recalc_initial_desc_idx(struct dwc2_hsotg *hsotg, in dwc2_recalc_initial_desc_idx() argument
484 frame = dwc2_calc_starting_frame(hsotg, qh, &skip_frames); in dwc2_recalc_initial_desc_idx()
495 qh->next_active_frame = dwc2_calc_starting_frame(hsotg, qh, in dwc2_recalc_initial_desc_idx()
511 static void dwc2_fill_host_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_fill_host_isoc_dma_desc() argument
543 dma_sync_single_for_device(hsotg->dev, in dwc2_fill_host_isoc_dma_desc()
550 static void dwc2_init_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_init_isoc_dma_desc() argument
561 hsotg->frame_number = dwc2_hcd_get_frame_number(hsotg); in dwc2_init_isoc_dma_desc()
562 cur_idx = dwc2_frame_list_idx(hsotg->frame_number); in dwc2_init_isoc_dma_desc()
574 dev_vdbg(hsotg->dev, in dwc2_init_isoc_dma_desc()
601 dwc2_fill_host_isoc_dma_desc(hsotg, qtd, qh, in dwc2_init_isoc_dma_desc()
617 dma_sync_single_for_device(hsotg->dev, in dwc2_init_isoc_dma_desc()
651 dma_sync_single_for_device(hsotg->dev, in dwc2_init_isoc_dma_desc()
659 static void dwc2_fill_host_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_fill_host_dma_desc() argument
693 dma_sync_single_for_device(hsotg->dev, in dwc2_fill_host_dma_desc()
711 static void dwc2_init_non_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_init_non_isoc_dma_desc() argument
718 dev_vdbg(hsotg->dev, "%s(): qh=%p dma=%08lx len=%d\n", __func__, qh, in dwc2_init_non_isoc_dma_desc()
729 dev_vdbg(hsotg->dev, "qtd=%p\n", qtd); in dwc2_init_non_isoc_dma_desc()
737 dev_vdbg(hsotg->dev, "buf=%08lx len=%d\n", in dwc2_init_non_isoc_dma_desc()
745 dev_vdbg(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
749 dma_sync_single_for_device(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
756 dwc2_fill_host_dma_desc(hsotg, chan, qtd, qh, n_desc); in dwc2_init_non_isoc_dma_desc()
757 dev_vdbg(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
767 dev_vdbg(hsotg->dev, "n_desc=%d\n", n_desc); in dwc2_init_non_isoc_dma_desc()
778 dev_vdbg(hsotg->dev, "set IOC/EOL/A bits in desc %d (%p)\n", in dwc2_init_non_isoc_dma_desc()
780 dma_sync_single_for_device(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
787 dev_vdbg(hsotg->dev, "set A bit in desc 0 (%p)\n", in dwc2_init_non_isoc_dma_desc()
789 dma_sync_single_for_device(hsotg->dev, in dwc2_init_non_isoc_dma_desc()
817 void dwc2_hcd_start_xfer_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) in dwc2_hcd_start_xfer_ddma() argument
826 dwc2_init_non_isoc_dma_desc(hsotg, qh); in dwc2_hcd_start_xfer_ddma()
827 dwc2_hc_start_transfer_ddma(hsotg, chan); in dwc2_hcd_start_xfer_ddma()
830 dwc2_init_non_isoc_dma_desc(hsotg, qh); in dwc2_hcd_start_xfer_ddma()
831 dwc2_update_frame_list(hsotg, qh, 1); in dwc2_hcd_start_xfer_ddma()
832 dwc2_hc_start_transfer_ddma(hsotg, chan); in dwc2_hcd_start_xfer_ddma()
836 skip_frames = dwc2_recalc_initial_desc_idx(hsotg, qh); in dwc2_hcd_start_xfer_ddma()
837 dwc2_init_isoc_dma_desc(hsotg, qh, skip_frames); in dwc2_hcd_start_xfer_ddma()
840 dwc2_update_frame_list(hsotg, qh, 1); in dwc2_hcd_start_xfer_ddma()
850 dwc2_hc_start_transfer_ddma(hsotg, chan); in dwc2_hcd_start_xfer_ddma()
862 static int dwc2_cmpl_host_isoc_dma_desc(struct dwc2_hsotg *hsotg, in dwc2_cmpl_host_isoc_dma_desc() argument
875 dma_sync_single_for_cpu(hsotg->dev, qh->desc_list_dma + (idx * in dwc2_cmpl_host_isoc_dma_desc()
908 dwc2_host_complete(hsotg, qtd, 0); in dwc2_cmpl_host_isoc_dma_desc()
909 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_cmpl_host_isoc_dma_desc()
931 static void dwc2_complete_isoc_xfer_ddma(struct dwc2_hsotg *hsotg, in dwc2_complete_isoc_xfer_ddma() argument
973 dwc2_host_complete(hsotg, qtd, err); in dwc2_complete_isoc_xfer_ddma()
976 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_complete_isoc_xfer_ddma()
992 dev_vdbg(hsotg->dev, in dwc2_complete_isoc_xfer_ddma()
1002 rc = dwc2_cmpl_host_isoc_dma_desc(hsotg, chan, qtd, qh, in dwc2_complete_isoc_xfer_ddma()
1020 cur_idx = dwc2_frame_list_idx(hsotg->frame_number); in dwc2_complete_isoc_xfer_ddma()
1037 static int dwc2_update_non_isoc_urb_state_ddma(struct dwc2_hsotg *hsotg, in dwc2_update_non_isoc_urb_state_ddma() argument
1051 dev_vdbg(hsotg->dev, "remain=%d dwc2_urb=%p\n", remain, urb); in dwc2_update_non_isoc_urb_state_ddma()
1054 dev_err(hsotg->dev, "EIO\n"); in dwc2_update_non_isoc_urb_state_ddma()
1062 dev_vdbg(hsotg->dev, "Stall\n"); in dwc2_update_non_isoc_urb_state_ddma()
1066 dev_err(hsotg->dev, "Babble\n"); in dwc2_update_non_isoc_urb_state_ddma()
1070 dev_err(hsotg->dev, "XactErr\n"); in dwc2_update_non_isoc_urb_state_ddma()
1074 dev_err(hsotg->dev, in dwc2_update_non_isoc_urb_state_ddma()
1083 dev_vdbg(hsotg->dev, in dwc2_update_non_isoc_urb_state_ddma()
1108 dev_vdbg(hsotg->dev, "length=%d actual=%d\n", urb->length, in dwc2_update_non_isoc_urb_state_ddma()
1119 static int dwc2_process_non_isoc_desc(struct dwc2_hsotg *hsotg, in dwc2_process_non_isoc_desc() argument
1132 dev_vdbg(hsotg->dev, "%s()\n", __func__); in dwc2_process_non_isoc_desc()
1137 dma_sync_single_for_cpu(hsotg->dev, in dwc2_process_non_isoc_desc()
1145 dev_vdbg(hsotg->dev, in dwc2_process_non_isoc_desc()
1148 failed = dwc2_update_non_isoc_urb_state_ddma(hsotg, chan, qtd, dma_desc, in dwc2_process_non_isoc_desc()
1152 dwc2_host_complete(hsotg, qtd, urb->status); in dwc2_process_non_isoc_desc()
1153 dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); in dwc2_process_non_isoc_desc()
1154 dev_vdbg(hsotg->dev, "failed=%1x xfer_done=%1x\n", in dwc2_process_non_isoc_desc()
1166 dev_vdbg(hsotg->dev, in dwc2_process_non_isoc_desc()
1172 dev_vdbg(hsotg->dev, in dwc2_process_non_isoc_desc()
1179 dwc2_hcd_save_data_toggle(hsotg, chan, chnum, in dwc2_process_non_isoc_desc()
1191 static void dwc2_complete_non_isoc_xfer_ddma(struct dwc2_hsotg *hsotg, in dwc2_complete_non_isoc_xfer_ddma() argument
1217 if (dwc2_process_non_isoc_desc(hsotg, chan, chnum, qtd, in dwc2_complete_non_isoc_xfer_ddma()
1237 dwc2_hcd_save_data_toggle(hsotg, chan, chnum, NULL); in dwc2_complete_non_isoc_xfer_ddma()
1269 void dwc2_hcd_complete_xfer_ddma(struct dwc2_hsotg *hsotg, in dwc2_hcd_complete_xfer_ddma() argument
1278 dwc2_complete_isoc_xfer_ddma(hsotg, chan, halt_status); in dwc2_hcd_complete_xfer_ddma()
1292 dwc2_host_complete(hsotg, qtd, in dwc2_hcd_complete_xfer_ddma()
1294 dwc2_hcd_qtd_unlink_and_free(hsotg, in dwc2_hcd_complete_xfer_ddma()
1300 dwc2_hc_halt(hsotg, chan, halt_status); in dwc2_hcd_complete_xfer_ddma()
1301 dwc2_release_channel_ddma(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1302 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1306 &hsotg->periodic_sched_assigned); in dwc2_hcd_complete_xfer_ddma()
1323 dwc2_complete_non_isoc_xfer_ddma(hsotg, chan, chnum, in dwc2_hcd_complete_xfer_ddma()
1325 dwc2_release_channel_ddma(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1326 dwc2_hcd_qh_unlink(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1333 dwc2_hcd_qh_add(hsotg, qh); in dwc2_hcd_complete_xfer_ddma()
1337 tr_type = dwc2_hcd_select_transactions(hsotg); in dwc2_hcd_complete_xfer_ddma()
1345 dwc2_hcd_queue_transactions(hsotg, tr_type); in dwc2_hcd_complete_xfer_ddma()