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 | |
| 28 | #include <osdep.h> |
| 29 | #include "a_types.h" |
| 30 | #include "athdefs.h" |
| 31 | #include "osapi_linux.h" |
| 32 | #include "targcfg.h" |
| 33 | #include "cdf_lock.h" |
| 34 | #include "cdf_status.h" |
| 35 | #include <cdf_atomic.h> /* cdf_atomic_read */ |
| 36 | #include <targaddrs.h> |
| 37 | #include <bmi_msg.h> |
| 38 | #include "hif_io32.h" |
| 39 | #include <hif.h> |
| 40 | #include <htc_services.h> |
| 41 | #include "regtable.h" |
| 42 | #define ATH_MODULE_NAME hif |
| 43 | #include <a_debug.h> |
| 44 | #include "hif_main.h" |
| 45 | #include "hif_hw_version.h" |
| 46 | #include "ce_api.h" |
| 47 | #include "ce_tasklet.h" |
| 48 | #include "cdf_trace.h" |
| 49 | #include "cdf_status.h" |
| 50 | #include "cds_api.h" |
| 51 | #ifdef CONFIG_CNSS |
| 52 | #include <net/cnss.h> |
| 53 | #endif |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 54 | #include "epping_main.h" |
| 55 | #include "hif_debug.h" |
| 56 | #include "mp_dev.h" |
| 57 | #ifdef HIF_PCI |
| 58 | #include "icnss_stub.h" |
| 59 | #else |
| 60 | #include <soc/qcom/icnss.h> |
| 61 | #endif |
| 62 | |
Chandrasekaran, Manishekar | 681d137 | 2015-11-05 10:42:48 +0530 | [diff] [blame] | 63 | #include "cds_concurrency.h" |
| 64 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 65 | #define AGC_DUMP 1 |
| 66 | #define CHANINFO_DUMP 2 |
| 67 | #define BB_WATCHDOG_DUMP 3 |
| 68 | #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG |
| 69 | #define PCIE_ACCESS_DUMP 4 |
| 70 | #endif |
| 71 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 72 | void hif_dump(struct ol_softc *hif_ctx, uint8_t cmd_id, bool start) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 73 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 74 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 75 | switch (cmd_id) { |
| 76 | case AGC_DUMP: |
| 77 | if (start) |
| 78 | priv_start_agc(scn); |
| 79 | else |
| 80 | priv_dump_agc(scn); |
| 81 | break; |
| 82 | |
| 83 | case CHANINFO_DUMP: |
| 84 | if (start) |
| 85 | priv_start_cap_chaninfo(scn); |
| 86 | else |
| 87 | priv_dump_chaninfo(scn); |
| 88 | break; |
| 89 | |
| 90 | case BB_WATCHDOG_DUMP: |
| 91 | priv_dump_bbwatchdog(scn); |
| 92 | break; |
| 93 | |
| 94 | #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG |
| 95 | case PCIE_ACCESS_DUMP: |
| 96 | hif_target_dump_access_log(); |
| 97 | break; |
| 98 | #endif |
| 99 | default: |
| 100 | HIF_ERROR("%s: Invalid htc dump command", __func__); |
| 101 | break; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * hif_shut_down_device() - hif_shut_down_device |
| 107 | * |
| 108 | * SThis fucntion shuts down the device |
| 109 | * |
| 110 | * @scn: ol_softc |
| 111 | * |
| 112 | * Return: void |
| 113 | */ |
| 114 | void hif_shut_down_device(struct ol_softc *scn) |
| 115 | { |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 116 | hif_stop(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | |
| 120 | |
| 121 | /** |
| 122 | * hif_cancel_deferred_target_sleep() - cancel deferred target sleep |
| 123 | * |
| 124 | * This function cancels the defered target sleep |
| 125 | * |
| 126 | * @scn: ol_softc |
| 127 | * |
| 128 | * Return: void |
| 129 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 130 | void hif_cancel_deferred_target_sleep(struct ol_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 131 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 132 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 133 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 134 | hif_pci_cancel_deferred_target_sleep(scn); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * hif_get_target_id(): hif_get_target_id |
| 139 | * |
| 140 | * Return the virtual memory base address to the caller |
| 141 | * |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 142 | * @scn: hif_softc |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 143 | * |
| 144 | * Return: A_target_id_t |
| 145 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 146 | A_target_id_t hif_get_target_id(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 147 | { |
| 148 | return scn->mem; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * hif_set_target_sleep(): hif_set_target_sleep |
| 153 | * @scn: scn |
| 154 | * @sleep_ok: sleep_ok |
| 155 | * @wait_for_it: wait |
| 156 | * |
| 157 | * Return: void |
| 158 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 159 | void hif_set_target_sleep(struct ol_softc *hif_ctx, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 160 | bool sleep_ok, bool wait_for_it) |
| 161 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 162 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 163 | hif_target_sleep_state_adjust(scn, |
| 164 | sleep_ok, wait_for_it); |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * hif_target_forced_awake(): hif_target_forced_awake |
| 169 | * @scn: scn |
| 170 | * |
| 171 | * Return: bool |
| 172 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 173 | bool hif_target_forced_awake(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 174 | { |
| 175 | A_target_id_t addr = scn->mem; |
| 176 | bool awake; |
| 177 | bool forced_awake; |
| 178 | |
| 179 | awake = hif_targ_is_awake(scn, addr); |
| 180 | |
| 181 | forced_awake = |
| 182 | !!(hif_read32_mb |
| 183 | (addr + PCIE_LOCAL_BASE_ADDRESS + |
| 184 | PCIE_SOC_WAKE_ADDRESS) & PCIE_SOC_WAKE_V_MASK); |
| 185 | |
| 186 | return awake && forced_awake; |
| 187 | } |
| 188 | |
Houston Hoffman | 0dad509 | 2015-09-28 16:25:51 -0700 | [diff] [blame] | 189 | |
| 190 | static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state) |
| 191 | { |
| 192 | struct hif_msg_callbacks *msg_callbacks = |
| 193 | &hif_state->msg_callbacks_current; |
| 194 | |
| 195 | if (!msg_callbacks->fwEventHandler) |
| 196 | return; |
| 197 | |
| 198 | msg_callbacks->fwEventHandler(msg_callbacks->Context, |
| 199 | CDF_STATUS_E_FAILURE); |
| 200 | } |
| 201 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 202 | /** |
| 203 | * hif_fw_interrupt_handler(): FW interrupt handler |
| 204 | * |
| 205 | * This function is the FW interrupt handlder |
| 206 | * |
| 207 | * @irq: irq number |
| 208 | * @arg: the user pointer |
| 209 | * |
| 210 | * Return: bool |
| 211 | */ |
| 212 | #ifndef QCA_WIFI_3_0 |
| 213 | irqreturn_t hif_fw_interrupt_handler(int irq, void *arg) |
| 214 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 215 | struct hif_softc *scn = arg; |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 216 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 217 | uint32_t fw_indicator_address, fw_indicator; |
| 218 | |
| 219 | A_TARGET_ACCESS_BEGIN_RET(scn); |
| 220 | |
| 221 | fw_indicator_address = hif_state->fw_indicator_address; |
| 222 | /* For sudden unplug this will return ~0 */ |
| 223 | fw_indicator = A_TARGET_READ(scn, fw_indicator_address); |
| 224 | |
| 225 | if ((fw_indicator != ~0) && (fw_indicator & FW_IND_EVENT_PENDING)) { |
| 226 | /* ACK: clear Target-side pending event */ |
| 227 | A_TARGET_WRITE(scn, fw_indicator_address, |
| 228 | fw_indicator & ~FW_IND_EVENT_PENDING); |
| 229 | A_TARGET_ACCESS_END_RET(scn); |
| 230 | |
| 231 | if (hif_state->started) { |
Houston Hoffman | 0dad509 | 2015-09-28 16:25:51 -0700 | [diff] [blame] | 232 | hif_fw_event_handler(hif_state); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 233 | } else { |
| 234 | /* |
| 235 | * Probable Target failure before we're prepared |
| 236 | * to handle it. Generally unexpected. |
| 237 | */ |
| 238 | AR_DEBUG_PRINTF(ATH_DEBUG_ERR, |
| 239 | ("%s: Early firmware event indicated\n", |
| 240 | __func__)); |
| 241 | } |
| 242 | } else { |
| 243 | A_TARGET_ACCESS_END_RET(scn); |
| 244 | } |
| 245 | |
| 246 | return ATH_ISR_SCHED; |
| 247 | } |
| 248 | #else |
| 249 | irqreturn_t hif_fw_interrupt_handler(int irq, void *arg) |
| 250 | { |
| 251 | return ATH_ISR_SCHED; |
| 252 | } |
| 253 | #endif /* #ifdef QCA_WIFI_3_0 */ |
| 254 | |
| 255 | /** |
| 256 | * hif_get_targetdef(): hif_get_targetdef |
| 257 | * @scn: scn |
| 258 | * |
| 259 | * Return: void * |
| 260 | */ |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 261 | void *hif_get_targetdef(struct ol_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 262 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 263 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 264 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 265 | return scn->targetdef; |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * hif_vote_link_down(): unvote for link up |
| 270 | * |
| 271 | * Call hif_vote_link_down to release a previous request made using |
| 272 | * hif_vote_link_up. A hif_vote_link_down call should only be made |
| 273 | * after a corresponding hif_vote_link_up, otherwise you could be |
| 274 | * negating a vote from another source. When no votes are present |
| 275 | * hif will not guarantee the linkstate after hif_bus_suspend. |
| 276 | * |
| 277 | * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread |
| 278 | * and initialization deinitialization sequencences. |
| 279 | * |
| 280 | * Return: n/a |
| 281 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 282 | void hif_vote_link_down(struct ol_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 283 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 284 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 285 | CDF_BUG(scn); |
| 286 | |
| 287 | scn->linkstate_vote--; |
| 288 | if (scn->linkstate_vote == 0) |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 289 | hif_bus_prevent_linkdown(scn, false); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | /** |
| 293 | * hif_vote_link_up(): vote to prevent bus from suspending |
| 294 | * |
| 295 | * Makes hif guarantee that fw can message the host normally |
| 296 | * durring suspend. |
| 297 | * |
| 298 | * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread |
| 299 | * and initialization deinitialization sequencences. |
| 300 | * |
| 301 | * Return: n/a |
| 302 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 303 | void hif_vote_link_up(struct ol_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 304 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 305 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 306 | CDF_BUG(scn); |
| 307 | |
| 308 | scn->linkstate_vote++; |
| 309 | if (scn->linkstate_vote == 1) |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 310 | hif_bus_prevent_linkdown(scn, true); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | /** |
| 314 | * hif_can_suspend_link(): query if hif is permitted to suspend the link |
| 315 | * |
| 316 | * Hif will ensure that the link won't be suspended if the upperlayers |
| 317 | * don't want it to. |
| 318 | * |
| 319 | * SYNCHRONIZATION: MC thread is stopped before bus suspend thus |
| 320 | * we don't need extra locking to ensure votes dont change while |
| 321 | * we are in the process of suspending or resuming. |
| 322 | * |
| 323 | * Return: false if hif will guarantee link up durring suspend. |
| 324 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 325 | bool hif_can_suspend_link(struct ol_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 326 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 327 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 328 | CDF_BUG(scn); |
| 329 | |
| 330 | return scn->linkstate_vote == 0; |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * hif_hia_item_address(): hif_hia_item_address |
| 335 | * @target_type: target_type |
| 336 | * @item_offset: item_offset |
| 337 | * |
| 338 | * Return: n/a |
| 339 | */ |
| 340 | uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset) |
| 341 | { |
| 342 | switch (target_type) { |
| 343 | case TARGET_TYPE_AR6002: |
| 344 | return AR6002_HOST_INTEREST_ADDRESS + item_offset; |
| 345 | case TARGET_TYPE_AR6003: |
| 346 | return AR6003_HOST_INTEREST_ADDRESS + item_offset; |
| 347 | case TARGET_TYPE_AR6004: |
| 348 | return AR6004_HOST_INTEREST_ADDRESS + item_offset; |
| 349 | case TARGET_TYPE_AR6006: |
| 350 | return AR6006_HOST_INTEREST_ADDRESS + item_offset; |
| 351 | case TARGET_TYPE_AR9888: |
| 352 | return AR9888_HOST_INTEREST_ADDRESS + item_offset; |
| 353 | case TARGET_TYPE_AR6320: |
| 354 | case TARGET_TYPE_AR6320V2: |
| 355 | return AR6320_HOST_INTEREST_ADDRESS + item_offset; |
| 356 | case TARGET_TYPE_QCA6180: |
| 357 | return QCA6180_HOST_INTEREST_ADDRESS + item_offset; |
| 358 | case TARGET_TYPE_ADRASTEA: |
| 359 | /* ADRASTEA doesn't have a host interest address */ |
| 360 | ASSERT(0); |
| 361 | return 0; |
| 362 | default: |
| 363 | ASSERT(0); |
| 364 | return 0; |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * hif_max_num_receives_reached() - check max receive is reached |
| 370 | * @count: unsigned int. |
| 371 | * |
| 372 | * Output check status as bool |
| 373 | * |
| 374 | * Return: bool |
| 375 | */ |
| 376 | bool hif_max_num_receives_reached(unsigned int count) |
| 377 | { |
| 378 | if (WLAN_IS_EPPING_ENABLED(cds_get_conparam())) |
| 379 | return count > 120; |
| 380 | else |
| 381 | return count > MAX_NUM_OF_RECEIVES; |
| 382 | } |
| 383 | |
| 384 | /** |
| 385 | * init_buffer_count() - initial buffer count |
| 386 | * @maxSize: cdf_size_t |
| 387 | * |
| 388 | * routine to modify the initial buffer count to be allocated on an os |
| 389 | * platform basis. Platform owner will need to modify this as needed |
| 390 | * |
| 391 | * Return: cdf_size_t |
| 392 | */ |
| 393 | cdf_size_t init_buffer_count(cdf_size_t maxSize) |
| 394 | { |
| 395 | return maxSize; |
| 396 | } |
| 397 | |
| 398 | /** |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 399 | * hif_save_htc_htt_config_endpoint(): |
| 400 | * hif_save_htc_htt_config_endpoint |
| 401 | * @htc_endpoint: htc_endpoint |
| 402 | * |
| 403 | * Return: void |
| 404 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 405 | void |
| 406 | hif_save_htc_htt_config_endpoint(struct ol_softc *hif_ctx, int htc_endpoint) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 407 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 408 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 409 | |
| 410 | if (!scn) { |
| 411 | HIF_ERROR("%s: error: scn or scn->hif_sc is NULL!", |
| 412 | __func__); |
| 413 | return; |
| 414 | } |
| 415 | |
| 416 | scn->htc_endpoint = htc_endpoint; |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * hif_get_hw_name(): get a human readable name for the hardware |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 421 | * @info: Target Info |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 422 | * |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 423 | * Return: human readable name for the underlying wifi hardware. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 424 | */ |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 425 | static const char *hif_get_hw_name(struct hif_target_info *info) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 426 | { |
| 427 | int i; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 428 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 429 | for (i = 0; i < ARRAY_SIZE(qwlan_hw_list); i++) { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 430 | if (info->target_version == qwlan_hw_list[i].id && |
| 431 | info->target_revision == qwlan_hw_list[i].subid) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 432 | return qwlan_hw_list[i].name; |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | return "Unknown Device"; |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * hif_get_hw_info(): hif_get_hw_info |
| 441 | * @scn: scn |
| 442 | * @version: version |
| 443 | * @revision: revision |
| 444 | * |
| 445 | * Return: n/a |
| 446 | */ |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 447 | void hif_get_hw_info(struct ol_softc *scn, u32 *version, u32 *revision, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 448 | const char **target_name) |
| 449 | { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 450 | struct hif_target_info *info = hif_get_target_info_handle(scn); |
| 451 | *version = info->target_version; |
| 452 | *revision = info->target_revision; |
| 453 | *target_name = hif_get_hw_name(info); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | /** |
| 457 | * hif_open(): hif_open |
| 458 | * |
| 459 | * Return: scn |
| 460 | */ |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 461 | CDF_STATUS hif_open(cdf_device_t cdf_ctx, enum ath_hal_bus_type bus_type) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 462 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 463 | struct ol_softc *hif_hdl; |
| 464 | struct hif_softc *scn; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 465 | v_CONTEXT_t cds_context; |
| 466 | CDF_STATUS status = CDF_STATUS_SUCCESS; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 467 | struct hif_config_info *cfg; |
Komal Seelam | 43301de | 2016-02-02 18:20:48 +0530 | [diff] [blame] | 468 | int bus_context_size = hif_bus_get_context_size(); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 469 | |
| 470 | cds_context = cds_get_global_context(); |
| 471 | status = cds_alloc_context(cds_context, CDF_MODULE_ID_HIF, |
Komal Seelam | 43301de | 2016-02-02 18:20:48 +0530 | [diff] [blame] | 472 | (void **)&scn, bus_context_size); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 473 | if (status != CDF_STATUS_SUCCESS) { |
| 474 | HIF_ERROR("%s: cannot alloc ol_sc", __func__); |
| 475 | return status; |
| 476 | } |
| 477 | |
Komal Seelam | 43301de | 2016-02-02 18:20:48 +0530 | [diff] [blame] | 478 | cdf_mem_zero(scn, bus_context_size); |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 479 | hif_hdl = GET_HIF_OPAQUE_HDL(scn); |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 480 | scn->cdf_dev = cdf_ctx; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 481 | cfg = hif_get_ini_handle(hif_hdl); |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 482 | cfg->max_no_of_peers = 1; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 483 | cdf_atomic_init(&scn->active_tasklet_cnt); |
| 484 | cdf_atomic_init(&scn->link_suspended); |
| 485 | cdf_atomic_init(&scn->tasklet_from_intr); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 486 | scn->linkstate_vote = 0; |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 487 | |
| 488 | status = hif_bus_open(scn, bus_type); |
| 489 | if (status != CDF_STATUS_SUCCESS) { |
| 490 | HIF_ERROR("%s: hif_bus_open error = %d, bus_type = %d", |
| 491 | __func__, status, bus_type); |
| 492 | cds_free_context(cds_context, CDF_MODULE_ID_HIF, scn); |
| 493 | } |
| 494 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 495 | return status; |
| 496 | } |
| 497 | |
| 498 | /** |
| 499 | * hif_close(): hif_close |
| 500 | * @hif_ctx: hif_ctx |
| 501 | * |
| 502 | * Return: n/a |
| 503 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 504 | void hif_close(struct ol_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 505 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 506 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 507 | |
| 508 | if (scn == NULL) { |
| 509 | HIF_ERROR("%s: ol_softc is NULL", __func__); |
| 510 | return; |
| 511 | } |
| 512 | |
| 513 | if (scn->athdiag_procfs_inited) { |
| 514 | athdiag_procfs_remove(); |
| 515 | scn->athdiag_procfs_inited = false; |
| 516 | } |
| 517 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 518 | hif_bus_close(scn); |
| 519 | cds_free_context(cds_get_global_context(), |
| 520 | CDF_MODULE_ID_HIF, hif_ctx); |
| 521 | } |
| 522 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 523 | void hif_init_opaque_handle(struct hif_softc *scn) |
| 524 | { |
| 525 | struct ol_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn); |
| 526 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 527 | hif_hdl->targetdef = scn->targetdef; |
| 528 | } |
| 529 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 530 | /** |
| 531 | * hif_enable(): hif_enable |
| 532 | * @hif_ctx: hif_ctx |
| 533 | * @dev: dev |
| 534 | * @bdev: bus dev |
| 535 | * @bid: bus ID |
| 536 | * @bus_type: bus type |
| 537 | * @type: enable type |
| 538 | * |
| 539 | * Return: CDF_STATUS |
| 540 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 541 | CDF_STATUS hif_enable(struct ol_softc *hif_ctx, struct device *dev, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 542 | void *bdev, const hif_bus_id *bid, |
| 543 | enum ath_hal_bus_type bus_type, |
| 544 | enum hif_enable_type type) |
| 545 | { |
| 546 | CDF_STATUS status; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 547 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 548 | |
| 549 | if (scn == NULL) { |
| 550 | HIF_ERROR("%s: hif_ctx = NULL", __func__); |
| 551 | return CDF_STATUS_E_NULL_VALUE; |
| 552 | } |
| 553 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 554 | status = hif_enable_bus(scn, dev, bdev, bid, type); |
| 555 | if (status != CDF_STATUS_SUCCESS) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 556 | HIF_ERROR("%s: hif_enable_bus error = %d", |
| 557 | __func__, status); |
| 558 | return status; |
| 559 | } |
| 560 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 561 | hif_init_opaque_handle(scn); |
| 562 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 563 | if (ADRASTEA_BU) |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 564 | hif_vote_link_up(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 565 | |
| 566 | if (hif_config_ce(scn)) { |
| 567 | HIF_ERROR("%s: Target probe failed.", __func__); |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame^] | 568 | hif_disable_bus(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 569 | status = CDF_STATUS_E_FAILURE; |
| 570 | return status; |
| 571 | } |
| 572 | /* |
| 573 | * Flag to avoid potential unallocated memory access from MSI |
| 574 | * interrupt handler which could get scheduled as soon as MSI |
| 575 | * is enabled, i.e to take care of the race due to the order |
| 576 | * in where MSI is enabled before the memory, that will be |
| 577 | * in interrupt handlers, is allocated. |
| 578 | */ |
| 579 | |
| 580 | #ifdef HIF_PCI |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 581 | status = hif_configure_irq(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 582 | if (status < 0) { |
| 583 | HIF_ERROR("%s: ERROR - configure_IRQ_and_CE failed, status = %d", |
| 584 | __func__, status); |
| 585 | return CDF_STATUS_E_FAILURE; |
| 586 | } |
| 587 | #endif |
| 588 | |
| 589 | scn->hif_init_done = true; |
| 590 | |
| 591 | HIF_TRACE("%s: X OK", __func__); |
| 592 | |
| 593 | return CDF_STATUS_SUCCESS; |
| 594 | } |
| 595 | |
| 596 | /** |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 597 | * hif_wlan_disable(): call the platform driver to disable wlan |
| 598 | * |
| 599 | * This function passes the con_mode to platform driver to disable |
| 600 | * wlan. |
| 601 | * |
| 602 | * Return: void |
| 603 | */ |
| 604 | void hif_wlan_disable(void) |
| 605 | { |
| 606 | enum icnss_driver_mode mode; |
| 607 | uint32_t con_mode = cds_get_conparam(); |
| 608 | |
Peng Xu | 7b96253 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 609 | if (CDF_GLOBAL_FTM_MODE == con_mode) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 610 | mode = ICNSS_FTM; |
Peng Xu | 7b96253 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 611 | else if (WLAN_IS_EPPING_ENABLED(cds_get_conparam())) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 612 | mode = ICNSS_EPPING; |
Peng Xu | 7b96253 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 613 | else |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 614 | mode = ICNSS_MISSION; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 615 | |
| 616 | icnss_wlan_disable(mode); |
| 617 | } |
| 618 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 619 | void hif_disable(struct ol_softc *hif_ctx, enum hif_disable_type type) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 620 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 621 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 622 | |
| 623 | if (!scn) |
| 624 | return; |
| 625 | |
| 626 | hif_nointrs(scn); |
| 627 | if (scn->hif_init_done == false) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 628 | hif_shut_down_device(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 629 | else |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 630 | hif_stop(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 631 | |
| 632 | if (ADRASTEA_BU) |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 633 | hif_vote_link_down(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 634 | |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame^] | 635 | hif_disable_bus(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 636 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 637 | hif_wlan_disable(); |
| 638 | |
| 639 | scn->notice_send = false; |
| 640 | |
| 641 | HIF_INFO("%s: X", __func__); |
| 642 | } |
| 643 | |
| 644 | |
| 645 | /** |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 646 | * hif_crash_shutdown_dump_bus_register() - dump bus registers |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 647 | * @hif_ctx: hif_ctx |
| 648 | * |
| 649 | * Return: n/a |
| 650 | */ |
| 651 | #if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \ |
| 652 | && defined(HIF_PCI) && defined(DEBUG) |
| 653 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 654 | static void hif_crash_shutdown_dump_bus_register(void *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 655 | { |
| 656 | struct ol_softc *scn = hif_ctx; |
| 657 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 658 | if (hif_check_soc_status(scn)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 659 | return; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 660 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 661 | if (hif_dump_registers(scn)) |
| 662 | HIF_ERROR("Failed to dump bus registers!"); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | /** |
| 666 | * hif_crash_shutdown(): hif_crash_shutdown |
| 667 | * |
| 668 | * This function is called by the platform driver to dump CE registers |
| 669 | * |
| 670 | * @hif_ctx: hif_ctx |
| 671 | * |
| 672 | * Return: n/a |
| 673 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 674 | void hif_crash_shutdown(struct ol_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 675 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 676 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 677 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 678 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 679 | if (!hif_state) |
| 680 | return; |
| 681 | |
| 682 | |
| 683 | if (OL_TRGET_STATUS_RESET == scn->target_status) { |
| 684 | HIF_INFO_MED("%s: Target is already asserted, ignore!", |
| 685 | __func__); |
| 686 | return; |
| 687 | } |
| 688 | |
Rajeev Kumar | e3b4b4b | 2016-01-19 15:23:52 -0800 | [diff] [blame] | 689 | if (cds_is_load_or_unload_in_progress()) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 690 | HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__); |
| 691 | return; |
| 692 | } |
| 693 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 694 | hif_crash_shutdown_dump_bus_register(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 695 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 696 | if (ol_copy_ramdump(hif_ctx)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 697 | goto out; |
| 698 | |
| 699 | HIF_INFO_MED("%s: RAM dump collecting completed!", __func__); |
| 700 | |
| 701 | out: |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 702 | return; |
| 703 | } |
| 704 | #else |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 705 | void hif_crash_shutdown(struct ol_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 706 | { |
| 707 | HIF_INFO_MED("%s: Collecting target RAM dump disabled", |
| 708 | __func__); |
| 709 | return; |
| 710 | } |
| 711 | #endif /* TARGET_RAMDUMP_AFTER_KERNEL_PANIC */ |
| 712 | |
| 713 | #ifdef QCA_WIFI_3_0 |
| 714 | /** |
| 715 | * hif_check_fw_reg(): hif_check_fw_reg |
| 716 | * @scn: scn |
| 717 | * @state: |
| 718 | * |
| 719 | * Return: int |
| 720 | */ |
| 721 | int hif_check_fw_reg(struct ol_softc *scn) |
| 722 | { |
| 723 | return 0; |
| 724 | } |
| 725 | #endif |
| 726 | |
| 727 | #ifdef IPA_OFFLOAD |
| 728 | /** |
| 729 | * hif_read_phy_mem_base(): hif_read_phy_mem_base |
| 730 | * @scn: scn |
| 731 | * @phy_mem_base: physical mem base |
| 732 | * |
| 733 | * Return: n/a |
| 734 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 735 | void hif_read_phy_mem_base(struct hif_softc *scn, cdf_dma_addr_t *phy_mem_base) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 736 | { |
| 737 | *phy_mem_base = scn->mem_pa; |
| 738 | } |
| 739 | #endif /* IPA_OFFLOAD */ |
| 740 | |
| 741 | /** |
| 742 | * hif_get_device_type(): hif_get_device_type |
| 743 | * @device_id: device_id |
| 744 | * @revision_id: revision_id |
| 745 | * @hif_type: returned hif_type |
| 746 | * @target_type: returned target_type |
| 747 | * |
| 748 | * Return: int |
| 749 | */ |
| 750 | int hif_get_device_type(uint32_t device_id, |
| 751 | uint32_t revision_id, |
| 752 | uint32_t *hif_type, uint32_t *target_type) |
| 753 | { |
| 754 | int ret = 0; |
| 755 | |
| 756 | switch (device_id) { |
| 757 | #ifdef QCA_WIFI_3_0_ADRASTEA |
| 758 | case ADRASTEA_DEVICE_ID: |
| 759 | case ADRASTEA_DEVICE_ID_P2_E12: |
| 760 | |
| 761 | *hif_type = HIF_TYPE_ADRASTEA; |
| 762 | *target_type = TARGET_TYPE_ADRASTEA; |
| 763 | break; |
| 764 | #else |
| 765 | case QCA6180_DEVICE_ID: |
| 766 | *hif_type = HIF_TYPE_QCA6180; |
| 767 | *target_type = TARGET_TYPE_QCA6180; |
| 768 | break; |
| 769 | #endif |
| 770 | |
| 771 | case AR9888_DEVICE_ID: |
| 772 | *hif_type = HIF_TYPE_AR9888; |
| 773 | *target_type = TARGET_TYPE_AR9888; |
| 774 | break; |
| 775 | |
| 776 | case AR6320_DEVICE_ID: |
| 777 | switch (revision_id) { |
| 778 | case AR6320_FW_1_1: |
| 779 | case AR6320_FW_1_3: |
| 780 | *hif_type = HIF_TYPE_AR6320; |
| 781 | *target_type = TARGET_TYPE_AR6320; |
| 782 | break; |
| 783 | |
| 784 | case AR6320_FW_2_0: |
| 785 | case AR6320_FW_3_0: |
| 786 | case AR6320_FW_3_2: |
| 787 | *hif_type = HIF_TYPE_AR6320V2; |
| 788 | *target_type = TARGET_TYPE_AR6320V2; |
| 789 | break; |
| 790 | |
| 791 | default: |
| 792 | HIF_ERROR("%s: error - dev_id = 0x%x, rev_id = 0x%x", |
| 793 | __func__, device_id, revision_id); |
| 794 | ret = -ENODEV; |
| 795 | goto end; |
| 796 | } |
| 797 | break; |
| 798 | |
| 799 | default: |
| 800 | HIF_ERROR("%s: Unsupported device ID!", __func__); |
| 801 | ret = -ENODEV; |
| 802 | break; |
| 803 | } |
| 804 | end: |
| 805 | return ret; |
| 806 | } |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 807 | |
| 808 | /** |
| 809 | * Target info and ini parameters are global to the driver |
| 810 | * Hence these structures are exposed to all the modules in |
| 811 | * the driver and they don't need to maintains multiple copies |
| 812 | * of the same info, instead get the handle from hif and |
| 813 | * modify them in hif |
| 814 | */ |
| 815 | |
| 816 | /** |
| 817 | * hif_get_ini_handle() - API to get hif_config_param handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 818 | * @hif_ctx: HIF Context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 819 | * |
| 820 | * Return: pointer to hif_config_info |
| 821 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 822 | struct hif_config_info *hif_get_ini_handle(struct ol_softc *hif_ctx) |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 823 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 824 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 825 | |
| 826 | return &sc->hif_config; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | /** |
| 830 | * hif_get_target_info_handle() - API to get hif_target_info handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 831 | * @hif_ctx: HIF context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 832 | * |
| 833 | * Return: Pointer to hif_target_info |
| 834 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 835 | struct hif_target_info *hif_get_target_info_handle(struct ol_softc *hif_ctx) |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 836 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 837 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 838 | |
| 839 | return &sc->target_info; |
| 840 | |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 841 | } |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 842 | |
| 843 | #if defined(FEATURE_LRO) |
| 844 | /** |
| 845 | * hif_lro_flush_cb_register - API to register for LRO Flush Callback |
| 846 | * @scn: HIF Context |
| 847 | * @handler: Function pointer to be called by HIF |
| 848 | * @data: Private data to be used by the module registering to HIF |
| 849 | * |
| 850 | * Return: void |
| 851 | */ |
| 852 | void hif_lro_flush_cb_register(struct ol_softc *scn, |
| 853 | void (handler)(void *), void *data) |
| 854 | { |
| 855 | ce_lro_flush_cb_register(scn, handler, data); |
| 856 | } |
| 857 | |
| 858 | /** |
| 859 | * hif_lro_flush_cb_deregister - API to deregister for LRO Flush Callbacks |
| 860 | * @scn: HIF Context |
| 861 | * |
| 862 | * Return: void |
| 863 | */ |
| 864 | void hif_lro_flush_cb_deregister(struct ol_softc *scn) |
| 865 | { |
| 866 | ce_lro_flush_cb_deregister(scn); |
| 867 | } |
| 868 | #endif |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 869 | |
| 870 | /** |
| 871 | * hif_get_target_status - API to get target status |
| 872 | * @hif_ctx: HIF Context |
| 873 | * |
| 874 | * Return: enum ol_target_status |
| 875 | */ |
| 876 | ol_target_status hif_get_target_status(struct ol_softc *hif_ctx) |
| 877 | { |
| 878 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 879 | |
| 880 | return scn->target_status; |
| 881 | } |
| 882 | |
| 883 | /** |
| 884 | * hif_set_target_status - API to set target status |
| 885 | * @hif_ctx: HIF Context |
| 886 | * @status: Target Status |
| 887 | * |
| 888 | * Return: void |
| 889 | */ |
| 890 | void hif_set_target_status(struct ol_softc *hif_ctx, ol_target_status status) |
| 891 | { |
| 892 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 893 | |
| 894 | scn->target_status = status; |
| 895 | } |