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" |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame^] | 41 | #if defined(HIF_PCI) || defined(HIF_SNOC) || defined(HIF_AHB) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 42 | #include "ce_api.h" |
| 43 | #include "ce_tasklet.h" |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame^] | 44 | #include "platform_icnss.h" |
| 45 | #endif |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 46 | #include "qdf_trace.h" |
| 47 | #include "qdf_status.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 48 | #ifdef CONFIG_CNSS |
| 49 | #include <net/cnss.h> |
| 50 | #endif |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 51 | #include "hif_debug.h" |
| 52 | #include "mp_dev.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 53 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 54 | 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] | 55 | { |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame^] | 56 | hif_trigger_dump(hif_ctx, cmd_id, start); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 57 | } |
| 58 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 59 | /** |
| 60 | * hif_get_target_id(): hif_get_target_id |
| 61 | * |
| 62 | * Return the virtual memory base address to the caller |
| 63 | * |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 64 | * @scn: hif_softc |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 65 | * |
| 66 | * Return: A_target_id_t |
| 67 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 68 | A_target_id_t hif_get_target_id(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 69 | { |
| 70 | return scn->mem; |
| 71 | } |
| 72 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 73 | /** |
| 74 | * hif_get_targetdef(): hif_get_targetdef |
| 75 | * @scn: scn |
| 76 | * |
| 77 | * Return: void * |
| 78 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 79 | void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 80 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 81 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 82 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 83 | return scn->targetdef; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * hif_vote_link_down(): unvote for link up |
| 88 | * |
| 89 | * Call hif_vote_link_down to release a previous request made using |
| 90 | * hif_vote_link_up. A hif_vote_link_down call should only be made |
| 91 | * after a corresponding hif_vote_link_up, otherwise you could be |
| 92 | * negating a vote from another source. When no votes are present |
| 93 | * hif will not guarantee the linkstate after hif_bus_suspend. |
| 94 | * |
| 95 | * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread |
| 96 | * and initialization deinitialization sequencences. |
| 97 | * |
| 98 | * Return: n/a |
| 99 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 100 | void hif_vote_link_down(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 101 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 102 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 103 | QDF_BUG(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 104 | |
| 105 | scn->linkstate_vote--; |
| 106 | if (scn->linkstate_vote == 0) |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 107 | hif_bus_prevent_linkdown(scn, false); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /** |
| 111 | * hif_vote_link_up(): vote to prevent bus from suspending |
| 112 | * |
| 113 | * Makes hif guarantee that fw can message the host normally |
| 114 | * durring suspend. |
| 115 | * |
| 116 | * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread |
| 117 | * and initialization deinitialization sequencences. |
| 118 | * |
| 119 | * Return: n/a |
| 120 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 121 | void hif_vote_link_up(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 122 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 123 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 124 | QDF_BUG(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 125 | |
| 126 | scn->linkstate_vote++; |
| 127 | if (scn->linkstate_vote == 1) |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 128 | hif_bus_prevent_linkdown(scn, true); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | /** |
| 132 | * hif_can_suspend_link(): query if hif is permitted to suspend the link |
| 133 | * |
| 134 | * Hif will ensure that the link won't be suspended if the upperlayers |
| 135 | * don't want it to. |
| 136 | * |
| 137 | * SYNCHRONIZATION: MC thread is stopped before bus suspend thus |
| 138 | * we don't need extra locking to ensure votes dont change while |
| 139 | * we are in the process of suspending or resuming. |
| 140 | * |
| 141 | * Return: false if hif will guarantee link up durring suspend. |
| 142 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 143 | bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 144 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 145 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 146 | QDF_BUG(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 147 | |
| 148 | return scn->linkstate_vote == 0; |
| 149 | } |
| 150 | |
Houston Hoffman | 4f52998 | 2016-05-05 16:11:04 -0700 | [diff] [blame] | 151 | #ifndef CONFIG_WIN |
| 152 | #define QCA9984_HOST_INTEREST_ADDRESS -1 |
| 153 | #define QCA9888_HOST_INTEREST_ADDRESS -1 |
| 154 | #define IPQ4019_HOST_INTEREST_ADDRESS -1 |
| 155 | #endif |
| 156 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 157 | /** |
| 158 | * hif_hia_item_address(): hif_hia_item_address |
| 159 | * @target_type: target_type |
| 160 | * @item_offset: item_offset |
| 161 | * |
| 162 | * Return: n/a |
| 163 | */ |
| 164 | uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset) |
| 165 | { |
| 166 | switch (target_type) { |
| 167 | case TARGET_TYPE_AR6002: |
| 168 | return AR6002_HOST_INTEREST_ADDRESS + item_offset; |
| 169 | case TARGET_TYPE_AR6003: |
| 170 | return AR6003_HOST_INTEREST_ADDRESS + item_offset; |
| 171 | case TARGET_TYPE_AR6004: |
| 172 | return AR6004_HOST_INTEREST_ADDRESS + item_offset; |
| 173 | case TARGET_TYPE_AR6006: |
| 174 | return AR6006_HOST_INTEREST_ADDRESS + item_offset; |
| 175 | case TARGET_TYPE_AR9888: |
| 176 | return AR9888_HOST_INTEREST_ADDRESS + item_offset; |
| 177 | case TARGET_TYPE_AR6320: |
| 178 | case TARGET_TYPE_AR6320V2: |
| 179 | return AR6320_HOST_INTEREST_ADDRESS + item_offset; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 180 | case TARGET_TYPE_ADRASTEA: |
| 181 | /* ADRASTEA doesn't have a host interest address */ |
| 182 | ASSERT(0); |
| 183 | return 0; |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 184 | case TARGET_TYPE_AR900B: |
| 185 | return AR900B_HOST_INTEREST_ADDRESS + item_offset; |
| 186 | case TARGET_TYPE_QCA9984: |
| 187 | return QCA9984_HOST_INTEREST_ADDRESS + item_offset; |
| 188 | case TARGET_TYPE_QCA9888: |
| 189 | return QCA9888_HOST_INTEREST_ADDRESS + item_offset; |
| 190 | case TARGET_TYPE_IPQ4019: |
| 191 | return IPQ4019_HOST_INTEREST_ADDRESS + item_offset; |
| 192 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 193 | default: |
| 194 | ASSERT(0); |
| 195 | return 0; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * hif_max_num_receives_reached() - check max receive is reached |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 201 | * @scn: HIF Context |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 202 | * @count: unsigned int. |
| 203 | * |
| 204 | * Output check status as bool |
| 205 | * |
| 206 | * Return: bool |
| 207 | */ |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 208 | 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] | 209 | { |
Houston Hoffman | 75ef5a5 | 2016-04-14 17:15:49 -0700 | [diff] [blame] | 210 | if (QDF_IS_EPPING_ENABLED(hif_get_conparam(scn))) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 211 | return count > 120; |
| 212 | else |
| 213 | return count > MAX_NUM_OF_RECEIVES; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * init_buffer_count() - initial buffer count |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 218 | * @maxSize: qdf_size_t |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 219 | * |
| 220 | * routine to modify the initial buffer count to be allocated on an os |
| 221 | * platform basis. Platform owner will need to modify this as needed |
| 222 | * |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 223 | * Return: qdf_size_t |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 224 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 225 | qdf_size_t init_buffer_count(qdf_size_t maxSize) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 226 | { |
| 227 | return maxSize; |
| 228 | } |
| 229 | |
| 230 | /** |
Nirav Shah | d7f9159 | 2016-04-21 14:18:43 +0530 | [diff] [blame] | 231 | * hif_save_htc_htt_config_endpoint() - save htt_tx_endpoint |
| 232 | * @hif_ctx: hif context |
| 233 | * @htc_htt_tx_endpoint: htt_tx_endpoint |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 234 | * |
| 235 | * Return: void |
| 236 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 237 | 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] | 238 | int htc_htt_tx_endpoint) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 239 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 240 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 241 | |
| 242 | if (!scn) { |
| 243 | HIF_ERROR("%s: error: scn or scn->hif_sc is NULL!", |
| 244 | __func__); |
| 245 | return; |
| 246 | } |
| 247 | |
Nirav Shah | d7f9159 | 2016-04-21 14:18:43 +0530 | [diff] [blame] | 248 | scn->htc_htt_tx_endpoint = htc_htt_tx_endpoint; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 249 | } |
| 250 | |
Houston Hoffman | ec93ab0 | 2016-05-03 20:09:55 -0700 | [diff] [blame] | 251 | static const struct qwlan_hw qwlan_hw_list[] = { |
| 252 | { |
| 253 | .id = AR6320_REV1_VERSION, |
| 254 | .subid = 0, |
| 255 | .name = "QCA6174_REV1", |
| 256 | }, |
| 257 | { |
| 258 | .id = AR6320_REV1_1_VERSION, |
| 259 | .subid = 0x1, |
| 260 | .name = "QCA6174_REV1_1", |
| 261 | }, |
| 262 | { |
| 263 | .id = AR6320_REV1_3_VERSION, |
| 264 | .subid = 0x2, |
| 265 | .name = "QCA6174_REV1_3", |
| 266 | }, |
| 267 | { |
| 268 | .id = AR6320_REV2_1_VERSION, |
| 269 | .subid = 0x4, |
| 270 | .name = "QCA6174_REV2_1", |
| 271 | }, |
| 272 | { |
| 273 | .id = AR6320_REV2_1_VERSION, |
| 274 | .subid = 0x5, |
| 275 | .name = "QCA6174_REV2_2", |
| 276 | }, |
| 277 | { |
| 278 | .id = AR6320_REV3_VERSION, |
| 279 | .subid = 0x6, |
| 280 | .name = "QCA6174_REV2.3", |
| 281 | }, |
| 282 | { |
| 283 | .id = AR6320_REV3_VERSION, |
| 284 | .subid = 0x8, |
| 285 | .name = "QCA6174_REV3", |
| 286 | }, |
| 287 | { |
| 288 | .id = AR6320_REV3_VERSION, |
| 289 | .subid = 0x9, |
| 290 | .name = "QCA6174_REV3_1", |
| 291 | }, |
| 292 | { |
| 293 | .id = AR6320_REV3_2_VERSION, |
| 294 | .subid = 0xA, |
| 295 | .name = "AR6320_REV3_2_VERSION", |
| 296 | } |
| 297 | }; |
| 298 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 299 | /** |
| 300 | * hif_get_hw_name(): get a human readable name for the hardware |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 301 | * @info: Target Info |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 302 | * |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 303 | * Return: human readable name for the underlying wifi hardware. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 304 | */ |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 305 | static const char *hif_get_hw_name(struct hif_target_info *info) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 306 | { |
| 307 | int i; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 308 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 309 | for (i = 0; i < ARRAY_SIZE(qwlan_hw_list); i++) { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 310 | if (info->target_version == qwlan_hw_list[i].id && |
| 311 | info->target_revision == qwlan_hw_list[i].subid) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 312 | return qwlan_hw_list[i].name; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | return "Unknown Device"; |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * hif_get_hw_info(): hif_get_hw_info |
| 321 | * @scn: scn |
| 322 | * @version: version |
| 323 | * @revision: revision |
| 324 | * |
| 325 | * Return: n/a |
| 326 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 327 | 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] | 328 | const char **target_name) |
| 329 | { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 330 | struct hif_target_info *info = hif_get_target_info_handle(scn); |
| 331 | *version = info->target_version; |
| 332 | *revision = info->target_revision; |
| 333 | *target_name = hif_get_hw_name(info); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | /** |
| 337 | * hif_open(): hif_open |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 338 | * @qdf_ctx: QDF Context |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 339 | * @mode: Driver Mode |
| 340 | * @bus_type: Bus Type |
| 341 | * @cbk: CDS Callbacks |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 342 | * |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 343 | * API to open HIF Context |
| 344 | * |
| 345 | * Return: HIF Opaque Pointer |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 346 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 347 | struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode, |
| 348 | enum qdf_bus_type bus_type, |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 349 | struct hif_driver_state_callbacks *cbk) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 350 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 351 | struct hif_softc *scn; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 352 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Houston Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 353 | int bus_context_size = hif_bus_get_context_size(bus_type); |
| 354 | |
| 355 | if (bus_context_size == 0) { |
| 356 | HIF_ERROR("%s: context size 0 not allowed", __func__); |
| 357 | return NULL; |
| 358 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 359 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 360 | scn = (struct hif_softc *)qdf_mem_malloc(bus_context_size); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 361 | if (!scn) { |
| 362 | HIF_ERROR("%s: cannot alloc memory for HIF context of size:%d", |
| 363 | __func__, bus_context_size); |
| 364 | return GET_HIF_OPAQUE_HDL(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 365 | } |
| 366 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 367 | qdf_mem_zero(scn, bus_context_size); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 368 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 369 | scn->qdf_dev = qdf_ctx; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 370 | scn->hif_con_param = mode; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 371 | qdf_atomic_init(&scn->active_tasklet_cnt); |
| 372 | qdf_atomic_init(&scn->link_suspended); |
| 373 | qdf_atomic_init(&scn->tasklet_from_intr); |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 374 | qdf_mem_copy(&scn->callbacks, cbk, sizeof(struct hif_driver_state_callbacks)); |
Houston Hoffman | 3db96a4 | 2016-05-05 19:54:39 -0700 | [diff] [blame] | 375 | scn->bus_type = bus_type; |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 376 | status = hif_bus_open(scn, bus_type); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 377 | if (status != QDF_STATUS_SUCCESS) { |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 378 | HIF_ERROR("%s: hif_bus_open error = %d, bus_type = %d", |
| 379 | __func__, status, bus_type); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 380 | qdf_mem_free(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 381 | scn = NULL; |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 382 | } |
| 383 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 384 | return GET_HIF_OPAQUE_HDL(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /** |
| 388 | * hif_close(): hif_close |
| 389 | * @hif_ctx: hif_ctx |
| 390 | * |
| 391 | * Return: n/a |
| 392 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 393 | void hif_close(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 394 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 395 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 396 | |
| 397 | if (scn == NULL) { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 398 | HIF_ERROR("%s: hif_opaque_softc is NULL", __func__); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 399 | return; |
| 400 | } |
| 401 | |
| 402 | if (scn->athdiag_procfs_inited) { |
| 403 | athdiag_procfs_remove(); |
| 404 | scn->athdiag_procfs_inited = false; |
| 405 | } |
| 406 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 407 | hif_bus_close(scn); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 408 | qdf_mem_free(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | /** |
| 412 | * hif_enable(): hif_enable |
| 413 | * @hif_ctx: hif_ctx |
| 414 | * @dev: dev |
| 415 | * @bdev: bus dev |
| 416 | * @bid: bus ID |
| 417 | * @bus_type: bus type |
| 418 | * @type: enable type |
| 419 | * |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 420 | * Return: QDF_STATUS |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 421 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 422 | 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] | 423 | void *bdev, const hif_bus_id *bid, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 424 | enum qdf_bus_type bus_type, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 425 | enum hif_enable_type type) |
| 426 | { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 427 | QDF_STATUS status; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 428 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 429 | |
| 430 | if (scn == NULL) { |
| 431 | HIF_ERROR("%s: hif_ctx = NULL", __func__); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 432 | return QDF_STATUS_E_NULL_VALUE; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 433 | } |
| 434 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 435 | status = hif_enable_bus(scn, dev, bdev, bid, type); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 436 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 437 | HIF_ERROR("%s: hif_enable_bus error = %d", |
| 438 | __func__, status); |
| 439 | return status; |
| 440 | } |
| 441 | |
| 442 | if (ADRASTEA_BU) |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 443 | hif_vote_link_up(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 444 | |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 445 | if (hif_bus_configure(scn)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 446 | HIF_ERROR("%s: Target probe failed.", __func__); |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 447 | hif_disable_bus(scn); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 448 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 449 | return status; |
| 450 | } |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 451 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 452 | /* |
| 453 | * Flag to avoid potential unallocated memory access from MSI |
| 454 | * interrupt handler which could get scheduled as soon as MSI |
| 455 | * is enabled, i.e to take care of the race due to the order |
| 456 | * in where MSI is enabled before the memory, that will be |
| 457 | * in interrupt handlers, is allocated. |
| 458 | */ |
| 459 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 460 | scn->hif_init_done = true; |
| 461 | |
| 462 | HIF_TRACE("%s: X OK", __func__); |
| 463 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 464 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 465 | } |
| 466 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 467 | 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] | 468 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 469 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 470 | |
| 471 | if (!scn) |
| 472 | return; |
| 473 | |
| 474 | hif_nointrs(scn); |
| 475 | if (scn->hif_init_done == false) |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame^] | 476 | hif_shutdown_device(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 477 | else |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 478 | hif_stop(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 479 | |
| 480 | if (ADRASTEA_BU) |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 481 | hif_vote_link_down(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 482 | |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 483 | hif_disable_bus(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 484 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 485 | hif_wlan_disable(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 486 | |
| 487 | scn->notice_send = false; |
| 488 | |
| 489 | HIF_INFO("%s: X", __func__); |
| 490 | } |
| 491 | |
| 492 | |
| 493 | /** |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 494 | * hif_crash_shutdown_dump_bus_register() - dump bus registers |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 495 | * @hif_ctx: hif_ctx |
| 496 | * |
| 497 | * Return: n/a |
| 498 | */ |
| 499 | #if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \ |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 500 | && defined(DEBUG) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 501 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 502 | static void hif_crash_shutdown_dump_bus_register(void *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 503 | { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 504 | struct hif_opaque_softc *scn = hif_ctx; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 505 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 506 | if (hif_check_soc_status(scn)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 507 | return; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 508 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 509 | if (hif_dump_registers(scn)) |
| 510 | HIF_ERROR("Failed to dump bus registers!"); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | /** |
| 514 | * hif_crash_shutdown(): hif_crash_shutdown |
| 515 | * |
| 516 | * This function is called by the platform driver to dump CE registers |
| 517 | * |
| 518 | * @hif_ctx: hif_ctx |
| 519 | * |
| 520 | * Return: n/a |
| 521 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 522 | void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 523 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 524 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 525 | |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 526 | if (!hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 527 | return; |
| 528 | |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 529 | if (scn->bus_type == QDF_BUS_TYPE_SNOC) { |
| 530 | HIF_INFO_MED("%s: RAM dump disabled for bustype %d", |
| 531 | __func__, scn->bus_type); |
| 532 | return; |
| 533 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 534 | |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 535 | if (TARGET_STATUS_RESET == scn->target_status) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 536 | HIF_INFO_MED("%s: Target is already asserted, ignore!", |
| 537 | __func__); |
| 538 | return; |
| 539 | } |
| 540 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 541 | if (hif_is_load_or_unload_in_progress(scn)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 542 | HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__); |
| 543 | return; |
| 544 | } |
| 545 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 546 | hif_crash_shutdown_dump_bus_register(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 547 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 548 | if (ol_copy_ramdump(hif_ctx)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 549 | goto out; |
| 550 | |
| 551 | HIF_INFO_MED("%s: RAM dump collecting completed!", __func__); |
| 552 | |
| 553 | out: |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 554 | return; |
| 555 | } |
| 556 | #else |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 557 | void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 558 | { |
| 559 | HIF_INFO_MED("%s: Collecting target RAM dump disabled", |
| 560 | __func__); |
| 561 | return; |
| 562 | } |
| 563 | #endif /* TARGET_RAMDUMP_AFTER_KERNEL_PANIC */ |
| 564 | |
| 565 | #ifdef QCA_WIFI_3_0 |
| 566 | /** |
| 567 | * hif_check_fw_reg(): hif_check_fw_reg |
| 568 | * @scn: scn |
| 569 | * @state: |
| 570 | * |
| 571 | * Return: int |
| 572 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 573 | int hif_check_fw_reg(struct hif_opaque_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 574 | { |
| 575 | return 0; |
| 576 | } |
| 577 | #endif |
| 578 | |
| 579 | #ifdef IPA_OFFLOAD |
| 580 | /** |
| 581 | * hif_read_phy_mem_base(): hif_read_phy_mem_base |
| 582 | * @scn: scn |
| 583 | * @phy_mem_base: physical mem base |
| 584 | * |
| 585 | * Return: n/a |
| 586 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 587 | 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] | 588 | { |
| 589 | *phy_mem_base = scn->mem_pa; |
| 590 | } |
| 591 | #endif /* IPA_OFFLOAD */ |
| 592 | |
| 593 | /** |
| 594 | * hif_get_device_type(): hif_get_device_type |
| 595 | * @device_id: device_id |
| 596 | * @revision_id: revision_id |
| 597 | * @hif_type: returned hif_type |
| 598 | * @target_type: returned target_type |
| 599 | * |
| 600 | * Return: int |
| 601 | */ |
| 602 | int hif_get_device_type(uint32_t device_id, |
| 603 | uint32_t revision_id, |
| 604 | uint32_t *hif_type, uint32_t *target_type) |
| 605 | { |
| 606 | int ret = 0; |
| 607 | |
| 608 | switch (device_id) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 609 | case ADRASTEA_DEVICE_ID: |
| 610 | case ADRASTEA_DEVICE_ID_P2_E12: |
| 611 | |
| 612 | *hif_type = HIF_TYPE_ADRASTEA; |
| 613 | *target_type = TARGET_TYPE_ADRASTEA; |
| 614 | break; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 615 | |
| 616 | case AR9888_DEVICE_ID: |
| 617 | *hif_type = HIF_TYPE_AR9888; |
| 618 | *target_type = TARGET_TYPE_AR9888; |
| 619 | break; |
| 620 | |
| 621 | case AR6320_DEVICE_ID: |
| 622 | switch (revision_id) { |
| 623 | case AR6320_FW_1_1: |
| 624 | case AR6320_FW_1_3: |
| 625 | *hif_type = HIF_TYPE_AR6320; |
| 626 | *target_type = TARGET_TYPE_AR6320; |
| 627 | break; |
| 628 | |
| 629 | case AR6320_FW_2_0: |
| 630 | case AR6320_FW_3_0: |
| 631 | case AR6320_FW_3_2: |
| 632 | *hif_type = HIF_TYPE_AR6320V2; |
| 633 | *target_type = TARGET_TYPE_AR6320V2; |
| 634 | break; |
| 635 | |
| 636 | default: |
| 637 | HIF_ERROR("%s: error - dev_id = 0x%x, rev_id = 0x%x", |
| 638 | __func__, device_id, revision_id); |
| 639 | ret = -ENODEV; |
| 640 | goto end; |
| 641 | } |
| 642 | break; |
| 643 | |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 644 | case AR9887_DEVICE_ID: |
| 645 | *hif_type = HIF_TYPE_AR9888; |
| 646 | *target_type = TARGET_TYPE_AR9888; |
| 647 | HIF_INFO(" *********** AR9887 **************\n"); |
| 648 | break; |
| 649 | |
| 650 | case QCA9984_DEVICE_ID: |
| 651 | *hif_type = HIF_TYPE_QCA9984; |
| 652 | *target_type = TARGET_TYPE_QCA9984; |
| 653 | HIF_INFO(" *********** QCA9984 *************\n"); |
| 654 | break; |
| 655 | |
| 656 | case QCA9888_DEVICE_ID: |
| 657 | *hif_type = HIF_TYPE_QCA9888; |
| 658 | *target_type = TARGET_TYPE_QCA9888; |
| 659 | HIF_INFO(" *********** QCA9888 *************\n"); |
| 660 | break; |
| 661 | |
| 662 | case AR900B_DEVICE_ID: |
| 663 | *hif_type = HIF_TYPE_AR900B; |
| 664 | *target_type = TARGET_TYPE_AR900B; |
| 665 | HIF_INFO(" *********** AR900B *************\n"); |
| 666 | break; |
| 667 | |
Houston Hoffman | 3db96a4 | 2016-05-05 19:54:39 -0700 | [diff] [blame] | 668 | case IPQ4019_DEVICE_ID: |
| 669 | *hif_type = HIF_TYPE_IPQ4019; |
| 670 | *target_type = TARGET_TYPE_IPQ4019; |
| 671 | HIF_INFO(" *********** IPQ4019 *************\n"); |
| 672 | break; |
| 673 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 674 | default: |
| 675 | HIF_ERROR("%s: Unsupported device ID!", __func__); |
| 676 | ret = -ENODEV; |
| 677 | break; |
| 678 | } |
| 679 | end: |
| 680 | return ret; |
| 681 | } |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 682 | |
| 683 | /** |
Houston Hoffman | 2635259 | 2016-03-14 21:11:43 -0700 | [diff] [blame] | 684 | * hif_needs_bmi() - return true if the soc needs bmi through the driver |
| 685 | * @hif_ctx: hif context |
| 686 | * |
| 687 | * Return: true if the soc needs driver bmi otherwise false |
| 688 | */ |
| 689 | bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx) |
| 690 | { |
| 691 | struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx); |
| 692 | return hif_sc->bus_type != QDF_BUS_TYPE_SNOC; |
| 693 | } |
| 694 | |
| 695 | /** |
Houston Hoffman | 60a1eeb | 2016-03-14 21:11:44 -0700 | [diff] [blame] | 696 | * hif_get_bus_type() - return the bus type |
| 697 | * |
| 698 | * Return: enum qdf_bus_type |
| 699 | */ |
| 700 | enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl) |
| 701 | { |
| 702 | struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl); |
| 703 | return scn->bus_type; |
| 704 | } |
| 705 | |
| 706 | /** |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 707 | * Target info and ini parameters are global to the driver |
| 708 | * Hence these structures are exposed to all the modules in |
| 709 | * the driver and they don't need to maintains multiple copies |
| 710 | * of the same info, instead get the handle from hif and |
| 711 | * modify them in hif |
| 712 | */ |
| 713 | |
| 714 | /** |
| 715 | * hif_get_ini_handle() - API to get hif_config_param handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 716 | * @hif_ctx: HIF Context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 717 | * |
| 718 | * Return: pointer to hif_config_info |
| 719 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 720 | 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] | 721 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 722 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 723 | |
| 724 | return &sc->hif_config; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | /** |
| 728 | * hif_get_target_info_handle() - API to get hif_target_info handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 729 | * @hif_ctx: HIF context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 730 | * |
| 731 | * Return: Pointer to hif_target_info |
| 732 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 733 | struct hif_target_info *hif_get_target_info_handle( |
| 734 | struct hif_opaque_softc *hif_ctx) |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 735 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 736 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 737 | |
| 738 | return &sc->target_info; |
| 739 | |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 740 | } |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 741 | |
| 742 | #if defined(FEATURE_LRO) |
| 743 | /** |
| 744 | * hif_lro_flush_cb_register - API to register for LRO Flush Callback |
| 745 | * @scn: HIF Context |
| 746 | * @handler: Function pointer to be called by HIF |
| 747 | * @data: Private data to be used by the module registering to HIF |
| 748 | * |
| 749 | * Return: void |
| 750 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 751 | void hif_lro_flush_cb_register(struct hif_opaque_softc *scn, |
| 752 | void (handler)(void *), void *data) |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 753 | { |
| 754 | ce_lro_flush_cb_register(scn, handler, data); |
| 755 | } |
| 756 | |
| 757 | /** |
| 758 | * hif_lro_flush_cb_deregister - API to deregister for LRO Flush Callbacks |
| 759 | * @scn: HIF Context |
| 760 | * |
| 761 | * Return: void |
| 762 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 763 | void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn) |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 764 | { |
| 765 | ce_lro_flush_cb_deregister(scn); |
| 766 | } |
| 767 | #endif |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 768 | |
| 769 | /** |
| 770 | * hif_get_target_status - API to get target status |
| 771 | * @hif_ctx: HIF Context |
| 772 | * |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 773 | * Return: enum hif_target_status |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 774 | */ |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 775 | 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] | 776 | { |
| 777 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 778 | |
| 779 | return scn->target_status; |
| 780 | } |
| 781 | |
| 782 | /** |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 783 | * hif_set_target_status() - API to set target status |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 784 | * @hif_ctx: HIF Context |
| 785 | * @status: Target Status |
| 786 | * |
| 787 | * Return: void |
| 788 | */ |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 789 | void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum |
| 790 | hif_target_status status) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 791 | { |
| 792 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 793 | |
| 794 | scn->target_status = status; |
| 795 | } |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 796 | |
| 797 | /** |
| 798 | * hif_init_ini_config() - API to initialize HIF configuration parameters |
| 799 | * @hif_ctx: HIF Context |
| 800 | * @cfg: HIF Configuration |
| 801 | * |
| 802 | * Return: void |
| 803 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 804 | void hif_init_ini_config(struct hif_opaque_softc *hif_ctx, |
| 805 | struct hif_config_info *cfg) |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 806 | { |
| 807 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 808 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 809 | qdf_mem_copy(&scn->hif_config, cfg, sizeof(struct hif_config_info)); |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 810 | } |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 811 | |
| 812 | /** |
| 813 | * hif_get_conparam() - API to get driver mode in HIF |
| 814 | * @scn: HIF Context |
| 815 | * |
| 816 | * Return: driver mode of operation |
| 817 | */ |
| 818 | uint32_t hif_get_conparam(struct hif_softc *scn) |
| 819 | { |
| 820 | if (!scn) |
| 821 | return 0; |
| 822 | |
| 823 | return scn->hif_con_param; |
| 824 | } |
| 825 | |
| 826 | /** |
| 827 | * hif_get_callbacks_handle() - API to get callbacks Handle |
| 828 | * @scn: HIF Context |
| 829 | * |
| 830 | * Return: pointer to HIF Callbacks |
| 831 | */ |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 832 | 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] | 833 | { |
| 834 | return &scn->callbacks; |
| 835 | } |
| 836 | |
| 837 | /** |
| 838 | * hif_is_driver_unloading() - API to query upper layers if driver is unloading |
| 839 | * @scn: HIF Context |
| 840 | * |
| 841 | * Return: True/False |
| 842 | */ |
| 843 | bool hif_is_driver_unloading(struct hif_softc *scn) |
| 844 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 845 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 846 | |
| 847 | if (cbk && cbk->is_driver_unloading) |
| 848 | return cbk->is_driver_unloading(cbk->context); |
| 849 | |
| 850 | return false; |
| 851 | } |
| 852 | |
| 853 | /** |
| 854 | * hif_is_load_or_unload_in_progress() - API to query upper layers if |
| 855 | * load/unload in progress |
| 856 | * @scn: HIF Context |
| 857 | * |
| 858 | * Return: True/False |
| 859 | */ |
| 860 | bool hif_is_load_or_unload_in_progress(struct hif_softc *scn) |
| 861 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 862 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 863 | |
| 864 | if (cbk && cbk->is_load_unload_in_progress) |
| 865 | return cbk->is_load_unload_in_progress(cbk->context); |
| 866 | |
| 867 | return false; |
| 868 | } |
| 869 | |
| 870 | /** |
| 871 | * hif_is_recovery_in_progress() - API to query upper layers if recovery in |
| 872 | * progress |
| 873 | * @scn: HIF Context |
| 874 | * |
| 875 | * Return: True/False |
| 876 | */ |
| 877 | bool hif_is_recovery_in_progress(struct hif_softc *scn) |
| 878 | { |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame] | 879 | struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 880 | |
| 881 | if (cbk && cbk->is_recovery_in_progress) |
| 882 | return cbk->is_recovery_in_progress(cbk->context); |
| 883 | |
| 884 | return false; |
| 885 | } |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 886 | |
| 887 | /** |
| 888 | * hif_batch_send() - API to access hif specific function |
| 889 | * ce_batch_send. |
| 890 | * @osc: HIF Context |
| 891 | * @msdu : list of msdus to be sent |
| 892 | * @transfer_id : transfer id |
| 893 | * @len : donwloaded length |
| 894 | * |
| 895 | * Return: list of msds not sent |
| 896 | */ |
| 897 | qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, |
| 898 | uint32_t transfer_id, u_int32_t len, uint32_t sendhead) |
| 899 | { |
| 900 | void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE); |
| 901 | return ce_batch_send((struct CE_handle *)ce_tx_hdl, msdu, transfer_id, |
| 902 | len, sendhead); |
| 903 | } |
| 904 | |
| 905 | /** |
| 906 | * hif_update_tx_ring() - API to access hif specific function |
| 907 | * ce_update_tx_ring. |
| 908 | * @osc: HIF Context |
| 909 | * @num_htt_cmpls : number of htt compl received. |
| 910 | * |
| 911 | * Return: void |
| 912 | */ |
| 913 | void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls) |
| 914 | { |
| 915 | void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE); |
| 916 | ce_update_tx_ring(ce_tx_hdl, num_htt_cmpls); |
| 917 | } |
| 918 | |
| 919 | |
| 920 | /** |
| 921 | * hif_send_single() - API to access hif specific function |
| 922 | * ce_send_single. |
| 923 | * @osc: HIF Context |
| 924 | * @msdu : msdu to be sent |
| 925 | * @transfer_id: transfer id |
| 926 | * @len : downloaded length |
| 927 | * |
| 928 | * Return: msdu sent status |
| 929 | */ |
| 930 | int hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, uint32_t |
| 931 | transfer_id, u_int32_t len) |
| 932 | { |
| 933 | void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE); |
| 934 | return ce_send_single((struct CE_handle *)ce_tx_hdl, msdu, transfer_id, |
| 935 | len); |
| 936 | } |
| 937 | |
| 938 | /** |
| 939 | * hif_send_fast() - API to access hif specific function |
| 940 | * ce_send_fast. |
| 941 | * @osc: HIF Context |
| 942 | * @msdu : array of msdus to be sent |
| 943 | * @num_msdus : number of msdus in an array |
| 944 | * @transfer_id: transfer id |
| 945 | * |
| 946 | * Return: No. of packets that could be sent |
| 947 | */ |
| 948 | int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t *nbuf_arr, |
| 949 | uint32_t num_msdus, uint32_t transfer_id) |
| 950 | { |
| 951 | void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE); |
| 952 | return ce_send_fast((struct CE_handle *)ce_tx_hdl, nbuf_arr, num_msdus, |
| 953 | transfer_id); |
| 954 | } |
| 955 | |
| 956 | /** |
| 957 | * hif_pkt_dl_len_set() - API to access hif specific function |
| 958 | * ce_pkt_dl_len_set. |
| 959 | * @osc: HIF Context |
| 960 | * @pkt_download_len: download length |
| 961 | * |
| 962 | * Return: None |
| 963 | */ |
| 964 | void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len) |
| 965 | { |
| 966 | ce_pkt_dl_len_set(hif_sc, pkt_download_len); |
| 967 | } |
| 968 | |
| 969 | /** |
| 970 | * hif_reg_write() - API to access hif specific function |
| 971 | * hif_write32_mb. |
| 972 | * @hif_ctx : HIF Context |
| 973 | * @offset : offset on which value has to be written |
| 974 | * @value : value to be written |
| 975 | * |
| 976 | * Return: None |
| 977 | */ |
| 978 | void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset, |
| 979 | uint32_t value) |
| 980 | { |
| 981 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 982 | hif_write32_mb(scn->mem + offset, value); |
| 983 | |
| 984 | } |
| 985 | |
| 986 | /** |
| 987 | * hif_reg_read() - API to access hif specific function |
| 988 | * hif_read32_mb. |
| 989 | * @hif_ctx : HIF Context |
| 990 | * @offset : offset from which value has to be read |
| 991 | * |
| 992 | * Return: Read value |
| 993 | */ |
| 994 | uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset) |
| 995 | { |
| 996 | |
| 997 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 998 | return hif_read32_mb(scn->mem + offset); |
| 999 | } |