Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Yuanyuan Liu | 057fc4c | 2018-01-08 10:50:28 -0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -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 <linux/platform_device.h> |
| 29 | #include <linux/pci.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 30 | #include "cds_api.h" |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 31 | #include "qdf_status.h" |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 32 | #include "qdf_lock.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 33 | #include "cds_sched.h" |
| 34 | #include "osdep.h" |
| 35 | #include "hif.h" |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 36 | #include "htc.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 37 | #include "epping_main.h" |
| 38 | #include "wlan_hdd_main.h" |
| 39 | #include "wlan_hdd_power.h" |
| 40 | #include "wlan_logging_sock_svc.h" |
| 41 | #include "wma_api.h" |
| 42 | #include "wlan_hdd_napi.h" |
Tushnim Bhattacharyya | 9028cc7 | 2017-03-09 13:10:49 -0800 | [diff] [blame] | 43 | #include "wlan_policy_mgr_api.h" |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 44 | #include "qwlan_version.h" |
Komal Seelam | d910649 | 2016-02-15 10:31:44 +0530 | [diff] [blame] | 45 | #include "bmi.h" |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 46 | #include "cdp_txrx_bus.h" |
Sarada Prasanna Garnayak | e172263 | 2017-01-05 15:27:15 +0530 | [diff] [blame] | 47 | #include "cdp_txrx_misc.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 48 | #include "pld_common.h" |
Jeff Johnson | 7782cb9 | 2016-10-05 14:22:40 -0700 | [diff] [blame] | 49 | #include "wlan_hdd_driver_ops.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 50 | |
| 51 | #ifdef MODULE |
| 52 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 53 | #else |
| 54 | #define WLAN_MODULE_NAME "wlan" |
| 55 | #endif |
| 56 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 57 | #define DISABLE_KRAIT_IDLE_PS_VAL 1 |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 58 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 59 | #define SSR_MAX_FAIL_CNT 3 |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 60 | static uint8_t re_init_fail_cnt, probe_fail_cnt; |
| 61 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 62 | /* |
| 63 | * In BMI Phase we are only sending small chunk (256 bytes) of the FW image at |
| 64 | * a time, and wait for the completion interrupt to start the next transfer. |
| 65 | * During this phase, the KRAIT is entering IDLE/StandAlone(SA) Power Save(PS). |
| 66 | * The delay incurred for resuming from IDLE/SA PS is huge during driver load. |
| 67 | * So prevent APPS IDLE/SA PS durint driver load for reducing interrupt latency. |
| 68 | */ |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 69 | |
| 70 | static inline void hdd_request_pm_qos(struct device *dev, int val) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 71 | { |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 72 | pld_request_pm_qos(dev, val); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 73 | } |
| 74 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 75 | static inline void hdd_remove_pm_qos(struct device *dev) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 76 | { |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 77 | pld_remove_pm_qos(dev); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 78 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 79 | |
| 80 | /** |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 81 | * hdd_set_recovery_in_progress() - API to set recovery in progress |
| 82 | * @data: Context |
| 83 | * @val: Value to set |
| 84 | * |
| 85 | * Return: None |
| 86 | */ |
| 87 | static void hdd_set_recovery_in_progress(void *data, uint8_t val) |
| 88 | { |
| 89 | cds_set_recovery_in_progress(val); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * hdd_is_driver_unloading() - API to query if driver is unloading |
| 94 | * @data: Private Data |
| 95 | * |
| 96 | * Return: True/False |
| 97 | */ |
| 98 | static bool hdd_is_driver_unloading(void *data) |
| 99 | { |
| 100 | return cds_is_driver_unloading(); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * hdd_is_load_or_unload_in_progress() - API to query if driver is |
| 105 | * loading/unloading |
| 106 | * @data: Private Data |
| 107 | * |
| 108 | * Return: bool |
| 109 | */ |
| 110 | static bool hdd_is_load_or_unload_in_progress(void *data) |
| 111 | { |
| 112 | return cds_is_load_or_unload_in_progress(); |
| 113 | } |
| 114 | |
| 115 | /** |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 116 | * hdd_is_recovery_in_progress() - API to query if recovery in progress |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 117 | * @data: Private Data |
| 118 | * |
| 119 | * Return: bool |
| 120 | */ |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 121 | static bool hdd_is_recovery_in_progress(void *data) |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 122 | { |
| 123 | return cds_is_driver_recovering(); |
| 124 | } |
| 125 | |
| 126 | /** |
Govind Singh | a1f6dac | 2017-06-13 11:45:07 +0530 | [diff] [blame] | 127 | * hdd_is_target_ready() - API to query if target is in ready state |
| 128 | * @data: Private Data |
| 129 | * |
| 130 | * Return: bool |
| 131 | */ |
| 132 | static bool hdd_is_target_ready(void *data) |
| 133 | { |
| 134 | return cds_is_target_ready(); |
| 135 | } |
| 136 | |
| 137 | /** |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 138 | * hdd_hif_init_driver_state_callbacks() - API to initialize HIF callbacks |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 139 | * @data: Private Data |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 140 | * @cbk: HIF Driver State callbacks |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 141 | * |
| 142 | * HIF should be independent of CDS calls. Pass CDS Callbacks to HIF, HIF will |
| 143 | * call the callbacks. |
| 144 | * |
| 145 | * Return: void |
| 146 | */ |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 147 | static void hdd_hif_init_driver_state_callbacks(void *data, |
| 148 | struct hif_driver_state_callbacks *cbk) |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 149 | { |
| 150 | cbk->context = data; |
| 151 | cbk->set_recovery_in_progress = hdd_set_recovery_in_progress; |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 152 | cbk->is_recovery_in_progress = hdd_is_recovery_in_progress; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 153 | cbk->is_load_unload_in_progress = hdd_is_load_or_unload_in_progress; |
| 154 | cbk->is_driver_unloading = hdd_is_driver_unloading; |
Govind Singh | a1f6dac | 2017-06-13 11:45:07 +0530 | [diff] [blame] | 155 | cbk->is_target_ready = hdd_is_target_ready; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /** |
| 159 | * hdd_init_cds_hif_context() - API to set CDS HIF Context |
| 160 | * @hif: HIF Context |
| 161 | * |
| 162 | * Return: success/failure |
| 163 | */ |
| 164 | static int hdd_init_cds_hif_context(void *hif) |
| 165 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 166 | QDF_STATUS status; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 167 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 168 | status = cds_set_context(QDF_MODULE_ID_HIF, hif); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 169 | |
| 170 | if (status) |
| 171 | return -ENOENT; |
| 172 | |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * hdd_deinit_cds_hif_context() - API to clear CDS HIF COntext |
| 178 | * |
| 179 | * Return: None |
| 180 | */ |
| 181 | static void hdd_deinit_cds_hif_context(void) |
| 182 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 183 | QDF_STATUS status; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 184 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 185 | status = cds_set_context(QDF_MODULE_ID_HIF, NULL); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 186 | |
| 187 | if (status) |
| 188 | hdd_err("Failed to reset CDS HIF Context"); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 192 | * to_bus_type() - Map PLD bus type to low level bus type |
| 193 | * @bus_type: PLD bus type |
| 194 | * |
| 195 | * Map PLD bus type to low level bus type. |
| 196 | * |
| 197 | * Return: low level bus type. |
| 198 | */ |
| 199 | static enum qdf_bus_type to_bus_type(enum pld_bus_type bus_type) |
| 200 | { |
| 201 | switch (bus_type) { |
| 202 | case PLD_BUS_TYPE_PCIE: |
| 203 | return QDF_BUS_TYPE_PCI; |
| 204 | case PLD_BUS_TYPE_SNOC: |
| 205 | return QDF_BUS_TYPE_SNOC; |
Poddar, Siddarth | 3e9fa5c | 2016-05-13 14:25:05 +0530 | [diff] [blame] | 206 | case PLD_BUS_TYPE_SDIO: |
| 207 | return QDF_BUS_TYPE_SDIO; |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 208 | case PLD_BUS_TYPE_USB: |
| 209 | return QDF_BUS_TYPE_USB; |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 210 | default: |
| 211 | return QDF_BUS_TYPE_NONE; |
| 212 | } |
| 213 | } |
| 214 | |
Manikandan Mohan | 617a516 | 2017-04-10 13:14:40 -0700 | [diff] [blame] | 215 | int hdd_hif_open(struct device *dev, void *bdev, const struct hif_bus_id *bid, |
Anurag Chouhan | 2ed1fce | 2016-02-22 15:07:01 +0530 | [diff] [blame] | 216 | enum qdf_bus_type bus_type, bool reinit) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 217 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 218 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 219 | int ret = 0; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 220 | struct hif_opaque_softc *hif_ctx; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 221 | qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 222 | struct hif_driver_state_callbacks cbk; |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 223 | uint32_t mode = cds_get_conparam(); |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 224 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Govind Singh | 068c4b0 | 2016-08-17 16:37:13 +0530 | [diff] [blame] | 225 | |
| 226 | if (!hdd_ctx) { |
| 227 | hdd_err("hdd_ctx error"); |
| 228 | return -EFAULT; |
| 229 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 230 | |
Komal Seelam | 1aac198 | 2016-03-02 15:57:26 +0530 | [diff] [blame] | 231 | hdd_hif_init_driver_state_callbacks(dev, &cbk); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 232 | |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 233 | hif_ctx = hif_open(qdf_ctx, mode, bus_type, &cbk); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 234 | if (!hif_ctx) { |
| 235 | hdd_err("hif_open error"); |
| 236 | return -ENOMEM; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 237 | } |
| 238 | |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 239 | ret = hdd_init_cds_hif_context(hif_ctx); |
| 240 | if (ret) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 241 | hdd_err("Failed to set global HIF CDS Context err: %d", ret); |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 242 | goto err_hif_close; |
| 243 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 244 | |
Houston Hoffman | c1f962e | 2016-04-13 16:35:44 -0700 | [diff] [blame] | 245 | status = hif_enable(hif_ctx, dev, bdev, bid, bus_type, |
| 246 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 247 | HIF_ENABLE_TYPE_PROBE); |
| 248 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 249 | hdd_err("hif_enable failed status: %d, reinit: %d", |
Houston Hoffman | c1f962e | 2016-04-13 16:35:44 -0700 | [diff] [blame] | 250 | status, reinit); |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 251 | |
Houston Hoffman | c1f962e | 2016-04-13 16:35:44 -0700 | [diff] [blame] | 252 | ret = qdf_status_to_os_return(status); |
| 253 | goto err_hif_close; |
| 254 | } else { |
Yuanyuan Liu | 057fc4c | 2018-01-08 10:50:28 -0800 | [diff] [blame] | 255 | cds_set_target_ready(true); |
Houston Hoffman | c1f962e | 2016-04-13 16:35:44 -0700 | [diff] [blame] | 256 | ret = hdd_napi_create(); |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 257 | hdd_debug("hdd_napi_create returned: %d", ret); |
Manjunathappa Prakash | 9dd1913 | 2016-04-21 16:27:04 -0700 | [diff] [blame] | 258 | if (ret == 0) |
| 259 | hdd_warn("NAPI: no instances are created"); |
| 260 | else if (ret < 0) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 261 | hdd_err("NAPI creation error, rc: 0x%x, reinit: %d", |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 262 | ret, reinit); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 263 | ret = -EFAULT; |
| 264 | goto err_hif_close; |
Govind Singh | 068c4b0 | 2016-08-17 16:37:13 +0530 | [diff] [blame] | 265 | } else { |
| 266 | hdd_napi_event(NAPI_EVT_INI_FILE, |
| 267 | (void *)hdd_ctx->napi_enable); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 271 | pmo_ucfg_psoc_set_hif_handle(hdd_ctx->hdd_psoc, hif_ctx); |
| 272 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 273 | return 0; |
| 274 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 275 | err_hif_close: |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 276 | hdd_deinit_cds_hif_context(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 277 | hif_close(hif_ctx); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 278 | return ret; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 279 | } |
| 280 | |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 281 | void hdd_hif_close(struct hdd_context *hdd_ctx, void *hif_ctx) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 282 | { |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 283 | if (!hdd_ctx) { |
| 284 | hdd_err("hdd_ctx error"); |
| 285 | return; |
| 286 | } |
| 287 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 288 | if (hif_ctx == NULL) |
| 289 | return; |
| 290 | |
| 291 | hif_disable(hif_ctx, HIF_DISABLE_TYPE_REMOVE); |
| 292 | |
| 293 | hdd_napi_destroy(true); |
| 294 | |
Komal Seelam | ad5a90d | 2016-02-16 13:50:03 +0530 | [diff] [blame] | 295 | hdd_deinit_cds_hif_context(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 296 | hif_close(hif_ctx); |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 297 | |
| 298 | pmo_ucfg_psoc_set_hif_handle(hdd_ctx->hdd_psoc, NULL); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 299 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 300 | |
| 301 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 302 | * hdd_init_qdf_ctx() - API to initialize global QDF Device structure |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 303 | * @dev: Device Pointer |
| 304 | * @bdev: Bus Device pointer |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 305 | * @bus_type: Underlying bus type |
| 306 | * @bid: Bus id passed by platform driver |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 307 | * |
| 308 | * Return: void |
| 309 | */ |
Jeff Johnson | 7782cb9 | 2016-10-05 14:22:40 -0700 | [diff] [blame] | 310 | static void hdd_init_qdf_ctx(struct device *dev, void *bdev, |
| 311 | enum qdf_bus_type bus_type, |
| 312 | const struct hif_bus_id *bid) |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 313 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 314 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 315 | |
Jeff Johnson | 615d4bb | 2016-07-20 11:03:04 -0700 | [diff] [blame] | 316 | if (!qdf_dev) { |
| 317 | hdd_err("Invalid QDF device"); |
| 318 | return; |
| 319 | } |
| 320 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 321 | qdf_dev->dev = dev; |
| 322 | qdf_dev->drv_hdl = bdev; |
Govind Singh | 9db91ba | 2016-04-29 14:15:47 +0530 | [diff] [blame] | 323 | qdf_dev->bus_type = bus_type; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 324 | qdf_dev->bid = bid; |
Komal Seelam | 48152e1 | 2016-02-09 17:50:33 +0530 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | /** |
Yuanyuan Liu | 5583b2c | 2017-10-09 17:30:13 -0700 | [diff] [blame] | 328 | * check_for_probe_defer() - API to check return value |
| 329 | * @ret: Return Value |
| 330 | * |
| 331 | * Return: return -EPROBE_DEFER to platform driver if return value |
| 332 | * is -ENOMEM. Platform driver will try to re-probe. |
| 333 | */ |
| 334 | #ifdef MODULE |
| 335 | static int check_for_probe_defer(int ret) |
| 336 | { |
| 337 | return ret; |
| 338 | } |
| 339 | #else |
| 340 | static int check_for_probe_defer(int ret) |
| 341 | { |
| 342 | if (ret == -ENOMEM) |
| 343 | return -EPROBE_DEFER; |
| 344 | return ret; |
| 345 | } |
| 346 | #endif |
| 347 | |
| 348 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 349 | * wlan_hdd_probe() - handles probe request |
| 350 | * |
| 351 | * This function is called to probe the wlan driver |
| 352 | * |
| 353 | * @dev: wlan device structure |
| 354 | * @bdev: bus device structure |
| 355 | * @bid: bus identifier for shared busses |
| 356 | * @bus_type: underlying bus type |
| 357 | * @reinit: true if we are reinitiallizing the driver after a subsystem restart |
| 358 | * |
| 359 | * Return: 0 on successfull probe |
| 360 | */ |
Manikandan Mohan | 617a516 | 2017-04-10 13:14:40 -0700 | [diff] [blame] | 361 | static int wlan_hdd_probe(struct device *dev, void *bdev, |
| 362 | const struct hif_bus_id *bid, |
| 363 | enum qdf_bus_type bus_type, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 364 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 365 | int ret = 0; |
| 366 | |
| 367 | pr_info("%s: %sprobing driver v%s\n", WLAN_MODULE_NAME, |
| 368 | reinit ? "re-" : "", QWLAN_VERSIONSTR); |
| 369 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 370 | mutex_lock(&hdd_init_deinit_lock); |
Rakesh Pillai | 0a54fa9 | 2017-11-23 17:13:38 +0530 | [diff] [blame] | 371 | cds_set_driver_in_bad_state(false); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 372 | if (!reinit) |
| 373 | hdd_start_driver_ops_timer(eHDD_DRV_OP_PROBE); |
| 374 | else |
| 375 | hdd_start_driver_ops_timer(eHDD_DRV_OP_REINIT); |
| 376 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 377 | hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
| 378 | |
| 379 | /* |
Jeff Johnson | 0a9da59 | 2017-01-12 09:48:36 -0800 | [diff] [blame] | 380 | * The Krait is going to Idle/Stand Alone Power Save more |
| 381 | * aggressively which is resulting in the longer driver load |
| 382 | * time. The Fix is to not allow Krait to enter Idle Power |
| 383 | * Save during driver load. |
| 384 | */ |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 385 | hdd_request_pm_qos(dev, DISABLE_KRAIT_IDLE_PS_VAL); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 386 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 387 | if (reinit) |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 388 | cds_set_recovery_in_progress(true); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 389 | else |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 390 | cds_set_load_in_progress(true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 391 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 392 | hdd_init_qdf_ctx(dev, bdev, bus_type, (const struct hif_bus_id *)bid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 393 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 394 | if (reinit) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 395 | ret = hdd_wlan_re_init(); |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 396 | if (ret) |
| 397 | re_init_fail_cnt++; |
| 398 | } else { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 399 | ret = hdd_wlan_startup(dev); |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 400 | if (ret) |
| 401 | probe_fail_cnt++; |
| 402 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 403 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 404 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 405 | goto err_hdd_deinit; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 406 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 407 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 408 | if (reinit) { |
| 409 | cds_set_recovery_in_progress(false); |
| 410 | } else { |
| 411 | cds_set_load_in_progress(false); |
| 412 | cds_set_driver_loaded(true); |
| 413 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 414 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 415 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 416 | hdd_remove_pm_qos(dev); |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 417 | cds_set_fw_down(false); |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 418 | probe_fail_cnt = 0; |
| 419 | re_init_fail_cnt = 0; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 420 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 421 | mutex_unlock(&hdd_init_deinit_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 422 | return 0; |
| 423 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 424 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 425 | err_hdd_deinit: |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 426 | pr_err("probe/reinit failure counts %hhu/%hhu", |
| 427 | probe_fail_cnt, re_init_fail_cnt); |
| 428 | if (probe_fail_cnt >= SSR_MAX_FAIL_CNT || |
| 429 | re_init_fail_cnt >= SSR_MAX_FAIL_CNT) |
| 430 | QDF_BUG(0); |
| 431 | |
| 432 | if (reinit) { |
| 433 | cds_set_driver_in_bad_state(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 434 | cds_set_recovery_in_progress(false); |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 435 | } else |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 436 | cds_set_load_in_progress(false); |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 437 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 438 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 439 | hdd_remove_pm_qos(dev); |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 440 | |
| 441 | cds_set_fw_down(false); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 442 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 443 | mutex_unlock(&hdd_init_deinit_lock); |
Yuanyuan Liu | 5583b2c | 2017-10-09 17:30:13 -0700 | [diff] [blame] | 444 | return check_for_probe_defer(ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | /** |
| 448 | * wlan_hdd_remove() - wlan_hdd_remove |
| 449 | * |
| 450 | * This function is called by the platform driver to remove the |
| 451 | * driver |
| 452 | * |
| 453 | * Return: void |
| 454 | */ |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 455 | static void wlan_hdd_remove(struct device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 456 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 457 | pr_info("%s: Removing driver v%s\n", WLAN_MODULE_NAME, |
| 458 | QWLAN_VERSIONSTR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 459 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 460 | cds_set_driver_loaded(false); |
| 461 | cds_set_unload_in_progress(true); |
| 462 | |
Rajeev Kumar | dbc886e | 2016-01-19 12:56:04 -0800 | [diff] [blame] | 463 | if (!cds_wait_for_external_threads_completion(__func__)) |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 464 | hdd_warn("External threads are still active attempting driver unload anyway"); |
Rajeev Kumar | dbc886e | 2016-01-19 12:56:04 -0800 | [diff] [blame] | 465 | |
Houston Hoffman | 371d4a9 | 2016-04-14 17:02:37 -0700 | [diff] [blame] | 466 | if (QDF_IS_EPPING_ENABLED(cds_get_conparam())) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 467 | epping_disable(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 468 | epping_close(); |
| 469 | } else { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 470 | __hdd_wlan_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 471 | } |
| 472 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 473 | cds_set_driver_in_bad_state(false); |
Hanumanth Reddy Pothula | fc70ea3 | 2017-01-18 18:19:08 +0530 | [diff] [blame] | 474 | cds_set_unload_in_progress(false); |
| 475 | |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 476 | pr_info("%s: Driver De-initialized\n", WLAN_MODULE_NAME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 477 | } |
| 478 | |
Sen, Devendra | 154b3c4 | 2017-02-13 20:44:15 +0530 | [diff] [blame] | 479 | #ifdef FEATURE_WLAN_DIAG_SUPPORT |
| 480 | /** |
| 481 | * hdd_wlan_ssr_shutdown_event()- send ssr shutdown state |
| 482 | * |
| 483 | * This Function send send ssr shutdown state diag event |
| 484 | * |
| 485 | * Return: void. |
| 486 | */ |
| 487 | static void hdd_wlan_ssr_shutdown_event(void) |
| 488 | { |
| 489 | WLAN_HOST_DIAG_EVENT_DEF(ssr_shutdown, |
| 490 | struct host_event_wlan_ssr_shutdown); |
| 491 | qdf_mem_zero(&ssr_shutdown, sizeof(ssr_shutdown)); |
| 492 | ssr_shutdown.status = SSR_SUB_SYSTEM_SHUTDOWN; |
| 493 | WLAN_HOST_DIAG_EVENT_REPORT(&ssr_shutdown, |
| 494 | EVENT_WLAN_SSR_SHUTDOWN_SUBSYSTEM); |
| 495 | } |
| 496 | #else |
| 497 | static inline void hdd_wlan_ssr_shutdown_event(void) |
| 498 | { |
| 499 | |
| 500 | }; |
| 501 | #endif |
| 502 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 503 | /** |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 504 | * hdd_send_hang_reason() - Send hang reason to the userspace |
| 505 | * |
| 506 | * Return: None |
| 507 | */ |
| 508 | static void hdd_send_hang_reason(void) |
| 509 | { |
Mahesh Kumar Kalikot Veetil | 9111a57 | 2017-10-10 16:11:11 -0700 | [diff] [blame] | 510 | enum qdf_hang_reason reason = QDF_REASON_UNSPECIFIED; |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 511 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 512 | |
| 513 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 514 | return; |
| 515 | |
| 516 | cds_get_recovery_reason(&reason); |
| 517 | cds_reset_recovery_reason(); |
| 518 | wlan_hdd_send_hang_reason_event(hdd_ctx, reason); |
| 519 | } |
| 520 | |
| 521 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 522 | * wlan_hdd_shutdown() - wlan_hdd_shutdown |
| 523 | * |
| 524 | * This is routine is called by platform driver to shutdown the |
| 525 | * driver |
| 526 | * |
| 527 | * Return: void |
| 528 | */ |
| 529 | static void wlan_hdd_shutdown(void) |
| 530 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 531 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 532 | |
Dustin Brown | cd60132 | 2017-03-28 14:18:46 -0700 | [diff] [blame] | 533 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 534 | hdd_err("Crash recovery is not allowed in FTM mode"); |
| 535 | QDF_BUG(0); |
| 536 | return; |
| 537 | } |
| 538 | |
bings | 5f0ae14 | 2017-07-14 17:52:45 +0800 | [diff] [blame] | 539 | if (!hif_ctx) { |
| 540 | hdd_err("Failed to get HIF context, ignore SSR shutdown"); |
| 541 | return; |
| 542 | } |
| 543 | /* mask the host controller interrupts */ |
| 544 | hif_mask_interrupt_call(hif_ctx); |
| 545 | |
Rajeev Kumar | fec3dbe | 2016-01-19 15:23:52 -0800 | [diff] [blame] | 546 | if (cds_is_load_or_unload_in_progress()) { |
Jeff Johnson | bd561a9 | 2016-01-07 18:31:35 -0800 | [diff] [blame] | 547 | hdd_err("Load/unload in progress, ignore SSR shutdown"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 548 | return; |
| 549 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 550 | /* this is for cases, where shutdown invoked from platform */ |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 551 | cds_set_recovery_in_progress(true); |
Sen, Devendra | 154b3c4 | 2017-02-13 20:44:15 +0530 | [diff] [blame] | 552 | hdd_wlan_ssr_shutdown_event(); |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 553 | hdd_send_hang_reason(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 554 | |
Rajeev Kumar | dbc886e | 2016-01-19 12:56:04 -0800 | [diff] [blame] | 555 | if (!cds_wait_for_external_threads_completion(__func__)) |
Jeff Johnson | bd561a9 | 2016-01-07 18:31:35 -0800 | [diff] [blame] | 556 | hdd_err("Host is not ready for SSR, attempting anyway"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 557 | |
Houston Hoffman | 371d4a9 | 2016-04-14 17:02:37 -0700 | [diff] [blame] | 558 | if (!QDF_IS_EPPING_ENABLED(cds_get_conparam())) { |
bings | 5f0ae14 | 2017-07-14 17:52:45 +0800 | [diff] [blame] | 559 | hif_disable_isr(hif_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 560 | hdd_wlan_shutdown(); |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 561 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | /** |
| 565 | * wlan_hdd_crash_shutdown() - wlan_hdd_crash_shutdown |
| 566 | * |
| 567 | * HDD crash shutdown funtion: This function is called by |
| 568 | * platfrom driver's crash shutdown routine |
| 569 | * |
| 570 | * Return: void |
| 571 | */ |
Jeff Johnson | 7782cb9 | 2016-10-05 14:22:40 -0700 | [diff] [blame] | 572 | static void wlan_hdd_crash_shutdown(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 573 | { |
Yu Wang | 46082dc | 2017-09-19 12:25:38 +0800 | [diff] [blame] | 574 | QDF_STATUS ret; |
| 575 | WMA_HANDLE wma_handle = cds_get_context(QDF_MODULE_ID_WMA); |
| 576 | |
| 577 | if (!wma_handle) { |
| 578 | hdd_err("wma_handle is null"); |
| 579 | return; |
| 580 | } |
| 581 | |
| 582 | /* |
| 583 | * When kernel panic happen, if WiFi FW is still active |
| 584 | * it may cause NOC errors/memory corruption, to avoid |
| 585 | * this, inject a fw crash first. |
| 586 | * send crash_inject to FW directly, because we are now |
| 587 | * in an atomic context, and preempt has been disabled, |
| 588 | * MCThread won't be scheduled at the moment, at the same |
| 589 | * time, TargetFailure event wont't be received after inject |
| 590 | * crash due to the same reason. |
| 591 | */ |
| 592 | ret = wma_crash_inject(wma_handle, RECOVERY_SIM_ASSERT, 0); |
| 593 | if (QDF_IS_STATUS_ERROR(ret)) { |
| 594 | hdd_err("Failed to send crash inject:%d", ret); |
| 595 | return; |
| 596 | } |
| 597 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 598 | hif_crash_shutdown(cds_get_context(QDF_MODULE_ID_HIF)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | /** |
| 602 | * wlan_hdd_notify_handler() - wlan_hdd_notify_handler |
| 603 | * |
| 604 | * This function is called by the platform driver to notify the |
| 605 | * COEX |
| 606 | * |
| 607 | * @state: state |
| 608 | * |
| 609 | * Return: void |
| 610 | */ |
Jeff Johnson | 7782cb9 | 2016-10-05 14:22:40 -0700 | [diff] [blame] | 611 | static void wlan_hdd_notify_handler(int state) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 612 | { |
Houston Hoffman | 371d4a9 | 2016-04-14 17:02:37 -0700 | [diff] [blame] | 613 | if (!QDF_IS_EPPING_ENABLED(cds_get_conparam())) { |
Jeff Johnson | 10251bc | 2017-03-24 15:30:52 -0700 | [diff] [blame] | 614 | int ret; |
| 615 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 616 | ret = hdd_wlan_notify_modem_power_state(state); |
| 617 | if (ret < 0) |
Jeff Johnson | bd561a9 | 2016-01-07 18:31:35 -0800 | [diff] [blame] | 618 | hdd_err("Fail to send notify"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 619 | } |
| 620 | } |
| 621 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 622 | static int hdd_to_pmo_interface_pause(enum wow_interface_pause hdd_pause, |
| 623 | enum pmo_wow_interface_pause *pmo_pause) |
| 624 | { |
| 625 | switch (hdd_pause) { |
| 626 | case WOW_INTERFACE_PAUSE_DEFAULT: |
| 627 | *pmo_pause = PMO_WOW_INTERFACE_PAUSE_DEFAULT; |
| 628 | break; |
| 629 | case WOW_INTERFACE_PAUSE_ENABLE: |
| 630 | *pmo_pause = PMO_WOW_INTERFACE_PAUSE_ENABLE; |
| 631 | break; |
| 632 | case WOW_INTERFACE_PAUSE_DISABLE: |
| 633 | *pmo_pause = PMO_WOW_INTERFACE_PAUSE_DISABLE; |
| 634 | break; |
| 635 | default: |
| 636 | hdd_err("Invalid interface pause: %d", hdd_pause); |
| 637 | return -EINVAL; |
| 638 | } |
| 639 | |
| 640 | return 0; |
| 641 | } |
| 642 | |
| 643 | static int hdd_to_pmo_resume_trigger(enum wow_resume_trigger hdd_trigger, |
| 644 | enum pmo_wow_resume_trigger *pmo_trigger) |
| 645 | { |
| 646 | switch (hdd_trigger) { |
| 647 | case WOW_RESUME_TRIGGER_DEFAULT: |
| 648 | *pmo_trigger = PMO_WOW_RESUME_TRIGGER_DEFAULT; |
| 649 | break; |
| 650 | case WOW_RESUME_TRIGGER_HTC_WAKEUP: |
| 651 | *pmo_trigger = PMO_WOW_RESUME_TRIGGER_HTC_WAKEUP; |
| 652 | break; |
| 653 | case WOW_RESUME_TRIGGER_GPIO: |
| 654 | *pmo_trigger = PMO_WOW_RESUME_TRIGGER_GPIO; |
| 655 | break; |
| 656 | default: |
| 657 | hdd_err("Invalid resume trigger: %d", hdd_trigger); |
| 658 | return -EINVAL; |
| 659 | } |
| 660 | |
| 661 | return 0; |
| 662 | } |
| 663 | |
| 664 | static int |
| 665 | hdd_to_pmo_wow_enable_params(struct wow_enable_params *in_params, |
| 666 | struct pmo_wow_enable_params *out_params) |
| 667 | { |
| 668 | int err; |
| 669 | |
| 670 | /* unit-test suspend */ |
| 671 | out_params->is_unit_test = in_params->is_unit_test; |
| 672 | |
| 673 | /* interface pause */ |
| 674 | err = hdd_to_pmo_interface_pause(in_params->interface_pause, |
| 675 | &out_params->interface_pause); |
| 676 | if (err) |
| 677 | return err; |
| 678 | |
| 679 | /* resume trigger */ |
| 680 | err = hdd_to_pmo_resume_trigger(in_params->resume_trigger, |
| 681 | &out_params->resume_trigger); |
| 682 | if (err) |
| 683 | return err; |
| 684 | |
| 685 | return 0; |
| 686 | } |
| 687 | |
Yuanyuan Liu | 06a342f | 2017-01-12 16:48:19 -0800 | [diff] [blame] | 688 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 689 | * __wlan_hdd_bus_suspend() - handles platform supsend |
Dustin Brown | 5409643 | 2017-02-23 13:00:44 -0800 | [diff] [blame] | 690 | * @wow_params: collection of wow enable override parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 691 | * |
| 692 | * Does precondtion validation. Ensures that a subsystem restart isn't in |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 693 | * progress. Ensures that no load or unload is in progress. Does: |
| 694 | * data path suspend |
| 695 | * component (pmo) suspend |
| 696 | * hif (bus) suspend |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 697 | * |
| 698 | * Return: 0 for success, -EFAULT for null pointers, |
| 699 | * -EBUSY or -EAGAIN if another opperation is in progress and |
| 700 | * wlan will not be ready to suspend in time. |
| 701 | */ |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 702 | static int __wlan_hdd_bus_suspend(struct wow_enable_params wow_params) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 703 | { |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 704 | int err; |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 705 | QDF_STATUS status; |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 706 | struct hdd_context *hdd_ctx; |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 707 | void *hif_ctx; |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 708 | void *dp_soc; |
| 709 | void *dp_pdev; |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 710 | struct pmo_wow_enable_params pmo_params; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 711 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 712 | hdd_info("starting bus suspend"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 713 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 714 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 715 | err = wlan_hdd_validate_context(hdd_ctx); |
| 716 | if (err) { |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 717 | hdd_err("Invalid hdd context: %d", err); |
| 718 | return err; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 719 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 720 | |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 721 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 722 | hdd_debug("Driver Module closed; skipping suspend"); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 723 | return 0; |
| 724 | } |
| 725 | |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 726 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 727 | if (!hif_ctx) { |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 728 | hdd_err("Failed to get hif context"); |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 729 | return -EINVAL; |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 730 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 731 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 732 | err = hdd_to_pmo_wow_enable_params(&wow_params, &pmo_params); |
| 733 | if (err) { |
| 734 | hdd_err("Invalid WoW enable parameters: %d", err); |
| 735 | return err; |
| 736 | } |
| 737 | |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 738 | dp_soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 739 | dp_pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 740 | err = qdf_status_to_os_return(cdp_bus_suspend(dp_soc, dp_pdev)); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 741 | if (err) { |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 742 | hdd_err("Failed cdp bus suspend: %d", err); |
| 743 | return err; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 744 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 745 | |
Houston Hoffman | e5cd52c | 2017-02-08 17:48:57 -0800 | [diff] [blame] | 746 | err = hif_bus_early_suspend(hif_ctx); |
| 747 | if (err) { |
| 748 | hdd_err("Failed hif bus early suspend"); |
| 749 | goto resume_cdp; |
| 750 | } |
| 751 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 752 | status = pmo_ucfg_psoc_bus_suspend_req(hdd_ctx->hdd_psoc, |
| 753 | QDF_SYSTEM_SUSPEND, |
| 754 | &pmo_params); |
| 755 | err = qdf_status_to_os_return(status); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 756 | if (err) { |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 757 | hdd_err("Failed pmo bus suspend: %d", status); |
Houston Hoffman | e5cd52c | 2017-02-08 17:48:57 -0800 | [diff] [blame] | 758 | goto late_hif_resume; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 759 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 760 | |
Komal Seelam | c12e675 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 761 | err = hif_bus_suspend(hif_ctx); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 762 | if (err) { |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 763 | hdd_err("Failed hif bus suspend: %d", err); |
| 764 | goto resume_pmo; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 765 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 766 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 767 | hdd_info("bus suspend succeeded"); |
Dustin Brown | 2d22823 | 2016-09-22 15:06:19 -0700 | [diff] [blame] | 768 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 769 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 770 | resume_pmo: |
| 771 | status = pmo_ucfg_psoc_bus_resume_req(hdd_ctx->hdd_psoc, |
| 772 | QDF_SYSTEM_SUSPEND); |
| 773 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 774 | |
Houston Hoffman | e5cd52c | 2017-02-08 17:48:57 -0800 | [diff] [blame] | 775 | late_hif_resume: |
| 776 | status = hif_bus_late_resume(hif_ctx); |
| 777 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 778 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 779 | resume_cdp: |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 780 | status = cdp_bus_resume(dp_soc, dp_pdev); |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 781 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 782 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 783 | return err; |
| 784 | } |
| 785 | |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 786 | int wlan_hdd_bus_suspend(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 787 | { |
| 788 | int ret; |
Dustin Brown | 5409643 | 2017-02-23 13:00:44 -0800 | [diff] [blame] | 789 | struct wow_enable_params default_params = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 790 | |
| 791 | cds_ssr_protect(__func__); |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 792 | ret = __wlan_hdd_bus_suspend(default_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 793 | cds_ssr_unprotect(__func__); |
| 794 | |
| 795 | return ret; |
| 796 | } |
| 797 | |
Dustin Brown | e70fd97 | 2016-11-10 11:17:40 -0800 | [diff] [blame] | 798 | #ifdef WLAN_SUSPEND_RESUME_TEST |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 799 | int wlan_hdd_unit_test_bus_suspend(struct wow_enable_params wow_params) |
Dustin Brown | e70fd97 | 2016-11-10 11:17:40 -0800 | [diff] [blame] | 800 | { |
| 801 | int ret; |
| 802 | |
| 803 | cds_ssr_protect(__func__); |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 804 | ret = __wlan_hdd_bus_suspend(wow_params); |
Dustin Brown | e70fd97 | 2016-11-10 11:17:40 -0800 | [diff] [blame] | 805 | cds_ssr_unprotect(__func__); |
| 806 | |
| 807 | return ret; |
| 808 | } |
| 809 | #endif |
| 810 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 811 | /** |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 812 | * __wlan_hdd_bus_suspend_noirq() - handle .suspend_noirq callback |
| 813 | * |
| 814 | * This function is called by the platform driver to complete the |
| 815 | * bus suspend callback when device interrupts are disabled by kernel. |
| 816 | * Call HIF and WMA suspend_noirq callbacks to make sure there is no |
| 817 | * wake up pending from FW before allowing suspend. |
| 818 | * |
| 819 | * Return: 0 for success and -EBUSY if FW is requesting wake up |
| 820 | */ |
Jeff Johnson | 7782cb9 | 2016-10-05 14:22:40 -0700 | [diff] [blame] | 821 | static int __wlan_hdd_bus_suspend_noirq(void) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 822 | { |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 823 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 824 | void *hif_ctx; |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 825 | int errno; |
| 826 | uint32_t pending_events; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 827 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 828 | hdd_info("start bus_suspend_noirq"); |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 829 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 830 | if (errno) { |
| 831 | hdd_err("Invalid HDD context: errno %d", errno); |
| 832 | return errno; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 836 | hdd_debug("Driver module closed; skip bus-noirq suspend"); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 837 | return 0; |
| 838 | } |
| 839 | |
| 840 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 841 | if (!hif_ctx) { |
| 842 | hdd_err("hif_ctx is null"); |
| 843 | return -EINVAL; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 844 | } |
| 845 | |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 846 | errno = hif_bus_suspend_noirq(hif_ctx); |
| 847 | if (errno) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 848 | goto done; |
| 849 | |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 850 | errno = pmo_ucfg_psoc_is_target_wake_up_received(hdd_ctx->hdd_psoc); |
| 851 | if (errno == -EAGAIN) { |
| 852 | hdd_err("Firmware attempting wakeup, try again"); |
| 853 | wlan_hdd_inc_suspend_stats(hdd_ctx, |
| 854 | SUSPEND_FAIL_INITIAL_WAKEUP); |
| 855 | } |
| 856 | if (errno) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 857 | goto resume_hif_noirq; |
| 858 | |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 859 | pending_events = wma_critical_events_in_flight(); |
| 860 | if (pending_events) { |
| 861 | hdd_err("%d critical event(s) in flight; try again", |
| 862 | pending_events); |
| 863 | errno = -EAGAIN; |
| 864 | goto resume_hif_noirq; |
| 865 | } |
| 866 | |
Dustin Brown | d932248 | 2017-01-09 12:46:03 -0800 | [diff] [blame] | 867 | hdd_ctx->suspend_resume_stats.suspends++; |
| 868 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 869 | hdd_info("bus_suspend_noirq done"); |
Dustin Brown | 2d22823 | 2016-09-22 15:06:19 -0700 | [diff] [blame] | 870 | return 0; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 871 | |
| 872 | resume_hif_noirq: |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 873 | QDF_BUG(!hif_bus_resume_noirq(hif_ctx)); |
Dustin Brown | 105d790 | 2016-10-03 16:27:59 -0700 | [diff] [blame] | 874 | |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 875 | done: |
| 876 | hdd_err("suspend_noirq failed, status: %d", errno); |
| 877 | |
| 878 | return errno; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 879 | } |
| 880 | |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 881 | int wlan_hdd_bus_suspend_noirq(void) |
| 882 | { |
| 883 | int ret; |
| 884 | |
| 885 | cds_ssr_protect(__func__); |
| 886 | ret = __wlan_hdd_bus_suspend_noirq(); |
| 887 | cds_ssr_unprotect(__func__); |
| 888 | |
| 889 | return ret; |
| 890 | } |
| 891 | |
| 892 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 893 | * __wlan_hdd_bus_resume() - handles platform resume |
| 894 | * |
| 895 | * Does precondtion validation. Ensures that a subsystem restart isn't in |
| 896 | * progress. Ensures that no load or unload is in progress. Ensures that |
| 897 | * it has valid pointers for the required contexts. |
| 898 | * Calls into hif to resume the bus opperation. |
| 899 | * Calls into wma to handshake with firmware and notify it that the bus is up. |
| 900 | * Calls into ol_txrx for symetry. |
| 901 | * Failures are treated as catastrophic. |
| 902 | * |
| 903 | * return: error code or 0 for success |
| 904 | */ |
| 905 | static int __wlan_hdd_bus_resume(void) |
| 906 | { |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 907 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 908 | void *hif_ctx; |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 909 | int status; |
| 910 | QDF_STATUS qdf_status; |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 911 | void *dp_soc; |
| 912 | void *dp_pdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 913 | |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 914 | if (cds_is_driver_recovering()) |
| 915 | return 0; |
| 916 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 917 | hdd_info("starting bus resume"); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 918 | |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 919 | status = wlan_hdd_validate_context(hdd_ctx); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 920 | if (status) { |
| 921 | hdd_err("Invalid hdd context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 922 | return status; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 923 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 924 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 925 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 926 | hdd_debug("Driver Module closed; return success"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 927 | return 0; |
| 928 | } |
| 929 | |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 930 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 931 | if (NULL == hif_ctx) { |
| 932 | hdd_err("Failed to get hif context"); |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 933 | return -EINVAL; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 934 | } |
SaidiReddy Yenuga | d832366 | 2016-07-20 15:45:34 +0530 | [diff] [blame] | 935 | |
Komal Seelam | c12e675 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 936 | status = hif_bus_resume(hif_ctx); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 937 | if (status) { |
| 938 | hdd_err("Failed hif bus resume"); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 939 | goto out; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 940 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 941 | |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 942 | qdf_status = pmo_ucfg_psoc_bus_resume_req(hdd_ctx->hdd_psoc, |
| 943 | QDF_SYSTEM_SUSPEND); |
| 944 | status = qdf_status_to_os_return(qdf_status); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 945 | if (status) { |
Dustin Brown | 0555718 | 2017-10-12 14:44:49 -0700 | [diff] [blame] | 946 | hdd_err("Failed pmo bus resume"); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 947 | goto out; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 948 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 949 | |
Houston Hoffman | e5cd52c | 2017-02-08 17:48:57 -0800 | [diff] [blame] | 950 | status = hif_bus_late_resume(hif_ctx); |
| 951 | if (status) { |
| 952 | hdd_err("Failed hif bus late resume"); |
| 953 | goto out; |
| 954 | } |
| 955 | |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 956 | dp_soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 957 | dp_pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 958 | qdf_status = cdp_bus_resume(dp_soc, dp_pdev); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 959 | status = qdf_status_to_os_return(qdf_status); |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 960 | if (status) { |
| 961 | hdd_err("Failed cdp bus resume"); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 962 | goto out; |
Dustin Brown | 562b967 | 2016-12-22 15:25:33 -0800 | [diff] [blame] | 963 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 965 | hdd_info("bus resume succeeded"); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 966 | return 0; |
| 967 | |
| 968 | out: |
Rajeev Kumar | 1046601 | 2018-01-24 14:12:20 -0800 | [diff] [blame] | 969 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state() || |
| 970 | cds_is_fw_down()) |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 971 | return 0; |
| 972 | |
| 973 | QDF_BUG(false); |
| 974 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 975 | return status; |
| 976 | } |
| 977 | |
Rajeev Kumar | a78a0a4 | 2016-07-13 19:28:20 -0700 | [diff] [blame] | 978 | int wlan_hdd_bus_resume(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 979 | { |
| 980 | int ret; |
| 981 | |
| 982 | cds_ssr_protect(__func__); |
| 983 | ret = __wlan_hdd_bus_resume(); |
| 984 | cds_ssr_unprotect(__func__); |
| 985 | |
| 986 | return ret; |
| 987 | } |
| 988 | |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 989 | /** |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 990 | * __wlan_hdd_bus_resume_noirq(): handle bus resume no irq |
| 991 | * |
| 992 | * This function is called by the platform driver to do bus |
| 993 | * resume no IRQ before calling resume callback. Call WMA and HIF |
| 994 | * layers to complete the resume_noirq. |
| 995 | * |
| 996 | * Return: 0 for success and negative error code for failure |
| 997 | */ |
Jeff Johnson | 7782cb9 | 2016-10-05 14:22:40 -0700 | [diff] [blame] | 998 | static int __wlan_hdd_bus_resume_noirq(void) |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 999 | { |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 1000 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1001 | void *hif_ctx; |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1002 | int status; |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1003 | QDF_STATUS qdf_status; |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1004 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 1005 | hdd_info("starting bus_resume_noirq"); |
Prashanth Bhatta | 697dd0c | 2016-10-20 18:42:41 -0700 | [diff] [blame] | 1006 | if (cds_is_driver_recovering()) |
| 1007 | return 0; |
| 1008 | |
| 1009 | status = wlan_hdd_validate_context(hdd_ctx); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1010 | if (status) { |
| 1011 | hdd_err("Invalid HDD context: %d", status); |
| 1012 | return status; |
| 1013 | } |
| 1014 | |
| 1015 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Srinivas Girigowda | 852c254 | 2017-03-06 16:18:21 -0800 | [diff] [blame] | 1016 | hdd_debug("Driver Module closed return success"); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1017 | return 0; |
| 1018 | } |
| 1019 | |
| 1020 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 1021 | if (NULL == hif_ctx) |
| 1022 | return -EINVAL; |
| 1023 | |
Mukul Sharma | 4c60a7e | 2017-03-06 19:42:18 +0530 | [diff] [blame] | 1024 | qdf_status = pmo_ucfg_psoc_clear_target_wake_up(hdd_ctx->hdd_psoc); |
| 1025 | QDF_BUG(!qdf_status); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1026 | |
| 1027 | status = hif_bus_resume_noirq(hif_ctx); |
| 1028 | QDF_BUG(!status); |
| 1029 | |
Rajeev Kumar | b0ef982 | 2017-12-15 18:14:43 -0800 | [diff] [blame] | 1030 | hdd_info("bus_resume_noirq done"); |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1031 | return status; |
| 1032 | } |
| 1033 | |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1034 | int wlan_hdd_bus_resume_noirq(void) |
| 1035 | { |
| 1036 | int ret; |
| 1037 | |
| 1038 | cds_ssr_protect(__func__); |
| 1039 | ret = __wlan_hdd_bus_resume_noirq(); |
| 1040 | cds_ssr_unprotect(__func__); |
| 1041 | |
| 1042 | return ret; |
| 1043 | } |
| 1044 | |
| 1045 | /** |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1046 | * wlan_hdd_bus_reset_resume() - resume wlan bus after reset |
| 1047 | * |
| 1048 | * This function is called to tell the driver that the device has been resumed |
| 1049 | * and it has also been reset. The driver should redo any necessary |
| 1050 | * initialization. It is mainly used by the USB bus |
| 1051 | * |
| 1052 | * Return: int 0 for success, non zero for failure |
| 1053 | */ |
| 1054 | static int wlan_hdd_bus_reset_resume(void) |
| 1055 | { |
| 1056 | int ret; |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 1057 | struct hif_opaque_softc *scn = NULL; |
| 1058 | |
| 1059 | scn = cds_get_context(QDF_MODULE_ID_HIF); |
| 1060 | if (!scn) { |
| 1061 | hdd_err("Failed to get HIF context"); |
| 1062 | return -EFAULT; |
| 1063 | } |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1064 | |
| 1065 | cds_ssr_protect(__func__); |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 1066 | ret = hif_bus_reset_resume(scn); |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1067 | cds_ssr_unprotect(__func__); |
| 1068 | return ret; |
| 1069 | } |
| 1070 | |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1071 | #ifdef FEATURE_RUNTIME_PM |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1072 | /** |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1073 | * hdd_pld_runtime_suspend_cb() - Runtime suspend callback from PMO |
| 1074 | * |
| 1075 | * Return: 0 on success or error value otherwise |
| 1076 | */ |
| 1077 | static int hdd_pld_runtime_suspend_cb(void) |
| 1078 | { |
| 1079 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 1080 | |
| 1081 | if (!qdf_dev) { |
| 1082 | hdd_err("Invalid context"); |
| 1083 | return -EINVAL; |
| 1084 | } |
| 1085 | |
| 1086 | return pld_auto_suspend(qdf_dev->dev); |
| 1087 | } |
| 1088 | |
| 1089 | /** |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1090 | * __wlan_hdd_runtime_suspend() - suspend the wlan bus without apps suspend |
| 1091 | * |
| 1092 | * Each layer is responsible for its own suspend actions. wma_runtime_suspend |
| 1093 | * takes care of the parts of the 802.11 suspend that we want to do for runtime |
| 1094 | * suspend. |
| 1095 | * |
| 1096 | * Return: 0 or errno |
| 1097 | */ |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 1098 | static int __wlan_hdd_runtime_suspend(struct device *dev) |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1099 | { |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1100 | int err; |
| 1101 | QDF_STATUS status; |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 1102 | struct hdd_context *hdd_ctx; |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1103 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1104 | hdd_debug("Starting runtime suspend"); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1105 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1106 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1107 | err = wlan_hdd_validate_context(hdd_ctx); |
| 1108 | if (err) |
| 1109 | return err; |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1110 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1111 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1112 | hdd_debug("Driver module closed skipping runtime suspend"); |
| 1113 | return 0; |
| 1114 | } |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1115 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1116 | if (ucfg_scan_get_pdev_status(hdd_ctx->hdd_pdev) != |
| 1117 | SCAN_NOT_IN_PROGRESS) { |
| 1118 | hdd_debug("Scan in progress, ignore runtime suspend"); |
| 1119 | return -EBUSY; |
| 1120 | } |
Yue Ma | 1e11d79 | 2016-02-26 18:58:44 -0800 | [diff] [blame] | 1121 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1122 | status = pmo_ucfg_psoc_bus_runtime_suspend(hdd_ctx->hdd_psoc, |
| 1123 | hdd_pld_runtime_suspend_cb); |
| 1124 | err = qdf_status_to_os_return(status); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1125 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1126 | hdd_debug("Runtime suspend done result: %d", err); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1127 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1128 | return err; |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1129 | } |
| 1130 | |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1131 | /** |
| 1132 | * wlan_hdd_runtime_suspend() - suspend the wlan bus without apps suspend |
| 1133 | * |
| 1134 | * This function is called by the platform driver to suspend the |
| 1135 | * wlan bus separately from system suspend |
| 1136 | * |
| 1137 | * Return: 0 or errno |
| 1138 | */ |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 1139 | static int wlan_hdd_runtime_suspend(struct device *dev) |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1140 | { |
| 1141 | int ret; |
| 1142 | |
| 1143 | cds_ssr_protect(__func__); |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 1144 | ret = __wlan_hdd_runtime_suspend(dev); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1145 | cds_ssr_unprotect(__func__); |
| 1146 | |
| 1147 | return ret; |
| 1148 | } |
| 1149 | |
| 1150 | /** |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1151 | * hdd_pld_runtime_resume_cb() - Runtime resume callback from PMO |
| 1152 | * |
| 1153 | * Return: 0 on success or error value otherwise |
| 1154 | */ |
| 1155 | static int hdd_pld_runtime_resume_cb(void) |
| 1156 | { |
| 1157 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 1158 | |
| 1159 | if (!qdf_dev) { |
| 1160 | hdd_err("Invalid context"); |
| 1161 | return -EINVAL; |
| 1162 | } |
| 1163 | |
| 1164 | return pld_auto_resume(qdf_dev->dev); |
| 1165 | } |
| 1166 | |
| 1167 | /** |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1168 | * __wlan_hdd_runtime_resume() - resume the wlan bus from runtime suspend |
| 1169 | * |
| 1170 | * Sets the runtime pm state and coordinates resume between hif wma and |
| 1171 | * ol_txrx. |
| 1172 | * |
| 1173 | * Return: success since failure is a bug |
| 1174 | */ |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 1175 | static int __wlan_hdd_runtime_resume(struct device *dev) |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1176 | { |
Jeff Johnson | 6bc79d8 | 2017-08-28 12:02:36 -0700 | [diff] [blame] | 1177 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1178 | QDF_STATUS status; |
Komal Seelam | c12e675 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 1179 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 1180 | hdd_debug("Starting runtime resume"); |
| 1181 | |
| 1182 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 1183 | return 0; |
| 1184 | |
| 1185 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1186 | hdd_debug("Driver module closed skipping runtime resume"); |
| 1187 | return 0; |
| 1188 | } |
| 1189 | |
| 1190 | status = pmo_ucfg_psoc_bus_runtime_resume(hdd_ctx->hdd_psoc, |
| 1191 | hdd_pld_runtime_resume_cb); |
| 1192 | if (status != QDF_STATUS_SUCCESS) |
| 1193 | hdd_err("PMO Runtime resume failed: %d", status); |
| 1194 | |
| 1195 | hdd_debug("Runtime resume done"); |
| 1196 | |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1197 | return 0; |
| 1198 | } |
| 1199 | |
| 1200 | /** |
| 1201 | * wlan_hdd_runtime_resume() - resume the wlan bus from runtime suspend |
| 1202 | * |
| 1203 | * This function is called by the platform driver to resume the |
| 1204 | * wlan bus separately from system suspend |
| 1205 | * |
| 1206 | * Return: success since failure is a bug |
| 1207 | */ |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 1208 | static int wlan_hdd_runtime_resume(struct device *dev) |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1209 | { |
| 1210 | int ret; |
| 1211 | |
| 1212 | cds_ssr_protect(__func__); |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 1213 | ret = __wlan_hdd_runtime_resume(dev); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1214 | cds_ssr_unprotect(__func__); |
| 1215 | |
| 1216 | return ret; |
| 1217 | } |
| 1218 | #endif |
| 1219 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1220 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1221 | * wlan_hdd_pld_probe() - probe function registered to PLD |
| 1222 | * @dev: device |
| 1223 | * @pld_bus_type: PLD bus type |
| 1224 | * @bdev: bus device structure |
| 1225 | * @id: bus identifier for shared busses |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1226 | * |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1227 | * Return: 0 on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1228 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1229 | static int wlan_hdd_pld_probe(struct device *dev, |
| 1230 | enum pld_bus_type pld_bus_type, |
| 1231 | void *bdev, void *id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1232 | { |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1233 | enum qdf_bus_type bus_type; |
| 1234 | |
| 1235 | bus_type = to_bus_type(pld_bus_type); |
| 1236 | if (bus_type == QDF_BUS_TYPE_NONE) { |
| 1237 | hdd_err("Invalid bus type %d->%d", |
| 1238 | pld_bus_type, bus_type); |
| 1239 | return -EINVAL; |
| 1240 | } |
| 1241 | |
| 1242 | return wlan_hdd_probe(dev, bdev, id, bus_type, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1246 | * wlan_hdd_pld_remove() - remove function registered to PLD |
| 1247 | * @dev: device |
| 1248 | * @pld_bus_type: PLD bus type |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1249 | * |
| 1250 | * Return: void |
| 1251 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1252 | static void wlan_hdd_pld_remove(struct device *dev, |
| 1253 | enum pld_bus_type bus_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1254 | { |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 1255 | ENTER(); |
| 1256 | mutex_lock(&hdd_init_deinit_lock); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 1257 | hdd_start_driver_ops_timer(eHDD_DRV_OP_REMOVE); |
| 1258 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 1259 | wlan_hdd_remove(dev); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 1260 | |
| 1261 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 1262 | mutex_unlock(&hdd_init_deinit_lock); |
| 1263 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1264 | } |
| 1265 | |
| 1266 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1267 | * wlan_hdd_pld_shutdown() - shutdown function registered to PLD |
| 1268 | * @dev: device |
| 1269 | * @pld_bus_type: PLD bus type |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1270 | * |
| 1271 | * Return: void |
| 1272 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1273 | static void wlan_hdd_pld_shutdown(struct device *dev, |
| 1274 | enum pld_bus_type bus_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1275 | { |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 1276 | ENTER(); |
| 1277 | mutex_lock(&hdd_init_deinit_lock); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 1278 | hdd_start_driver_ops_timer(eHDD_DRV_OP_SHUTDOWN); |
| 1279 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1280 | wlan_hdd_shutdown(); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 1281 | |
| 1282 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 1283 | mutex_unlock(&hdd_init_deinit_lock); |
| 1284 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1288 | * wlan_hdd_pld_reinit() - reinit function registered to PLD |
| 1289 | * @dev: device |
| 1290 | * @pld_bus_type: PLD bus type |
| 1291 | * @bdev: bus device structure |
| 1292 | * @id: bus identifier for shared busses |
| 1293 | * |
| 1294 | * Return: 0 on success |
| 1295 | */ |
| 1296 | static int wlan_hdd_pld_reinit(struct device *dev, |
| 1297 | enum pld_bus_type pld_bus_type, |
| 1298 | void *bdev, void *id) |
| 1299 | { |
| 1300 | enum qdf_bus_type bus_type; |
| 1301 | |
| 1302 | bus_type = to_bus_type(pld_bus_type); |
| 1303 | if (bus_type == QDF_BUS_TYPE_NONE) { |
| 1304 | hdd_err("Invalid bus type %d->%d", |
| 1305 | pld_bus_type, bus_type); |
| 1306 | return -EINVAL; |
| 1307 | } |
| 1308 | |
| 1309 | return wlan_hdd_probe(dev, bdev, id, bus_type, true); |
| 1310 | } |
| 1311 | |
| 1312 | /** |
| 1313 | * wlan_hdd_pld_crash_shutdown() - crash_shutdown function registered to PLD |
| 1314 | * @dev: device |
| 1315 | * @pld_bus_type: PLD bus type |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1316 | * |
| 1317 | * Return: void |
| 1318 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1319 | static void wlan_hdd_pld_crash_shutdown(struct device *dev, |
| 1320 | enum pld_bus_type bus_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1321 | { |
| 1322 | wlan_hdd_crash_shutdown(); |
| 1323 | } |
| 1324 | |
| 1325 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1326 | * wlan_hdd_pld_suspend() - suspend function registered to PLD |
| 1327 | * @dev: device |
| 1328 | * @pld_bus_type: PLD bus type |
| 1329 | * @state: PM state |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1330 | * |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1331 | * Return: 0 on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1332 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1333 | static int wlan_hdd_pld_suspend(struct device *dev, |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1334 | enum pld_bus_type bus_type, |
| 1335 | pm_message_t state) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1336 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1337 | { |
Dustin Brown | 9ef609b | 2017-03-15 12:19:37 -0700 | [diff] [blame] | 1338 | return wlan_hdd_bus_suspend(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1339 | } |
| 1340 | |
| 1341 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1342 | * wlan_hdd_pld_resume() - resume function registered to PLD |
| 1343 | * @dev: device |
| 1344 | * @pld_bus_type: PLD bus type |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1345 | * |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1346 | * Return: 0 on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1347 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1348 | static int wlan_hdd_pld_resume(struct device *dev, |
| 1349 | enum pld_bus_type bus_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1350 | { |
| 1351 | return wlan_hdd_bus_resume(); |
| 1352 | } |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1353 | |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1354 | |
| 1355 | /** |
| 1356 | * wlan_hdd_pld_suspend_noirq() - handle suspend no irq |
| 1357 | * @dev: device |
| 1358 | * @pld_bus_type: PLD bus type |
| 1359 | * |
| 1360 | * Complete the actions started by suspend(). Carry out any |
| 1361 | * additional operations required for suspending the device that might be |
| 1362 | * racing with its driver's interrupt handler, which is guaranteed not to |
| 1363 | * run while suspend_noirq() is being executed. Make sure to resume device |
| 1364 | * if FW has sent initial wake up message and expecting APPS to wake up. |
| 1365 | * |
| 1366 | * Return: 0 on success |
| 1367 | */ |
| 1368 | static int wlan_hdd_pld_suspend_noirq(struct device *dev, |
| 1369 | enum pld_bus_type bus_type) |
| 1370 | { |
| 1371 | return wlan_hdd_bus_suspend_noirq(); |
| 1372 | } |
| 1373 | |
| 1374 | /** |
| 1375 | * wlan_hdd_pld_resume_noirq() - handle resume no irq |
| 1376 | * @dev: device |
| 1377 | * @pld_bus_type: PLD bus type |
| 1378 | * |
| 1379 | * Prepare for the execution of resume() by carrying out any |
| 1380 | * operations required for resuming the device that might be racing with |
| 1381 | * its driver's interrupt handler, which is guaranteed not to run while |
| 1382 | * resume_noirq() is being executed. Make sure to clear target initial |
| 1383 | * wake up request such that next suspend can happen cleanly. |
| 1384 | * |
| 1385 | * Return: 0 on success |
| 1386 | */ |
| 1387 | static int wlan_hdd_pld_resume_noirq(struct device *dev, |
| 1388 | enum pld_bus_type bus_type) |
| 1389 | { |
| 1390 | return wlan_hdd_bus_resume_noirq(); |
| 1391 | } |
| 1392 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1393 | /** |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1394 | * wlan_hdd_pld_reset_resume() - reset resume function registered to PLD |
| 1395 | * @dev: device |
| 1396 | * @pld_bus_type: PLD bus type |
| 1397 | * |
| 1398 | * Return: 0 on success |
| 1399 | */ |
| 1400 | static int wlan_hdd_pld_reset_resume(struct device *dev, |
| 1401 | enum pld_bus_type bus_type) |
| 1402 | { |
| 1403 | return wlan_hdd_bus_reset_resume(); |
| 1404 | } |
| 1405 | |
| 1406 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1407 | * wlan_hdd_pld_notify_handler() - notify_handler function registered to PLD |
| 1408 | * @dev: device |
| 1409 | * @pld_bus_type: PLD bus type |
| 1410 | * @state: Modem power state |
| 1411 | * |
| 1412 | * Return: void |
| 1413 | */ |
| 1414 | static void wlan_hdd_pld_notify_handler(struct device *dev, |
| 1415 | enum pld_bus_type bus_type, |
| 1416 | int state) |
| 1417 | { |
| 1418 | wlan_hdd_notify_handler(state); |
| 1419 | } |
| 1420 | |
Arunk Khandavalli | 932a9e1 | 2017-10-04 12:41:27 +0530 | [diff] [blame] | 1421 | static void wlan_hdd_purge_notifier(void) |
| 1422 | { |
| 1423 | struct hdd_context *hdd_ctx; |
| 1424 | |
| 1425 | ENTER(); |
| 1426 | |
| 1427 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1428 | if (!hdd_ctx) { |
| 1429 | hdd_err("hdd context is NULL return!!"); |
| 1430 | return; |
| 1431 | } |
| 1432 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 1433 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 1434 | |
| 1435 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arunk Khandavalli | 932a9e1 | 2017-10-04 12:41:27 +0530 | [diff] [blame] | 1436 | cds_shutdown_notifier_call(); |
| 1437 | cds_shutdown_notifier_purge(); |
| 1438 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 1439 | EXIT(); |
| 1440 | } |
| 1441 | |
Yuanyuan Liu | 06a342f | 2017-01-12 16:48:19 -0800 | [diff] [blame] | 1442 | /** |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1443 | * wlan_hdd_set_the_pld_uevent() - set the pld event |
| 1444 | * @uevent: uevent status |
| 1445 | * |
| 1446 | * Return: void |
| 1447 | */ |
| 1448 | static void wlan_hdd_set_the_pld_uevent(struct pld_uevent_data *uevent) |
| 1449 | { |
| 1450 | switch (uevent->uevent) { |
| 1451 | case PLD_RECOVERY: |
| 1452 | cds_set_recovery_in_progress(true); |
| 1453 | break; |
| 1454 | case PLD_FW_DOWN: |
| 1455 | cds_set_fw_state(CDS_FW_STATE_DOWN); |
| 1456 | break; |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | /** |
| 1461 | * wlan_hdd_handle_the_pld_uevent() - handle the pld event |
| 1462 | * @uevent: uevent status |
| 1463 | * |
| 1464 | * Return: void |
| 1465 | */ |
| 1466 | static void wlan_hdd_handle_the_pld_uevent(struct pld_uevent_data *uevent) |
| 1467 | { |
| 1468 | enum cds_driver_state driver_state; |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 1469 | struct hdd_context *hdd_ctx; |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1470 | |
| 1471 | driver_state = cds_get_driver_state(); |
| 1472 | |
| 1473 | if (driver_state == CDS_DRIVER_STATE_UNINITIALIZED) |
| 1474 | return; |
| 1475 | |
| 1476 | if (cds_is_driver_loading()) |
| 1477 | return; |
| 1478 | |
| 1479 | switch (uevent->uevent) { |
| 1480 | case PLD_RECOVERY: |
| 1481 | hdd_pld_ipa_uc_shutdown_pipes(); |
| 1482 | break; |
| 1483 | case PLD_FW_DOWN: |
| 1484 | qdf_complete_wait_events(); |
| 1485 | cds_set_target_ready(false); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 1486 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1487 | if (hdd_ctx != NULL) |
| 1488 | wlan_cfg80211_cleanup_scan_queue( |
| 1489 | hdd_ctx->hdd_pdev); |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1490 | break; |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1491 | default: |
| 1492 | break; |
| 1493 | } |
| 1494 | } |
| 1495 | |
| 1496 | /** |
Anurag Chouhan | 1ddb9b3 | 2017-04-13 13:57:09 +0530 | [diff] [blame] | 1497 | * wlan_hdd_pld_uevent() - update driver status |
Yuanyuan Liu | 06a342f | 2017-01-12 16:48:19 -0800 | [diff] [blame] | 1498 | * @dev: device |
Anurag Chouhan | 1ddb9b3 | 2017-04-13 13:57:09 +0530 | [diff] [blame] | 1499 | * @uevent: uevent status |
Yuanyuan Liu | 06a342f | 2017-01-12 16:48:19 -0800 | [diff] [blame] | 1500 | * |
| 1501 | * Return: void |
| 1502 | */ |
Anurag Chouhan | 1ddb9b3 | 2017-04-13 13:57:09 +0530 | [diff] [blame] | 1503 | static void wlan_hdd_pld_uevent(struct device *dev, |
| 1504 | struct pld_uevent_data *uevent) |
Yuanyuan Liu | 06a342f | 2017-01-12 16:48:19 -0800 | [diff] [blame] | 1505 | { |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1506 | ENTER(); |
Sandeep Puligilla | 5ac6bd2 | 2017-10-17 12:33:56 -0700 | [diff] [blame] | 1507 | hdd_info("pld event %d", uevent->uevent); |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1508 | |
| 1509 | mutex_lock(&hdd_init_deinit_lock); |
| 1510 | wlan_hdd_set_the_pld_uevent(uevent); |
| 1511 | wlan_hdd_handle_the_pld_uevent(uevent); |
| 1512 | mutex_unlock(&hdd_init_deinit_lock); |
Arunk Khandavalli | 932a9e1 | 2017-10-04 12:41:27 +0530 | [diff] [blame] | 1513 | |
| 1514 | wlan_hdd_purge_notifier(); |
Kabilan Kannan | d48b016 | 2017-11-22 14:00:44 -0800 | [diff] [blame] | 1515 | EXIT(); |
Yuanyuan Liu | 06a342f | 2017-01-12 16:48:19 -0800 | [diff] [blame] | 1516 | } |
| 1517 | |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1518 | #ifdef FEATURE_RUNTIME_PM |
| 1519 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1520 | * wlan_hdd_pld_runtime_suspend() - runtime suspend function registered to PLD |
| 1521 | * @dev: device |
| 1522 | * @pld_bus_type: PLD bus type |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1523 | * |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1524 | * Return: 0 on success |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1525 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1526 | static int wlan_hdd_pld_runtime_suspend(struct device *dev, |
| 1527 | enum pld_bus_type bus_type) |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1528 | { |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 1529 | return wlan_hdd_runtime_suspend(dev); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1530 | } |
| 1531 | |
| 1532 | /** |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1533 | * wlan_hdd_pld_runtime_resume() - runtime resume function registered to PLD |
| 1534 | * @dev: device |
| 1535 | * @pld_bus_type: PLD bus type |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1536 | * |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1537 | * Return: 0 on success |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1538 | */ |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1539 | static int wlan_hdd_pld_runtime_resume(struct device *dev, |
| 1540 | enum pld_bus_type bus_type) |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1541 | { |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 1542 | return wlan_hdd_runtime_resume(dev); |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1543 | } |
| 1544 | #endif |
| 1545 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1546 | struct pld_driver_ops wlan_drv_ops = { |
| 1547 | .probe = wlan_hdd_pld_probe, |
| 1548 | .remove = wlan_hdd_pld_remove, |
| 1549 | .shutdown = wlan_hdd_pld_shutdown, |
| 1550 | .reinit = wlan_hdd_pld_reinit, |
| 1551 | .crash_shutdown = wlan_hdd_pld_crash_shutdown, |
| 1552 | .suspend = wlan_hdd_pld_suspend, |
| 1553 | .resume = wlan_hdd_pld_resume, |
Rajeev Kumar | 99805a7 | 2016-08-29 13:53:52 -0700 | [diff] [blame] | 1554 | .suspend_noirq = wlan_hdd_pld_suspend_noirq, |
| 1555 | .resume_noirq = wlan_hdd_pld_resume_noirq, |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 1556 | .reset_resume = wlan_hdd_pld_reset_resume, |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1557 | .modem_status = wlan_hdd_pld_notify_handler, |
Anurag Chouhan | 1ddb9b3 | 2017-04-13 13:57:09 +0530 | [diff] [blame] | 1558 | .uevent = wlan_hdd_pld_uevent, |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1559 | #ifdef FEATURE_RUNTIME_PM |
Jeff Johnson | 330292a | 2016-05-16 16:09:49 -0700 | [diff] [blame] | 1560 | .runtime_suspend = wlan_hdd_pld_runtime_suspend, |
| 1561 | .runtime_resume = wlan_hdd_pld_runtime_resume, |
Houston Hoffman | e893708 | 2015-11-10 16:49:12 -0800 | [diff] [blame] | 1562 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1563 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1564 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1565 | int wlan_hdd_register_driver(void) |
| 1566 | { |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1567 | return pld_register_driver(&wlan_drv_ops); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1568 | } |
| 1569 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1570 | void wlan_hdd_unregister_driver(void) |
| 1571 | { |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 1572 | pld_unregister_driver(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1573 | } |