Path: blob/main/sys/contrib/dev/athk/ath10k/hif.h
107763 views
/* SPDX-License-Identifier: ISC */1/*2* Copyright (c) 2005-2011 Atheros Communications Inc.3* Copyright (c) 2011-2015,2017 Qualcomm Atheros, Inc.4*/56#ifndef _HIF_H_7#define _HIF_H_89#include <linux/kernel.h>10#include "core.h"11#include "bmi.h"12#include "debug.h"1314/* Types of fw logging mode */15enum ath_dbg_mode {16ATH10K_ENABLE_FW_LOG_DIAG,17ATH10K_ENABLE_FW_LOG_CE,18};1920struct ath10k_hif_sg_item {21u16 transfer_id;22void *transfer_context; /* NULL = tx completion callback not called */23void *vaddr; /* for debugging mostly */24dma_addr_t paddr;25u16 len;26};2728struct ath10k_hif_ops {29/* send a scatter-gather list to the target */30int (*tx_sg)(struct ath10k *ar, u8 pipe_id,31struct ath10k_hif_sg_item *items, int n_items);3233/* read firmware memory through the diagnose interface */34int (*diag_read)(struct ath10k *ar, u32 address, void *buf,35size_t buf_len);3637int (*diag_write)(struct ath10k *ar, u32 address, const void *data,38int nbytes);39/*40* API to handle HIF-specific BMI message exchanges, this API is41* synchronous and only allowed to be called from a context that42* can block (sleep)43*/44int (*exchange_bmi_msg)(struct ath10k *ar,45void *request, u32 request_len,46void *response, u32 *response_len);4748/* Post BMI phase, after FW is loaded. Starts regular operation */49int (*start)(struct ath10k *ar);5051/* Clean up what start() did. This does not revert to BMI phase. If52* desired so, call power_down() and power_up()53*/54void (*stop)(struct ath10k *ar);5556int (*start_post)(struct ath10k *ar);5758int (*get_htt_tx_complete)(struct ath10k *ar);5960int (*map_service_to_pipe)(struct ath10k *ar, u16 service_id,61u8 *ul_pipe, u8 *dl_pipe);6263void (*get_default_pipe)(struct ath10k *ar, u8 *ul_pipe, u8 *dl_pipe);6465/*66* Check if prior sends have completed.67*68* Check whether the pipe in question has any completed69* sends that have not yet been processed.70* This function is only relevant for HIF pipes that are configured71* to be polled rather than interrupt-driven.72*/73void (*send_complete_check)(struct ath10k *ar, u8 pipe_id, int force);7475u16 (*get_free_queue_number)(struct ath10k *ar, u8 pipe_id);7677u32 (*read32)(struct ath10k *ar, u32 address);7879void (*write32)(struct ath10k *ar, u32 address, u32 value);8081/* Power up the device and enter BMI transfer mode for FW download */82int (*power_up)(struct ath10k *ar, enum ath10k_firmware_mode fw_mode);8384/* Power down the device and free up resources. stop() must be called85* before this if start() was called earlier86*/87void (*power_down)(struct ath10k *ar);8889int (*suspend)(struct ath10k *ar);90int (*resume)(struct ath10k *ar);9192/* fetch calibration data from target eeprom */93int (*fetch_cal_eeprom)(struct ath10k *ar, void **data,94size_t *data_len);9596int (*get_target_info)(struct ath10k *ar,97struct bmi_target_info *target_info);98int (*set_target_log_mode)(struct ath10k *ar, u8 fw_log_mode);99};100101static inline int ath10k_hif_tx_sg(struct ath10k *ar, u8 pipe_id,102struct ath10k_hif_sg_item *items,103int n_items)104{105return ar->hif.ops->tx_sg(ar, pipe_id, items, n_items);106}107108static inline int ath10k_hif_diag_read(struct ath10k *ar, u32 address, void *buf,109size_t buf_len)110{111return ar->hif.ops->diag_read(ar, address, buf, buf_len);112}113114static inline int ath10k_hif_diag_write(struct ath10k *ar, u32 address,115const void *data, int nbytes)116{117if (!ar->hif.ops->diag_write)118return -EOPNOTSUPP;119120return ar->hif.ops->diag_write(ar, address, data, nbytes);121}122123static inline int ath10k_hif_exchange_bmi_msg(struct ath10k *ar,124void *request, u32 request_len,125void *response, u32 *response_len)126{127return ar->hif.ops->exchange_bmi_msg(ar, request, request_len,128response, response_len);129}130131static inline int ath10k_hif_start(struct ath10k *ar)132{133return ar->hif.ops->start(ar);134}135136static inline void ath10k_hif_stop(struct ath10k *ar)137{138return ar->hif.ops->stop(ar);139}140141static inline int ath10k_hif_start_post(struct ath10k *ar)142{143if (ar->hif.ops->start_post)144return ar->hif.ops->start_post(ar);145return 0;146}147148static inline int ath10k_hif_get_htt_tx_complete(struct ath10k *ar)149{150if (ar->hif.ops->get_htt_tx_complete)151return ar->hif.ops->get_htt_tx_complete(ar);152return 0;153}154155static inline int ath10k_hif_map_service_to_pipe(struct ath10k *ar,156u16 service_id,157u8 *ul_pipe, u8 *dl_pipe)158{159return ar->hif.ops->map_service_to_pipe(ar, service_id,160ul_pipe, dl_pipe);161}162163static inline void ath10k_hif_get_default_pipe(struct ath10k *ar,164u8 *ul_pipe, u8 *dl_pipe)165{166ar->hif.ops->get_default_pipe(ar, ul_pipe, dl_pipe);167}168169static inline void ath10k_hif_send_complete_check(struct ath10k *ar,170u8 pipe_id, int force)171{172if (ar->hif.ops->send_complete_check)173ar->hif.ops->send_complete_check(ar, pipe_id, force);174}175176static inline u16 ath10k_hif_get_free_queue_number(struct ath10k *ar,177u8 pipe_id)178{179return ar->hif.ops->get_free_queue_number(ar, pipe_id);180}181182static inline int ath10k_hif_power_up(struct ath10k *ar,183enum ath10k_firmware_mode fw_mode)184{185return ar->hif.ops->power_up(ar, fw_mode);186}187188static inline void ath10k_hif_power_down(struct ath10k *ar)189{190ar->hif.ops->power_down(ar);191}192193static inline int ath10k_hif_suspend(struct ath10k *ar)194{195if (!ar->hif.ops->suspend)196return -EOPNOTSUPP;197198return ar->hif.ops->suspend(ar);199}200201static inline int ath10k_hif_resume(struct ath10k *ar)202{203if (!ar->hif.ops->resume)204return -EOPNOTSUPP;205206return ar->hif.ops->resume(ar);207}208209static inline u32 ath10k_hif_read32(struct ath10k *ar, u32 address)210{211if (!ar->hif.ops->read32) {212ath10k_warn(ar, "hif read32 not supported\n");213return 0xdeaddead;214}215216return ar->hif.ops->read32(ar, address);217}218219static inline void ath10k_hif_write32(struct ath10k *ar,220u32 address, u32 data)221{222if (!ar->hif.ops->write32) {223ath10k_warn(ar, "hif write32 not supported\n");224return;225}226227ar->hif.ops->write32(ar, address, data);228}229230static inline int ath10k_hif_fetch_cal_eeprom(struct ath10k *ar,231void **data,232size_t *data_len)233{234if (!ar->hif.ops->fetch_cal_eeprom)235return -EOPNOTSUPP;236237return ar->hif.ops->fetch_cal_eeprom(ar, data, data_len);238}239240static inline int ath10k_hif_get_target_info(struct ath10k *ar,241struct bmi_target_info *tgt_info)242{243if (!ar->hif.ops->get_target_info)244return -EOPNOTSUPP;245246return ar->hif.ops->get_target_info(ar, tgt_info);247}248249static inline int ath10k_hif_set_target_log_mode(struct ath10k *ar,250u8 fw_log_mode)251{252if (!ar->hif.ops->set_target_log_mode)253return -EOPNOTSUPP;254255return ar->hif.ops->set_target_log_mode(ar, fw_log_mode);256}257#endif /* _HIF_H_ */258259260