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 | |
Houston Hoffman | ec93ab0 | 2016-05-03 20:09:55 -0700 | [diff] [blame^] | 351 | static const struct qwlan_hw qwlan_hw_list[] = { |
| 352 | { |
| 353 | .id = AR6320_REV1_VERSION, |
| 354 | .subid = 0, |
| 355 | .name = "QCA6174_REV1", |
| 356 | }, |
| 357 | { |
| 358 | .id = AR6320_REV1_1_VERSION, |
| 359 | .subid = 0x1, |
| 360 | .name = "QCA6174_REV1_1", |
| 361 | }, |
| 362 | { |
| 363 | .id = AR6320_REV1_3_VERSION, |
| 364 | .subid = 0x2, |
| 365 | .name = "QCA6174_REV1_3", |
| 366 | }, |
| 367 | { |
| 368 | .id = AR6320_REV2_1_VERSION, |
| 369 | .subid = 0x4, |
| 370 | .name = "QCA6174_REV2_1", |
| 371 | }, |
| 372 | { |
| 373 | .id = AR6320_REV2_1_VERSION, |
| 374 | .subid = 0x5, |
| 375 | .name = "QCA6174_REV2_2", |
| 376 | }, |
| 377 | { |
| 378 | .id = AR6320_REV3_VERSION, |
| 379 | .subid = 0x6, |
| 380 | .name = "QCA6174_REV2.3", |
| 381 | }, |
| 382 | { |
| 383 | .id = AR6320_REV3_VERSION, |
| 384 | .subid = 0x8, |
| 385 | .name = "QCA6174_REV3", |
| 386 | }, |
| 387 | { |
| 388 | .id = AR6320_REV3_VERSION, |
| 389 | .subid = 0x9, |
| 390 | .name = "QCA6174_REV3_1", |
| 391 | }, |
| 392 | { |
| 393 | .id = AR6320_REV3_2_VERSION, |
| 394 | .subid = 0xA, |
| 395 | .name = "AR6320_REV3_2_VERSION", |
| 396 | } |
| 397 | }; |
| 398 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 399 | /** |
| 400 | * hif_get_hw_name(): get a human readable name for the hardware |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 401 | * @info: Target Info |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 402 | * |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 403 | * Return: human readable name for the underlying wifi hardware. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 404 | */ |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 405 | static const char *hif_get_hw_name(struct hif_target_info *info) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 406 | { |
| 407 | int i; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 408 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 409 | for (i = 0; i < ARRAY_SIZE(qwlan_hw_list); i++) { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 410 | if (info->target_version == qwlan_hw_list[i].id && |
| 411 | info->target_revision == qwlan_hw_list[i].subid) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 412 | return qwlan_hw_list[i].name; |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | return "Unknown Device"; |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * hif_get_hw_info(): hif_get_hw_info |
| 421 | * @scn: scn |
| 422 | * @version: version |
| 423 | * @revision: revision |
| 424 | * |
| 425 | * Return: n/a |
| 426 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 427 | 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] | 428 | const char **target_name) |
| 429 | { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 430 | struct hif_target_info *info = hif_get_target_info_handle(scn); |
| 431 | *version = info->target_version; |
| 432 | *revision = info->target_revision; |
| 433 | *target_name = hif_get_hw_name(info); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | /** |
| 437 | * hif_open(): hif_open |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 438 | * @qdf_ctx: QDF Context |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 439 | * @mode: Driver Mode |
| 440 | * @bus_type: Bus Type |
| 441 | * @cbk: CDS Callbacks |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 442 | * |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 443 | * API to open HIF Context |
| 444 | * |
| 445 | * Return: HIF Opaque Pointer |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 446 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 447 | struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode, |
| 448 | enum qdf_bus_type bus_type, |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 449 | struct hif_driver_state_callbacks *cbk) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 450 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 451 | struct hif_softc *scn; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 452 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Houston Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 453 | int bus_context_size = hif_bus_get_context_size(bus_type); |
| 454 | |
| 455 | if (bus_context_size == 0) { |
| 456 | HIF_ERROR("%s: context size 0 not allowed", __func__); |
| 457 | return NULL; |
| 458 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 459 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 460 | scn = (struct hif_softc *)qdf_mem_malloc(bus_context_size); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 461 | if (!scn) { |
| 462 | HIF_ERROR("%s: cannot alloc memory for HIF context of size:%d", |
| 463 | __func__, bus_context_size); |
| 464 | return GET_HIF_OPAQUE_HDL(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 465 | } |
| 466 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 467 | qdf_mem_zero(scn, bus_context_size); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 468 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 469 | scn->qdf_dev = qdf_ctx; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 470 | scn->hif_con_param = mode; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 471 | qdf_atomic_init(&scn->active_tasklet_cnt); |
| 472 | qdf_atomic_init(&scn->link_suspended); |
| 473 | qdf_atomic_init(&scn->tasklet_from_intr); |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 474 | qdf_mem_copy(&scn->callbacks, cbk, sizeof(struct hif_driver_state_callbacks)); |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 475 | |
| 476 | status = hif_bus_open(scn, bus_type); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 477 | if (status != QDF_STATUS_SUCCESS) { |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 478 | HIF_ERROR("%s: hif_bus_open error = %d, bus_type = %d", |
| 479 | __func__, status, bus_type); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 480 | qdf_mem_free(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 481 | scn = NULL; |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 482 | } |
| 483 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 484 | return GET_HIF_OPAQUE_HDL(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | /** |
| 488 | * hif_close(): hif_close |
| 489 | * @hif_ctx: hif_ctx |
| 490 | * |
| 491 | * Return: n/a |
| 492 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 493 | void hif_close(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 494 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 495 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 496 | |
| 497 | if (scn == NULL) { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 498 | HIF_ERROR("%s: hif_opaque_softc is NULL", __func__); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 499 | return; |
| 500 | } |
| 501 | |
| 502 | if (scn->athdiag_procfs_inited) { |
| 503 | athdiag_procfs_remove(); |
| 504 | scn->athdiag_procfs_inited = false; |
| 505 | } |
| 506 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 507 | hif_bus_close(scn); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 508 | qdf_mem_free(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | /** |
| 512 | * hif_enable(): hif_enable |
| 513 | * @hif_ctx: hif_ctx |
| 514 | * @dev: dev |
| 515 | * @bdev: bus dev |
| 516 | * @bid: bus ID |
| 517 | * @bus_type: bus type |
| 518 | * @type: enable type |
| 519 | * |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 520 | * Return: QDF_STATUS |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 521 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 522 | 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] | 523 | void *bdev, const 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 | |
| 542 | if (ADRASTEA_BU) |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 543 | hif_vote_link_up(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 544 | |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 545 | if (hif_bus_configure(scn)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 546 | HIF_ERROR("%s: Target probe failed.", __func__); |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 547 | hif_disable_bus(scn); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 548 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 549 | return status; |
| 550 | } |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 551 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 552 | /* |
| 553 | * Flag to avoid potential unallocated memory access from MSI |
| 554 | * interrupt handler which could get scheduled as soon as MSI |
| 555 | * is enabled, i.e to take care of the race due to the order |
| 556 | * in where MSI is enabled before the memory, that will be |
| 557 | * in interrupt handlers, is allocated. |
| 558 | */ |
| 559 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 560 | scn->hif_init_done = true; |
| 561 | |
| 562 | HIF_TRACE("%s: X OK", __func__); |
| 563 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 564 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | /** |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 568 | * hif_wlan_disable(): call the platform driver to disable wlan |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 569 | * @scn: HIF Context |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 570 | * |
| 571 | * This function passes the con_mode to platform driver to disable |
| 572 | * wlan. |
| 573 | * |
| 574 | * Return: void |
| 575 | */ |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 576 | void hif_wlan_disable(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 577 | { |
| 578 | enum icnss_driver_mode mode; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 579 | uint32_t con_mode = hif_get_conparam(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 580 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 581 | if (QDF_GLOBAL_FTM_MODE == con_mode) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 582 | mode = ICNSS_FTM; |
Houston Hoffman | 75ef5a5 | 2016-04-14 17:15:49 -0700 | [diff] [blame] | 583 | else if (QDF_IS_EPPING_ENABLED(con_mode)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 584 | mode = ICNSS_EPPING; |
Peng Xu | 7b96253 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 585 | else |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 586 | mode = ICNSS_MISSION; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 587 | |
| 588 | icnss_wlan_disable(mode); |
| 589 | } |
| 590 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 591 | 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] | 592 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 593 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 594 | |
| 595 | if (!scn) |
| 596 | return; |
| 597 | |
| 598 | hif_nointrs(scn); |
| 599 | if (scn->hif_init_done == false) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 600 | hif_shut_down_device(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 601 | else |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 602 | hif_stop(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 603 | |
| 604 | if (ADRASTEA_BU) |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 605 | hif_vote_link_down(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 606 | |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 607 | hif_disable_bus(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 608 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 609 | hif_wlan_disable(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 610 | |
| 611 | scn->notice_send = false; |
| 612 | |
| 613 | HIF_INFO("%s: X", __func__); |
| 614 | } |
| 615 | |
| 616 | |
| 617 | /** |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 618 | * hif_crash_shutdown_dump_bus_register() - dump bus registers |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 619 | * @hif_ctx: hif_ctx |
| 620 | * |
| 621 | * Return: n/a |
| 622 | */ |
| 623 | #if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \ |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 624 | && defined(DEBUG) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 625 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 626 | static void hif_crash_shutdown_dump_bus_register(void *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 627 | { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 628 | struct hif_opaque_softc *scn = hif_ctx; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 629 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 630 | if (hif_check_soc_status(scn)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 631 | return; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 632 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 633 | if (hif_dump_registers(scn)) |
| 634 | HIF_ERROR("Failed to dump bus registers!"); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | /** |
| 638 | * hif_crash_shutdown(): hif_crash_shutdown |
| 639 | * |
| 640 | * This function is called by the platform driver to dump CE registers |
| 641 | * |
| 642 | * @hif_ctx: hif_ctx |
| 643 | * |
| 644 | * Return: n/a |
| 645 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 646 | void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 647 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 648 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 649 | |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 650 | if (!hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 651 | return; |
| 652 | |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 653 | if (scn->bus_type == QDF_BUS_TYPE_SNOC) { |
| 654 | HIF_INFO_MED("%s: RAM dump disabled for bustype %d", |
| 655 | __func__, scn->bus_type); |
| 656 | return; |
| 657 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 658 | |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 659 | if (TARGET_STATUS_RESET == scn->target_status) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 660 | HIF_INFO_MED("%s: Target is already asserted, ignore!", |
| 661 | __func__); |
| 662 | return; |
| 663 | } |
| 664 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 665 | if (hif_is_load_or_unload_in_progress(scn)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 666 | HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__); |
| 667 | return; |
| 668 | } |
| 669 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 670 | hif_crash_shutdown_dump_bus_register(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 671 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 672 | if (ol_copy_ramdump(hif_ctx)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 673 | goto out; |
| 674 | |
| 675 | HIF_INFO_MED("%s: RAM dump collecting completed!", __func__); |
| 676 | |
| 677 | out: |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 678 | return; |
| 679 | } |
| 680 | #else |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 681 | void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 682 | { |
| 683 | HIF_INFO_MED("%s: Collecting target RAM dump disabled", |
| 684 | __func__); |
| 685 | return; |
| 686 | } |
| 687 | #endif /* TARGET_RAMDUMP_AFTER_KERNEL_PANIC */ |
| 688 | |
| 689 | #ifdef QCA_WIFI_3_0 |
| 690 | /** |
| 691 | * hif_check_fw_reg(): hif_check_fw_reg |
| 692 | * @scn: scn |
| 693 | * @state: |
| 694 | * |
| 695 | * Return: int |
| 696 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 697 | int hif_check_fw_reg(struct hif_opaque_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 698 | { |
| 699 | return 0; |
| 700 | } |
| 701 | #endif |
| 702 | |
| 703 | #ifdef IPA_OFFLOAD |
| 704 | /** |
| 705 | * hif_read_phy_mem_base(): hif_read_phy_mem_base |
| 706 | * @scn: scn |
| 707 | * @phy_mem_base: physical mem base |
| 708 | * |
| 709 | * Return: n/a |
| 710 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 711 | 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] | 712 | { |
| 713 | *phy_mem_base = scn->mem_pa; |
| 714 | } |
| 715 | #endif /* IPA_OFFLOAD */ |
| 716 | |
| 717 | /** |
| 718 | * hif_get_device_type(): hif_get_device_type |
| 719 | * @device_id: device_id |
| 720 | * @revision_id: revision_id |
| 721 | * @hif_type: returned hif_type |
| 722 | * @target_type: returned target_type |
| 723 | * |
| 724 | * Return: int |
| 725 | */ |
| 726 | int hif_get_device_type(uint32_t device_id, |
| 727 | uint32_t revision_id, |
| 728 | uint32_t *hif_type, uint32_t *target_type) |
| 729 | { |
| 730 | int ret = 0; |
| 731 | |
| 732 | switch (device_id) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 733 | case ADRASTEA_DEVICE_ID: |
| 734 | case ADRASTEA_DEVICE_ID_P2_E12: |
| 735 | |
| 736 | *hif_type = HIF_TYPE_ADRASTEA; |
| 737 | *target_type = TARGET_TYPE_ADRASTEA; |
| 738 | break; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 739 | |
| 740 | case AR9888_DEVICE_ID: |
| 741 | *hif_type = HIF_TYPE_AR9888; |
| 742 | *target_type = TARGET_TYPE_AR9888; |
| 743 | break; |
| 744 | |
| 745 | case AR6320_DEVICE_ID: |
| 746 | switch (revision_id) { |
| 747 | case AR6320_FW_1_1: |
| 748 | case AR6320_FW_1_3: |
| 749 | *hif_type = HIF_TYPE_AR6320; |
| 750 | *target_type = TARGET_TYPE_AR6320; |
| 751 | break; |
| 752 | |
| 753 | case AR6320_FW_2_0: |
| 754 | case AR6320_FW_3_0: |
| 755 | case AR6320_FW_3_2: |
| 756 | *hif_type = HIF_TYPE_AR6320V2; |
| 757 | *target_type = TARGET_TYPE_AR6320V2; |
| 758 | break; |
| 759 | |
| 760 | default: |
| 761 | HIF_ERROR("%s: error - dev_id = 0x%x, rev_id = 0x%x", |
| 762 | __func__, device_id, revision_id); |
| 763 | ret = -ENODEV; |
| 764 | goto end; |
| 765 | } |
| 766 | break; |
| 767 | |
| 768 | default: |
| 769 | HIF_ERROR("%s: Unsupported device ID!", __func__); |
| 770 | ret = -ENODEV; |
| 771 | break; |
| 772 | } |
| 773 | end: |
| 774 | return ret; |
| 775 | } |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 776 | |
| 777 | /** |
Houston Hoffman | 2635259 | 2016-03-14 21:11:43 -0700 | [diff] [blame] | 778 | * hif_needs_bmi() - return true if the soc needs bmi through the driver |
| 779 | * @hif_ctx: hif context |
| 780 | * |
| 781 | * Return: true if the soc needs driver bmi otherwise false |
| 782 | */ |
| 783 | bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx) |
| 784 | { |
| 785 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 786 | return hif_sc->bus_type != QDF_BUS_TYPE_SNOC; |
| 787 | } |
| 788 | |
| 789 | /** |
Houston Hoffman | 60a1eeb | 2016-03-14 21:11:44 -0700 | [diff] [blame] | 790 | * hif_get_bus_type() - return the bus type |
| 791 | * |
| 792 | * Return: enum qdf_bus_type |
| 793 | */ |
| 794 | enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl) |
| 795 | { |
| 796 | struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl); |
| 797 | return scn->bus_type; |
| 798 | } |
| 799 | |
| 800 | /** |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 801 | * Target info and ini parameters are global to the driver |
| 802 | * Hence these structures are exposed to all the modules in |
| 803 | * the driver and they don't need to maintains multiple copies |
| 804 | * of the same info, instead get the handle from hif and |
| 805 | * modify them in hif |
| 806 | */ |
| 807 | |
| 808 | /** |
| 809 | * hif_get_ini_handle() - API to get hif_config_param handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 810 | * @hif_ctx: HIF Context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 811 | * |
| 812 | * Return: pointer to hif_config_info |
| 813 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 814 | 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] | 815 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 816 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 817 | |
| 818 | return &sc->hif_config; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | /** |
| 822 | * hif_get_target_info_handle() - API to get hif_target_info handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 823 | * @hif_ctx: HIF context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 824 | * |
| 825 | * Return: Pointer to hif_target_info |
| 826 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 827 | struct hif_target_info *hif_get_target_info_handle( |
| 828 | struct hif_opaque_softc *hif_ctx) |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 829 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 830 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 831 | |
| 832 | return &sc->target_info; |
| 833 | |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 834 | } |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 835 | |
| 836 | #if defined(FEATURE_LRO) |
| 837 | /** |
| 838 | * hif_lro_flush_cb_register - API to register for LRO Flush Callback |
| 839 | * @scn: HIF Context |
| 840 | * @handler: Function pointer to be called by HIF |
| 841 | * @data: Private data to be used by the module registering to HIF |
| 842 | * |
| 843 | * Return: void |
| 844 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 845 | void hif_lro_flush_cb_register(struct hif_opaque_softc *scn, |
| 846 | void (handler)(void *), void *data) |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 847 | { |
| 848 | ce_lro_flush_cb_register(scn, handler, data); |
| 849 | } |
| 850 | |
| 851 | /** |
| 852 | * hif_lro_flush_cb_deregister - API to deregister for LRO Flush Callbacks |
| 853 | * @scn: HIF Context |
| 854 | * |
| 855 | * Return: void |
| 856 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 857 | void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn) |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 858 | { |
| 859 | ce_lro_flush_cb_deregister(scn); |
| 860 | } |
| 861 | #endif |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 862 | |
| 863 | /** |
| 864 | * hif_get_target_status - API to get target status |
| 865 | * @hif_ctx: HIF Context |
| 866 | * |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 867 | * Return: enum hif_target_status |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 868 | */ |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 869 | 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] | 870 | { |
| 871 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 872 | |
| 873 | return scn->target_status; |
| 874 | } |
| 875 | |
| 876 | /** |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 877 | * hif_set_target_status() - API to set target status |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 878 | * @hif_ctx: HIF Context |
| 879 | * @status: Target Status |
| 880 | * |
| 881 | * Return: void |
| 882 | */ |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 883 | void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum |
| 884 | hif_target_status status) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 885 | { |
| 886 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 887 | |
| 888 | scn->target_status = status; |
| 889 | } |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 890 | |
| 891 | /** |
| 892 | * hif_init_ini_config() - API to initialize HIF configuration parameters |
| 893 | * @hif_ctx: HIF Context |
| 894 | * @cfg: HIF Configuration |
| 895 | * |
| 896 | * Return: void |
| 897 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 898 | void hif_init_ini_config(struct hif_opaque_softc *hif_ctx, |
| 899 | struct hif_config_info *cfg) |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 900 | { |
| 901 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 902 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 903 | qdf_mem_copy(&scn->hif_config, cfg, sizeof(struct hif_config_info)); |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 904 | } |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 905 | |
| 906 | /** |
| 907 | * hif_get_conparam() - API to get driver mode in HIF |
| 908 | * @scn: HIF Context |
| 909 | * |
| 910 | * Return: driver mode of operation |
| 911 | */ |
| 912 | uint32_t hif_get_conparam(struct hif_softc *scn) |
| 913 | { |
| 914 | if (!scn) |
| 915 | return 0; |
| 916 | |
| 917 | return scn->hif_con_param; |
| 918 | } |
| 919 | |
| 920 | /** |
| 921 | * hif_get_callbacks_handle() - API to get callbacks Handle |
| 922 | * @scn: HIF Context |
| 923 | * |
| 924 | * Return: pointer to HIF Callbacks |
| 925 | */ |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 926 | 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] | 927 | { |
| 928 | return &scn->callbacks; |
| 929 | } |
| 930 | |
| 931 | /** |
| 932 | * hif_is_driver_unloading() - API to query upper layers if driver is unloading |
| 933 | * @scn: HIF Context |
| 934 | * |
| 935 | * Return: True/False |
| 936 | */ |
| 937 | bool hif_is_driver_unloading(struct hif_softc *scn) |
| 938 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 939 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 940 | |
| 941 | if (cbk && cbk->is_driver_unloading) |
| 942 | return cbk->is_driver_unloading(cbk->context); |
| 943 | |
| 944 | return false; |
| 945 | } |
| 946 | |
| 947 | /** |
| 948 | * hif_is_load_or_unload_in_progress() - API to query upper layers if |
| 949 | * load/unload in progress |
| 950 | * @scn: HIF Context |
| 951 | * |
| 952 | * Return: True/False |
| 953 | */ |
| 954 | bool hif_is_load_or_unload_in_progress(struct hif_softc *scn) |
| 955 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 956 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 957 | |
| 958 | if (cbk && cbk->is_load_unload_in_progress) |
| 959 | return cbk->is_load_unload_in_progress(cbk->context); |
| 960 | |
| 961 | return false; |
| 962 | } |
| 963 | |
| 964 | /** |
| 965 | * hif_is_recovery_in_progress() - API to query upper layers if recovery in |
| 966 | * progress |
| 967 | * @scn: HIF Context |
| 968 | * |
| 969 | * Return: True/False |
| 970 | */ |
| 971 | bool hif_is_recovery_in_progress(struct hif_softc *scn) |
| 972 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 973 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 974 | |
| 975 | if (cbk && cbk->is_recovery_in_progress) |
| 976 | return cbk->is_recovery_in_progress(cbk->context); |
| 977 | |
| 978 | return false; |
| 979 | } |