root/drivers/net/wireless/ath/ath10k/hif.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ath10k_hif_tx_sg
  2. ath10k_hif_diag_read
  3. ath10k_hif_diag_write
  4. ath10k_hif_exchange_bmi_msg
  5. ath10k_hif_start
  6. ath10k_hif_stop
  7. ath10k_hif_swap_mailbox
  8. ath10k_hif_map_service_to_pipe
  9. ath10k_hif_get_default_pipe
  10. ath10k_hif_send_complete_check
  11. ath10k_hif_get_free_queue_number
  12. ath10k_hif_power_up
  13. ath10k_hif_power_down
  14. ath10k_hif_suspend
  15. ath10k_hif_resume
  16. ath10k_hif_read32
  17. ath10k_hif_write32
  18. ath10k_hif_fetch_cal_eeprom
  19. ath10k_hif_get_target_info
  20. ath10k_hif_set_target_log_mode

   1 /* SPDX-License-Identifier: ISC */
   2 /*
   3  * Copyright (c) 2005-2011 Atheros Communications Inc.
   4  * Copyright (c) 2011-2015,2017 Qualcomm Atheros, Inc.
   5  */
   6 
   7 #ifndef _HIF_H_
   8 #define _HIF_H_
   9 
  10 #include <linux/kernel.h>
  11 #include "core.h"
  12 #include "bmi.h"
  13 #include "debug.h"
  14 
  15 /* Types of fw logging mode */
  16 enum ath_dbg_mode {
  17         ATH10K_ENABLE_FW_LOG_DIAG,
  18         ATH10K_ENABLE_FW_LOG_CE,
  19 };
  20 
  21 struct ath10k_hif_sg_item {
  22         u16 transfer_id;
  23         void *transfer_context; /* NULL = tx completion callback not called */
  24         void *vaddr; /* for debugging mostly */
  25         dma_addr_t paddr;
  26         u16 len;
  27 };
  28 
  29 struct ath10k_hif_ops {
  30         /* send a scatter-gather list to the target */
  31         int (*tx_sg)(struct ath10k *ar, u8 pipe_id,
  32                      struct ath10k_hif_sg_item *items, int n_items);
  33 
  34         /* read firmware memory through the diagnose interface */
  35         int (*diag_read)(struct ath10k *ar, u32 address, void *buf,
  36                          size_t buf_len);
  37 
  38         int (*diag_write)(struct ath10k *ar, u32 address, const void *data,
  39                           int nbytes);
  40         /*
  41          * API to handle HIF-specific BMI message exchanges, this API is
  42          * synchronous and only allowed to be called from a context that
  43          * can block (sleep)
  44          */
  45         int (*exchange_bmi_msg)(struct ath10k *ar,
  46                                 void *request, u32 request_len,
  47                                 void *response, u32 *response_len);
  48 
  49         /* Post BMI phase, after FW is loaded. Starts regular operation */
  50         int (*start)(struct ath10k *ar);
  51 
  52         /* Clean up what start() did. This does not revert to BMI phase. If
  53          * desired so, call power_down() and power_up()
  54          */
  55         void (*stop)(struct ath10k *ar);
  56 
  57         int (*swap_mailbox)(struct ath10k *ar);
  58 
  59         int (*map_service_to_pipe)(struct ath10k *ar, u16 service_id,
  60                                    u8 *ul_pipe, u8 *dl_pipe);
  61 
  62         void (*get_default_pipe)(struct ath10k *ar, u8 *ul_pipe, u8 *dl_pipe);
  63 
  64         /*
  65          * Check if prior sends have completed.
  66          *
  67          * Check whether the pipe in question has any completed
  68          * sends that have not yet been processed.
  69          * This function is only relevant for HIF pipes that are configured
  70          * to be polled rather than interrupt-driven.
  71          */
  72         void (*send_complete_check)(struct ath10k *ar, u8 pipe_id, int force);
  73 
  74         u16 (*get_free_queue_number)(struct ath10k *ar, u8 pipe_id);
  75 
  76         u32 (*read32)(struct ath10k *ar, u32 address);
  77 
  78         void (*write32)(struct ath10k *ar, u32 address, u32 value);
  79 
  80         /* Power up the device and enter BMI transfer mode for FW download */
  81         int (*power_up)(struct ath10k *ar, enum ath10k_firmware_mode fw_mode);
  82 
  83         /* Power down the device and free up resources. stop() must be called
  84          * before this if start() was called earlier
  85          */
  86         void (*power_down)(struct ath10k *ar);
  87 
  88         int (*suspend)(struct ath10k *ar);
  89         int (*resume)(struct ath10k *ar);
  90 
  91         /* fetch calibration data from target eeprom */
  92         int (*fetch_cal_eeprom)(struct ath10k *ar, void **data,
  93                                 size_t *data_len);
  94 
  95         int (*get_target_info)(struct ath10k *ar,
  96                                struct bmi_target_info *target_info);
  97         int (*set_target_log_mode)(struct ath10k *ar, u8 fw_log_mode);
  98 };
  99 
 100 static inline int ath10k_hif_tx_sg(struct ath10k *ar, u8 pipe_id,
 101                                    struct ath10k_hif_sg_item *items,
 102                                    int n_items)
 103 {
 104         return ar->hif.ops->tx_sg(ar, pipe_id, items, n_items);
 105 }
 106 
 107 static inline int ath10k_hif_diag_read(struct ath10k *ar, u32 address, void *buf,
 108                                        size_t buf_len)
 109 {
 110         return ar->hif.ops->diag_read(ar, address, buf, buf_len);
 111 }
 112 
 113 static inline int ath10k_hif_diag_write(struct ath10k *ar, u32 address,
 114                                         const void *data, int nbytes)
 115 {
 116         if (!ar->hif.ops->diag_write)
 117                 return -EOPNOTSUPP;
 118 
 119         return ar->hif.ops->diag_write(ar, address, data, nbytes);
 120 }
 121 
 122 static inline int ath10k_hif_exchange_bmi_msg(struct ath10k *ar,
 123                                               void *request, u32 request_len,
 124                                               void *response, u32 *response_len)
 125 {
 126         return ar->hif.ops->exchange_bmi_msg(ar, request, request_len,
 127                                              response, response_len);
 128 }
 129 
 130 static inline int ath10k_hif_start(struct ath10k *ar)
 131 {
 132         return ar->hif.ops->start(ar);
 133 }
 134 
 135 static inline void ath10k_hif_stop(struct ath10k *ar)
 136 {
 137         return ar->hif.ops->stop(ar);
 138 }
 139 
 140 static inline int ath10k_hif_swap_mailbox(struct ath10k *ar)
 141 {
 142         if (ar->hif.ops->swap_mailbox)
 143                 return ar->hif.ops->swap_mailbox(ar);
 144         return 0;
 145 }
 146 
 147 static inline int ath10k_hif_map_service_to_pipe(struct ath10k *ar,
 148                                                  u16 service_id,
 149                                                  u8 *ul_pipe, u8 *dl_pipe)
 150 {
 151         return ar->hif.ops->map_service_to_pipe(ar, service_id,
 152                                                 ul_pipe, dl_pipe);
 153 }
 154 
 155 static inline void ath10k_hif_get_default_pipe(struct ath10k *ar,
 156                                                u8 *ul_pipe, u8 *dl_pipe)
 157 {
 158         ar->hif.ops->get_default_pipe(ar, ul_pipe, dl_pipe);
 159 }
 160 
 161 static inline void ath10k_hif_send_complete_check(struct ath10k *ar,
 162                                                   u8 pipe_id, int force)
 163 {
 164         ar->hif.ops->send_complete_check(ar, pipe_id, force);
 165 }
 166 
 167 static inline u16 ath10k_hif_get_free_queue_number(struct ath10k *ar,
 168                                                    u8 pipe_id)
 169 {
 170         return ar->hif.ops->get_free_queue_number(ar, pipe_id);
 171 }
 172 
 173 static inline int ath10k_hif_power_up(struct ath10k *ar,
 174                                       enum ath10k_firmware_mode fw_mode)
 175 {
 176         return ar->hif.ops->power_up(ar, fw_mode);
 177 }
 178 
 179 static inline void ath10k_hif_power_down(struct ath10k *ar)
 180 {
 181         ar->hif.ops->power_down(ar);
 182 }
 183 
 184 static inline int ath10k_hif_suspend(struct ath10k *ar)
 185 {
 186         if (!ar->hif.ops->suspend)
 187                 return -EOPNOTSUPP;
 188 
 189         return ar->hif.ops->suspend(ar);
 190 }
 191 
 192 static inline int ath10k_hif_resume(struct ath10k *ar)
 193 {
 194         if (!ar->hif.ops->resume)
 195                 return -EOPNOTSUPP;
 196 
 197         return ar->hif.ops->resume(ar);
 198 }
 199 
 200 static inline u32 ath10k_hif_read32(struct ath10k *ar, u32 address)
 201 {
 202         if (!ar->hif.ops->read32) {
 203                 ath10k_warn(ar, "hif read32 not supported\n");
 204                 return 0xdeaddead;
 205         }
 206 
 207         return ar->hif.ops->read32(ar, address);
 208 }
 209 
 210 static inline void ath10k_hif_write32(struct ath10k *ar,
 211                                       u32 address, u32 data)
 212 {
 213         if (!ar->hif.ops->write32) {
 214                 ath10k_warn(ar, "hif write32 not supported\n");
 215                 return;
 216         }
 217 
 218         ar->hif.ops->write32(ar, address, data);
 219 }
 220 
 221 static inline int ath10k_hif_fetch_cal_eeprom(struct ath10k *ar,
 222                                               void **data,
 223                                               size_t *data_len)
 224 {
 225         if (!ar->hif.ops->fetch_cal_eeprom)
 226                 return -EOPNOTSUPP;
 227 
 228         return ar->hif.ops->fetch_cal_eeprom(ar, data, data_len);
 229 }
 230 
 231 static inline int ath10k_hif_get_target_info(struct ath10k *ar,
 232                                              struct bmi_target_info *tgt_info)
 233 {
 234         if (!ar->hif.ops->get_target_info)
 235                 return -EOPNOTSUPP;
 236 
 237         return ar->hif.ops->get_target_info(ar, tgt_info);
 238 }
 239 
 240 static inline int ath10k_hif_set_target_log_mode(struct ath10k *ar,
 241                                                  u8 fw_log_mode)
 242 {
 243         if (!ar->hif.ops->set_target_log_mode)
 244                 return -EOPNOTSUPP;
 245 
 246         return ar->hif.ops->set_target_log_mode(ar, fw_log_mode);
 247 }
 248 #endif /* _HIF_H_ */

/* [<][>][^][v][top][bottom][index][help] */