blob: da1666cbf4216438a4c5630c35983df90f234bc2 [file] [log] [blame]
Houston Hoffman32bc8eb2016-03-14 21:11:34 -07001/*
Pratik Gandhidc82a772018-01-30 18:57:05 +05302 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
Houston Hoffman32bc8eb2016-03-14 21:11:34 -07003 *
Houston Hoffman32bc8eb2016-03-14 21:11:34 -07004 * 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
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070019/* this file dispatches functions to bus specific definitions */
20#include "hif_debug.h"
21#include "hif.h"
22#include "hif_main.h"
Jeff Johnson6950fdb2016-10-07 13:00:59 -070023#include "hif_io32.h"
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070024#include "multibus.h"
Mohit Khanna1957ba92016-05-11 11:17:01 -070025#include "dummy.h"
Nirav Shah3573f952016-05-12 18:37:03 +053026#if defined(HIF_PCI) || defined(HIF_SNOC) || defined(HIF_AHB)
Houston Hoffman162164c2016-03-14 21:12:10 -070027#include "ce_main.h"
Dustin Brown6834d322017-03-20 15:02:48 -070028#include "ce_api.h"
29#include "ce_internal.h"
Nirav Shah3573f952016-05-12 18:37:03 +053030#endif
Komal Seelam6ee55902016-04-11 17:11:07 +053031#include "htc_services.h"
32#include "a_types.h"
Nirav Shahb70bd732016-05-25 14:31:51 +053033#include "dummy.h"
Pratik Gandhidc82a772018-01-30 18:57:05 +053034#include "qdf_module.h"
Nirav Shahb70bd732016-05-25 14:31:51 +053035
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070036/**
37 * hif_intialize_default_ops() - intializes default operations values
38 *
39 * bus specific features should assign their dummy implementations here.
40 */
41static void hif_intialize_default_ops(struct hif_softc *hif_sc)
42{
43 struct hif_bus_ops *bus_ops = &hif_sc->bus_ops;
44
45 /* must be filled in by hif_bus_open */
46 bus_ops->hif_bus_close = NULL;
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070047 /* dummy implementations */
Nirav Shahb70bd732016-05-25 14:31:51 +053048 bus_ops->hif_display_stats =
49 &hif_dummy_display_stats;
50 bus_ops->hif_clear_stats =
51 &hif_dummy_clear_stats;
Houston Hoffman7fdff0c2016-08-29 12:31:58 -070052 bus_ops->hif_set_bundle_mode = &hif_dummy_set_bundle_mode;
53 bus_ops->hif_bus_reset_resume = &hif_dummy_bus_reset_resume;
54 bus_ops->hif_bus_suspend_noirq = &hif_dummy_bus_suspend_noirq;
55 bus_ops->hif_bus_resume_noirq = &hif_dummy_bus_resume_noirq;
Houston Hoffmancbcd8392017-02-08 17:43:13 -080056 bus_ops->hif_bus_early_suspend = &hif_dummy_bus_suspend;
57 bus_ops->hif_bus_late_resume = &hif_dummy_bus_resume;
Dustin Brown07d24be2017-04-03 10:20:49 -070058 bus_ops->hif_map_ce_to_irq = &hif_dummy_map_ce_to_irq;
Venkateswara Swamy Bandaru61824942017-04-12 12:31:59 +053059 bus_ops->hif_grp_irq_configure = &hif_dummy_grp_irq_configure;
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070060}
61
62#define NUM_OPS (sizeof(struct hif_bus_ops) / sizeof(void *))
63
64/**
65 * hif_verify_basic_ops() - ensure required bus apis are defined
66 *
67 * all bus operations must be defined to avoid crashes
68 * itterate over the structure and ensure all function pointers
69 * are non null.
70 *
71 * Return: QDF_STATUS_SUCCESS if all the operations are defined
72 */
73static QDF_STATUS hif_verify_basic_ops(struct hif_softc *hif_sc)
74{
75 struct hif_bus_ops *bus_ops = &hif_sc->bus_ops;
76 void **ops_array = (void *)bus_ops;
77 QDF_STATUS status = QDF_STATUS_SUCCESS;
78 int i;
79
80 for (i = 0; i < NUM_OPS; i++) {
81 if (!ops_array[i]) {
82 HIF_ERROR("%s: function %d is null", __func__, i);
83 status = QDF_STATUS_E_NOSUPPORT;
84 }
85 }
86 return status;
87}
88
89/**
Houston Hoffman162164c2016-03-14 21:12:10 -070090 * hif_bus_get_context_size - API to return size of the bus specific structure
91 *
92 * Return: sizeof of hif_pci_softc
93 */
94int hif_bus_get_context_size(enum qdf_bus_type bus_type)
95{
96 switch (bus_type) {
97 case QDF_BUS_TYPE_PCI:
98 return hif_pci_get_context_size();
Houston Hoffman3db96a42016-05-05 19:54:39 -070099 case QDF_BUS_TYPE_AHB:
100 return hif_ahb_get_context_size();
Houston Hoffman162164c2016-03-14 21:12:10 -0700101 case QDF_BUS_TYPE_SNOC:
102 return hif_snoc_get_context_size();
Nirav Shah3573f952016-05-12 18:37:03 +0530103 case QDF_BUS_TYPE_SDIO:
104 return hif_sdio_get_context_size();
Mohit Khanna1957ba92016-05-11 11:17:01 -0700105 case QDF_BUS_TYPE_USB:
106 return hif_usb_get_context_size();
Houston Hoffman162164c2016-03-14 21:12:10 -0700107 default:
108 return 0;
109 }
110}
111
112/**
Houston Hoffman32bc8eb2016-03-14 21:11:34 -0700113 * hif_bus_open() - initialize the bus_ops and call the bus specific open
114 * hif_sc: hif_context
115 * bus_type: type of bus being enumerated
116 *
117 * Return: QDF_STATUS_SUCCESS or error
118 */
119QDF_STATUS hif_bus_open(struct hif_softc *hif_sc,
120 enum qdf_bus_type bus_type)
121{
122 QDF_STATUS status = QDF_STATUS_E_INVAL;
123
124 hif_intialize_default_ops(hif_sc);
125
126 switch (bus_type) {
127 case QDF_BUS_TYPE_PCI:
Houston Hoffman54ef87d2016-03-14 21:11:58 -0700128 status = hif_initialize_pci_ops(hif_sc);
Houston Hoffman32bc8eb2016-03-14 21:11:34 -0700129 break;
130 case QDF_BUS_TYPE_SNOC:
131 status = hif_initialize_snoc_ops(&hif_sc->bus_ops);
132 break;
Houston Hoffman3db96a42016-05-05 19:54:39 -0700133 case QDF_BUS_TYPE_AHB:
134 status = hif_initialize_ahb_ops(&hif_sc->bus_ops);
135 break;
Nirav Shah3573f952016-05-12 18:37:03 +0530136 case QDF_BUS_TYPE_SDIO:
137 status = hif_initialize_sdio_ops(hif_sc);
Yu Wang1e487a52017-02-07 20:10:42 +0800138 break;
Mohit Khanna1957ba92016-05-11 11:17:01 -0700139 case QDF_BUS_TYPE_USB:
140 status = hif_initialize_usb_ops(&hif_sc->bus_ops);
Nirav Shah3573f952016-05-12 18:37:03 +0530141 break;
Houston Hoffman32bc8eb2016-03-14 21:11:34 -0700142 default:
143 status = QDF_STATUS_E_NOSUPPORT;
144 break;
145 }
146
147 if (status != QDF_STATUS_SUCCESS) {
148 HIF_ERROR("%s: %d not supported", __func__, bus_type);
149 return status;
150 }
151
152 status = hif_verify_basic_ops(hif_sc);
153 if (status != QDF_STATUS_SUCCESS)
154 return status;
155
156 return hif_sc->bus_ops.hif_bus_open(hif_sc, bus_type);
157}
158
159/**
160 * hif_bus_close() - close the bus
161 * @hif_sc: hif_context
162 */
163void hif_bus_close(struct hif_softc *hif_sc)
164{
165 hif_sc->bus_ops.hif_bus_close(hif_sc);
166}
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700167
168/**
169 * hif_bus_prevent_linkdown() - prevent linkdown
170 * @hif_ctx: hif context
171 * @flag: true = keep bus alive false = let bus go to sleep
172 *
173 * Keeps the bus awake durring suspend.
174 */
175void hif_bus_prevent_linkdown(struct hif_softc *hif_sc, bool flag)
176{
177 hif_sc->bus_ops.hif_bus_prevent_linkdown(hif_sc, flag);
178}
179
180
181void hif_reset_soc(struct hif_opaque_softc *hif_ctx)
182{
183 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700184
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700185 hif_sc->bus_ops.hif_reset_soc(hif_sc);
186}
187
Houston Hoffmancbcd8392017-02-08 17:43:13 -0800188int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx)
189{
190 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700191
Houston Hoffmancbcd8392017-02-08 17:43:13 -0800192 return hif_sc->bus_ops.hif_bus_early_suspend(hif_sc);
193}
194
195int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx)
196{
197 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700198
Houston Hoffmancbcd8392017-02-08 17:43:13 -0800199 return hif_sc->bus_ops.hif_bus_late_resume(hif_sc);
200}
201
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700202int hif_bus_suspend(struct hif_opaque_softc *hif_ctx)
203{
204 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700205
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700206 return hif_sc->bus_ops.hif_bus_suspend(hif_sc);
207}
208
209int hif_bus_resume(struct hif_opaque_softc *hif_ctx)
210{
211 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700212
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700213 return hif_sc->bus_ops.hif_bus_resume(hif_sc);
214}
215
Houston Hoffman7fdff0c2016-08-29 12:31:58 -0700216int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx)
217{
218 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700219
Houston Hoffman7fdff0c2016-08-29 12:31:58 -0700220 return hif_sc->bus_ops.hif_bus_suspend_noirq(hif_sc);
221}
222
223int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx)
224{
225 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700226
Houston Hoffman7fdff0c2016-08-29 12:31:58 -0700227 return hif_sc->bus_ops.hif_bus_resume_noirq(hif_sc);
228}
229
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700230int hif_target_sleep_state_adjust(struct hif_softc *hif_sc,
231 bool sleep_ok, bool wait_for_it)
232{
233 return hif_sc->bus_ops.hif_target_sleep_state_adjust(hif_sc,
234 sleep_ok, wait_for_it);
235}
Pratik Gandhidc82a772018-01-30 18:57:05 +0530236qdf_export_symbol(hif_target_sleep_state_adjust);
Houston Hoffman8f239f62016-03-14 21:12:05 -0700237
238void hif_disable_isr(struct hif_opaque_softc *hif_hdl)
239{
240 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700241
Houston Hoffman8f239f62016-03-14 21:12:05 -0700242 hif_sc->bus_ops.hif_disable_isr(hif_sc);
243}
244
245void hif_nointrs(struct hif_softc *hif_sc)
246{
247 hif_sc->bus_ops.hif_nointrs(hif_sc);
248}
249
250QDF_STATUS hif_enable_bus(struct hif_softc *hif_sc, struct device *dev,
Manikandan Mohanbd0ef8a2017-04-10 13:10:21 -0700251 void *bdev, const struct hif_bus_id *bid,
Houston Hoffman8f239f62016-03-14 21:12:05 -0700252 enum hif_enable_type type)
253{
254 return hif_sc->bus_ops.hif_enable_bus(hif_sc, dev, bdev, bid, type);
255}
256
257void hif_disable_bus(struct hif_softc *hif_sc)
258{
259 hif_sc->bus_ops.hif_disable_bus(hif_sc);
260}
261
262int hif_bus_configure(struct hif_softc *hif_sc)
263{
264 return hif_sc->bus_ops.hif_bus_configure(hif_sc);
265}
266
Nirav Shah3573f952016-05-12 18:37:03 +0530267QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
268 int opcode, void *config, uint32_t config_len)
269{
270 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700271
Nirav Shah3573f952016-05-12 18:37:03 +0530272 return hif_sc->bus_ops.hif_get_config_item(hif_sc, opcode, config,
273 config_len);
274}
275
276void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx)
277{
278 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700279
Nirav Shah3573f952016-05-12 18:37:03 +0530280 hif_sc->bus_ops.hif_set_mailbox_swap(hif_sc);
281}
282
283void hif_claim_device(struct hif_opaque_softc *hif_ctx)
284{
285 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700286
Nirav Shah3573f952016-05-12 18:37:03 +0530287 hif_sc->bus_ops.hif_claim_device(hif_sc);
288}
289
290void hif_shutdown_device(struct hif_opaque_softc *hif_ctx)
291{
292 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700293
Nirav Shah3573f952016-05-12 18:37:03 +0530294 hif_sc->bus_ops.hif_shutdown_device(hif_sc);
295}
296
297void hif_stop(struct hif_opaque_softc *hif_ctx)
298{
299 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700300
Nirav Shah3573f952016-05-12 18:37:03 +0530301 hif_sc->bus_ops.hif_stop(hif_sc);
302}
303
Nirav Shah3573f952016-05-12 18:37:03 +0530304void hif_cancel_deferred_target_sleep(struct hif_softc *hif_sc)
305{
306 return hif_sc->bus_ops.hif_cancel_deferred_target_sleep(hif_sc);
307}
308
Houston Hoffman8f239f62016-03-14 21:12:05 -0700309void hif_irq_enable(struct hif_softc *hif_sc, int irq_id)
310{
311 hif_sc->bus_ops.hif_irq_enable(hif_sc, irq_id);
312}
Pratik Gandhidc82a772018-01-30 18:57:05 +0530313qdf_export_symbol(hif_irq_enable);
Houston Hoffman8f239f62016-03-14 21:12:05 -0700314
315void hif_irq_disable(struct hif_softc *hif_sc, int irq_id)
316{
317 hif_sc->bus_ops.hif_irq_disable(hif_sc, irq_id);
318}
Houston Hoffman3c017e72016-03-14 21:12:11 -0700319
Houston Hoffmandef86a32017-04-21 20:23:45 -0700320int hif_grp_irq_configure(struct hif_softc *hif_sc,
321 struct hif_exec_context *hif_exec)
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530322{
Houston Hoffmandef86a32017-04-21 20:23:45 -0700323 return hif_sc->bus_ops.hif_grp_irq_configure(hif_sc, hif_exec);
Venkateswara Swamy Bandaru61824942017-04-12 12:31:59 +0530324}
325
Houston Hoffman3c017e72016-03-14 21:12:11 -0700326int hif_dump_registers(struct hif_opaque_softc *hif_hdl)
327{
328 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700329
Houston Hoffman3c017e72016-03-14 21:12:11 -0700330 return hif_sc->bus_ops.hif_dump_registers(hif_sc);
331}
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700332
Nirav Shah3573f952016-05-12 18:37:03 +0530333void hif_dump_target_memory(struct hif_opaque_softc *hif_hdl,
334 void *ramdump_base,
335 uint32_t address, uint32_t size)
336{
337 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700338
Nirav Shah3573f952016-05-12 18:37:03 +0530339 hif_sc->bus_ops.hif_dump_target_memory(hif_sc, ramdump_base,
340 address, size);
341}
342
343void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_hdl,
Sravan Kumar Kairam58e0adf2018-02-27 18:37:40 +0530344 qdf_shared_mem_t **ce_sr,
Nirav Shah3573f952016-05-12 18:37:03 +0530345 uint32_t *ce_sr_ring_size,
346 qdf_dma_addr_t *ce_reg_paddr)
347{
348 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700349
Sravan Kumar Kairam58e0adf2018-02-27 18:37:40 +0530350 hif_sc->bus_ops.hif_ipa_get_ce_resource(hif_sc, ce_sr,
351 ce_sr_ring_size, ce_reg_paddr);
Nirav Shah3573f952016-05-12 18:37:03 +0530352}
353
354void hif_mask_interrupt_call(struct hif_opaque_softc *hif_hdl)
355{
356 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700357
Nirav Shah3573f952016-05-12 18:37:03 +0530358 hif_sc->bus_ops.hif_mask_interrupt_call(hif_sc);
359}
360
Nirav Shahb70bd732016-05-25 14:31:51 +0530361void hif_display_bus_stats(struct hif_opaque_softc *scn)
362{
363 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
364
365 hif_sc->bus_ops.hif_display_stats(hif_sc);
366}
367
368void hif_clear_bus_stats(struct hif_opaque_softc *scn)
369{
370 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
371
372 hif_sc->bus_ops.hif_clear_stats(hif_sc);
373}
374
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700375/**
376 * hif_enable_power_management() - enable power management after driver load
377 * @hif_hdl: opaque pointer to the hif context
378 * is_packet_log_enabled: true if packet log is enabled
379 *
380 * Driver load and firmware download are done in a high performance mode.
381 * Enable power management after the driver is loaded.
382 * packet log can require fewer power management features to be enabled.
383 */
384void hif_enable_power_management(struct hif_opaque_softc *hif_hdl,
385 bool is_packet_log_enabled)
386{
387 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700388
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700389 hif_sc->bus_ops.hif_enable_power_management(hif_sc,
390 is_packet_log_enabled);
391}
392
393/**
394 * hif_disable_power_management() - reset the bus power management
395 * @hif_hdl: opaque pointer to the hif context
396 *
397 * return the power management of the bus to its default state.
398 * This isn't necessarily a complete reversal of its counterpart.
399 * This should be called when unloading the driver.
400 */
401void hif_disable_power_management(struct hif_opaque_softc *hif_hdl)
402{
403 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700404
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700405 hif_sc->bus_ops.hif_disable_power_management(hif_sc);
406}
407
Mohit Khanna1957ba92016-05-11 11:17:01 -0700408/**
409 * hif_set_bundle_mode() - enable bundling and set default rx bundle cnt
410 * @scn: pointer to hif_opaque_softc structure
411 * @enabled: flag to enable/disable bundling
412 * @rx_bundle_cnt: bundle count to be used for RX
413 *
414 * Return: none
415 */
416void hif_set_bundle_mode(struct hif_opaque_softc *scn, bool enabled,
417 int rx_bundle_cnt)
418{
419 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700420
Mohit Khanna1957ba92016-05-11 11:17:01 -0700421 hif_sc->bus_ops.hif_set_bundle_mode(hif_sc, enabled, rx_bundle_cnt);
422}
423
424/**
425 * hif_bus_reset_resume() - resume the bus after reset
426 * @scn: struct hif_opaque_softc
427 *
428 * This function is called to tell the driver that USB device has been resumed
429 * and it has also been reset. The driver should redo any necessary
430 * initialization. This function resets WLAN SOC.
431 *
432 * Return: int 0 for success, non zero for failure
433 */
434int hif_bus_reset_resume(struct hif_opaque_softc *scn)
Mohit Khanna1957ba92016-05-11 11:17:01 -0700435{
436 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700437
Mohit Khanna1957ba92016-05-11 11:17:01 -0700438 return hif_sc->bus_ops.hif_bus_reset_resume(hif_sc);
439}
Dustin Brown6834d322017-03-20 15:02:48 -0700440
441int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx)
442{
443 struct hif_softc *scn;
444 int i;
445
Dustin Brown2af3d672017-05-30 16:14:01 -0700446 QDF_BUG(hif_ctx);
Dustin Brown6834d322017-03-20 15:02:48 -0700447 scn = HIF_GET_SOFTC(hif_ctx);
Dustin Brown2af3d672017-05-30 16:14:01 -0700448 if (!scn)
Dustin Brown6834d322017-03-20 15:02:48 -0700449 return -EINVAL;
Dustin Brown6834d322017-03-20 15:02:48 -0700450
Dustin Brown2af3d672017-05-30 16:14:01 -0700451 /* if the wake_irq is shared, don't disable it twice */
452 disable_irq(scn->wake_irq);
453 for (i = 0; i < scn->ce_count; ++i) {
454 int irq = scn->bus_ops.hif_map_ce_to_irq(scn, i);
455
456 if (irq != scn->wake_irq)
457 disable_irq(irq);
458 }
Dustin Brown6834d322017-03-20 15:02:48 -0700459
460 return 0;
461}
462
463int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx)
464{
465 struct hif_softc *scn;
466 int i;
467
Dustin Brown2af3d672017-05-30 16:14:01 -0700468 QDF_BUG(hif_ctx);
Dustin Brown6834d322017-03-20 15:02:48 -0700469 scn = HIF_GET_SOFTC(hif_ctx);
Dustin Brown2af3d672017-05-30 16:14:01 -0700470 if (!scn)
Dustin Brown6834d322017-03-20 15:02:48 -0700471 return -EINVAL;
Dustin Brown6834d322017-03-20 15:02:48 -0700472
Dustin Brown2af3d672017-05-30 16:14:01 -0700473 /* if the wake_irq is shared, don't enable it twice */
474 enable_irq(scn->wake_irq);
475 for (i = 0; i < scn->ce_count; ++i) {
476 int irq = scn->bus_ops.hif_map_ce_to_irq(scn, i);
477
478 if (irq != scn->wake_irq)
479 enable_irq(irq);
480 }
Dustin Brown6834d322017-03-20 15:02:48 -0700481
482 return 0;
483}
484
485int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx)
486{
Dustin Brown6834d322017-03-20 15:02:48 -0700487 struct hif_softc *scn;
Dustin Brown6834d322017-03-20 15:02:48 -0700488
Dustin Brown2af3d672017-05-30 16:14:01 -0700489 QDF_BUG(hif_ctx);
Dustin Brown6834d322017-03-20 15:02:48 -0700490 scn = HIF_GET_SOFTC(hif_ctx);
Dustin Brown2af3d672017-05-30 16:14:01 -0700491 if (!scn)
Dustin Brown6834d322017-03-20 15:02:48 -0700492 return -EINVAL;
Dustin Brown6834d322017-03-20 15:02:48 -0700493
Dustin Brown2af3d672017-05-30 16:14:01 -0700494 disable_irq(scn->wake_irq);
Dustin Brown6834d322017-03-20 15:02:48 -0700495
496 return 0;
497}
498
499int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx)
500{
Dustin Brown6834d322017-03-20 15:02:48 -0700501 struct hif_softc *scn;
Dustin Brown6834d322017-03-20 15:02:48 -0700502
Dustin Brown2af3d672017-05-30 16:14:01 -0700503 QDF_BUG(hif_ctx);
Dustin Brown6834d322017-03-20 15:02:48 -0700504 scn = HIF_GET_SOFTC(hif_ctx);
Dustin Brown2af3d672017-05-30 16:14:01 -0700505 if (!scn)
Dustin Brown6834d322017-03-20 15:02:48 -0700506 return -EINVAL;
Dustin Brown6834d322017-03-20 15:02:48 -0700507
Dustin Brown2af3d672017-05-30 16:14:01 -0700508 enable_irq(scn->wake_irq);
Dustin Brown6834d322017-03-20 15:02:48 -0700509
510 return 0;
511}
Nirav Shahd9dce6e2018-02-26 14:50:25 +0530512
513bool hif_needs_bmi(struct hif_opaque_softc *scn)
514{
515 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
516
517 return hif_sc->bus_ops.hif_needs_bmi(hif_sc);
518}