summaryrefslogtreecommitdiff
path: root/sta_dk_4_0_4_32/pform/linux/inc/esta_drv.h
blob: b181124627954c9d1ba0a297392cb49d9d5f06fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/****************************************************************************
**+-----------------------------------------------------------------------+**
**|                                                                       |**
**| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
**| All rights reserved.                                                  |**
**|                                                                       |**
**| Redistribution and use in source and binary forms, with or without    |**
**| modification, are permitted provided that the following conditions    |**
**| are met:                                                              |**
**|                                                                       |**
**|  * Redistributions of source code must retain the above copyright     |**
**|    notice, this list of conditions and the following disclaimer.      |**
**|  * Redistributions in binary form must reproduce the above copyright  |**
**|    notice, this list of conditions and the following disclaimer in    |**
**|    the documentation and/or other materials provided with the         |**
**|    distribution.                                                      |**
**|  * Neither the name Texas Instruments nor the names of its            |**
**|    contributors may be used to endorse or promote products derived    |**
**|    from this software without specific prior written permission.      |**
**|                                                                       |**
**| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
**| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
**| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
**| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
**| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
**| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
**| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
**| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
**| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
**| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
**| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
**|                                                                       |**
**+-----------------------------------------------------------------------+**
****************************************************************************/


#ifndef ESTA_DRV_INCLUDE_FILE
#define ESTA_DRV_INCLUDE_FILE

#include <linux/version.h>
#include <linux/completion.h>
#include <linux/netdevice.h>
#include <linux/interrupt.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
#include <asm/arch/gpio.h>
#else
#include <asm/gpio.h>
#endif

#ifdef CONFIG_TROUT_PWRSINK
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
#include <asm/arch/trout_pwrsink.h>
#else
#include <mach/trout_pwrsink.h>
#endif
#endif

#ifdef CONFIG_ANDROID_POWER
#include <linux/android_power.h>
#endif

#include "osTIType.h"
#include "osAdapter.h"
#include "paramOut.h"
#ifndef GWSI_DRIVER /* for GWSI Stand Alone */
#include "configMgr.h"
#endif
#include "linux_ioctl_common.h"

#define TIWLAN_DRV_NAME    "tiwlan"
#define TIWLAN_DRV_IF_NAME TIWLAN_DRV_NAME"%d"
#define TIWLAN_DRV_NAME_WIRELESS_PROTO "IEEE 802.11-DS"

#ifdef TIWLAN_MSM7000
#ifdef CONFIG_WIFI_CONTROL_FUNC
#include <linux/platform_device.h>
#include <mach/msm_wifi.h>
int msm_wifi_power(int on);
int msm_wifi_reset(int on);
#else
extern int trout_wifi_power(int on);
extern void trout_wifi_reset(int on);
extern void trout_wifi_set_carddetect(int val);
#define msm_wifi_power(a)	trout_wifi_power(a)
#define msm_wifi_reset(a)	trout_wifi_reset(a)
#endif
#endif

#ifndef TIWLAN_OMAP1610_REGBASE

#if defined(TIWLAN_OMAP1610_INNOVATOR)
#define TIWLAN_OMAP1610_REGBASE	0xEC100000	/* VA*/
#elif defined(TIWLAN_OMAP1610_WIPP) || defined(TIWLAN_OMAP1610_CRTWIPP) 
#ifndef OMAP_WLAN_BASE
#define OMAP_WLAN_BASE  0
#endif
#define TIWLAN_OMAP1610_REGBASE	(OMAP_WLAN_BASE+0x100000)
#else
/* Dm: #error TIWLAN_OMAP1610_REGBASE not defined for this platform */
#endif

#endif /* #ifndef TIWLAN_OMAP1610_REGBASE */

#ifdef TIWLAN_OMAP1610_REGBASE

#define TIWLAN_OMAP1610_REGSIZE 0x10000
#define TIWLAN_OMAP1610_MEMBASE (TIWLAN_OMAP1610_REGBASE | 0x20000)
#define TIWLAN_OMAP1610_MEMSIZE 0x10000

