Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1 | /* |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 28 | #include "targcfg.h" |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 29 | #include "qdf_lock.h" |
| 30 | #include "qdf_status.h" |
| 31 | #include "qdf_status.h" |
| 32 | #include <qdf_atomic.h> /* qdf_atomic_read */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 33 | #include <targaddrs.h> |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 34 | #include "hif_io32.h" |
| 35 | #include <hif.h> |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 36 | #include "regtable.h" |
| 37 | #define ATH_MODULE_NAME hif |
| 38 | #include <a_debug.h> |
| 39 | #include "hif_main.h" |
| 40 | #include "hif_hw_version.h" |
| 41 | #include "ce_api.h" |
| 42 | #include "ce_tasklet.h" |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 43 | #include "qdf_trace.h" |
| 44 | #include "qdf_status.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 45 | #ifdef CONFIG_CNSS |
| 46 | #include <net/cnss.h> |
| 47 | #endif |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 48 | #include "hif_debug.h" |
| 49 | #include "mp_dev.h" |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 50 | #include "platform_icnss.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 51 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 52 | #define AGC_DUMP 1 |
| 53 | #define CHANINFO_DUMP 2 |
| 54 | #define BB_WATCHDOG_DUMP 3 |
| 55 | #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG |
| 56 | #define PCIE_ACCESS_DUMP 4 |
| 57 | #endif |
| 58 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 59 | 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] | 60 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 61 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 62 | switch (cmd_id) { |
| 63 | case AGC_DUMP: |
| 64 | if (start) |
| 65 | priv_start_agc(scn); |
| 66 | else |
| 67 | priv_dump_agc(scn); |
| 68 | break; |
| 69 | |
| 70 | case CHANINFO_DUMP: |
| 71 | if (start) |
| 72 | priv_start_cap_chaninfo(scn); |
| 73 | else |
| 74 | priv_dump_chaninfo(scn); |
| 75 | break; |
| 76 | |
| 77 | case BB_WATCHDOG_DUMP: |
| 78 | priv_dump_bbwatchdog(scn); |
| 79 | break; |
| 80 | |
| 81 | #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG |
| 82 | case PCIE_ACCESS_DUMP: |
| 83 | hif_target_dump_access_log(); |
| 84 | break; |
| 85 | #endif |
| 86 | default: |
| 87 | HIF_ERROR("%s: Invalid htc dump command", __func__); |
| 88 | break; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * hif_shut_down_device() - hif_shut_down_device |
| 94 | * |
| 95 | * SThis fucntion shuts down the device |
| 96 | * |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 97 | * @scn: hif_opaque_softc |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 98 | * |
| 99 | * Return: void |
| 100 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 101 | void hif_shut_down_device(struct hif_opaque_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 102 | { |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 103 | hif_stop(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 104 | } |
| 105 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 106 | /** |
| 107 | * hif_get_target_id(): hif_get_target_id |
| 108 | * |
| 109 | * Return the virtual memory base address to the caller |
| 110 | * |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 111 | * @scn: hif_softc |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 112 | * |
| 113 | * Return: A_target_id_t |
| 114 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 115 | A_target_id_t hif_get_target_id(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 116 | { |
| 117 | return scn->mem; |
| 118 | } |
| 119 | |
Houston Hoffman | 0dad509 | 2015-09-28 16:25:51 -0700 | [diff] [blame] | 120 | static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state) |
| 121 | { |
| 122 | struct hif_msg_callbacks *msg_callbacks = |
| 123 | &hif_state->msg_callbacks_current; |
| 124 | |
| 125 | if (!msg_callbacks->fwEventHandler) |
| 126 | return; |
| 127 | |
| 128 | msg_callbacks->fwEventHandler(msg_callbacks->Context, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 129 | QDF_STATUS_E_FAILURE); |
Houston Hoffman | 0dad509 | 2015-09-28 16:25:51 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 132 | /** |
| 133 | * hif_fw_interrupt_handler(): FW interrupt handler |
| 134 | * |
| 135 | * This function is the FW interrupt handlder |
| 136 | * |
| 137 | * @irq: irq number |
| 138 | * @arg: the user pointer |
| 139 | * |
| 140 | * Return: bool |
| 141 | */ |
| 142 | #ifndef QCA_WIFI_3_0 |
| 143 | irqreturn_t hif_fw_interrupt_handler(int irq, void *arg) |
| 144 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 145 | struct hif_softc *scn = arg; |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 146 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 147 | uint32_t fw_indicator_address, fw_indicator; |
| 148 | |
Houston Hoffman | 2c32cf6 | 2016-03-14 21:12:00 -0700 | [diff] [blame] | 149 | if (Q_TARGET_ACCESS_BEGIN(scn) < 0) |
| 150 | return ATH_ISR_NOSCHED; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 151 | |
| 152 | fw_indicator_address = hif_state->fw_indicator_address; |
| 153 | /* For sudden unplug this will return ~0 */ |
| 154 | fw_indicator = A_TARGET_READ(scn, fw_indicator_address); |
| 155 | |
| 156 | if ((fw_indicator != ~0) && (fw_indicator & FW_IND_EVENT_PENDING)) { |
| 157 | /* ACK: clear Target-side pending event */ |
| 158 | A_TARGET_WRITE(scn, fw_indicator_address, |
| 159 | fw_indicator & ~FW_IND_EVENT_PENDING); |
Houston Hoffman | 2c32cf6 | 2016-03-14 21:12:00 -0700 | [diff] [blame] | 160 | if (Q_TARGET_ACCESS_END(scn) < 0) |
| 161 | return ATH_ISR_SCHED; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 162 | |
| 163 | if (hif_state->started) { |
Houston Hoffman | 0dad509 | 2015-09-28 16:25:51 -0700 | [diff] [blame] | 164 | hif_fw_event_handler(hif_state); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 165 | } else { |
| 166 | /* |
| 167 | * Probable Target failure before we're prepared |
| 168 | * to handle it. Generally unexpected. |
| 169 | */ |
| 170 | AR_DEBUG_PRINTF(ATH_DEBUG_ERR, |
| 171 | ("%s: Early firmware event indicated\n", |
| 172 | __func__)); |
| 173 | } |
| 174 | } else { |
Houston Hoffman | 2c32cf6 | 2016-03-14 21:12:00 -0700 | [diff] [blame] | 175 | if (Q_TARGET_ACCESS_END(scn) < 0) |
| 176 | return ATH_ISR_SCHED; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | return ATH_ISR_SCHED; |
| 180 | } |
| 181 | #else |
| 182 | irqreturn_t hif_fw_interrupt_handler(int irq, void *arg) |
| 183 | { |
| 184 | return ATH_ISR_SCHED; |
| 185 | } |
| 186 | #endif /* #ifdef QCA_WIFI_3_0 */ |
| 187 | |
| 188 | /** |
| 189 | * hif_get_targetdef(): hif_get_targetdef |
| 190 | * @scn: scn |
| 191 | * |
| 192 | * Return: void * |
| 193 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 194 | void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 195 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 196 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 197 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 198 | return scn->targetdef; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * hif_vote_link_down(): unvote for link up |
| 203 | * |
| 204 | * Call hif_vote_link_down to release a previous request made using |
| 205 | * hif_vote_link_up. A hif_vote_link_down call should only be made |
| 206 | * after a corresponding hif_vote_link_up, otherwise you could be |
| 207 | * negating a vote from another source. When no votes are present |
| 208 | * hif will not guarantee the linkstate after hif_bus_suspend. |
| 209 | * |
| 210 | * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread |
| 211 | * and initialization deinitialization sequencences. |
| 212 | * |
| 213 | * Return: n/a |
| 214 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 215 | void hif_vote_link_down(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 216 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 217 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 218 | QDF_BUG(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 219 | |
| 220 | scn->linkstate_vote--; |
| 221 | if (scn->linkstate_vote == 0) |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 222 | hif_bus_prevent_linkdown(scn, false); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | /** |
| 226 | * hif_vote_link_up(): vote to prevent bus from suspending |
| 227 | * |
| 228 | * Makes hif guarantee that fw can message the host normally |
| 229 | * durring suspend. |
| 230 | * |
| 231 | * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread |
| 232 | * and initialization deinitialization sequencences. |
| 233 | * |
| 234 | * Return: n/a |
| 235 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 236 | void hif_vote_link_up(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 237 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 238 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 239 | QDF_BUG(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 240 | |
| 241 | scn->linkstate_vote++; |
| 242 | if (scn->linkstate_vote == 1) |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 243 | hif_bus_prevent_linkdown(scn, true); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | /** |
| 247 | * hif_can_suspend_link(): query if hif is permitted to suspend the link |
| 248 | * |
| 249 | * Hif will ensure that the link won't be suspended if the upperlayers |
| 250 | * don't want it to. |
| 251 | * |
| 252 | * SYNCHRONIZATION: MC thread is stopped before bus suspend thus |
| 253 | * we don't need extra locking to ensure votes dont change while |
| 254 | * we are in the process of suspending or resuming. |
| 255 | * |
| 256 | * Return: false if hif will guarantee link up durring suspend. |
| 257 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 258 | bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 259 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 260 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 261 | QDF_BUG(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 262 | |
| 263 | return scn->linkstate_vote == 0; |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * hif_hia_item_address(): hif_hia_item_address |
| 268 | * @target_type: target_type |
| 269 | * @item_offset: item_offset |
| 270 | * |
| 271 | * Return: n/a |
| 272 | */ |
| 273 | uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset) |
| 274 | { |
| 275 | switch (target_type) { |
| 276 | case TARGET_TYPE_AR6002: |
| 277 | return AR6002_HOST_INTEREST_ADDRESS + item_offset; |
| 278 | case TARGET_TYPE_AR6003: |
| 279 | return AR6003_HOST_INTEREST_ADDRESS + item_offset; |
| 280 | case TARGET_TYPE_AR6004: |
| 281 | return AR6004_HOST_INTEREST_ADDRESS + item_offset; |
| 282 | case TARGET_TYPE_AR6006: |
| 283 | return AR6006_HOST_INTEREST_ADDRESS + item_offset; |
| 284 | case TARGET_TYPE_AR9888: |
| 285 | return AR9888_HOST_INTEREST_ADDRESS + item_offset; |
| 286 | case TARGET_TYPE_AR6320: |
| 287 | case TARGET_TYPE_AR6320V2: |
| 288 | return AR6320_HOST_INTEREST_ADDRESS + item_offset; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 289 | case TARGET_TYPE_ADRASTEA: |
| 290 | /* ADRASTEA doesn't have a host interest address */ |
| 291 | ASSERT(0); |
| 292 | return 0; |
| 293 | default: |
| 294 | ASSERT(0); |
| 295 | return 0; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | /** |
| 300 | * hif_max_num_receives_reached() - check max receive is reached |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 301 | * @scn: HIF Context |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 302 | * @count: unsigned int. |
| 303 | * |
| 304 | * Output check status as bool |
| 305 | * |
| 306 | * Return: bool |
| 307 | */ |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 308 | 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] | 309 | { |
Houston Hoffman | 75ef5a5 | 2016-04-14 17:15:49 -0700 | [diff] [blame] | 310 | if (QDF_IS_EPPING_ENABLED(hif_get_conparam(scn))) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 311 | return count > 120; |
| 312 | else |
| 313 | return count > MAX_NUM_OF_RECEIVES; |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * init_buffer_count() - initial buffer count |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 318 | * @maxSize: qdf_size_t |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 319 | * |
| 320 | * routine to modify the initial buffer count to be allocated on an os |
| 321 | * platform basis. Platform owner will need to modify this as needed |
| 322 | * |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 323 | * Return: qdf_size_t |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 324 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 325 | qdf_size_t init_buffer_count(qdf_size_t maxSize) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 326 | { |
| 327 | return maxSize; |
| 328 | } |
| 329 | |
| 330 | /** |
Nirav Shah | d7f9159 | 2016-04-21 14:18:43 +0530 | [diff] [blame] | 331 | * hif_save_htc_htt_config_endpoint() - save htt_tx_endpoint |
| 332 | * @hif_ctx: hif context |
| 333 | * @htc_htt_tx_endpoint: htt_tx_endpoint |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 334 | * |
| 335 | * Return: void |
| 336 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 337 | 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] | 338 | int htc_htt_tx_endpoint) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 339 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 340 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 341 | |
| 342 | if (!scn) { |
| 343 | HIF_ERROR("%s: error: scn or scn->hif_sc is NULL!", |
| 344 | __func__); |
| 345 | return; |
| 346 | } |
| 347 | |
Nirav Shah | d7f9159 | 2016-04-21 14:18:43 +0530 | [diff] [blame] | 348 | scn->htc_htt_tx_endpoint = htc_htt_tx_endpoint; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | /** |
| 352 | * hif_get_hw_name(): get a human readable name for the hardware |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 353 | * @info: Target Info |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 354 | * |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 355 | * Return: human readable name for the underlying wifi hardware. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 356 | */ |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 357 | static const char *hif_get_hw_name(struct hif_target_info *info) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 358 | { |
| 359 | int i; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 360 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 361 | for (i = 0; i < ARRAY_SIZE(qwlan_hw_list); i++) { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 362 | if (info->target_version == qwlan_hw_list[i].id && |
| 363 | info->target_revision == qwlan_hw_list[i].subid) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 364 | return qwlan_hw_list[i].name; |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | return "Unknown Device"; |
| 369 | } |
| 370 | |
| 371 | /** |
| 372 | * hif_get_hw_info(): hif_get_hw_info |
| 373 | * @scn: scn |
| 374 | * @version: version |
| 375 | * @revision: revision |
| 376 | * |
| 377 | * Return: n/a |
| 378 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 379 | 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] | 380 | const char **target_name) |
| 381 | { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 382 | struct hif_target_info *info = hif_get_target_info_handle(scn); |
| 383 | *version = info->target_version; |
| 384 | *revision = info->target_revision; |
| 385 | *target_name = hif_get_hw_name(info); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | /** |
| 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 | qdf_mem_zero(scn, bus_context_size); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 420 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 421 | scn->qdf_dev = qdf_ctx; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 422 | scn->hif_con_param = mode; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 423 | qdf_atomic_init(&scn->active_tasklet_cnt); |
| 424 | qdf_atomic_init(&scn->link_suspended); |
| 425 | qdf_atomic_init(&scn->tasklet_from_intr); |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 426 | qdf_mem_copy(&scn->callbacks, cbk, sizeof(struct hif_driver_state_callbacks)); |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 427 | |
| 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 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 459 | hif_bus_close(scn); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 460 | qdf_mem_free(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | /** |
| 464 | * hif_enable(): hif_enable |
| 465 | * @hif_ctx: hif_ctx |
| 466 | * @dev: dev |
| 467 | * @bdev: bus dev |
| 468 | * @bid: bus ID |
| 469 | * @bus_type: bus type |
| 470 | * @type: enable type |
| 471 | * |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 472 | * Return: QDF_STATUS |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 473 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 474 | QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 475 | void *bdev, const hif_bus_id *bid, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 476 | enum qdf_bus_type bus_type, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 477 | enum hif_enable_type type) |
| 478 | { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 479 | QDF_STATUS status; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 480 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 481 | |
| 482 | if (scn == NULL) { |
| 483 | HIF_ERROR("%s: hif_ctx = NULL", __func__); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 484 | return QDF_STATUS_E_NULL_VALUE; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 485 | } |
| 486 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 487 | status = hif_enable_bus(scn, dev, bdev, bid, type); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 488 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 489 | HIF_ERROR("%s: hif_enable_bus error = %d", |
| 490 | __func__, status); |
| 491 | return status; |
| 492 | } |
| 493 | |
| 494 | if (ADRASTEA_BU) |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 495 | hif_vote_link_up(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 496 | |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 497 | if (hif_bus_configure(scn)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 498 | HIF_ERROR("%s: Target probe failed.", __func__); |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 499 | hif_disable_bus(scn); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 500 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 501 | return status; |
| 502 | } |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 503 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 504 | /* |
| 505 | * Flag to avoid potential unallocated memory access from MSI |
| 506 | * interrupt handler which could get scheduled as soon as MSI |
| 507 | * is enabled, i.e to take care of the race due to the order |
| 508 | * in where MSI is enabled before the memory, that will be |
| 509 | * in interrupt handlers, is allocated. |
| 510 | */ |
| 511 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 512 | scn->hif_init_done = true; |
| 513 | |
| 514 | HIF_TRACE("%s: X OK", __func__); |
| 515 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 516 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | /** |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 520 | * hif_wlan_disable(): call the platform driver to disable wlan |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 521 | * @scn: HIF Context |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 522 | * |
| 523 | * This function passes the con_mode to platform driver to disable |
| 524 | * wlan. |
| 525 | * |
| 526 | * Return: void |
| 527 | */ |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 528 | void hif_wlan_disable(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 529 | { |
| 530 | enum icnss_driver_mode mode; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 531 | uint32_t con_mode = hif_get_conparam(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 532 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 533 | if (QDF_GLOBAL_FTM_MODE == con_mode) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 534 | mode = ICNSS_FTM; |
Houston Hoffman | 75ef5a5 | 2016-04-14 17:15:49 -0700 | [diff] [blame] | 535 | else if (QDF_IS_EPPING_ENABLED(con_mode)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 536 | mode = ICNSS_EPPING; |
Peng Xu | 7b96253 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 537 | else |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 538 | mode = ICNSS_MISSION; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 539 | |
| 540 | icnss_wlan_disable(mode); |
| 541 | } |
| 542 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 543 | 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] | 544 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 545 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 546 | |
| 547 | if (!scn) |
| 548 | return; |
| 549 | |
| 550 | hif_nointrs(scn); |
| 551 | if (scn->hif_init_done == false) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 552 | hif_shut_down_device(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 553 | else |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 554 | hif_stop(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 555 | |
| 556 | if (ADRASTEA_BU) |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 557 | hif_vote_link_down(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 558 | |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 559 | hif_disable_bus(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 560 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 561 | hif_wlan_disable(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 562 | |
| 563 | scn->notice_send = false; |
| 564 | |
| 565 | HIF_INFO("%s: X", __func__); |
| 566 | } |
| 567 | |
| 568 | |
| 569 | /** |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 570 | * hif_crash_shutdown_dump_bus_register() - dump bus registers |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 571 | * @hif_ctx: hif_ctx |
| 572 | * |
| 573 | * Return: n/a |
| 574 | */ |
| 575 | #if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \ |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 576 | && defined(DEBUG) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 577 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 578 | static void hif_crash_shutdown_dump_bus_register(void *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 579 | { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 580 | struct hif_opaque_softc *scn = hif_ctx; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 581 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 582 | if (hif_check_soc_status(scn)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 583 | return; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 584 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 585 | if (hif_dump_registers(scn)) |
| 586 | HIF_ERROR("Failed to dump bus registers!"); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | /** |
| 590 | * hif_crash_shutdown(): hif_crash_shutdown |
| 591 | * |
| 592 | * This function is called by the platform driver to dump CE registers |
| 593 | * |
| 594 | * @hif_ctx: hif_ctx |
| 595 | * |
| 596 | * Return: n/a |
| 597 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 598 | void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 599 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 600 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 601 | |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 602 | if (!hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 603 | return; |
| 604 | |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 605 | if (scn->bus_type == QDF_BUS_TYPE_SNOC) { |
| 606 | HIF_INFO_MED("%s: RAM dump disabled for bustype %d", |
| 607 | __func__, scn->bus_type); |
| 608 | return; |
| 609 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 610 | |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame^] | 611 | if (TARGET_STATUS_RESET == scn->target_status) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 612 | HIF_INFO_MED("%s: Target is already asserted, ignore!", |
| 613 | __func__); |
| 614 | return; |
| 615 | } |
| 616 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 617 | if (hif_is_load_or_unload_in_progress(scn)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 618 | HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__); |
| 619 | return; |
| 620 | } |
| 621 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 622 | hif_crash_shutdown_dump_bus_register(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 623 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 624 | if (ol_copy_ramdump(hif_ctx)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 625 | goto out; |
| 626 | |
| 627 | HIF_INFO_MED("%s: RAM dump collecting completed!", __func__); |
| 628 | |
| 629 | out: |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 630 | return; |
| 631 | } |
| 632 | #else |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 633 | void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 634 | { |
| 635 | HIF_INFO_MED("%s: Collecting target RAM dump disabled", |
| 636 | __func__); |
| 637 | return; |
| 638 | } |
| 639 | #endif /* TARGET_RAMDUMP_AFTER_KERNEL_PANIC */ |
| 640 | |
| 641 | #ifdef QCA_WIFI_3_0 |
| 642 | /** |
| 643 | * hif_check_fw_reg(): hif_check_fw_reg |
| 644 | * @scn: scn |
| 645 | * @state: |
| 646 | * |
| 647 | * Return: int |
| 648 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 649 | int hif_check_fw_reg(struct hif_opaque_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 650 | { |
| 651 | return 0; |
| 652 | } |
| 653 | #endif |
| 654 | |
| 655 | #ifdef IPA_OFFLOAD |
| 656 | /** |
| 657 | * hif_read_phy_mem_base(): hif_read_phy_mem_base |
| 658 | * @scn: scn |
| 659 | * @phy_mem_base: physical mem base |
| 660 | * |
| 661 | * Return: n/a |
| 662 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 663 | 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] | 664 | { |
| 665 | *phy_mem_base = scn->mem_pa; |
| 666 | } |
| 667 | #endif /* IPA_OFFLOAD */ |
| 668 | |
| 669 | /** |
| 670 | * hif_get_device_type(): hif_get_device_type |
| 671 | * @device_id: device_id |
| 672 | * @revision_id: revision_id |
| 673 | * @hif_type: returned hif_type |
| 674 | * @target_type: returned target_type |
| 675 | * |
| 676 | * Return: int |
| 677 | */ |
| 678 | int hif_get_device_type(uint32_t device_id, |
| 679 | uint32_t revision_id, |
| 680 | uint32_t *hif_type, uint32_t *target_type) |
| 681 | { |
| 682 | int ret = 0; |
| 683 | |
| 684 | switch (device_id) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 685 | case ADRASTEA_DEVICE_ID: |
| 686 | case ADRASTEA_DEVICE_ID_P2_E12: |
| 687 | |
| 688 | *hif_type = HIF_TYPE_ADRASTEA; |
| 689 | *target_type = TARGET_TYPE_ADRASTEA; |
| 690 | break; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 691 | |
| 692 | case AR9888_DEVICE_ID: |
| 693 | *hif_type = HIF_TYPE_AR9888; |
| 694 | *target_type = TARGET_TYPE_AR9888; |
| 695 | break; |
| 696 | |
| 697 | case AR6320_DEVICE_ID: |
| 698 | switch (revision_id) { |
| 699 | case AR6320_FW_1_1: |
| 700 | case AR6320_FW_1_3: |
| 701 | *hif_type = HIF_TYPE_AR6320; |
| 702 | *target_type = TARGET_TYPE_AR6320; |
| 703 | break; |
| 704 | |
| 705 | case AR6320_FW_2_0: |
| 706 | case AR6320_FW_3_0: |
| 707 | case AR6320_FW_3_2: |
| 708 | *hif_type = HIF_TYPE_AR6320V2; |
| 709 | *target_type = TARGET_TYPE_AR6320V2; |
| 710 | break; |
| 711 | |
| 712 | default: |
| 713 | HIF_ERROR("%s: error - dev_id = 0x%x, rev_id = 0x%x", |
| 714 | __func__, device_id, revision_id); |
| 715 | ret = -ENODEV; |
| 716 | goto end; |
| 717 | } |
| 718 | break; |
| 719 | |
| 720 | default: |
| 721 | HIF_ERROR("%s: Unsupported device ID!", __func__); |
| 722 | ret = -ENODEV; |
| 723 | break; |
| 724 | } |
| 725 | end: |
| 726 | return ret; |
| 727 | } |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 728 | |
| 729 | /** |
Houston Hoffman | 2635259 | 2016-03-14 21:11:43 -0700 | [diff] [blame] | 730 | * hif_needs_bmi() - return true if the soc needs bmi through the driver |
| 731 | * @hif_ctx: hif context |
| 732 | * |
| 733 | * Return: true if the soc needs driver bmi otherwise false |
| 734 | */ |
| 735 | bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx) |
| 736 | { |
| 737 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 738 | return hif_sc->bus_type != QDF_BUS_TYPE_SNOC; |
| 739 | } |
| 740 | |
| 741 | /** |
Houston Hoffman | 60a1eeb | 2016-03-14 21:11:44 -0700 | [diff] [blame] | 742 | * hif_get_bus_type() - return the bus type |
| 743 | * |
| 744 | * Return: enum qdf_bus_type |
| 745 | */ |
| 746 | enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl) |
| 747 | { |
| 748 | struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl); |
| 749 | return scn->bus_type; |
| 750 | } |
| 751 | |
| 752 | /** |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 753 | * Target info and ini parameters are global to the driver |
| 754 | * Hence these structures are exposed to all the modules in |
| 755 | * the driver and they don't need to maintains multiple copies |
| 756 | * of the same info, instead get the handle from hif and |
| 757 | * modify them in hif |
| 758 | */ |
| 759 | |
| 760 | /** |
| 761 | * hif_get_ini_handle() - API to get hif_config_param handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 762 | * @hif_ctx: HIF Context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 763 | * |
| 764 | * Return: pointer to hif_config_info |
| 765 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 766 | 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] | 767 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 768 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 769 | |
| 770 | return &sc->hif_config; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | /** |
| 774 | * hif_get_target_info_handle() - API to get hif_target_info handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 775 | * @hif_ctx: HIF context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 776 | * |
| 777 | * Return: Pointer to hif_target_info |
| 778 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 779 | struct hif_target_info *hif_get_target_info_handle( |
| 780 | struct hif_opaque_softc *hif_ctx) |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 781 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 782 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 783 | |
| 784 | return &sc->target_info; |
| 785 | |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 786 | } |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 787 | |
| 788 | #if defined(FEATURE_LRO) |
| 789 | /** |
| 790 | * hif_lro_flush_cb_register - API to register for LRO Flush Callback |
| 791 | * @scn: HIF Context |
| 792 | * @handler: Function pointer to be called by HIF |
| 793 | * @data: Private data to be used by the module registering to HIF |
| 794 | * |
| 795 | * Return: void |
| 796 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 797 | void hif_lro_flush_cb_register(struct hif_opaque_softc *scn, |
| 798 | void (handler)(void *), void *data) |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 799 | { |
| 800 | ce_lro_flush_cb_register(scn, handler, data); |
| 801 | } |
| 802 | |
| 803 | /** |
| 804 | * hif_lro_flush_cb_deregister - API to deregister for LRO Flush Callbacks |
| 805 | * @scn: HIF Context |
| 806 | * |
| 807 | * Return: void |
| 808 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 809 | void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn) |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 810 | { |
| 811 | ce_lro_flush_cb_deregister(scn); |
| 812 | } |
| 813 | #endif |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 814 | |
| 815 | /** |
| 816 | * hif_get_target_status - API to get target status |
| 817 | * @hif_ctx: HIF Context |
| 818 | * |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame^] | 819 | * Return: enum hif_target_status |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 820 | */ |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame^] | 821 | 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] | 822 | { |
| 823 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 824 | |
| 825 | return scn->target_status; |
| 826 | } |
| 827 | |
| 828 | /** |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 829 | * hif_set_target_status() - API to set target status |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 830 | * @hif_ctx: HIF Context |
| 831 | * @status: Target Status |
| 832 | * |
| 833 | * Return: void |
| 834 | */ |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame^] | 835 | void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum |
| 836 | hif_target_status status) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 837 | { |
| 838 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 839 | |
| 840 | scn->target_status = status; |
| 841 | } |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 842 | |
| 843 | /** |
| 844 | * hif_init_ini_config() - API to initialize HIF configuration parameters |
| 845 | * @hif_ctx: HIF Context |
| 846 | * @cfg: HIF Configuration |
| 847 | * |
| 848 | * Return: void |
| 849 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 850 | void hif_init_ini_config(struct hif_opaque_softc *hif_ctx, |
| 851 | struct hif_config_info *cfg) |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 852 | { |
| 853 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 854 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 855 | qdf_mem_copy(&scn->hif_config, cfg, sizeof(struct hif_config_info)); |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 856 | } |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 857 | |
| 858 | /** |
| 859 | * hif_get_conparam() - API to get driver mode in HIF |
| 860 | * @scn: HIF Context |
| 861 | * |
| 862 | * Return: driver mode of operation |
| 863 | */ |
| 864 | uint32_t hif_get_conparam(struct hif_softc *scn) |
| 865 | { |
| 866 | if (!scn) |
| 867 | return 0; |
| 868 | |
| 869 | return scn->hif_con_param; |
| 870 | } |
| 871 | |
| 872 | /** |
| 873 | * hif_get_callbacks_handle() - API to get callbacks Handle |
| 874 | * @scn: HIF Context |
| 875 | * |
| 876 | * Return: pointer to HIF Callbacks |
| 877 | */ |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 878 | struct hif_driver_state_callbacks *hif_get_callbacks_handle(struct hif_softc *scn) |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 879 | { |
| 880 | return &scn->callbacks; |
| 881 | } |
| 882 | |
| 883 | /** |
| 884 | * hif_is_driver_unloading() - API to query upper layers if driver is unloading |
| 885 | * @scn: HIF Context |
| 886 | * |
| 887 | * Return: True/False |
| 888 | */ |
| 889 | bool hif_is_driver_unloading(struct hif_softc *scn) |
| 890 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 891 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 892 | |
| 893 | if (cbk && cbk->is_driver_unloading) |
| 894 | return cbk->is_driver_unloading(cbk->context); |
| 895 | |
| 896 | return false; |
| 897 | } |
| 898 | |
| 899 | /** |
| 900 | * hif_is_load_or_unload_in_progress() - API to query upper layers if |
| 901 | * load/unload in progress |
| 902 | * @scn: HIF Context |
| 903 | * |
| 904 | * Return: True/False |
| 905 | */ |
| 906 | bool hif_is_load_or_unload_in_progress(struct hif_softc *scn) |
| 907 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 908 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 909 | |
| 910 | if (cbk && cbk->is_load_unload_in_progress) |
| 911 | return cbk->is_load_unload_in_progress(cbk->context); |
| 912 | |
| 913 | return false; |
| 914 | } |
| 915 | |
| 916 | /** |
| 917 | * hif_is_recovery_in_progress() - API to query upper layers if recovery in |
| 918 | * progress |
| 919 | * @scn: HIF Context |
| 920 | * |
| 921 | * Return: True/False |
| 922 | */ |
| 923 | bool hif_is_recovery_in_progress(struct hif_softc *scn) |
| 924 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 925 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 926 | |
| 927 | if (cbk && cbk->is_recovery_in_progress) |
| 928 | return cbk->is_recovery_in_progress(cbk->context); |
| 929 | |
| 930 | return false; |
| 931 | } |