add ltq-hcd
[openwrt/openwrt.git] / package / platform / lantiq / ltq-hcd / src / ifxusb_driver.c
1 /*****************************************************************************
2 ** FILE NAME : ifxusb_driver.c
3 ** PROJECT : IFX USB sub-system V3
4 ** MODULES : IFX USB sub-system Host and Device driver
5 ** SRC VERSION : 3.2
6 ** DATE : 1/Jan/2011
7 ** AUTHOR : Chen, Howard
8 ** DESCRIPTION : The provides the initialization and cleanup entry
9 ** points for the IFX USB driver. This module can be
10 ** dynamically loaded with insmod command or built-in
11 ** with kernel. When loaded or executed the ifxusb_driver_init
12 ** function is called. When the module is removed (using rmmod),
13 ** the ifxusb_driver_cleanup function is called.
14 ** FUNCTIONS :
15 ** COMPILER : gcc
16 ** REFERENCE : Synopsys DWC-OTG Driver 2.7
17 ** COPYRIGHT : Copyright (c) 2010
18 ** LANTIQ DEUTSCHLAND GMBH,
19 ** Am Campeon 3, 85579 Neubiberg, Germany
20 **
21 ** This program is free software; you can redistribute it and/or modify
22 ** it under the terms of the GNU General Public License as published by
23 ** the Free Software Foundation; either version 2 of the License, or
24 ** (at your option) any later version.
25 **
26 ** Version Control Section **
27 ** $Author$
28 ** $Date$
29 ** $Revisions$
30 ** $Log$ Revision history
31 *****************************************************************************/
32
33 /*
34 * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
35 * For this code the following notice is applicable:
36 *
37 * ==========================================================================
38 *
39 * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
40 * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
41 * otherwise expressly agreed to in writing between Synopsys and you.
42 *
43 * The Software IS NOT an item of Licensed Software or Licensed Product under
44 * any End User Software License Agreement or Agreement for Licensed Product
45 * with Synopsys or any supplement thereto. You are permitted to use and
46 * redistribute this Software in source and binary forms, with or without
47 * modification, provided that redistributions of source code must retain this
48 * notice. You may not view, use, disclose, copy or distribute this file or
49 * any information contained herein except pursuant to this license grant from
50 * Synopsys. If you do not agree with this notice, including the disclaimer
51 * below, then you are not authorized to use the Software.
52 *
53 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
54 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
57 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
58 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
59 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
60 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
63 * DAMAGE.
64 * ========================================================================== */
65
66 /*!
67 \file ifxusb_driver.c
68 \brief This file contains the loading/unloading interface to the Linux driver.
69 */
70
71 #include <linux/version.h>
72 #include "ifxusb_version.h"
73
74 #include <linux/kernel.h>
75 #include <linux/module.h>
76 #include <linux/moduleparam.h>
77 #include <linux/init.h>
78
79 #include <linux/device.h>
80 #include <linux/of_platform.h>
81 #include <linux/of_gpio.h>
82
83 #include <linux/errno.h>
84 #include <linux/types.h>
85 #include <linux/stat.h> /* permission constants */
86
87 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
88 #include <linux/irq.h>
89 #endif
90
91 #include <asm/io.h>
92
93 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
94 #include <asm/irq.h>
95 #endif
96
97 #include "ifxusb_plat.h"
98
99 #include "ifxusb_cif.h"
100
101 #ifdef __IS_HOST__
102 #include "ifxhcd.h"
103
104 #define USB_DRIVER_DESC "IFX USB HCD driver"
105 const char ifxusb_hcd_driver_name[] = "ifxusb_hcd";
106 #ifdef __IS_DUAL__
107 ifxhcd_hcd_t ifxusb_hcd_1;
108 ifxhcd_hcd_t ifxusb_hcd_2;
109 const char ifxusb_hcd_name_1[] = "ifxusb_hcd_1";
110 const char ifxusb_hcd_name_2[] = "ifxusb_hcd_2";
111 #else
112 ifxhcd_hcd_t ifxusb_hcd;
113 const char ifxusb_hcd_name[] = "ifxusb_hcd";
114 #endif
115
116 #if defined(__DO_OC_INT__)
117 ifxhcd_hcd_t *oc_int_id=NULL;
118 #ifdef __IS_DUAL__
119 ifxhcd_hcd_t *oc_int_id_1=NULL;
120 ifxhcd_hcd_t *oc_int_id_2=NULL;
121 #endif
122 #endif
123 #endif
124
125 #ifdef __IS_DEVICE__
126 #include "ifxpcd.h"
127
128 #define USB_DRIVER_DESC "IFX USB PCD driver"
129 const char ifxusb_pcd_driver_name[] = "ifxusb_pcd";
130 ifxpcd_pcd_t ifxusb_pcd;
131 const char ifxusb_pcd_name[] = "ifxusb_pcd";
132 #endif
133
134 /* Global Debug Level Mask. */
135 #ifdef __IS_HOST__
136 uint32_t h_dbg_lvl = 0xff;
137 #endif
138
139 #ifdef __IS_DEVICE__
140 uint32_t d_dbg_lvl = 0x00;
141 #endif
142
143 #ifdef __IS_HOST__
144 ifxusb_params_t ifxusb_module_params_h;
145 #else
146 ifxusb_params_t ifxusb_module_params_d;
147 #endif
148
149 static void parse_parms(void);
150
151
152 #if defined(__IS_TWINPASS__)
153 #warning "Compiled as TWINPASS"
154 #elif defined(__IS_DANUBE__)
155 #warning "Compiled as DANUBE"
156 #elif defined(__IS_AMAZON_SE__)
157 #warning "Compiled as AMAZON_SE"
158 #elif defined(__IS_AR9__)
159 #warning "Compiled as AR9"
160 #elif defined(__IS_VR9__)
161 #warning "Compiled as VR9"
162 #elif defined(__IS_AR10__)
163 #warning "Compiled as AR10"
164 #else
165 #error "No Platform defined"
166 #endif
167
168
169 /* Function to setup the structures to control one usb core running as host*/
170 #ifdef __IS_HOST__
171 /*!
172 \brief inlined by ifxusb_driver_probe(), handling host mode probing. Run at each host core.
173 */
174 static inline int ifxusb_driver_probe_h(ifxhcd_hcd_t *_hcd,
175 int _irq,
176 uint32_t _iobase,
177 uint32_t _fifomem,
178 uint32_t _fifodbg
179 )
180 {
181 int retval = 0;
182
183 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
184
185 ifxusb_power_on_h (&_hcd->core_if);
186 mdelay(50);
187 ifxusb_phy_power_on_h (&_hcd->core_if); // Test
188 mdelay(50);
189 ifxusb_hard_reset_h(&_hcd->core_if);
190 retval =ifxusb_core_if_init_h(&_hcd->core_if,
191 _irq,
192 _iobase,
193 _fifomem,
194 _fifodbg);
195 if(retval)
196 return retval;
197
198 ifxusb_host_core_init(&_hcd->core_if,&ifxusb_module_params_h);
199
200 ifxusb_disable_global_interrupts_h( &_hcd->core_if);
201
202 /* The driver is now initialized and need to be registered into Linux USB sub-system */
203
204 retval = ifxhcd_init(_hcd); // hook the hcd into usb ss
205
206 if (retval != 0)
207 {
208 IFX_ERROR("_hcd_init failed\n");
209 return retval;
210 }
211
212 //ifxusb_enable_global_interrupts_h( _hcd->core_if ); // this should be done at hcd_start , including hcd_interrupt
213 return 0;
214 }
215 #endif //__IS_HOST__
216
217 #ifdef __IS_DEVICE__
218 /*!
219 \brief inlined by ifxusb_driver_probe(), handling device mode probing.
220 */
221 static inline int ifxusb_driver_probe_d(ifxpcd_pcd_t *_pcd,
222 int _irq,
223 uint32_t _iobase,
224 uint32_t _fifomem,
225 uint32_t _fifodbg
226 )
227 {
228 int retval = 0;
229
230 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
231 ifxusb_power_on_d (&_pcd->core_if);
232 mdelay(50);
233 ifxusb_phy_power_on_d (&_pcd->core_if); // Test
234 mdelay(50);
235 ifxusb_hard_reset_d(&_pcd->core_if);
236 retval =ifxusb_core_if_init_d(&_pcd->core_if,
237 _irq,
238 _iobase,
239 _fifomem,
240 _fifodbg);
241 if(retval)
242 return retval;
243
244 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
245 ifxusb_dev_core_init(&_pcd->core_if,&ifxusb_module_params_d);
246
247 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
248 ifxusb_disable_global_interrupts_d( &_pcd->core_if);
249
250 /* The driver is now initialized and need to be registered into
251 Linux USB Gadget sub-system
252 */
253 retval = ifxpcd_init();
254 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
255
256 if (retval != 0)
257 {
258 IFX_ERROR("_pcd_init failed\n");
259 return retval;
260 }
261 //ifxusb_enable_global_interrupts_d( _pcd->core_if ); // this should be done at gadget bind or start
262 return 0;
263 }
264 #endif //__IS_DEVICE__
265
266 /*!
267 \brief This function is called when a driver is unregistered. This happens when
268 the rmmod command is executed. The device may or may not be electrically
269 present. If it is present, the driver stops device processing. Any resources
270 used on behalf of this device are freed.
271 */
272 static int ifxusb_driver_remove(struct platform_device *_pdev)
273 {
274 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
275 #ifdef __IS_HOST__
276 #if defined(__IS_DUAL__)
277 ifxhcd_remove(&ifxusb_hcd_1);
278 ifxusb_core_if_remove_h(&ifxusb_hcd_1.core_if );
279 ifxhcd_remove(&ifxusb_hcd_2);
280 ifxusb_core_if_remove_h(&ifxusb_hcd_2.core_if );
281 #else
282 ifxhcd_remove(&ifxusb_hcd);
283 ifxusb_core_if_remove_h(&ifxusb_hcd.core_if );
284 #endif
285 #endif
286 #ifdef __IS_DEVICE__
287 ifxpcd_remove();
288 ifxusb_core_if_remove_d(&ifxusb_pcd.core_if );
289 #endif
290 /* Remove the device attributes */
291 #ifdef __IS_HOST__
292 ifxusb_attr_remove_h(&_pdev->dev);
293 #else
294 ifxusb_attr_remove_d(&_pdev->dev);
295 #endif
296 return 0;
297 }
298
299 /*!
300 \brief This function is called by module management in 2.6 kernel or by ifxusb_driver_init with 2.4 kernel
301 It is to probe and setup IFXUSB core(s).
302 */
303 static int ifxusb_driver_probe(struct platform_device *_pdev)
304 {
305 int retval = 0;
306 struct device_node *np;
307 int gpio_count;
308 #ifdef __IS_DANUBE__
309 np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-danube");
310 #elif defined __IS_AMAZON_SE__
311 np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-ase");
312 #elif defined __IS_AR9__
313 np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-arx100");
314 #elif defined __IS_VR9__
315 np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-xrx200");
316 #endif
317 if (!np) {
318 dev_err(&_pdev->dev, "failed to find hcd device node\n");
319 return -ENODEV;
320 }
321
322 // Parsing and store the parameters
323 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
324 parse_parms();
325
326 #ifdef __IS_HOST__
327 #if defined(__DO_OC_INT__)
328 if(!oc_int_id)
329 {
330 #if defined(__IS_DUAL__)
331 oc_int_id=&ifxusb_hcd_1;
332 oc_int_id_1=&ifxusb_hcd_1;
333 oc_int_id_2=&ifxusb_hcd_2;
334 #else
335 oc_int_id=&ifxusb_hcd;
336 #endif
337 }
338 #endif
339
340 #if defined(__IS_DUAL__)
341 memset(&ifxusb_hcd_1, 0, sizeof(ifxhcd_hcd_t));
342 memset(&ifxusb_hcd_2, 0, sizeof(ifxhcd_hcd_t));
343
344 ifxusb_hcd_1.core_if.core_no=0;
345 ifxusb_hcd_2.core_if.core_no=1;
346 ifxusb_hcd_1.core_if.core_name=(char *)ifxusb_hcd_name_1;
347 ifxusb_hcd_2.core_if.core_name=(char *)ifxusb_hcd_name_2;
348
349 ifxusb_hcd_1.dev=&_pdev->dev;
350 ifxusb_hcd_2.dev=&_pdev->dev;
351
352 retval = ifxusb_driver_probe_h(&ifxusb_hcd_1,
353 IFXUSB1_IRQ,
354 IFXUSB1_IOMEM_BASE,
355 IFXUSB1_FIFOMEM_BASE,
356 IFXUSB1_FIFODBG_BASE
357 );
358 if(retval)
359 goto ifxusb_driver_probe_fail;
360
361 retval = ifxusb_driver_probe_h(&ifxusb_hcd_2,
362 IFXUSB2_IRQ,
363 IFXUSB2_IOMEM_BASE,
364 IFXUSB2_FIFOMEM_BASE,
365 IFXUSB2_FIFODBG_BASE
366 );
367 if(retval)
368 goto ifxusb_driver_probe_fail;
369
370 #elif defined(__IS_FIRST__)
371 memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
372
373 ifxusb_hcd.core_if.core_no=0;
374 ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
375
376 ifxusb_hcd.dev=&_pdev->dev;
377
378 retval = ifxusb_driver_probe_h(&ifxusb_hcd,
379 IFXUSB1_IRQ,
380 IFXUSB1_IOMEM_BASE,
381 IFXUSB1_FIFOMEM_BASE,
382 IFXUSB1_FIFODBG_BASE
383 );
384 if(retval)
385 goto ifxusb_driver_probe_fail;
386
387 #elif defined(__IS_SECOND__)
388 memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
389
390 ifxusb_hcd.core_if.core_no=1;
391 ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
392
393 ifxusb_hcd.dev=&_pdev->dev;
394
395 retval = ifxusb_driver_probe_h(&ifxusb_hcd,
396 IFXUSB2_IRQ,
397 IFXUSB2_IOMEM_BASE,
398 IFXUSB2_FIFOMEM_BASE,
399 IFXUSB2_FIFODBG_BASE
400 );
401 if(retval)
402 goto ifxusb_driver_probe_fail;
403
404 #else
405 memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t));
406
407 ifxusb_hcd.core_if.core_no=0;
408 ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name;
409
410 ifxusb_hcd.dev=&_pdev->dev;
411
412 retval = ifxusb_driver_probe_h(&ifxusb_hcd,
413 IFXUSB_IRQ,
414 IFXUSB_IOMEM_BASE,
415 IFXUSB_FIFOMEM_BASE,
416 IFXUSB_FIFODBG_BASE
417 );
418 if(retval)
419 goto ifxusb_driver_probe_fail;
420 #endif
421 #endif
422
423 #ifdef __IS_DEVICE__
424 memset(&ifxusb_pcd, 0, sizeof(ifxpcd_pcd_t));
425 ifxusb_pcd.core_if.core_name=(char *)&ifxusb_pcd_name[0];
426
427 ifxusb_pcd.dev=&_pdev->dev;
428
429 #if defined(__IS_FIRST__)
430 ifxusb_pcd.core_if.core_no=0;
431 retval = ifxusb_driver_probe_d(&ifxusb_pcd,
432 IFXUSB1_IRQ,
433 IFXUSB1_IOMEM_BASE,
434 IFXUSB1_FIFOMEM_BASE,
435 IFXUSB1_FIFODBG_BASE
436 );
437 #elif defined(__IS_SECOND__)
438 ifxusb_pcd.core_if.core_no=1;
439 retval = ifxusb_driver_probe_d(&ifxusb_pcd,
440 IFXUSB2_IRQ,
441 IFXUSB2_IOMEM_BASE,
442 IFXUSB2_FIFOMEM_BASE,
443 IFXUSB2_FIFODBG_BASE
444 );
445 #else
446 ifxusb_pcd.core_if.core_no=0;
447 retval = ifxusb_driver_probe_d(&ifxusb_pcd,
448 IFXUSB_IRQ,
449 IFXUSB_IOMEM_BASE,
450 IFXUSB_FIFOMEM_BASE,
451 IFXUSB_FIFODBG_BASE
452 );
453 #endif
454 if(retval)
455 goto ifxusb_driver_probe_fail;
456 #endif
457
458 #ifdef __IS_HOST__
459 ifxusb_attr_create_h(&_pdev->dev);
460 #else
461 ifxusb_attr_create_d(&_pdev->dev);
462 #endif
463
464 gpio_count = of_gpio_count(np);
465 while (gpio_count) {
466 enum of_gpio_flags flags;
467 int gpio = of_get_gpio_flags(np, --gpio_count, &flags);
468 if (gpio_request(gpio, "usb"))
469 continue;
470 dev_info(&_pdev->dev, "requested GPIO %d\n", gpio);
471 gpio_direction_output(gpio, (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
472 }
473
474
475 return 0;
476
477 ifxusb_driver_probe_fail:
478 ifxusb_driver_remove(_pdev);
479 return retval;
480 }
481
482 static struct resource ifxusb_device_resources[] =
483 {
484 #if defined(__IS_DUAL__)
485 [0] = { .start = IFXUSB1_IRQ,
486 .flags = IORESOURCE_IRQ,
487 },
488 [1] = { .start = IFXUSB1_IOMEM_BASE,
489 .end = IFXUSB1_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
490 .flags = IORESOURCE_MEM,
491 },
492 [2] = { .start = IFXUSB2_IRQ,
493 .flags = IORESOURCE_IRQ,
494 },
495 [3] = { .start = IFXUSB2_IOMEM_BASE,
496 .end = IFXUSB2_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
497 .flags = IORESOURCE_MEM,
498 },
499 [4] = { .start = IFXUSB1_FIFOMEM_BASE,
500 .end = IFXUSB1_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
501 .flags = IORESOURCE_MEM,
502 },
503 [5] = { .start = IFXUSB2_FIFOMEM_BASE,
504 .end = IFXUSB2_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
505 .flags = IORESOURCE_MEM,
506 },
507 [6] = { .start = IFXUSB1_FIFODBG_BASE,
508 .end = IFXUSB1_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
509 .flags = IORESOURCE_MEM,
510 },
511 [7] = { .start = IFXUSB2_FIFODBG_BASE,
512 .end = IFXUSB2_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
513 .flags = IORESOURCE_MEM,
514 },
515 #elif defined(__IS_FIRST__)
516 [0] = { .start = IFXUSB1_IRQ,
517 .flags = IORESOURCE_IRQ,
518 },
519 [1] = { .start = IFXUSB1_IOMEM_BASE,
520 .end = IFXUSB1_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
521 .flags = IORESOURCE_MEM,
522 },
523 [2] = { .start = IFXUSB1_FIFOMEM_BASE,
524 .end = IFXUSB1_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
525 .flags = IORESOURCE_MEM,
526 },
527 [3] = { .start = IFXUSB1_FIFODBG_BASE,
528 .end = IFXUSB1_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
529 .flags = IORESOURCE_MEM,
530 },
531 #elif defined(__IS_SECOND__)
532 [0] = { .start = IFXUSB2_IRQ,
533 .flags = IORESOURCE_IRQ,
534 },
535 [1] = { .start = IFXUSB2_IOMEM_BASE,
536 .end = IFXUSB2_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
537 .flags = IORESOURCE_MEM,
538 },
539 [2] = { .start = IFXUSB2_FIFOMEM_BASE,
540 .end = IFXUSB2_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1,
541 .flags = IORESOURCE_MEM,
542 },
543 [3] = { .start = IFXUSB2_FIFODBG_BASE,
544 .end = IFXUSB2_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1,
545 .flags = IORESOURCE_MEM,
546 },
547 #else
548 [0] = { .start = IFXUSB_IRQ,
549 .flags = IORESOURCE_IRQ,
550 },
551 [1] = { .start = IFXUSB_IOMEM_BASE,
552 .end = IFXUSB_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1,
553 .flags = IORESOURCE_MEM,
554 },
555 [2] = { .start = IFXUSB_FIFOMEM_BASE,
556 .end = IFXUSB_FIFOMEM_BASE+IFXUSB_FIFOMEM_SIZE-1,
557 .flags = IORESOURCE_MEM,
558 },
559 [3] = { .start = IFXUSB_FIFODBG_BASE,
560 .end = IFXUSB_FIFODBG_BASE+IFXUSB_FIFODBG_SIZE-1,
561 .flags = IORESOURCE_MEM,
562 },
563 #endif //__IS_DUAL__
564 };
565
566 static u64 ifxusb_dmamask = (u32)0x1fffffff;
567
568 static void ifxusb_device_release(struct device * dev)
569 {
570 IFX_PRINT("IFX USB platform_dev release\n");
571 dev->parent = NULL;
572 }
573
574 static struct platform_device ifxusb_device =
575 {
576 .id = -1,
577 .dev =
578 {
579 .release = ifxusb_device_release,
580 .dma_mask = &ifxusb_dmamask,
581 },
582 .resource = ifxusb_device_resources,
583 .num_resources = ARRAY_SIZE(ifxusb_device_resources),
584 };
585
586
587 /*!
588 \brief This function is called when the ifxusb_driver is installed with the insmod command.
589 */
590 static struct platform_driver ifxusb_driver = {
591 .probe = ifxusb_driver_probe,
592 .remove = ifxusb_driver_remove,
593 .driver ={
594 .owner = THIS_MODULE,
595 #ifdef __IS_HOST__
596 .name = ifxusb_hcd_driver_name,
597 #else
598 .name = ifxusb_pcd_driver_name,
599 #endif
600 },
601 };
602
603 #ifdef __IS_HOST__
604 int __init ifxusb_hcd_driver_init(void)
605 #else
606 int __init ifxusb_pcd_driver_init(void)
607 #endif
608 {
609 int retval = 0;
610 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
611 #if defined(__IS_HOST__)
612 IFX_PRINT("%s: version %s\n", ifxusb_hcd_driver_name, IFXUSB_VERSION);
613 #else
614 IFX_PRINT("%s: version %s\n", ifxusb_pcd_driver_name, IFXUSB_VERSION);
615 #endif
616
617 #if 0
618 #if defined(__IS_TWINPASS__)
619 IFX_PRINT(" OPTION: __IS_TWINPASS__\n");
620 #elif defined(__IS_DANUBE__)
621 IFX_PRINT(" OPTION: __IS_DANUBE__\n");
622 #elif defined(__IS_AMAZON_SE__)
623 IFX_PRINT(" OPTION: __IS_AMAZON_SE__\n");
624 #elif defined(__IS_AR9__)
625 IFX_PRINT(" OPTION: __IS_AR9__\n");
626 #elif defined(__IS_VR9__)
627 IFX_PRINT(" OPTION: __IS_VR9__\n");
628 #elif defined(__IS_AR10__)
629 IFX_PRINT(" OPTION: __IS_AR10__\n");
630 #else
631 IFX_PRINT(" OPTION: NO PLATFORM DEFINED\n");
632 #endif
633
634 #ifdef __UEIP__
635 IFX_PRINT(" OPTION: __UEIP__\n");
636 #endif
637
638 #ifdef __PHY_LONG_PREEMP__
639 IFX_PRINT(" OPTION: __PHY_LONG_PREEMP__\n");
640 #endif
641 #ifdef __FORCE_USB11__
642 IFX_PRINT(" OPTION: __FORCE_USB11__\n");
643 #endif
644 #ifdef __UNALIGNED_BUF_ADJ__
645 IFX_PRINT(" OPTION: __UNALIGNED_BUF_ADJ__\n");
646 #endif
647 #ifdef __UNALIGNED_BUF_CHK__
648 IFX_PRINT(" OPTION: __UNALIGNED_BUF_CHK__\n");
649 #endif
650 #ifdef __UNALIGNED_BUF_BURST__
651 IFX_PRINT(" OPTION: __UNALIGNED_BUF_BURST__\n");
652 #endif
653 #ifdef __DEBUG__
654 IFX_PRINT(" OPTION: __DEBUG__\n");
655 #endif
656 #ifdef __ENABLE_DUMP__
657 IFX_PRINT(" OPTION: __ENABLE_DUMP__\n");
658 #endif
659
660 #ifdef __IS_HOST__
661 IFX_PRINT(" OPTION: __IS_HOST__\n");
662 #ifdef __IS_DUAL__
663 IFX_PRINT(" __IS_DUAL__\n");
664 #endif
665 #ifdef __IS_FIRST__
666 IFX_PRINT(" __IS_FIRST__\n");
667 #endif
668 #ifdef __IS_SECOND__
669 IFX_PRINT(" __IS_SECOND__\n");
670 #endif
671 #ifdef __WITH_HS_ELECT_TST__
672 IFX_PRINT(" __WITH_HS_ELECT_TST__\n");
673 #endif
674 #ifdef __EN_ISOC__
675 IFX_PRINT(" __EN_ISOC__\n");
676 #endif
677 #ifdef __EN_ISOC_SPLIT__
678 IFX_PRINT(" __EN_ISOC_SPLIT__\n");
679 #endif
680 #ifdef __EPQD_DESTROY_TIMEOUT__
681 IFX_PRINT(" __EPQD_DESTROY_TIMEOUT__\n");
682 #endif
683 #ifdef __DYN_SOF_INTR__
684 IFX_PRINT(" __DYN_SOF_INTR__\n");
685 #endif
686 #else
687 IFX_PRINT(" OPTION: __IS_DEVICE__\n");
688 #ifdef __DED_INTR__
689 IFX_PRINT(" __DED_INTR__\n");
690 #endif
691 #ifdef __DED_FIFO__
692 IFX_PRINT(" __DED_FIFO__\n");
693 #endif
694 #ifdef __DESC_DMA__
695 IFX_PRINT(" __DESC_DMA__\n");
696 #endif
697 #ifdef __IS_FIRST__
698 IFX_PRINT(" __IS_FIRST__\n");
699 #endif
700 #ifdef __IS_SECOND__
701 IFX_PRINT(" __IS_SECOND__\n");
702 #endif
703 #ifdef __GADGET_TASKLET_TX__
704 IFX_PRINT(" __GADGET_TASKLET_TX__\n");
705 #endif
706 #ifdef __GADGET_TASKLET_RX__
707 IFX_PRINT(" __GADGET_TASKLET_RX__\n");
708 #endif
709 #ifdef __GADGET_TASKLET_HIGH__
710 IFX_PRINT(" __GADGET_TASKLET_HIGH__\n");
711 #endif
712 #ifdef __DO_PCD_UNLOCK__
713 IFX_PRINT(" __DO_PCD_UNLOCK__\n");
714 #endif
715 #ifdef __GADGET_LED__
716 IFX_PRINT(" __GADGET_LED__\n");
717 #endif
718
719 #ifdef __ECM_NO_INTR__
720 IFX_PRINT(" __ECM_NO_INTR__\n");
721 #endif
722 #ifdef __NOSWAPINCTRL__
723 IFX_PRINT(" __NOSWAPINCTRL__\n");
724 #endif
725 #ifdef __MAC_ECM_FIX__
726 IFX_PRINT(" __MAC_ECM_FIX__\n");
727 #endif
728 #ifdef __RETAIN_BUF_TX__
729 IFX_PRINT(" __RETAIN_BUF_TX__\n");
730 #endif
731 #ifdef __RETAIN_BUF_RX__
732 IFX_PRINT(" __RETAIN_BUF_RX__\n");
733 #endif
734 #ifdef __QUICKNAK__
735 IFX_PRINT(" __QUICKNAK__\n");
736 #endif
737 #endif
738 #endif
739
740 retval = platform_driver_register(&ifxusb_driver);
741
742 if (retval < 0) {
743 IFX_ERROR("%s retval=%d\n", __func__, retval);
744 return retval;
745 }
746
747 #ifdef __IS_HOST__
748 ifxusb_device.name = ifxusb_hcd_driver_name;
749 #else
750 ifxusb_device.name = ifxusb_pcd_driver_name;
751 #endif
752
753 if (ifxusb_device.dev.parent)
754 retval = -EBUSY;
755 else
756 retval = platform_device_register(&ifxusb_device);
757
758 if (retval < 0)
759 {
760 IFX_ERROR("%s retval=%d\n", __func__, retval);
761 platform_driver_unregister(&ifxusb_driver);
762 return retval;
763 }
764 return retval;
765 }
766
767 #ifdef __IS_HOST__
768 module_init(ifxusb_hcd_driver_init);
769 #else
770 module_init(ifxusb_pcd_driver_init);
771 #endif
772
773 /*!
774 \brief This function is called when the driver is removed from the kernel
775 with the rmmod command. The driver unregisters itself with its bus
776 driver.
777 */
778 #ifdef __IS_HOST__
779 void __exit ifxusb_hcd_driver_cleanup(void)
780 {
781 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
782 platform_device_unregister(&ifxusb_device);
783 platform_driver_unregister(&ifxusb_driver);
784 IFX_PRINT("%s module removed\n", ifxusb_hcd_driver_name);
785 }
786 module_exit(ifxusb_hcd_driver_cleanup);
787 #else
788 void __exit ifxusb_pcd_driver_cleanup(void)
789 {
790 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
791 platform_device_unregister(&ifxusb_device);
792 platform_driver_unregister(&ifxusb_driver);
793 IFX_PRINT("%s module removed\n", ifxusb_pcd_driver_name);
794 }
795 module_exit(ifxusb_pcd_driver_cleanup);
796 #endif
797 MODULE_DESCRIPTION(USB_DRIVER_DESC);
798 MODULE_AUTHOR("Lantiq");
799 MODULE_LICENSE("GPL");
800
801
802
803 // Parameters set when loaded
804 //static long dbg_lvl =0xFFFFFFFF;
805 static long dbg_lvl =0;
806 static short dma_burst_size =-1;
807 static short speed =-1;
808 static long data_fifo_size =-1;
809 #ifdef __IS_DEVICE__
810 static long rx_fifo_size =-1;
811 #ifdef __DED_FIFO__
812 static long tx_fifo_size_00 =-1;
813 static long tx_fifo_size_01 =-1;
814 static long tx_fifo_size_02 =-1;
815 static long tx_fifo_size_03 =-1;
816 static long tx_fifo_size_04 =-1;
817 static long tx_fifo_size_05 =-1;
818 static long tx_fifo_size_06 =-1;
819 static long tx_fifo_size_07 =-1;
820 static long tx_fifo_size_08 =-1;
821 static long tx_fifo_size_09 =-1;
822 static long tx_fifo_size_10 =-1;
823 static long tx_fifo_size_11 =-1;
824 static long tx_fifo_size_12 =-1;
825 static long tx_fifo_size_13 =-1;
826 static long tx_fifo_size_14 =-1;
827 static long tx_fifo_size_15 =-1;
828 static short thr_ctl=-1;
829 static long tx_thr_length =-1;
830 static long rx_thr_length =-1;
831 #else
832 static long nperio_tx_fifo_size =-1;
833 static long perio_tx_fifo_size_01 =-1;
834 static long perio_tx_fifo_size_02 =-1;
835 static long perio_tx_fifo_size_03 =-1;
836 static long perio_tx_fifo_size_04 =-1;
837 static long perio_tx_fifo_size_05 =-1;
838 static long perio_tx_fifo_size_06 =-1;
839 static long perio_tx_fifo_size_07 =-1;
840 static long perio_tx_fifo_size_08 =-1;
841 static long perio_tx_fifo_size_09 =-1;
842 static long perio_tx_fifo_size_10 =-1;
843 static long perio_tx_fifo_size_11 =-1;
844 static long perio_tx_fifo_size_12 =-1;
845 static long perio_tx_fifo_size_13 =-1;
846 static long perio_tx_fifo_size_14 =-1;
847 static long perio_tx_fifo_size_15 =-1;
848 #endif
849 static short dev_endpoints =-1;
850 #endif
851
852 #ifdef __IS_HOST__
853 static long rx_fifo_size =-1;
854 static long nperio_tx_fifo_size =-1;
855 static long perio_tx_fifo_size =-1;
856 static short host_channels =-1;
857 #endif
858
859 static long max_transfer_size =-1;
860 static long max_packet_count =-1;
861 static long phy_utmi_width =-1;
862 static long turn_around_time_hs =-1;
863 static long turn_around_time_fs =-1;
864 static long timeout_cal_hs =-1;
865 static long timeout_cal_fs =-1;
866
867 /*!
868 \brief Parsing the parameters taken when module load
869 */
870 static void parse_parms(void)
871 {
872
873 ifxusb_params_t *params;
874 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
875 #ifdef __IS_HOST__
876 h_dbg_lvl=dbg_lvl;
877 params=&ifxusb_module_params_h;
878 #endif
879 #ifdef __IS_DEVICE__
880 d_dbg_lvl=dbg_lvl;
881 params=&ifxusb_module_params_d;
882 #endif
883
884 switch(dma_burst_size)
885 {
886 case 0:
887 case 1:
888 case 4:
889 case 8:
890 case 16:
891 params->dma_burst_size=dma_burst_size;
892 break;
893 default:
894 #if defined(__IS_VR9__)
895 {
896 unsigned int chipid;
897 unsigned int partnum;
898 chipid=*((volatile uint32_t *)IFX_MPS_CHIPID);
899 partnum=(chipid&0x0FFFF000)>>12;
900 switch(partnum)
901 {
902 case 0x000B: //VRX288_A2x
903 case 0x000E: //VRX282_A2x
904 case 0x000C: //VRX268_A2x
905 case 0x000D: //GRX288_A2x
906 params->dma_burst_size=default_param_dma_burst_size_n;
907 break;
908 default:
909 params->dma_burst_size=default_param_dma_burst_size;
910 }
911 printk(KERN_INFO "Chip Version :%04x BurstSize=%d\n",partnum,params->dma_burst_size);
912 }
913 #else
914 params->dma_burst_size=default_param_dma_burst_size;
915 #endif
916 }
917
918 if(speed==0 || speed==1)
919 params->speed=speed;
920 else
921 params->speed=default_param_speed;
922
923 if(max_transfer_size>=2048 && max_transfer_size<=65535)
924 params->max_transfer_size=max_transfer_size;
925 else
926 params->max_transfer_size=default_param_max_transfer_size;
927
928 if(max_packet_count>=15 && max_packet_count<=511)
929 params->max_packet_count=max_packet_count;
930 else
931 params->max_packet_count=default_param_max_packet_count;
932
933 switch(phy_utmi_width)
934 {
935 case 8:
936 case 16:
937 params->phy_utmi_width=phy_utmi_width;
938 break;
939 default:
940 params->phy_utmi_width=default_param_phy_utmi_width;
941 }
942
943 if(turn_around_time_hs>=0 && turn_around_time_hs<=7)
944 params->turn_around_time_hs=turn_around_time_hs;
945 else
946 params->turn_around_time_hs=default_param_turn_around_time_hs;
947
948 if(turn_around_time_fs>=0 && turn_around_time_fs<=7)
949 params->turn_around_time_fs=turn_around_time_fs;
950 else
951 params->turn_around_time_fs=default_param_turn_around_time_fs;
952
953 if(timeout_cal_hs>=0 && timeout_cal_hs<=7)
954 params->timeout_cal_hs=timeout_cal_hs;
955 else
956 params->timeout_cal_hs=default_param_timeout_cal_hs;
957
958 if(timeout_cal_fs>=0 && timeout_cal_fs<=7)
959 params->timeout_cal_fs=timeout_cal_fs;
960 else
961 params->timeout_cal_fs=default_param_timeout_cal_fs;
962
963 if(data_fifo_size>=32 && data_fifo_size<=32768)
964 params->data_fifo_size=data_fifo_size;
965 else
966 params->data_fifo_size=default_param_data_fifo_size;
967
968 #ifdef __IS_HOST__
969 if(host_channels>=1 && host_channels<=16)
970 params->host_channels=host_channels;
971 else
972 params->host_channels=default_param_host_channels;
973
974 if(rx_fifo_size>=16 && rx_fifo_size<=32768)
975 params->rx_fifo_size=rx_fifo_size;
976 else
977 params->rx_fifo_size=default_param_rx_fifo_size;
978
979 if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768)
980 params->nperio_tx_fifo_size=nperio_tx_fifo_size;
981 else
982 params->nperio_tx_fifo_size=default_param_nperio_tx_fifo_size;
983
984 if(perio_tx_fifo_size>=16 && perio_tx_fifo_size<=32768)
985 params->perio_tx_fifo_size=perio_tx_fifo_size;
986 else
987 params->perio_tx_fifo_size=default_param_perio_tx_fifo_size;
988 #endif //__IS_HOST__
989
990 #ifdef __IS_DEVICE__
991 if(rx_fifo_size>=16 && rx_fifo_size<=32768)
992 params->rx_fifo_size=rx_fifo_size;
993 else
994 params->rx_fifo_size=default_param_rx_fifo_size;
995 #ifdef __DED_FIFO__
996 if(tx_fifo_size_00>=16 && tx_fifo_size_00<=32768)
997 params->tx_fifo_size[ 0]=tx_fifo_size_00;
998 else
999 params->tx_fifo_size[ 0]=default_param_tx_fifo_size_00;
1000 if(tx_fifo_size_01>=0 && tx_fifo_size_01<=32768)
1001 params->tx_fifo_size[ 1]=tx_fifo_size_01;
1002 else
1003 params->tx_fifo_size[ 1]=default_param_tx_fifo_size_01;
1004 if(tx_fifo_size_02>=0 && tx_fifo_size_02<=32768)
1005 params->tx_fifo_size[ 2]=tx_fifo_size_02;
1006 else
1007 params->tx_fifo_size[ 2]=default_param_tx_fifo_size_02;
1008 if(tx_fifo_size_03>=0 && tx_fifo_size_03<=32768)
1009 params->tx_fifo_size[ 3]=tx_fifo_size_03;
1010 else
1011 params->tx_fifo_size[ 3]=default_param_tx_fifo_size_03;
1012 if(tx_fifo_size_04>=0 && tx_fifo_size_04<=32768)
1013 params->tx_fifo_size[ 4]=tx_fifo_size_04;
1014 else
1015 params->tx_fifo_size[ 4]=default_param_tx_fifo_size_04;
1016 if(tx_fifo_size_05>=0 && tx_fifo_size_05<=32768)
1017 params->tx_fifo_size[ 5]=tx_fifo_size_05;
1018 else
1019 params->tx_fifo_size[ 5]=default_param_tx_fifo_size_05;
1020 if(tx_fifo_size_06>=0 && tx_fifo_size_06<=32768)
1021 params->tx_fifo_size[ 6]=tx_fifo_size_06;
1022 else
1023 params->tx_fifo_size[ 6]=default_param_tx_fifo_size_06;
1024 if(tx_fifo_size_07>=0 && tx_fifo_size_07<=32768)
1025 params->tx_fifo_size[ 7]=tx_fifo_size_07;
1026 else
1027 params->tx_fifo_size[ 7]=default_param_tx_fifo_size_07;
1028 if(tx_fifo_size_08>=0 && tx_fifo_size_08<=32768)
1029 params->tx_fifo_size[ 8]=tx_fifo_size_08;
1030 else
1031 params->tx_fifo_size[ 8]=default_param_tx_fifo_size_08;
1032 if(tx_fifo_size_09>=0 && tx_fifo_size_09<=32768)
1033 params->tx_fifo_size[ 9]=tx_fifo_size_09;
1034 else
1035 params->tx_fifo_size[ 9]=default_param_tx_fifo_size_09;
1036 if(tx_fifo_size_10>=0 && tx_fifo_size_10<=32768)
1037 params->tx_fifo_size[10]=tx_fifo_size_10;
1038 else
1039 params->tx_fifo_size[10]=default_param_tx_fifo_size_10;
1040 if(tx_fifo_size_11>=0 && tx_fifo_size_11<=32768)
1041 params->tx_fifo_size[11]=tx_fifo_size_11;
1042 else
1043 params->tx_fifo_size[11]=default_param_tx_fifo_size_11;
1044 if(tx_fifo_size_12>=0 && tx_fifo_size_12<=32768)
1045 params->tx_fifo_size[12]=tx_fifo_size_12;
1046 else
1047 params->tx_fifo_size[12]=default_param_tx_fifo_size_12;
1048 if(tx_fifo_size_13>=0 && tx_fifo_size_13<=32768)
1049 params->tx_fifo_size[13]=tx_fifo_size_13;
1050 else
1051 params->tx_fifo_size[13]=default_param_tx_fifo_size_13;
1052 if(tx_fifo_size_14>=0 && tx_fifo_size_14<=32768)
1053 params->tx_fifo_size[14]=tx_fifo_size_14;
1054 else
1055 params->tx_fifo_size[14]=default_param_tx_fifo_size_14;
1056 if(tx_fifo_size_15>=0 && tx_fifo_size_15<=32768)
1057 params->tx_fifo_size[15]=tx_fifo_size_15;
1058 else
1059 params->tx_fifo_size[15]=default_param_tx_fifo_size_15;
1060 if(thr_ctl==0 || thr_ctl==1)
1061 params->thr_ctl=thr_ctl;
1062 else
1063 params->thr_ctl=default_param_thr_ctl;
1064 if(tx_thr_length>=16 && tx_thr_length<=511)
1065 params->tx_thr_length=tx_thr_length;
1066 else
1067 params->tx_thr_length=default_param_tx_thr_length;
1068 if(rx_thr_length>=16 && rx_thr_length<=511)
1069 params->rx_thr_length=rx_thr_length;
1070 else
1071 params->rx_thr_length=default_param_rx_thr_length;
1072 #else //__DED_FIFO__
1073 if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768)
1074 params->tx_fifo_size[ 0]=nperio_tx_fifo_size;
1075 else
1076 params->tx_fifo_size[ 0]=default_param_nperio_tx_fifo_size;
1077 if(perio_tx_fifo_size_01>=0 && perio_tx_fifo_size_01<=32768)
1078 params->tx_fifo_size[ 1]=perio_tx_fifo_size_01;
1079 else
1080 params->tx_fifo_size[ 1]=default_param_perio_tx_fifo_size_01;
1081 if(perio_tx_fifo_size_02>=0 && perio_tx_fifo_size_02<=32768)
1082 params->tx_fifo_size[ 2]=perio_tx_fifo_size_02;
1083 else
1084 params->tx_fifo_size[ 2]=default_param_perio_tx_fifo_size_02;
1085 if(perio_tx_fifo_size_03>=0 && perio_tx_fifo_size_03<=32768)
1086 params->tx_fifo_size[ 3]=perio_tx_fifo_size_03;
1087 else
1088 params->tx_fifo_size[ 3]=default_param_perio_tx_fifo_size_03;
1089 if(perio_tx_fifo_size_04>=0 && perio_tx_fifo_size_04<=32768)
1090 params->tx_fifo_size[ 4]=perio_tx_fifo_size_04;
1091 else
1092 params->tx_fifo_size[ 4]=default_param_perio_tx_fifo_size_04;
1093 if(perio_tx_fifo_size_05>=0 && perio_tx_fifo_size_05<=32768)
1094 params->tx_fifo_size[ 5]=perio_tx_fifo_size_05;
1095 else
1096 params->tx_fifo_size[ 5]=default_param_perio_tx_fifo_size_05;
1097 if(perio_tx_fifo_size_06>=0 && perio_tx_fifo_size_06<=32768)
1098 params->tx_fifo_size[ 6]=perio_tx_fifo_size_06;
1099 else
1100 params->tx_fifo_size[ 6]=default_param_perio_tx_fifo_size_06;
1101 if(perio_tx_fifo_size_07>=0 && perio_tx_fifo_size_07<=32768)
1102 params->tx_fifo_size[ 7]=perio_tx_fifo_size_07;
1103 else
1104 params->tx_fifo_size[ 7]=default_param_perio_tx_fifo_size_07;
1105 if(perio_tx_fifo_size_08>=0 && perio_tx_fifo_size_08<=32768)
1106 params->tx_fifo_size[ 8]=perio_tx_fifo_size_08;
1107 else
1108 params->tx_fifo_size[ 8]=default_param_perio_tx_fifo_size_08;
1109 if(perio_tx_fifo_size_09>=0 && perio_tx_fifo_size_09<=32768)
1110 params->tx_fifo_size[ 9]=perio_tx_fifo_size_09;
1111 else
1112 params->tx_fifo_size[ 9]=default_param_perio_tx_fifo_size_09;
1113 if(perio_tx_fifo_size_10>=0 && perio_tx_fifo_size_10<=32768)
1114 params->tx_fifo_size[10]=perio_tx_fifo_size_10;
1115 else
1116 params->tx_fifo_size[10]=default_param_perio_tx_fifo_size_10;
1117 if(perio_tx_fifo_size_11>=0 && perio_tx_fifo_size_11<=32768)
1118 params->tx_fifo_size[11]=perio_tx_fifo_size_11;
1119 else
1120 params->tx_fifo_size[11]=default_param_perio_tx_fifo_size_11;
1121 if(perio_tx_fifo_size_12>=0 && perio_tx_fifo_size_12<=32768)
1122 params->tx_fifo_size[12]=perio_tx_fifo_size_12;
1123 else
1124 params->tx_fifo_size[12]=default_param_perio_tx_fifo_size_12;
1125 if(perio_tx_fifo_size_13>=0 && perio_tx_fifo_size_13<=32768)
1126 params->tx_fifo_size[13]=perio_tx_fifo_size_13;
1127 else
1128 params->tx_fifo_size[13]=default_param_perio_tx_fifo_size_13;
1129 if(perio_tx_fifo_size_14>=0 && perio_tx_fifo_size_14<=32768)
1130 params->tx_fifo_size[14]=perio_tx_fifo_size_14;
1131 else
1132 params->tx_fifo_size[14]=default_param_perio_tx_fifo_size_14;
1133 if(perio_tx_fifo_size_15>=0 && perio_tx_fifo_size_15<=32768)
1134 params->tx_fifo_size[15]=perio_tx_fifo_size_15;
1135 else
1136 params->tx_fifo_size[15]=default_param_perio_tx_fifo_size_15;
1137 #endif //__DED_FIFO__
1138 #endif //__IS_DEVICE__
1139 }
1140
1141
1142
1143
1144
1145
1146
1147 module_param(dbg_lvl, long, 0444);
1148 MODULE_PARM_DESC(dbg_lvl, "Debug level.");
1149
1150 module_param(dma_burst_size, short, 0444);
1151 MODULE_PARM_DESC(dma_burst_size, "DMA Burst Size 0, 1, 4, 8, 16");
1152
1153 module_param(speed, short, 0444);
1154 MODULE_PARM_DESC(speed, "Speed 0=High Speed 1=Full Speed");
1155
1156 module_param(data_fifo_size, long, 0444);
1157 MODULE_PARM_DESC(data_fifo_size, "Total number of words in the data FIFO memory 32-32768");
1158
1159 #ifdef __IS_DEVICE__
1160 module_param(rx_fifo_size, long, 0444);
1161 MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768");
1162
1163 #ifdef __DED_FIFO__
1164 module_param(tx_fifo_size_00, long, 0444);
1165 MODULE_PARM_DESC(tx_fifo_size_00, "Number of words in the Tx FIFO #00 16-32768");
1166 module_param(tx_fifo_size_01, long, 0444);
1167 MODULE_PARM_DESC(tx_fifo_size_01, "Number of words in the Tx FIFO #01 0-32768");
1168 module_param(tx_fifo_size_02, long, 0444);
1169 MODULE_PARM_DESC(tx_fifo_size_02, "Number of words in the Tx FIFO #02 0-32768");
1170 module_param(tx_fifo_size_03, long, 0444);
1171 MODULE_PARM_DESC(tx_fifo_size_03, "Number of words in the Tx FIFO #03 0-32768");
1172 module_param(tx_fifo_size_04, long, 0444);
1173 MODULE_PARM_DESC(tx_fifo_size_04, "Number of words in the Tx FIFO #04 0-32768");
1174 module_param(tx_fifo_size_05, long, 0444);
1175 MODULE_PARM_DESC(tx_fifo_size_05, "Number of words in the Tx FIFO #05 0-32768");
1176 module_param(tx_fifo_size_06, long, 0444);
1177 MODULE_PARM_DESC(tx_fifo_size_06, "Number of words in the Tx FIFO #06 0-32768");
1178 module_param(tx_fifo_size_07, long, 0444);
1179 MODULE_PARM_DESC(tx_fifo_size_07, "Number of words in the Tx FIFO #07 0-32768");
1180 module_param(tx_fifo_size_08, long, 0444);
1181 MODULE_PARM_DESC(tx_fifo_size_08, "Number of words in the Tx FIFO #08 0-32768");
1182 module_param(tx_fifo_size_09, long, 0444);
1183 MODULE_PARM_DESC(tx_fifo_size_09, "Number of words in the Tx FIFO #09 0-32768");
1184 module_param(tx_fifo_size_10, long, 0444);
1185 MODULE_PARM_DESC(tx_fifo_size_10, "Number of words in the Tx FIFO #10 0-32768");
1186 module_param(tx_fifo_size_11, long, 0444);
1187 MODULE_PARM_DESC(tx_fifo_size_11, "Number of words in the Tx FIFO #11 0-32768");
1188 module_param(tx_fifo_size_12, long, 0444);
1189 MODULE_PARM_DESC(tx_fifo_size_12, "Number of words in the Tx FIFO #12 0-32768");
1190 module_param(tx_fifo_size_13, long, 0444);
1191 MODULE_PARM_DESC(tx_fifo_size_13, "Number of words in the Tx FIFO #13 0-32768");
1192 module_param(tx_fifo_size_14, long, 0444);
1193 MODULE_PARM_DESC(tx_fifo_size_14, "Number of words in the Tx FIFO #14 0-32768");
1194 module_param(tx_fifo_size_15, long, 0444);
1195 MODULE_PARM_DESC(tx_fifo_size_15, "Number of words in the Tx FIFO #15 0-32768");
1196
1197 module_param(thr_ctl, short, 0444);
1198 MODULE_PARM_DESC(thr_ctl, "0=Without 1=With Theshold Ctrl");
1199
1200 module_param(tx_thr_length, long, 0444);
1201 MODULE_PARM_DESC(tx_thr_length, "TX Threshold length");
1202
1203 module_param(rx_thr_length, long, 0444);
1204 MODULE_PARM_DESC(rx_thr_length, "RX Threshold length");
1205
1206 #else
1207 module_param(nperio_tx_fifo_size, long, 0444);
1208 MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768");
1209
1210 module_param(perio_tx_fifo_size_01, long, 0444);
1211 MODULE_PARM_DESC(perio_tx_fifo_size_01, "Number of words in the periodic Tx FIFO #01 0-32768");
1212 module_param(perio_tx_fifo_size_02, long, 0444);
1213 MODULE_PARM_DESC(perio_tx_fifo_size_02, "Number of words in the periodic Tx FIFO #02 0-32768");
1214 module_param(perio_tx_fifo_size_03, long, 0444);
1215 MODULE_PARM_DESC(perio_tx_fifo_size_03, "Number of words in the periodic Tx FIFO #03 0-32768");
1216 module_param(perio_tx_fifo_size_04, long, 0444);
1217 MODULE_PARM_DESC(perio_tx_fifo_size_04, "Number of words in the periodic Tx FIFO #04 0-32768");
1218 module_param(perio_tx_fifo_size_05, long, 0444);
1219 MODULE_PARM_DESC(perio_tx_fifo_size_05, "Number of words in the periodic Tx FIFO #05 0-32768");
1220 module_param(perio_tx_fifo_size_06, long, 0444);
1221 MODULE_PARM_DESC(perio_tx_fifo_size_06, "Number of words in the periodic Tx FIFO #06 0-32768");
1222 module_param(perio_tx_fifo_size_07, long, 0444);
1223 MODULE_PARM_DESC(perio_tx_fifo_size_07, "Number of words in the periodic Tx FIFO #07 0-32768");
1224 module_param(perio_tx_fifo_size_08, long, 0444);
1225 MODULE_PARM_DESC(perio_tx_fifo_size_08, "Number of words in the periodic Tx FIFO #08 0-32768");
1226 module_param(perio_tx_fifo_size_09, long, 0444);
1227 MODULE_PARM_DESC(perio_tx_fifo_size_09, "Number of words in the periodic Tx FIFO #09 0-32768");
1228 module_param(perio_tx_fifo_size_10, long, 0444);
1229 MODULE_PARM_DESC(perio_tx_fifo_size_10, "Number of words in the periodic Tx FIFO #10 0-32768");
1230 module_param(perio_tx_fifo_size_11, long, 0444);
1231 MODULE_PARM_DESC(perio_tx_fifo_size_11, "Number of words in the periodic Tx FIFO #11 0-32768");
1232 module_param(perio_tx_fifo_size_12, long, 0444);
1233 MODULE_PARM_DESC(perio_tx_fifo_size_12, "Number of words in the periodic Tx FIFO #12 0-32768");
1234 module_param(perio_tx_fifo_size_13, long, 0444);
1235 MODULE_PARM_DESC(perio_tx_fifo_size_13, "Number of words in the periodic Tx FIFO #13 0-32768");
1236 module_param(perio_tx_fifo_size_14, long, 0444);
1237 MODULE_PARM_DESC(perio_tx_fifo_size_14, "Number of words in the periodic Tx FIFO #14 0-32768");
1238 module_param(perio_tx_fifo_size_15, long, 0444);
1239 MODULE_PARM_DESC(perio_tx_fifo_size_15, "Number of words in the periodic Tx FIFO #15 0-32768");
1240 #endif//__DED_FIFO__
1241 module_param(dev_endpoints, short, 0444);
1242 MODULE_PARM_DESC(dev_endpoints, "The number of endpoints in addition to EP0 available for device mode 1-15");
1243 #endif
1244
1245 #ifdef __IS_HOST__
1246 module_param(rx_fifo_size, long, 0444);
1247 MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768");
1248
1249 module_param(nperio_tx_fifo_size, long, 0444);
1250 MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768");
1251
1252 module_param(perio_tx_fifo_size, long, 0444);
1253 MODULE_PARM_DESC(perio_tx_fifo_size, "Number of words in the host periodic Tx FIFO 16-32768");
1254
1255 module_param(host_channels, short, 0444);
1256 MODULE_PARM_DESC(host_channels, "The number of host channel registers to use 1-16");
1257 #endif
1258
1259 module_param(max_transfer_size, long, 0444);
1260 MODULE_PARM_DESC(max_transfer_size, "The maximum transfer size supported in bytes 2047-65535");
1261
1262 module_param(max_packet_count, long, 0444);
1263 MODULE_PARM_DESC(max_packet_count, "The maximum number of packets in a transfer 15-511");
1264
1265 module_param(phy_utmi_width, long, 0444);
1266 MODULE_PARM_DESC(phy_utmi_width, "Specifies the UTMI+ Data Width 8 or 16 bits");
1267
1268 module_param(turn_around_time_hs, long, 0444);
1269 MODULE_PARM_DESC(turn_around_time_hs, "Turn-Around time for HS");
1270
1271 module_param(turn_around_time_fs, long, 0444);
1272 MODULE_PARM_DESC(turn_around_time_fs, "Turn-Around time for FS");
1273
1274 module_param(timeout_cal_hs, long, 0444);
1275 MODULE_PARM_DESC(timeout_cal_hs, "Timeout Cal for HS");
1276
1277 module_param(timeout_cal_fs, long, 0444);
1278 MODULE_PARM_DESC(timeout_cal_fs, "Timeout Cal for FS");
1279