Lines Matching refs:ohci
46 static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop) in ohci_rh_suspend() argument
47 __releases(ohci->lock) in ohci_rh_suspend()
48 __acquires(ohci->lock) in ohci_rh_suspend()
52 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); in ohci_rh_suspend()
53 switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_rh_suspend()
55 ohci_dbg (ohci, "resume/suspend?\n"); in ohci_rh_suspend()
56 ohci->hc_control &= ~OHCI_CTRL_HCFS; in ohci_rh_suspend()
57 ohci->hc_control |= OHCI_USB_RESET; in ohci_rh_suspend()
58 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_rh_suspend()
59 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_suspend()
63 ohci_dbg (ohci, "needs reinit!\n"); in ohci_rh_suspend()
66 if (!ohci->autostop) { in ohci_rh_suspend()
67 ohci_dbg (ohci, "already suspended\n"); in ohci_rh_suspend()
71 ohci_dbg (ohci, "%s root hub\n", in ohci_rh_suspend()
75 if (!autostop && (ohci->hc_control & OHCI_SCHED_ENABLES)) { in ohci_rh_suspend()
76 ohci->hc_control &= ~OHCI_SCHED_ENABLES; in ohci_rh_suspend()
77 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_rh_suspend()
78 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); in ohci_rh_suspend()
79 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrstatus); in ohci_rh_suspend()
84 ohci_dbg (ohci, "stopping schedules ...\n"); in ohci_rh_suspend()
85 ohci->autostop = 0; in ohci_rh_suspend()
86 spin_unlock_irq (&ohci->lock); in ohci_rh_suspend()
88 spin_lock_irq (&ohci->lock); in ohci_rh_suspend()
90 update_done_list(ohci); in ohci_rh_suspend()
91 ohci_work(ohci); in ohci_rh_suspend()
98 if (ohci->flags & OHCI_QUIRK_GLOBAL_SUSPEND) { in ohci_rh_suspend()
99 __hc32 __iomem *portstat = ohci->regs->roothub.portstatus; in ohci_rh_suspend()
103 for (i = 0; i < ohci->num_ports; (++i, ++portstat)) { in ohci_rh_suspend()
104 temp = ohci_readl(ohci, portstat); in ohci_rh_suspend()
107 ohci_writel(ohci, RH_PS_PSS, portstat); in ohci_rh_suspend()
112 if (ohci_to_hcd(ohci)->self.root_hub->do_remote_wakeup || autostop) { in ohci_rh_suspend()
113 ohci->hc_control |= OHCI_CTRL_RWE; in ohci_rh_suspend()
115 ohci_writel(ohci, OHCI_INTR_RHSC | OHCI_INTR_RD, in ohci_rh_suspend()
116 &ohci->regs->intrdisable); in ohci_rh_suspend()
117 ohci->hc_control &= ~OHCI_CTRL_RWE; in ohci_rh_suspend()
123 ohci->hc_control &= ~OHCI_CTRL_HCFS; in ohci_rh_suspend()
124 ohci->hc_control |= OHCI_USB_SUSPEND; in ohci_rh_suspend()
125 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_rh_suspend()
126 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_suspend()
130 ohci->next_statechange = jiffies + msecs_to_jiffies (5); in ohci_rh_suspend()
131 ohci->autostop = 0; in ohci_rh_suspend()
132 ohci->rh_state = OHCI_RH_SUSPENDED; in ohci_rh_suspend()
148 static int ohci_rh_resume (struct ohci_hcd *ohci) in ohci_rh_resume() argument
149 __releases(ohci->lock) in ohci_rh_resume()
150 __acquires(ohci->lock) in ohci_rh_resume()
152 struct usb_hcd *hcd = ohci_to_hcd (ohci); in ohci_rh_resume()
155 int autostopped = ohci->autostop; in ohci_rh_resume()
157 ohci->autostop = 0; in ohci_rh_resume()
158 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
160 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { in ohci_rh_resume()
162 if (ohci->rh_state != OHCI_RH_RUNNING) { in ohci_rh_resume()
163 ohci_dbg (ohci, "BIOS/SMM active, control %03x\n", in ohci_rh_resume()
164 ohci->hc_control); in ohci_rh_resume()
168 ohci_dbg (ohci, "duplicate resume\n"); in ohci_rh_resume()
171 } else switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_rh_resume()
173 ohci->hc_control &= ~(OHCI_CTRL_HCFS|OHCI_SCHED_ENABLES); in ohci_rh_resume()
174 ohci->hc_control |= OHCI_USB_RESUME; in ohci_rh_resume()
175 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_rh_resume()
176 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
177 ohci_dbg (ohci, "%s root hub\n", in ohci_rh_resume()
182 ohci_dbg(ohci, "%swakeup root hub\n", in ohci_rh_resume()
187 ohci_dbg (ohci, "snapshot resume? reinit\n"); in ohci_rh_resume()
191 ohci_dbg (ohci, "lost power\n"); in ohci_rh_resume()
196 spin_unlock_irq (&ohci->lock); in ohci_rh_resume()
197 status = ohci_restart (ohci); in ohci_rh_resume()
201 spin_lock_irq (&ohci->lock); in ohci_rh_resume()
209 spin_unlock_irq (&ohci->lock); in ohci_rh_resume()
214 temp = ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
217 ohci_err (ohci, "controller won't resume\n"); in ohci_rh_resume()
218 spin_lock_irq(&ohci->lock); in ohci_rh_resume()
223 ohci_writel (ohci, 0, &ohci->regs->ed_controlhead); in ohci_rh_resume()
224 ohci_writel (ohci, 0, &ohci->regs->ed_controlcurrent); in ohci_rh_resume()
225 ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead); in ohci_rh_resume()
226 ohci_writel (ohci, 0, &ohci->regs->ed_bulkcurrent); in ohci_rh_resume()
227 ohci_writel (ohci, 0, &ohci->regs->ed_periodcurrent); in ohci_rh_resume()
228 ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca); in ohci_rh_resume()
231 periodic_reinit (ohci); in ohci_rh_resume()
240 ohci_writel (ohci, OHCI_INTR_INIT, &ohci->regs->intrenable); in ohci_rh_resume()
241 if (ohci->ed_rm_list) in ohci_rh_resume()
242 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable); in ohci_rh_resume()
245 ohci_writel (ohci, OHCI_USB_OPER, &ohci->regs->control); in ohci_rh_resume()
246 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
250 temp = ohci->hc_control; in ohci_rh_resume()
253 ohci->hc_control = temp; in ohci_rh_resume()
254 ohci_writel (ohci, temp, &ohci->regs->control); in ohci_rh_resume()
255 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
260 spin_lock_irq (&ohci->lock); in ohci_rh_resume()
265 ohci->next_statechange = jiffies + STATECHANGE_DELAY; in ohci_rh_resume()
270 if (!ohci->ed_rm_list) { in ohci_rh_resume()
271 if (ohci->ed_controltail) { in ohci_rh_resume()
272 ohci_writel (ohci, in ohci_rh_resume()
273 find_head (ohci->ed_controltail)->dma, in ohci_rh_resume()
274 &ohci->regs->ed_controlhead); in ohci_rh_resume()
278 if (ohci->ed_bulktail) { in ohci_rh_resume()
279 ohci_writel (ohci, find_head (ohci->ed_bulktail)->dma, in ohci_rh_resume()
280 &ohci->regs->ed_bulkhead); in ohci_rh_resume()
288 ohci_dbg (ohci, "restarting schedules ... %08x\n", enables); in ohci_rh_resume()
289 ohci->hc_control |= enables; in ohci_rh_resume()
290 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in ohci_rh_resume()
292 ohci_writel (ohci, temp, &ohci->regs->cmdstatus); in ohci_rh_resume()
293 (void) ohci_readl (ohci, &ohci->regs->control); in ohci_rh_resume()
296 ohci->rh_state = OHCI_RH_RUNNING; in ohci_rh_resume()
302 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_bus_suspend() local
305 spin_lock_irq (&ohci->lock); in ohci_bus_suspend()
310 rc = ohci_rh_suspend (ohci, 0); in ohci_bus_suspend()
311 spin_unlock_irq (&ohci->lock); in ohci_bus_suspend()
314 del_timer_sync(&ohci->io_watchdog); in ohci_bus_suspend()
320 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_bus_resume() local
323 if (time_before (jiffies, ohci->next_statechange)) in ohci_bus_resume()
326 spin_lock_irq (&ohci->lock); in ohci_bus_resume()
331 rc = ohci_rh_resume (ohci); in ohci_bus_resume()
332 spin_unlock_irq (&ohci->lock); in ohci_bus_resume()
341 static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, in ohci_root_hub_state_changes() argument
351 rhsc_enable = ohci_readl(ohci, &ohci->regs->intrenable) & in ohci_root_hub_state_changes()
354 switch (ohci->hc_control & OHCI_CTRL_HCFS) { in ohci_root_hub_state_changes()
359 ohci_writel(ohci, rhsc_enable, &ohci->regs->intrenable); in ohci_root_hub_state_changes()
365 if (!ohci->autostop) { in ohci_root_hub_state_changes()
367 !device_may_wakeup(&ohci_to_hcd(ohci) in ohci_root_hub_state_changes()
372 ohci->autostop = 1; in ohci_root_hub_state_changes()
373 ohci->next_statechange = jiffies + HZ; in ohci_root_hub_state_changes()
379 ohci->autostop = 0; in ohci_root_hub_state_changes()
380 ohci->next_statechange = jiffies + in ohci_root_hub_state_changes()
383 ohci->next_statechange) in ohci_root_hub_state_changes()
384 && !ohci->ed_rm_list in ohci_root_hub_state_changes()
385 && !(ohci->hc_control & in ohci_root_hub_state_changes()
387 ohci_rh_suspend(ohci, 1); in ohci_root_hub_state_changes()
398 if (ohci->autostop) in ohci_root_hub_state_changes()
399 ohci_rh_resume(ohci); in ohci_root_hub_state_changes()
401 usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); in ohci_root_hub_state_changes()
404 } else if (!ohci->autostop && in ohci_root_hub_state_changes()
405 !ohci_to_hcd(ohci)->self.root_hub-> in ohci_root_hub_state_changes()
415 ohci_writel(ohci, rhsc_enable, in ohci_root_hub_state_changes()
416 &ohci->regs->intrenable); in ohci_root_hub_state_changes()
429 static inline int ohci_rh_resume(struct ohci_hcd *ohci) in ohci_rh_resume() argument
437 static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, in ohci_root_hub_state_changes() argument
441 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) in ohci_root_hub_state_changes()
452 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); in ohci_root_hub_state_changes()
464 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_hub_status_data() local
470 spin_lock_irqsave (&ohci->lock, flags); in ohci_hub_status_data()
475 if ((ohci->flags & OHCI_QUIRK_AMD756) in ohci_hub_status_data()
476 && (roothub_a (ohci) & RH_A_NDP) > MAX_ROOT_PORTS) { in ohci_hub_status_data()
477 ohci_warn (ohci, "bogus NDP, rereads as NDP=%d\n", in ohci_hub_status_data()
478 ohci_readl (ohci, &ohci->regs->roothub.a) & RH_A_NDP); in ohci_hub_status_data()
484 if (roothub_status (ohci) & (RH_HS_LPSC | RH_HS_OCIC)) in ohci_hub_status_data()
488 if (ohci->num_ports > 7) { in ohci_hub_status_data()
494 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrstatus); in ohci_hub_status_data()
495 rhsc_status = ohci_readl(ohci, &ohci->regs->intrstatus) & in ohci_hub_status_data()
499 for (i = 0; i < ohci->num_ports; i++) { in ohci_hub_status_data()
500 u32 status = roothub_portstatus (ohci, i); in ohci_hub_status_data()
515 if (ohci_root_hub_state_changes(ohci, changed, in ohci_hub_status_data()
523 spin_unlock_irqrestore (&ohci->lock, flags); in ohci_hub_status_data()
533 struct ohci_hcd *ohci, in ohci_hub_descriptor() argument
536 u32 rh = roothub_a (ohci); in ohci_hub_descriptor()
543 desc->bNbrPorts = ohci->num_ports; in ohci_hub_descriptor()
544 temp = 1 + (ohci->num_ports / 8); in ohci_hub_descriptor()
559 rh = roothub_b (ohci); in ohci_hub_descriptor()
563 if (ohci->num_ports > 7) { in ohci_hub_descriptor()
576 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_start_port_reset() local
584 status = ohci_readl(ohci, &ohci->regs->roothub.portstatus [port]); in ohci_start_port_reset()
589 ohci_writel(ohci, RH_PS_PRS, &ohci->regs->roothub.portstatus [port]); in ohci_start_port_reset()
614 static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) in root_port_reset() argument
616 __hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port]; in root_port_reset()
618 u16 now = ohci_readl(ohci, &ohci->regs->fmnumber); in root_port_reset()
632 temp = ohci_readl (ohci, portstat); in root_port_reset()
646 ohci_dbg(ohci, in root_port_reset()
655 ohci_writel (ohci, RH_PS_PRSC, portstat); in root_port_reset()
658 ohci_writel (ohci, RH_PS_PRS, portstat); in root_port_reset()
660 now = ohci_readl(ohci, &ohci->regs->fmnumber); in root_port_reset()
678 struct ohci_hcd *ohci = hcd_to_ohci (hcd); in ohci_hub_control() local
679 int ports = ohci->num_ports; in ohci_hub_control()
690 ohci_writel (ohci, RH_HS_OCIC, in ohci_hub_control()
691 &ohci->regs->roothub.status); in ohci_hub_control()
731 ohci_writel (ohci, temp, in ohci_hub_control()
732 &ohci->regs->roothub.portstatus [wIndex]); in ohci_hub_control()
736 ohci_hub_descriptor (ohci, (struct usb_hub_descriptor *) buf); in ohci_hub_control()
739 temp = roothub_status (ohci) & ~(RH_HS_CRWE | RH_HS_DRWE); in ohci_hub_control()
746 temp = roothub_portstatus (ohci, wIndex); in ohci_hub_control()
750 dbg_port(ohci, "GetStatus", wIndex, temp); in ohci_hub_control()
771 ohci->start_hnp(ohci); in ohci_hub_control()
774 ohci_writel (ohci, RH_PS_PSS, in ohci_hub_control()
775 &ohci->regs->roothub.portstatus [wIndex]); in ohci_hub_control()
778 ohci_writel (ohci, RH_PS_PPS, in ohci_hub_control()
779 &ohci->regs->roothub.portstatus [wIndex]); in ohci_hub_control()
782 retval = root_port_reset (ohci, wIndex); in ohci_hub_control()