Lines Matching refs:ehci
6 /* this file is part of ehci-hcd.c */
22 static void unlink_empty_async_suspended(struct ehci_hcd *ehci);
33 static void ehci_handover_companion_ports(struct ehci_hcd *ehci)
39 struct usb_hcd *hcd = ehci_to_hcd(ehci);
41 if (!ehci->owned_ports)
55 port = HCS_N_PORTS(ehci->hcs_params);
57 if (test_bit(port, &ehci->owned_ports)) {
58 reg = &ehci->regs->port_status[port];
59 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
61 ehci_port_power(ehci, port, true);
68 spin_lock_irq(&ehci->lock);
69 port = HCS_N_PORTS(ehci->hcs_params);
71 if (test_bit(port, &ehci->owned_ports)) {
72 reg = &ehci->regs->port_status[port];
73 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
77 clear_bit(port, &ehci->owned_ports);
78 else if (test_bit(port, &ehci->companion_ports))
79 ehci_writel(ehci, status & ~PORT_PE, reg);
81 spin_unlock_irq(&ehci->lock);
85 spin_lock_irq(&ehci->lock);
89 spin_unlock_irq(&ehci->lock);
91 if (!ehci->owned_ports)
95 spin_lock_irq(&ehci->lock);
96 port = HCS_N_PORTS(ehci->hcs_params);
98 if (test_bit(port, &ehci->owned_ports)) {
99 spin_unlock_irq(&ehci->lock);
103 spin_lock_irq(&ehci->lock);
109 reg = &ehci->regs->port_status[port];
110 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
112 ehci_writel(ehci, status | PORT_CSC, reg);
114 ehci_dbg(ehci, "failed handover port %d: %x\n",
116 ehci_writel(ehci, status & ~PORT_PE, reg);
121 ehci->owned_ports = 0;
122 spin_unlock_irq(&ehci->lock);
125 static int ehci_port_change(struct ehci_hcd *ehci)
127 int i = HCS_N_PORTS(ehci->hcs_params);
131 if (ehci_readl(ehci, &ehci->regs->status) & STS_PCD)
140 if (ehci_readl(ehci, &ehci->regs->port_status[i]) & PORT_CSC)
146 void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
157 if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || do_wakeup)
160 spin_lock_irq(&ehci->lock);
163 if (ehci->has_tdi_phy_lpm) {
164 port = HCS_N_PORTS(ehci->hcs_params);
166 u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port];
168 temp = ehci_readl(ehci, hostpc_reg);
169 ehci_writel(ehci, temp & ~HOSTPC_PHCD, hostpc_reg);
171 spin_unlock_irq(&ehci->lock);
173 spin_lock_irq(&ehci->lock);
176 port = HCS_N_PORTS(ehci->hcs_params);
178 u32 __iomem *reg = &ehci->regs->port_status[port];
179 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
191 ehci_writel(ehci, t2, reg);
195 if (ehci->has_tdi_phy_lpm) {
196 port = HCS_N_PORTS(ehci->hcs_params);
198 u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port];
200 temp = ehci_readl(ehci, hostpc_reg);
201 ehci_writel(ehci, temp | HOSTPC_PHCD, hostpc_reg);
206 if (!suspending && ehci_port_change(ehci))
207 usb_hcd_resume_root_hub(ehci_to_hcd(ehci));
209 spin_unlock_irq(&ehci->lock);
215 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
221 ehci_dbg(ehci, "suspend root hub\n");
223 if (time_before (jiffies, ehci->next_statechange))
227 ehci_quiesce(ehci);
229 spin_lock_irq (&ehci->lock);
230 if (ehci->rh_state < EHCI_RH_RUNNING)
239 if (ehci->resuming_ports) {
240 spin_unlock_irq(&ehci->lock);
241 ehci_dbg(ehci, "suspend failed because a port is resuming\n");
251 ehci->bus_suspended = 0;
252 ehci->owned_ports = 0;
255 port = HCS_N_PORTS(ehci->hcs_params);
257 u32 __iomem *reg = &ehci->regs->port_status [port];
258 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
263 set_bit(port, &ehci->owned_ports);
266 set_bit(port, &ehci->bus_suspended);
290 ehci_port_speed(ehci, t2) ==
293 ehci_writel(ehci, t2, reg);
297 spin_unlock_irq(&ehci->lock);
299 if (changed && ehci_has_fsl_susp_errata(ehci))
307 if ((changed && ehci->has_tdi_phy_lpm) || fs_idle_delay) {
315 if (changed && ehci->has_tdi_phy_lpm) {
316 spin_lock_irq(&ehci->lock);
317 port = HCS_N_PORTS(ehci->hcs_params);
319 u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port];
322 t3 = ehci_readl(ehci, hostpc_reg);
323 ehci_writel(ehci, t3 | HOSTPC_PHCD, hostpc_reg);
324 t3 = ehci_readl(ehci, hostpc_reg);
325 ehci_dbg(ehci, "Port %d phy low-power mode %s\n",
329 spin_unlock_irq(&ehci->lock);
333 if (ehci->bus_suspended)
337 ehci_halt (ehci);
339 spin_lock_irq(&ehci->lock);
340 if (ehci->enabled_hrtimer_events & BIT(EHCI_HRTIMER_POLL_DEAD))
341 ehci_handle_controller_death(ehci);
342 if (ehci->rh_state != EHCI_RH_RUNNING)
344 ehci->rh_state = EHCI_RH_SUSPENDED;
346 unlink_empty_async_suspended(ehci);
349 ehci_writel(ehci, STS_IAA, &ehci->regs->status);
352 end_iaa_cycle(ehci);
353 ehci_handle_start_intr_unlinks(ehci);
354 ehci_handle_intr_unlinks(ehci);
355 end_free_itds(ehci);
361 ehci_writel(ehci, mask, &ehci->regs->intr_enable);
362 ehci_readl(ehci, &ehci->regs->intr_enable);
365 ehci->next_statechange = jiffies + msecs_to_jiffies(10);
366 ehci->enabled_hrtimer_events = 0;
367 ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT;
368 spin_unlock_irq (&ehci->lock);
370 hrtimer_cancel(&ehci->hrtimer);
378 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
384 if (time_before (jiffies, ehci->next_statechange))
386 spin_lock_irq (&ehci->lock);
387 if (!HCD_HW_ACCESSIBLE(hcd) || ehci->shutdown)
390 if (unlikely(ehci->debug)) {
392 ehci->debug = NULL;
403 power_okay = ehci_readl(ehci, &ehci->regs->intr_enable);
404 ehci_dbg(ehci, "resume root hub%s\n",
410 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
413 ehci_writel(ehci, 0, &ehci->regs->segment);
414 ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list);
415 ehci_writel(ehci, (u32) ehci->async->qh_dma, &ehci->regs->async_next);
418 ehci->command |= CMD_RUN;
419 ehci_writel(ehci, ehci->command, &ehci->regs->command);
420 ehci->rh_state = EHCI_RH_RUNNING;
427 i = HCS_N_PORTS(ehci->hcs_params);
429 temp = ehci_readl(ehci, &ehci->regs->port_status[i]);
432 ehci_dbg(ehci, "Port status(0x%x) is wrong\n", temp);
433 spin_unlock_irq(&ehci->lock);
435 spin_lock_irq(&ehci->lock);
440 if (ehci->shutdown)
444 if (ehci->bus_suspended && ehci->has_tdi_phy_lpm) {
445 i = HCS_N_PORTS(ehci->hcs_params);
447 if (test_bit(i, &ehci->bus_suspended)) {
449 &ehci->regs->hostpc[i];
451 temp = ehci_readl(ehci, hostpc_reg);
452 ehci_writel(ehci, temp & ~HOSTPC_PHCD,
456 spin_unlock_irq(&ehci->lock);
458 spin_lock_irq(&ehci->lock);
459 if (ehci->shutdown)
464 i = HCS_N_PORTS (ehci->hcs_params);
466 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
468 if (test_bit(i, &ehci->bus_suspended) &&
473 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
481 spin_unlock_irq(&ehci->lock);
483 spin_lock_irq(&ehci->lock);
484 if (ehci->shutdown)
488 i = HCS_N_PORTS (ehci->hcs_params);
490 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
493 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
497 ehci->next_statechange = jiffies + msecs_to_jiffies(5);
498 spin_unlock_irq(&ehci->lock);
500 ehci_handover_companion_ports(ehci);
503 spin_lock_irq(&ehci->lock);
504 if (ehci->shutdown)
506 ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable);
507 (void) ehci_readl(ehci, &ehci->regs->intr_enable);
508 spin_unlock_irq(&ehci->lock);
513 spin_unlock_irq(&ehci->lock);
519 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
521 return ehci->resuming_ports;
537 static void set_owner(struct ehci_hcd *ehci, int portnum, int new_owner)
543 status_reg = &ehci->regs->port_status[portnum];
551 spin_lock_irq(&ehci->lock);
552 port_status = ehci_readl(ehci, status_reg);
560 ehci_writel(ehci, port_status, status_reg);
562 spin_unlock_irq(&ehci->lock);
571 struct ehci_hcd *ehci,
583 if (ehci_is_TDI(ehci)) {
584 ehci_dbg (ehci,
590 ehci_dbg (ehci, "port %d full speed --> companion\n",
596 ehci_writel(ehci, port_status, status_reg);
599 if (ehci->has_amcc_usb23)
600 set_ohci_hcfs(ehci, 1);
602 ehci_dbg(ehci, "port %d reset complete, port enabled\n",
605 if (ehci->has_amcc_usb23)
606 set_ohci_hcfs(ehci, 0);
620 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
629 ports = HCS_N_PORTS (ehci->hcs_params);
638 status = ehci->resuming_ports;
646 if (!ignore_oc && !ehci->spurious_oc)
655 spin_lock_irqsave (&ehci->lock, flags);
658 if (ehci->has_ppcd)
659 ppcd = ehci_readl(ehci, &ehci->regs->status) >> 16;
664 temp = ehci_readl(ehci, &ehci->regs->port_status[i]);
675 if ((temp & mask) != 0 || test_bit(i, &ehci->port_c_suspend)
676 || (ehci->reset_done[i] && time_after_eq(
677 jiffies, ehci->reset_done[i]))
678 || ehci_has_ci_pec_bug(ehci, temp)) {
688 if (ehci->resuming_ports)
691 spin_unlock_irqrestore (&ehci->lock, flags);
699 struct ehci_hcd *ehci,
702 int ports = HCS_N_PORTS (ehci->hcs_params);
706 desc->bPwrOn2PwrGood = 10; /* ehci 1.0, 2.3.9 says 20ms max */
718 if (HCS_PPC (ehci->hcs_params))
724 if (HCS_INDICATOR (ehci->hcs_params))
740 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
741 int ports = HCS_N_PORTS (ehci->hcs_params);
756 status_reg = &ehci->regs->port_status[temp];
757 hostpc_reg = &ehci->regs->hostpc[temp];
766 spin_lock_irqsave (&ehci->lock, flags);
782 temp = ehci_readl(ehci, status_reg);
794 ehci_writel(ehci, temp & ~PORT_PE, status_reg);
797 ehci_writel(ehci, temp | PORT_PEC, status_reg);
802 if (ehci->no_selective_suspend)
817 if (ehci->has_tdi_phy_lpm) {
818 temp1 = ehci_readl(ehci, hostpc_reg);
819 ehci_writel(ehci, temp1 & ~HOSTPC_PHCD,
821 spin_unlock_irqrestore(&ehci->lock, flags);
823 spin_lock_irqsave(&ehci->lock, flags);
827 ehci_writel(ehci, temp | PORT_RESUME, status_reg);
828 ehci->reset_done[wIndex] = jiffies
830 set_bit(wIndex, &ehci->resuming_ports);
834 clear_bit(wIndex, &ehci->port_c_suspend);
837 if (HCS_PPC(ehci->hcs_params)) {
838 spin_unlock_irqrestore(&ehci->lock, flags);
839 ehci_port_power(ehci, wIndex, false);
840 spin_lock_irqsave(&ehci->lock, flags);
844 ehci_writel(ehci, temp | PORT_CSC, status_reg);
847 ehci_writel(ehci, temp | PORT_OCC, status_reg);
855 ehci_readl(ehci, &ehci->regs->command); /* unblock posted write */
858 ehci_hub_descriptor (ehci, (struct usb_hub_descriptor *)
871 temp = ehci_readl(ehci, status_reg);
879 if (ehci_has_ci_pec_bug(ehci, temp)) {
881 ehci_info(ehci,
886 if ((temp & PORT_OCC) && (!ignore_oc && !ehci->spurious_oc)){
896 if (((temp & PORT_OC) || (ehci->need_oc_pp_cycle))
897 && HCS_PPC(ehci->hcs_params)) {
898 spin_unlock_irqrestore(&ehci->lock, flags);
899 ehci_port_power(ehci, wIndex, false);
900 spin_lock_irqsave(&ehci->lock, flags);
901 temp = ehci_readl(ehci, status_reg);
906 if (!ehci->reset_done[wIndex]) {
911 ehci->reset_done[wIndex] = jiffies
914 set_bit(wIndex, &ehci->resuming_ports);
916 mod_timer(&ehci_to_hcd(ehci)->rh_timer,
917 ehci->reset_done[wIndex]);
921 } else if (!time_after_eq(jiffies, ehci->reset_done[wIndex])) {
925 } else if (test_bit(wIndex, &ehci->resuming_ports)) {
926 clear_bit(wIndex, &ehci->suspended_ports);
927 set_bit(wIndex, &ehci->port_c_suspend);
928 ehci->reset_done[wIndex] = 0;
933 ehci_writel(ehci, temp, status_reg);
934 clear_bit(wIndex, &ehci->resuming_ports);
935 retval = ehci_handshake(ehci, status_reg,
938 ehci_err(ehci, "port %d resume error %d\n",
942 temp = ehci_readl(ehci, status_reg);
947 ehci->reset_done [wIndex] = 0;
950 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET),
955 retval = ehci_handshake(ehci, status_reg,
958 ehci_err (ehci, "port %d reset error %d\n",
964 temp = check_reset_complete (ehci, wIndex, status_reg,
965 ehci_readl(ehci, status_reg));
970 test_bit(wIndex, &ehci->companion_ports)) {
973 ehci_writel(ehci, temp, status_reg);
974 ehci_dbg(ehci, "port %d --> companion\n", wIndex + 1);
975 temp = ehci_readl(ehci, status_reg);
987 if (ehci->has_hostpc) {
988 temp1 = ehci_readl(ehci, hostpc_reg);
989 status |= ehci_port_speed(ehci, temp1);
991 status |= ehci_port_speed(ehci, temp);
999 } else if (test_bit(wIndex, &ehci->suspended_ports)) {
1000 clear_bit(wIndex, &ehci->suspended_ports);
1001 clear_bit(wIndex, &ehci->resuming_ports);
1002 ehci->reset_done[wIndex] = 0;
1004 set_bit(wIndex, &ehci->port_c_suspend);
1014 if (test_bit(wIndex, &ehci->port_c_suspend))
1018 dbg_port(ehci, "GetStatus", wIndex + 1, temp);
1034 if (unlikely(ehci->debug)) {
1037 if (wIndex == HCS_DEBUG_PORT(ehci->hcs_params) &&
1038 (readl(&ehci->debug->control) & DBGP_ENABLED)) {
1046 temp = ehci_readl(ehci, status_reg);
1053 if (ehci->no_selective_suspend)
1065 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
1066 if (ehci->has_tdi_phy_lpm) {
1067 spin_unlock_irqrestore(&ehci->lock, flags);
1069 spin_lock_irqsave(&ehci->lock, flags);
1070 temp1 = ehci_readl(ehci, hostpc_reg);
1071 ehci_writel(ehci, temp1 | HOSTPC_PHCD,
1073 temp1 = ehci_readl(ehci, hostpc_reg);
1074 ehci_dbg(ehci, "Port%d phy low pwr mode %s\n",
1078 if (ehci_has_fsl_susp_errata(ehci)) {
1080 spin_unlock_irqrestore(&ehci->lock, flags);
1082 spin_lock_irqsave(&ehci->lock, flags);
1084 set_bit(wIndex, &ehci->suspended_ports);
1087 if (HCS_PPC(ehci->hcs_params)) {
1088 spin_unlock_irqrestore(&ehci->lock, flags);
1089 ehci_port_power(ehci, wIndex, true);
1090 spin_lock_irqsave(&ehci->lock, flags);
1101 && !ehci_is_TDI(ehci)
1103 ehci_dbg (ehci,
1115 ehci->reset_done [wIndex] = jiffies
1122 if (ehci_has_fsl_hs_errata(ehci))
1125 ehci_writel(ehci, temp, status_reg);
1137 spin_unlock_irqrestore(&ehci->lock, flags);
1140 spin_lock_irqsave(&ehci->lock, flags);
1146 spin_unlock_irqrestore(&ehci->lock, flags);
1147 ehci_quiesce(ehci);
1148 spin_lock_irqsave(&ehci->lock, flags);
1153 &ehci->regs->port_status[ports];
1155 temp = ehci_readl(ehci, sreg) & ~PORT_RWC_BITS;
1157 ehci_writel(ehci, temp | PORT_SUSPEND,
1161 spin_unlock_irqrestore(&ehci->lock, flags);
1162 ehci_halt(ehci);
1163 spin_lock_irqsave(&ehci->lock, flags);
1165 temp = ehci_readl(ehci, status_reg);
1167 ehci_writel(ehci, temp, status_reg);
1173 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
1182 spin_unlock_irqrestore (&ehci->lock, flags);
1189 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1191 if (ehci_is_TDI(ehci))
1193 set_owner(ehci, --portnum, PORT_OWNER);
1198 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1201 if (ehci_is_TDI(ehci))
1203 reg = &ehci->regs->port_status[portnum - 1];
1204 return ehci_readl(ehci, reg) & PORT_OWNER;
1207 static int ehci_port_power(struct ehci_hcd *ehci, int portnum, bool enable)
1209 struct usb_hcd *hcd = ehci_to_hcd(ehci);
1210 u32 __iomem *status_reg = &ehci->regs->port_status[portnum];
1211 u32 temp = ehci_readl(ehci, status_reg) & ~PORT_RWC_BITS;
1214 ehci_writel(ehci, temp | PORT_POWER, status_reg);
1216 ehci_writel(ehci, temp & ~PORT_POWER, status_reg);