| 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 | u32 port_mask = 0x1; |
| 309 | |
| 310 | #ifdef __IS_DANUBE__ |
| 311 | np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-danube"); |
| 312 | #elif defined __IS_AMAZON_SE__ |
| 313 | np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-ase"); |
| 314 | #elif defined __IS_AR9__ |
| 315 | np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-arx100"); |
| 316 | #elif defined __IS_VR9__ |
| 317 | np = of_find_compatible_node(NULL, NULL, "lantiq,ifxhcd-xrx200"); |
| 318 | #endif |
| 319 | if (!np) { |
| 320 | dev_err(&_pdev->dev, "failed to find hcd device node\n"); |
| 321 | return -ENODEV; |
| 322 | } |
| 323 | of_property_read_u32(np, "lantiq,portmask", &port_mask); |
| 324 | // Parsing and store the parameters |
| 325 | IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); |
| 326 | parse_parms(); |
| 327 | |
| 328 | #ifdef __IS_HOST__ |
| 329 | #if defined(__DO_OC_INT__) |
| 330 | if(!oc_int_id) |
| 331 | { |
| 332 | #if defined(__IS_DUAL__) |
| 333 | oc_int_id=&ifxusb_hcd_1; |
| 334 | oc_int_id_1=&ifxusb_hcd_1; |
| 335 | oc_int_id_2=&ifxusb_hcd_2; |
| 336 | #else |
| 337 | oc_int_id=&ifxusb_hcd; |
| 338 | #endif |
| 339 | } |
| 340 | #endif |
| 341 | |
| 342 | #if defined(__IS_DUAL__) |
| 343 | memset(&ifxusb_hcd_1, 0, sizeof(ifxhcd_hcd_t)); |
| 344 | memset(&ifxusb_hcd_2, 0, sizeof(ifxhcd_hcd_t)); |
| 345 | |
| 346 | ifxusb_hcd_1.core_if.core_no=0; |
| 347 | ifxusb_hcd_2.core_if.core_no=1; |
| 348 | ifxusb_hcd_1.core_if.core_name=(char *)ifxusb_hcd_name_1; |
| 349 | ifxusb_hcd_2.core_if.core_name=(char *)ifxusb_hcd_name_2; |
| 350 | |
| 351 | ifxusb_hcd_1.dev=&_pdev->dev; |
| 352 | ifxusb_hcd_2.dev=&_pdev->dev; |
| 353 | |
| 354 | if (port_mask & 0x1) { |
| 355 | retval = ifxusb_driver_probe_h(&ifxusb_hcd_1, |
| 356 | IFXUSB1_IRQ, |
| 357 | IFXUSB1_IOMEM_BASE, |
| 358 | IFXUSB1_FIFOMEM_BASE, |
| 359 | IFXUSB1_FIFODBG_BASE |
| 360 | ); |
| 361 | if(retval) |
| 362 | goto ifxusb_driver_probe_fail; |
| 363 | } |
| 364 | |
| 365 | if (port_mask & 0x2) { |
| 366 | retval = ifxusb_driver_probe_h(&ifxusb_hcd_2, |
| 367 | IFXUSB2_IRQ, |
| 368 | IFXUSB2_IOMEM_BASE, |
| 369 | IFXUSB2_FIFOMEM_BASE, |
| 370 | IFXUSB2_FIFODBG_BASE |
| 371 | ); |
| 372 | if(retval) |
| 373 | goto ifxusb_driver_probe_fail; |
| 374 | } |
| 375 | #elif defined(__IS_FIRST__) |
| 376 | memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t)); |
| 377 | |
| 378 | ifxusb_hcd.core_if.core_no=0; |
| 379 | ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name; |
| 380 | |
| 381 | ifxusb_hcd.dev=&_pdev->dev; |
| 382 | |
| 383 | retval = ifxusb_driver_probe_h(&ifxusb_hcd, |
| 384 | IFXUSB1_IRQ, |
| 385 | IFXUSB1_IOMEM_BASE, |
| 386 | IFXUSB1_FIFOMEM_BASE, |
| 387 | IFXUSB1_FIFODBG_BASE |
| 388 | ); |
| 389 | if(retval) |
| 390 | goto ifxusb_driver_probe_fail; |
| 391 | |
| 392 | #elif defined(__IS_SECOND__) |
| 393 | memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t)); |
| 394 | |
| 395 | ifxusb_hcd.core_if.core_no=1; |
| 396 | ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name; |
| 397 | |
| 398 | ifxusb_hcd.dev=&_pdev->dev; |
| 399 | |
| 400 | retval = ifxusb_driver_probe_h(&ifxusb_hcd, |
| 401 | IFXUSB2_IRQ, |
| 402 | IFXUSB2_IOMEM_BASE, |
| 403 | IFXUSB2_FIFOMEM_BASE, |
| 404 | IFXUSB2_FIFODBG_BASE |
| 405 | ); |
| 406 | if(retval) |
| 407 | goto ifxusb_driver_probe_fail; |
| 408 | |
| 409 | #else |
| 410 | memset(&ifxusb_hcd, 0, sizeof(ifxhcd_hcd_t)); |
| 411 | |
| 412 | ifxusb_hcd.core_if.core_no=0; |
| 413 | ifxusb_hcd.core_if.core_name=(char *)ifxusb_hcd_name; |
| 414 | |
| 415 | ifxusb_hcd.dev=&_pdev->dev; |
| 416 | |
| 417 | retval = ifxusb_driver_probe_h(&ifxusb_hcd, |
| 418 | IFXUSB_IRQ, |
| 419 | IFXUSB_IOMEM_BASE, |
| 420 | IFXUSB_FIFOMEM_BASE, |
| 421 | IFXUSB_FIFODBG_BASE |
| 422 | ); |
| 423 | if(retval) |
| 424 | goto ifxusb_driver_probe_fail; |
| 425 | #endif |
| 426 | #endif |
| 427 | |
| 428 | #ifdef __IS_DEVICE__ |
| 429 | memset(&ifxusb_pcd, 0, sizeof(ifxpcd_pcd_t)); |
| 430 | ifxusb_pcd.core_if.core_name=(char *)&ifxusb_pcd_name[0]; |
| 431 | |
| 432 | ifxusb_pcd.dev=&_pdev->dev; |
| 433 | |
| 434 | #if defined(__IS_FIRST__) |
| 435 | ifxusb_pcd.core_if.core_no=0; |
| 436 | retval = ifxusb_driver_probe_d(&ifxusb_pcd, |
| 437 | IFXUSB1_IRQ, |
| 438 | IFXUSB1_IOMEM_BASE, |
| 439 | IFXUSB1_FIFOMEM_BASE, |
| 440 | IFXUSB1_FIFODBG_BASE |
| 441 | ); |
| 442 | #elif defined(__IS_SECOND__) |
| 443 | ifxusb_pcd.core_if.core_no=1; |
| 444 | retval = ifxusb_driver_probe_d(&ifxusb_pcd, |
| 445 | IFXUSB2_IRQ, |
| 446 | IFXUSB2_IOMEM_BASE, |
| 447 | IFXUSB2_FIFOMEM_BASE, |
| 448 | IFXUSB2_FIFODBG_BASE |
| 449 | ); |
| 450 | #else |
| 451 | ifxusb_pcd.core_if.core_no=0; |
| 452 | retval = ifxusb_driver_probe_d(&ifxusb_pcd, |
| 453 | IFXUSB_IRQ, |
| 454 | IFXUSB_IOMEM_BASE, |
| 455 | IFXUSB_FIFOMEM_BASE, |
| 456 | IFXUSB_FIFODBG_BASE |
| 457 | ); |
| 458 | #endif |
| 459 | if(retval) |
| 460 | goto ifxusb_driver_probe_fail; |
| 461 | #endif |
| 462 | |
| 463 | #ifdef __IS_HOST__ |
| 464 | ifxusb_attr_create_h(&_pdev->dev); |
| 465 | #else |
| 466 | ifxusb_attr_create_d(&_pdev->dev); |
| 467 | #endif |
| 468 | |
| 469 | gpio_count = of_gpio_count(np); |
| 470 | while (gpio_count) { |
| 471 | enum of_gpio_flags flags; |
| 472 | int gpio = of_get_gpio_flags(np, --gpio_count, &flags); |
| 473 | if (gpio_request(gpio, "usb")) |
| 474 | continue; |
| 475 | dev_info(&_pdev->dev, "requested GPIO %d\n", gpio); |
| 476 | gpio_direction_output(gpio, (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1)); |
| 477 | } |
| 478 | |
| 479 | |
| 480 | return 0; |
| 481 | |
| 482 | ifxusb_driver_probe_fail: |
| 483 | ifxusb_driver_remove(_pdev); |
| 484 | return retval; |
| 485 | } |
| 486 | |
| 487 | static struct resource ifxusb_device_resources[] = |
| 488 | { |
| 489 | #if defined(__IS_DUAL__) |
| 490 | [0] = { .start = IFXUSB1_IRQ, |
| 491 | .flags = IORESOURCE_IRQ, |
| 492 | }, |
| 493 | [1] = { .start = IFXUSB1_IOMEM_BASE, |
| 494 | .end = IFXUSB1_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1, |
| 495 | .flags = IORESOURCE_MEM, |
| 496 | }, |
| 497 | [2] = { .start = IFXUSB2_IRQ, |
| 498 | .flags = IORESOURCE_IRQ, |
| 499 | }, |
| 500 | [3] = { .start = IFXUSB2_IOMEM_BASE, |
| 501 | .end = IFXUSB2_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1, |
| 502 | .flags = IORESOURCE_MEM, |
| 503 | }, |
| 504 | [4] = { .start = IFXUSB1_FIFOMEM_BASE, |
| 505 | .end = IFXUSB1_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1, |
| 506 | .flags = IORESOURCE_MEM, |
| 507 | }, |
| 508 | [5] = { .start = IFXUSB2_FIFOMEM_BASE, |
| 509 | .end = IFXUSB2_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1, |
| 510 | .flags = IORESOURCE_MEM, |
| 511 | }, |
| 512 | [6] = { .start = IFXUSB1_FIFODBG_BASE, |
| 513 | .end = IFXUSB1_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1, |
| 514 | .flags = IORESOURCE_MEM, |
| 515 | }, |
| 516 | [7] = { .start = IFXUSB2_FIFODBG_BASE, |
| 517 | .end = IFXUSB2_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1, |
| 518 | .flags = IORESOURCE_MEM, |
| 519 | }, |
| 520 | #elif defined(__IS_FIRST__) |
| 521 | [0] = { .start = IFXUSB1_IRQ, |
| 522 | .flags = IORESOURCE_IRQ, |
| 523 | }, |
| 524 | [1] = { .start = IFXUSB1_IOMEM_BASE, |
| 525 | .end = IFXUSB1_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1, |
| 526 | .flags = IORESOURCE_MEM, |
| 527 | }, |
| 528 | [2] = { .start = IFXUSB1_FIFOMEM_BASE, |
| 529 | .end = IFXUSB1_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1, |
| 530 | .flags = IORESOURCE_MEM, |
| 531 | }, |
| 532 | [3] = { .start = IFXUSB1_FIFODBG_BASE, |
| 533 | .end = IFXUSB1_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1, |
| 534 | .flags = IORESOURCE_MEM, |
| 535 | }, |
| 536 | #elif defined(__IS_SECOND__) |
| 537 | [0] = { .start = IFXUSB2_IRQ, |
| 538 | .flags = IORESOURCE_IRQ, |
| 539 | }, |
| 540 | [1] = { .start = IFXUSB2_IOMEM_BASE, |
| 541 | .end = IFXUSB2_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1, |
| 542 | .flags = IORESOURCE_MEM, |
| 543 | }, |
| 544 | [2] = { .start = IFXUSB2_FIFOMEM_BASE, |
| 545 | .end = IFXUSB2_FIFOMEM_BASE + IFXUSB_FIFOMEM_SIZE-1, |
| 546 | .flags = IORESOURCE_MEM, |
| 547 | }, |
| 548 | [3] = { .start = IFXUSB2_FIFODBG_BASE, |
| 549 | .end = IFXUSB2_FIFODBG_BASE + IFXUSB_FIFODBG_SIZE-1, |
| 550 | .flags = IORESOURCE_MEM, |
| 551 | }, |
| 552 | #else |
| 553 | [0] = { .start = IFXUSB_IRQ, |
| 554 | .flags = IORESOURCE_IRQ, |
| 555 | }, |
| 556 | [1] = { .start = IFXUSB_IOMEM_BASE, |
| 557 | .end = IFXUSB_IOMEM_BASE + IFXUSB_IOMEM_SIZE-1, |
| 558 | .flags = IORESOURCE_MEM, |
| 559 | }, |
| 560 | [2] = { .start = IFXUSB_FIFOMEM_BASE, |
| 561 | .end = IFXUSB_FIFOMEM_BASE+IFXUSB_FIFOMEM_SIZE-1, |
| 562 | .flags = IORESOURCE_MEM, |
| 563 | }, |
| 564 | [3] = { .start = IFXUSB_FIFODBG_BASE, |
| 565 | .end = IFXUSB_FIFODBG_BASE+IFXUSB_FIFODBG_SIZE-1, |
| 566 | .flags = IORESOURCE_MEM, |
| 567 | }, |
| 568 | #endif //__IS_DUAL__ |
| 569 | }; |
| 570 | |
| 571 | static u64 ifxusb_dmamask = (u32)0x1fffffff; |
| 572 | |
| 573 | static void ifxusb_device_release(struct device * dev) |
| 574 | { |
| 575 | IFX_PRINT("IFX USB platform_dev release\n"); |
| 576 | dev->parent = NULL; |
| 577 | } |
| 578 | |
| 579 | static struct platform_device ifxusb_device = |
| 580 | { |
| 581 | .id = -1, |
| 582 | .dev = |
| 583 | { |
| 584 | .release = ifxusb_device_release, |
| 585 | .dma_mask = &ifxusb_dmamask, |
| 586 | }, |
| 587 | .resource = ifxusb_device_resources, |
| 588 | .num_resources = ARRAY_SIZE(ifxusb_device_resources), |
| 589 | }; |
| 590 | |
| 591 | |
| 592 | /*! |
| 593 | \brief This function is called when the ifxusb_driver is installed with the insmod command. |
| 594 | */ |
| 595 | static struct platform_driver ifxusb_driver = { |
| 596 | .probe = ifxusb_driver_probe, |
| 597 | .remove = ifxusb_driver_remove, |
| 598 | .driver ={ |
| 599 | .owner = THIS_MODULE, |
| 600 | #ifdef __IS_HOST__ |
| 601 | .name = ifxusb_hcd_driver_name, |
| 602 | #else |
| 603 | .name = ifxusb_pcd_driver_name, |
| 604 | #endif |
| 605 | }, |
| 606 | }; |
| 607 | |
| 608 | #ifdef __IS_HOST__ |
| 609 | int __init ifxusb_hcd_driver_init(void) |
| 610 | #else |
| 611 | int __init ifxusb_pcd_driver_init(void) |
| 612 | #endif |
| 613 | { |
| 614 | int retval = 0; |
| 615 | IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); |
| 616 | #if defined(__IS_HOST__) |
| 617 | IFX_PRINT("%s: version %s\n", ifxusb_hcd_driver_name, IFXUSB_VERSION); |
| 618 | #else |
| 619 | IFX_PRINT("%s: version %s\n", ifxusb_pcd_driver_name, IFXUSB_VERSION); |
| 620 | #endif |
| 621 | |
| 622 | #if 0 |
| 623 | #if defined(__IS_TWINPASS__) |
| 624 | IFX_PRINT(" OPTION: __IS_TWINPASS__\n"); |
| 625 | #elif defined(__IS_DANUBE__) |
| 626 | IFX_PRINT(" OPTION: __IS_DANUBE__\n"); |
| 627 | #elif defined(__IS_AMAZON_SE__) |
| 628 | IFX_PRINT(" OPTION: __IS_AMAZON_SE__\n"); |
| 629 | #elif defined(__IS_AR9__) |
| 630 | IFX_PRINT(" OPTION: __IS_AR9__\n"); |
| 631 | #elif defined(__IS_VR9__) |
| 632 | IFX_PRINT(" OPTION: __IS_VR9__\n"); |
| 633 | #elif defined(__IS_AR10__) |
| 634 | IFX_PRINT(" OPTION: __IS_AR10__\n"); |
| 635 | #else |
| 636 | IFX_PRINT(" OPTION: NO PLATFORM DEFINED\n"); |
| 637 | #endif |
| 638 | |
| 639 | #ifdef __UEIP__ |
| 640 | IFX_PRINT(" OPTION: __UEIP__\n"); |
| 641 | #endif |
| 642 | |
| 643 | #ifdef __PHY_LONG_PREEMP__ |
| 644 | IFX_PRINT(" OPTION: __PHY_LONG_PREEMP__\n"); |
| 645 | #endif |
| 646 | #ifdef __FORCE_USB11__ |
| 647 | IFX_PRINT(" OPTION: __FORCE_USB11__\n"); |
| 648 | #endif |
| 649 | #ifdef __UNALIGNED_BUF_ADJ__ |
| 650 | IFX_PRINT(" OPTION: __UNALIGNED_BUF_ADJ__\n"); |
| 651 | #endif |
| 652 | #ifdef __UNALIGNED_BUF_CHK__ |
| 653 | IFX_PRINT(" OPTION: __UNALIGNED_BUF_CHK__\n"); |
| 654 | #endif |
| 655 | #ifdef __UNALIGNED_BUF_BURST__ |
| 656 | IFX_PRINT(" OPTION: __UNALIGNED_BUF_BURST__\n"); |
| 657 | #endif |
| 658 | #ifdef __DEBUG__ |
| 659 | IFX_PRINT(" OPTION: __DEBUG__\n"); |
| 660 | #endif |
| 661 | #ifdef __ENABLE_DUMP__ |
| 662 | IFX_PRINT(" OPTION: __ENABLE_DUMP__\n"); |
| 663 | #endif |
| 664 | |
| 665 | #ifdef __IS_HOST__ |
| 666 | IFX_PRINT(" OPTION: __IS_HOST__\n"); |
| 667 | #ifdef __IS_DUAL__ |
| 668 | IFX_PRINT(" __IS_DUAL__\n"); |
| 669 | #endif |
| 670 | #ifdef __IS_FIRST__ |
| 671 | IFX_PRINT(" __IS_FIRST__\n"); |
| 672 | #endif |
| 673 | #ifdef __IS_SECOND__ |
| 674 | IFX_PRINT(" __IS_SECOND__\n"); |
| 675 | #endif |
| 676 | #ifdef __WITH_HS_ELECT_TST__ |
| 677 | IFX_PRINT(" __WITH_HS_ELECT_TST__\n"); |
| 678 | #endif |
| 679 | #ifdef __EN_ISOC__ |
| 680 | IFX_PRINT(" __EN_ISOC__\n"); |
| 681 | #endif |
| 682 | #ifdef __EN_ISOC_SPLIT__ |
| 683 | IFX_PRINT(" __EN_ISOC_SPLIT__\n"); |
| 684 | #endif |
| 685 | #ifdef __EPQD_DESTROY_TIMEOUT__ |
| 686 | IFX_PRINT(" __EPQD_DESTROY_TIMEOUT__\n"); |
| 687 | #endif |
| 688 | #ifdef __DYN_SOF_INTR__ |
| 689 | IFX_PRINT(" __DYN_SOF_INTR__\n"); |
| 690 | #endif |
| 691 | #else |
| 692 | IFX_PRINT(" OPTION: __IS_DEVICE__\n"); |
| 693 | #ifdef __DED_INTR__ |
| 694 | IFX_PRINT(" __DED_INTR__\n"); |
| 695 | #endif |
| 696 | #ifdef __DED_FIFO__ |
| 697 | IFX_PRINT(" __DED_FIFO__\n"); |
| 698 | #endif |
| 699 | #ifdef __DESC_DMA__ |
| 700 | IFX_PRINT(" __DESC_DMA__\n"); |
| 701 | #endif |
| 702 | #ifdef __IS_FIRST__ |
| 703 | IFX_PRINT(" __IS_FIRST__\n"); |
| 704 | #endif |
| 705 | #ifdef __IS_SECOND__ |
| 706 | IFX_PRINT(" __IS_SECOND__\n"); |
| 707 | #endif |
| 708 | #ifdef __GADGET_TASKLET_TX__ |
| 709 | IFX_PRINT(" __GADGET_TASKLET_TX__\n"); |
| 710 | #endif |
| 711 | #ifdef __GADGET_TASKLET_RX__ |
| 712 | IFX_PRINT(" __GADGET_TASKLET_RX__\n"); |
| 713 | #endif |
| 714 | #ifdef __GADGET_TASKLET_HIGH__ |
| 715 | IFX_PRINT(" __GADGET_TASKLET_HIGH__\n"); |
| 716 | #endif |
| 717 | #ifdef __DO_PCD_UNLOCK__ |
| 718 | IFX_PRINT(" __DO_PCD_UNLOCK__\n"); |
| 719 | #endif |
| 720 | #ifdef __GADGET_LED__ |
| 721 | IFX_PRINT(" __GADGET_LED__\n"); |
| 722 | #endif |
| 723 | |
| 724 | #ifdef __ECM_NO_INTR__ |
| 725 | IFX_PRINT(" __ECM_NO_INTR__\n"); |
| 726 | #endif |
| 727 | #ifdef __NOSWAPINCTRL__ |
| 728 | IFX_PRINT(" __NOSWAPINCTRL__\n"); |
| 729 | #endif |
| 730 | #ifdef __MAC_ECM_FIX__ |
| 731 | IFX_PRINT(" __MAC_ECM_FIX__\n"); |
| 732 | #endif |
| 733 | #ifdef __RETAIN_BUF_TX__ |
| 734 | IFX_PRINT(" __RETAIN_BUF_TX__\n"); |
| 735 | #endif |
| 736 | #ifdef __RETAIN_BUF_RX__ |
| 737 | IFX_PRINT(" __RETAIN_BUF_RX__\n"); |
| 738 | #endif |
| 739 | #ifdef __QUICKNAK__ |
| 740 | IFX_PRINT(" __QUICKNAK__\n"); |
| 741 | #endif |
| 742 | #endif |
| 743 | #endif |
| 744 | |
| 745 | retval = platform_driver_register(&ifxusb_driver); |
| 746 | |
| 747 | if (retval < 0) { |
| 748 | IFX_ERROR("%s retval=%d\n", __func__, retval); |
| 749 | return retval; |
| 750 | } |
| 751 | |
| 752 | #ifdef __IS_HOST__ |
| 753 | ifxusb_device.name = ifxusb_hcd_driver_name; |
| 754 | #else |
| 755 | ifxusb_device.name = ifxusb_pcd_driver_name; |
| 756 | #endif |
| 757 | |
| 758 | if (ifxusb_device.dev.parent) |
| 759 | retval = -EBUSY; |
| 760 | else |
| 761 | retval = platform_device_register(&ifxusb_device); |
| 762 | |
| 763 | if (retval < 0) |
| 764 | { |
| 765 | IFX_ERROR("%s retval=%d\n", __func__, retval); |
| 766 | platform_driver_unregister(&ifxusb_driver); |
| 767 | return retval; |
| 768 | } |
| 769 | return retval; |
| 770 | } |
| 771 | |
| 772 | #ifdef __IS_HOST__ |
| 773 | module_init(ifxusb_hcd_driver_init); |
| 774 | #else |
| 775 | module_init(ifxusb_pcd_driver_init); |
| 776 | #endif |
| 777 | |
| 778 | /*! |
| 779 | \brief This function is called when the driver is removed from the kernel |
| 780 | with the rmmod command. The driver unregisters itself with its bus |
| 781 | driver. |
| 782 | */ |
| 783 | #ifdef __IS_HOST__ |
| 784 | void __exit ifxusb_hcd_driver_cleanup(void) |
| 785 | { |
| 786 | IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); |
| 787 | platform_device_unregister(&ifxusb_device); |
| 788 | platform_driver_unregister(&ifxusb_driver); |
| 789 | IFX_PRINT("%s module removed\n", ifxusb_hcd_driver_name); |
| 790 | } |
| 791 | module_exit(ifxusb_hcd_driver_cleanup); |
| 792 | #else |
| 793 | void __exit ifxusb_pcd_driver_cleanup(void) |
| 794 | { |
| 795 | IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); |
| 796 | platform_device_unregister(&ifxusb_device); |
| 797 | platform_driver_unregister(&ifxusb_driver); |
| 798 | IFX_PRINT("%s module removed\n", ifxusb_pcd_driver_name); |
| 799 | } |
| 800 | module_exit(ifxusb_pcd_driver_cleanup); |
| 801 | #endif |
| 802 | MODULE_DESCRIPTION(USB_DRIVER_DESC); |
| 803 | MODULE_AUTHOR("Lantiq"); |
| 804 | MODULE_LICENSE("GPL"); |
| 805 | |
| 806 | |
| 807 | |
| 808 | // Parameters set when loaded |
| 809 | //static long dbg_lvl =0xFFFFFFFF; |
| 810 | static long dbg_lvl =0; |
| 811 | static short dma_burst_size =-1; |
| 812 | static short speed =-1; |
| 813 | static long data_fifo_size =-1; |
| 814 | #ifdef __IS_DEVICE__ |
| 815 | static long rx_fifo_size =-1; |
| 816 | #ifdef __DED_FIFO__ |
| 817 | static long tx_fifo_size_00 =-1; |
| 818 | static long tx_fifo_size_01 =-1; |
| 819 | static long tx_fifo_size_02 =-1; |
| 820 | static long tx_fifo_size_03 =-1; |
| 821 | static long tx_fifo_size_04 =-1; |
| 822 | static long tx_fifo_size_05 =-1; |
| 823 | static long tx_fifo_size_06 =-1; |
| 824 | static long tx_fifo_size_07 =-1; |
| 825 | static long tx_fifo_size_08 =-1; |
| 826 | static long tx_fifo_size_09 =-1; |
| 827 | static long tx_fifo_size_10 =-1; |
| 828 | static long tx_fifo_size_11 =-1; |
| 829 | static long tx_fifo_size_12 =-1; |
| 830 | static long tx_fifo_size_13 =-1; |
| 831 | static long tx_fifo_size_14 =-1; |
| 832 | static long tx_fifo_size_15 =-1; |
| 833 | static short thr_ctl=-1; |
| 834 | static long tx_thr_length =-1; |
| 835 | static long rx_thr_length =-1; |
| 836 | #else |
| 837 | static long nperio_tx_fifo_size =-1; |
| 838 | static long perio_tx_fifo_size_01 =-1; |
| 839 | static long perio_tx_fifo_size_02 =-1; |
| 840 | static long perio_tx_fifo_size_03 =-1; |
| 841 | static long perio_tx_fifo_size_04 =-1; |
| 842 | static long perio_tx_fifo_size_05 =-1; |
| 843 | static long perio_tx_fifo_size_06 =-1; |
| 844 | static long perio_tx_fifo_size_07 =-1; |
| 845 | static long perio_tx_fifo_size_08 =-1; |
| 846 | static long perio_tx_fifo_size_09 =-1; |
| 847 | static long perio_tx_fifo_size_10 =-1; |
| 848 | static long perio_tx_fifo_size_11 =-1; |
| 849 | static long perio_tx_fifo_size_12 =-1; |
| 850 | static long perio_tx_fifo_size_13 =-1; |
| 851 | static long perio_tx_fifo_size_14 =-1; |
| 852 | static long perio_tx_fifo_size_15 =-1; |
| 853 | #endif |
| 854 | static short dev_endpoints =-1; |
| 855 | #endif |
| 856 | |
| 857 | #ifdef __IS_HOST__ |
| 858 | static long rx_fifo_size =-1; |
| 859 | static long nperio_tx_fifo_size =-1; |
| 860 | static long perio_tx_fifo_size =-1; |
| 861 | static short host_channels =-1; |
| 862 | #endif |
| 863 | |
| 864 | static long max_transfer_size =-1; |
| 865 | static long max_packet_count =-1; |
| 866 | static long phy_utmi_width =-1; |
| 867 | static long turn_around_time_hs =-1; |
| 868 | static long turn_around_time_fs =-1; |
| 869 | static long timeout_cal_hs =-1; |
| 870 | static long timeout_cal_fs =-1; |
| 871 | |
| 872 | /*! |
| 873 | \brief Parsing the parameters taken when module load |
| 874 | */ |
| 875 | static void parse_parms(void) |
| 876 | { |
| 877 | |
| 878 | ifxusb_params_t *params; |
| 879 | IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); |
| 880 | #ifdef __IS_HOST__ |
| 881 | h_dbg_lvl=dbg_lvl; |
| 882 | params=&ifxusb_module_params_h; |
| 883 | #endif |
| 884 | #ifdef __IS_DEVICE__ |
| 885 | d_dbg_lvl=dbg_lvl; |
| 886 | params=&ifxusb_module_params_d; |
| 887 | #endif |
| 888 | |
| 889 | switch(dma_burst_size) |
| 890 | { |
| 891 | case 0: |
| 892 | case 1: |
| 893 | case 4: |
| 894 | case 8: |
| 895 | case 16: |
| 896 | params->dma_burst_size=dma_burst_size; |
| 897 | break; |
| 898 | default: |
| 899 | #if defined(__IS_VR9__) |
| 900 | { |
| 901 | unsigned int chipid; |
| 902 | unsigned int partnum; |
| 903 | chipid=*((volatile uint32_t *)IFX_MPS_CHIPID); |
| 904 | partnum=(chipid&0x0FFFF000)>>12; |
| 905 | switch(partnum) |
| 906 | { |
| 907 | case 0x000B: //VRX288_A2x |
| 908 | case 0x000E: //VRX282_A2x |
| 909 | case 0x000C: //VRX268_A2x |
| 910 | case 0x000D: //GRX288_A2x |
| 911 | params->dma_burst_size=default_param_dma_burst_size_n; |
| 912 | break; |
| 913 | default: |
| 914 | params->dma_burst_size=default_param_dma_burst_size; |
| 915 | } |
| 916 | printk(KERN_INFO "Chip Version :%04x BurstSize=%d\n",partnum,params->dma_burst_size); |
| 917 | } |
| 918 | #else |
| 919 | params->dma_burst_size=default_param_dma_burst_size; |
| 920 | #endif |
| 921 | } |
| 922 | |
| 923 | if(speed==0 || speed==1) |
| 924 | params->speed=speed; |
| 925 | else |
| 926 | params->speed=default_param_speed; |
| 927 | |
| 928 | if(max_transfer_size>=2048 && max_transfer_size<=65535) |
| 929 | params->max_transfer_size=max_transfer_size; |
| 930 | else |
| 931 | params->max_transfer_size=default_param_max_transfer_size; |
| 932 | |
| 933 | if(max_packet_count>=15 && max_packet_count<=511) |
| 934 | params->max_packet_count=max_packet_count; |
| 935 | else |
| 936 | params->max_packet_count=default_param_max_packet_count; |
| 937 | |
| 938 | switch(phy_utmi_width) |
| 939 | { |
| 940 | case 8: |
| 941 | case 16: |
| 942 | params->phy_utmi_width=phy_utmi_width; |
| 943 | break; |
| 944 | default: |
| 945 | params->phy_utmi_width=default_param_phy_utmi_width; |
| 946 | } |
| 947 | |
| 948 | if(turn_around_time_hs>=0 && turn_around_time_hs<=7) |
| 949 | params->turn_around_time_hs=turn_around_time_hs; |
| 950 | else |
| 951 | params->turn_around_time_hs=default_param_turn_around_time_hs; |
| 952 | |
| 953 | if(turn_around_time_fs>=0 && turn_around_time_fs<=7) |
| 954 | params->turn_around_time_fs=turn_around_time_fs; |
| 955 | else |
| 956 | params->turn_around_time_fs=default_param_turn_around_time_fs; |
| 957 | |
| 958 | if(timeout_cal_hs>=0 && timeout_cal_hs<=7) |
| 959 | params->timeout_cal_hs=timeout_cal_hs; |
| 960 | else |
| 961 | params->timeout_cal_hs=default_param_timeout_cal_hs; |
| 962 | |
| 963 | if(timeout_cal_fs>=0 && timeout_cal_fs<=7) |
| 964 | params->timeout_cal_fs=timeout_cal_fs; |
| 965 | else |
| 966 | params->timeout_cal_fs=default_param_timeout_cal_fs; |
| 967 | |
| 968 | if(data_fifo_size>=32 && data_fifo_size<=32768) |
| 969 | params->data_fifo_size=data_fifo_size; |
| 970 | else |
| 971 | params->data_fifo_size=default_param_data_fifo_size; |
| 972 | |
| 973 | #ifdef __IS_HOST__ |
| 974 | if(host_channels>=1 && host_channels<=16) |
| 975 | params->host_channels=host_channels; |
| 976 | else |
| 977 | params->host_channels=default_param_host_channels; |
| 978 | |
| 979 | if(rx_fifo_size>=16 && rx_fifo_size<=32768) |
| 980 | params->rx_fifo_size=rx_fifo_size; |
| 981 | else |
| 982 | params->rx_fifo_size=default_param_rx_fifo_size; |
| 983 | |
| 984 | if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768) |
| 985 | params->nperio_tx_fifo_size=nperio_tx_fifo_size; |
| 986 | else |
| 987 | params->nperio_tx_fifo_size=default_param_nperio_tx_fifo_size; |
| 988 | |
| 989 | if(perio_tx_fifo_size>=16 && perio_tx_fifo_size<=32768) |
| 990 | params->perio_tx_fifo_size=perio_tx_fifo_size; |
| 991 | else |
| 992 | params->perio_tx_fifo_size=default_param_perio_tx_fifo_size; |
| 993 | #endif //__IS_HOST__ |
| 994 | |
| 995 | #ifdef __IS_DEVICE__ |
| 996 | if(rx_fifo_size>=16 && rx_fifo_size<=32768) |
| 997 | params->rx_fifo_size=rx_fifo_size; |
| 998 | else |
| 999 | params->rx_fifo_size=default_param_rx_fifo_size; |
| 1000 | #ifdef __DED_FIFO__ |
| 1001 | if(tx_fifo_size_00>=16 && tx_fifo_size_00<=32768) |
| 1002 | params->tx_fifo_size[ 0]=tx_fifo_size_00; |
| 1003 | else |
| 1004 | params->tx_fifo_size[ 0]=default_param_tx_fifo_size_00; |
| 1005 | if(tx_fifo_size_01>=0 && tx_fifo_size_01<=32768) |
| 1006 | params->tx_fifo_size[ 1]=tx_fifo_size_01; |
| 1007 | else |
| 1008 | params->tx_fifo_size[ 1]=default_param_tx_fifo_size_01; |
| 1009 | if(tx_fifo_size_02>=0 && tx_fifo_size_02<=32768) |
| 1010 | params->tx_fifo_size[ 2]=tx_fifo_size_02; |
| 1011 | else |
| 1012 | params->tx_fifo_size[ 2]=default_param_tx_fifo_size_02; |
| 1013 | if(tx_fifo_size_03>=0 && tx_fifo_size_03<=32768) |
| 1014 | params->tx_fifo_size[ 3]=tx_fifo_size_03; |
| 1015 | else |
| 1016 | params->tx_fifo_size[ 3]=default_param_tx_fifo_size_03; |
| 1017 | if(tx_fifo_size_04>=0 && tx_fifo_size_04<=32768) |
| 1018 | params->tx_fifo_size[ 4]=tx_fifo_size_04; |
| 1019 | else |
| 1020 | params->tx_fifo_size[ 4]=default_param_tx_fifo_size_04; |
| 1021 | if(tx_fifo_size_05>=0 && tx_fifo_size_05<=32768) |
| 1022 | params->tx_fifo_size[ 5]=tx_fifo_size_05; |
| 1023 | else |
| 1024 | params->tx_fifo_size[ 5]=default_param_tx_fifo_size_05; |
| 1025 | if(tx_fifo_size_06>=0 && tx_fifo_size_06<=32768) |
| 1026 | params->tx_fifo_size[ 6]=tx_fifo_size_06; |
| 1027 | else |
| 1028 | params->tx_fifo_size[ 6]=default_param_tx_fifo_size_06; |
| 1029 | if(tx_fifo_size_07>=0 && tx_fifo_size_07<=32768) |
| 1030 | params->tx_fifo_size[ 7]=tx_fifo_size_07; |
| 1031 | else |
| 1032 | params->tx_fifo_size[ 7]=default_param_tx_fifo_size_07; |
| 1033 | if(tx_fifo_size_08>=0 && tx_fifo_size_08<=32768) |
| 1034 | params->tx_fifo_size[ 8]=tx_fifo_size_08; |
| 1035 | else |
| 1036 | params->tx_fifo_size[ 8]=default_param_tx_fifo_size_08; |
| 1037 | if(tx_fifo_size_09>=0 && tx_fifo_size_09<=32768) |
| 1038 | params->tx_fifo_size[ 9]=tx_fifo_size_09; |
| 1039 | else |
| 1040 | params->tx_fifo_size[ 9]=default_param_tx_fifo_size_09; |
| 1041 | if(tx_fifo_size_10>=0 && tx_fifo_size_10<=32768) |
| 1042 | params->tx_fifo_size[10]=tx_fifo_size_10; |
| 1043 | else |
| 1044 | params->tx_fifo_size[10]=default_param_tx_fifo_size_10; |
| 1045 | if(tx_fifo_size_11>=0 && tx_fifo_size_11<=32768) |
| 1046 | params->tx_fifo_size[11]=tx_fifo_size_11; |
| 1047 | else |
| 1048 | params->tx_fifo_size[11]=default_param_tx_fifo_size_11; |
| 1049 | if(tx_fifo_size_12>=0 && tx_fifo_size_12<=32768) |
| 1050 | params->tx_fifo_size[12]=tx_fifo_size_12; |
| 1051 | else |
| 1052 | params->tx_fifo_size[12]=default_param_tx_fifo_size_12; |
| 1053 | if(tx_fifo_size_13>=0 && tx_fifo_size_13<=32768) |
| 1054 | params->tx_fifo_size[13]=tx_fifo_size_13; |
| 1055 | else |
| 1056 | params->tx_fifo_size[13]=default_param_tx_fifo_size_13; |
| 1057 | if(tx_fifo_size_14>=0 && tx_fifo_size_14<=32768) |
| 1058 | params->tx_fifo_size[14]=tx_fifo_size_14; |
| 1059 | else |
| 1060 | params->tx_fifo_size[14]=default_param_tx_fifo_size_14; |
| 1061 | if(tx_fifo_size_15>=0 && tx_fifo_size_15<=32768) |
| 1062 | params->tx_fifo_size[15]=tx_fifo_size_15; |
| 1063 | else |
| 1064 | params->tx_fifo_size[15]=default_param_tx_fifo_size_15; |
| 1065 | if(thr_ctl==0 || thr_ctl==1) |
| 1066 | params->thr_ctl=thr_ctl; |
| 1067 | else |
| 1068 | params->thr_ctl=default_param_thr_ctl; |
| 1069 | if(tx_thr_length>=16 && tx_thr_length<=511) |
| 1070 | params->tx_thr_length=tx_thr_length; |
| 1071 | else |
| 1072 | params->tx_thr_length=default_param_tx_thr_length; |
| 1073 | if(rx_thr_length>=16 && rx_thr_length<=511) |
| 1074 | params->rx_thr_length=rx_thr_length; |
| 1075 | else |
| 1076 | params->rx_thr_length=default_param_rx_thr_length; |
| 1077 | #else //__DED_FIFO__ |
| 1078 | if(nperio_tx_fifo_size>=16 && nperio_tx_fifo_size<=32768) |
| 1079 | params->tx_fifo_size[ 0]=nperio_tx_fifo_size; |
| 1080 | else |
| 1081 | params->tx_fifo_size[ 0]=default_param_nperio_tx_fifo_size; |
| 1082 | if(perio_tx_fifo_size_01>=0 && perio_tx_fifo_size_01<=32768) |
| 1083 | params->tx_fifo_size[ 1]=perio_tx_fifo_size_01; |
| 1084 | else |
| 1085 | params->tx_fifo_size[ 1]=default_param_perio_tx_fifo_size_01; |
| 1086 | if(perio_tx_fifo_size_02>=0 && perio_tx_fifo_size_02<=32768) |
| 1087 | params->tx_fifo_size[ 2]=perio_tx_fifo_size_02; |
| 1088 | else |
| 1089 | params->tx_fifo_size[ 2]=default_param_perio_tx_fifo_size_02; |
| 1090 | if(perio_tx_fifo_size_03>=0 && perio_tx_fifo_size_03<=32768) |
| 1091 | params->tx_fifo_size[ 3]=perio_tx_fifo_size_03; |
| 1092 | else |
| 1093 | params->tx_fifo_size[ 3]=default_param_perio_tx_fifo_size_03; |
| 1094 | if(perio_tx_fifo_size_04>=0 && perio_tx_fifo_size_04<=32768) |
| 1095 | params->tx_fifo_size[ 4]=perio_tx_fifo_size_04; |
| 1096 | else |
| 1097 | params->tx_fifo_size[ 4]=default_param_perio_tx_fifo_size_04; |
| 1098 | if(perio_tx_fifo_size_05>=0 && perio_tx_fifo_size_05<=32768) |
| 1099 | params->tx_fifo_size[ 5]=perio_tx_fifo_size_05; |
| 1100 | else |
| 1101 | params->tx_fifo_size[ 5]=default_param_perio_tx_fifo_size_05; |
| 1102 | if(perio_tx_fifo_size_06>=0 && perio_tx_fifo_size_06<=32768) |
| 1103 | params->tx_fifo_size[ 6]=perio_tx_fifo_size_06; |
| 1104 | else |
| 1105 | params->tx_fifo_size[ 6]=default_param_perio_tx_fifo_size_06; |
| 1106 | if(perio_tx_fifo_size_07>=0 && perio_tx_fifo_size_07<=32768) |
| 1107 | params->tx_fifo_size[ 7]=perio_tx_fifo_size_07; |
| 1108 | else |
| 1109 | params->tx_fifo_size[ 7]=default_param_perio_tx_fifo_size_07; |
| 1110 | if(perio_tx_fifo_size_08>=0 && perio_tx_fifo_size_08<=32768) |
| 1111 | params->tx_fifo_size[ 8]=perio_tx_fifo_size_08; |
| 1112 | else |
| 1113 | params->tx_fifo_size[ 8]=default_param_perio_tx_fifo_size_08; |
| 1114 | if(perio_tx_fifo_size_09>=0 && perio_tx_fifo_size_09<=32768) |
| 1115 | params->tx_fifo_size[ 9]=perio_tx_fifo_size_09; |
| 1116 | else |
| 1117 | params->tx_fifo_size[ 9]=default_param_perio_tx_fifo_size_09; |
| 1118 | if(perio_tx_fifo_size_10>=0 && perio_tx_fifo_size_10<=32768) |
| 1119 | params->tx_fifo_size[10]=perio_tx_fifo_size_10; |
| 1120 | else |
| 1121 | params->tx_fifo_size[10]=default_param_perio_tx_fifo_size_10; |
| 1122 | if(perio_tx_fifo_size_11>=0 && perio_tx_fifo_size_11<=32768) |
| 1123 | params->tx_fifo_size[11]=perio_tx_fifo_size_11; |
| 1124 | else |
| 1125 | params->tx_fifo_size[11]=default_param_perio_tx_fifo_size_11; |
| 1126 | if(perio_tx_fifo_size_12>=0 && perio_tx_fifo_size_12<=32768) |
| 1127 | params->tx_fifo_size[12]=perio_tx_fifo_size_12; |
| 1128 | else |
| 1129 | params->tx_fifo_size[12]=default_param_perio_tx_fifo_size_12; |
| 1130 | if(perio_tx_fifo_size_13>=0 && perio_tx_fifo_size_13<=32768) |
| 1131 | params->tx_fifo_size[13]=perio_tx_fifo_size_13; |
| 1132 | else |
| 1133 | params->tx_fifo_size[13]=default_param_perio_tx_fifo_size_13; |
| 1134 | if(perio_tx_fifo_size_14>=0 && perio_tx_fifo_size_14<=32768) |
| 1135 | params->tx_fifo_size[14]=perio_tx_fifo_size_14; |
| 1136 | else |
| 1137 | params->tx_fifo_size[14]=default_param_perio_tx_fifo_size_14; |
| 1138 | if(perio_tx_fifo_size_15>=0 && perio_tx_fifo_size_15<=32768) |
| 1139 | params->tx_fifo_size[15]=perio_tx_fifo_size_15; |
| 1140 | else |
| 1141 | params->tx_fifo_size[15]=default_param_perio_tx_fifo_size_15; |
| 1142 | #endif //__DED_FIFO__ |
| 1143 | #endif //__IS_DEVICE__ |
| 1144 | } |
| 1145 | |
| 1146 | |
| 1147 | |
| 1148 | |
| 1149 | |
| 1150 | |
| 1151 | |
| 1152 | module_param(dbg_lvl, long, 0444); |
| 1153 | MODULE_PARM_DESC(dbg_lvl, "Debug level."); |
| 1154 | |
| 1155 | module_param(dma_burst_size, short, 0444); |
| 1156 | MODULE_PARM_DESC(dma_burst_size, "DMA Burst Size 0, 1, 4, 8, 16"); |
| 1157 | |
| 1158 | module_param(speed, short, 0444); |
| 1159 | MODULE_PARM_DESC(speed, "Speed 0=High Speed 1=Full Speed"); |
| 1160 | |
| 1161 | module_param(data_fifo_size, long, 0444); |
| 1162 | MODULE_PARM_DESC(data_fifo_size, "Total number of words in the data FIFO memory 32-32768"); |
| 1163 | |
| 1164 | #ifdef __IS_DEVICE__ |
| 1165 | module_param(rx_fifo_size, long, 0444); |
| 1166 | MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768"); |
| 1167 | |
| 1168 | #ifdef __DED_FIFO__ |
| 1169 | module_param(tx_fifo_size_00, long, 0444); |
| 1170 | MODULE_PARM_DESC(tx_fifo_size_00, "Number of words in the Tx FIFO #00 16-32768"); |
| 1171 | module_param(tx_fifo_size_01, long, 0444); |
| 1172 | MODULE_PARM_DESC(tx_fifo_size_01, "Number of words in the Tx FIFO #01 0-32768"); |
| 1173 | module_param(tx_fifo_size_02, long, 0444); |
| 1174 | MODULE_PARM_DESC(tx_fifo_size_02, "Number of words in the Tx FIFO #02 0-32768"); |
| 1175 | module_param(tx_fifo_size_03, long, 0444); |
| 1176 | MODULE_PARM_DESC(tx_fifo_size_03, "Number of words in the Tx FIFO #03 0-32768"); |
| 1177 | module_param(tx_fifo_size_04, long, 0444); |
| 1178 | MODULE_PARM_DESC(tx_fifo_size_04, "Number of words in the Tx FIFO #04 0-32768"); |
| 1179 | module_param(tx_fifo_size_05, long, 0444); |
| 1180 | MODULE_PARM_DESC(tx_fifo_size_05, "Number of words in the Tx FIFO #05 0-32768"); |
| 1181 | module_param(tx_fifo_size_06, long, 0444); |
| 1182 | MODULE_PARM_DESC(tx_fifo_size_06, "Number of words in the Tx FIFO #06 0-32768"); |
| 1183 | module_param(tx_fifo_size_07, long, 0444); |
| 1184 | MODULE_PARM_DESC(tx_fifo_size_07, "Number of words in the Tx FIFO #07 0-32768"); |
| 1185 | module_param(tx_fifo_size_08, long, 0444); |
| 1186 | MODULE_PARM_DESC(tx_fifo_size_08, "Number of words in the Tx FIFO #08 0-32768"); |
| 1187 | module_param(tx_fifo_size_09, long, 0444); |
| 1188 | MODULE_PARM_DESC(tx_fifo_size_09, "Number of words in the Tx FIFO #09 0-32768"); |
| 1189 | module_param(tx_fifo_size_10, long, 0444); |
| 1190 | MODULE_PARM_DESC(tx_fifo_size_10, "Number of words in the Tx FIFO #10 0-32768"); |
| 1191 | module_param(tx_fifo_size_11, long, 0444); |
| 1192 | MODULE_PARM_DESC(tx_fifo_size_11, "Number of words in the Tx FIFO #11 0-32768"); |
| 1193 | module_param(tx_fifo_size_12, long, 0444); |
| 1194 | MODULE_PARM_DESC(tx_fifo_size_12, "Number of words in the Tx FIFO #12 0-32768"); |
| 1195 | module_param(tx_fifo_size_13, long, 0444); |
| 1196 | MODULE_PARM_DESC(tx_fifo_size_13, "Number of words in the Tx FIFO #13 0-32768"); |
| 1197 | module_param(tx_fifo_size_14, long, 0444); |
| 1198 | MODULE_PARM_DESC(tx_fifo_size_14, "Number of words in the Tx FIFO #14 0-32768"); |
| 1199 | module_param(tx_fifo_size_15, long, 0444); |
| 1200 | MODULE_PARM_DESC(tx_fifo_size_15, "Number of words in the Tx FIFO #15 0-32768"); |
| 1201 | |
| 1202 | module_param(thr_ctl, short, 0444); |
| 1203 | MODULE_PARM_DESC(thr_ctl, "0=Without 1=With Theshold Ctrl"); |
| 1204 | |
| 1205 | module_param(tx_thr_length, long, 0444); |
| 1206 | MODULE_PARM_DESC(tx_thr_length, "TX Threshold length"); |
| 1207 | |
| 1208 | module_param(rx_thr_length, long, 0444); |
| 1209 | MODULE_PARM_DESC(rx_thr_length, "RX Threshold length"); |
| 1210 | |
| 1211 | #else |
| 1212 | module_param(nperio_tx_fifo_size, long, 0444); |
| 1213 | MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768"); |
| 1214 | |
| 1215 | module_param(perio_tx_fifo_size_01, long, 0444); |
| 1216 | MODULE_PARM_DESC(perio_tx_fifo_size_01, "Number of words in the periodic Tx FIFO #01 0-32768"); |
| 1217 | module_param(perio_tx_fifo_size_02, long, 0444); |
| 1218 | MODULE_PARM_DESC(perio_tx_fifo_size_02, "Number of words in the periodic Tx FIFO #02 0-32768"); |
| 1219 | module_param(perio_tx_fifo_size_03, long, 0444); |
| 1220 | MODULE_PARM_DESC(perio_tx_fifo_size_03, "Number of words in the periodic Tx FIFO #03 0-32768"); |
| 1221 | module_param(perio_tx_fifo_size_04, long, 0444); |
| 1222 | MODULE_PARM_DESC(perio_tx_fifo_size_04, "Number of words in the periodic Tx FIFO #04 0-32768"); |
| 1223 | module_param(perio_tx_fifo_size_05, long, 0444); |
| 1224 | MODULE_PARM_DESC(perio_tx_fifo_size_05, "Number of words in the periodic Tx FIFO #05 0-32768"); |
| 1225 | module_param(perio_tx_fifo_size_06, long, 0444); |
| 1226 | MODULE_PARM_DESC(perio_tx_fifo_size_06, "Number of words in the periodic Tx FIFO #06 0-32768"); |
| 1227 | module_param(perio_tx_fifo_size_07, long, 0444); |
| 1228 | MODULE_PARM_DESC(perio_tx_fifo_size_07, "Number of words in the periodic Tx FIFO #07 0-32768"); |
| 1229 | module_param(perio_tx_fifo_size_08, long, 0444); |
| 1230 | MODULE_PARM_DESC(perio_tx_fifo_size_08, "Number of words in the periodic Tx FIFO #08 0-32768"); |
| 1231 | module_param(perio_tx_fifo_size_09, long, 0444); |
| 1232 | MODULE_PARM_DESC(perio_tx_fifo_size_09, "Number of words in the periodic Tx FIFO #09 0-32768"); |
| 1233 | module_param(perio_tx_fifo_size_10, long, 0444); |
| 1234 | MODULE_PARM_DESC(perio_tx_fifo_size_10, "Number of words in the periodic Tx FIFO #10 0-32768"); |
| 1235 | module_param(perio_tx_fifo_size_11, long, 0444); |
| 1236 | MODULE_PARM_DESC(perio_tx_fifo_size_11, "Number of words in the periodic Tx FIFO #11 0-32768"); |
| 1237 | module_param(perio_tx_fifo_size_12, long, 0444); |
| 1238 | MODULE_PARM_DESC(perio_tx_fifo_size_12, "Number of words in the periodic Tx FIFO #12 0-32768"); |
| 1239 | module_param(perio_tx_fifo_size_13, long, 0444); |
| 1240 | MODULE_PARM_DESC(perio_tx_fifo_size_13, "Number of words in the periodic Tx FIFO #13 0-32768"); |
| 1241 | module_param(perio_tx_fifo_size_14, long, 0444); |
| 1242 | MODULE_PARM_DESC(perio_tx_fifo_size_14, "Number of words in the periodic Tx FIFO #14 0-32768"); |
| 1243 | module_param(perio_tx_fifo_size_15, long, 0444); |
| 1244 | MODULE_PARM_DESC(perio_tx_fifo_size_15, "Number of words in the periodic Tx FIFO #15 0-32768"); |
| 1245 | #endif//__DED_FIFO__ |
| 1246 | module_param(dev_endpoints, short, 0444); |
| 1247 | MODULE_PARM_DESC(dev_endpoints, "The number of endpoints in addition to EP0 available for device mode 1-15"); |
| 1248 | #endif |
| 1249 | |
| 1250 | #ifdef __IS_HOST__ |
| 1251 | module_param(rx_fifo_size, long, 0444); |
| 1252 | MODULE_PARM_DESC(rx_fifo_size, "Number of words in the Rx FIFO 16-32768"); |
| 1253 | |
| 1254 | module_param(nperio_tx_fifo_size, long, 0444); |
| 1255 | MODULE_PARM_DESC(nperio_tx_fifo_size, "Number of words in the non-periodic Tx FIFO 16-32768"); |
| 1256 | |
| 1257 | module_param(perio_tx_fifo_size, long, 0444); |
| 1258 | MODULE_PARM_DESC(perio_tx_fifo_size, "Number of words in the host periodic Tx FIFO 16-32768"); |
| 1259 | |
| 1260 | module_param(host_channels, short, 0444); |
| 1261 | MODULE_PARM_DESC(host_channels, "The number of host channel registers to use 1-16"); |
| 1262 | #endif |
| 1263 | |
| 1264 | module_param(max_transfer_size, long, 0444); |
| 1265 | MODULE_PARM_DESC(max_transfer_size, "The maximum transfer size supported in bytes 2047-65535"); |
| 1266 | |
| 1267 | module_param(max_packet_count, long, 0444); |
| 1268 | MODULE_PARM_DESC(max_packet_count, "The maximum number of packets in a transfer 15-511"); |
| 1269 | |
| 1270 | module_param(phy_utmi_width, long, 0444); |
| 1271 | MODULE_PARM_DESC(phy_utmi_width, "Specifies the UTMI+ Data Width 8 or 16 bits"); |
| 1272 | |
| 1273 | module_param(turn_around_time_hs, long, 0444); |
| 1274 | MODULE_PARM_DESC(turn_around_time_hs, "Turn-Around time for HS"); |
| 1275 | |
| 1276 | module_param(turn_around_time_fs, long, 0444); |
| 1277 | MODULE_PARM_DESC(turn_around_time_fs, "Turn-Around time for FS"); |
| 1278 | |
| 1279 | module_param(timeout_cal_hs, long, 0444); |
| 1280 | MODULE_PARM_DESC(timeout_cal_hs, "Timeout Cal for HS"); |
| 1281 | |
| 1282 | module_param(timeout_cal_fs, long, 0444); |
| 1283 | MODULE_PARM_DESC(timeout_cal_fs, "Timeout Cal for FS"); |
| 1284 | |
| 1285 | |