blob: 7c170a29f959db21ce77398ec1e60ddb02131560 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
David Brownelld49d4312005-05-07 13:21:50 -07002 * Copyright (C) 2001-2004 by David Brownell
David Brownell53bd6a62006-08-30 14:50:06 -07003 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * 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
19/* this file is part of ehci-hcd.c */
20
21/*-------------------------------------------------------------------------*/
22
23/*
24 * EHCI Root Hub ... the nonsharable stuff
25 *
26 * Registers don't need cpu_to_le32, that happens transparently
27 */
28
29/*-------------------------------------------------------------------------*/
30
31#ifdef CONFIG_PM
32
Alan Stern0c0382e2005-10-13 17:08:02 -040033static int ehci_bus_suspend (struct usb_hcd *hcd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034{
35 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
36 int port;
37
38 if (time_before (jiffies, ehci->next_statechange))
39 msleep(5);
40
41 port = HCS_N_PORTS (ehci->hcs_params);
42 spin_lock_irq (&ehci->lock);
43
44 /* stop schedules, clean any completed work */
45 if (HC_IS_RUNNING(hcd->state)) {
46 ehci_quiesce (ehci);
47 hcd->state = HC_STATE_QUIESCING;
48 }
49 ehci->command = readl (&ehci->regs->command);
50 if (ehci->reclaim)
Greg Kroah-Hartman64f89792006-10-17 13:57:18 -070051 ehci->reclaim_ready = 1;
David Howells7d12e782006-10-05 14:55:46 +010052 ehci_work(ehci);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54 /* suspend any active/unsuspended ports, maybe allow wakeup */
55 while (port--) {
56 u32 __iomem *reg = &ehci->regs->port_status [port];
David Brownell10f65242005-08-31 10:55:38 -070057 u32 t1 = readl (reg) & ~PORT_RWC_BITS;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 u32 t2 = t1;
59
60 if ((t1 & PORT_PE) && !(t1 & PORT_OWNER))
61 t2 |= PORT_SUSPEND;
David Brownell2c1c3c42005-11-07 15:24:46 -080062 if (device_may_wakeup(&hcd->self.root_hub->dev))
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E;
64 else
65 t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E);
66
67 if (t1 != t2) {
68 ehci_vdbg (ehci, "port %d, %08x -> %08x\n",
69 port + 1, t1, t2);
70 writel (t2, reg);
71 }
72 }
73
74 /* turn off now-idle HC */
David Brownell4756ae52005-05-09 17:23:51 -070075 del_timer_sync (&ehci->watchdog);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 ehci_halt (ehci);
77 hcd->state = HC_STATE_SUSPENDED;
78
79 ehci->next_statechange = jiffies + msecs_to_jiffies(10);
80 spin_unlock_irq (&ehci->lock);
81 return 0;
82}
83
84
85/* caller has locked the root hub, and should reset/reinit on error */
Alan Stern0c0382e2005-10-13 17:08:02 -040086static int ehci_bus_resume (struct usb_hcd *hcd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
88 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
89 u32 temp;
90 int i;
91 int intr_enable;
92
93 if (time_before (jiffies, ehci->next_statechange))
94 msleep(5);
95 spin_lock_irq (&ehci->lock);
96
David Brownellf03c17f2005-11-23 15:45:28 -080097 /* Ideally and we've got a real resume here, and no port's power
98 * was lost. (For PCI, that means Vaux was maintained.) But we
99 * could instead be restoring a swsusp snapshot -- so that BIOS was
100 * the last user of the controller, not reset/pm hardware keeping
101 * state we gave to it.
102 */
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 /* re-init operational registers in case we lost power */
105 if (readl (&ehci->regs->intr_enable) == 0) {
David Brownell53bd6a62006-08-30 14:50:06 -0700106 /* at least some APM implementations will try to deliver
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 * IRQs right away, so delay them until we're ready.
David Brownell53bd6a62006-08-30 14:50:06 -0700108 */
109 intr_enable = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 writel (0, &ehci->regs->segment);
111 writel (ehci->periodic_dma, &ehci->regs->frame_list);
112 writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next);
113 } else
114 intr_enable = 0;
115 ehci_dbg(ehci, "resume root hub%s\n",
116 intr_enable ? " after power loss" : "");
117
118 /* restore CMD_RUN, framelist size, and irq threshold */
119 writel (ehci->command, &ehci->regs->command);
120
121 /* take ports out of suspend */
122 i = HCS_N_PORTS (ehci->hcs_params);
123 while (i--) {
124 temp = readl (&ehci->regs->port_status [i]);
David Brownell10f65242005-08-31 10:55:38 -0700125 temp &= ~(PORT_RWC_BITS
126 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 if (temp & PORT_SUSPEND) {
128 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
129 temp |= PORT_RESUME;
130 }
131 writel (temp, &ehci->regs->port_status [i]);
132 }
133 i = HCS_N_PORTS (ehci->hcs_params);
134 mdelay (20);
135 while (i--) {
136 temp = readl (&ehci->regs->port_status [i]);
137 if ((temp & PORT_SUSPEND) == 0)
138 continue;
David Brownell10f65242005-08-31 10:55:38 -0700139 temp &= ~(PORT_RWC_BITS | PORT_RESUME);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 writel (temp, &ehci->regs->port_status [i]);
141 ehci_vdbg (ehci, "resumed port %d\n", i + 1);
142 }
143 (void) readl (&ehci->regs->command);
144
145 /* maybe re-activate the schedule(s) */
146 temp = 0;
147 if (ehci->async->qh_next.qh)
148 temp |= CMD_ASE;
149 if (ehci->periodic_sched)
150 temp |= CMD_PSE;
151 if (temp) {
152 ehci->command |= temp;
153 writel (ehci->command, &ehci->regs->command);
154 }
155
156 ehci->next_statechange = jiffies + msecs_to_jiffies(5);
157 hcd->state = HC_STATE_RUNNING;
158
159 /* Now we can safely re-enable irqs */
160 if (intr_enable)
161 writel (INTR_MASK, &ehci->regs->intr_enable);
162
163 spin_unlock_irq (&ehci->lock);
164 return 0;
165}
166
167#else
168
Alan Stern0c0382e2005-10-13 17:08:02 -0400169#define ehci_bus_suspend NULL
170#define ehci_bus_resume NULL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
172#endif /* CONFIG_PM */
173
174/*-------------------------------------------------------------------------*/
175
176static int check_reset_complete (
177 struct ehci_hcd *ehci,
178 int index,
179 int port_status
180) {
181 if (!(port_status & PORT_CONNECT)) {
182 ehci->reset_done [index] = 0;
183 return port_status;
184 }
185
186 /* if reset finished and it's still not enabled -- handoff */
187 if (!(port_status & PORT_PE)) {
188
189 /* with integrated TT, there's nobody to hand it to! */
190 if (ehci_is_TDI(ehci)) {
191 ehci_dbg (ehci,
192 "Failed to enable port %d on root hub TT\n",
193 index+1);
194 return port_status;
195 }
196
197 ehci_dbg (ehci, "port %d full speed --> companion\n",
198 index + 1);
199
200 // what happens if HCS_N_CC(params) == 0 ?
201 port_status |= PORT_OWNER;
David Brownell10f65242005-08-31 10:55:38 -0700202 port_status &= ~PORT_RWC_BITS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 writel (port_status, &ehci->regs->port_status [index]);
204
205 } else
206 ehci_dbg (ehci, "port %d high speed\n", index + 1);
207
208 return port_status;
209}
210
211/*-------------------------------------------------------------------------*/
212
213
214/* build "status change" packet (one or two bytes) from HC registers */
215
216static int
217ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
218{
219 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
220 u32 temp, status = 0;
221 int ports, i, retval = 1;
222 unsigned long flags;
223
224 /* if !USB_SUSPEND, root hub timers won't get shut down ... */
225 if (!HC_IS_RUNNING(hcd->state))
226 return 0;
227
228 /* init status to no-changes */
229 buf [0] = 0;
230 ports = HCS_N_PORTS (ehci->hcs_params);
231 if (ports > 7) {
232 buf [1] = 0;
233 retval++;
234 }
David Brownell53bd6a62006-08-30 14:50:06 -0700235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 /* no hub change reports (bit 0) for now (power, ...) */
237
238 /* port N changes (bit N)? */
239 spin_lock_irqsave (&ehci->lock, flags);
240 for (i = 0; i < ports; i++) {
241 temp = readl (&ehci->regs->port_status [i]);
242 if (temp & PORT_OWNER) {
243 /* don't report this in GetPortStatus */
244 if (temp & PORT_CSC) {
David Brownell10f65242005-08-31 10:55:38 -0700245 temp &= ~PORT_RWC_BITS;
246 temp |= PORT_CSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 writel (temp, &ehci->regs->port_status [i]);
248 }
249 continue;
250 }
251 if (!(temp & PORT_CONNECT))
252 ehci->reset_done [i] = 0;
253 if ((temp & (PORT_CSC | PORT_PEC | PORT_OCC)) != 0
254 // PORT_STAT_C_SUSPEND?
255 || ((temp & PORT_RESUME) != 0
256 && time_after (jiffies,
257 ehci->reset_done [i]))) {
258 if (i < 7)
259 buf [0] |= 1 << (i + 1);
260 else
261 buf [1] |= 1 << (i - 7);
262 status = STS_PCD;
263 }
264 }
265 /* FIXME autosuspend idle root hubs */
266 spin_unlock_irqrestore (&ehci->lock, flags);
267 return status ? retval : 0;
268}
269
270/*-------------------------------------------------------------------------*/
271
272static void
273ehci_hub_descriptor (
274 struct ehci_hcd *ehci,
275 struct usb_hub_descriptor *desc
276) {
277 int ports = HCS_N_PORTS (ehci->hcs_params);
278 u16 temp;
279
280 desc->bDescriptorType = 0x29;
281 desc->bPwrOn2PwrGood = 10; /* ehci 1.0, 2.3.9 says 20ms max */
282 desc->bHubContrCurrent = 0;
283
284 desc->bNbrPorts = ports;
285 temp = 1 + (ports / 8);
286 desc->bDescLength = 7 + 2 * temp;
287
288 /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */
289 memset (&desc->bitmap [0], 0, temp);
290 memset (&desc->bitmap [temp], 0xff, temp);
291
292 temp = 0x0008; /* per-port overcurrent reporting */
293 if (HCS_PPC (ehci->hcs_params))
294 temp |= 0x0001; /* per-port power control */
David Brownell56c1e262005-04-09 09:00:29 -0700295 else
296 temp |= 0x0002; /* no power switching */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297#if 0
298// re-enable when we support USB_PORT_FEAT_INDICATOR below.
299 if (HCS_INDICATOR (ehci->hcs_params))
300 temp |= 0x0080; /* per-port indicators (LEDs) */
301#endif
302 desc->wHubCharacteristics = (__force __u16)cpu_to_le16 (temp);
303}
304
305/*-------------------------------------------------------------------------*/
306
David Brownell53bd6a62006-08-30 14:50:06 -0700307#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
309static int ehci_hub_control (
310 struct usb_hcd *hcd,
311 u16 typeReq,
312 u16 wValue,
313 u16 wIndex,
314 char *buf,
315 u16 wLength
316) {
317 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
318 int ports = HCS_N_PORTS (ehci->hcs_params);
319 u32 temp, status;
320 unsigned long flags;
321 int retval = 0;
David Brownellf0d7f272006-11-16 23:56:15 -0800322 unsigned selector;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
324 /*
325 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
326 * HCS_INDICATOR may say we can change LEDs to off/amber/green.
327 * (track current state ourselves) ... blink for diagnostics,
328 * power, "this is the one", etc. EHCI spec supports this.
329 */
330
331 spin_lock_irqsave (&ehci->lock, flags);
332 switch (typeReq) {
333 case ClearHubFeature:
334 switch (wValue) {
335 case C_HUB_LOCAL_POWER:
336 case C_HUB_OVER_CURRENT:
337 /* no hub-wide feature/status flags */
338 break;
339 default:
340 goto error;
341 }
342 break;
343 case ClearPortFeature:
344 if (!wIndex || wIndex > ports)
345 goto error;
346 wIndex--;
347 temp = readl (&ehci->regs->port_status [wIndex]);
348 if (temp & PORT_OWNER)
349 break;
350
351 switch (wValue) {
352 case USB_PORT_FEAT_ENABLE:
353 writel (temp & ~PORT_PE,
354 &ehci->regs->port_status [wIndex]);
355 break;
356 case USB_PORT_FEAT_C_ENABLE:
David Brownell10f65242005-08-31 10:55:38 -0700357 writel((temp & ~PORT_RWC_BITS) | PORT_PEC,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 &ehci->regs->port_status [wIndex]);
359 break;
360 case USB_PORT_FEAT_SUSPEND:
361 if (temp & PORT_RESET)
362 goto error;
David Brownellf8aeb3b2006-01-20 13:55:14 -0800363 if (ehci->no_selective_suspend)
364 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 if (temp & PORT_SUSPEND) {
366 if ((temp & PORT_PE) == 0)
367 goto error;
368 /* resume signaling for 20 msec */
David Brownell10f65242005-08-31 10:55:38 -0700369 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
370 writel (temp | PORT_RESUME,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 &ehci->regs->port_status [wIndex]);
372 ehci->reset_done [wIndex] = jiffies
373 + msecs_to_jiffies (20);
374 }
375 break;
376 case USB_PORT_FEAT_C_SUSPEND:
377 /* we auto-clear this feature */
378 break;
379 case USB_PORT_FEAT_POWER:
380 if (HCS_PPC (ehci->hcs_params))
David Brownell10f65242005-08-31 10:55:38 -0700381 writel (temp & ~(PORT_RWC_BITS | PORT_POWER),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 &ehci->regs->port_status [wIndex]);
383 break;
384 case USB_PORT_FEAT_C_CONNECTION:
David Brownell10f65242005-08-31 10:55:38 -0700385 writel((temp & ~PORT_RWC_BITS) | PORT_CSC,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 &ehci->regs->port_status [wIndex]);
387 break;
388 case USB_PORT_FEAT_C_OVER_CURRENT:
David Brownell10f65242005-08-31 10:55:38 -0700389 writel((temp & ~PORT_RWC_BITS) | PORT_OCC,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 &ehci->regs->port_status [wIndex]);
391 break;
392 case USB_PORT_FEAT_C_RESET:
393 /* GetPortStatus clears reset */
394 break;
395 default:
396 goto error;
397 }
398 readl (&ehci->regs->command); /* unblock posted write */
399 break;
400 case GetHubDescriptor:
401 ehci_hub_descriptor (ehci, (struct usb_hub_descriptor *)
402 buf);
403 break;
404 case GetHubStatus:
405 /* no hub-wide feature/status flags */
406 memset (buf, 0, 4);
407 //cpu_to_le32s ((u32 *) buf);
408 break;
409 case GetPortStatus:
410 if (!wIndex || wIndex > ports)
411 goto error;
412 wIndex--;
413 status = 0;
414 temp = readl (&ehci->regs->port_status [wIndex]);
415
416 // wPortChange bits
417 if (temp & PORT_CSC)
418 status |= 1 << USB_PORT_FEAT_C_CONNECTION;
419 if (temp & PORT_PEC)
420 status |= 1 << USB_PORT_FEAT_C_ENABLE;
421 if (temp & PORT_OCC)
422 status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT;
423
424 /* whoever resumes must GetPortStatus to complete it!! */
425 if ((temp & PORT_RESUME)
426 && time_after (jiffies,
427 ehci->reset_done [wIndex])) {
428 status |= 1 << USB_PORT_FEAT_C_SUSPEND;
429 ehci->reset_done [wIndex] = 0;
430
431 /* stop resume signaling */
432 temp = readl (&ehci->regs->port_status [wIndex]);
David Brownell10f65242005-08-31 10:55:38 -0700433 writel (temp & ~(PORT_RWC_BITS | PORT_RESUME),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 &ehci->regs->port_status [wIndex]);
435 retval = handshake (
436 &ehci->regs->port_status [wIndex],
437 PORT_RESUME, 0, 2000 /* 2msec */);
438 if (retval != 0) {
439 ehci_err (ehci, "port %d resume error %d\n",
440 wIndex + 1, retval);
441 goto error;
442 }
443 temp &= ~(PORT_SUSPEND|PORT_RESUME|(3<<10));
444 }
445
446 /* whoever resets must GetPortStatus to complete it!! */
447 if ((temp & PORT_RESET)
448 && time_after (jiffies,
449 ehci->reset_done [wIndex])) {
450 status |= 1 << USB_PORT_FEAT_C_RESET;
451 ehci->reset_done [wIndex] = 0;
452
453 /* force reset to complete */
David Brownell10f65242005-08-31 10:55:38 -0700454 writel (temp & ~(PORT_RWC_BITS | PORT_RESET),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 &ehci->regs->port_status [wIndex]);
David Brownellc22fa3a2005-06-13 07:15:28 -0700456 /* REVISIT: some hardware needs 550+ usec to clear
457 * this bit; seems too long to spin routinely...
458 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 retval = handshake (
460 &ehci->regs->port_status [wIndex],
David Brownellc22fa3a2005-06-13 07:15:28 -0700461 PORT_RESET, 0, 750);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 if (retval != 0) {
463 ehci_err (ehci, "port %d reset error %d\n",
464 wIndex + 1, retval);
465 goto error;
466 }
467
468 /* see what we found out */
469 temp = check_reset_complete (ehci, wIndex,
470 readl (&ehci->regs->port_status [wIndex]));
471 }
472
473 // don't show wPortStatus if it's owned by a companion hc
474 if (!(temp & PORT_OWNER)) {
475 if (temp & PORT_CONNECT) {
476 status |= 1 << USB_PORT_FEAT_CONNECTION;
477 // status may be from integrated TT
478 status |= ehci_port_speed(ehci, temp);
479 }
480 if (temp & PORT_PE)
481 status |= 1 << USB_PORT_FEAT_ENABLE;
482 if (temp & (PORT_SUSPEND|PORT_RESUME))
483 status |= 1 << USB_PORT_FEAT_SUSPEND;
484 if (temp & PORT_OC)
485 status |= 1 << USB_PORT_FEAT_OVER_CURRENT;
486 if (temp & PORT_RESET)
487 status |= 1 << USB_PORT_FEAT_RESET;
488 if (temp & PORT_POWER)
489 status |= 1 << USB_PORT_FEAT_POWER;
490 }
491
492#ifndef EHCI_VERBOSE_DEBUG
493 if (status & ~0xffff) /* only if wPortChange is interesting */
494#endif
495 dbg_port (ehci, "GetStatus", wIndex + 1, temp);
496 // we "know" this alignment is good, caller used kmalloc()...
497 *((__le32 *) buf) = cpu_to_le32 (status);
498 break;
499 case SetHubFeature:
500 switch (wValue) {
501 case C_HUB_LOCAL_POWER:
502 case C_HUB_OVER_CURRENT:
503 /* no hub-wide feature/status flags */
504 break;
505 default:
506 goto error;
507 }
508 break;
509 case SetPortFeature:
David Brownellf0d7f272006-11-16 23:56:15 -0800510 selector = wIndex >> 8;
511 wIndex &= 0xff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 if (!wIndex || wIndex > ports)
513 goto error;
514 wIndex--;
515 temp = readl (&ehci->regs->port_status [wIndex]);
516 if (temp & PORT_OWNER)
517 break;
518
David Brownell10f65242005-08-31 10:55:38 -0700519 temp &= ~PORT_RWC_BITS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 switch (wValue) {
521 case USB_PORT_FEAT_SUSPEND:
David Brownellf8aeb3b2006-01-20 13:55:14 -0800522 if (ehci->no_selective_suspend)
523 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 if ((temp & PORT_PE) == 0
525 || (temp & PORT_RESET) != 0)
526 goto error;
David Brownell2c1c3c42005-11-07 15:24:46 -0800527 if (device_may_wakeup(&hcd->self.root_hub->dev))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 temp |= PORT_WAKE_BITS;
529 writel (temp | PORT_SUSPEND,
530 &ehci->regs->port_status [wIndex]);
531 break;
532 case USB_PORT_FEAT_POWER:
533 if (HCS_PPC (ehci->hcs_params))
534 writel (temp | PORT_POWER,
535 &ehci->regs->port_status [wIndex]);
536 break;
537 case USB_PORT_FEAT_RESET:
538 if (temp & PORT_RESUME)
539 goto error;
540 /* line status bits may report this as low speed,
541 * which can be fine if this root hub has a
542 * transaction translator built in.
543 */
544 if ((temp & (PORT_PE|PORT_CONNECT)) == PORT_CONNECT
545 && !ehci_is_TDI(ehci)
546 && PORT_USB11 (temp)) {
547 ehci_dbg (ehci,
548 "port %d low speed --> companion\n",
549 wIndex + 1);
550 temp |= PORT_OWNER;
551 } else {
552 ehci_vdbg (ehci, "port %d reset\n", wIndex + 1);
553 temp |= PORT_RESET;
554 temp &= ~PORT_PE;
555
556 /*
557 * caller must wait, then call GetPortStatus
558 * usb 2.0 spec says 50 ms resets on root
559 */
560 ehci->reset_done [wIndex] = jiffies
561 + msecs_to_jiffies (50);
562 }
563 writel (temp, &ehci->regs->port_status [wIndex]);
564 break;
David Brownellf0d7f272006-11-16 23:56:15 -0800565
566 /* For downstream facing ports (these): one hub port is put
567 * into test mode according to USB2 11.24.2.13, then the hub
568 * must be reset (which for root hub now means rmmod+modprobe,
569 * or else system reboot). See EHCI 2.3.9 and 4.14 for info
570 * about the EHCI-specific stuff.
571 */
572 case USB_PORT_FEAT_TEST:
573 if (!selector || selector > 5)
574 goto error;
575 ehci_quiesce(ehci);
576 ehci_halt(ehci);
577 temp |= selector << 16;
578 writel (temp, &ehci->regs->port_status [wIndex]);
579 break;
580
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 default:
582 goto error;
583 }
584 readl (&ehci->regs->command); /* unblock posted writes */
585 break;
586
587 default:
588error:
589 /* "stall" on error */
590 retval = -EPIPE;
591 }
592 spin_unlock_irqrestore (&ehci->lock, flags);
593 return retval;
594}