1 /* 2 * power management interfaces for XRadio drivers 3 * 4 * Copyright (c) 2013 5 * Xradio Technology Co., Ltd. <www.xradiotech.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 10 */ 11 12 13 #ifndef PM_H_INCLUDED 14 #define PM_H_INCLUDED 15 16 #ifdef CONFIG_WAKELOCK 17 #include <linux/wakelock.h> 18 #endif 19 20 /* ******************************************************************** */ 21 /* mac80211 API */ 22 23 #define XRADIO_WAKE_LOCK "xradio_wlan" 24 25 /* extern */ struct xradio_common; 26 /* private */ struct xradio_suspend_state; 27 28 #ifndef CONFIG_WAKELOCK 29 enum xradio_pm_keep_wake_state { 30 XRADIO_PM_STATE_ALLOW_SUSPEND, 31 XRADIO_PM_STATE_KEEP_WAKE, 32 }; 33 #endif 34 35 struct xradio_pm_state { 36 #ifdef CONFIG_WAKELOCK 37 struct wake_lock wakelock; 38 #else 39 struct timer_list stay_awake; 40 atomic_t status; 41 #endif 42 spinlock_t lock; 43 long expires_save; 44 }; 45 46 struct xradio_pm_state_vif { 47 struct xradio_suspend_state *suspend_state; 48 }; 49 50 enum suspend_state { 51 XRADIO_RESUME = 0, 52 XRADIO_CONNECT_SUSP, 53 XRADIO_DISCONNECT_SUSP, 54 #ifdef CONFIG_XRADIO_SUSPEND_POWER_OFF 55 XRADIO_POWEROFF_SUSP 56 #endif 57 }; 58 59 enum suspend_lock_state { 60 XRADIO_SUSPEND_LOCK_IDEL = 0, 61 XRADIO_SUSPEND_LOCK_SUSPEND, 62 XRADIO_SUSPEND_LOCK_OTHERS, 63 }; 64 65 int xradio_pm_init(struct xradio_pm_state *pm, struct xradio_common *priv); 66 void xradio_pm_deinit(struct xradio_pm_state *pm); 67 void xradio_pm_stay_awake(struct xradio_pm_state *pm, unsigned long tmo); 68 void xradio_pm_lock_awake(struct xradio_pm_state *pm); 69 void xradio_pm_unlock_awake(struct xradio_pm_state *pm); 70 int xradio_wow_suspend(struct ieee80211_hw *hw, 71 struct cfg80211_wowlan *wowlan); 72 int xradio_wow_resume(struct ieee80211_hw *hw); 73 74 #endif 75