Lines Matching refs:ohci

80 static void ohci_dump(struct ohci_hcd *ohci);
149 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_urb_enqueue() local
158 if (! (ed = ed_get (ohci, urb->ep, urb->dev, pipe, urb->interval))) in ohci_urb_enqueue()
200 urb_priv->td [i] = td_alloc (ohci, mem_flags); in ohci_urb_enqueue()
203 urb_free_priv (ohci, urb_priv); in ohci_urb_enqueue()
208 spin_lock_irqsave (&ohci->lock, flags); in ohci_urb_enqueue()
215 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_urb_enqueue()
225 retval = ed_schedule (ohci, ed); in ohci_urb_enqueue()
232 if (!timer_pending(&ohci->io_watchdog) && in ohci_urb_enqueue()
233 list_empty(&ohci->eds_in_use)) { in ohci_urb_enqueue()
234 ohci->prev_frame_no = ohci_frame_no(ohci); in ohci_urb_enqueue()
235 mod_timer(&ohci->io_watchdog, in ohci_urb_enqueue()
238 list_add(&ed->in_use_list, &ohci->eds_in_use); in ohci_urb_enqueue()
241 u16 frame = ohci_frame_no(ohci); in ohci_urb_enqueue()
251 u16 next = ohci_frame_no(ohci) + 1; in ohci_urb_enqueue()
280 ohci_dbg(ohci, "iso underrun %p (%u+%u < %u)\n", in ohci_urb_enqueue()
295 td_submit_urb (ohci, urb); in ohci_urb_enqueue()
299 urb_free_priv (ohci, urb_priv); in ohci_urb_enqueue()
300 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_urb_enqueue()
312 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_urb_dequeue() local
317 spin_lock_irqsave (&ohci->lock, flags); in ohci_urb_dequeue()
327 start_ed_unlink(ohci, urb_priv->ed); in ohci_urb_dequeue()
329 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_urb_dequeue()
331 ohci_work(ohci); in ohci_urb_dequeue()
334 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_urb_dequeue()
347 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_endpoint_disable() local
359 spin_lock_irqsave (&ohci->lock, flags); in ohci_endpoint_disable()
361 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_endpoint_disable()
364 ohci_work(ohci); in ohci_endpoint_disable()
371 ohci_warn(ohci, "ED unlink timeout\n"); in ohci_endpoint_disable()
374 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_endpoint_disable()
379 td_free (ohci, ed->dummy); in ohci_endpoint_disable()
380 ed_free (ohci, ed); in ohci_endpoint_disable()
388 ohci_err (ohci, "leak ed %p (#%02x) state %d%s\n", in ohci_endpoint_disable()
391 td_free (ohci, ed->dummy); in ohci_endpoint_disable()
395 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_endpoint_disable()
400 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_get_frame() local
402 return ohci_frame_no(ohci); in ohci_get_frame()
405 static void ohci_usb_reset (struct ohci_hcd *ohci) in ohci_usb_reset() argument
407 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); in ohci_usb_reset()
408 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_usb_reset()
409 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_usb_reset()
410 ohci->rh_state = OHCI_RH_HALTED; in ohci_usb_reset()
420 struct ohci_hcd *ohci; in ohci_shutdown() local
422 ohci = hcd_to_ohci (hcd); in ohci_shutdown()
423 ohci_writel(ohci, (u32) ~0, &ohci->regs->intrdisable); in ohci_shutdown()
426 ohci_writel(ohci, OHCI_HCR, &ohci->regs->cmdstatus); in ohci_shutdown()
427 ohci_readl(ohci, &ohci->regs->cmdstatus); /* flush the writes */ in ohci_shutdown()
430 ohci_writel(ohci, ohci->fminterval, &ohci->regs->fminterval); in ohci_shutdown()
431 ohci->rh_state = OHCI_RH_HALTED; in ohci_shutdown()
440 static int ohci_init (struct ohci_hcd *ohci) in ohci_init() argument
443 struct usb_hcd *hcd = ohci_to_hcd(ohci); in ohci_init()
449 ohci->flags |= OHCI_QUIRK_HUB_POWER; in ohci_init()
451 ohci->rh_state = OHCI_RH_HALTED; in ohci_init()
452 ohci->regs = hcd->regs; in ohci_init()
460 if (!no_handshake && ohci_readl (ohci, in ohci_init()
461 &ohci->regs->control) & OHCI_CTRL_IR) { in ohci_init()
464 ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n"); in ohci_init()
472 ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable); in ohci_init()
473 ohci_writel (ohci, OHCI_OCR, &ohci->regs->cmdstatus); in ohci_init()
474 while (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) { in ohci_init()
477 ohci_err (ohci, "USB HC takeover failed!" in ohci_init()
482 ohci_usb_reset (ohci); in ohci_init()
487 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); in ohci_init()
490 if (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_RWC) in ohci_init()
491 ohci->hc_control |= OHCI_CTRL_RWC; in ohci_init()
494 if (ohci->num_ports == 0) in ohci_init()
495 ohci->num_ports = roothub_a(ohci) & RH_A_NDP; in ohci_init()
497 if (ohci->hcca) in ohci_init()
500 setup_timer(&ohci->io_watchdog, io_watchdog_func, in ohci_init()
501 (unsigned long) ohci); in ohci_init()
502 set_timer_slack(&ohci->io_watchdog, msecs_to_jiffies(20)); in ohci_init()
504 ohci->hcca = dma_alloc_coherent (hcd->self.controller, in ohci_init()
505 sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL); in ohci_init()
506 if (!ohci->hcca) in ohci_init()
509 if ((ret = ohci_mem_init (ohci)) < 0) in ohci_init()
512 create_debug_files (ohci); in ohci_init()
524 static int ohci_run (struct ohci_hcd *ohci) in ohci_run() argument
527 int first = ohci->fminterval == 0; in ohci_run()
528 struct usb_hcd *hcd = ohci_to_hcd(ohci); in ohci_run()
530 ohci->rh_state = OHCI_RH_HALTED; in ohci_run()
535 val = ohci_readl (ohci, &ohci->regs->fminterval); in ohci_run()
536 ohci->fminterval = val & 0x3fff; in ohci_run()
537 if (ohci->fminterval != FI) in ohci_run()
538 ohci_dbg (ohci, "fminterval delta %d\n", in ohci_run()
539 ohci->fminterval - FI); in ohci_run()
540 ohci->fminterval |= FSMP (ohci->fminterval) << 16; in ohci_run()
550 if ((ohci->hc_control & OHCI_CTRL_RWC) != 0) in ohci_run()
553 switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_run()
559 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_run()
560 ohci->hc_control |= OHCI_USB_RESUME; in ohci_run()
565 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_run()
566 ohci->hc_control |= OHCI_USB_RESET; in ohci_run()
570 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_run()
572 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_run()
575 memset (ohci->hcca, 0, sizeof (struct ohci_hcca)); in ohci_run()
578 spin_lock_irq (&ohci->lock); in ohci_run()
582 ohci_writel (ohci, OHCI_HCR, &ohci->regs->cmdstatus); in ohci_run()
584 while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) { in ohci_run()
586 spin_unlock_irq (&ohci->lock); in ohci_run()
587 ohci_err (ohci, "USB HC reset timed out!\n"); in ohci_run()
602 if (ohci->flags & OHCI_QUIRK_INITRESET) { in ohci_run()
603 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_run()
605 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_run()
610 ohci_writel (ohci, 0, &ohci->regs->ed_controlhead); in ohci_run()
611 ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead); in ohci_run()
614 ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca); in ohci_run()
616 periodic_reinit (ohci); in ohci_run()
621 if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0 in ohci_run()
622 || !ohci_readl (ohci, &ohci->regs->periodicstart)) { in ohci_run()
623 if (!(ohci->flags & OHCI_QUIRK_INITRESET)) { in ohci_run()
624 ohci->flags |= OHCI_QUIRK_INITRESET; in ohci_run()
625 ohci_dbg (ohci, "enabling initreset quirk\n"); in ohci_run()
628 spin_unlock_irq (&ohci->lock); in ohci_run()
629 ohci_err (ohci, "init err (%08x %04x)\n", in ohci_run()
630 ohci_readl (ohci, &ohci->regs->fminterval), in ohci_run()
631 ohci_readl (ohci, &ohci->regs->periodicstart)); in ohci_run()
640 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_run()
641 ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER; in ohci_run()
642 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_run()
643 ohci->rh_state = OHCI_RH_RUNNING; in ohci_run()
646 ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status); in ohci_run()
650 ohci_writel (ohci, ~0, &ohci->regs->intrstatus); in ohci_run()
651 ohci_writel (ohci, mask, &ohci->regs->intrenable); in ohci_run()
654 val = roothub_a (ohci); in ohci_run()
656 if (ohci->flags & OHCI_QUIRK_SUPERIO) { in ohci_run()
660 ohci_writel (ohci, val, &ohci->regs->roothub.a); in ohci_run()
661 } else if ((ohci->flags & OHCI_QUIRK_AMD756) || in ohci_run()
662 (ohci->flags & OHCI_QUIRK_HUB_POWER)) { in ohci_run()
667 ohci_writel (ohci, val, &ohci->regs->roothub.a); in ohci_run()
669 ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status); in ohci_run()
670 ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM, in ohci_run()
671 &ohci->regs->roothub.b); in ohci_run()
673 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_run()
675 ohci->next_statechange = jiffies + STATECHANGE_DELAY; in ohci_run()
676 spin_unlock_irq (&ohci->lock); in ohci_run()
681 ohci_dump(ohci); in ohci_run()
690 struct ohci_hcd *ohci = hcd_to_ohci(hcd); in ohci_setup() local
692 ohci_hcd_init(ohci); in ohci_setup()
694 return ohci_init(ohci); in ohci_setup()
701 struct ohci_hcd *ohci = hcd_to_ohci(hcd); in ohci_start() local
704 ret = ohci_run(ohci); in ohci_start()
706 ohci_err(ohci, "can't start\n"); in ohci_start()
726 struct ohci_hcd *ohci = (struct ohci_hcd *) _ohci; in io_watchdog_func() local
735 spin_lock_irqsave(&ohci->lock, flags); in io_watchdog_func()
744 status = ohci_readl(ohci, &ohci->regs->intrstatus); in io_watchdog_func()
745 if (!(status & OHCI_INTR_WDH) && ohci->wdh_cnt == ohci->prev_wdh_cnt) { in io_watchdog_func()
746 if (ohci->prev_donehead) { in io_watchdog_func()
747 ohci_err(ohci, "HcDoneHead not written back; disabled\n"); in io_watchdog_func()
749 usb_hc_died(ohci_to_hcd(ohci)); in io_watchdog_func()
750 ohci_dump(ohci); in io_watchdog_func()
751 ohci_shutdown(ohci_to_hcd(ohci)); in io_watchdog_func()
760 list_for_each_entry(ed, &ohci->eds_in_use, in_use_list) { in io_watchdog_func()
763 OKAY_TO_TAKEBACK(ohci, ed)) { in io_watchdog_func()
764 unsigned tmp = hc32_to_cpu(ohci, ed->hwINFO); in io_watchdog_func()
766 ohci_dbg(ohci, "takeback pending TD for dev %d ep 0x%x\n", in io_watchdog_func()
770 add_to_done_list(ohci, ed->pending_td); in io_watchdog_func()
787 head = hc32_to_cpu(ohci, ACCESS_ONCE(ed->hwHeadP)) & TD_MASK; in io_watchdog_func()
801 ed->takeback_wdh_cnt = ohci->wdh_cnt + 2; in io_watchdog_func()
806 ohci_work(ohci); in io_watchdog_func()
808 if (ohci->rh_state == OHCI_RH_RUNNING) { in io_watchdog_func()
818 frame_no = ohci_frame_no(ohci); in io_watchdog_func()
819 if (frame_no == ohci->prev_frame_no) { in io_watchdog_func()
824 for (i = 0; i < ohci->num_ports; ++i) { in io_watchdog_func()
825 tmp = roothub_portstatus(ohci, i); in io_watchdog_func()
832 ohci_err(ohci, "frame counter not updating; disabled\n"); in io_watchdog_func()
836 if (!list_empty(&ohci->eds_in_use)) { in io_watchdog_func()
837 ohci->prev_frame_no = frame_no; in io_watchdog_func()
838 ohci->prev_wdh_cnt = ohci->wdh_cnt; in io_watchdog_func()
839 ohci->prev_donehead = ohci_readl(ohci, in io_watchdog_func()
840 &ohci->regs->donehead); in io_watchdog_func()
841 mod_timer(&ohci->io_watchdog, in io_watchdog_func()
847 spin_unlock_irqrestore(&ohci->lock, flags); in io_watchdog_func()
854 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_irq() local
855 struct ohci_regs __iomem *regs = ohci->regs; in ohci_irq()
862 ints = ohci_readl(ohci, &regs->intrstatus); in ohci_irq()
868 ohci->rh_state = OHCI_RH_HALTED; in ohci_irq()
869 ohci_dbg (ohci, "device removed!\n"); in ohci_irq()
875 ints &= ohci_readl(ohci, &regs->intrenable); in ohci_irq()
878 if (ints == 0 || unlikely(ohci->rh_state == OHCI_RH_HALTED)) in ohci_irq()
883 if (quirk_nec(ohci)) { in ohci_irq()
887 ohci_err (ohci, "OHCI Unrecoverable Error, scheduling NEC chip restart\n"); in ohci_irq()
889 ohci_writel (ohci, OHCI_INTR_UE, &regs->intrdisable); in ohci_irq()
891 schedule_work (&ohci->nec_work); in ohci_irq()
893 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n"); in ohci_irq()
894 ohci->rh_state = OHCI_RH_HALTED; in ohci_irq()
898 ohci_dump(ohci); in ohci_irq()
899 ohci_usb_reset (ohci); in ohci_irq()
903 ohci_dbg(ohci, "rhsc\n"); in ohci_irq()
904 ohci->next_statechange = jiffies + STATECHANGE_DELAY; in ohci_irq()
905 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC, in ohci_irq()
916 ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable); in ohci_irq()
925 ohci_dbg(ohci, "resume detect\n"); in ohci_irq()
926 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus); in ohci_irq()
928 if (ohci->autostop) { in ohci_irq()
929 spin_lock (&ohci->lock); in ohci_irq()
930 ohci_rh_resume (ohci); in ohci_irq()
931 spin_unlock (&ohci->lock); in ohci_irq()
936 spin_lock(&ohci->lock); in ohci_irq()
938 update_done_list(ohci); in ohci_irq()
945 ohci_work(ohci); in ohci_irq()
946 if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list in ohci_irq()
947 && ohci->rh_state == OHCI_RH_RUNNING) in ohci_irq()
948 ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable); in ohci_irq()
950 if (ohci->rh_state == OHCI_RH_RUNNING) { in ohci_irq()
951 ohci_writel (ohci, ints, &regs->intrstatus); in ohci_irq()
953 ++ohci->wdh_cnt; in ohci_irq()
955 ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable); in ohci_irq()
957 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_irq()
959 spin_unlock(&ohci->lock); in ohci_irq()
968 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_stop() local
970 ohci_dump(ohci); in ohci_stop()
972 if (quirk_nec(ohci)) in ohci_stop()
973 flush_work(&ohci->nec_work); in ohci_stop()
974 del_timer_sync(&ohci->io_watchdog); in ohci_stop()
976 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); in ohci_stop()
977 ohci_usb_reset(ohci); in ohci_stop()
981 if (quirk_amdiso(ohci)) in ohci_stop()
984 remove_debug_files (ohci); in ohci_stop()
985 ohci_mem_cleanup (ohci); in ohci_stop()
986 if (ohci->hcca) { in ohci_stop()
988 sizeof *ohci->hcca, in ohci_stop()
989 ohci->hcca, ohci->hcca_dma); in ohci_stop()
990 ohci->hcca = NULL; in ohci_stop()
991 ohci->hcca_dma = 0; in ohci_stop()
1000 int ohci_restart(struct ohci_hcd *ohci) in ohci_restart() argument
1006 ohci_init(ohci); in ohci_restart()
1007 spin_lock_irq(&ohci->lock); in ohci_restart()
1008 ohci->rh_state = OHCI_RH_HALTED; in ohci_restart()
1011 if (!list_empty (&ohci->pending)) in ohci_restart()
1012 ohci_dbg(ohci, "abort schedule...\n"); in ohci_restart()
1013 list_for_each_entry (priv, &ohci->pending, pending) { in ohci_restart()
1020 ed->hwINFO |= cpu_to_hc32(ohci, ED_DEQUEUE); in ohci_restart()
1021 ed_deschedule (ohci, ed); in ohci_restart()
1023 ed->ed_next = ohci->ed_rm_list; in ohci_restart()
1025 ohci->ed_rm_list = ed; in ohci_restart()
1030 ohci_dbg(ohci, "bogus ed %p state %d\n", in ohci_restart()
1037 ohci_work(ohci); in ohci_restart()
1038 spin_unlock_irq(&ohci->lock); in ohci_restart()
1043 for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0; in ohci_restart()
1044 for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0; in ohci_restart()
1047 ohci->ed_rm_list = NULL; in ohci_restart()
1050 ohci->ed_controltail = NULL; in ohci_restart()
1051 ohci->ed_bulktail = NULL; in ohci_restart()
1053 if ((temp = ohci_run (ohci)) < 0) { in ohci_restart()
1054 ohci_err (ohci, "can't restart, %d\n", temp); in ohci_restart()
1057 ohci_dbg(ohci, "restart complete\n"); in ohci_restart()
1068 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_suspend() local
1076 spin_lock_irqsave (&ohci->lock, flags); in ohci_suspend()
1077 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); in ohci_suspend()
1078 (void)ohci_readl(ohci, &ohci->regs->intrdisable); in ohci_suspend()
1081 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_suspend()
1096 struct ohci_hcd *ohci = hcd_to_ohci(hcd); in ohci_resume() local
1104 ohci_usb_reset(ohci); in ohci_resume()
1107 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); in ohci_resume()
1108 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { in ohci_resume()
1111 switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_resume()
1120 spin_lock_irq(&ohci->lock); in ohci_resume()
1121 ohci_rh_resume(ohci); in ohci_resume()
1122 ohci_rh_suspend(ohci, 0); in ohci_resume()
1123 spin_unlock_irq(&ohci->lock); in ohci_resume()
1128 ohci_dbg(ohci, "powerup ports\n"); in ohci_resume()
1129 for (port = 0; port < ohci->num_ports; port++) in ohci_resume()
1130 ohci_writel(ohci, RH_PS_PPS, in ohci_resume()
1131 &ohci->regs->roothub.portstatus[port]); in ohci_resume()
1133 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable); in ohci_resume()
1134 ohci_readl(ohci, &ohci->regs->intrenable); in ohci_resume()