Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2011 Atheros Communications Inc. |
| 3 | * Copyright (c) 2011-2013 Qualcomm Atheros, Inc. |
| 4 | * |
| 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 6 | * purpose with or without fee is hereby granted, provided that the above |
| 7 | * copyright notice and this permission notice appear in all copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | */ |
| 17 | |
| 18 | #ifndef _CE_H_ |
| 19 | #define _CE_H_ |
| 20 | |
| 21 | #include "hif.h" |
| 22 | |
| 23 | |
| 24 | /* Maximum number of Copy Engine's supported */ |
| 25 | #define CE_COUNT_MAX 8 |
Michal Kazior | a16942e | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 26 | #define CE_HTT_H2T_MSG_SRC_NENTRIES 4096 |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 27 | |
| 28 | /* Descriptor rings must be aligned to this boundary */ |
| 29 | #define CE_DESC_RING_ALIGN 8 |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 30 | #define CE_SEND_FLAG_GATHER 0x00010000 |
| 31 | |
| 32 | /* |
| 33 | * Copy Engine support: low-level Target-side Copy Engine API. |
| 34 | * This is a hardware access layer used by code that understands |
| 35 | * how to use copy engines. |
| 36 | */ |
| 37 | |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 38 | struct ath10k_ce_pipe; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 39 | |
| 40 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 41 | #define CE_DESC_FLAGS_GATHER (1 << 0) |
| 42 | #define CE_DESC_FLAGS_BYTE_SWAP (1 << 1) |
| 43 | #define CE_DESC_FLAGS_META_DATA_MASK 0xFFFC |
| 44 | #define CE_DESC_FLAGS_META_DATA_LSB 3 |
| 45 | |
| 46 | struct ce_desc { |
| 47 | __le32 addr; |
| 48 | __le16 nbytes; |
| 49 | __le16 flags; /* %CE_DESC_FLAGS_ */ |
| 50 | }; |
| 51 | |
Michal Kazior | d21fb95 | 2013-08-27 13:08:03 +0200 | [diff] [blame] | 52 | struct ath10k_ce_ring { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 53 | /* Number of entries in this ring; must be power of 2 */ |
| 54 | unsigned int nentries; |
| 55 | unsigned int nentries_mask; |
| 56 | |
| 57 | /* |
| 58 | * For dest ring, this is the next index to be processed |
| 59 | * by software after it was/is received into. |
| 60 | * |
| 61 | * For src ring, this is the last descriptor that was sent |
| 62 | * and completion processed by software. |
| 63 | * |
| 64 | * Regardless of src or dest ring, this is an invariant |
| 65 | * (modulo ring size): |
| 66 | * write index >= read index >= sw_index |
| 67 | */ |
| 68 | unsigned int sw_index; |
| 69 | /* cached copy */ |
| 70 | unsigned int write_index; |
| 71 | /* |
| 72 | * For src ring, this is the next index not yet processed by HW. |
| 73 | * This is a cached copy of the real HW index (read index), used |
| 74 | * for avoiding reading the HW index register more often than |
| 75 | * necessary. |
| 76 | * This extends the invariant: |
| 77 | * write index >= read index >= hw_index >= sw_index |
| 78 | * |
| 79 | * For dest ring, this is currently unused. |
| 80 | */ |
| 81 | /* cached copy */ |
| 82 | unsigned int hw_index; |
| 83 | |
| 84 | /* Start of DMA-coherent area reserved for descriptors */ |
| 85 | /* Host address space */ |
| 86 | void *base_addr_owner_space_unaligned; |
| 87 | /* CE address space */ |
| 88 | u32 base_addr_ce_space_unaligned; |
| 89 | |
| 90 | /* |
| 91 | * Actual start of descriptors. |
| 92 | * Aligned to descriptor-size boundary. |
| 93 | * Points into reserved DMA-coherent area, above. |
| 94 | */ |
| 95 | /* Host address space */ |
| 96 | void *base_addr_owner_space; |
| 97 | |
| 98 | /* CE address space */ |
| 99 | u32 base_addr_ce_space; |
| 100 | /* |
| 101 | * Start of shadow copy of descriptors, within regular memory. |
| 102 | * Aligned to descriptor-size boundary. |
| 103 | */ |
| 104 | void *shadow_base_unaligned; |
| 105 | struct ce_desc *shadow_base; |
| 106 | |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame^] | 107 | /* keep last */ |
| 108 | void *per_transfer_context[0]; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 109 | }; |
| 110 | |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 111 | struct ath10k_ce_pipe { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 112 | struct ath10k *ar; |
| 113 | unsigned int id; |
| 114 | |
| 115 | unsigned int attr_flags; |
| 116 | |
| 117 | u32 ctrl_addr; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 118 | |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 119 | void (*send_cb)(struct ath10k_ce_pipe *); |
| 120 | void (*recv_cb)(struct ath10k_ce_pipe *); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 121 | |
| 122 | unsigned int src_sz_max; |
Michal Kazior | d21fb95 | 2013-08-27 13:08:03 +0200 | [diff] [blame] | 123 | struct ath10k_ce_ring *src_ring; |
| 124 | struct ath10k_ce_ring *dest_ring; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 125 | }; |
| 126 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 127 | /* Copy Engine settable attributes */ |
| 128 | struct ce_attr; |
| 129 | |
| 130 | /*==================Send====================*/ |
| 131 | |
| 132 | /* ath10k_ce_send flags */ |
| 133 | #define CE_SEND_FLAG_BYTE_SWAP 1 |
| 134 | |
| 135 | /* |
| 136 | * Queue a source buffer to be sent to an anonymous destination buffer. |
| 137 | * ce - which copy engine to use |
| 138 | * buffer - address of buffer |
| 139 | * nbytes - number of bytes to send |
| 140 | * transfer_id - arbitrary ID; reflected to destination |
| 141 | * flags - CE_SEND_FLAG_* values |
| 142 | * Returns 0 on success; otherwise an error status. |
| 143 | * |
| 144 | * Note: If no flags are specified, use CE's default data swap mode. |
| 145 | * |
| 146 | * Implementation note: pushes 1 buffer to Source ring |
| 147 | */ |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 148 | int ath10k_ce_send(struct ath10k_ce_pipe *ce_state, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 149 | void *per_transfer_send_context, |
| 150 | u32 buffer, |
| 151 | unsigned int nbytes, |
| 152 | /* 14 bits */ |
| 153 | unsigned int transfer_id, |
| 154 | unsigned int flags); |
| 155 | |
Michal Kazior | 726346f | 2014-02-27 18:50:04 +0200 | [diff] [blame] | 156 | int ath10k_ce_send_nolock(struct ath10k_ce_pipe *ce_state, |
| 157 | void *per_transfer_context, |
| 158 | u32 buffer, |
| 159 | unsigned int nbytes, |
| 160 | unsigned int transfer_id, |
| 161 | unsigned int flags); |
| 162 | |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 163 | void ath10k_ce_send_cb_register(struct ath10k_ce_pipe *ce_state, |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 164 | void (*send_cb)(struct ath10k_ce_pipe *), |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 165 | int disable_interrupts); |
| 166 | |
Michal Kazior | 3efcb3b | 2013-10-02 11:03:41 +0200 | [diff] [blame] | 167 | int ath10k_ce_num_free_src_entries(struct ath10k_ce_pipe *pipe); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 168 | |
| 169 | /*==================Recv=======================*/ |
| 170 | |
| 171 | /* |
| 172 | * Make a buffer available to receive. The buffer must be at least of a |
| 173 | * minimal size appropriate for this copy engine (src_sz_max attribute). |
| 174 | * ce - which copy engine to use |
| 175 | * per_transfer_recv_context - context passed back to caller's recv_cb |
| 176 | * buffer - address of buffer in CE space |
| 177 | * Returns 0 on success; otherwise an error status. |
| 178 | * |
| 179 | * Implemenation note: Pushes a buffer to Dest ring. |
| 180 | */ |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 181 | int ath10k_ce_recv_buf_enqueue(struct ath10k_ce_pipe *ce_state, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 182 | void *per_transfer_recv_context, |
| 183 | u32 buffer); |
| 184 | |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 185 | void ath10k_ce_recv_cb_register(struct ath10k_ce_pipe *ce_state, |
Michal Kazior | 5440ce2 | 2013-09-03 15:09:58 +0200 | [diff] [blame] | 186 | void (*recv_cb)(struct ath10k_ce_pipe *)); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 187 | |
| 188 | /* recv flags */ |
| 189 | /* Data is byte-swapped */ |
| 190 | #define CE_RECV_FLAG_SWAPPED 1 |
| 191 | |
| 192 | /* |
| 193 | * Supply data for the next completed unprocessed receive descriptor. |
| 194 | * Pops buffer from Dest ring. |
| 195 | */ |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 196 | int ath10k_ce_completed_recv_next(struct ath10k_ce_pipe *ce_state, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 197 | void **per_transfer_contextp, |
| 198 | u32 *bufferp, |
| 199 | unsigned int *nbytesp, |
| 200 | unsigned int *transfer_idp, |
| 201 | unsigned int *flagsp); |
| 202 | /* |
| 203 | * Supply data for the next completed unprocessed send descriptor. |
| 204 | * Pops 1 completed send buffer from Source ring. |
| 205 | */ |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 206 | int ath10k_ce_completed_send_next(struct ath10k_ce_pipe *ce_state, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 207 | void **per_transfer_contextp, |
| 208 | u32 *bufferp, |
| 209 | unsigned int *nbytesp, |
| 210 | unsigned int *transfer_idp); |
| 211 | |
| 212 | /*==================CE Engine Initialization=======================*/ |
| 213 | |
Michal Kazior | 25d0dbc | 2014-03-28 10:02:38 +0200 | [diff] [blame^] | 214 | int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id, |
| 215 | const struct ce_attr *attr); |
| 216 | void ath10k_ce_deinit_pipe(struct ath10k *ar, unsigned int ce_id); |
| 217 | int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id, |
| 218 | const struct ce_attr *attr); |
| 219 | void ath10k_ce_free_pipe(struct ath10k *ar, int ce_id); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 220 | |
| 221 | /*==================CE Engine Shutdown=======================*/ |
| 222 | /* |
| 223 | * Support clean shutdown by allowing the caller to revoke |
| 224 | * receive buffers. Target DMA must be stopped before using |
| 225 | * this API. |
| 226 | */ |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 227 | int ath10k_ce_revoke_recv_next(struct ath10k_ce_pipe *ce_state, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 228 | void **per_transfer_contextp, |
| 229 | u32 *bufferp); |
| 230 | |
| 231 | /* |
| 232 | * Support clean shutdown by allowing the caller to cancel |
| 233 | * pending sends. Target DMA must be stopped before using |
| 234 | * this API. |
| 235 | */ |
Michal Kazior | 2aa3911 | 2013-08-27 13:08:02 +0200 | [diff] [blame] | 236 | int ath10k_ce_cancel_send_next(struct ath10k_ce_pipe *ce_state, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 237 | void **per_transfer_contextp, |
| 238 | u32 *bufferp, |
| 239 | unsigned int *nbytesp, |
| 240 | unsigned int *transfer_idp); |
| 241 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 242 | /*==================CE Interrupt Handlers====================*/ |
| 243 | void ath10k_ce_per_engine_service_any(struct ath10k *ar); |
| 244 | void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id); |
Michal Kazior | 28642f4 | 2013-11-08 08:01:31 +0100 | [diff] [blame] | 245 | int ath10k_ce_disable_interrupts(struct ath10k *ar); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 246 | |
| 247 | /* ce_attr.flags values */ |
| 248 | /* Use NonSnooping PCIe accesses? */ |
| 249 | #define CE_ATTR_NO_SNOOP 1 |
| 250 | |
| 251 | /* Byte swap data words */ |
| 252 | #define CE_ATTR_BYTE_SWAP_DATA 2 |
| 253 | |
| 254 | /* Swizzle descriptors? */ |
| 255 | #define CE_ATTR_SWIZZLE_DESCRIPTORS 4 |
| 256 | |
| 257 | /* no interrupt on copy completion */ |
| 258 | #define CE_ATTR_DIS_INTR 8 |
| 259 | |
| 260 | /* Attributes of an instance of a Copy Engine */ |
| 261 | struct ce_attr { |
| 262 | /* CE_ATTR_* values */ |
| 263 | unsigned int flags; |
| 264 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 265 | /* #entries in source ring - Must be a power of 2 */ |
| 266 | unsigned int src_nentries; |
| 267 | |
| 268 | /* |
| 269 | * Max source send size for this CE. |
| 270 | * This is also the minimum size of a destination buffer. |
| 271 | */ |
| 272 | unsigned int src_sz_max; |
| 273 | |
| 274 | /* #entries in destination ring - Must be a power of 2 */ |
| 275 | unsigned int dest_nentries; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 276 | }; |
| 277 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 278 | #define SR_BA_ADDRESS 0x0000 |
| 279 | #define SR_SIZE_ADDRESS 0x0004 |
| 280 | #define DR_BA_ADDRESS 0x0008 |
| 281 | #define DR_SIZE_ADDRESS 0x000c |
| 282 | #define CE_CMD_ADDRESS 0x0018 |
| 283 | |
| 284 | #define CE_CTRL1_DST_RING_BYTE_SWAP_EN_MSB 17 |
| 285 | #define CE_CTRL1_DST_RING_BYTE_SWAP_EN_LSB 17 |
| 286 | #define CE_CTRL1_DST_RING_BYTE_SWAP_EN_MASK 0x00020000 |
| 287 | #define CE_CTRL1_DST_RING_BYTE_SWAP_EN_SET(x) \ |
| 288 | (((0 | (x)) << CE_CTRL1_DST_RING_BYTE_SWAP_EN_LSB) & \ |
| 289 | CE_CTRL1_DST_RING_BYTE_SWAP_EN_MASK) |
| 290 | |
| 291 | #define CE_CTRL1_SRC_RING_BYTE_SWAP_EN_MSB 16 |
| 292 | #define CE_CTRL1_SRC_RING_BYTE_SWAP_EN_LSB 16 |
| 293 | #define CE_CTRL1_SRC_RING_BYTE_SWAP_EN_MASK 0x00010000 |
| 294 | #define CE_CTRL1_SRC_RING_BYTE_SWAP_EN_GET(x) \ |
| 295 | (((x) & CE_CTRL1_SRC_RING_BYTE_SWAP_EN_MASK) >> \ |
| 296 | CE_CTRL1_SRC_RING_BYTE_SWAP_EN_LSB) |
| 297 | #define CE_CTRL1_SRC_RING_BYTE_SWAP_EN_SET(x) \ |
| 298 | (((0 | (x)) << CE_CTRL1_SRC_RING_BYTE_SWAP_EN_LSB) & \ |
| 299 | CE_CTRL1_SRC_RING_BYTE_SWAP_EN_MASK) |
| 300 | |
| 301 | #define CE_CTRL1_DMAX_LENGTH_MSB 15 |
| 302 | #define CE_CTRL1_DMAX_LENGTH_LSB 0 |
| 303 | #define CE_CTRL1_DMAX_LENGTH_MASK 0x0000ffff |
| 304 | #define CE_CTRL1_DMAX_LENGTH_GET(x) \ |
| 305 | (((x) & CE_CTRL1_DMAX_LENGTH_MASK) >> CE_CTRL1_DMAX_LENGTH_LSB) |
| 306 | #define CE_CTRL1_DMAX_LENGTH_SET(x) \ |
| 307 | (((0 | (x)) << CE_CTRL1_DMAX_LENGTH_LSB) & CE_CTRL1_DMAX_LENGTH_MASK) |
| 308 | |
| 309 | #define CE_CTRL1_ADDRESS 0x0010 |
| 310 | #define CE_CTRL1_HW_MASK 0x0007ffff |
| 311 | #define CE_CTRL1_SW_MASK 0x0007ffff |
| 312 | #define CE_CTRL1_HW_WRITE_MASK 0x00000000 |
| 313 | #define CE_CTRL1_SW_WRITE_MASK 0x0007ffff |
| 314 | #define CE_CTRL1_RSTMASK 0xffffffff |
| 315 | #define CE_CTRL1_RESET 0x00000080 |
| 316 | |
| 317 | #define CE_CMD_HALT_STATUS_MSB 3 |
| 318 | #define CE_CMD_HALT_STATUS_LSB 3 |
| 319 | #define CE_CMD_HALT_STATUS_MASK 0x00000008 |
| 320 | #define CE_CMD_HALT_STATUS_GET(x) \ |
| 321 | (((x) & CE_CMD_HALT_STATUS_MASK) >> CE_CMD_HALT_STATUS_LSB) |
| 322 | #define CE_CMD_HALT_STATUS_SET(x) \ |
| 323 | (((0 | (x)) << CE_CMD_HALT_STATUS_LSB) & CE_CMD_HALT_STATUS_MASK) |
| 324 | #define CE_CMD_HALT_STATUS_RESET 0 |
| 325 | #define CE_CMD_HALT_MSB 0 |
| 326 | #define CE_CMD_HALT_MASK 0x00000001 |
| 327 | |
| 328 | #define HOST_IE_COPY_COMPLETE_MSB 0 |
| 329 | #define HOST_IE_COPY_COMPLETE_LSB 0 |
| 330 | #define HOST_IE_COPY_COMPLETE_MASK 0x00000001 |
| 331 | #define HOST_IE_COPY_COMPLETE_GET(x) \ |
| 332 | (((x) & HOST_IE_COPY_COMPLETE_MASK) >> HOST_IE_COPY_COMPLETE_LSB) |
| 333 | #define HOST_IE_COPY_COMPLETE_SET(x) \ |
| 334 | (((0 | (x)) << HOST_IE_COPY_COMPLETE_LSB) & HOST_IE_COPY_COMPLETE_MASK) |
| 335 | #define HOST_IE_COPY_COMPLETE_RESET 0 |
| 336 | #define HOST_IE_ADDRESS 0x002c |
| 337 | |
| 338 | #define HOST_IS_DST_RING_LOW_WATERMARK_MASK 0x00000010 |
| 339 | #define HOST_IS_DST_RING_HIGH_WATERMARK_MASK 0x00000008 |
| 340 | #define HOST_IS_SRC_RING_LOW_WATERMARK_MASK 0x00000004 |
| 341 | #define HOST_IS_SRC_RING_HIGH_WATERMARK_MASK 0x00000002 |
| 342 | #define HOST_IS_COPY_COMPLETE_MASK 0x00000001 |
| 343 | #define HOST_IS_ADDRESS 0x0030 |
| 344 | |
| 345 | #define MISC_IE_ADDRESS 0x0034 |
| 346 | |
| 347 | #define MISC_IS_AXI_ERR_MASK 0x00000400 |
| 348 | |
| 349 | #define MISC_IS_DST_ADDR_ERR_MASK 0x00000200 |
| 350 | #define MISC_IS_SRC_LEN_ERR_MASK 0x00000100 |
| 351 | #define MISC_IS_DST_MAX_LEN_VIO_MASK 0x00000080 |
| 352 | #define MISC_IS_DST_RING_OVERFLOW_MASK 0x00000040 |
| 353 | #define MISC_IS_SRC_RING_OVERFLOW_MASK 0x00000020 |
| 354 | |
| 355 | #define MISC_IS_ADDRESS 0x0038 |
| 356 | |
| 357 | #define SR_WR_INDEX_ADDRESS 0x003c |
| 358 | |
| 359 | #define DST_WR_INDEX_ADDRESS 0x0040 |
| 360 | |
| 361 | #define CURRENT_SRRI_ADDRESS 0x0044 |
| 362 | |
| 363 | #define CURRENT_DRRI_ADDRESS 0x0048 |
| 364 | |
| 365 | #define SRC_WATERMARK_LOW_MSB 31 |
| 366 | #define SRC_WATERMARK_LOW_LSB 16 |
| 367 | #define SRC_WATERMARK_LOW_MASK 0xffff0000 |
| 368 | #define SRC_WATERMARK_LOW_GET(x) \ |
| 369 | (((x) & SRC_WATERMARK_LOW_MASK) >> SRC_WATERMARK_LOW_LSB) |
| 370 | #define SRC_WATERMARK_LOW_SET(x) \ |
| 371 | (((0 | (x)) << SRC_WATERMARK_LOW_LSB) & SRC_WATERMARK_LOW_MASK) |
| 372 | #define SRC_WATERMARK_LOW_RESET 0 |
| 373 | #define SRC_WATERMARK_HIGH_MSB 15 |
| 374 | #define SRC_WATERMARK_HIGH_LSB 0 |
| 375 | #define SRC_WATERMARK_HIGH_MASK 0x0000ffff |
| 376 | #define SRC_WATERMARK_HIGH_GET(x) \ |
| 377 | (((x) & SRC_WATERMARK_HIGH_MASK) >> SRC_WATERMARK_HIGH_LSB) |
| 378 | #define SRC_WATERMARK_HIGH_SET(x) \ |
| 379 | (((0 | (x)) << SRC_WATERMARK_HIGH_LSB) & SRC_WATERMARK_HIGH_MASK) |
| 380 | #define SRC_WATERMARK_HIGH_RESET 0 |
| 381 | #define SRC_WATERMARK_ADDRESS 0x004c |
| 382 | |
| 383 | #define DST_WATERMARK_LOW_LSB 16 |
| 384 | #define DST_WATERMARK_LOW_MASK 0xffff0000 |
| 385 | #define DST_WATERMARK_LOW_SET(x) \ |
| 386 | (((0 | (x)) << DST_WATERMARK_LOW_LSB) & DST_WATERMARK_LOW_MASK) |
| 387 | #define DST_WATERMARK_LOW_RESET 0 |
| 388 | #define DST_WATERMARK_HIGH_MSB 15 |
| 389 | #define DST_WATERMARK_HIGH_LSB 0 |
| 390 | #define DST_WATERMARK_HIGH_MASK 0x0000ffff |
| 391 | #define DST_WATERMARK_HIGH_GET(x) \ |
| 392 | (((x) & DST_WATERMARK_HIGH_MASK) >> DST_WATERMARK_HIGH_LSB) |
| 393 | #define DST_WATERMARK_HIGH_SET(x) \ |
| 394 | (((0 | (x)) << DST_WATERMARK_HIGH_LSB) & DST_WATERMARK_HIGH_MASK) |
| 395 | #define DST_WATERMARK_HIGH_RESET 0 |
| 396 | #define DST_WATERMARK_ADDRESS 0x0050 |
| 397 | |
| 398 | |
| 399 | static inline u32 ath10k_ce_base_address(unsigned int ce_id) |
| 400 | { |
| 401 | return CE0_BASE_ADDRESS + (CE1_BASE_ADDRESS - CE0_BASE_ADDRESS) * ce_id; |
| 402 | } |
| 403 | |
| 404 | #define CE_WATERMARK_MASK (HOST_IS_SRC_RING_LOW_WATERMARK_MASK | \ |
| 405 | HOST_IS_SRC_RING_HIGH_WATERMARK_MASK | \ |
| 406 | HOST_IS_DST_RING_LOW_WATERMARK_MASK | \ |
| 407 | HOST_IS_DST_RING_HIGH_WATERMARK_MASK) |
| 408 | |
| 409 | #define CE_ERROR_MASK (MISC_IS_AXI_ERR_MASK | \ |
| 410 | MISC_IS_DST_ADDR_ERR_MASK | \ |
| 411 | MISC_IS_SRC_LEN_ERR_MASK | \ |
| 412 | MISC_IS_DST_MAX_LEN_VIO_MASK | \ |
| 413 | MISC_IS_DST_RING_OVERFLOW_MASK | \ |
| 414 | MISC_IS_SRC_RING_OVERFLOW_MASK) |
| 415 | |
| 416 | #define CE_SRC_RING_TO_DESC(baddr, idx) \ |
| 417 | (&(((struct ce_desc *)baddr)[idx])) |
| 418 | |
| 419 | #define CE_DEST_RING_TO_DESC(baddr, idx) \ |
| 420 | (&(((struct ce_desc *)baddr)[idx])) |
| 421 | |
| 422 | /* Ring arithmetic (modulus number of entries in ring, which is a pwr of 2). */ |
| 423 | #define CE_RING_DELTA(nentries_mask, fromidx, toidx) \ |
| 424 | (((int)(toidx)-(int)(fromidx)) & (nentries_mask)) |
| 425 | |
| 426 | #define CE_RING_IDX_INCR(nentries_mask, idx) (((idx) + 1) & (nentries_mask)) |
| 427 | |
| 428 | #define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_LSB 8 |
| 429 | #define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_MASK 0x0000ff00 |
| 430 | #define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_GET(x) \ |
| 431 | (((x) & CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_MASK) >> \ |
| 432 | CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_LSB) |
| 433 | #define CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS 0x0000 |
| 434 | |
| 435 | #define CE_INTERRUPT_SUMMARY(ar) \ |
| 436 | CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_GET( \ |
| 437 | ath10k_pci_read32((ar), CE_WRAPPER_BASE_ADDRESS + \ |
| 438 | CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS)) |
| 439 | |
| 440 | #endif /* _CE_H_ */ |