lkml.org 
[lkml]   [2009]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[rfc/patch 14/15] power: bq27200: add time to empty/full
    Date
    the chip reports time to empty and time to full
    in minutes, so we multiply the result by 60 to get
    it in seconds as requested by power_supply interface.

    Signed-off-by: Felipe Balbi <me@felipebalbi.com>
    ---
    drivers/power/bq27200_battery.c | 35 +++++++++++++++++++++++++++++++++++
    1 files changed, 35 insertions(+), 0 deletions(-)

    diff --git a/drivers/power/bq27200_battery.c b/drivers/power/bq27200_battery.c
    index 85e824a..26ef2be 100644
    --- a/drivers/power/bq27200_battery.c
    +++ b/drivers/power/bq27200_battery.c
    @@ -75,6 +75,8 @@ static enum power_supply_property bq27200_props[] = {
    POWER_SUPPLY_PROP_CAPACITY,
    POWER_SUPPLY_PROP_TEMP,
    POWER_SUPPLY_PROP_POWER_AVG,
    + POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
    + POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
    };

    /*
    @@ -181,6 +183,32 @@ static int bq27200_power(struct bq27200 *bq)
    return (ret * BQ27200_POWER_CONSTANT) / BQ27200_SENSING_RESISTOR;
    }

    +static int bq27200_time_to_empty(struct bq27200 *bq)
    +{
    + int ret;
    +
    + ret = bq27200_readw(bq, BQ27200_REG_TTE);
    + if (ret < 0) {
    + dev_err(&bq->client->dev, "error reading time to empty\n");
    + return ret;
    + }
    +
    + return ret * 60;
    +}
    +
    +static int bq27200_time_to_full(struct bq27200 *bq)
    +{
    + int ret;
    +
    + ret = bq27200_readw(bq, BQ27200_REG_TTF);
    + if (ret < 0) {
    + dev_err(&bq->client->dev, "error reading time to full\n");
    + return ret;
    + }
    +
    + return ret * 60;
    +}
    +
    static int bq27200_get_property(struct power_supply *psy,
    enum power_supply_property psp, union power_supply_propval *val)
    {
    @@ -207,6 +235,13 @@ static int bq27200_get_property(struct power_supply *psy,
    break;
    case POWER_SUPPLY_PROP_POWER_AVG:
    val->intval = bq27200_power(bq);
    + break;
    + case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
    + val->intval = bq27200_time_to_empty(bq);
    + break;
    + case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
    + val->intval = bq27200_time_to_full(bq);
    + break;
    default:
    return -EINVAL;
    }
    --
    1.6.1.3


    \
     
     \ /
      Last update: 2009-07-12 20:37    [W:2.795 / U:0.112 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site