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;
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]))) {
687 if (ehci->resuming_ports)
690 spin_unlock_irqrestore (&ehci->lock, flags);
698 struct ehci_hcd *ehci,
701 int ports = HCS_N_PORTS (ehci->hcs_params);
705 desc->bPwrOn2PwrGood = 10; /* ehci 1.0, 2.3.9 says 20ms max */
717 if (HCS_PPC (ehci->hcs_params))
723 if (HCS_INDICATOR (ehci->hcs_params))
806 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
813 ehci_err(ehci, "No device attached to the RootHub\n");
843 ehci_err(ehci, "%s SETUP stage timed out on ep0\n", __func__);
858 ehci_err(ehci, "%s IN stage timed out on ep0\n", __func__);
878 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
879 int ports = HCS_N_PORTS (ehci->hcs_params);
893 status_reg = &ehci->regs->port_status[temp];
894 hostpc_reg = &ehci->regs->hostpc[temp];
903 spin_lock_irqsave (&ehci->lock, flags);
919 temp = ehci_readl(ehci, status_reg);
931 ehci_writel(ehci, temp & ~PORT_PE, status_reg);
934 ehci_writel(ehci, temp | PORT_PEC, status_reg);
939 if (ehci->no_selective_suspend)
954 if (ehci->has_tdi_phy_lpm) {
955 temp1 = ehci_readl(ehci, hostpc_reg);
956 ehci_writel(ehci, temp1 & ~HOSTPC_PHCD,
958 spin_unlock_irqrestore(&ehci->lock, flags);
960 spin_lock_irqsave(&ehci->lock, flags);
964 ehci_writel(ehci, temp | PORT_RESUME, status_reg);
965 ehci->reset_done[wIndex] = jiffies
967 set_bit(wIndex, &ehci->resuming_ports);
971 clear_bit(wIndex, &ehci->port_c_suspend);
974 if (HCS_PPC(ehci->hcs_params)) {
975 spin_unlock_irqrestore(&ehci->lock, flags);
976 ehci_port_power(ehci, wIndex, false);
977 spin_lock_irqsave(&ehci->lock, flags);
981 ehci_writel(ehci, temp | PORT_CSC, status_reg);
984 ehci_writel(ehci, temp | PORT_OCC, status_reg);
992 ehci_readl(ehci, &ehci->regs->command); /* unblock posted write */
995 ehci_hub_descriptor (ehci, (struct usb_hub_descriptor *)
1008 temp = ehci_readl(ehci, status_reg);
1026 if (((temp & PORT_OC) || (ehci->need_oc_pp_cycle))
1027 && HCS_PPC(ehci->hcs_params)) {
1028 spin_unlock_irqrestore(&ehci->lock, flags);
1029 ehci_port_power(ehci, wIndex, false);
1030 spin_lock_irqsave(&ehci->lock, flags);
1031 temp = ehci_readl(ehci, status_reg);
1036 if (!ehci->reset_done[wIndex]) {
1041 ehci->reset_done[wIndex] = jiffies
1044 set_bit(wIndex, &ehci->resuming_ports);
1046 mod_timer(&ehci_to_hcd(ehci)->rh_timer,
1047 ehci->reset_done[wIndex]);
1051 } else if (!time_after_eq(jiffies, ehci->reset_done[wIndex])) {
1055 } else if (test_bit(wIndex, &ehci->resuming_ports)) {
1056 clear_bit(wIndex, &ehci->suspended_ports);
1057 set_bit(wIndex, &ehci->port_c_suspend);
1058 ehci->reset_done[wIndex] = 0;
1063 ehci_writel(ehci, temp, status_reg);
1064 clear_bit(wIndex, &ehci->resuming_ports);
1065 retval = ehci_handshake(ehci, status_reg,
1068 ehci_err(ehci, "port %d resume error %d\n",
1072 temp = ehci_readl(ehci, status_reg);
1077 ehci->reset_done [wIndex] = 0;
1080 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET),
1085 retval = ehci_handshake(ehci, status_reg,
1088 ehci_err (ehci, "port %d reset error %d\n",
1094 temp = check_reset_complete (ehci, wIndex, status_reg,
1095 ehci_readl(ehci, status_reg));
1100 test_bit(wIndex, &ehci->companion_ports)) {
1103 ehci_writel(ehci, temp, status_reg);
1104 ehci_dbg(ehci, "port %d --> companion\n", wIndex + 1);
1105 temp = ehci_readl(ehci, status_reg);
1117 if (ehci->has_hostpc) {
1118 temp1 = ehci_readl(ehci, hostpc_reg);
1119 status |= ehci_port_speed(ehci, temp1);
1121 status |= ehci_port_speed(ehci, temp);
1129 } else if (test_bit(wIndex, &ehci->suspended_ports)) {
1130 clear_bit(wIndex, &ehci->suspended_ports);
1131 clear_bit(wIndex, &ehci->resuming_ports);
1132 ehci->reset_done[wIndex] = 0;
1134 set_bit(wIndex, &ehci->port_c_suspend);
1144 if (test_bit(wIndex, &ehci->port_c_suspend))
1148 dbg_port(ehci, "GetStatus", wIndex + 1, temp);
1164 if (unlikely(ehci->debug)) {
1167 if (wIndex == HCS_DEBUG_PORT(ehci->hcs_params) &&
1168 (readl(&ehci->debug->control) & DBGP_ENABLED)) {
1176 temp = ehci_readl(ehci, status_reg);
1183 if (ehci->no_selective_suspend)
1195 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
1196 if (ehci->has_tdi_phy_lpm) {
1197 spin_unlock_irqrestore(&ehci->lock, flags);
1199 spin_lock_irqsave(&ehci->lock, flags);
1200 temp1 = ehci_readl(ehci, hostpc_reg);
1201 ehci_writel(ehci, temp1 | HOSTPC_PHCD,
1203 temp1 = ehci_readl(ehci, hostpc_reg);
1204 ehci_dbg(ehci, "Port%d phy low pwr mode %s\n",
1208 if (ehci_has_fsl_susp_errata(ehci)) {
1210 spin_unlock_irqrestore(&ehci->lock, flags);
1212 spin_lock_irqsave(&ehci->lock, flags);
1214 set_bit(wIndex, &ehci->suspended_ports);
1217 if (HCS_PPC(ehci->hcs_params)) {
1218 spin_unlock_irqrestore(&ehci->lock, flags);
1219 ehci_port_power(ehci, wIndex, true);
1220 spin_lock_irqsave(&ehci->lock, flags);
1231 && !ehci_is_TDI(ehci)
1233 ehci_dbg (ehci,
1245 ehci->reset_done [wIndex] = jiffies
1252 if (ehci_has_fsl_hs_errata(ehci))
1255 ehci_writel(ehci, temp, status_reg);
1267 spin_unlock_irqrestore(&ehci->lock, flags);
1270 spin_lock_irqsave(&ehci->lock, flags);
1276 spin_unlock_irqrestore(&ehci->lock, flags);
1277 ehci_quiesce(ehci);
1278 spin_lock_irqsave(&ehci->lock, flags);
1283 &ehci->regs->port_status[ports];
1285 temp = ehci_readl(ehci, sreg) & ~PORT_RWC_BITS;
1287 ehci_writel(ehci, temp | PORT_SUSPEND,
1291 spin_unlock_irqrestore(&ehci->lock, flags);
1292 ehci_halt(ehci);
1293 spin_lock_irqsave(&ehci->lock, flags);
1295 temp = ehci_readl(ehci, status_reg);
1297 ehci_writel(ehci, temp, status_reg);
1303 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
1312 spin_unlock_irqrestore (&ehci->lock, flags);
1319 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1321 if (ehci_is_TDI(ehci))
1323 set_owner(ehci, --portnum, PORT_OWNER);
1328 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1331 if (ehci_is_TDI(ehci))
1333 reg = &ehci->regs->port_status[portnum - 1];
1334 return ehci_readl(ehci, reg) & PORT_OWNER;
1337 static int ehci_port_power(struct ehci_hcd *ehci, int portnum, bool enable)
1339 struct usb_hcd *hcd = ehci_to_hcd(ehci);
1340 u32 __iomem *status_reg = &ehci->regs->port_status[portnum];
1341 u32 temp = ehci_readl(ehci, status_reg) & ~PORT_RWC_BITS;
1344 ehci_writel(ehci, temp | PORT_POWER, status_reg);
1346 ehci_writel(ehci, temp & ~PORT_POWER, status_reg);