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