Lines Matching refs:ehci

109 #include "ehci.h"
122 static unsigned ehci_moschip_read_frame_index(struct ehci_hcd *ehci)
126 uf = ehci_readl(ehci, &ehci->regs->frame_index);
128 uf = ehci_readl(ehci, &ehci->regs->frame_index);
132 static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
134 if (ehci->frame_index_bug)
135 return ehci_moschip_read_frame_index(ehci);
136 return ehci_readl(ehci, &ehci->regs->frame_index);
139 #include "ehci-dbg.c"
160 int ehci_handshake(struct ehci_hcd *ehci, void __iomem *ptr,
166 result = ehci_readl(ehci, ptr);
180 static int tdi_in_host_mode (struct ehci_hcd *ehci)
184 tmp = ehci_readl(ehci, &ehci->regs->usbmode);
192 static int ehci_halt (struct ehci_hcd *ehci)
196 spin_lock_irq(&ehci->lock);
199 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
201 if (ehci_is_TDI(ehci) && !tdi_in_host_mode(ehci)) {
202 spin_unlock_irq(&ehci->lock);
207 * This routine gets called during probe before ehci->command
210 ehci->command &= ~CMD_RUN;
211 temp = ehci_readl(ehci, &ehci->regs->command);
213 ehci_writel(ehci, temp, &ehci->regs->command);
215 spin_unlock_irq(&ehci->lock);
216 synchronize_irq(ehci_to_hcd(ehci)->irq);
218 return ehci_handshake(ehci, &ehci->regs->status,
223 static void tdi_reset (struct ehci_hcd *ehci)
227 tmp = ehci_readl(ehci, &ehci->regs->usbmode);
233 if (ehci_big_endian_mmio(ehci))
235 ehci_writel(ehci, tmp, &ehci->regs->usbmode);
242 static int ehci_reset (struct ehci_hcd *ehci)
245 u32 command = ehci_readl(ehci, &ehci->regs->command);
249 if (ehci->debug && !dbgp_reset_prep(ehci_to_hcd(ehci)))
250 ehci->debug = NULL;
253 dbg_cmd (ehci, "reset", command);
254 ehci_writel(ehci, command, &ehci->regs->command);
255 ehci->rh_state = EHCI_RH_HALTED;
256 ehci->next_statechange = jiffies;
257 retval = ehci_handshake(ehci, &ehci->regs->command,
260 if (ehci->has_hostpc) {
261 ehci_writel(ehci, USBMODE_EX_HC | USBMODE_EX_VBPS,
262 &ehci->regs->usbmode_ex);
263 ehci_writel(ehci, TXFIFO_DEFAULT, &ehci->regs->txfill_tuning);
268 if (ehci_is_TDI(ehci))
269 tdi_reset (ehci);
271 if (ehci->debug)
272 dbgp_external_startup(ehci_to_hcd(ehci));
274 ehci->port_c_suspend = ehci->suspended_ports =
275 ehci->resuming_ports = 0;
283 static void ehci_quiesce (struct ehci_hcd *ehci)
287 if (ehci->rh_state != EHCI_RH_RUNNING)
291 temp = (ehci->command << 10) & (STS_ASS | STS_PSS);
292 ehci_handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, temp,
296 spin_lock_irq(&ehci->lock);
297 ehci->command &= ~(CMD_ASE | CMD_PSE);
298 ehci_writel(ehci, ehci->command, &ehci->regs->command);
299 spin_unlock_irq(&ehci->lock);
302 ehci_handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, 0,
308 static void end_unlink_async(struct ehci_hcd *ehci);
309 static void unlink_empty_async(struct ehci_hcd *ehci);
310 static void unlink_empty_async_suspended(struct ehci_hcd *ehci);
311 static void ehci_work(struct ehci_hcd *ehci);
312 static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
313 static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
315 #include "ehci-timer.c"
316 #include "ehci-hub.c"
317 #include "ehci-mem.c"
318 #include "ehci-q.c"
319 #include "ehci-sched.c"
320 #include "ehci-sysfs.c"
328 static void ehci_turn_off_all_ports(struct ehci_hcd *ehci)
330 int port = HCS_N_PORTS(ehci->hcs_params);
333 ehci_writel(ehci, PORT_RWC_BITS,
334 &ehci->regs->port_status[port]);
341 static void ehci_silence_controller(struct ehci_hcd *ehci)
343 ehci_halt(ehci);
345 spin_lock_irq(&ehci->lock);
346 ehci->rh_state = EHCI_RH_HALTED;
347 ehci_turn_off_all_ports(ehci);
350 ehci_writel(ehci, 0, &ehci->regs->configured_flag);
353 ehci_readl(ehci, &ehci->regs->configured_flag);
354 spin_unlock_irq(&ehci->lock);
363 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
365 spin_lock_irq(&ehci->lock);
366 ehci->shutdown = true;
367 ehci->rh_state = EHCI_RH_STOPPING;
368 ehci->enabled_hrtimer_events = 0;
369 spin_unlock_irq(&ehci->lock);
371 ehci_silence_controller(ehci);
373 hrtimer_cancel(&ehci->hrtimer);
380 * it calls driver completion functions, after dropping ehci->lock.
382 static void ehci_work (struct ehci_hcd *ehci)
384 /* another CPU may drop ehci->lock during a schedule scan while
388 if (ehci->scanning) {
389 ehci->need_rescan = true;
392 ehci->scanning = true;
395 ehci->need_rescan = false;
396 if (ehci->async_count)
397 scan_async(ehci);
398 if (ehci->intr_count > 0)
399 scan_intr(ehci);
400 if (ehci->isoc_count > 0)
401 scan_isoc(ehci);
402 if (ehci->need_rescan)
404 ehci->scanning = false;
410 turn_on_io_watchdog(ehci);
418 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
420 ehci_dbg (ehci, "stop\n");
424 spin_lock_irq(&ehci->lock);
425 ehci->enabled_hrtimer_events = 0;
426 spin_unlock_irq(&ehci->lock);
428 ehci_quiesce(ehci);
429 ehci_silence_controller(ehci);
430 ehci_reset (ehci);
432 hrtimer_cancel(&ehci->hrtimer);
433 remove_sysfs_files(ehci);
434 remove_debug_files (ehci);
437 spin_lock_irq (&ehci->lock);
438 end_free_itds(ehci);
439 spin_unlock_irq (&ehci->lock);
440 ehci_mem_cleanup (ehci);
442 if (ehci->amd_pll_fix == 1)
445 dbg_status (ehci, "ehci_stop completed",
446 ehci_readl(ehci, &ehci->regs->status));
452 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
458 spin_lock_init(&ehci->lock);
463 ehci->need_io_watchdog = 1;
465 hrtimer_init(&ehci->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
466 ehci->hrtimer.function = ehci_hrtimer_func;
467 ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT;
469 hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);
475 ehci->uframe_periodic_max = 100;
481 ehci->periodic_size = DEFAULT_I_TDPS;
482 INIT_LIST_HEAD(&ehci->async_unlink);
483 INIT_LIST_HEAD(&ehci->async_idle);
484 INIT_LIST_HEAD(&ehci->intr_unlink_wait);
485 INIT_LIST_HEAD(&ehci->intr_unlink);
486 INIT_LIST_HEAD(&ehci->intr_qh_list);
487 INIT_LIST_HEAD(&ehci->cached_itd_list);
488 INIT_LIST_HEAD(&ehci->cached_sitd_list);
489 INIT_LIST_HEAD(&ehci->tt_list);
494 case 0: ehci->periodic_size = 1024; break;
495 case 1: ehci->periodic_size = 512; break;
496 case 2: ehci->periodic_size = 256; break;
500 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0)
505 ehci->i_thresh = 0;
507 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
516 ehci->async->qh_next.qh = NULL;
517 hw = ehci->async->hw;
518 hw->hw_next = QH_NEXT(ehci, ehci->async->qh_dma);
519 hw->hw_info1 = cpu_to_hc32(ehci, QH_HEAD);
521 hw->hw_info1 |= cpu_to_hc32(ehci, QH_INACTIVATE);
523 hw->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT);
524 hw->hw_qtd_next = EHCI_LIST_END(ehci);
525 ehci->async->qh_state = QH_STATE_LINKED;
526 hw->hw_alt_next = QTD_NEXT(ehci, ehci->async->dummy->qtd_dma);
533 ehci->has_ppcd = 1;
534 ehci_dbg(ehci, "enable per-port change event\n");
550 ehci_dbg(ehci, "park %d\n", park);
557 ehci->command = temp;
568 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
576 ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list);
577 ehci_writel(ehci, (u32)ehci->async->qh_dma, &ehci->regs->async_next);
580 * hcc_params controls whether ehci->regs->segment must (!!!)
591 hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);
593 ehci_writel(ehci, 0, &ehci->regs->segment);
597 ehci_info(ehci, "enabled 64bit DMA\n");
604 ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET);
605 ehci->command |= CMD_RUN;
606 ehci_writel(ehci, ehci->command, &ehci->regs->command);
607 dbg_cmd (ehci, "init", ehci->command);
624 ehci->rh_state = EHCI_RH_RUNNING;
625 ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
626 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
629 ehci->last_periodic_enable = ktime_get_real();
631 temp = HC_VERSION(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
632 ehci_info (ehci,
634 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
638 ehci_writel(ehci, INTR_MASK,
639 &ehci->regs->intr_enable); /* Turn On Interrupts */
645 create_debug_files(ehci);
646 create_sysfs_files(ehci);
653 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
656 ehci->regs = (void __iomem *)ehci->caps +
657 HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
658 dbg_hcs_params(ehci, "reset");
659 dbg_hcc_params(ehci, "reset");
662 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
664 ehci->sbrn = HCD_USB2;
671 retval = ehci_halt(ehci);
675 ehci_reset(ehci);
685 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
692 * deadlock with ehci hrtimer callback, because hrtimer callbacks run
696 spin_lock_irqsave(&ehci->lock, flags);
698 status = ehci_readl(ehci, &ehci->regs->status);
702 ehci_dbg (ehci, "device removed\n");
713 if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) {
714 spin_unlock_irqrestore(&ehci->lock, flags);
719 ehci_writel(ehci, masked_status, &ehci->regs->status);
720 cmd = ehci_readl(ehci, &ehci->regs->command);
726 COUNT (ehci->stats.normal);
728 COUNT (ehci->stats.error);
736 ehci->enabled_hrtimer_events &= ~BIT(EHCI_HRTIMER_IAA_WATCHDOG);
745 if (ehci->next_hrtimer_event == EHCI_HRTIMER_IAA_WATCHDOG)
746 ++ehci->next_hrtimer_event;
750 ehci_dbg(ehci, "IAA with IAAD still set?\n");
751 if (ehci->iaa_in_progress)
752 COUNT(ehci->stats.iaa);
753 end_unlink_async(ehci);
758 unsigned i = HCS_N_PORTS (ehci->hcs_params);
765 if (ehci->rh_state == EHCI_RH_SUSPENDED)
769 if (ehci->has_ppcd)
778 pstatus = ehci_readl(ehci,
779 &ehci->regs->port_status[i]);
783 if (!(test_bit(i, &ehci->suspended_ports) &&
787 ehci->reset_done[i] == 0))
795 ehci->reset_done[i] = jiffies + msecs_to_jiffies(25);
796 set_bit(i, &ehci->resuming_ports);
797 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
799 mod_timer(&hcd->rh_timer, ehci->reset_done[i]);
805 ehci_err(ehci, "fatal error\n");
806 dbg_cmd(ehci, "fatal", cmd);
807 dbg_status(ehci, "fatal", status);
812 ehci->shutdown = true;
813 ehci->rh_state = EHCI_RH_STOPPING;
814 ehci->command &= ~(CMD_RUN | CMD_ASE | CMD_PSE);
815 ehci_writel(ehci, ehci->command, &ehci->regs->command);
816 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
817 ehci_handle_controller_death(ehci);
824 ehci_work (ehci);
825 spin_unlock_irqrestore(&ehci->lock, flags);
850 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
865 if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
867 return submit_async(ehci, urb, &qtd_list, mem_flags);
870 if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
872 return intr_submit(ehci, urb, &qtd_list, mem_flags);
876 return itd_submit (ehci, urb, mem_flags);
878 return sitd_submit (ehci, urb, mem_flags);
888 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
893 spin_lock_irqsave (&ehci->lock, flags);
910 start_unlink_intr(ehci, qh);
912 start_unlink_async(ehci, qh);
923 qh_completions(ehci, qh);
928 spin_unlock_irqrestore (&ehci->lock, flags);
939 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
947 spin_lock_irqsave (&ehci->lock, flags);
962 reserve_release_iso_bandwidth(ehci, stream, -1);
972 start_unlink_async(ehci, qh);
974 start_unlink_intr(ehci, qh);
980 spin_unlock_irqrestore (&ehci->lock, flags);
988 reserve_release_intr_bandwidth(ehci, qh, -1);
989 qh_destroy(ehci, qh);
997 ehci_err (ehci, "qh %p (#%02x) state %d%s\n",
1004 spin_unlock_irqrestore (&ehci->lock, flags);
1010 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1020 spin_lock_irqsave(&ehci->lock, flags);
1039 start_unlink_async(ehci, qh);
1041 start_unlink_intr(ehci, qh);
1044 spin_unlock_irqrestore(&ehci->lock, flags);
1049 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
1050 return (ehci_read_frame_index(ehci) >> 3) % ehci->periodic_size;
1059 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1061 spin_lock_irq(&ehci->lock);
1063 spin_unlock_irq(&ehci->lock);
1076 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1078 if (time_before(jiffies, ehci->next_statechange))
1086 ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup);
1088 spin_lock_irq(&ehci->lock);
1089 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
1090 (void) ehci_readl(ehci, &ehci->regs->intr_enable);
1093 spin_unlock_irq(&ehci->lock);
1110 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1112 if (time_before(jiffies, ehci->next_statechange))
1118 if (ehci->shutdown)
1126 if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF &&
1130 ehci_prepare_ports_for_controller_resume(ehci);
1132 spin_lock_irq(&ehci->lock);
1133 if (ehci->shutdown)
1138 ehci_writel(ehci, mask, &ehci->regs->intr_enable);
1139 ehci_readl(ehci, &ehci->regs->intr_enable);
1141 spin_unlock_irq(&ehci->lock);
1150 (void) ehci_halt(ehci);
1151 (void) ehci_reset(ehci);
1153 spin_lock_irq(&ehci->lock);
1154 if (ehci->shutdown)
1157 ehci_writel(ehci, ehci->command, &ehci->regs->command);
1158 ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
1159 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
1161 ehci->rh_state = EHCI_RH_SUSPENDED;
1162 spin_unlock_irq(&ehci->lock);
1247 #include "ehci-fsl.c"
1252 #include "ehci-sh.c"
1257 #include "ehci-ps3.c"
1262 #include "ehci-ppc-of.c"
1267 #include "ehci-xilinx-of.c"
1272 #include "ehci-octeon.c"
1277 #include "ehci-tilegx.c"
1282 #include "ehci-pmcmsp.c"
1287 #include "ehci-grlib.c"
1292 #include "ehci-mv.c"
1297 #include "ehci-sead3.c"
1321 ehci_debug_root = debugfs_create_dir("ehci", usb_debug_root);