Lines Matching refs:ohci

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