xref: /openbmc/linux/drivers/net/wireless/ath/ath11k/hif.h (revision 31e67366)
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 (*suspend)(struct ath11k_base *ab);
21 	int (*resume)(struct ath11k_base *ab);
22 	int (*map_service_to_pipe)(struct ath11k_base *sc, u16 service_id,
23 				   u8 *ul_pipe, u8 *dl_pipe);
24 	int (*get_user_msi_vector)(struct ath11k_base *ab, char *user_name,
25 				   int *num_vectors, u32 *user_base_data,
26 				   u32 *base_vector);
27 	void (*get_msi_address)(struct ath11k_base *ab, u32 *msi_addr_lo,
28 				u32 *msi_addr_hi);
29 	void (*ce_irq_enable)(struct ath11k_base *ab);
30 	void (*ce_irq_disable)(struct ath11k_base *ab);
31 };
32 
33 static inline void ath11k_hif_ce_irq_enable(struct ath11k_base *ab)
34 {
35 	if (ab->hif.ops->ce_irq_enable)
36 		ab->hif.ops->ce_irq_enable(ab);
37 }
38 
39 static inline void ath11k_hif_ce_irq_disable(struct ath11k_base *ab)
40 {
41 	if (ab->hif.ops->ce_irq_disable)
42 		ab->hif.ops->ce_irq_disable(ab);
43 }
44 
45 static inline int ath11k_hif_start(struct ath11k_base *sc)
46 {
47 	return sc->hif.ops->start(sc);
48 }
49 
50 static inline void ath11k_hif_stop(struct ath11k_base *sc)
51 {
52 	sc->hif.ops->stop(sc);
53 }
54 
55 static inline void ath11k_hif_irq_enable(struct ath11k_base *sc)
56 {
57 	sc->hif.ops->irq_enable(sc);
58 }
59 
60 static inline void ath11k_hif_irq_disable(struct ath11k_base *sc)
61 {
62 	sc->hif.ops->irq_disable(sc);
63 }
64 
65 static inline int ath11k_hif_power_up(struct ath11k_base *sc)
66 {
67 	return sc->hif.ops->power_up(sc);
68 }
69 
70 static inline void ath11k_hif_power_down(struct ath11k_base *sc)
71 {
72 	sc->hif.ops->power_down(sc);
73 }
74 
75 static inline int ath11k_hif_suspend(struct ath11k_base *ab)
76 {
77 	if (ab->hif.ops->suspend)
78 		return ab->hif.ops->suspend(ab);
79 
80 	return 0;
81 }
82 
83 static inline int ath11k_hif_resume(struct ath11k_base *ab)
84 {
85 	if (ab->hif.ops->resume)
86 		return ab->hif.ops->resume(ab);
87 
88 	return 0;
89 }
90 
91 static inline u32 ath11k_hif_read32(struct ath11k_base *sc, u32 address)
92 {
93 	return sc->hif.ops->read32(sc, address);
94 }
95 
96 static inline void ath11k_hif_write32(struct ath11k_base *sc, u32 address, u32 data)
97 {
98 	sc->hif.ops->write32(sc, address, data);
99 }
100 
101 static inline int ath11k_hif_map_service_to_pipe(struct ath11k_base *sc, u16 service_id,
102 						 u8 *ul_pipe, u8 *dl_pipe)
103 {
104 	return sc->hif.ops->map_service_to_pipe(sc, service_id, ul_pipe, dl_pipe);
105 }
106 
107 static inline int ath11k_get_user_msi_vector(struct ath11k_base *ab, char *user_name,
108 					     int *num_vectors, u32 *user_base_data,
109 					     u32 *base_vector)
110 {
111 	if (!ab->hif.ops->get_user_msi_vector)
112 		return -EOPNOTSUPP;
113 
114 	return ab->hif.ops->get_user_msi_vector(ab, user_name, num_vectors,
115 						user_base_data,
116 						base_vector);
117 }
118 
119 static inline void ath11k_get_msi_address(struct ath11k_base *ab, u32 *msi_addr_lo,
120 					  u32 *msi_addr_hi)
121 {
122 	if (!ab->hif.ops->get_msi_address)
123 		return;
124 
125 	ab->hif.ops->get_msi_address(ab, msi_addr_lo, msi_addr_hi);
126 }
127 #endif /* _HIF_H_ */
128