1 // SPDX-License-Identifier: BSD-3-Clause-Clear
3 * Copyright (c) 2020 The Linux Foundation. All rights reserved.
6 #include <linux/delay.h>
15 int ath11k_wow_enable(struct ath11k_base *ab)
17 struct ath11k *ar = ath11k_ab_to_ar(ab, 0);
20 clear_bit(ATH11K_FLAG_HTC_SUSPEND_COMPLETE, &ab->dev_flags);
22 for (i = 0; i < ATH11K_WOW_RETRY_NUM; i++) {
23 reinit_completion(&ab->htc_suspend);
25 ret = ath11k_wmi_wow_enable(ar);
27 ath11k_warn(ab, "failed to issue wow enable: %d\n", ret);
31 ret = wait_for_completion_timeout(&ab->htc_suspend, 3 * HZ);
34 "timed out while waiting for htc suspend completion\n");
38 if (test_bit(ATH11K_FLAG_HTC_SUSPEND_COMPLETE, &ab->dev_flags))
39 /* success, suspend complete received */
42 ath11k_warn(ab, "htc suspend not complete, retrying (try %d)\n",
44 msleep(ATH11K_WOW_RETRY_WAIT_MS);
47 ath11k_warn(ab, "htc suspend not complete, failing after %d tries\n", i);
52 int ath11k_wow_wakeup(struct ath11k_base *ab)
54 struct ath11k *ar = ath11k_ab_to_ar(ab, 0);
57 reinit_completion(&ab->wow.wakeup_completed);
59 ret = ath11k_wmi_wow_host_wakeup_ind(ar);
61 ath11k_warn(ab, "failed to send wow wakeup indication: %d\n",
66 ret = wait_for_completion_timeout(&ab->wow.wakeup_completed, 3 * HZ);
68 ath11k_warn(ab, "timed out while waiting for wow wakeup completion\n");