Lines Matching refs:ohci

10  * [ uhci code and gregs ohci fragments ]
78 #include "ohci.h"
81 static void ohci_dump (struct ohci_hcd *ohci, int verbose);
82 static int ohci_init (struct ohci_hcd *ohci);
86 static int ohci_restart (struct ohci_hcd *ohci);
90 static void sb800_prefetch(struct ohci_hcd *ohci, int on);
92 static inline void sb800_prefetch(struct ohci_hcd *ohci, int on)
99 #include "ohci-hub.c"
100 #include "ohci-dbg.c"
101 #include "ohci-mem.c"
102 #include "ohci-q.c"
137 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
150 if (! (ed = ed_get (ohci, urb->ep, urb->dev, pipe, urb->interval)))
196 urb_priv->td [i] = td_alloc (ohci, mem_flags);
199 urb_free_priv (ohci, urb_priv);
204 spin_lock_irqsave (&ohci->lock, flags);
211 if (ohci->rh_state != OHCI_RH_RUNNING) {
221 retval = ed_schedule (ohci, ed);
227 u16 frame = ohci_frame_no(ohci);
247 td_submit_urb (ohci, urb);
251 urb_free_priv (ohci, urb_priv);
252 spin_unlock_irqrestore (&ohci->lock, flags);
264 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
272 spin_lock_irqsave (&ohci->lock, flags);
276 } else if (ohci->rh_state == OHCI_RH_RUNNING) {
286 start_ed_unlink (ohci, urb_priv->ed);
294 finish_urb(ohci, urb, status);
296 spin_unlock_irqrestore (&ohci->lock, flags);
309 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
321 spin_lock_irqsave (&ohci->lock, flags);
323 if (ohci->rh_state != OHCI_RH_RUNNING) {
326 if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT)
327 ohci->eds_scheduled--;
328 finish_unlinks (ohci, 0);
335 ohci_warn(ohci, "ED unlink timeout\n");
336 if (quirk_zfmicro(ohci)) {
337 ohci_warn(ohci, "Attempting ZF TD recovery\n");
338 ohci->ed_to_check = ed;
339 ohci->zf_delay = 2;
343 spin_unlock_irqrestore (&ohci->lock, flags);
348 td_free (ohci, ed->dummy);
349 ed_free (ohci, ed);
357 ohci_err (ohci, "leak ed %p (#%02x) state %d%s\n",
360 td_free (ohci, ed->dummy);
364 spin_unlock_irqrestore (&ohci->lock, flags);
369 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
371 return ohci_frame_no(ohci);
374 static void ohci_usb_reset (struct ohci_hcd *ohci)
376 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
377 ohci->hc_control &= OHCI_CTRL_RWC;
378 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
379 ohci->rh_state = OHCI_RH_HALTED;
389 struct ohci_hcd *ohci;
391 ohci = hcd_to_ohci (hcd);
392 ohci_writel(ohci, (u32) ~0, &ohci->regs->intrdisable);
395 ohci_writel(ohci, OHCI_HCR, &ohci->regs->cmdstatus);
396 ohci_readl(ohci, &ohci->regs->cmdstatus); /* flush the writes */
399 ohci_writel(ohci, ohci->fminterval, &ohci->regs->fminterval);
402 static int check_ed(struct ohci_hcd *ohci, struct ed *ed)
404 return (hc32_to_cpu(ohci, ed->hwINFO) & ED_IN) != 0
405 && (hc32_to_cpu(ohci, ed->hwHeadP) & TD_MASK)
406 == (hc32_to_cpu(ohci, ed->hwTailP) & TD_MASK)
422 struct ohci_hcd *ohci = (struct ohci_hcd *) _ohci;
424 spin_lock_irqsave(&ohci->lock, flags);
425 max = ohci->eds_scheduled;
429 if (ohci->ed_to_check)
437 struct ed *ed = ohci->periodic[i];
453 if (!check_ed(ohci, ed)) {
461 ohci->ed_to_check = ed;
462 ohci->zf_delay = 2;
470 ohci_writel(ohci, OHCI_INTR_SF,
471 &ohci->regs->intrstatus);
472 ohci_writel(ohci, OHCI_INTR_SF,
473 &ohci->regs->intrenable);
476 (void) ohci_readl(ohci, &ohci->regs->control);
483 if (ohci->eds_scheduled)
484 mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
486 spin_unlock_irqrestore(&ohci->lock, flags);
495 static int ohci_init (struct ohci_hcd *ohci)
498 struct usb_hcd *hcd = ohci_to_hcd(ohci);
501 ohci->flags |= OHCI_QUIRK_HUB_POWER;
503 ohci->rh_state = OHCI_RH_HALTED;
504 ohci->regs = hcd->regs;
512 if (!no_handshake && ohci_readl (ohci,
513 &ohci->regs->control) & OHCI_CTRL_IR) {
516 ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n");
524 ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable);
525 ohci_writel (ohci, OHCI_OCR, &ohci->regs->cmdstatus);
526 while (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) {
529 ohci_err (ohci, "USB HC takeover failed!"
534 ohci_usb_reset (ohci);
539 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
542 if (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_RWC)
543 ohci->hc_control |= OHCI_CTRL_RWC;
546 if (ohci->num_ports == 0)
547 ohci->num_ports = roothub_a(ohci) & RH_A_NDP;
549 if (ohci->hcca)
552 ohci->hcca = dma_alloc_coherent (hcd->self.controller,
553 sizeof *ohci->hcca, &ohci->hcca_dma, 0);
554 if (!ohci->hcca)
557 if ((ret = ohci_mem_init (ohci)) < 0)
560 create_debug_files (ohci);
572 static int ohci_run (struct ohci_hcd *ohci)
575 int first = ohci->fminterval == 0;
576 struct usb_hcd *hcd = ohci_to_hcd(ohci);
578 ohci->rh_state = OHCI_RH_HALTED;
583 val = ohci_readl (ohci, &ohci->regs->fminterval);
584 ohci->fminterval = val & 0x3fff;
585 if (ohci->fminterval != FI)
586 ohci_dbg (ohci, "fminterval delta %d\n",
587 ohci->fminterval - FI);
588 ohci->fminterval |= FSMP (ohci->fminterval) << 16;
598 if ((ohci->hc_control & OHCI_CTRL_RWC) != 0)
601 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
607 ohci->hc_control &= OHCI_CTRL_RWC;
608 ohci->hc_control |= OHCI_USB_RESUME;
613 ohci->hc_control &= OHCI_CTRL_RWC;
614 ohci->hc_control |= OHCI_USB_RESET;
618 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
620 (void) ohci_readl (ohci, &ohci->regs->control);
623 memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
626 spin_lock_irq (&ohci->lock);
630 ohci_writel (ohci, OHCI_HCR, &ohci->regs->cmdstatus);
632 while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
634 spin_unlock_irq (&ohci->lock);
635 ohci_err (ohci, "USB HC reset timed out!\n");
650 if (ohci->flags & OHCI_QUIRK_INITRESET) {
651 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
653 (void) ohci_readl (ohci, &ohci->regs->control);
658 ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
659 ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
662 ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
664 periodic_reinit (ohci);
669 if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0
670 || !ohci_readl (ohci, &ohci->regs->periodicstart)) {
671 if (!(ohci->flags & OHCI_QUIRK_INITRESET)) {
672 ohci->flags |= OHCI_QUIRK_INITRESET;
673 ohci_dbg (ohci, "enabling initreset quirk\n");
676 spin_unlock_irq (&ohci->lock);
677 ohci_err (ohci, "init err (%08x %04x)\n",
678 ohci_readl (ohci, &ohci->regs->fminterval),
679 ohci_readl (ohci, &ohci->regs->periodicstart));
688 ohci->hc_control &= OHCI_CTRL_RWC;
689 ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER;
690 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
691 ohci->rh_state = OHCI_RH_RUNNING;
694 ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status);
698 ohci_writel (ohci, ~0, &ohci->regs->intrstatus);
699 ohci_writel (ohci, mask, &ohci->regs->intrenable);
702 val = roothub_a (ohci);
704 if (ohci->flags & OHCI_QUIRK_SUPERIO) {
708 ohci_writel (ohci, val, &ohci->regs->roothub.a);
709 } else if ((ohci->flags & OHCI_QUIRK_AMD756) ||
710 (ohci->flags & OHCI_QUIRK_HUB_POWER)) {
715 ohci_writel (ohci, val, &ohci->regs->roothub.a);
717 ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);
718 ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM,
719 &ohci->regs->roothub.b);
721 (void) ohci_readl (ohci, &ohci->regs->control);
723 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
724 spin_unlock_irq (&ohci->lock);
729 if (quirk_zfmicro(ohci)) {
731 setup_timer(&ohci->unlink_watchdog, unlink_watchdog_func,
732 (unsigned long) ohci);
734 ohci->eds_scheduled = 0;
735 ohci->ed_to_check = NULL;
738 ohci_dump (ohci, 1);
749 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
750 struct ohci_regs __iomem *regs = ohci->regs;
757 ints = ohci_readl(ohci, &regs->intrstatus);
763 ohci->rh_state = OHCI_RH_HALTED;
764 ohci_dbg (ohci, "device removed!\n");
770 ints &= ohci_readl(ohci, &regs->intrenable);
773 if (ints == 0 || unlikely(ohci->rh_state == OHCI_RH_HALTED))
778 if (quirk_nec(ohci)) {
782 ohci_err (ohci, "OHCI Unrecoverable Error, scheduling NEC chip restart\n");
784 ohci_writel (ohci, OHCI_INTR_UE, &regs->intrdisable);
786 schedule_work (&ohci->nec_work);
788 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
789 ohci->rh_state = OHCI_RH_HALTED;
793 ohci_dump (ohci, 1);
794 ohci_usb_reset (ohci);
798 ohci_vdbg(ohci, "rhsc\n");
799 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
800 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
811 ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable);
820 ohci_vdbg(ohci, "resume detect\n");
821 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
823 if (ohci->autostop) {
824 spin_lock (&ohci->lock);
825 ohci_rh_resume (ohci);
826 spin_unlock (&ohci->lock);
832 spin_lock (&ohci->lock);
833 dl_done_list (ohci);
834 spin_unlock (&ohci->lock);
837 if (quirk_zfmicro(ohci) && (ints & OHCI_INTR_SF)) {
838 spin_lock(&ohci->lock);
839 if (ohci->ed_to_check) {
840 struct ed *ed = ohci->ed_to_check;
842 if (check_ed(ohci, ed)) {
846 if (--ohci->zf_delay == 0) {
850 ohci_warn(ohci,
853 takeback_td(ohci, td);
854 ohci->ed_to_check = NULL;
857 ohci->ed_to_check = NULL;
859 spin_unlock(&ohci->lock);
867 spin_lock (&ohci->lock);
868 if (ohci->ed_rm_list)
869 finish_unlinks (ohci, ohci_frame_no(ohci));
871 && !ohci->ed_rm_list
872 && !ohci->ed_to_check
873 && ohci->rh_state == OHCI_RH_RUNNING)
874 ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable);
875 spin_unlock (&ohci->lock);
877 if (ohci->rh_state == OHCI_RH_RUNNING) {
878 ohci_writel (ohci, ints, &regs->intrstatus);
879 ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable);
881 (void) ohci_readl (ohci, &ohci->regs->control);
891 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
893 ohci_dump (ohci, 1);
895 if (quirk_nec(ohci))
896 flush_work_sync(&ohci->nec_work);
898 ohci_usb_reset (ohci);
899 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
903 if (quirk_zfmicro(ohci))
904 del_timer(&ohci->unlink_watchdog);
905 if (quirk_amdiso(ohci))
908 remove_debug_files (ohci);
909 ohci_mem_cleanup (ohci);
910 if (ohci->hcca) {
912 sizeof *ohci->hcca,
913 ohci->hcca, ohci->hcca_dma);
914 ohci->hcca = NULL;
915 ohci->hcca_dma = 0;
924 static int ohci_restart (struct ohci_hcd *ohci)
930 spin_lock_irq(&ohci->lock);
931 ohci->rh_state = OHCI_RH_HALTED;
934 if (!list_empty (&ohci->pending))
935 ohci_dbg(ohci, "abort schedule...\n");
936 list_for_each_entry (priv, &ohci->pending, pending) {
943 ed->hwINFO |= cpu_to_hc32(ohci, ED_DEQUEUE);
944 ed_deschedule (ohci, ed);
946 ed->ed_next = ohci->ed_rm_list;
948 ohci->ed_rm_list = ed;
953 ohci_dbg(ohci, "bogus ed %p state %d\n",
960 finish_unlinks (ohci, 0);
961 spin_unlock_irq(&ohci->lock);
966 for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0;
967 for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0;
970 ohci->ed_rm_list = NULL;
973 ohci->ed_controltail = NULL;
974 ohci->ed_bulktail = NULL;
976 if ((temp = ohci_run (ohci)) < 0) {
977 ohci_err (ohci, "can't restart, %d\n", temp);
980 ohci_dbg(ohci, "restart complete\n");
993 #include "ohci-pci.c"
998 #include "ohci-sa1111.c"
1003 #include "ohci-s3c2410.c"
1008 #include "ohci-exynos.c"
1013 #include "ohci-omap.c"
1018 #include "ohci-omap3.c"
1023 #include "ohci-pxa27x.c"
1028 #include "ohci-ep93xx.c"
1033 #include "ohci-au1xxx.c"
1038 #include "ohci-pnx8550.c"
1043 #include "ohci-ppc-soc.c"
1048 #include "ohci-at91.c"
1053 #include "ohci-nxp.c"
1058 #include "ohci-da8xx.c"
1063 #include "ohci-sh.c"
1069 #include "ohci-ppc-of.c"
1074 #include "ohci-spear.c"
1079 #include "ohci-ps3.c"
1084 #include "ohci-ssb.c"
1089 #include "ohci-sm501.c"
1094 #include "ohci-tmio.c"
1099 #include "ohci-jz4740.c"
1104 #include "ohci-octeon.c"
1109 #include "ohci-cns3xxx.c"
1114 #include "ohci-xls.c"
1119 #include "ohci-platform.c"
1133 #error "missing bus glue for ohci-hcd"
1149 ohci_debug_root = debugfs_create_dir("ohci", usb_debug_root);