1 /* 2 * Copyright (c) 2014-2018 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_qdf_types.h 30 * This file provides OS dependent types API's. 31 */ 32 33 #if !defined(__I_QDF_TYPES_H) 34 #define __I_QDF_TYPES_H 35 36 #include <qdf_status.h> 37 38 #ifndef __KERNEL__ 39 #define __iomem 40 #endif 41 #include <asm/types.h> 42 #include <asm/byteorder.h> 43 #include <linux/version.h> 44 45 #ifndef __ahdecl 46 #ifdef __i386__ 47 #define __ahdecl __attribute__((regparm(0))) 48 #else 49 #define __ahdecl 50 #endif 51 #endif 52 53 #ifdef __KERNEL__ 54 #include <generated/autoconf.h> 55 #include <linux/list.h> 56 #include <linux/mutex.h> 57 #include <linux/types.h> 58 #include <linux/ctype.h> 59 #include <linux/sched.h> 60 #include <linux/completion.h> 61 #include <linux/string.h> 62 #include <linux/slab.h> 63 #include <linux/interrupt.h> 64 #include <linux/version.h> 65 #include <asm/div64.h> 66 #include <linux/compiler.h> 67 #include <linux/dma-mapping.h> 68 #include <linux/wireless.h> 69 #include <linux/if.h> 70 #else 71 72 /* 73 * Hack - coexist with prior defs of dma_addr_t. 74 * Eventually all other defs of dma_addr_t should be removed. 75 * At that point, the "already_defined" wrapper can be removed. 76 */ 77 #ifndef __dma_addr_t_already_defined__ 78 #define __dma_addr_t_already_defined__ 79 typedef unsigned long dma_addr_t; 80 #endif 81 82 #define SIOCGIWAP 0 83 #define IWEVCUSTOM 0 84 #define IWEVREGISTERED 0 85 #define IWEVEXPIRED 0 86 #define SIOCGIWSCAN 0 87 #define DMA_TO_DEVICE 0 88 #define DMA_BIDIRECTIONAL 0 89 #define DMA_FROM_DEVICE 0 90 #define __iomem 91 #endif /* __KERNEL__ */ 92 93 /* 94 * max sg that we support 95 */ 96 #define __QDF_MAX_SCATTER 1 97 98 #if defined(__LITTLE_ENDIAN_BITFIELD) 99 #define QDF_LITTLE_ENDIAN_MACHINE 100 #elif defined(__BIG_ENDIAN_BITFIELD) 101 #define QDF_BIG_ENDIAN_MACHINE 102 #else 103 #error "Please fix <asm/byteorder.h>" 104 #endif 105 106 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) || !defined(__KERNEL__) 107 #ifndef __bool_already_defined__ 108 #define __bool_already_defined__ 109 110 /** 111 * bool - This is an enum for boolean 112 * @false: zero 113 * @true: one 114 */ 115 typedef enum bool { 116 false = 0, 117 true = 1, 118 } bool; 119 #endif /* __bool_already_defined__ */ 120 #endif 121 122 #define __qdf_packed __attribute__((packed)) 123 124 typedef int (*__qdf_os_intr)(void *); 125 /** 126 * Private definitions of general data types 127 */ 128 typedef dma_addr_t __qdf_dma_addr_t; 129 typedef size_t __qdf_dma_size_t; 130 typedef dma_addr_t __qdf_dma_context_t; 131 typedef struct net_device *__qdf_netdev_t; 132 typedef __le16 __qdf_le16_t; 133 typedef __le32 __qdf_le32_t; 134 typedef __le64 __qdf_le64_t; 135 typedef __be16 __qdf_be16_t; 136 typedef __be32 __qdf_be32_t; 137 typedef __be64 __qdf_be64_t; 138 139 #define qdf_dma_mem_context(context) dma_addr_t context 140 #define qdf_get_dma_mem_context(var, field) ((qdf_dma_context_t)(var->field)) 141 142 /** 143 * typedef struct __qdf_resource_t - qdf resource type 144 * @paddr: Physical address 145 * @paddr: Virtual address 146 * @len: Length 147 */ 148 typedef struct __qdf_resource { 149 unsigned long paddr; 150 void __iomem *vaddr; 151 unsigned long len; 152 } __qdf_resource_t; 153 154 struct __qdf_mempool_ctxt; 155 156 #define MAX_MEM_POOLS 64 157 158 /** 159 * enum qdf_bus_type - Supported Bus types 160 * @QDF_BUS_TYPE_NONE: None Bus type for error check 161 * @QDF_BUS_TYPE_PCI: PCI Bus 162 * @QDF_BUS_TYPE_AHB: AHB Bus 163 * @QDF_BUS_TYPE_SNOC: SNOC Bus 164 * @QDF_BUS_TYPE_SIM: Simulator 165 * @QDF_BUS_TYPE_USB: USB Bus 166 */ 167 enum qdf_bus_type { 168 QDF_BUS_TYPE_NONE = -1, 169 QDF_BUS_TYPE_PCI = 0, 170 QDF_BUS_TYPE_AHB, 171 QDF_BUS_TYPE_SNOC, 172 QDF_BUS_TYPE_SIM, 173 QDF_BUS_TYPE_SDIO, 174 QDF_BUS_TYPE_USB 175 }; 176 177 /** 178 * struct __qdf_device - generic qdf device type 179 * @drv: Pointer to driver 180 * @drv_hdl: Pointer to driver handle 181 * @drv_name: Pointer to driver name 182 * @irq: IRQ 183 * @dev: Pointer to device 184 * @res: QDF resource 185 * @func: Interrupt handler 186 * @mem_pool: array to pointer to mem context 187 */ 188 struct __qdf_device { 189 void *drv; 190 void *drv_hdl; 191 char *drv_name; 192 int irq; 193 struct device *dev; 194 __qdf_resource_t res; 195 __qdf_os_intr func; 196 struct __qdf_mempool_ctxt *mem_pool[MAX_MEM_POOLS]; 197 enum qdf_bus_type bus_type; 198 #ifdef CONFIG_MCL 199 const struct hif_bus_id *bid; 200 #endif 201 }; 202 typedef struct __qdf_device *__qdf_device_t; 203 204 typedef size_t __qdf_size_t; 205 typedef off_t __qdf_off_t; 206 typedef uint8_t __iomem *__qdf_iomem_t; 207 208 typedef uint32_t ath_dma_addr_t; 209 210 /** 211 * typedef __qdf_segment_t - segment of memory 212 * @daddr: dma address 213 * @len: lenght of segment 214 */ 215 typedef struct __qdf_segment { 216 dma_addr_t daddr; 217 uint32_t len; 218 } __qdf_segment_t; 219 220 /** 221 * __qdf_dma_map - dma map of memory 222 * @mapped: mapped address 223 * @nsegs: number of segments 224 * @coherent: coherency status 225 * @seg: segment of memory 226 */ 227 struct __qdf_dma_map { 228 uint32_t mapped; 229 uint32_t nsegs; 230 uint32_t coherent; 231 __qdf_segment_t seg[__QDF_MAX_SCATTER]; 232 }; 233 typedef struct __qdf_dma_map *__qdf_dma_map_t; 234 235 /** 236 * __qdf_net_wireless_evcode - enum for event code 237 * @__QDF_IEEE80211_ASSOC: association event code 238 * @__QDF_IEEE80211_REASSOC: reassociation event code 239 * @__QDF_IEEE80211_DISASSOC: disassociation event code 240 * @__QDF_IEEE80211_JOIN: join event code 241 * @__QDF_IEEE80211_LEAVE: leave event code 242 * @__QDF_IEEE80211_SCAN: scan event code 243 * @__QDF_IEEE80211_REPLAY: replay event code 244 * @__QDF_IEEE80211_MICHAEL:michael event code 245 * @__QDF_IEEE80211_REJOIN: rejoin event code 246 * @__QDF_CUSTOM_PUSH_BUTTON: push button event code 247 */ 248 enum __qdf_net_wireless_evcode { 249 __QDF_IEEE80211_ASSOC = SIOCGIWAP, 250 __QDF_IEEE80211_REASSOC = IWEVCUSTOM, 251 __QDF_IEEE80211_DISASSOC = SIOCGIWAP, 252 __QDF_IEEE80211_JOIN = IWEVREGISTERED, 253 __QDF_IEEE80211_LEAVE = IWEVEXPIRED, 254 __QDF_IEEE80211_SCAN = SIOCGIWSCAN, 255 __QDF_IEEE80211_REPLAY = IWEVCUSTOM, 256 __QDF_IEEE80211_MICHAEL = IWEVCUSTOM, 257 __QDF_IEEE80211_REJOIN = IWEVCUSTOM, 258 __QDF_CUSTOM_PUSH_BUTTON = IWEVCUSTOM, 259 }; 260 261 #define __qdf_print printk 262 #define __qdf_vprint vprintk 263 #define __qdf_snprint snprintf 264 #define __qdf_vsnprint vsnprintf 265 #define __qdf_toupper toupper 266 267 #define __QDF_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL 268 #define __QDF_DMA_TO_DEVICE DMA_TO_DEVICE 269 #ifndef __ubicom32__ 270 #define __QDF_DMA_FROM_DEVICE DMA_FROM_DEVICE 271 #else 272 #define __QDF_DMA_FROM_DEVICE DMA_TO_DEVICE 273 #endif 274 #define __qdf_inline inline 275 276 /* 277 * 1. GNU C/C++ Compiler 278 * 279 * How to detect gcc : __GNUC__ 280 * How to detect gcc version : 281 * major version : __GNUC__ (2 = 2.x, 3 = 3.x, 4 = 4.x) 282 * minor version : __GNUC_MINOR__ 283 * 284 * 2. Microsoft C/C++ Compiler 285 * 286 * How to detect msc : _MSC_VER 287 * How to detect msc version : 288 * _MSC_VER (1200 = MSVC 6.0, 1300 = MSVC 7.0, ...) 289 * 290 */ 291 292 /* 293 * MACROs to help with compiler and OS specifics. May need to get a little 294 * more sophisticated than this and define these to specific 'VERSIONS' of 295 * the compiler and OS. Until we have a need for that, lets go with this 296 */ 297 #if defined(_MSC_VER) 298 299 #define QDF_COMPILER_MSC 300 /* assuming that if we build with MSC, OS is WinMobile */ 301 #define QDF_OS_WINMOBILE 302 303 #elif defined(__GNUC__) 304 305 #define QDF_COMPILER_GNUC 306 #define QDF_OS_LINUX /* assuming if building with GNUC, OS is Linux */ 307 308 #endif 309 310 #if defined(QDF_COMPILER_MSC) 311 312 313 /* 314 * Does nothing on Windows. packing individual structs is not 315 * supported on the Windows compiler 316 */ 317 #define QDF_PACK_STRUCT_1 318 #define QDF_PACK_STRUCT_2 319 #define QDF_PACK_STRUCT_4 320 #define QDF_PACK_STRUCT_8 321 #define QDF_PACK_STRUCT_16 322 323 #elif defined(QDF_COMPILER_GNUC) 324 325 #else 326 #error "Compiling with an unknown compiler!!" 327 #endif 328 329 #endif /* __I_QDF_TYPES_H */ 330