2 * Copyright (c) 2014 Qualcomm Atheros, Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 int wil_can_suspend(struct wil6210_priv
*wil
, bool is_runtime
)
22 struct wireless_dev
*wdev
= wil
->wdev
;
24 wil_dbg_pm(wil
, "%s(%s)\n", __func__
,
25 is_runtime
? "runtime" : "system");
27 switch (wdev
->iftype
) {
28 case NL80211_IFTYPE_MONITOR
:
29 case NL80211_IFTYPE_STATION
:
30 case NL80211_IFTYPE_P2P_CLIENT
:
32 /* AP-like interface - can't suspend */
34 wil_dbg_pm(wil
, "AP-like interface\n");
39 wil_dbg_pm(wil
, "%s(%s) => %s (%d)\n", __func__
,
40 is_runtime
? "runtime" : "system", rc
? "No" : "Yes", rc
);
45 int wil_suspend(struct wil6210_priv
*wil
, bool is_runtime
)
48 struct net_device
*ndev
= wil_to_ndev(wil
);
50 wil_dbg_pm(wil
, "%s(%s)\n", __func__
,
51 is_runtime
? "runtime" : "system");
53 /* if netif up, hardware is alive, shut it down */
54 if (ndev
->flags
& IFF_UP
) {
57 wil_err(wil
, "wil_down : %d\n", rc
);
62 if (wil
->platform_ops
.suspend
)
63 rc
= wil
->platform_ops
.suspend(wil
->platform_handle
);
66 wil_dbg_pm(wil
, "%s(%s) => %d\n", __func__
,
67 is_runtime
? "runtime" : "system", rc
);
71 int wil_resume(struct wil6210_priv
*wil
, bool is_runtime
)
74 struct net_device
*ndev
= wil_to_ndev(wil
);
76 wil_dbg_pm(wil
, "%s(%s)\n", __func__
,
77 is_runtime
? "runtime" : "system");
79 if (wil
->platform_ops
.resume
) {
80 rc
= wil
->platform_ops
.resume(wil
->platform_handle
);
82 wil_err(wil
, "platform_ops.resume : %d\n", rc
);
87 /* if netif up, bring hardware up
88 * During open(), IFF_UP set after actual device method
89 * invocation. This prevent recursive call to wil_up()
91 if (ndev
->flags
& IFF_UP
)
95 wil_dbg_pm(wil
, "%s(%s) => %d\n", __func__
,
96 is_runtime
? "runtime" : "system", rc
);