blob: 872a278261e084c026ce3059fd0f370604992fb1 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
2 * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22#if !defined( __WLAN_QCT_PAL_API_H )
23#define __WLAN_QCT_PAL_API_H
24
25/**=========================================================================
26
27 \file wlan_qct_pal_api.h
28
29 \brief define general APIs PAL exports. wpt = (Wlan Pal Type) wpal = (Wlan PAL)
30
31 Definitions for platform independent
32
33 Copyright 2010 (c) Qualcomm, Incorporated. All Rights Reserved.
34
35 Qualcomm Confidential and Proprietary.
36
37 ========================================================================*/
38
39#include "wlan_qct_pal_type.h"
40#include "wlan_qct_pal_status.h"
41
42#ifdef MEMORY_DEBUG
43#include "vos_memory.h"
44#endif /* MEMORY_DEBUG */
45
46/*********************************MACRO**********************/
47
48// macro to get maximum of two values.
49#define WPAL_MAX( _x, _y ) ( ( (_x) > (_y) ) ? (_x) : (_y) )
50
51// macro to get minimum of two values
52#define WPAL_MIN( _x, _y ) ( ( (_x) < (_y) ) ? (_x) : (_y) )
53
54// macro to get the ceiling of an integer division operation...
55#define WPAL_CEIL_DIV( _a, _b ) ( 0 != (_a) % (_b) ) ? ( (_a) / (_b) + 1 ) : ( (_a) / (_b) )
56
57// macro to return the floor of an integer division operation
58#define WPAL_FLOOR_DIV( _a, _b ) ( ( (_a) - ( (_a) % (_b) ) ) / (_b) )
59
60#define WPAL_SWAP_U16(_x) \
61 ( ( ( (_x) << 8 ) & 0xFF00 ) | ( ( (_x) >> 8 ) & 0x00FF ) )
62
63#define WPAL_SWAP_U32(_x) \
64 ( ( ( (_x) << 24 ) & 0xFF000000 ) | ( ( (_x) >> 24 ) & 0x000000FF ) ) | \
65 ( ( ( (_x) << 8 ) & 0x00FF0000 ) | ( ( (_x) >> 8 ) & 0x0000FF00 ) )
66
67// Endian operations for Big Endian and Small Endian modes
68#ifndef ANI_BIG_BYTE_ENDIAN
69
70//This portion is for little-endian cpu
71#define WPAL_CPU_TO_BE32(_x) WPAL_SWAP_U32(_x)
72#define WPAL_BE32_TO_CPU(_x) WPAL_SWAP_U32(_x)
73#define WPAL_CPU_TO_BE16(_x) WPAL_SWAP_U16(_x)
74#define WPAL_BE16_TO_CPU(_x) WPAL_SWAP_U16(_x)
75#define WPAL_CPU_TO_LE32(_x) (_x)
76#define WPAL_LE32_TO_CPU(_x) (_x)
77#define WPAL_CPU_TO_LE16(_x) (_x)
78#define WPAL_LE16_TO_CPU(_x) (_x)
79
80#else //#ifndef ANI_BIG_BYTE_ENDIAN
81
82//This portion is for big-endian cpu
83#define WPAL_CPU_TO_BE32(_x) (_x)
84#define WPAL_BE32_TO_CPU(_x) (_x)
85#define WPAL_CPU_TO_BE16(_x) (_x)
86#define WPAL_BE16_TO_CPU(_x) (_x)
87#define WPAL_CPU_TO_LE32(_x) WPAL_SWAP_U32(_x)
88#define WPAL_LE32_TO_CPU(_x) WPAL_SWAP_U32(_x)
89#define WPAL_CPU_TO_LE16(_x) WPAL_SWAP_U16(_x)
90#define WPAL_LE16_TO_CPU(_x) WPAL_SWAP_U16(_x)
91
92#endif //#ifndef ANI_BIG_BYTE_ENDIAN
93
94
95/*********************************Generic API*******************************/
96/*---------------------------------------------------------------------------
97 wpalOpen - Initialize PAL
98 Param:
99 ppPalContext – pointer to a caller allocated pointer. It is opaque to caller.
100 Caller save the returned pointer for future use when calling
101 PAL APIs. If this is NULL, it means that PAL doesn't need it.
102 pOSContext - Pointer to a context that is OS specific. This is NULL is a
103 particular PAL doesn't use it for that OS.
104 Return:
105 eWLAN_PAL_STATUS_SUCCESS - success. Otherwise fail.
106---------------------------------------------------------------------------*/
107wpt_status wpalOpen(void **ppPalContext, void *pOSContext);
108
109/*---------------------------------------------------------------------------
110 wpalClose - Release PAL
111 Param:
112 pPalContext – pointer returned from wpalOpen.
113 Return:
114 eWLAN_PAL_STATUS_SUCCESS - success. Otherwise fail.
115---------------------------------------------------------------------------*/
116wpt_status wpalClose(void *pPalContext);
117
118
119/*********************************Memory API********************************/
120#ifdef MEMORY_DEBUG
121/* For Memory Debugging, Hook up PAL memory API to VOS memory API */
122#define wpalMemoryAllocate vos_mem_malloc
123#define wpalMemoryFree vos_mem_free
124#else
125
126/*---------------------------------------------------------------------------
127 wpalMemoryAllocate - Allocate memory
128 Param:
129 size – number of bytes to allocate
130 Return:
131 A pointer to the allocated memory.
132 NULL – fail to allocate memory
133---------------------------------------------------------------------------*/
134void *wpalMemoryAllocate(wpt_uint32 size);
135
136/*---------------------------------------------------------------------------
137 wpalMemoryFree - Free allocated memory
138 Param:
139 pv – pointer to buffer to be freed
140 Return:
141 None
142---------------------------------------------------------------------------*/
143void wpalMemoryFree(void *pv);
144#endif /* MEMORY_DEBUG */
145
146/*---------------------------------------------------------------------------
147 wpalMemoryCopy - copy memory
148 Param:
149 dest – address which data is copied to
150 src – address which data is copied from
151 size – number of bytes to copy
152 Return:
153 eWLAN_PAL_STATUS_SUCCESS
154 eWLAN_PAL_STATUS_INVALID_PARAM
155---------------------------------------------------------------------------*/
156wpt_status wpalMemoryCopy(void * dest, void * src, wpt_uint32 size);
157
158
159/*---------------------------------------------------------------------------
160 wpalMemoryCompare - compare memory
161 Param:
162 buf1 – address of buffer1
163 buf2 – address of buffer2
164 size – number of bytes to compare
165 Return:
166 eWLAN_PAL_TRUE – if two buffers have same content
167 eWLAN_PAL_FALSE – not match
168---------------------------------------------------------------------------*/
169wpt_boolean wpalMemoryCompare(void * buf1, void * buf2, wpt_uint32 size);
170
171/*---------------------------------------------------------------------------
172 wpalMemoryZero - Zero memory
173 Param:
174 buf – address of buffer to be zero
175 size – number of bytes to zero
176 Return:
177 None
178---------------------------------------------------------------------------*/
179void wpalMemoryZero(void *buf, wpt_uint32 size);
180
181
182/*---------------------------------------------------------------------------
183 wpalMemoryFill - Fill memory with one pattern
184 Param:
185 buf – address of buffer to be zero
186 size – number of bytes to zero
187 bFill - one byte of data to fill in (size) bytes from the start of the buffer
188 Return:
189 None
190---------------------------------------------------------------------------*/
191void wpalMemoryFill(void *buf, wpt_uint32 size, wpt_byte bFill);
192
193
194/*---------------------------------------------------------------------------
195 wpalDmaMemoryAllocate - Allocate memory ready for DMA. Aligned at 4-byte
196 Param:
197 pPalContext - PAL context pointer
198 size – number of bytes to allocate
199 ppPhysicalAddr – Physical address of the buffer if allocation succeeds
200 Return:
201 A pointer to the allocated memory (virtual address).
202 NULL – fail to allocate memory
203-----------------------------------------------------------------------------*/
204void *wpalDmaMemoryAllocate(wpt_uint32 size, void **ppPhysicalAddr);
205
206/*---------------------------------------------------------------------------
207 wpalDmaMemoryFree - Free memory ready for DMA
208 Param:
209 pPalContext - PAL context pointer
210 pv – address for the buffer to be freed
211 Return:
212 None
213---------------------------------------------------------------------------*/
214void wpalDmaMemoryFree(void *pv);
215
216
217
218/*---------------------------------------------------------------------------
219 wpalDbgReadRegister - Read register from the WiFi BB chip
220 Param:
221 regAddr - register address
222 pregValue - return value from register if success
223 Return:
224 eWLAN_PAL_STATUS_SUCCESS - when everything is OK
225---------------------------------------------------------------------------*/
226wpt_status wpalDbgReadRegister(wpt_uint32 regAddr, wpt_uint32 *pregValue);
227
228/*---------------------------------------------------------------------------
229 wpalDbgWriteRegister - Write a value to the register in the WiFi BB chip
230 Param:
231 regAddr - register address
232 regValue - value to be written
233 Return:
234 eWLAN_PAL_STATUS_SUCCESS - when everything is OK
235---------------------------------------------------------------------------*/
236wpt_status wpalDbgWriteRegister(wpt_uint32 regAddr, wpt_uint32 regValue);
237
238/*---------------------------------------------------------------------------
239 wpalDbgReadMemory - Read memory from WiFi BB chip space
240 Param:
241 memAddr - address of memory
242 buf - output
243 len - length to be read
244 Return:
245 eWLAN_PAL_STATUS_SUCCESS - when everything is OK
246---------------------------------------------------------------------------*/
247wpt_status wpalDbgReadMemory(wpt_uint32 memAddr, wpt_uint8 *buf, wpt_uint32 len);
248
249/*---------------------------------------------------------------------------
250 wpalDbgWriteMemory - Write a value to the memory in the WiFi BB chip space
251 Param:
252 memAddr - memory address
253 buf - vlaue to be written
254 len - length of buf
255 Return:
256 eWLAN_PAL_STATUS_SUCCESS - when everything is OK
257---------------------------------------------------------------------------*/
258wpt_status wpalDbgWriteMemory(wpt_uint32 memAddr, wpt_uint8 *buf, wpt_uint32 len);
259
260/*---------------------------------------------------------------------------
261 wpalDriverShutdown - Shutdown WLAN driver
262
263 This API is requied by SSR, call in to 'VOS shutdown' to shutdown WLAN
264 driver when Riva crashes.
265
266 Param:
267 None
268 Return:
269 eWLAN_PAL_STATUS_SUCCESS - when everything is OK
270---------------------------------------------------------------------------*/
271wpt_status wpalDriverShutdown(void);
272
273/*---------------------------------------------------------------------------
274 wpalDriverShutdown - Re-init WLAN driver
275
276 This API is requied by SSR, call in to 'VOS re-init' to re-init WLAN
277 driver.
278
279 Param:
280 None
281 Return:
282 eWLAN_PAL_STATUS_SUCCESS - when everything is OK
283---------------------------------------------------------------------------*/
284wpt_status wpalDriverReInit(void);
285
286/*---------------------------------------------------------------------------
287 wpalRivaSubystemRestart - Initiate Riva SSR
288
289 This API is called by WLAN driver to initiate Riva SSR
290
291 Param:
292 None
293 Return:
294 eWLAN_PAL_STATUS_SUCCESS - when everything is OK
295---------------------------------------------------------------------------*/
296wpt_status wpalRivaSubystemRestart(void);
297
Jeff Johnsone7245742012-09-05 17:12:55 -0700298/*---------------------------------------------------------------------------
299 wpalWlanReload - Initiate WLAN Driver reload
300
301 Param:
302 None
303 Return:
304 NONE
305---------------------------------------------------------------------------*/
306void wpalWlanReload(void);
Jeff Johnson295189b2012-06-20 16:38:30 -0700307#endif // __WLAN_QCT_PAL_API_H