#endif /* #ifdef TIWLAN_OMAP1610_REGBASE */

#ifndef TIWLAN_OMAP1610_IRQ

#if defined(TIWLAN_OMAP1610_INNOVATOR)
#define TIWLAN_OMAP1610_IRQ     (OMAP_GPIO_IRQ(8))
#elif defined(TIWLAN_OMAP1610_CRTWIPP)
#define TIWLAN_OMAP1610_IRQ     (OMAP_GPIO_IRQ(2))
#elif defined(TIWLAN_OMAP1610_WIPP)
#define TIWLAN_OMAP1610_IRQ     (OMAP_GPIO_IRQ(2))
#endif

#endif	 /* TIWLAN_OMAP1610_IRQ */
#define TIWLAN_IRQ_POLL_INTERVAL  HZ/100  /* Used when no Intr are handled from the FW */


#ifdef TI_DBG
#define ti_dprintf(log, fmt, args...) do { \
   if (log != TIWLAN_LOG_OTHER) {   \
      printk(KERN_INFO fmt, ## args); \
   } \
} while (0)
#else
#define ti_dprintf(log, fmt, args...)
#endif


#define ti_nodprintf(log, fmt, args...)

typedef enum {
   TIWLAN_LOG_ERROR,
   TIWLAN_LOG_INFO,
   TIWLAN_LOG_OTHER,
   TIWLAN_LOG_DUMMY
} tiwlan_log_t;

typedef struct tiwlan_region {
      unsigned long pa;
      void *va;
      unsigned long size;
} tiwlan_region_t;

/* Driver structure */
typedef struct tiwlan_net_dev tiwlan_net_dev_t;

#if defined (__KERNEL__)
/* Request/response to/from control tasklet */
typedef struct tiwlan_req {
      struct list_head list;
      tiwlan_net_dev_t *drv;
      struct
      {
            struct {
                  int (*f)(struct tiwlan_req *req);
                  unsigned long p1;
                  unsigned long p2;
                  unsigned long p3;
                  unsigned long p4;
                  int reply_expected;     /* 1=reply expected */
                  struct completion comp;
            } req;
            int reply;
      } u;
} tiwlan_req_t;

/* Timer structure */
typedef struct timer_obj {
      tiwlan_req_t req;
         /* Timer handler function ->p1 */
         /* Timer handler function parameter ->p2 */
         /* Periodic ->p3 */
         /* jiffies ->p4 */
      struct timer_list  timer;
      int use_count;
} timer_obj_t;


#ifdef DRIVER_PROFILING

/* Profiler banchmark function type */
typedef void (*tiwlan_pfofile_t) (void*, unsigned);

/* Maximum number of profile banchmarks */
#define MAX_PROFILE_BM 10

#endif

#ifdef CONFIG_TROUT_PWRSINK
#define PWRSINK_WIFI_PERCENT_BASE 4
#endif

/* #define DM_USE_WORKQUEUE */

/* Driver structure */
struct tiwlan_net_dev {
      struct list_head list;

