Lines Matching refs:ehci

19 /* this file is part of ehci-hcd.c */
48 static void ehci_handover_companion_ports(struct ehci_hcd *ehci)
54 struct usb_hcd *hcd = ehci_to_hcd(ehci);
56 if (!ehci->owned_ports)
62 port = HCS_N_PORTS(ehci->hcs_params);
64 if (test_bit(port, &ehci->owned_ports)) {
65 reg = &ehci->regs->port_status[port];
66 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
70 clear_bit(port, &ehci->owned_ports);
71 else if (test_bit(port, &ehci->companion_ports))
72 ehci_writel(ehci, status & ~PORT_PE, reg);
80 if (!ehci->owned_ports)
84 port = HCS_N_PORTS(ehci->hcs_params);
86 if (test_bit(port, &ehci->owned_ports)) {
95 reg = &ehci->regs->port_status[port];
96 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
98 ehci_writel(ehci, status | PORT_CSC, reg);
100 ehci_dbg(ehci, "failed handover port %d: %x\n",
102 ehci_writel(ehci, status & ~PORT_PE, reg);
107 ehci->owned_ports = 0;
110 static int __maybe_unused ehci_port_change(struct ehci_hcd *ehci)
112 int i = HCS_N_PORTS(ehci->hcs_params);
116 if (ehci_readl(ehci, &ehci->regs->status) & STS_PCD)
125 if (ehci_readl(ehci, &ehci->regs->port_status[i]) & PORT_CSC)
131 static __maybe_unused void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
143 if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || do_wakeup)
146 spin_lock_irqsave(&ehci->lock, flags);
149 if (ehci->has_hostpc) {
150 port = HCS_N_PORTS(ehci->hcs_params);
154 hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs
156 temp = ehci_readl(ehci, hostpc_reg);
157 ehci_writel(ehci, temp & ~HOSTPC_PHCD, hostpc_reg);
159 spin_unlock_irqrestore(&ehci->lock, flags);
161 spin_lock_irqsave(&ehci->lock, flags);
164 port = HCS_N_PORTS(ehci->hcs_params);
166 u32 __iomem *reg = &ehci->regs->port_status[port];
167 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
179 ehci_vdbg(ehci, "port %d, %08x -> %08x\n",
181 ehci_writel(ehci, t2, reg);
185 if (ehci->has_hostpc) {
186 port = HCS_N_PORTS(ehci->hcs_params);
190 hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs
192 temp = ehci_readl(ehci, hostpc_reg);
193 ehci_writel(ehci, temp | HOSTPC_PHCD, hostpc_reg);
198 if (!suspending && ehci_port_change(ehci))
199 usb_hcd_resume_root_hub(ehci_to_hcd(ehci));
201 spin_unlock_irqrestore(&ehci->lock, flags);
206 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
211 ehci_dbg(ehci, "suspend root hub\n");
213 if (time_before (jiffies, ehci->next_statechange))
215 del_timer_sync(&ehci->watchdog);
216 del_timer_sync(&ehci->iaa_watchdog);
218 spin_lock_irq (&ehci->lock);
226 if (ehci->resuming_ports) {
227 spin_unlock_irq(&ehci->lock);
228 ehci_dbg(ehci, "suspend failed because a port is resuming\n");
234 if (ehci->rh_state == EHCI_RH_RUNNING)
235 ehci_quiesce (ehci);
236 ehci->command = ehci_readl(ehci, &ehci->regs->command);
237 ehci_work(ehci);
244 ehci->bus_suspended = 0;
245 ehci->owned_ports = 0;
247 port = HCS_N_PORTS(ehci->hcs_params);
249 u32 __iomem *reg = &ehci->regs->port_status [port];
250 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
255 set_bit(port, &ehci->owned_ports);
258 set_bit(port, &ehci->bus_suspended);
275 ehci_vdbg (ehci, "port %d, %08x -> %08x\n",
277 ehci_writel(ehci, t2, reg);
282 if (changed && ehci->has_hostpc) {
283 spin_unlock_irq(&ehci->lock);
285 spin_lock_irq(&ehci->lock);
287 port = HCS_N_PORTS(ehci->hcs_params);
292 hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs
294 t3 = ehci_readl(ehci, hostpc_reg);
295 ehci_writel(ehci, t3 | HOSTPC_PHCD, hostpc_reg);
296 t3 = ehci_readl(ehci, hostpc_reg);
297 ehci_dbg(ehci, "Port %d phy low-power mode %s\n",
304 if (ehci->bus_suspended)
308 ehci_halt (ehci);
309 ehci->rh_state = EHCI_RH_SUSPENDED;
311 if (ehci->reclaim)
312 end_unlink_async(ehci);
318 ehci_writel(ehci, mask, &ehci->regs->intr_enable);
319 ehci_readl(ehci, &ehci->regs->intr_enable);
321 ehci->next_statechange = jiffies + msecs_to_jiffies(10);
322 spin_unlock_irq (&ehci->lock);
327 del_timer_sync(&ehci->watchdog);
335 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
341 if (time_before (jiffies, ehci->next_statechange))
343 spin_lock_irq (&ehci->lock);
345 spin_unlock_irq(&ehci->lock);
349 if (unlikely(ehci->debug)) {
351 ehci->debug = NULL;
362 power_okay = ehci_readl(ehci, &ehci->regs->intr_enable);
363 ehci_dbg(ehci, "resume root hub%s\n",
369 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
372 ehci_writel(ehci, 0, &ehci->regs->segment);
373 ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list);
374 ehci_writel(ehci, (u32) ehci->async->qh_dma, &ehci->regs->async_next);
377 ehci_writel(ehci, ehci->command, &ehci->regs->command);
378 ehci->rh_state = EHCI_RH_RUNNING;
382 spin_unlock_irq(&ehci->lock);
384 spin_lock_irq(&ehci->lock);
387 if (ehci->bus_suspended && ehci->has_hostpc) {
388 i = HCS_N_PORTS(ehci->hcs_params);
390 if (test_bit(i, &ehci->bus_suspended)) {
393 hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs
395 temp = ehci_readl(ehci, hostpc_reg);
396 ehci_writel(ehci, temp & ~HOSTPC_PHCD,
400 spin_unlock_irq(&ehci->lock);
402 spin_lock_irq(&ehci->lock);
406 i = HCS_N_PORTS (ehci->hcs_params);
408 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
410 if (test_bit(i, &ehci->bus_suspended) &&
415 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
420 spin_unlock_irq(&ehci->lock);
422 spin_lock_irq(&ehci->lock);
425 i = HCS_N_PORTS (ehci->hcs_params);
427 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
430 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
431 ehci_vdbg (ehci, "resumed port %d\n", i + 1);
434 (void) ehci_readl(ehci, &ehci->regs->command);
438 if (ehci->async->qh_next.qh)
440 if (ehci->periodic_sched)
443 ehci->command |= temp;
444 ehci_writel(ehci, ehci->command, &ehci->regs->command);
447 ehci->next_statechange = jiffies + msecs_to_jiffies(5);
450 ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable);
452 spin_unlock_irq (&ehci->lock);
453 ehci_handover_companion_ports(ehci);
469 static void set_owner(struct ehci_hcd *ehci, int portnum, int new_owner)
475 status_reg = &ehci->regs->port_status[portnum];
483 spin_lock_irq(&ehci->lock);
484 port_status = ehci_readl(ehci, status_reg);
492 ehci_writel(ehci, port_status, status_reg);
494 spin_unlock_irq(&ehci->lock);
503 struct ehci_hcd *ehci,
515 if (ehci_is_TDI(ehci)) {
516 ehci_dbg (ehci,
522 ehci_dbg (ehci, "port %d full speed --> companion\n",
528 ehci_writel(ehci, port_status, status_reg);
531 if (ehci->has_amcc_usb23)
532 set_ohci_hcfs(ehci, 1);
534 ehci_dbg (ehci, "port %d high speed\n", index + 1);
536 if (ehci->has_amcc_usb23)
537 set_ohci_hcfs(ehci, 0);
551 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
560 ports = HCS_N_PORTS (ehci->hcs_params);
569 status = ehci->resuming_ports;
586 spin_lock_irqsave (&ehci->lock, flags);
589 if (ehci->has_ppcd)
590 ppcd = ehci_readl(ehci, &ehci->regs->status) >> 16;
594 if (ehci->has_ppcd && !(ppcd & (1 << i)))
596 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
605 if ((temp & mask) != 0 || test_bit(i, &ehci->port_c_suspend)
606 || (ehci->reset_done[i] && time_after_eq(
607 jiffies, ehci->reset_done[i]))) {
616 spin_unlock_irqrestore (&ehci->lock, flags);
624 struct ehci_hcd *ehci,
627 int ports = HCS_N_PORTS (ehci->hcs_params);
631 desc->bPwrOn2PwrGood = 10; /* ehci 1.0, 2.3.9 says 20ms max */
643 if (HCS_PPC (ehci->hcs_params))
649 if (HCS_INDICATOR (ehci->hcs_params))
665 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
666 int ports = HCS_N_PORTS (ehci->hcs_params);
667 u32 __iomem *status_reg = &ehci->regs->port_status[
682 if (ehci->has_hostpc)
683 hostpc_reg = (u32 __iomem *)((u8 *)ehci->regs
685 spin_lock_irqsave (&ehci->lock, flags);
701 temp = ehci_readl(ehci, status_reg);
712 ehci_writel(ehci, temp & ~PORT_PE, status_reg);
715 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_PEC,
721 if (ehci->no_selective_suspend)
726 otg_start_hnp(ehci->transceiver->otg);
737 temp1 = ehci_readl(ehci, hostpc_reg);
738 ehci_writel(ehci, temp1 & ~HOSTPC_PHCD,
740 spin_unlock_irqrestore(&ehci->lock, flags);
742 spin_lock_irqsave(&ehci->lock, flags);
746 ehci_writel(ehci, temp | PORT_RESUME, status_reg);
747 ehci->reset_done[wIndex] = jiffies
751 clear_bit(wIndex, &ehci->port_c_suspend);
754 if (HCS_PPC (ehci->hcs_params))
755 ehci_writel(ehci,
760 if (ehci->has_lpm) {
765 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_CSC,
769 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_OCC,
778 ehci_readl(ehci, &ehci->regs->command); /* unblock posted write */
781 ehci_hub_descriptor (ehci, (struct usb_hub_descriptor *)
794 temp = ehci_readl(ehci, status_reg);
812 if ((temp & PORT_OC) && HCS_PPC(ehci->hcs_params)) {
813 ehci_writel(ehci,
816 temp = ehci_readl(ehci, status_reg);
824 if (!ehci->reset_done[wIndex]) {
826 ehci->reset_done[wIndex] = jiffies
829 mod_timer(&ehci_to_hcd(ehci)->rh_timer,
830 ehci->reset_done[wIndex]);
835 ehci->reset_done[wIndex])) {
836 clear_bit(wIndex, &ehci->suspended_ports);
837 set_bit(wIndex, &ehci->port_c_suspend);
838 ehci->reset_done[wIndex] = 0;
841 temp = ehci_readl(ehci, status_reg);
842 ehci_writel(ehci,
845 clear_bit(wIndex, &ehci->resuming_ports);
846 retval = handshake(ehci, status_reg,
849 ehci_err(ehci,
861 ehci->reset_done[wIndex])) {
863 ehci->reset_done [wIndex] = 0;
864 clear_bit(wIndex, &ehci->resuming_ports);
867 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET),
872 retval = handshake(ehci, status_reg,
875 ehci_err (ehci, "port %d reset error %d\n",
881 temp = check_reset_complete (ehci, wIndex, status_reg,
882 ehci_readl(ehci, status_reg));
886 ehci->reset_done[wIndex] = 0;
887 clear_bit(wIndex, &ehci->resuming_ports);
892 test_bit(wIndex, &ehci->companion_ports)) {
895 ehci_writel(ehci, temp, status_reg);
896 ehci_dbg(ehci, "port %d --> companion\n", wIndex + 1);
897 temp = ehci_readl(ehci, status_reg);
909 if (ehci->has_hostpc) {
910 temp1 = ehci_readl(ehci, hostpc_reg);
911 status |= ehci_port_speed(ehci, temp1);
913 status |= ehci_port_speed(ehci, temp);
921 } else if (test_bit(wIndex, &ehci->suspended_ports)) {
922 clear_bit(wIndex, &ehci->suspended_ports);
923 clear_bit(wIndex, &ehci->resuming_ports);
924 ehci->reset_done[wIndex] = 0;
926 set_bit(wIndex, &ehci->port_c_suspend);
935 if (test_bit(wIndex, &ehci->port_c_suspend))
941 dbg_port (ehci, "GetStatus", wIndex + 1, temp);
957 if (unlikely(ehci->debug)) {
960 if (wIndex == HCS_DEBUG_PORT(ehci->hcs_params) &&
961 (readl(&ehci->debug->control) & DBGP_ENABLED)) {
969 temp = ehci_readl(ehci, status_reg);
976 if (ehci->no_selective_suspend)
988 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
990 spin_unlock_irqrestore(&ehci->lock, flags);
992 spin_lock_irqsave(&ehci->lock, flags);
993 temp1 = ehci_readl(ehci, hostpc_reg);
994 ehci_writel(ehci, temp1 | HOSTPC_PHCD,
996 temp1 = ehci_readl(ehci, hostpc_reg);
997 ehci_dbg(ehci, "Port%d phy low pwr mode %s\n",
1001 set_bit(wIndex, &ehci->suspended_ports);
1004 if (HCS_PPC (ehci->hcs_params))
1005 ehci_writel(ehci, temp | PORT_POWER,
1016 && !ehci_is_TDI(ehci)
1018 ehci_dbg (ehci,
1023 ehci_vdbg (ehci, "port %d reset\n", wIndex + 1);
1031 ehci->reset_done [wIndex] = jiffies
1034 ehci_writel(ehci, temp, status_reg);
1046 ehci_quiesce(ehci);
1051 &ehci->regs->port_status[ports];
1053 temp = ehci_readl(ehci, sreg) & ~PORT_RWC_BITS;
1055 ehci_writel(ehci, temp | PORT_SUSPEND,
1058 ehci_halt(ehci);
1059 temp = ehci_readl(ehci, status_reg);
1061 ehci_writel(ehci, temp, status_reg);
1067 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
1076 spin_unlock_irqrestore (&ehci->lock, flags);
1083 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1085 if (ehci_is_TDI(ehci))
1087 set_owner(ehci, --portnum, PORT_OWNER);
1093 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1096 if (ehci_is_TDI(ehci))
1098 reg = &ehci->regs->port_status[portnum - 1];
1099 return ehci_readl(ehci, reg) & PORT_OWNER;