blob: fe091e3fa083c6e5e1efa2c4c2020aaa4338910a [file] [log] [blame]
Stefan Roese326c9712005-08-01 16:41:48 +02001/*
Stefan Roese40ee63b2005-08-02 10:05:21 +02002 * URB OHCI HCD (Host Controller Driver) for USB on the PPC440EP.
Stefan Roese326c9712005-08-01 16:41:48 +02003 *
4 * (C) Copyright 2003-2004
Detlev Zundelf1b3f2b2009-05-13 10:54:10 +02005 * Gary Jennejohn, DENX Software Engineering <garyj@denx.de>
Stefan Roese326c9712005-08-01 16:41:48 +02006 *
7 * (C) Copyright 2004
8 * Pierre Aubert, Staubli Faverges <p.aubert@staubli.com>
9 *
10 * Note: Much of this code has been derived from Linux 2.4
11 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
12 * (C) Copyright 2000-2002 David Brownell
13 *
14 * See file CREDITS for list of people who contributed to this
15 * project.
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * MA 02111-1307 USA
31 *
32 */
33/*
34 * IMPORTANT NOTES
35 * 1 - this driver is intended for use with USB Mass Storage Devices
36 * (BBB) ONLY. There is NO support for Interrupt or Isochronous pipes!
37 */
38
39#include <common.h>
40
41#ifdef CONFIG_USB_OHCI
42
43#include <malloc.h>
44#include <usb.h>
45#include "usb_ohci.h"
Stefan Roese40ee63b2005-08-02 10:05:21 +020046
Stefan Roese326c9712005-08-01 16:41:48 +020047#include "usbdev.h"
48
49#define OHCI_USE_NPS /* force NoPowerSwitching mode */
50#undef OHCI_VERBOSE_DEBUG /* not always helpful */
51#undef DEBUG
52#undef SHOW_INFO
53#undef OHCI_FILL_TRACE
54
55/* For initializing controller (mask in an HCFS mode too) */
56#define OHCI_CONTROL_INIT \
57 (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE
58
Wolfgang Denk9af58052008-04-25 12:44:08 +020059#define readl(a) (*((volatile u32 *)(a)))
60#define writel(a, b) (*((volatile u32 *)(b)) = ((volatile u32)a))
Stefan Roese326c9712005-08-01 16:41:48 +020061
62#define min_t(type,x,y) ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
63
64#ifdef DEBUG
65#define dbg(format, arg...) printf("DEBUG: " format "\n", ## arg)
66#else
67#define dbg(format, arg...) do {} while(0)
Stefan Roese40ee63b2005-08-02 10:05:21 +020068#endif /* DEBUG */
Stefan Roese326c9712005-08-01 16:41:48 +020069#define err(format, arg...) printf("ERROR: " format "\n", ## arg)
70#ifdef SHOW_INFO
71#define info(format, arg...) printf("INFO: " format "\n", ## arg)
72#else
73#define info(format, arg...) do {} while(0)
74#endif
75
76#define m16_swap(x) swap_16(x)
77#define m32_swap(x) swap_32(x)
78
Stefan Roese17ffbc82007-03-21 13:38:59 +010079#if defined(CONFIG_405EZ) || defined(CONFIG_440EP) || defined(CONFIG_440EPX)
Stefan Roese326c9712005-08-01 16:41:48 +020080#define ohci_cpu_to_le16(x) (x)
81#define ohci_cpu_to_le32(x) (x)
82#else
83#define ohci_cpu_to_le16(x) swap_16(x)
84#define ohci_cpu_to_le32(x) swap_32(x)
85#endif
86
87/* global ohci_t */
88static ohci_t gohci;
89/* this must be aligned to a 256 byte boundary */
90struct ohci_hcca ghcca[1];
91/* a pointer to the aligned storage */
92struct ohci_hcca *phcca;
93/* this allocates EDs for all possible endpoints */
94struct ohci_device ohci_dev;
95/* urb_priv */
96urb_priv_t urb_priv;
97/* RHSC flag */
98int got_rhsc;
99/* device which was disconnected */
100struct usb_device *devgone;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200101/* flag guarding URB transation */
102int urb_finished = 0;
Stefan Roese326c9712005-08-01 16:41:48 +0200103
104/*-------------------------------------------------------------------------*/
105
106/* AMD-756 (D2 rev) reports corrupt register contents in some cases.
107 * The erratum (#4) description is incorrect. AMD's workaround waits
108 * till some bits (mostly reserved) are clear; ok for all revs.
109 */
110#define OHCI_QUIRK_AMD756 0xabcd
111#define read_roothub(hc, register, mask) ({ \
112 u32 temp = readl (&hc->regs->roothub.register); \
113 if (hc->flags & OHCI_QUIRK_AMD756) \
114 while (temp & mask) \
115 temp = readl (&hc->regs->roothub.register); \
116 temp; })
117
Stefan Roese40ee63b2005-08-02 10:05:21 +0200118static u32 roothub_a (struct ohci *hc)
119 { return read_roothub (hc, a, 0xfc0fe000); }
120static inline u32 roothub_b (struct ohci *hc)
121 { return readl (&hc->regs->roothub.b); }
122static inline u32 roothub_status (struct ohci *hc)
123 { return readl (&hc->regs->roothub.status); }
124static u32 roothub_portstatus (struct ohci *hc, int i)
125 { return read_roothub (hc, portstatus [i], 0xffe0fce0); }
126
Stefan Roese326c9712005-08-01 16:41:48 +0200127
128/* forward declaration */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200129static int hc_interrupt (void);
Stefan Roese326c9712005-08-01 16:41:48 +0200130static void
Stefan Roese40ee63b2005-08-02 10:05:21 +0200131td_submit_job (struct usb_device * dev, unsigned long pipe, void * buffer,
132 int transfer_len, struct devrequest * setup, urb_priv_t * urb, int interval);
Stefan Roese326c9712005-08-01 16:41:48 +0200133
134/*-------------------------------------------------------------------------*
135 * URB support functions
136 *-------------------------------------------------------------------------*/
137
138/* free HCD-private data associated with this URB */
139
Stefan Roese40ee63b2005-08-02 10:05:21 +0200140static void urb_free_priv (urb_priv_t * urb)
Stefan Roese326c9712005-08-01 16:41:48 +0200141{
Stefan Roese40ee63b2005-08-02 10:05:21 +0200142 int i;
143 int last;
144 struct td * td;
Stefan Roese326c9712005-08-01 16:41:48 +0200145
146 last = urb->length - 1;
147 if (last >= 0) {
148 for (i = 0; i <= last; i++) {
149 td = urb->td[i];
150 if (td) {
151 td->usb_dev = NULL;
152 urb->td[i] = NULL;
153 }
154 }
155 }
156}
157
158/*-------------------------------------------------------------------------*/
159
160#ifdef DEBUG
Stefan Roese40ee63b2005-08-02 10:05:21 +0200161static int sohci_get_current_frame_number (struct usb_device * dev);
Stefan Roese326c9712005-08-01 16:41:48 +0200162
163/* debug| print the main components of an URB
164 * small: 0) header + data packets 1) just header */
165
Stefan Roese40ee63b2005-08-02 10:05:21 +0200166static void pkt_print (struct usb_device * dev, unsigned long pipe, void * buffer,
167 int transfer_len, struct devrequest * setup, char * str, int small)
Stefan Roese326c9712005-08-01 16:41:48 +0200168{
Stefan Roese40ee63b2005-08-02 10:05:21 +0200169 urb_priv_t * purb = &urb_priv;
Stefan Roese326c9712005-08-01 16:41:48 +0200170
171 dbg("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,len:%d/%d stat:%#lx",
Stefan Roese40ee63b2005-08-02 10:05:21 +0200172 str,
173 sohci_get_current_frame_number (dev),
174 usb_pipedevice (pipe),
175 usb_pipeendpoint (pipe),
176 usb_pipeout (pipe)? 'O': 'I',
177 usb_pipetype (pipe) < 2? (usb_pipeint (pipe)? "INTR": "ISOC"):
178 (usb_pipecontrol (pipe)? "CTRL": "BULK"),
179 purb->actual_length,
180 transfer_len, dev->status);
Stefan Roese326c9712005-08-01 16:41:48 +0200181#ifdef OHCI_VERBOSE_DEBUG
182 if (!small) {
183 int i, len;
184
Stefan Roese40ee63b2005-08-02 10:05:21 +0200185 if (usb_pipecontrol (pipe)) {
186 printf (__FILE__ ": cmd(8):");
187 for (i = 0; i < 8 ; i++)
188 printf (" %02x", ((__u8 *) setup) [i]);
189 printf ("\n");
Stefan Roese326c9712005-08-01 16:41:48 +0200190 }
191 if (transfer_len > 0 && buffer) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200192 printf (__FILE__ ": data(%d/%d):",
193 purb->actual_length,
194 transfer_len);
195 len = usb_pipeout (pipe)?
196 transfer_len: purb->actual_length;
Stefan Roese326c9712005-08-01 16:41:48 +0200197 for (i = 0; i < 16 && i < len; i++)
Stefan Roese40ee63b2005-08-02 10:05:21 +0200198 printf (" %02x", ((__u8 *) buffer) [i]);
199 printf ("%s\n", i < len? "...": "");
Stefan Roese326c9712005-08-01 16:41:48 +0200200 }
201 }
202#endif
203}
204
205/* just for debugging; prints non-empty branches of the int ed tree inclusive iso eds*/
Stefan Roese40ee63b2005-08-02 10:05:21 +0200206void ep_print_int_eds (ohci_t *ohci, char * str) {
Stefan Roese326c9712005-08-01 16:41:48 +0200207 int i, j;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200208 __u32 * ed_p;
209 for (i= 0; i < 32; i++) {
Stefan Roese326c9712005-08-01 16:41:48 +0200210 j = 5;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200211 ed_p = &(ohci->hcca->int_table [i]);
Stefan Roese326c9712005-08-01 16:41:48 +0200212 if (*ed_p == 0)
Stefan Roese40ee63b2005-08-02 10:05:21 +0200213 continue;
214 printf (__FILE__ ": %s branch int %2d(%2x):", str, i, i);
Stefan Roese326c9712005-08-01 16:41:48 +0200215 while (*ed_p != 0 && j--) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200216 ed_t *ed = (ed_t *)ohci_cpu_to_le32(ed_p);
217 printf (" ed: %4x;", ed->hwINFO);
Stefan Roese326c9712005-08-01 16:41:48 +0200218 ed_p = &ed->hwNextED;
219 }
Stefan Roese40ee63b2005-08-02 10:05:21 +0200220 printf ("\n");
Stefan Roese326c9712005-08-01 16:41:48 +0200221 }
222}
223
Stefan Roese40ee63b2005-08-02 10:05:21 +0200224static void ohci_dump_intr_mask (char *label, __u32 mask)
Stefan Roese326c9712005-08-01 16:41:48 +0200225{
Stefan Roese40ee63b2005-08-02 10:05:21 +0200226 dbg ("%s: 0x%08x%s%s%s%s%s%s%s%s%s",
227 label,
228 mask,
229 (mask & OHCI_INTR_MIE) ? " MIE" : "",
230 (mask & OHCI_INTR_OC) ? " OC" : "",
231 (mask & OHCI_INTR_RHSC) ? " RHSC" : "",
232 (mask & OHCI_INTR_FNO) ? " FNO" : "",
233 (mask & OHCI_INTR_UE) ? " UE" : "",
234 (mask & OHCI_INTR_RD) ? " RD" : "",
235 (mask & OHCI_INTR_SF) ? " SF" : "",
236 (mask & OHCI_INTR_WDH) ? " WDH" : "",
237 (mask & OHCI_INTR_SO) ? " SO" : ""
238 );
Stefan Roese326c9712005-08-01 16:41:48 +0200239}
240
Stefan Roese40ee63b2005-08-02 10:05:21 +0200241static void maybe_print_eds (char *label, __u32 value)
Stefan Roese326c9712005-08-01 16:41:48 +0200242{
Stefan Roese40ee63b2005-08-02 10:05:21 +0200243 ed_t *edp = (ed_t *)value;
Stefan Roese326c9712005-08-01 16:41:48 +0200244
245 if (value) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200246 dbg ("%s %08x", label, value);
247 dbg ("%08x", edp->hwINFO);
248 dbg ("%08x", edp->hwTailP);
249 dbg ("%08x", edp->hwHeadP);
250 dbg ("%08x", edp->hwNextED);
Stefan Roese326c9712005-08-01 16:41:48 +0200251 }
252}
253
Stefan Roese40ee63b2005-08-02 10:05:21 +0200254static char * hcfs2string (int state)
Stefan Roese326c9712005-08-01 16:41:48 +0200255{
256 switch (state) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200257 case OHCI_USB_RESET: return "reset";
258 case OHCI_USB_RESUME: return "resume";
259 case OHCI_USB_OPER: return "operational";
260 case OHCI_USB_SUSPEND: return "suspend";
Stefan Roese326c9712005-08-01 16:41:48 +0200261 }
262 return "?";
263}
264
265/* dump control and status registers */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200266static void ohci_dump_status (ohci_t *controller)
Stefan Roese326c9712005-08-01 16:41:48 +0200267{
Stefan Roese40ee63b2005-08-02 10:05:21 +0200268 struct ohci_regs *regs = controller->regs;
269 __u32 temp;
Stefan Roese326c9712005-08-01 16:41:48 +0200270
Stefan Roese40ee63b2005-08-02 10:05:21 +0200271 temp = readl (&regs->revision) & 0xff;
Stefan Roese326c9712005-08-01 16:41:48 +0200272 if (temp != 0x10)
Stefan Roese40ee63b2005-08-02 10:05:21 +0200273 dbg ("spec %d.%d", (temp >> 4), (temp & 0x0f));
Stefan Roese326c9712005-08-01 16:41:48 +0200274
Stefan Roese40ee63b2005-08-02 10:05:21 +0200275 temp = readl (&regs->control);
276 dbg ("control: 0x%08x%s%s%s HCFS=%s%s%s%s%s CBSR=%d", temp,
277 (temp & OHCI_CTRL_RWE) ? " RWE" : "",
278 (temp & OHCI_CTRL_RWC) ? " RWC" : "",
279 (temp & OHCI_CTRL_IR) ? " IR" : "",
280 hcfs2string (temp & OHCI_CTRL_HCFS),
281 (temp & OHCI_CTRL_BLE) ? " BLE" : "",
282 (temp & OHCI_CTRL_CLE) ? " CLE" : "",
283 (temp & OHCI_CTRL_IE) ? " IE" : "",
284 (temp & OHCI_CTRL_PLE) ? " PLE" : "",
285 temp & OHCI_CTRL_CBSR
286 );
Stefan Roese326c9712005-08-01 16:41:48 +0200287
Stefan Roese40ee63b2005-08-02 10:05:21 +0200288 temp = readl (&regs->cmdstatus);
289 dbg ("cmdstatus: 0x%08x SOC=%d%s%s%s%s", temp,
290 (temp & OHCI_SOC) >> 16,
291 (temp & OHCI_OCR) ? " OCR" : "",
292 (temp & OHCI_BLF) ? " BLF" : "",
293 (temp & OHCI_CLF) ? " CLF" : "",
294 (temp & OHCI_HCR) ? " HCR" : ""
295 );
Stefan Roese326c9712005-08-01 16:41:48 +0200296
Stefan Roese40ee63b2005-08-02 10:05:21 +0200297 ohci_dump_intr_mask ("intrstatus", readl (&regs->intrstatus));
298 ohci_dump_intr_mask ("intrenable", readl (&regs->intrenable));
Stefan Roese326c9712005-08-01 16:41:48 +0200299
Stefan Roese40ee63b2005-08-02 10:05:21 +0200300 maybe_print_eds ("ed_periodcurrent", readl (&regs->ed_periodcurrent));
Stefan Roese326c9712005-08-01 16:41:48 +0200301
Stefan Roese40ee63b2005-08-02 10:05:21 +0200302 maybe_print_eds ("ed_controlhead", readl (&regs->ed_controlhead));
303 maybe_print_eds ("ed_controlcurrent", readl (&regs->ed_controlcurrent));
Stefan Roese326c9712005-08-01 16:41:48 +0200304
Stefan Roese40ee63b2005-08-02 10:05:21 +0200305 maybe_print_eds ("ed_bulkhead", readl (&regs->ed_bulkhead));
306 maybe_print_eds ("ed_bulkcurrent", readl (&regs->ed_bulkcurrent));
Stefan Roese326c9712005-08-01 16:41:48 +0200307
Stefan Roese40ee63b2005-08-02 10:05:21 +0200308 maybe_print_eds ("donehead", readl (&regs->donehead));
Stefan Roese326c9712005-08-01 16:41:48 +0200309}
310
Stefan Roese40ee63b2005-08-02 10:05:21 +0200311static void ohci_dump_roothub (ohci_t *controller, int verbose)
Stefan Roese326c9712005-08-01 16:41:48 +0200312{
Stefan Roese40ee63b2005-08-02 10:05:21 +0200313 __u32 temp, ndp, i;
Stefan Roese326c9712005-08-01 16:41:48 +0200314
Stefan Roese40ee63b2005-08-02 10:05:21 +0200315 temp = roothub_a (controller);
Stefan Roese326c9712005-08-01 16:41:48 +0200316 ndp = (temp & RH_A_NDP);
317
318 if (verbose) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200319 dbg ("roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d", temp,
320 ((temp & RH_A_POTPGT) >> 24) & 0xff,
321 (temp & RH_A_NOCP) ? " NOCP" : "",
322 (temp & RH_A_OCPM) ? " OCPM" : "",
323 (temp & RH_A_DT) ? " DT" : "",
324 (temp & RH_A_NPS) ? " NPS" : "",
325 (temp & RH_A_PSM) ? " PSM" : "",
326 ndp
327 );
328 temp = roothub_b (controller);
329 dbg ("roothub.b: %08x PPCM=%04x DR=%04x",
330 temp,
331 (temp & RH_B_PPCM) >> 16,
332 (temp & RH_B_DR)
333 );
334 temp = roothub_status (controller);
335 dbg ("roothub.status: %08x%s%s%s%s%s%s",
336 temp,
337 (temp & RH_HS_CRWE) ? " CRWE" : "",
338 (temp & RH_HS_OCIC) ? " OCIC" : "",
339 (temp & RH_HS_LPSC) ? " LPSC" : "",
340 (temp & RH_HS_DRWE) ? " DRWE" : "",
341 (temp & RH_HS_OCI) ? " OCI" : "",
342 (temp & RH_HS_LPS) ? " LPS" : ""
343 );
Stefan Roese326c9712005-08-01 16:41:48 +0200344 }
345
346 for (i = 0; i < ndp; i++) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200347 temp = roothub_portstatus (controller, i);
348 dbg ("roothub.portstatus [%d] = 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s",
349 i,
350 temp,
351 (temp & RH_PS_PRSC) ? " PRSC" : "",
352 (temp & RH_PS_OCIC) ? " OCIC" : "",
353 (temp & RH_PS_PSSC) ? " PSSC" : "",
354 (temp & RH_PS_PESC) ? " PESC" : "",
355 (temp & RH_PS_CSC) ? " CSC" : "",
356
357 (temp & RH_PS_LSDA) ? " LSDA" : "",
358 (temp & RH_PS_PPS) ? " PPS" : "",
359 (temp & RH_PS_PRS) ? " PRS" : "",
360 (temp & RH_PS_POCI) ? " POCI" : "",
361 (temp & RH_PS_PSS) ? " PSS" : "",
362
363 (temp & RH_PS_PES) ? " PES" : "",
364 (temp & RH_PS_CCS) ? " CCS" : ""
365 );
Stefan Roese326c9712005-08-01 16:41:48 +0200366 }
367}
368
Stefan Roese40ee63b2005-08-02 10:05:21 +0200369static void ohci_dump (ohci_t *controller, int verbose)
Stefan Roese326c9712005-08-01 16:41:48 +0200370{
Stefan Roese40ee63b2005-08-02 10:05:21 +0200371 dbg ("OHCI controller usb-%s state", controller->slot_name);
Stefan Roese326c9712005-08-01 16:41:48 +0200372
373 /* dumps some of the state we know about */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200374 ohci_dump_status (controller);
Stefan Roese326c9712005-08-01 16:41:48 +0200375 if (verbose)
Stefan Roese40ee63b2005-08-02 10:05:21 +0200376 ep_print_int_eds (controller, "hcca");
377 dbg ("hcca frame #%04x", controller->hcca->frame_no);
378 ohci_dump_roothub (controller, 1);
Stefan Roese326c9712005-08-01 16:41:48 +0200379}
380
Stefan Roese40ee63b2005-08-02 10:05:21 +0200381
382#endif /* DEBUG */
Stefan Roese326c9712005-08-01 16:41:48 +0200383
384/*-------------------------------------------------------------------------*
385 * Interface functions (URB)
386 *-------------------------------------------------------------------------*/
387
388/* get a transfer request */
389
390int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer,
Stefan Roese40ee63b2005-08-02 10:05:21 +0200391 int transfer_len, struct devrequest *setup, int interval)
Stefan Roese326c9712005-08-01 16:41:48 +0200392{
393 ohci_t *ohci;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200394 ed_t * ed;
Stefan Roese326c9712005-08-01 16:41:48 +0200395 urb_priv_t *purb_priv;
396 int i, size = 0;
397
398 ohci = &gohci;
399
400 /* when controller's hung, permit only roothub cleanup attempts
401 * such as powering down ports */
402 if (ohci->disabled) {
403 err("sohci_submit_job: EPIPE");
404 return -1;
405 }
406
Stefan Roese40ee63b2005-08-02 10:05:21 +0200407 /* if we have an unfinished URB from previous transaction let's
408 * fail and scream as quickly as possible so as not to corrupt
409 * further communication */
410 if (!urb_finished) {
411 err("sohci_submit_job: URB NOT FINISHED");
412 return -1;
413 }
414 /* we're about to begin a new transaction here so mark the URB unfinished */
415 urb_finished = 0;
416
Stefan Roese326c9712005-08-01 16:41:48 +0200417 /* every endpoint has a ed, locate and fill it */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200418 if (!(ed = ep_add_ed (dev, pipe))) {
Stefan Roese326c9712005-08-01 16:41:48 +0200419 err("sohci_submit_job: ENOMEM");
420 return -1;
421 }
422
423 /* for the private part of the URB we need the number of TDs (size) */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200424 switch (usb_pipetype (pipe)) {
425 case PIPE_BULK: /* one TD for every 4096 Byte */
426 size = (transfer_len - 1) / 4096 + 1;
427 break;
428 case PIPE_CONTROL: /* 1 TD for setup, 1 for ACK and 1 for every 4096 B */
429 size = (transfer_len == 0)? 2:
430 (transfer_len - 1) / 4096 + 3;
431 break;
Stefan Roese326c9712005-08-01 16:41:48 +0200432 }
433
434 if (size >= (N_URB_TD - 1)) {
435 err("need %d TDs, only have %d", size, N_URB_TD);
436 return -1;
437 }
438 purb_priv = &urb_priv;
439 purb_priv->pipe = pipe;
440
441 /* fill the private part of the URB */
442 purb_priv->length = size;
443 purb_priv->ed = ed;
444 purb_priv->actual_length = 0;
445
446 /* allocate the TDs */
447 /* note that td[0] was allocated in ep_add_ed */
448 for (i = 0; i < size; i++) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200449 purb_priv->td[i] = td_alloc (dev);
Stefan Roese326c9712005-08-01 16:41:48 +0200450 if (!purb_priv->td[i]) {
451 purb_priv->length = i;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200452 urb_free_priv (purb_priv);
Stefan Roese326c9712005-08-01 16:41:48 +0200453 err("sohci_submit_job: ENOMEM");
454 return -1;
455 }
456 }
457
458 if (ed->state == ED_NEW || (ed->state & ED_DEL)) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200459 urb_free_priv (purb_priv);
Stefan Roese326c9712005-08-01 16:41:48 +0200460 err("sohci_submit_job: EINVAL");
461 return -1;
462 }
463
464 /* link the ed into a chain if is not already */
465 if (ed->state != ED_OPER)
Stefan Roese40ee63b2005-08-02 10:05:21 +0200466 ep_link (ohci, ed);
Stefan Roese326c9712005-08-01 16:41:48 +0200467
468 /* fill the TDs and link it to the ed */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200469 td_submit_job(dev, pipe, buffer, transfer_len, setup, purb_priv, interval);
Stefan Roese326c9712005-08-01 16:41:48 +0200470
471 return 0;
472}
473
474/*-------------------------------------------------------------------------*/
475
476#ifdef DEBUG
477/* tell us the current USB frame number */
478
Stefan Roese40ee63b2005-08-02 10:05:21 +0200479static int sohci_get_current_frame_number (struct usb_device *usb_dev)
Stefan Roese326c9712005-08-01 16:41:48 +0200480{
481 ohci_t *ohci = &gohci;
482
Stefan Roese40ee63b2005-08-02 10:05:21 +0200483 return ohci_cpu_to_le16 (ohci->hcca->frame_no);
Stefan Roese326c9712005-08-01 16:41:48 +0200484}
485#endif
486
487/*-------------------------------------------------------------------------*
488 * ED handling functions
489 *-------------------------------------------------------------------------*/
490
491/* link an ed into one of the HC chains */
492
Stefan Roese40ee63b2005-08-02 10:05:21 +0200493static int ep_link (ohci_t *ohci, ed_t *edi)
Stefan Roese326c9712005-08-01 16:41:48 +0200494{
495 volatile ed_t *ed = edi;
496
497 ed->state = ED_OPER;
498
499 switch (ed->type) {
500 case PIPE_CONTROL:
501 ed->hwNextED = 0;
502 if (ohci->ed_controltail == NULL) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200503 writel (ed, &ohci->regs->ed_controlhead);
Stefan Roese326c9712005-08-01 16:41:48 +0200504 } else {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200505 ohci->ed_controltail->hwNextED = ohci_cpu_to_le32 ((unsigned long)ed);
Stefan Roese326c9712005-08-01 16:41:48 +0200506 }
507 ed->ed_prev = ohci->ed_controltail;
508 if (!ohci->ed_controltail && !ohci->ed_rm_list[0] &&
Stefan Roese40ee63b2005-08-02 10:05:21 +0200509 !ohci->ed_rm_list[1] && !ohci->sleeping) {
Stefan Roese326c9712005-08-01 16:41:48 +0200510 ohci->hc_control |= OHCI_CTRL_CLE;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200511 writel (ohci->hc_control, &ohci->regs->control);
Stefan Roese326c9712005-08-01 16:41:48 +0200512 }
513 ohci->ed_controltail = edi;
514 break;
515
516 case PIPE_BULK:
517 ed->hwNextED = 0;
518 if (ohci->ed_bulktail == NULL) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200519 writel (ed, &ohci->regs->ed_bulkhead);
Stefan Roese326c9712005-08-01 16:41:48 +0200520 } else {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200521 ohci->ed_bulktail->hwNextED = ohci_cpu_to_le32 ((unsigned long)ed);
Stefan Roese326c9712005-08-01 16:41:48 +0200522 }
523 ed->ed_prev = ohci->ed_bulktail;
524 if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] &&
Stefan Roese40ee63b2005-08-02 10:05:21 +0200525 !ohci->ed_rm_list[1] && !ohci->sleeping) {
Stefan Roese326c9712005-08-01 16:41:48 +0200526 ohci->hc_control |= OHCI_CTRL_BLE;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200527 writel (ohci->hc_control, &ohci->regs->control);
Stefan Roese326c9712005-08-01 16:41:48 +0200528 }
529 ohci->ed_bulktail = edi;
530 break;
531 }
532 return 0;
533}
534
535/*-------------------------------------------------------------------------*/
536
537/* unlink an ed from one of the HC chains.
538 * just the link to the ed is unlinked.
539 * the link from the ed still points to another operational ed or 0
540 * so the HC can eventually finish the processing of the unlinked ed */
541
Stefan Roese40ee63b2005-08-02 10:05:21 +0200542static int ep_unlink (ohci_t *ohci, ed_t *edi)
Stefan Roese326c9712005-08-01 16:41:48 +0200543{
544 volatile ed_t *ed = edi;
545
Stefan Roese40ee63b2005-08-02 10:05:21 +0200546 ed->hwINFO |= ohci_cpu_to_le32 (OHCI_ED_SKIP);
Stefan Roese326c9712005-08-01 16:41:48 +0200547
548 switch (ed->type) {
549 case PIPE_CONTROL:
550 if (ed->ed_prev == NULL) {
551 if (!ed->hwNextED) {
552 ohci->hc_control &= ~OHCI_CTRL_CLE;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200553 writel (ohci->hc_control, &ohci->regs->control);
Stefan Roese326c9712005-08-01 16:41:48 +0200554 }
Stefan Roese40ee63b2005-08-02 10:05:21 +0200555 writel (ohci_cpu_to_le32 (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_controlhead);
Stefan Roese326c9712005-08-01 16:41:48 +0200556 } else {
557 ed->ed_prev->hwNextED = ed->hwNextED;
558 }
559 if (ohci->ed_controltail == ed) {
560 ohci->ed_controltail = ed->ed_prev;
561 } else {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200562 ((ed_t *)ohci_cpu_to_le32 (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
Stefan Roese326c9712005-08-01 16:41:48 +0200563 }
564 break;
565
566 case PIPE_BULK:
567 if (ed->ed_prev == NULL) {
568 if (!ed->hwNextED) {
569 ohci->hc_control &= ~OHCI_CTRL_BLE;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200570 writel (ohci->hc_control, &ohci->regs->control);
Stefan Roese326c9712005-08-01 16:41:48 +0200571 }
Stefan Roese40ee63b2005-08-02 10:05:21 +0200572 writel (ohci_cpu_to_le32 (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_bulkhead);
Stefan Roese326c9712005-08-01 16:41:48 +0200573 } else {
574 ed->ed_prev->hwNextED = ed->hwNextED;
575 }
576 if (ohci->ed_bulktail == ed) {
577 ohci->ed_bulktail = ed->ed_prev;
578 } else {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200579 ((ed_t *)ohci_cpu_to_le32 (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
Stefan Roese326c9712005-08-01 16:41:48 +0200580 }
581 break;
582 }
583 ed->state = ED_UNLINK;
584 return 0;
585}
586
Stefan Roese40ee63b2005-08-02 10:05:21 +0200587
Stefan Roese326c9712005-08-01 16:41:48 +0200588/*-------------------------------------------------------------------------*/
589
590/* add/reinit an endpoint; this should be done once at the usb_set_configuration command,
591 * but the USB stack is a little bit stateless so we do it at every transaction
592 * if the state of the ed is ED_NEW then a dummy td is added and the state is changed to ED_UNLINK
593 * in all other cases the state is left unchanged
594 * the ed info fields are setted anyway even though most of them should not change */
595
Stefan Roese40ee63b2005-08-02 10:05:21 +0200596static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
Stefan Roese326c9712005-08-01 16:41:48 +0200597{
598 td_t *td;
599 ed_t *ed_ret;
600 volatile ed_t *ed;
601
Stefan Roese40ee63b2005-08-02 10:05:21 +0200602 ed = ed_ret = &ohci_dev.ed[(usb_pipeendpoint (pipe) << 1) |
603 (usb_pipecontrol (pipe)? 0: usb_pipeout (pipe))];
Stefan Roese326c9712005-08-01 16:41:48 +0200604
605 if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) {
606 err("ep_add_ed: pending delete");
607 /* pending delete request */
608 return NULL;
609 }
610
611 if (ed->state == ED_NEW) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200612 ed->hwINFO = ohci_cpu_to_le32 (OHCI_ED_SKIP); /* skip ed */
Stefan Roese326c9712005-08-01 16:41:48 +0200613 /* dummy td; end of td list for ed */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200614 td = td_alloc (usb_dev);
615 ed->hwTailP = ohci_cpu_to_le32 ((unsigned long)td);
Stefan Roese326c9712005-08-01 16:41:48 +0200616 ed->hwHeadP = ed->hwTailP;
617 ed->state = ED_UNLINK;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200618 ed->type = usb_pipetype (pipe);
Stefan Roese326c9712005-08-01 16:41:48 +0200619 ohci_dev.ed_cnt++;
620 }
621
Stefan Roese40ee63b2005-08-02 10:05:21 +0200622 ed->hwINFO = ohci_cpu_to_le32 (usb_pipedevice (pipe)
623 | usb_pipeendpoint (pipe) << 7
624 | (usb_pipeisoc (pipe)? 0x8000: 0)
625 | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000))
626 | usb_pipeslow (pipe) << 13
627 | usb_maxpacket (usb_dev, pipe) << 16);
Stefan Roese326c9712005-08-01 16:41:48 +0200628
629 return ed_ret;
630}
631
632/*-------------------------------------------------------------------------*
633 * TD handling functions
634 *-------------------------------------------------------------------------*/
635
636/* enqueue next TD for this URB (OHCI spec 5.2.8.2) */
637
Stefan Roese40ee63b2005-08-02 10:05:21 +0200638static void td_fill (ohci_t *ohci, unsigned int info,
639 void *data, int len,
640 struct usb_device *dev, int index, urb_priv_t *urb_priv)
Stefan Roese326c9712005-08-01 16:41:48 +0200641{
Stefan Roese40ee63b2005-08-02 10:05:21 +0200642 volatile td_t *td, *td_pt;
Stefan Roese326c9712005-08-01 16:41:48 +0200643#ifdef OHCI_FILL_TRACE
644 int i;
645#endif
646
647 if (index > urb_priv->length) {
648 err("index > length");
649 return;
650 }
651 /* use this td as the next dummy */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200652 td_pt = urb_priv->td [index];
Stefan Roese326c9712005-08-01 16:41:48 +0200653 td_pt->hwNextTD = 0;
654
655 /* fill the old dummy TD */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200656 td = urb_priv->td [index] = (td_t *)(ohci_cpu_to_le32 (urb_priv->ed->hwTailP) & ~0xf);
Stefan Roese326c9712005-08-01 16:41:48 +0200657
658 td->ed = urb_priv->ed;
659 td->next_dl_td = NULL;
660 td->index = index;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200661 td->data = (__u32)data;
Stefan Roese326c9712005-08-01 16:41:48 +0200662#ifdef OHCI_FILL_TRACE
Remy Bohmerd8c55ab2008-10-10 10:23:22 +0200663 if (usb_pipebulk(urb_priv->pipe) && usb_pipeout(urb_priv->pipe)) {
Stefan Roese326c9712005-08-01 16:41:48 +0200664 for (i = 0; i < len; i++)
Stefan Roese40ee63b2005-08-02 10:05:21 +0200665 printf("td->data[%d] %#2x ",i, ((unsigned char *)td->data)[i]);
Stefan Roese326c9712005-08-01 16:41:48 +0200666 printf("\n");
667 }
668#endif
669 if (!len)
670 data = 0;
671
Stefan Roese40ee63b2005-08-02 10:05:21 +0200672 td->hwINFO = ohci_cpu_to_le32 (info);
673 td->hwCBP = ohci_cpu_to_le32 ((unsigned long)data);
Stefan Roese326c9712005-08-01 16:41:48 +0200674 if (data)
Stefan Roese40ee63b2005-08-02 10:05:21 +0200675 td->hwBE = ohci_cpu_to_le32 ((unsigned long)(data + len - 1));
Stefan Roese326c9712005-08-01 16:41:48 +0200676 else
677 td->hwBE = 0;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200678 td->hwNextTD = ohci_cpu_to_le32 ((unsigned long)td_pt);
Stefan Roese326c9712005-08-01 16:41:48 +0200679
680 /* append to queue */
681 td->ed->hwTailP = td->hwNextTD;
682}
683
684/*-------------------------------------------------------------------------*/
685
686/* prepare all TDs of a transfer */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200687static void td_submit_job (struct usb_device *dev, unsigned long pipe, void *buffer,
688 int transfer_len, struct devrequest *setup, urb_priv_t *urb, int interval)
Stefan Roese326c9712005-08-01 16:41:48 +0200689{
690 ohci_t *ohci = &gohci;
691 int data_len = transfer_len;
692 void *data;
693 int cnt = 0;
694 __u32 info = 0;
695 unsigned int toggle = 0;
696
697 /* OHCI handles the DATA-toggles itself, we just use the USB-toggle bits for reseting */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200698 if(usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe))) {
Stefan Roese326c9712005-08-01 16:41:48 +0200699 toggle = TD_T_TOGGLE;
700 } else {
701 toggle = TD_T_DATA0;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200702 usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 1);
Stefan Roese326c9712005-08-01 16:41:48 +0200703 }
704 urb->td_cnt = 0;
705 if (data_len)
706 data = buffer;
707 else
708 data = 0;
709
Stefan Roese40ee63b2005-08-02 10:05:21 +0200710 switch (usb_pipetype (pipe)) {
Stefan Roese326c9712005-08-01 16:41:48 +0200711 case PIPE_BULK:
Stefan Roese40ee63b2005-08-02 10:05:21 +0200712 info = usb_pipeout (pipe)?
713 TD_CC | TD_DP_OUT : TD_CC | TD_DP_IN ;
714 while(data_len > 4096) {
715 td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, 4096, dev, cnt, urb);
716 data += 4096; data_len -= 4096; cnt++;
Stefan Roese326c9712005-08-01 16:41:48 +0200717 }
Stefan Roese40ee63b2005-08-02 10:05:21 +0200718 info = usb_pipeout (pipe)?
719 TD_CC | TD_DP_OUT : TD_CC | TD_R | TD_DP_IN ;
720 td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, data_len, dev, cnt, urb);
Stefan Roese326c9712005-08-01 16:41:48 +0200721 cnt++;
722
723 if (!ohci->sleeping)
Stefan Roese40ee63b2005-08-02 10:05:21 +0200724 writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
Stefan Roese326c9712005-08-01 16:41:48 +0200725 break;
726
727 case PIPE_CONTROL:
728 info = TD_CC | TD_DP_SETUP | TD_T_DATA0;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200729 td_fill (ohci, info, setup, 8, dev, cnt++, urb);
Stefan Roese326c9712005-08-01 16:41:48 +0200730 if (data_len > 0) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200731 info = usb_pipeout (pipe)?
732 TD_CC | TD_R | TD_DP_OUT | TD_T_DATA1 : TD_CC | TD_R | TD_DP_IN | TD_T_DATA1;
Stefan Roese326c9712005-08-01 16:41:48 +0200733 /* NOTE: mishandles transfers >8K, some >4K */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200734 td_fill (ohci, info, data, data_len, dev, cnt++, urb);
Stefan Roese326c9712005-08-01 16:41:48 +0200735 }
Stefan Roese40ee63b2005-08-02 10:05:21 +0200736 info = usb_pipeout (pipe)?
737 TD_CC | TD_DP_IN | TD_T_DATA1: TD_CC | TD_DP_OUT | TD_T_DATA1;
738 td_fill (ohci, info, data, 0, dev, cnt++, urb);
Stefan Roese326c9712005-08-01 16:41:48 +0200739 if (!ohci->sleeping)
Stefan Roese40ee63b2005-08-02 10:05:21 +0200740 writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
Stefan Roese326c9712005-08-01 16:41:48 +0200741 break;
742 }
743 if (urb->length != cnt)
744 dbg("TD LENGTH %d != CNT %d", urb->length, cnt);
745}
746
747/*-------------------------------------------------------------------------*
748 * Done List handling functions
749 *-------------------------------------------------------------------------*/
750
Stefan Roese40ee63b2005-08-02 10:05:21 +0200751
Stefan Roese326c9712005-08-01 16:41:48 +0200752/* calculate the transfer length and update the urb */
753
754static void dl_transfer_length(td_t * td)
755{
756 __u32 tdINFO, tdBE, tdCBP;
757 urb_priv_t *lurb_priv = &urb_priv;
758
Stefan Roese40ee63b2005-08-02 10:05:21 +0200759 tdINFO = ohci_cpu_to_le32 (td->hwINFO);
760 tdBE = ohci_cpu_to_le32 (td->hwBE);
761 tdCBP = ohci_cpu_to_le32 (td->hwCBP);
762
Stefan Roese326c9712005-08-01 16:41:48 +0200763
Remy Bohmerd8c55ab2008-10-10 10:23:22 +0200764 if (!(usb_pipecontrol(lurb_priv->pipe) &&
Stefan Roese40ee63b2005-08-02 10:05:21 +0200765 ((td->index == 0) || (td->index == lurb_priv->length - 1)))) {
Stefan Roese326c9712005-08-01 16:41:48 +0200766 if (tdBE != 0) {
767 if (td->hwCBP == 0)
768 lurb_priv->actual_length += tdBE - td->data + 1;
769 else
770 lurb_priv->actual_length += tdCBP - td->data;
771 }
772 }
773}
774
775/*-------------------------------------------------------------------------*/
776
777/* replies to the request have to be on a FIFO basis so
778 * we reverse the reversed done-list */
779
Stefan Roese40ee63b2005-08-02 10:05:21 +0200780static td_t * dl_reverse_done_list (ohci_t *ohci)
Stefan Roese326c9712005-08-01 16:41:48 +0200781{
782 __u32 td_list_hc;
783 td_t *td_rev = NULL;
784 td_t *td_list = NULL;
785 urb_priv_t *lurb_priv = NULL;
786
Stefan Roese40ee63b2005-08-02 10:05:21 +0200787 td_list_hc = ohci_cpu_to_le32 (ohci->hcca->done_head) & 0xfffffff0;
Stefan Roese326c9712005-08-01 16:41:48 +0200788 ohci->hcca->done_head = 0;
789
790 while (td_list_hc) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200791 td_list = (td_t *)td_list_hc;
Stefan Roese326c9712005-08-01 16:41:48 +0200792
Stefan Roese40ee63b2005-08-02 10:05:21 +0200793 if (TD_CC_GET (ohci_cpu_to_le32 (td_list->hwINFO))) {
Stefan Roese326c9712005-08-01 16:41:48 +0200794 lurb_priv = &urb_priv;
795 dbg(" USB-error/status: %x : %p",
Stefan Roese40ee63b2005-08-02 10:05:21 +0200796 TD_CC_GET (ohci_cpu_to_le32 (td_list->hwINFO)), td_list);
797 if (td_list->ed->hwHeadP & ohci_cpu_to_le32 (0x1)) {
798 if (lurb_priv && ((td_list->index + 1) < lurb_priv->length)) {
Stefan Roese326c9712005-08-01 16:41:48 +0200799 td_list->ed->hwHeadP =
Stefan Roese40ee63b2005-08-02 10:05:21 +0200800 (lurb_priv->td[lurb_priv->length - 1]->hwNextTD & ohci_cpu_to_le32 (0xfffffff0)) |
801 (td_list->ed->hwHeadP & ohci_cpu_to_le32 (0x2));
802 lurb_priv->td_cnt += lurb_priv->length - td_list->index - 1;
Stefan Roese326c9712005-08-01 16:41:48 +0200803 } else
Stefan Roese40ee63b2005-08-02 10:05:21 +0200804 td_list->ed->hwHeadP &= ohci_cpu_to_le32 (0xfffffff2);
Stefan Roese326c9712005-08-01 16:41:48 +0200805 }
806#ifdef CONFIG_MPC5200
807 td_list->hwNextTD = 0;
808#endif
809 }
810
811 td_list->next_dl_td = td_rev;
812 td_rev = td_list;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200813 td_list_hc = ohci_cpu_to_le32 (td_list->hwNextTD) & 0xfffffff0;
Stefan Roese326c9712005-08-01 16:41:48 +0200814 }
815 return td_list;
816}
817
818/*-------------------------------------------------------------------------*/
819
820/* td done list */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200821static int dl_done_list (ohci_t *ohci, td_t *td_list)
Stefan Roese326c9712005-08-01 16:41:48 +0200822{
823 td_t *td_list_next = NULL;
824 ed_t *ed;
825 int cc = 0;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200826 int stat = 0;
Stefan Roese326c9712005-08-01 16:41:48 +0200827 /* urb_t *urb; */
828 urb_priv_t *lurb_priv;
829 __u32 tdINFO, edHeadP, edTailP;
830
831 while (td_list) {
832 td_list_next = td_list->next_dl_td;
833
834 lurb_priv = &urb_priv;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200835 tdINFO = ohci_cpu_to_le32 (td_list->hwINFO);
Stefan Roese326c9712005-08-01 16:41:48 +0200836
837 ed = td_list->ed;
838
839 dl_transfer_length(td_list);
840
841 /* error code of transfer */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200842 cc = TD_CC_GET (tdINFO);
Stefan Roese326c9712005-08-01 16:41:48 +0200843 if (++(lurb_priv->td_cnt) == lurb_priv->length) {
844 if ((ed->state & (ED_OPER | ED_UNLINK))
Stefan Roese40ee63b2005-08-02 10:05:21 +0200845 && (lurb_priv->state != URB_DEL)) {
Stefan Roese326c9712005-08-01 16:41:48 +0200846 dbg("ConditionCode %#x", cc);
847 stat = cc_to_error[cc];
Stefan Roese40ee63b2005-08-02 10:05:21 +0200848 urb_finished = 1;
Stefan Roese326c9712005-08-01 16:41:48 +0200849 }
850 }
851
852 if (ed->state != ED_NEW) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200853 edHeadP = ohci_cpu_to_le32 (ed->hwHeadP) & 0xfffffff0;
854 edTailP = ohci_cpu_to_le32 (ed->hwTailP);
Stefan Roese326c9712005-08-01 16:41:48 +0200855
856 /* unlink eds if they are not busy */
857 if ((edHeadP == edTailP) && (ed->state == ED_OPER))
Stefan Roese40ee63b2005-08-02 10:05:21 +0200858 ep_unlink (ohci, ed);
Stefan Roese326c9712005-08-01 16:41:48 +0200859 }
860
861 td_list = td_list_next;
862 }
863 return stat;
864}
865
866/*-------------------------------------------------------------------------*
867 * Virtual Root Hub
868 *-------------------------------------------------------------------------*/
869
870/* Device descriptor */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200871static __u8 root_hub_dev_des[] =
872{
873 0x12, /* __u8 bLength; */
874 0x01, /* __u8 bDescriptorType; Device */
875 0x10, /* __u16 bcdUSB; v1.1 */
Stefan Roese326c9712005-08-01 16:41:48 +0200876 0x01,
Stefan Roese40ee63b2005-08-02 10:05:21 +0200877 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
878 0x00, /* __u8 bDeviceSubClass; */
879 0x00, /* __u8 bDeviceProtocol; */
880 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */
881 0x00, /* __u16 idVendor; */
Stefan Roese326c9712005-08-01 16:41:48 +0200882 0x00,
Stefan Roese40ee63b2005-08-02 10:05:21 +0200883 0x00, /* __u16 idProduct; */
Stefan Roese326c9712005-08-01 16:41:48 +0200884 0x00,
Stefan Roese40ee63b2005-08-02 10:05:21 +0200885 0x00, /* __u16 bcdDevice; */
Stefan Roese326c9712005-08-01 16:41:48 +0200886 0x00,
Stefan Roese40ee63b2005-08-02 10:05:21 +0200887 0x00, /* __u8 iManufacturer; */
888 0x01, /* __u8 iProduct; */
889 0x00, /* __u8 iSerialNumber; */
890 0x01 /* __u8 bNumConfigurations; */
Stefan Roese326c9712005-08-01 16:41:48 +0200891};
892
Stefan Roese40ee63b2005-08-02 10:05:21 +0200893
Stefan Roese326c9712005-08-01 16:41:48 +0200894/* Configuration descriptor */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200895static __u8 root_hub_config_des[] =
896{
897 0x09, /* __u8 bLength; */
898 0x02, /* __u8 bDescriptorType; Configuration */
899 0x19, /* __u16 wTotalLength; */
Stefan Roese326c9712005-08-01 16:41:48 +0200900 0x00,
Stefan Roese40ee63b2005-08-02 10:05:21 +0200901 0x01, /* __u8 bNumInterfaces; */
902 0x01, /* __u8 bConfigurationValue; */
903 0x00, /* __u8 iConfiguration; */
904 0x40, /* __u8 bmAttributes;
905 Bit 7: Bus-powered, 6: Self-powered, 5 Remote-wakwup, 4..0: resvd */
906 0x00, /* __u8 MaxPower; */
Stefan Roese326c9712005-08-01 16:41:48 +0200907
908 /* interface */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200909 0x09, /* __u8 if_bLength; */
910 0x04, /* __u8 if_bDescriptorType; Interface */
911 0x00, /* __u8 if_bInterfaceNumber; */
912 0x00, /* __u8 if_bAlternateSetting; */
913 0x01, /* __u8 if_bNumEndpoints; */
914 0x09, /* __u8 if_bInterfaceClass; HUB_CLASSCODE */
915 0x00, /* __u8 if_bInterfaceSubClass; */
916 0x00, /* __u8 if_bInterfaceProtocol; */
917 0x00, /* __u8 if_iInterface; */
Stefan Roese326c9712005-08-01 16:41:48 +0200918
919 /* endpoint */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200920 0x07, /* __u8 ep_bLength; */
921 0x05, /* __u8 ep_bDescriptorType; Endpoint */
922 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */
923 0x03, /* __u8 ep_bmAttributes; Interrupt */
924 0x02, /* __u16 ep_wMaxPacketSize; ((MAX_ROOT_PORTS + 1) / 8 */
Stefan Roese326c9712005-08-01 16:41:48 +0200925 0x00,
Stefan Roese40ee63b2005-08-02 10:05:21 +0200926 0xff /* __u8 ep_bInterval; 255 ms */
Stefan Roese326c9712005-08-01 16:41:48 +0200927};
928
Stefan Roese40ee63b2005-08-02 10:05:21 +0200929static unsigned char root_hub_str_index0[] =
930{
Stefan Roese326c9712005-08-01 16:41:48 +0200931 0x04, /* __u8 bLength; */
932 0x03, /* __u8 bDescriptorType; String-descriptor */
933 0x09, /* __u8 lang ID */
934 0x04, /* __u8 lang ID */
935};
936
Stefan Roese40ee63b2005-08-02 10:05:21 +0200937static unsigned char root_hub_str_index1[] =
938{
Stefan Roese326c9712005-08-01 16:41:48 +0200939 28, /* __u8 bLength; */
940 0x03, /* __u8 bDescriptorType; String-descriptor */
941 'O', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200942 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200943 'H', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200944 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200945 'C', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200946 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200947 'I', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200948 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200949 ' ', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200950 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200951 'R', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200952 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200953 'o', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200954 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200955 'o', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200956 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200957 't', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200958 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200959 ' ', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200960 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200961 'H', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200962 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200963 'u', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200964 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200965 'b', /* __u8 Unicode */
Stefan Roese40ee63b2005-08-02 10:05:21 +0200966 0, /* __u8 Unicode */
Stefan Roese326c9712005-08-01 16:41:48 +0200967};
968
969/* Hub class-specific descriptor is constructed dynamically */
970
Stefan Roese40ee63b2005-08-02 10:05:21 +0200971
Stefan Roese326c9712005-08-01 16:41:48 +0200972/*-------------------------------------------------------------------------*/
973
974#define OK(x) len = (x); break
975#ifdef DEBUG
976#define WR_RH_STAT(x) {info("WR:status %#8x", (x));writel((x), &gohci.regs->roothub.status);}
977#define WR_RH_PORTSTAT(x) {info("WR:portstatus[%d] %#8x", wIndex-1, (x));writel((x), &gohci.regs->roothub.portstatus[wIndex-1]);}
978#else
979#define WR_RH_STAT(x) writel((x), &gohci.regs->roothub.status)
980#define WR_RH_PORTSTAT(x) writel((x), &gohci.regs->roothub.portstatus[wIndex-1])
981#endif
982#define RD_RH_STAT roothub_status(&gohci)
983#define RD_RH_PORTSTAT roothub_portstatus(&gohci,wIndex-1)
984
985/* request to virtual root hub */
986
Stefan Roese40ee63b2005-08-02 10:05:21 +0200987int rh_check_port_status(ohci_t *controller)
Stefan Roese326c9712005-08-01 16:41:48 +0200988{
989 __u32 temp, ndp, i;
990 int res;
991
992 res = -1;
Stefan Roese40ee63b2005-08-02 10:05:21 +0200993 temp = roothub_a (controller);
Stefan Roese326c9712005-08-01 16:41:48 +0200994 ndp = (temp & RH_A_NDP);
995 for (i = 0; i < ndp; i++) {
Stefan Roese40ee63b2005-08-02 10:05:21 +0200996 temp = roothub_portstatus (controller, i);
Stefan Roese326c9712005-08-01 16:41:48 +0200997 /* check for a device disconnect */
998 if (((temp & (RH_PS_PESC | RH_PS_CSC)) ==
Stefan Roese40ee63b2005-08-02 10:05:21 +0200999 (RH_PS_PESC | RH_PS_CSC)) &&
1000 ((temp & RH_PS_CCS) == 0)) {
Stefan Roese326c9712005-08-01 16:41:48 +02001001 res = i;
1002 break;
1003 }
1004 }
1005 return res;
1006}
1007
1008static int ohci_submit_rh_msg(struct usb_device *dev, unsigned long pipe,
Stefan Roese40ee63b2005-08-02 10:05:21 +02001009 void *buffer, int transfer_len, struct devrequest *cmd)
Stefan Roese326c9712005-08-01 16:41:48 +02001010{
Stefan Roese40ee63b2005-08-02 10:05:21 +02001011 void * data = buffer;
Stefan Roese326c9712005-08-01 16:41:48 +02001012 int leni = transfer_len;
1013 int len = 0;
1014 int stat = 0;
1015 __u32 datab[4];
Stefan Roese40ee63b2005-08-02 10:05:21 +02001016 __u8 *data_buf = (__u8 *)datab;
Stefan Roese326c9712005-08-01 16:41:48 +02001017 __u16 bmRType_bReq;
1018 __u16 wValue;
1019 __u16 wIndex;
1020 __u16 wLength;
1021
1022#ifdef DEBUG
Stefan Roese40ee63b2005-08-02 10:05:21 +02001023urb_priv.actual_length = 0;
1024pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
Stefan Roese326c9712005-08-01 16:41:48 +02001025#endif
Remy Bohmerd8c55ab2008-10-10 10:23:22 +02001026 if (usb_pipeint(pipe)) {
Stefan Roese326c9712005-08-01 16:41:48 +02001027 info("Root-Hub submit IRQ: NOT implemented");
1028 return 0;
1029 }
1030
Stefan Roese40ee63b2005-08-02 10:05:21 +02001031 bmRType_bReq = cmd->requesttype | (cmd->request << 8);
1032 wValue = m16_swap (cmd->value);
1033 wIndex = m16_swap (cmd->index);
1034 wLength = m16_swap (cmd->length);
Stefan Roese326c9712005-08-01 16:41:48 +02001035
1036 info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x",
Stefan Roese40ee63b2005-08-02 10:05:21 +02001037 dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength);
Stefan Roese326c9712005-08-01 16:41:48 +02001038
1039 switch (bmRType_bReq) {
Stefan Roese40ee63b2005-08-02 10:05:21 +02001040 /* Request Destination:
1041 without flags: Device,
1042 RH_INTERFACE: interface,
1043 RH_ENDPOINT: endpoint,
1044 RH_CLASS means HUB here,
1045 RH_OTHER | RH_CLASS almost ever means HUB_PORT here
1046 */
Stefan Roese326c9712005-08-01 16:41:48 +02001047
1048 case RH_GET_STATUS:
Stefan Roese40ee63b2005-08-02 10:05:21 +02001049 *(__u16 *) data_buf = m16_swap (1); OK (2);
Stefan Roese326c9712005-08-01 16:41:48 +02001050 case RH_GET_STATUS | RH_INTERFACE:
Stefan Roese40ee63b2005-08-02 10:05:21 +02001051 *(__u16 *) data_buf = m16_swap (0); OK (2);
Stefan Roese326c9712005-08-01 16:41:48 +02001052 case RH_GET_STATUS | RH_ENDPOINT:
Stefan Roese40ee63b2005-08-02 10:05:21 +02001053 *(__u16 *) data_buf = m16_swap (0); OK (2);
Stefan Roese326c9712005-08-01 16:41:48 +02001054 case RH_GET_STATUS | RH_CLASS:
Stefan Roese40ee63b2005-08-02 10:05:21 +02001055 *(__u32 *) data_buf = m32_swap (
1056 RD_RH_STAT & ~(RH_HS_CRWE | RH_HS_DRWE));
1057 OK (4);
Stefan Roese326c9712005-08-01 16:41:48 +02001058 case RH_GET_STATUS | RH_OTHER | RH_CLASS:
Stefan Roese40ee63b2005-08-02 10:05:21 +02001059 *(__u32 *) data_buf = m32_swap (RD_RH_PORTSTAT); OK (4);
Stefan Roese326c9712005-08-01 16:41:48 +02001060
1061 case RH_CLEAR_FEATURE | RH_ENDPOINT:
1062 switch (wValue) {
Stefan Roese40ee63b2005-08-02 10:05:21 +02001063 case (RH_ENDPOINT_STALL): OK (0);
Stefan Roese326c9712005-08-01 16:41:48 +02001064 }
1065 break;
1066
1067 case RH_CLEAR_FEATURE | RH_CLASS:
1068 switch (wValue) {
Stefan Roese40ee63b2005-08-02 10:05:21 +02001069 case RH_C_HUB_LOCAL_POWER:
1070 OK(0);
1071 case (RH_C_HUB_OVER_CURRENT):
1072 WR_RH_STAT(RH_HS_OCIC); OK (0);
Stefan Roese326c9712005-08-01 16:41:48 +02001073 }
1074 break;
1075
1076 case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS:
1077 switch (wValue) {
Stefan Roese40ee63b2005-08-02 10:05:21 +02001078 case (RH_PORT_ENABLE):
1079 WR_RH_PORTSTAT (RH_PS_CCS ); OK (0);
1080 case (RH_PORT_SUSPEND):
1081 WR_RH_PORTSTAT (RH_PS_POCI); OK (0);
1082 case (RH_PORT_POWER):
1083 WR_RH_PORTSTAT (RH_PS_LSDA); OK (0);
1084 case (RH_C_PORT_CONNECTION):
1085 WR_RH_PORTSTAT (RH_PS_CSC ); OK (0);
1086 case (RH_C_PORT_ENABLE):
1087 WR_RH_PORTSTAT (RH_PS_PESC); OK (0);
1088 case (RH_C_PORT_SUSPEND):
1089 WR_RH_PORTSTAT (RH_PS_PSSC); OK (0);
1090 case (RH_C_PORT_OVER_CURRENT):
1091 WR_RH_PORTSTAT (RH_PS_OCIC); OK (0);
1092 case (RH_C_PORT_RESET):
1093 WR_RH_PORTSTAT (RH_PS_PRSC); OK (0);
Stefan Roese326c9712005-08-01 16:41:48 +02001094 }
1095 break;
1096
1097 case RH_SET_FEATURE | RH_OTHER | RH_CLASS:
1098 switch (wValue) {
Stefan Roese40ee63b2005-08-02 10:05:21 +02001099 case (RH_PORT_SUSPEND):
1100 WR_RH_PORTSTAT (RH_PS_PSS ); OK (0);
1101 case (RH_PORT_RESET): /* BUG IN HUP CODE *********/
1102 if (RD_RH_PORTSTAT & RH_PS_CCS)
1103 WR_RH_PORTSTAT (RH_PS_PRS);
1104 OK (0);
1105 case (RH_PORT_POWER):
1106 WR_RH_PORTSTAT (RH_PS_PPS ); OK (0);
1107 case (RH_PORT_ENABLE): /* BUG IN HUP CODE *********/
1108 if (RD_RH_PORTSTAT & RH_PS_CCS)
1109 WR_RH_PORTSTAT (RH_PS_PES );
1110 OK (0);
Stefan Roese326c9712005-08-01 16:41:48 +02001111 }
1112 break;
1113
Stefan Roese40ee63b2005-08-02 10:05:21 +02001114 case RH_SET_ADDRESS: gohci.rh.devnum = wValue; OK(0);
Stefan Roese326c9712005-08-01 16:41:48 +02001115
1116 case RH_GET_DESCRIPTOR:
1117 switch ((wValue & 0xff00) >> 8) {
Stefan Roese40ee63b2005-08-02 10:05:21 +02001118 case (0x01): /* device descriptor */
Stefan Roese326c9712005-08-01 16:41:48 +02001119 len = min_t(unsigned int,
Stefan Roese40ee63b2005-08-02 10:05:21 +02001120 leni,
1121 min_t(unsigned int,
1122 sizeof (root_hub_dev_des),
1123 wLength));
1124 data_buf = root_hub_dev_des; OK(len);
1125 case (0x02): /* configuration descriptor */
Stefan Roese326c9712005-08-01 16:41:48 +02001126 len = min_t(unsigned int,
Stefan Roese40ee63b2005-08-02 10:05:21 +02001127 leni,
1128 min_t(unsigned int,
1129 sizeof (root_hub_config_des),
1130 wLength));
1131 data_buf = root_hub_config_des; OK(len);
1132 case (0x03): /* string descriptors */
1133 if(wValue==0x0300) {
1134 len = min_t(unsigned int,
1135 leni,
1136 min_t(unsigned int,
1137 sizeof (root_hub_str_index0),
1138 wLength));
1139 data_buf = root_hub_str_index0;
1140 OK(len);
1141 }
1142 if(wValue==0x0301) {
1143 len = min_t(unsigned int,
1144 leni,
1145 min_t(unsigned int,
1146 sizeof (root_hub_str_index1),
1147 wLength));
1148 data_buf = root_hub_str_index1;
1149 OK(len);
Stefan Roese326c9712005-08-01 16:41:48 +02001150 }
Stefan Roese40ee63b2005-08-02 10:05:21 +02001151 default:
1152 stat = USB_ST_STALLED;
Stefan Roese326c9712005-08-01 16:41:48 +02001153 }
1154 break;
1155
1156 case RH_GET_DESCRIPTOR | RH_CLASS:
Stefan Roese40ee63b2005-08-02 10:05:21 +02001157 {
1158 __u32 temp = roothub_a (&gohci);
Stefan Roese326c9712005-08-01 16:41:48 +02001159
Stefan Roese40ee63b2005-08-02 10:05:21 +02001160 data_buf [0] = 9; /* min length; */
1161 data_buf [1] = 0x29;
1162 data_buf [2] = temp & RH_A_NDP;
1163 data_buf [3] = 0;
1164 if (temp & RH_A_PSM) /* per-port power switching? */
1165 data_buf [3] |= 0x1;
1166 if (temp & RH_A_NOCP) /* no overcurrent reporting? */
1167 data_buf [3] |= 0x10;
1168 else if (temp & RH_A_OCPM) /* per-port overcurrent reporting? */
1169 data_buf [3] |= 0x8;
Stefan Roese326c9712005-08-01 16:41:48 +02001170
Stefan Roese40ee63b2005-08-02 10:05:21 +02001171 /* corresponds to data_buf[4-7] */
1172 datab [1] = 0;
1173 data_buf [5] = (temp & RH_A_POTPGT) >> 24;
1174 temp = roothub_b (&gohci);
1175 data_buf [7] = temp & RH_B_DR;
1176 if (data_buf [2] < 7) {
1177 data_buf [8] = 0xff;
1178 } else {
1179 data_buf [0] += 2;
1180 data_buf [8] = (temp & RH_B_DR) >> 8;
1181 data_buf [10] = data_buf [9] = 0xff;
1182 }
Stefan Roese326c9712005-08-01 16:41:48 +02001183
Stefan Roese40ee63b2005-08-02 10:05:21 +02001184 len = min_t(unsigned int, leni,
1185 min_t(unsigned int, data_buf [0], wLength));
1186 OK (len);
Stefan Roese326c9712005-08-01 16:41:48 +02001187 }
1188
Stefan Roese40ee63b2005-08-02 10:05:21 +02001189 case RH_GET_CONFIGURATION: *(__u8 *) data_buf = 0x01; OK (1);
Stefan Roese326c9712005-08-01 16:41:48 +02001190
Stefan Roese40ee63b2005-08-02 10:05:21 +02001191 case RH_SET_CONFIGURATION: WR_RH_STAT (0x10000); OK (0);
Stefan Roese326c9712005-08-01 16:41:48 +02001192
1193 default:
Stefan Roese40ee63b2005-08-02 10:05:21 +02001194 dbg ("unsupported root hub command");
Stefan Roese326c9712005-08-01 16:41:48 +02001195 stat = USB_ST_STALLED;
1196 }
1197
1198#ifdef DEBUG
Stefan Roese40ee63b2005-08-02 10:05:21 +02001199 ohci_dump_roothub (&gohci, 1);
Stefan Roese326c9712005-08-01 16:41:48 +02001200#endif
1201
1202 len = min_t(int, len, leni);
1203 if (data != data_buf)
Stefan Roese40ee63b2005-08-02 10:05:21 +02001204 memcpy (data, data_buf, len);
Stefan Roese326c9712005-08-01 16:41:48 +02001205 dev->act_len = len;
1206 dev->status = stat;
1207
1208#ifdef DEBUG
1209 if (transfer_len)
1210 urb_priv.actual_length = transfer_len;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001211 pkt_print(dev, pipe, buffer, transfer_len, cmd, "RET(rh)", 0/*usb_pipein(pipe)*/);
Stefan Roese326c9712005-08-01 16:41:48 +02001212#endif
1213
1214 return stat;
1215}
1216
1217/*-------------------------------------------------------------------------*/
1218
1219/* common code for handling submit messages - used for all but root hub */
1220/* accesses. */
1221int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
Stefan Roese40ee63b2005-08-02 10:05:21 +02001222 int transfer_len, struct devrequest *setup, int interval)
Stefan Roese326c9712005-08-01 16:41:48 +02001223{
1224 int stat = 0;
1225 int maxsize = usb_maxpacket(dev, pipe);
1226 int timeout;
1227
1228 /* device pulled? Shortcut the action. */
1229 if (devgone == dev) {
1230 dev->status = USB_ST_CRC_ERR;
1231 return 0;
1232 }
Stefan Roese40ee63b2005-08-02 10:05:21 +02001233
Stefan Roese326c9712005-08-01 16:41:48 +02001234#ifdef DEBUG
1235 urb_priv.actual_length = 0;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001236 pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
Stefan Roese326c9712005-08-01 16:41:48 +02001237#endif
1238 if (!maxsize) {
1239 err("submit_common_message: pipesize for pipe %lx is zero",
Stefan Roese40ee63b2005-08-02 10:05:21 +02001240 pipe);
Stefan Roese326c9712005-08-01 16:41:48 +02001241 return -1;
1242 }
1243
Stefan Roese40ee63b2005-08-02 10:05:21 +02001244 if (sohci_submit_job(dev, pipe, buffer, transfer_len, setup, interval) < 0) {
Stefan Roese326c9712005-08-01 16:41:48 +02001245 err("sohci_submit_job failed");
1246 return -1;
1247 }
1248
1249 /* allow more time for a BULK device to react - some are slow */
Stefan Roese40ee63b2005-08-02 10:05:21 +02001250#define BULK_TO 5000 /* timeout in milliseconds */
Remy Bohmerd8c55ab2008-10-10 10:23:22 +02001251 if (usb_pipebulk(pipe))
Stefan Roese326c9712005-08-01 16:41:48 +02001252 timeout = BULK_TO;
1253 else
1254 timeout = 100;
1255
1256 /* wait for it to complete */
1257 for (;;) {
1258 /* check whether the controller is done */
1259 stat = hc_interrupt();
1260 if (stat < 0) {
1261 stat = USB_ST_CRC_ERR;
1262 break;
1263 }
Stefan Roese40ee63b2005-08-02 10:05:21 +02001264
1265 /* NOTE: since we are not interrupt driven in U-Boot and always
1266 * handle only one URB at a time, we cannot assume the
1267 * transaction finished on the first successful return from
1268 * hc_interrupt().. unless the flag for current URB is set,
1269 * meaning that all TD's to/from device got actually
1270 * transferred and processed. If the current URB is not
1271 * finished we need to re-iterate this loop so as
1272 * hc_interrupt() gets called again as there needs to be some
1273 * more TD's to process still */
1274 if ((stat >= 0) && (stat != 0xff) && (urb_finished)) {
Stefan Roese326c9712005-08-01 16:41:48 +02001275 /* 0xff is returned for an SF-interrupt */
1276 break;
1277 }
Stefan Roese40ee63b2005-08-02 10:05:21 +02001278
Stefan Roese326c9712005-08-01 16:41:48 +02001279 if (--timeout) {
1280 wait_ms(1);
Stefan Roese40ee63b2005-08-02 10:05:21 +02001281 if (!urb_finished)
1282 dbg("\%");
1283
Stefan Roese326c9712005-08-01 16:41:48 +02001284 } else {
1285 err("CTL:TIMEOUT ");
Stefan Roese40ee63b2005-08-02 10:05:21 +02001286 dbg("submit_common_msg: TO status %x\n", stat);
Stefan Roese326c9712005-08-01 16:41:48 +02001287 stat = USB_ST_CRC_ERR;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001288 urb_finished = 1;
Stefan Roese326c9712005-08-01 16:41:48 +02001289 break;
1290 }
1291 }
Stefan Roese40ee63b2005-08-02 10:05:21 +02001292#if 0
Stefan Roese326c9712005-08-01 16:41:48 +02001293 /* we got an Root Hub Status Change interrupt */
1294 if (got_rhsc) {
1295#ifdef DEBUG
Stefan Roese40ee63b2005-08-02 10:05:21 +02001296 ohci_dump_roothub (&gohci, 1);
Stefan Roese326c9712005-08-01 16:41:48 +02001297#endif
1298 got_rhsc = 0;
1299 /* abuse timeout */
1300 timeout = rh_check_port_status(&gohci);
1301 if (timeout >= 0) {
Stefan Roese40ee63b2005-08-02 10:05:21 +02001302#if 0 /* this does nothing useful, but leave it here in case that changes */
Stefan Roese326c9712005-08-01 16:41:48 +02001303 /* the called routine adds 1 to the passed value */
1304 usb_hub_port_connect_change(gohci.rh.dev, timeout - 1);
1305#endif
1306 /*
1307 * XXX
1308 * This is potentially dangerous because it assumes
1309 * that only one device is ever plugged in!
1310 */
1311 devgone = dev;
1312 }
1313 }
Stefan Roese40ee63b2005-08-02 10:05:21 +02001314#endif
Stefan Roese326c9712005-08-01 16:41:48 +02001315
1316 dev->status = stat;
1317 dev->act_len = transfer_len;
1318
1319#ifdef DEBUG
Stefan Roese40ee63b2005-08-02 10:05:21 +02001320 pkt_print(dev, pipe, buffer, transfer_len, setup, "RET(ctlr)", usb_pipein(pipe));
Stefan Roese326c9712005-08-01 16:41:48 +02001321#endif
1322
1323 /* free TDs in urb_priv */
Stefan Roese40ee63b2005-08-02 10:05:21 +02001324 urb_free_priv (&urb_priv);
Stefan Roese326c9712005-08-01 16:41:48 +02001325 return 0;
1326}
1327
1328/* submit routines called from usb.c */
1329int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
Stefan Roese40ee63b2005-08-02 10:05:21 +02001330 int transfer_len)
Stefan Roese326c9712005-08-01 16:41:48 +02001331{
1332 info("submit_bulk_msg");
1333 return submit_common_msg(dev, pipe, buffer, transfer_len, NULL, 0);
1334}
1335
1336int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
Stefan Roese40ee63b2005-08-02 10:05:21 +02001337 int transfer_len, struct devrequest *setup)
Stefan Roese326c9712005-08-01 16:41:48 +02001338{
1339 int maxsize = usb_maxpacket(dev, pipe);
1340
1341 info("submit_control_msg");
1342#ifdef DEBUG
1343 urb_priv.actual_length = 0;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001344 pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
Stefan Roese326c9712005-08-01 16:41:48 +02001345#endif
1346 if (!maxsize) {
1347 err("submit_control_message: pipesize for pipe %lx is zero",
Stefan Roese40ee63b2005-08-02 10:05:21 +02001348 pipe);
Stefan Roese326c9712005-08-01 16:41:48 +02001349 return -1;
1350 }
1351 if (((pipe >> 8) & 0x7f) == gohci.rh.devnum) {
1352 gohci.rh.dev = dev;
1353 /* root hub - redirect */
1354 return ohci_submit_rh_msg(dev, pipe, buffer, transfer_len,
Stefan Roese40ee63b2005-08-02 10:05:21 +02001355 setup);
Stefan Roese326c9712005-08-01 16:41:48 +02001356 }
1357
1358 return submit_common_msg(dev, pipe, buffer, transfer_len, setup, 0);
1359}
1360
1361int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
Stefan Roese40ee63b2005-08-02 10:05:21 +02001362 int transfer_len, int interval)
Stefan Roese326c9712005-08-01 16:41:48 +02001363{
1364 info("submit_int_msg");
1365 return -1;
1366}
1367
1368/*-------------------------------------------------------------------------*
1369 * HC functions
1370 *-------------------------------------------------------------------------*/
1371
1372/* reset the HC and BUS */
1373
Stefan Roese40ee63b2005-08-02 10:05:21 +02001374static int hc_reset (ohci_t *ohci)
Stefan Roese326c9712005-08-01 16:41:48 +02001375{
1376 int timeout = 30;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001377 int smm_timeout = 50; /* 0,5 sec */
Stefan Roese326c9712005-08-01 16:41:48 +02001378
Stefan Roese40ee63b2005-08-02 10:05:21 +02001379 if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { /* SMM owns the HC */
1380 writel (OHCI_OCR, &ohci->regs->cmdstatus); /* request ownership */
Stefan Roese326c9712005-08-01 16:41:48 +02001381 info("USB HC TakeOver from SMM");
Stefan Roese40ee63b2005-08-02 10:05:21 +02001382 while (readl (&ohci->regs->control) & OHCI_CTRL_IR) {
1383 wait_ms (10);
Stefan Roese326c9712005-08-01 16:41:48 +02001384 if (--smm_timeout == 0) {
1385 err("USB HC TakeOver failed!");
1386 return -1;
1387 }
1388 }
1389 }
1390
1391 /* Disable HC interrupts */
Stefan Roese40ee63b2005-08-02 10:05:21 +02001392 writel (OHCI_INTR_MIE, &ohci->regs->intrdisable);
Stefan Roese326c9712005-08-01 16:41:48 +02001393
1394 dbg("USB HC reset_hc usb-%s: ctrl = 0x%X ;",
Stefan Roese40ee63b2005-08-02 10:05:21 +02001395 ohci->slot_name,
1396 readl (&ohci->regs->control));
Stefan Roese326c9712005-08-01 16:41:48 +02001397
1398 /* Reset USB (needed by some controllers) */
1399 ohci->hc_control = 0;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001400 writel (ohci->hc_control, &ohci->regs->control);
Stefan Roese326c9712005-08-01 16:41:48 +02001401
1402 /* HC Reset requires max 10 us delay */
Stefan Roese40ee63b2005-08-02 10:05:21 +02001403 writel (OHCI_HCR, &ohci->regs->cmdstatus);
1404 while ((readl (&ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
Stefan Roese326c9712005-08-01 16:41:48 +02001405 if (--timeout == 0) {
1406 err("USB HC reset timed out!");
1407 return -1;
1408 }
Stefan Roese40ee63b2005-08-02 10:05:21 +02001409 udelay (1);
Stefan Roese326c9712005-08-01 16:41:48 +02001410 }
1411 return 0;
1412}
1413
1414/*-------------------------------------------------------------------------*/
1415
1416/* Start an OHCI controller, set the BUS operational
1417 * enable interrupts
1418 * connect the virtual root hub */
1419
Stefan Roese40ee63b2005-08-02 10:05:21 +02001420static int hc_start (ohci_t * ohci)
Stefan Roese326c9712005-08-01 16:41:48 +02001421{
1422 __u32 mask;
1423 unsigned int fminterval;
1424
1425 ohci->disabled = 1;
1426
1427 /* Tell the controller where the control and bulk lists are
1428 * The lists are empty now. */
1429
Stefan Roese40ee63b2005-08-02 10:05:21 +02001430 writel (0, &ohci->regs->ed_controlhead);
1431 writel (0, &ohci->regs->ed_bulkhead);
Stefan Roese326c9712005-08-01 16:41:48 +02001432
Stefan Roese40ee63b2005-08-02 10:05:21 +02001433 writel ((__u32)ohci->hcca, &ohci->regs->hcca); /* a reset clears this */
Stefan Roese326c9712005-08-01 16:41:48 +02001434
1435 fminterval = 0x2edf;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001436 writel ((fminterval * 9) / 10, &ohci->regs->periodicstart);
Stefan Roese326c9712005-08-01 16:41:48 +02001437 fminterval |= ((((fminterval - 210) * 6) / 7) << 16);
Stefan Roese40ee63b2005-08-02 10:05:21 +02001438 writel (fminterval, &ohci->regs->fminterval);
1439 writel (0x628, &ohci->regs->lsthresh);
Stefan Roese326c9712005-08-01 16:41:48 +02001440
1441 /* start controller operations */
1442 ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER;
1443 ohci->disabled = 0;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001444 writel (ohci->hc_control, &ohci->regs->control);
Stefan Roese326c9712005-08-01 16:41:48 +02001445
1446 /* disable all interrupts */
1447 mask = (OHCI_INTR_SO | OHCI_INTR_WDH | OHCI_INTR_SF | OHCI_INTR_RD |
Stefan Roese40ee63b2005-08-02 10:05:21 +02001448 OHCI_INTR_UE | OHCI_INTR_FNO | OHCI_INTR_RHSC |
1449 OHCI_INTR_OC | OHCI_INTR_MIE);
1450 writel (mask, &ohci->regs->intrdisable);
Stefan Roese326c9712005-08-01 16:41:48 +02001451 /* clear all interrupts */
1452 mask &= ~OHCI_INTR_MIE;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001453 writel (mask, &ohci->regs->intrstatus);
Stefan Roese326c9712005-08-01 16:41:48 +02001454 /* Choose the interrupts we care about now - but w/o MIE */
1455 mask = OHCI_INTR_RHSC | OHCI_INTR_UE | OHCI_INTR_WDH | OHCI_INTR_SO;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001456 writel (mask, &ohci->regs->intrenable);
Stefan Roese326c9712005-08-01 16:41:48 +02001457
1458#ifdef OHCI_USE_NPS
1459 /* required for AMD-756 and some Mac platforms */
Stefan Roese40ee63b2005-08-02 10:05:21 +02001460 writel ((roothub_a (ohci) | RH_A_NPS) & ~RH_A_PSM,
1461 &ohci->regs->roothub.a);
1462 writel (RH_HS_LPSC, &ohci->regs->roothub.status);
1463#endif /* OHCI_USE_NPS */
Stefan Roese326c9712005-08-01 16:41:48 +02001464
Stefan Roese326c9712005-08-01 16:41:48 +02001465 /* POTPGT delay is bits 24-31, in 2 ms units. */
Stefan Roese40ee63b2005-08-02 10:05:21 +02001466 mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
Stefan Roese326c9712005-08-01 16:41:48 +02001467
1468 /* connect the virtual root hub */
1469 ohci->rh.devnum = 0;
1470
1471 return 0;
1472}
1473
1474/*-------------------------------------------------------------------------*/
1475
1476/* an interrupt happens */
1477
Stefan Roese40ee63b2005-08-02 10:05:21 +02001478static int
1479hc_interrupt (void)
Stefan Roese326c9712005-08-01 16:41:48 +02001480{
1481 ohci_t *ohci = &gohci;
1482 struct ohci_regs *regs = ohci->regs;
1483 int ints;
1484 int stat = -1;
1485
Stefan Roese40ee63b2005-08-02 10:05:21 +02001486 if ((ohci->hcca->done_head != 0) &&
1487 !(ohci_cpu_to_le32(ohci->hcca->done_head) & 0x01)) {
1488
1489 ints = OHCI_INTR_WDH;
1490
1491 } else if ((ints = readl (&regs->intrstatus)) == ~(u32)0) {
1492 ohci->disabled++;
1493 err ("%s device removed!", ohci->slot_name);
1494 return -1;
1495
1496 } else if ((ints &= readl (&regs->intrenable)) == 0) {
1497 dbg("hc_interrupt: returning..\n");
1498 return 0xff;
Stefan Roese326c9712005-08-01 16:41:48 +02001499 }
1500
1501 /* dbg("Interrupt: %x frame: %x", ints, le16_to_cpu (ohci->hcca->frame_no)); */
1502
1503 if (ints & OHCI_INTR_RHSC) {
1504 got_rhsc = 1;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001505 stat = 0xff;
Stefan Roese326c9712005-08-01 16:41:48 +02001506 }
1507
1508 if (ints & OHCI_INTR_UE) {
1509 ohci->disabled++;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001510 err ("OHCI Unrecoverable Error, controller usb-%s disabled",
1511 ohci->slot_name);
Stefan Roese326c9712005-08-01 16:41:48 +02001512 /* e.g. due to PCI Master/Target Abort */
1513
1514#ifdef DEBUG
Stefan Roese40ee63b2005-08-02 10:05:21 +02001515 ohci_dump (ohci, 1);
Stefan Roese326c9712005-08-01 16:41:48 +02001516#endif
1517 /* FIXME: be optimistic, hope that bug won't repeat often. */
1518 /* Make some non-interrupt context restart the controller. */
1519 /* Count and limit the retries though; either hardware or */
1520 /* software errors can go forever... */
Stefan Roese40ee63b2005-08-02 10:05:21 +02001521 hc_reset (ohci);
Stefan Roese326c9712005-08-01 16:41:48 +02001522 return -1;
1523 }
1524
1525 if (ints & OHCI_INTR_WDH) {
Stefan Roese40ee63b2005-08-02 10:05:21 +02001526 writel (OHCI_INTR_WDH, &regs->intrdisable);
1527 stat = dl_done_list (&gohci, dl_reverse_done_list (&gohci));
1528 writel (OHCI_INTR_WDH, &regs->intrenable);
Stefan Roese326c9712005-08-01 16:41:48 +02001529 }
1530
1531 if (ints & OHCI_INTR_SO) {
1532 dbg("USB Schedule overrun\n");
Stefan Roese40ee63b2005-08-02 10:05:21 +02001533 writel (OHCI_INTR_SO, &regs->intrenable);
Stefan Roese326c9712005-08-01 16:41:48 +02001534 stat = -1;
1535 }
1536
1537 /* FIXME: this assumes SOF (1/ms) interrupts don't get lost... */
1538 if (ints & OHCI_INTR_SF) {
Stefan Roese40ee63b2005-08-02 10:05:21 +02001539 unsigned int frame = ohci_cpu_to_le16 (ohci->hcca->frame_no) & 1;
1540 wait_ms(1);
1541 writel (OHCI_INTR_SF, &regs->intrdisable);
Stefan Roese326c9712005-08-01 16:41:48 +02001542 if (ohci->ed_rm_list[frame] != NULL)
Stefan Roese40ee63b2005-08-02 10:05:21 +02001543 writel (OHCI_INTR_SF, &regs->intrenable);
Stefan Roese326c9712005-08-01 16:41:48 +02001544 stat = 0xff;
1545 }
1546
Stefan Roese40ee63b2005-08-02 10:05:21 +02001547 writel (ints, &regs->intrstatus);
Stefan Roese326c9712005-08-01 16:41:48 +02001548 return stat;
1549}
1550
1551/*-------------------------------------------------------------------------*/
1552
1553/*-------------------------------------------------------------------------*/
1554
1555/* De-allocate all resources.. */
1556
Stefan Roese40ee63b2005-08-02 10:05:21 +02001557static void hc_release_ohci (ohci_t *ohci)
Stefan Roese326c9712005-08-01 16:41:48 +02001558{
Stefan Roese40ee63b2005-08-02 10:05:21 +02001559 dbg ("USB HC release ohci usb-%s", ohci->slot_name);
Stefan Roese326c9712005-08-01 16:41:48 +02001560
1561 if (!ohci->disabled)
Stefan Roese40ee63b2005-08-02 10:05:21 +02001562 hc_reset (ohci);
Stefan Roese326c9712005-08-01 16:41:48 +02001563}
1564
1565/*-------------------------------------------------------------------------*/
1566
1567/*
1568 * low level initalisation routine, called from usb.c
1569 */
1570static char ohci_inited = 0;
1571
1572int usb_lowlevel_init(void)
1573{
Stefan Roese40ee63b2005-08-02 10:05:21 +02001574 memset (&gohci, 0, sizeof (ohci_t));
1575 memset (&urb_priv, 0, sizeof (urb_priv_t));
Stefan Roese326c9712005-08-01 16:41:48 +02001576
1577 /* align the storage */
Stefan Roese40ee63b2005-08-02 10:05:21 +02001578 if ((__u32)&ghcca[0] & 0xff) {
Stefan Roese326c9712005-08-01 16:41:48 +02001579 err("HCCA not aligned!!");
1580 return -1;
1581 }
1582 phcca = &ghcca[0];
1583 info("aligned ghcca %p", phcca);
1584 memset(&ohci_dev, 0, sizeof(struct ohci_device));
Stefan Roese40ee63b2005-08-02 10:05:21 +02001585 if ((__u32)&ohci_dev.ed[0] & 0x7) {
Stefan Roese326c9712005-08-01 16:41:48 +02001586 err("EDs not aligned!!");
1587 return -1;
1588 }
1589 memset(gtd, 0, sizeof(td_t) * (NUM_TD + 1));
Stefan Roese40ee63b2005-08-02 10:05:21 +02001590 if ((__u32)gtd & 0x7) {
Stefan Roese326c9712005-08-01 16:41:48 +02001591 err("TDs not aligned!!");
1592 return -1;
1593 }
1594 ptd = gtd;
1595 gohci.hcca = phcca;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001596 memset (phcca, 0, sizeof (struct ohci_hcca));
Stefan Roese326c9712005-08-01 16:41:48 +02001597
1598 gohci.disabled = 1;
1599 gohci.sleeping = 0;
1600 gohci.irq = -1;
Stefan Roese42fbddd2006-09-07 11:51:23 +02001601#if defined(CONFIG_440EP)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +02001602 gohci.regs = (struct ohci_regs *)(CONFIG_SYS_PERIPHERAL_BASE | 0x1000);
1603#elif defined(CONFIG_440EPX) || defined(CONFIG_SYS_USB_HOST)
1604 gohci.regs = (struct ohci_regs *)(CONFIG_SYS_USB_HOST);
Stefan Roese42fbddd2006-09-07 11:51:23 +02001605#endif
Stefan Roese326c9712005-08-01 16:41:48 +02001606
1607 gohci.flags = 0;
1608 gohci.slot_name = "ppc440";
1609
Stefan Roese40ee63b2005-08-02 10:05:21 +02001610 if (hc_reset (&gohci) < 0) {
1611 hc_release_ohci (&gohci);
Stefan Roese326c9712005-08-01 16:41:48 +02001612 return -1;
1613 }
1614
Stefan Roese40ee63b2005-08-02 10:05:21 +02001615 if (hc_start (&gohci) < 0) {
1616 err ("can't start usb-%s", gohci.slot_name);
1617 hc_release_ohci (&gohci);
Stefan Roese326c9712005-08-01 16:41:48 +02001618 return -1;
1619 }
Stefan Roese40ee63b2005-08-02 10:05:21 +02001620
Stefan Roese326c9712005-08-01 16:41:48 +02001621#ifdef DEBUG
Stefan Roese40ee63b2005-08-02 10:05:21 +02001622 ohci_dump (&gohci, 1);
Stefan Roese326c9712005-08-01 16:41:48 +02001623#endif
1624 ohci_inited = 1;
Stefan Roese40ee63b2005-08-02 10:05:21 +02001625 urb_finished = 1;
Stefan Roese326c9712005-08-01 16:41:48 +02001626
Stefan Roese17ffbc82007-03-21 13:38:59 +01001627#if defined(CONFIG_440EP) || defined(CONFIG_440EPX)
Stefan Roese326c9712005-08-01 16:41:48 +02001628 /* init the device driver */
1629 usb_dev_init();
Stefan Roese17ffbc82007-03-21 13:38:59 +01001630#endif
Stefan Roese326c9712005-08-01 16:41:48 +02001631
1632 return 0;
1633}
1634
1635int usb_lowlevel_stop(void)
1636{
1637 /* this gets called really early - before the controller has */
1638 /* even been initialized! */
1639 if (!ohci_inited)
1640 return 0;
1641 /* TODO release any interrupts, etc. */
1642 /* call hc_release_ohci() here ? */
Stefan Roese40ee63b2005-08-02 10:05:21 +02001643 hc_reset (&gohci);
Stefan Roese326c9712005-08-01 16:41:48 +02001644 return 0;
1645}
1646
Stefan Roese40ee63b2005-08-02 10:05:21 +02001647#endif /* CONFIG_USB_OHCI */