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; |
Dustin Brown | 07d24be | 2017-04-03 10:20:49 -0700 | [diff] [blame] | 67 | 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] | 68 | bus_ops->hif_grp_irq_configure = &hif_dummy_grp_irq_configure; |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 69 | } |
| 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 | */ |
| 82 | static 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 Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 99 | * hif_bus_get_context_size - API to return size of the bus specific structure |
| 100 | * |
| 101 | * Return: sizeof of hif_pci_softc |
| 102 | */ |
| 103 | int 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 Hoffman | 3db96a4 | 2016-05-05 19:54:39 -0700 | [diff] [blame] | 108 | case QDF_BUS_TYPE_AHB: |
| 109 | return hif_ahb_get_context_size(); |
Houston Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 110 | case QDF_BUS_TYPE_SNOC: |
| 111 | return hif_snoc_get_context_size(); |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 112 | case QDF_BUS_TYPE_SDIO: |
| 113 | return hif_sdio_get_context_size(); |
Mohit Khanna | 1957ba9 | 2016-05-11 11:17:01 -0700 | [diff] [blame] | 114 | case QDF_BUS_TYPE_USB: |
| 115 | return hif_usb_get_context_size(); |
Houston Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 116 | default: |
| 117 | return 0; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | /** |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 122 | * 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 | */ |
| 128 | QDF_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 Hoffman | 54ef87d | 2016-03-14 21:11:58 -0700 | [diff] [blame] | 137 | status = hif_initialize_pci_ops(hif_sc); |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 138 | break; |
| 139 | case QDF_BUS_TYPE_SNOC: |
| 140 | status = hif_initialize_snoc_ops(&hif_sc->bus_ops); |
| 141 | break; |
Houston Hoffman | 3db96a4 | 2016-05-05 19:54:39 -0700 | [diff] [blame] | 142 | case QDF_BUS_TYPE_AHB: |
| 143 | status = hif_initialize_ahb_ops(&hif_sc->bus_ops); |
| 144 | break; |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 145 | case QDF_BUS_TYPE_SDIO: |
| 146 | status = hif_initialize_sdio_ops(hif_sc); |
Yu Wang | 1e487a5 | 2017-02-07 20:10:42 +0800 | [diff] [blame] | 147 | break; |
Mohit Khanna | 1957ba9 | 2016-05-11 11:17:01 -0700 | [diff] [blame] | 148 | case QDF_BUS_TYPE_USB: |
| 149 | status = hif_initialize_usb_ops(&hif_sc->bus_ops); |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 150 | break; |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 151 | 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 | */ |
| 172 | void hif_bus_close(struct hif_softc *hif_sc) |
| 173 | { |
| 174 | hif_sc->bus_ops.hif_bus_close(hif_sc); |
| 175 | } |
Houston Hoffman | 4ca03b6 | 2016-03-14 21:11:51 -0700 | [diff] [blame] | 176 | |
| 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 | */ |
| 184 | void 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 | |
| 190 | void hif_reset_soc(struct hif_opaque_softc *hif_ctx) |
| 191 | { |
| 192 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 193 | |
Houston Hoffman | 4ca03b6 | 2016-03-14 21:11:51 -0700 | [diff] [blame] | 194 | hif_sc->bus_ops.hif_reset_soc(hif_sc); |
| 195 | } |
| 196 | |
Houston Hoffman | cbcd839 | 2017-02-08 17:43:13 -0800 | [diff] [blame] | 197 | int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx) |
| 198 | { |
| 199 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 200 | |
Houston Hoffman | cbcd839 | 2017-02-08 17:43:13 -0800 | [diff] [blame] | 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); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 207 | |
Houston Hoffman | cbcd839 | 2017-02-08 17:43:13 -0800 | [diff] [blame] | 208 | return hif_sc->bus_ops.hif_bus_late_resume(hif_sc); |
| 209 | } |
| 210 | |
Houston Hoffman | 4ca03b6 | 2016-03-14 21:11:51 -0700 | [diff] [blame] | 211 | int hif_bus_suspend(struct hif_opaque_softc *hif_ctx) |
| 212 | { |
| 213 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 214 | |
Houston Hoffman | 4ca03b6 | 2016-03-14 21:11:51 -0700 | [diff] [blame] | 215 | return hif_sc->bus_ops.hif_bus_suspend(hif_sc); |
| 216 | } |
| 217 | |
| 218 | int hif_bus_resume(struct hif_opaque_softc *hif_ctx) |
| 219 | { |
| 220 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 221 | |
Houston Hoffman | 4ca03b6 | 2016-03-14 21:11:51 -0700 | [diff] [blame] | 222 | return hif_sc->bus_ops.hif_bus_resume(hif_sc); |
| 223 | } |
| 224 | |
Houston Hoffman | 7fdff0c | 2016-08-29 12:31:58 -0700 | [diff] [blame] | 225 | int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx) |
| 226 | { |
| 227 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 228 | |
Houston Hoffman | 7fdff0c | 2016-08-29 12:31:58 -0700 | [diff] [blame] | 229 | return hif_sc->bus_ops.hif_bus_suspend_noirq(hif_sc); |
| 230 | } |
| 231 | |
| 232 | int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx) |
| 233 | { |
| 234 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 235 | |
Houston Hoffman | 7fdff0c | 2016-08-29 12:31:58 -0700 | [diff] [blame] | 236 | return hif_sc->bus_ops.hif_bus_resume_noirq(hif_sc); |
| 237 | } |
| 238 | |
Houston Hoffman | 4ca03b6 | 2016-03-14 21:11:51 -0700 | [diff] [blame] | 239 | int 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 Hoffman | 8f239f6 | 2016-03-14 21:12:05 -0700 | [diff] [blame] | 245 | |
| 246 | void hif_disable_isr(struct hif_opaque_softc *hif_hdl) |
| 247 | { |
| 248 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 249 | |
Houston Hoffman | 8f239f6 | 2016-03-14 21:12:05 -0700 | [diff] [blame] | 250 | hif_sc->bus_ops.hif_disable_isr(hif_sc); |
| 251 | } |
| 252 | |
| 253 | void hif_nointrs(struct hif_softc *hif_sc) |
| 254 | { |
| 255 | hif_sc->bus_ops.hif_nointrs(hif_sc); |
| 256 | } |
| 257 | |
| 258 | QDF_STATUS hif_enable_bus(struct hif_softc *hif_sc, struct device *dev, |
Manikandan Mohan | bd0ef8a | 2017-04-10 13:10:21 -0700 | [diff] [blame] | 259 | void *bdev, const struct hif_bus_id *bid, |
Houston Hoffman | 8f239f6 | 2016-03-14 21:12:05 -0700 | [diff] [blame] | 260 | enum hif_enable_type type) |
| 261 | { |
| 262 | return hif_sc->bus_ops.hif_enable_bus(hif_sc, dev, bdev, bid, type); |
| 263 | } |
| 264 | |
| 265 | void hif_disable_bus(struct hif_softc *hif_sc) |
| 266 | { |
| 267 | hif_sc->bus_ops.hif_disable_bus(hif_sc); |
| 268 | } |
| 269 | |
| 270 | int hif_bus_configure(struct hif_softc *hif_sc) |
| 271 | { |
| 272 | return hif_sc->bus_ops.hif_bus_configure(hif_sc); |
| 273 | } |
| 274 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 275 | QDF_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 Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 279 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 280 | return hif_sc->bus_ops.hif_get_config_item(hif_sc, opcode, config, |
| 281 | config_len); |
| 282 | } |
| 283 | |
| 284 | void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx) |
| 285 | { |
| 286 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 287 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 288 | hif_sc->bus_ops.hif_set_mailbox_swap(hif_sc); |
| 289 | } |
| 290 | |
| 291 | void hif_claim_device(struct hif_opaque_softc *hif_ctx) |
| 292 | { |
| 293 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 294 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 295 | hif_sc->bus_ops.hif_claim_device(hif_sc); |
| 296 | } |
| 297 | |
| 298 | void hif_shutdown_device(struct hif_opaque_softc *hif_ctx) |
| 299 | { |
| 300 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 301 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 302 | hif_sc->bus_ops.hif_shutdown_device(hif_sc); |
| 303 | } |
| 304 | |
| 305 | void hif_stop(struct hif_opaque_softc *hif_ctx) |
| 306 | { |
| 307 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 308 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 309 | hif_sc->bus_ops.hif_stop(hif_sc); |
| 310 | } |
| 311 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 312 | void 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 Hoffman | 8f239f6 | 2016-03-14 21:12:05 -0700 | [diff] [blame] | 317 | void 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 | |
| 322 | void 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 Hoffman | 3c017e7 | 2016-03-14 21:12:11 -0700 | [diff] [blame] | 326 | |
Houston Hoffman | def86a3 | 2017-04-21 20:23:45 -0700 | [diff] [blame] | 327 | int hif_grp_irq_configure(struct hif_softc *hif_sc, |
| 328 | struct hif_exec_context *hif_exec) |
Venkateswara Swamy Bandaru | 31108f3 | 2016-08-08 18:04:29 +0530 | [diff] [blame] | 329 | { |
Houston Hoffman | def86a3 | 2017-04-21 20:23:45 -0700 | [diff] [blame] | 330 | return hif_sc->bus_ops.hif_grp_irq_configure(hif_sc, hif_exec); |
Venkateswara Swamy Bandaru | 6182494 | 2017-04-12 12:31:59 +0530 | [diff] [blame] | 331 | } |
| 332 | |
Houston Hoffman | 3c017e7 | 2016-03-14 21:12:11 -0700 | [diff] [blame] | 333 | int hif_dump_registers(struct hif_opaque_softc *hif_hdl) |
| 334 | { |
| 335 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 336 | |
Houston Hoffman | 3c017e7 | 2016-03-14 21:12:11 -0700 | [diff] [blame] | 337 | return hif_sc->bus_ops.hif_dump_registers(hif_sc); |
| 338 | } |
Houston Hoffman | b4149dd | 2016-03-23 15:55:41 -0700 | [diff] [blame] | 339 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 340 | void 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 Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 345 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 346 | hif_sc->bus_ops.hif_dump_target_memory(hif_sc, ramdump_base, |
| 347 | address, size); |
| 348 | } |
| 349 | |
| 350 | void 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 Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 356 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 357 | 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 | |
| 361 | void hif_mask_interrupt_call(struct hif_opaque_softc *hif_hdl) |
| 362 | { |
| 363 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 364 | |
Nirav Shah | 3573f95 | 2016-05-12 18:37:03 +0530 | [diff] [blame] | 365 | hif_sc->bus_ops.hif_mask_interrupt_call(hif_sc); |
| 366 | } |
| 367 | |
Nirav Shah | b70bd73 | 2016-05-25 14:31:51 +0530 | [diff] [blame] | 368 | void 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 | |
| 375 | void 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 Hoffman | b4149dd | 2016-03-23 15:55:41 -0700 | [diff] [blame] | 382 | /** |
| 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 | */ |
| 391 | void 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 Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 395 | |
Houston Hoffman | b4149dd | 2016-03-23 15:55:41 -0700 | [diff] [blame] | 396 | 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 | */ |
| 408 | void hif_disable_power_management(struct hif_opaque_softc *hif_hdl) |
| 409 | { |
| 410 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_hdl); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 411 | |
Houston Hoffman | b4149dd | 2016-03-23 15:55:41 -0700 | [diff] [blame] | 412 | hif_sc->bus_ops.hif_disable_power_management(hif_sc); |
| 413 | } |
| 414 | |
Mohit Khanna | 1957ba9 | 2016-05-11 11:17:01 -0700 | [diff] [blame] | 415 | /** |
| 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 | */ |
| 423 | void 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 Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 427 | |
Mohit Khanna | 1957ba9 | 2016-05-11 11:17:01 -0700 | [diff] [blame] | 428 | 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 | */ |
| 441 | int hif_bus_reset_resume(struct hif_opaque_softc *scn) |
Mohit Khanna | 1957ba9 | 2016-05-11 11:17:01 -0700 | [diff] [blame] | 442 | { |
| 443 | struct hif_softc *hif_sc = HIF_GET_SOFTC(scn); |
Manikandan Mohan | 8e03135 | 2017-04-07 18:32:02 -0700 | [diff] [blame] | 444 | |
Mohit Khanna | 1957ba9 | 2016-05-11 11:17:01 -0700 | [diff] [blame] | 445 | return hif_sc->bus_ops.hif_bus_reset_resume(hif_sc); |
| 446 | } |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 447 | |
| 448 | int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx) |
| 449 | { |
| 450 | struct hif_softc *scn; |
| 451 | int i; |
| 452 | |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 453 | QDF_BUG(hif_ctx); |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 454 | scn = HIF_GET_SOFTC(hif_ctx); |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 455 | if (!scn) |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 456 | return -EINVAL; |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 457 | |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 458 | /* 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 Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 466 | |
| 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx) |
| 471 | { |
| 472 | struct hif_softc *scn; |
| 473 | int i; |
| 474 | |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 475 | QDF_BUG(hif_ctx); |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 476 | scn = HIF_GET_SOFTC(hif_ctx); |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 477 | if (!scn) |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 478 | return -EINVAL; |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 479 | |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 480 | /* 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 Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 488 | |
| 489 | return 0; |
| 490 | } |
| 491 | |
| 492 | int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx) |
| 493 | { |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 494 | struct hif_softc *scn; |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 495 | |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 496 | QDF_BUG(hif_ctx); |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 497 | scn = HIF_GET_SOFTC(hif_ctx); |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 498 | if (!scn) |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 499 | return -EINVAL; |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 500 | |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 501 | disable_irq(scn->wake_irq); |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 502 | |
| 503 | return 0; |
| 504 | } |
| 505 | |
| 506 | int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx) |
| 507 | { |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 508 | struct hif_softc *scn; |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 509 | |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 510 | QDF_BUG(hif_ctx); |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 511 | scn = HIF_GET_SOFTC(hif_ctx); |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 512 | if (!scn) |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 513 | return -EINVAL; |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 514 | |
Dustin Brown | 2af3d67 | 2017-05-30 16:14:01 -0700 | [diff] [blame^] | 515 | enable_irq(scn->wake_irq); |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 516 | |
| 517 | return 0; |
| 518 | } |