aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt73usb.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-12-20 04:52:42 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:58:34 -0500
commit7d7f19ccb777946df0a8fb7c83189ba2ae08b02e (patch)
tree38fcea85510a4945283cf23bc029261b3941fc74 /drivers/net/wireless/rt2x00/rt73usb.c
parent3ebbbb56a162b8f9b9a77bc7810b9d4e0868e039 (diff)
rt2x00: Implement Powersaving
Listen to IEEE80211_CONF_PS to determine if the device should drop into powersaving mode. This feature depends on the dynamic power save functionality in mac80211. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt73usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 96a8d69f8790..ae3b31d0d511 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -844,6 +844,44 @@ static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev,
844 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg); 844 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
845} 845}
846 846
847static void rt73usb_config_ps(struct rt2x00_dev *rt2x00dev,
848 struct rt2x00lib_conf *libconf)
849{
850 enum dev_state state =
851 (libconf->conf->flags & IEEE80211_CONF_PS) ?
852 STATE_SLEEP : STATE_AWAKE;
853 u32 reg;
854
855 if (state == STATE_SLEEP) {
856 rt2x00usb_register_read(rt2x00dev, MAC_CSR11, &reg);
857 rt2x00_set_field32(&reg, MAC_CSR11_DELAY_AFTER_TBCN,
858 libconf->conf->beacon_int - 10);
859 rt2x00_set_field32(&reg, MAC_CSR11_TBCN_BEFORE_WAKEUP,
860 libconf->conf->listen_interval - 1);
861 rt2x00_set_field32(&reg, MAC_CSR11_WAKEUP_LATENCY, 5);
862
863 /* We must first disable autowake before it can be enabled */
864 rt2x00_set_field32(&reg, MAC_CSR11_AUTOWAKE, 0);
865 rt2x00usb_register_write(rt2x00dev, MAC_CSR11, reg);
866
867 rt2x00_set_field32(&reg, MAC_CSR11_AUTOWAKE, 1);
868 rt2x00usb_register_write(rt2x00dev, MAC_CSR11, reg);
869
870 rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
871 USB_MODE_SLEEP, REGISTER_TIMEOUT);
872 } else {
873 rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
874 USB_MODE_WAKEUP, REGISTER_TIMEOUT);
875
876 rt2x00usb_register_read(rt2x00dev, MAC_CSR11, &reg);
877 rt2x00_set_field32(&reg, MAC_CSR11_DELAY_AFTER_TBCN, 0);
878 rt2x00_set_field32(&reg, MAC_CSR11_TBCN_BEFORE_WAKEUP, 0);
879 rt2x00_set_field32(&reg, MAC_CSR11_AUTOWAKE, 0);
880 rt2x00_set_field32(&reg, MAC_CSR11_WAKEUP_LATENCY, 0);
881 rt2x00usb_register_write(rt2x00dev, MAC_CSR11, reg);
882 }
883}
884
847static void rt73usb_config(struct rt2x00_dev *rt2x00dev, 885static void rt73usb_config(struct rt2x00_dev *rt2x00dev,
848 struct rt2x00lib_conf *libconf, 886 struct rt2x00lib_conf *libconf,
849 const unsigned int flags) 887 const unsigned int flags)
@@ -861,6 +899,8 @@ static void rt73usb_config(struct rt2x00_dev *rt2x00dev,
861 rt73usb_config_retry_limit(rt2x00dev, libconf); 899 rt73usb_config_retry_limit(rt2x00dev, libconf);
862 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL) 900 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
863 rt73usb_config_duration(rt2x00dev, libconf); 901 rt73usb_config_duration(rt2x00dev, libconf);
902 if (flags & IEEE80211_CONF_CHANGE_PS)
903 rt73usb_config_ps(rt2x00dev, libconf);
864} 904}
865 905
866/* 906/*