ath9k_htc: Update to upstream's commit d19607454d656cb14d8c16dfbf161eebb542e8fe dated...
[linux-libre-firmware.git] / ath9k_htc / target_firmware / magpie_fw_dev / target / inc / adf_os_types.h
1 /*
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted (subject to the limitations in the
7  * disclaimer below) provided that the following conditions are met:
8  *
9  *  * Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *  * Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *  * Neither the name of Qualcomm Atheros 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  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 /**
36  * @ingroup adf_os_public
37  * @file adf_os_types.h
38  * This file defines types used in the OS abstraction API.
39  */
40
41 #ifndef _ADF_OS_TYPES_H
42 #define _ADF_OS_TYPES_H
43
44
45 #include <adf_os_stdtypes.h>
46 #include <adf_os_types_pvt.h>
47
48 #define ADF_OS_MAX_SCATTER  __ADF_OS_MAX_SCATTER
49 /**
50  * @brief Max number of scatter-gather segments.
51  */
52 #define ADF_OS_MAX_SGLIST   4
53
54 /**
55  * @brief denotes structure is packed.
56  */
57 #define adf_os_packed       __adf_os_packed
58
59 /**
60  * @brief handles opaque to each other
61  */
62 typedef void *      adf_net_handle_t;
63 typedef void *      adf_drv_handle_t;
64 typedef void *      adf_os_handle_t;
65
66 /*
67  * XXX FIXME For compilation only.
68  *
69  */
70 typedef void *      adf_os_pm_t;
71
72 /**
73  * @brief Platform/bus generic handle. Used for bus specific functions.
74  */
75 typedef __adf_os_device_t              adf_os_device_t;
76
77 /**
78  * @brief size of an object
79  */
80 typedef __adf_os_size_t                adf_os_size_t;
81
82 /**
83  * @brief offset for API's that need them.
84  */
85 typedef __adf_os_off_t      adf_os_off_t;
86
87 /**
88  * @brief DMA mapping object.
89  */
90 typedef __adf_os_dma_map_t  adf_os_dma_map_t;
91
92 /**
93  * @brief DMA address.
94  */
95 typedef __adf_os_dma_addr_t     adf_os_dma_addr_t;
96
97 /**
98  * @brief DMA size.
99  */
100 typedef __adf_os_dma_size_t     adf_os_dma_size_t;
101
102 /**
103  * @brief Information inside a DMA map.
104  */
105 typedef struct adf_os_dmamap_info{
106     a_uint32_t                  nsegs;      /**< total number mapped segments*/
107     struct __dma_segs{
108         adf_os_dma_addr_t       paddr;      /**< physical(dma'able) address of the segment*/
109         adf_os_dma_size_t       len;        /**< length of the segment*/
110     } dma_segs[ADF_OS_MAX_SCATTER];
111
112 }adf_os_dmamap_info_t;
113
114 /**
115  * @brief Representation of a scatter-gather list.
116  */
117 typedef struct adf_os_sglist{
118     a_uint32_t                  nsegs;      /**< total number of segments*/
119     struct __sg_segs{
120         a_uint8_t              *vaddr;      /**< Virtual address of the segment*/
121         a_uint32_t              len;        /**< Length of the segment*/
122     } sg_segs[ADF_OS_MAX_SGLIST];
123
124 }adf_os_sglist_t;
125
126 /**
127  *  @brief All operations specified below are performed from
128  *  the host memory point of view, where a read
129  *  implies data coming from the device to the host
130  *  memory, and a write implies data going from the
131  *  host memory to the device.  Alternately, the
132  *  operations can be thought of in terms of driver
133  *  operations, where reading a network packet or
134  *  storage sector corresponds to a read operation in
135  *  bus_dma.
136  *
137  *  ADF_SYNC_PREREAD       Perform any synchronization
138  *                         required prior to an update
139  *                         of host memory by the DMA
140  *                         read operation.
141  *  ADF_SYNC_PREWRITE      Perform any synchronization
142  *                         required after an update of
143  *                         host memory by the CPU and
144  *                         prior to DMA write
145  *                         operations.
146  *  ADF_SYNC_POSTREAD      Perform any synchronization
147  *                         required after DMA read
148  *                         operations and prior to CPU
149  *                         access to host
150  *                         memory.
151  *  ADF_SYNC_POSTWRITE     Perform any synchronization
152  *                         required after DMA write
153  *                                   operations.
154  */
155
156 typedef enum adf_os_cache_sync{
157     ADF_SYNC_PREREAD=__ADF_SYNC_PREREAD,
158     ADF_SYNC_PREWRITE=__ADF_SYNC_PREWRITE,
159     ADF_SYNC_POSTREAD=__ADF_SYNC_POSTREAD,
160     ADF_SYNC_POSTWRITE=__ADF_SYNC_POSTWRITE
161 }adf_os_cache_sync_t;
162
163 /**
164  * @brief Generic status to be used by adf_drv.
165  */
166 typedef enum {
167     A_STATUS_OK,
168     A_STATUS_FAILED,
169     A_STATUS_ENOENT,
170     A_STATUS_ENOMEM,
171     A_STATUS_EINVAL,
172     A_STATUS_EINPROGRESS,
173     A_STATUS_ENOTSUPP,
174     A_STATUS_EBUSY,
175     A_STATUS_E2BIG,
176     A_STATUS_EADDRNOTAVAIL,
177     A_STATUS_ENXIO,
178     A_STATUS_EFAULT,
179     A_STATUS_EIO,
180 } a_status_t;
181
182 /**
183  * @brief An ecore needs to provide a table of all pci device/vendor id's it
184  * supports
185  *
186  * This table should be terminated by a NULL entry , i.e. {0}
187  */
188 typedef struct {
189     a_uint32_t vendor;
190     a_uint32_t device;
191     a_uint32_t subvendor;
192     a_uint32_t subdevice;
193 }adf_os_pci_dev_id_t;
194
195 #define ADF_OS_PCI_ANY_ID  (~0)
196
197 /**
198  * @brief Typically core's can use this macro to create a table of various device
199  * ID's
200  */
201 #define ADF_OS_PCI_DEVICE(_vendor, _device)   \
202     (_vendor), (_device), ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID
203
204
205 #define adf_os_iomem_t   __adf_os_iomem_t;
206 /**
207  * @brief These define the hw resources the OS has allocated for the device
208  * Note that start defines a mapped area.
209  */
210 typedef enum {
211     ADF_OS_RESOURCE_TYPE_MEM,
212     ADF_OS_RESOURCE_TYPE_IO,
213 }adf_os_resource_type_t;
214
215 /**
216  * @brief Representation of a h/w resource.
217  */
218 typedef struct {
219     a_uint64_t             start;
220     a_uint64_t             end;
221     adf_os_resource_type_t type;
222 }adf_os_resource_t;
223
224 #define ADF_OS_DEV_ID_TABLE_MAX    256
225
226 /**
227  * @brief Representation of bus registration data.
228  */
229 typedef union {
230     adf_os_pci_dev_id_t  *pci;
231     void              *raw;
232 }adf_os_bus_reg_data_t;
233
234 /**
235  * @brief Representation of data required for attach.
236  */
237 typedef union {
238     adf_os_pci_dev_id_t pci;
239     void *raw;
240 }adf_os_attach_data_t;
241
242 #define ADF_OS_REGIONS_MAX     5
243
244 /**
245  * @brief Types of buses.
246  */
247 typedef enum {
248     ADF_OS_BUS_TYPE_PCI = 1,
249     ADF_OS_BUS_TYPE_GENERIC,
250 }adf_os_bus_type_t;
251
252 /**
253  * @brief IRQ handler response codes.
254  */
255 typedef enum {
256     ADF_OS_IRQ_NONE,
257     ADF_OS_IRQ_HANDLED,
258 }adf_os_irq_resp_t;
259
260 /**
261  * @brief DMA mask types.
262  */
263 typedef enum {
264     ADF_OS_DMA_MASK_32BIT,
265     ADF_OS_DMA_MASK_64BIT,
266 }adf_os_dma_mask_t;
267
268
269 /**
270  * @brief DMA directions
271  *        ADF_OS_DMA_TO_DEVICE (data going from device to memory)
272  *        ADF_OS_DMA_FROM_DEVICE (data going from memory to device)
273  */
274 typedef enum {
275     ADF_OS_DMA_TO_DEVICE = __ADF_OS_DMA_TO_DEVICE,
276     ADF_OS_DMA_FROM_DEVICE = __ADF_OS_DMA_FROM_DEVICE,
277 } adf_os_dma_dir_t;
278
279 /*
280  * Protoypes shared between public and private headers
281  */
282
283
284 /**
285  * @brief work queue(kernel thread)/DPC function callback
286  */
287 typedef void (*adf_os_defer_fn_t)(void *);
288
289 /**
290  * @brief Prototype of the critical region function that is to be
291  * executed with spinlock held and interrupt disalbed
292  */
293 typedef a_bool_t (*adf_os_irqlocked_func_t)(void *);
294
295
296 /**
297  * @brief Prototype of timer function
298  */
299 typedef void (*adf_os_timer_func_t)(void *);
300
301 /**
302  * @brief Prototype of IRQ function.
303  */
304 typedef adf_os_irq_resp_t (*adf_os_drv_intr)(adf_drv_handle_t hdl);
305
306 /**
307  * @brief The OS print routine.
308  */
309 #define adf_os_print         __adf_os_print
310
311 /**
312  * @brief driver info structure needed while we do the register
313  *        for the driver to the shim.
314  */
315 typedef struct _adf_drv_info{
316     /**
317      * @brief driver specific functions
318      */
319     adf_drv_handle_t (*drv_attach)  (adf_os_resource_t *res, int count,
320                                      adf_os_attach_data_t *data,
321                                      adf_os_device_t osdev);
322     void       (*drv_detach)  (adf_drv_handle_t hdl);
323     void       (*drv_suspend) (adf_drv_handle_t hdl, adf_os_pm_t pm);
324     void       (*drv_resume)  (adf_drv_handle_t hdl);
325     /**
326      * @brief driver specific data
327      */
328     adf_os_bus_type_t          bus_type;
329     adf_os_bus_reg_data_t      bus_data;
330     unsigned char              *mod_name;
331     unsigned char              *ifname;
332 }adf_drv_info_t;
333
334 #endif