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