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