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()
99 if (ohci->flags & OHCI_QUIRK_GLOBAL_SUSPEND) { in ohci_rh_suspend()
100 __hc32 __iomem *portstat = ohci->regs->roothub.portstatus; in ohci_rh_suspend()
104 for (i = 0; i < ohci->num_ports; (++i, ++portstat)) { in ohci_rh_suspend()
105 temp = ohci_readl(ohci, portstat); in ohci_rh_suspend()
108 ohci_writel(ohci, RH_PS_PSS, portstat); in ohci_rh_suspend()
113 if (ohci_to_hcd(ohci)->self.root_hub->do_remote_wakeup || autostop) { in ohci_rh_suspend()
114 ohci->hc_control |= OHCI_CTRL_RWE; in ohci_rh_suspend()
116 ohci_writel(ohci, OHCI_INTR_RHSC | OHCI_INTR_RD, in ohci_rh_suspend()
117 &ohci->regs->intrdisable); in ohci_rh_suspend()
118 ohci->hc_control &= ~OHCI_CTRL_RWE; in ohci_rh_suspend()
124 ohci->hc_control &= ~OHCI_CTRL_HCFS; in ohci_rh_suspend()
125 ohci->hc_control |= OHCI_USB_SUSPEND; in ohci_rh_suspend()
126 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_rh_suspend()
127 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_suspend()
131 ohci->next_statechange = jiffies + msecs_to_jiffies (5); in ohci_rh_suspend()
132 ohci->autostop = 0; in ohci_rh_suspend()
133 ohci->rh_state = OHCI_RH_SUSPENDED; in ohci_rh_suspend()
149 static int ohci_rh_resume (struct ohci_hcd *ohci) in ohci_rh_resume() argument
150 __releases(ohci->lock) in ohci_rh_resume()
151 __acquires(ohci->lock) in ohci_rh_resume()
153 struct usb_hcd *hcd = ohci_to_hcd (ohci); in ohci_rh_resume()
156 int autostopped = ohci->autostop; in ohci_rh_resume()
158 ohci->autostop = 0; in ohci_rh_resume()
159 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
161 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { in ohci_rh_resume()
163 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_rh_resume()
164 ohci_dbg (ohci, "BIOS/SMM active, control %03x\n", in ohci_rh_resume()
165 ohci->hc_control); in ohci_rh_resume()
169 ohci_dbg (ohci, "duplicate resume\n"); in ohci_rh_resume()
172 } else switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_rh_resume()
174 ohci->hc_control &= ~(OHCI_CTRL_HCFS|OHCI_SCHED_ENABLES); in ohci_rh_resume()
175 ohci->hc_control |= OHCI_USB_RESUME; in ohci_rh_resume()
176 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_rh_resume()
177 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
178 ohci_dbg (ohci, "%s root hub\n", in ohci_rh_resume()
183 ohci_dbg(ohci, "%swakeup root hub\n", in ohci_rh_resume()
188 ohci_dbg (ohci, "snapshot resume? reinit\n"); in ohci_rh_resume()
192 ohci_dbg (ohci, "lost power\n"); in ohci_rh_resume()
197 spin_unlock_irq (&ohci->lock); in ohci_rh_resume()
198 status = ohci_restart (ohci); in ohci_rh_resume()
202 spin_lock_irq (&ohci->lock); in ohci_rh_resume()
210 spin_unlock_irq (&ohci->lock); in ohci_rh_resume()
215 temp = ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
218 ohci_err (ohci, "controller won't resume\n"); in ohci_rh_resume()
219 spin_lock_irq(&ohci->lock); in ohci_rh_resume()
224 ohci_writel (ohci, 0, &ohci->regs->ed_controlhead); in ohci_rh_resume()
225 ohci_writel (ohci, 0, &ohci->regs->ed_controlcurrent); in ohci_rh_resume()
226 ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead); in ohci_rh_resume()
227 ohci_writel (ohci, 0, &ohci->regs->ed_bulkcurrent); in ohci_rh_resume()
228 ohci_writel (ohci, 0, &ohci->regs->ed_periodcurrent); in ohci_rh_resume()
229 ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca); in ohci_rh_resume()
232 periodic_reinit (ohci); in ohci_rh_resume()
241 ohci_writel (ohci, OHCI_INTR_INIT, &ohci->regs->intrenable); in ohci_rh_resume()
242 if (ohci->ed_rm_list) in ohci_rh_resume()
243 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable); in ohci_rh_resume()
246 ohci_writel (ohci, OHCI_USB_OPER, &ohci->regs->control); in ohci_rh_resume()
247 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
251 temp = ohci->hc_control; in ohci_rh_resume()
254 ohci->hc_control = temp; in ohci_rh_resume()
255 ohci_writel (ohci, temp, &ohci->regs->control); in ohci_rh_resume()
256 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
261 spin_lock_irq (&ohci->lock); in ohci_rh_resume()
266 ohci->next_statechange = jiffies + STATECHANGE_DELAY; in ohci_rh_resume()
271 if (!ohci->ed_rm_list) { in ohci_rh_resume()
272 if (ohci->ed_controltail) { in ohci_rh_resume()
273 ohci_writel (ohci, in ohci_rh_resume()
274 find_head (ohci->ed_controltail)->dma, in ohci_rh_resume()
275 &ohci->regs->ed_controlhead); in ohci_rh_resume()
279 if (ohci->ed_bulktail) { in ohci_rh_resume()
280 ohci_writel (ohci, find_head (ohci->ed_bulktail)->dma, in ohci_rh_resume()
281 &ohci->regs->ed_bulkhead); in ohci_rh_resume()
289 ohci_dbg (ohci, "restarting schedules ... %08x\n", enables); in ohci_rh_resume()
290 ohci->hc_control |= enables; in ohci_rh_resume()
291 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_rh_resume()
293 ohci_writel (ohci, temp, &ohci->regs->cmdstatus); in ohci_rh_resume()
294 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
297 ohci->rh_state = OHCI_RH_RUNNING; in ohci_rh_resume()
303 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_bus_suspend() local
306 spin_lock_irq (&ohci->lock); in ohci_bus_suspend()
311 rc = ohci_rh_suspend (ohci, 0); in ohci_bus_suspend()
312 spin_unlock_irq (&ohci->lock); in ohci_bus_suspend()
315 del_timer_sync(&ohci->io_watchdog); in ohci_bus_suspend()
316 ohci->prev_frame_no = IO_WATCHDOG_OFF; in ohci_bus_suspend()
323 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_bus_resume() local
326 if (time_before (jiffies, ohci->next_statechange)) in ohci_bus_resume()
329 spin_lock_irq (&ohci->lock); in ohci_bus_resume()
334 rc = ohci_rh_resume (ohci); in ohci_bus_resume()
335 spin_unlock_irq (&ohci->lock); in ohci_bus_resume()
344 static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, in ohci_root_hub_state_changes() argument
354 rhsc_enable = ohci_readl(ohci, &ohci->regs->intrenable) & in ohci_root_hub_state_changes()
357 switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_root_hub_state_changes()
362 ohci_writel(ohci, rhsc_enable, &ohci->regs->intrenable); in ohci_root_hub_state_changes()
368 if (!ohci->autostop) { in ohci_root_hub_state_changes()
370 !device_may_wakeup(&ohci_to_hcd(ohci) in ohci_root_hub_state_changes()
375 ohci->autostop = 1; in ohci_root_hub_state_changes()
376 ohci->next_statechange = jiffies + HZ; in ohci_root_hub_state_changes()
382 ohci->autostop = 0; in ohci_root_hub_state_changes()
383 ohci->next_statechange = jiffies + in ohci_root_hub_state_changes()
386 ohci->next_statechange) in ohci_root_hub_state_changes()
387 && !ohci->ed_rm_list in ohci_root_hub_state_changes()
388 && !(ohci->hc_control & in ohci_root_hub_state_changes()
390 ohci_rh_suspend(ohci, 1); in ohci_root_hub_state_changes()
401 if (ohci->autostop) in ohci_root_hub_state_changes()
402 ohci_rh_resume(ohci); in ohci_root_hub_state_changes()
404 usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); in ohci_root_hub_state_changes()
407 } else if (!ohci->autostop && in ohci_root_hub_state_changes()
408 !ohci_to_hcd(ohci)->self.root_hub-> in ohci_root_hub_state_changes()
418 ohci_writel(ohci, rhsc_enable, in ohci_root_hub_state_changes()
419 &ohci->regs->intrenable); in ohci_root_hub_state_changes()
432 static inline int ohci_rh_resume(struct ohci_hcd *ohci) in ohci_rh_resume() argument
440 static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, in ohci_root_hub_state_changes() argument
444 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) in ohci_root_hub_state_changes()
455 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); in ohci_root_hub_state_changes()
467 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_hub_status_data() local
473 spin_lock_irqsave (&ohci->lock, flags); in ohci_hub_status_data()
478 if ((ohci->flags & OHCI_QUIRK_AMD756) in ohci_hub_status_data()
479 && (roothub_a (ohci) & RH_A_NDP) > MAX_ROOT_PORTS) { in ohci_hub_status_data()
480 ohci_warn (ohci, "bogus NDP, rereads as NDP=%d\n", in ohci_hub_status_data()
481 ohci_readl (ohci, &ohci->regs->roothub.a) & RH_A_NDP); in ohci_hub_status_data()
487 if (roothub_status (ohci) & (RH_HS_LPSC | RH_HS_OCIC)) in ohci_hub_status_data()
491 if (ohci->num_ports > 7) { in ohci_hub_status_data()
497 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrstatus); in ohci_hub_status_data()
498 rhsc_status = ohci_readl(ohci, &ohci->regs->intrstatus) & in ohci_hub_status_data()
502 for (i = 0; i < ohci->num_ports; i++) { in ohci_hub_status_data()
503 u32 status = roothub_portstatus (ohci, i); in ohci_hub_status_data()
518 if (ohci_root_hub_state_changes(ohci, changed, in ohci_hub_status_data()
526 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_hub_status_data()
536 struct ohci_hcd *ohci, in ohci_hub_descriptor() argument
539 u32 rh = roothub_a (ohci); in ohci_hub_descriptor()
546 desc->bNbrPorts = ohci->num_ports; in ohci_hub_descriptor()
547 temp = 1 + (ohci->num_ports / 8); in ohci_hub_descriptor()
562 rh = roothub_b (ohci); in ohci_hub_descriptor()
566 if (ohci->num_ports > 7) { in ohci_hub_descriptor()
579 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_start_port_reset() local
587 status = ohci_readl(ohci, &ohci->regs->roothub.portstatus [port]); in ohci_start_port_reset()
592 ohci_writel(ohci, RH_PS_PRS, &ohci->regs->roothub.portstatus [port]); in ohci_start_port_reset()
617 static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) in root_port_reset() argument
619 __hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port]; in root_port_reset()
621 u16 now = ohci_readl(ohci, &ohci->regs->fmnumber); in root_port_reset()
635 temp = ohci_readl (ohci, portstat); in root_port_reset()
649 ohci_dbg(ohci, in root_port_reset()
658 ohci_writel (ohci, RH_PS_PRSC, portstat); in root_port_reset()
661 ohci_writel (ohci, RH_PS_PRS, portstat); in root_port_reset()
663 now = ohci_readl(ohci, &ohci->regs->fmnumber); in root_port_reset()
681 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_hub_control() local
682 int ports = ohci->num_ports; in ohci_hub_control()
693 ohci_writel (ohci, RH_HS_OCIC, in ohci_hub_control()
694 &ohci->regs->roothub.status); in ohci_hub_control()
734 ohci_writel (ohci, temp, in ohci_hub_control()
735 &ohci->regs->roothub.portstatus [wIndex]); in ohci_hub_control()
739 ohci_hub_descriptor (ohci, (struct usb_hub_descriptor *) buf); in ohci_hub_control()
742 temp = roothub_status (ohci) & ~(RH_HS_CRWE | RH_HS_DRWE); in ohci_hub_control()
749 temp = roothub_portstatus (ohci, wIndex); in ohci_hub_control()
753 dbg_port(ohci, "GetStatus", wIndex, temp); in ohci_hub_control()
774 ohci->start_hnp(ohci); in ohci_hub_control()
777 ohci_writel (ohci, RH_PS_PSS, in ohci_hub_control()
778 &ohci->regs->roothub.portstatus [wIndex]); in ohci_hub_control()
781 ohci_writel (ohci, RH_PS_PPS, in ohci_hub_control()
782 &ohci->regs->roothub.portstatus [wIndex]); in ohci_hub_control()
785 retval = root_port_reset (ohci, wIndex); in ohci_hub_control()