PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/pform/linux/inc/esta_drv.h

http://github.com/CyanogenMod/cm-kernel
C Header | 335 lines | 229 code | 49 blank | 57 comment | 6 complexity | 93521fd9a32721ffb434606915594510 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. #ifndef ESTA_DRV_INCLUDE_FILE
  36. #define ESTA_DRV_INCLUDE_FILE
  37. #include <linux/version.h>
  38. #include <linux/completion.h>
  39. #include <linux/netdevice.h>
  40. #include <linux/interrupt.h>
  41. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
  42. #include <asm/arch/gpio.h>
  43. #ifdef CONFIG_ANDROID_POWER
  44. #include <linux/android_power.h>
  45. #endif
  46. #else
  47. #include <asm/gpio.h>
  48. #ifdef CONFIG_HAS_WAKELOCK
  49. #include <linux/wakelock.h>
  50. #endif
  51. #endif
  52. #ifdef CONFIG_TROUT_PWRSINK
  53. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
  54. #include <asm/arch/trout_pwrsink.h>
  55. #else
  56. #include <mach/trout_pwrsink.h>
  57. #endif
  58. #endif
  59. #ifdef CONFIG_HTC_PWRSINK
  60. #include <mach/htc_pwrsink.h>
  61. #endif
  62. #include "osTIType.h"
  63. #include "osAdapter.h"
  64. #include "paramOut.h"
  65. #ifndef GWSI_DRIVER /* for GWSI Stand Alone */
  66. #include "configMgr.h"
  67. #endif
  68. #include "linux_ioctl_common.h"
  69. #define TIWLAN_DRV_NAME "tiwlan"
  70. #define TIWLAN_DRV_IF_NAME TIWLAN_DRV_NAME"%d"
  71. #define TIWLAN_DRV_NAME_WIRELESS_PROTO "IEEE 802.11-DS"
  72. #define TIWLAN_DBG_PROC "wifidbg"
  73. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
  74. #define NETDEV_SET_PRIVATE(dev, drv) dev->priv = drv
  75. #define NETDEV_GET_PRIVATE(dev) dev->priv
  76. #else
  77. #define NETDEV_SET_PRIVATE(dev, drv) dev->ml_priv = drv
  78. #define NETDEV_GET_PRIVATE(dev) dev->ml_priv
  79. #endif
  80. void *wifi_kernel_prealloc(int section, unsigned long size);
  81. #ifdef TIWLAN_MSM7000
  82. #ifdef CONFIG_WIFI_CONTROL_FUNC
  83. #include <linux/platform_device.h>
  84. #include <linux/wifi_tiwlan.h>
  85. int msm_wifi_power(int on);
  86. int msm_wifi_reset(int on);
  87. #else
  88. extern int trout_wifi_power(int on);
  89. extern int trout_wifi_reset(int on);
  90. extern int trout_wifi_set_carddetect(int val);
  91. #define msm_wifi_power(a) trout_wifi_power(a)
  92. #define msm_wifi_reset(a) trout_wifi_reset(a)
  93. #endif
  94. #endif
  95. #ifdef CONFIG_HAS_WAKELOCK
  96. #define CONFIG_ANDROID_POWER
  97. typedef struct wake_lock android_suspend_lock_t;
  98. #define android_unlock_suspend(a) wake_unlock(a)
  99. #define android_lock_suspend(a) wake_lock(a)
  100. #define android_lock_suspend_auto_expire(a,t) wake_lock_timeout(a,t)
  101. #define android_init_suspend_wakelock(a,n) wake_lock_init(a,WAKE_LOCK_SUSPEND,n)
  102. #define android_uninit_suspend_lock(a) wake_lock_destroy(a)
  103. #endif
  104. #ifndef TIWLAN_OMAP1610_REGBASE
  105. #if defined(TIWLAN_OMAP1610_INNOVATOR)
  106. #define TIWLAN_OMAP1610_REGBASE 0xEC100000 /* VA*/
  107. #elif defined(TIWLAN_OMAP1610_WIPP) || defined(TIWLAN_OMAP1610_CRTWIPP)
  108. #ifndef OMAP_WLAN_BASE
  109. #define OMAP_WLAN_BASE 0
  110. #endif
  111. #define TIWLAN_OMAP1610_REGBASE (OMAP_WLAN_BASE+0x100000)
  112. #else
  113. /* Dm: #error TIWLAN_OMAP1610_REGBASE not defined for this platform */
  114. #endif
  115. #endif /* #ifndef TIWLAN_OMAP1610_REGBASE */
  116. #ifdef TIWLAN_OMAP1610_REGBASE
  117. #define TIWLAN_OMAP1610_REGSIZE 0x10000
  118. #define TIWLAN_OMAP1610_MEMBASE (TIWLAN_OMAP1610_REGBASE | 0x20000)
  119. #define TIWLAN_OMAP1610_MEMSIZE 0x10000
  120. #endif /* #ifdef TIWLAN_OMAP1610_REGBASE */
  121. #ifndef TIWLAN_OMAP1610_IRQ
  122. #if defined(TIWLAN_OMAP1610_INNOVATOR)
  123. #define TIWLAN_OMAP1610_IRQ (OMAP_GPIO_IRQ(8))
  124. #elif defined(TIWLAN_OMAP1610_CRTWIPP)
  125. #define TIWLAN_OMAP1610_IRQ (OMAP_GPIO_IRQ(2))
  126. #elif defined(TIWLAN_OMAP1610_WIPP)
  127. #define TIWLAN_OMAP1610_IRQ (OMAP_GPIO_IRQ(2))
  128. #endif
  129. #endif /* TIWLAN_OMAP1610_IRQ */
  130. #define TIWLAN_IRQ_POLL_INTERVAL HZ/100 /* Used when no Intr are handled from the FW */
  131. #ifdef TI_DBG
  132. #define ti_dprintf(log, fmt, args...) do { \
  133. if (log != TIWLAN_LOG_OTHER) { \
  134. printk(KERN_INFO fmt, ## args); \
  135. } \
  136. } while (0)
  137. #else
  138. #define ti_dprintf(log, fmt, args...)
  139. #endif
  140. #define ti_nodprintf(log, fmt, args...)
  141. typedef enum {
  142. TIWLAN_LOG_ERROR,
  143. TIWLAN_LOG_INFO,
  144. TIWLAN_LOG_OTHER,
  145. TIWLAN_LOG_DUMMY
  146. } tiwlan_log_t;
  147. typedef struct tiwlan_region {
  148. unsigned long pa;
  149. void *va;
  150. unsigned long size;
  151. } tiwlan_region_t;
  152. /* Driver structure */
  153. typedef struct tiwlan_net_dev tiwlan_net_dev_t;
  154. #if defined (__KERNEL__)
  155. /* Request/response to/from control tasklet */
  156. typedef struct tiwlan_req {
  157. struct list_head list;
  158. tiwlan_net_dev_t *drv;
  159. struct
  160. {
  161. struct {
  162. int (*f)(struct tiwlan_req *req);
  163. unsigned long p1;
  164. unsigned long p2;
  165. unsigned long p3;
  166. unsigned long p4;
  167. int reply_expected; /* 1=reply expected */
  168. struct completion comp;
  169. } req;
  170. int reply;
  171. } u;
  172. } tiwlan_req_t;
  173. /* Timer structure */
  174. typedef struct timer_obj {
  175. tiwlan_req_t req;
  176. /* Timer handler function ->p1 */
  177. /* Timer handler function parameter ->p2 */
  178. /* Periodic ->p3 */
  179. /* jiffies ->p4 */
  180. struct timer_list timer;
  181. int use_count;
  182. } timer_obj_t;
  183. #ifdef DRIVER_PROFILING
  184. /* Profiler banchmark function type */
  185. typedef void (*tiwlan_pfofile_t) (void*, unsigned);
  186. /* Maximum number of profile banchmarks */
  187. #define MAX_PROFILE_BM 10
  188. #endif
  189. #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK)
  190. #define PWRSINK_WIFI_PERCENT_BASE 4
  191. #endif
  192. /* #define DM_USE_WORKQUEUE */
  193. /* Driver structure */
  194. struct tiwlan_net_dev {
  195. struct list_head list;
  196. tiwlan_region_t acx_mem;
  197. tiwlan_region_t acx_reg;
  198. tiwlan_region_t eeprom_image;
  199. tiwlan_region_t firmware_image;
  200. int irq;
  201. #ifdef DM_USE_WORKQUEUE
  202. struct workqueue_struct *tiwlan_wq; /* Work Queue */
  203. struct work_struct tirq; /* Work Task for interrupt */
  204. struct work_struct tw; /* Work Task for other stuff */
  205. mem_MSDU_T *txmit_msdu_next;
  206. mem_MSDU_T *txmit_msdu_last;
  207. struct work_struct txmit; /* Work Task for transmit */
  208. #else
  209. struct tasklet_struct tl; /* Control tasklet */
  210. #endif
  211. #if defined(CONFIG_TROUT_PWRSINK) || defined(CONFIG_HTC_PWRSINK)
  212. struct delayed_work trxw; /* Work Task for rx watchdog */
  213. #endif
  214. #ifdef CONFIG_ANDROID_POWER
  215. android_suspend_lock_t irq_wake_lock; /* Suspend Lock to keep system awake */
  216. android_suspend_lock_t xmit_wake_lock;
  217. android_suspend_lock_t timer_wake_lock;
  218. android_suspend_lock_t rx_wake_lock;
  219. android_suspend_lock_t exec_wake_lock;
  220. int receive_packet; /* 1=packet was pushed to network stack */
  221. #endif
  222. int interrupt_pending; /* 1=tasklet has to handle interrupts when awakes */
  223. int dma_done;
  224. struct list_head request_q; /* Requests queue: -> tasklet */
  225. spinlock_t lock;
  226. unsigned long flags;
  227. struct timer_list poll_timer; /* Polling timer. Used only when working without interrupts */
  228. int started; /* 1=config manager started. 0=config manager stopped */
  229. int initialized; /* 1=succeeded to pass init stage, 0=otherwise */
  230. int unload_driver; /* Driver unload indicator */
  231. struct net_device_stats stats;
  232. int alloc_msdu_failures; /* Extra statistics */
  233. initTable_t init_table;
  234. TIWLN_ADAPTER_T adapter;
  235. struct sock *wl_sock;
  236. struct completion comp;
  237. struct net_device *netdev;
  238. void *priv; /* Pointer to struct net_device */
  239. #ifdef DRIVER_PROFILING
  240. tiwlan_pfofile_t fpro [MAX_PROFILE_BM]; /* Profiler functions */
  241. unsigned max_number_of_timers; /* Maximum number of allocated timers */
  242. unsigned cur_number_of_timers; /* Current number of allocated timers */
  243. unsigned max_heap_bytes_allocated; /* Maximum number of allocated bytes on the heap */
  244. unsigned cur_heap_bytes_allocated; /* Current number of allocated bytes on the heap */
  245. unsigned max_buf_bytes_allocated; /* Maximum number of allocated bytes on the heap for TX/RX buffers */
  246. unsigned cpu_usage_estimator_start_time; /* Time measured when CPU estimation was started */
  247. unsigned cpu_usage_estimator_stop_time; /* Time measured when CPU estimation was stopped */
  248. unsigned cpu_usage_estimator_resolution; /* Resolution of the CPU estimation in us */
  249. unsigned total_us_of_cpu_time; /* Total number of CPU time used by the driver since CPU estimator started */
  250. unsigned total_us_of_bus_access_cpu_time; /* Total number of CPU time used by the bus driver since CPU estimator started */
  251. unsigned driver_entry_start_time; /* Time measured at the start of last driver entry point */
  252. unsigned bus_driver_entry_start_time; /* Time measured at the start of last bus driver entry point */
  253. #endif
  254. #ifdef GWSI_DRIVER
  255. void *gwsi; /* GWSI manager handler */
  256. void *gwsi_ev; /* GWSI event handler */
  257. char gwsi_tester_buf [4096]; /* GWSI tester buffer */
  258. #endif
  259. };
  260. #define VENDOR_ID_TI 0x104c
  261. #define DEVICE_ID_TI_WLAN 0x9066
  262. /* tiwlan_send_wait_reply
  263. This internal interface function creates request and sends
  264. it to the control tasklet for processing.
  265. The calling process is blocked until the request is replied.
  266. Function f is being called in the context of the control tasklet.
  267. The request block that is passed to the function as a parameter
  268. contains p1, p2, p3, p4.
  269. The function return code is propagated back to the caller.
  270. tiwlan_send_req_and_wait returns (*f) return code or
  271. -ENOMEM if failed to allocate a request.
  272. */
  273. int tiwlan_send_wait_reply(tiwlan_net_dev_t *drv,
  274. int (*f)(tiwlan_req_t *req),
  275. unsigned long p1,
  276. unsigned long p2,
  277. unsigned long p3,
  278. unsigned long p4);
  279. #endif /* #if defined (__KERNEL__)*/
  280. int tiwlan_init_drv(tiwlan_net_dev_t *drv, tiwlan_dev_init_t *init_info);
  281. int tiwlan_start_drv(tiwlan_net_dev_t *drv);
  282. int tiwlan_stop_drv(tiwlan_net_dev_t *drv);
  283. int tiwlan_stop_and_destroy_drv(tiwlan_net_dev_t *drv);
  284. int tiwlan_stop_and_destroy_drv_request(tiwlan_req_t *req);
  285. int tiwlan_ioctl_init(struct net_device *dev);
  286. #endif /* ESTA_DRV_INCLUDE_FILE*/