Lines Matching refs:ehci
37 qtd_fill(struct ehci_hcd *ehci, struct ehci_qtd *qtd, dma_addr_t buf, in qtd_fill() argument
44 qtd->hw_buf[0] = cpu_to_hc32(ehci, (u32)addr); in qtd_fill()
45 qtd->hw_buf_hi[0] = cpu_to_hc32(ehci, (u32)(addr >> 32)); in qtd_fill()
56 qtd->hw_buf[i] = cpu_to_hc32(ehci, (u32)addr); in qtd_fill()
57 qtd->hw_buf_hi[i] = cpu_to_hc32(ehci, in qtd_fill()
70 qtd->hw_token = cpu_to_hc32(ehci, (count << 16) | token); in qtd_fill()
79 qh_update (struct ehci_hcd *ehci, struct ehci_qh *qh, struct ehci_qtd *qtd) in qh_update() argument
86 hw->hw_qtd_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_update()
87 hw->hw_alt_next = EHCI_LIST_END(ehci); in qh_update()
94 if (!(hw->hw_info1 & cpu_to_hc32(ehci, QH_TOGGLE_CTL))) { in qh_update()
98 epnum = (hc32_to_cpup(ehci, &hw->hw_info1) >> 8) & 0x0f; in qh_update()
100 hw->hw_token &= ~cpu_to_hc32(ehci, QTD_TOGGLE); in qh_update()
105 hw->hw_token &= cpu_to_hc32(ehci, QTD_TOGGLE | QTD_STS_PING); in qh_update()
113 qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_refresh() argument
126 if (qh->hw->hw_token & ACTIVE_BIT(ehci)) { in qh_refresh()
129 ehci_warn(ehci, "qh %p should be inactive!\n", qh); in qh_refresh()
131 qh_update(ehci, qh, qtd); in qh_refresh()
138 static void qh_link_async(struct ehci_hcd *ehci, struct ehci_qh *qh);
143 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_clear_tt_buffer_complete() local
147 spin_lock_irqsave(&ehci->lock, flags); in ehci_clear_tt_buffer_complete()
150 && ehci->rh_state == EHCI_RH_RUNNING) in ehci_clear_tt_buffer_complete()
151 qh_link_async(ehci, qh); in ehci_clear_tt_buffer_complete()
152 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_clear_tt_buffer_complete()
155 static void ehci_clear_tt_buffer(struct ehci_hcd *ehci, struct ehci_qh *qh, in ehci_clear_tt_buffer() argument
173 if (!ehci_is_TDI(ehci) in ehci_clear_tt_buffer()
175 ehci_to_hcd(ehci)->self.root_hub) { in ehci_clear_tt_buffer()
188 struct ehci_hcd *ehci, in qtd_copy_status() argument
237 ehci_dbg(ehci, "devpath %s ep%d%s 3strikes\n", in qtd_copy_status()
251 ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status) in ehci_urb_done() argument
255 ehci_to_hcd(ehci)->self.bandwidth_int_reqs--; in ehci_urb_done()
259 INCR(ehci->stats.unlink); in ehci_urb_done()
264 INCR(ehci->stats.complete); in ehci_urb_done()
268 ehci_dbg (ehci, in ehci_urb_done()
277 usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); in ehci_urb_done()
278 usb_hcd_giveback_urb(ehci_to_hcd(ehci), urb, status); in ehci_urb_done()
281 static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh);
289 qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_completions() argument
333 ehci_urb_done(ehci, last->urb, last_status); in qh_completions()
336 ehci_qtd_free (ehci, last); in qh_completions()
346 token = hc32_to_cpu(ehci, qtd->hw_token); in qh_completions()
354 ehci_dbg(ehci, in qh_completions()
375 ehci_dbg(ehci, in qh_completions()
387 qtd->hw_token = cpu_to_hc32(ehci, in qh_completions()
390 hw->hw_token = cpu_to_hc32(ehci, in qh_completions()
408 & EHCI_LIST_END(ehci))) { in qh_completions()
415 && ehci->rh_state >= EHCI_RH_RUNNING)) { in qh_completions()
423 if (ehci->rh_state < EHCI_RH_RUNNING) { in qh_completions()
444 (hw->hw_token & ACTIVE_BIT(ehci))) { in qh_completions()
445 token = hc32_to_cpu(ehci, hw->hw_token); in qh_completions()
446 hw->hw_token &= ~ACTIVE_BIT(ehci); in qh_completions()
453 ehci_clear_tt_buffer(ehci, qh, urb, token); in qh_completions()
465 last_status = qtd_copy_status(ehci, urb, in qh_completions()
469 & EHCI_LIST_END(ehci))) in qh_completions()
487 ehci_clear_tt_buffer(ehci, qh, urb, in qh_completions()
511 ehci_urb_done(ehci, last->urb, last_status); in qh_completions()
512 ehci_qtd_free (ehci, last); in qh_completions()
542 if (stopped != 0 || hw->hw_qtd_next == EHCI_LIST_END(ehci)) in qh_completions()
556 struct ehci_hcd *ehci, in qtd_list_free() argument
567 ehci_qtd_free (ehci, qtd); in qtd_list_free()
576 struct ehci_hcd *ehci, in qh_urb_transaction() argument
592 qtd = ehci_qtd_alloc (ehci, flags); in qh_urb_transaction()
606 qtd_fill(ehci, qtd, urb->setup_dma, in qh_urb_transaction()
613 qtd = ehci_qtd_alloc (ehci, flags); in qh_urb_transaction()
617 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
657 this_qtd_len = qtd_fill(ehci, qtd, buf, this_sg_len, token, in qh_urb_transaction()
669 qtd->hw_alt_next = ehci->async->hw->hw_alt_next; in qh_urb_transaction()
684 qtd = ehci_qtd_alloc (ehci, flags); in qh_urb_transaction()
688 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
699 qtd->hw_alt_next = EHCI_LIST_END(ehci); in qh_urb_transaction()
720 qtd = ehci_qtd_alloc (ehci, flags); in qh_urb_transaction()
724 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
728 qtd_fill(ehci, qtd, 0, 0, token, 0); in qh_urb_transaction()
734 qtd->hw_token |= cpu_to_hc32(ehci, QTD_IOC); in qh_urb_transaction()
738 qtd_list_free (ehci, urb, head); in qh_urb_transaction()
761 struct ehci_hcd *ehci, in qh_make() argument
765 struct ehci_qh *qh = ehci_qh_alloc (ehci, flags); in qh_make()
793 ehci_dbg(ehci, "bogus qh maxpacket %d\n", maxp); in qh_make()
822 } else if (urb->interval > ehci->periodic_size << 3) { in qh_make()
823 urb->interval = ehci->periodic_size << 3; in qh_make()
854 if (urb->interval > ehci->periodic_size) in qh_make()
855 urb->interval = ehci->periodic_size; in qh_make()
894 if (ehci_has_fsl_portno_bug(ehci)) in qh_make()
902 if (tt && tt->hub != ehci_to_hcd(ehci)->self.root_hub) in qh_make()
932 ehci_dbg(ehci, "bogus dev %p speed %d\n", urb->dev, in qh_make()
935 qh_destroy(ehci, qh); in qh_make()
944 hw->hw_info1 = cpu_to_hc32(ehci, info1); in qh_make()
945 hw->hw_info2 = cpu_to_hc32(ehci, info2); in qh_make()
953 static void enable_async(struct ehci_hcd *ehci) in enable_async() argument
955 if (ehci->async_count++) in enable_async()
959 ehci->enabled_hrtimer_events &= ~BIT(EHCI_HRTIMER_DISABLE_ASYNC); in enable_async()
962 ehci_poll_ASS(ehci); in enable_async()
963 turn_on_io_watchdog(ehci); in enable_async()
966 static void disable_async(struct ehci_hcd *ehci) in disable_async() argument
968 if (--ehci->async_count) in disable_async()
972 WARN_ON(ehci->async->qh_next.qh || !list_empty(&ehci->async_unlink) || in disable_async()
973 !list_empty(&ehci->async_idle)); in disable_async()
976 ehci_poll_ASS(ehci); in disable_async()
981 static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_link_async() argument
983 __hc32 dma = QH_NEXT(ehci, qh->qh_dma); in qh_link_async()
993 qh_refresh(ehci, qh); in qh_link_async()
996 head = ehci->async; in qh_link_async()
1009 enable_async(ehci); in qh_link_async()
1021 struct ehci_hcd *ehci, in qh_append_tds() argument
1029 __hc32 qh_addr_mask = cpu_to_hc32(ehci, 0x7f); in qh_append_tds()
1034 qh = qh_make (ehci, urb, GFP_ATOMIC); in qh_append_tds()
1068 qtd->hw_token = HALT_BIT(ehci); in qh_append_tds()
1080 ehci_qtd_init(ehci, qtd, qtd->qtd_dma); in qh_append_tds()
1087 qtd->hw_next = QTD_NEXT(ehci, dma); in qh_append_tds()
1103 struct ehci_hcd *ehci, in submit_async() argument
1119 ehci_dbg(ehci, in submit_async()
1128 spin_lock_irqsave (&ehci->lock, flags); in submit_async()
1129 if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { in submit_async()
1133 rc = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); in submit_async()
1137 qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv); in submit_async()
1139 usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); in submit_async()
1148 qh_link_async(ehci, qh); in submit_async()
1150 spin_unlock_irqrestore (&ehci->lock, flags); in submit_async()
1152 qtd_list_free (ehci, urb, qtd_list); in submit_async()
1173 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in submit_single_step_set_feature() local
1186 qtd = ehci_qtd_alloc(ehci, GFP_KERNEL); in submit_single_step_set_feature()
1203 qtd_fill(ehci, qtd, urb->setup_dma, in submit_single_step_set_feature()
1207 submit_async(ehci, urb, &qtd_list, GFP_ATOMIC); in submit_single_step_set_feature()
1222 qtd_fill(ehci, qtd, buf, len, token, maxpacket); in submit_single_step_set_feature()
1228 qtd->hw_alt_next = EHCI_LIST_END(ehci); in submit_single_step_set_feature()
1235 qtd = ehci_qtd_alloc(ehci, GFP_ATOMIC); in submit_single_step_set_feature()
1239 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in submit_single_step_set_feature()
1243 qtd_fill(ehci, qtd, 0, 0, token | QTD_IOC, 0); in submit_single_step_set_feature()
1245 submit_async(ehci, urb, &qtd_list, GFP_KERNEL); in submit_single_step_set_feature()
1250 qtd_list_free(ehci, urb, head); in submit_single_step_set_feature()
1257 static void single_unlink_async(struct ehci_hcd *ehci, struct ehci_qh *qh) in single_unlink_async() argument
1263 list_add_tail(&qh->unlink_node, &ehci->async_unlink); in single_unlink_async()
1266 prev = ehci->async; in single_unlink_async()
1272 if (ehci->qh_scan_next == qh) in single_unlink_async()
1273 ehci->qh_scan_next = qh->qh_next.qh; in single_unlink_async()
1276 static void start_iaa_cycle(struct ehci_hcd *ehci) in start_iaa_cycle() argument
1279 if (unlikely(ehci->rh_state < EHCI_RH_RUNNING)) { in start_iaa_cycle()
1280 end_unlink_async(ehci); in start_iaa_cycle()
1283 } else if (ehci->rh_state == EHCI_RH_RUNNING && in start_iaa_cycle()
1284 !ehci->iaa_in_progress) { in start_iaa_cycle()
1289 ehci_writel(ehci, ehci->command | CMD_IAAD, in start_iaa_cycle()
1290 &ehci->regs->command); in start_iaa_cycle()
1291 ehci_readl(ehci, &ehci->regs->command); in start_iaa_cycle()
1292 ehci->iaa_in_progress = true; in start_iaa_cycle()
1293 ehci_enable_event(ehci, EHCI_HRTIMER_IAA_WATCHDOG, true); in start_iaa_cycle()
1297 static void end_iaa_cycle(struct ehci_hcd *ehci) in end_iaa_cycle() argument
1299 if (ehci->has_synopsys_hc_bug) in end_iaa_cycle()
1300 ehci_writel(ehci, (u32) ehci->async->qh_dma, in end_iaa_cycle()
1301 &ehci->regs->async_next); in end_iaa_cycle()
1304 ehci->iaa_in_progress = false; in end_iaa_cycle()
1306 end_unlink_async(ehci); in end_iaa_cycle()
1311 static void end_unlink_async(struct ehci_hcd *ehci) in end_unlink_async() argument
1316 if (list_empty(&ehci->async_unlink)) in end_unlink_async()
1318 qh = list_first_entry(&ehci->async_unlink, struct ehci_qh, in end_unlink_async()
1325 early_exit = ehci->async_unlinking; in end_unlink_async()
1328 if (ehci->rh_state < EHCI_RH_RUNNING) in end_unlink_async()
1329 list_splice_tail_init(&ehci->async_unlink, &ehci->async_idle); in end_unlink_async()
1341 list_move_tail(&qh->unlink_node, &ehci->async_idle); in end_unlink_async()
1368 else if (qh->hw->hw_token & cpu_to_hc32(ehci, QTD_STS_HALT)) in end_unlink_async()
1377 if (qh_current != ehci->old_current || in end_unlink_async()
1378 qh_token != ehci->old_token) { in end_unlink_async()
1379 ehci->old_current = qh_current; in end_unlink_async()
1380 ehci->old_token = qh_token; in end_unlink_async()
1381 ehci_enable_event(ehci, in end_unlink_async()
1389 ehci->old_current = ~0; /* Prepare for next QH */ in end_unlink_async()
1392 if (!list_empty(&ehci->async_unlink)) in end_unlink_async()
1393 start_iaa_cycle(ehci); in end_unlink_async()
1403 ehci->async_unlinking = true; in end_unlink_async()
1404 while (!list_empty(&ehci->async_idle)) { in end_unlink_async()
1405 qh = list_first_entry(&ehci->async_idle, struct ehci_qh, in end_unlink_async()
1413 qh_completions(ehci, qh); in end_unlink_async()
1415 ehci->rh_state == EHCI_RH_RUNNING) in end_unlink_async()
1416 qh_link_async(ehci, qh); in end_unlink_async()
1417 disable_async(ehci); in end_unlink_async()
1419 ehci->async_unlinking = false; in end_unlink_async()
1422 static void start_unlink_async(struct ehci_hcd *ehci, struct ehci_qh *qh);
1424 static void unlink_empty_async(struct ehci_hcd *ehci) in unlink_empty_async() argument
1431 for (qh = ehci->async->qh_next.qh; qh; qh = qh->qh_next.qh) { in unlink_empty_async()
1435 if (qh->unlink_cycle != ehci->async_unlink_cycle) in unlink_empty_async()
1441 if (list_empty(&ehci->async_unlink) && qh_to_unlink) { in unlink_empty_async()
1443 start_unlink_async(ehci, qh_to_unlink); in unlink_empty_async()
1449 ehci_enable_event(ehci, EHCI_HRTIMER_ASYNC_UNLINKS, true); in unlink_empty_async()
1450 ++ehci->async_unlink_cycle; in unlink_empty_async()
1457 static void unlink_empty_async_suspended(struct ehci_hcd *ehci) in unlink_empty_async_suspended() argument
1461 while (ehci->async->qh_next.qh) { in unlink_empty_async_suspended()
1462 qh = ehci->async->qh_next.qh; in unlink_empty_async_suspended()
1464 single_unlink_async(ehci, qh); in unlink_empty_async_suspended()
1473 static void start_unlink_async(struct ehci_hcd *ehci, struct ehci_qh *qh) in start_unlink_async() argument
1479 single_unlink_async(ehci, qh); in start_unlink_async()
1480 start_iaa_cycle(ehci); in start_unlink_async()
1485 static void scan_async (struct ehci_hcd *ehci) in scan_async() argument
1490 ehci->qh_scan_next = ehci->async->qh_next.qh; in scan_async()
1491 while (ehci->qh_scan_next) { in scan_async()
1492 qh = ehci->qh_scan_next; in scan_async()
1493 ehci->qh_scan_next = qh->qh_next.qh; in scan_async()
1506 temp = qh_completions(ehci, qh); in scan_async()
1508 start_unlink_async(ehci, qh); in scan_async()
1511 qh->unlink_cycle = ehci->async_unlink_cycle; in scan_async()
1523 if (check_unlinks_later && ehci->rh_state == EHCI_RH_RUNNING && in scan_async()
1524 !(ehci->enabled_hrtimer_events & in scan_async()
1526 ehci_enable_event(ehci, EHCI_HRTIMER_ASYNC_UNLINKS, true); in scan_async()
1527 ++ehci->async_unlink_cycle; in scan_async()