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