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