Lines Matching refs:ohci
11 * [ uhci code and gregs ohci fragments ]
80 #include "ohci.h"
83 static void ohci_dump(struct ohci_hcd *ohci);
87 #include "ohci-hub.c"
88 #include "ohci-dbg.c"
89 #include "ohci-mem.c"
90 #include "ohci-q.c"
152 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
161 ed = ed_get(ohci, urb->ep, urb->dev, pipe, urb->interval);
204 urb_priv->td [i] = td_alloc (ohci, mem_flags);
207 urb_free_priv (ohci, urb_priv);
212 spin_lock_irqsave (&ohci->lock, flags);
219 if (ohci->rh_state != OHCI_RH_RUNNING) {
229 retval = ed_schedule (ohci, ed);
236 if (ohci->prev_frame_no == IO_WATCHDOG_OFF &&
237 list_empty(&ohci->eds_in_use) &&
238 !(ohci->flags & OHCI_QUIRK_QEMU)) {
239 ohci->prev_frame_no = ohci_frame_no(ohci);
240 mod_timer(&ohci->io_watchdog,
243 list_add(&ed->in_use_list, &ohci->eds_in_use);
246 u16 frame = ohci_frame_no(ohci);
256 u16 next = ohci_frame_no(ohci) + 1;
285 ohci_dbg(ohci, "iso underrun %p (%u+%u < %u)\n",
300 td_submit_urb (ohci, urb);
304 urb_free_priv (ohci, urb_priv);
305 spin_unlock_irqrestore (&ohci->lock, flags);
317 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
322 spin_lock_irqsave (&ohci->lock, flags);
332 start_ed_unlink(ohci, urb_priv->ed);
334 if (ohci->rh_state != OHCI_RH_RUNNING) {
336 ohci_work(ohci);
339 spin_unlock_irqrestore (&ohci->lock, flags);
352 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
364 spin_lock_irqsave (&ohci->lock, flags);
366 if (ohci->rh_state != OHCI_RH_RUNNING) {
369 ohci_work(ohci);
376 ohci_warn(ohci, "ED unlink timeout\n");
379 spin_unlock_irqrestore (&ohci->lock, flags);
384 td_free (ohci, ed->dummy);
385 ed_free (ohci, ed);
393 ohci_err (ohci, "leak ed %p (#%02x) state %d%s\n",
396 td_free (ohci, ed->dummy);
400 spin_unlock_irqrestore (&ohci->lock, flags);
405 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
407 return ohci_frame_no(ohci);
410 static void ohci_usb_reset (struct ohci_hcd *ohci)
412 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
413 ohci->hc_control &= OHCI_CTRL_RWC;
414 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
415 ohci->rh_state = OHCI_RH_HALTED;
424 struct ohci_hcd *ohci;
426 ohci = hcd_to_ohci (hcd);
427 ohci_writel(ohci, (u32) ~0, &ohci->regs->intrdisable);
430 ohci_writel(ohci, OHCI_HCR, &ohci->regs->cmdstatus);
431 ohci_readl(ohci, &ohci->regs->cmdstatus); /* flush the writes */
434 ohci_writel(ohci, ohci->fminterval, &ohci->regs->fminterval);
435 ohci->rh_state = OHCI_RH_HALTED;
440 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
443 spin_lock_irqsave(&ohci->lock, flags);
445 spin_unlock_irqrestore(&ohci->lock, flags);
454 static int ohci_init (struct ohci_hcd *ohci)
457 struct usb_hcd *hcd = ohci_to_hcd(ohci);
464 ohci->flags |= OHCI_QUIRK_HUB_POWER;
466 ohci->rh_state = OHCI_RH_HALTED;
467 ohci->regs = hcd->regs;
475 if (!no_handshake && ohci_readl (ohci,
476 &ohci->regs->control) & OHCI_CTRL_IR) {
479 ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n");
487 ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable);
488 ohci_writel (ohci, OHCI_OCR, &ohci->regs->cmdstatus);
489 while (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) {
492 ohci_err (ohci, "USB HC takeover failed!"
497 ohci_usb_reset (ohci);
502 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
505 if (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_RWC)
506 ohci->hc_control |= OHCI_CTRL_RWC;
509 if (ohci->num_ports == 0)
510 ohci->num_ports = roothub_a(ohci) & RH_A_NDP;
512 if (ohci->hcca)
515 timer_setup(&ohci->io_watchdog, io_watchdog_func, 0);
516 ohci->prev_frame_no = IO_WATCHDOG_OFF;
519 ohci->hcca = gen_pool_dma_alloc_align(hcd->localmem_pool,
520 sizeof(*ohci->hcca),
521 &ohci->hcca_dma, 256);
523 ohci->hcca = dma_alloc_coherent(hcd->self.controller,
524 sizeof(*ohci->hcca),
525 &ohci->hcca_dma,
527 if (!ohci->hcca)
530 if ((ret = ohci_mem_init (ohci)) < 0)
533 create_debug_files (ohci);
545 static int ohci_run (struct ohci_hcd *ohci)
548 int first = ohci->fminterval == 0;
549 struct usb_hcd *hcd = ohci_to_hcd(ohci);
551 ohci->rh_state = OHCI_RH_HALTED;
556 val = ohci_readl (ohci, &ohci->regs->fminterval);
557 ohci->fminterval = val & 0x3fff;
558 if (ohci->fminterval != FI)
559 ohci_dbg (ohci, "fminterval delta %d\n",
560 ohci->fminterval - FI);
561 ohci->fminterval |= FSMP (ohci->fminterval) << 16;
571 if ((ohci->hc_control & OHCI_CTRL_RWC) != 0)
574 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
580 ohci->hc_control &= OHCI_CTRL_RWC;
581 ohci->hc_control |= OHCI_USB_RESUME;
586 ohci->hc_control &= OHCI_CTRL_RWC;
587 ohci->hc_control |= OHCI_USB_RESET;
591 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
593 (void) ohci_readl (ohci, &ohci->regs->control);
596 memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
599 spin_lock_irq (&ohci->lock);
603 ohci_writel (ohci, OHCI_HCR, &ohci->regs->cmdstatus);
605 while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
607 spin_unlock_irq (&ohci->lock);
608 ohci_err (ohci, "USB HC reset timed out!\n");
623 if (ohci->flags & OHCI_QUIRK_INITRESET) {
624 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
626 (void) ohci_readl (ohci, &ohci->regs->control);
631 ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
632 ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
635 ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
637 periodic_reinit (ohci);
642 if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0
643 || !ohci_readl (ohci, &ohci->regs->periodicstart)) {
644 if (!(ohci->flags & OHCI_QUIRK_INITRESET)) {
645 ohci->flags |= OHCI_QUIRK_INITRESET;
646 ohci_dbg (ohci, "enabling initreset quirk\n");
649 spin_unlock_irq (&ohci->lock);
650 ohci_err (ohci, "init err (%08x %04x)\n",
651 ohci_readl (ohci, &ohci->regs->fminterval),
652 ohci_readl (ohci, &ohci->regs->periodicstart));
661 ohci->hc_control &= OHCI_CTRL_RWC;
662 ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER;
663 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
664 ohci->rh_state = OHCI_RH_RUNNING;
667 ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status);
671 ohci_writel (ohci, ~0, &ohci->regs->intrstatus);
672 ohci_writel (ohci, mask, &ohci->regs->intrenable);
675 val = roothub_a (ohci);
679 if (ohci->flags & OHCI_QUIRK_SUPERIO) {
685 } else if ((ohci->flags & OHCI_QUIRK_AMD756) ||
686 (ohci->flags & OHCI_QUIRK_HUB_POWER)) {
692 ohci_writel(ohci, val, &ohci->regs->roothub.a);
694 ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);
695 ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM,
696 &ohci->regs->roothub.b);
698 (void) ohci_readl (ohci, &ohci->regs->control);
700 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
701 spin_unlock_irq (&ohci->lock);
706 ohci_dump(ohci);
715 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
717 ohci_hcd_init(ohci);
719 return ohci_init(ohci);
726 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
729 ret = ohci_run(ohci);
731 ohci_err(ohci, "can't start\n");
751 struct ohci_hcd *ohci = from_timer(ohci, t, io_watchdog);
760 spin_lock_irqsave(&ohci->lock, flags);
769 status = ohci_readl(ohci, &ohci->regs->intrstatus);
770 if (!(status & OHCI_INTR_WDH) && ohci->wdh_cnt == ohci->prev_wdh_cnt) {
771 if (ohci->prev_donehead) {
772 ohci_err(ohci, "HcDoneHead not written back; disabled\n");
774 usb_hc_died(ohci_to_hcd(ohci));
775 ohci_dump(ohci);
776 _ohci_shutdown(ohci_to_hcd(ohci));
785 list_for_each_entry(ed, &ohci->eds_in_use, in_use_list) {
788 OKAY_TO_TAKEBACK(ohci, ed)) {
789 unsigned tmp = hc32_to_cpu(ohci, ed->hwINFO);
791 ohci_dbg(ohci, "takeback pending TD for dev %d ep 0x%x\n",
795 add_to_done_list(ohci, ed->pending_td);
812 head = hc32_to_cpu(ohci, READ_ONCE(ed->hwHeadP)) & TD_MASK;
826 ed->takeback_wdh_cnt = ohci->wdh_cnt + 2;
831 ohci_work(ohci);
833 if (ohci->rh_state == OHCI_RH_RUNNING) {
843 frame_no = ohci_frame_no(ohci);
844 if (frame_no == ohci->prev_frame_no) {
849 for (i = 0; i < ohci->num_ports; ++i) {
850 tmp = roothub_portstatus(ohci, i);
857 ohci_err(ohci, "frame counter not updating; disabled\n");
861 if (!list_empty(&ohci->eds_in_use)) {
863 ohci->prev_wdh_cnt = ohci->wdh_cnt;
864 ohci->prev_donehead = ohci_readl(ohci,
865 &ohci->regs->donehead);
866 mod_timer(&ohci->io_watchdog,
872 ohci->prev_frame_no = prev_frame_no;
873 spin_unlock_irqrestore(&ohci->lock, flags);
880 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
881 struct ohci_regs __iomem *regs = ohci->regs;
888 ints = ohci_readl(ohci, ®s->intrstatus);
894 ohci->rh_state = OHCI_RH_HALTED;
895 ohci_dbg (ohci, "device removed!\n");
901 ints &= ohci_readl(ohci, ®s->intrenable);
904 if (ints == 0 || unlikely(ohci->rh_state == OHCI_RH_HALTED))
909 if (quirk_nec(ohci)) {
913 ohci_err (ohci, "OHCI Unrecoverable Error, scheduling NEC chip restart\n");
915 ohci_writel (ohci, OHCI_INTR_UE, ®s->intrdisable);
917 schedule_work (&ohci->nec_work);
919 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
920 ohci->rh_state = OHCI_RH_HALTED;
924 ohci_dump(ohci);
925 ohci_usb_reset (ohci);
929 ohci_dbg(ohci, "rhsc\n");
930 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
931 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
942 ohci_writel(ohci, OHCI_INTR_RHSC, ®s->intrdisable);
951 ohci_dbg(ohci, "resume detect\n");
952 ohci_writel(ohci, OHCI_INTR_RD, ®s->intrstatus);
954 if (ohci->autostop) {
955 spin_lock (&ohci->lock);
956 ohci_rh_resume (ohci);
957 spin_unlock (&ohci->lock);
962 spin_lock(&ohci->lock);
964 update_done_list(ohci);
971 ohci_work(ohci);
972 if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list
973 && ohci->rh_state == OHCI_RH_RUNNING)
974 ohci_writel (ohci, OHCI_INTR_SF, ®s->intrdisable);
976 if (ohci->rh_state == OHCI_RH_RUNNING) {
977 ohci_writel (ohci, ints, ®s->intrstatus);
979 ++ohci->wdh_cnt;
981 ohci_writel (ohci, OHCI_INTR_MIE, ®s->intrenable);
983 (void) ohci_readl (ohci, &ohci->regs->control);
985 spin_unlock(&ohci->lock);
994 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
996 ohci_dump(ohci);
998 if (quirk_nec(ohci))
999 flush_work(&ohci->nec_work);
1000 del_timer_sync(&ohci->io_watchdog);
1001 ohci->prev_frame_no = IO_WATCHDOG_OFF;
1003 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
1004 ohci_usb_reset(ohci);
1008 if (quirk_amdiso(ohci))
1011 remove_debug_files (ohci);
1012 ohci_mem_cleanup (ohci);
1013 if (ohci->hcca) {
1016 (unsigned long)ohci->hcca,
1017 sizeof(*ohci->hcca));
1020 sizeof(*ohci->hcca),
1021 ohci->hcca, ohci->hcca_dma);
1022 ohci->hcca = NULL;
1023 ohci->hcca_dma = 0;
1032 int ohci_restart(struct ohci_hcd *ohci)
1038 ohci_init(ohci);
1039 spin_lock_irq(&ohci->lock);
1040 ohci->rh_state = OHCI_RH_HALTED;
1043 if (!list_empty (&ohci->pending))
1044 ohci_dbg(ohci, "abort schedule...\n");
1045 list_for_each_entry (priv, &ohci->pending, pending) {
1052 ed->hwINFO |= cpu_to_hc32(ohci, ED_DEQUEUE);
1053 ed_deschedule (ohci, ed);
1055 ed->ed_next = ohci->ed_rm_list;
1057 ohci->ed_rm_list = ed;
1062 ohci_dbg(ohci, "bogus ed %p state %d\n",
1069 ohci_work(ohci);
1070 spin_unlock_irq(&ohci->lock);
1075 for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0;
1076 for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0;
1079 ohci->ed_rm_list = NULL;
1082 ohci->ed_controltail = NULL;
1083 ohci->ed_bulktail = NULL;
1085 if ((temp = ohci_run (ohci)) < 0) {
1086 ohci_err (ohci, "can't restart, %d\n", temp);
1089 ohci_dbg(ohci, "restart complete\n");
1100 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
1108 spin_lock_irqsave (&ohci->lock, flags);
1109 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
1110 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
1113 spin_unlock_irqrestore (&ohci->lock, flags);
1128 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
1136 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
1137 ohci_usb_reset(ohci);
1141 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
1142 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
1145 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
1154 spin_lock_irq(&ohci->lock);
1155 ohci_rh_resume(ohci);
1156 ohci_rh_suspend(ohci, 0);
1157 spin_unlock_irq(&ohci->lock);
1162 ohci_dbg(ohci, "powerup ports\n");
1163 for (port = 0; port < ohci->num_ports; port++)
1164 ohci_writel(ohci, RH_PS_PPS,
1165 &ohci->regs->roothub.portstatus[port]);
1167 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable);
1168 ohci_readl(ohci, &ohci->regs->intrenable);
1252 #include "ohci-sa1111.c"
1257 #include "ohci-ppc-of.c"
1262 #include "ohci-ps3.c"
1267 #include "ohci-sm501.c"
1272 #include "ohci-tmio.c"
1288 ohci_debug_root = debugfs_create_dir("ohci", usb_debug_root);