PageRenderTime 88ms CodeModel.GetById 59ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/pform/linux/src/chip_stat.c

http://github.com/CyanogenMod/cm-kernel
C | 176 lines | 113 code | 17 blank | 46 comment | 6 complexity | 558296e9b0fdfd5f30eb72b1ba967e66 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  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. #include <linux/module.h>
  36. #include <linux/kernel.h>
  37. #include <linux/version.h>
  38. #include "mmc_tnetw1150_api.h"
  39. #include "esta_drv.h"
  40. #include "srcApi.h"
  41. #include "osApi.h"
  42. #include "whalHwRegs.h"
  43. #include "tiwlnif.h"
  44. #include "osUtil.h"
  45. #ifdef TIWLAN_MSM7000
  46. struct sdio_func *SDIO_GetFunc( void );
  47. #endif
  48. /* Module parameters */
  49. static char tiwlan_chip_id[10] = "na";
  50. module_param_string(chip_id, tiwlan_chip_id, sizeof(tiwlan_chip_id), S_IWUSR | S_IRUGO);
  51. MODULE_PARM_DESC(tiwlan_chip_id, "WiFi chip id");
  52. static char fw_version[10] = "na";
  53. module_param_string(fw_version, fw_version, sizeof(fw_version), S_IWUSR | S_IRUGO);
  54. MODULE_PARM_DESC(fw_version, "WiFi firmware version");
  55. /* export_wifi_fw_version
  56. Exports WiFi firmware version to /sys/module/wlan/parameters/fw_version
  57. Returns 0 if OK
  58. */
  59. int export_wifi_fw_version( tiwlan_net_dev_t *drv )
  60. {
  61. TIWLN_VERSION swVer;
  62. unsigned long swLen;
  63. int ret;
  64. if (!drv)
  65. return -EINVAL;
  66. swLen = sizeof(swVer);
  67. memset(&swVer, 0, swLen);
  68. ret = UtilGetSwVersion(&drv->adapter, (unsigned char *)&swVer, &swLen);
  69. if (ret != 0)
  70. return -EINVAL;
  71. fw_version[0] = swVer.FWVersion.major + 48;
  72. fw_version[1] = '.';
  73. fw_version[2] = swVer.FWVersion.minor + 48;
  74. fw_version[3] = '.';
  75. fw_version[4] = swVer.FWVersion.bugfix + 48;
  76. fw_version[5] = '.';
  77. fw_version[6] = swVer.FWVersion.subld + 48;
  78. fw_version[7] = '.';
  79. fw_version[8] = swVer.FWVersion.build + 48;
  80. fw_version[9] = '\0';
  81. return ret;
  82. }
  83. /* export_wifi_chip_id
  84. Reads WiFi chip id (0x07030101) and prints it
  85. Returns 0 if OK
  86. */
  87. int export_wifi_chip_id( void )
  88. {
  89. unsigned char chip_id[4];
  90. unsigned long amap;
  91. #ifdef TIWLAN_MSM7000
  92. SDIO_Request_t req;
  93. struct sdio_func *func;
  94. func = SDIO_GetFunc();
  95. if (!func)
  96. return -EINVAL;
  97. /* configure partition */
  98. amap = SDIO_DOWNLOAD_PARTITION_START;
  99. req.buffer = (unsigned char *)&amap;
  100. req.buffer_len = 4;
  101. req.peripheral_addr = 0x1ffc4;
  102. SDIO_SyncWrite(func, &req);
  103. amap = SDIO_DOWNLOAD_PARTITION_SIZE;
  104. req.buffer = (unsigned char *)&amap;
  105. req.buffer_len = 4;
  106. req.peripheral_addr = 0x1ffc0;
  107. SDIO_SyncWrite(func, &req);
  108. amap = SDIO_REG_PARTITION_START;
  109. req.buffer = (unsigned char *)&amap;
  110. req.buffer_len = 4;
  111. req.peripheral_addr = 0x1ffcc;
  112. SDIO_SyncWrite(func, &req);
  113. amap = SDIO_REG_PARTITION_SIZE;
  114. req.buffer = (unsigned char *)&amap;
  115. req.buffer_len = 4;
  116. req.peripheral_addr = 0x1ffc8;
  117. SDIO_SyncWrite(func, &req);
  118. /* get TIWLAN1251 ID */
  119. memset(chip_id, 0, 4);
  120. req.buffer = chip_id;
  121. req.buffer_len = 4;
  122. req.peripheral_addr = SDIO_DOWNLOAD_PARTITION_SIZE + CHIP_ID; /* 0x1BE74 */
  123. SDIO_SyncRead(func, &req);
  124. #endif
  125. #ifdef TIWLAN_OMAP1610
  126. /* Can not be read on this stage - SDIO stack is not initialized yet */
  127. amap = TNETW1251_CHIP_ID_PG1_2;
  128. memcpy(chip_id, &amap, 4);
  129. #endif
  130. if ((chip_id[2] >= 1) && (chip_id[2] <= 3)){
  131. tiwlan_chip_id[0] = '1';
  132. tiwlan_chip_id[1] = '2';
  133. tiwlan_chip_id[2] = '5';
  134. tiwlan_chip_id[3] = '1';
  135. tiwlan_chip_id[4] = 'P';
  136. tiwlan_chip_id[5] = 'G';
  137. tiwlan_chip_id[6] = '1';
  138. tiwlan_chip_id[7] = '.';
  139. }
  140. switch(chip_id[2]){
  141. case 1:
  142. tiwlan_chip_id[8] = '0';
  143. printk("TIWLAN: 1251 PG 1.0\n");
  144. break;
  145. case 2:
  146. tiwlan_chip_id[8] = '1';
  147. printk("TIWLAN: 1251 PG 1.1\n");
  148. break;
  149. case 3:
  150. tiwlan_chip_id[8] = '2';
  151. printk("TIWLAN: 1251 PG 1.2\n");
  152. break;
  153. default:
  154. printk("TIWLAN: invalid chip id = 0x%2x%2x%2x%2x!\n",
  155. chip_id[3], chip_id[2], chip_id[1], chip_id[0]);
  156. return -EINVAL;
  157. };
  158. return 0;
  159. }