0001
0002
0003
0004
0005
0006 #ifndef _HIF_H_
0007 #define _HIF_H_
0008
0009 #include "core.h"
0010
0011 struct ath11k_hif_ops {
0012 u32 (*read32)(struct ath11k_base *sc, u32 address);
0013 void (*write32)(struct ath11k_base *sc, u32 address, u32 data);
0014 void (*irq_enable)(struct ath11k_base *sc);
0015 void (*irq_disable)(struct ath11k_base *sc);
0016 int (*start)(struct ath11k_base *sc);
0017 void (*stop)(struct ath11k_base *sc);
0018 int (*power_up)(struct ath11k_base *sc);
0019 void (*power_down)(struct ath11k_base *sc);
0020 int (*suspend)(struct ath11k_base *ab);
0021 int (*resume)(struct ath11k_base *ab);
0022 int (*map_service_to_pipe)(struct ath11k_base *sc, u16 service_id,
0023 u8 *ul_pipe, u8 *dl_pipe);
0024 int (*get_user_msi_vector)(struct ath11k_base *ab, char *user_name,
0025 int *num_vectors, u32 *user_base_data,
0026 u32 *base_vector);
0027 void (*get_msi_address)(struct ath11k_base *ab, u32 *msi_addr_lo,
0028 u32 *msi_addr_hi);
0029 void (*ce_irq_enable)(struct ath11k_base *ab);
0030 void (*ce_irq_disable)(struct ath11k_base *ab);
0031 void (*get_ce_msi_idx)(struct ath11k_base *ab, u32 ce_id, u32 *msi_idx);
0032 };
0033
0034 static inline void ath11k_hif_ce_irq_enable(struct ath11k_base *ab)
0035 {
0036 if (ab->hif.ops->ce_irq_enable)
0037 ab->hif.ops->ce_irq_enable(ab);
0038 }
0039
0040 static inline void ath11k_hif_ce_irq_disable(struct ath11k_base *ab)
0041 {
0042 if (ab->hif.ops->ce_irq_disable)
0043 ab->hif.ops->ce_irq_disable(ab);
0044 }
0045
0046 static inline int ath11k_hif_start(struct ath11k_base *sc)
0047 {
0048 return sc->hif.ops->start(sc);
0049 }
0050
0051 static inline void ath11k_hif_stop(struct ath11k_base *sc)
0052 {
0053 sc->hif.ops->stop(sc);
0054 }
0055
0056 static inline void ath11k_hif_irq_enable(struct ath11k_base *sc)
0057 {
0058 sc->hif.ops->irq_enable(sc);
0059 }
0060
0061 static inline void ath11k_hif_irq_disable(struct ath11k_base *sc)
0062 {
0063 sc->hif.ops->irq_disable(sc);
0064 }
0065
0066 static inline int ath11k_hif_power_up(struct ath11k_base *sc)
0067 {
0068 return sc->hif.ops->power_up(sc);
0069 }
0070
0071 static inline void ath11k_hif_power_down(struct ath11k_base *sc)
0072 {
0073 sc->hif.ops->power_down(sc);
0074 }
0075
0076 static inline int ath11k_hif_suspend(struct ath11k_base *ab)
0077 {
0078 if (ab->hif.ops->suspend)
0079 return ab->hif.ops->suspend(ab);
0080
0081 return 0;
0082 }
0083
0084 static inline int ath11k_hif_resume(struct ath11k_base *ab)
0085 {
0086 if (ab->hif.ops->resume)
0087 return ab->hif.ops->resume(ab);
0088
0089 return 0;
0090 }
0091
0092 static inline u32 ath11k_hif_read32(struct ath11k_base *sc, u32 address)
0093 {
0094 return sc->hif.ops->read32(sc, address);
0095 }
0096
0097 static inline void ath11k_hif_write32(struct ath11k_base *sc, u32 address, u32 data)
0098 {
0099 sc->hif.ops->write32(sc, address, data);
0100 }
0101
0102 static inline int ath11k_hif_map_service_to_pipe(struct ath11k_base *sc, u16 service_id,
0103 u8 *ul_pipe, u8 *dl_pipe)
0104 {
0105 return sc->hif.ops->map_service_to_pipe(sc, service_id, ul_pipe, dl_pipe);
0106 }
0107
0108 static inline int ath11k_get_user_msi_vector(struct ath11k_base *ab, char *user_name,
0109 int *num_vectors, u32 *user_base_data,
0110 u32 *base_vector)
0111 {
0112 if (!ab->hif.ops->get_user_msi_vector)
0113 return -EOPNOTSUPP;
0114
0115 return ab->hif.ops->get_user_msi_vector(ab, user_name, num_vectors,
0116 user_base_data,
0117 base_vector);
0118 }
0119
0120 static inline void ath11k_get_msi_address(struct ath11k_base *ab, u32 *msi_addr_lo,
0121 u32 *msi_addr_hi)
0122 {
0123 if (!ab->hif.ops->get_msi_address)
0124 return;
0125
0126 ab->hif.ops->get_msi_address(ab, msi_addr_lo, msi_addr_hi);
0127 }
0128
0129 static inline void ath11k_get_ce_msi_idx(struct ath11k_base *ab, u32 ce_id,
0130 u32 *msi_data_idx)
0131 {
0132 if (ab->hif.ops->get_ce_msi_idx)
0133 ab->hif.ops->get_ce_msi_idx(ab, ce_id, msi_data_idx);
0134 else
0135 *msi_data_idx = ce_id;
0136 }
0137 #endif