1 From fa9b7fc2e662e086a7c0e045e541f773bf34c555 Mon Sep 17 00:00:00 2001
2 From: Ivo van Doorn <IvDoorn@gmail.com>
3 Date: Sat, 10 Jan 2009 14:31:00 +0100
4 Subject: [PATCH] rt2x00: Add powersaving support (rt2800usb)
6 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
8 drivers/net/wireless/rt2x00/rt2800usb.c | 36 ++++++++++++++++++++++++++++++-
9 1 files changed, 35 insertions(+), 1 deletions(-)
11 --- a/drivers/net/wireless/rt2x00/rt2800usb.c
12 +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
13 @@ -860,6 +860,36 @@ static void rt2800usb_config_duration(st
14 rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
17 +static void rt2800usb_config_ps(struct rt2x00_dev *rt2x00dev,
18 + struct rt2x00lib_conf *libconf)
20 + enum dev_state state =
21 + (libconf->conf->flags & IEEE80211_CONF_PS) ?
22 + STATE_SLEEP : STATE_AWAKE;
25 + if (state == STATE_SLEEP) {
26 + rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, 0);
28 + rt2x00usb_register_read(rt2x00dev, AUTOWAKEUP_CFG, ®);
29 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_AUTO_LEAD_TIME, 5);
30 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE,
31 + libconf->conf->listen_interval - 1);
32 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_AUTOWAKE, 1);
33 + rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, reg);
35 + rt2800usb_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 0);
37 + rt2800usb_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 0);
39 + rt2x00usb_register_read(rt2x00dev, AUTOWAKEUP_CFG, ®);
40 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_AUTO_LEAD_TIME, 0);
41 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE, 0);
42 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_AUTOWAKE, 0);
43 + rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, reg);
47 static void rt2800usb_config(struct rt2x00_dev *rt2x00dev,
48 struct rt2x00lib_conf *libconf,
49 const unsigned int flags)
50 @@ -876,6 +906,8 @@ static void rt2800usb_config(struct rt2x
51 rt2800usb_config_retry_limit(rt2x00dev, libconf);
52 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
53 rt2800usb_config_duration(rt2x00dev, libconf);
54 + if (flags & IEEE80211_CONF_CHANGE_PS)
55 + rt2800usb_config_ps(rt2x00dev, libconf);
59 @@ -2112,7 +2144,9 @@ static int rt2800usb_probe_hw_mode(struc
61 rt2x00dev->hw->flags =
62 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
63 - IEEE80211_HW_SIGNAL_DBM;
64 + IEEE80211_HW_SIGNAL_DBM |
65 + IEEE80211_HW_SUPPORTS_PS |
66 + IEEE80211_HW_PS_NULLFUNC_STACK;
67 rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE + TXINFO_DESC_SIZE;
69 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);