Lines Matching +full:generic +full:- +full:ohci

1 // SPDX-License-Identifier: GPL-1.0+
3 * Open Host Controller Interface (OHCI) driver for USB.
8 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
11 * [ uhci code and gregs ohci fragments ]
16 * OHCI is the main "non-Intel/VIA" standard for USB 1.1 host controller
17 * interfaces (though some non-x86 Intel chips use it). It supports
39 #include <linux/dma-mapping.h>
52 #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver"
54 /*-------------------------------------------------------------------------*/
63 /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
72 /*-------------------------------------------------------------------------*/
80 #include "ohci.h"
81 #include "pci-quirks.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"
94 * On architectures with edge-triggered interrupts we must never return
97 #if defined(CONFIG_SA1111) /* ... or other edge-triggered systems */
115 /*-------------------------------------------------------------------------*/
122 len = urb->transfer_buffer_length; in number_of_tds()
123 i = urb->num_mapped_sgs; in number_of_tds()
125 if (len > 0 && i > 0) { /* Scatter-gather transfer */ in number_of_tds()
127 sg = urb->sg; in number_of_tds()
131 len -= this_sg_len; in number_of_tds()
132 if (--i <= 0 || len <= 0) in number_of_tds()
137 } else { /* Non-SG transfer */ in number_of_tds()
152 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_urb_enqueue() local
155 unsigned int pipe = urb->pipe; in ohci_urb_enqueue()
161 ed = ed_get(ohci, urb->ep, urb->dev, pipe, urb->interval); in ohci_urb_enqueue()
163 return -ENOMEM; in ohci_urb_enqueue()
166 switch (ed->type) { in ohci_urb_enqueue()
169 if (urb->transfer_buffer_length > 4096) in ohci_urb_enqueue()
170 return -EMSGSIZE; in ohci_urb_enqueue()
179 /* maybe a zero-length packet to wrap it up */ in ohci_urb_enqueue()
182 else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0 in ohci_urb_enqueue()
183 && (urb->transfer_buffer_length in ohci_urb_enqueue()
184 % usb_maxpacket (urb->dev, pipe, in ohci_urb_enqueue()
189 size = urb->number_of_packets; in ohci_urb_enqueue()
197 return -ENOMEM; in ohci_urb_enqueue()
198 INIT_LIST_HEAD (&urb_priv->pending); in ohci_urb_enqueue()
199 urb_priv->length = size; in ohci_urb_enqueue()
200 urb_priv->ed = ed; in ohci_urb_enqueue()
204 urb_priv->td [i] = td_alloc (ohci, mem_flags); in ohci_urb_enqueue()
205 if (!urb_priv->td [i]) { in ohci_urb_enqueue()
206 urb_priv->length = i; in ohci_urb_enqueue()
207 urb_free_priv (ohci, urb_priv); in ohci_urb_enqueue()
208 return -ENOMEM; in ohci_urb_enqueue()
212 spin_lock_irqsave (&ohci->lock, flags); in ohci_urb_enqueue()
216 retval = -ENODEV; in ohci_urb_enqueue()
219 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_urb_enqueue()
220 retval = -ENODEV; in ohci_urb_enqueue()
228 if (ed->state == ED_IDLE) { in ohci_urb_enqueue()
229 retval = ed_schedule (ohci, ed); in ohci_urb_enqueue()
236 if (ohci->prev_frame_no == IO_WATCHDOG_OFF && in ohci_urb_enqueue()
237 list_empty(&ohci->eds_in_use) && in ohci_urb_enqueue()
238 !(ohci->flags & OHCI_QUIRK_QEMU)) { in ohci_urb_enqueue()
239 ohci->prev_frame_no = ohci_frame_no(ohci); in ohci_urb_enqueue()
240 mod_timer(&ohci->io_watchdog, in ohci_urb_enqueue()
243 list_add(&ed->in_use_list, &ohci->eds_in_use); in ohci_urb_enqueue()
245 if (ed->type == PIPE_ISOCHRONOUS) { in ohci_urb_enqueue()
246 u16 frame = ohci_frame_no(ohci); in ohci_urb_enqueue()
249 frame += max_t (u16, 8, ed->interval); in ohci_urb_enqueue()
250 frame &= ~(ed->interval - 1); in ohci_urb_enqueue()
251 frame |= ed->branch; in ohci_urb_enqueue()
252 urb->start_frame = frame; in ohci_urb_enqueue()
253 ed->last_iso = frame + ed->interval * (size - 1); in ohci_urb_enqueue()
255 } else if (ed->type == PIPE_ISOCHRONOUS) { in ohci_urb_enqueue()
256 u16 next = ohci_frame_no(ohci) + 1; in ohci_urb_enqueue()
257 u16 frame = ed->last_iso + ed->interval; in ohci_urb_enqueue()
258 u16 length = ed->interval * (size - 1); in ohci_urb_enqueue()
264 if (urb->transfer_flags & URB_ISO_ASAP) { in ohci_urb_enqueue()
265 frame += (next - frame + ed->interval - 1) & in ohci_urb_enqueue()
266 -ed->interval; in ohci_urb_enqueue()
274 * Some OHCI hardware doesn't handle late TDs in ohci_urb_enqueue()
280 urb_priv->td_cnt = DIV_ROUND_UP( in ohci_urb_enqueue()
281 (u16) (next - frame), in ohci_urb_enqueue()
282 ed->interval); in ohci_urb_enqueue()
283 if (urb_priv->td_cnt >= urb_priv->length) { in ohci_urb_enqueue()
284 ++urb_priv->td_cnt; /* Mark it */ in ohci_urb_enqueue()
285 ohci_dbg(ohci, "iso underrun %p (%u+%u < %u)\n", in ohci_urb_enqueue()
291 urb->start_frame = frame; in ohci_urb_enqueue()
292 ed->last_iso = frame + length; in ohci_urb_enqueue()
299 urb->hcpriv = urb_priv; in ohci_urb_enqueue()
300 td_submit_urb (ohci, urb); in ohci_urb_enqueue()
304 urb_free_priv (ohci, urb_priv); in ohci_urb_enqueue()
305 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_urb_enqueue()
317 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_urb_dequeue() local
322 spin_lock_irqsave (&ohci->lock, flags); in ohci_urb_dequeue()
330 urb_priv = urb->hcpriv; in ohci_urb_dequeue()
331 if (urb_priv->ed->state == ED_OPER) in ohci_urb_dequeue()
332 start_ed_unlink(ohci, urb_priv->ed); in ohci_urb_dequeue()
334 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_urb_dequeue()
336 ohci_work(ohci); in ohci_urb_dequeue()
339 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_urb_dequeue()
343 /*-------------------------------------------------------------------------*/
352 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_endpoint_disable() local
354 struct ed *ed = ep->hcpriv; in ohci_endpoint_disable()
364 spin_lock_irqsave (&ohci->lock, flags); in ohci_endpoint_disable()
366 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_endpoint_disable()
368 ed->state = ED_IDLE; in ohci_endpoint_disable()
369 ohci_work(ohci); in ohci_endpoint_disable()
372 switch (ed->state) { in ohci_endpoint_disable()
375 if (limit-- == 0) { in ohci_endpoint_disable()
376 ohci_warn(ohci, "ED unlink timeout\n"); in ohci_endpoint_disable()
379 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_endpoint_disable()
383 if (list_empty (&ed->td_list)) { in ohci_endpoint_disable()
384 td_free (ohci, ed->dummy); in ohci_endpoint_disable()
385 ed_free (ohci, ed); in ohci_endpoint_disable()
393 ohci_err (ohci, "leak ed %p (#%02x) state %d%s\n", in ohci_endpoint_disable()
394 ed, ep->desc.bEndpointAddress, ed->state, in ohci_endpoint_disable()
395 list_empty (&ed->td_list) ? "" : " (has tds)"); in ohci_endpoint_disable()
396 td_free (ohci, ed->dummy); in ohci_endpoint_disable()
399 ep->hcpriv = NULL; in ohci_endpoint_disable()
400 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_endpoint_disable()
405 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_get_frame() local
407 return ohci_frame_no(ohci); in ohci_get_frame()
410 static void ohci_usb_reset (struct ohci_hcd *ohci) in ohci_usb_reset() argument
412 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); in ohci_usb_reset()
413 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_usb_reset()
414 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_usb_reset()
415 ohci->rh_state = OHCI_RH_HALTED; in ohci_usb_reset()
420 * "firmware". this is bus-neutral, unlike shutdown() methods.
424 struct ohci_hcd *ohci; in _ohci_shutdown() local
426 ohci = hcd_to_ohci (hcd); in _ohci_shutdown()
427 ohci_writel(ohci, (u32) ~0, &ohci->regs->intrdisable); in _ohci_shutdown()
430 ohci_writel(ohci, OHCI_HCR, &ohci->regs->cmdstatus); in _ohci_shutdown()
431 ohci_readl(ohci, &ohci->regs->cmdstatus); /* flush the writes */ in _ohci_shutdown()
434 ohci_writel(ohci, ohci->fminterval, &ohci->regs->fminterval); in _ohci_shutdown()
435 ohci->rh_state = OHCI_RH_HALTED; in _ohci_shutdown()
440 struct ohci_hcd *ohci = hcd_to_ohci(hcd); in ohci_shutdown() local
443 spin_lock_irqsave(&ohci->lock, flags); in ohci_shutdown()
445 spin_unlock_irqrestore(&ohci->lock, flags); in ohci_shutdown()
448 /*-------------------------------------------------------------------------*
450 *-------------------------------------------------------------------------*/
454 static int ohci_init (struct ohci_hcd *ohci) in ohci_init() argument
457 struct usb_hcd *hcd = ohci_to_hcd(ohci); in ohci_init()
459 /* Accept arbitrarily long scatter-gather lists */ in ohci_init()
460 if (!hcd->localmem_pool) in ohci_init()
461 hcd->self.sg_tablesize = ~0; in ohci_init()
464 ohci->flags |= OHCI_QUIRK_HUB_POWER; in ohci_init()
466 ohci->rh_state = OHCI_RH_HALTED; in ohci_init()
467 ohci->regs = hcd->regs; in ohci_init()
470 * was never needed for most non-PCI systems ... remove the code? in ohci_init()
475 if (!no_handshake && ohci_readl (ohci, in ohci_init()
476 &ohci->regs->control) & OHCI_CTRL_IR) { in ohci_init()
479 ohci_dbg (ohci, "USB HC TakeOver from BIOS/SMM\n"); in ohci_init()
487 ohci_writel (ohci, OHCI_INTR_OC, &ohci->regs->intrenable); in ohci_init()
488 ohci_writel (ohci, OHCI_OCR, &ohci->regs->cmdstatus); in ohci_init()
489 while (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_IR) { in ohci_init()
491 if (--temp == 0) { in ohci_init()
492 ohci_err (ohci, "USB HC takeover failed!" in ohci_init()
494 return -EBUSY; in ohci_init()
497 ohci_usb_reset (ohci); in ohci_init()
502 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); in ohci_init()
505 if (ohci_readl (ohci, &ohci->regs->control) & OHCI_CTRL_RWC) in ohci_init()
506 ohci->hc_control |= OHCI_CTRL_RWC; in ohci_init()
509 if (ohci->num_ports == 0) in ohci_init()
510 ohci->num_ports = roothub_a(ohci) & RH_A_NDP; in ohci_init()
512 if (ohci->hcca) in ohci_init()
515 timer_setup(&ohci->io_watchdog, io_watchdog_func, 0); in ohci_init()
516 ohci->prev_frame_no = IO_WATCHDOG_OFF; in ohci_init()
518 if (hcd->localmem_pool) in ohci_init()
519 ohci->hcca = gen_pool_dma_alloc_align(hcd->localmem_pool, in ohci_init()
520 sizeof(*ohci->hcca), in ohci_init()
521 &ohci->hcca_dma, 256); in ohci_init()
523 ohci->hcca = dma_alloc_coherent(hcd->self.controller, in ohci_init()
524 sizeof(*ohci->hcca), in ohci_init()
525 &ohci->hcca_dma, in ohci_init()
527 if (!ohci->hcca) in ohci_init()
528 return -ENOMEM; in ohci_init()
530 if ((ret = ohci_mem_init (ohci)) < 0) in ohci_init()
533 create_debug_files (ohci); in ohci_init()
539 /*-------------------------------------------------------------------------*/
541 /* Start an OHCI controller, set the BUS operational
545 static int ohci_run (struct ohci_hcd *ohci) in ohci_run() argument
548 int first = ohci->fminterval == 0; in ohci_run()
549 struct usb_hcd *hcd = ohci_to_hcd(ohci); in ohci_run()
551 ohci->rh_state = OHCI_RH_HALTED; in ohci_run()
556 val = ohci_readl (ohci, &ohci->regs->fminterval); in ohci_run()
557 ohci->fminterval = val & 0x3fff; in ohci_run()
558 if (ohci->fminterval != FI) in ohci_run()
559 ohci_dbg (ohci, "fminterval delta %d\n", in ohci_run()
560 ohci->fminterval - FI); in ohci_run()
561 ohci->fminterval |= FSMP (ohci->fminterval) << 16; in ohci_run()
571 if ((ohci->hc_control & OHCI_CTRL_RWC) != 0) in ohci_run()
572 device_set_wakeup_capable(hcd->self.controller, 1); in ohci_run()
574 switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_run()
580 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_run()
581 ohci->hc_control |= OHCI_USB_RESUME; in ohci_run()
586 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_run()
587 ohci->hc_control |= OHCI_USB_RESET; in ohci_run()
591 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_run()
593 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_run()
596 memset (ohci->hcca, 0, sizeof (struct ohci_hcca)); in ohci_run()
599 spin_lock_irq (&ohci->lock); in ohci_run()
603 ohci_writel (ohci, OHCI_HCR, &ohci->regs->cmdstatus); in ohci_run()
605 while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) { in ohci_run()
606 if (--val == 0) { in ohci_run()
607 spin_unlock_irq (&ohci->lock); in ohci_run()
608 ohci_err (ohci, "USB HC reset timed out!\n"); in ohci_run()
609 return -1; in ohci_run()
623 if (ohci->flags & OHCI_QUIRK_INITRESET) { in ohci_run()
624 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_run()
626 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_run()
631 ohci_writel (ohci, 0, &ohci->regs->ed_controlhead); in ohci_run()
632 ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead); in ohci_run()
635 ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca); in ohci_run()
637 periodic_reinit (ohci); in ohci_run()
639 /* some OHCI implementations are finicky about how they init. in ohci_run()
642 if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0 in ohci_run()
643 || !ohci_readl (ohci, &ohci->regs->periodicstart)) { in ohci_run()
644 if (!(ohci->flags & OHCI_QUIRK_INITRESET)) { in ohci_run()
645 ohci->flags |= OHCI_QUIRK_INITRESET; in ohci_run()
646 ohci_dbg (ohci, "enabling initreset quirk\n"); in ohci_run()
649 spin_unlock_irq (&ohci->lock); in ohci_run()
650 ohci_err (ohci, "init err (%08x %04x)\n", in ohci_run()
651 ohci_readl (ohci, &ohci->regs->fminterval), in ohci_run()
652 ohci_readl (ohci, &ohci->regs->periodicstart)); in ohci_run()
653 return -EOVERFLOW; in ohci_run()
657 set_bit(HCD_FLAG_POLL_RH, &hcd->flags); in ohci_run()
658 hcd->uses_new_polling = 1; in ohci_run()
661 ohci->hc_control &= OHCI_CTRL_RWC; in ohci_run()
662 ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER; in ohci_run()
663 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_run()
664 ohci->rh_state = OHCI_RH_RUNNING; in ohci_run()
667 ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status); in ohci_run()
671 ohci_writel (ohci, ~0, &ohci->regs->intrstatus); in ohci_run()
672 ohci_writel (ohci, mask, &ohci->regs->intrenable); in ohci_run()
675 val = roothub_a (ohci); in ohci_run()
676 /* Configure for per-port over-current protection by default */ in ohci_run()
679 if (ohci->flags & OHCI_QUIRK_SUPERIO) { in ohci_run()
681 * Ganged power switching, no over-current protection. in ohci_run()
685 } else if ((ohci->flags & OHCI_QUIRK_AMD756) || in ohci_run()
686 (ohci->flags & OHCI_QUIRK_HUB_POWER)) { in ohci_run()
687 /* hub power always on; required for AMD-756 and some in ohci_run()
692 ohci_writel(ohci, val, &ohci->regs->roothub.a); in ohci_run()
694 ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status); in ohci_run()
695 ohci_writel (ohci, (val & RH_A_NPS) ? 0 : RH_B_PPCM, in ohci_run()
696 &ohci->regs->roothub.b); in ohci_run()
698 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_run()
700 ohci->next_statechange = jiffies + STATECHANGE_DELAY; in ohci_run()
701 spin_unlock_irq (&ohci->lock); in ohci_run()
703 // POTPGT delay is bits 24-31, in 2 ms units. in ohci_run()
706 ohci_dump(ohci); in ohci_run()
711 /* ohci_setup routine for generic controller initialization */
715 struct ohci_hcd *ohci = hcd_to_ohci(hcd); in ohci_setup() local
717 ohci_hcd_init(ohci); in ohci_setup()
719 return ohci_init(ohci); in ohci_setup()
723 /* ohci_start routine for generic controller start of all OHCI bus glue */
726 struct ohci_hcd *ohci = hcd_to_ohci(hcd); in ohci_start() local
729 ret = ohci_run(ohci); in ohci_start()
731 ohci_err(ohci, "can't start\n"); in ohci_start()
737 /*-------------------------------------------------------------------------*/
740 * Some OHCI controllers are known to lose track of completed TDs. They
751 struct ohci_hcd *ohci = from_timer(ohci, t, io_watchdog); in io_watchdog_func() local
760 spin_lock_irqsave(&ohci->lock, flags); in io_watchdog_func()
766 * was non-empty at that time, something is badly wrong with the in io_watchdog_func()
769 status = ohci_readl(ohci, &ohci->regs->intrstatus); in io_watchdog_func()
770 if (!(status & OHCI_INTR_WDH) && ohci->wdh_cnt == ohci->prev_wdh_cnt) { in io_watchdog_func()
771 if (ohci->prev_donehead) { in io_watchdog_func()
772 ohci_err(ohci, "HcDoneHead not written back; disabled\n"); in io_watchdog_func()
774 usb_hc_died(ohci_to_hcd(ohci)); in io_watchdog_func()
775 ohci_dump(ohci); in io_watchdog_func()
776 _ohci_shutdown(ohci_to_hcd(ohci)); in io_watchdog_func()
785 list_for_each_entry(ed, &ohci->eds_in_use, in_use_list) { in io_watchdog_func()
786 if (ed->pending_td) { in io_watchdog_func()
788 OKAY_TO_TAKEBACK(ohci, ed)) { in io_watchdog_func()
789 unsigned tmp = hc32_to_cpu(ohci, ed->hwINFO); in io_watchdog_func()
791 ohci_dbg(ohci, "takeback pending TD for dev %d ep 0x%x\n", in io_watchdog_func()
795 add_to_done_list(ohci, ed->pending_td); in io_watchdog_func()
800 td = ed->pending_td; in io_watchdog_func()
804 list_for_each_entry(td_next, &ed->td_list, td_list) { in io_watchdog_func()
805 if (!td_next->next_dl_td) in io_watchdog_func()
812 head = hc32_to_cpu(ohci, READ_ONCE(ed->hwHeadP)) & TD_MASK; in io_watchdog_func()
814 td_next = list_prepare_entry(td, &ed->td_list, td_list); in io_watchdog_func()
815 list_for_each_entry_continue(td_next, &ed->td_list, td_list) { in io_watchdog_func()
816 if (head == (u32) td_next->td_dma) in io_watchdog_func()
826 ed->takeback_wdh_cnt = ohci->wdh_cnt + 2; in io_watchdog_func()
827 ed->pending_td = td; in io_watchdog_func()
831 ohci_work(ohci); in io_watchdog_func()
833 if (ohci->rh_state == OHCI_RH_RUNNING) { in io_watchdog_func()
843 frame_no = ohci_frame_no(ohci); in io_watchdog_func()
844 if (frame_no == ohci->prev_frame_no) { in io_watchdog_func()
849 for (i = 0; i < ohci->num_ports; ++i) { in io_watchdog_func()
850 tmp = roothub_portstatus(ohci, i); in io_watchdog_func()
857 ohci_err(ohci, "frame counter not updating; disabled\n"); in io_watchdog_func()
861 if (!list_empty(&ohci->eds_in_use)) { in io_watchdog_func()
863 ohci->prev_wdh_cnt = ohci->wdh_cnt; in io_watchdog_func()
864 ohci->prev_donehead = ohci_readl(ohci, in io_watchdog_func()
865 &ohci->regs->donehead); in io_watchdog_func()
866 mod_timer(&ohci->io_watchdog, in io_watchdog_func()
872 ohci->prev_frame_no = prev_frame_no; in io_watchdog_func()
873 spin_unlock_irqrestore(&ohci->lock, flags); in io_watchdog_func()
880 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_irq() local
881 struct ohci_regs __iomem *regs = ohci->regs; in ohci_irq()
885 * optimization of checking the LSB of hcca->done_head; it doesn't in ohci_irq()
886 * work on all systems (edge triggering for OHCI can be a factor). in ohci_irq()
888 ints = ohci_readl(ohci, &regs->intrstatus); in ohci_irq()
894 ohci->rh_state = OHCI_RH_HALTED; in ohci_irq()
895 ohci_dbg (ohci, "device removed!\n"); in ohci_irq()
901 ints &= ohci_readl(ohci, &regs->intrenable); in ohci_irq()
904 if (ints == 0 || unlikely(ohci->rh_state == OHCI_RH_HALTED)) in ohci_irq()
909 if (quirk_nec(ohci)) { in ohci_irq()
913 ohci_err (ohci, "OHCI Unrecoverable Error, scheduling NEC chip restart\n"); in ohci_irq()
915 ohci_writel (ohci, OHCI_INTR_UE, &regs->intrdisable); in ohci_irq()
917 schedule_work (&ohci->nec_work); in ohci_irq()
919 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n"); in ohci_irq()
920 ohci->rh_state = OHCI_RH_HALTED; in ohci_irq()
924 ohci_dump(ohci); in ohci_irq()
925 ohci_usb_reset (ohci); in ohci_irq()
929 ohci_dbg(ohci, "rhsc\n"); in ohci_irq()
930 ohci->next_statechange = jiffies + STATECHANGE_DELAY; in ohci_irq()
931 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC, in ohci_irq()
932 &regs->intrstatus); in ohci_irq()
937 * change bit. With others it's level-triggered, active in ohci_irq()
940 * re-enables it. in ohci_irq()
942 ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable); in ohci_irq()
951 ohci_dbg(ohci, "resume detect\n"); in ohci_irq()
952 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus); in ohci_irq()
953 set_bit(HCD_FLAG_POLL_RH, &hcd->flags); in ohci_irq()
954 if (ohci->autostop) { in ohci_irq()
955 spin_lock (&ohci->lock); in ohci_irq()
956 ohci_rh_resume (ohci); in ohci_irq()
957 spin_unlock (&ohci->lock); in ohci_irq()
962 spin_lock(&ohci->lock); in ohci_irq()
964 update_done_list(ohci); in ohci_irq()
971 ohci_work(ohci); in ohci_irq()
972 if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list in ohci_irq()
973 && ohci->rh_state == OHCI_RH_RUNNING) in ohci_irq()
974 ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable); in ohci_irq()
976 if (ohci->rh_state == OHCI_RH_RUNNING) { in ohci_irq()
977 ohci_writel (ohci, ints, &regs->intrstatus); in ohci_irq()
979 ++ohci->wdh_cnt; in ohci_irq()
981 ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable); in ohci_irq()
983 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_irq()
985 spin_unlock(&ohci->lock); in ohci_irq()
990 /*-------------------------------------------------------------------------*/
994 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_stop() local
996 ohci_dump(ohci); in ohci_stop()
998 if (quirk_nec(ohci)) in ohci_stop()
999 flush_work(&ohci->nec_work); in ohci_stop()
1000 del_timer_sync(&ohci->io_watchdog); in ohci_stop()
1001 ohci->prev_frame_no = IO_WATCHDOG_OFF; in ohci_stop()
1003 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); in ohci_stop()
1004 ohci_usb_reset(ohci); in ohci_stop()
1005 free_irq(hcd->irq, hcd); in ohci_stop()
1006 hcd->irq = 0; in ohci_stop()
1008 if (quirk_amdiso(ohci)) in ohci_stop()
1011 remove_debug_files (ohci); in ohci_stop()
1012 ohci_mem_cleanup (ohci); in ohci_stop()
1013 if (ohci->hcca) { in ohci_stop()
1014 if (hcd->localmem_pool) in ohci_stop()
1015 gen_pool_free(hcd->localmem_pool, in ohci_stop()
1016 (unsigned long)ohci->hcca, in ohci_stop()
1017 sizeof(*ohci->hcca)); in ohci_stop()
1019 dma_free_coherent(hcd->self.controller, in ohci_stop()
1020 sizeof(*ohci->hcca), in ohci_stop()
1021 ohci->hcca, ohci->hcca_dma); in ohci_stop()
1022 ohci->hcca = NULL; in ohci_stop()
1023 ohci->hcca_dma = 0; in ohci_stop()
1027 /*-------------------------------------------------------------------------*/
1032 int ohci_restart(struct ohci_hcd *ohci) in ohci_restart() argument
1038 ohci_init(ohci); in ohci_restart()
1039 spin_lock_irq(&ohci->lock); in ohci_restart()
1040 ohci->rh_state = OHCI_RH_HALTED; in ohci_restart()
1043 if (!list_empty (&ohci->pending)) in ohci_restart()
1044 ohci_dbg(ohci, "abort schedule...\n"); in ohci_restart()
1045 list_for_each_entry (priv, &ohci->pending, pending) { in ohci_restart()
1046 struct urb *urb = priv->td[0]->urb; in ohci_restart()
1047 struct ed *ed = priv->ed; in ohci_restart()
1049 switch (ed->state) { in ohci_restart()
1051 ed->state = ED_UNLINK; in ohci_restart()
1052 ed->hwINFO |= cpu_to_hc32(ohci, ED_DEQUEUE); in ohci_restart()
1053 ed_deschedule (ohci, ed); in ohci_restart()
1055 ed->ed_next = ohci->ed_rm_list; in ohci_restart()
1056 ed->ed_prev = NULL; in ohci_restart()
1057 ohci->ed_rm_list = ed; in ohci_restart()
1062 ohci_dbg(ohci, "bogus ed %p state %d\n", in ohci_restart()
1063 ed, ed->state); in ohci_restart()
1066 if (!urb->unlinked) in ohci_restart()
1067 urb->unlinked = -ESHUTDOWN; in ohci_restart()
1069 ohci_work(ohci); in ohci_restart()
1070 spin_unlock_irq(&ohci->lock); in ohci_restart()
1075 for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0; in ohci_restart()
1076 for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0; in ohci_restart()
1079 ohci->ed_rm_list = NULL; in ohci_restart()
1082 ohci->ed_controltail = NULL; in ohci_restart()
1083 ohci->ed_bulktail = NULL; in ohci_restart()
1085 if ((temp = ohci_run (ohci)) < 0) { in ohci_restart()
1086 ohci_err (ohci, "can't restart, %d\n", temp); in ohci_restart()
1089 ohci_dbg(ohci, "restart complete\n"); in ohci_restart()
1100 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_suspend() local
1108 spin_lock_irqsave (&ohci->lock, flags); in ohci_suspend()
1109 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); in ohci_suspend()
1110 (void)ohci_readl(ohci, &ohci->regs->intrdisable); in ohci_suspend()
1112 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); in ohci_suspend()
1113 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_suspend()
1115 synchronize_irq(hcd->irq); in ohci_suspend()
1119 rc = -EBUSY; in ohci_suspend()
1128 struct ohci_hcd *ohci = hcd_to_ohci(hcd); in ohci_resume() local
1132 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); in ohci_resume()
1134 /* Make sure resume from hibernation re-enumerates everything */ in ohci_resume()
1136 ohci_usb_reset(ohci); in ohci_resume()
1139 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); in ohci_resume()
1140 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { in ohci_resume()
1143 switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_resume()
1152 spin_lock_irq(&ohci->lock); in ohci_resume()
1153 ohci_rh_resume(ohci); in ohci_resume()
1154 ohci_rh_suspend(ohci, 0); in ohci_resume()
1155 spin_unlock_irq(&ohci->lock); in ohci_resume()
1160 ohci_dbg(ohci, "powerup ports\n"); in ohci_resume()
1161 for (port = 0; port < ohci->num_ports; port++) in ohci_resume()
1162 ohci_writel(ohci, RH_PS_PPS, in ohci_resume()
1163 &ohci->regs->roothub.portstatus[port]); in ohci_resume()
1165 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable); in ohci_resume()
1166 ohci_readl(ohci, &ohci->regs->intrenable); in ohci_resume()
1178 /*-------------------------------------------------------------------------*/
1181 * Generic structure: This gets copied for platform drivers so that
1187 .product_desc = "OHCI Host Controller",
1191 * generic hardware linkage
1231 /* Copy the generic table to drv and then apply the overrides */ in ohci_init_driver()
1235 drv->product_desc = over->product_desc; in ohci_init_driver()
1236 drv->hcd_priv_size += over->extra_priv_size; in ohci_init_driver()
1237 if (over->reset) in ohci_init_driver()
1238 drv->reset = over->reset; in ohci_init_driver()
1243 /*-------------------------------------------------------------------------*/
1250 #include "ohci-sa1111.c"
1255 #include "ohci-ppc-of.c"
1260 #include "ohci-ps3.c"
1265 #include "ohci-sm501.c"
1270 #include "ohci-tmio.c"
1279 return -ENODEV; in ohci_hcd_mod_init()
1286 ohci_debug_root = debugfs_create_dir("ohci", usb_debug_root); in ohci_hcd_mod_init()