ehci-hub.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /*
  2. * Copyright (C) 2001-2004 by David Brownell
  3. *
  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.
  8. *
  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
  12. * for more details.
  13. *
  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.
  17. */
  18. /* this file is part of ehci-hcd.c */
  19. /*-------------------------------------------------------------------------*/
  20. /*
  21. * EHCI Root Hub ... the nonsharable stuff
  22. *
  23. * Registers don't need cpu_to_le32, that happens transparently
  24. */
  25. /*-------------------------------------------------------------------------*/
  26. #ifdef CONFIG_PM
  27. static int ehci_bus_suspend (struct usb_hcd *hcd)
  28. {
  29. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  30. int port;
  31. int mask;
  32. if (time_before (jiffies, ehci->next_statechange))
  33. msleep(5);
  34. port = HCS_N_PORTS (ehci->hcs_params);
  35. spin_lock_irq (&ehci->lock);
  36. /* stop schedules, clean any completed work */
  37. if (HC_IS_RUNNING(hcd->state)) {
  38. ehci_quiesce (ehci);
  39. hcd->state = HC_STATE_QUIESCING;
  40. }
  41. ehci->command = readl (&ehci->regs->command);
  42. if (ehci->reclaim)
  43. ehci->reclaim_ready = 1;
  44. ehci_work(ehci);
  45. /* Unlike other USB host controller types, EHCI doesn't have
  46. * any notion of "global" or bus-wide suspend. The driver has
  47. * to manually suspend all the active unsuspended ports, and
  48. * then manually resume them in the bus_resume() routine.
  49. */
  50. ehci->bus_suspended = 0;
  51. while (port--) {
  52. u32 __iomem *reg = &ehci->regs->port_status [port];
  53. u32 t1 = readl (reg) & ~PORT_RWC_BITS;
  54. u32 t2 = t1;
  55. /* keep track of which ports we suspend */
  56. if ((t1 & PORT_PE) && !(t1 & PORT_OWNER) &&
  57. !(t1 & PORT_SUSPEND)) {
  58. t2 |= PORT_SUSPEND;
  59. set_bit(port, &ehci->bus_suspended);
  60. }
  61. /* enable remote wakeup on all ports */
  62. if (device_may_wakeup(&hcd->self.root_hub->dev))
  63. t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E;
  64. else
  65. t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E);
  66. if (t1 != t2) {
  67. ehci_vdbg (ehci, "port %d, %08x -> %08x\n",
  68. port + 1, t1, t2);
  69. writel (t2, reg);
  70. }
  71. }
  72. /* turn off now-idle HC */
  73. del_timer_sync (&ehci->watchdog);
  74. ehci_halt (ehci);
  75. hcd->state = HC_STATE_SUSPENDED;
  76. /* allow remote wakeup */
  77. mask = INTR_MASK;
  78. if (!device_may_wakeup(&hcd->self.root_hub->dev))
  79. mask &= ~STS_PCD;
  80. writel(mask, &ehci->regs->intr_enable);
  81. readl(&ehci->regs->intr_enable);
  82. ehci->next_statechange = jiffies + msecs_to_jiffies(10);
  83. spin_unlock_irq (&ehci->lock);
  84. return 0;
  85. }
  86. /* caller has locked the root hub, and should reset/reinit on error */
  87. static int ehci_bus_resume (struct usb_hcd *hcd)
  88. {
  89. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  90. u32 temp;
  91. int i;
  92. if (time_before (jiffies, ehci->next_statechange))
  93. msleep(5);
  94. spin_lock_irq (&ehci->lock);
  95. /* Ideally and we've got a real resume here, and no port's power
  96. * was lost. (For PCI, that means Vaux was maintained.) But we
  97. * could instead be restoring a swsusp snapshot -- so that BIOS was
  98. * the last user of the controller, not reset/pm hardware keeping
  99. * state we gave to it.
  100. */
  101. temp = readl(&ehci->regs->intr_enable);
  102. ehci_dbg(ehci, "resume root hub%s\n", temp ? "" : " after power loss");
  103. /* at least some APM implementations will try to deliver
  104. * IRQs right away, so delay them until we're ready.
  105. */
  106. writel(0, &ehci->regs->intr_enable);
  107. /* re-init operational registers */
  108. writel(0, &ehci->regs->segment);
  109. writel(ehci->periodic_dma, &ehci->regs->frame_list);
  110. writel((u32) ehci->async->qh_dma, &ehci->regs->async_next);
  111. /* restore CMD_RUN, framelist size, and irq threshold */
  112. writel (ehci->command, &ehci->regs->command);
  113. /* manually resume the ports we suspended during bus_suspend() */
  114. i = HCS_N_PORTS (ehci->hcs_params);
  115. while (i--) {
  116. temp = readl (&ehci->regs->port_status [i]);
  117. temp &= ~(PORT_RWC_BITS
  118. | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E);
  119. if (test_bit(i, &ehci->bus_suspended) &&
  120. (temp & PORT_SUSPEND)) {
  121. ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
  122. temp |= PORT_RESUME;
  123. }
  124. writel (temp, &ehci->regs->port_status [i]);
  125. }
  126. i = HCS_N_PORTS (ehci->hcs_params);
  127. mdelay (20);
  128. while (i--) {
  129. temp = readl (&ehci->regs->port_status [i]);
  130. if (test_bit(i, &ehci->bus_suspended) &&
  131. (temp & PORT_SUSPEND)) {
  132. temp &= ~(PORT_RWC_BITS | PORT_RESUME);
  133. writel (temp, &ehci->regs->port_status [i]);
  134. ehci_vdbg (ehci, "resumed port %d\n", i + 1);
  135. }
  136. }
  137. (void) readl (&ehci->regs->command);
  138. /* maybe re-activate the schedule(s) */
  139. temp = 0;
  140. if (ehci->async->qh_next.qh)
  141. temp |= CMD_ASE;
  142. if (ehci->periodic_sched)
  143. temp |= CMD_PSE;
  144. if (temp) {
  145. ehci->command |= temp;
  146. writel (ehci->command, &ehci->regs->command);
  147. }
  148. ehci->next_statechange = jiffies + msecs_to_jiffies(5);
  149. hcd->state = HC_STATE_RUNNING;
  150. /* Now we can safely re-enable irqs */
  151. writel(INTR_MASK, &ehci->regs->intr_enable);
  152. spin_unlock_irq (&ehci->lock);
  153. return 0;
  154. }
  155. #else
  156. #define ehci_bus_suspend NULL
  157. #define ehci_bus_resume NULL
  158. #endif /* CONFIG_PM */
  159. /*-------------------------------------------------------------------------*/
  160. static int check_reset_complete (
  161. struct ehci_hcd *ehci,
  162. int index,
  163. int port_status
  164. ) {
  165. if (!(port_status & PORT_CONNECT)) {
  166. ehci->reset_done [index] = 0;
  167. return port_status;
  168. }
  169. /* if reset finished and it's still not enabled -- handoff */
  170. if (!(port_status & PORT_PE)) {
  171. /* with integrated TT, there's nobody to hand it to! */
  172. if (ehci_is_TDI(ehci)) {
  173. ehci_dbg (ehci,
  174. "Failed to enable port %d on root hub TT\n",
  175. index+1);
  176. return port_status;
  177. }
  178. ehci_dbg (ehci, "port %d full speed --> companion\n",
  179. index + 1);
  180. // what happens if HCS_N_CC(params) == 0 ?
  181. port_status |= PORT_OWNER;
  182. port_status &= ~PORT_RWC_BITS;
  183. writel (port_status, &ehci->regs->port_status [index]);
  184. } else
  185. ehci_dbg (ehci, "port %d high speed\n", index + 1);
  186. return port_status;
  187. }
  188. /*-------------------------------------------------------------------------*/
  189. /* build "status change" packet (one or two bytes) from HC registers */
  190. static int
  191. ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
  192. {
  193. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  194. u32 temp, status = 0;
  195. u32 mask;
  196. int ports, i, retval = 1;
  197. unsigned long flags;
  198. /* if !USB_SUSPEND, root hub timers won't get shut down ... */
  199. if (!HC_IS_RUNNING(hcd->state))
  200. return 0;
  201. /* init status to no-changes */
  202. buf [0] = 0;
  203. ports = HCS_N_PORTS (ehci->hcs_params);
  204. if (ports > 7) {
  205. buf [1] = 0;
  206. retval++;
  207. }
  208. /* Some boards (mostly VIA?) report bogus overcurrent indications,
  209. * causing massive log spam unless we completely ignore them. It
  210. * may be relevant that VIA VT8235 controlers, where PORT_POWER is
  211. * always set, seem to clear PORT_OCC and PORT_CSC when writing to
  212. * PORT_POWER; that's surprising, but maybe within-spec.
  213. */
  214. if (!ignore_oc)
  215. mask = PORT_CSC | PORT_PEC | PORT_OCC;
  216. else
  217. mask = PORT_CSC | PORT_PEC;
  218. // PORT_RESUME from hardware ~= PORT_STAT_C_SUSPEND
  219. /* no hub change reports (bit 0) for now (power, ...) */
  220. /* port N changes (bit N)? */
  221. spin_lock_irqsave (&ehci->lock, flags);
  222. for (i = 0; i < ports; i++) {
  223. temp = readl (&ehci->regs->port_status [i]);
  224. if (temp & PORT_OWNER) {
  225. /* don't report this in GetPortStatus */
  226. if (temp & PORT_CSC) {
  227. temp &= ~PORT_RWC_BITS;
  228. temp |= PORT_CSC;
  229. writel (temp, &ehci->regs->port_status [i]);
  230. }
  231. continue;
  232. }
  233. if (!(temp & PORT_CONNECT))
  234. ehci->reset_done [i] = 0;
  235. if ((temp & mask) != 0
  236. || ((temp & PORT_RESUME) != 0
  237. && time_after (jiffies,
  238. ehci->reset_done [i]))) {
  239. if (i < 7)
  240. buf [0] |= 1 << (i + 1);
  241. else
  242. buf [1] |= 1 << (i - 7);
  243. status = STS_PCD;
  244. }
  245. }
  246. /* FIXME autosuspend idle root hubs */
  247. spin_unlock_irqrestore (&ehci->lock, flags);
  248. return status ? retval : 0;
  249. }
  250. /*-------------------------------------------------------------------------*/
  251. static void
  252. ehci_hub_descriptor (
  253. struct ehci_hcd *ehci,
  254. struct usb_hub_descriptor *desc
  255. ) {
  256. int ports = HCS_N_PORTS (ehci->hcs_params);
  257. u16 temp;
  258. desc->bDescriptorType = 0x29;
  259. desc->bPwrOn2PwrGood = 10; /* ehci 1.0, 2.3.9 says 20ms max */
  260. desc->bHubContrCurrent = 0;
  261. desc->bNbrPorts = ports;
  262. temp = 1 + (ports / 8);
  263. desc->bDescLength = 7 + 2 * temp;
  264. /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */
  265. memset (&desc->bitmap [0], 0, temp);
  266. memset (&desc->bitmap [temp], 0xff, temp);
  267. temp = 0x0008; /* per-port overcurrent reporting */
  268. if (HCS_PPC (ehci->hcs_params))
  269. temp |= 0x0001; /* per-port power control */
  270. else
  271. temp |= 0x0002; /* no power switching */
  272. #if 0
  273. // re-enable when we support USB_PORT_FEAT_INDICATOR below.
  274. if (HCS_INDICATOR (ehci->hcs_params))
  275. temp |= 0x0080; /* per-port indicators (LEDs) */
  276. #endif
  277. desc->wHubCharacteristics = (__force __u16)cpu_to_le16 (temp);
  278. }
  279. /*-------------------------------------------------------------------------*/
  280. #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
  281. static int ehci_hub_control (
  282. struct usb_hcd *hcd,
  283. u16 typeReq,
  284. u16 wValue,
  285. u16 wIndex,
  286. char *buf,
  287. u16 wLength
  288. ) {
  289. struct ehci_hcd *ehci = hcd_to_ehci (hcd);
  290. int ports = HCS_N_PORTS (ehci->hcs_params);
  291. u32 temp, status;
  292. unsigned long flags;
  293. int retval = 0;
  294. unsigned selector;
  295. /*
  296. * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
  297. * HCS_INDICATOR may say we can change LEDs to off/amber/green.
  298. * (track current state ourselves) ... blink for diagnostics,
  299. * power, "this is the one", etc. EHCI spec supports this.
  300. */
  301. spin_lock_irqsave (&ehci->lock, flags);
  302. switch (typeReq) {
  303. case ClearHubFeature:
  304. switch (wValue) {
  305. case C_HUB_LOCAL_POWER:
  306. case C_HUB_OVER_CURRENT:
  307. /* no hub-wide feature/status flags */
  308. break;
  309. default:
  310. goto error;
  311. }
  312. break;
  313. case ClearPortFeature:
  314. if (!wIndex || wIndex > ports)
  315. goto error;
  316. wIndex--;
  317. temp = readl (&ehci->regs->port_status [wIndex]);
  318. if (temp & PORT_OWNER)
  319. break;
  320. switch (wValue) {
  321. case USB_PORT_FEAT_ENABLE:
  322. writel (temp & ~PORT_PE,
  323. &ehci->regs->port_status [wIndex]);
  324. break;
  325. case USB_PORT_FEAT_C_ENABLE:
  326. writel((temp & ~PORT_RWC_BITS) | PORT_PEC,
  327. &ehci->regs->port_status [wIndex]);
  328. break;
  329. case USB_PORT_FEAT_SUSPEND:
  330. if (temp & PORT_RESET)
  331. goto error;
  332. if (ehci->no_selective_suspend)
  333. break;
  334. if (temp & PORT_SUSPEND) {
  335. if ((temp & PORT_PE) == 0)
  336. goto error;
  337. /* resume signaling for 20 msec */
  338. temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
  339. writel (temp | PORT_RESUME,
  340. &ehci->regs->port_status [wIndex]);
  341. ehci->reset_done [wIndex] = jiffies
  342. + msecs_to_jiffies (20);
  343. }
  344. break;
  345. case USB_PORT_FEAT_C_SUSPEND:
  346. /* we auto-clear this feature */
  347. break;
  348. case USB_PORT_FEAT_POWER:
  349. if (HCS_PPC (ehci->hcs_params))
  350. writel (temp & ~(PORT_RWC_BITS | PORT_POWER),
  351. &ehci->regs->port_status [wIndex]);
  352. break;
  353. case USB_PORT_FEAT_C_CONNECTION:
  354. writel((temp & ~PORT_RWC_BITS) | PORT_CSC,
  355. &ehci->regs->port_status [wIndex]);
  356. break;
  357. case USB_PORT_FEAT_C_OVER_CURRENT:
  358. writel((temp & ~PORT_RWC_BITS) | PORT_OCC,
  359. &ehci->regs->port_status [wIndex]);
  360. break;
  361. case USB_PORT_FEAT_C_RESET:
  362. /* GetPortStatus clears reset */
  363. break;
  364. default:
  365. goto error;
  366. }
  367. readl (&ehci->regs->command); /* unblock posted write */
  368. break;
  369. case GetHubDescriptor:
  370. ehci_hub_descriptor (ehci, (struct usb_hub_descriptor *)
  371. buf);
  372. break;
  373. case GetHubStatus:
  374. /* no hub-wide feature/status flags */
  375. memset (buf, 0, 4);
  376. //cpu_to_le32s ((u32 *) buf);
  377. break;
  378. case GetPortStatus:
  379. if (!wIndex || wIndex > ports)
  380. goto error;
  381. wIndex--;
  382. status = 0;
  383. temp = readl (&ehci->regs->port_status [wIndex]);
  384. // wPortChange bits
  385. if (temp & PORT_CSC)
  386. status |= 1 << USB_PORT_FEAT_C_CONNECTION;
  387. if (temp & PORT_PEC)
  388. status |= 1 << USB_PORT_FEAT_C_ENABLE;
  389. if ((temp & PORT_OCC) && !ignore_oc)
  390. status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT;
  391. /* whoever resumes must GetPortStatus to complete it!! */
  392. if ((temp & PORT_RESUME)
  393. && time_after (jiffies,
  394. ehci->reset_done [wIndex])) {
  395. status |= 1 << USB_PORT_FEAT_C_SUSPEND;
  396. ehci->reset_done [wIndex] = 0;
  397. /* stop resume signaling */
  398. temp = readl (&ehci->regs->port_status [wIndex]);
  399. writel (temp & ~(PORT_RWC_BITS | PORT_RESUME),
  400. &ehci->regs->port_status [wIndex]);
  401. retval = handshake (
  402. &ehci->regs->port_status [wIndex],
  403. PORT_RESUME, 0, 2000 /* 2msec */);
  404. if (retval != 0) {
  405. ehci_err (ehci, "port %d resume error %d\n",
  406. wIndex + 1, retval);
  407. goto error;
  408. }
  409. temp &= ~(PORT_SUSPEND|PORT_RESUME|(3<<10));
  410. }
  411. /* whoever resets must GetPortStatus to complete it!! */
  412. if ((temp & PORT_RESET)
  413. && time_after (jiffies,
  414. ehci->reset_done [wIndex])) {
  415. status |= 1 << USB_PORT_FEAT_C_RESET;
  416. ehci->reset_done [wIndex] = 0;
  417. /* force reset to complete */
  418. writel (temp & ~(PORT_RWC_BITS | PORT_RESET),
  419. &ehci->regs->port_status [wIndex]);
  420. /* REVISIT: some hardware needs 550+ usec to clear
  421. * this bit; seems too long to spin routinely...
  422. */
  423. retval = handshake (
  424. &ehci->regs->port_status [wIndex],
  425. PORT_RESET, 0, 750);
  426. if (retval != 0) {
  427. ehci_err (ehci, "port %d reset error %d\n",
  428. wIndex + 1, retval);
  429. goto error;
  430. }
  431. /* see what we found out */
  432. temp = check_reset_complete (ehci, wIndex,
  433. readl (&ehci->regs->port_status [wIndex]));
  434. }
  435. // don't show wPortStatus if it's owned by a companion hc
  436. if (!(temp & PORT_OWNER)) {
  437. if (temp & PORT_CONNECT) {
  438. status |= 1 << USB_PORT_FEAT_CONNECTION;
  439. // status may be from integrated TT
  440. status |= ehci_port_speed(ehci, temp);
  441. }
  442. if (temp & PORT_PE)
  443. status |= 1 << USB_PORT_FEAT_ENABLE;
  444. if (temp & (PORT_SUSPEND|PORT_RESUME))
  445. status |= 1 << USB_PORT_FEAT_SUSPEND;
  446. if (temp & PORT_OC)
  447. status |= 1 << USB_PORT_FEAT_OVER_CURRENT;
  448. if (temp & PORT_RESET)
  449. status |= 1 << USB_PORT_FEAT_RESET;
  450. if (temp & PORT_POWER)
  451. status |= 1 << USB_PORT_FEAT_POWER;
  452. }
  453. #ifndef EHCI_VERBOSE_DEBUG
  454. if (status & ~0xffff) /* only if wPortChange is interesting */
  455. #endif
  456. dbg_port (ehci, "GetStatus", wIndex + 1, temp);
  457. // we "know" this alignment is good, caller used kmalloc()...
  458. *((__le32 *) buf) = cpu_to_le32 (status);
  459. break;
  460. case SetHubFeature:
  461. switch (wValue) {
  462. case C_HUB_LOCAL_POWER:
  463. case C_HUB_OVER_CURRENT:
  464. /* no hub-wide feature/status flags */
  465. break;
  466. default:
  467. goto error;
  468. }
  469. break;
  470. case SetPortFeature:
  471. selector = wIndex >> 8;
  472. wIndex &= 0xff;
  473. if (!wIndex || wIndex > ports)
  474. goto error;
  475. wIndex--;
  476. temp = readl (&ehci->regs->port_status [wIndex]);
  477. if (temp & PORT_OWNER)
  478. break;
  479. temp &= ~PORT_RWC_BITS;
  480. switch (wValue) {
  481. case USB_PORT_FEAT_SUSPEND:
  482. if (ehci->no_selective_suspend)
  483. break;
  484. if ((temp & PORT_PE) == 0
  485. || (temp & PORT_RESET) != 0)
  486. goto error;
  487. if (device_may_wakeup(&hcd->self.root_hub->dev))
  488. temp |= PORT_WAKE_BITS;
  489. writel (temp | PORT_SUSPEND,
  490. &ehci->regs->port_status [wIndex]);
  491. break;
  492. case USB_PORT_FEAT_POWER:
  493. if (HCS_PPC (ehci->hcs_params))
  494. writel (temp | PORT_POWER,
  495. &ehci->regs->port_status [wIndex]);
  496. break;
  497. case USB_PORT_FEAT_RESET:
  498. if (temp & PORT_RESUME)
  499. goto error;
  500. /* line status bits may report this as low speed,
  501. * which can be fine if this root hub has a
  502. * transaction translator built in.
  503. */
  504. if ((temp & (PORT_PE|PORT_CONNECT)) == PORT_CONNECT
  505. && !ehci_is_TDI(ehci)
  506. && PORT_USB11 (temp)) {
  507. ehci_dbg (ehci,
  508. "port %d low speed --> companion\n",
  509. wIndex + 1);
  510. temp |= PORT_OWNER;
  511. } else {
  512. ehci_vdbg (ehci, "port %d reset\n", wIndex + 1);
  513. temp |= PORT_RESET;
  514. temp &= ~PORT_PE;
  515. /*
  516. * caller must wait, then call GetPortStatus
  517. * usb 2.0 spec says 50 ms resets on root
  518. */
  519. ehci->reset_done [wIndex] = jiffies
  520. + msecs_to_jiffies (50);
  521. }
  522. writel (temp, &ehci->regs->port_status [wIndex]);
  523. break;
  524. /* For downstream facing ports (these): one hub port is put
  525. * into test mode according to USB2 11.24.2.13, then the hub
  526. * must be reset (which for root hub now means rmmod+modprobe,
  527. * or else system reboot). See EHCI 2.3.9 and 4.14 for info
  528. * about the EHCI-specific stuff.
  529. */
  530. case USB_PORT_FEAT_TEST:
  531. if (!selector || selector > 5)
  532. goto error;
  533. ehci_quiesce(ehci);
  534. ehci_halt(ehci);
  535. temp |= selector << 16;
  536. writel (temp, &ehci->regs->port_status [wIndex]);
  537. break;
  538. default:
  539. goto error;
  540. }
  541. readl (&ehci->regs->command); /* unblock posted writes */
  542. break;
  543. default:
  544. error:
  545. /* "stall" on error */
  546. retval = -EPIPE;
  547. }
  548. spin_unlock_irqrestore (&ehci->lock, flags);
  549. return retval;
  550. }