2 * Copyright (C) 2001-2004 by David Brownell
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* this file is part of ehci-hcd.c */
21 /*-------------------------------------------------------------------------*/
24 * EHCI Root Hub ... the nonsharable stuff
26 * Registers don't need cpu_to_le32, that happens transparently
29 /*-------------------------------------------------------------------------*/
33 static int ehci_hub_control(
42 /* After a power loss, ports that were owned by the companion must be
43 * reset so that the companion can still own them.
45 static void ehci_handover_companion_ports(struct ehci_hcd *ehci)
51 struct usb_hcd *hcd = ehci_to_hcd(ehci);
53 if (!ehci->owned_ports)
56 /* Give the connections some time to appear */
59 port = HCS_N_PORTS(ehci->hcs_params);
61 if (test_bit(port, &ehci->owned_ports)) {
62 reg = &ehci->regs->port_status[port];
63 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
65 /* Port already owned by companion? */
66 if (status & PORT_OWNER)
67 clear_bit(port, &ehci->owned_ports);
68 else if (test_bit(port, &ehci->companion_ports))
69 ehci_writel(ehci, status & ~PORT_PE, reg);
71 ehci_hub_control(hcd, SetPortFeature,
72 USB_PORT_FEAT_RESET, port + 1,
77 if (!ehci->owned_ports)
79 msleep(90); /* Wait for resets to complete */
81 port = HCS_N_PORTS(ehci->hcs_params);
83 if (test_bit(port, &ehci->owned_ports)) {
84 ehci_hub_control(hcd, GetPortStatus,
86 (char *) &buf, sizeof(buf));
88 /* The companion should now own the port,
89 * but if something went wrong the port must not
92 reg = &ehci->regs->port_status[port];
93 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
94 if (status & PORT_OWNER)
95 ehci_writel(ehci, status | PORT_CSC, reg);
97 ehci_dbg(ehci, "failed handover port %d: %x\n",
99 ehci_writel(ehci, status & ~PORT_PE, reg);
104 ehci->owned_ports = 0;
107 static int ehci_bus_suspend (struct usb_hcd *hcd)
109 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
113 ehci_dbg(ehci, "suspend root hub\n");
115 if (time_before (jiffies, ehci->next_statechange))
117 del_timer_sync(&ehci->watchdog);
118 del_timer_sync(&ehci->iaa_watchdog);
120 port = HCS_N_PORTS (ehci->hcs_params);
121 spin_lock_irq (&ehci->lock);
123 /* stop schedules, clean any completed work */
124 if (HC_IS_RUNNING(hcd->state)) {
126 hcd->state = HC_STATE_QUIESCING;
128 ehci->command = ehci_readl(ehci, &ehci->regs->command);
131 /* Unlike other USB host controller types, EHCI doesn't have
132 * any notion of "global" or bus-wide suspend. The driver has
133 * to manually suspend all the active unsuspended ports, and
134 * then manually resume them in the bus_resume() routine.
136 ehci->bus_suspended = 0;
137 ehci->owned_ports = 0;
139 u32 __iomem *reg = &ehci->regs->port_status [port];
140 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
143 /* keep track of which ports we suspend */
145 set_bit(port, &ehci->owned_ports);
146 else if ((t1 & PORT_PE) && !(t1 & PORT_SUSPEND)) {
148 set_bit(port, &ehci->bus_suspended);
151 /* enable remote wakeup on all ports */
152 if (device_may_wakeup(&hcd->self.root_hub->dev))
153 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E;
155 t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E);
158 ehci_vdbg (ehci, "port %d, %08x -> %08x\n",
160 ehci_writel(ehci, t2, reg);
164 /* Apparently some devices need a >= 1-uframe delay here */
165 if (ehci->bus_suspended)
168 /* turn off now-idle HC */
170 hcd->state = HC_STATE_SUSPENDED;
173 end_unlink_async(ehci);
175 /* allow remote wakeup */
177 if (!device_may_wakeup(&hcd->self.root_hub->dev))
179 ehci_writel(ehci, mask, &ehci->regs->intr_enable);
180 ehci_readl(ehci, &ehci->regs->intr_enable);
182 ehci->next_statechange = jiffies + msecs_to_jiffies(10);
183 spin_unlock_irq (&ehci->lock);
188 /* caller has locked the root hub, and should reset/reinit on error */
189 static int ehci_bus_resume (struct usb_hcd *hcd)
191 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
196 if (time_before (jiffies, ehci->next_statechange))
198 spin_lock_irq (&ehci->lock);
199 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
200 spin_unlock_irq(&ehci->lock);
204 /* Ideally and we've got a real resume here, and no port's power
205 * was lost. (For PCI, that means Vaux was maintained.) But we
206 * could instead be restoring a swsusp snapshot -- so that BIOS was
207 * the last user of the controller, not reset/pm hardware keeping
208 * state we gave to it.
210 power_okay = ehci_readl(ehci, &ehci->regs->intr_enable);
211 ehci_dbg(ehci, "resume root hub%s\n",
212 power_okay ? "" : " after power loss");
214 /* at least some APM implementations will try to deliver
215 * IRQs right away, so delay them until we're ready.
217 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
219 /* re-init operational registers */
220 ehci_writel(ehci, 0, &ehci->regs->segment);
221 ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list);
222 ehci_writel(ehci, (u32) ehci->async->qh_dma, &ehci->regs->async_next);
224 /* restore CMD_RUN, framelist size, and irq threshold */
225 ehci_writel(ehci, ehci->command, &ehci->regs->command);
227 /* Some controller/firmware combinations need a delay during which
228 * they set up the port statuses. See Bugzilla #8190. */
231 /* manually resume the ports we suspended during bus_suspend() */
232 i = HCS_N_PORTS (ehci->hcs_params);
234 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
235 temp &= ~(PORT_RWC_BITS
236 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E);
237 if (test_bit(i, &ehci->bus_suspended) &&
238 (temp & PORT_SUSPEND)) {
239 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
242 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
244 i = HCS_N_PORTS (ehci->hcs_params);
247 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
248 if (test_bit(i, &ehci->bus_suspended) &&
249 (temp & PORT_SUSPEND)) {
250 temp &= ~(PORT_RWC_BITS | PORT_RESUME);
251 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
252 ehci_vdbg (ehci, "resumed port %d\n", i + 1);
255 (void) ehci_readl(ehci, &ehci->regs->command);
257 /* maybe re-activate the schedule(s) */
259 if (ehci->async->qh_next.qh)
261 if (ehci->periodic_sched)
264 ehci->command |= temp;
265 ehci_writel(ehci, ehci->command, &ehci->regs->command);
268 ehci->next_statechange = jiffies + msecs_to_jiffies(5);
269 hcd->state = HC_STATE_RUNNING;
271 /* Now we can safely re-enable irqs */
272 ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable);
274 spin_unlock_irq (&ehci->lock);
275 ehci_handover_companion_ports(ehci);
281 #define ehci_bus_suspend NULL
282 #define ehci_bus_resume NULL
284 #endif /* CONFIG_PM */
286 /*-------------------------------------------------------------------------*/
288 /* Display the ports dedicated to the companion controller */
289 static ssize_t show_companion(struct device *dev,
290 struct device_attribute *attr,
293 struct ehci_hcd *ehci;
294 int nports, index, n;
295 int count = PAGE_SIZE;
298 ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev)));
299 nports = HCS_N_PORTS(ehci->hcs_params);
301 for (index = 0; index < nports; ++index) {
302 if (test_bit(index, &ehci->companion_ports)) {
303 n = scnprintf(ptr, count, "%d\n", index + 1);
312 * Sets the owner of a port
314 static void set_owner(struct ehci_hcd *ehci, int portnum, int new_owner)
316 u32 __iomem *status_reg;
320 status_reg = &ehci->regs->port_status[portnum];
323 * The controller won't set the OWNER bit if the port is
324 * enabled, so this loop will sometimes require at least two
325 * iterations: one to disable the port and one to set OWNER.
327 for (try = 4; try > 0; --try) {
328 spin_lock_irq(&ehci->lock);
329 port_status = ehci_readl(ehci, status_reg);
330 if ((port_status & PORT_OWNER) == new_owner
331 || (port_status & (PORT_OWNER | PORT_CONNECT))
335 port_status ^= PORT_OWNER;
336 port_status &= ~(PORT_PE | PORT_RWC_BITS);
337 ehci_writel(ehci, port_status, status_reg);
339 spin_unlock_irq(&ehci->lock);
346 * Dedicate or undedicate a port to the companion controller.
347 * Syntax is "[-]portnum", where a leading '-' sign means
348 * return control of the port to the EHCI controller.
350 static ssize_t store_companion(struct device *dev,
351 struct device_attribute *attr,
352 const char *buf, size_t count)
354 struct ehci_hcd *ehci;
355 int portnum, new_owner;
357 ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev)));
358 new_owner = PORT_OWNER; /* Owned by companion */
359 if (sscanf(buf, "%d", &portnum) != 1)
363 new_owner = 0; /* Owned by EHCI */
365 if (portnum <= 0 || portnum > HCS_N_PORTS(ehci->hcs_params))
369 set_bit(portnum, &ehci->companion_ports);
371 clear_bit(portnum, &ehci->companion_ports);
372 set_owner(ehci, portnum, new_owner);
375 static DEVICE_ATTR(companion, 0644, show_companion, store_companion);
377 static inline void create_companion_file(struct ehci_hcd *ehci)
381 /* with integrated TT there is no companion! */
382 if (!ehci_is_TDI(ehci))
383 i = device_create_file(ehci_to_hcd(ehci)->self.dev,
384 &dev_attr_companion);
387 static inline void remove_companion_file(struct ehci_hcd *ehci)
389 /* with integrated TT there is no companion! */
390 if (!ehci_is_TDI(ehci))
391 device_remove_file(ehci_to_hcd(ehci)->self.dev,
392 &dev_attr_companion);
396 /*-------------------------------------------------------------------------*/
398 static int check_reset_complete (
399 struct ehci_hcd *ehci,
401 u32 __iomem *status_reg,
404 if (!(port_status & PORT_CONNECT))
407 /* if reset finished and it's still not enabled -- handoff */
408 if (!(port_status & PORT_PE)) {
410 /* with integrated TT, there's nobody to hand it to! */
411 if (ehci_is_TDI(ehci)) {
413 "Failed to enable port %d on root hub TT\n",
418 ehci_dbg (ehci, "port %d full speed --> companion\n",
421 // what happens if HCS_N_CC(params) == 0 ?
422 port_status |= PORT_OWNER;
423 port_status &= ~PORT_RWC_BITS;
424 ehci_writel(ehci, port_status, status_reg);
427 ehci_dbg (ehci, "port %d high speed\n", index + 1);
432 /*-------------------------------------------------------------------------*/
435 /* build "status change" packet (one or two bytes) from HC registers */
438 ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
440 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
441 u32 temp, status = 0;
443 int ports, i, retval = 1;
446 /* if !USB_SUSPEND, root hub timers won't get shut down ... */
447 if (!HC_IS_RUNNING(hcd->state))
450 /* init status to no-changes */
452 ports = HCS_N_PORTS (ehci->hcs_params);
458 /* Some boards (mostly VIA?) report bogus overcurrent indications,
459 * causing massive log spam unless we completely ignore them. It
460 * may be relevant that VIA VT8235 controllers, where PORT_POWER is
461 * always set, seem to clear PORT_OCC and PORT_CSC when writing to
462 * PORT_POWER; that's surprising, but maybe within-spec.
465 mask = PORT_CSC | PORT_PEC | PORT_OCC;
467 mask = PORT_CSC | PORT_PEC;
468 // PORT_RESUME from hardware ~= PORT_STAT_C_SUSPEND
470 /* no hub change reports (bit 0) for now (power, ...) */
472 /* port N changes (bit N)? */
473 spin_lock_irqsave (&ehci->lock, flags);
474 for (i = 0; i < ports; i++) {
475 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
478 * Return status information even for ports with OWNER set.
479 * Otherwise khubd wouldn't see the disconnect event when a
480 * high-speed device is switched over to the companion
481 * controller by the user.
484 if ((temp & mask) != 0
485 || ((temp & PORT_RESUME) != 0
486 && time_after_eq(jiffies,
487 ehci->reset_done[i]))) {
489 buf [0] |= 1 << (i + 1);
491 buf [1] |= 1 << (i - 7);
495 /* FIXME autosuspend idle root hubs */
496 spin_unlock_irqrestore (&ehci->lock, flags);
497 return status ? retval : 0;
500 /*-------------------------------------------------------------------------*/
503 ehci_hub_descriptor (
504 struct ehci_hcd *ehci,
505 struct usb_hub_descriptor *desc
507 int ports = HCS_N_PORTS (ehci->hcs_params);
510 desc->bDescriptorType = 0x29;
511 desc->bPwrOn2PwrGood = 10; /* ehci 1.0, 2.3.9 says 20ms max */
512 desc->bHubContrCurrent = 0;
514 desc->bNbrPorts = ports;
515 temp = 1 + (ports / 8);
516 desc->bDescLength = 7 + 2 * temp;
518 /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */
519 memset (&desc->bitmap [0], 0, temp);
520 memset (&desc->bitmap [temp], 0xff, temp);
522 temp = 0x0008; /* per-port overcurrent reporting */
523 if (HCS_PPC (ehci->hcs_params))
524 temp |= 0x0001; /* per-port power control */
526 temp |= 0x0002; /* no power switching */
528 // re-enable when we support USB_PORT_FEAT_INDICATOR below.
529 if (HCS_INDICATOR (ehci->hcs_params))
530 temp |= 0x0080; /* per-port indicators (LEDs) */
532 desc->wHubCharacteristics = (__force __u16)cpu_to_le16 (temp);
535 /*-------------------------------------------------------------------------*/
537 #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
539 static int ehci_hub_control (
547 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
548 int ports = HCS_N_PORTS (ehci->hcs_params);
549 u32 __iomem *status_reg = &ehci->regs->port_status[
550 (wIndex & 0xff) - 1];
557 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
558 * HCS_INDICATOR may say we can change LEDs to off/amber/green.
559 * (track current state ourselves) ... blink for diagnostics,
560 * power, "this is the one", etc. EHCI spec supports this.
563 spin_lock_irqsave (&ehci->lock, flags);
565 case ClearHubFeature:
567 case C_HUB_LOCAL_POWER:
568 case C_HUB_OVER_CURRENT:
569 /* no hub-wide feature/status flags */
575 case ClearPortFeature:
576 if (!wIndex || wIndex > ports)
579 temp = ehci_readl(ehci, status_reg);
582 * Even if OWNER is set, so the port is owned by the
583 * companion controller, khubd needs to be able to clear
584 * the port-change status bits (especially
585 * USB_PORT_FEAT_C_CONNECTION).
589 case USB_PORT_FEAT_ENABLE:
590 ehci_writel(ehci, temp & ~PORT_PE, status_reg);
592 case USB_PORT_FEAT_C_ENABLE:
593 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_PEC,
596 case USB_PORT_FEAT_SUSPEND:
597 if (temp & PORT_RESET)
599 if (ehci->no_selective_suspend)
601 if (temp & PORT_SUSPEND) {
602 if ((temp & PORT_PE) == 0)
604 /* resume signaling for 20 msec */
605 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
606 ehci_writel(ehci, temp | PORT_RESUME,
608 ehci->reset_done [wIndex] = jiffies
609 + msecs_to_jiffies (20);
612 case USB_PORT_FEAT_C_SUSPEND:
613 /* we auto-clear this feature */
615 case USB_PORT_FEAT_POWER:
616 if (HCS_PPC (ehci->hcs_params))
618 temp & ~(PORT_RWC_BITS | PORT_POWER),
621 case USB_PORT_FEAT_C_CONNECTION:
622 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_CSC,
625 case USB_PORT_FEAT_C_OVER_CURRENT:
626 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_OCC,
629 case USB_PORT_FEAT_C_RESET:
630 /* GetPortStatus clears reset */
635 ehci_readl(ehci, &ehci->regs->command); /* unblock posted write */
637 case GetHubDescriptor:
638 ehci_hub_descriptor (ehci, (struct usb_hub_descriptor *)
642 /* no hub-wide feature/status flags */
644 //cpu_to_le32s ((u32 *) buf);
647 if (!wIndex || wIndex > ports)
651 temp = ehci_readl(ehci, status_reg);
655 status |= 1 << USB_PORT_FEAT_C_CONNECTION;
657 status |= 1 << USB_PORT_FEAT_C_ENABLE;
659 if ((temp & PORT_OCC) && !ignore_oc){
660 status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT;
663 * Hubs should disable port power on over-current.
664 * However, not all EHCI implementations do this
665 * automatically, even if they _do_ support per-port
666 * power switching; they're allowed to just limit the
667 * current. khubd will turn the power back on.
669 if (HCS_PPC (ehci->hcs_params)){
671 temp & ~(PORT_RWC_BITS | PORT_POWER),
676 /* whoever resumes must GetPortStatus to complete it!! */
677 if (temp & PORT_RESUME) {
679 /* Remote Wakeup received? */
680 if (!ehci->reset_done[wIndex]) {
681 /* resume signaling for 20 msec */
682 ehci->reset_done[wIndex] = jiffies
683 + msecs_to_jiffies(20);
684 /* check the port again */
685 mod_timer(&ehci_to_hcd(ehci)->rh_timer,
686 ehci->reset_done[wIndex]);
689 /* resume completed? */
690 else if (time_after_eq(jiffies,
691 ehci->reset_done[wIndex])) {
692 status |= 1 << USB_PORT_FEAT_C_SUSPEND;
693 ehci->reset_done[wIndex] = 0;
695 /* stop resume signaling */
696 temp = ehci_readl(ehci, status_reg);
698 temp & ~(PORT_RWC_BITS | PORT_RESUME),
700 retval = handshake(ehci, status_reg,
701 PORT_RESUME, 0, 2000 /* 2msec */);
704 "port %d resume error %d\n",
708 temp &= ~(PORT_SUSPEND|PORT_RESUME|(3<<10));
712 /* whoever resets must GetPortStatus to complete it!! */
713 if ((temp & PORT_RESET)
714 && time_after_eq(jiffies,
715 ehci->reset_done[wIndex])) {
716 status |= 1 << USB_PORT_FEAT_C_RESET;
717 ehci->reset_done [wIndex] = 0;
719 /* force reset to complete */
720 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET),
722 /* REVISIT: some hardware needs 550+ usec to clear
723 * this bit; seems too long to spin routinely...
725 retval = handshake(ehci, status_reg,
728 ehci_err (ehci, "port %d reset error %d\n",
733 /* see what we found out */
734 temp = check_reset_complete (ehci, wIndex, status_reg,
735 ehci_readl(ehci, status_reg));
738 /* transfer dedicated ports to the companion hc */
739 if ((temp & PORT_CONNECT) &&
740 test_bit(wIndex, &ehci->companion_ports)) {
741 temp &= ~PORT_RWC_BITS;
743 ehci_writel(ehci, temp, status_reg);
744 ehci_dbg(ehci, "port %d --> companion\n", wIndex + 1);
745 temp = ehci_readl(ehci, status_reg);
749 * Even if OWNER is set, there's no harm letting khubd
750 * see the wPortStatus values (they should all be 0 except
751 * for PORT_POWER anyway).
754 if (temp & PORT_CONNECT) {
755 status |= 1 << USB_PORT_FEAT_CONNECTION;
756 // status may be from integrated TT
757 status |= ehci_port_speed(ehci, temp);
760 status |= 1 << USB_PORT_FEAT_ENABLE;
761 if (temp & (PORT_SUSPEND|PORT_RESUME))
762 status |= 1 << USB_PORT_FEAT_SUSPEND;
764 status |= 1 << USB_PORT_FEAT_OVER_CURRENT;
765 if (temp & PORT_RESET)
766 status |= 1 << USB_PORT_FEAT_RESET;
767 if (temp & PORT_POWER)
768 status |= 1 << USB_PORT_FEAT_POWER;
770 #ifndef VERBOSE_DEBUG
771 if (status & ~0xffff) /* only if wPortChange is interesting */
773 dbg_port (ehci, "GetStatus", wIndex + 1, temp);
774 put_unaligned(cpu_to_le32 (status), (__le32 *) buf);
778 case C_HUB_LOCAL_POWER:
779 case C_HUB_OVER_CURRENT:
780 /* no hub-wide feature/status flags */
787 selector = wIndex >> 8;
789 if (!wIndex || wIndex > ports)
792 temp = ehci_readl(ehci, status_reg);
793 if (temp & PORT_OWNER)
796 temp &= ~PORT_RWC_BITS;
798 case USB_PORT_FEAT_SUSPEND:
799 if (ehci->no_selective_suspend)
801 if ((temp & PORT_PE) == 0
802 || (temp & PORT_RESET) != 0)
804 if (device_may_wakeup(&hcd->self.root_hub->dev))
805 temp |= PORT_WAKE_BITS;
806 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
808 case USB_PORT_FEAT_POWER:
809 if (HCS_PPC (ehci->hcs_params))
810 ehci_writel(ehci, temp | PORT_POWER,
813 case USB_PORT_FEAT_RESET:
814 if (temp & PORT_RESUME)
816 /* line status bits may report this as low speed,
817 * which can be fine if this root hub has a
818 * transaction translator built in.
820 if ((temp & (PORT_PE|PORT_CONNECT)) == PORT_CONNECT
821 && !ehci_is_TDI(ehci)
822 && PORT_USB11 (temp)) {
824 "port %d low speed --> companion\n",
828 ehci_vdbg (ehci, "port %d reset\n", wIndex + 1);
833 * caller must wait, then call GetPortStatus
834 * usb 2.0 spec says 50 ms resets on root
836 ehci->reset_done [wIndex] = jiffies
837 + msecs_to_jiffies (50);
839 ehci_writel(ehci, temp, status_reg);
842 /* For downstream facing ports (these): one hub port is put
843 * into test mode according to USB2 11.24.2.13, then the hub
844 * must be reset (which for root hub now means rmmod+modprobe,
845 * or else system reboot). See EHCI 2.3.9 and 4.14 for info
846 * about the EHCI-specific stuff.
848 case USB_PORT_FEAT_TEST:
849 if (!selector || selector > 5)
853 temp |= selector << 16;
854 ehci_writel(ehci, temp, status_reg);
860 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
865 /* "stall" on error */
868 spin_unlock_irqrestore (&ehci->lock, flags);
872 static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum)
874 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
876 if (ehci_is_TDI(ehci))
878 set_owner(ehci, --portnum, PORT_OWNER);