1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */ 2 /* 3 * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved. 4 */ 5 6 #ifndef _HIF_H_ 7 #define _HIF_H_ 8 9 #include "core.h" 10 11 struct ath11k_hif_ops { 12 u32 (*read32)(struct ath11k_base *sc, u32 address); 13 void (*write32)(struct ath11k_base *sc, u32 address, u32 data); 14 void (*irq_enable)(struct ath11k_base *sc); 15 void (*irq_disable)(struct ath11k_base *sc); 16 int (*start)(struct ath11k_base *sc); 17 void (*stop)(struct ath11k_base *sc); 18 int (*power_up)(struct ath11k_base *sc); 19 void (*power_down)(struct ath11k_base *sc); 20 int (*map_service_to_pipe)(struct ath11k_base *sc, u16 service_id, 21 u8 *ul_pipe, u8 *dl_pipe); 22 int (*get_user_msi_vector)(struct ath11k_base *ab, char *user_name, 23 int *num_vectors, u32 *user_base_data, 24 u32 *base_vector); 25 void (*get_msi_address)(struct ath11k_base *ab, u32 *msi_addr_lo, 26 u32 *msi_addr_hi); 27 }; 28 29 static inline int ath11k_hif_start(struct ath11k_base *sc) 30 { 31 return sc->hif.ops->start(sc); 32 } 33 34 static inline void ath11k_hif_stop(struct ath11k_base *sc) 35 { 36 sc->hif.ops->stop(sc); 37 } 38 39 static inline void ath11k_hif_irq_enable(struct ath11k_base *sc) 40 { 41 sc->hif.ops->irq_enable(sc); 42 } 43 44 static inline void ath11k_hif_irq_disable(struct ath11k_base *sc) 45 { 46 sc->hif.ops->irq_disable(sc); 47 } 48 49 static inline int ath11k_hif_power_up(struct ath11k_base *sc) 50 { 51 return sc->hif.ops->power_up(sc); 52 } 53 54 static inline void ath11k_hif_power_down(struct ath11k_base *sc) 55 { 56 sc->hif.ops->power_down(sc); 57 } 58 59 static inline u32 ath11k_hif_read32(struct ath11k_base *sc, u32 address) 60 { 61 return sc->hif.ops->read32(sc, address); 62 } 63 64 static inline void ath11k_hif_write32(struct ath11k_base *sc, u32 address, u32 data) 65 { 66 sc->hif.ops->write32(sc, address, data); 67 } 68 69 static inline int ath11k_hif_map_service_to_pipe(struct ath11k_base *sc, u16 service_id, 70 u8 *ul_pipe, u8 *dl_pipe) 71 { 72 return sc->hif.ops->map_service_to_pipe(sc, service_id, ul_pipe, dl_pipe); 73 } 74 75 static inline int ath11k_get_user_msi_vector(struct ath11k_base *ab, char *user_name, 76 int *num_vectors, u32 *user_base_data, 77 u32 *base_vector) 78 { 79 if (!ab->hif.ops->get_user_msi_vector) 80 return -EOPNOTSUPP; 81 82 return ab->hif.ops->get_user_msi_vector(ab, user_name, num_vectors, 83 user_base_data, 84 base_vector); 85 } 86 87 static inline void ath11k_get_msi_address(struct ath11k_base *ab, u32 *msi_addr_lo, 88 u32 *msi_addr_hi) 89 { 90 if (!ab->hif.ops->get_msi_address) 91 return; 92 93 ab->hif.ops->get_msi_address(ab, msi_addr_lo, msi_addr_hi); 94 } 95 #endif /* _HIF_H_ */ 96