xref: /wlan-dirver/qca-wifi-host-cmn/hif/src/dispatcher/multibus.h (revision 4865edfd190c086bbe2c69aae12a8226f877b91e)
1 /*
2  * Copyright (c) 2016-2018 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 	int (*hif_bus_configure)(struct hif_softc *hif_sc);
52 	QDF_STATUS (*hif_get_config_item)(struct hif_softc *hif_sc,
53 			     int opcode, void *config, uint32_t config_len);
54 	void (*hif_set_mailbox_swap)(struct hif_softc *hif_sc);
55 	void (*hif_claim_device)(struct hif_softc *hif_sc);
56 	void (*hif_shutdown_device)(struct hif_softc *hif_sc);
57 	void (*hif_stop)(struct hif_softc *hif_sc);
58 	void (*hif_cancel_deferred_target_sleep)(struct hif_softc *hif_sc);
59 	void (*hif_irq_disable)(struct hif_softc *hif_sc, int ce_id);
60 	void (*hif_irq_enable)(struct hif_softc *hif_sc, int ce_id);
61 	int (*hif_grp_irq_configure)(struct hif_softc *hif_sc,
62 				     struct hif_exec_context *exec);
63 	int (*hif_dump_registers)(struct hif_softc *hif_sc);
64 	void (*hif_dump_target_memory)(struct hif_softc *hif_sc,
65 				       void *ramdump_base,
66 				       uint32_t address, uint32_t size);
67 	void (*hif_ipa_get_ce_resource)(struct hif_softc *hif_sc,
68 					qdf_shared_mem_t **ce_sr,
69 					uint32_t *sr_ring_size,
70 					qdf_dma_addr_t *reg_paddr);
71 	void (*hif_mask_interrupt_call)(struct hif_softc *hif_sc);
72 	void (*hif_enable_power_management)(struct hif_softc *hif_ctx,
73 				 bool is_packet_log_enabled);
74 	void (*hif_disable_power_management)(struct hif_softc *hif_ctx);
75 	void (*hif_display_stats)(struct hif_softc *hif_ctx);
76 	void (*hif_clear_stats)(struct hif_softc *hif_ctx);
77 	void (*hif_set_bundle_mode)(struct hif_softc *hif_ctx, bool enabled,
78 					int rx_bundle_cnt);
79 	int (*hif_bus_reset_resume)(struct hif_softc *hif_ctx);
80 	int (*hif_map_ce_to_irq)(struct hif_softc *hif_sc, int ce_id);
81 	int (*hif_addr_in_boundary)(struct hif_softc *scn, uint32_t offset);
82 	bool (*hif_needs_bmi)(struct hif_softc *hif_sc);
83 };
84 
85 #ifdef HIF_SNOC
86 QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc);
87 int hif_snoc_get_context_size(void);
88 #else
89 static inline QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc)
90 {
91 	HIF_ERROR("%s: not supported", __func__);
92 	return QDF_STATUS_E_NOSUPPORT;
93 }
94 /**
95  * hif_snoc_get_context_size() - dummy when snoc isn't supported
96  *
97  * Return: 0 as an invalid size to indicate no support
98  */
99 static inline int hif_snoc_get_context_size(void)
100 {
101 	return 0;
102 }
103 #endif /* HIF_SNOC */
104 
105 #ifdef HIF_PCI
106 QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc);
107 int hif_pci_get_context_size(void);
108 #else
109 static inline QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc)
110 {
111 	HIF_ERROR("%s: not supported", __func__);
112 	return QDF_STATUS_E_NOSUPPORT;
113 }
114 /**
115  * hif_pci_get_context_size() - dummy when pci isn't supported
116  *
117  * Return: 0 as an invalid size to indicate no support
118  */
119 static inline int hif_pci_get_context_size(void)
120 {
121 	return 0;
122 }
123 #endif /* HIF_PCI */
124 
125 #ifdef HIF_AHB
126 QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops);
127 int hif_ahb_get_context_size(void);
128 #else
129 /**
130  * hif_initialize_ahb_ops() - dummy for when ahb not supported
131  *
132  * Return: QDF_STATUS_E_NOSUPPORT
133  */
134 static inline QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops)
135 {
136 	HIF_ERROR("%s: not supported", __func__);
137 	return QDF_STATUS_E_NOSUPPORT;
138 }
139 
140 /**
141  * hif_ahb_get_context_size() - dummy for when ahb not supported
142  *
143  * Return: 0 as an invalid size to indicate no support
144  */
145 static inline int hif_ahb_get_context_size(void)
146 {
147 	return 0;
148 }
149 #endif
150 
151 #ifdef HIF_SDIO
152 QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc);
153 int hif_sdio_get_context_size(void);
154 #else
155 /**
156  * hif_initialize_sdio_ops() - dummy for when sdio not supported
157  *
158  * Return: QDF_STATUS_E_NOSUPPORT
159  */
160 
161 static inline QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc)
162 {
163 	HIF_ERROR("%s: not supported", __func__);
164 	return QDF_STATUS_E_NOSUPPORT;
165 }
166 
167 /**
168  * hif_sdio_get_context_size() - dummy when sdio isn't supported
169  *
170  * Return: 0 as an invalid size to indicate no support
171  */
172 static inline int hif_sdio_get_context_size(void)
173 {
174 	return 0;
175 }
176 #endif /* HIF_SDIO */
177 
178 int hif_grp_irq_configure(struct hif_softc *hif_sc,
179 			  struct hif_exec_context *hif_exec);
180 #ifdef HIF_USB
181 QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops);
182 int hif_usb_get_context_size(void);
183 #else
184 static inline QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops)
185 {
186 	HIF_ERROR("%s: not supported", __func__);
187 	return QDF_STATUS_E_NOSUPPORT;
188 }
189 /**
190  * hif_usb_get_context_size() - dummy when usb isn't supported
191  *
192  * Return: 0 as an invalid size to indicate no support
193  */
194 static inline int hif_usb_get_context_size(void)
195 {
196 	return 0;
197 }
198 #endif /* HIF_USB */
199 #endif /* _MULTIBUS_H_ */
200