765b5ddf75ee49da945bf3c02f23d8a7a1147274
[oweals/u-boot.git] / drivers / usb / usb_ehci_core.c
1 /*-
2  * Copyright (c) 2007-2008, Juniper Networks, Inc.
3  * Copyright (c) 2008, Excito Elektronik i Skåne AB
4  * All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation version 2 of
9  * the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19  * MA 02111-1307 USA
20  */
21
22 #include <common.h>
23 #include <usb.h>
24 #include <asm/io.h>
25 #include "usb_ehci.h"
26
27 int rootdev;
28 struct ehci_hccr *hccr;         /* R/O registers, not need for volatile */
29 volatile struct ehci_hcor *hcor;
30
31 static uint16_t portreset;
32 static struct QH qh_list __attribute__((aligned(32)));
33
34 struct usb_device_descriptor device = {
35         sizeof(struct usb_device_descriptor),   /* bLength */
36         1,              /* bDescriptorType: UDESC_DEVICE */
37         0x0002,         /* bcdUSB: v2.0 */
38         9,              /* bDeviceClass: UDCLASS_HUB */
39         0,              /* bDeviceSubClass: UDSUBCLASS_HUB */
40         1,              /* bDeviceProtocol: UDPROTO_HSHUBSTT */
41         64,             /* bMaxPacketSize: 64 bytes */
42         0x0000,         /* idVendor */
43         0x0000,         /* idProduct */
44         0x0001,         /* bcdDevice */
45         1,              /* iManufacturer */
46         2,              /* iProduct */
47         0,              /* iSerialNumber */
48         1               /* bNumConfigurations: 1 */
49 };
50
51 struct usb_config_descriptor config = {
52         sizeof(struct usb_config_descriptor),
53         2,              /* bDescriptorType: UDESC_CONFIG */
54         sizeof(struct usb_config_descriptor) +
55         sizeof(struct usb_interface_descriptor) +
56         sizeof(struct usb_endpoint_descriptor),
57         0,
58         1,              /* bNumInterface */
59         1,              /* bConfigurationValue */
60         0,              /* iConfiguration */
61         0x40,           /* bmAttributes: UC_SELF_POWER */
62         0               /* bMaxPower */
63 };
64
65 struct usb_interface_descriptor interface = {
66         sizeof(struct usb_interface_descriptor),        /* bLength */
67         4,              /* bDescriptorType: UDESC_INTERFACE */
68         0,              /* bInterfaceNumber */
69         0,              /* bAlternateSetting */
70         1,              /* bNumEndpoints */
71         9,              /* bInterfaceClass: UICLASS_HUB */
72         0,              /* bInterfaceSubClass: UISUBCLASS_HUB */
73         0,              /* bInterfaceProtocol: UIPROTO_HSHUBSTT */
74         0               /* iInterface */
75 };
76
77 struct usb_endpoint_descriptor endpoint = {
78 sizeof(struct usb_endpoint_descriptor), /* bLength */
79         5,              /* bDescriptorType: UDESC_ENDPOINT */
80         0x81,           /* bEndpointAddress: UE_DIR_IN | EHCI_INTR_ENDPT */
81         3,              /* bmAttributes: UE_INTERRUPT */
82         8, 0,           /* wMaxPacketSize */
83         255             /* bInterval */
84 };
85
86 struct usb_hub_descriptor hub = {
87         sizeof(struct usb_hub_descriptor),      /* bDescLength */
88         0x29,           /* bDescriptorType: hub descriptor */
89         2,              /* bNrPorts -- runtime modified */
90         0, 0,           /* wHubCharacteristics */
91         0xff,           /* bPwrOn2PwrGood */
92         {},             /* bHubCntrCurrent */
93         {}              /* at most 7 ports! XXX */
94 };
95
96 static void *ehci_alloc(size_t sz, size_t align)
97 {
98         static struct QH qh __attribute__((aligned(32)));
99         static struct qTD td[3] __attribute__((aligned (32)));
100         static int ntds;
101         void *p;
102
103         switch (sz) {
104         case sizeof(struct QH):
105                 p = &qh;
106                 ntds = 0;
107                 break;
108         case sizeof(struct qTD):
109                 if (ntds == 3) {
110                         debug("out of TDs");
111                         return NULL;
112                 }
113                 p = &td[ntds];
114                 ntds++;
115                 break;
116         default:
117                 debug("unknown allocation size");
118                 return NULL;
119         }
120
121         memset(p, sz, 0);
122         return p;
123 }
124
125 static void ehci_free(void *p, size_t sz)
126 {
127 }
128
129 static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz)
130 {
131         uint32_t addr, delta, next;
132         int idx;
133
134         addr = (uint32_t) buf;
135         idx = 0;
136         while (idx < 5) {
137                 td->qt_buffer[idx] = cpu_to_le32(addr);
138                 next = (addr + 4096) & ~4095;
139                 delta = next - addr;
140                 if (delta >= sz)
141                         break;
142                 sz -= delta;
143                 addr = next;
144                 idx++;
145         }
146
147         if (idx == 5) {
148                 debug("out of buffer pointers (%u bytes left)", sz);
149                 return -1;
150         }
151
152         return 0;
153 }
154
155 static int
156 ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
157                    int length, struct devrequest *req)
158 {
159         struct QH *qh;
160         struct qTD *td;
161         volatile struct qTD *vtd;
162         unsigned long ts;
163         uint32_t *tdp;
164         uint32_t endpt, token, usbsts;
165         uint32_t c, toggle;
166
167         debug("dev=%p, pipe=%lx, buffer=%p, length=%d, req=%p", dev, pipe,
168               buffer, length, req);
169         if (req != NULL)
170                 debug("req=%u (%#x), type=%u (%#x), value=%u (%#x), index=%u",
171                       req->request, req->request,
172                       req->requesttype, req->requesttype,
173                       le16_to_cpu(req->value), le16_to_cpu(req->value),
174                       le16_to_cpu(req->index), le16_to_cpu(req->index));
175
176         qh = ehci_alloc(sizeof(struct QH), 32);
177         if (qh == NULL) {
178                 debug("unable to allocate QH");
179                 return -1;
180         }
181         qh->qh_link = cpu_to_le32((uint32_t)&qh_list | QH_LINK_TYPE_QH);
182         c = (usb_pipespeed(pipe) != USB_SPEED_HIGH &&
183              usb_pipeendpoint(pipe) == 0) ? 1 : 0;
184         endpt = (8 << 28) |
185             (c << 27) |
186             (usb_maxpacket(dev, pipe) << 16) |
187             (0 << 15) |
188             (1 << 14) |
189             (usb_pipespeed(pipe) << 12) |
190             (usb_pipeendpoint(pipe) << 8) |
191             (0 << 7) | (usb_pipedevice(pipe) << 0);
192         qh->qh_endpt1 = cpu_to_le32(endpt);
193         endpt = (1 << 30) |
194             (dev->portnr << 23) |
195             (dev->parent->devnum << 16) | (0 << 8) | (0 << 0);
196         qh->qh_endpt2 = cpu_to_le32(endpt);
197         qh->qh_overlay.qt_next = cpu_to_le32(QT_NEXT_TERMINATE);
198         qh->qh_overlay.qt_altnext = cpu_to_le32(QT_NEXT_TERMINATE);
199
200         td = NULL;
201         tdp = &qh->qh_overlay.qt_next;
202
203         toggle =
204             usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe));
205
206         if (req != NULL) {
207                 td = ehci_alloc(sizeof(struct qTD), 32);
208                 if (td == NULL) {
209                         debug("unable to allocate SETUP td");
210                         goto fail;
211                 }
212                 td->qt_next = cpu_to_le32(QT_NEXT_TERMINATE);
213                 td->qt_altnext = cpu_to_le32(QT_NEXT_TERMINATE);
214                 token = (0 << 31) |
215                     (sizeof(*req) << 16) |
216                     (0 << 15) | (0 << 12) | (3 << 10) | (2 << 8) | (0x80 << 0);
217                 td->qt_token = cpu_to_le32(token);
218                 if (ehci_td_buffer(td, req, sizeof(*req)) != 0) {
219                         debug("unable construct SETUP td");
220                         ehci_free(td, sizeof(*td));
221                         goto fail;
222                 }
223                 *tdp = cpu_to_le32((uint32_t) td);
224                 tdp = &td->qt_next;
225                 toggle = 1;
226         }
227
228         if (length > 0 || req == NULL) {
229                 td = ehci_alloc(sizeof(struct qTD), 32);
230                 if (td == NULL) {
231                         debug("unable to allocate DATA td");
232                         goto fail;
233                 }
234                 td->qt_next = cpu_to_le32(QT_NEXT_TERMINATE);
235                 td->qt_altnext = cpu_to_le32(QT_NEXT_TERMINATE);
236                 token = (toggle << 31) |
237                     (length << 16) |
238                     ((req == NULL ? 1 : 0) << 15) |
239                     (0 << 12) |
240                     (3 << 10) |
241                     ((usb_pipein(pipe) ? 1 : 0) << 8) | (0x80 << 0);
242                 td->qt_token = cpu_to_le32(token);
243                 if (ehci_td_buffer(td, buffer, length) != 0) {
244                         debug("unable construct DATA td");
245                         ehci_free(td, sizeof(*td));
246                         goto fail;
247                 }
248                 *tdp = cpu_to_le32((uint32_t) td);
249                 tdp = &td->qt_next;
250         }
251
252         if (req != NULL) {
253                 td = ehci_alloc(sizeof(struct qTD), 32);
254                 if (td == NULL) {
255                         debug("unable to allocate ACK td");
256                         goto fail;
257                 }
258                 td->qt_next = cpu_to_le32(QT_NEXT_TERMINATE);
259                 td->qt_altnext = cpu_to_le32(QT_NEXT_TERMINATE);
260                 token = (toggle << 31) |
261                     (0 << 16) |
262                     (1 << 15) |
263                     (0 << 12) |
264                     (3 << 10) |
265                     ((usb_pipein(pipe) ? 0 : 1) << 8) | (0x80 << 0);
266                 td->qt_token = cpu_to_le32(token);
267                 *tdp = cpu_to_le32((uint32_t) td);
268                 tdp = &td->qt_next;
269         }
270
271         qh_list.qh_link = cpu_to_le32((uint32_t) qh | QH_LINK_TYPE_QH);
272
273         usbsts = le32_to_cpu(hcor->or_usbsts);
274         hcor->or_usbsts = cpu_to_le32(usbsts & 0x3f);
275
276         /* Enable async. schedule. */
277         hcor->or_usbcmd |= cpu_to_le32(0x20);
278         while ((hcor->or_usbsts & cpu_to_le32(0x8000)) == 0)
279                 udelay(1);
280
281         /* Wait for TDs to be processed. */
282         ts = get_timer(0);
283         vtd = td;
284         do {
285                 token = le32_to_cpu(vtd->qt_token);
286                 if (!(token & 0x80))
287                         break;
288         } while (get_timer(ts) < CONFIG_SYS_HZ);
289
290         /* Disable async schedule. */
291         hcor->or_usbcmd &= ~cpu_to_le32(0x20);
292         while ((hcor->or_usbsts & cpu_to_le32(0x8000)) != 0)
293                 udelay(1);
294
295         qh_list.qh_link = cpu_to_le32((uint32_t)&qh_list | QH_LINK_TYPE_QH);
296
297         token = le32_to_cpu(qh->qh_overlay.qt_token);
298         if (!(token & 0x80)) {
299                 debug("TOKEN=%#x", token);
300                 switch (token & 0xfc) {
301                 case 0:
302                         toggle = token >> 31;
303                         usb_settoggle(dev, usb_pipeendpoint(pipe),
304                                        usb_pipeout(pipe), toggle);
305                         dev->status = 0;
306                         break;
307                 case 0x40:
308                         dev->status = USB_ST_STALLED;
309                         break;
310                 case 0xa0:
311                 case 0x20:
312                         dev->status = USB_ST_BUF_ERR;
313                         break;
314                 case 0x50:
315                 case 0x10:
316                         dev->status = USB_ST_BABBLE_DET;
317                         break;
318                 default:
319                         dev->status = USB_ST_CRC_ERR;
320                         break;
321                 }
322                 dev->act_len = length - ((token >> 16) & 0x7fff);
323         } else {
324                 dev->act_len = 0;
325                 debug("dev=%u, usbsts=%#x, p[1]=%#x, p[2]=%#x",
326                       dev->devnum, le32_to_cpu(hcor->or_usbsts),
327                       le32_to_cpu(hcor->or_portsc[0]),
328                       le32_to_cpu(hcor->or_portsc[1]));
329         }
330
331         return (dev->status != USB_ST_NOT_PROC) ? 0 : -1;
332
333 fail:
334         td = (void *)le32_to_cpu(qh->qh_overlay.qt_next);
335         while (td != (void *)QT_NEXT_TERMINATE) {
336                 qh->qh_overlay.qt_next = td->qt_next;
337                 ehci_free(td, sizeof(*td));
338                 td = (void *)le32_to_cpu(qh->qh_overlay.qt_next);
339         }
340         ehci_free(qh, sizeof(*qh));
341         return -1;
342 }
343
344 static inline int min3(int a, int b, int c)
345 {
346
347         if (b < a)
348                 a = b;
349         if (c < a)
350                 a = c;
351         return a;
352 }
353
354 ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
355                  int length, struct devrequest *req)
356 {
357         uint8_t tmpbuf[4];
358         u16 typeReq;
359         void *srcptr;
360         int len, srclen;
361         uint32_t reg;
362
363         srclen = 0;
364         srcptr = NULL;
365
366         debug("req=%u (%#x), type=%u (%#x), value=%u, index=%u",
367               req->request, req->request,
368               req->requesttype, req->requesttype,
369               le16_to_cpu(req->value), le16_to_cpu(req->index));
370
371         typeReq = req->request << 8 | req->requesttype;
372
373         switch (typeReq) {
374         case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
375                 switch (le16_to_cpu(req->value) >> 8) {
376                 case USB_DT_DEVICE:
377                         srcptr = &device;
378                         srclen = sizeof(struct usb_device_descriptor);
379                         break;
380                 case USB_DT_CONFIG:
381                         srcptr = &config;
382                         srclen = sizeof(config) +
383                                 sizeof(struct usb_interface_descriptor) +
384                                 sizeof(struct usb_hub_descriptor);
385                         break;
386                 case USB_DT_STRING:
387                         switch (le16_to_cpu(req->value) & 0xff) {
388                         case 0: /* Language */
389                                 srcptr = "\4\3\1\0";
390                                 srclen = 4;
391                                 break;
392                         case 1: /* Vendor */
393                                 srcptr = "\16\3u\0-\0b\0o\0o\0t\0";
394                                 srclen = 14;
395                                 break;
396                         case 2: /* Product */
397                                 srcptr = "\52\3E\0H\0C\0I\0 "
398                                          "\0H\0o\0s\0t\0 "
399                                          "\0C\0o\0n\0t\0r\0o\0l\0l\0e\0r\0";
400                                 srclen = 42;
401                                 break;
402                         default:
403                                 goto unknown;
404                         }
405                         break;
406                 default:
407                         debug("unknown value %x", le16_to_cpu(req->value));
408                         goto unknown;
409                 }
410                 break;
411         case USB_REQ_GET_DESCRIPTOR | ((USB_DIR_IN | USB_RT_HUB) << 8):
412                 switch (le16_to_cpu(req->value) >> 8) {
413                 case USB_DT_HUB:
414                         srcptr = &hub;
415                         srclen = sizeof(hub);
416                         break;
417                 default:
418                         debug("unknown value %x", le16_to_cpu(req->value));
419                         goto unknown;
420                 }
421                 break;
422         case USB_REQ_SET_ADDRESS | (USB_RECIP_DEVICE << 8):
423                 rootdev = le16_to_cpu(req->value);
424                 break;
425         case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
426                 /* Nothing to do */
427                 break;
428         case USB_REQ_GET_STATUS | ((USB_DIR_IN | USB_RT_HUB) << 8):
429                 tmpbuf[0] = 1;  /* USB_STATUS_SELFPOWERED */
430                 tmpbuf[1] = 0;
431                 srcptr = tmpbuf;
432                 srclen = 2;
433                 break;
434         case DeviceRequest | USB_REQ_GET_STATUS:
435                 memset(tmpbuf, 0, 4);
436                 reg = le32_to_cpu(hcor->or_portsc[le16_to_cpu(req->index)
437                                    - 1]);
438                 if (reg & EHCI_PS_CS)
439                         tmpbuf[0] |= USB_PORT_STAT_CONNECTION;
440                 if (reg & EHCI_PS_PE)
441                         tmpbuf[0] |= USB_PORT_STAT_ENABLE;
442                 if (reg & EHCI_PS_SUSP)
443                         tmpbuf[0] |= USB_PORT_STAT_SUSPEND;
444                 if (reg & EHCI_PS_OCA)
445                         tmpbuf[0] |= USB_PORT_STAT_OVERCURRENT;
446                 if (reg & EHCI_PS_PR)
447                         tmpbuf[0] |= USB_PORT_STAT_RESET;
448                 if (reg & EHCI_PS_PP)
449                         tmpbuf[1] |= USB_PORT_STAT_POWER >> 8;
450                 tmpbuf[1] |= USB_PORT_STAT_HIGH_SPEED >> 8;
451
452                 if (reg & EHCI_PS_CSC)
453                         tmpbuf[2] |= USB_PORT_STAT_C_CONNECTION;
454                 if (reg & EHCI_PS_PEC)
455                         tmpbuf[2] |= USB_PORT_STAT_C_ENABLE;
456                 if (reg & EHCI_PS_OCC)
457                         tmpbuf[2] |= USB_PORT_STAT_C_OVERCURRENT;
458                 if (portreset & (1 << le16_to_cpu(req->index)))
459                         tmpbuf[2] |= USB_PORT_STAT_C_RESET;
460                 srcptr = tmpbuf;
461                 srclen = 4;
462                 break;
463         case DeviceOutRequest | USB_REQ_SET_FEATURE:
464                 reg = le32_to_cpu(hcor->or_portsc[le16_to_cpu(req->index) - 1]);
465                 reg &= ~EHCI_PS_CLEAR;
466                 switch (le16_to_cpu(req->value)) {
467                 case USB_PORT_FEAT_POWER:
468                         reg |= EHCI_PS_PP;
469                         break;
470                 case USB_PORT_FEAT_RESET:
471                         if (EHCI_PS_IS_LOWSPEED(reg)) {
472                                 /* Low speed device, give up ownership. */
473                                 reg |= EHCI_PS_PO;
474                                 break;
475                         }
476                         /* Start reset sequence. */
477                         reg &= ~EHCI_PS_PE;
478                         reg |= EHCI_PS_PR;
479                         hcor->or_portsc[le16_to_cpu(req->index) - 1] =
480                             cpu_to_le32(reg);
481                         /* Wait for reset to complete. */
482                         udelay(500000);
483                         /* Terminate reset sequence. */
484                         reg &= ~EHCI_PS_PR;
485                         /* TODO: is it only fsl chip that requires this
486                          * manual setting of port enable?
487                          */
488                         reg |= EHCI_PS_PE;
489                         hcor->or_portsc[le16_to_cpu(req->index) - 1] =
490                             cpu_to_le32(reg);
491                         /* Wait for HC to complete reset. */
492                         udelay(2000);
493                         reg =
494                             le32_to_cpu(hcor->or_portsc[le16_to_cpu(req->index)
495                                                         - 1]);
496                         reg &= ~EHCI_PS_CLEAR;
497                         if ((reg & EHCI_PS_PE) == 0) {
498                                 /* Not a high speed device, give up
499                                  * ownership. */
500                                 reg |= EHCI_PS_PO;
501                                 break;
502                         }
503                         portreset |= 1 << le16_to_cpu(req->index);
504                         break;
505                 default:
506                         debug("unknown feature %x", le16_to_cpu(req->value));
507                         goto unknown;
508                 }
509                 hcor->or_portsc[le16_to_cpu(req->index) - 1] =
510                                         cpu_to_le32(reg);
511                 break;
512         case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
513                 reg = le32_to_cpu(hcor->or_portsc[le16_to_cpu(req->index) - 1]);
514                 reg &= ~EHCI_PS_CLEAR;
515                 switch (le16_to_cpu(req->value)) {
516                 case USB_PORT_FEAT_ENABLE:
517                         reg &= ~EHCI_PS_PE;
518                         break;
519                 case USB_PORT_FEAT_C_CONNECTION:
520                         reg |= EHCI_PS_CSC;
521                         break;
522                 case USB_PORT_FEAT_C_RESET:
523                         portreset &= ~(1 << le16_to_cpu(req->index));
524                         break;
525                 default:
526                         debug("unknown feature %x", le16_to_cpu(req->value));
527                         goto unknown;
528                 }
529                 hcor->or_portsc[le16_to_cpu(req->index) - 1] =
530                                         cpu_to_le32(reg);
531                 break;
532         default:
533                 debug("Unknown request");
534                 goto unknown;
535         }
536
537         len = min3(srclen, le16_to_cpu(req->length), length);
538         if (srcptr != NULL && len > 0)
539                 memcpy(buffer, srcptr, len);
540         dev->act_len = len;
541         dev->status = 0;
542         return 0;
543
544 unknown:
545         debug("requesttype=%x, request=%x, value=%x, index=%x, length=%x",
546               req->requesttype, req->request, le16_to_cpu(req->value),
547               le16_to_cpu(req->index), le16_to_cpu(req->length));
548
549         dev->act_len = 0;
550         dev->status = USB_ST_STALLED;
551         return -1;
552 }
553
554 int usb_lowlevel_stop(void)
555 {
556         return ehci_hcd_stop();
557 }
558
559 int usb_lowlevel_init(void)
560 {
561         uint32_t reg;
562
563         if (ehci_hcd_init() != 0)
564                 return -1;
565
566         /* Set head of reclaim list */
567         memset(&qh_list, 0, sizeof(qh_list));
568         qh_list.qh_link = cpu_to_le32((uint32_t)&qh_list | QH_LINK_TYPE_QH);
569         qh_list.qh_endpt1 = cpu_to_le32((1 << 15) | (USB_SPEED_HIGH << 12));
570         qh_list.qh_curtd = cpu_to_le32(QT_NEXT_TERMINATE);
571         qh_list.qh_overlay.qt_next = cpu_to_le32(QT_NEXT_TERMINATE);
572         qh_list.qh_overlay.qt_altnext = cpu_to_le32(QT_NEXT_TERMINATE);
573         qh_list.qh_overlay.qt_token = cpu_to_le32(0x40);
574
575         /* Set async. queue head pointer. */
576         hcor->or_asynclistaddr = cpu_to_le32((uint32_t)&qh_list);
577
578         reg = le32_to_cpu(hccr->cr_hcsparams);
579         hub.bNbrPorts = reg & 0xf;
580         if (reg & 0x10000)      /* Port Indicators */
581                 hub.wHubCharacteristics |= 0x80;
582         if (reg & 0x10)         /* Port Power Control */
583                 hub.wHubCharacteristics |= 0x01;
584
585         /* take control over the ports */
586         hcor->or_configflag |= cpu_to_le32(1);
587
588         /* Start the host controller. */
589         hcor->or_usbcmd |= cpu_to_le32(1);
590
591         rootdev = 0;
592
593         return 0;
594 }
595
596 int
597 submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
598                 int length)
599 {
600
601         if (usb_pipetype(pipe) != PIPE_BULK) {
602                 debug("non-bulk pipe (type=%lu)", usb_pipetype(pipe));
603                 return -1;
604         }
605         return ehci_submit_async(dev, pipe, buffer, length, NULL);
606 }
607
608 int
609 submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
610                    int length, struct devrequest *setup)
611 {
612
613         if (usb_pipetype(pipe) != PIPE_CONTROL) {
614                 debug("non-control pipe (type=%lu)", usb_pipetype(pipe));
615                 return -1;
616         }
617
618         if (usb_pipedevice(pipe) == rootdev) {
619                 if (rootdev == 0)
620                         dev->speed = USB_SPEED_HIGH;
621                 return ehci_submit_root(dev, pipe, buffer, length, setup);
622         }
623         return ehci_submit_async(dev, pipe, buffer, length, setup);
624 }
625
626 int
627 submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
628                int length, int interval)
629 {
630
631         debug("dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d",
632               dev, pipe, buffer, length, interval);
633         return -1;
634 }