1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3 * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
5 */
6
7 #ifndef ATH12K_HIF_H
8 #define ATH12K_HIF_H
9
10 #include "core.h"
11
12 struct ath12k_hif_ops {
13 u32 (*read32)(struct ath12k_base *sc, u32 address);
14 void (*write32)(struct ath12k_base *sc, u32 address, u32 data);
15 void (*irq_enable)(struct ath12k_base *sc);
16 void (*irq_disable)(struct ath12k_base *sc);
17 int (*start)(struct ath12k_base *sc);
18 void (*stop)(struct ath12k_base *sc);
19 int (*power_up)(struct ath12k_base *sc);
20 void (*power_down)(struct ath12k_base *sc);
21 int (*suspend)(struct ath12k_base *ab);
22 int (*resume)(struct ath12k_base *ab);
23 int (*map_service_to_pipe)(struct ath12k_base *sc, u16 service_id,
24 u8 *ul_pipe, u8 *dl_pipe);
25 int (*get_user_msi_vector)(struct ath12k_base *ab, char *user_name,
26 int *num_vectors, u32 *user_base_data,
27 u32 *base_vector);
28 void (*get_msi_address)(struct ath12k_base *ab, u32 *msi_addr_lo,
29 u32 *msi_addr_hi);
30 void (*ce_irq_enable)(struct ath12k_base *ab);
31 void (*ce_irq_disable)(struct ath12k_base *ab);
32 void (*get_ce_msi_idx)(struct ath12k_base *ab, u32 ce_id, u32 *msi_idx);
33 };
34
ath12k_hif_map_service_to_pipe(struct ath12k_base * ab,u16 service_id,u8 * ul_pipe,u8 * dl_pipe)35 static inline int ath12k_hif_map_service_to_pipe(struct ath12k_base *ab, u16 service_id,
36 u8 *ul_pipe, u8 *dl_pipe)
37 {
38 return ab->hif.ops->map_service_to_pipe(ab, service_id,
39 ul_pipe, dl_pipe);
40 }
41
ath12k_hif_get_user_msi_vector(struct ath12k_base * ab,char * user_name,int * num_vectors,u32 * user_base_data,u32 * base_vector)42 static inline int ath12k_hif_get_user_msi_vector(struct ath12k_base *ab,
43 char *user_name,
44 int *num_vectors,
45 u32 *user_base_data,
46 u32 *base_vector)
47 {
48 if (!ab->hif.ops->get_user_msi_vector)
49 return -EOPNOTSUPP;
50
51 return ab->hif.ops->get_user_msi_vector(ab, user_name, num_vectors,
52 user_base_data,
53 base_vector);
54 }
55
ath12k_hif_get_msi_address(struct ath12k_base * ab,u32 * msi_addr_lo,u32 * msi_addr_hi)56 static inline void ath12k_hif_get_msi_address(struct ath12k_base *ab,
57 u32 *msi_addr_lo,
58 u32 *msi_addr_hi)
59 {
60 if (!ab->hif.ops->get_msi_address)
61 return;
62
63 ab->hif.ops->get_msi_address(ab, msi_addr_lo, msi_addr_hi);
64 }
65
ath12k_hif_get_ce_msi_idx(struct ath12k_base * ab,u32 ce_id,u32 * msi_data_idx)66 static inline void ath12k_hif_get_ce_msi_idx(struct ath12k_base *ab, u32 ce_id,
67 u32 *msi_data_idx)
68 {
69 if (ab->hif.ops->get_ce_msi_idx)
70 ab->hif.ops->get_ce_msi_idx(ab, ce_id, msi_data_idx);
71 else
72 *msi_data_idx = ce_id;
73 }
74
ath12k_hif_ce_irq_enable(struct ath12k_base * ab)75 static inline void ath12k_hif_ce_irq_enable(struct ath12k_base *ab)
76 {
77 if (ab->hif.ops->ce_irq_enable)
78 ab->hif.ops->ce_irq_enable(ab);
79 }
80
ath12k_hif_ce_irq_disable(struct ath12k_base * ab)81 static inline void ath12k_hif_ce_irq_disable(struct ath12k_base *ab)
82 {
83 if (ab->hif.ops->ce_irq_disable)
84 ab->hif.ops->ce_irq_disable(ab);
85 }
86
ath12k_hif_irq_enable(struct ath12k_base * ab)87 static inline void ath12k_hif_irq_enable(struct ath12k_base *ab)
88 {
89 ab->hif.ops->irq_enable(ab);
90 }
91
ath12k_hif_irq_disable(struct ath12k_base * ab)92 static inline void ath12k_hif_irq_disable(struct ath12k_base *ab)
93 {
94 ab->hif.ops->irq_disable(ab);
95 }
96
ath12k_hif_suspend(struct ath12k_base * ab)97 static inline int ath12k_hif_suspend(struct ath12k_base *ab)
98 {
99 if (ab->hif.ops->suspend)
100 return ab->hif.ops->suspend(ab);
101
102 return 0;
103 }
104
ath12k_hif_resume(struct ath12k_base * ab)105 static inline int ath12k_hif_resume(struct ath12k_base *ab)
106 {
107 if (ab->hif.ops->resume)
108 return ab->hif.ops->resume(ab);
109
110 return 0;
111 }
112
ath12k_hif_start(struct ath12k_base * ab)113 static inline int ath12k_hif_start(struct ath12k_base *ab)
114 {
115 return ab->hif.ops->start(ab);
116 }
117
ath12k_hif_stop(struct ath12k_base * ab)118 static inline void ath12k_hif_stop(struct ath12k_base *ab)
119 {
120 ab->hif.ops->stop(ab);
121 }
122
ath12k_hif_read32(struct ath12k_base * ab,u32 address)123 static inline u32 ath12k_hif_read32(struct ath12k_base *ab, u32 address)
124 {
125 return ab->hif.ops->read32(ab, address);
126 }
127
ath12k_hif_write32(struct ath12k_base * ab,u32 address,u32 data)128 static inline void ath12k_hif_write32(struct ath12k_base *ab, u32 address,
129 u32 data)
130 {
131 ab->hif.ops->write32(ab, address, data);
132 }
133
ath12k_hif_power_up(struct ath12k_base * ab)134 static inline int ath12k_hif_power_up(struct ath12k_base *ab)
135 {
136 return ab->hif.ops->power_up(ab);
137 }
138
ath12k_hif_power_down(struct ath12k_base * ab)139 static inline void ath12k_hif_power_down(struct ath12k_base *ab)
140 {
141 ab->hif.ops->power_down(ab);
142 }
143
144 #endif /* ATH12K_HIF_H */
145