Home | History | Annotate | Download | only in src
      1 /****************************************************************************
      2 **+-----------------------------------------------------------------------+**
      3 **|                                                                       |**
      4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
      5 **| All rights reserved.                                                  |**
      6 **|                                                                       |**
      7 **| Redistribution and use in source and binary forms, with or without    |**
      8 **| modification, are permitted provided that the following conditions    |**
      9 **| are met:                                                              |**
     10 **|                                                                       |**
     11 **|  * Redistributions of source code must retain the above copyright     |**
     12 **|    notice, this list of conditions and the following disclaimer.      |**
     13 **|  * Redistributions in binary form must reproduce the above copyright  |**
     14 **|    notice, this list of conditions and the following disclaimer in    |**
     15 **|    the documentation and/or other materials provided with the         |**
     16 **|    distribution.                                                      |**
     17 **|  * Neither the name Texas Instruments nor the names of its            |**
     18 **|    contributors may be used to endorse or promote products derived    |**
     19 **|    from this software without specific prior written permission.      |**
     20 **|                                                                       |**
     21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
     22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
     23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
     24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
     25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
     26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
     27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
     28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
     29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
     30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
     31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
     32 **|                                                                       |**
     33 **+-----------------------------------------------------------------------+**
     34 ****************************************************************************/
     35 
     36 #include <linux/module.h>
     37 #include <linux/kernel.h>
     38 #include <linux/version.h>
     39 
     40 #include "mmc_tnetw1150_api.h"
     41 #include "esta_drv.h"
     42 #include "srcApi.h"
     43 #include "osApi.h"
     44 #include "whalHwRegs.h"
     45 
     46 #include "tiwlnif.h"
     47 #include "osUtil.h"
     48 
     49 #ifdef TIWLAN_MSM7000
     50 struct sdio_func *SDIO_GetFunc( void );
     51 #endif
     52 
     53 /* Module parameters */
     54 static char tiwlan_chip_id[10] = "na";
     55 module_param_string(chip_id, tiwlan_chip_id, sizeof(tiwlan_chip_id), S_IWUSR | S_IRUGO);
     56 MODULE_PARM_DESC(tiwlan_chip_id, "WiFi chip id");
     57 static char fw_version[10] = "na";
     58 module_param_string(fw_version, fw_version, sizeof(fw_version), S_IWUSR | S_IRUGO);
     59 MODULE_PARM_DESC(fw_version, "WiFi firmware version");
     60 
     61 /* export_wifi_fw_version
     62    Exports WiFi firmware version to /sys/module/wlan/parameters/fw_version
     63    Returns 0 if OK
     64 */
     65 int export_wifi_fw_version( tiwlan_net_dev_t *drv )
     66 {
     67 	TIWLN_VERSION swVer;
     68 	unsigned long swLen;
     69 	int ret;
     70 
     71 	if (!drv)
     72 		return -EINVAL;
     73 
     74 	swLen = sizeof(swVer);
     75 	memset(&swVer, 0, swLen);
     76 	ret = UtilGetSwVersion(&drv->adapter, (unsigned char *)&swVer, &swLen);
     77 	if (ret != 0)
     78 		return -EINVAL;
     79 
     80 	fw_version[0] = swVer.FWVersion.major + 48;
     81 	fw_version[1] = '.';
     82 	fw_version[2] = swVer.FWVersion.minor + 48;
     83 	fw_version[3] = '.';
     84 	fw_version[4] = swVer.FWVersion.bugfix + 48;
     85 	fw_version[5] = '.';
     86 	fw_version[6] = swVer.FWVersion.subld + 48;
     87 	fw_version[7] = '.';
     88 	fw_version[8] = swVer.FWVersion.build + 48;
     89 	fw_version[9] = '\0';
     90 	return ret;
     91 }
     92 
     93 /* export_wifi_chip_id
     94    Reads WiFi chip id (0x07030101) and prints it
     95    Returns 0 if OK
     96 */
     97 int export_wifi_chip_id( void )
     98 {
     99 	unsigned char chip_id[4];
    100 	unsigned long amap;
    101 #ifdef TIWLAN_MSM7000
    102 	SDIO_Request_t req;
    103 	struct sdio_func *func;
    104 
    105 	func = SDIO_GetFunc();
    106 	if (!func)
    107 		return -EINVAL;
    108 
    109 	/* configure partition */
    110 	amap = SDIO_DOWNLOAD_PARTITION_START;
    111 	req.buffer = (unsigned char *)&amap;
    112 	req.buffer_len = 4;
    113 	req.peripheral_addr = 0x1ffc4;
    114 	SDIO_SyncWrite(func, &req);
    115 
    116 	amap = SDIO_DOWNLOAD_PARTITION_SIZE;
    117 	req.buffer = (unsigned char *)&amap;
    118 	req.buffer_len = 4;
    119 	req.peripheral_addr = 0x1ffc0;
    120 	SDIO_SyncWrite(func, &req);
    121 
    122 	amap = SDIO_REG_PARTITION_START;
    123 	req.buffer = (unsigned char *)&amap;
    124 	req.buffer_len = 4;
    125 	req.peripheral_addr = 0x1ffcc;
    126 	SDIO_SyncWrite(func, &req);
    127 
    128 	amap = SDIO_REG_PARTITION_SIZE;
    129 	req.buffer = (unsigned char *)&amap;
    130 	req.buffer_len = 4;
    131 	req.peripheral_addr = 0x1ffc8;
    132 	SDIO_SyncWrite(func, &req);
    133 
    134 	/* get TIWLAN1251 ID */
    135 	memset(chip_id, 0, 4);
    136 	req.buffer = chip_id;
    137 	req.buffer_len = 4;
    138 	req.peripheral_addr = SDIO_DOWNLOAD_PARTITION_SIZE + CHIP_ID; /* 0x1BE74 */
    139 	SDIO_SyncRead(func, &req);
    140 #endif
    141 #ifdef TIWLAN_OMAP1610
    142 	/* Can not be read on this stage - SDIO stack is not initialized yet */
    143 	amap = TNETW1251_CHIP_ID_PG1_2;
    144 	memcpy(chip_id, &amap, 4);
    145 #endif
    146 
    147 	if ((chip_id[2] >= 1) && (chip_id[2] <= 3)){
    148 		tiwlan_chip_id[0] = '1';
    149 		tiwlan_chip_id[1] = '2';
    150 		tiwlan_chip_id[2] = '5';
    151 		tiwlan_chip_id[3] = '1';
    152 		tiwlan_chip_id[4] = 'P';
    153 		tiwlan_chip_id[5] = 'G';
    154 		tiwlan_chip_id[6] = '1';
    155 		tiwlan_chip_id[7] = '.';
    156 	}
    157 	switch(chip_id[2]){
    158 	case 1:
    159 		tiwlan_chip_id[8] = '0';
    160 		printk("TIWLAN: 1251 PG 1.0\n");
    161 		break;
    162 	case 2:
    163 		tiwlan_chip_id[8] = '1';
    164 		printk("TIWLAN: 1251 PG 1.1\n");
    165 		break;
    166 	case 3:
    167 		tiwlan_chip_id[8] = '2';
    168 		printk("TIWLAN: 1251 PG 1.2\n");
    169 		break;
    170 	default:
    171 		printk("TIWLAN: invalid chip id = 0x%2x%2x%2x%2x!\n",
    172 			chip_id[3], chip_id[2], chip_id[1], chip_id[0]);
    173 		return -EINVAL;
    174 	};
    175 	return 0;
    176 }
    177