wl1251: Add support for idle mode
authorJarkko Nikula <jhnikula@gmail.com>
Mon, 4 Apr 2011 08:04:58 +0000 (11:04 +0300)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 7 Apr 2011 19:34:14 +0000 (15:34 -0400)
On Nokia N900 the wl1251 consumes the most power when the interface is up
but not associated to access point (that supports PSM). In terms of battery
current consumption, the consumption is ~180 mA higher when the interface is
up but not associated and only ~5 mA higher when associated compared to
interface down and driver not loaded cases.

This patch adds support for the mac80211 idle notifications. Chip is put into
idle very much the same way when entering into PSM by utilizing the Extreme
Low Power (ELP) mode. I.e. idle is entered by setting necessary conditions
in wl1251_ps_set_mode followed by a call to wl1251_ps_elp_sleep.

It seems it is just enough the authorize ELP mode followed by
CMD_DISCONNECT (thanks to Kalle Valo about the idea to use it).
Without disconnect command the chip remains somewhat active and stays
consuming ~20 mA. Idle mode is left by same way than PSM. The wl1251_join
call is used to revert the CMD_DISCONNECT. Without it association to AP
doesn't work when trying second time.

With this patch the interface up but not associated case the battery current
consumption is less than 1 mA higher compared to interface down case.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Kalle Valo <kvalo@adurom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/wl1251/main.c
drivers/net/wireless/wl1251/ps.c
drivers/net/wireless/wl1251/wl1251.h

index 04a054915dbefd7c80d194e3c3304017ec2f7a1f..a14a48c99cdc73ff8e9c6182a2da7078d27c4550 100644 (file)
@@ -639,6 +639,22 @@ static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed)
                }
        }
 
+       if (changed & IEEE80211_CONF_CHANGE_IDLE) {
+               if (conf->flags & IEEE80211_CONF_IDLE) {
+                       ret = wl1251_ps_set_mode(wl, STATION_IDLE);
+                       if (ret < 0)
+                               goto out_sleep;
+               } else {
+                       ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE);
+                       if (ret < 0)
+                               goto out_sleep;
+                       ret = wl1251_join(wl, wl->bss_type, wl->channel,
+                                         wl->beacon_int, wl->dtim_period);
+                       if (ret < 0)
+                               goto out_sleep;
+               }
+       }
+
        if (conf->power_level != wl->power_level) {
                ret = wl1251_acx_tx_power(wl, conf->power_level);
                if (ret < 0)
index 97a5b8c82f01fbde62f46070a134fa8998b3e061..db719f7d26928c4012a1020a050edbd3a9560980 100644 (file)
@@ -136,6 +136,17 @@ int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_station_mode mode)
                if (ret < 0)
                        return ret;
                break;
+       case STATION_IDLE:
+               wl1251_debug(DEBUG_PSM, "entering idle");
+
+               ret = wl1251_acx_sleep_auth(wl, WL1251_PSM_ELP);
+               if (ret < 0)
+                       return ret;
+
+               ret = wl1251_cmd_template_set(wl, CMD_DISCONNECT, NULL, 0);
+               if (ret < 0)
+                       return ret;
+               break;
        case STATION_ACTIVE_MODE:
        default:
                wl1251_debug(DEBUG_PSM, "leaving psm");
index bf245a87e80e85c4aff702b4722e79e3413f2c13..a77f1bbbed0ad063aae085ff857c4cc7abadd717 100644 (file)
@@ -132,6 +132,7 @@ enum wl1251_partition_type {
 enum wl1251_station_mode {
        STATION_ACTIVE_MODE,
        STATION_POWER_SAVE_MODE,
+       STATION_IDLE,
 };
 
 struct wl1251_partition {