Lines Matching defs:ohci
47 static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop)
48 __releases(ohci->lock)
49 __acquires(ohci->lock)
53 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
54 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
56 ohci_dbg (ohci, "resume/suspend?\n");
57 ohci->hc_control &= ~OHCI_CTRL_HCFS;
58 ohci->hc_control |= OHCI_USB_RESET;
59 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
60 (void) ohci_readl (ohci, &ohci->regs->control);
64 ohci_dbg (ohci, "needs reinit!\n");
67 if (!ohci->autostop) {
68 ohci_dbg (ohci, "already suspended\n");
72 ohci_dbg (ohci, "%s root hub\n",
76 if (!autostop && (ohci->hc_control & OHCI_SCHED_ENABLES)) {
77 ohci->hc_control &= ~OHCI_SCHED_ENABLES;
78 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
79 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
80 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrstatus);
85 ohci_dbg (ohci, "stopping schedules ...\n");
86 ohci->autostop = 0;
87 spin_unlock_irq (&ohci->lock);
89 spin_lock_irq (&ohci->lock);
91 update_done_list(ohci);
92 ohci_work(ohci);
95 ohci_writel(ohci, OHCI_INTR_SF, &ohci->regs->intrdisable);
102 if (ohci->flags & OHCI_QUIRK_GLOBAL_SUSPEND) {
103 __hc32 __iomem *portstat = ohci->regs->roothub.portstatus;
107 for (i = 0; i < ohci->num_ports; (++i, ++portstat)) {
108 temp = ohci_readl(ohci, portstat);
111 ohci_writel(ohci, RH_PS_PSS, portstat);
116 if (ohci_to_hcd(ohci)->self.root_hub->do_remote_wakeup || autostop) {
117 ohci->hc_control |= OHCI_CTRL_RWE;
119 ohci_writel(ohci, OHCI_INTR_RHSC | OHCI_INTR_RD,
120 &ohci->regs->intrdisable);
121 ohci->hc_control &= ~OHCI_CTRL_RWE;
127 ohci->hc_control &= ~OHCI_CTRL_HCFS;
128 ohci->hc_control |= OHCI_USB_SUSPEND;
129 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
130 (void) ohci_readl (ohci, &ohci->regs->control);
134 ohci->next_statechange = jiffies + msecs_to_jiffies (5);
135 ohci->autostop = 0;
136 ohci->rh_state = OHCI_RH_SUSPENDED;
152 static int ohci_rh_resume (struct ohci_hcd *ohci)
153 __releases(ohci->lock)
154 __acquires(ohci->lock)
156 struct usb_hcd *hcd = ohci_to_hcd (ohci);
159 int autostopped = ohci->autostop;
161 ohci->autostop = 0;
162 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
164 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
166 if (ohci->rh_state != OHCI_RH_RUNNING) {
167 ohci_dbg (ohci, "BIOS/SMM active, control %03x\n",
168 ohci->hc_control);
172 ohci_dbg (ohci, "duplicate resume\n");
175 } else switch (ohci->hc_control & OHCI_CTRL_HCFS) {
177 ohci->hc_control &= ~(OHCI_CTRL_HCFS|OHCI_SCHED_ENABLES);
178 ohci->hc_control |= OHCI_USB_RESUME;
179 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
180 (void) ohci_readl (ohci, &ohci->regs->control);
181 ohci_dbg (ohci, "%s root hub\n",
186 ohci_dbg(ohci, "%swakeup root hub\n",
191 ohci_dbg (ohci, "snapshot resume? reinit\n");
195 ohci_dbg (ohci, "lost power\n");
200 spin_unlock_irq (&ohci->lock);
201 status = ohci_restart (ohci);
205 spin_lock_irq (&ohci->lock);
213 spin_unlock_irq (&ohci->lock);
218 temp = ohci_readl (ohci, &ohci->regs->control);
221 ohci_err (ohci, "controller won't resume\n");
222 spin_lock_irq(&ohci->lock);
227 ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);
228 ohci_writel (ohci, 0, &ohci->regs->ed_controlcurrent);
229 ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);
230 ohci_writel (ohci, 0, &ohci->regs->ed_bulkcurrent);
231 ohci_writel (ohci, 0, &ohci->regs->ed_periodcurrent);
232 ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);
235 periodic_reinit (ohci);
238 * The following code is executed with ohci->lock held and
244 ohci_writel (ohci, OHCI_INTR_INIT, &ohci->regs->intrenable);
245 if (ohci->ed_rm_list)
246 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable);
249 ohci_writel (ohci, OHCI_USB_OPER, &ohci->regs->control);
250 (void) ohci_readl (ohci, &ohci->regs->control);
254 temp = ohci->hc_control;
257 ohci->hc_control = temp;
258 ohci_writel (ohci, temp, &ohci->regs->control);
259 (void) ohci_readl (ohci, &ohci->regs->control);
264 spin_lock_irq (&ohci->lock);
266 /* now ohci->lock is always held and irqs are always disabled */
269 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
274 if (!ohci->ed_rm_list) {
275 if (ohci->ed_controltail) {
276 ohci_writel (ohci,
277 find_head (ohci->ed_controltail)->dma,
278 &ohci->regs->ed_controlhead);
282 if (ohci->ed_bulktail) {
283 ohci_writel (ohci, find_head (ohci->ed_bulktail)->dma,
284 &ohci->regs->ed_bulkhead);
292 ohci_dbg (ohci, "restarting schedules ... %08x\n", enables);
293 ohci->hc_control |= enables;
294 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
296 ohci_writel (ohci, temp, &ohci->regs->cmdstatus);
297 (void) ohci_readl (ohci, &ohci->regs->control);
300 ohci->rh_state = OHCI_RH_RUNNING;
306 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
309 spin_lock_irq (&ohci->lock);
314 rc = ohci_rh_suspend (ohci, 0);
315 spin_unlock_irq (&ohci->lock);
318 del_timer_sync(&ohci->io_watchdog);
319 ohci->prev_frame_no = IO_WATCHDOG_OFF;
326 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
329 if (time_before (jiffies, ohci->next_statechange))
332 spin_lock_irq (&ohci->lock);
337 rc = ohci_rh_resume (ohci);
338 spin_unlock_irq (&ohci->lock);
347 static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
357 rhsc_enable = ohci_readl(ohci, &ohci->regs->intrenable) &
360 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
365 ohci_writel(ohci, rhsc_enable, &ohci->regs->intrenable);
371 if (!ohci->autostop) {
373 !device_may_wakeup(&ohci_to_hcd(ohci)
378 ohci->autostop = 1;
379 ohci->next_statechange = jiffies + HZ;
385 ohci->autostop = 0;
386 ohci->next_statechange = jiffies +
389 ohci->next_statechange)
390 && !ohci->ed_rm_list
391 && !(ohci->hc_control &
393 ohci_rh_suspend(ohci, 1);
404 if (ohci->autostop)
405 ohci_rh_resume(ohci);
407 usb_hcd_resume_root_hub(ohci_to_hcd(ohci));
410 } else if (!ohci->autostop &&
411 !ohci_to_hcd(ohci)->self.root_hub->
421 ohci_writel(ohci, rhsc_enable,
422 &ohci->regs->intrenable);
435 static inline int ohci_rh_resume(struct ohci_hcd *ohci)
443 static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
447 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC)
458 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable);
470 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
476 spin_lock_irqsave (&ohci->lock, flags);
481 if ((ohci->flags & OHCI_QUIRK_AMD756)
482 && (roothub_a (ohci) & RH_A_NDP) > MAX_ROOT_PORTS) {
483 ohci_warn (ohci, "bogus NDP, rereads as NDP=%d\n",
484 ohci_readl (ohci, &ohci->regs->roothub.a) & RH_A_NDP);
490 if (roothub_status (ohci) & (RH_HS_LPSC | RH_HS_OCIC))
494 if (ohci->num_ports > 7) {
500 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrstatus);
501 rhsc_status = ohci_readl(ohci, &ohci->regs->intrstatus) &
505 for (i = 0; i < ohci->num_ports; i++) {
506 u32 status = roothub_portstatus (ohci, i);
521 if (ohci_root_hub_state_changes(ohci, changed,
529 spin_unlock_irqrestore (&ohci->lock, flags);
539 struct ohci_hcd *ohci,
542 u32 rh = roothub_a (ohci);
549 desc->bNbrPorts = ohci->num_ports;
550 temp = 1 + (ohci->num_ports / 8);
565 rh = roothub_b (ohci);
569 if (ohci->num_ports > 7) {
582 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
590 status = ohci_readl(ohci, &ohci->regs->roothub.portstatus [port]);
595 ohci_writel(ohci, RH_PS_PRS, &ohci->regs->roothub.portstatus [port]);
620 static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port)
622 __hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port];
624 u16 now = ohci_readl(ohci, &ohci->regs->fmnumber);
638 temp = ohci_readl (ohci, portstat);
652 ohci_dbg(ohci,
661 ohci_writel (ohci, RH_PS_PRSC, portstat);
664 ohci_writel (ohci, RH_PS_PRS, portstat);
666 now = ohci_readl(ohci, &ohci->regs->fmnumber);
684 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
685 int ports = ohci->num_ports;
696 ohci_writel (ohci, RH_HS_OCIC,
697 &ohci->regs->roothub.status);
737 ohci_writel (ohci, temp,
738 &ohci->regs->roothub.portstatus [wIndex]);
739 // ohci_readl (ohci, &ohci->regs->roothub.portstatus [wIndex]);
742 ohci_hub_descriptor (ohci, (struct usb_hub_descriptor *) buf);
745 temp = roothub_status (ohci) & ~(RH_HS_CRWE | RH_HS_DRWE);
752 temp = roothub_portstatus (ohci, wIndex);
756 dbg_port(ohci, "GetStatus", wIndex, temp);
777 ohci->start_hnp(ohci);
780 ohci_writel (ohci, RH_PS_PSS,
781 &ohci->regs->roothub.portstatus [wIndex]);
784 ohci_writel (ohci, RH_PS_PPS,
785 &ohci->regs->roothub.portstatus [wIndex]);
788 retval = root_port_reset (ohci, wIndex);