Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 1 | /* |
Yu Wang | 1e487a5 | 2017-02-07 20:10:42 +0800 | [diff] [blame] | 2 | * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved. |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 3 | * |
| 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 Johnson | 6950fdb | 2016-10-07 13:00:59 -0700 | [diff] [blame] | 33 | #include "hif_io32.h" |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 34 | #include "multibus.h" |
Mohit Khanna | 1957ba9 | 2016-05-11 11:17:01 -0700 | [diff] [blame] | 35 | #include "dummy.h" |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 36 | #if defined(HIF_PCI) || defined(HIF_SNOC) || defined(HIF_AHB) |
Houston Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 37 | #include "ce_main.h" |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 38 | #include "ce_api.h" |
| 39 | #include "ce_internal.h" |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 40 | #endif |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 41 | #include "htc_services.h" |
| 42 | #include "a_types.h" |
Nirav Shah | b70bd73 | 2016-05-25 14:31:51 +0530 | [diff] [blame] | 43 | #include "dummy.h" |
| 44 | |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 45 | /** |
| 46 | * hif_intialize_default_ops() - intializes default operations values |
| 47 | * |
| 48 | * bus specific features should assign their dummy implementations here. |
| 49 | */ |
| 50 | static 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 Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 56 | /* dummy implementations */ |
Nirav Shah | b70bd73 | 2016-05-25 14:31:51 +0530 | [diff] [blame] | 57 | bus_ops->hif_display_stats = |
| 58 | &hif_dummy_display_stats; |
| 59 | bus_ops->hif_clear_stats = |
| 60 | &hif_dummy_clear_stats; |
Houston Hoffman | 7fdff0c | 2016-08-29 12:31:58 -0700 | [diff] [blame] | 61 | 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 Hoffman | cbcd839 | 2017-02-08 17:43:13 -0800 | [diff] [blame] | 65 | bus_ops->hif_bus_early_suspend = &hif_dummy_bus_suspend; |
| 66 | bus_ops->hif_bus_late_resume = &hif_dummy_bus_resume; |
Venkateswara Swamy Bandaru | 31108f3 | 2016-08-08 18:04:29 +0530 | [diff] [blame] | 67 | bus_ops->hif_grp_irq_disable = &hif_dummy_grp_irq_disable; |
| 68 | bus_ops->hif_grp_irq_enable = &hif_dummy_grp_irq_enable; |
Dustin Brown | 07d24be | 2017-04-03 10:20:49 -0700 | [diff] [blame] | 69 | bus_ops->hif_map_ce_to_irq = &hif_dummy_map_ce_to_irq; |
Venkateswara Swamy Bandaru | 6182494 | 2017-04-12 12:31:59 +0530 | [diff] [blame^] | 70 | bus_ops->hif_grp_irq_configure = &hif_dummy_grp_irq_configure; |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 71 | } |
| 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 | */ |
| 84 | static 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 Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 101 | * hif_bus_get_context_size - API to return size of the bus specific structure |
| 102 | * |
| 103 | * Return: sizeof of hif_pci_softc |
| 104 | */ |
| 105 | int 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 Hoffman | 3db96a4 | 2016-05-05 19:54:39 -0700 | [diff] [blame] | 110 | case QDF_BUS_TYPE_AHB: |
| 111 | return hif_ahb_get_context_size(); |
Houston Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 112 | case QDF_BUS_TYPE_SNOC: |
| 113 | return hif_snoc_get_context_size(); |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 114 | case QDF_BUS_TYPE_SDIO: |
| 115 | return hif_sdio_get_context_size(); |
Mohit Khanna | 1957ba9 | 2016-05-11 11:17:01 -0700 | [diff] [blame] | 116 | case QDF_BUS_TYPE_USB: |
| 117 | return hif_usb_get_context_size(); |
Houston Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 118 | default: |
| 119 | return 0; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | /** |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 124 | * 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 | */ |
| 130 | QDF_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 Hoffman | 54ef87d | 2016-03-14 21:11:58 -0700 | [diff] [blame] | 139 | status = hif_initialize_pci_ops(hif_sc); |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 140 | break; |
| 141 | case QDF_BUS_TYPE_SNOC: |
| 142 | status = hif_initialize_snoc_ops(&hif_sc->bus_ops); |
| 143 | break; |
Houston Hoffman | 3db96a4 | 2016-05-05 19:54:39 -0700 | [diff] [blame] | 144 | case QDF_BUS_TYPE_AHB: |
| 145 | status = hif_initialize_ahb_ops(&hif_sc->bus_ops); |
| 146 | break; |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 147 | case QDF_BUS_TYPE_SDIO: |
| 148 | status = hif_initialize_sdio_ops(hif_sc); |
Yu Wang | 1e487a5 | 2017-02-07 20:10:42 +0800 | [diff] [blame] | 149 | break; |
Mohit Khanna | 1957ba9 | 2016-05-11 11:17:01 -0700 | [diff] [blame] | 150 | case QDF_BUS_TYPE_USB: |
| 151 | status = hif_initialize_usb_ops(&hif_sc->bus_ops); |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 152 | break; |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 153 | 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 | */ |
| 174 | void hif_bus_close(struct hif_softc *hif_sc) |
| 175 | { |
| 176 | hif_sc->bus_ops.hif_bus_close(hif_sc); |
| 177 | } |
Houston Hoffman | 4ca03b6 | 2016-03-14 21:11:51 -0700 | [diff] [blame] | 178 | |
| 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 | */ |
| 186 | void 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 | |
| 192 | void hif_reset_soc(struct hif_opaque_softc *hif_ctx) |
| 193 | { |
| 194 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 195 | hif_sc->bus_ops.hif_reset_soc(hif_sc); |
| 196 | } |
| 197 | |
Houston Hoffman | cbcd839 | 2017-02-08 17:43:13 -0800 | [diff] [blame] | 198 | int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx) |
| 199 | { |
| 200 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 201 | return hif_sc->bus_ops.hif_bus_early_suspend(hif_sc); |
| 202 | } |
| 203 | |
| 204 | int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx) |
| 205 | { |
| 206 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 207 | return hif_sc->bus_ops.hif_bus_late_resume(hif_sc); |
| 208 | } |
| 209 | |
Houston Hoffman | 4ca03b6 | 2016-03-14 21:11:51 -0700 | [diff] [blame] | 210 | int hif_bus_suspend(struct hif_opaque_softc *hif_ctx) |
| 211 | { |
| 212 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 213 | return hif_sc->bus_ops.hif_bus_suspend(hif_sc); |
| 214 | } |
| 215 | |
| 216 | int hif_bus_resume(struct hif_opaque_softc *hif_ctx) |
| 217 | { |
| 218 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 219 | return hif_sc->bus_ops.hif_bus_resume(hif_sc); |
| 220 | } |
| 221 | |
Houston Hoffman | 7fdff0c | 2016-08-29 12:31:58 -0700 | [diff] [blame] | 222 | int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx) |
| 223 | { |
| 224 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 225 | return hif_sc->bus_ops.hif_bus_suspend_noirq(hif_sc); |
| 226 | } |
| 227 | |
| 228 | int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx) |
| 229 | { |
| 230 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 231 | return hif_sc->bus_ops.hif_bus_resume_noirq(hif_sc); |
| 232 | } |
| 233 | |
Houston Hoffman | 4ca03b6 | 2016-03-14 21:11:51 -0700 | [diff] [blame] | 234 | int hif_target_sleep_state_adjust(struct hif_softc *hif_sc, |
| 235 | bool sleep_ok, bool wait_for_it) |
| 236 | { |
| 237 | return hif_sc->bus_ops.hif_target_sleep_state_adjust(hif_sc, |
| 238 | sleep_ok, wait_for_it); |
| 239 | } |
Houston Hoffman | 8f239f6 | 2016-03-14 21:12:05 -0700 | [diff] [blame] | 240 | |
| 241 | void hif_disable_isr(struct hif_opaque_softc *hif_hdl) |
| 242 | { |
| 243 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
| 244 | hif_sc->bus_ops.hif_disable_isr(hif_sc); |
| 245 | } |
| 246 | |
| 247 | void hif_nointrs(struct hif_softc *hif_sc) |
| 248 | { |
| 249 | hif_sc->bus_ops.hif_nointrs(hif_sc); |
| 250 | } |
| 251 | |
| 252 | QDF_STATUS hif_enable_bus(struct hif_softc *hif_sc, struct device *dev, |
| 253 | void *bdev, const hif_bus_id *bid, |
| 254 | enum hif_enable_type type) |
| 255 | { |
| 256 | return hif_sc->bus_ops.hif_enable_bus(hif_sc, dev, bdev, bid, type); |
| 257 | } |
| 258 | |
| 259 | void hif_disable_bus(struct hif_softc *hif_sc) |
| 260 | { |
| 261 | hif_sc->bus_ops.hif_disable_bus(hif_sc); |
| 262 | } |
| 263 | |
| 264 | int hif_bus_configure(struct hif_softc *hif_sc) |
| 265 | { |
| 266 | return hif_sc->bus_ops.hif_bus_configure(hif_sc); |
| 267 | } |
| 268 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 269 | QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx, |
| 270 | int opcode, void *config, uint32_t config_len) |
| 271 | { |
| 272 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 273 | return hif_sc->bus_ops.hif_get_config_item(hif_sc, opcode, config, |
| 274 | config_len); |
| 275 | } |
| 276 | |
| 277 | void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx) |
| 278 | { |
| 279 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 280 | hif_sc->bus_ops.hif_set_mailbox_swap(hif_sc); |
| 281 | } |
| 282 | |
| 283 | void hif_claim_device(struct hif_opaque_softc *hif_ctx) |
| 284 | { |
| 285 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 286 | hif_sc->bus_ops.hif_claim_device(hif_sc); |
| 287 | } |
| 288 | |
| 289 | void hif_shutdown_device(struct hif_opaque_softc *hif_ctx) |
| 290 | { |
| 291 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 292 | hif_sc->bus_ops.hif_shutdown_device(hif_sc); |
| 293 | } |
| 294 | |
| 295 | void hif_stop(struct hif_opaque_softc *hif_ctx) |
| 296 | { |
| 297 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 298 | hif_sc->bus_ops.hif_stop(hif_sc); |
| 299 | } |
| 300 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 301 | void hif_cancel_deferred_target_sleep(struct hif_softc *hif_sc) |
| 302 | { |
| 303 | return hif_sc->bus_ops.hif_cancel_deferred_target_sleep(hif_sc); |
| 304 | } |
| 305 | |
Houston Hoffman | 8f239f6 | 2016-03-14 21:12:05 -0700 | [diff] [blame] | 306 | void hif_irq_enable(struct hif_softc *hif_sc, int irq_id) |
| 307 | { |
| 308 | hif_sc->bus_ops.hif_irq_enable(hif_sc, irq_id); |
| 309 | } |
| 310 | |
Venkateswara Swamy Bandaru | 31108f3 | 2016-08-08 18:04:29 +0530 | [diff] [blame] | 311 | void hif_grp_irq_enable(struct hif_softc *hif_sc, uint32_t grp_id) |
| 312 | { |
| 313 | hif_sc->bus_ops.hif_grp_irq_enable(hif_sc, grp_id); |
| 314 | } |
| 315 | |
Houston Hoffman | 8f239f6 | 2016-03-14 21:12:05 -0700 | [diff] [blame] | 316 | void hif_irq_disable(struct hif_softc *hif_sc, int irq_id) |
| 317 | { |
| 318 | hif_sc->bus_ops.hif_irq_disable(hif_sc, irq_id); |
| 319 | } |
Houston Hoffman | 3c017e7 | 2016-03-14 21:12:11 -0700 | [diff] [blame] | 320 | |
Venkateswara Swamy Bandaru | 31108f3 | 2016-08-08 18:04:29 +0530 | [diff] [blame] | 321 | void hif_grp_irq_disable(struct hif_softc *hif_sc, uint32_t grp_id) |
| 322 | { |
| 323 | hif_sc->bus_ops.hif_grp_irq_disable(hif_sc, grp_id); |
| 324 | } |
| 325 | |
Venkateswara Swamy Bandaru | 6182494 | 2017-04-12 12:31:59 +0530 | [diff] [blame^] | 326 | int hif_grp_irq_configure(struct hif_softc *hif_sc) |
| 327 | { |
| 328 | return hif_sc->bus_ops.hif_grp_irq_configure(hif_sc); |
| 329 | } |
| 330 | |
Houston Hoffman | 3c017e7 | 2016-03-14 21:12:11 -0700 | [diff] [blame] | 331 | int hif_dump_registers(struct hif_opaque_softc *hif_hdl) |
| 332 | { |
| 333 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
| 334 | return hif_sc->bus_ops.hif_dump_registers(hif_sc); |
| 335 | } |
Houston Hoffman | b4149dd | 2016-03-23 15:55:41 -0700 | [diff] [blame] | 336 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 337 | void hif_dump_target_memory(struct hif_opaque_softc *hif_hdl, |
| 338 | void *ramdump_base, |
| 339 | uint32_t address, uint32_t size) |
| 340 | { |
| 341 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
| 342 | hif_sc->bus_ops.hif_dump_target_memory(hif_sc, ramdump_base, |
| 343 | address, size); |
| 344 | } |
| 345 | |
| 346 | void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_hdl, |
| 347 | qdf_dma_addr_t *ce_sr_base_paddr, |
| 348 | uint32_t *ce_sr_ring_size, |
| 349 | qdf_dma_addr_t *ce_reg_paddr) |
| 350 | { |
| 351 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
| 352 | hif_sc->bus_ops.hif_ipa_get_ce_resource(hif_sc, ce_sr_base_paddr, |
| 353 | ce_sr_ring_size, ce_reg_paddr); |
| 354 | } |
| 355 | |
| 356 | void hif_mask_interrupt_call(struct hif_opaque_softc *hif_hdl) |
| 357 | { |
| 358 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
| 359 | hif_sc->bus_ops.hif_mask_interrupt_call(hif_sc); |
| 360 | } |
| 361 | |
Nirav Shah | b70bd73 | 2016-05-25 14:31:51 +0530 | [diff] [blame] | 362 | void hif_display_bus_stats(struct hif_opaque_softc *scn) |
| 363 | { |
| 364 | struct hif_softc *hif_sc = HIF_GET_SOFTC(scn); |
| 365 | |
| 366 | hif_sc->bus_ops.hif_display_stats(hif_sc); |
| 367 | } |
| 368 | |
| 369 | void hif_clear_bus_stats(struct hif_opaque_softc *scn) |
| 370 | { |
| 371 | struct hif_softc *hif_sc = HIF_GET_SOFTC(scn); |
| 372 | |
| 373 | hif_sc->bus_ops.hif_clear_stats(hif_sc); |
| 374 | } |
| 375 | |
Houston Hoffman | b4149dd | 2016-03-23 15:55:41 -0700 | [diff] [blame] | 376 | /** |
| 377 | * hif_enable_power_management() - enable power management after driver load |
| 378 | * @hif_hdl: opaque pointer to the hif context |
| 379 | * is_packet_log_enabled: true if packet log is enabled |
| 380 | * |
| 381 | * Driver load and firmware download are done in a high performance mode. |
| 382 | * Enable power management after the driver is loaded. |
| 383 | * packet log can require fewer power management features to be enabled. |
| 384 | */ |
| 385 | void hif_enable_power_management(struct hif_opaque_softc *hif_hdl, |
| 386 | bool is_packet_log_enabled) |
| 387 | { |
| 388 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
| 389 | 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 | */ |
| 401 | void hif_disable_power_management(struct hif_opaque_softc *hif_hdl) |
| 402 | { |
| 403 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
| 404 | hif_sc->bus_ops.hif_disable_power_management(hif_sc); |
| 405 | } |
| 406 | |
Mohit Khanna | 1957ba9 | 2016-05-11 11:17:01 -0700 | [diff] [blame] | 407 | /** |
| 408 | * hif_set_bundle_mode() - enable bundling and set default rx bundle cnt |
| 409 | * @scn: pointer to hif_opaque_softc structure |
| 410 | * @enabled: flag to enable/disable bundling |
| 411 | * @rx_bundle_cnt: bundle count to be used for RX |
| 412 | * |
| 413 | * Return: none |
| 414 | */ |
| 415 | void hif_set_bundle_mode(struct hif_opaque_softc *scn, bool enabled, |
| 416 | int rx_bundle_cnt) |
| 417 | { |
| 418 | struct hif_softc *hif_sc = HIF_GET_SOFTC(scn); |
| 419 | hif_sc->bus_ops.hif_set_bundle_mode(hif_sc, enabled, rx_bundle_cnt); |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * hif_bus_reset_resume() - resume the bus after reset |
| 424 | * @scn: struct hif_opaque_softc |
| 425 | * |
| 426 | * This function is called to tell the driver that USB device has been resumed |
| 427 | * and it has also been reset. The driver should redo any necessary |
| 428 | * initialization. This function resets WLAN SOC. |
| 429 | * |
| 430 | * Return: int 0 for success, non zero for failure |
| 431 | */ |
| 432 | int hif_bus_reset_resume(struct hif_opaque_softc *scn) |
| 433 | |
| 434 | { |
| 435 | struct hif_softc *hif_sc = HIF_GET_SOFTC(scn); |
| 436 | return hif_sc->bus_ops.hif_bus_reset_resume(hif_sc); |
| 437 | } |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 438 | |
| 439 | int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx) |
| 440 | { |
| 441 | struct hif_softc *scn; |
| 442 | int i; |
| 443 | |
| 444 | scn = HIF_GET_SOFTC(hif_ctx); |
| 445 | if (!scn) { |
| 446 | QDF_BUG(0); |
| 447 | return -EINVAL; |
| 448 | } |
| 449 | |
| 450 | for (i = 0; i < scn->ce_count; ++i) |
| 451 | disable_irq(scn->bus_ops.hif_map_ce_to_irq(scn, i)); |
| 452 | |
| 453 | return 0; |
| 454 | } |
| 455 | |
| 456 | int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx) |
| 457 | { |
| 458 | struct hif_softc *scn; |
| 459 | int i; |
| 460 | |
| 461 | scn = HIF_GET_SOFTC(hif_ctx); |
| 462 | if (!scn) { |
| 463 | QDF_BUG(0); |
| 464 | return -EINVAL; |
| 465 | } |
| 466 | |
| 467 | for (i = 0; i < scn->ce_count; ++i) |
| 468 | enable_irq(scn->bus_ops.hif_map_ce_to_irq(scn, i)); |
| 469 | |
| 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx) |
| 474 | { |
| 475 | int errno; |
| 476 | struct hif_softc *scn; |
| 477 | uint8_t wake_ce_id; |
| 478 | |
| 479 | scn = HIF_GET_SOFTC(hif_ctx); |
| 480 | if (!scn) { |
| 481 | QDF_BUG(0); |
| 482 | return -EINVAL; |
| 483 | } |
| 484 | |
| 485 | errno = hif_get_wake_ce_id(scn, &wake_ce_id); |
| 486 | if (errno) { |
| 487 | HIF_ERROR("%s: failed to get wake CE Id: %d", __func__, errno); |
| 488 | return errno; |
| 489 | } |
| 490 | |
| 491 | disable_irq(scn->bus_ops.hif_map_ce_to_irq(scn, wake_ce_id)); |
| 492 | |
| 493 | return 0; |
| 494 | } |
| 495 | |
| 496 | int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx) |
| 497 | { |
| 498 | int errno; |
| 499 | struct hif_softc *scn; |
| 500 | uint8_t wake_ce_id; |
| 501 | |
| 502 | scn = HIF_GET_SOFTC(hif_ctx); |
| 503 | if (!scn) { |
| 504 | QDF_BUG(0); |
| 505 | return -EINVAL; |
| 506 | } |
| 507 | |
| 508 | errno = hif_get_wake_ce_id(scn, &wake_ce_id); |
| 509 | if (errno) { |
| 510 | HIF_ERROR("%s: failed to get wake CE Id: %d", __func__, errno); |
| 511 | return errno; |
| 512 | } |
| 513 | |
| 514 | enable_irq(scn->bus_ops.hif_map_ce_to_irq(scn, wake_ce_id)); |
| 515 | |
| 516 | return 0; |
| 517 | } |