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 : 1.0 6 ** DATE : 1/Jan/2009 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 *****************************************************************************/ 15 16/*! 17 \file ifxusb_driver.c 18 \brief This file contains the loading/unloading interface to the Linux driver. 19*/ 20 21#include <linux/version.h> 22#include "ifxusb_version.h" 23 24#include <linux/kernel.h> 25#include <linux/module.h> 26#include <linux/moduleparam.h> 27#include <linux/init.h> 28 29#include <linux/device.h> 30#include <linux/platform_device.h> 31 32#include <linux/errno.h> 33#include <linux/types.h> 34#include <linux/stat.h> /* permission constants */ 35#include <linux/gpio.h> 36#include <lantiq_soc.h> 37 38#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 39 #include <linux/irq.h> 40#endif 41 42#include <asm/io.h> 43 44#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) 45 #include <asm/irq.h> 46#endif 47 48#include "ifxusb_plat.h" 49 50#include "ifxusb_cif.h" 51 52#ifdef __IS_HOST__ 53 #include "ifxhcd.h" 54 55 #define USB_DRIVER_DESC "IFX USB HCD driver" 56 const char ifxusb_driver_name[] = "ifxusb_hcd"; 57 58 #ifdef __IS_DUAL__ 59 ifxhcd_hcd_t ifxusb_hcd_1; 60 ifxhcd_hcd_t ifxusb_hcd_2; 61 const char ifxusb_hcd_name_1[] = "ifxusb_hcd_1"; 62 const char ifxusb_hcd_name_2[] = "ifxusb_hcd_2"; 63 #else 64 ifxhcd_hcd_t ifxusb_hcd; 65 const char ifxusb_hcd_name[] = "ifxusb_hcd"; 66 #endif 67 68 #if defined(__DO_OC_INT__) 69 static unsigned int oc_int_installed=0; 70 static ifxhcd_hcd_t *oc_int_id=NULL; 71 #endif 72#endif 73 74#ifdef __IS_DEVICE__ 75 #include "ifxpcd.h" 76 77 #define USB_DRIVER_DESC "IFX USB PCD driver" 78 const char ifxusb_driver_name[] = "ifxusb_pcd"; 79 80 ifxpcd_pcd_t ifxusb_pcd; 81 const char ifxusb_pcd_name[] = "ifxusb_pcd"; 82#endif 83 84/* Global Debug Level Mask. */ 85#ifdef __IS_HOST__ 86 uint32_t h_dbg_lvl = 0x00; 87#endif 88 89#ifdef __IS_DEVICE__ 90 uint32_t d_dbg_lvl = 0x00; 91#endif 92 93ifxusb_params_t ifxusb_module_params; 94 95static void parse_parms(void); 96 97 98#include <lantiq_irq.h> 99#define IFX_USB0_IR (INT_NUM_IM1_IRL0 + 22) 100#define IFX_USB1_IR (INT_NUM_IM2_IRL0 + 19) 101 102/*! 103 \brief This function is called when a driver is unregistered. This happens when 104 the rmmod command is executed. The device may or may not be electrically 105 present. If it is present, the driver stops device processing. Any resources 106 used on behalf of this device are freed. 107*/ 108static int ifxusb_driver_remove(struct platform_device *_dev) 109{ 110 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 111 #ifdef __IS_HOST__ 112 #if defined(__DO_OC_INT__) 113 #if defined(__DO_OC_INT_ENABLE__) 114 ifxusb_oc_int_off(); 115 #endif 116 117 if(oc_int_installed && oc_int_id) 118 free_irq((unsigned int)IFXUSB_OC_IRQ, oc_int_id ); 119 oc_int_installed=0; 120 oc_int_id=NULL; 121 #endif 122 123 #if defined(__IS_DUAL__) 124 ifxhcd_remove(&ifxusb_hcd_1); 125 ifxusb_core_if_remove(&ifxusb_hcd_1.core_if ); 126 ifxhcd_remove(&ifxusb_hcd_2); 127 ifxusb_core_if_remove(&ifxusb_hcd_2.core_if ); 128 #else 129 ifxhcd_remove(&ifxusb_hcd); 130 ifxusb_core_if_remove(&ifxusb_hcd.core_if ); 131 #endif 132 #endif 133 134 #ifdef __IS_DEVICE__ 135 ifxpcd_remove(); 136 ifxusb_core_if_remove(&ifxusb_pcd.core_if ); 137 #endif 138 139 /* Remove the device attributes */ 140 141 ifxusb_attr_remove(&_dev->dev); 142 143 return 0; 144} 145 146 147/* Function to setup the structures to control one usb core running as host*/ 148#ifdef __IS_HOST__ 149/*! 150 \brief inlined by ifxusb_driver_probe(), handling host mode probing. Run at each host core. 151*/ 152 static inline int ifxusb_driver_probe_h(ifxhcd_hcd_t *_hcd, 153 int _irq, 154 uint32_t _iobase, 155 uint32_t _fifomem, 156 uint32_t _fifodbg 157 ) 158 { 159 int retval = 0; 160 161 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 162 163#ifdef __DEV_NEW__ 164 ifxusb_power_off (&_hcd->core_if); 165 ifxusb_phy_power_off (&_hcd->core_if); // Test 166 mdelay(500); 167#endif //__DEV_NEW__ 168 ifxusb_power_on (&_hcd->core_if); 169 mdelay(50); 170 ifxusb_phy_power_on (&_hcd->core_if); // Test 171 mdelay(50); 172 ifxusb_hard_reset(&_hcd->core_if); 173 retval =ifxusb_core_if_init(&_hcd->core_if, 174 _irq, 175 _iobase, 176 _fifomem, 177 _fifodbg); 178 if(retval) 179 return retval; 180 181 ifxusb_host_core_init(&_hcd->core_if,&ifxusb_module_params); 182 183 ifxusb_disable_global_interrupts( &_hcd->core_if); 184 185 /* The driver is now initialized and need to be registered into Linux USB sub-system */ 186 187 retval = ifxhcd_init(_hcd); // hook the hcd into usb ss 188 189 if (retval != 0) 190 { 191 IFX_ERROR("_hcd_init failed\n"); 192 return retval; 193 } 194 195 //ifxusb_enable_global_interrupts( _hcd->core_if ); // this should be done at hcd_start , including hcd_interrupt 196 return 0; 197 } 198#endif //__IS_HOST__ 199 200#ifdef __IS_DEVICE__ 201/*! 202 \brief inlined by ifxusb_driver_probe(), handling device mode probing. 203*/ 204 static inline int ifxusb_driver_probe_d(ifxpcd_pcd_t *_pcd, 205 int _irq, 206 uint32_t _iobase, 207 uint32_t _fifomem, 208 uint32_t _fifodbg 209 ) 210 { 211 int retval = 0; 212 213 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 214#ifdef __DEV_NEW__ 215 ifxusb_power_off (&_pcd->core_if); 216 ifxusb_phy_power_off (&_pcd->core_if); // Test 217 mdelay(500); 218#endif // __DEV_NEW__ 219 ifxusb_power_on (&_pcd->core_if); 220 mdelay(50); 221 ifxusb_phy_power_on (&_pcd->core_if); // Test 222 mdelay(50); 223 ifxusb_hard_reset(&_pcd->core_if); 224 retval =ifxusb_core_if_init(&_pcd->core_if, 225 _irq, 226 _iobase, 227 _fifomem, 228 _fifodbg); 229 if(retval) 230 return retval; 231 232 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 233 ifxusb_dev_core_init(&_pcd->core_if,&ifxusb_module_params); 234 235 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 236 ifxusb_disable_global_interrupts( &_pcd->core_if); 237 238 /* The driver is now initialized and need to be registered into 239 Linux USB Gadget sub-system 240 */ 241 retval = ifxpcd_init(); 242 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 243 244 if (retval != 0) 245 { 246 IFX_ERROR("_pcd_init failed\n"); 247 return retval; 248 } 249 //ifxusb_enable_global_interrupts( _pcd->core_if ); // this should be done at gadget bind or start 250 return 0; 251 } 252#endif //__IS_DEVICE__ 253 254 255 256/*! 257 \brief This function is called by module management in 2.6 kernel or by ifxusb_driver_init with 2.4 kernel 258 It is to probe and setup IFXUSB core(s). 259*/ 260static int ifxusb_driver_probe(struct platform_device *_dev) 261{ 262 int retval = 0; 263 int *pins = _dev->dev.platform_data; 264 if (ltq_is_vr9()) { 265 gpio_request(6, "id1"); 266 gpio_request(9, "id2"); 267 gpio_direction_input(6); 268 gpio_direction_input(9); 269 } 270 if (pins) { 271 if (pins[0]) { 272 gpio_request(pins[0], "vbus1"); 273 gpio_direction_output(pins[0], 1); 274 } 275 if (pins[1] && ltq_is_vr9()) { 276 gpio_request(pins[1], "vbus2"); 277 gpio_direction_output(pins[1], 1); 278 } 279 } 280 // Parsing and store the parameters 281 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 282 parse_parms(); 283 284 #ifdef __IS_HOST__ 285 #if defined(__IS_DUAL__) 286 memset(&ifxusb_hcd_1, 0, sizeof(ifxhcd_hcd_t)); 287 memset(&ifxusb_hcd_2, 0, sizeof(ifxhcd_hcd_t)); 288 289 ifxusb_hcd_1.core_if.core_no=0; 290 ifxusb_hcd_2.core_if.core_no=1; 291 ifxusb_hcd_1.core_if.core_name=(char *)ifxusb_hcd_name_1; 292 ifxusb_hcd_2.core_if.core_name=(char *)ifxusb_hcd_name_2; 293 294 ifxusb_hcd_1.dev=&_dev->dev; 295 ifxusb_hcd_2.dev=&_dev->dev; 296 297 retval = ifxusb_driver_probe_h(&ifxusb_hcd_1, 298 IFX_USB0_IR, 299 IFXUSB1_IOMEM_BASE, 300 IFXUSB1_FIFOMEM_BASE, 301 IFXUSB1_FIFODBG_BASE 302 ); 303 if(retval) 304 goto ifxusb_driver_probe_fail; 305 306 retval = ifxusb_driver_probe_h(&ifxusb_hcd_2, 307 IFX_USB1_IR, 308 IFXUSB2_IOMEM_BASE, 309 IFXUSB2_FIFOMEM_BASE, 310 IFXUSB2_FIFODBG_BASE 311 ); 312 if(retval) 313 goto ifxusb_driver_probe_fail; 314 315 #elif defined(__IS_FIRST__) 316 memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t)); 317 318 ifxusb_hcd.core_if.core_no=0; 319 ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name; 320 321 ifxusb_hcd.dev=&_dev->dev; 322 323 retval = ifxusb_driver_probe_h(&ifxusb_hcd, 324 IFX_USB0_IR, 325 IFXUSB1_IOMEM_BASE, 326 IFXUSB1_FIFOMEM_BASE, 327 IFXUSB1_FIFODBG_BASE 328 ); 329 if(retval) 330 goto ifxusb_driver_probe_fail; 331 332 #elif defined(__IS_SECOND__) 333 memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t)); 334 335 ifxusb_hcd.core_if.core_no=1; 336 ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name; 337 338 ifxusb_hcd.dev=&_dev->dev; 339 340 retval = ifxusb_driver_probe_h(&ifxusb_hcd, 341 IFX_USB1_IR, 342 IFXUSB2_IOMEM_BASE, 343 IFXUSB2_FIFOMEM_BASE, 344 IFXUSB2_FIFODBG_BASE 345 ); 346 if(retval) 347 goto ifxusb_driver_probe_fail; 348 349 #else 350 memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t)); 351 352 ifxusb_hcd.core_if.core_no=0; 353 ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name; 354 355 ifxusb_hcd.dev=&_dev->dev; 356 357 retval = ifxusb_driver_probe_h(&ifxusb_hcd, 358 IFXUSB_IRQ, 359 IFXUSB_IOMEM_BASE, 360 IFXUSB_FIFOMEM_BASE, 361 IFXUSB_FIFODBG_BASE 362 ); 363 if(retval) 364 goto ifxusb_driver_probe_fail; 365 #endif 366 367 #if defined(__DO_OC_INT__) 368 IFXUSB_DEBUGPL( DBG_CIL, "registering (overcurrent) handler for irq%d\n", IFXUSB_OC_IRQ); 369 #if defined(__IS_DUAL__) 370 request_irq((unsigned int)IFXUSB_OC_IRQ, &ifx_hcd_oc_irq, 371// SA_INTERRUPT|SA_SHIRQ, "ifxusb_oc", (void *)&ifxusb_hcd_1); 372 IRQF_DISABLED | IRQF_SHARED, "ifxusb_oc", (void *)&ifxusb_hcd_1); 373 oc_int_id=&ifxusb_hcd_1; 374 #else 375 request_irq((unsigned int)IFXUSB_OC_IRQ, &ifx_hcd_oc_irq, 376// SA_INTERRUPT|SA_SHIRQ, "ifxusb_oc", (void *)&ifxusb_hcd); 377 IRQF_DISABLED | IRQF_SHARED, "ifxusb_oc", (void *)&ifxusb_hcd); 378 oc_int_id=&ifxusb_hcd; 379 #endif 380 oc_int_installed=1; 381 382 #if defined(__DO_OC_INT_ENABLE__) 383 ifxusb_oc_int_on(); 384 #endif 385 #endif 386 387 #endif 388 389 #ifdef __IS_DEVICE__ 390 memset(&ifxusb_pcd, 0, sizeof(ifxpcd_pcd_t)); 391 ifxusb_pcd.core_if.core_name=(char *)&ifxusb_pcd_name[0]; 392 393 ifxusb_pcd.dev=&_dev->dev; 394 395 #if defined(__IS_FIRST__) 396 ifxusb_pcd.core_if.core_no=0; 397 retval = ifxusb_driver_probe_d(&ifxusb_pcd, 398 IFXUSB1_IRQ, 399 IFXUSB1_IOMEM_BASE, 400 IFXUSB1_FIFOMEM_BASE, 401 IFXUSB1_FIFODBG_BASE 402 ); 403 #elif defined(__IS_SECOND__) 404 ifxusb_pcd.core_if.core_no=1; 405 retval = ifxusb_driver_probe_d(&ifxusb_pcd, 406 IFXUSB2_IRQ, 407 IFXUSB2_IOMEM_BASE, 408 IFXUSB2_FIFOMEM_BASE, 409 IFXUSB2_FIFODBG_BASE 410 ); 411 #else 412 ifxusb_pcd.core_if.core_no=0; 413 retval = ifxusb_driver_probe_d(&ifxusb_pcd, 414 IFXUSB_IRQ, 415 IFXUSB_IOMEM_BASE, 416 IFXUSB_FIFOMEM_BASE, 417 IFXUSB_FIFODBG_BASE 418 ); 419 #endif 420 if(retval) 421 goto ifxusb_driver_probe_fail; 422 #endif 423 424 ifxusb_attr_create(&_dev->dev); 425 426 return 0; 427 428ifxusb_driver_probe_fail: 429 ifxusb_driver_remove(_dev); 430 return retval; 431} 432 433 434 435/*! 436 \brief This function is called when the ifxusb_driver is installed with the insmod command. 437*/ 438 439 440static struct platform_driver ifxusb_driver = { 441 .driver = { 442 .name = ifxusb_driver_name, 443 .owner = THIS_MODULE, 444 }, 445 .probe = ifxusb_driver_probe, 446 .remove = ifxusb_driver_remove, 447}; 448 449int __init ifxusb_driver_init(void) 450{ 451 int retval = 0; 452 453 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 454 IFX_PRINT("%s: version %s\n", ifxusb_driver_name, IFXUSB_VERSION); 455 456 retval = platform_driver_register(&ifxusb_driver); 457 458 if (retval < 0) { 459 IFX_ERROR("%s retval=%d\n", __func__, retval); 460 return retval; 461 } 462 return retval; 463} 464 465#if 0 // 2.4 466 int __init ifxusb_driver_init(void) 467 { 468 int retval = 0; 469 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 470 IFX_PRINT("%s: version %s\n", ifxusb_driver_name, IFXUSB_VERSION); 471 retval = ifxusb_driver_probe(); 472 473 if (retval < 0) { 474 IFX_ERROR("%s retval=%d\n", __func__, retval); 475 return retval; 476 } 477 478 return retval; 479 } 480#endif 481 482module_init(ifxusb_driver_init); 483 484 485/*! 486 \brief This function is called when the driver is removed from the kernel 487 with the rmmod command. The driver unregisters itself with its bus 488 driver. 489*/ 490 491void __exit ifxusb_driver_cleanup(void) 492{ 493 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 494 495 platform_driver_unregister(&ifxusb_driver); 496 497 IFX_PRINT("%s module removed\n", ifxusb_driver_name); 498} 499#if 0 500 void __exit ifxusb_driver_cleanup(void) 501 { 502 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 503 ifxusb_driver_remove(); 504 IFX_PRINT("%s module removed\n", ifxusb_driver_name); 505 } 506#endif 507module_exit(ifxusb_driver_cleanup); 508 509 510 511MODULE_DESCRIPTION(USB_DRIVER_DESC); 512MODULE_AUTHOR("Infineon"); 513MODULE_LICENSE("GPL"); 514 515 516 517// Parameters set when loaded 518//static long dbg_lvl =0xFFFFFFFF; 519static long dbg_lvl =0; 520static short dma_burst_size =-1; 521static short speed =-1; 522static long data_fifo_size =-1; 523#ifdef __IS_DEVICE__ 524 static long rx_fifo_size =-1; 525 #ifdef __DED_FIFO__ 526 static long tx_fifo_size_00 =-1; 527 static long tx_fifo_size_01 =-1; 528 static long tx_fifo_size_02 =-1; 529 static long tx_fifo_size_03 =-1; 530 static long tx_fifo_size_04 =-1; 531 static long tx_fifo_size_05 =-1; 532 static long tx_fifo_size_06 =-1; 533 static long tx_fifo_size_07 =-1; 534 static long tx_fifo_size_08 =-1; 535 static long tx_fifo_size_09 =-1; 536 static long tx_fifo_size_10 =-1; 537 static long tx_fifo_size_11 =-1; 538 static long tx_fifo_size_12 =-1; 539 static long tx_fifo_size_13 =-1; 540 static long tx_fifo_size_14 =-1; 541 static long tx_fifo_size_15 =-1; 542 static short thr_ctl=-1; 543 static long tx_thr_length =-1; 544 static long rx_thr_length =-1; 545 #else 546 static long nperio_tx_fifo_size =-1; 547 static long perio_tx_fifo_size_01 =-1; 548 static long perio_tx_fifo_size_02 =-1; 549 static long perio_tx_fifo_size_03 =-1; 550 static long perio_tx_fifo_size_04 =-1; 551 static long perio_tx_fifo_size_05 =-1; 552 static long perio_tx_fifo_size_06 =-1; 553 static long perio_tx_fifo_size_07 =-1; 554 static long perio_tx_fifo_size_08 =-1; 555 static long perio_tx_fifo_size_09 =-1; 556 static long perio_tx_fifo_size_10 =-1; 557 static long perio_tx_fifo_size_11 =-1; 558 static long perio_tx_fifo_size_12 =-1; 559 static long perio_tx_fifo_size_13 =-1; 560 static long perio_tx_fifo_size_14 =-1; 561 static long perio_tx_fifo_size_15 =-1; 562 #endif 563 static short dev_endpoints =-1; 564#endif 565 566#ifdef __IS_HOST__ 567 static long rx_fifo_size =-1; 568 static long nperio_tx_fifo_size =-1; 569 static long perio_tx_fifo_size =-1; 570 static short host_channels =-1; 571#endif 572 573static long max_transfer_size =-1; 574static long max_packet_count =-1; 575static long phy_utmi_width =-1; 576static long turn_around_time_hs =-1; 577static long turn_around_time_fs =-1; 578static long timeout_cal_hs =-1; 579static long timeout_cal_fs =-1; 580 581/*! 582 \brief Parsing the parameters taken when module load 583*/ 584static void parse_parms(void) 585{ 586 587 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 588 #ifdef __IS_HOST__ 589 h_dbg_lvl=dbg_lvl; 590 #endif 591 #ifdef __IS_DEVICE__ 592 d_dbg_lvl=dbg_lvl; 593 #endif 594 595 switch(dma_burst_size) 596 { 597 case 0: 598 case 1: 599 case 4: 600 case 8: 601 case 16: 602 ifxusb_module_params.dma_burst_size=dma_burst_size; 603 break; 604 default: 605 ifxusb_module_params.dma_burst_size=default_param_dma_burst_size; 606 } 607 608 if(speed==0 || speed==1) 609 ifxusb_module_params.speed=speed; 610 else 611 ifxusb_module_params.speed=default_param_speed; 612 613 if(max_transfer_size>=2048 && max_transfer_size<=65535) 614 ifxusb_module_params.max_transfer_size=max_transfer_size; 615 else 616 ifxusb_module_params.max_transfer_size=default_param_max_transfer_size; 617 618 if(max_packet_count>=15 && max_packet_count<=511) 619 ifxusb_module_params.max_packet_count=max_packet_count; 620 else 621 ifxusb_module_params.max_packet_count=default_param_max_packet_count; 622 623 switch(phy_utmi_width) 624 { 625 case 8: 626 case 16: 627 ifxusb_module_params.phy_utmi_width=phy_utmi_width; 628 break; 629 default: 630 ifxusb_module_params.phy_utmi_width=default_param_phy_utmi_width; 631 } 632 633 if(turn_around_time_hs>=0 && turn_around_time_hs<=7) 634 ifxusb_module_params.turn_around_time_hs=turn_around_time_hs; 635 else 636 ifxusb_module_params.turn_around_time_hs=default_param_turn_around_time_hs; 637 638 if(turn_around_time_fs>=0 && turn_around_time_fs<=7) 639 ifxusb_module_params.turn_around_time_fs=turn_around_time_fs; 640 else 641 ifxusb_module_params.turn_around_time_fs=default_param_turn_around_time_fs; 642 643 if(timeout_cal_hs>=0 && timeout_cal_hs<=7) 644 ifxusb_module_params.timeout_cal_hs=timeout_cal_hs; 645 else 646 ifxusb_module_params.timeout_cal_hs=default_param_timeout_cal_hs; 647 648 if(timeout_cal_fs>=0 && timeout_cal_fs<=7) 649 ifxusb_module_params.timeout_cal_fs=timeout_cal_fs; 650 else 651 ifxusb_module_params.timeout_cal_fs=default_param_timeout_cal_fs; 652 653 if(data_fifo_size>=32 && data_fifo_size<=32768) 654 ifxusb_module_params.data_fifo_size=data_fifo_size; 655 else 656 ifxusb_module_params.data_fifo_size=default_param_data_fifo_size; 657 658 #ifdef __IS_HOST__ 659 if(host_channels>=1 && host_channels<=16) 660 ifxusb_module_params.host_channels=host_channels; 661 else 662 ifxusb_module_params.host_channels=default_param_host_channels; 663 664 if(rx_fifo_size>=16 && rx_fifo_size<=32768) 665 ifxusb_module_params.rx_fifo_size=rx_fifo_size; 666 else 667 ifxusb_module_params.rx_fifo_size=default_param_rx_fifo_size; 668 669 if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768) 670 ifxusb_module_params.nperio_tx_fifo_size=nperio_tx_fifo_size; 671 else 672 ifxusb_module_params.nperio_tx_fifo_size=default_param_nperio_tx_fifo_size; 673 674 if(perio_tx_fifo_size>=16 && perio_tx_fifo_size<=32768) 675 ifxusb_module_params.perio_tx_fifo_size=perio_tx_fifo_size; 676 else 677 ifxusb_module_params.perio_tx_fifo_size=default_param_perio_tx_fifo_size; 678 #endif //__IS_HOST__ 679 680 #ifdef __IS_DEVICE__ 681 if(rx_fifo_size>=16 && rx_fifo_size<=32768) 682 ifxusb_module_params.rx_fifo_size=rx_fifo_size; 683 else 684 ifxusb_module_params.rx_fifo_size=default_param_rx_fifo_size; 685 #ifdef __DED_FIFO__ 686 if(tx_fifo_size_00>=16 && tx_fifo_size_00<=32768) 687 ifxusb_module_params.tx_fifo_size[ 0]=tx_fifo_size_00; 688 else 689 ifxusb_module_params.tx_fifo_size[ 0]=default_param_tx_fifo_size_00; 690 if(tx_fifo_size_01>=0 && tx_fifo_size_01<=32768) 691 ifxusb_module_params.tx_fifo_size[ 1]=tx_fifo_size_01; 692 else 693 ifxusb_module_params.tx_fifo_size[ 1]=default_param_tx_fifo_size_01; 694 if(tx_fifo_size_02>=0 && tx_fifo_size_02<=32768) 695 ifxusb_module_params.tx_fifo_size[ 2]=tx_fifo_size_02; 696 else 697 ifxusb_module_params.tx_fifo_size[ 2]=default_param_tx_fifo_size_02; 698 if(tx_fifo_size_03>=0 && tx_fifo_size_03<=32768) 699 ifxusb_module_params.tx_fifo_size[ 3]=tx_fifo_size_03; 700 else 701 ifxusb_module_params.tx_fifo_size[ 3]=default_param_tx_fifo_size_03; 702 if(tx_fifo_size_04>=0 && tx_fifo_size_04<=32768) 703 ifxusb_module_params.tx_fifo_size[ 4]=tx_fifo_size_04; 704 else 705 ifxusb_module_params.tx_fifo_size[ 4]=default_param_tx_fifo_size_04; 706 if(tx_fifo_size_05>=0 && tx_fifo_size_05<=32768) 707 ifxusb_module_params.tx_fifo_size[ 5]=tx_fifo_size_05; 708 else 709 ifxusb_module_params.tx_fifo_size[ 5]=default_param_tx_fifo_size_05; 710 if(tx_fifo_size_06>=0 && tx_fifo_size_06<=32768) 711 ifxusb_module_params.tx_fifo_size[ 6]=tx_fifo_size_06; 712 else 713 ifxusb_module_params.tx_fifo_size[ 6]=default_param_tx_fifo_size_06; 714 if(tx_fifo_size_07>=0 && tx_fifo_size_07<=32768) 715 ifxusb_module_params.tx_fifo_size[ 7]=tx_fifo_size_07; 716 else 717 ifxusb_module_params.tx_fifo_size[ 7]=default_param_tx_fifo_size_07; 718 if(tx_fifo_size_08>=0 && tx_fifo_size_08<=32768) 719 ifxusb_module_params.tx_fifo_size[ 8]=tx_fifo_size_08; 720 else 721 ifxusb_module_params.tx_fifo_size[ 8]=default_param_tx_fifo_size_08; 722 if(tx_fifo_size_09>=0 && tx_fifo_size_09<=32768) 723 ifxusb_module_params.tx_fifo_size[ 9]=tx_fifo_size_09; 724 else 725 ifxusb_module_params.tx_fifo_size[ 9]=default_param_tx_fifo_size_09; 726 if(tx_fifo_size_10>=0 && tx_fifo_size_10<=32768) 727 ifxusb_module_params.tx_fifo_size[10]=tx_fifo_size_10; 728 else 729 ifxusb_module_params.tx_fifo_size[10]=default_param_tx_fifo_size_10; 730 if(tx_fifo_size_11>=0 && tx_fifo_size_11<=32768) 731 ifxusb_module_params.tx_fifo_size[11]=tx_fifo_size_11; 732 else 733 ifxusb_module_params.tx_fifo_size[11]=default_param_tx_fifo_size_11; 734 if(tx_fifo_size_12>=0 && tx_fifo_size_12<=32768) 735 ifxusb_module_params.tx_fifo_size[12]=tx_fifo_size_12; 736 else 737 ifxusb_module_params.tx_fifo_size[12]=default_param_tx_fifo_size_12; 738 if(tx_fifo_size_13>=0 && tx_fifo_size_13<=32768) 739 ifxusb_module_params.tx_fifo_size[13]=tx_fifo_size_13; 740 else 741 ifxusb_module_params.tx_fifo_size[13]=default_param_tx_fifo_size_13; 742 if(tx_fifo_size_14>=0 && tx_fifo_size_14<=32768) 743 ifxusb_module_params.tx_fifo_size[14]=tx_fifo_size_14; 744 else 745 ifxusb_module_params.tx_fifo_size[14]=default_param_tx_fifo_size_14; 746 if(tx_fifo_size_15>=0 && tx_fifo_size_15<=32768) 747 ifxusb_module_params.tx_fifo_size[15]=tx_fifo_size_15; 748 else 749 ifxusb_module_params.tx_fifo_size[15]=default_param_tx_fifo_size_15; 750 if(thr_ctl==0 || thr_ctl==1) 751 ifxusb_module_params.thr_ctl=thr_ctl; 752 else 753 ifxusb_module_params.thr_ctl=default_param_thr_ctl; 754 if(tx_thr_length>=16 && tx_thr_length<=511) 755 ifxusb_module_params.tx_thr_length=tx_thr_length; 756 else 757 ifxusb_module_params.tx_thr_length=default_param_tx_thr_length; 758 if(rx_thr_length>=16 && rx_thr_length<=511) 759 ifxusb_module_params.rx_thr_length=rx_thr_length; 760 else 761 ifxusb_module_params.rx_thr_length=default_param_rx_thr_length; 762 #else //__DED_FIFO__ 763 if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768) 764 ifxusb_module_params.tx_fifo_size[ 0]=nperio_tx_fifo_size; 765 else 766 ifxusb_module_params.tx_fifo_size[ 0]=default_param_nperio_tx_fifo_size; 767 if(perio_tx_fifo_size_01>=0 && perio_tx_fifo_size_01<=32768) 768 ifxusb_module_params.tx_fifo_size[ 1]=perio_tx_fifo_size_01; 769 else 770 ifxusb_module_params.tx_fifo_size[ 1]=default_param_perio_tx_fifo_size_01; 771 if(perio_tx_fifo_size_02>=0 && perio_tx_fifo_size_02<=32768) 772 ifxusb_module_params.tx_fifo_size[ 2]=perio_tx_fifo_size_02; 773 else 774 ifxusb_module_params.tx_fifo_size[ 2]=default_param_perio_tx_fifo_size_02; 775 if(perio_tx_fifo_size_03>=0 && perio_tx_fifo_size_03<=32768) 776 ifxusb_module_params.tx_fifo_size[ 3]=perio_tx_fifo_size_03; 777 else 778 ifxusb_module_params.tx_fifo_size[ 3]=default_param_perio_tx_fifo_size_03; 779 if(perio_tx_fifo_size_04>=0 && perio_tx_fifo_size_04<=32768) 780 ifxusb_module_params.tx_fifo_size[ 4]=perio_tx_fifo_size_04; 781 else 782 ifxusb_module_params.tx_fifo_size[ 4]=default_param_perio_tx_fifo_size_04; 783 if(perio_tx_fifo_size_05>=0 && perio_tx_fifo_size_05<=32768) 784 ifxusb_module_params.tx_fifo_size[ 5]=perio_tx_fifo_size_05; 785 else 786 ifxusb_module_params.tx_fifo_size[ 5]=default_param_perio_tx_fifo_size_05; 787 if(perio_tx_fifo_size_06>=0 && perio_tx_fifo_size_06<=32768) 788 ifxusb_module_params.tx_fifo_size[ 6]=perio_tx_fifo_size_06; 789 else 790 ifxusb_module_params.tx_fifo_size[ 6]=default_param_perio_tx_fifo_size_06; 791 if(perio_tx_fifo_size_07>=0 && perio_tx_fifo_size_07<=32768) 792 ifxusb_module_params.tx_fifo_size[ 7]=perio_tx_fifo_size_07; 793 else 794 ifxusb_module_params.tx_fifo_size[ 7]=default_param_perio_tx_fifo_size_07; 795 if(perio_tx_fifo_size_08>=0 && perio_tx_fifo_size_08<=32768) 796 ifxusb_module_params.tx_fifo_size[ 8]=perio_tx_fifo_size_08; 797 else 798 ifxusb_module_params.tx_fifo_size[ 8]=default_param_perio_tx_fifo_size_08; 799 if(perio_tx_fifo_size_09>=0 && perio_tx_fifo_size_09<=32768) 800 ifxusb_module_params.tx_fifo_size[ 9]=perio_tx_fifo_size_09; 801 else 802 ifxusb_module_params.tx_fifo_size[ 9]=default_param_perio_tx_fifo_size_09; 803 if(perio_tx_fifo_size_10>=0 && perio_tx_fifo_size_10<=32768) 804 ifxusb_module_params.tx_fifo_size[10]=perio_tx_fifo_size_10; 805 else 806 ifxusb_module_params.tx_fifo_size[10]=default_param_perio_tx_fifo_size_10; 807 if(perio_tx_fifo_size_11>=0 && perio_tx_fifo_size_11<=32768) 808 ifxusb_module_params.tx_fifo_size[11]=perio_tx_fifo_size_11; 809 else 810 ifxusb_module_params.tx_fifo_size[11]=default_param_perio_tx_fifo_size_11; 811 if(perio_tx_fifo_size_12>=0 && perio_tx_fifo_size_12<=32768) 812 ifxusb_module_params.tx_fifo_size[12]=perio_tx_fifo_size_12; 813 else 814 ifxusb_module_params.tx_fifo_size[12]=default_param_perio_tx_fifo_size_12; 815 if(perio_tx_fifo_size_13>=0 && perio_tx_fifo_size_13<=32768) 816 ifxusb_module_params.tx_fifo_size[13]=perio_tx_fifo_size_13; 817 else 818 ifxusb_module_params.tx_fifo_size[13]=default_param_perio_tx_fifo_size_13; 819 if(perio_tx_fifo_size_14>=0 && perio_tx_fifo_size_14<=32768) 820 ifxusb_module_params.tx_fifo_size[14]=perio_tx_fifo_size_14; 821 else 822 ifxusb_module_params.tx_fifo_size[14]=default_param_perio_tx_fifo_size_14; 823 if(perio_tx_fifo_size_15>=0 && perio_tx_fifo_size_15<=32768) 824 ifxusb_module_params.tx_fifo_size[15]=perio_tx_fifo_size_15; 825 else 826 ifxusb_module_params.tx_fifo_size[15]=default_param_perio_tx_fifo_size_15; 827 #endif //__DED_FIFO__ 828 #endif //__IS_DEVICE__ 829} 830 831 832 833 834 835 836 837module_param(dbg_lvl, long, 0444); 838MODULE_PARM_DESC(dbg_lvl, "Debug level."); 839 840module_param(dma_burst_size, short, 0444); 841MODULE_PARM_DESC(dma_burst_size, "DMA Burst Size 0, 1, 4, 8, 16"); 842 843module_param(speed, short, 0444); 844MODULE_PARM_DESC(speed, "Speed 0=High Speed 1=Full Speed"); 845 846module_param(data_fifo_size, long, 0444); 847MODULE_PARM_DESC(data_fifo_size, "Total number of words in the data FIFO memory 32-32768"); 848 849#ifdef __IS_DEVICE__ 850 module_param(rx_fifo_size, long, 0444); 851 MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768"); 852 853 #ifdef __DED_FIFO__ 854 module_param(tx_fifo_size_00, long, 0444); 855 MODULE_PARM_DESC(tx_fifo_size_00, "Number of words in the Tx FIFO #00 16-32768"); 856 module_param(tx_fifo_size_01, long, 0444); 857 MODULE_PARM_DESC(tx_fifo_size_01, "Number of words in the Tx FIFO #01 0-32768"); 858 module_param(tx_fifo_size_02, long, 0444); 859 MODULE_PARM_DESC(tx_fifo_size_02, "Number of words in the Tx FIFO #02 0-32768"); 860 module_param(tx_fifo_size_03, long, 0444); 861 MODULE_PARM_DESC(tx_fifo_size_03, "Number of words in the Tx FIFO #03 0-32768"); 862 module_param(tx_fifo_size_04, long, 0444); 863 MODULE_PARM_DESC(tx_fifo_size_04, "Number of words in the Tx FIFO #04 0-32768"); 864 module_param(tx_fifo_size_05, long, 0444); 865 MODULE_PARM_DESC(tx_fifo_size_05, "Number of words in the Tx FIFO #05 0-32768"); 866 module_param(tx_fifo_size_06, long, 0444); 867 MODULE_PARM_DESC(tx_fifo_size_06, "Number of words in the Tx FIFO #06 0-32768"); 868 module_param(tx_fifo_size_07, long, 0444); 869 MODULE_PARM_DESC(tx_fifo_size_07, "Number of words in the Tx FIFO #07 0-32768"); 870 module_param(tx_fifo_size_08, long, 0444); 871 MODULE_PARM_DESC(tx_fifo_size_08, "Number of words in the Tx FIFO #08 0-32768"); 872 module_param(tx_fifo_size_09, long, 0444); 873 MODULE_PARM_DESC(tx_fifo_size_09, "Number of words in the Tx FIFO #09 0-32768"); 874 module_param(tx_fifo_size_10, long, 0444); 875 MODULE_PARM_DESC(tx_fifo_size_10, "Number of words in the Tx FIFO #10 0-32768"); 876 module_param(tx_fifo_size_11, long, 0444); 877 MODULE_PARM_DESC(tx_fifo_size_11, "Number of words in the Tx FIFO #11 0-32768"); 878 module_param(tx_fifo_size_12, long, 0444); 879 MODULE_PARM_DESC(tx_fifo_size_12, "Number of words in the Tx FIFO #12 0-32768"); 880 module_param(tx_fifo_size_13, long, 0444); 881 MODULE_PARM_DESC(tx_fifo_size_13, "Number of words in the Tx FIFO #13 0-32768"); 882 module_param(tx_fifo_size_14, long, 0444); 883 MODULE_PARM_DESC(tx_fifo_size_14, "Number of words in the Tx FIFO #14 0-32768"); 884 module_param(tx_fifo_size_15, long, 0444); 885 MODULE_PARM_DESC(tx_fifo_size_15, "Number of words in the Tx FIFO #15 0-32768"); 886 887 module_param(thr_ctl, short, 0444); 888 MODULE_PARM_DESC(thr_ctl, "0=Without 1=With Theshold Ctrl"); 889 890 module_param(tx_thr_length, long, 0444); 891 MODULE_PARM_DESC(tx_thr_length, "TX Threshold length"); 892 893 module_param(rx_thr_length, long, 0444); 894 MODULE_PARM_DESC(rx_thr_length, "RX Threshold length"); 895 896 #else 897 module_param(nperio_tx_fifo_size, long, 0444); 898 MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768"); 899 900 module_param(perio_tx_fifo_size_01, long, 0444); 901 MODULE_PARM_DESC(perio_tx_fifo_size_01, "Number of words in the periodic Tx FIFO #01 0-32768"); 902 module_param(perio_tx_fifo_size_02, long, 0444); 903 MODULE_PARM_DESC(perio_tx_fifo_size_02, "Number of words in the periodic Tx FIFO #02 0-32768"); 904 module_param(perio_tx_fifo_size_03, long, 0444); 905 MODULE_PARM_DESC(perio_tx_fifo_size_03, "Number of words in the periodic Tx FIFO #03 0-32768"); 906 module_param(perio_tx_fifo_size_04, long, 0444); 907 MODULE_PARM_DESC(perio_tx_fifo_size_04, "Number of words in the periodic Tx FIFO #04 0-32768"); 908 module_param(perio_tx_fifo_size_05, long, 0444); 909 MODULE_PARM_DESC(perio_tx_fifo_size_05, "Number of words in the periodic Tx FIFO #05 0-32768"); 910 module_param(perio_tx_fifo_size_06, long, 0444); 911 MODULE_PARM_DESC(perio_tx_fifo_size_06, "Number of words in the periodic Tx FIFO #06 0-32768"); 912 module_param(perio_tx_fifo_size_07, long, 0444); 913 MODULE_PARM_DESC(perio_tx_fifo_size_07, "Number of words in the periodic Tx FIFO #07 0-32768"); 914 module_param(perio_tx_fifo_size_08, long, 0444); 915 MODULE_PARM_DESC(perio_tx_fifo_size_08, "Number of words in the periodic Tx FIFO #08 0-32768"); 916 module_param(perio_tx_fifo_size_09, long, 0444); 917 MODULE_PARM_DESC(perio_tx_fifo_size_09, "Number of words in the periodic Tx FIFO #09 0-32768"); 918 module_param(perio_tx_fifo_size_10, long, 0444); 919 MODULE_PARM_DESC(perio_tx_fifo_size_10, "Number of words in the periodic Tx FIFO #10 0-32768"); 920 module_param(perio_tx_fifo_size_11, long, 0444); 921 MODULE_PARM_DESC(perio_tx_fifo_size_11, "Number of words in the periodic Tx FIFO #11 0-32768"); 922 module_param(perio_tx_fifo_size_12, long, 0444); 923 MODULE_PARM_DESC(perio_tx_fifo_size_12, "Number of words in the periodic Tx FIFO #12 0-32768"); 924 module_param(perio_tx_fifo_size_13, long, 0444); 925 MODULE_PARM_DESC(perio_tx_fifo_size_13, "Number of words in the periodic Tx FIFO #13 0-32768"); 926 module_param(perio_tx_fifo_size_14, long, 0444); 927 MODULE_PARM_DESC(perio_tx_fifo_size_14, "Number of words in the periodic Tx FIFO #14 0-32768"); 928 module_param(perio_tx_fifo_size_15, long, 0444); 929 MODULE_PARM_DESC(perio_tx_fifo_size_15, "Number of words in the periodic Tx FIFO #15 0-32768"); 930 #endif//__DED_FIFO__ 931 module_param(dev_endpoints, short, 0444); 932 MODULE_PARM_DESC(dev_endpoints, "The number of endpoints in addition to EP0 available for device mode 1-15"); 933#endif 934 935#ifdef __IS_HOST__ 936 module_param(rx_fifo_size, long, 0444); 937 MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768"); 938 939 module_param(nperio_tx_fifo_size, long, 0444); 940 MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768"); 941 942 module_param(perio_tx_fifo_size, long, 0444); 943 MODULE_PARM_DESC(perio_tx_fifo_size, "Number of words in the host periodic Tx FIFO 16-32768"); 944 945 module_param(host_channels, short, 0444); 946 MODULE_PARM_DESC(host_channels, "The number of host channel registers to use 1-16"); 947#endif 948 949module_param(max_transfer_size, long, 0444); 950MODULE_PARM_DESC(max_transfer_size, "The maximum transfer size supported in bytes 2047-65535"); 951 952module_param(max_packet_count, long, 0444); 953MODULE_PARM_DESC(max_packet_count, "The maximum number of packets in a transfer 15-511"); 954 955module_param(phy_utmi_width, long, 0444); 956MODULE_PARM_DESC(phy_utmi_width, "Specifies the UTMI+ Data Width 8 or 16 bits"); 957 958module_param(turn_around_time_hs, long, 0444); 959MODULE_PARM_DESC(turn_around_time_hs, "Turn-Around time for HS"); 960 961module_param(turn_around_time_fs, long, 0444); 962MODULE_PARM_DESC(turn_around_time_fs, "Turn-Around time for FS"); 963 964module_param(timeout_cal_hs, long, 0444); 965MODULE_PARM_DESC(timeout_cal_hs, "Timeout Cal for HS"); 966 967module_param(timeout_cal_fs, long, 0444); 968MODULE_PARM_DESC(timeout_cal_fs, "Timeout Cal for FS"); 969 970 971