      tiwlan_region_t acx_mem;
      tiwlan_region_t acx_reg;
      tiwlan_region_t eeprom_image;
      tiwlan_region_t firmware_image;
      int irq;
#ifdef DM_USE_WORKQUEUE
      struct workqueue_struct *tiwlan_wq; /* Work Queue */
      struct work_struct tirq;         /* Work Task for interrupt */
      struct work_struct tw;           /* Work Task for other stuff */
      mem_MSDU_T *txmit_msdu_next;
      mem_MSDU_T *txmit_msdu_last;
      struct work_struct txmit;        /* Work Task for transmit */
#else
      struct tasklet_struct tl;        /* Control tasklet */
#endif
#ifdef CONFIG_TROUT_PWRSINK
      struct delayed_work trxw;        /* Work Task for rx watchdog */
#endif
#ifdef CONFIG_ANDROID_POWER
      android_suspend_lock_t irq_wake_lock; /* Suspend Lock to keep system awake */
      android_suspend_lock_t xmit_wake_lock;
      android_suspend_lock_t timer_wake_lock;
      android_suspend_lock_t rx_wake_lock;
      int receive_packet;              /* 1=packet was pushed to network stack */
#endif
      int interrupt_pending;           /* 1=tasklet has to handle interrupts when awakes */
      int dma_done;
      struct list_head request_q;      /* Requests queue: -> tasklet */
      spinlock_t lock;
      unsigned long flags;
      struct timer_list poll_timer;    /* Polling timer. Used only when working without interrupts */
      int started;                     /* 1=config manager started. 0=config manager stopped */
      int initialized;                 /* 1=succeeded to pass init stage, 0=otherwise */     
      int unload_driver;               /* Driver unload indicator */
      struct net_device_stats stats;
      int alloc_msdu_failures;         /* Extra statistics */
      initTable_t  init_table;
      TIWLN_ADAPTER_T adapter;
      struct sock *wl_sock;
      struct completion comp;
      struct net_device *netdev;
      void *priv;                      /* Pointer to struct net_device */

#ifdef DRIVER_PROFILING
      tiwlan_pfofile_t fpro [MAX_PROFILE_BM];   /* Profiler functions */

      unsigned max_number_of_timers;            /* Maximum number of allocated timers */
      unsigned cur_number_of_timers;            /* Current number of allocated timers */

      unsigned max_heap_bytes_allocated;        /* Maximum number of allocated bytes on the heap */
      unsigned cur_heap_bytes_allocated;        /* Current number of allocated bytes on the heap */
      unsigned max_buf_bytes_allocated;         /* Maximum number of allocated bytes on the heap for TX/RX buffers */

      unsigned cpu_usage_estimator_start_time;  /* Time measured when CPU estimation was started */
      unsigned cpu_usage_estimator_stop_time;   /* Time measured when CPU estimation was stopped */
      unsigned cpu_usage_estimator_resolution;  /* Resolution of the CPU estimation in us */
      unsigned total_us_of_cpu_time;            /* Total number of CPU time used by the driver since CPU estimator started */
      unsigned total_us_of_bus_access_cpu_time; /* Total number of CPU time used by the bus driver since CPU estimator started */
      unsigned driver_entry_start_time;         /* Time measured at the start of last driver entry point */
      unsigned bus_driver_entry_start_time;     /* Time measured at the start of last bus driver entry point */
#endif

#ifdef GWSI_DRIVER
      void *gwsi;                      /* GWSI manager handler */
      void *gwsi_ev;                   /* GWSI event handler */
      char  gwsi_tester_buf [4096];    /* GWSI tester buffer */                                        
#endif
};


#define VENDOR_ID_TI            0x104c
#define DEVICE_ID_TI_WLAN       0x9066

/* tiwlan_send_wait_reply
   This internal interface function creates request and sends
   it to the control tasklet for processing.
   The calling process is blocked until the request is replied.
   Function f is being called in the context of the control tasklet.
   The request block that is passed to the function as a parameter
   contains p1, p2, p3, p4.
   The function return code is propagated back to the caller.
   tiwlan_send_req_and_wait returns (*f) return code or
   -ENOMEM if failed to allocate a request.
*/
int tiwlan_send_wait_reply(tiwlan_net_dev_t *drv,
                           int (*f)(tiwlan_req_t *req),
                           unsigned long p1,
                           unsigned long p2,
                           unsigned long p3,
                           unsigned long p4);

#endif /* #if defined (__KERNEL__)*/

int tiwlan_init_drv(tiwlan_net_dev_t *drv, tiwlan_dev_init_t *init_info);
int tiwlan_start_drv(tiwlan_net_dev_t *drv);
int tiwlan_stop_drv(tiwlan_net_dev_t *drv);
int tiwlan_stop_and_destroy_drv(tiwlan_net_dev_t *drv);
int tiwlan_ioctl_init(struct net_device *dev);

#endif /* ESTA_DRV_INCLUDE_FILE*/