Sascha Silbe | 1 May 18:58 2010

[PATCH (V2) 0/3] battery: add properties required by UPower

After some research and comments from Paul Fox and Richard Smith (thanks!)
I've revised and split up the patch.

Changes:
- calculate CHARGE_FULL_DESIGN based on technology and manufacturer
- replace CHARGE_AVG with CHARGE_NOW
- add CURRENT_NOW
Sascha Silbe | 1 May 18:58 2010

[PATCH 1/3] battery: add CHARGE_FULL_DESIGN

The maximum ("full") charge of the battery is required for UPower to
return the current capacity, both directly (as CHARGE_FULL_DESIGN) and
indirectly (calculating CHARGE_NOW).
---
 drivers/power/olpc_battery.c |   57 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 753c170..0c1cff0 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
 <at>  <at>  -200,6 +200,57  <at>  <at>  static int olpc_bat_get_tech(union power_supply_propval *val)
 	return ret;
 }

+static int olpc_bat_get_charge_full_design(union power_supply_propval *val)
+{
+	uint8_t ec_byte;
+	union power_supply_propval tech;
+	int ret, mfr;
+
+	ret = olpc_bat_get_tech(&tech);
+	if (ret)
+		return ret;
+
+	ec_byte = BAT_ADDR_MFR_TYPE;
+	ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1);
+	if (ret)
+		return ret;
+
(Continue reading)

Sascha Silbe | 1 May 18:58 2010

[PATCH 3/3] battery: add CURRENT_NOW

CURRENT_AVG is actually CURRENT_NOW (the EC code directly passes through
the value from the gas gauge instead of the internally used average).
We retain CURRENT_AVG as an alias for compatibility reasons, it will be
removed later.

