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