Lines Matching refs:ehci
123 static unsigned ehci_moschip_read_frame_index(struct ehci_hcd *ehci) in ehci_moschip_read_frame_index() argument
127 uf = ehci_readl(ehci, &ehci->regs->frame_index); in ehci_moschip_read_frame_index()
129 uf = ehci_readl(ehci, &ehci->regs->frame_index); in ehci_moschip_read_frame_index()
133 static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci) in ehci_read_frame_index() argument
135 if (ehci->frame_index_bug) in ehci_read_frame_index()
136 return ehci_moschip_read_frame_index(ehci); in ehci_read_frame_index()
137 return ehci_readl(ehci, &ehci->regs->frame_index); in ehci_read_frame_index()
161 int ehci_handshake(struct ehci_hcd *ehci, void __iomem *ptr, in ehci_handshake() argument
167 result = ehci_readl(ehci, ptr); in ehci_handshake()
181 static int tdi_in_host_mode (struct ehci_hcd *ehci) in tdi_in_host_mode() argument
185 tmp = ehci_readl(ehci, &ehci->regs->usbmode); in tdi_in_host_mode()
193 static int ehci_halt (struct ehci_hcd *ehci) in ehci_halt() argument
197 spin_lock_irq(&ehci->lock); in ehci_halt()
200 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in ehci_halt()
202 if (ehci_is_TDI(ehci) && !tdi_in_host_mode(ehci)) { in ehci_halt()
203 spin_unlock_irq(&ehci->lock); in ehci_halt()
211 ehci->command &= ~CMD_RUN; in ehci_halt()
212 temp = ehci_readl(ehci, &ehci->regs->command); in ehci_halt()
214 ehci_writel(ehci, temp, &ehci->regs->command); in ehci_halt()
216 spin_unlock_irq(&ehci->lock); in ehci_halt()
217 synchronize_irq(ehci_to_hcd(ehci)->irq); in ehci_halt()
219 return ehci_handshake(ehci, &ehci->regs->status, in ehci_halt()
224 static void tdi_reset (struct ehci_hcd *ehci) in tdi_reset() argument
228 tmp = ehci_readl(ehci, &ehci->regs->usbmode); in tdi_reset()
234 if (ehci_big_endian_mmio(ehci)) in tdi_reset()
236 ehci_writel(ehci, tmp, &ehci->regs->usbmode); in tdi_reset()
243 int ehci_reset(struct ehci_hcd *ehci) in ehci_reset() argument
246 u32 command = ehci_readl(ehci, &ehci->regs->command); in ehci_reset()
250 if (ehci->debug && !dbgp_reset_prep(ehci_to_hcd(ehci))) in ehci_reset()
251 ehci->debug = NULL; in ehci_reset()
254 dbg_cmd (ehci, "reset", command); in ehci_reset()
255 ehci_writel(ehci, command, &ehci->regs->command); in ehci_reset()
256 ehci->rh_state = EHCI_RH_HALTED; in ehci_reset()
257 ehci->next_statechange = jiffies; in ehci_reset()
258 retval = ehci_handshake(ehci, &ehci->regs->command, in ehci_reset()
261 if (ehci->has_hostpc) { in ehci_reset()
262 ehci_writel(ehci, USBMODE_EX_HC | USBMODE_EX_VBPS, in ehci_reset()
263 &ehci->regs->usbmode_ex); in ehci_reset()
264 ehci_writel(ehci, TXFIFO_DEFAULT, &ehci->regs->txfill_tuning); in ehci_reset()
269 if (ehci_is_TDI(ehci)) in ehci_reset()
270 tdi_reset (ehci); in ehci_reset()
272 if (ehci->debug) in ehci_reset()
273 dbgp_external_startup(ehci_to_hcd(ehci)); in ehci_reset()
275 ehci->port_c_suspend = ehci->suspended_ports = in ehci_reset()
276 ehci->resuming_ports = 0; in ehci_reset()
285 static void ehci_quiesce (struct ehci_hcd *ehci) in ehci_quiesce() argument
289 if (ehci->rh_state != EHCI_RH_RUNNING) in ehci_quiesce()
293 temp = (ehci->command << 10) & (STS_ASS | STS_PSS); in ehci_quiesce()
294 ehci_handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, temp, in ehci_quiesce()
298 spin_lock_irq(&ehci->lock); in ehci_quiesce()
299 ehci->command &= ~(CMD_ASE | CMD_PSE); in ehci_quiesce()
300 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_quiesce()
301 spin_unlock_irq(&ehci->lock); in ehci_quiesce()
304 ehci_handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, 0, in ehci_quiesce()
310 static void end_unlink_async(struct ehci_hcd *ehci);
311 static void unlink_empty_async(struct ehci_hcd *ehci);
312 static void unlink_empty_async_suspended(struct ehci_hcd *ehci);
313 static void ehci_work(struct ehci_hcd *ehci);
314 static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
315 static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
316 static int ehci_port_power(struct ehci_hcd *ehci, int portnum, bool enable);
331 static void ehci_turn_off_all_ports(struct ehci_hcd *ehci) in ehci_turn_off_all_ports() argument
333 int port = HCS_N_PORTS(ehci->hcs_params); in ehci_turn_off_all_ports()
336 spin_unlock_irq(&ehci->lock); in ehci_turn_off_all_ports()
337 ehci_port_power(ehci, port, false); in ehci_turn_off_all_ports()
338 spin_lock_irq(&ehci->lock); in ehci_turn_off_all_ports()
339 ehci_writel(ehci, PORT_RWC_BITS, in ehci_turn_off_all_ports()
340 &ehci->regs->port_status[port]); in ehci_turn_off_all_ports()
348 static void ehci_silence_controller(struct ehci_hcd *ehci) in ehci_silence_controller() argument
350 ehci_halt(ehci); in ehci_silence_controller()
352 spin_lock_irq(&ehci->lock); in ehci_silence_controller()
353 ehci->rh_state = EHCI_RH_HALTED; in ehci_silence_controller()
354 ehci_turn_off_all_ports(ehci); in ehci_silence_controller()
357 ehci_writel(ehci, 0, &ehci->regs->configured_flag); in ehci_silence_controller()
360 ehci_readl(ehci, &ehci->regs->configured_flag); in ehci_silence_controller()
361 spin_unlock_irq(&ehci->lock); in ehci_silence_controller()
370 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_shutdown() local
372 spin_lock_irq(&ehci->lock); in ehci_shutdown()
373 ehci->shutdown = true; in ehci_shutdown()
374 ehci->rh_state = EHCI_RH_STOPPING; in ehci_shutdown()
375 ehci->enabled_hrtimer_events = 0; in ehci_shutdown()
376 spin_unlock_irq(&ehci->lock); in ehci_shutdown()
378 ehci_silence_controller(ehci); in ehci_shutdown()
380 hrtimer_cancel(&ehci->hrtimer); in ehci_shutdown()
389 static void ehci_work (struct ehci_hcd *ehci) in ehci_work() argument
395 if (ehci->scanning) { in ehci_work()
396 ehci->need_rescan = true; in ehci_work()
399 ehci->scanning = true; in ehci_work()
402 ehci->need_rescan = false; in ehci_work()
403 if (ehci->async_count) in ehci_work()
404 scan_async(ehci); in ehci_work()
405 if (ehci->intr_count > 0) in ehci_work()
406 scan_intr(ehci); in ehci_work()
407 if (ehci->isoc_count > 0) in ehci_work()
408 scan_isoc(ehci); in ehci_work()
409 if (ehci->need_rescan) in ehci_work()
411 ehci->scanning = false; in ehci_work()
417 turn_on_io_watchdog(ehci); in ehci_work()
425 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_stop() local
427 ehci_dbg (ehci, "stop\n"); in ehci_stop()
431 spin_lock_irq(&ehci->lock); in ehci_stop()
432 ehci->enabled_hrtimer_events = 0; in ehci_stop()
433 spin_unlock_irq(&ehci->lock); in ehci_stop()
435 ehci_quiesce(ehci); in ehci_stop()
436 ehci_silence_controller(ehci); in ehci_stop()
437 ehci_reset (ehci); in ehci_stop()
439 hrtimer_cancel(&ehci->hrtimer); in ehci_stop()
440 remove_sysfs_files(ehci); in ehci_stop()
441 remove_debug_files (ehci); in ehci_stop()
444 spin_lock_irq (&ehci->lock); in ehci_stop()
445 end_free_itds(ehci); in ehci_stop()
446 spin_unlock_irq (&ehci->lock); in ehci_stop()
447 ehci_mem_cleanup (ehci); in ehci_stop()
449 if (ehci->amd_pll_fix == 1) in ehci_stop()
452 dbg_status (ehci, "ehci_stop completed", in ehci_stop()
453 ehci_readl(ehci, &ehci->regs->status)); in ehci_stop()
459 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_init() local
465 spin_lock_init(&ehci->lock); in ehci_init()
470 ehci->need_io_watchdog = 1; in ehci_init()
472 hrtimer_init(&ehci->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); in ehci_init()
473 ehci->hrtimer.function = ehci_hrtimer_func; in ehci_init()
474 ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT; in ehci_init()
476 hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); in ehci_init()
482 ehci->uframe_periodic_max = 100; in ehci_init()
488 ehci->periodic_size = DEFAULT_I_TDPS; in ehci_init()
489 INIT_LIST_HEAD(&ehci->async_unlink); in ehci_init()
490 INIT_LIST_HEAD(&ehci->async_idle); in ehci_init()
491 INIT_LIST_HEAD(&ehci->intr_unlink_wait); in ehci_init()
492 INIT_LIST_HEAD(&ehci->intr_unlink); in ehci_init()
493 INIT_LIST_HEAD(&ehci->intr_qh_list); in ehci_init()
494 INIT_LIST_HEAD(&ehci->cached_itd_list); in ehci_init()
495 INIT_LIST_HEAD(&ehci->cached_sitd_list); in ehci_init()
496 INIT_LIST_HEAD(&ehci->tt_list); in ehci_init()
501 case 0: ehci->periodic_size = 1024; break; in ehci_init()
502 case 1: ehci->periodic_size = 512; break; in ehci_init()
503 case 2: ehci->periodic_size = 256; break; in ehci_init()
507 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0) in ehci_init()
512 ehci->i_thresh = 0; in ehci_init()
514 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); in ehci_init()
523 ehci->async->qh_next.qh = NULL; in ehci_init()
524 hw = ehci->async->hw; in ehci_init()
525 hw->hw_next = QH_NEXT(ehci, ehci->async->qh_dma); in ehci_init()
526 hw->hw_info1 = cpu_to_hc32(ehci, QH_HEAD); in ehci_init()
528 hw->hw_info1 |= cpu_to_hc32(ehci, QH_INACTIVATE); in ehci_init()
530 hw->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT); in ehci_init()
531 hw->hw_qtd_next = EHCI_LIST_END(ehci); in ehci_init()
532 ehci->async->qh_state = QH_STATE_LINKED; in ehci_init()
533 hw->hw_alt_next = QTD_NEXT(ehci, ehci->async->dummy->qtd_dma); in ehci_init()
540 ehci->has_ppcd = 1; in ehci_init()
541 ehci_dbg(ehci, "enable per-port change event\n"); in ehci_init()
557 ehci_dbg(ehci, "park %d\n", park); in ehci_init()
564 ehci->command = temp; in ehci_init()
575 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_run() local
584 ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list); in ehci_run()
585 ehci_writel(ehci, (u32)ehci->async->qh_dma, &ehci->regs->async_next); in ehci_run()
599 hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); in ehci_run()
601 ehci_writel(ehci, 0, &ehci->regs->segment); in ehci_run()
605 ehci_info(ehci, "enabled 64bit DMA\n"); in ehci_run()
612 ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET); in ehci_run()
613 ehci->command |= CMD_RUN; in ehci_run()
614 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_run()
615 dbg_cmd (ehci, "init", ehci->command); in ehci_run()
632 ehci->rh_state = EHCI_RH_RUNNING; in ehci_run()
633 ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); in ehci_run()
636 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ in ehci_run()
638 rc = ehci_handshake(ehci, &ehci->regs->status, STS_HALT, 0, 100 * 1000); in ehci_run()
643 ehci_err(ehci, "USB %x.%x, controller refused to start: %d\n", in ehci_run()
644 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), rc); in ehci_run()
648 ehci->last_periodic_enable = ktime_get_real(); in ehci_run()
650 temp = HC_VERSION(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); in ehci_run()
651 ehci_info (ehci, in ehci_run()
653 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), in ehci_run()
657 ehci_writel(ehci, INTR_MASK, in ehci_run()
658 &ehci->regs->intr_enable); /* Turn On Interrupts */ in ehci_run()
664 create_debug_files(ehci); in ehci_run()
665 create_sysfs_files(ehci); in ehci_run()
672 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_setup() local
675 ehci->regs = (void __iomem *)ehci->caps + in ehci_setup()
676 HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); in ehci_setup()
677 dbg_hcs_params(ehci, "reset"); in ehci_setup()
678 dbg_hcc_params(ehci, "reset"); in ehci_setup()
681 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); in ehci_setup()
683 ehci->sbrn = HCD_USB2; in ehci_setup()
690 retval = ehci_halt(ehci); in ehci_setup()
694 ehci_reset(ehci); in ehci_setup()
704 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_irq() local
715 spin_lock_irqsave(&ehci->lock, flags); in ehci_irq()
717 status = ehci_readl(ehci, &ehci->regs->status); in ehci_irq()
721 ehci_dbg (ehci, "device removed\n"); in ehci_irq()
732 if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) { in ehci_irq()
733 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_irq()
738 ehci_writel(ehci, masked_status, &ehci->regs->status); in ehci_irq()
739 cmd = ehci_readl(ehci, &ehci->regs->command); in ehci_irq()
745 COUNT (ehci->stats.normal); in ehci_irq()
747 COUNT (ehci->stats.error); in ehci_irq()
755 ehci->enabled_hrtimer_events &= ~BIT(EHCI_HRTIMER_IAA_WATCHDOG); in ehci_irq()
764 if (ehci->next_hrtimer_event == EHCI_HRTIMER_IAA_WATCHDOG) in ehci_irq()
765 ++ehci->next_hrtimer_event; in ehci_irq()
769 ehci_dbg(ehci, "IAA with IAAD still set?\n"); in ehci_irq()
770 if (ehci->iaa_in_progress) in ehci_irq()
771 COUNT(ehci->stats.iaa); in ehci_irq()
772 end_unlink_async(ehci); in ehci_irq()
777 unsigned i = HCS_N_PORTS (ehci->hcs_params); in ehci_irq()
784 if (ehci->rh_state == EHCI_RH_SUSPENDED) in ehci_irq()
788 if (ehci->has_ppcd) in ehci_irq()
797 pstatus = ehci_readl(ehci, in ehci_irq()
798 &ehci->regs->port_status[i]); in ehci_irq()
802 if (!(test_bit(i, &ehci->suspended_ports) && in ehci_irq()
806 ehci->reset_done[i] == 0)) in ehci_irq()
813 ehci->reset_done[i] = jiffies + in ehci_irq()
815 set_bit(i, &ehci->resuming_ports); in ehci_irq()
816 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); in ehci_irq()
818 mod_timer(&hcd->rh_timer, ehci->reset_done[i]); in ehci_irq()
824 ehci_err(ehci, "fatal error\n"); in ehci_irq()
825 dbg_cmd(ehci, "fatal", cmd); in ehci_irq()
826 dbg_status(ehci, "fatal", status); in ehci_irq()
831 ehci->shutdown = true; in ehci_irq()
832 ehci->rh_state = EHCI_RH_STOPPING; in ehci_irq()
833 ehci->command &= ~(CMD_RUN | CMD_ASE | CMD_PSE); in ehci_irq()
834 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_irq()
835 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in ehci_irq()
836 ehci_handle_controller_death(ehci); in ehci_irq()
843 ehci_work (ehci); in ehci_irq()
844 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_irq()
869 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_urb_enqueue() local
884 if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) in ehci_urb_enqueue()
886 return submit_async(ehci, urb, &qtd_list, mem_flags); in ehci_urb_enqueue()
889 if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags)) in ehci_urb_enqueue()
891 return intr_submit(ehci, urb, &qtd_list, mem_flags); in ehci_urb_enqueue()
895 return itd_submit (ehci, urb, mem_flags); in ehci_urb_enqueue()
897 return sitd_submit (ehci, urb, mem_flags); in ehci_urb_enqueue()
907 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_urb_dequeue() local
912 spin_lock_irqsave (&ehci->lock, flags); in ehci_urb_dequeue()
929 start_unlink_intr(ehci, qh); in ehci_urb_dequeue()
931 start_unlink_async(ehci, qh); in ehci_urb_dequeue()
942 qh_completions(ehci, qh); in ehci_urb_dequeue()
947 spin_unlock_irqrestore (&ehci->lock, flags); in ehci_urb_dequeue()
958 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_endpoint_disable() local
966 spin_lock_irqsave (&ehci->lock, flags); in ehci_endpoint_disable()
981 reserve_release_iso_bandwidth(ehci, stream, -1); in ehci_endpoint_disable()
991 start_unlink_async(ehci, qh); in ehci_endpoint_disable()
993 start_unlink_intr(ehci, qh); in ehci_endpoint_disable()
999 spin_unlock_irqrestore (&ehci->lock, flags); in ehci_endpoint_disable()
1007 reserve_release_intr_bandwidth(ehci, qh, -1); in ehci_endpoint_disable()
1008 qh_destroy(ehci, qh); in ehci_endpoint_disable()
1016 ehci_err (ehci, "qh %p (#%02x) state %d%s\n", in ehci_endpoint_disable()
1023 spin_unlock_irqrestore (&ehci->lock, flags); in ehci_endpoint_disable()
1029 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_endpoint_reset() local
1039 spin_lock_irqsave(&ehci->lock, flags); in ehci_endpoint_reset()
1058 start_unlink_async(ehci, qh); in ehci_endpoint_reset()
1060 start_unlink_intr(ehci, qh); in ehci_endpoint_reset()
1063 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_endpoint_reset()
1068 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_get_frame() local
1069 return (ehci_read_frame_index(ehci) >> 3) % ehci->periodic_size; in ehci_get_frame()
1078 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_remove_device() local
1080 spin_lock_irq(&ehci->lock); in ehci_remove_device()
1082 spin_unlock_irq(&ehci->lock); in ehci_remove_device()
1095 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_suspend() local
1097 if (time_before(jiffies, ehci->next_statechange)) in ehci_suspend()
1105 ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup); in ehci_suspend()
1107 spin_lock_irq(&ehci->lock); in ehci_suspend()
1108 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in ehci_suspend()
1109 (void) ehci_readl(ehci, &ehci->regs->intr_enable); in ehci_suspend()
1112 spin_unlock_irq(&ehci->lock); in ehci_suspend()
1129 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_resume() local
1131 if (time_before(jiffies, ehci->next_statechange)) in ehci_resume()
1137 if (ehci->shutdown) in ehci_resume()
1145 if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF && in ehci_resume()
1149 ehci_prepare_ports_for_controller_resume(ehci); in ehci_resume()
1151 spin_lock_irq(&ehci->lock); in ehci_resume()
1152 if (ehci->shutdown) in ehci_resume()
1157 ehci_writel(ehci, mask, &ehci->regs->intr_enable); in ehci_resume()
1158 ehci_readl(ehci, &ehci->regs->intr_enable); in ehci_resume()
1160 spin_unlock_irq(&ehci->lock); in ehci_resume()
1169 (void) ehci_halt(ehci); in ehci_resume()
1170 (void) ehci_reset(ehci); in ehci_resume()
1172 spin_lock_irq(&ehci->lock); in ehci_resume()
1173 if (ehci->shutdown) in ehci_resume()
1176 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_resume()
1177 ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); in ehci_resume()
1178 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ in ehci_resume()
1180 ehci->rh_state = EHCI_RH_SUSPENDED; in ehci_resume()
1181 spin_unlock_irq(&ehci->lock); in ehci_resume()