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 ed = ed_get(ohci, urb->ep, urb->dev, pipe, urb->interval); in ohci_urb_enqueue()
201 urb_priv->td [i] = td_alloc (ohci, mem_flags); in ohci_urb_enqueue()
204 urb_free_priv (ohci, urb_priv); in ohci_urb_enqueue()
209 spin_lock_irqsave (&ohci->lock, flags); in ohci_urb_enqueue()
216 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_urb_enqueue()
226 retval = ed_schedule (ohci, ed); in ohci_urb_enqueue()
233 if (!timer_pending(&ohci->io_watchdog) && in ohci_urb_enqueue()
234 list_empty(&ohci->eds_in_use)) { in ohci_urb_enqueue()
235 ohci->prev_frame_no = ohci_frame_no(ohci); in ohci_urb_enqueue()
236 mod_timer(&ohci->io_watchdog, in ohci_urb_enqueue()
239 list_add(&ed->in_use_list, &ohci->eds_in_use); in ohci_urb_enqueue()
242 u16 frame = ohci_frame_no(ohci); in ohci_urb_enqueue()
252 u16 next = ohci_frame_no(ohci) + 1; in ohci_urb_enqueue()
281 ohci_dbg(ohci, "iso underrun %p (%u+%u < %u)\n", in ohci_urb_enqueue()
296 td_submit_urb (ohci, urb); in ohci_urb_enqueue()
300 urb_free_priv (ohci, urb_priv); in ohci_urb_enqueue()
301 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_urb_enqueue()
313 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_urb_dequeue() local
318 spin_lock_irqsave (&ohci->lock, flags); in ohci_urb_dequeue()
328 start_ed_unlink(ohci, urb_priv->ed); in ohci_urb_dequeue()
330 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_urb_dequeue()
332 ohci_work(ohci); in ohci_urb_dequeue()
335 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_urb_dequeue()
348 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_endpoint_disable() local
360 spin_lock_irqsave (&ohci->lock, flags); in ohci_endpoint_disable()
362 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_endpoint_disable()
365 ohci_work(ohci); in ohci_endpoint_disable()
372 ohci_warn(ohci, "ED unlink timeout\n"); in ohci_endpoint_disable()
375 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_endpoint_disable()
380 td_free (ohci, ed->dummy); in ohci_endpoint_disable()
381 ed_free (ohci, ed); in ohci_endpoint_disable()
389 ohci_err (ohci, "leak ed %p (#%02x) state %d%s\n", in ohci_endpoint_disable()
392 td_free (ohci, ed->dummy); in ohci_endpoint_disable()
396 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_endpoint_disable()
401 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_get_frame() local
403 return ohci_frame_no(ohci); in ohci_get_frame()
406 static void ohci_usb_reset (struct ohci_hcd *ohci) in ohci_usb_reset() argument
408 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); in ohci_usb_reset()
409 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_usb_reset()
410 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_usb_reset()
411 ohci->rh_state = OHCI_RH_HALTED; in ohci_usb_reset()
421 struct ohci_hcd *ohci; in ohci_shutdown() local
423 ohci = hcd_to_ohci (hcd); in ohci_shutdown()
424 ohci_writel(ohci, (u32) ~0, &ohci->regs->intrdisable); in ohci_shutdown()
427 ohci_writel(ohci, OHCI_HCR, &ohci->regs->cmdstatus); in ohci_shutdown()
428 ohci_readl(ohci, &ohci->regs->cmdstatus); /* flush the writes */ in ohci_shutdown()
431 ohci_writel(ohci, ohci->fminterval, &ohci->regs->fminterval); in ohci_shutdown()
432 ohci->rh_state = OHCI_RH_HALTED; in ohci_shutdown()
441 static int ohci_init (struct ohci_hcd *ohci) in ohci_init() argument
444 struct usb_hcd *hcd = ohci_to_hcd(ohci); in ohci_init()
450 ohci->flags |= OHCI_QUIRK_HUB_POWER; in ohci_init()
452 ohci->rh_state = OHCI_RH_HALTED; in ohci_init()
453 ohci->regs = hcd->regs; in ohci_init()
461 if (!no_handshake && ohci_readl (ohci, in ohci_init()
462 &ohci->regs->control) & OHCI_CTRL_IR) { in ohci_init()
465 ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n"); in ohci_init()
473 ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable); in ohci_init()
474 ohci_writel (ohci, OHCI_OCR, &ohci->regs->cmdstatus); in ohci_init()
475 while (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) { in ohci_init()
478 ohci_err (ohci, "USB HC takeover failed!" in ohci_init()
483 ohci_usb_reset (ohci); in ohci_init()
488 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); in ohci_init()
491 if (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_RWC) in ohci_init()
492 ohci->hc_control |= OHCI_CTRL_RWC; in ohci_init()
495 if (ohci->num_ports == 0) in ohci_init()
496 ohci->num_ports = roothub_a(ohci) & RH_A_NDP; in ohci_init()
498 if (ohci->hcca) in ohci_init()
501 setup_timer(&ohci->io_watchdog, io_watchdog_func, in ohci_init()
502 (unsigned long) ohci); in ohci_init()
503 set_timer_slack(&ohci->io_watchdog, msecs_to_jiffies(20)); in ohci_init()
505 ohci->hcca = dma_alloc_coherent (hcd->self.controller, in ohci_init()
506 sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL); in ohci_init()
507 if (!ohci->hcca) in ohci_init()
510 if ((ret = ohci_mem_init (ohci)) < 0) in ohci_init()
513 create_debug_files (ohci); in ohci_init()
525 static int ohci_run (struct ohci_hcd *ohci) in ohci_run() argument
528 int first = ohci->fminterval == 0; in ohci_run()
529 struct usb_hcd *hcd = ohci_to_hcd(ohci); in ohci_run()
531 ohci->rh_state = OHCI_RH_HALTED; in ohci_run()
536 val = ohci_readl (ohci, &ohci->regs->fminterval); in ohci_run()
537 ohci->fminterval = val & 0x3fff; in ohci_run()
538 if (ohci->fminterval != FI) in ohci_run()
539 ohci_dbg (ohci, "fminterval delta %d\n", in ohci_run()
540 ohci->fminterval - FI); in ohci_run()
541 ohci->fminterval |= FSMP (ohci->fminterval) << 16; in ohci_run()
551 if ((ohci->hc_control & OHCI_CTRL_RWC) != 0) in ohci_run()
554 switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_run()
560 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_run()
561 ohci->hc_control |= OHCI_USB_RESUME; in ohci_run()
566 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_run()
567 ohci->hc_control |= OHCI_USB_RESET; in ohci_run()
571 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_run()
573 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_run()
576 memset (ohci->hcca, 0, sizeof (struct ohci_hcca)); in ohci_run()
579 spin_lock_irq (&ohci->lock); in ohci_run()
583 ohci_writel (ohci, OHCI_HCR, &ohci->regs->cmdstatus); in ohci_run()
585 while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) { in ohci_run()
587 spin_unlock_irq (&ohci->lock); in ohci_run()
588 ohci_err (ohci, "USB HC reset timed out!\n"); in ohci_run()
603 if (ohci->flags & OHCI_QUIRK_INITRESET) { in ohci_run()
604 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_run()
606 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_run()
611 ohci_writel (ohci, 0, &ohci->regs->ed_controlhead); in ohci_run()
612 ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead); in ohci_run()
615 ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca); in ohci_run()
617 periodic_reinit (ohci); in ohci_run()
622 if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0 in ohci_run()
623 || !ohci_readl (ohci, &ohci->regs->periodicstart)) { in ohci_run()
624 if (!(ohci->flags & OHCI_QUIRK_INITRESET)) { in ohci_run()
625 ohci->flags |= OHCI_QUIRK_INITRESET; in ohci_run()
626 ohci_dbg (ohci, "enabling initreset quirk\n"); in ohci_run()
629 spin_unlock_irq (&ohci->lock); in ohci_run()
630 ohci_err (ohci, "init err (%08x %04x)\n", in ohci_run()
631 ohci_readl (ohci, &ohci->regs->fminterval), in ohci_run()
632 ohci_readl (ohci, &ohci->regs->periodicstart)); in ohci_run()
641 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_run()
642 ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER; in ohci_run()
643 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_run()
644 ohci->rh_state = OHCI_RH_RUNNING; in ohci_run()
647 ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status); in ohci_run()
651 ohci_writel (ohci, ~0, &ohci->regs->intrstatus); in ohci_run()
652 ohci_writel (ohci, mask, &ohci->regs->intrenable); in ohci_run()
655 val = roothub_a (ohci); in ohci_run()
657 if (ohci->flags & OHCI_QUIRK_SUPERIO) { in ohci_run()
661 ohci_writel (ohci, val, &ohci->regs->roothub.a); in ohci_run()
662 } else if ((ohci->flags & OHCI_QUIRK_AMD756) || in ohci_run()
663 (ohci->flags & OHCI_QUIRK_HUB_POWER)) { in ohci_run()
668 ohci_writel (ohci, val, &ohci->regs->roothub.a); in ohci_run()
670 ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status); in ohci_run()
671 ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM, in ohci_run()
672 &ohci->regs->roothub.b); in ohci_run()
674 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_run()
676 ohci->next_statechange = jiffies + STATECHANGE_DELAY; in ohci_run()
677 spin_unlock_irq (&ohci->lock); in ohci_run()
682 ohci_dump(ohci); in ohci_run()
691 struct ohci_hcd *ohci = hcd_to_ohci(hcd); in ohci_setup() local
693 ohci_hcd_init(ohci); in ohci_setup()
695 return ohci_init(ohci); in ohci_setup()
702 struct ohci_hcd *ohci = hcd_to_ohci(hcd); in ohci_start() local
705 ret = ohci_run(ohci); in ohci_start()
707 ohci_err(ohci, "can't start\n"); in ohci_start()
727 struct ohci_hcd *ohci = (struct ohci_hcd *) _ohci; in io_watchdog_func() local
736 spin_lock_irqsave(&ohci->lock, flags); in io_watchdog_func()
745 status = ohci_readl(ohci, &ohci->regs->intrstatus); in io_watchdog_func()
746 if (!(status & OHCI_INTR_WDH) && ohci->wdh_cnt == ohci->prev_wdh_cnt) { in io_watchdog_func()
747 if (ohci->prev_donehead) { in io_watchdog_func()
748 ohci_err(ohci, "HcDoneHead not written back; disabled\n"); in io_watchdog_func()
750 usb_hc_died(ohci_to_hcd(ohci)); in io_watchdog_func()
751 ohci_dump(ohci); in io_watchdog_func()
752 ohci_shutdown(ohci_to_hcd(ohci)); in io_watchdog_func()
761 list_for_each_entry(ed, &ohci->eds_in_use, in_use_list) { in io_watchdog_func()
764 OKAY_TO_TAKEBACK(ohci, ed)) { in io_watchdog_func()
765 unsigned tmp = hc32_to_cpu(ohci, ed->hwINFO); in io_watchdog_func()
767 ohci_dbg(ohci, "takeback pending TD for dev %d ep 0x%x\n", in io_watchdog_func()
771 add_to_done_list(ohci, ed->pending_td); in io_watchdog_func()
788 head = hc32_to_cpu(ohci, ACCESS_ONCE(ed->hwHeadP)) & TD_MASK; in io_watchdog_func()
802 ed->takeback_wdh_cnt = ohci->wdh_cnt + 2; in io_watchdog_func()
807 ohci_work(ohci); in io_watchdog_func()
809 if (ohci->rh_state == OHCI_RH_RUNNING) { in io_watchdog_func()
819 frame_no = ohci_frame_no(ohci); in io_watchdog_func()
820 if (frame_no == ohci->prev_frame_no) { in io_watchdog_func()
825 for (i = 0; i < ohci->num_ports; ++i) { in io_watchdog_func()
826 tmp = roothub_portstatus(ohci, i); in io_watchdog_func()
833 ohci_err(ohci, "frame counter not updating; disabled\n"); in io_watchdog_func()
837 if (!list_empty(&ohci->eds_in_use)) { in io_watchdog_func()
838 ohci->prev_frame_no = frame_no; in io_watchdog_func()
839 ohci->prev_wdh_cnt = ohci->wdh_cnt; in io_watchdog_func()
840 ohci->prev_donehead = ohci_readl(ohci, in io_watchdog_func()
841 &ohci->regs->donehead); in io_watchdog_func()
842 mod_timer(&ohci->io_watchdog, in io_watchdog_func()
848 spin_unlock_irqrestore(&ohci->lock, flags); in io_watchdog_func()
855 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_irq() local
856 struct ohci_regs __iomem *regs = ohci->regs; in ohci_irq()
863 ints = ohci_readl(ohci, &regs->intrstatus); in ohci_irq()
869 ohci->rh_state = OHCI_RH_HALTED; in ohci_irq()
870 ohci_dbg (ohci, "device removed!\n"); in ohci_irq()
876 ints &= ohci_readl(ohci, &regs->intrenable); in ohci_irq()
879 if (ints == 0 || unlikely(ohci->rh_state == OHCI_RH_HALTED)) in ohci_irq()
884 if (quirk_nec(ohci)) { in ohci_irq()
888 ohci_err (ohci, "OHCI Unrecoverable Error, scheduling NEC chip restart\n"); in ohci_irq()
890 ohci_writel (ohci, OHCI_INTR_UE, &regs->intrdisable); in ohci_irq()
892 schedule_work (&ohci->nec_work); in ohci_irq()
894 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n"); in ohci_irq()
895 ohci->rh_state = OHCI_RH_HALTED; in ohci_irq()
899 ohci_dump(ohci); in ohci_irq()
900 ohci_usb_reset (ohci); in ohci_irq()
904 ohci_dbg(ohci, "rhsc\n"); in ohci_irq()
905 ohci->next_statechange = jiffies + STATECHANGE_DELAY; in ohci_irq()
906 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC, in ohci_irq()
917 ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable); in ohci_irq()
926 ohci_dbg(ohci, "resume detect\n"); in ohci_irq()
927 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus); in ohci_irq()
929 if (ohci->autostop) { in ohci_irq()
930 spin_lock (&ohci->lock); in ohci_irq()
931 ohci_rh_resume (ohci); in ohci_irq()
932 spin_unlock (&ohci->lock); in ohci_irq()
937 spin_lock(&ohci->lock); in ohci_irq()
939 update_done_list(ohci); in ohci_irq()
946 ohci_work(ohci); in ohci_irq()
947 if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list in ohci_irq()
948 && ohci->rh_state == OHCI_RH_RUNNING) in ohci_irq()
949 ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable); in ohci_irq()
951 if (ohci->rh_state == OHCI_RH_RUNNING) { in ohci_irq()
952 ohci_writel (ohci, ints, &regs->intrstatus); in ohci_irq()
954 ++ohci->wdh_cnt; in ohci_irq()
956 ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable); in ohci_irq()
958 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_irq()
960 spin_unlock(&ohci->lock); in ohci_irq()
969 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_stop() local
971 ohci_dump(ohci); in ohci_stop()
973 if (quirk_nec(ohci)) in ohci_stop()
974 flush_work(&ohci->nec_work); in ohci_stop()
975 del_timer_sync(&ohci->io_watchdog); in ohci_stop()
977 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); in ohci_stop()
978 ohci_usb_reset(ohci); in ohci_stop()
982 if (quirk_amdiso(ohci)) in ohci_stop()
985 remove_debug_files (ohci); in ohci_stop()
986 ohci_mem_cleanup (ohci); in ohci_stop()
987 if (ohci->hcca) { in ohci_stop()
989 sizeof *ohci->hcca, in ohci_stop()
990 ohci->hcca, ohci->hcca_dma); in ohci_stop()
991 ohci->hcca = NULL; in ohci_stop()
992 ohci->hcca_dma = 0; in ohci_stop()
1001 int ohci_restart(struct ohci_hcd *ohci) in ohci_restart() argument
1007 ohci_init(ohci); in ohci_restart()
1008 spin_lock_irq(&ohci->lock); in ohci_restart()
1009 ohci->rh_state = OHCI_RH_HALTED; in ohci_restart()
1012 if (!list_empty (&ohci->pending)) in ohci_restart()
1013 ohci_dbg(ohci, "abort schedule...\n"); in ohci_restart()
1014 list_for_each_entry (priv, &ohci->pending, pending) { in ohci_restart()
1021 ed->hwINFO |= cpu_to_hc32(ohci, ED_DEQUEUE); in ohci_restart()
1022 ed_deschedule (ohci, ed); in ohci_restart()
1024 ed->ed_next = ohci->ed_rm_list; in ohci_restart()
1026 ohci->ed_rm_list = ed; in ohci_restart()
1031 ohci_dbg(ohci, "bogus ed %p state %d\n", in ohci_restart()
1038 ohci_work(ohci); in ohci_restart()
1039 spin_unlock_irq(&ohci->lock); in ohci_restart()
1044 for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0; in ohci_restart()
1045 for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0; in ohci_restart()
1048 ohci->ed_rm_list = NULL; in ohci_restart()
1051 ohci->ed_controltail = NULL; in ohci_restart()
1052 ohci->ed_bulktail = NULL; in ohci_restart()
1054 if ((temp = ohci_run (ohci)) < 0) { in ohci_restart()
1055 ohci_err (ohci, "can't restart, %d\n", temp); in ohci_restart()
1058 ohci_dbg(ohci, "restart complete\n"); in ohci_restart()
1069 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_suspend() local
1077 spin_lock_irqsave (&ohci->lock, flags); in ohci_suspend()
1078 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); in ohci_suspend()
1079 (void)ohci_readl(ohci, &ohci->regs->intrdisable); in ohci_suspend()
1082 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_suspend()
1097 struct ohci_hcd *ohci = hcd_to_ohci(hcd); in ohci_resume() local
1105 ohci_usb_reset(ohci); in ohci_resume()
1108 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); in ohci_resume()
1109 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { in ohci_resume()
1112 switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_resume()
1121 spin_lock_irq(&ohci->lock); in ohci_resume()
1122 ohci_rh_resume(ohci); in ohci_resume()
1123 ohci_rh_suspend(ohci, 0); in ohci_resume()
1124 spin_unlock_irq(&ohci->lock); in ohci_resume()
1129 ohci_dbg(ohci, "powerup ports\n"); in ohci_resume()
1130 for (port = 0; port < ohci->num_ports; port++) in ohci_resume()
1131 ohci_writel(ohci, RH_PS_PPS, in ohci_resume()
1132 &ohci->regs->roothub.portstatus[port]); in ohci_resume()
1134 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable); in ohci_resume()
1135 ohci_readl(ohci, &ohci->regs->intrenable); in ohci_resume()