blob: 36f6f5f5c3f38ea43a47fa994e035bbaec9ccacf [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;
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +053067 bus_ops->hif_grp_irq_disable = &hif_dummy_grp_irq_disable;
68 bus_ops->hif_grp_irq_enable = &hif_dummy_grp_irq_enable;
Dustin Brown07d24be2017-04-03 10:20:49 -070069 bus_ops->hif_map_ce_to_irq = &hif_dummy_map_ce_to_irq;
Venkateswara Swamy Bandaru61824942017-04-12 12:31:59 +053070 bus_ops->hif_grp_irq_configure = &hif_dummy_grp_irq_configure;
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070071}
72
73#define NUM_OPS (sizeof(struct hif_bus_ops) / sizeof(void *))
74
75/**
76 * hif_verify_basic_ops() - ensure required bus apis are defined
77 *
78 * all bus operations must be defined to avoid crashes
79 * itterate over the structure and ensure all function pointers
80 * are non null.
81 *
82 * Return: QDF_STATUS_SUCCESS if all the operations are defined
83 */
84static QDF_STATUS hif_verify_basic_ops(struct hif_softc *hif_sc)
85{
86 struct hif_bus_ops *bus_ops = &hif_sc->bus_ops;
87 void **ops_array = (void *)bus_ops;
88 QDF_STATUS status = QDF_STATUS_SUCCESS;
89 int i;
90
91 for (i = 0; i < NUM_OPS; i++) {
92 if (!ops_array[i]) {
93 HIF_ERROR("%s: function %d is null", __func__, i);
94 status = QDF_STATUS_E_NOSUPPORT;
95 }
96 }
97 return status;
98}
99
100/**
Houston Hoffman162164c2016-03-14 21:12:10 -0700101 * hif_bus_get_context_size - API to return size of the bus specific structure
102 *
103 * Return: sizeof of hif_pci_softc
104 */
105int hif_bus_get_context_size(enum qdf_bus_type bus_type)
106{
107 switch (bus_type) {
108 case QDF_BUS_TYPE_PCI:
109 return hif_pci_get_context_size();
Houston Hoffman3db96a42016-05-05 19:54:39 -0700110 case QDF_BUS_TYPE_AHB:
111 return hif_ahb_get_context_size();
Houston Hoffman162164c2016-03-14 21:12:10 -0700112 case QDF_BUS_TYPE_SNOC:
113 return hif_snoc_get_context_size();
Nirav Shah3573f952016-05-12 18:37:03 +0530114 case QDF_BUS_TYPE_SDIO:
115 return hif_sdio_get_context_size();
Mohit Khanna1957ba92016-05-11 11:17:01 -0700116 case QDF_BUS_TYPE_USB:
117 return hif_usb_get_context_size();
Houston Hoffman162164c2016-03-14 21:12:10 -0700118 default:
119 return 0;
120 }
121}
122
123/**
Houston Hoffman32bc8eb2016-03-14 21:11:34 -0700124 * hif_bus_open() - initialize the bus_ops and call the bus specific open
125 * hif_sc: hif_context
126 * bus_type: type of bus being enumerated
127 *
128 * Return: QDF_STATUS_SUCCESS or error
129 */
130QDF_STATUS hif_bus_open(struct hif_softc *hif_sc,
131 enum qdf_bus_type bus_type)
132{
133 QDF_STATUS status = QDF_STATUS_E_INVAL;
134
135 hif_intialize_default_ops(hif_sc);
136
137 switch (bus_type) {
138 case QDF_BUS_TYPE_PCI:
Houston Hoffman54ef87d2016-03-14 21:11:58 -0700139 status = hif_initialize_pci_ops(hif_sc);
Houston Hoffman32bc8eb2016-03-14 21:11:34 -0700140 break;
141 case QDF_BUS_TYPE_SNOC:
142 status = hif_initialize_snoc_ops(&hif_sc->bus_ops);
143 break;
Houston Hoffman3db96a42016-05-05 19:54:39 -0700144 case QDF_BUS_TYPE_AHB:
145 status = hif_initialize_ahb_ops(&hif_sc->bus_ops);
146 break;
Nirav Shah3573f952016-05-12 18:37:03 +0530147 case QDF_BUS_TYPE_SDIO:
148 status = hif_initialize_sdio_ops(hif_sc);
Yu Wang1e487a52017-02-07 20:10:42 +0800149 break;
Mohit Khanna1957ba92016-05-11 11:17:01 -0700150 case QDF_BUS_TYPE_USB:
151 status = hif_initialize_usb_ops(&hif_sc->bus_ops);
Nirav Shah3573f952016-05-12 18:37:03 +0530152 break;
Houston Hoffman32bc8eb2016-03-14 21:11:34 -0700153 default:
154 status = QDF_STATUS_E_NOSUPPORT;
155 break;
156 }
157
158 if (status != QDF_STATUS_SUCCESS) {
159 HIF_ERROR("%s: %d not supported", __func__, bus_type);
160 return status;
161 }
162
163 status = hif_verify_basic_ops(hif_sc);
164 if (status != QDF_STATUS_SUCCESS)
165 return status;
166
167 return hif_sc->bus_ops.hif_bus_open(hif_sc, bus_type);
168}
169
170/**
171 * hif_bus_close() - close the bus
172 * @hif_sc: hif_context
173 */
174void hif_bus_close(struct hif_softc *hif_sc)
175{
176 hif_sc->bus_ops.hif_bus_close(hif_sc);
177}
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700178
179/**
180 * hif_bus_prevent_linkdown() - prevent linkdown
181 * @hif_ctx: hif context
182 * @flag: true = keep bus alive false = let bus go to sleep
183 *
184 * Keeps the bus awake durring suspend.
185 */
186void hif_bus_prevent_linkdown(struct hif_softc *hif_sc, bool flag)
187{
188 hif_sc->bus_ops.hif_bus_prevent_linkdown(hif_sc, flag);
189}
190
191
192void hif_reset_soc(struct hif_opaque_softc *hif_ctx)
193{
194 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700195
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700196 hif_sc->bus_ops.hif_reset_soc(hif_sc);
197}
198
Houston Hoffmancbcd8392017-02-08 17:43:13 -0800199int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx)
200{
201 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700202
Houston Hoffmancbcd8392017-02-08 17:43:13 -0800203 return hif_sc->bus_ops.hif_bus_early_suspend(hif_sc);
204}
205
206int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx)
207{
208 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700209
Houston Hoffmancbcd8392017-02-08 17:43:13 -0800210 return hif_sc->bus_ops.hif_bus_late_resume(hif_sc);
211}
212
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700213int hif_bus_suspend(struct hif_opaque_softc *hif_ctx)
214{
215 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700216
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700217 return hif_sc->bus_ops.hif_bus_suspend(hif_sc);
218}
219
220int hif_bus_resume(struct hif_opaque_softc *hif_ctx)
221{
222 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700223
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700224 return hif_sc->bus_ops.hif_bus_resume(hif_sc);
225}
226
Houston Hoffman7fdff0c2016-08-29 12:31:58 -0700227int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx)
228{
229 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700230
Houston Hoffman7fdff0c2016-08-29 12:31:58 -0700231 return hif_sc->bus_ops.hif_bus_suspend_noirq(hif_sc);
232}
233
234int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx)
235{
236 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700237
Houston Hoffman7fdff0c2016-08-29 12:31:58 -0700238 return hif_sc->bus_ops.hif_bus_resume_noirq(hif_sc);
239}
240
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700241int hif_target_sleep_state_adjust(struct hif_softc *hif_sc,
242 bool sleep_ok, bool wait_for_it)
243{
244 return hif_sc->bus_ops.hif_target_sleep_state_adjust(hif_sc,
245 sleep_ok, wait_for_it);
246}
Houston Hoffman8f239f62016-03-14 21:12:05 -0700247
248void hif_disable_isr(struct hif_opaque_softc *hif_hdl)
249{
250 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700251
Houston Hoffman8f239f62016-03-14 21:12:05 -0700252 hif_sc->bus_ops.hif_disable_isr(hif_sc);
253}
254
255void hif_nointrs(struct hif_softc *hif_sc)
256{
257 hif_sc->bus_ops.hif_nointrs(hif_sc);
258}
259
260QDF_STATUS hif_enable_bus(struct hif_softc *hif_sc, struct device *dev,
261 void *bdev, const hif_bus_id *bid,
262 enum hif_enable_type type)
263{
264 return hif_sc->bus_ops.hif_enable_bus(hif_sc, dev, bdev, bid, type);
265}
266
267void hif_disable_bus(struct hif_softc *hif_sc)
268{
269 hif_sc->bus_ops.hif_disable_bus(hif_sc);
270}
271
272int hif_bus_configure(struct hif_softc *hif_sc)
273{
274 return hif_sc->bus_ops.hif_bus_configure(hif_sc);
275}
276
Nirav Shah3573f952016-05-12 18:37:03 +0530277QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
278 int opcode, void *config, uint32_t config_len)
279{
280 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700281
Nirav Shah3573f952016-05-12 18:37:03 +0530282 return hif_sc->bus_ops.hif_get_config_item(hif_sc, opcode, config,
283 config_len);
284}
285
286void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx)
287{
288 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700289
Nirav Shah3573f952016-05-12 18:37:03 +0530290 hif_sc->bus_ops.hif_set_mailbox_swap(hif_sc);
291}
292
293void hif_claim_device(struct hif_opaque_softc *hif_ctx)
294{
295 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700296
Nirav Shah3573f952016-05-12 18:37:03 +0530297 hif_sc->bus_ops.hif_claim_device(hif_sc);
298}
299
300void hif_shutdown_device(struct hif_opaque_softc *hif_ctx)
301{
302 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700303
Nirav Shah3573f952016-05-12 18:37:03 +0530304 hif_sc->bus_ops.hif_shutdown_device(hif_sc);
305}
306
307void hif_stop(struct hif_opaque_softc *hif_ctx)
308{
309 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700310
Nirav Shah3573f952016-05-12 18:37:03 +0530311 hif_sc->bus_ops.hif_stop(hif_sc);
312}
313
Nirav Shah3573f952016-05-12 18:37:03 +0530314void hif_cancel_deferred_target_sleep(struct hif_softc *hif_sc)
315{
316 return hif_sc->bus_ops.hif_cancel_deferred_target_sleep(hif_sc);
317}
318
Houston Hoffman8f239f62016-03-14 21:12:05 -0700319void hif_irq_enable(struct hif_softc *hif_sc, int irq_id)
320{
321 hif_sc->bus_ops.hif_irq_enable(hif_sc, irq_id);
322}
323
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530324void hif_grp_irq_enable(struct hif_softc *hif_sc, uint32_t grp_id)
325{
326 hif_sc->bus_ops.hif_grp_irq_enable(hif_sc, grp_id);
327}
328
Houston Hoffman8f239f62016-03-14 21:12:05 -0700329void hif_irq_disable(struct hif_softc *hif_sc, int irq_id)
330{
331 hif_sc->bus_ops.hif_irq_disable(hif_sc, irq_id);
332}
Houston Hoffman3c017e72016-03-14 21:12:11 -0700333
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530334void hif_grp_irq_disable(struct hif_softc *hif_sc, uint32_t grp_id)
335{
336 hif_sc->bus_ops.hif_grp_irq_disable(hif_sc, grp_id);
337}
338
Venkateswara Swamy Bandaru61824942017-04-12 12:31:59 +0530339int hif_grp_irq_configure(struct hif_softc *hif_sc)
340{
341 return hif_sc->bus_ops.hif_grp_irq_configure(hif_sc);
342}
343
Houston Hoffman3c017e72016-03-14 21:12:11 -0700344int hif_dump_registers(struct hif_opaque_softc *hif_hdl)
345{
346 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700347
Houston Hoffman3c017e72016-03-14 21:12:11 -0700348 return hif_sc->bus_ops.hif_dump_registers(hif_sc);
349}
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700350
Nirav Shah3573f952016-05-12 18:37:03 +0530351void hif_dump_target_memory(struct hif_opaque_softc *hif_hdl,
352 void *ramdump_base,
353 uint32_t address, uint32_t size)
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_dump_target_memory(hif_sc, ramdump_base,
358 address, size);
359}
360
361void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_hdl,
362 qdf_dma_addr_t *ce_sr_base_paddr,
363 uint32_t *ce_sr_ring_size,
364 qdf_dma_addr_t *ce_reg_paddr)
365{
366 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700367
Nirav Shah3573f952016-05-12 18:37:03 +0530368 hif_sc->bus_ops.hif_ipa_get_ce_resource(hif_sc, ce_sr_base_paddr,
369 ce_sr_ring_size, ce_reg_paddr);
370}
371
372void hif_mask_interrupt_call(struct hif_opaque_softc *hif_hdl)
373{
374 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700375
Nirav Shah3573f952016-05-12 18:37:03 +0530376 hif_sc->bus_ops.hif_mask_interrupt_call(hif_sc);
377}
378
Nirav Shahb70bd732016-05-25 14:31:51 +0530379void hif_display_bus_stats(struct hif_opaque_softc *scn)
380{
381 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
382
383 hif_sc->bus_ops.hif_display_stats(hif_sc);
384}
385
386void hif_clear_bus_stats(struct hif_opaque_softc *scn)
387{
388 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
389
390 hif_sc->bus_ops.hif_clear_stats(hif_sc);
391}
392
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700393/**
394 * hif_enable_power_management() - enable power management after driver load
395 * @hif_hdl: opaque pointer to the hif context
396 * is_packet_log_enabled: true if packet log is enabled
397 *
398 * Driver load and firmware download are done in a high performance mode.
399 * Enable power management after the driver is loaded.
400 * packet log can require fewer power management features to be enabled.
401 */
402void hif_enable_power_management(struct hif_opaque_softc *hif_hdl,
403 bool is_packet_log_enabled)
404{
405 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700406
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700407 hif_sc->bus_ops.hif_enable_power_management(hif_sc,
408 is_packet_log_enabled);
409}
410
411/**
412 * hif_disable_power_management() - reset the bus power management
413 * @hif_hdl: opaque pointer to the hif context
414 *
415 * return the power management of the bus to its default state.
416 * This isn't necessarily a complete reversal of its counterpart.
417 * This should be called when unloading the driver.
418 */
419void hif_disable_power_management(struct hif_opaque_softc *hif_hdl)
420{
421 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700422
Houston Hoffmanb4149dd2016-03-23 15:55:41 -0700423 hif_sc->bus_ops.hif_disable_power_management(hif_sc);
424}
425
Mohit Khanna1957ba92016-05-11 11:17:01 -0700426/**
427 * hif_set_bundle_mode() - enable bundling and set default rx bundle cnt
428 * @scn: pointer to hif_opaque_softc structure
429 * @enabled: flag to enable/disable bundling
430 * @rx_bundle_cnt: bundle count to be used for RX
431 *
432 * Return: none
433 */
434void hif_set_bundle_mode(struct hif_opaque_softc *scn, bool enabled,
435 int rx_bundle_cnt)
436{
437 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700438
Mohit Khanna1957ba92016-05-11 11:17:01 -0700439 hif_sc->bus_ops.hif_set_bundle_mode(hif_sc, enabled, rx_bundle_cnt);
440}
441
442/**
443 * hif_bus_reset_resume() - resume the bus after reset
444 * @scn: struct hif_opaque_softc
445 *
446 * This function is called to tell the driver that USB device has been resumed
447 * and it has also been reset. The driver should redo any necessary
448 * initialization. This function resets WLAN SOC.
449 *
450 * Return: int 0 for success, non zero for failure
451 */
452int hif_bus_reset_resume(struct hif_opaque_softc *scn)
453
454{
455 struct hif_softc *hif_sc = HIF_GET_SOFTC(scn);
Manikandan Mohan8e031352017-04-07 18:32:02 -0700456
Mohit Khanna1957ba92016-05-11 11:17:01 -0700457 return hif_sc->bus_ops.hif_bus_reset_resume(hif_sc);
458}
Dustin Brown6834d322017-03-20 15:02:48 -0700459
460int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx)
461{
462 struct hif_softc *scn;
463 int i;
464
465 scn = HIF_GET_SOFTC(hif_ctx);
466 if (!scn) {
467 QDF_BUG(0);
468 return -EINVAL;
469 }
470
471 for (i = 0; i < scn->ce_count; ++i)
472 disable_irq(scn->bus_ops.hif_map_ce_to_irq(scn, i));
473
474 return 0;
475}
476
477int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx)
478{
479 struct hif_softc *scn;
480 int i;
481
482 scn = HIF_GET_SOFTC(hif_ctx);
483 if (!scn) {
484 QDF_BUG(0);
485 return -EINVAL;
486 }
487
488 for (i = 0; i < scn->ce_count; ++i)
489 enable_irq(scn->bus_ops.hif_map_ce_to_irq(scn, i));
490
491 return 0;
492}
493
494int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx)
495{
496 int errno;
497 struct hif_softc *scn;
498 uint8_t wake_ce_id;
499
500 scn = HIF_GET_SOFTC(hif_ctx);
501 if (!scn) {
502 QDF_BUG(0);
503 return -EINVAL;
504 }
505
506 errno = hif_get_wake_ce_id(scn, &wake_ce_id);
507 if (errno) {
508 HIF_ERROR("%s: failed to get wake CE Id: %d", __func__, errno);
509 return errno;
510 }
511
512 disable_irq(scn->bus_ops.hif_map_ce_to_irq(scn, wake_ce_id));
513
514 return 0;
515}
516
517int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx)
518{
519 int errno;
520 struct hif_softc *scn;
521 uint8_t wake_ce_id;
522
523 scn = HIF_GET_SOFTC(hif_ctx);
524 if (!scn) {
525 QDF_BUG(0);
526 return -EINVAL;
527 }
528
529 errno = hif_get_wake_ce_id(scn, &wake_ce_id);
530 if (errno) {
531 HIF_ERROR("%s: failed to get wake CE Id: %d", __func__, errno);
532 return errno;
533 }
534
535 enable_irq(scn->bus_ops.hif_map_ce_to_irq(scn, wake_ce_id));
536
537 return 0;
538}