xref: /wlan-dirver/qca-wifi-host-cmn/hif/src/dispatcher/multibus.h (revision 70a19e16789e308182f63b15c75decec7bf0b342)
1 /*
2  * Copyright (c) 2016-2018, 2020-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _MULTIBUS_H_
21 #define _MULTIBUS_H_
22 
23 #include "osdep.h"
24 #include "qdf_status.h"
25 #include "hif_debug.h"
26 
27 struct hif_softc;
28 struct hif_exec_context;
29 
30 struct hif_bus_ops {
31 	QDF_STATUS (*hif_bus_open)(struct hif_softc *hif_sc,
32 					enum qdf_bus_type bus_type);
33 	void (*hif_bus_close)(struct hif_softc *hif_sc);
34 	void (*hif_bus_prevent_linkdown)(struct hif_softc *hif_sc, bool flag);
35 	void (*hif_reset_soc)(struct hif_softc *hif_sc);
36 	int (*hif_bus_early_suspend)(struct hif_softc *hif_ctx);
37 	int (*hif_bus_late_resume)(struct hif_softc *hif_ctx);
38 	int (*hif_bus_suspend)(struct hif_softc *hif_ctx);
39 	int (*hif_bus_resume)(struct hif_softc *hif_ctx);
40 	int (*hif_bus_suspend_noirq)(struct hif_softc *hif_ctx);
41 	int (*hif_bus_resume_noirq)(struct hif_softc *hif_ctx);
42 	int (*hif_target_sleep_state_adjust)(struct hif_softc *scn,
43 			bool sleep_ok, bool wait_for_it);
44 	void (*hif_disable_isr)(struct hif_softc *hif_sc);
45 	void (*hif_nointrs)(struct hif_softc *hif_sc);
46 	QDF_STATUS (*hif_enable_bus)(struct hif_softc *hif_sc,
47 				      struct device *dev,
48 				      void *bdev,
49 				      const struct hif_bus_id *bid,
50 				      enum hif_enable_type type);
51 	void (*hif_disable_bus)(struct hif_softc *hif_sc);
52 	int (*hif_bus_configure)(struct hif_softc *hif_sc);
53 	QDF_STATUS (*hif_get_config_item)(struct hif_softc *hif_sc,
54 			     int opcode, void *config, uint32_t config_len);
55 	void (*hif_set_mailbox_swap)(struct hif_softc *hif_sc);
56 	void (*hif_claim_device)(struct hif_softc *hif_sc);
57 	void (*hif_shutdown_device)(struct hif_softc *hif_sc);
58 	void (*hif_stop)(struct hif_softc *hif_sc);
59 	void (*hif_cancel_deferred_target_sleep)(struct hif_softc *hif_sc);
60 	void (*hif_irq_disable)(struct hif_softc *hif_sc, int ce_id);
61 	void (*hif_irq_enable)(struct hif_softc *hif_sc, int ce_id);
62 	int (*hif_grp_irq_configure)(struct hif_softc *hif_sc,
63 				     struct hif_exec_context *exec);
64 	void (*hif_grp_irq_deconfigure)(struct hif_softc *hif_sc);
65 	int (*hif_dump_registers)(struct hif_softc *hif_sc);
66 	void (*hif_dump_target_memory)(struct hif_softc *hif_sc,
67 				       void *ramdump_base,
68 				       uint32_t address, uint32_t size);
69 	uint32_t (*hif_reg_read32)(struct hif_softc *hif_sc,
70 				   uint32_t offset);
71 	void (*hif_reg_write32)(struct hif_softc *hif_sc,
72 				uint32_t offset,
73 				uint32_t value);
74 	void (*hif_ipa_get_ce_resource)(struct hif_softc *hif_sc,
75 					qdf_shared_mem_t **ce_sr,
76 					uint32_t *sr_ring_size,
77 					qdf_dma_addr_t *reg_paddr);
78 	void (*hif_mask_interrupt_call)(struct hif_softc *hif_sc);
79 	void (*hif_enable_power_management)(struct hif_softc *hif_ctx,
80 				 bool is_packet_log_enabled);
81 	void (*hif_disable_power_management)(struct hif_softc *hif_ctx);
82 	void (*hif_display_stats)(struct hif_softc *hif_ctx);
83 	void (*hif_clear_stats)(struct hif_softc *hif_ctx);
84 	void (*hif_set_bundle_mode)(struct hif_softc *hif_ctx, bool enabled,
85 					int rx_bundle_cnt);
86 	int (*hif_bus_reset_resume)(struct hif_softc *hif_ctx);
87 	int (*hif_map_ce_to_irq)(struct hif_softc *hif_sc, int ce_id);
88 	int (*hif_addr_in_boundary)(struct hif_softc *scn, uint32_t offset);
89 	bool (*hif_needs_bmi)(struct hif_softc *hif_sc);
90 	void (*hif_config_irq_affinity)(struct hif_softc *hif_sc);
91 	int (*hif_config_irq_by_ceid)(struct hif_softc *hif_sc, int ce_id);
92 	void (*hif_config_irq_clear_cpu_affinity)(struct hif_softc *hif_sc,
93 						  int intr_ctxt_id, int cpu);
94 	bool (*hif_log_bus_info)(struct hif_softc *scn, uint8_t *data,
95 				 unsigned int *offset);
96 	int (*hif_enable_grp_irqs)(struct hif_softc *scn);
97 	int (*hif_disable_grp_irqs)(struct hif_softc *scn);
98 #ifdef FEATURE_IRQ_AFFINITY
99 	void (*hif_set_grp_intr_affinity)(struct hif_softc *scn,
100 					  uint32_t grp_intr_bitmask, bool perf);
101 #endif
102 };
103 
104 #ifdef HIF_SNOC
105 QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc);
106 int hif_snoc_get_context_size(void);
107 #else
108 static inline QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc)
109 {
110 	hif_warn("not supported");
111 	return QDF_STATUS_E_NOSUPPORT;
112 }
113 /**
114  * hif_snoc_get_context_size() - dummy when snoc isn't supported
115  *
116  * Return: 0 as an invalid size to indicate no support
117  */
118 static inline int hif_snoc_get_context_size(void)
119 {
120 	return 0;
121 }
122 #endif /* HIF_SNOC */
123 
124 #ifdef HIF_PCI
125 QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc);
126 QDF_STATUS hif_update_irq_ops_with_pci(struct hif_softc *hif_sc);
127 int hif_pci_get_context_size(void);
128 #else
129 static inline QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc)
130 {
131 	hif_warn("not supported");
132 	return QDF_STATUS_E_NOSUPPORT;
133 }
134 
135 static inline
136 QDF_STATUS hif_update_irq_ops_with_pci(struct hif_softc *hif_sc)
137 {
138 	hif_err("not supported");
139 	return QDF_STATUS_E_NOSUPPORT;
140 }
141 /**
142  * hif_pci_get_context_size() - dummy when pci isn't supported
143  *
144  * Return: 0 as an invalid size to indicate no support
145  */
146 static inline int hif_pci_get_context_size(void)
147 {
148 	return 0;
149 }
150 #endif /* HIF_PCI */
151 
152 #ifdef HIF_IPCI
153 /**
154  * hif_initialize_ipci_ops() - initialize the pci ops
155  * @hif_sc: pointer to hif context
156  *
157  * Return: QDF_STATUS_SUCCESS
158  */
159 QDF_STATUS hif_initialize_ipci_ops(struct hif_softc *hif_sc);
160 
161 /**
162  * hif_ipci_get_context_size() - return the size of the ipci context
163  *
164  * Return the size of the context.  (0 for invalid bus)
165  */
166 int hif_ipci_get_context_size(void);
167 #else
168 static inline QDF_STATUS hif_initialize_ipci_ops(struct hif_softc *hif_sc)
169 {
170 	hif_warn("not supported");
171 	return QDF_STATUS_E_NOSUPPORT;
172 }
173 
174 /**
175  * hif_ipci_get_context_size() - dummy when ipci isn't supported
176  *
177  * Return: 0 as an invalid size to indicate no support
178  */
179 static inline int hif_ipci_get_context_size(void)
180 {
181 	return 0;
182 }
183 #endif /* HIF_IPCI */
184 
185 #ifdef HIF_AHB
186 QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops);
187 int hif_ahb_get_context_size(void);
188 #else
189 /**
190  * hif_initialize_ahb_ops() - dummy for when ahb not supported
191  * @bus_ops: hif_bus_ops table pointer to initialize
192  *
193  * Return: QDF_STATUS_E_NOSUPPORT
194  */
195 static inline QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops)
196 {
197 	hif_warn("not supported");
198 	return QDF_STATUS_E_NOSUPPORT;
199 }
200 
201 /**
202  * hif_ahb_get_context_size() - dummy for when ahb not supported
203  *
204  * Return: 0 as an invalid size to indicate no support
205  */
206 static inline int hif_ahb_get_context_size(void)
207 {
208 	return 0;
209 }
210 #endif
211 
212 #ifdef HIF_SDIO
213 QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc);
214 int hif_sdio_get_context_size(void);
215 #else
216 /**
217  * hif_initialize_sdio_ops() - dummy for when sdio not supported
218  * @hif_sc: hif context
219  *
220  * Return: QDF_STATUS_E_NOSUPPORT
221  */
222 
223 static inline QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc)
224 {
225 	hif_warn("not supported");
226 	return QDF_STATUS_E_NOSUPPORT;
227 }
228 
229 /**
230  * hif_sdio_get_context_size() - dummy when sdio isn't supported
231  *
232  * Return: 0 as an invalid size to indicate no support
233  */
234 static inline int hif_sdio_get_context_size(void)
235 {
236 	return 0;
237 }
238 #endif /* HIF_SDIO */
239 
240 int hif_grp_irq_configure(struct hif_softc *hif_sc,
241 			  struct hif_exec_context *hif_exec);
242 void hif_grp_irq_deconfigure(struct hif_softc *hif_sc);
243 #ifdef HIF_USB
244 QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops);
245 int hif_usb_get_context_size(void);
246 #else
247 static inline QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops)
248 {
249 	hif_warn("not supported");
250 	return QDF_STATUS_E_NOSUPPORT;
251 }
252 /**
253  * hif_usb_get_context_size() - dummy when usb isn't supported
254  *
255  * Return: 0 as an invalid size to indicate no support
256  */
257 static inline int hif_usb_get_context_size(void)
258 {
259 	return 0;
260 }
261 #endif /* HIF_USB */
262 
263 /**
264  * hif_config_irq_affinity() - Set IRQ affinity for WLAN IRQs
265  * @hif_sc: hif context
266  *
267  * Set IRQ affinity hint for WLAN IRQs in order to affine to
268  * gold cores.
269  *
270  * Return: None
271  */
272 void hif_config_irq_affinity(struct hif_softc *hif_sc);
273 
274 /**
275  * hif_config_irq_by_ceid() - register irq by CE id
276  * @hif_sc: hif context
277  * @ce_id: Copy Engine id for which the irq need to be configured
278  *
279  * Return: 0 on success, negative value on error.
280  */
281 int hif_config_irq_by_ceid(struct hif_softc *hif_sc, int ce_id);
282 
283 #ifdef HIF_BUS_LOG_INFO
284 /**
285  * hif_log_bus_info() - API to log bus related info
286  * @scn: hif handle
287  * @data: hang event data buffer
288  * @offset: offset at which data needs to be written
289  *
290  * Return:  true if bus_id is invalid else false
291  */
292 bool hif_log_bus_info(struct hif_softc *scn, uint8_t *data,
293 		      unsigned int *offset);
294 #else
295 static inline
296 bool hif_log_bus_info(struct hif_softc *scn, uint8_t *data,
297 		      unsigned int *offset)
298 {
299 	return false;
300 }
301 #endif
302 #endif /* _MULTIBUS_H_ */
303