xref: /wlan-dirver/qca-wifi-host-cmn/hif/src/dispatcher/multibus.h (revision 6d768494e5ce14eb1603a695c86739d12ecc6ec2)
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 	void (*hif_ipa_get_ce_resource)(struct hif_softc *hif_sc,
73 					qdf_shared_mem_t **ce_sr,
74 					uint32_t *sr_ring_size,
75 					qdf_dma_addr_t *reg_paddr);
76 	void (*hif_mask_interrupt_call)(struct hif_softc *hif_sc);
77 	void (*hif_enable_power_management)(struct hif_softc *hif_ctx,
78 				 bool is_packet_log_enabled);
79 	void (*hif_disable_power_management)(struct hif_softc *hif_ctx);
80 	void (*hif_display_stats)(struct hif_softc *hif_ctx);
81 	void (*hif_clear_stats)(struct hif_softc *hif_ctx);
82 	void (*hif_set_bundle_mode)(struct hif_softc *hif_ctx, bool enabled,
83 					int rx_bundle_cnt);
84 	int (*hif_bus_reset_resume)(struct hif_softc *hif_ctx);
85 	int (*hif_map_ce_to_irq)(struct hif_softc *hif_sc, int ce_id);
86 	int (*hif_addr_in_boundary)(struct hif_softc *scn, uint32_t offset);
87 	bool (*hif_needs_bmi)(struct hif_softc *hif_sc);
88 	void (*hif_config_irq_affinity)(struct hif_softc *hif_sc);
89 };
90 
91 #ifdef HIF_SNOC
92 QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc);
93 int hif_snoc_get_context_size(void);
94 #else
95 static inline QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc)
96 {
97 	HIF_ERROR("%s: not supported", __func__);
98 	return QDF_STATUS_E_NOSUPPORT;
99 }
100 /**
101  * hif_snoc_get_context_size() - dummy when snoc isn't supported
102  *
103  * Return: 0 as an invalid size to indicate no support
104  */
105 static inline int hif_snoc_get_context_size(void)
106 {
107 	return 0;
108 }
109 #endif /* HIF_SNOC */
110 
111 #ifdef HIF_PCI
112 QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc);
113 int hif_pci_get_context_size(void);
114 #else
115 static inline QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc)
116 {
117 	HIF_ERROR("%s: not supported", __func__);
118 	return QDF_STATUS_E_NOSUPPORT;
119 }
120 /**
121  * hif_pci_get_context_size() - dummy when pci isn't supported
122  *
123  * Return: 0 as an invalid size to indicate no support
124  */
125 static inline int hif_pci_get_context_size(void)
126 {
127 	return 0;
128 }
129 #endif /* HIF_PCI */
130 
131 #ifdef HIF_IPCI
132 /**
133  * hif_initialize_ipci_ops() - initialize the pci ops
134  * @hif_sc: pointer to hif context
135  *
136  * Return: QDF_STATUS_SUCCESS
137  */
138 QDF_STATUS hif_initialize_ipci_ops(struct hif_softc *hif_sc);
139 
140 /**
141  * hif_ipci_get_context_size() - return the size of the ipci context
142  *
143  * Return the size of the context.  (0 for invalid bus)
144  */
145 int hif_ipci_get_context_size(void);
146 #else
147 static inline QDF_STATUS hif_initialize_ipci_ops(struct hif_softc *hif_sc)
148 {
149 	HIF_ERROR("%s: not supported", __func__);
150 	return QDF_STATUS_E_NOSUPPORT;
151 }
152 
153 /**
154  * hif_ipci_get_context_size() - dummy when ipci isn't supported
155  *
156  * Return: 0 as an invalid size to indicate no support
157  */
158 static inline int hif_ipci_get_context_size(void)
159 {
160 	return 0;
161 }
162 #endif /* HIF_IPCI */
163 
164 #ifdef HIF_AHB
165 QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops);
166 int hif_ahb_get_context_size(void);
167 #else
168 /**
169  * hif_initialize_ahb_ops() - dummy for when ahb not supported
170  *
171  * Return: QDF_STATUS_E_NOSUPPORT
172  */
173 static inline QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops)
174 {
175 	HIF_ERROR("%s: not supported", __func__);
176 	return QDF_STATUS_E_NOSUPPORT;
177 }
178 
179 /**
180  * hif_ahb_get_context_size() - dummy for when ahb not supported
181  *
182  * Return: 0 as an invalid size to indicate no support
183  */
184 static inline int hif_ahb_get_context_size(void)
185 {
186 	return 0;
187 }
188 #endif
189 
190 #ifdef HIF_SDIO
191 QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc);
192 int hif_sdio_get_context_size(void);
193 #else
194 /**
195  * hif_initialize_sdio_ops() - dummy for when sdio not supported
196  *
197  * Return: QDF_STATUS_E_NOSUPPORT
198  */
199 
200 static inline QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc)
201 {
202 	HIF_ERROR("%s: not supported", __func__);
203 	return QDF_STATUS_E_NOSUPPORT;
204 }
205 
206 /**
207  * hif_sdio_get_context_size() - dummy when sdio isn't supported
208  *
209  * Return: 0 as an invalid size to indicate no support
210  */
211 static inline int hif_sdio_get_context_size(void)
212 {
213 	return 0;
214 }
215 #endif /* HIF_SDIO */
216 
217 int hif_grp_irq_configure(struct hif_softc *hif_sc,
218 			  struct hif_exec_context *hif_exec);
219 #ifdef HIF_USB
220 QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops);
221 int hif_usb_get_context_size(void);
222 #else
223 static inline QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops)
224 {
225 	HIF_ERROR("%s: not supported", __func__);
226 	return QDF_STATUS_E_NOSUPPORT;
227 }
228 /**
229  * hif_usb_get_context_size() - dummy when usb isn't supported
230  *
231  * Return: 0 as an invalid size to indicate no support
232  */
233 static inline int hif_usb_get_context_size(void)
234 {
235 	return 0;
236 }
237 #endif /* HIF_USB */
238 
239 /**
240  * hif_config_irq_affinity() - Set IRQ affinity for WLAN IRQs
241  * @hif_sc - hif context
242  *
243  * Set IRQ affinity hint for WLAN IRQs in order to affine to
244  * gold cores.
245  *
246  * Return: None
247  */
248 void hif_config_irq_affinity(struct hif_softc *hif_sc);
249 #endif /* _MULTIBUS_H_ */
250