This change allows an unpatched UPower (0.9.2) to calculate TimeToEmpty
and TimeToFull.
---
 drivers/power/olpc_battery.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index dc144c5..c85dd7c 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
 <at>  <at>  -342,6 +342,7  <at>  <at>  static int olpc_bat_get_property(struct power_supply *psy,
 		val->intval = (int)((s16)be16_to_cpu(ec_word)) * 9760L / 32;
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_AVG:
+	case POWER_SUPPLY_PROP_CURRENT_NOW:
 		ret = olpc_ec_cmd(EC_BAT_CURRENT, NULL, 0, (void *)&ec_word, 2);
 		if (ret)
 			return ret;
 <at>  <at>  -419,6 +420,7  <at>  <at>  static enum power_supply_property olpc_bat_props[] = {
 	POWER_SUPPLY_PROP_TECHNOLOGY,
 	POWER_SUPPLY_PROP_VOLTAGE_AVG,
 	POWER_SUPPLY_PROP_CURRENT_AVG,
+	POWER_SUPPLY_PROP_CURRENT_NOW,
 	POWER_SUPPLY_PROP_CAPACITY,
 	POWER_SUPPLY_PROP_CAPACITY_LEVEL,
(Continue reading)

Sascha Silbe | 1 May 18:58 2010

[PATCH 2/3] battery: add CHARGE_NOW

CHARGE_NOW is needed by UPower to return the current capacity
('Percentage').

This patch violates the power supply class definition (as we already
do for CAPACITY though it isn't as obvious there), but this is the best
we can do without adding rather sophisticated algorithms to either the EC
or UPower.
---
 drivers/power/olpc_battery.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 0c1cff0..dc144c5 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
 <at>  <at>  -251,6 +251,24  <at>  <at>  static int olpc_bat_get_charge_full_design(union power_supply_propval *val)
 	return ret;
 }

+static int olpc_bat_get_charge_now(union power_supply_propval *val)
+{
+	uint8_t soc;
+	union power_supply_propval full;
+	int ret;
+
+	ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &soc, 1);
+	if (ret)
+		return ret;
+
+	ret = olpc_bat_get_charge_full_design(&full);
(Continue reading)

Paul Fox | 1 May 19:15 2010

Re: [PATCH (V2) 0/3] battery: add properties required by UPower

thanks sascha!  these look good.  i'll apply soon.

paul

sascha wrote:
 > After some research and comments from Paul Fox and Richard Smith (thanks!)
 > I've revised and split up the patch.
 > 
 > Changes:
 > - calculate CHARGE_FULL_DESIGN based on technology and manufacturer
 > - replace CHARGE_AVG with CHARGE_NOW
 > - add CURRENT_NOW
 > _______________________________________________
 > Devel mailing list
 > Devel <at> lists.laptop.org
 > http://lists.laptop.org/listinfo/devel

=---------------------
 paul fox, pgf <at> laptop.org
Sascha Silbe | 1 May 20:35 2010

[PATCH v3 0/3] olpc-battery: add properties required by UPower

Changes v2->v3:
- style fixes for switch () according to scripts/checkpatch.pl output
- add Signed-Off-By

Changes v1->v2:
- calculate CHARGE_FULL_DESIGN based on technology and manufacturer
- replace CHARGE_AVG with CHARGE_NOW
- add CURRENT_NOW
Sascha Silbe | 1 May 20:35 2010

[PATCH 1/3] olpc-battery: add support for CHARGE_FULL_DESIGN

The maximum ("full") charge of the battery is required for UPower to
return the current capacity, both directly (as CHARGE_FULL_DESIGN) and
indirectly (calculating CHARGE_NOW).

Signed-off-by: Sascha Silbe <sascha-pgp <at> silbe.org>
---
 drivers/power/olpc_battery.c |   54 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 753c170..dbe5b85 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
 <at>  <at>  -200,6 +200,54  <at>  <at>  static int olpc_bat_get_tech(union power_supply_propval *val)
 	return ret;
 }

+static int olpc_bat_get_charge_full_design(union power_supply_propval *val)
+{
+	uint8_t ec_byte;
+	union power_supply_propval tech;
+	int ret, mfr;
+
+	ret = olpc_bat_get_tech(&tech);
+	if (ret)
+		return ret;
+
+	ec_byte = BAT_ADDR_MFR_TYPE;
+	ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1);
+	if (ret)
(Continue reading)

Sascha Silbe | 1 May 20:35 2010

[PATCH 2/3] olpc-battery: add support for CHARGE_NOW

CHARGE_NOW is needed by UPower to return the current capacity
('Percentage').

This patch violates the power supply class definition (as we already
do for CAPACITY though it isn't as obvious there), but this is the best
we can do without adding rather sophisticated algorithms to either the EC
or UPower.

Signed-off-by: Sascha Silbe <sascha-pgp <at> silbe.org>
---
 drivers/power/olpc_battery.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index dbe5b85..a49e548 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
 <at>  <at>  -248,6 +248,24  <at>  <at>  static int olpc_bat_get_charge_full_design(union power_supply_propval *val)
 	return ret;
 }

+static int olpc_bat_get_charge_now(union power_supply_propval *val)
+{
+	uint8_t soc;
+	union power_supply_propval full;
+	int ret;
+
+	ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &soc, 1);
+	if (ret)
+		return ret;
(Continue reading)

Sascha Silbe | 1 May 20:35 2010

[PATCH 3/3] olpc-battery: add support for CURRENT_NOW

CURRENT_AVG is actually CURRENT_NOW (the EC code directly passes through
the value from the gas gauge instead of the internally used average).
We retain CURRENT_AVG as an alias for compatibility reasons, it will be
removed later.

This change allows an unpatched UPower (0.9.2) to calculate TimeToEmpty
and TimeToFull.

Signed-off-by: Sascha Silbe <sascha-pgp <at> silbe.org>
---
 drivers/power/olpc_battery.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index a49e548..ce0d316 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
 <at>  <at>  -339,6 +339,7  <at>  <at>  static int olpc_bat_get_property(struct power_supply *psy,
 		val->intval = (int)((s16)be16_to_cpu(ec_word)) * 9760L / 32;
 		break;
 	case POWER_SUPPLY_PROP_CURRENT_AVG:
+	case POWER_SUPPLY_PROP_CURRENT_NOW:
 		ret = olpc_ec_cmd(EC_BAT_CURRENT, NULL, 0, (void *)&ec_word, 2);
 		if (ret)
 			return ret;
 <at>  <at>  -416,6 +417,7  <at>  <at>  static enum power_supply_property olpc_bat_props[] = {
 	POWER_SUPPLY_PROP_TECHNOLOGY,
 	POWER_SUPPLY_PROP_VOLTAGE_AVG,
 	POWER_SUPPLY_PROP_CURRENT_AVG,
+	POWER_SUPPLY_PROP_CURRENT_NOW,
(Continue reading)

Chris Ball | 2 May 03:38 2010

New XO-1.5 10.2.0 build 122

http://wiki.laptop.org/go/F11_for_1.5
http://build.laptop.org/10.2.0/os122

Compressed image size: 677.68mb (-0.70mb since build 121)

Description of changes in this build:
 * kernel, #10137: correct camera framerate setting (note, this version
                   of the patch may break the camera fps on XO-1)
 * record, #10045: Fix sync issues by moving to dsd's Record-74.
 * olpc-runin-tests: update from rsmith
 * olpc-powerd, #10129: fix a bug that could cause unwanted idle-suspend
 * olpc-update: fix param order for check_stolen_hash()
 * Upgrade to firmware Q3A37.
 * Pull F11 updates.

Package changes since build 121:

-bootfw-q3a36-1.unsigned.i386
+bootfw-q3a37-1.unsigned.i386
-kernel-2.6.31_xo1.5-20100423.1840.1.olpc.2884b56.i586
+kernel-2.6.31_xo1.5-20100430.1441.1.olpc.6a2d568.i586
-kernel-firmware-2.6.31_xo1.5-20100423.1840.1.olpc.2884b56.i586
+kernel-firmware-2.6.31_xo1.5-20100430.1441.1.olpc.6a2d568.i586
-olpc-powerd-19-1.fc11.i586
+olpc-powerd-20-1.fc11.i586
-olpc-runin-tests-0.9.17-1.noarch
+olpc-runin-tests-0.9.18-1.noarch
-olpc-update-2.22-1.fc11.noarch
+olpc-update-2.23-1.fc11.noarch
-wxBase-2.8.10-5.fc11.i586
(Continue reading)


Gmane