blob: 04300be1100acb0c7bf23d4d744d0f13d5ed16b3 [file] [log] [blame]
Michael Trimarchiaaf098c2008-11-28 13:20:46 +01001/*-
2 * Copyright (c) 2007-2008, Juniper Networks, Inc.
michaeldb632992008-12-10 17:55:19 +01003 * Copyright (c) 2008, Excito Elektronik i Skåne AB
Remy Böhmerc0d722f2008-12-13 22:51:58 +01004 * Copyright (c) 2008, Michael Trimarchi <trimarchimichael@yahoo.it>
5 *
Michael Trimarchiaaf098c2008-11-28 13:20:46 +01006 * All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation version 2 of
11 * the License.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010023#include <common.h>
michaeldb632992008-12-10 17:55:19 +010024#include <asm/byteorder.h>
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010025#include <usb.h>
26#include <asm/io.h>
michaeldb632992008-12-10 17:55:19 +010027#include <malloc.h>
Stefan Roese67333f72010-11-26 15:43:28 +010028#include <watchdog.h>
Jean-Christophe PLAGNIOL-VILLARD2731b9a2009-04-03 12:46:58 +020029
30#include "ehci.h"
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010031
32int rootdev;
Michael Trimarchi1ed9f9a2008-12-31 10:33:22 +010033struct ehci_hccr *hccr; /* R/O registers, not need for volatile */
Michael Trimarchiaaf098c2008-11-28 13:20:46 +010034volatile struct ehci_hcor *hcor;
35
36static uint16_t portreset;
37static struct QH qh_list __attribute__((aligned(32)));
38
michaeldb632992008-12-10 17:55:19 +010039static struct descriptor {
40 struct usb_hub_descriptor hub;
41 struct usb_device_descriptor device;
42 struct usb_linux_config_descriptor config;
43 struct usb_linux_interface_descriptor interface;
44 struct usb_endpoint_descriptor endpoint;
45} __attribute__ ((packed)) descriptor = {
46 {
47 0x8, /* bDescLength */
48 0x29, /* bDescriptorType: hub descriptor */
49 2, /* bNrPorts -- runtime modified */
50 0, /* wHubCharacteristics */
Vincent Palatin5f4b4f22011-12-05 14:52:22 -080051 10, /* bPwrOn2PwrGood */
michaeldb632992008-12-10 17:55:19 +010052 0, /* bHubCntrCurrent */
53 {}, /* Device removable */
54 {} /* at most 7 ports! XXX */
55 },
56 {
57 0x12, /* bLength */
58 1, /* bDescriptorType: UDESC_DEVICE */
Sergei Shtylyov6d313c82010-02-27 21:29:42 +030059 cpu_to_le16(0x0200), /* bcdUSB: v2.0 */
michaeldb632992008-12-10 17:55:19 +010060 9, /* bDeviceClass: UDCLASS_HUB */
61 0, /* bDeviceSubClass: UDSUBCLASS_HUB */
62 1, /* bDeviceProtocol: UDPROTO_HSHUBSTT */
63 64, /* bMaxPacketSize: 64 bytes */
64 0x0000, /* idVendor */
65 0x0000, /* idProduct */
Sergei Shtylyov6d313c82010-02-27 21:29:42 +030066 cpu_to_le16(0x0100), /* bcdDevice */
michaeldb632992008-12-10 17:55:19 +010067 1, /* iManufacturer */
68 2, /* iProduct */
69 0, /* iSerialNumber */
70 1 /* bNumConfigurations: 1 */
71 },
72 {
73 0x9,
74 2, /* bDescriptorType: UDESC_CONFIG */
75 cpu_to_le16(0x19),
76 1, /* bNumInterface */
77 1, /* bConfigurationValue */
78 0, /* iConfiguration */
79 0x40, /* bmAttributes: UC_SELF_POWER */
80 0 /* bMaxPower */
81 },
82 {
83 0x9, /* bLength */
84 4, /* bDescriptorType: UDESC_INTERFACE */
85 0, /* bInterfaceNumber */
86 0, /* bAlternateSetting */
87 1, /* bNumEndpoints */
88 9, /* bInterfaceClass: UICLASS_HUB */
89 0, /* bInterfaceSubClass: UISUBCLASS_HUB */
90 0, /* bInterfaceProtocol: UIPROTO_HSHUBSTT */
91 0 /* iInterface */
92 },
93 {
94 0x7, /* bLength */
95 5, /* bDescriptorType: UDESC_ENDPOINT */
96 0x81, /* bEndpointAddress:
97 * UE_DIR_IN | EHCI_INTR_ENDPT
98 */
99 3, /* bmAttributes: UE_INTERRUPT */
Tom Rix8f8bd562009-10-31 12:37:38 -0500100 8, /* wMaxPacketSize */
michaeldb632992008-12-10 17:55:19 +0100101 255 /* bInterval */
102 },
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100103};
104
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100105#if defined(CONFIG_EHCI_IS_TDI)
106#define ehci_is_TDI() (1)
107#else
108#define ehci_is_TDI() (0)
109#endif
110
Marek Vasut3874b6d2011-07-11 02:37:01 +0200111void __ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
112{
113 mdelay(50);
114}
115
116void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
117 __attribute__((weak, alias("__ehci_powerup_fixup")));
118
Michael Trimarchi1ed9f9a2008-12-31 10:33:22 +0100119static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec)
michaeldb632992008-12-10 17:55:19 +0100120{
michael51ab1422008-12-11 13:43:55 +0100121 uint32_t result;
122 do {
123 result = ehci_readl(ptr);
Wolfgang Denk09c83a42010-10-22 14:23:00 +0200124 udelay(5);
michael51ab1422008-12-11 13:43:55 +0100125 if (result == ~(uint32_t)0)
126 return -1;
127 result &= mask;
128 if (result == done)
129 return 0;
Michael Trimarchi1ed9f9a2008-12-31 10:33:22 +0100130 usec--;
131 } while (usec > 0);
michael51ab1422008-12-11 13:43:55 +0100132 return -1;
133}
134
michael51ab1422008-12-11 13:43:55 +0100135static int ehci_reset(void)
136{
137 uint32_t cmd;
138 uint32_t tmp;
139 uint32_t *reg_ptr;
140 int ret = 0;
141
142 cmd = ehci_readl(&hcor->or_usbcmd);
Stefan Roese273d7202010-11-26 15:44:00 +0100143 cmd = (cmd & ~CMD_RUN) | CMD_RESET;
michael51ab1422008-12-11 13:43:55 +0100144 ehci_writel(&hcor->or_usbcmd, cmd);
Michael Trimarchi1ed9f9a2008-12-31 10:33:22 +0100145 ret = handshake((uint32_t *)&hcor->or_usbcmd, CMD_RESET, 0, 250 * 1000);
michael51ab1422008-12-11 13:43:55 +0100146 if (ret < 0) {
147 printf("EHCI fail to reset\n");
148 goto out;
149 }
150
Michael Trimarchi1ed9f9a2008-12-31 10:33:22 +0100151 if (ehci_is_TDI()) {
152 reg_ptr = (uint32_t *)((u8 *)hcor + USBMODE);
153 tmp = ehci_readl(reg_ptr);
154 tmp |= USBMODE_CM_HC;
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100155#if defined(CONFIG_EHCI_MMIO_BIG_ENDIAN)
Michael Trimarchi1ed9f9a2008-12-31 10:33:22 +0100156 tmp |= USBMODE_BE;
michael51ab1422008-12-11 13:43:55 +0100157#endif
Michael Trimarchi1ed9f9a2008-12-31 10:33:22 +0100158 ehci_writel(reg_ptr, tmp);
159 }
Simon Glass9ab4ce22012-02-27 10:52:47 +0000160
161#ifdef CONFIG_USB_EHCI_TXFIFO_THRESH
162 cmd = ehci_readl(&hcor->or_txfilltuning);
163 cmd &= ~TXFIFO_THRESH(0x3f);
164 cmd |= TXFIFO_THRESH(CONFIG_USB_EHCI_TXFIFO_THRESH);
165 ehci_writel(&hcor->or_txfilltuning, cmd);
166#endif
michael51ab1422008-12-11 13:43:55 +0100167out:
168 return ret;
michaeldb632992008-12-10 17:55:19 +0100169}
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100170
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100171static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz)
172{
Marek Vasutb8adb122012-04-09 04:07:46 +0200173 uint32_t delta, next;
174 uint32_t addr = (uint32_t)buf;
175 size_t rsz = roundup(sz, 32);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100176 int idx;
177
Marek Vasutb8adb122012-04-09 04:07:46 +0200178 if (sz != rsz)
179 debug("EHCI-HCD: Misaligned buffer size (%08x)\n", sz);
180
181 if (addr & 31)
182 debug("EHCI-HCD: Misaligned buffer address (%p)\n", buf);
183
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100184 idx = 0;
185 while (idx < 5) {
Marek Vasutb8adb122012-04-09 04:07:46 +0200186 flush_dcache_range(addr, addr + rsz);
michaeldb632992008-12-10 17:55:19 +0100187 td->qt_buffer[idx] = cpu_to_hc32(addr);
Wolfgang Denk3ed16072010-10-19 16:13:15 +0200188 td->qt_buffer_hi[idx] = 0;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100189 next = (addr + 4096) & ~4095;
190 delta = next - addr;
191 if (delta >= sz)
192 break;
193 sz -= delta;
194 addr = next;
195 idx++;
196 }
197
198 if (idx == 5) {
michaeldb632992008-12-10 17:55:19 +0100199 debug("out of buffer pointers (%u bytes left)\n", sz);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100200 return -1;
201 }
202
203 return 0;
204}
205
206static int
207ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
208 int length, struct devrequest *req)
209{
Marek Vasutde98e8b2012-04-08 23:32:05 +0200210 static struct QH qh __attribute__((aligned(32)));
211 static struct qTD qtd[3] __attribute__((aligned (32)));
212 int qtd_counter = 0;
213
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100214 volatile struct qTD *vtd;
215 unsigned long ts;
216 uint32_t *tdp;
217 uint32_t endpt, token, usbsts;
218 uint32_t c, toggle;
michaeldb632992008-12-10 17:55:19 +0100219 uint32_t cmd;
Simon Glass96820a32011-02-07 14:42:16 -0800220 int timeout;
Michael Trimarchi1ed9f9a2008-12-31 10:33:22 +0100221 int ret = 0;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100222
michaeldb632992008-12-10 17:55:19 +0100223 debug("dev=%p, pipe=%lx, buffer=%p, length=%d, req=%p\n", dev, pipe,
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100224 buffer, length, req);
225 if (req != NULL)
michaeldb632992008-12-10 17:55:19 +0100226 debug("req=%u (%#x), type=%u (%#x), value=%u (%#x), index=%u\n",
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100227 req->request, req->request,
228 req->requesttype, req->requesttype,
229 le16_to_cpu(req->value), le16_to_cpu(req->value),
michaeldb632992008-12-10 17:55:19 +0100230 le16_to_cpu(req->index));
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100231
Marek Vasutde98e8b2012-04-08 23:32:05 +0200232 memset(&qh, 0, sizeof(struct QH));
233 memset(qtd, 0, sizeof(qtd));
234
Marek Vasutb8adb122012-04-09 04:07:46 +0200235 toggle = usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe));
236
Marek Vasut41b1f0a2012-04-09 04:13:00 +0200237 /*
238 * Setup QH (3.6 in ehci-r10.pdf)
239 *
240 * qh_link ................. 03-00 H
241 * qh_endpt1 ............... 07-04 H
242 * qh_endpt2 ............... 0B-08 H
243 * - qh_curtd
244 * qh_overlay.qt_next ...... 13-10 H
245 * - qh_overlay.qt_altnext
246 */
Marek Vasutde98e8b2012-04-08 23:32:05 +0200247 qh.qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100248 c = (usb_pipespeed(pipe) != USB_SPEED_HIGH &&
249 usb_pipeendpoint(pipe) == 0) ? 1 : 0;
250 endpt = (8 << 28) |
251 (c << 27) |
252 (usb_maxpacket(dev, pipe) << 16) |
253 (0 << 15) |
254 (1 << 14) |
255 (usb_pipespeed(pipe) << 12) |
256 (usb_pipeendpoint(pipe) << 8) |
257 (0 << 7) | (usb_pipedevice(pipe) << 0);
Marek Vasutde98e8b2012-04-08 23:32:05 +0200258 qh.qh_endpt1 = cpu_to_hc32(endpt);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100259 endpt = (1 << 30) |
260 (dev->portnr << 23) |
261 (dev->parent->devnum << 16) | (0 << 8) | (0 << 0);
Marek Vasutde98e8b2012-04-08 23:32:05 +0200262 qh.qh_endpt2 = cpu_to_hc32(endpt);
263 qh.qh_overlay.qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100264
Marek Vasutde98e8b2012-04-08 23:32:05 +0200265 tdp = &qh.qh_overlay.qt_next;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100266
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100267 if (req != NULL) {
Marek Vasut41b1f0a2012-04-09 04:13:00 +0200268 /*
269 * Setup request qTD (3.5 in ehci-r10.pdf)
270 *
271 * qt_next ................ 03-00 H
272 * qt_altnext ............. 07-04 H
273 * qt_token ............... 0B-08 H
274 *
275 * [ buffer, buffer_hi ] loaded with "req".
276 */
Marek Vasutde98e8b2012-04-08 23:32:05 +0200277 qtd[qtd_counter].qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);
278 qtd[qtd_counter].qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100279 token = (0 << 31) |
280 (sizeof(*req) << 16) |
281 (0 << 15) | (0 << 12) | (3 << 10) | (2 << 8) | (0x80 << 0);
Marek Vasutde98e8b2012-04-08 23:32:05 +0200282 qtd[qtd_counter].qt_token = cpu_to_hc32(token);
283 if (ehci_td_buffer(&qtd[qtd_counter], req, sizeof(*req)) != 0) {
michaeldb632992008-12-10 17:55:19 +0100284 debug("unable construct SETUP td\n");
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100285 goto fail;
286 }
Marek Vasut41b1f0a2012-04-09 04:13:00 +0200287 /* Update previous qTD! */
Marek Vasutde98e8b2012-04-08 23:32:05 +0200288 *tdp = cpu_to_hc32((uint32_t)&qtd[qtd_counter]);
289 tdp = &qtd[qtd_counter++].qt_next;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100290 toggle = 1;
291 }
292
293 if (length > 0 || req == NULL) {
Marek Vasut41b1f0a2012-04-09 04:13:00 +0200294 /*
295 * Setup request qTD (3.5 in ehci-r10.pdf)
296 *
297 * qt_next ................ 03-00 H
298 * qt_altnext ............. 07-04 H
299 * qt_token ............... 0B-08 H
300 *
301 * [ buffer, buffer_hi ] loaded with "buffer".
302 */
Marek Vasutde98e8b2012-04-08 23:32:05 +0200303 qtd[qtd_counter].qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);
304 qtd[qtd_counter].qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100305 token = (toggle << 31) |
306 (length << 16) |
307 ((req == NULL ? 1 : 0) << 15) |
308 (0 << 12) |
309 (3 << 10) |
310 ((usb_pipein(pipe) ? 1 : 0) << 8) | (0x80 << 0);
Marek Vasutde98e8b2012-04-08 23:32:05 +0200311 qtd[qtd_counter].qt_token = cpu_to_hc32(token);
312 if (ehci_td_buffer(&qtd[qtd_counter], buffer, length) != 0) {
michaeldb632992008-12-10 17:55:19 +0100313 debug("unable construct DATA td\n");
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100314 goto fail;
315 }
Marek Vasut41b1f0a2012-04-09 04:13:00 +0200316 /* Update previous qTD! */
Marek Vasutde98e8b2012-04-08 23:32:05 +0200317 *tdp = cpu_to_hc32((uint32_t)&qtd[qtd_counter]);
318 tdp = &qtd[qtd_counter++].qt_next;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100319 }
320
321 if (req != NULL) {
Marek Vasut41b1f0a2012-04-09 04:13:00 +0200322 /*
323 * Setup request qTD (3.5 in ehci-r10.pdf)
324 *
325 * qt_next ................ 03-00 H
326 * qt_altnext ............. 07-04 H
327 * qt_token ............... 0B-08 H
328 */
Marek Vasutde98e8b2012-04-08 23:32:05 +0200329 qtd[qtd_counter].qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);
330 qtd[qtd_counter].qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100331 token = (toggle << 31) |
332 (0 << 16) |
333 (1 << 15) |
334 (0 << 12) |
335 (3 << 10) |
336 ((usb_pipein(pipe) ? 0 : 1) << 8) | (0x80 << 0);
Marek Vasutde98e8b2012-04-08 23:32:05 +0200337 qtd[qtd_counter].qt_token = cpu_to_hc32(token);
Marek Vasut41b1f0a2012-04-09 04:13:00 +0200338 /* Update previous qTD! */
Marek Vasutde98e8b2012-04-08 23:32:05 +0200339 *tdp = cpu_to_hc32((uint32_t)&qtd[qtd_counter]);
340 tdp = &qtd[qtd_counter++].qt_next;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100341 }
342
Marek Vasutde98e8b2012-04-08 23:32:05 +0200343 qh_list.qh_link = cpu_to_hc32((uint32_t)&qh | QH_LINK_TYPE_QH);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100344
Stefan Roesedaa2daf2009-01-21 17:12:19 +0100345 /* Flush dcache */
Marek Vasutb8adb122012-04-09 04:07:46 +0200346 flush_dcache_range((uint32_t)&qh_list,
347 (uint32_t)&qh_list + sizeof(struct QH));
348 flush_dcache_range((uint32_t)&qh, (uint32_t)&qh + sizeof(struct QH));
349 flush_dcache_range((uint32_t)qtd, (uint32_t)qtd + sizeof(qtd));
Stefan Roesedaa2daf2009-01-21 17:12:19 +0100350
michael51ab1422008-12-11 13:43:55 +0100351 usbsts = ehci_readl(&hcor->or_usbsts);
352 ehci_writel(&hcor->or_usbsts, (usbsts & 0x3f));
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100353
354 /* Enable async. schedule. */
michael51ab1422008-12-11 13:43:55 +0100355 cmd = ehci_readl(&hcor->or_usbcmd);
356 cmd |= CMD_ASE;
357 ehci_writel(&hcor->or_usbcmd, cmd);
michaeldb632992008-12-10 17:55:19 +0100358
Michael Trimarchi1ed9f9a2008-12-31 10:33:22 +0100359 ret = handshake((uint32_t *)&hcor->or_usbsts, STD_ASS, STD_ASS,
360 100 * 1000);
361 if (ret < 0) {
362 printf("EHCI fail timeout STD_ASS set\n");
363 goto fail;
michael51ab1422008-12-11 13:43:55 +0100364 }
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100365
366 /* Wait for TDs to be processed. */
367 ts = get_timer(0);
Marek Vasutde98e8b2012-04-08 23:32:05 +0200368 vtd = &qtd[qtd_counter - 1];
Simon Glass96820a32011-02-07 14:42:16 -0800369 timeout = USB_TIMEOUT_MS(pipe);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100370 do {
Stefan Roesedaa2daf2009-01-21 17:12:19 +0100371 /* Invalidate dcache */
Marek Vasutb8adb122012-04-09 04:07:46 +0200372 invalidate_dcache_range((uint32_t)&qh_list,
373 (uint32_t)&qh_list + sizeof(struct QH));
374 invalidate_dcache_range((uint32_t)&qh,
375 (uint32_t)&qh + sizeof(struct QH));
376 invalidate_dcache_range((uint32_t)qtd,
377 (uint32_t)qtd + sizeof(qtd));
378
michaeldb632992008-12-10 17:55:19 +0100379 token = hc32_to_cpu(vtd->qt_token);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100380 if (!(token & 0x80))
381 break;
Stefan Roese67333f72010-11-26 15:43:28 +0100382 WATCHDOG_RESET();
Simon Glass96820a32011-02-07 14:42:16 -0800383 } while (get_timer(ts) < timeout);
384
Marek Vasutb8adb122012-04-09 04:07:46 +0200385 /* Invalidate the memory area occupied by buffer */
386 invalidate_dcache_range(((uint32_t)buffer & ~31),
387 ((uint32_t)buffer & ~31) + roundup(length, 32));
388
Simon Glass96820a32011-02-07 14:42:16 -0800389 /* Check that the TD processing happened */
390 if (token & 0x80) {
391 printf("EHCI timed out on TD - token=%#x\n", token);
Simon Glass96820a32011-02-07 14:42:16 -0800392 }
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100393
394 /* Disable async schedule. */
michael51ab1422008-12-11 13:43:55 +0100395 cmd = ehci_readl(&hcor->or_usbcmd);
michaeldb632992008-12-10 17:55:19 +0100396 cmd &= ~CMD_ASE;
michael51ab1422008-12-11 13:43:55 +0100397 ehci_writel(&hcor->or_usbcmd, cmd);
398
Michael Trimarchi1ed9f9a2008-12-31 10:33:22 +0100399 ret = handshake((uint32_t *)&hcor->or_usbsts, STD_ASS, 0,
400 100 * 1000);
401 if (ret < 0) {
402 printf("EHCI fail timeout STD_ASS reset\n");
403 goto fail;
michael51ab1422008-12-11 13:43:55 +0100404 }
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100405
michaeldb632992008-12-10 17:55:19 +0100406 qh_list.qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100407
Marek Vasutde98e8b2012-04-08 23:32:05 +0200408 token = hc32_to_cpu(qh.qh_overlay.qt_token);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100409 if (!(token & 0x80)) {
michaeldb632992008-12-10 17:55:19 +0100410 debug("TOKEN=%#x\n", token);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100411 switch (token & 0xfc) {
412 case 0:
413 toggle = token >> 31;
414 usb_settoggle(dev, usb_pipeendpoint(pipe),
415 usb_pipeout(pipe), toggle);
416 dev->status = 0;
417 break;
418 case 0x40:
419 dev->status = USB_ST_STALLED;
420 break;
421 case 0xa0:
422 case 0x20:
423 dev->status = USB_ST_BUF_ERR;
424 break;
425 case 0x50:
426 case 0x10:
427 dev->status = USB_ST_BABBLE_DET;
428 break;
429 default:
430 dev->status = USB_ST_CRC_ERR;
Anatolij Gustschin222d6df2010-11-02 11:47:29 +0100431 if ((token & 0x40) == 0x40)
432 dev->status |= USB_ST_STALLED;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100433 break;
434 }
435 dev->act_len = length - ((token >> 16) & 0x7fff);
436 } else {
437 dev->act_len = 0;
michaeldb632992008-12-10 17:55:19 +0100438 debug("dev=%u, usbsts=%#x, p[1]=%#x, p[2]=%#x\n",
michael51ab1422008-12-11 13:43:55 +0100439 dev->devnum, ehci_readl(&hcor->or_usbsts),
440 ehci_readl(&hcor->or_portsc[0]),
441 ehci_readl(&hcor->or_portsc[1]));
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100442 }
443
444 return (dev->status != USB_ST_NOT_PROC) ? 0 : -1;
445
446fail:
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100447 return -1;
448}
449
450static inline int min3(int a, int b, int c)
451{
452
453 if (b < a)
454 a = b;
455 if (c < a)
456 a = c;
457 return a;
458}
459
michaeldb632992008-12-10 17:55:19 +0100460int
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100461ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
462 int length, struct devrequest *req)
463{
464 uint8_t tmpbuf[4];
465 u16 typeReq;
michaeldb632992008-12-10 17:55:19 +0100466 void *srcptr = NULL;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100467 int len, srclen;
468 uint32_t reg;
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100469 uint32_t *status_reg;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100470
Sergei Shtylyove06a0552010-02-27 21:32:17 +0300471 if (le16_to_cpu(req->index) > CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS) {
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100472 printf("The request port(%d) is not configured\n",
473 le16_to_cpu(req->index) - 1);
474 return -1;
475 }
476 status_reg = (uint32_t *)&hcor->or_portsc[
477 le16_to_cpu(req->index) - 1];
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100478 srclen = 0;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100479
michaeldb632992008-12-10 17:55:19 +0100480 debug("req=%u (%#x), type=%u (%#x), value=%u, index=%u\n",
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100481 req->request, req->request,
482 req->requesttype, req->requesttype,
483 le16_to_cpu(req->value), le16_to_cpu(req->index));
484
Prafulla Wadaskar44259bb2009-07-17 19:56:30 +0530485 typeReq = req->request | req->requesttype << 8;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100486
Prafulla Wadaskar44259bb2009-07-17 19:56:30 +0530487 switch (typeReq) {
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100488 case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
489 switch (le16_to_cpu(req->value) >> 8) {
490 case USB_DT_DEVICE:
michaeldb632992008-12-10 17:55:19 +0100491 debug("USB_DT_DEVICE request\n");
492 srcptr = &descriptor.device;
493 srclen = 0x12;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100494 break;
495 case USB_DT_CONFIG:
michaeldb632992008-12-10 17:55:19 +0100496 debug("USB_DT_CONFIG config\n");
497 srcptr = &descriptor.config;
498 srclen = 0x19;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100499 break;
500 case USB_DT_STRING:
michaeldb632992008-12-10 17:55:19 +0100501 debug("USB_DT_STRING config\n");
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100502 switch (le16_to_cpu(req->value) & 0xff) {
503 case 0: /* Language */
504 srcptr = "\4\3\1\0";
505 srclen = 4;
506 break;
507 case 1: /* Vendor */
508 srcptr = "\16\3u\0-\0b\0o\0o\0t\0";
509 srclen = 14;
510 break;
511 case 2: /* Product */
512 srcptr = "\52\3E\0H\0C\0I\0 "
513 "\0H\0o\0s\0t\0 "
514 "\0C\0o\0n\0t\0r\0o\0l\0l\0e\0r\0";
515 srclen = 42;
516 break;
517 default:
michaeldb632992008-12-10 17:55:19 +0100518 debug("unknown value DT_STRING %x\n",
519 le16_to_cpu(req->value));
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100520 goto unknown;
521 }
522 break;
523 default:
michaeldb632992008-12-10 17:55:19 +0100524 debug("unknown value %x\n", le16_to_cpu(req->value));
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100525 goto unknown;
526 }
527 break;
528 case USB_REQ_GET_DESCRIPTOR | ((USB_DIR_IN | USB_RT_HUB) << 8):
529 switch (le16_to_cpu(req->value) >> 8) {
530 case USB_DT_HUB:
michaeldb632992008-12-10 17:55:19 +0100531 debug("USB_DT_HUB config\n");
532 srcptr = &descriptor.hub;
533 srclen = 0x8;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100534 break;
535 default:
michaeldb632992008-12-10 17:55:19 +0100536 debug("unknown value %x\n", le16_to_cpu(req->value));
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100537 goto unknown;
538 }
539 break;
540 case USB_REQ_SET_ADDRESS | (USB_RECIP_DEVICE << 8):
michaeldb632992008-12-10 17:55:19 +0100541 debug("USB_REQ_SET_ADDRESS\n");
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100542 rootdev = le16_to_cpu(req->value);
543 break;
544 case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
michaeldb632992008-12-10 17:55:19 +0100545 debug("USB_REQ_SET_CONFIGURATION\n");
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100546 /* Nothing to do */
547 break;
548 case USB_REQ_GET_STATUS | ((USB_DIR_IN | USB_RT_HUB) << 8):
549 tmpbuf[0] = 1; /* USB_STATUS_SELFPOWERED */
550 tmpbuf[1] = 0;
551 srcptr = tmpbuf;
552 srclen = 2;
553 break;
michaeldb632992008-12-10 17:55:19 +0100554 case USB_REQ_GET_STATUS | ((USB_RT_PORT | USB_DIR_IN) << 8):
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100555 memset(tmpbuf, 0, 4);
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100556 reg = ehci_readl(status_reg);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100557 if (reg & EHCI_PS_CS)
558 tmpbuf[0] |= USB_PORT_STAT_CONNECTION;
559 if (reg & EHCI_PS_PE)
560 tmpbuf[0] |= USB_PORT_STAT_ENABLE;
561 if (reg & EHCI_PS_SUSP)
562 tmpbuf[0] |= USB_PORT_STAT_SUSPEND;
563 if (reg & EHCI_PS_OCA)
564 tmpbuf[0] |= USB_PORT_STAT_OVERCURRENT;
Sergei Shtylyovc8b2d1d2010-02-27 21:33:21 +0300565 if (reg & EHCI_PS_PR)
566 tmpbuf[0] |= USB_PORT_STAT_RESET;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100567 if (reg & EHCI_PS_PP)
568 tmpbuf[1] |= USB_PORT_STAT_POWER >> 8;
Stefan Roese597eb282009-01-21 17:12:01 +0100569
570 if (ehci_is_TDI()) {
571 switch ((reg >> 26) & 3) {
572 case 0:
573 break;
574 case 1:
575 tmpbuf[1] |= USB_PORT_STAT_LOW_SPEED >> 8;
576 break;
577 case 2:
578 default:
579 tmpbuf[1] |= USB_PORT_STAT_HIGH_SPEED >> 8;
580 break;
581 }
582 } else {
583 tmpbuf[1] |= USB_PORT_STAT_HIGH_SPEED >> 8;
584 }
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100585
586 if (reg & EHCI_PS_CSC)
587 tmpbuf[2] |= USB_PORT_STAT_C_CONNECTION;
588 if (reg & EHCI_PS_PEC)
589 tmpbuf[2] |= USB_PORT_STAT_C_ENABLE;
590 if (reg & EHCI_PS_OCC)
591 tmpbuf[2] |= USB_PORT_STAT_C_OVERCURRENT;
592 if (portreset & (1 << le16_to_cpu(req->index)))
593 tmpbuf[2] |= USB_PORT_STAT_C_RESET;
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100594
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100595 srcptr = tmpbuf;
596 srclen = 4;
597 break;
michaeldb632992008-12-10 17:55:19 +0100598 case USB_REQ_SET_FEATURE | ((USB_DIR_OUT | USB_RT_PORT) << 8):
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100599 reg = ehci_readl(status_reg);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100600 reg &= ~EHCI_PS_CLEAR;
601 switch (le16_to_cpu(req->value)) {
michael51ab1422008-12-11 13:43:55 +0100602 case USB_PORT_FEAT_ENABLE:
603 reg |= EHCI_PS_PE;
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100604 ehci_writel(status_reg, reg);
michael51ab1422008-12-11 13:43:55 +0100605 break;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100606 case USB_PORT_FEAT_POWER:
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100607 if (HCS_PPC(ehci_readl(&hccr->cr_hcsparams))) {
608 reg |= EHCI_PS_PP;
609 ehci_writel(status_reg, reg);
610 }
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100611 break;
612 case USB_PORT_FEAT_RESET:
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100613 if ((reg & (EHCI_PS_PE | EHCI_PS_CS)) == EHCI_PS_CS &&
614 !ehci_is_TDI() &&
615 EHCI_PS_IS_LOWSPEED(reg)) {
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100616 /* Low speed device, give up ownership. */
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100617 debug("port %d low speed --> companion\n",
618 req->index - 1);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100619 reg |= EHCI_PS_PO;
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100620 ehci_writel(status_reg, reg);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100621 break;
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100622 } else {
Sergei Shtylyovc8b2d1d2010-02-27 21:33:21 +0300623 int ret;
624
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100625 reg |= EHCI_PS_PR;
626 reg &= ~EHCI_PS_PE;
627 ehci_writel(status_reg, reg);
628 /*
629 * caller must wait, then call GetPortStatus
630 * usb 2.0 specification say 50 ms resets on
631 * root
632 */
Marek Vasut3874b6d2011-07-11 02:37:01 +0200633 ehci_powerup_fixup(status_reg, &reg);
634
Chris Zhangb4161912010-01-06 13:34:04 -0800635 ehci_writel(status_reg, reg & ~EHCI_PS_PR);
Sergei Shtylyovc8b2d1d2010-02-27 21:33:21 +0300636 /*
637 * A host controller must terminate the reset
638 * and stabilize the state of the port within
639 * 2 milliseconds
640 */
641 ret = handshake(status_reg, EHCI_PS_PR, 0,
642 2 * 1000);
643 if (!ret)
644 portreset |=
645 1 << le16_to_cpu(req->index);
646 else
647 printf("port(%d) reset error\n",
648 le16_to_cpu(req->index) - 1);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100649 }
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100650 break;
651 default:
michaeldb632992008-12-10 17:55:19 +0100652 debug("unknown feature %x\n", le16_to_cpu(req->value));
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100653 goto unknown;
654 }
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100655 /* unblock posted writes */
Kumar Gala50243e32009-07-07 15:48:58 -0500656 (void) ehci_readl(&hcor->or_usbcmd);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100657 break;
michaeldb632992008-12-10 17:55:19 +0100658 case USB_REQ_CLEAR_FEATURE | ((USB_DIR_OUT | USB_RT_PORT) << 8):
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100659 reg = ehci_readl(status_reg);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100660 switch (le16_to_cpu(req->value)) {
661 case USB_PORT_FEAT_ENABLE:
662 reg &= ~EHCI_PS_PE;
663 break;
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100664 case USB_PORT_FEAT_C_ENABLE:
665 reg = (reg & ~EHCI_PS_CLEAR) | EHCI_PS_PE;
666 break;
667 case USB_PORT_FEAT_POWER:
668 if (HCS_PPC(ehci_readl(&hccr->cr_hcsparams)))
669 reg = reg & ~(EHCI_PS_CLEAR | EHCI_PS_PP);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100670 case USB_PORT_FEAT_C_CONNECTION:
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100671 reg = (reg & ~EHCI_PS_CLEAR) | EHCI_PS_CSC;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100672 break;
michael51ab1422008-12-11 13:43:55 +0100673 case USB_PORT_FEAT_OVER_CURRENT:
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100674 reg = (reg & ~EHCI_PS_CLEAR) | EHCI_PS_OCC;
michael51ab1422008-12-11 13:43:55 +0100675 break;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100676 case USB_PORT_FEAT_C_RESET:
677 portreset &= ~(1 << le16_to_cpu(req->index));
678 break;
679 default:
michaeldb632992008-12-10 17:55:19 +0100680 debug("unknown feature %x\n", le16_to_cpu(req->value));
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100681 goto unknown;
682 }
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100683 ehci_writel(status_reg, reg);
684 /* unblock posted write */
Kumar Gala50243e32009-07-07 15:48:58 -0500685 (void) ehci_readl(&hcor->or_usbcmd);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100686 break;
687 default:
michaeldb632992008-12-10 17:55:19 +0100688 debug("Unknown request\n");
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100689 goto unknown;
690 }
691
Mike Frysinger5b84dd62012-03-05 13:47:00 +0000692 mdelay(1);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100693 len = min3(srclen, le16_to_cpu(req->length), length);
694 if (srcptr != NULL && len > 0)
695 memcpy(buffer, srcptr, len);
michaeldb632992008-12-10 17:55:19 +0100696 else
697 debug("Len is 0\n");
698
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100699 dev->act_len = len;
700 dev->status = 0;
701 return 0;
702
703unknown:
michaeldb632992008-12-10 17:55:19 +0100704 debug("requesttype=%x, request=%x, value=%x, index=%x, length=%x\n",
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100705 req->requesttype, req->request, le16_to_cpu(req->value),
706 le16_to_cpu(req->index), le16_to_cpu(req->length));
707
708 dev->act_len = 0;
709 dev->status = USB_ST_STALLED;
710 return -1;
711}
712
713int usb_lowlevel_stop(void)
714{
715 return ehci_hcd_stop();
716}
717
718int usb_lowlevel_init(void)
719{
720 uint32_t reg;
michaeldb632992008-12-10 17:55:19 +0100721 uint32_t cmd;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100722
723 if (ehci_hcd_init() != 0)
724 return -1;
725
michael51ab1422008-12-11 13:43:55 +0100726 /* EHCI spec section 4.1 */
727 if (ehci_reset() != 0)
728 return -1;
729
Stefan Roese832e6142009-01-21 17:12:10 +0100730#if defined(CONFIG_EHCI_HCD_INIT_AFTER_RESET)
731 if (ehci_hcd_init() != 0)
732 return -1;
733#endif
734
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100735 /* Set head of reclaim list */
736 memset(&qh_list, 0, sizeof(qh_list));
michaeldb632992008-12-10 17:55:19 +0100737 qh_list.qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH);
738 qh_list.qh_endpt1 = cpu_to_hc32((1 << 15) | (USB_SPEED_HIGH << 12));
739 qh_list.qh_curtd = cpu_to_hc32(QT_NEXT_TERMINATE);
740 qh_list.qh_overlay.qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);
741 qh_list.qh_overlay.qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);
742 qh_list.qh_overlay.qt_token = cpu_to_hc32(0x40);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100743
744 /* Set async. queue head pointer. */
michael51ab1422008-12-11 13:43:55 +0100745 ehci_writel(&hcor->or_asynclistaddr, (uint32_t)&qh_list);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100746
michael51ab1422008-12-11 13:43:55 +0100747 reg = ehci_readl(&hccr->cr_hcsparams);
748 descriptor.hub.bNbrPorts = HCS_N_PORTS(reg);
749 printf("Register %x NbrPorts %d\n", reg, descriptor.hub.bNbrPorts);
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100750 /* Port Indicators */
751 if (HCS_INDICATOR(reg))
michaeldb632992008-12-10 17:55:19 +0100752 descriptor.hub.wHubCharacteristics |= 0x80;
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100753 /* Port Power Control */
754 if (HCS_PPC(reg))
michaeldb632992008-12-10 17:55:19 +0100755 descriptor.hub.wHubCharacteristics |= 0x01;
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100756
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100757 /* Start the host controller. */
michael51ab1422008-12-11 13:43:55 +0100758 cmd = ehci_readl(&hcor->or_usbcmd);
Wolfgang Denkf15c6512009-02-12 00:08:39 +0100759 /*
760 * Philips, Intel, and maybe others need CMD_RUN before the
761 * root hub will detect new devices (why?); NEC doesn't
762 */
michael51ab1422008-12-11 13:43:55 +0100763 cmd &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET);
764 cmd |= CMD_RUN;
765 ehci_writel(&hcor->or_usbcmd, cmd);
766
767 /* take control over the ports */
768 cmd = ehci_readl(&hcor->or_configflag);
769 cmd |= FLAG_CF;
770 ehci_writel(&hcor->or_configflag, cmd);
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100771 /* unblock posted write */
michael51ab1422008-12-11 13:43:55 +0100772 cmd = ehci_readl(&hcor->or_usbcmd);
Mike Frysinger5b84dd62012-03-05 13:47:00 +0000773 mdelay(5);
Remy Böhmerc0d722f2008-12-13 22:51:58 +0100774 reg = HC_VERSION(ehci_readl(&hccr->cr_capbase));
775 printf("USB EHCI %x.%02x\n", reg >> 8, reg & 0xff);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100776
777 rootdev = 0;
778
779 return 0;
780}
781
782int
783submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
784 int length)
785{
786
787 if (usb_pipetype(pipe) != PIPE_BULK) {
788 debug("non-bulk pipe (type=%lu)", usb_pipetype(pipe));
789 return -1;
790 }
791 return ehci_submit_async(dev, pipe, buffer, length, NULL);
792}
793
794int
795submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
796 int length, struct devrequest *setup)
797{
798
799 if (usb_pipetype(pipe) != PIPE_CONTROL) {
800 debug("non-control pipe (type=%lu)", usb_pipetype(pipe));
801 return -1;
802 }
803
804 if (usb_pipedevice(pipe) == rootdev) {
805 if (rootdev == 0)
806 dev->speed = USB_SPEED_HIGH;
807 return ehci_submit_root(dev, pipe, buffer, length, setup);
808 }
809 return ehci_submit_async(dev, pipe, buffer, length, setup);
810}
811
812int
813submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
814 int length, int interval)
815{
816
817 debug("dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d",
818 dev, pipe, buffer, length, interval);
Marek Vasut7555d5e2011-09-25 21:07:56 +0200819 return ehci_submit_async(dev, pipe, buffer, length, NULL);
Michael Trimarchiaaf098c2008-11-28 13:20:46 +0100820}