xref: /wlan-dirver/qca-wifi-host-cmn/hif/src/dispatcher/multibus.h (revision 5db38f17138c409346f0ba0d72e13640f35d04b5)
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 	void (*hif_affinity_mgr_set_affinity)(struct hif_softc *scn);
103 };
104 
105 #ifdef HIF_SNOC
106 QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc);
107 int hif_snoc_get_context_size(void);
108 #else
109 static inline QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc)
110 {
111 	hif_warn("not supported");
112 	return QDF_STATUS_E_NOSUPPORT;
113 }
114 /**
115  * hif_snoc_get_context_size() - dummy when snoc isn't supported
116  *
117  * Return: 0 as an invalid size to indicate no support
118  */
119 static inline int hif_snoc_get_context_size(void)
120 {
121 	return 0;
122 }
123 #endif /* HIF_SNOC */
124 
125 #ifdef HIF_PCI
126 QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc);
127 QDF_STATUS hif_update_irq_ops_with_pci(struct hif_softc *hif_sc);
128 int hif_pci_get_context_size(void);
129 #else
130 static inline QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc)
131 {
132 	hif_warn("not supported");
133 	return QDF_STATUS_E_NOSUPPORT;
134 }
135 
136 static inline
137 QDF_STATUS hif_update_irq_ops_with_pci(struct hif_softc *hif_sc)
138 {
139 	hif_err("not supported");
140 	return QDF_STATUS_E_NOSUPPORT;
141 }
142 /**
143  * hif_pci_get_context_size() - dummy when pci isn't supported
144  *
145  * Return: 0 as an invalid size to indicate no support
146  */
147 static inline int hif_pci_get_context_size(void)
148 {
149 	return 0;
150 }
151 #endif /* HIF_PCI */
152 
153 #ifdef HIF_IPCI
154 /**
155  * hif_initialize_ipci_ops() - initialize the pci ops
156  * @hif_sc: pointer to hif context
157  *
158  * Return: QDF_STATUS_SUCCESS
159  */
160 QDF_STATUS hif_initialize_ipci_ops(struct hif_softc *hif_sc);
161 
162 /**
163  * hif_ipci_get_context_size() - return the size of the ipci context
164  *
165  * Return the size of the context.  (0 for invalid bus)
166  */
167 int hif_ipci_get_context_size(void);
168 #else
169 static inline QDF_STATUS hif_initialize_ipci_ops(struct hif_softc *hif_sc)
170 {
171 	hif_warn("not supported");
172 	return QDF_STATUS_E_NOSUPPORT;
173 }
174 
175 /**
176  * hif_ipci_get_context_size() - dummy when ipci isn't supported
177  *
178  * Return: 0 as an invalid size to indicate no support
179  */
180 static inline int hif_ipci_get_context_size(void)
181 {
182 	return 0;
183 }
184 #endif /* HIF_IPCI */
185 
186 #ifdef HIF_AHB
187 QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops);
188 int hif_ahb_get_context_size(void);
189 #else
190 /**
191  * hif_initialize_ahb_ops() - dummy for when ahb not supported
192  * @bus_ops: hif_bus_ops table pointer to initialize
193  *
194  * Return: QDF_STATUS_E_NOSUPPORT
195  */
196 static inline QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops)
197 {
198 	hif_warn("not supported");
199 	return QDF_STATUS_E_NOSUPPORT;
200 }
201 
202 /**
203  * hif_ahb_get_context_size() - dummy for when ahb not supported
204  *
205  * Return: 0 as an invalid size to indicate no support
206  */
207 static inline int hif_ahb_get_context_size(void)
208 {
209 	return 0;
210 }
211 #endif
212 
213 #ifdef HIF_SDIO
214 QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc);
215 int hif_sdio_get_context_size(void);
216 #else
217 /**
218  * hif_initialize_sdio_ops() - dummy for when sdio not supported
219  * @hif_sc: hif context
220  *
221  * Return: QDF_STATUS_E_NOSUPPORT
222  */
223 
224 static inline QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc)
225 {
226 	hif_warn("not supported");
227 	return QDF_STATUS_E_NOSUPPORT;
228 }
229 
230 /**
231  * hif_sdio_get_context_size() - dummy when sdio isn't supported
232  *
233  * Return: 0 as an invalid size to indicate no support
234  */
235 static inline int hif_sdio_get_context_size(void)
236 {
237 	return 0;
238 }
239 #endif /* HIF_SDIO */
240 
241 int hif_grp_irq_configure(struct hif_softc *hif_sc,
242 			  struct hif_exec_context *hif_exec);
243 void hif_grp_irq_deconfigure(struct hif_softc *hif_sc);
244 #ifdef HIF_USB
245 QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops);
246 int hif_usb_get_context_size(void);
247 #else
248 static inline QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops)
249 {
250 	hif_warn("not supported");
251 	return QDF_STATUS_E_NOSUPPORT;
252 }
253 /**
254  * hif_usb_get_context_size() - dummy when usb isn't supported
255  *
256  * Return: 0 as an invalid size to indicate no support
257  */
258 static inline int hif_usb_get_context_size(void)
259 {
260 	return 0;
261 }
262 #endif /* HIF_USB */
263 
264 /**
265  * hif_config_irq_affinity() - Set IRQ affinity for WLAN IRQs
266  * @hif_sc: hif context
267  *
268  * Set IRQ affinity hint for WLAN IRQs in order to affine to
269  * gold cores.
270  *
271  * Return: None
272  */
273 void hif_config_irq_affinity(struct hif_softc *hif_sc);
274 
275 /**
276  * hif_config_irq_by_ceid() - register irq by CE id
277  * @hif_sc: hif context
278  * @ce_id: Copy Engine id for which the irq need to be configured
279  *
280  * Return: 0 on success, negative value on error.
281  */
282 int hif_config_irq_by_ceid(struct hif_softc *hif_sc, int ce_id);
283 
284 #ifdef HIF_BUS_LOG_INFO
285 /**
286  * hif_log_bus_info() - API to log bus related info
287  * @scn: hif handle
288  * @data: hang event data buffer
289  * @offset: offset at which data needs to be written
290  *
291  * Return:  true if bus_id is invalid else false
292  */
293 bool hif_log_bus_info(struct hif_softc *scn, uint8_t *data,
294 		      unsigned int *offset);
295 #else
296 static inline
297 bool hif_log_bus_info(struct hif_softc *scn, uint8_t *data,
298 		      unsigned int *offset)
299 {
300 	return false;
301 }
302 #endif
303 #endif /* _MULTIBUS_H_ */
304