Show
Ignore:
Timestamp:
07/03/2009 04:48:37 PM (9 months ago)
Author:
BrainSlayer
Message:

fixes usb issues with some devices

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/linux/rt2880/linux-2.6.23/drivers/usb/dwc_otg/dwc_otg_driver.c

    r11800 r12433  
    11/* ========================================================================== 
    22 * $File: //dwh/usb_iip/dev/software/otg_ipmate/linux/drivers/dwc_otg_driver.c $ 
    3  * $Revision: 1.2
    4  * $Date: 2007-11-30 08:32:28
     3 * $Revision: 1.7
     4 * $Date: 2008-11-21 05:39:15
    55 * $Change: 791271 $ 
    66 * 
     
    88 * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless 
    99 * otherwise expressly agreed to in writing between Synopsys and you. 
    10  *  
     10 * 
    1111 * The Software IS NOT an item of Licensed Software or Licensed Product under 
    1212 * any End User Software License Agreement or Agreement for Licensed Product 
     
    1818 * Synopsys. If you do not agree with this notice, including the disclaimer 
    1919 * below, then you are not authorized to use the Software. 
    20  *  
     20 * 
    2121 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS 
    2222 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     
    3838 * installed, the dwc_otg_driver_init function is called. When the module is 
    3939 * removed (using rmmod), the dwc_otg_driver_cleanup function is called. 
    40  *  
     40 * 
    4141 * This module also defines a data structure for the dwc_otg_driver, which is 
    4242 * used in conjunction with the standard ARM lm_device structure. These 
     
    5757#include <linux/types.h> 
    5858#include <linux/stat.h>  /* permission constants */ 
     59#include <linux/version.h> 
     60 
     61#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 
     62# include <linux/irq.h> 
     63#endif 
    5964 
    6065#include <asm/io.h> 
     66 
     67#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) 
     68# include <asm/irq.h> 
     69#endif 
     70 
    6171//#include <asm/arch/lm.h> 
    6272#include <asm/rt2880/lm.h> 
     
    7282#include "dwc_otg_hcd.h" 
    7383 
    74 #define DWC_DRIVER_VERSION      "2.60a 22-NOV-2006
     84#define DWC_DRIVER_VERSION      "2.72a 24-JUN-2008
    7585#define DWC_DRIVER_DESC         "HS OTG USB Controller driver" 
    7686 
    7787static const char dwc_driver_name[] = "dwc_otg"; 
    78  
    7988 
    8089/*-------------------------------------------------------------------------*/ 
     
    8594        .otg_cap = -1, 
    8695        .dma_enable = -1, 
     96        .dma_desc_enable = -1, 
    8797        .dma_burst_size = -1, 
    8898        .speed = -1, 
     
    93103        .dev_rx_fifo_size = -1, 
    94104        .dev_nperio_tx_fifo_size = -1, 
    95         .dev_perio_tx_fifo_size =  
    96         {       /* dev_perio_tx_fifo_size_1 */ 
    97                         -1, 
    98                         -1, 
    99                         -1, 
    100                         -1, 
    101                         -1, 
    102                         -1, 
    103                         -1, 
    104                         -1, 
    105                         -1, 
    106                         -1, 
    107                         -1, 
    108                         -1, 
    109                         -1, 
    110                         -1, 
    111                         -1 
    112         },      /* 15 */ 
     105        .dev_perio_tx_fifo_size = { 
     106                /* dev_perio_tx_fifo_size_1 */ 
     107                -1, 
     108                -1, 
     109                -1, 
     110                -1, 
     111                -1, 
     112                -1, 
     113                -1, 
     114                -1, 
     115                -1, 
     116                -1, 
     117                -1, 
     118                -1, 
     119                -1, 
     120                -1, 
     121                -1 
     122                /* 15 */ 
     123        }, 
    113124        .host_rx_fifo_size = -1, 
    114125        .host_nperio_tx_fifo_size = -1, 
     
    126137        .ts_dline = -1, 
    127138        .en_multiple_tx_fifo = -1, 
    128         .dev_tx_fifo_size =  
    129         {       /* dev_tx_fifo_size */ 
    130                         -1, 
    131                         -1, 
    132                         -1, 
    133                         -1, 
    134                         -1, 
    135                         -1, 
    136                         -1, 
    137                         -1, 
    138                         -1, 
    139                         -1, 
    140                         -1, 
    141                         -1, 
    142                         -1, 
    143                         -1, 
    144                         -1 
    145         },      /* 15 */ 
     139        .dev_tx_fifo_size = { 
     140                /* dev_tx_fifo_size */ 
     141                -1, 
     142                -1, 
     143                -1, 
     144                -1, 
     145                -1, 
     146                -1, 
     147                -1, 
     148                -1, 
     149                -1, 
     150                -1, 
     151                -1, 
     152                -1, 
     153                -1, 
     154                -1, 
     155                -1 
     156                /* 15 */ 
     157        }, 
    146158        .thr_ctl = -1, 
    147159        .tx_thr_length = -1, 
    148160        .rx_thr_length = -1, 
     161        .pti_enable = -1, 
     162        .mpi_enable = -1, 
    149163}; 
    150164 
     
    154168static ssize_t version_show(struct device_driver *dev, char *buf) 
    155169{ 
    156         return snprintf(buf, sizeof(DWC_DRIVER_VERSION)+2,"%s\n",  
    157                 DWC_DRIVER_VERSION); 
     170        return snprintf(buf, sizeof(DWC_DRIVER_VERSION)+2, "%s\n", 
     171                       DWC_DRIVER_VERSION); 
    158172} 
    159173static DRIVER_ATTR(version, S_IRUGO, version_show, NULL); 
     
    167181 * This function shows the driver Debug Level. 
    168182 */ 
    169 static ssize_t dbg_level_show(struct device_driver *_drv, char *_buf) 
     183static ssize_t dbg_level_show(struct device_driver *drv, char *buf) 
    170184{ 
    171         return sprintf(_buf, "0x%0x\n", g_dbg_lvl); 
     185        return sprintf(buf, "0x%0x\n", g_dbg_lvl); 
    172186} 
     187 
    173188/** 
    174189 * This function stores the driver Debug Level. 
    175190 */ 
    176 static ssize_t dbg_level_store(struct device_driver *_drv, const char *_buf,  
    177                                                           size_t _count) 
     191static ssize_t dbg_level_store(struct device_driver *drv, const char *buf, 
     192                               size_t count) 
    178193{ 
    179         g_dbg_lvl = simple_strtoul(_buf, NULL, 16); 
    180                 return _count; 
     194        g_dbg_lvl = simple_strtoul(buf, NULL, 16); 
     195                return count; 
    181196} 
    182197static DRIVER_ATTR(debuglevel, S_IRUGO|S_IWUSR, dbg_level_show, dbg_level_store); 
    183  
    184198 
    185199/** 
     
    191205        int i; 
    192206        int retval = 0; 
    193  
     207         
    194208/* Checks if the parameter is outside of its valid range of values */ 
    195 #define DWC_OTG_PARAM_TEST(_param_,_low_,_high_) \ 
     209#define DWC_OTG_PARAM_TEST(_param_, _low_, _high_) \ 
    196210                ((dwc_otg_module_params._param_ < (_low_)) || \ 
    197211                (dwc_otg_module_params._param_ > (_high_))) 
     
    199213/* If the parameter has been set by the user, check that the parameter value is 
    200214 * within the value range of values.  If not, report a module error. */ 
    201 #define DWC_OTG_PARAM_ERR(_param_,_low_,_high_,_string_) \ 
     215#define DWC_OTG_PARAM_ERR(_param_, _low_, _high_, _string_) \ 
    202216                do { \ 
    203217                        if (dwc_otg_module_params._param_ != -1) { \ 
    204                                 if (DWC_OTG_PARAM_TEST(_param_,(_low_),(_high_))) { \ 
     218                                if (DWC_OTG_PARAM_TEST(_param_, (_low_), (_high_))) { \ 
    205219                                        DWC_ERROR("`%d' invalid for parameter `%s'\n", \ 
    206                                                 dwc_otg_module_params._param_, _string_); \ 
     220                                                  dwc_otg_module_params._param_, _string_); \ 
    207221                                        dwc_otg_module_params._param_ = dwc_param_##_param_##_default; \ 
    208                                         retval ++; \ 
     222                                        retval++; \ 
    209223                                } \ 
    210224                        } \ 
     
    214228        DWC_OTG_PARAM_ERR(otg_cap,0,2,"otg_cap"); 
    215229        DWC_OTG_PARAM_ERR(dma_enable,0,1,"dma_enable"); 
     230        DWC_OTG_PARAM_ERR(dma_desc_enable,0,1,"dma_desc_enable"); 
    216231        DWC_OTG_PARAM_ERR(speed,0,1,"speed"); 
    217232        DWC_OTG_PARAM_ERR(host_support_fs_ls_low_power,0,1,"host_support_fs_ls_low_power"); 
     
    235250        DWC_OTG_PARAM_ERR(ts_dline,0,1,"ts_dline"); 
    236251 
    237         if (dwc_otg_module_params.dma_burst_size != -1)  
    238         { 
     252        if (dwc_otg_module_params.dma_burst_size != -1) { 
    239253                if (DWC_OTG_PARAM_TEST(dma_burst_size,1,1) && 
    240                         DWC_OTG_PARAM_TEST(dma_burst_size,4,4) && 
    241                         DWC_OTG_PARAM_TEST(dma_burst_size,8,8) && 
    242                         DWC_OTG_PARAM_TEST(dma_burst_size,16,16) && 
    243                         DWC_OTG_PARAM_TEST(dma_burst_size,32,32) && 
    244                         DWC_OTG_PARAM_TEST(dma_burst_size,64,64) && 
    245                         DWC_OTG_PARAM_TEST(dma_burst_size,128,128) && 
    246                         DWC_OTG_PARAM_TEST(dma_burst_size,256,256)) 
    247                 { 
    248                         DWC_ERROR("`%d' invalid for parameter `dma_burst_size'\n",  
     254                    DWC_OTG_PARAM_TEST(dma_burst_size,4,4) && 
     255                    DWC_OTG_PARAM_TEST(dma_burst_size,8,8) && 
     256                    DWC_OTG_PARAM_TEST(dma_burst_size,16,16) && 
     257                    DWC_OTG_PARAM_TEST(dma_burst_size,32,32) && 
     258                    DWC_OTG_PARAM_TEST(dma_burst_size,64,64) && 
     259                    DWC_OTG_PARAM_TEST(dma_burst_size,128,128) && 
     260                    DWC_OTG_PARAM_TEST(dma_burst_size,256,256)) { 
     261                        DWC_ERROR("`%d' invalid for parameter `dma_burst_size'\n", 
    249262                                  dwc_otg_module_params.dma_burst_size); 
    250263                        dwc_otg_module_params.dma_burst_size = 32; 
    251                         retval ++; 
     264                        retval++; 
    252265                } 
    253         } 
    254  
    255         if (dwc_otg_module_params.phy_utmi_width != -1)  
    256         { 
    257                 if (DWC_OTG_PARAM_TEST(phy_utmi_width,8,8) && 
    258                         DWC_OTG_PARAM_TEST(phy_utmi_width,16,16))  
     266 
    259267                { 
    260                         DWC_ERROR("`%d' invalid for parameter `phy_utmi_width'\n",  
     268                        uint8_t brst_sz = 0; 
     269                        while(dwc_otg_module_params.dma_burst_size > 1) { 
     270                                brst_sz ++; 
     271                                dwc_otg_module_params.dma_burst_size >>= 1; 
     272                        } 
     273                        dwc_otg_module_params.dma_burst_size = brst_sz; 
     274                } 
     275        } 
     276 
     277        if (dwc_otg_module_params.phy_utmi_width != -1) { 
     278                if (DWC_OTG_PARAM_TEST(phy_utmi_width, 8, 8) && 
     279                    DWC_OTG_PARAM_TEST(phy_utmi_width, 16, 16)) { 
     280                        DWC_ERROR("`%d' invalid for parameter `phy_utmi_width'\n", 
    261281                                  dwc_otg_module_params.phy_utmi_width); 
    262282                        dwc_otg_module_params.phy_utmi_width = 16; 
    263                         retval ++; 
     283                        retval++; 
    264284                } 
    265285        } 
    266286 
    267         for (i=0; i<15; i++)  
    268         { 
     287        for (i = 0; i < 15; i++) { 
    269288                /** @todo should be like above */ 
    270                 //DWC_OTG_PARAM_ERR(dev_perio_tx_fifo_size[i],4,768,"dev_perio_tx_fifo_size"); 
    271                 if (dwc_otg_module_params.dev_perio_tx_fifo_size[i] != -1)  
    272                 { 
    273                         if (DWC_OTG_PARAM_TEST(dev_perio_tx_fifo_size[i],4,768))  
    274                         { 
     289                //DWC_OTG_PARAM_ERR(dev_perio_tx_fifo_size[i], 4, 768, "dev_perio_tx_fifo_size"); 
     290                if (dwc_otg_module_params.dev_perio_tx_fifo_size[i] != -1) { 
     291                        if (DWC_OTG_PARAM_TEST(dev_perio_tx_fifo_size[i], 4, 768)) { 
    275292                                DWC_ERROR("`%d' invalid for parameter `%s_%d'\n", 
    276293                                          dwc_otg_module_params.dev_perio_tx_fifo_size[i], "dev_perio_tx_fifo_size", i); 
    277294                                dwc_otg_module_params.dev_perio_tx_fifo_size[i] = dwc_param_dev_perio_tx_fifo_size_default; 
    278                                 retval ++; 
     295                                retval++; 
    279296                        } 
    280297                } 
    281298        } 
    282299 
    283         DWC_OTG_PARAM_ERR(en_multiple_tx_fifo,0,1,"en_multiple_tx_fifo"); 
    284  
    285         for (i=0; i<15; i++)  
    286         { 
     300        DWC_OTG_PARAM_ERR(en_multiple_tx_fifo, 0, 1, "en_multiple_tx_fifo"); 
     301 
     302        for (i = 0; i < 15; i++) { 
    287303                /** @todo should be like above */ 
    288                 //DWC_OTG_PARAM_ERR(dev_tx_fifo_size[i],4,768,"dev_tx_fifo_size"); 
    289                 if (dwc_otg_module_params.dev_tx_fifo_size[i] != -1)  
    290                 { 
    291                         if (DWC_OTG_PARAM_TEST(dev_tx_fifo_size[i],4,768))  
    292                         { 
     304                //DWC_OTG_PARAM_ERR(dev_tx_fifo_size[i], 4, 768, "dev_tx_fifo_size"); 
     305                if (dwc_otg_module_params.dev_tx_fifo_size[i] != -1) { 
     306                        if (DWC_OTG_PARAM_TEST(dev_tx_fifo_size[i], 4, 768)) { 
    293307                                DWC_ERROR("`%d' invalid for parameter `%s_%d'\n", 
    294308                                          dwc_otg_module_params.dev_tx_fifo_size[i], "dev_tx_fifo_size", i); 
    295309                                dwc_otg_module_params.dev_tx_fifo_size[i] = dwc_param_dev_tx_fifo_size_default; 
    296                                 retval ++; 
     310                                retval++; 
    297311                        } 
    298312                } 
     
    302316        DWC_OTG_PARAM_ERR(tx_thr_length, 8, 128, "tx_thr_length"); 
    303317        DWC_OTG_PARAM_ERR(rx_thr_length, 8, 128, "rx_thr_length"); 
    304          
    305          
     318 
     319        DWC_OTG_PARAM_ERR(pti_enable,0,1,"pti_enable"); 
     320        DWC_OTG_PARAM_ERR(mpi_enable,0,1,"mpi_enable"); 
     321 
    306322        /* At this point, all module parameters that have been set by the user 
    307323         * are valid, and those that have not are left unset.  Now set their 
    308324         * default values and/or check the parameters against the hardware 
    309325         * configurations of the OTG core. */ 
    310  
    311  
    312326 
    313327/* This sets the parameter to the default value if it has not been set by the 
     
    324338 
    325339/* This checks the macro agains the hardware configuration to see if it is 
    326  * valid.  It is possible that the default value could be invalid.     In this 
     340 * valid.  It is possible that the default value could be invalid. In this 
    327341 * case, it will report a module error if the user touched the parameter. 
    328342 * Otherwise it will adjust the value without any error. */ 
    329 #define DWC_OTG_PARAM_CHECK_VALID(_param_,_str_,_is_valid_,_set_valid_) \ 
     343#define DWC_OTG_PARAM_CHECK_VALID(_param_, _str_, _is_valid_, _set_valid_) \ 
    330344        ({ \ 
    331                        int changed = DWC_OTG_PARAM_SET_DEFAULT(_param_); \ 
     345                int changed = DWC_OTG_PARAM_SET_DEFAULT(_param_); \ 
    332346                int error = 0; \ 
    333347                if (!(_is_valid_)) { \ 
    334348                        if (changed) { \ 
    335                                 DWC_ERROR("`%d' invalid for parameter `%s'.     Check HW configuration.\n", dwc_otg_module_params._param_,_str_); \ 
     349                                DWC_ERROR("`%d' invalid for parameter `%s'. Check HW configuration.\n", dwc_otg_module_params._param_, _str_); \ 
    336350                                error = 1; \ 
    337351                        } \ 
     
    342356 
    343357        /* OTG Cap */ 
    344         retval += DWC_OTG_PARAM_CHECK_VALID(otg_cap,"otg_cap", 
    345                                   ({ 
    346                                           int valid; 
    347                                           valid = 1; 
    348                                           switch (dwc_otg_module_params.otg_cap) { 
    349                                           case DWC_OTG_CAP_PARAM_HNP_SRP_CAPABLE: 
    350                                                   if (core_if->hwcfg2.b.op_mode != DWC_HWCFG2_OP_MODE_HNP_SRP_CAPABLE_OTG) valid = 0; 
    351                                                   break
    352                                           case DWC_OTG_CAP_PARAM_SRP_ONLY_CAPABLE: 
    353                                                  if ((core_if->hwcfg2.b.op_mode != DWC_HWCFG2_OP_MODE_HNP_SRP_CAPABLE_OTG) && 
    354                                                          (core_if->hwcfg2.b.op_mode != DWC_HWCFG2_OP_MODE_SRP_ONLY_CAPABLE_OTG) && 
    355                                                          (core_if->hwcfg2.b.op_mode != DWC_HWCFG2_OP_MODE_SRP_CAPABLE_DEVICE) && 
    356                                                          (core_if->hwcfg2.b.op_mode != DWC_HWCFG2_OP_MODE_SRP_CAPABLE_HOST)) 
    357                                                  
    358                                                           valid = 0; 
    359                                                  
    360                                                   break; 
    361                                           case DWC_OTG_CAP_PARAM_NO_HNP_SRP_CAPABLE: 
    362                                                   /* always valid */ 
    363                                                   break; 
    364                                           }  
    365                                           valid; 
    366                           }), 
    367                                        (((core_if->hwcfg2.b.op_mode == DWC_HWCFG2_OP_MODE_HNP_SRP_CAPABLE_OTG) || 
    368                                        (core_if->hwcfg2.b.op_mode == DWC_HWCFG2_OP_MODE_SRP_ONLY_CAPABLE_OTG) || 
    369                                        (core_if->hwcfg2.b.op_mode == DWC_HWCFG2_OP_MODE_SRP_CAPABLE_DEVICE) || 
    370                                        (core_if->hwcfg2.b.op_mode == DWC_HWCFG2_OP_MODE_SRP_CAPABLE_HOST)) ? 
    371                                        DWC_OTG_CAP_PARAM_SRP_ONLY_CAPABLE : 
    372                                        DWC_OTG_CAP_PARAM_NO_HNP_SRP_CAPABLE)); 
    373          
    374         retval += DWC_OTG_PARAM_CHECK_VALID(dma_enable,"dma_enable", 
    375                                 ((dwc_otg_module_params.dma_enable == 1) && (core_if->hwcfg2.b.architecture == 0)) ? 0 : 1,  
     358        retval += DWC_OTG_PARAM_CHECK_VALID(otg_cap, "otg_cap", 
     359                                ({ 
     360                                        int valid; 
     361                                        valid = 1; 
     362                                        switch (dwc_otg_module_params.otg_cap) { 
     363                                        case DWC_OTG_CAP_PARAM_HNP_SRP_CAPABLE: 
     364                                                if (core_if->hwcfg2.b.op_mode != DWC_HWCFG2_OP_MODE_HNP_SRP_CAPABLE_OTG) 
     365                                                       valid = 0
     366                                               break; 
     367                                        case DWC_OTG_CAP_PARAM_SRP_ONLY_CAPABLE: 
     368                                                if ((core_if->hwcfg2.b.op_mode != DWC_HWCFG2_OP_MODE_HNP_SRP_CAPABLE_OTG) && 
     369                                                    (core_if->hwcfg2.b.op_mode != DWC_HWCFG2_OP_MODE_SRP_ONLY_CAPABLE_OTG) && 
     370                                                    (core_if->hwcfg2.b.op_mode != DWC_HWCFG2_OP_MODE_SRP_CAPABLE_DEVICE) && 
     371                                                    (core_if->hwcfg2.b.op_mode != DWC_HWCFG2_OP_MODE_SRP_CAPABLE_HOST))
     372                                                        valid = 0; 
     373                                               
     374                                                break; 
     375                                        case DWC_OTG_CAP_PARAM_NO_HNP_SRP_CAPABLE: 
     376                                                /* always valid */ 
     377                                                break; 
     378                                        } 
     379                                        valid; 
     380                               }), 
     381                                (((core_if->hwcfg2.b.op_mode == DWC_HWCFG2_OP_MODE_HNP_SRP_CAPABLE_OTG) || 
     382                                  (core_if->hwcfg2.b.op_mode == DWC_HWCFG2_OP_MODE_SRP_ONLY_CAPABLE_OTG) || 
     383                                  (core_if->hwcfg2.b.op_mode == DWC_HWCFG2_OP_MODE_SRP_CAPABLE_DEVICE) || 
     384                                  (core_if->hwcfg2.b.op_mode == DWC_HWCFG2_OP_MODE_SRP_CAPABLE_HOST)) ? 
     385                                DWC_OTG_CAP_PARAM_SRP_ONLY_CAPABLE : 
     386                                DWC_OTG_CAP_PARAM_NO_HNP_SRP_CAPABLE)); 
     387 
     388        retval += DWC_OTG_PARAM_CHECK_VALID(dma_enable, "dma_enable", 
     389                                ((dwc_otg_module_params.dma_enable == 1) && (core_if->hwcfg2.b.architecture == 0)) ? 0 : 1, 
    376390                                0); 
    377391 
    378         retval += DWC_OTG_PARAM_CHECK_VALID(opt,"opt", 
    379                                 1, 
     392        retval += DWC_OTG_PARAM_CHECK_VALID(dma_desc_enable, "dma_desc_enable", 
     393                                ((dwc_otg_module_params.dma_desc_enable == 1) && 
     394                                 ((dwc_otg_module_params.dma_enable == 0) || (core_if->hwcfg4.b.desc_dma == 0))) ? 0 : 1, 
    380395                                0); 
     396 
     397        retval += DWC_OTG_PARAM_CHECK_VALID(opt, "opt", 1, 0); 
    381398 
    382399        DWC_OTG_PARAM_SET_DEFAULT(dma_burst_size); 
     
    390407                                        ((dwc_otg_module_params.enable_dynamic_fifo == 0) || 
    391408                                        (core_if->hwcfg2.b.dynamic_fifo == 1)), 0); 
    392          
    393409 
    394410        retval += DWC_OTG_PARAM_CHECK_VALID(data_fifo_size, 
     
    412428                                        dwc_read_reg32(&core_if->core_global_regs->grxfsiz)); 
    413429 
    414  
    415430        retval += DWC_OTG_PARAM_CHECK_VALID(host_nperio_tx_fifo_size, 
    416431                                        "host_nperio_tx_fifo_size", 
     
    447462 * internal testing only. 
    448463 * 
    449  * #define NO_FS_PHY_HW_CHECKS  
     464 * #define NO_FS_PHY_HW_CHECKS 
    450465 */ 
    451466 
     
    459474                                        int valid = 0; 
    460475                                        if ((dwc_otg_module_params.phy_type == DWC_PHY_TYPE_PARAM_UTMI) && 
    461                                         ((core_if->hwcfg2.b.hs_phy_type == 1) ||  
    462                                          (core_if->hwcfg2.b.hs_phy_type == 3))) 
    463                                         { 
     476                                        ((core_if->hwcfg2.b.hs_phy_type == 1) || 
     477                                         (core_if->hwcfg2.b.hs_phy_type == 3))) { 
    464478                                                valid = 1; 
    465479                                        } 
    466480                                        else if ((dwc_otg_module_params.phy_type == DWC_PHY_TYPE_PARAM_ULPI) && 
    467                                                  ((core_if->hwcfg2.b.hs_phy_type == 2) ||  
    468                                                   (core_if->hwcfg2.b.hs_phy_type == 3))) 
    469                                         { 
     481                                                 ((core_if->hwcfg2.b.hs_phy_type == 2) || 
     482                                                  (core_if->hwcfg2.b.hs_phy_type == 3))) { 
    470483                                                valid = 1; 
    471484                                        } 
    472485                                        else if ((dwc_otg_module_params.phy_type == DWC_PHY_TYPE_PARAM_FS) && 
    473                                                  (core_if->hwcfg2.b.fs_phy_type == 1)) 
    474                                         { 
     486                                                 (core_if->hwcfg2.b.fs_phy_type == 1)) { 
    475487                                                valid = 1; 
    476488                                        } 
     
    479491                                ({ 
    480492                                        int set = DWC_PHY_TYPE_PARAM_FS; 
    481                                         if (core_if->hwcfg2.b.hs_phy_type) {  
    482                                                 if ((core_if->hwcfg2.b.hs_phy_type == 3) ||  
     493                                        if (core_if->hwcfg2.b.hs_phy_type) { 
     494                                                if ((core_if->hwcfg2.b.hs_phy_type == 3) || 
    483495                                                (core_if->hwcfg2.b.hs_phy_type == 1)) { 
    484496                                                        set = DWC_PHY_TYPE_PARAM_UTMI; 
     
    492504#endif 
    493505 
    494         retval += DWC_OTG_PARAM_CHECK_VALID(speed,"speed", 
     506        retval += DWC_OTG_PARAM_CHECK_VALID(speed, "speed", 
    495507                                (dwc_otg_module_params.speed == 0) && (dwc_otg_module_params.phy_type == DWC_PHY_TYPE_PARAM_FS) ? 0 : 1, 
    496508                                dwc_otg_module_params.phy_type == DWC_PHY_TYPE_PARAM_FS ? 1 : 0); 
     
    508520 
    509521#ifdef NO_FS_PHY_HW_CHECKS 
    510         retval += DWC_OTG_PARAM_CHECK_VALID(i2c_enable, 
    511                                 "i2c_enable", 1, 0); 
     522        retval += DWC_OTG_PARAM_CHECK_VALID(i2c_enable, "i2c_enable", 1, 0); 
    512523#else 
    513524        retval += DWC_OTG_PARAM_CHECK_VALID(i2c_enable, 
     
    517528#endif 
    518529 
    519         for (i=0; i<15; i++)  
    520         { 
     530        for (i = 0; i < 15; i++) { 
    521531                int changed = 1; 
    522532                int error = 0; 
    523533 
    524                 if (dwc_otg_module_params.dev_perio_tx_fifo_size[i] == -1)  
    525                 { 
     534                if (dwc_otg_module_params.dev_perio_tx_fifo_size[i] == -1) { 
    526535                        changed = 0; 
    527536                        dwc_otg_module_params.dev_perio_tx_fifo_size[i] = dwc_param_dev_perio_tx_fifo_size_default; 
    528537                } 
    529                 if (!(dwc_otg_module_params.dev_perio_tx_fifo_size[i] <= (dwc_read_reg32(&core_if->core_global_regs->dptxfsiz_dieptxf[i]))))  
    530                 { 
    531                         if (changed)  
    532                         { 
    533                                 DWC_ERROR("`%d' invalid for parameter `dev_perio_fifo_size_%d'.  Check HW configuration.\n", dwc_otg_module_params.dev_perio_tx_fifo_size[i],i); 
     538                if (!(dwc_otg_module_params.dev_perio_tx_fifo_size[i] <= (dwc_read_reg32(&core_if->core_global_regs->dptxfsiz_dieptxf[i])))) { 
     539                        if (changed) { 
     540                                DWC_ERROR("`%d' invalid for parameter `dev_perio_fifo_size_%d'. Check HW configuration.\n", dwc_otg_module_params.dev_perio_tx_fifo_size[i], i); 
    534541                                error = 1; 
    535542                        } 
     
    539546        } 
    540547 
    541  
    542         retval += DWC_OTG_PARAM_CHECK_VALID(en_multiple_tx_fifo,"en_multiple_tx_fifo", 
    543                                                 ((dwc_otg_module_params.en_multiple_tx_fifo == 1) && (core_if->hwcfg4.b.ded_fifo_en == 0)) ? 0 : 1,  
     548        retval += DWC_OTG_PARAM_CHECK_VALID(en_multiple_tx_fifo, "en_multiple_tx_fifo", 
     549                                                ((dwc_otg_module_params.en_multiple_tx_fifo == 1) && (core_if->hwcfg4.b.ded_fifo_en == 0)) ? 0 : 1, 
    544550                                                0); 
    545551 
    546          
    547         for (i=0; i<15; i++)  
    548         { 
    549  
     552        for (i = 0; i < 15; i++) { 
    550553                int changed = 1; 
    551554                int error = 0; 
    552555 
    553                 if (dwc_otg_module_params.dev_tx_fifo_size[i] == -1)  
    554                 { 
     556                if (dwc_otg_module_params.dev_tx_fifo_size[i] == -1) { 
    555557                        changed = 0; 
    556558                        dwc_otg_module_params.dev_tx_fifo_size[i] = dwc_param_dev_tx_fifo_size_default; 
    557559                } 
    558                 if (!(dwc_otg_module_params.dev_tx_fifo_size[i] <= (dwc_read_reg32(&core_if->core_global_regs->dptxfsiz_dieptxf[i]))))  
    559                 { 
    560                         if (changed)  
    561                         { 
    562                                 DWC_ERROR("%d' invalid for parameter `dev_perio_fifo_size_%d'.  Check HW configuration.\n", dwc_otg_module_params.dev_tx_fifo_size[i],i); 
     560                if (!(dwc_otg_module_params.dev_tx_fifo_size[i] <= (dwc_read_reg32(&core_if->core_global_regs->dptxfsiz_dieptxf[i])))) { 
     561                        if (changed) { 
     562                                DWC_ERROR("%d' invalid for parameter `dev_perio_fifo_size_%d'. Check HW configuration.\n", dwc_otg_module_params.dev_tx_fifo_size[i], i); 
    563563                                error = 1; 
    564564                        } 
     
    566566                } 
    567567                retval += error; 
    568                  
    569                  
    570         } 
    571          
    572         DWC_OTG_PARAM_SET_DEFAULT(thr_ctl); 
     568        } 
     569 
     570        retval += DWC_OTG_PARAM_CHECK_VALID(thr_ctl, "thr_ctl", 
     571                                ((dwc_otg_module_params.thr_ctl != 0) && ((dwc_otg_module_params.dma_enable == 0) || (core_if->hwcfg4.b.ded_fifo_en == 0))) ? 0 : 1, 
     572                                0); 
     573 
    573574        DWC_OTG_PARAM_SET_DEFAULT(tx_thr_length); 
    574575        DWC_OTG_PARAM_SET_DEFAULT(rx_thr_length); 
    575          
     576 
     577        retval += DWC_OTG_PARAM_CHECK_VALID(pti_enable, "pti_enable", 
     578                ((dwc_otg_module_params.pti_enable == 0) || ((dwc_otg_module_params.pti_enable == 1) && (core_if->snpsid >= 0x4F54272A))) ? 1 : 0, 
     579                        0); 
     580 
     581        retval += DWC_OTG_PARAM_CHECK_VALID(mpi_enable, "mpi_enable", 
     582                        ((dwc_otg_module_params.mpi_enable == 0) || ((dwc_otg_module_params.mpi_enable == 1) && (core_if->hwcfg2.b.multi_proc_int == 1))) ? 1 : 0, 
     583                        0); 
    576584        return retval; 
    577585} 
    578586 
    579 /**  
     587/** 
    580588 * This function is the top level interrupt handler for the Common 
    581589 * (Device and host modes) interrupts. 
    582590 */ 
    583 static irqreturn_t dwc_otg_common_irq(int _irq, void *_dev) 
     591static irqreturn_t dwc_otg_common_irq(int irq, void *dev 
     592#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) 
     593                                      , struct pt_regs *r 
     594#endif 
     595                                     ) 
    584596{ 
    585         dwc_otg_device_t *otg_dev = _dev; 
     597        dwc_otg_device_t *otg_dev = dev; 
    586598        int32_t retval = IRQ_NONE; 
    587599 
    588         retval = dwc_otg_handle_common_intr( otg_dev->core_if ); 
     600        retval = dwc_otg_handle_common_intr(otg_dev->core_if); 
    589601        return IRQ_RETVAL(retval); 
    590602} 
     
    597609 * of this device are freed. 
    598610 * 
    599  * @param[in] _lmdev 
     611 * @param[in] lmdev 
    600612 */ 
    601 static void dwc_otg_driver_remove(struct lm_device *_lmdev) 
     613static void dwc_otg_driver_remove(struct lm_device *lmdev) 
    602614{ 
    603         dwc_otg_device_t *otg_dev = lm_get_drvdata(_lmdev); 
    604         DWC_DEBUGPL(DBG_ANY, "%s(%p)\n", __func__, _lmdev); 
    605          
    606         if (otg_dev == NULL)  
    607         { 
     615        dwc_otg_device_t *otg_dev = lm_get_drvdata(lmdev); 
     616        DWC_DEBUGPL(DBG_ANY, "%s(%p)\n", __func__, lmdev); 
     617 
     618        if (!otg_dev) { 
    608619                /* Memory allocation for the dwc_otg_device failed. */ 
     620                DWC_DEBUGPL(DBG_ANY, "%s: otg_dev NULL!\n", __func__); 
    609621                return; 
    610622        } 
    611623 
    612624        /* 
    613          * Free the IRQ  
    614          */ 
    615         if (otg_dev->common_irq_installed)  
    616         { 
    617                 free_irq( _lmdev->irq, otg_dev ); 
     625         * Free the IRQ 
     626         */ 
     627        if (otg_dev->common_irq_installed) { 
     628                free_irq(lmdev->irq, otg_dev); 
    618629        } 
    619630 
    620631#ifndef DWC_DEVICE_ONLY 
    621         if (otg_dev->hcd != NULL)  
    622         { 
    623                 dwc_otg_hcd_remove( _lmdev ); 
     632        if (otg_dev->hcd) { 
     633                dwc_otg_hcd_remove(lmdev); 
     634        } else { 
     635                DWC_DEBUGPL(DBG_ANY, "%s: otg_dev->hcd NULL!\n", __func__); 
     636                return; 
    624637        } 
    625638#endif 
    626639 
    627640#ifndef DWC_HOST_ONLY 
    628         if (otg_dev->pcd != NULL)  
    629         { 
    630                 dwc_otg_pcd_remove( _lmdev ); 
     641        if (otg_dev->pcd) { 
     642                dwc_otg_pcd_remove(lmdev); 
    631643        } 
    632644#endif 
    633         if (otg_dev->core_if != NULL)  
    634         { 
    635                 dwc_otg_cil_remove( otg_dev->core_if ); 
     645        if (otg_dev->core_if) { 
     646                dwc_otg_cil_remove(otg_dev->core_if); 
    636647        } 
    637648 
     
    639650         * Remove the device attributes 
    640651         */ 
    641         dwc_otg_attr_remove(_lmdev); 
     652        dwc_otg_attr_remove(lmdev); 
    642653 
    643654        /* 
    644655         * Return the memory. 
    645656         */ 
    646         if (otg_dev->base != NULL)  
    647         { 
     657        if (otg_dev->base) { 
    648658                iounmap(otg_dev->base); 
    649659        } 
    650660        kfree(otg_dev); 
    651                  
     661 
    652662        /* 
    653663         * Clear the drvdata pointer. 
    654664         */ 
    655         lm_set_drvdata( _lmdev, 0 ); 
     665        lm_set_drvdata(lmdev, 0); 
    656666} 
    657667 
     
    665675 * structure on subsequent calls to driver methods for this device. 
    666676 * 
    667  * @param[in] _lmdev  lm_device definition 
     677 * @param[in] lmdev  lm_device definition 
    668678 */ 
    669 static int dwc_otg_driver_probe(struct lm_device *_lmdev) 
     679static int dwc_otg_driver_probe(struct lm_device *lmdev) 
    670680{ 
    671681        int retval = 0; 
     682        uint32_t snpsid; 
    672683        dwc_otg_device_t *dwc_otg_device; 
    673         int32_t snpsid; 
    674  
    675         dev_dbg(&_lmdev->dev, "dwc_otg_driver_probe(%p)\n", _lmdev); 
    676         dev_dbg(&_lmdev->dev, "start=0x%08x\n", (unsigned)_lmdev->resource.start); 
     684 
     685        dev_dbg(&lmdev->dev, "dwc_otg_driver_probe(%p)\n", lmdev); 
     686        dev_dbg(&lmdev->dev, "start=0x%08x\n", (unsigned)lmdev->resource.start); 
    677687 
    678688        dwc_otg_device = kmalloc(sizeof(dwc_otg_device_t), GFP_KERNEL); 
    679          
    680         if (dwc_otg_device == 0)  
    681         { 
    682                 dev_err(&_lmdev->dev, "kmalloc of dwc_otg_device failed\n"); 
     689 
     690        if (!dwc_otg_device) { 
     691                dev_err(&lmdev->dev, "kmalloc of dwc_otg_device failed\n"); 
    683692                retval = -ENOMEM; 
    684693                goto fail; 
    685694        } 
    686          
     695 
    687696        memset(dwc_otg_device, 0, sizeof(*dwc_otg_device)); 
    688697        dwc_otg_device->reg_offset = 0xFFFFFFFF; 
     
    691700         * Map the DWC_otg Core memory into virtual address space. 
    692701         */ 
    693         dwc_otg_device->base = ioremap(_lmdev->resource.start, SZ_256K); 
    694          
    695         if (dwc_otg_device->base == NULL) 
    696         { 
    697                 dev_err(&_lmdev->dev, "ioremap() failed\n"); 
     702        dwc_otg_device->base = ioremap(lmdev->resource.start, SZ_256K); 
     703 
     704        if (!dwc_otg_device->base) { 
     705                dev_err(&lmdev->dev, "ioremap() failed\n"); 
    698706                retval = -ENOMEM; 
    699707                goto fail; 
    700708        } 
    701         dev_dbg(&_lmdev->dev, "base=0x%08x\n", (unsigned)dwc_otg_device->base); 
     709        dev_dbg(&lmdev->dev, "base=0x%08x\n", (unsigned)dwc_otg_device->base); 
    702710 
    703711        /* 
     
    707715         */ 
    708716        snpsid = dwc_read_reg32((uint32_t *)((uint8_t *)dwc_otg_device->base + 0x40)); 
    709          
    710         if ((snpsid & 0xFFFFF000) != 0x4F542000)  
    711         { 
    712                 dev_err(&_lmdev->dev, "Bad value for SNPSID: 0x%08x\n", snpsid); 
     717 
     718        if ((snpsid & 0xFFFFF000) != OTG_CORE_REV_2_00) { 
     719                dev_err(&lmdev->dev, "Bad value for SNPSID: 0x%08x\n", snpsid); 
    713720                retval = -EINVAL; 
    714721                goto fail; 
    715722        } 
    716723 
     724        DWC_PRINT("Core Release: %x.%x%x%x\n",  
     725                        (snpsid >> 12 & 0xF),  
     726                        (snpsid >> 8 & 0xF), 
     727                        (snpsid >> 4 & 0xF), 
     728                        (snpsid & 0xF)); 
     729 
    717730        /* 
    718731         * Initialize driver data to point to the global DWC_otg 
    719732         * Device structure. 
    720733         */ 
    721         lm_set_drvdata( _lmdev, dwc_otg_device ); 
    722         dev_dbg(&_lmdev->dev, "dwc_otg_device=0x%p\n", dwc_otg_device); 
     734        lm_set_drvdata(lmdev, dwc_otg_device); 
     735        dev_dbg(&lmdev->dev, "dwc_otg_device=0x%p\n", dwc_otg_device); 
     736 
     737        dwc_otg_device->core_if = dwc_otg_cil_init(dwc_otg_device->base, 
     738                                                   &dwc_otg_module_params); 
    723739         
    724         dwc_otg_device->core_if = dwc_otg_cil_init( dwc_otg_device->base,  
    725                                                         &dwc_otg_module_params); 
    726         if (dwc_otg_device->core_if == 0)  
    727         { 
    728                 dev_err(&_lmdev->dev, "CIL initialization failed!\n"); 
     740        dwc_otg_device->core_if->snpsid = snpsid; 
     741         
     742        if (!dwc_otg_device->core_if) { 
     743                dev_err(&lmdev->dev, "CIL initialization failed!\n"); 
    729744                retval = -ENOMEM; 
    730745                goto fail; 
    731746        } 
    732          
     747 
    733748        /* 
    734749         * Validate parameter values. 
    735750         */ 
    736         if (check_parameters(dwc_otg_device->core_if) != 0)  
    737         { 
     751        if (check_parameters(dwc_otg_device->core_if)) { 
    738752                retval = -EINVAL; 
    739753                goto fail; 
     
    742756        /* 
    743757         * Create Device Attributes in sysfs 
    744          */      
    745         dwc_otg_attr_create (_lmdev); 
     758         */ 
     759        dwc_otg_attr_create(lmdev); 
    746760 
    747761        /* 
     
    749763         * handlers are installed. 
    750764         */ 
    751         dwc_otg_disable_global_interrupts( dwc_otg_device->core_if ); 
     765        dwc_otg_disable_global_interrupts(dwc_otg_device->core_if); 
     766 
    752767        /* 
    753768         * Install the interrupt handler for the common interrupts before 
    754769         * enabling common interrupts in core_init below. 
    755770         */ 
    756         DWC_DEBUGPL( DBG_CIL, "registering (common) handler for irq%d\n",  
    757                         _lmdev->irq); 
    758         retval = request_irq(_lmdev->irq, dwc_otg_common_irq,SA_SHIRQ, "dwc_otg", dwc_otg_device ); 
    759         if (retval != 0)  
    760        
    761                 DWC_ERROR("request of irq%d failed\n", _lmdev->irq); 
     771        DWC_DEBUGPL(DBG_CIL, "registering (common) handler for irq%d\n", 
     772                    lmdev->irq); 
     773        retval = request_irq(lmdev->irq, dwc_otg_common_irq, 
     774                            SA_SHIRQ, "dwc_otg", dwc_otg_device); 
     775        if (retval)
     776                DWC_ERROR("request of irq%d failed\n", lmdev->irq); 
    762777                retval = -EBUSY; 
    763778                goto fail; 
    764         }  
    765         else  
    766         { 
     779        } else { 
    767780                dwc_otg_device->common_irq_installed = 1; 
    768781        } 
    769782 
    770 #ifdef CONFIG_MACH_IPMATE 
    771         set_irq_type(_lmdev->irq, IRQT_LOW); 
    772 #endif 
    773  
    774783        /* 
    775784         * Initialize the DWC_otg core. 
    776785         */ 
    777         dwc_otg_core_init( dwc_otg_device->core_if ); 
     786        dwc_otg_core_init(dwc_otg_device->core_if); 
    778787 
    779788#ifndef DWC_HOST_ONLY 
     
    781790         * Initialize the PCD 
    782791         */ 
    783         retval = dwc_otg_pcd_init( _lmdev ); 
    784         if (retval != 0)  
    785         { 
     792        retval = dwc_otg_pcd_init(lmdev); 
     793        if (retval != 0) { 
    786794                DWC_ERROR("dwc_otg_pcd_init failed\n"); 
    787795                dwc_otg_device->pcd = NULL; 
     
    793801         * Initialize the HCD 
    794802         */ 
    795         retval = dwc_otg_hcd_init(_lmdev); 
    796         if (retval != 0)  
    797         { 
     803        retval = dwc_otg_hcd_init(lmdev); 
     804        if (retval != 0) { 
    798805                DWC_ERROR("dwc_otg_hcd_init failed\n"); 
    799806                dwc_otg_device->hcd = NULL; 
     
    806813         * handlers are installed. 
    807814         */ 
    808         dwc_otg_enable_global_interrupts( dwc_otg_device->core_if ); 
     815        dwc_otg_enable_global_interrupts(dwc_otg_device->core_if); 
    809816 
    810817        return 0; 
    811818 
    812819 fail: 
    813         dwc_otg_driver_remove(_lmdev); 
     820        dwc_otg_driver_remove(lmdev); 
    814821        return retval; 
    815822} 
    816823 
    817 /**  
     824/** 
    818825 * This structure defines the methods to be called by a bus driver 
    819826 * during the lifecycle of a device on that bus. Both drivers and 
     
    826833 * unregistered with the bus driver. 
    827834 */ 
    828 static struct lm_driver dwc_otg_driver =  
    829 
    830         .drv =   
    831                         { 
    832                 .               name    = (char*)dwc_driver_name, 
    833                         }, 
     835static struct lm_driver dwc_otg_driver = { 
     836        .drv = { 
     837                .name   = (char *)dwc_driver_name, 
     838        }, 
    834839        .probe          = dwc_otg_driver_probe, 
    835840        .remove         = dwc_otg_driver_remove, 
    836841}; 
    837  
     842#define RALINK_PIO_BASE                 0xA0300600 
     843 
     844#define RALINK_PRGIO_ADDR               RALINK_PIO_BASE // Programmable I/O 
     845 
     846#define RALINK_REG_PIOINT               (RALINK_PRGIO_ADDR + 0) 
     847#define RALINK_REG_PIOEDGE              (RALINK_PRGIO_ADDR + 0x04) 
     848#define RALINK_REG_PIORENA              (RALINK_PRGIO_ADDR + 0x08) 
     849#define RALINK_REG_PIOFENA              (RALINK_PRGIO_ADDR + 0x0C) 
     850#define RALINK_REG_PIODATA              (RALINK_PRGIO_ADDR + 0x20) 
     851#define RALINK_REG_PIODIR               (RALINK_PRGIO_ADDR + 0x24) 
     852#define RALINK_REG_PIOSET               (RALINK_PRGIO_ADDR + 0x2C) 
     853#define RALINK_REG_PIORESET             (RALINK_PRGIO_ADDR + 0x30) 
     854 
     855void ralink_gpio_control(int gpio,int level) 
     856
     857   unsigned long piodir,piodata; 
     858 
     859       piodir = le32_to_cpu(*(volatile u32 *)(RALINK_REG_PIODIR)); 
     860       piodir |= (1L << gpio); 
     861       *(volatile u32 *)(RALINK_REG_PIODIR) = cpu_to_le32(piodir); 
     862       piodata = le32_to_cpu(*(volatile u32 *)(RALINK_REG_PIODATA)); 
     863 
     864       if(level) 
     865          piodata |= (1L << gpio); 
     866       else 
     867          piodata &= ~(1L << gpio); 
     868 
     869       *(volatile u32 *)(RALINK_REG_PIODATA) = cpu_to_le32(piodata);  
     870
    838871 
    839872/** 
     
    847880 * @return 
    848881 */ 
    849 static int __init dwc_otg_driver_init(void)  
     882static int __init dwc_otg_driver_init(void) 
    850883{ 
    851884        int retval = 0; 
    852885        struct lm_device *lmdev; 
    853  
     886        int error; 
     887         
    854888        *(unsigned long *)(KSEG1ADDR(RALINK_USB_OTG_BASE+0xE00)) = 0x0; //Enable USB Port 
    855  
     889        ralink_gpio_control(6,1); // turn on 5V 
    856890        lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL); 
    857  
    858891        if (!lmdev) 
    859892        { 
     
    871904        printk(KERN_INFO "%s: version %s\n", dwc_driver_name, DWC_DRIVER_VERSION); 
    872905        retval = lm_driver_register(&dwc_otg_driver); 
    873         if (retval < 0)  
    874         { 
     906        if (retval < 0) { 
    875907                printk(KERN_ERR "%s retval=%d\n", __func__, retval); 
    876908                return retval; 
    877909        } 
    878         driver_create_file(&dwc_otg_driver.drv, &driver_attr_version); 
    879         driver_create_file(&dwc_otg_driver.drv, &driver_attr_debuglevel); 
     910        error = driver_create_file(&dwc_otg_driver.drv, &driver_attr_version); 
     911        error = driver_create_file(&dwc_otg_driver.drv, &driver_attr_debuglevel); 
    880912 
    881913        return retval; 
     
    883915module_init(dwc_otg_driver_init); 
    884916 
    885 /**  
     917/** 
    886918 * This function is called when the driver is removed from the kernel 
    887919 * with the rmmod command. The driver unregisters itself with its bus 
     
    897929 
    898930        lm_driver_unregister(&dwc_otg_driver); 
    899  
     931        ralink_gpio_control(6,0); // turn off 5V 
    900932        *(unsigned long *)(KSEG1ADDR(RALINK_USB_OTG_BASE+0xE00)) = 0xF; //Disable USB Port 
    901933        printk(KERN_INFO "%s module removed\n", dwc_driver_name); 
     
    913945module_param_named(dma_enable, dwc_otg_module_params.dma_enable, int, 0444); 
    914946MODULE_PARM_DESC(dma_enable, "DMA Mode 0=Slave 1=DMA enabled"); 
     947 
     948module_param_named(dma_desc_enable, dwc_otg_module_params.dma_desc_enable, int, 0444); 
     949MODULE_PARM_DESC(dma_desc_enable, "DMA Desc Mode 0=Address DMA 1=DMA Descriptor enabled"); 
     950 
    915951module_param_named(dma_burst_size, dwc_otg_module_params.dma_burst_size, int, 0444); 
    916952MODULE_PARM_DESC(dma_burst_size, "DMA Burst Size 1, 4, 8, 16, 32, 64, 128, 256"); 
     
    10301066module_param_named(rx_thr_length, dwc_otg_module_params.rx_thr_length, int, 0444); 
    10311067MODULE_PARM_DESC(rx_thr_length, "Rx Threshold length in 32 bit DWORDs"); 
     1068 
     1069module_param_named(pti_enable, dwc_otg_module_params.pti_enable, int, 0444); 
     1070MODULE_PARM_DESC(pti_enable, "Per Transfer Interrupt mode 0=disabled 1=enabled"); 
     1071 
     1072module_param_named(mpi_enable, dwc_otg_module_params.mpi_enable, int, 0444); 
     1073MODULE_PARM_DESC(mpi_enable, "Multiprocessor Interrupt mode 0=disabled 1=enabled"); 
     1074 
    10321075/** @page "Module Parameters" 
    10331076 * 
    10341077 * The following parameters may be specified when starting the module. 
    10351078 * These parameters define how the DWC_otg controller should be 
    1036  * configured. Parameter values are passed to the CIL initialization 
     1079 * configured. Parameter values are passed to the CIL initialization 
    10371080 * function dwc_otg_cil_init 
    10381081 * 
    10391082 * Example: <code>modprobe dwc_otg speed=1 otg_cap=1</code> 
    10401083 * 
    1041   
     1084 
    10421085 <table> 
    1043  <tr><td>Parameter Name</td><td>Meaning</td></tr>  
    1044   
     1086 <tr><td>Parameter Name</td><td>Meaning</td></tr> 
     1087 
    10451088 <tr> 
    10461089 <td>otg_cap</td> 
     
    10511094 - 2: No HNP/SRP capable 
    10521095 </td></tr> 
    1053   
     1096 
    10541097 <tr> 
    10551098 <td>dma_enable</td> 
     
    10601103 - 1: DMA (default, if available) 
    10611104 </td></tr> 
    1062   
     1105 
    10631106 <tr> 
    10641107 <td>dma_burst_size</td> 
     
    10661109 - Values: 1, 4, 8 16, 32, 64, 128, 256 (default 32) 
    10671110 </td></tr> 
    1068   
     1111 
    10691112 <tr> 
    10701113 <td>speed</td> 
     
    10751118 - 1: Full Speed 
    10761119 </td></tr> 
    1077   
     1120 
    10781121 <tr> 
    10791122 <td>host_support_fs_ls_low_power</td> 
     
    10831126 - 1: Support low power mode 
    10841127 </td></tr> 
    1085   
     1128 
    10861129 <tr> 
    10871130 <td>host_ls_low_power_phy_clk</td> 
     
    10921135 - 1: 6 MHz 
    10931136 </td></tr> 
    1094   
     1137 
    10951138 <tr> 
    10961139 <td>enable_dynamic_fifo</td> 
     
    10991142 - 1: Allow dynamic FIFO sizing (default) 
    11001143 </td></tr> 
    1101   
     1144 
    11021145 <tr> 
    11031146 <td>data_fifo_size</td> 
     
    11081151 Note: The total FIFO memory depth in the FPGA configuration is 8192. 
    11091152 </td></tr> 
    1110   
     1153 
    11111154 <tr> 
    11121155 <td>dev_rx_fifo_size</td> 
     
    11151158 - Values: 16 to 32768 (default 1064) 
    11161159 </td></tr> 
    1117   
     1160 
    11181161 <tr> 
    11191162 <td>dev_nperio_tx_fifo_size</td> 
     
    11221165 - Values: 16 to 32768 (default 1024) 
    11231166 </td></tr> 
    1124   
     1167 
    11251168 <tr> 
    11261169 <td>dev_perio_tx_fifo_size_n (n = 1 to 15)</td> 
     
    11291172 - Values: 4 to 768 (default 256) 
    11301173 </td></tr> 
    1131   
     1174 
    11321175 <tr> 
    11331176 <td>host_rx_fifo_size</td> 
     
    11361179 - Values: 16 to 32768 (default 1024) 
    11371180 </td></tr> 
    1138   
     1181 
    11391182 <tr> 
    11401183 <td>host_nperio_tx_fifo_size</td> 
     
    11431186 - Values: 16 to 32768 (default 1024) 
    11441187 </td></tr> 
    1145   
     1188 
    11461189 <tr> 
    11471190 <td>host_perio_tx_fifo_size</td> 
     
    11501193 - Values: 16 to 32768 (default 1024) 
    11511194 </td></tr> 
    1152   
     1195 
    11531196 <tr> 
    11541197 <td>max_transfer_size</td> 
     
    11561199 - Values: 2047 to 65,535 (default 65,535) 
    11571200 </td></tr> 
    1158   
     1201 
    11591202 <tr> 
    11601203 <td>max_packet_count</td> 
     
    11621205 - Values: 15 to 511 (default 511) 
    11631206 </td></tr> 
    1164   
     1207 
    11651208 <tr> 
    11661209 <td>host_channels</td> 
     
    11701213 Note: The FPGA configuration supports a maximum of 12 host channels. 
    11711214 </td></tr> 
    1172   
     1215 
    11731216 <tr> 
    11741217 <td>dev_endpoints</td> 
     
    11801223 addition to EP0. 
    11811224 </td></tr> 
    1182   
     1225 
    11831226 <tr> 
    11841227 <td>phy_type</td> 
     
    11891232 - 2: ULPI 
    11901233 </td></tr> 
    1191   
     1234 
    11921235 <tr> 
    11931236 <td>phy_utmi_width</td> 
     
    11981241 - Values: 8 or 16 bits (default 16) 
    11991242 </td></tr> 
    1200   
     1243 
    12011244 <tr> 
    12021245 <td>phy_ulpi_ddr</td>