Lines Matching defs: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);
202 urb_priv->td [i] = td_alloc (ohci, mem_flags);
205 urb_free_priv (ohci, urb_priv);
210 spin_lock_irqsave (&ohci->lock, flags);
217 if (ohci->rh_state != OHCI_RH_RUNNING) {
227 retval = ed_schedule (ohci, ed);
234 if (ohci->prev_frame_no == IO_WATCHDOG_OFF &&
235 list_empty(&ohci->eds_in_use) &&
236 !(ohci->flags & OHCI_QUIRK_QEMU)) {
237 ohci->prev_frame_no = ohci_frame_no(ohci);
238 mod_timer(&ohci->io_watchdog,
241 list_add(&ed->in_use_list, &ohci->eds_in_use);
244 u16 frame = ohci_frame_no(ohci);
254 u16 next = ohci_frame_no(ohci) + 1;
283 ohci_dbg(ohci, "iso underrun %p (%u+%u < %u)\n",
298 td_submit_urb (ohci, urb);
302 urb_free_priv (ohci, urb_priv);
303 spin_unlock_irqrestore (&ohci->lock, flags);
315 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
320 spin_lock_irqsave (&ohci->lock, flags);
330 start_ed_unlink(ohci, urb_priv->ed);
332 if (ohci->rh_state != OHCI_RH_RUNNING) {
334 ohci_work(ohci);
337 spin_unlock_irqrestore (&ohci->lock, flags);
350 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
362 spin_lock_irqsave (&ohci->lock, flags);
364 if (ohci->rh_state != OHCI_RH_RUNNING) {
367 ohci_work(ohci);
374 ohci_warn(ohci, "ED unlink timeout\n");
377 spin_unlock_irqrestore (&ohci->lock, flags);
382 td_free (ohci, ed->dummy);
383 ed_free (ohci, ed);
391 ohci_err (ohci, "leak ed %p (#%02x) state %d%s\n",
394 td_free (ohci, ed->dummy);
398 spin_unlock_irqrestore (&ohci->lock, flags);
403 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
405 return ohci_frame_no(ohci);
408 static void ohci_usb_reset (struct ohci_hcd *ohci)
410 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
411 ohci->hc_control &= OHCI_CTRL_RWC;
412 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
413 ohci->rh_state = OHCI_RH_HALTED;
422 struct ohci_hcd *ohci;
424 ohci = hcd_to_ohci (hcd);
425 ohci_writel(ohci, (u32) ~0, &ohci->regs->intrdisable);
428 ohci_writel(ohci, OHCI_HCR, &ohci->regs->cmdstatus);
429 ohci_readl(ohci, &ohci->regs->cmdstatus); /* flush the writes */
432 ohci_writel(ohci, ohci->fminterval, &ohci->regs->fminterval);
433 ohci->rh_state = OHCI_RH_HALTED;
438 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
441 spin_lock_irqsave(&ohci->lock, flags);
443 spin_unlock_irqrestore(&ohci->lock, flags);
452 static int ohci_init (struct ohci_hcd *ohci)
455 struct usb_hcd *hcd = ohci_to_hcd(ohci);
462 ohci->flags |= OHCI_QUIRK_HUB_POWER;
464 ohci->rh_state = OHCI_RH_HALTED;
465 ohci->regs = hcd->regs;
473 if (!no_handshake && ohci_readl (ohci,
474 &ohci->regs->control) & OHCI_CTRL_IR) {
477 ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n");
485 ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable);
486 ohci_writel (ohci, OHCI_OCR, &ohci->regs->cmdstatus);
487 while (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) {
490 ohci_err (ohci, "USB HC takeover failed!"
495 ohci_usb_reset (ohci);
500 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
503 if (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_RWC)
504 ohci->hc_control |= OHCI_CTRL_RWC;
507 if (ohci->num_ports == 0)
508 ohci->num_ports = roothub_a(ohci) & RH_A_NDP;
510 if (ohci->hcca)
513 timer_setup(&ohci->io_watchdog, io_watchdog_func, 0);
514 ohci->prev_frame_no = IO_WATCHDOG_OFF;
517 ohci->hcca = gen_pool_dma_alloc_align(hcd->localmem_pool,
518 sizeof(*ohci->hcca),
519 &ohci->hcca_dma, 256);
521 ohci->hcca = dma_alloc_coherent(hcd->self.controller,
522 sizeof(*ohci->hcca),
523 &ohci->hcca_dma,
525 if (!ohci->hcca)
528 if ((ret = ohci_mem_init (ohci)) < 0)
531 create_debug_files (ohci);
543 static int ohci_run (struct ohci_hcd *ohci)
546 int first = ohci->fminterval == 0;
547 struct usb_hcd *hcd = ohci_to_hcd(ohci);
549 ohci->rh_state = OHCI_RH_HALTED;
554 val = ohci_readl (ohci, &ohci->regs->fminterval);
555 ohci->fminterval = val & 0x3fff;
556 if (ohci->fminterval != FI)
557 ohci_dbg (ohci, "fminterval delta %d\n",
558 ohci->fminterval - FI);
559 ohci->fminterval |= FSMP (ohci->fminterval) << 16;
569 if ((ohci->hc_control & OHCI_CTRL_RWC) != 0)
572 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
578 ohci->hc_control &= OHCI_CTRL_RWC;
579 ohci->hc_control |= OHCI_USB_RESUME;
584 ohci->hc_control &= OHCI_CTRL_RWC;
585 ohci->hc_control |= OHCI_USB_RESET;
589 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
591 (void) ohci_readl (ohci, &ohci->regs->control);
594 memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
597 spin_lock_irq (&ohci->lock);
601 ohci_writel (ohci, OHCI_HCR, &ohci->regs->cmdstatus);
603 while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
605 spin_unlock_irq (&ohci->lock);
606 ohci_err (ohci, "USB HC reset timed out!\n");
621 if (ohci->flags & OHCI_QUIRK_INITRESET) {
622 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
624 (void) ohci_readl (ohci, &ohci->regs->control);
629 ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
630 ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
633 ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
635 periodic_reinit (ohci);
640 if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0
641 || !ohci_readl (ohci, &ohci->regs->periodicstart)) {
642 if (!(ohci->flags & OHCI_QUIRK_INITRESET)) {
643 ohci->flags |= OHCI_QUIRK_INITRESET;
644 ohci_dbg (ohci, "enabling initreset quirk\n");
647 spin_unlock_irq (&ohci->lock);
648 ohci_err (ohci, "init err (%08x %04x)\n",
649 ohci_readl (ohci, &ohci->regs->fminterval),
650 ohci_readl (ohci, &ohci->regs->periodicstart));
659 ohci->hc_control &= OHCI_CTRL_RWC;
660 ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER;
661 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
662 ohci->rh_state = OHCI_RH_RUNNING;
665 ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status);
669 ohci_writel (ohci, ~0, &ohci->regs->intrstatus);
670 ohci_writel (ohci, mask, &ohci->regs->intrenable);
673 val = roothub_a (ohci);
677 if (ohci->flags & OHCI_QUIRK_SUPERIO) {
683 } else if ((ohci->flags & OHCI_QUIRK_AMD756) ||
684 (ohci->flags & OHCI_QUIRK_HUB_POWER)) {
690 ohci_writel(ohci, val, &ohci->regs->roothub.a);
692 ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);
693 ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM,
694 &ohci->regs->roothub.b);
696 (void) ohci_readl (ohci, &ohci->regs->control);
698 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
699 spin_unlock_irq (&ohci->lock);
704 ohci_dump(ohci);
713 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
715 ohci_hcd_init(ohci);
717 return ohci_init(ohci);
724 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
727 ret = ohci_run(ohci);
729 ohci_err(ohci, "can't start\n");
749 struct ohci_hcd *ohci = timer_container_of(ohci, t,
759 spin_lock_irqsave(&ohci->lock, flags);
768 status = ohci_readl(ohci, &ohci->regs->intrstatus);
769 if (!(status & OHCI_INTR_WDH) && ohci->wdh_cnt == ohci->prev_wdh_cnt) {
770 if (ohci->prev_donehead) {
771 ohci_err(ohci, "HcDoneHead not written back; disabled\n");
773 usb_hc_died(ohci_to_hcd(ohci));
774 ohci_dump(ohci);
775 _ohci_shutdown(ohci_to_hcd(ohci));
784 list_for_each_entry(ed, &ohci->eds_in_use, in_use_list) {
787 OKAY_TO_TAKEBACK(ohci, ed)) {
788 unsigned tmp = hc32_to_cpu(ohci, ed->hwINFO);
790 ohci_dbg(ohci, "takeback pending TD for dev %d ep 0x%x\n",
794 add_to_done_list(ohci, ed->pending_td);
811 head = hc32_to_cpu(ohci, READ_ONCE(ed->hwHeadP)) & TD_MASK;
825 ed->takeback_wdh_cnt = ohci->wdh_cnt + 2;
830 ohci_work(ohci);
832 if (ohci->rh_state == OHCI_RH_RUNNING) {
842 frame_no = ohci_frame_no(ohci);
843 if (frame_no == ohci->prev_frame_no) {
848 for (i = 0; i < ohci->num_ports; ++i) {
849 tmp = roothub_portstatus(ohci, i);
856 ohci_err(ohci, "frame counter not updating; disabled\n");
860 if (!list_empty(&ohci->eds_in_use)) {
862 ohci->prev_wdh_cnt = ohci->wdh_cnt;
863 ohci->prev_donehead = ohci_readl(ohci,
864 &ohci->regs->donehead);
865 mod_timer(&ohci->io_watchdog,
871 ohci->prev_frame_no = prev_frame_no;
872 spin_unlock_irqrestore(&ohci->lock, flags);
879 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
880 struct ohci_regs __iomem *regs = ohci->regs;
887 ints = ohci_readl(ohci, &regs->intrstatus);
894 ohci->rh_state = OHCI_RH_HALTED;
895 ohci_dbg (ohci, "device removed!\n");
901 ints &= ohci_readl(ohci, &regs->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, &regs->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, &regs->intrdisable);
951 ohci_dbg(ohci, "resume detect\n");
952 ohci_writel(ohci, OHCI_INTR_RD, &regs->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, &regs->intrdisable);
976 if (ohci->rh_state == OHCI_RH_RUNNING) {
977 ohci_writel (ohci, ints, &regs->intrstatus);
979 ++ohci->wdh_cnt;
981 ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable);
983 (void) ohci_readl (ohci, &ohci->regs->control);
985 spin_unlock(&ohci->lock);
988 if (ohci->rh_state != OHCI_RH_HALTED) {
989 ints = ohci_readl(ohci, &regs->intrstatus);
990 if (ints && (ints & ohci_readl(ohci, &regs->intrenable)))
1001 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
1003 ohci_dump(ohci);
1005 if (quirk_nec(ohci))
1006 flush_work(&ohci->nec_work);
1007 timer_delete_sync(&ohci->io_watchdog);
1008 ohci->prev_frame_no = IO_WATCHDOG_OFF;
1010 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
1011 ohci_usb_reset(ohci);
1015 if (quirk_amdiso(ohci))
1018 remove_debug_files (ohci);
1019 ohci_mem_cleanup (ohci);
1020 if (ohci->hcca) {
1023 (unsigned long)ohci->hcca,
1024 sizeof(*ohci->hcca));
1027 sizeof(*ohci->hcca),
1028 ohci->hcca, ohci->hcca_dma);
1029 ohci->hcca = NULL;
1030 ohci->hcca_dma = 0;
1039 int ohci_restart(struct ohci_hcd *ohci)
1045 ohci_init(ohci);
1046 spin_lock_irq(&ohci->lock);
1047 ohci->rh_state = OHCI_RH_HALTED;
1050 if (!list_empty (&ohci->pending))
1051 ohci_dbg(ohci, "abort schedule...\n");
1052 list_for_each_entry (priv, &ohci->pending, pending) {
1059 ed->hwINFO |= cpu_to_hc32(ohci, ED_DEQUEUE);
1060 ed_deschedule (ohci, ed);
1062 ed->ed_next = ohci->ed_rm_list;
1064 ohci->ed_rm_list = ed;
1069 ohci_dbg(ohci, "bogus ed %p state %d\n",
1076 ohci_work(ohci);
1077 spin_unlock_irq(&ohci->lock);
1082 for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0;
1083 for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0;
1086 ohci->ed_rm_list = NULL;
1089 ohci->ed_controltail = NULL;
1090 ohci->ed_bulktail = NULL;
1092 if ((temp = ohci_run (ohci)) < 0) {
1093 ohci_err (ohci, "can't restart, %d\n", temp);
1096 ohci_dbg(ohci, "restart complete\n");
1107 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
1115 spin_lock_irqsave (&ohci->lock, flags);
1116 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
1117 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
1120 spin_unlock_irqrestore (&ohci->lock, flags);
1135 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
1143 ohci_usb_reset(ohci);
1146 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
1147 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
1150 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
1159 spin_lock_irq(&ohci->lock);
1160 ohci_rh_resume(ohci);
1161 ohci_rh_suspend(ohci, 0);
1162 spin_unlock_irq(&ohci->lock);
1167 ohci_dbg(ohci, "powerup ports\n");
1168 for (port = 0; port < ohci->num_ports; port++)
1169 ohci_writel(ohci, RH_PS_PPS,
1170 &ohci->regs->roothub.portstatus[port]);
1172 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable);
1173 ohci_readl(ohci, &ohci->regs->intrenable);
1257 #include "ohci-sa1111.c"
1262 #include "ohci-ppc-of.c"
1267 #include "ohci-ps3.c"
1272 #include "ohci-sm501.c"
1287 ohci_debug_root = debugfs_create_dir("ohci", usb_debug_root);