support different wifi bt chip auto compatible
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / combo_mt66xx / mt6628 / wlan / os / linux / include / gl_typedef.h
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/os/linux/include/gl_typedef.h#1 $
3 */
4
5 /*! \file   gl_typedef.h
6     \brief  Definition of basic data type(os dependent).
7
8     In this file we define the basic data type.
9 */
10
11
12
13 /*
14 ** $Log: gl_typedef.h $
15  *
16  * 06 22 2012 cp.wu
17  * [WCXRP00001257] [MT6620][MT5931][MT6628][Driver][Linux] Modify KAL_HZ to align ms accuracy
18  * modify KAL_HZ to (1000) for correct definition.
19  *
20  * 03 21 2011 cp.wu
21  * [WCXRP00000540] [MT5931][Driver] Add eHPI8/eHPI16 support to Linux Glue Layer
22  * portability improvement
23  *
24  * 02 15 2011 jeffrey.chang
25  * NULL
26  * to support early suspend in android
27  *
28  * 07 08 2010 cp.wu
29  * 
30  * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
31  *
32  * 06 06 2010 kevin.huang
33  * [WPD00003832][MT6620 5931] Create driver base 
34  * [MT6620 5931] Create driver base
35  *
36  * 03 24 2010 jeffrey.chang
37  * [WPD00003826]Initial import for Linux port 
38  * initial import for Linux port
39 **  \main\maintrunk.MT5921\6 2009-08-18 22:57:14 GMT mtk01090
40 **  Add Linux SDIO (with mmc core) support.
41 **  Add Linux 2.6.21, 2.6.25, 2.6.26.
42 **  Fix compile warning in Linux.
43 **  \main\maintrunk.MT5921\5 2008-09-22 23:19:30 GMT mtk01461
44 **  Update comment for code review
45 **  \main\maintrunk.MT5921\4 2008-09-05 17:25:16 GMT mtk01461
46 **  Update Driver for Code Review
47 **  \main\maintrunk.MT5921\3 2007-11-09 11:00:50 GMT mtk01425
48 **  1. Use macro to unify network-to-host and host-to-network related functions
49 ** Revision 1.3  2007/06/27 02:18:51  MTK01461
50 ** Update SCAN_FSM, Initial(Can Load Module), Proc(Can do Reg R/W), TX API
51 **
52 ** Revision 1.2  2007/06/25 06:16:24  MTK01461
53 ** Update illustrations, gl_init.c, gl_kal.c, gl_kal.h, gl_os.h and RX API
54 **
55 */
56
57 #ifndef _GL_TYPEDEF_H
58 #define _GL_TYPEDEF_H
59
60 #if defined(CONFIG_HAS_EARLYSUSPEND)
61 #include <linux/earlysuspend.h>
62 #endif
63
64 /*******************************************************************************
65 *                         C O M P I L E R   F L A G S
66 ********************************************************************************
67 */
68
69 /*******************************************************************************
70 *                    E X T E R N A L   R E F E R E N C E S
71 ********************************************************************************
72 */
73
74 /*******************************************************************************
75 *                              C O N S T A N T S
76 ********************************************************************************
77 */
78 /* Define HZ of timer tick for function kalGetTimeTick() */
79 #define KAL_HZ                  (1000)
80
81 /* Miscellaneous Equates */
82 #ifndef FALSE
83     #define FALSE               ((BOOL) 0)
84     #define TRUE                ((BOOL) 1)
85 #endif /* FALSE */
86
87 #ifndef NULL
88     #if defined(__cplusplus)
89         #define NULL            0
90     #else
91         #define NULL            ((void *) 0)
92     #endif
93 #endif
94
95 #if defined(CONFIG_HAS_EARLYSUSPEND)
96 typedef void (*early_suspend_callback)(struct early_suspend *h);
97 typedef void (*late_resume_callback) (struct early_suspend *h);
98 #endif
99
100
101 /*******************************************************************************
102 *                             D A T A   T Y P E S
103 ********************************************************************************
104 */
105 /* Type definition for void */
106 typedef void                    VOID, *PVOID, **PPVOID;
107
108 /* Type definition for Boolean */
109 typedef unsigned char           BOOL, *PBOOL, BOOLEAN, *PBOOLEAN;
110
111 /* Type definition for signed integers */
112 typedef signed char             CHAR, *PCHAR, **PPCHAR;
113 typedef signed char             INT_8, *PINT_8, **PPINT_8;
114 typedef signed short            INT_16, *PINT_16, **PPINT_16;
115 typedef signed long             INT_32, *PINT_32, **PPINT_32;
116 typedef signed long long        INT_64, *PINT_64, **PPINT_64;
117
118 /* Type definition for unsigned integers */
119 typedef unsigned char           UCHAR, *PUCHAR, **PPUCHAR;
120 typedef unsigned char           UINT_8, *PUINT_8, **PPUINT_8, *P_UINT_8;
121 typedef unsigned short          UINT_16, *PUINT_16, **PPUINT_16;
122 typedef unsigned long           ULONG, UINT_32, *PUINT_32, **PPUINT_32;
123 typedef unsigned long long      UINT_64, *PUINT_64, **PPUINT_64;
124
125 typedef unsigned long           OS_SYSTIME, *POS_SYSTIME, **PPOS_SYSTIME;
126
127
128 /* Type definition of large integer (64bits) union to be comptaible with
129  * Windows definition, so we won't apply our own coding style to these data types.
130  * NOTE: LARGE_INTEGER must NOT be floating variable.
131  * <TODO>: Check for big-endian compatibility.
132  */
133 typedef union _LARGE_INTEGER {
134     struct {
135         UINT_32  LowPart;
136         INT_32   HighPart;
137     } u;
138     INT_64       QuadPart;
139 } LARGE_INTEGER, *PLARGE_INTEGER;
140
141 typedef union _ULARGE_INTEGER {
142     struct {
143         UINT_32  LowPart;
144         UINT_32  HighPart;
145     } u;
146     UINT_64      QuadPart;
147 } ULARGE_INTEGER, *PULARGE_INTEGER;
148
149
150 typedef INT_32 (*probe_card)(PVOID pvData);
151 typedef VOID (*remove_card)(VOID);
152
153 /*******************************************************************************
154 *                            P U B L I C   D A T A
155 ********************************************************************************
156 */
157
158 /*******************************************************************************
159 *                           P R I V A T E   D A T A
160 ********************************************************************************
161 */
162
163 /*******************************************************************************
164 *                                 M A C R O S
165 ********************************************************************************
166 */
167 #define IN  //volatile
168 #define OUT //volatile
169
170 #define __KAL_INLINE__                  static __inline__
171 #define __KAL_ATTRIB_PACKED__           __attribute__((__packed__))
172 #define __KAL_ATTRIB_ALIGN_4__          __attribute__ ((aligned (4)))
173
174
175 #ifndef BIT
176 #define BIT(n)                          ((UINT_32) 1UL << (n))
177 #endif /* BIT */
178
179 #ifndef BITS
180 /* bits range: for example BITS(16,23) = 0xFF0000
181  *   ==>  (BIT(m)-1)   = 0x0000FFFF     ~(BIT(m)-1)   => 0xFFFF0000
182  *   ==>  (BIT(n+1)-1) = 0x00FFFFFF
183  */
184 #define BITS(m,n)                       (~(BIT(m)-1) & ((BIT(n) - 1) | BIT(n)))
185 #endif /* BIT */
186
187
188 /* This macro returns the byte offset of a named field in a known structure
189    type.
190    _type - structure name,
191    _field - field name of the structure */
192 #ifndef OFFSET_OF
193     #define OFFSET_OF(_type, _field)    ((UINT_32)&(((_type *)0)->_field))
194 #endif /* OFFSET_OF */
195
196
197 /* This macro returns the base address of an instance of a structure
198  * given the type of the structure and the address of a field within the
199  * containing structure.
200  * _addrOfField - address of current field of the structure,
201  * _type - structure name,
202  * _field - field name of the structure
203  */
204 #ifndef ENTRY_OF
205     #define ENTRY_OF(_addrOfField, _type, _field) \
206         ((_type *)((PINT_8)(_addrOfField) - (PINT_8)OFFSET_OF(_type, _field)))
207 #endif /* ENTRY_OF */
208
209
210 /* This macro align the input value to the DW boundary.
211  * _value - value need to check
212  */
213 #ifndef ALIGN_4
214     #define ALIGN_4(_value)             (((_value) + 3) & ~3u)
215 #endif /* ALIGN_4 */
216
217 /* This macro check the DW alignment of the input value.
218  * _value - value of address need to check
219  */
220 #ifndef IS_ALIGN_4
221     #define IS_ALIGN_4(_value)          (((_value) & 0x3) ? FALSE : TRUE)
222 #endif /* IS_ALIGN_4 */
223
224 #ifndef IS_NOT_ALIGN_4
225     #define IS_NOT_ALIGN_4(_value)      (((_value) & 0x3) ? TRUE : FALSE)
226 #endif /* IS_NOT_ALIGN_4 */
227
228
229 /* This macro evaluate the input length in unit of Double Word(4 Bytes).
230  * _value - value in unit of Byte, output will round up to DW boundary.
231  */
232 #ifndef BYTE_TO_DWORD
233     #define BYTE_TO_DWORD(_value)       ((_value + 3) >> 2)
234 #endif /* BYTE_TO_DWORD */
235
236 /* This macro evaluate the input length in unit of Byte.
237  * _value - value in unit of DW, output is in unit of Byte.
238  */
239 #ifndef DWORD_TO_BYTE
240     #define DWORD_TO_BYTE(_value)       ((_value) << 2)
241 #endif /* DWORD_TO_BYTE */
242
243 #if 1 // Little-Endian
244     #define CONST_NTOHS(_x)     __constant_ntohs(_x)
245
246     #define CONST_HTONS(_x)     __constant_htons(_x)
247
248     #define NTOHS(_x)           ntohs(_x)
249
250     #define HTONS(_x)           htons(_x)
251
252     #define NTOHL(_x)           ntohl(_x)
253
254     #define HTONL(_x)           htonl(_x)
255
256 #else // Big-Endian
257
258     #define CONST_NTOHS(_x)
259
260     #define CONST_HTONS(_x)
261
262     #define NTOHS(_x)
263
264     #define HTONS(_x)
265
266 #endif
267
268 /*******************************************************************************
269 *                  F U N C T I O N   D E C L A R A T I O N S
270 ********************************************************************************
271 */
272
273 /*******************************************************************************
274 *                              F U N C T I O N S
275 ********************************************************************************
276 */
277
278 #endif /* _GL_TYPEDEF_H */
279