Lines Matching refs:ehci

48 static void ehci_handover_companion_ports(struct ehci_hcd *ehci)  in ehci_handover_companion_ports()  argument
54 struct usb_hcd *hcd = ehci_to_hcd(ehci); in ehci_handover_companion_ports()
56 if (!ehci->owned_ports) in ehci_handover_companion_ports()
62 port = HCS_N_PORTS(ehci->hcs_params); in ehci_handover_companion_ports()
64 if (test_bit(port, &ehci->owned_ports)) { in ehci_handover_companion_ports()
65 reg = &ehci->regs->port_status[port]; in ehci_handover_companion_ports()
66 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; in ehci_handover_companion_ports()
70 clear_bit(port, &ehci->owned_ports); in ehci_handover_companion_ports()
71 else if (test_bit(port, &ehci->companion_ports)) in ehci_handover_companion_ports()
72 ehci_writel(ehci, status & ~PORT_PE, reg); in ehci_handover_companion_ports()
80 if (!ehci->owned_ports) in ehci_handover_companion_ports()
84 port = HCS_N_PORTS(ehci->hcs_params); in ehci_handover_companion_ports()
86 if (test_bit(port, &ehci->owned_ports)) { in ehci_handover_companion_ports()
95 reg = &ehci->regs->port_status[port]; in ehci_handover_companion_ports()
96 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; in ehci_handover_companion_ports()
98 ehci_writel(ehci, status | PORT_CSC, reg); in ehci_handover_companion_ports()
100 ehci_dbg(ehci, "failed handover port %d: %x\n", in ehci_handover_companion_ports()
102 ehci_writel(ehci, status & ~PORT_PE, reg); in ehci_handover_companion_ports()
107 ehci->owned_ports = 0; in ehci_handover_companion_ports()
110 static int __maybe_unused ehci_port_change(struct ehci_hcd *ehci) in ehci_port_change() argument
112 int i = HCS_N_PORTS(ehci->hcs_params); in ehci_port_change()
116 if (ehci_readl(ehci, &ehci->regs->status) & STS_PCD) in ehci_port_change()
125 if (ehci_readl(ehci, &ehci->regs->port_status[i]) & PORT_CSC) in ehci_port_change()
131 static __maybe_unused void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci, in ehci_adjust_port_wakeup_flags() argument
143 if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || do_wakeup) in ehci_adjust_port_wakeup_flags()
146 spin_lock_irqsave(&ehci->lock, flags); in ehci_adjust_port_wakeup_flags()
149 if (ehci->has_hostpc) { in ehci_adjust_port_wakeup_flags()
150 port = HCS_N_PORTS(ehci->hcs_params); in ehci_adjust_port_wakeup_flags()
154 hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs in ehci_adjust_port_wakeup_flags()
156 temp = ehci_readl(ehci, hostpc_reg); in ehci_adjust_port_wakeup_flags()
157 ehci_writel(ehci, temp & ~HOSTPC_PHCD, hostpc_reg); in ehci_adjust_port_wakeup_flags()
159 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_adjust_port_wakeup_flags()
161 spin_lock_irqsave(&ehci->lock, flags); in ehci_adjust_port_wakeup_flags()
164 port = HCS_N_PORTS(ehci->hcs_params); in ehci_adjust_port_wakeup_flags()
166 u32 __iomem *reg = &ehci->regs->port_status[port]; in ehci_adjust_port_wakeup_flags()
167 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; in ehci_adjust_port_wakeup_flags()
179 ehci_vdbg(ehci, "port %d, %08x -> %08x\n", in ehci_adjust_port_wakeup_flags()
181 ehci_writel(ehci, t2, reg); in ehci_adjust_port_wakeup_flags()
185 if (ehci->has_hostpc) { in ehci_adjust_port_wakeup_flags()
186 port = HCS_N_PORTS(ehci->hcs_params); in ehci_adjust_port_wakeup_flags()
190 hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs in ehci_adjust_port_wakeup_flags()
192 temp = ehci_readl(ehci, hostpc_reg); in ehci_adjust_port_wakeup_flags()
193 ehci_writel(ehci, temp | HOSTPC_PHCD, hostpc_reg); in ehci_adjust_port_wakeup_flags()
198 if (!suspending && ehci_port_change(ehci)) in ehci_adjust_port_wakeup_flags()
199 usb_hcd_resume_root_hub(ehci_to_hcd(ehci)); in ehci_adjust_port_wakeup_flags()
201 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_adjust_port_wakeup_flags()
206 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_bus_suspend() local
211 ehci_dbg(ehci, "suspend root hub\n"); in ehci_bus_suspend()
213 if (time_before (jiffies, ehci->next_statechange)) in ehci_bus_suspend()
215 del_timer_sync(&ehci->watchdog); in ehci_bus_suspend()
216 del_timer_sync(&ehci->iaa_watchdog); in ehci_bus_suspend()
218 spin_lock_irq (&ehci->lock); in ehci_bus_suspend()
226 if (ehci->resuming_ports) { in ehci_bus_suspend()
227 spin_unlock_irq(&ehci->lock); in ehci_bus_suspend()
228 ehci_dbg(ehci, "suspend failed because a port is resuming\n"); in ehci_bus_suspend()
234 if (ehci->rh_state == EHCI_RH_RUNNING) in ehci_bus_suspend()
235 ehci_quiesce (ehci); in ehci_bus_suspend()
236 ehci->command = ehci_readl(ehci, &ehci->regs->command); in ehci_bus_suspend()
237 ehci_work(ehci); in ehci_bus_suspend()
244 ehci->bus_suspended = 0; in ehci_bus_suspend()
245 ehci->owned_ports = 0; in ehci_bus_suspend()
247 port = HCS_N_PORTS(ehci->hcs_params); in ehci_bus_suspend()
249 u32 __iomem *reg = &ehci->regs->port_status [port]; in ehci_bus_suspend()
250 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; in ehci_bus_suspend()
255 set_bit(port, &ehci->owned_ports); in ehci_bus_suspend()
258 set_bit(port, &ehci->bus_suspended); in ehci_bus_suspend()
275 ehci_vdbg (ehci, "port %d, %08x -> %08x\n", in ehci_bus_suspend()
277 ehci_writel(ehci, t2, reg); in ehci_bus_suspend()
282 if (changed && ehci->has_hostpc) { in ehci_bus_suspend()
283 spin_unlock_irq(&ehci->lock); in ehci_bus_suspend()
285 spin_lock_irq(&ehci->lock); in ehci_bus_suspend()
287 port = HCS_N_PORTS(ehci->hcs_params); in ehci_bus_suspend()
292 hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs in ehci_bus_suspend()
294 t3 = ehci_readl(ehci, hostpc_reg); in ehci_bus_suspend()
295 ehci_writel(ehci, t3 | HOSTPC_PHCD, hostpc_reg); in ehci_bus_suspend()
296 t3 = ehci_readl(ehci, hostpc_reg); in ehci_bus_suspend()
297 ehci_dbg(ehci, "Port %d phy low-power mode %s\n", in ehci_bus_suspend()
304 if (ehci->bus_suspended) in ehci_bus_suspend()
308 ehci_halt (ehci); in ehci_bus_suspend()
309 ehci->rh_state = EHCI_RH_SUSPENDED; in ehci_bus_suspend()
311 if (ehci->reclaim) in ehci_bus_suspend()
312 end_unlink_async(ehci); in ehci_bus_suspend()
318 ehci_writel(ehci, mask, &ehci->regs->intr_enable); in ehci_bus_suspend()
319 ehci_readl(ehci, &ehci->regs->intr_enable); in ehci_bus_suspend()
321 ehci->next_statechange = jiffies + msecs_to_jiffies(10); in ehci_bus_suspend()
322 spin_unlock_irq (&ehci->lock); in ehci_bus_suspend()
327 del_timer_sync(&ehci->watchdog); in ehci_bus_suspend()
335 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_bus_resume() local
341 if (time_before (jiffies, ehci->next_statechange)) in ehci_bus_resume()
343 spin_lock_irq (&ehci->lock); in ehci_bus_resume()
345 spin_unlock_irq(&ehci->lock); in ehci_bus_resume()
349 if (unlikely(ehci->debug)) { in ehci_bus_resume()
351 ehci->debug = NULL; in ehci_bus_resume()
362 power_okay = ehci_readl(ehci, &ehci->regs->intr_enable); in ehci_bus_resume()
363 ehci_dbg(ehci, "resume root hub%s\n", in ehci_bus_resume()
369 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in ehci_bus_resume()
372 ehci_writel(ehci, 0, &ehci->regs->segment); in ehci_bus_resume()
373 ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list); in ehci_bus_resume()
374 ehci_writel(ehci, (u32) ehci->async->qh_dma, &ehci->regs->async_next); in ehci_bus_resume()
377 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_bus_resume()
378 ehci->rh_state = EHCI_RH_RUNNING; in ehci_bus_resume()
382 spin_unlock_irq(&ehci->lock); in ehci_bus_resume()
384 spin_lock_irq(&ehci->lock); in ehci_bus_resume()
387 if (ehci->bus_suspended && ehci->has_hostpc) { in ehci_bus_resume()
388 i = HCS_N_PORTS(ehci->hcs_params); in ehci_bus_resume()
390 if (test_bit(i, &ehci->bus_suspended)) { in ehci_bus_resume()
393 hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs in ehci_bus_resume()
395 temp = ehci_readl(ehci, hostpc_reg); in ehci_bus_resume()
396 ehci_writel(ehci, temp & ~HOSTPC_PHCD, in ehci_bus_resume()
400 spin_unlock_irq(&ehci->lock); in ehci_bus_resume()
402 spin_lock_irq(&ehci->lock); in ehci_bus_resume()
406 i = HCS_N_PORTS (ehci->hcs_params); in ehci_bus_resume()
408 temp = ehci_readl(ehci, &ehci->regs->port_status [i]); in ehci_bus_resume()
410 if (test_bit(i, &ehci->bus_suspended) && in ehci_bus_resume()
415 ehci_writel(ehci, temp, &ehci->regs->port_status [i]); in ehci_bus_resume()
420 spin_unlock_irq(&ehci->lock); in ehci_bus_resume()
422 spin_lock_irq(&ehci->lock); in ehci_bus_resume()
425 i = HCS_N_PORTS (ehci->hcs_params); in ehci_bus_resume()
427 temp = ehci_readl(ehci, &ehci->regs->port_status [i]); in ehci_bus_resume()
430 ehci_writel(ehci, temp, &ehci->regs->port_status [i]); in ehci_bus_resume()
431 ehci_vdbg (ehci, "resumed port %d\n", i + 1); in ehci_bus_resume()
434 (void) ehci_readl(ehci, &ehci->regs->command); in ehci_bus_resume()
438 if (ehci->async->qh_next.qh) in ehci_bus_resume()
440 if (ehci->periodic_sched) in ehci_bus_resume()
443 ehci->command |= temp; in ehci_bus_resume()
444 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_bus_resume()
447 ehci->next_statechange = jiffies + msecs_to_jiffies(5); in ehci_bus_resume()
450 ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable); in ehci_bus_resume()
452 spin_unlock_irq (&ehci->lock); in ehci_bus_resume()
453 ehci_handover_companion_ports(ehci); in ehci_bus_resume()
469 static void set_owner(struct ehci_hcd *ehci, int portnum, int new_owner) in set_owner() argument
475 status_reg = &ehci->regs->port_status[portnum]; in set_owner()
483 spin_lock_irq(&ehci->lock); in set_owner()
484 port_status = ehci_readl(ehci, status_reg); in set_owner()
492 ehci_writel(ehci, port_status, status_reg); in set_owner()
494 spin_unlock_irq(&ehci->lock); in set_owner()
503 struct ehci_hcd *ehci, in check_reset_complete() argument
515 if (ehci_is_TDI(ehci)) { in check_reset_complete()
516 ehci_dbg (ehci, in check_reset_complete()
522 ehci_dbg (ehci, "port %d full speed --> companion\n", in check_reset_complete()
528 ehci_writel(ehci, port_status, status_reg); in check_reset_complete()
531 if (ehci->has_amcc_usb23) in check_reset_complete()
532 set_ohci_hcfs(ehci, 1); in check_reset_complete()
534 ehci_dbg (ehci, "port %d high speed\n", index + 1); in check_reset_complete()
536 if (ehci->has_amcc_usb23) in check_reset_complete()
537 set_ohci_hcfs(ehci, 0); in check_reset_complete()
551 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_hub_status_data() local
560 ports = HCS_N_PORTS (ehci->hcs_params); in ehci_hub_status_data()
569 status = ehci->resuming_ports; in ehci_hub_status_data()
586 spin_lock_irqsave (&ehci->lock, flags); in ehci_hub_status_data()
589 if (ehci->has_ppcd) in ehci_hub_status_data()
590 ppcd = ehci_readl(ehci, &ehci->regs->status) >> 16; in ehci_hub_status_data()
594 if (ehci->has_ppcd && !(ppcd & (1 << i))) in ehci_hub_status_data()
596 temp = ehci_readl(ehci, &ehci->regs->port_status [i]); in ehci_hub_status_data()
605 if ((temp & mask) != 0 || test_bit(i, &ehci->port_c_suspend) in ehci_hub_status_data()
606 || (ehci->reset_done[i] && time_after_eq( in ehci_hub_status_data()
607 jiffies, ehci->reset_done[i]))) { in ehci_hub_status_data()
617 if (ehci->resuming_ports) in ehci_hub_status_data()
620 spin_unlock_irqrestore (&ehci->lock, flags); in ehci_hub_status_data()
628 struct ehci_hcd *ehci, in ehci_hub_descriptor() argument
631 int ports = HCS_N_PORTS (ehci->hcs_params); in ehci_hub_descriptor()
647 if (HCS_PPC (ehci->hcs_params)) in ehci_hub_descriptor()
653 if (HCS_INDICATOR (ehci->hcs_params)) in ehci_hub_descriptor()
669 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_hub_control() local
670 int ports = HCS_N_PORTS (ehci->hcs_params); in ehci_hub_control()
671 u32 __iomem *status_reg = &ehci->regs->port_status[ in ehci_hub_control()
686 if (ehci->has_hostpc) in ehci_hub_control()
687 hostpc_reg = (u32 __iomem *)((u8 *)ehci->regs in ehci_hub_control()
689 spin_lock_irqsave (&ehci->lock, flags); in ehci_hub_control()
705 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
716 ehci_writel(ehci, temp & ~PORT_PE, status_reg); in ehci_hub_control()
719 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_PEC, in ehci_hub_control()
725 if (ehci->no_selective_suspend) in ehci_hub_control()
730 otg_start_hnp(ehci->transceiver->otg); in ehci_hub_control()
741 temp1 = ehci_readl(ehci, hostpc_reg); in ehci_hub_control()
742 ehci_writel(ehci, temp1 & ~HOSTPC_PHCD, in ehci_hub_control()
744 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
746 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
750 ehci_writel(ehci, temp | PORT_RESUME, status_reg); in ehci_hub_control()
751 ehci->reset_done[wIndex] = jiffies in ehci_hub_control()
755 clear_bit(wIndex, &ehci->port_c_suspend); in ehci_hub_control()
758 if (HCS_PPC (ehci->hcs_params)) in ehci_hub_control()
759 ehci_writel(ehci, in ehci_hub_control()
764 if (ehci->has_lpm) { in ehci_hub_control()
769 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_CSC, in ehci_hub_control()
773 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_OCC, in ehci_hub_control()
782 ehci_readl(ehci, &ehci->regs->command); /* unblock posted write */ in ehci_hub_control()
785 ehci_hub_descriptor (ehci, (struct usb_hub_descriptor *) in ehci_hub_control()
798 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
816 if ((temp & PORT_OC) && HCS_PPC(ehci->hcs_params)) { in ehci_hub_control()
817 ehci_writel(ehci, in ehci_hub_control()
820 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
828 if (!ehci->reset_done[wIndex]) { in ehci_hub_control()
830 ehci->reset_done[wIndex] = jiffies in ehci_hub_control()
833 mod_timer(&ehci_to_hcd(ehci)->rh_timer, in ehci_hub_control()
834 ehci->reset_done[wIndex]); in ehci_hub_control()
839 ehci->reset_done[wIndex])) { in ehci_hub_control()
840 clear_bit(wIndex, &ehci->suspended_ports); in ehci_hub_control()
841 set_bit(wIndex, &ehci->port_c_suspend); in ehci_hub_control()
842 ehci->reset_done[wIndex] = 0; in ehci_hub_control()
845 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
846 ehci_writel(ehci, in ehci_hub_control()
849 clear_bit(wIndex, &ehci->resuming_ports); in ehci_hub_control()
850 retval = handshake(ehci, status_reg, in ehci_hub_control()
853 ehci_err(ehci, in ehci_hub_control()
865 ehci->reset_done[wIndex])) { in ehci_hub_control()
867 ehci->reset_done [wIndex] = 0; in ehci_hub_control()
868 clear_bit(wIndex, &ehci->resuming_ports); in ehci_hub_control()
871 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET), in ehci_hub_control()
876 retval = handshake(ehci, status_reg, in ehci_hub_control()
879 ehci_err (ehci, "port %d reset error %d\n", in ehci_hub_control()
885 temp = check_reset_complete (ehci, wIndex, status_reg, in ehci_hub_control()
886 ehci_readl(ehci, status_reg)); in ehci_hub_control()
890 ehci->reset_done[wIndex] = 0; in ehci_hub_control()
891 clear_bit(wIndex, &ehci->resuming_ports); in ehci_hub_control()
896 test_bit(wIndex, &ehci->companion_ports)) { in ehci_hub_control()
899 ehci_writel(ehci, temp, status_reg); in ehci_hub_control()
900 ehci_dbg(ehci, "port %d --> companion\n", wIndex + 1); in ehci_hub_control()
901 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
913 if (ehci->has_hostpc) { in ehci_hub_control()
914 temp1 = ehci_readl(ehci, hostpc_reg); in ehci_hub_control()
915 status |= ehci_port_speed(ehci, temp1); in ehci_hub_control()
917 status |= ehci_port_speed(ehci, temp); in ehci_hub_control()
925 } else if (test_bit(wIndex, &ehci->suspended_ports)) { in ehci_hub_control()
926 clear_bit(wIndex, &ehci->suspended_ports); in ehci_hub_control()
927 clear_bit(wIndex, &ehci->resuming_ports); in ehci_hub_control()
928 ehci->reset_done[wIndex] = 0; in ehci_hub_control()
930 set_bit(wIndex, &ehci->port_c_suspend); in ehci_hub_control()
939 if (test_bit(wIndex, &ehci->port_c_suspend)) in ehci_hub_control()
945 dbg_port (ehci, "GetStatus", wIndex + 1, temp); in ehci_hub_control()
961 if (unlikely(ehci->debug)) { in ehci_hub_control()
964 if (wIndex == HCS_DEBUG_PORT(ehci->hcs_params) && in ehci_hub_control()
965 (readl(&ehci->debug->control) & DBGP_ENABLED)) { in ehci_hub_control()
973 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
980 if (ehci->no_selective_suspend) in ehci_hub_control()
992 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); in ehci_hub_control()
994 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
996 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
997 temp1 = ehci_readl(ehci, hostpc_reg); in ehci_hub_control()
998 ehci_writel(ehci, temp1 | HOSTPC_PHCD, in ehci_hub_control()
1000 temp1 = ehci_readl(ehci, hostpc_reg); in ehci_hub_control()
1001 ehci_dbg(ehci, "Port%d phy low pwr mode %s\n", in ehci_hub_control()
1005 set_bit(wIndex, &ehci->suspended_ports); in ehci_hub_control()
1008 if (HCS_PPC (ehci->hcs_params)) in ehci_hub_control()
1009 ehci_writel(ehci, temp | PORT_POWER, in ehci_hub_control()
1020 && !ehci_is_TDI(ehci) in ehci_hub_control()
1022 ehci_dbg (ehci, in ehci_hub_control()
1027 ehci_vdbg (ehci, "port %d reset\n", wIndex + 1); in ehci_hub_control()
1035 ehci->reset_done [wIndex] = jiffies in ehci_hub_control()
1038 ehci_writel(ehci, temp, status_reg); in ehci_hub_control()
1050 ehci_quiesce(ehci); in ehci_hub_control()
1055 &ehci->regs->port_status[ports]; in ehci_hub_control()
1057 temp = ehci_readl(ehci, sreg) & ~PORT_RWC_BITS; in ehci_hub_control()
1059 ehci_writel(ehci, temp | PORT_SUSPEND, in ehci_hub_control()
1062 ehci_halt(ehci); in ehci_hub_control()
1063 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
1065 ehci_writel(ehci, temp, status_reg); in ehci_hub_control()
1071 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ in ehci_hub_control()
1080 spin_unlock_irqrestore (&ehci->lock, flags); in ehci_hub_control()
1087 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_relinquish_port() local
1089 if (ehci_is_TDI(ehci)) in ehci_relinquish_port()
1091 set_owner(ehci, --portnum, PORT_OWNER); in ehci_relinquish_port()
1097 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_port_handed_over() local
1100 if (ehci_is_TDI(ehci)) in ehci_port_handed_over()
1102 reg = &ehci->regs->port_status[portnum - 1]; in ehci_port_handed_over()
1103 return ehci_readl(ehci, reg) & PORT_OWNER; in ehci_port_handed_over()