blob: e22eabe2db7283a0ac35e396fba6fcd5728f7e2c [file] [log] [blame]
Houston Hoffman32bc8eb2016-03-14 21:11:34 -07001/*
Yu Wang1e487a52017-02-07 20:10:42 +08002 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
Houston Hoffman32bc8eb2016-03-14 21:11:34 -07003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28
29/* this file dispatches functions to bus specific definitions */
30#include "hif_debug.h"
31#include "hif.h"
32#include "hif_main.h"
Jeff Johnson6950fdb2016-10-07 13:00:59 -070033#include "hif_io32.h"
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070034#include "multibus.h"
Mohit Khanna1957ba92016-05-11 11:17:01 -070035#include "dummy.h"
Nirav Shah3573f952016-05-12 18:37:03 +053036#if defined(HIF_PCI) || defined(HIF_SNOC) || defined(HIF_AHB)
Houston Hoffman162164c2016-03-14 21:12:10 -070037#include "ce_main.h"
Dustin Brown6834d322017-03-20 15:02:48 -070038#include "ce_api.h"
39#include "ce_internal.h"
Nirav Shah3573f952016-05-12 18:37:03 +053040#endif
Komal Seelam6ee55902016-04-11 17:11:07 +053041#include "htc_services.h"
42#include "a_types.h"
Nirav Shahb70bd732016-05-25 14:31:51 +053043#include "dummy.h"
44
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070045/**
46 * hif_intialize_default_ops() - intializes default operations values
47 *
48 * bus specific features should assign their dummy implementations here.
49 */
50static void hif_intialize_default_ops(struct hif_softc *hif_sc)
51{
52 struct hif_bus_ops *bus_ops = &hif_sc->bus_ops;
53
54 /* must be filled in by hif_bus_open */
55 bus_ops->hif_bus_close = NULL;
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070056 /* dummy implementations */
Nirav Shahb70bd732016-05-25 14:31:51 +053057 bus_ops->hif_display_stats =
58 &hif_dummy_display_stats;
59 bus_ops->hif_clear_stats =
60 &hif_dummy_clear_stats;
Houston Hoffman7fdff0c2016-08-29 12:31:58 -070061 bus_ops->hif_set_bundle_mode = &hif_dummy_set_bundle_mode;
62 bus_ops->hif_bus_reset_resume = &hif_dummy_bus_reset_resume;
63 bus_ops->hif_bus_suspend_noirq = &hif_dummy_bus_suspend_noirq;
64 bus_ops->hif_bus_resume_noirq = &hif_dummy_bus_resume_noirq;
Houston Hoffmancbcd8392017-02-08 17:43:13 -080065 bus_ops->hif_bus_early_suspend = &hif_dummy_bus_suspend;
66 bus_ops->hif_bus_late_resume = &hif_dummy_bus_resume;
Dustin Brown07d24be2017-04-03 10:20:49 -070067 bus_ops->hif_map_ce_to_irq = &hif_dummy_map_ce_to_irq;
Venkateswara Swamy Bandaru61824942017-04-12 12:31:59 +053068 bus_ops->hif_grp_irq_configure = &hif_dummy_grp_irq_configure;
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070069}
70
71#define NUM_OPS (sizeof(struct hif_bus_ops) / sizeof(void *))
72
73/**
74 * hif_verify_basic_ops() - ensure required bus apis are defined
75 *
76 * all bus operations must be defined to avoid crashes
77 * itterate over the structure and ensure all function pointers
78 * are non null.
79 *
80 * Return: QDF_STATUS_SUCCESS if all the operations are defined
81 */
82static QDF_STATUS hif_verify_basic_ops(struct hif_softc *hif_sc)
83{
84 struct hif_bus_ops *bus_ops = &hif_sc->bus_ops;
85 void **ops_array = (void *)bus_ops;
86 QDF_STATUS status = QDF_STATUS_SUCCESS;
87 int i;
88
89 for (i = 0; i < NUM_OPS; i++) {
90 if (!ops_array[i]) {
91 HIF_ERROR("%s: function %d is null", __func__, i);
92 status = QDF_STATUS_E_NOSUPPORT;
93 }
94 }
95 return status;
96}
97
98/**
Houston Hoffman162164c2016-03-14 21:12:10 -070099 * hif_bus_get_context_size - API to return size of the bus specific structure
100 *
101 * Return: sizeof of hif_pci_softc
102 */
103int hif_bus_get_context_size(enum qdf_bus_type bus_type)
104{
105 switch (bus_type) {
106 case QDF_BUS_TYPE_PCI:
107 return hif_pci_get_context_size();
Houston Hoffman3db96a42016-05-05 19:54:39 -0700108 case QDF_BUS_TYPE_AHB:
109 return hif_ahb_get_context_size();
Houston Hoffman162164c2016-03-14 21:12:10 -0700110 case QDF_BUS_TYPE_SNOC:
111 return hif_snoc_get_context_size();
Nirav Shah3573f952016-05-12 18:37:03 +0530112 case QDF_BUS_TYPE_SDIO:
113 return hif_sdio_get_context_size();
Mohit Khanna1957ba92016-05-11 11:17:01 -0700114 case QDF_BUS_TYPE_USB:
115 return hif_usb_get_context_size();
Houston Hoffman162164c2016-03-14 21:12:10 -0700116 default:
117 return 0;
118 }
119}
120
121/**
Houston Hoffman32bc8eb2016-03-14 21:11:34 -0700122 * hif_bus_open() - initialize the bus_ops and call the bus specific open
123 * hif_sc: hif_context
124 * bus_type: type of bus being enumerated
125 *
126 * Return: QDF_STATUS_SUCCESS or error
127 */
128QDF_STATUS hif_bus_open(struct hif_softc *hif_sc,
129 enum qdf_bus_type bus_type)
130{
131 QDF_STATUS status = QDF_STATUS_E_INVAL;
132
133 hif_intialize_default_ops(hif_sc);
134
135 switch (bus_type) {
136 case QDF_BUS_TYPE_PCI:
Houston Hoffman54ef87d2016-03-14 21:11:58 -0700137 status = hif_initialize_pci_ops(hif_sc);
Houston Hoffman32bc8eb2016-03-14 21:11:34 -0700138 break;
139 case QDF_BUS_TYPE_SNOC:
140 status = hif_initialize_snoc_ops(&hif_sc->bus_ops);
141 break;
Houston Hoffman3db96a42016-05-05 19:54:39 -0700142 case QDF_BUS_TYPE_AHB:
143 status = hif_initialize_ahb_ops(&hif_sc->bus_ops);
144 break;
Nirav Shah3573f952016-05-12 18:37:03 +0530145 case QDF_BUS_TYPE_SDIO:
146 status = hif_initialize_sdio_ops(hif_sc);
Yu Wang1e487a52017-02-07 20:10:42 +0800147 break;
Mohit Khanna1957ba92016-05-11 11:17:01 -0700148 case QDF_BUS_TYPE_USB:
149 status = hif_initialize_usb_ops(&hif_sc->bus_ops);
Nirav Shah3573f952016-05-12 18:37:03 +0530150 break;
Houston Hoffman32bc8eb2016-03-14 21:11:34 -0700151 default:
152 status = QDF_STATUS_E_NOSUPPORT;
153 break;
154 }
155
156 if (status != QDF_STATUS_SUCCESS) {
157 HIF_ERROR("%s: %d not supported", __func__, bus_type);
158 return status;
159 }
160
161 status = hif_verify_basic_ops(hif_sc);
162 if (status != QDF_STATUS_SUCCESS)
163 return status;
164
165 return hif_sc->bus_ops.hif_bus_open(hif_sc, bus_type);
166}
167
168/**
169 * hif_bus_close() - close the bus
170 * @hif_sc: hif_context
171 */
172void hif_bus_close(struct hif_softc *hif_sc)
173{
174 hif_sc->bus_ops.hif_bus_close(hif_sc);
175}
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700176
177/**
178 * hif_bus_prevent_linkdown() - prevent linkdown
179 * @hif_ctx: hif context
180 * @flag: true = keep bus alive false = let bus go to sleep
181 *
182 * Keeps the bus awake durring suspend.
183 */
184void hif_bus_prevent_linkdown(struct hif_softc *hif_sc, bool flag)
185{
186 hif_sc->bus_ops.hif_bus_prevent_linkdown(hif_sc, flag);
187}
188
189
190void hif_reset_soc(struct hif_opaque_softc *hif_ctx)
191{
192 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700193
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700194 hif_sc->bus_ops.hif_reset_soc(hif_sc);
195}
196
Houston Hoffmancbcd8392017-02-08 17:43:13 -0800197int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx)
198{
199 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700200
Houston Hoffmancbcd8392017-02-08 17:43:13 -0800201 return hif_sc->bus_ops.hif_bus_early_suspend(hif_sc);
202}
203
204int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx)
205{
206 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700207
Houston Hoffmancbcd8392017-02-08 17:43:13 -0800208 return hif_sc->bus_ops.hif_bus_late_resume(hif_sc);
209}
210
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700211int hif_bus_suspend(struct hif_opaque_softc *hif_ctx)
212{
213 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700214
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700215 return hif_sc->bus_ops.hif_bus_suspend(hif_sc);
216}
217
218int hif_bus_resume(struct hif_opaque_softc *hif_ctx)
219{
220 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700221
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700222 return hif_sc->bus_ops.hif_bus_resume(hif_sc);
223}
224
Houston Hoffman7fdff0c2016-08-29 12:31:58 -0700225int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx)
226{
227 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700228
Houston Hoffman7fdff0c2016-08-29 12:31:58 -0700229 return hif_sc->bus_ops.hif_bus_suspend_noirq(hif_sc);
230}
231
232int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx)
233{
234 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700235
Houston Hoffman7fdff0c2016-08-29 12:31:58 -0700236 return hif_sc->bus_ops.hif_bus_resume_noirq(hif_sc);
237}
238
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700239int hif_target_sleep_state_adjust(struct hif_softc *hif_sc,
240 bool sleep_ok, bool wait_for_it)
241{
242 return hif_sc->bus_ops.hif_target_sleep_state_adjust(hif_sc,
243 sleep_ok, wait_for_it);
244}
Houston Hoffman8f239f62016-03-14 21:12:05 -0700245
246void hif_disable_isr(struct hif_opaque_softc *hif_hdl)
247{
248 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700249
Houston Hoffman8f239f62016-03-14 21:12:05 -0700250 hif_sc->bus_ops.hif_disable_isr(hif_sc);
251}
252
253void hif_nointrs(struct hif_softc *hif_sc)
254{
255 hif_sc->bus_ops.hif_nointrs(hif_sc);
256}
257
258QDF_STATUS hif_enable_bus(struct hif_softc *hif_sc, struct device *dev,
Manikandan Mohanbd0ef8a2017-04-10 13:10:21 -0700259 void *bdev, const struct hif_bus_id *bid,
Houston Hoffman8f239f62016-03-14 21:12:05 -0700260 enum hif_enable_type type)
261{
262 return hif_sc->bus_ops.hif_enable_bus(hif_sc, dev, bdev, bid, type);
263}
264
265void hif_disable_bus(struct hif_softc *hif_sc)
266{
267 hif_sc->bus_ops.hif_disable_bus(hif_sc);
268}
269
270int hif_bus_configure(struct hif_softc *hif_sc)
271{
272 return hif_sc->bus_ops.hif_bus_configure(hif_sc);
273}
274
Nirav Shah3573f952016-05-12 18:37:03 +0530275QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
276 int opcode, void *config, uint32_t config_len)
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 return hif_sc->bus_ops.hif_get_config_item(hif_sc, opcode, config,
281 config_len);
282}
283
284void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx)
285{
286 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700287
Nirav Shah3573f952016-05-12 18:37:03 +0530288 hif_sc->bus_ops.hif_set_mailbox_swap(hif_sc);
289}
290
291void hif_claim_device(struct hif_opaque_softc *hif_ctx)
292{
293 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700294
Nirav Shah3573f952016-05-12 18:37:03 +0530295 hif_sc->bus_ops.hif_claim_device(hif_sc);
296}
297
298void hif_shutdown_device(struct hif_opaque_softc *hif_ctx)
299{
300 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700301
Nirav Shah3573f952016-05-12 18:37:03 +0530302 hif_sc->bus_ops.hif_shutdown_device(hif_sc);
303}
304
305void hif_stop(struct hif_opaque_softc *hif_ctx)
306{
307 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700308
Nirav Shah3573f952016-05-12 18:37:03 +0530309 hif_sc->bus_ops.hif_stop(hif_sc);
310}
311
Nirav Shah3573f952016-05-12 18:37:03 +0530312void hif_cancel_deferred_target_sleep(struct hif_softc *hif_sc)
313{
314 return hif_sc->bus_ops.hif_cancel_deferred_target_sleep(hif_sc);
315}
316
Houston Hoffman8f239f62016-03-14 21:12:05 -0700317void hif_irq_enable(struct hif_softc *hif_sc, int irq_id)
318{
319 hif_sc->bus_ops.hif_irq_enable(hif_sc, irq_id);
320}
321
322void hif_irq_disable(struct hif_softc *hif_sc, int irq_id)
323{
324 hif_sc->bus_ops.hif_irq_disable(hif_sc, irq_id);
325}
Houston Hoffman3c017e72016-03-14 21:12:11 -0700326
Houston Hoffmandef86a32017-04-21 20:23:45 -0700327int hif_grp_irq_configure(struct hif_softc *hif_sc,
328 struct hif_exec_context *hif_exec)
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530329{
Houston Hoffmandef86a32017-04-21 20:23:45 -0700330 return hif_sc->bus_ops.hif_grp_irq_configure(hif_sc, hif_exec);
Venkateswara Swamy Bandaru61824942017-04-12 12:31:59 +0530331}
332
Houston Hoffman3c017e72016-03-14 21:12:11 -0700333int hif_dump_registers(struct hif_opaque_softc *hif_hdl)
334{
335 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700336
Houston Hoffman3c017e72016-03-14 21:12:11 -0700337 return hif_sc->bus_ops.hif_dump_registers(hif_sc);
338}
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700339
Nirav Shah3573f952016-05-12 18:37:03 +0530340void hif_dump_target_memory(struct hif_opaque_softc *hif_hdl,
341 void *ramdump_base,
342 uint32_t address, uint32_t size)
343{
344 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700345
Nirav Shah3573f952016-05-12 18:37:03 +0530346 hif_sc->bus_ops.hif_dump_target_memory(hif_sc, ramdump_base,
347 address, size);
348}
349
350void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_hdl,
351 qdf_dma_addr_t *ce_sr_base_paddr,
352 uint32_t *ce_sr_ring_size,
353 qdf_dma_addr_t *ce_reg_paddr)
354{
355 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700356
Nirav Shah3573f952016-05-12 18:37:03 +0530357 hif_sc->bus_ops.hif_ipa_get_ce_resource(hif_sc, ce_sr_base_paddr,
358 ce_sr_ring_size, ce_reg_paddr);
359}
360
361void hif_mask_interrupt_call(struct hif_opaque_softc *hif_hdl)
362{
363 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700364
Nirav Shah3573f952016-05-12 18:37:03 +0530365 hif_sc->bus_ops.hif_mask_interrupt_call(hif_sc);
366}
367
Nirav Shahb70bd732016-05-25 14:31:51 +0530368void hif_display_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_display_stats(hif_sc);
373}
374
375void hif_clear_bus_stats(struct hif_opaque_softc *scn)
376{
377 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
378
379 hif_sc->bus_ops.hif_clear_stats(hif_sc);
380}
381
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700382/**
383 * hif_enable_power_management() - enable power management after driver load
384 * @hif_hdl: opaque pointer to the hif context
385 * is_packet_log_enabled: true if packet log is enabled
386 *
387 * Driver load and firmware download are done in a high performance mode.
388 * Enable power management after the driver is loaded.
389 * packet log can require fewer power management features to be enabled.
390 */
391void hif_enable_power_management(struct hif_opaque_softc *hif_hdl,
392 bool is_packet_log_enabled)
393{
394 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700395
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700396 hif_sc->bus_ops.hif_enable_power_management(hif_sc,
397 is_packet_log_enabled);
398}
399
400/**
401 * hif_disable_power_management() - reset the bus power management
402 * @hif_hdl: opaque pointer to the hif context
403 *
404 * return the power management of the bus to its default state.
405 * This isn't necessarily a complete reversal of its counterpart.
406 * This should be called when unloading the driver.
407 */
408void hif_disable_power_management(struct hif_opaque_softc *hif_hdl)
409{
410 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700411
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700412 hif_sc->bus_ops.hif_disable_power_management(hif_sc);
413}
414
Mohit Khanna1957ba92016-05-11 11:17:01 -0700415/**
416 * hif_set_bundle_mode() - enable bundling and set default rx bundle cnt
417 * @scn: pointer to hif_opaque_softc structure
418 * @enabled: flag to enable/disable bundling
419 * @rx_bundle_cnt: bundle count to be used for RX
420 *
421 * Return: none
422 */
423void hif_set_bundle_mode(struct hif_opaque_softc *scn, bool enabled,
424 int rx_bundle_cnt)
425{
426 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700427
Mohit Khanna1957ba92016-05-11 11:17:01 -0700428 hif_sc->bus_ops.hif_set_bundle_mode(hif_sc, enabled, rx_bundle_cnt);
429}
430
431/**
432 * hif_bus_reset_resume() - resume the bus after reset
433 * @scn: struct hif_opaque_softc
434 *
435 * This function is called to tell the driver that USB device has been resumed
436 * and it has also been reset. The driver should redo any necessary
437 * initialization. This function resets WLAN SOC.
438 *
439 * Return: int 0 for success, non zero for failure
440 */
441int hif_bus_reset_resume(struct hif_opaque_softc *scn)
Mohit Khanna1957ba92016-05-11 11:17:01 -0700442{
443 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700444
Mohit Khanna1957ba92016-05-11 11:17:01 -0700445 return hif_sc->bus_ops.hif_bus_reset_resume(hif_sc);
446}
Dustin Brown6834d322017-03-20 15:02:48 -0700447
448int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx)
449{
450 struct hif_softc *scn;
451 int i;
452
Dustin Brown2af3d672017-05-30 16:14:01 -0700453 QDF_BUG(hif_ctx);
Dustin Brown6834d322017-03-20 15:02:48 -0700454 scn = HIF_GET_SOFTC(hif_ctx);
Dustin Brown2af3d672017-05-30 16:14:01 -0700455 if (!scn)
Dustin Brown6834d322017-03-20 15:02:48 -0700456 return -EINVAL;
Dustin Brown6834d322017-03-20 15:02:48 -0700457
Dustin Brown2af3d672017-05-30 16:14:01 -0700458 /* if the wake_irq is shared, don't disable it twice */
459 disable_irq(scn->wake_irq);
460 for (i = 0; i < scn->ce_count; ++i) {
461 int irq = scn->bus_ops.hif_map_ce_to_irq(scn, i);
462
463 if (irq != scn->wake_irq)
464 disable_irq(irq);
465 }
Dustin Brown6834d322017-03-20 15:02:48 -0700466
467 return 0;
468}
469
470int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx)
471{
472 struct hif_softc *scn;
473 int i;
474
Dustin Brown2af3d672017-05-30 16:14:01 -0700475 QDF_BUG(hif_ctx);
Dustin Brown6834d322017-03-20 15:02:48 -0700476 scn = HIF_GET_SOFTC(hif_ctx);
Dustin Brown2af3d672017-05-30 16:14:01 -0700477 if (!scn)
Dustin Brown6834d322017-03-20 15:02:48 -0700478 return -EINVAL;
Dustin Brown6834d322017-03-20 15:02:48 -0700479
Dustin Brown2af3d672017-05-30 16:14:01 -0700480 /* if the wake_irq is shared, don't enable it twice */
481 enable_irq(scn->wake_irq);
482 for (i = 0; i < scn->ce_count; ++i) {
483 int irq = scn->bus_ops.hif_map_ce_to_irq(scn, i);
484
485 if (irq != scn->wake_irq)
486 enable_irq(irq);
487 }
Dustin Brown6834d322017-03-20 15:02:48 -0700488
489 return 0;
490}
491
492int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx)
493{
Dustin Brown6834d322017-03-20 15:02:48 -0700494 struct hif_softc *scn;
Dustin Brown6834d322017-03-20 15:02:48 -0700495
Dustin Brown2af3d672017-05-30 16:14:01 -0700496 QDF_BUG(hif_ctx);
Dustin Brown6834d322017-03-20 15:02:48 -0700497 scn = HIF_GET_SOFTC(hif_ctx);
Dustin Brown2af3d672017-05-30 16:14:01 -0700498 if (!scn)
Dustin Brown6834d322017-03-20 15:02:48 -0700499 return -EINVAL;
Dustin Brown6834d322017-03-20 15:02:48 -0700500
Dustin Brown2af3d672017-05-30 16:14:01 -0700501 disable_irq(scn->wake_irq);
Dustin Brown6834d322017-03-20 15:02:48 -0700502
503 return 0;
504}
505
506int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx)
507{
Dustin Brown6834d322017-03-20 15:02:48 -0700508 struct hif_softc *scn;
Dustin Brown6834d322017-03-20 15:02:48 -0700509
Dustin Brown2af3d672017-05-30 16:14:01 -0700510 QDF_BUG(hif_ctx);
Dustin Brown6834d322017-03-20 15:02:48 -0700511 scn = HIF_GET_SOFTC(hif_ctx);
Dustin Brown2af3d672017-05-30 16:14:01 -0700512 if (!scn)
Dustin Brown6834d322017-03-20 15:02:48 -0700513 return -EINVAL;
Dustin Brown6834d322017-03-20 15:02:48 -0700514
Dustin Brown2af3d672017-05-30 16:14:01 -0700515 enable_irq(scn->wake_irq);
Dustin Brown6834d322017-03-20 15:02:48 -0700516
517 return 0;
518}