From patchwork Tue Jan 29 18:57:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hornung X-Patchwork-Id: 216628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 1C0D22C0096 for ; Wed, 30 Jan 2013 05:57:07 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1U0GMX-00010y-KD; Tue, 29 Jan 2013 18:56:53 +0000 Received: from miau.alexhornung.com ([92.243.25.66]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1U0GMV-00010o-Pz for kernel-team@lists.ubuntu.com; Tue, 29 Jan 2013 18:56:51 +0000 Received: from alex-laptop.home (188-221-246-203.zone12.bethere.co.uk [188.221.246.203]) by miau.alexhornung.com (Postfix) with ESMTPSA id 7AEAD5048 for ; Tue, 29 Jan 2013 19:52:57 +0100 (CET) Message-ID: <51081B7F.40709@alexhornung.com> Date: Tue, 29 Jan 2013 18:57:03 +0000 From: Alex Hornung User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130105 Thunderbird/17.0.2 MIME-Version: 1.0 To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1] power: bq27541_battery - Provide energy measurement X-Enigmail-Version: 1.5 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com Hi, this patch addresses bug report 1109183[1]. It's a straight-forward patch adding support for energy measurements from the fuel gauge chip. The 10mWh unit is straight from the datasheet - everything else is straight forward, in line with other values the chip provides. Cheers, Alex [1]: https://bugs.launchpad.net/ubuntu-nexus7/+bug/1109183 Acked-by: Andy Whitcroft Acked-by: Leann Ogasawara From 715aaf72d40a5a68cca29a4a4e3dd242ee4fb38c Mon Sep 17 00:00:00 2001 From: Alex Hornung Date: Mon, 28 Jan 2013 18:47:48 +0000 Subject: [PATCH 1/1] power: bq27541_battery - Provide energy measurement * Since the fuel gauge chip provides energy estimates, expose those as well. Signed-off-by: Alex Hornung --- drivers/power/bq27541_battery.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/power/bq27541_battery.c b/drivers/power/bq27541_battery.c index 9ce5c2d..c433043 100755 --- a/drivers/power/bq27541_battery.c +++ b/drivers/power/bq27541_battery.c @@ -111,6 +111,7 @@ enum { REG_CAPACITY, REG_SERIAL_NUMBER, REG_CHARGE_NOW, + REG_ENERGY, REG_POWER, REG_CYCLE, @@ -142,6 +143,7 @@ static struct bq27541_device_data { [REG_CAPACITY] = BQ27541_DATA(CAPACITY, 0x2c, 0, 100), [REG_CHARGE_NOW] = BQ27541_DATA(CHARGE_NOW, 0x10, 0, 65535), + [REG_ENERGY] = BQ27541_DATA(ENERGY_NOW, 0x22, 0, 65535), [REG_POWER] = BQ27541_DATA(POWER_AVG, 0x24, 0, 65535), [REG_CYCLE] = BQ27541_DATA(CYCLE_COUNT, 0x2a, 0, 65535), @@ -156,6 +158,7 @@ static enum power_supply_property bq27541_properties[] = { POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_CHARGE_NOW, + POWER_SUPPLY_PROP_ENERGY_NOW, POWER_SUPPLY_PROP_CYCLE_COUNT }; @@ -505,6 +508,11 @@ static int bq27541_get_psp(int reg_offset, enum power_supply_property psp, val->intval = rt_value * 1000; BAT_NOTICE("charge_now = %u uA\n", val->intval); } + if (psp == POWER_SUPPLY_PROP_ENERGY_NOW) { + /* energy is reported in 10 mWh */ + val->intval = rt_value * 10000; + BAT_NOTICE("energy_now = %u uWh\n", val->intval); + } if (psp == POWER_SUPPLY_PROP_CYCLE_COUNT) { val->intval = rt_value; BAT_NOTICE("cycle count = %u\n", val->intval); @@ -714,6 +722,7 @@ static int bq27541_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_TEMP: case POWER_SUPPLY_PROP_SERIAL_NUMBER: case POWER_SUPPLY_PROP_CHARGE_NOW: + case POWER_SUPPLY_PROP_ENERGY_NOW: case POWER_SUPPLY_PROP_CYCLE_COUNT: for (count = 0; count < REG_MAX; count++) { if (psp == bq27541_data[count].psp) -- 1.7.10.4