308-rt2x00-Add-powersaving-support-rt2800pci.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. From 059fef55f609bded8e83ec8b54729a2f500db938 Mon Sep 17 00:00:00 2001
  2. From: Ivo van Doorn <[email protected]>
  3. Date: Sat, 10 Jan 2009 14:29:21 +0100
  4. Subject: [PATCH] rt2x00: Add powersaving support (rt2800pci)
  5. Signed-off-by: Ivo van Doorn <[email protected]>
  6. ---
  7. drivers/net/wireless/rt2x00/rt2800pci.c | 36 ++++++++++++++++++++++++++++++-
  8. 1 files changed, 35 insertions(+), 1 deletions(-)
  9. --- a/drivers/net/wireless/rt2x00/rt2800pci.c
  10. +++ b/drivers/net/wireless/rt2x00/rt2800pci.c
  11. @@ -880,6 +880,36 @@ static void rt2800pci_config_duration(st
  12. rt2x00pci_register_write(rt2x00dev, BCN_TIME_CFG, reg);
  13. }
  14. +static void rt2800pci_config_ps(struct rt2x00_dev *rt2x00dev,
  15. + struct rt2x00lib_conf *libconf)
  16. +{
  17. + enum dev_state state =
  18. + (libconf->conf->flags & IEEE80211_CONF_PS) ?
  19. + STATE_SLEEP : STATE_AWAKE;
  20. + u32 reg;
  21. +
  22. + if (state == STATE_SLEEP) {
  23. + rt2x00pci_register_write(rt2x00dev, AUTOWAKEUP_CFG, 0);
  24. +
  25. + rt2x00pci_register_read(rt2x00dev, AUTOWAKEUP_CFG, &reg);
  26. + rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_AUTO_LEAD_TIME, 5);
  27. + rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE,
  28. + libconf->conf->listen_interval - 1);
  29. + rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_AUTOWAKE, 1);
  30. + rt2x00pci_register_write(rt2x00dev, AUTOWAKEUP_CFG, reg);
  31. +
  32. + rt2800pci_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 0);
  33. + } else {
  34. + rt2800pci_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 0);
  35. +
  36. + rt2x00pci_register_read(rt2x00dev, AUTOWAKEUP_CFG, &reg);
  37. + rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_AUTO_LEAD_TIME, 0);
  38. + rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE, 0);
  39. + rt2x00_set_field32(&reg, AUTOWAKEUP_CFG_AUTOWAKE, 0);
  40. + rt2x00pci_register_write(rt2x00dev, AUTOWAKEUP_CFG, reg);
  41. + }
  42. +}
  43. +
  44. static void rt2800pci_config(struct rt2x00_dev *rt2x00dev,
  45. struct rt2x00lib_conf *libconf,
  46. const unsigned int flags)
  47. @@ -896,6 +926,8 @@ static void rt2800pci_config(struct rt2x
  48. rt2800pci_config_retry_limit(rt2x00dev, libconf);
  49. if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
  50. rt2800pci_config_duration(rt2x00dev, libconf);
  51. + if (flags & IEEE80211_CONF_CHANGE_PS)
  52. + rt2800pci_config_ps(rt2x00dev, libconf);
  53. }
  54. /*
  55. @@ -2346,7 +2378,9 @@ static int rt2800pci_probe_hw_mode(struc
  56. */
  57. rt2x00dev->hw->flags =
  58. IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
  59. - IEEE80211_HW_SIGNAL_DBM;
  60. + IEEE80211_HW_SIGNAL_DBM |
  61. + IEEE80211_HW_SUPPORTS_PS |
  62. + IEEE80211_HW_PS_NULLFUNC_STACK;
  63. rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
  64. SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);