Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1 | /* |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [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 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 28 | #include "targcfg.h" |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 29 | #include "qdf_lock.h" |
| 30 | #include "qdf_status.h" |
| 31 | #include "qdf_status.h" |
| 32 | #include <qdf_atomic.h> /* qdf_atomic_read */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 33 | #include <targaddrs.h> |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 34 | #include "hif_io32.h" |
| 35 | #include <hif.h> |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 36 | #include "regtable.h" |
| 37 | #define ATH_MODULE_NAME hif |
| 38 | #include <a_debug.h> |
| 39 | #include "hif_main.h" |
| 40 | #include "hif_hw_version.h" |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 41 | #if defined(HIF_PCI) || defined(HIF_SNOC) || defined(HIF_AHB) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 42 | #include "ce_tasklet.h" |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 43 | #endif |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 44 | #include "qdf_trace.h" |
| 45 | #include "qdf_status.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 46 | #include "hif_debug.h" |
| 47 | #include "mp_dev.h" |
Mohit Khanna | 440c529 | 2016-05-12 11:05:06 -0700 | [diff] [blame] | 48 | #include "ce_api.h" |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 49 | #ifdef QCA_WIFI_QCA8074 |
| 50 | #include "hal_api.h" |
| 51 | #endif |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 52 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 53 | void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t cmd_id, bool start) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 54 | { |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 55 | hif_trigger_dump(hif_ctx, cmd_id, start); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 56 | } |
| 57 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 58 | /** |
| 59 | * hif_get_target_id(): hif_get_target_id |
| 60 | * |
| 61 | * Return the virtual memory base address to the caller |
| 62 | * |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 63 | * @scn: hif_softc |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 64 | * |
| 65 | * Return: A_target_id_t |
| 66 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 67 | A_target_id_t hif_get_target_id(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 68 | { |
| 69 | return scn->mem; |
| 70 | } |
| 71 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 72 | /** |
| 73 | * hif_get_targetdef(): hif_get_targetdef |
| 74 | * @scn: scn |
| 75 | * |
| 76 | * Return: void * |
| 77 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 78 | void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 79 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 80 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 81 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 82 | return scn->targetdef; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * hif_vote_link_down(): unvote for link up |
| 87 | * |
| 88 | * Call hif_vote_link_down to release a previous request made using |
| 89 | * hif_vote_link_up. A hif_vote_link_down call should only be made |
| 90 | * after a corresponding hif_vote_link_up, otherwise you could be |
| 91 | * negating a vote from another source. When no votes are present |
| 92 | * hif will not guarantee the linkstate after hif_bus_suspend. |
| 93 | * |
| 94 | * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread |
| 95 | * and initialization deinitialization sequencences. |
| 96 | * |
| 97 | * Return: n/a |
| 98 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 99 | void hif_vote_link_down(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 100 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 101 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 102 | QDF_BUG(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 103 | |
| 104 | scn->linkstate_vote--; |
| 105 | if (scn->linkstate_vote == 0) |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 106 | hif_bus_prevent_linkdown(scn, false); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /** |
| 110 | * hif_vote_link_up(): vote to prevent bus from suspending |
| 111 | * |
| 112 | * Makes hif guarantee that fw can message the host normally |
| 113 | * durring suspend. |
| 114 | * |
| 115 | * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread |
| 116 | * and initialization deinitialization sequencences. |
| 117 | * |
| 118 | * Return: n/a |
| 119 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 120 | void hif_vote_link_up(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 121 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 122 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 123 | QDF_BUG(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 124 | |
| 125 | scn->linkstate_vote++; |
| 126 | if (scn->linkstate_vote == 1) |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 127 | hif_bus_prevent_linkdown(scn, true); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | /** |
| 131 | * hif_can_suspend_link(): query if hif is permitted to suspend the link |
| 132 | * |
| 133 | * Hif will ensure that the link won't be suspended if the upperlayers |
| 134 | * don't want it to. |
| 135 | * |
| 136 | * SYNCHRONIZATION: MC thread is stopped before bus suspend thus |
| 137 | * we don't need extra locking to ensure votes dont change while |
| 138 | * we are in the process of suspending or resuming. |
| 139 | * |
| 140 | * Return: false if hif will guarantee link up durring suspend. |
| 141 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 142 | bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 143 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 144 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 145 | QDF_BUG(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 146 | |
| 147 | return scn->linkstate_vote == 0; |
| 148 | } |
| 149 | |
Houston Hoffman | 4f52998 | 2016-05-05 16:11:04 -0700 | [diff] [blame] | 150 | #ifndef CONFIG_WIN |
| 151 | #define QCA9984_HOST_INTEREST_ADDRESS -1 |
| 152 | #define QCA9888_HOST_INTEREST_ADDRESS -1 |
| 153 | #define IPQ4019_HOST_INTEREST_ADDRESS -1 |
| 154 | #endif |
| 155 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 156 | /** |
| 157 | * hif_hia_item_address(): hif_hia_item_address |
| 158 | * @target_type: target_type |
| 159 | * @item_offset: item_offset |
| 160 | * |
| 161 | * Return: n/a |
| 162 | */ |
| 163 | uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset) |
| 164 | { |
| 165 | switch (target_type) { |
| 166 | case TARGET_TYPE_AR6002: |
| 167 | return AR6002_HOST_INTEREST_ADDRESS + item_offset; |
| 168 | case TARGET_TYPE_AR6003: |
| 169 | return AR6003_HOST_INTEREST_ADDRESS + item_offset; |
| 170 | case TARGET_TYPE_AR6004: |
| 171 | return AR6004_HOST_INTEREST_ADDRESS + item_offset; |
| 172 | case TARGET_TYPE_AR6006: |
| 173 | return AR6006_HOST_INTEREST_ADDRESS + item_offset; |
| 174 | case TARGET_TYPE_AR9888: |
| 175 | return AR9888_HOST_INTEREST_ADDRESS + item_offset; |
| 176 | case TARGET_TYPE_AR6320: |
| 177 | case TARGET_TYPE_AR6320V2: |
| 178 | return AR6320_HOST_INTEREST_ADDRESS + item_offset; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 179 | case TARGET_TYPE_ADRASTEA: |
| 180 | /* ADRASTEA doesn't have a host interest address */ |
| 181 | ASSERT(0); |
| 182 | return 0; |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 183 | case TARGET_TYPE_AR900B: |
| 184 | return AR900B_HOST_INTEREST_ADDRESS + item_offset; |
| 185 | case TARGET_TYPE_QCA9984: |
| 186 | return QCA9984_HOST_INTEREST_ADDRESS + item_offset; |
| 187 | case TARGET_TYPE_QCA9888: |
| 188 | return QCA9888_HOST_INTEREST_ADDRESS + item_offset; |
| 189 | case TARGET_TYPE_IPQ4019: |
| 190 | return IPQ4019_HOST_INTEREST_ADDRESS + item_offset; |
| 191 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 192 | default: |
| 193 | ASSERT(0); |
| 194 | return 0; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * hif_max_num_receives_reached() - check max receive is reached |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 200 | * @scn: HIF Context |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 201 | * @count: unsigned int. |
| 202 | * |
| 203 | * Output check status as bool |
| 204 | * |
| 205 | * Return: bool |
| 206 | */ |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 207 | bool hif_max_num_receives_reached(struct hif_softc *scn, unsigned int count) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 208 | { |
Houston Hoffman | 75ef5a5 | 2016-04-14 17:15:49 -0700 | [diff] [blame] | 209 | if (QDF_IS_EPPING_ENABLED(hif_get_conparam(scn))) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 210 | return count > 120; |
| 211 | else |
| 212 | return count > MAX_NUM_OF_RECEIVES; |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * init_buffer_count() - initial buffer count |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 217 | * @maxSize: qdf_size_t |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 218 | * |
| 219 | * routine to modify the initial buffer count to be allocated on an os |
| 220 | * platform basis. Platform owner will need to modify this as needed |
| 221 | * |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 222 | * Return: qdf_size_t |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 223 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 224 | qdf_size_t init_buffer_count(qdf_size_t maxSize) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 225 | { |
| 226 | return maxSize; |
| 227 | } |
| 228 | |
| 229 | /** |
Nirav Shah | d7f9159 | 2016-04-21 14:18:43 +0530 | [diff] [blame] | 230 | * hif_save_htc_htt_config_endpoint() - save htt_tx_endpoint |
| 231 | * @hif_ctx: hif context |
| 232 | * @htc_htt_tx_endpoint: htt_tx_endpoint |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 233 | * |
| 234 | * Return: void |
| 235 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 236 | void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx, |
Nirav Shah | d7f9159 | 2016-04-21 14:18:43 +0530 | [diff] [blame] | 237 | int htc_htt_tx_endpoint) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 238 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 239 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 240 | |
| 241 | if (!scn) { |
| 242 | HIF_ERROR("%s: error: scn or scn->hif_sc is NULL!", |
| 243 | __func__); |
| 244 | return; |
| 245 | } |
| 246 | |
Nirav Shah | d7f9159 | 2016-04-21 14:18:43 +0530 | [diff] [blame] | 247 | scn->htc_htt_tx_endpoint = htc_htt_tx_endpoint; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 248 | } |
| 249 | |
Houston Hoffman | ec93ab0 | 2016-05-03 20:09:55 -0700 | [diff] [blame] | 250 | static const struct qwlan_hw qwlan_hw_list[] = { |
| 251 | { |
| 252 | .id = AR6320_REV1_VERSION, |
| 253 | .subid = 0, |
| 254 | .name = "QCA6174_REV1", |
| 255 | }, |
| 256 | { |
| 257 | .id = AR6320_REV1_1_VERSION, |
| 258 | .subid = 0x1, |
| 259 | .name = "QCA6174_REV1_1", |
| 260 | }, |
| 261 | { |
| 262 | .id = AR6320_REV1_3_VERSION, |
| 263 | .subid = 0x2, |
| 264 | .name = "QCA6174_REV1_3", |
| 265 | }, |
| 266 | { |
| 267 | .id = AR6320_REV2_1_VERSION, |
| 268 | .subid = 0x4, |
| 269 | .name = "QCA6174_REV2_1", |
| 270 | }, |
| 271 | { |
| 272 | .id = AR6320_REV2_1_VERSION, |
| 273 | .subid = 0x5, |
| 274 | .name = "QCA6174_REV2_2", |
| 275 | }, |
| 276 | { |
| 277 | .id = AR6320_REV3_VERSION, |
| 278 | .subid = 0x6, |
| 279 | .name = "QCA6174_REV2.3", |
| 280 | }, |
| 281 | { |
| 282 | .id = AR6320_REV3_VERSION, |
| 283 | .subid = 0x8, |
| 284 | .name = "QCA6174_REV3", |
| 285 | }, |
| 286 | { |
| 287 | .id = AR6320_REV3_VERSION, |
| 288 | .subid = 0x9, |
| 289 | .name = "QCA6174_REV3_1", |
| 290 | }, |
| 291 | { |
| 292 | .id = AR6320_REV3_2_VERSION, |
| 293 | .subid = 0xA, |
| 294 | .name = "AR6320_REV3_2_VERSION", |
Houston Hoffman | cd0884a | 2016-08-24 15:30:09 -0700 | [diff] [blame] | 295 | }, |
| 296 | { |
| 297 | .id = WCN3990_v1, |
| 298 | .subid = 0x0, |
| 299 | .name = "WCN3990_V1", |
Houston Hoffman | dd4da48 | 2016-10-17 12:41:45 -0700 | [diff] [blame^] | 300 | }, |
| 301 | { |
| 302 | .id = WCN3990_v2, |
| 303 | .subid = 0x0, |
| 304 | .name = "WCN3990_V2", |
Houston Hoffman | ec93ab0 | 2016-05-03 20:09:55 -0700 | [diff] [blame] | 305 | } |
| 306 | }; |
| 307 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 308 | /** |
| 309 | * hif_get_hw_name(): get a human readable name for the hardware |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 310 | * @info: Target Info |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 311 | * |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 312 | * Return: human readable name for the underlying wifi hardware. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 313 | */ |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 314 | static const char *hif_get_hw_name(struct hif_target_info *info) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 315 | { |
| 316 | int i; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 317 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 318 | for (i = 0; i < ARRAY_SIZE(qwlan_hw_list); i++) { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 319 | if (info->target_version == qwlan_hw_list[i].id && |
| 320 | info->target_revision == qwlan_hw_list[i].subid) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 321 | return qwlan_hw_list[i].name; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | return "Unknown Device"; |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * hif_get_hw_info(): hif_get_hw_info |
| 330 | * @scn: scn |
| 331 | * @version: version |
| 332 | * @revision: revision |
| 333 | * |
| 334 | * Return: n/a |
| 335 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 336 | void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 337 | const char **target_name) |
| 338 | { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 339 | struct hif_target_info *info = hif_get_target_info_handle(scn); |
Mohit Khanna | 440c529 | 2016-05-12 11:05:06 -0700 | [diff] [blame] | 340 | struct hif_softc *sc = HIF_GET_SOFTC(scn); |
| 341 | |
| 342 | if (sc->bus_type == QDF_BUS_TYPE_USB) |
| 343 | hif_usb_get_hw_info(sc); |
| 344 | |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 345 | *version = info->target_version; |
| 346 | *revision = info->target_revision; |
| 347 | *target_name = hif_get_hw_name(info); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | /** |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 351 | * hif_get_dev_ba(): API to get device base address. |
| 352 | * @scn: scn |
| 353 | * @version: version |
| 354 | * @revision: revision |
| 355 | * |
| 356 | * Return: n/a |
| 357 | */ |
| 358 | void *hif_get_dev_ba(struct hif_opaque_softc *hif_handle) |
| 359 | { |
| 360 | struct hif_softc *scn = (struct hif_softc *)hif_handle; |
| 361 | |
| 362 | return scn->mem; |
| 363 | } |
| 364 | /** |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 365 | * hif_open(): hif_open |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 366 | * @qdf_ctx: QDF Context |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 367 | * @mode: Driver Mode |
| 368 | * @bus_type: Bus Type |
| 369 | * @cbk: CDS Callbacks |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 370 | * |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 371 | * API to open HIF Context |
| 372 | * |
| 373 | * Return: HIF Opaque Pointer |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 374 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 375 | struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode, |
| 376 | enum qdf_bus_type bus_type, |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 377 | struct hif_driver_state_callbacks *cbk) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 378 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 379 | struct hif_softc *scn; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 380 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Houston Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 381 | int bus_context_size = hif_bus_get_context_size(bus_type); |
| 382 | |
| 383 | if (bus_context_size == 0) { |
| 384 | HIF_ERROR("%s: context size 0 not allowed", __func__); |
| 385 | return NULL; |
| 386 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 387 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 388 | scn = (struct hif_softc *)qdf_mem_malloc(bus_context_size); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 389 | if (!scn) { |
| 390 | HIF_ERROR("%s: cannot alloc memory for HIF context of size:%d", |
| 391 | __func__, bus_context_size); |
| 392 | return GET_HIF_OPAQUE_HDL(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 393 | } |
| 394 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 395 | qdf_mem_zero(scn, bus_context_size); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 396 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 397 | scn->qdf_dev = qdf_ctx; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 398 | scn->hif_con_param = mode; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 399 | qdf_atomic_init(&scn->active_tasklet_cnt); |
Venkateswara Swamy Bandaru | 31108f3 | 2016-08-08 18:04:29 +0530 | [diff] [blame] | 400 | qdf_atomic_init(&scn->active_grp_tasklet_cnt); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 401 | qdf_atomic_init(&scn->link_suspended); |
| 402 | qdf_atomic_init(&scn->tasklet_from_intr); |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 403 | qdf_mem_copy(&scn->callbacks, cbk, sizeof(struct hif_driver_state_callbacks)); |
Houston Hoffman | 3db96a4 | 2016-05-05 19:54:39 -0700 | [diff] [blame] | 404 | scn->bus_type = bus_type; |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 405 | status = hif_bus_open(scn, bus_type); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 406 | if (status != QDF_STATUS_SUCCESS) { |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 407 | HIF_ERROR("%s: hif_bus_open error = %d, bus_type = %d", |
| 408 | __func__, status, bus_type); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 409 | qdf_mem_free(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 410 | scn = NULL; |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 411 | } |
| 412 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 413 | return GET_HIF_OPAQUE_HDL(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | /** |
| 417 | * hif_close(): hif_close |
| 418 | * @hif_ctx: hif_ctx |
| 419 | * |
| 420 | * Return: n/a |
| 421 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 422 | void hif_close(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 423 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 424 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 425 | |
| 426 | if (scn == NULL) { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 427 | HIF_ERROR("%s: hif_opaque_softc is NULL", __func__); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 428 | return; |
| 429 | } |
| 430 | |
| 431 | if (scn->athdiag_procfs_inited) { |
| 432 | athdiag_procfs_remove(); |
| 433 | scn->athdiag_procfs_inited = false; |
| 434 | } |
| 435 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 436 | hif_bus_close(scn); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 437 | qdf_mem_free(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 438 | } |
| 439 | |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 440 | static QDF_STATUS hif_hal_attach(struct hif_softc *scn) |
| 441 | { |
| 442 | #ifdef QCA_WIFI_QCA8074 |
| 443 | if (ce_srng_based(scn)) { |
| 444 | scn->hal_soc = hal_attach(scn, scn->qdf_dev); |
| 445 | if (scn->hal_soc == NULL) |
| 446 | return QDF_STATUS_E_FAILURE; |
| 447 | } |
| 448 | #endif |
| 449 | |
| 450 | return QDF_STATUS_SUCCESS; |
| 451 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 452 | /** |
| 453 | * hif_enable(): hif_enable |
| 454 | * @hif_ctx: hif_ctx |
| 455 | * @dev: dev |
| 456 | * @bdev: bus dev |
| 457 | * @bid: bus ID |
| 458 | * @bus_type: bus type |
| 459 | * @type: enable type |
| 460 | * |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 461 | * Return: QDF_STATUS |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 462 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 463 | QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 464 | void *bdev, const hif_bus_id *bid, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 465 | enum qdf_bus_type bus_type, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 466 | enum hif_enable_type type) |
| 467 | { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 468 | QDF_STATUS status; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 469 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 470 | |
| 471 | if (scn == NULL) { |
| 472 | HIF_ERROR("%s: hif_ctx = NULL", __func__); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 473 | return QDF_STATUS_E_NULL_VALUE; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 474 | } |
| 475 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 476 | status = hif_enable_bus(scn, dev, bdev, bid, type); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 477 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 478 | HIF_ERROR("%s: hif_enable_bus error = %d", |
| 479 | __func__, status); |
| 480 | return status; |
| 481 | } |
| 482 | |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 483 | status = hif_hal_attach(scn); |
| 484 | if (status != QDF_STATUS_SUCCESS) { |
| 485 | HIF_ERROR("%s: hal attach failed", __func__); |
| 486 | return status; |
| 487 | } |
| 488 | |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 489 | if (hif_bus_configure(scn)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 490 | HIF_ERROR("%s: Target probe failed.", __func__); |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 491 | hif_disable_bus(scn); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 492 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 493 | return status; |
| 494 | } |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 495 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 496 | /* |
| 497 | * Flag to avoid potential unallocated memory access from MSI |
| 498 | * interrupt handler which could get scheduled as soon as MSI |
| 499 | * is enabled, i.e to take care of the race due to the order |
| 500 | * in where MSI is enabled before the memory, that will be |
| 501 | * in interrupt handlers, is allocated. |
| 502 | */ |
| 503 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 504 | scn->hif_init_done = true; |
| 505 | |
Mohit Khanna | 440c529 | 2016-05-12 11:05:06 -0700 | [diff] [blame] | 506 | HIF_TRACE("%s: OK", __func__); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 507 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 508 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 509 | } |
| 510 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 511 | void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 512 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 513 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 514 | |
| 515 | if (!scn) |
| 516 | return; |
| 517 | |
| 518 | hif_nointrs(scn); |
| 519 | if (scn->hif_init_done == false) |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 520 | hif_shutdown_device(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 521 | else |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 522 | hif_stop(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 523 | |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 524 | hif_disable_bus(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 525 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 526 | hif_wlan_disable(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 527 | |
| 528 | scn->notice_send = false; |
| 529 | |
| 530 | HIF_INFO("%s: X", __func__); |
| 531 | } |
| 532 | |
Nirav Shah | b70bd73 | 2016-05-25 14:31:51 +0530 | [diff] [blame] | 533 | void hif_display_stats(struct hif_opaque_softc *hif_ctx) |
| 534 | { |
| 535 | hif_display_bus_stats(hif_ctx); |
| 536 | } |
| 537 | |
| 538 | void hif_clear_stats(struct hif_opaque_softc *hif_ctx) |
| 539 | { |
| 540 | hif_clear_bus_stats(hif_ctx); |
| 541 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 542 | |
| 543 | /** |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 544 | * hif_crash_shutdown_dump_bus_register() - dump bus registers |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 545 | * @hif_ctx: hif_ctx |
| 546 | * |
| 547 | * Return: n/a |
| 548 | */ |
| 549 | #if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \ |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 550 | && defined(DEBUG) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 551 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 552 | static void hif_crash_shutdown_dump_bus_register(void *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 553 | { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 554 | struct hif_opaque_softc *scn = hif_ctx; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 555 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 556 | if (hif_check_soc_status(scn)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 557 | return; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 558 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 559 | if (hif_dump_registers(scn)) |
| 560 | HIF_ERROR("Failed to dump bus registers!"); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | /** |
| 564 | * hif_crash_shutdown(): hif_crash_shutdown |
| 565 | * |
| 566 | * This function is called by the platform driver to dump CE registers |
| 567 | * |
| 568 | * @hif_ctx: hif_ctx |
| 569 | * |
| 570 | * Return: n/a |
| 571 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 572 | void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 573 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 574 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 575 | |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 576 | if (!hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 577 | return; |
| 578 | |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 579 | if (scn->bus_type == QDF_BUS_TYPE_SNOC) { |
| 580 | HIF_INFO_MED("%s: RAM dump disabled for bustype %d", |
| 581 | __func__, scn->bus_type); |
| 582 | return; |
| 583 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 584 | |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 585 | if (TARGET_STATUS_RESET == scn->target_status) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 586 | HIF_INFO_MED("%s: Target is already asserted, ignore!", |
| 587 | __func__); |
| 588 | return; |
| 589 | } |
| 590 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 591 | if (hif_is_load_or_unload_in_progress(scn)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 592 | HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__); |
| 593 | return; |
| 594 | } |
| 595 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 596 | hif_crash_shutdown_dump_bus_register(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 597 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 598 | if (ol_copy_ramdump(hif_ctx)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 599 | goto out; |
| 600 | |
| 601 | HIF_INFO_MED("%s: RAM dump collecting completed!", __func__); |
| 602 | |
| 603 | out: |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 604 | return; |
| 605 | } |
| 606 | #else |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 607 | void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 608 | { |
| 609 | HIF_INFO_MED("%s: Collecting target RAM dump disabled", |
| 610 | __func__); |
| 611 | return; |
| 612 | } |
| 613 | #endif /* TARGET_RAMDUMP_AFTER_KERNEL_PANIC */ |
| 614 | |
| 615 | #ifdef QCA_WIFI_3_0 |
| 616 | /** |
| 617 | * hif_check_fw_reg(): hif_check_fw_reg |
| 618 | * @scn: scn |
| 619 | * @state: |
| 620 | * |
| 621 | * Return: int |
| 622 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 623 | int hif_check_fw_reg(struct hif_opaque_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 624 | { |
| 625 | return 0; |
| 626 | } |
| 627 | #endif |
| 628 | |
| 629 | #ifdef IPA_OFFLOAD |
| 630 | /** |
| 631 | * hif_read_phy_mem_base(): hif_read_phy_mem_base |
| 632 | * @scn: scn |
| 633 | * @phy_mem_base: physical mem base |
| 634 | * |
| 635 | * Return: n/a |
| 636 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 637 | void hif_read_phy_mem_base(struct hif_softc *scn, qdf_dma_addr_t *phy_mem_base) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 638 | { |
| 639 | *phy_mem_base = scn->mem_pa; |
| 640 | } |
| 641 | #endif /* IPA_OFFLOAD */ |
| 642 | |
| 643 | /** |
| 644 | * hif_get_device_type(): hif_get_device_type |
| 645 | * @device_id: device_id |
| 646 | * @revision_id: revision_id |
| 647 | * @hif_type: returned hif_type |
| 648 | * @target_type: returned target_type |
| 649 | * |
| 650 | * Return: int |
| 651 | */ |
| 652 | int hif_get_device_type(uint32_t device_id, |
| 653 | uint32_t revision_id, |
| 654 | uint32_t *hif_type, uint32_t *target_type) |
| 655 | { |
| 656 | int ret = 0; |
| 657 | |
| 658 | switch (device_id) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 659 | case ADRASTEA_DEVICE_ID: |
| 660 | case ADRASTEA_DEVICE_ID_P2_E12: |
| 661 | |
| 662 | *hif_type = HIF_TYPE_ADRASTEA; |
| 663 | *target_type = TARGET_TYPE_ADRASTEA; |
| 664 | break; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 665 | |
| 666 | case AR9888_DEVICE_ID: |
| 667 | *hif_type = HIF_TYPE_AR9888; |
| 668 | *target_type = TARGET_TYPE_AR9888; |
| 669 | break; |
| 670 | |
| 671 | case AR6320_DEVICE_ID: |
| 672 | switch (revision_id) { |
| 673 | case AR6320_FW_1_1: |
| 674 | case AR6320_FW_1_3: |
| 675 | *hif_type = HIF_TYPE_AR6320; |
| 676 | *target_type = TARGET_TYPE_AR6320; |
| 677 | break; |
| 678 | |
| 679 | case AR6320_FW_2_0: |
| 680 | case AR6320_FW_3_0: |
| 681 | case AR6320_FW_3_2: |
| 682 | *hif_type = HIF_TYPE_AR6320V2; |
| 683 | *target_type = TARGET_TYPE_AR6320V2; |
| 684 | break; |
| 685 | |
| 686 | default: |
| 687 | HIF_ERROR("%s: error - dev_id = 0x%x, rev_id = 0x%x", |
| 688 | __func__, device_id, revision_id); |
| 689 | ret = -ENODEV; |
| 690 | goto end; |
| 691 | } |
| 692 | break; |
| 693 | |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 694 | case AR9887_DEVICE_ID: |
| 695 | *hif_type = HIF_TYPE_AR9888; |
| 696 | *target_type = TARGET_TYPE_AR9888; |
Houston Hoffman | c50572b | 2016-06-08 19:49:46 -0700 | [diff] [blame] | 697 | HIF_INFO(" *********** AR9887 **************"); |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 698 | break; |
| 699 | |
| 700 | case QCA9984_DEVICE_ID: |
| 701 | *hif_type = HIF_TYPE_QCA9984; |
| 702 | *target_type = TARGET_TYPE_QCA9984; |
Houston Hoffman | c50572b | 2016-06-08 19:49:46 -0700 | [diff] [blame] | 703 | HIF_INFO(" *********** QCA9984 *************"); |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 704 | break; |
| 705 | |
| 706 | case QCA9888_DEVICE_ID: |
| 707 | *hif_type = HIF_TYPE_QCA9888; |
| 708 | *target_type = TARGET_TYPE_QCA9888; |
Houston Hoffman | c50572b | 2016-06-08 19:49:46 -0700 | [diff] [blame] | 709 | HIF_INFO(" *********** QCA9888 *************"); |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 710 | break; |
| 711 | |
| 712 | case AR900B_DEVICE_ID: |
| 713 | *hif_type = HIF_TYPE_AR900B; |
| 714 | *target_type = TARGET_TYPE_AR900B; |
Houston Hoffman | c50572b | 2016-06-08 19:49:46 -0700 | [diff] [blame] | 715 | HIF_INFO(" *********** AR900B *************"); |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 716 | break; |
| 717 | |
Houston Hoffman | 3db96a4 | 2016-05-05 19:54:39 -0700 | [diff] [blame] | 718 | case IPQ4019_DEVICE_ID: |
| 719 | *hif_type = HIF_TYPE_IPQ4019; |
| 720 | *target_type = TARGET_TYPE_IPQ4019; |
Houston Hoffman | c50572b | 2016-06-08 19:49:46 -0700 | [diff] [blame] | 721 | HIF_INFO(" *********** IPQ4019 *************"); |
Houston Hoffman | 3db96a4 | 2016-05-05 19:54:39 -0700 | [diff] [blame] | 722 | break; |
| 723 | |
Venkateswara Swamy Bandaru | 9fd9af0 | 2016-09-20 20:27:31 +0530 | [diff] [blame] | 724 | case QCA8074_DEVICE_ID: |
| 725 | *hif_type = HIF_TYPE_QCA8074; |
| 726 | *target_type = TARGET_TYPE_QCA8074; |
| 727 | HIF_INFO(" *********** QCA8074 *************\n"); |
| 728 | break; |
| 729 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 730 | default: |
| 731 | HIF_ERROR("%s: Unsupported device ID!", __func__); |
| 732 | ret = -ENODEV; |
| 733 | break; |
| 734 | } |
| 735 | end: |
| 736 | return ret; |
| 737 | } |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 738 | |
| 739 | /** |
Houston Hoffman | 2635259 | 2016-03-14 21:11:43 -0700 | [diff] [blame] | 740 | * hif_needs_bmi() - return true if the soc needs bmi through the driver |
| 741 | * @hif_ctx: hif context |
| 742 | * |
| 743 | * Return: true if the soc needs driver bmi otherwise false |
| 744 | */ |
| 745 | bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx) |
| 746 | { |
| 747 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 748 | return hif_sc->bus_type != QDF_BUS_TYPE_SNOC; |
| 749 | } |
| 750 | |
| 751 | /** |
Houston Hoffman | 60a1eeb | 2016-03-14 21:11:44 -0700 | [diff] [blame] | 752 | * hif_get_bus_type() - return the bus type |
| 753 | * |
| 754 | * Return: enum qdf_bus_type |
| 755 | */ |
| 756 | enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl) |
| 757 | { |
| 758 | struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl); |
| 759 | return scn->bus_type; |
| 760 | } |
| 761 | |
| 762 | /** |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 763 | * Target info and ini parameters are global to the driver |
| 764 | * Hence these structures are exposed to all the modules in |
| 765 | * the driver and they don't need to maintains multiple copies |
| 766 | * of the same info, instead get the handle from hif and |
| 767 | * modify them in hif |
| 768 | */ |
| 769 | |
| 770 | /** |
| 771 | * hif_get_ini_handle() - API to get hif_config_param handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 772 | * @hif_ctx: HIF Context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 773 | * |
| 774 | * Return: pointer to hif_config_info |
| 775 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 776 | struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx) |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 777 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 778 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 779 | |
| 780 | return &sc->hif_config; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 781 | } |
| 782 | |
| 783 | /** |
| 784 | * hif_get_target_info_handle() - API to get hif_target_info handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 785 | * @hif_ctx: HIF context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 786 | * |
| 787 | * Return: Pointer to hif_target_info |
| 788 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 789 | struct hif_target_info *hif_get_target_info_handle( |
| 790 | struct hif_opaque_softc *hif_ctx) |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 791 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 792 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 793 | |
| 794 | return &sc->target_info; |
| 795 | |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 796 | } |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 797 | |
| 798 | #if defined(FEATURE_LRO) |
| 799 | /** |
| 800 | * hif_lro_flush_cb_register - API to register for LRO Flush Callback |
| 801 | * @scn: HIF Context |
| 802 | * @handler: Function pointer to be called by HIF |
| 803 | * @data: Private data to be used by the module registering to HIF |
| 804 | * |
| 805 | * Return: void |
| 806 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 807 | void hif_lro_flush_cb_register(struct hif_opaque_softc *scn, |
| 808 | void (handler)(void *), void *data) |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 809 | { |
| 810 | ce_lro_flush_cb_register(scn, handler, data); |
| 811 | } |
| 812 | |
| 813 | /** |
| 814 | * hif_lro_flush_cb_deregister - API to deregister for LRO Flush Callbacks |
| 815 | * @scn: HIF Context |
| 816 | * |
| 817 | * Return: void |
| 818 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 819 | void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn) |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 820 | { |
| 821 | ce_lro_flush_cb_deregister(scn); |
| 822 | } |
| 823 | #endif |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 824 | |
| 825 | /** |
| 826 | * hif_get_target_status - API to get target status |
| 827 | * @hif_ctx: HIF Context |
| 828 | * |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 829 | * Return: enum hif_target_status |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 830 | */ |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 831 | enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 832 | { |
| 833 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 834 | |
| 835 | return scn->target_status; |
| 836 | } |
| 837 | |
| 838 | /** |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 839 | * hif_set_target_status() - API to set target status |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 840 | * @hif_ctx: HIF Context |
| 841 | * @status: Target Status |
| 842 | * |
| 843 | * Return: void |
| 844 | */ |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 845 | void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum |
| 846 | hif_target_status status) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 847 | { |
| 848 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 849 | |
| 850 | scn->target_status = status; |
| 851 | } |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 852 | |
| 853 | /** |
| 854 | * hif_init_ini_config() - API to initialize HIF configuration parameters |
| 855 | * @hif_ctx: HIF Context |
| 856 | * @cfg: HIF Configuration |
| 857 | * |
| 858 | * Return: void |
| 859 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 860 | void hif_init_ini_config(struct hif_opaque_softc *hif_ctx, |
| 861 | struct hif_config_info *cfg) |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 862 | { |
| 863 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 864 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 865 | qdf_mem_copy(&scn->hif_config, cfg, sizeof(struct hif_config_info)); |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 866 | } |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 867 | |
| 868 | /** |
| 869 | * hif_get_conparam() - API to get driver mode in HIF |
| 870 | * @scn: HIF Context |
| 871 | * |
| 872 | * Return: driver mode of operation |
| 873 | */ |
| 874 | uint32_t hif_get_conparam(struct hif_softc *scn) |
| 875 | { |
| 876 | if (!scn) |
| 877 | return 0; |
| 878 | |
| 879 | return scn->hif_con_param; |
| 880 | } |
| 881 | |
| 882 | /** |
| 883 | * hif_get_callbacks_handle() - API to get callbacks Handle |
| 884 | * @scn: HIF Context |
| 885 | * |
| 886 | * Return: pointer to HIF Callbacks |
| 887 | */ |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 888 | struct hif_driver_state_callbacks *hif_get_callbacks_handle(struct hif_softc *scn) |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 889 | { |
| 890 | return &scn->callbacks; |
| 891 | } |
| 892 | |
| 893 | /** |
| 894 | * hif_is_driver_unloading() - API to query upper layers if driver is unloading |
| 895 | * @scn: HIF Context |
| 896 | * |
| 897 | * Return: True/False |
| 898 | */ |
| 899 | bool hif_is_driver_unloading(struct hif_softc *scn) |
| 900 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 901 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 902 | |
| 903 | if (cbk && cbk->is_driver_unloading) |
| 904 | return cbk->is_driver_unloading(cbk->context); |
| 905 | |
| 906 | return false; |
| 907 | } |
| 908 | |
| 909 | /** |
| 910 | * hif_is_load_or_unload_in_progress() - API to query upper layers if |
| 911 | * load/unload in progress |
| 912 | * @scn: HIF Context |
| 913 | * |
| 914 | * Return: True/False |
| 915 | */ |
| 916 | bool hif_is_load_or_unload_in_progress(struct hif_softc *scn) |
| 917 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 918 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 919 | |
| 920 | if (cbk && cbk->is_load_unload_in_progress) |
| 921 | return cbk->is_load_unload_in_progress(cbk->context); |
| 922 | |
| 923 | return false; |
| 924 | } |
| 925 | |
| 926 | /** |
Venkateswara Swamy Bandaru | 26f6f1e | 2016-10-03 19:35:57 +0530 | [diff] [blame] | 927 | * hif_update_pipe_callback() - API to register pipe specific callbacks |
| 928 | * @osc: Opaque softc |
| 929 | * @pipeid: pipe id |
| 930 | * @callbacks: callbacks to register |
| 931 | * |
| 932 | * Return: void |
| 933 | */ |
| 934 | |
| 935 | void hif_update_pipe_callback(struct hif_opaque_softc *osc, |
| 936 | u_int8_t pipeid, |
| 937 | struct hif_msg_callbacks *callbacks) |
| 938 | { |
| 939 | struct hif_softc *scn = HIF_GET_SOFTC(osc); |
| 940 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
| 941 | struct HIF_CE_pipe_info *pipe_info; |
| 942 | |
| 943 | QDF_BUG(pipeid < CE_COUNT_MAX); |
| 944 | |
| 945 | HIF_INFO_LO("+%s pipeid %d\n", __func__, pipeid); |
| 946 | |
| 947 | pipe_info = &hif_state->pipe_info[pipeid]; |
| 948 | |
| 949 | qdf_mem_copy(&pipe_info->pipe_callbacks, |
| 950 | callbacks, sizeof(pipe_info->pipe_callbacks)); |
| 951 | |
| 952 | HIF_INFO_LO("-%s\n", __func__); |
| 953 | } |
| 954 | |
| 955 | /** |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 956 | * hif_is_recovery_in_progress() - API to query upper layers if recovery in |
| 957 | * progress |
| 958 | * @scn: HIF Context |
| 959 | * |
| 960 | * Return: True/False |
| 961 | */ |
| 962 | bool hif_is_recovery_in_progress(struct hif_softc *scn) |
| 963 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 964 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 965 | |
| 966 | if (cbk && cbk->is_recovery_in_progress) |
| 967 | return cbk->is_recovery_in_progress(cbk->context); |
| 968 | |
| 969 | return false; |
| 970 | } |
Mohit Khanna | 440c529 | 2016-05-12 11:05:06 -0700 | [diff] [blame] | 971 | #if defined(HIF_PCI) || defined(SNOC) || defined(HIF_AHB) |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 972 | /** |
| 973 | * hif_batch_send() - API to access hif specific function |
| 974 | * ce_batch_send. |
| 975 | * @osc: HIF Context |
| 976 | * @msdu : list of msdus to be sent |
| 977 | * @transfer_id : transfer id |
| 978 | * @len : donwloaded length |
| 979 | * |
| 980 | * Return: list of msds not sent |
| 981 | */ |
| 982 | qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, |
| 983 | uint32_t transfer_id, u_int32_t len, uint32_t sendhead) |
| 984 | { |
| 985 | void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE); |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 986 | |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 987 | return ce_batch_send((struct CE_handle *)ce_tx_hdl, msdu, transfer_id, |
| 988 | len, sendhead); |
| 989 | } |
| 990 | |
| 991 | /** |
| 992 | * hif_update_tx_ring() - API to access hif specific function |
| 993 | * ce_update_tx_ring. |
| 994 | * @osc: HIF Context |
| 995 | * @num_htt_cmpls : number of htt compl received. |
| 996 | * |
| 997 | * Return: void |
| 998 | */ |
| 999 | void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls) |
| 1000 | { |
| 1001 | void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE); |
| 1002 | ce_update_tx_ring(ce_tx_hdl, num_htt_cmpls); |
| 1003 | } |
| 1004 | |
| 1005 | |
| 1006 | /** |
| 1007 | * hif_send_single() - API to access hif specific function |
| 1008 | * ce_send_single. |
| 1009 | * @osc: HIF Context |
| 1010 | * @msdu : msdu to be sent |
| 1011 | * @transfer_id: transfer id |
| 1012 | * @len : downloaded length |
| 1013 | * |
| 1014 | * Return: msdu sent status |
| 1015 | */ |
| 1016 | int hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, uint32_t |
| 1017 | transfer_id, u_int32_t len) |
| 1018 | { |
| 1019 | void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE); |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1020 | |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 1021 | return ce_send_single((struct CE_handle *)ce_tx_hdl, msdu, transfer_id, |
| 1022 | len); |
| 1023 | } |
| 1024 | |
| 1025 | /** |
| 1026 | * hif_send_fast() - API to access hif specific function |
| 1027 | * ce_send_fast. |
| 1028 | * @osc: HIF Context |
| 1029 | * @msdu : array of msdus to be sent |
| 1030 | * @num_msdus : number of msdus in an array |
| 1031 | * @transfer_id: transfer id |
Nirav Shah | da0881a | 2016-05-16 10:45:16 +0530 | [diff] [blame] | 1032 | * @download_len: download length |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 1033 | * |
| 1034 | * Return: No. of packets that could be sent |
| 1035 | */ |
Nirav Shah | da0881a | 2016-05-16 10:45:16 +0530 | [diff] [blame] | 1036 | int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf, |
| 1037 | uint32_t transfer_id, uint32_t download_len) |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 1038 | { |
| 1039 | void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE); |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1040 | |
Nirav Shah | da0881a | 2016-05-16 10:45:16 +0530 | [diff] [blame] | 1041 | return ce_send_fast((struct CE_handle *)ce_tx_hdl, nbuf, |
| 1042 | transfer_id, download_len); |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 1043 | } |
Mohit Khanna | 440c529 | 2016-05-12 11:05:06 -0700 | [diff] [blame] | 1044 | #endif |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 1045 | |
| 1046 | /** |
| 1047 | * hif_reg_write() - API to access hif specific function |
| 1048 | * hif_write32_mb. |
| 1049 | * @hif_ctx : HIF Context |
| 1050 | * @offset : offset on which value has to be written |
| 1051 | * @value : value to be written |
| 1052 | * |
| 1053 | * Return: None |
| 1054 | */ |
| 1055 | void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset, |
| 1056 | uint32_t value) |
| 1057 | { |
| 1058 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 1059 | hif_write32_mb(scn->mem + offset, value); |
| 1060 | |
| 1061 | } |
| 1062 | |
| 1063 | /** |
| 1064 | * hif_reg_read() - API to access hif specific function |
| 1065 | * hif_read32_mb. |
| 1066 | * @hif_ctx : HIF Context |
| 1067 | * @offset : offset from which value has to be read |
| 1068 | * |
| 1069 | * Return: Read value |
| 1070 | */ |
| 1071 | uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset) |
| 1072 | { |
| 1073 | |
| 1074 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 1075 | return hif_read32_mb(scn->mem + offset); |
| 1076 | } |
Mohit Khanna | 440c529 | 2016-05-12 11:05:06 -0700 | [diff] [blame] | 1077 | |
| 1078 | #if defined(HIF_USB) |
| 1079 | /** |
| 1080 | * hif_ramdump_handler(): generic ramdump handler |
| 1081 | * @scn: struct hif_opaque_softc |
| 1082 | * |
| 1083 | * Return: None |
| 1084 | */ |
| 1085 | |
| 1086 | void hif_ramdump_handler(struct hif_opaque_softc *scn) |
| 1087 | |
| 1088 | { |
| 1089 | if (hif_get_bus_type == QDF_BUS_TYPE_USB) |
| 1090 | hif_usb_ramdump_handler(); |
| 1091 | } |
| 1092 | #endif |
Venkateswara Swamy Bandaru | 31108f3 | 2016-08-08 18:04:29 +0530 | [diff] [blame] | 1093 | |
| 1094 | /** |
| 1095 | * hif_register_ext_group_int_handler() - API to register external group |
| 1096 | * interrupt handler. |
| 1097 | * @hif_ctx : HIF Context |
| 1098 | * @numirq: number of irq's in the group |
| 1099 | * @irq: array of irq values |
| 1100 | * @ext_intr_handler: callback interrupt handler function |
| 1101 | * @context: context to passed in callback |
| 1102 | * |
| 1103 | * Return: status |
| 1104 | */ |
| 1105 | uint32_t hif_register_ext_group_int_handler(struct hif_opaque_softc *hif_ctx, |
| 1106 | uint32_t numirq, uint32_t irq[], ext_intr_handler handler, |
| 1107 | void *context) |
| 1108 | { |
| 1109 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 1110 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
| 1111 | struct hif_ext_group_entry *hif_ext_group; |
| 1112 | |
| 1113 | if (scn->hif_init_done) { |
| 1114 | HIF_ERROR("%s Called after HIF initialization \n", __func__); |
| 1115 | return QDF_STATUS_E_FAILURE; |
| 1116 | } |
| 1117 | |
| 1118 | if (hif_state->hif_num_extgroup >= HIF_MAX_GROUP) { |
| 1119 | HIF_ERROR("%s Max groups reached\n", __func__); |
| 1120 | return QDF_STATUS_E_FAILURE; |
| 1121 | } |
| 1122 | |
| 1123 | if (numirq >= HIF_MAX_GRP_IRQ) { |
| 1124 | HIF_ERROR("%s invalid numirq\n", __func__); |
| 1125 | return QDF_STATUS_E_FAILURE; |
| 1126 | } |
| 1127 | |
| 1128 | hif_ext_group = &hif_state->hif_ext_group[hif_state->hif_num_extgroup]; |
| 1129 | |
| 1130 | hif_ext_group->numirq = numirq; |
| 1131 | qdf_mem_copy(&hif_ext_group->irq[0], irq, numirq * sizeof(irq[0])); |
| 1132 | hif_ext_group->context = context; |
| 1133 | hif_ext_group->handler = handler; |
| 1134 | hif_ext_group->configured = true; |
| 1135 | hif_ext_group->grp_id = hif_state->hif_num_extgroup; |
| 1136 | |
| 1137 | hif_state->hif_num_extgroup++; |
| 1138 | return QDF_STATUS_SUCCESS; |
| 1139 | } |
| 1140 | |
| 1141 | /** |
| 1142 | * hif_ext_grp_tasklet() - grp tasklet |
| 1143 | * data: context |
| 1144 | * |
| 1145 | * return: void |
| 1146 | */ |
| 1147 | void hif_ext_grp_tasklet(unsigned long data) |
| 1148 | { |
| 1149 | struct hif_ext_group_entry *hif_ext_group = |
| 1150 | (struct hif_ext_group_entry *)data; |
| 1151 | struct HIF_CE_state *hif_state = hif_ext_group->hif_state; |
| 1152 | struct hif_softc *scn = HIF_GET_SOFTC(hif_state); |
| 1153 | |
| 1154 | if (hif_ext_group->grp_id < HIF_MAX_GROUP) { |
| 1155 | hif_ext_group->handler(hif_ext_group->context, HIF_MAX_BUDGET); |
| 1156 | hif_grp_irq_enable(scn, hif_ext_group->grp_id); |
| 1157 | } else { |
| 1158 | HIF_ERROR("%s: ERROR - invalid grp_id = %d", |
| 1159 | __func__, hif_ext_group->grp_id); |
| 1160 | } |
| 1161 | |
| 1162 | qdf_atomic_dec(&scn->active_grp_tasklet_cnt); |
| 1163 | } |
| 1164 | |
| 1165 | /** |
| 1166 | * hif_grp_tasklet_kill() - grp tasklet kill |
| 1167 | * scn: hif_softc |
| 1168 | * |
| 1169 | * return: void |
| 1170 | */ |
| 1171 | void hif_grp_tasklet_kill(struct hif_softc *scn) |
| 1172 | { |
| 1173 | int i; |
| 1174 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
| 1175 | |
| 1176 | for (i = 0; i < HIF_MAX_GROUP; i++) |
| 1177 | if (hif_state->hif_ext_group[i].inited) { |
| 1178 | tasklet_kill(&hif_state->hif_ext_group[i].intr_tq); |
| 1179 | hif_state->hif_ext_group[i].inited = false; |
| 1180 | } |
| 1181 | qdf_atomic_set(&scn->active_grp_tasklet_cnt, 0); |
| 1182 | } |