0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef HIF_H
0019 #define HIF_H
0020
0021 #include "common.h"
0022 #include "core.h"
0023
0024 #include <linux/scatterlist.h>
0025
0026 #define BUS_REQUEST_MAX_NUM 64
0027 #define HIF_MBOX_BLOCK_SIZE 128
0028 #define HIF_MBOX0_BLOCK_SIZE 1
0029
0030 #define HIF_DMA_BUFFER_SIZE (32 * 1024)
0031 #define CMD53_FIXED_ADDRESS 1
0032 #define CMD53_INCR_ADDRESS 2
0033
0034 #define MAX_SCATTER_REQUESTS 4
0035 #define MAX_SCATTER_ENTRIES_PER_REQ 16
0036 #define MAX_SCATTER_REQ_TRANSFER_SIZE (32 * 1024)
0037
0038
0039 #define HIF_MBOX_BASE_ADDR 0x800
0040 #define HIF_MBOX_WIDTH 0x800
0041
0042 #define HIF_MBOX_END_ADDR (HTC_MAILBOX_NUM_MAX * HIF_MBOX_WIDTH - 1)
0043
0044
0045 #define HIF_MBOX0_EXT_BASE_ADDR 0x4000
0046 #define HIF_MBOX0_EXT_WIDTH (12*1024)
0047
0048
0049 #define HIF_GMBOX_BASE_ADDR 0x7000
0050 #define HIF_GMBOX_WIDTH 0x4000
0051
0052
0053 #define CCCR_SDIO_IRQ_MODE_REG 0xF0
0054
0055
0056 #define SDIO_IRQ_MODE_ASYNC_4BIT_IRQ (1 << 0)
0057
0058
0059 #define HTC_MAILBOX 0
0060
0061 #define ATH6KL_TARGET_DEBUG_INTR_MASK 0x01
0062
0063
0064 #define ATH6KL_SCATTER_ENTRIES_PER_REQ 16
0065 #define ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER (16 * 1024)
0066 #define ATH6KL_SCATTER_REQS 4
0067
0068 #define ATH6KL_HIF_COMMUNICATION_TIMEOUT 1000
0069
0070 struct bus_request {
0071 struct list_head list;
0072
0073
0074 u32 address;
0075
0076 u8 *buffer;
0077 u32 length;
0078 u32 request;
0079 struct htc_packet *packet;
0080 int status;
0081
0082
0083 struct hif_scatter_req *scat_req;
0084 };
0085
0086
0087 #define HIF_READ 0x00000001
0088 #define HIF_WRITE 0x00000002
0089 #define HIF_DIR_MASK (HIF_READ | HIF_WRITE)
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102 #define HIF_SYNCHRONOUS 0x00000010
0103 #define HIF_ASYNCHRONOUS 0x00000020
0104 #define HIF_EMODE_MASK (HIF_SYNCHRONOUS | HIF_ASYNCHRONOUS)
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 #define HIF_BYTE_BASIS 0x00000040
0117 #define HIF_BLOCK_BASIS 0x00000080
0118 #define HIF_DMODE_MASK (HIF_BYTE_BASIS | HIF_BLOCK_BASIS)
0119
0120
0121
0122
0123
0124
0125 #define HIF_FIXED_ADDRESS 0x00000100
0126 #define HIF_INCREMENTAL_ADDRESS 0x00000200
0127 #define HIF_AMODE_MASK (HIF_FIXED_ADDRESS | HIF_INCREMENTAL_ADDRESS)
0128
0129 #define HIF_WR_ASYNC_BYTE_INC \
0130 (HIF_WRITE | HIF_ASYNCHRONOUS | \
0131 HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS)
0132
0133 #define HIF_WR_ASYNC_BLOCK_INC \
0134 (HIF_WRITE | HIF_ASYNCHRONOUS | \
0135 HIF_BLOCK_BASIS | HIF_INCREMENTAL_ADDRESS)
0136
0137 #define HIF_WR_SYNC_BYTE_FIX \
0138 (HIF_WRITE | HIF_SYNCHRONOUS | \
0139 HIF_BYTE_BASIS | HIF_FIXED_ADDRESS)
0140
0141 #define HIF_WR_SYNC_BYTE_INC \
0142 (HIF_WRITE | HIF_SYNCHRONOUS | \
0143 HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS)
0144
0145 #define HIF_WR_SYNC_BLOCK_INC \
0146 (HIF_WRITE | HIF_SYNCHRONOUS | \
0147 HIF_BLOCK_BASIS | HIF_INCREMENTAL_ADDRESS)
0148
0149 #define HIF_RD_SYNC_BYTE_INC \
0150 (HIF_READ | HIF_SYNCHRONOUS | \
0151 HIF_BYTE_BASIS | HIF_INCREMENTAL_ADDRESS)
0152
0153 #define HIF_RD_SYNC_BYTE_FIX \
0154 (HIF_READ | HIF_SYNCHRONOUS | \
0155 HIF_BYTE_BASIS | HIF_FIXED_ADDRESS)
0156
0157 #define HIF_RD_ASYNC_BLOCK_FIX \
0158 (HIF_READ | HIF_ASYNCHRONOUS | \
0159 HIF_BLOCK_BASIS | HIF_FIXED_ADDRESS)
0160
0161 #define HIF_RD_SYNC_BLOCK_FIX \
0162 (HIF_READ | HIF_SYNCHRONOUS | \
0163 HIF_BLOCK_BASIS | HIF_FIXED_ADDRESS)
0164
0165 struct hif_scatter_item {
0166 u8 *buf;
0167 int len;
0168 struct htc_packet *packet;
0169 };
0170
0171 struct hif_scatter_req {
0172 struct list_head list;
0173
0174 u32 addr;
0175
0176
0177 u32 req;
0178
0179
0180 u32 len;
0181
0182 bool virt_scat;
0183
0184 void (*complete) (struct htc_target *, struct hif_scatter_req *);
0185 int status;
0186 int scat_entries;
0187
0188 struct bus_request *busrequest;
0189 struct scatterlist *sgentries;
0190
0191
0192 u8 *virt_dma_buf;
0193
0194 u32 scat_q_depth;
0195
0196 struct hif_scatter_item scat_list[];
0197 };
0198
0199 struct ath6kl_irq_proc_registers {
0200 u8 host_int_status;
0201 u8 cpu_int_status;
0202 u8 error_int_status;
0203 u8 counter_int_status;
0204 u8 mbox_frame;
0205 u8 rx_lkahd_valid;
0206 u8 host_int_status2;
0207 u8 gmbox_rx_avail;
0208 __le32 rx_lkahd[2];
0209 __le32 rx_gmbox_lkahd_alias[2];
0210 } __packed;
0211
0212 struct ath6kl_irq_enable_reg {
0213 u8 int_status_en;
0214 u8 cpu_int_status_en;
0215 u8 err_int_status_en;
0216 u8 cntr_int_status_en;
0217 } __packed;
0218
0219 struct ath6kl_device {
0220
0221 spinlock_t lock;
0222 struct ath6kl_irq_proc_registers irq_proc_reg;
0223 struct ath6kl_irq_enable_reg irq_en_reg;
0224 struct htc_target *htc_cnxt;
0225 struct ath6kl *ar;
0226 };
0227
0228 struct ath6kl_hif_ops {
0229 int (*read_write_sync)(struct ath6kl *ar, u32 addr, u8 *buf,
0230 u32 len, u32 request);
0231 int (*write_async)(struct ath6kl *ar, u32 address, u8 *buffer,
0232 u32 length, u32 request, struct htc_packet *packet);
0233
0234 void (*irq_enable)(struct ath6kl *ar);
0235 void (*irq_disable)(struct ath6kl *ar);
0236
0237 struct hif_scatter_req *(*scatter_req_get)(struct ath6kl *ar);
0238 void (*scatter_req_add)(struct ath6kl *ar,
0239 struct hif_scatter_req *s_req);
0240 int (*enable_scatter)(struct ath6kl *ar);
0241 int (*scat_req_rw) (struct ath6kl *ar,
0242 struct hif_scatter_req *scat_req);
0243 void (*cleanup_scatter)(struct ath6kl *ar);
0244 int (*suspend)(struct ath6kl *ar, struct cfg80211_wowlan *wow);
0245 int (*resume)(struct ath6kl *ar);
0246 int (*diag_read32)(struct ath6kl *ar, u32 address, u32 *value);
0247 int (*diag_write32)(struct ath6kl *ar, u32 address, __le32 value);
0248 int (*bmi_read)(struct ath6kl *ar, u8 *buf, u32 len);
0249 int (*bmi_write)(struct ath6kl *ar, u8 *buf, u32 len);
0250 int (*power_on)(struct ath6kl *ar);
0251 int (*power_off)(struct ath6kl *ar);
0252 void (*stop)(struct ath6kl *ar);
0253 int (*pipe_send)(struct ath6kl *ar, u8 pipe, struct sk_buff *hdr_buf,
0254 struct sk_buff *buf);
0255 void (*pipe_get_default)(struct ath6kl *ar, u8 *pipe_ul, u8 *pipe_dl);
0256 int (*pipe_map_service)(struct ath6kl *ar, u16 service_id, u8 *pipe_ul,
0257 u8 *pipe_dl);
0258 u16 (*pipe_get_free_queue_number)(struct ath6kl *ar, u8 pipe);
0259 };
0260
0261 int ath6kl_hif_setup(struct ath6kl_device *dev);
0262 int ath6kl_hif_unmask_intrs(struct ath6kl_device *dev);
0263 int ath6kl_hif_mask_intrs(struct ath6kl_device *dev);
0264 int ath6kl_hif_poll_mboxmsg_rx(struct ath6kl_device *dev,
0265 u32 *lk_ahd, int timeout);
0266 int ath6kl_hif_rx_control(struct ath6kl_device *dev, bool enable_rx);
0267 int ath6kl_hif_disable_intrs(struct ath6kl_device *dev);
0268
0269 int ath6kl_hif_rw_comp_handler(void *context, int status);
0270 int ath6kl_hif_intr_bh_handler(struct ath6kl *ar);
0271
0272
0273 int ath6kl_hif_submit_scat_req(struct ath6kl_device *dev,
0274 struct hif_scatter_req *scat_req, bool read);
0275
0276 #endif