vserver 1.9.3
[linux-2.6.git] / drivers / usb / host / ohci-hub.c
1 /*
2  * OHCI HCD (Host Controller Driver) for USB.
3  * 
4  * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5  * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6  * 
7  * This file is licenced under GPL
8  */
9
10 /*-------------------------------------------------------------------------*/
11
12 /*
13  * OHCI Root Hub ... the nonsharable stuff
14  *
15  * Registers don't need cpu_to_le32, that happens transparently
16  */
17
18 /* AMD-756 (D2 rev) reports corrupt register contents in some cases.
19  * The erratum (#4) description is incorrect.  AMD's workaround waits
20  * till some bits (mostly reserved) are clear; ok for all revs.
21  */
22 #define read_roothub(hc, register, mask) ({ \
23         u32 temp = ohci_readl (&hc->regs->roothub.register); \
24         if (temp == -1) \
25                 disable (hc); \
26         else if (hc->flags & OHCI_QUIRK_AMD756) \
27                 while (temp & mask) \
28                         temp = ohci_readl (&hc->regs->roothub.register); \
29         temp; })
30
31 static u32 roothub_a (struct ohci_hcd *hc)
32         { return read_roothub (hc, a, 0xfc0fe000); }
33 static inline u32 roothub_b (struct ohci_hcd *hc)
34         { return ohci_readl (&hc->regs->roothub.b); }
35 static inline u32 roothub_status (struct ohci_hcd *hc)
36         { return ohci_readl (&hc->regs->roothub.status); }
37 static u32 roothub_portstatus (struct ohci_hcd *hc, int i)
38         { return read_roothub (hc, portstatus [i], 0xffe0fce0); }
39
40 /*-------------------------------------------------------------------------*/
41
42 #define dbg_port(hc,label,num,value) \
43         ohci_dbg (hc, \
44                 "%s roothub.portstatus [%d] " \
45                 "= 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s\n", \
46                 label, num, temp, \
47                 (temp & RH_PS_PRSC) ? " PRSC" : "", \
48                 (temp & RH_PS_OCIC) ? " OCIC" : "", \
49                 (temp & RH_PS_PSSC) ? " PSSC" : "", \
50                 (temp & RH_PS_PESC) ? " PESC" : "", \
51                 (temp & RH_PS_CSC) ? " CSC" : "", \
52                 \
53                 (temp & RH_PS_LSDA) ? " LSDA" : "", \
54                 (temp & RH_PS_PPS) ? " PPS" : "", \
55                 (temp & RH_PS_PRS) ? " PRS" : "", \
56                 (temp & RH_PS_POCI) ? " POCI" : "", \
57                 (temp & RH_PS_PSS) ? " PSS" : "", \
58                 \
59                 (temp & RH_PS_PES) ? " PES" : "", \
60                 (temp & RH_PS_CCS) ? " CCS" : "" \
61                 );
62
63 /*-------------------------------------------------------------------------*/
64
65 #if     defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM)
66
67 #define OHCI_SCHED_ENABLES \
68         (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE)
69
70 static void dl_done_list (struct ohci_hcd *, struct pt_regs *);
71 static void finish_unlinks (struct ohci_hcd *, u16 , struct pt_regs *);
72
73 static int ohci_hub_suspend (struct usb_hcd *hcd)
74 {
75         struct ohci_hcd         *ohci = hcd_to_ohci (hcd);
76         struct usb_device       *root = hcd_to_bus (&ohci->hcd)->root_hub;
77         int                     status = 0;
78
79         if (root->dev.power.power_state != 0)
80                 return 0;
81         if (time_before (jiffies, ohci->next_statechange))
82                 return -EAGAIN;
83
84         spin_lock_irq (&ohci->lock);
85
86         ohci->hc_control = ohci_readl (&ohci->regs->control);
87         switch (ohci->hc_control & OHCI_CTRL_HCFS) {
88         case OHCI_USB_RESUME:
89                 ohci_dbg (ohci, "resume/suspend?\n");
90                 ohci->hc_control &= ~OHCI_CTRL_HCFS;
91                 ohci->hc_control |= OHCI_USB_RESET;
92                 writel (ohci->hc_control, &ohci->regs->control);
93                 (void) ohci_readl (&ohci->regs->control);
94                 /* FALL THROUGH */
95         case OHCI_USB_RESET:
96                 status = -EBUSY;
97                 ohci_dbg (ohci, "needs reinit!\n");
98                 goto done;
99         case OHCI_USB_SUSPEND:
100                 ohci_dbg (ohci, "already suspended?\n");
101                 goto succeed;
102         }
103         ohci_dbg (ohci, "suspend root hub\n");
104
105         /* First stop any processing */
106         ohci->hcd.state = USB_STATE_QUIESCING;
107         if (ohci->hc_control & OHCI_SCHED_ENABLES) {
108                 int             limit;
109
110                 ohci->hc_control &= ~OHCI_SCHED_ENABLES;
111                 writel (ohci->hc_control, &ohci->regs->control);
112                 ohci->hc_control = ohci_readl (&ohci->regs->control);
113                 writel (OHCI_INTR_SF, &ohci->regs->intrstatus);
114
115                 /* sched disables take effect on the next frame,
116                  * then the last WDH could take 6+ msec
117                  */
118                 ohci_dbg (ohci, "stopping schedules ...\n");
119                 limit = 2000;
120                 while (limit > 0) {
121                         udelay (250);
122                         limit =- 250;
123                         if (ohci_readl (&ohci->regs->intrstatus) & OHCI_INTR_SF)
124                                 break;
125                 }
126                 dl_done_list (ohci, NULL);
127                 mdelay (7);
128         }
129         dl_done_list (ohci, NULL);
130         finish_unlinks (ohci, OHCI_FRAME_NO(ohci->hcca), NULL);
131         writel (ohci_readl (&ohci->regs->intrstatus), &ohci->regs->intrstatus);
132
133         /* maybe resume can wake root hub */
134         if (ohci->hcd.remote_wakeup)
135                 ohci->hc_control |= OHCI_CTRL_RWE;
136         else
137                 ohci->hc_control &= ~OHCI_CTRL_RWE;
138
139         /* Suspend hub */
140         ohci->hc_control &= ~OHCI_CTRL_HCFS;
141         ohci->hc_control |= OHCI_USB_SUSPEND;
142         writel (ohci->hc_control, &ohci->regs->control);
143         (void) ohci_readl (&ohci->regs->control);
144
145         /* no resumes until devices finish suspending */
146         ohci->next_statechange = jiffies + msecs_to_jiffies (5);
147
148 succeed:
149         /* it's not USB_STATE_SUSPENDED unless access to this
150          * hub from the non-usb side (PCI, SOC, etc) stopped 
151          */
152         root->dev.power.power_state = 3;
153 done:
154         spin_unlock_irq (&ohci->lock);
155         return status;
156 }
157
158 static inline struct ed *find_head (struct ed *ed)
159 {
160         /* for bulk and control lists */
161         while (ed->ed_prev)
162                 ed = ed->ed_prev;
163         return ed;
164 }
165
166 static int hc_restart (struct ohci_hcd *ohci);
167
168 /* caller owns root->serialize */
169 static int ohci_hub_resume (struct usb_hcd *hcd)
170 {
171         struct ohci_hcd         *ohci = hcd_to_ohci (hcd);
172         struct usb_device       *root = hcd_to_bus (&ohci->hcd)->root_hub;
173         u32                     temp, enables;
174         int                     status = -EINPROGRESS;
175
176         if (!root->dev.power.power_state)
177                 return 0;
178         if (time_before (jiffies, ohci->next_statechange))
179                 return -EAGAIN;
180
181         spin_lock_irq (&ohci->lock);
182         ohci->hc_control = ohci_readl (&ohci->regs->control);
183         switch (ohci->hc_control & OHCI_CTRL_HCFS) {
184         case OHCI_USB_SUSPEND:
185                 ohci->hc_control &= ~(OHCI_CTRL_HCFS|OHCI_SCHED_ENABLES);
186                 ohci->hc_control |= OHCI_USB_RESUME;
187                 writel (ohci->hc_control, &ohci->regs->control);
188                 (void) ohci_readl (&ohci->regs->control);
189                 ohci_dbg (ohci, "resume root hub\n");
190                 break;
191         case OHCI_USB_RESUME:
192                 /* HCFS changes sometime after INTR_RD */
193                 ohci_info (ohci, "wakeup\n");
194                 break;
195         case OHCI_USB_OPER:
196                 ohci_dbg (ohci, "odd resume\n");
197                 root->dev.power.power_state = 0;
198                 status = 0;
199                 break;
200         default:                /* RESET, we lost power */
201                 ohci_dbg (ohci, "root hub hardware reset\n");
202                 status = -EBUSY;
203         }
204         spin_unlock_irq (&ohci->lock);
205         if (status == -EBUSY)
206                 return hc_restart (ohci);
207         if (status != -EINPROGRESS)
208                 return status;
209
210         temp = roothub_a (ohci) & RH_A_NDP;
211         enables = 0;
212         while (temp--) {
213                 u32 stat = ohci_readl (&ohci->regs->roothub.portstatus [temp]);
214
215                 /* force global, not selective, resume */
216                 if (!(stat & RH_PS_PSS))
217                         continue;
218                 writel (RH_PS_POCI, &ohci->regs->roothub.portstatus [temp]);
219         }
220
221         /* Some controllers (lucent) need extra-long delays */
222         ohci->hcd.state = USB_STATE_RESUMING;
223         mdelay (20 /* usb 11.5.1.10 */ + 15);
224
225         temp = ohci_readl (&ohci->regs->control);
226         temp &= OHCI_CTRL_HCFS;
227         if (temp != OHCI_USB_RESUME) {
228                 ohci_err (ohci, "controller won't resume\n");
229                 return -EBUSY;
230         }
231
232         /* disable old schedule state, reinit from scratch */
233         writel (0, &ohci->regs->ed_controlhead);
234         writel (0, &ohci->regs->ed_controlcurrent);
235         writel (0, &ohci->regs->ed_bulkhead);
236         writel (0, &ohci->regs->ed_bulkcurrent);
237         writel (0, &ohci->regs->ed_periodcurrent);
238         writel ((u32) ohci->hcca_dma, &ohci->regs->hcca);
239
240         periodic_reinit (ohci);
241
242         /* interrupts might have been disabled */
243         writel (OHCI_INTR_INIT, &ohci->regs->intrenable);
244         if (ohci->ed_rm_list)
245                 writel (OHCI_INTR_SF, &ohci->regs->intrenable);
246         writel (ohci_readl (&ohci->regs->intrstatus), &ohci->regs->intrstatus);
247
248         /* Then re-enable operations */
249         writel (OHCI_USB_OPER, &ohci->regs->control);
250         (void) ohci_readl (&ohci->regs->control);
251         msleep (3);
252
253         temp = OHCI_CONTROL_INIT | OHCI_USB_OPER;
254         if (ohci->hcd.can_wakeup)
255                 temp |= OHCI_CTRL_RWC;
256         ohci->hc_control = temp;
257         writel (temp, &ohci->regs->control);
258         (void) ohci_readl (&ohci->regs->control);
259
260         /* TRSMRCY */
261         msleep (10);
262         root->dev.power.power_state = 0;
263
264         /* keep it alive for ~5x suspend + resume costs */
265         ohci->next_statechange = jiffies + msecs_to_jiffies (250);
266
267         /* maybe turn schedules back on */
268         enables = 0;
269         temp = 0;
270         if (!ohci->ed_rm_list) {
271                 if (ohci->ed_controltail) {
272                         writel (find_head (ohci->ed_controltail)->dma,
273                                 &ohci->regs->ed_controlhead);
274                         enables |= OHCI_CTRL_CLE;
275                         temp |= OHCI_CLF;
276                 }
277                 if (ohci->ed_bulktail) {
278                         writel (find_head (ohci->ed_bulktail)->dma,
279                                 &ohci->regs->ed_bulkhead);
280                         enables |= OHCI_CTRL_BLE;
281                         temp |= OHCI_BLF;
282                 }
283         }
284         if (hcd_to_bus (&ohci->hcd)->bandwidth_isoc_reqs
285                         || hcd_to_bus (&ohci->hcd)->bandwidth_int_reqs)
286                 enables |= OHCI_CTRL_PLE|OHCI_CTRL_IE;
287         if (enables) {
288                 ohci_dbg (ohci, "restarting schedules ... %08x\n", enables);
289                 ohci->hc_control |= enables;
290                 writel (ohci->hc_control, &ohci->regs->control);
291                 if (temp)
292                         writel (status, &ohci->regs->cmdstatus);
293                 (void) ohci_readl (&ohci->regs->control);
294         }
295
296         ohci->hcd.state = USB_STATE_RUNNING;
297         return 0;
298 }
299
300 static void ohci_rh_resume (void *_hcd)
301 {
302         struct usb_hcd  *hcd = _hcd;
303
304         down (&hcd->self.root_hub->serialize);
305         (void) ohci_hub_resume (hcd);
306         up (&hcd->self.root_hub->serialize);
307 }
308
309 #else
310
311 static void ohci_rh_resume (void *_hcd)
312 {
313         struct ohci_hcd *ohci = hcd_to_ohci (_hcd);
314         ohci_dbg(ohci, "rh_resume ??\n");
315 }
316
317 #endif  /* CONFIG_USB_SUSPEND || CONFIG_PM */
318
319 /*-------------------------------------------------------------------------*/
320
321 /* build "status change" packet (one or two bytes) from HC registers */
322
323 static int
324 ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
325 {
326         struct ohci_hcd *ohci = hcd_to_ohci (hcd);
327         int             ports, i, changed = 0, length = 1;
328         int             can_suspend = 1;
329
330         ports = roothub_a (ohci) & RH_A_NDP; 
331         if (ports > MAX_ROOT_PORTS) {
332                 if (!HCD_IS_RUNNING(ohci->hcd.state))
333                         return -ESHUTDOWN;
334                 ohci_err (ohci, "bogus NDP=%d, rereads as NDP=%d\n",
335                         ports, ohci_readl (&ohci->regs->roothub.a) & RH_A_NDP);
336                 /* retry later; "should not happen" */
337                 return 0;
338         }
339
340         /* init status */
341         if (roothub_status (ohci) & (RH_HS_LPSC | RH_HS_OCIC))
342                 buf [0] = changed = 1;
343         else
344                 buf [0] = 0;
345         if (ports > 7) {
346                 buf [1] = 0;
347                 length++;
348         }
349
350         /* look at each port */
351         for (i = 0; i < ports; i++) {
352                 u32     status = roothub_portstatus (ohci, i);
353
354                 if (status & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC
355                                 | RH_PS_OCIC | RH_PS_PRSC)) {
356                         changed = 1;
357                         if (i < 7)
358                             buf [0] |= 1 << (i + 1);
359                         else
360                             buf [1] |= 1 << (i - 7);
361                         continue;
362                 }
363
364                 /* can suspend if no ports are enabled; or if all all
365                  * enabled ports are suspended AND remote wakeup is on.
366                  */
367                 if (!(status & RH_PS_CCS))
368                         continue;
369                 if ((status & RH_PS_PSS) && ohci->hcd.remote_wakeup)
370                         continue;
371                 can_suspend = 0;
372         }
373
374 #ifdef CONFIG_PM
375         /* save power by suspending idle root hubs;
376          * INTR_RD wakes us when there's work
377          */
378         if (can_suspend
379                         && !changed
380                         && !ohci->ed_rm_list
381                         && ((OHCI_CTRL_HCFS | OHCI_SCHED_ENABLES)
382                                         & ohci->hc_control)
383                                 == OHCI_USB_OPER
384                         && down_trylock (&hcd->self.root_hub->serialize) == 0
385                         ) {
386                 ohci_vdbg (ohci, "autosuspend\n");
387                 (void) ohci_hub_suspend (&ohci->hcd);
388                 ohci->hcd.state = USB_STATE_RUNNING;
389                 up (&hcd->self.root_hub->serialize);
390         }
391 #endif
392
393         return changed ? length : 0;
394 }
395
396 /*-------------------------------------------------------------------------*/
397
398 static void
399 ohci_hub_descriptor (
400         struct ohci_hcd                 *ohci,
401         struct usb_hub_descriptor       *desc
402 ) {
403         u32             rh = roothub_a (ohci);
404         int             ports = rh & RH_A_NDP; 
405         u16             temp;
406
407         desc->bDescriptorType = 0x29;
408         desc->bPwrOn2PwrGood = (rh & RH_A_POTPGT) >> 24;
409         desc->bHubContrCurrent = 0;
410
411         desc->bNbrPorts = ports;
412         temp = 1 + (ports / 8);
413         desc->bDescLength = 7 + 2 * temp;
414
415         temp = 0;
416         if (rh & RH_A_NPS)              /* no power switching? */
417             temp |= 0x0002;
418         if (rh & RH_A_PSM)              /* per-port power switching? */
419             temp |= 0x0001;
420         if (rh & RH_A_NOCP)             /* no overcurrent reporting? */
421             temp |= 0x0010;
422         else if (rh & RH_A_OCPM)        /* per-port overcurrent reporting? */
423             temp |= 0x0008;
424         desc->wHubCharacteristics = cpu_to_le16 (temp);
425
426         /* two bitmaps:  ports removable, and usb 1.0 legacy PortPwrCtrlMask */
427         rh = roothub_b (ohci);
428         desc->bitmap [0] = rh & RH_B_DR;
429         if (ports > 7) {
430                 desc->bitmap [1] = (rh & RH_B_DR) >> 8;
431                 desc->bitmap [2] = desc->bitmap [3] = 0xff;
432         } else
433                 desc->bitmap [1] = 0xff;
434 }
435
436 /*-------------------------------------------------------------------------*/
437
438 #ifdef  CONFIG_USB_OTG
439
440 static int ohci_start_port_reset (struct usb_hcd *hcd, unsigned port)
441 {
442         struct ohci_hcd *ohci = hcd_to_ohci (hcd);
443         u32                     status;
444
445         if (!port)
446                 return -EINVAL;
447         port--;
448
449         /* start port reset before HNP protocol times out */
450         status = ohci_readl(&ohci->regs->roothub.portstatus [port]);
451         if (!(status & RH_PS_CCS))
452                 return -ENODEV;
453
454         /* khubd will finish the reset later */
455         writel(RH_PS_PRS, &ohci->regs->roothub.portstatus [port]);
456         return 0;
457 }
458
459 static void start_hnp(struct ohci_hcd *ohci);
460
461 #else
462
463 #define ohci_start_port_reset           NULL
464
465 #endif
466
467 /*-------------------------------------------------------------------------*/
468
469
470 /* See usb 7.1.7.5:  root hubs must issue at least 50 msec reset signaling,
471  * not necessarily continuous ... to guard against resume signaling.
472  * The short timeout is safe for non-root hubs, and is backward-compatible
473  * with earlier Linux hosts.
474  */
475 #ifdef  CONFIG_USB_SUSPEND
476 #define PORT_RESET_MSEC         50
477 #else
478 #define PORT_RESET_MSEC         10
479 #endif
480
481 /* this timer value might be vendor-specific ... */
482 #define PORT_RESET_HW_MSEC      10
483
484 /* wrap-aware logic stolen from <linux/jiffies.h> */
485 #define tick_before(t1,t2) ((((s16)(t1))-((s16)(t2))) < 0)
486
487 /* called from some task, normally khubd */
488 static inline void root_port_reset (struct ohci_hcd *ohci, unsigned port)
489 {
490         u32 __iomem *portstat = &ohci->regs->roothub.portstatus [port];
491         u32     temp;
492         u16     now = readl(&ohci->regs->fmnumber);
493         u16     reset_done = now + PORT_RESET_MSEC;
494
495         /* build a "continuous enough" reset signal, with up to
496          * 3msec gap between pulses.  scheduler HZ==100 must work;
497          * this might need to be deadline-scheduled.
498          */
499         do {
500                 /* spin until any current reset finishes */
501                 for (;;) {
502                         temp = ohci_readl (portstat);
503                         if (!(temp & RH_PS_PRS))
504                                 break;
505                         udelay (500);
506                 } 
507
508                 if (!(temp & RH_PS_CCS))
509                         break;
510                 if (temp & RH_PS_PRSC)
511                         writel (RH_PS_PRSC, portstat);
512
513                 /* start the next reset, sleep till it's probably done */
514                 writel (RH_PS_PRS, portstat);
515                 msleep(PORT_RESET_HW_MSEC);
516                 now = readl(&ohci->regs->fmnumber);
517         } while (tick_before(now, reset_done));
518         /* caller synchronizes using PRSC */
519 }
520
521 static int ohci_hub_control (
522         struct usb_hcd  *hcd,
523         u16             typeReq,
524         u16             wValue,
525         u16             wIndex,
526         char            *buf,
527         u16             wLength
528 ) {
529         struct ohci_hcd *ohci = hcd_to_ohci (hcd);
530         int             ports = hcd_to_bus (hcd)->root_hub->maxchild;
531         u32             temp;
532         int             retval = 0;
533
534         switch (typeReq) {
535         case ClearHubFeature:
536                 switch (wValue) {
537                 case C_HUB_OVER_CURRENT:
538                         writel (RH_HS_OCIC, &ohci->regs->roothub.status);
539                 case C_HUB_LOCAL_POWER:
540                         break;
541                 default:
542                         goto error;
543                 }
544                 break;
545         case ClearPortFeature:
546                 if (!wIndex || wIndex > ports)
547                         goto error;
548                 wIndex--;
549
550                 switch (wValue) {
551                 case USB_PORT_FEAT_ENABLE:
552                         temp = RH_PS_CCS;
553                         break;
554                 case USB_PORT_FEAT_C_ENABLE:
555                         temp = RH_PS_PESC;
556                         break;
557                 case USB_PORT_FEAT_SUSPEND:
558                         temp = RH_PS_POCI;
559                         if ((ohci->hc_control & OHCI_CTRL_HCFS)
560                                         != OHCI_USB_OPER)
561                                 schedule_work (&ohci->rh_resume);
562                         break;
563                 case USB_PORT_FEAT_C_SUSPEND:
564                         temp = RH_PS_PSSC;
565                         break;
566                 case USB_PORT_FEAT_POWER:
567                         temp = RH_PS_LSDA;
568                         break;
569                 case USB_PORT_FEAT_C_CONNECTION:
570                         temp = RH_PS_CSC;
571                         break;
572                 case USB_PORT_FEAT_C_OVER_CURRENT:
573                         temp = RH_PS_OCIC;
574                         break;
575                 case USB_PORT_FEAT_C_RESET:
576                         temp = RH_PS_PRSC;
577                         break;
578                 default:
579                         goto error;
580                 }
581                 writel (temp, &ohci->regs->roothub.portstatus [wIndex]);
582                 // ohci_readl (&ohci->regs->roothub.portstatus [wIndex]);
583                 break;
584         case GetHubDescriptor:
585                 ohci_hub_descriptor (ohci, (struct usb_hub_descriptor *) buf);
586                 break;
587         case GetHubStatus:
588                 temp = roothub_status (ohci) & ~(RH_HS_CRWE | RH_HS_DRWE);
589                 *(__le32 *) buf = cpu_to_le32 (temp);
590                 break;
591         case GetPortStatus:
592                 if (!wIndex || wIndex > ports)
593                         goto error;
594                 wIndex--;
595                 temp = roothub_portstatus (ohci, wIndex);
596                 *(__le32 *) buf = cpu_to_le32 (temp);
597
598 #ifndef OHCI_VERBOSE_DEBUG
599         if (*(u16*)(buf+2))     /* only if wPortChange is interesting */
600 #endif
601                 dbg_port (ohci, "GetStatus", wIndex, temp);
602                 break;
603         case SetHubFeature:
604                 switch (wValue) {
605                 case C_HUB_OVER_CURRENT:
606                         // FIXME:  this can be cleared, yes?
607                 case C_HUB_LOCAL_POWER:
608                         break;
609                 default:
610                         goto error;
611                 }
612                 break;
613         case SetPortFeature:
614                 if (!wIndex || wIndex > ports)
615                         goto error;
616                 wIndex--;
617                 switch (wValue) {
618                 case USB_PORT_FEAT_SUSPEND:
619 #ifdef  CONFIG_USB_OTG
620                         if (ohci->hcd.self.otg_port == (wIndex + 1)
621                                         && ohci->hcd.self.b_hnp_enable)
622                                 start_hnp(ohci);
623                         else
624 #endif
625                         writel (RH_PS_PSS,
626                                 &ohci->regs->roothub.portstatus [wIndex]);
627                         break;
628                 case USB_PORT_FEAT_POWER:
629                         writel (RH_PS_PPS,
630                                 &ohci->regs->roothub.portstatus [wIndex]);
631                         break;
632                 case USB_PORT_FEAT_RESET:
633                         root_port_reset (ohci, wIndex);
634                         break;
635                 default:
636                         goto error;
637                 }
638                 break;
639
640         default:
641 error:
642                 /* "protocol stall" on error */
643                 retval = -EPIPE;
644         }
645         return retval;
646 }
647