Lines Matching +full:usb +full:- +full:ehci +full:- +full:440 +full:epx

1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2001-2004 by David Brownell
6 /* this file is part of ehci-hcd.c */
8 /*-------------------------------------------------------------------------*/
11 * EHCI Root Hub ... the nonsharable stuff
16 /*-------------------------------------------------------------------------*/
22 static void unlink_empty_async_suspended(struct ehci_hcd *ehci);
26 return !udev->maxchild && udev->persist_enabled && in persist_enabled_on_companion()
27 udev->bus->root_hub->speed < USB_SPEED_HIGH; in persist_enabled_on_companion()
33 static void ehci_handover_companion_ports(struct ehci_hcd *ehci) in ehci_handover_companion_ports() argument
39 struct usb_hcd *hcd = ehci_to_hcd(ehci); in ehci_handover_companion_ports()
41 if (!ehci->owned_ports) in ehci_handover_companion_ports()
45 * USB 1.1 devices are mostly HIDs, which don't need to persist across in ehci_handover_companion_ports()
47 * persist_enabled (by looking through all USB 1.1 buses in the system), in ehci_handover_companion_ports()
55 port = HCS_N_PORTS(ehci->hcs_params); in ehci_handover_companion_ports()
56 while (port--) { in ehci_handover_companion_ports()
57 if (test_bit(port, &ehci->owned_ports)) { in ehci_handover_companion_ports()
58 reg = &ehci->regs->port_status[port]; in ehci_handover_companion_ports()
59 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; in ehci_handover_companion_ports()
61 ehci_port_power(ehci, port, true); in ehci_handover_companion_ports()
68 spin_lock_irq(&ehci->lock); in ehci_handover_companion_ports()
69 port = HCS_N_PORTS(ehci->hcs_params); in ehci_handover_companion_ports()
70 while (port--) { in ehci_handover_companion_ports()
71 if (test_bit(port, &ehci->owned_ports)) { in ehci_handover_companion_ports()
72 reg = &ehci->regs->port_status[port]; in ehci_handover_companion_ports()
73 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; in ehci_handover_companion_ports()
77 clear_bit(port, &ehci->owned_ports); in ehci_handover_companion_ports()
78 else if (test_bit(port, &ehci->companion_ports)) in ehci_handover_companion_ports()
79 ehci_writel(ehci, status & ~PORT_PE, reg); in ehci_handover_companion_ports()
81 spin_unlock_irq(&ehci->lock); in ehci_handover_companion_ports()
85 spin_lock_irq(&ehci->lock); in ehci_handover_companion_ports()
89 spin_unlock_irq(&ehci->lock); in ehci_handover_companion_ports()
91 if (!ehci->owned_ports) in ehci_handover_companion_ports()
95 spin_lock_irq(&ehci->lock); in ehci_handover_companion_ports()
96 port = HCS_N_PORTS(ehci->hcs_params); in ehci_handover_companion_ports()
97 while (port--) { in ehci_handover_companion_ports()
98 if (test_bit(port, &ehci->owned_ports)) { in ehci_handover_companion_ports()
99 spin_unlock_irq(&ehci->lock); in ehci_handover_companion_ports()
103 spin_lock_irq(&ehci->lock); in ehci_handover_companion_ports()
109 reg = &ehci->regs->port_status[port]; in ehci_handover_companion_ports()
110 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; in ehci_handover_companion_ports()
112 ehci_writel(ehci, status | PORT_CSC, reg); in ehci_handover_companion_ports()
114 ehci_dbg(ehci, "failed handover port %d: %x\n", in ehci_handover_companion_ports()
116 ehci_writel(ehci, status & ~PORT_PE, reg); in ehci_handover_companion_ports()
121 ehci->owned_ports = 0; in ehci_handover_companion_ports()
122 spin_unlock_irq(&ehci->lock); in ehci_handover_companion_ports()
125 static int ehci_port_change(struct ehci_hcd *ehci) in ehci_port_change() argument
127 int i = HCS_N_PORTS(ehci->hcs_params); in ehci_port_change()
131 if (ehci_readl(ehci, &ehci->regs->status) & STS_PCD) in ehci_port_change()
139 while (i--) in ehci_port_change()
140 if (ehci_readl(ehci, &ehci->regs->port_status[i]) & PORT_CSC) in ehci_port_change()
146 void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci, in ehci_adjust_port_wakeup_flags() argument
157 if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || do_wakeup) in ehci_adjust_port_wakeup_flags()
160 spin_lock_irq(&ehci->lock); in ehci_adjust_port_wakeup_flags()
162 /* clear phy low-power mode before changing wakeup flags */ in ehci_adjust_port_wakeup_flags()
163 if (ehci->has_tdi_phy_lpm) { in ehci_adjust_port_wakeup_flags()
164 port = HCS_N_PORTS(ehci->hcs_params); in ehci_adjust_port_wakeup_flags()
165 while (port--) { in ehci_adjust_port_wakeup_flags()
166 u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port]; in ehci_adjust_port_wakeup_flags()
168 temp = ehci_readl(ehci, hostpc_reg); in ehci_adjust_port_wakeup_flags()
169 ehci_writel(ehci, temp & ~HOSTPC_PHCD, hostpc_reg); in ehci_adjust_port_wakeup_flags()
171 spin_unlock_irq(&ehci->lock); in ehci_adjust_port_wakeup_flags()
173 spin_lock_irq(&ehci->lock); in ehci_adjust_port_wakeup_flags()
176 port = HCS_N_PORTS(ehci->hcs_params); in ehci_adjust_port_wakeup_flags()
177 while (port--) { in ehci_adjust_port_wakeup_flags()
178 u32 __iomem *reg = &ehci->regs->port_status[port]; in ehci_adjust_port_wakeup_flags()
179 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; in ehci_adjust_port_wakeup_flags()
191 ehci_writel(ehci, t2, reg); in ehci_adjust_port_wakeup_flags()
194 /* enter phy low-power mode again */ in ehci_adjust_port_wakeup_flags()
195 if (ehci->has_tdi_phy_lpm) { in ehci_adjust_port_wakeup_flags()
196 port = HCS_N_PORTS(ehci->hcs_params); in ehci_adjust_port_wakeup_flags()
197 while (port--) { in ehci_adjust_port_wakeup_flags()
198 u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port]; in ehci_adjust_port_wakeup_flags()
200 temp = ehci_readl(ehci, hostpc_reg); in ehci_adjust_port_wakeup_flags()
201 ehci_writel(ehci, temp | HOSTPC_PHCD, hostpc_reg); in ehci_adjust_port_wakeup_flags()
206 if (!suspending && ehci_port_change(ehci)) in ehci_adjust_port_wakeup_flags()
207 usb_hcd_resume_root_hub(ehci_to_hcd(ehci)); in ehci_adjust_port_wakeup_flags()
209 spin_unlock_irq(&ehci->lock); in ehci_adjust_port_wakeup_flags()
215 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_bus_suspend() local
221 ehci_dbg(ehci, "suspend root hub\n"); in ehci_bus_suspend()
223 if (time_before (jiffies, ehci->next_statechange)) in ehci_bus_suspend()
227 ehci_quiesce(ehci); in ehci_bus_suspend()
229 spin_lock_irq (&ehci->lock); in ehci_bus_suspend()
230 if (ehci->rh_state < EHCI_RH_RUNNING) in ehci_bus_suspend()
238 if (hcd->self.root_hub->do_remote_wakeup) { in ehci_bus_suspend()
239 if (ehci->resuming_ports) { in ehci_bus_suspend()
240 spin_unlock_irq(&ehci->lock); in ehci_bus_suspend()
241 ehci_dbg(ehci, "suspend failed because a port is resuming\n"); in ehci_bus_suspend()
242 return -EBUSY; in ehci_bus_suspend()
246 /* Unlike other USB host controller types, EHCI doesn't have in ehci_bus_suspend()
247 * any notion of "global" or bus-wide suspend. The driver has in ehci_bus_suspend()
251 ehci->bus_suspended = 0; in ehci_bus_suspend()
252 ehci->owned_ports = 0; in ehci_bus_suspend()
255 port = HCS_N_PORTS(ehci->hcs_params); in ehci_bus_suspend()
256 while (port--) { in ehci_bus_suspend()
257 u32 __iomem *reg = &ehci->regs->port_status [port]; in ehci_bus_suspend()
258 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; in ehci_bus_suspend()
263 set_bit(port, &ehci->owned_ports); in ehci_bus_suspend()
266 set_bit(port, &ehci->bus_suspended); in ehci_bus_suspend()
270 if (hcd->self.root_hub->do_remote_wakeup) { in ehci_bus_suspend()
284 * On some controllers, Wake-On-Disconnect will in ehci_bus_suspend()
286 * switches over to full-speed idle. For their in ehci_bus_suspend()
290 ehci_port_speed(ehci, t2) == in ehci_bus_suspend()
293 ehci_writel(ehci, t2, reg); in ehci_bus_suspend()
297 spin_unlock_irq(&ehci->lock); in ehci_bus_suspend()
299 if (changed && ehci_has_fsl_susp_errata(ehci)) in ehci_bus_suspend()
303 * using the Force Port Resume bit (Not-EHCI compatible). in ehci_bus_suspend()
307 if ((changed && ehci->has_tdi_phy_lpm) || fs_idle_delay) { in ehci_bus_suspend()
309 * Wait for HCD to enter low-power mode or for the bus in ehci_bus_suspend()
310 * to switch to full-speed idle. in ehci_bus_suspend()
315 if (changed && ehci->has_tdi_phy_lpm) { in ehci_bus_suspend()
316 spin_lock_irq(&ehci->lock); in ehci_bus_suspend()
317 port = HCS_N_PORTS(ehci->hcs_params); in ehci_bus_suspend()
318 while (port--) { in ehci_bus_suspend()
319 u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port]; in ehci_bus_suspend()
322 t3 = ehci_readl(ehci, hostpc_reg); in ehci_bus_suspend()
323 ehci_writel(ehci, t3 | HOSTPC_PHCD, hostpc_reg); in ehci_bus_suspend()
324 t3 = ehci_readl(ehci, hostpc_reg); in ehci_bus_suspend()
325 ehci_dbg(ehci, "Port %d phy low-power mode %s\n", in ehci_bus_suspend()
329 spin_unlock_irq(&ehci->lock); in ehci_bus_suspend()
332 /* Apparently some devices need a >= 1-uframe delay here */ in ehci_bus_suspend()
333 if (ehci->bus_suspended) in ehci_bus_suspend()
336 /* turn off now-idle HC */ in ehci_bus_suspend()
337 ehci_halt (ehci); in ehci_bus_suspend()
339 spin_lock_irq(&ehci->lock); in ehci_bus_suspend()
340 if (ehci->enabled_hrtimer_events & BIT(EHCI_HRTIMER_POLL_DEAD)) in ehci_bus_suspend()
341 ehci_handle_controller_death(ehci); in ehci_bus_suspend()
342 if (ehci->rh_state != EHCI_RH_RUNNING) in ehci_bus_suspend()
344 ehci->rh_state = EHCI_RH_SUSPENDED; in ehci_bus_suspend()
346 unlink_empty_async_suspended(ehci); in ehci_bus_suspend()
349 end_iaa_cycle(ehci); in ehci_bus_suspend()
350 ehci_handle_start_intr_unlinks(ehci); in ehci_bus_suspend()
351 ehci_handle_intr_unlinks(ehci); in ehci_bus_suspend()
352 end_free_itds(ehci); in ehci_bus_suspend()
356 if (!hcd->self.root_hub->do_remote_wakeup) in ehci_bus_suspend()
358 ehci_writel(ehci, mask, &ehci->regs->intr_enable); in ehci_bus_suspend()
359 ehci_readl(ehci, &ehci->regs->intr_enable); in ehci_bus_suspend()
362 ehci->next_statechange = jiffies + msecs_to_jiffies(10); in ehci_bus_suspend()
363 ehci->enabled_hrtimer_events = 0; in ehci_bus_suspend()
364 ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT; in ehci_bus_suspend()
365 spin_unlock_irq (&ehci->lock); in ehci_bus_suspend()
367 hrtimer_cancel(&ehci->hrtimer); in ehci_bus_suspend()
375 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_bus_resume() local
381 if (time_before (jiffies, ehci->next_statechange)) in ehci_bus_resume()
383 spin_lock_irq (&ehci->lock); in ehci_bus_resume()
384 if (!HCD_HW_ACCESSIBLE(hcd) || ehci->shutdown) in ehci_bus_resume()
387 if (unlikely(ehci->debug)) { in ehci_bus_resume()
389 ehci->debug = NULL; in ehci_bus_resume()
396 * could instead be restoring a swsusp snapshot -- so that BIOS was in ehci_bus_resume()
400 power_okay = ehci_readl(ehci, &ehci->regs->intr_enable); in ehci_bus_resume()
401 ehci_dbg(ehci, "resume root hub%s\n", in ehci_bus_resume()
407 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in ehci_bus_resume()
409 /* re-init operational registers */ in ehci_bus_resume()
410 ehci_writel(ehci, 0, &ehci->regs->segment); in ehci_bus_resume()
411 ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list); in ehci_bus_resume()
412 ehci_writel(ehci, (u32) ehci->async->qh_dma, &ehci->regs->async_next); in ehci_bus_resume()
415 ehci->command |= CMD_RUN; in ehci_bus_resume()
416 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_bus_resume()
417 ehci->rh_state = EHCI_RH_RUNNING; in ehci_bus_resume()
424 i = HCS_N_PORTS(ehci->hcs_params); in ehci_bus_resume()
425 while (i--) { in ehci_bus_resume()
426 temp = ehci_readl(ehci, &ehci->regs->port_status[i]); in ehci_bus_resume()
429 ehci_dbg(ehci, "Port status(0x%x) is wrong\n", temp); in ehci_bus_resume()
430 spin_unlock_irq(&ehci->lock); in ehci_bus_resume()
432 spin_lock_irq(&ehci->lock); in ehci_bus_resume()
437 if (ehci->shutdown) in ehci_bus_resume()
440 /* clear phy low-power mode before resume */ in ehci_bus_resume()
441 if (ehci->bus_suspended && ehci->has_tdi_phy_lpm) { in ehci_bus_resume()
442 i = HCS_N_PORTS(ehci->hcs_params); in ehci_bus_resume()
443 while (i--) { in ehci_bus_resume()
444 if (test_bit(i, &ehci->bus_suspended)) { in ehci_bus_resume()
446 &ehci->regs->hostpc[i]; in ehci_bus_resume()
448 temp = ehci_readl(ehci, hostpc_reg); in ehci_bus_resume()
449 ehci_writel(ehci, temp & ~HOSTPC_PHCD, in ehci_bus_resume()
453 spin_unlock_irq(&ehci->lock); in ehci_bus_resume()
455 spin_lock_irq(&ehci->lock); in ehci_bus_resume()
456 if (ehci->shutdown) in ehci_bus_resume()
461 i = HCS_N_PORTS (ehci->hcs_params); in ehci_bus_resume()
462 while (i--) { in ehci_bus_resume()
463 temp = ehci_readl(ehci, &ehci->regs->port_status [i]); in ehci_bus_resume()
465 if (test_bit(i, &ehci->bus_suspended) && in ehci_bus_resume()
470 ehci_writel(ehci, temp, &ehci->regs->port_status [i]); in ehci_bus_resume()
478 spin_unlock_irq(&ehci->lock); in ehci_bus_resume()
480 spin_lock_irq(&ehci->lock); in ehci_bus_resume()
481 if (ehci->shutdown) in ehci_bus_resume()
485 i = HCS_N_PORTS (ehci->hcs_params); in ehci_bus_resume()
486 while (i--) { in ehci_bus_resume()
487 temp = ehci_readl(ehci, &ehci->regs->port_status [i]); in ehci_bus_resume()
490 ehci_writel(ehci, temp, &ehci->regs->port_status [i]); in ehci_bus_resume()
494 ehci->next_statechange = jiffies + msecs_to_jiffies(5); in ehci_bus_resume()
495 spin_unlock_irq(&ehci->lock); in ehci_bus_resume()
497 ehci_handover_companion_ports(ehci); in ehci_bus_resume()
499 /* Now we can safely re-enable irqs */ in ehci_bus_resume()
500 spin_lock_irq(&ehci->lock); in ehci_bus_resume()
501 if (ehci->shutdown) in ehci_bus_resume()
503 ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable); in ehci_bus_resume()
504 (void) ehci_readl(ehci, &ehci->regs->intr_enable); in ehci_bus_resume()
505 spin_unlock_irq(&ehci->lock); in ehci_bus_resume()
510 spin_unlock_irq(&ehci->lock); in ehci_bus_resume()
511 return -ESHUTDOWN; in ehci_bus_resume()
516 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_get_resuming_ports() local
518 return ehci->resuming_ports; in ehci_get_resuming_ports()
529 /*-------------------------------------------------------------------------*/
534 static void set_owner(struct ehci_hcd *ehci, int portnum, int new_owner) in set_owner() argument
540 status_reg = &ehci->regs->port_status[portnum]; in set_owner()
547 for (try = 4; try > 0; --try) { in set_owner()
548 spin_lock_irq(&ehci->lock); in set_owner()
549 port_status = ehci_readl(ehci, status_reg); in set_owner()
557 ehci_writel(ehci, port_status, status_reg); in set_owner()
559 spin_unlock_irq(&ehci->lock); in set_owner()
565 /*-------------------------------------------------------------------------*/
568 struct ehci_hcd *ehci, in check_reset_complete() argument
576 /* if reset finished and it's still not enabled -- handoff */ in check_reset_complete()
580 if (ehci_is_TDI(ehci)) { in check_reset_complete()
581 ehci_dbg (ehci, in check_reset_complete()
587 ehci_dbg (ehci, "port %d full speed --> companion\n", in check_reset_complete()
593 ehci_writel(ehci, port_status, status_reg); in check_reset_complete()
595 /* ensure 440EPX ohci controller state is operational */ in check_reset_complete()
596 if (ehci->has_amcc_usb23) in check_reset_complete()
597 set_ohci_hcfs(ehci, 1); in check_reset_complete()
599 ehci_dbg(ehci, "port %d reset complete, port enabled\n", in check_reset_complete()
601 /* ensure 440EPx ohci controller state is suspended */ in check_reset_complete()
602 if (ehci->has_amcc_usb23) in check_reset_complete()
603 set_ohci_hcfs(ehci, 0); in check_reset_complete()
609 /*-------------------------------------------------------------------------*/
617 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_hub_status_data() local
624 /* init status to no-changes */ in ehci_hub_status_data()
626 ports = HCS_N_PORTS (ehci->hcs_params); in ehci_hub_status_data()
632 /* Inform the core about resumes-in-progress by returning in ehci_hub_status_data()
633 * a non-zero value even if there are no status changes. in ehci_hub_status_data()
635 status = ehci->resuming_ports; in ehci_hub_status_data()
641 * PORT_POWER; that's surprising, but maybe within-spec. in ehci_hub_status_data()
652 spin_lock_irqsave (&ehci->lock, flags); in ehci_hub_status_data()
654 /* get per-port change detect bits */ in ehci_hub_status_data()
655 if (ehci->has_ppcd) in ehci_hub_status_data()
656 ppcd = ehci_readl(ehci, &ehci->regs->status) >> 16; in ehci_hub_status_data()
659 /* leverage per-port change bits feature */ in ehci_hub_status_data()
661 temp = ehci_readl(ehci, &ehci->regs->port_status[i]); in ehci_hub_status_data()
668 * high-speed device is switched over to the companion in ehci_hub_status_data()
672 if ((temp & mask) != 0 || test_bit(i, &ehci->port_c_suspend) in ehci_hub_status_data()
673 || (ehci->reset_done[i] && time_after_eq( in ehci_hub_status_data()
674 jiffies, ehci->reset_done[i]))) { in ehci_hub_status_data()
678 buf [1] |= 1 << (i - 7); in ehci_hub_status_data()
684 if (ehci->resuming_ports) in ehci_hub_status_data()
685 mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(25)); in ehci_hub_status_data()
687 spin_unlock_irqrestore (&ehci->lock, flags); in ehci_hub_status_data()
691 /*-------------------------------------------------------------------------*/
695 struct ehci_hcd *ehci, in ehci_hub_descriptor() argument
698 int ports = HCS_N_PORTS (ehci->hcs_params); in ehci_hub_descriptor()
701 desc->bDescriptorType = USB_DT_HUB; in ehci_hub_descriptor()
702 desc->bPwrOn2PwrGood = 10; /* ehci 1.0, 2.3.9 says 20ms max */ in ehci_hub_descriptor()
703 desc->bHubContrCurrent = 0; in ehci_hub_descriptor()
705 desc->bNbrPorts = ports; in ehci_hub_descriptor()
707 desc->bDescLength = 7 + 2 * temp; in ehci_hub_descriptor()
709 /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */ in ehci_hub_descriptor()
710 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); in ehci_hub_descriptor()
711 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); in ehci_hub_descriptor()
713 temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */ in ehci_hub_descriptor()
714 if (HCS_PPC (ehci->hcs_params)) in ehci_hub_descriptor()
715 temp |= HUB_CHAR_INDV_PORT_LPSM; /* per-port power control */ in ehci_hub_descriptor()
719 // re-enable when we support USB_PORT_FEAT_INDICATOR below. in ehci_hub_descriptor()
720 if (HCS_INDICATOR (ehci->hcs_params)) in ehci_hub_descriptor()
721 temp |= HUB_CHAR_PORTIND; /* per-port indicators (LEDs) */ in ehci_hub_descriptor()
723 desc->wHubCharacteristics = cpu_to_le16(temp); in ehci_hub_descriptor()
726 /*-------------------------------------------------------------------------*/
733 struct completion *done = urb->context; in usb_ehset_completion()
756 struct usb_hcd *hcd = bus_to_hcd(udev->bus); in request_single_step_set_feature_urb()
763 urb->pipe = usb_rcvctrlpipe(udev, 0); in request_single_step_set_feature_urb()
764 ep = (usb_pipein(urb->pipe) ? udev->ep_in : udev->ep_out) in request_single_step_set_feature_urb()
765 [usb_pipeendpoint(urb->pipe)]; in request_single_step_set_feature_urb()
771 urb->ep = ep; in request_single_step_set_feature_urb()
772 urb->dev = udev; in request_single_step_set_feature_urb()
773 urb->setup_packet = (void *)dr; in request_single_step_set_feature_urb()
774 urb->transfer_buffer = buf; in request_single_step_set_feature_urb()
775 urb->transfer_buffer_length = USB_DT_DEVICE_SIZE; in request_single_step_set_feature_urb()
776 urb->complete = usb_ehset_completion; in request_single_step_set_feature_urb()
777 urb->status = -EINPROGRESS; in request_single_step_set_feature_urb()
778 urb->actual_length = 0; in request_single_step_set_feature_urb()
779 urb->transfer_flags = URB_DIR_IN; in request_single_step_set_feature_urb()
781 atomic_inc(&urb->use_count); in request_single_step_set_feature_urb()
782 atomic_inc(&urb->dev->urbnum); in request_single_step_set_feature_urb()
783 urb->setup_dma = dma_map_single( in request_single_step_set_feature_urb()
784 hcd->self.sysdev, in request_single_step_set_feature_urb()
785 urb->setup_packet, in request_single_step_set_feature_urb()
788 urb->transfer_dma = dma_map_single( in request_single_step_set_feature_urb()
789 hcd->self.sysdev, in request_single_step_set_feature_urb()
790 urb->transfer_buffer, in request_single_step_set_feature_urb()
791 urb->transfer_buffer_length, in request_single_step_set_feature_urb()
793 urb->context = done; in request_single_step_set_feature_urb()
799 int retval = -ENOMEM; in ehset_single_step_set_feature()
803 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehset_single_step_set_feature() local
808 udev = usb_hub_find_child(hcd->self.root_hub, port); in ehset_single_step_set_feature()
810 ehci_err(ehci, "No device attached to the RootHub\n"); in ehset_single_step_set_feature()
811 return -ENODEV; in ehset_single_step_set_feature()
815 return -ENOMEM; in ehset_single_step_set_feature()
820 return -ENOMEM; in ehset_single_step_set_feature()
824 dr->bRequestType = USB_DIR_IN; in ehset_single_step_set_feature()
825 dr->bRequest = USB_REQ_GET_DESCRIPTOR; in ehset_single_step_set_feature()
826 dr->wValue = cpu_to_le16(USB_DT_DEVICE << 8); in ehset_single_step_set_feature()
827 dr->wIndex = 0; in ehset_single_step_set_feature()
828 dr->wLength = cpu_to_le16(USB_DT_DEVICE_SIZE); in ehset_single_step_set_feature()
839 retval = -ETIMEDOUT; in ehset_single_step_set_feature()
840 ehci_err(ehci, "%s SETUP stage timed out on ep0\n", __func__); in ehset_single_step_set_feature()
846 urb->status = -EINPROGRESS; in ehset_single_step_set_feature()
848 atomic_inc(&urb->use_count); in ehset_single_step_set_feature()
849 atomic_inc(&urb->dev->urbnum); in ehset_single_step_set_feature()
854 retval = -ETIMEDOUT; in ehset_single_step_set_feature()
855 ehci_err(ehci, "%s IN stage timed out on ep0\n", __func__); in ehset_single_step_set_feature()
865 /*-------------------------------------------------------------------------*/
875 struct ehci_hcd *ehci = hcd_to_ehci (hcd); in ehci_hub_control() local
876 int ports = HCS_N_PORTS (ehci->hcs_params); in ehci_hub_control()
884 * Avoid underflow while calculating (wIndex & 0xff) - 1. in ehci_hub_control()
889 temp -= (temp > 0); in ehci_hub_control()
890 status_reg = &ehci->regs->port_status[temp]; in ehci_hub_control()
891 hostpc_reg = &ehci->regs->hostpc[temp]; in ehci_hub_control()
897 * power, "this is the one", etc. EHCI spec supports this. in ehci_hub_control()
900 spin_lock_irqsave (&ehci->lock, flags); in ehci_hub_control()
906 /* no hub-wide feature/status flags */ in ehci_hub_control()
915 wIndex--; in ehci_hub_control()
916 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
922 * the port-change status bits (especially in ehci_hub_control()
928 ehci_writel(ehci, temp & ~PORT_PE, status_reg); in ehci_hub_control()
931 ehci_writel(ehci, temp | PORT_PEC, status_reg); in ehci_hub_control()
936 if (ehci->no_selective_suspend) in ehci_hub_control()
939 if ((hcd->self.otg_port == (wIndex + 1)) in ehci_hub_control()
940 && hcd->self.b_hnp_enable) { in ehci_hub_control()
941 otg_start_hnp(hcd->usb_phy->otg); in ehci_hub_control()
950 /* clear phy low-power mode before resume */ in ehci_hub_control()
951 if (ehci->has_tdi_phy_lpm) { in ehci_hub_control()
952 temp1 = ehci_readl(ehci, hostpc_reg); in ehci_hub_control()
953 ehci_writel(ehci, temp1 & ~HOSTPC_PHCD, in ehci_hub_control()
955 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
956 msleep(5);/* wait to leave low-power mode */ in ehci_hub_control()
957 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
961 ehci_writel(ehci, temp | PORT_RESUME, status_reg); in ehci_hub_control()
962 ehci->reset_done[wIndex] = jiffies in ehci_hub_control()
964 set_bit(wIndex, &ehci->resuming_ports); in ehci_hub_control()
965 usb_hcd_start_port_resume(&hcd->self, wIndex); in ehci_hub_control()
968 clear_bit(wIndex, &ehci->port_c_suspend); in ehci_hub_control()
971 if (HCS_PPC(ehci->hcs_params)) { in ehci_hub_control()
972 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
973 ehci_port_power(ehci, wIndex, false); in ehci_hub_control()
974 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
978 ehci_writel(ehci, temp | PORT_CSC, status_reg); in ehci_hub_control()
981 ehci_writel(ehci, temp | PORT_OCC, status_reg); in ehci_hub_control()
989 ehci_readl(ehci, &ehci->regs->command); /* unblock posted write */ in ehci_hub_control()
992 ehci_hub_descriptor (ehci, (struct usb_hub_descriptor *) in ehci_hub_control()
996 /* no hub-wide feature/status flags */ in ehci_hub_control()
1003 wIndex--; in ehci_hub_control()
1005 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
1017 * Hubs should disable port power on over-current. in ehci_hub_control()
1018 * However, not all EHCI implementations do this in ehci_hub_control()
1019 * automatically, even if they _do_ support per-port in ehci_hub_control()
1023 if (((temp & PORT_OC) || (ehci->need_oc_pp_cycle)) in ehci_hub_control()
1024 && HCS_PPC(ehci->hcs_params)) { in ehci_hub_control()
1025 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
1026 ehci_port_power(ehci, wIndex, false); in ehci_hub_control()
1027 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
1028 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
1033 if (!ehci->reset_done[wIndex]) { in ehci_hub_control()
1038 ehci->reset_done[wIndex] = jiffies in ehci_hub_control()
1040 usb_hcd_start_port_resume(&hcd->self, wIndex); in ehci_hub_control()
1041 set_bit(wIndex, &ehci->resuming_ports); in ehci_hub_control()
1043 mod_timer(&ehci_to_hcd(ehci)->rh_timer, in ehci_hub_control()
1044 ehci->reset_done[wIndex]); in ehci_hub_control()
1048 } else if (!time_after_eq(jiffies, ehci->reset_done[wIndex])) { in ehci_hub_control()
1052 } else if (test_bit(wIndex, &ehci->resuming_ports)) { in ehci_hub_control()
1053 clear_bit(wIndex, &ehci->suspended_ports); in ehci_hub_control()
1054 set_bit(wIndex, &ehci->port_c_suspend); in ehci_hub_control()
1055 ehci->reset_done[wIndex] = 0; in ehci_hub_control()
1056 usb_hcd_end_port_resume(&hcd->self, wIndex); in ehci_hub_control()
1060 ehci_writel(ehci, temp, status_reg); in ehci_hub_control()
1061 clear_bit(wIndex, &ehci->resuming_ports); in ehci_hub_control()
1062 retval = ehci_handshake(ehci, status_reg, in ehci_hub_control()
1065 ehci_err(ehci, "port %d resume error %d\n", in ehci_hub_control()
1069 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
1074 ehci->reset_done [wIndex] = 0; in ehci_hub_control()
1077 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET), in ehci_hub_control()
1082 retval = ehci_handshake(ehci, status_reg, in ehci_hub_control()
1085 ehci_err (ehci, "port %d reset error %d\n", in ehci_hub_control()
1091 temp = check_reset_complete (ehci, wIndex, status_reg, in ehci_hub_control()
1092 ehci_readl(ehci, status_reg)); in ehci_hub_control()
1097 test_bit(wIndex, &ehci->companion_ports)) { in ehci_hub_control()
1100 ehci_writel(ehci, temp, status_reg); in ehci_hub_control()
1101 ehci_dbg(ehci, "port %d --> companion\n", wIndex + 1); in ehci_hub_control()
1102 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
1114 if (ehci->has_hostpc) { in ehci_hub_control()
1115 temp1 = ehci_readl(ehci, hostpc_reg); in ehci_hub_control()
1116 status |= ehci_port_speed(ehci, temp1); in ehci_hub_control()
1118 status |= ehci_port_speed(ehci, temp); in ehci_hub_control()
1126 } else if (test_bit(wIndex, &ehci->suspended_ports)) { in ehci_hub_control()
1127 clear_bit(wIndex, &ehci->suspended_ports); in ehci_hub_control()
1128 clear_bit(wIndex, &ehci->resuming_ports); in ehci_hub_control()
1129 ehci->reset_done[wIndex] = 0; in ehci_hub_control()
1131 set_bit(wIndex, &ehci->port_c_suspend); in ehci_hub_control()
1132 usb_hcd_end_port_resume(&hcd->self, wIndex); in ehci_hub_control()
1141 if (test_bit(wIndex, &ehci->port_c_suspend)) in ehci_hub_control()
1145 dbg_port(ehci, "GetStatus", wIndex + 1, temp); in ehci_hub_control()
1152 /* no hub-wide feature/status flags */ in ehci_hub_control()
1161 if (unlikely(ehci->debug)) { in ehci_hub_control()
1164 if (wIndex == HCS_DEBUG_PORT(ehci->hcs_params) && in ehci_hub_control()
1165 (readl(&ehci->debug->control) & DBGP_ENABLED)) { in ehci_hub_control()
1166 retval = -ENODEV; in ehci_hub_control()
1172 wIndex--; in ehci_hub_control()
1173 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
1180 if (ehci->no_selective_suspend) in ehci_hub_control()
1192 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); in ehci_hub_control()
1193 if (ehci->has_tdi_phy_lpm) { in ehci_hub_control()
1194 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
1196 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
1197 temp1 = ehci_readl(ehci, hostpc_reg); in ehci_hub_control()
1198 ehci_writel(ehci, temp1 | HOSTPC_PHCD, in ehci_hub_control()
1200 temp1 = ehci_readl(ehci, hostpc_reg); in ehci_hub_control()
1201 ehci_dbg(ehci, "Port%d phy low pwr mode %s\n", in ehci_hub_control()
1205 if (ehci_has_fsl_susp_errata(ehci)) { in ehci_hub_control()
1207 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
1209 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
1211 set_bit(wIndex, &ehci->suspended_ports); in ehci_hub_control()
1214 if (HCS_PPC(ehci->hcs_params)) { in ehci_hub_control()
1215 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
1216 ehci_port_power(ehci, wIndex, true); in ehci_hub_control()
1217 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
1228 && !ehci_is_TDI(ehci) in ehci_hub_control()
1230 ehci_dbg (ehci, in ehci_hub_control()
1231 "port %d low speed --> companion\n", in ehci_hub_control()
1240 * usb 2.0 spec says 50 ms resets on root in ehci_hub_control()
1242 ehci->reset_done [wIndex] = jiffies in ehci_hub_control()
1246 * Force full-speed connect for FSL high-speed in ehci_hub_control()
1249 if (ehci_has_fsl_hs_errata(ehci)) in ehci_hub_control()
1252 ehci_writel(ehci, temp, status_reg); in ehci_hub_control()
1258 * or else system reboot). See EHCI 2.3.9 and 4.14 for info in ehci_hub_control()
1259 * about the EHCI-specific stuff. in ehci_hub_control()
1264 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
1267 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
1273 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
1274 ehci_quiesce(ehci); in ehci_hub_control()
1275 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
1278 while (ports--) { in ehci_hub_control()
1280 &ehci->regs->port_status[ports]; in ehci_hub_control()
1282 temp = ehci_readl(ehci, sreg) & ~PORT_RWC_BITS; in ehci_hub_control()
1284 ehci_writel(ehci, temp | PORT_SUSPEND, in ehci_hub_control()
1288 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hub_control()
1289 ehci_halt(ehci); in ehci_hub_control()
1290 spin_lock_irqsave(&ehci->lock, flags); in ehci_hub_control()
1292 temp = ehci_readl(ehci, status_reg); in ehci_hub_control()
1294 ehci_writel(ehci, temp, status_reg); in ehci_hub_control()
1300 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ in ehci_hub_control()
1306 retval = -EPIPE; in ehci_hub_control()
1309 spin_unlock_irqrestore (&ehci->lock, flags); in ehci_hub_control()
1316 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_relinquish_port() local
1318 if (ehci_is_TDI(ehci)) in ehci_relinquish_port()
1320 set_owner(ehci, --portnum, PORT_OWNER); in ehci_relinquish_port()
1325 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in ehci_port_handed_over() local
1328 if (ehci_is_TDI(ehci)) in ehci_port_handed_over()
1330 reg = &ehci->regs->port_status[portnum - 1]; in ehci_port_handed_over()
1331 return ehci_readl(ehci, reg) & PORT_OWNER; in ehci_port_handed_over()
1334 static int ehci_port_power(struct ehci_hcd *ehci, int portnum, bool enable) in ehci_port_power() argument
1336 struct usb_hcd *hcd = ehci_to_hcd(ehci); in ehci_port_power()
1337 u32 __iomem *status_reg = &ehci->regs->port_status[portnum]; in ehci_port_power()
1338 u32 temp = ehci_readl(ehci, status_reg) & ~PORT_RWC_BITS; in ehci_port_power()
1341 ehci_writel(ehci, temp | PORT_POWER, status_reg); in ehci_port_power()
1343 ehci_writel(ehci, temp & ~PORT_POWER, status_reg); in ehci_port_power()
1345 if (hcd->driver->port_power) in ehci_port_power()
1346 hcd->driver->port_power(hcd, portnum, enable); in ehci_port_power()