Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2014-2015 The Linux Foundation. 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 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: i_cdf_types.h |
| 30 | * |
| 31 | * Connectivity driver framework (CDF) types |
| 32 | */ |
| 33 | |
| 34 | #if !defined(__I_CDF_TYPES_H) |
| 35 | #define __I_CDF_TYPES_H |
| 36 | #include <linux/list.h> |
| 37 | #include <linux/mutex.h> |
| 38 | #include <linux/types.h> |
| 39 | #include <linux/sched.h> |
| 40 | #include <linux/completion.h> |
| 41 | #include <linux/string.h> |
| 42 | #include <linux/slab.h> |
| 43 | #include <linux/interrupt.h> |
| 44 | #include <linux/version.h> |
| 45 | #include <asm/div64.h> |
| 46 | |
| 47 | #ifndef __KERNEL__ |
| 48 | #define __iomem |
| 49 | #endif |
| 50 | #include <asm/types.h> |
| 51 | #include <asm/byteorder.h> |
| 52 | #include <linux/version.h> |
| 53 | |
| 54 | #ifdef __KERNEL__ |
| 55 | #include <generated/autoconf.h> |
| 56 | #include <linux/compiler.h> |
| 57 | #include <linux/dma-mapping.h> |
| 58 | #include <linux/wireless.h> |
| 59 | #include <linux/if.h> |
| 60 | #else |
| 61 | |
| 62 | /* |
| 63 | * Hack - coexist with prior defs of dma_addr_t. |
| 64 | * Eventually all other defs of dma_addr_t should be removed. |
| 65 | * At that point, the "already_defined" wrapper can be removed. |
| 66 | */ |
| 67 | #ifndef __dma_addr_t_already_defined__ |
| 68 | #define __dma_addr_t_already_defined__ |
| 69 | typedef unsigned long dma_addr_t; |
| 70 | #endif |
| 71 | |
| 72 | #define SIOCGIWAP 0 |
| 73 | #define IWEVCUSTOM 0 |
| 74 | #define IWEVREGISTERED 0 |
| 75 | #define IWEVEXPIRED 0 |
| 76 | #define SIOCGIWSCAN 0 |
| 77 | #define DMA_TO_DEVICE 0 |
| 78 | #define DMA_FROM_DEVICE 0 |
| 79 | #define __iomem |
| 80 | #endif /* __KERNEL__ */ |
| 81 | |
| 82 | /** |
| 83 | * max sg that we support |
| 84 | */ |
| 85 | #define __CDF_OS_MAX_SCATTER 1 |
| 86 | |
| 87 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
| 88 | #define CDF_LITTLE_ENDIAN_MACHINE |
| 89 | #elif defined (__BIG_ENDIAN_BITFIELD) |
| 90 | #define CDF_BIG_ENDIAN_MACHINE |
| 91 | #else |
| 92 | #error "Please fix <asm/byteorder.h>" |
| 93 | #endif |
| 94 | |
| 95 | #define __cdf_packed __attribute__ ((packed)) |
| 96 | |
| 97 | typedef int (*__cdf_os_intr)(void *); |
| 98 | /** |
| 99 | * Private definitions of general data types |
| 100 | */ |
| 101 | typedef dma_addr_t __cdf_dma_addr_t; |
| 102 | typedef dma_addr_t __cdf_dma_context_t; |
| 103 | |
| 104 | #define cdf_dma_mem_context(context) dma_addr_t context |
| 105 | #define cdf_get_dma_mem_context(var, field) ((cdf_dma_context_t)(var->field)) |
| 106 | |
| 107 | /** |
| 108 | * typedef struct __cdf_resource_t - cdf resource type |
| 109 | * @paddr: Physical address |
| 110 | * @paddr: Virtual address |
| 111 | * @len: Length |
| 112 | */ |
| 113 | typedef struct __cdf_os_resource { |
| 114 | unsigned long paddr; |
| 115 | void __iomem *vaddr; |
| 116 | unsigned long len; |
| 117 | } __cdf_resource_t; |
| 118 | |
| 119 | /** |
| 120 | * struct __cdf_device - generic cdf device type |
| 121 | * @drv: Pointer to driver |
| 122 | * @drv_hdl: Pointer to driver handle |
| 123 | * @drv_name: Pointer to driver name |
| 124 | * @irq: IRQ |
| 125 | * @dev: Pointer to device |
| 126 | * @res: CDF resource |
| 127 | * @func: Interrupt handler |
| 128 | */ |
| 129 | struct __cdf_device { |
| 130 | void *drv; |
| 131 | void *drv_hdl; |
| 132 | char *drv_name; |
| 133 | int irq; |
| 134 | struct device *dev; |
| 135 | __cdf_resource_t res; |
| 136 | __cdf_os_intr func; |
| 137 | }; |
| 138 | |
| 139 | typedef struct __cdf_device *__cdf_device_t; |
| 140 | |
| 141 | typedef size_t __cdf_size_t; |
| 142 | typedef uint8_t __iomem *__cdf_iomem_t; |
| 143 | |
| 144 | /** |
| 145 | * typedef struct __cdf_segment_t - cdf segment |
| 146 | * @daddr: DMA address |
| 147 | * @len: Length |
| 148 | */ |
| 149 | typedef struct __cdf_segment { |
| 150 | dma_addr_t daddr; |
| 151 | uint32_t len; |
| 152 | } __cdf_segment_t; |
| 153 | |
| 154 | /** |
| 155 | * struct __cdf_dma_map - dma map |
| 156 | * @mapped: dma is mapped or not |
| 157 | * @nsegs: Number of segments |
| 158 | * @coherent: Coherent |
| 159 | * @seg: Segment array |
| 160 | */ |
| 161 | struct __cdf_dma_map { |
| 162 | uint32_t mapped; |
| 163 | uint32_t nsegs; |
| 164 | uint32_t coherent; |
| 165 | __cdf_segment_t seg[__CDF_OS_MAX_SCATTER]; |
| 166 | }; |
| 167 | typedef struct __cdf_dma_map *__cdf_dma_map_t; |
| 168 | typedef uint32_t ath_dma_addr_t; |
| 169 | |
| 170 | #define __cdf_print printk |
| 171 | #define __cdf_vprint vprintk |
| 172 | #define __cdf_snprint snprintf |
| 173 | #define __cdf_vsnprint vsnprintf |
| 174 | |
| 175 | #define __CDF_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL |
| 176 | #define __CDF_DMA_TO_DEVICE DMA_TO_DEVICE |
| 177 | #define __CDF_DMA_FROM_DEVICE DMA_FROM_DEVICE |
| 178 | #define __cdf_inline inline |
| 179 | |
| 180 | /* |
| 181 | * 1. GNU C/C++ Compiler |
| 182 | * |
| 183 | * How to detect gcc : __GNUC__ |
| 184 | * How to detect gcc version : |
| 185 | * major version : __GNUC__ (2 = 2.x, 3 = 3.x, 4 = 4.x) |
| 186 | * minor version : __GNUC_MINOR__ |
| 187 | * |
| 188 | * 2. Microsoft C/C++ Compiler |
| 189 | * |
| 190 | * How to detect msc : _MSC_VER |
| 191 | * How to detect msc version : |
| 192 | * _MSC_VER (1200 = MSVC 6.0, 1300 = MSVC 7.0, ...) |
| 193 | * |
| 194 | */ |
| 195 | |
| 196 | /* MACROs to help with compiler and OS specifics. May need to get a little |
| 197 | * more sophisticated than this and define these to specific 'VERSIONS' of |
| 198 | * the compiler and OS. Until we have a need for that, lets go with this |
| 199 | */ |
| 200 | #if defined(_MSC_VER) |
| 201 | |
| 202 | #define CDF_COMPILER_MSC |
| 203 | /* assuming that if we build with MSC, OS is WinMobile */ |
| 204 | #define CDF_OS_WINMOBILE |
| 205 | |
| 206 | #elif defined(__GNUC__) |
| 207 | |
| 208 | #define CDF_COMPILER_GNUC |
| 209 | #define CDF_OS_LINUX /* assuming if building with GNUC, OS is Linux */ |
| 210 | |
| 211 | #endif |
| 212 | |
| 213 | #if defined(CDF_COMPILER_MSC) |
| 214 | |
| 215 | #define CDF_INLINE_FN __inline |
| 216 | |
| 217 | /* Does nothing on Windows. packing individual structs is not |
| 218 | * supported on the Windows compiler |
| 219 | */ |
| 220 | #define CDF_PACK_STRUCT_1 |
| 221 | #define CDF_PACK_STRUCT_2 |
| 222 | #define CDF_PACK_STRUCT_4 |
| 223 | #define CDF_PACK_STRUCT_8 |
| 224 | #define CDF_PACK_STRUCT_16 |
| 225 | |
| 226 | #elif defined(CDF_COMPILER_GNUC) |
| 227 | |
| 228 | #define CDF_INLINE_FN static inline |
| 229 | |
| 230 | #else |
| 231 | #error "Compiling with an unknown compiler!!" |
| 232 | #endif |
| 233 | |
| 234 | #endif /* __I_CDF_TYPES_H */ |