From: Lars-Peter Clausen <lars@metafoo.de>
To: "Pali Rohár" <pali.rohar@gmail.com>
Cc: Anton Vorontsov <cbouatmailru@gmail.com>,
Grazvydas Ignotas <notasas@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: Fwd: [PATCH] bq27x00_battery: Add new properties
Date: Mon, 31 Jan 2011 23:28:52 +0100 [thread overview]
Message-ID: <4D4737A4.4010203@metafoo.de> (raw)
In-Reply-To: <AANLkTikUU9WamKweb=nL+v1eYg=GqguXSe5x++JZGBQ2@mail.gmail.com>
Hi Pali
Your mail-client seems to mess up the patches whitespace(tabs converted to spaces,
trailing whitespace truncated, etc). Could you resend the patches properly formated?
I guess there is an option in your mail-client somewhere to disable it from chaning
the messages whitespace. Otherwise you could try to use the `git send-email` tool.
- Lars
On 01/31/2011 08:43 PM, Pali Rohár wrote:
> Here is new patch. It is possible to merge it then with changes on git?
>
> ===
>
> This patch add support for reporting properties
> POWER_SUPPLY_PROP_CHARGE_NOW, POWER_SUPPLY_PROP_CHARGE_FULL,
> POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
> POWER_SUPPLY_PROP_CHARGE_COUNTER, POWER_SUPPLY_PROP_ENERGY_NOW in
> module bq27x00_battery.
>
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> Tested-by: Pali Rohár <pali.rohar@gmail.com>
>
> --- a/drivers/power/bq27x00_battery.c 2011-01-31 17:45:01.000000000 +0100
> +++ b/drivers/power/bq27x00_battery.c 2011-01-31 18:43:16.000000000 +0100
> @@ -4,6 +4,11 @@
> * Copyright (C) 2008 Rodolfo Giometti <giometti@linux.it>
> * Copyright (C) 2008 Eurotech S.p.A. <info@eurotech.it>
> *
> + * Support for reporting properties: POWER_SUPPLY_PROP_CHARGE_NOW,
> + * POWER_SUPPLY_PROP_CHARGE_FULL, POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
> + * POWER_SUPPLY_PROP_CHARGE_COUNTER, POWER_SUPPLY_PROP_ENERGY_NOW
> + * Copyright (C) 2011 Pali Rohár <pali.rohar@gmail.com>
> + *
> * Based on a previous work by Copyright (C) 2008 Texas Instruments, Inc.
> *
> * This package is free software; you can redistribute it and/or modify
> @@ -15,6 +20,13 @@
> * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
> *
> */
> +
> +/*
> + * Datasheets:
> + * http://focus.ti.com/docs/prod/folders/print/bq27000.html
> + * http://focus.ti.com/docs/prod/folders/print/bq27500.html
> + */
> +
> #include <linux/module.h>
> #include <linux/param.h>
> #include <linux/jiffies.h>
> @@ -27,7 +39,7 @@
> #include <linux/slab.h>
> #include <asm/unaligned.h>
>
> -#define DRIVER_VERSION "1.1.0"
> +#define DRIVER_VERSION "1.2.0"
>
> #define BQ27x00_REG_TEMP 0x06
> #define BQ27x00_REG_VOLT 0x08
> @@ -36,12 +48,19 @@
> #define BQ27x00_REG_TTE 0x16
> #define BQ27x00_REG_TTF 0x18
> #define BQ27x00_REG_TTECP 0x26
> +#define BQ27x00_REG_NAC 0x0C /* Nominal
> available capaciy */
> +#define BQ27x00_REG_LMD 0x12 /* Last measured
> discharge */
> +#define BQ27x00_REG_CYCT 0x2A /* Cycle count total */
> +#define BQ27x00_REG_AE 0x22 /* Available enery */
>
> #define BQ27000_RS 20 /* Resistor sense */
> #define BQ27000_REG_RSOC 0x0B /* Relative State-of-Charge */
> +#define BQ27000_REG_ILMD 0x76 /* Initial last measured
> discharge */
> #define BQ27000_FLAG_CHGS BIT(7)
> +#define BQ27000_FLAG_FC BIT(5)
>
> #define BQ27500_REG_SOC 0x2C
> +#define BQ27500_REG_DCAP 0x3C /* Design capacity */
> #define BQ27500_FLAG_DSC BIT(0)
> #define BQ27500_FLAG_FC BIT(9)
>
> @@ -75,6 +94,11 @@ static enum power_supply_property bq27x0
> POWER_SUPPLY_PROP_VOLTAGE_NOW,
> POWER_SUPPLY_PROP_CURRENT_NOW,
> POWER_SUPPLY_PROP_CAPACITY,
> + POWER_SUPPLY_PROP_CHARGE_NOW,
> + POWER_SUPPLY_PROP_CHARGE_FULL,
> + POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
> + POWER_SUPPLY_PROP_CHARGE_COUNTER,
> + POWER_SUPPLY_PROP_ENERGY_NOW,
> POWER_SUPPLY_PROP_TEMP,
> POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
> POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
> @@ -188,6 +212,119 @@ static int bq27x00_battery_rsoc(struct b
> return rsoc;
> }
>
> +/*
> + * Return the battery Nominal available capaciy in µAh
> + * Or < 0 if something fails.
> + */
> +static int bq27x00_battery_nac(struct bq27x00_device_info *di)
> +{
> + int ret;
> + int nac = 0;
> +
> + ret = bq27x00_read(BQ27x00_REG_NAC, &nac, 0, di);
> + if (ret) {
> + dev_err(di->dev, "error reading nominal available capacity\n");
> + return ret;
> + }
> +
> + if (di->chip == BQ27500)
> + nac *= 1000;
> + else
> + nac = nac * 3570 / BQ27000_RS;
> +
> + return nac;
> +}
> +
> +/*
> + * Return the battery Last measured discharge in µAh
> + * Or < 0 if something fails.
> + */
> +static int bq27x00_battery_lmd(struct bq27x00_device_info *di)
> +{
> + int ret;
> + int lmd = 0;
> +
> + ret = bq27x00_read(BQ27x00_REG_LMD, &lmd, 0, di);
> + if (ret) {
> + dev_err(di->dev, "error reading last measured discharge\n");
> + return ret;
> + }
> +
> + if (di->chip == BQ27500)
> + lmd *= 1000;
> + else
> + lmd = lmd * 3570 / BQ27000_RS;
> +
> + return lmd;
> +}
> +
> +/*
> + * Return the battery Initial last measured discharge in µAh
> + * Or < 0 if something fails.
> + */
> +static int bq27x00_battery_ilmd(struct bq27x00_device_info *di)
> +{
> + int ret;
> + int ilmd = 0;
> +
> + if (di->chip == BQ27500)
> + ret = bq27x00_read(BQ27500_REG_DCAP, &ilmd, 0, di);
> + else
> + ret = bq27x00_read(BQ27000_REG_ILMD, &ilmd, 0, di);
> + if (ret) {
> + dev_err(di->dev, "error reading initial last measured
> discharge\n");
> + return ret;
> + }
> +
> + if (di->chip == BQ27500)
> + ilmd *= 1000;
> + else
> + ilmd = ilmd * 256 * 3570 / BQ27000_RS;
> +
> + return ilmd;
> +}
> +
> +/*
> + * Return the battery Cycle count total
> + * Or < 0 if something fails.
> + */
> +static int bq27x00_battery_cyct(struct bq27x00_device_info *di)
> +{
> + int ret;
> + int cyct = 0;
> +
> + ret = bq27x00_read(BQ27x00_REG_CYCT, &cyct, 0, di);
> + if (ret) {
> + dev_err(di->dev, "error reading cycle count total\n");
> + return ret;
> + }
> +
> + return cyct;
> +}
> +
> +/*
> + * Return the battery Available energy in µWh
> + * Or < 0 if something fails.
> + */
> +static int bq27x00_battery_energy(struct bq27x00_device_info *di)
> +{
> + int ret;
> + int ae = 0;
> +
> + ret = bq27x00_read(BQ27x00_REG_LMD, &ae, 0, di);
> + if (ret) {
> + dev_err(di->dev, "error reading available energy\n");
> + return ret;
> + }
> +
> + if (di->chip == BQ27500)
> + ae *= 1000;
> + else
> + ae = ae * 29200 / BQ27000_RS;
> +
> + return ae;
> +}
> +
> static int bq27x00_battery_status(struct bq27x00_device_info *di,
> union power_supply_propval *val)
> {
> @@ -209,7 +346,9 @@ static int bq27x00_battery_status(struct
> else
> status = POWER_SUPPLY_STATUS_CHARGING;
> } else {
> - if (flags & BQ27000_FLAG_CHGS)
> + if (flags & BQ27000_FLAG_FC)
> + status = POWER_SUPPLY_STATUS_FULL;
> + else if (flags & BQ27000_FLAG_CHGS)
> status = POWER_SUPPLY_STATUS_CHARGING;
> else
> status = POWER_SUPPLY_STATUS_DISCHARGING;
> @@ -268,6 +407,21 @@ static int bq27x00_battery_get_property(
> case POWER_SUPPLY_PROP_CAPACITY:
> val->intval = bq27x00_battery_rsoc(di);
> break;
> + case POWER_SUPPLY_PROP_CHARGE_NOW:
> + val->intval = bq27x00_battery_nac(di);
> + break;
> + case POWER_SUPPLY_PROP_CHARGE_FULL:
> + val->intval = bq27x00_battery_lmd(di);
> + break;
> + case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
> + val->intval = bq27x00_battery_ilmd(di);
> + break;
> + case POWER_SUPPLY_PROP_CHARGE_COUNTER:
> + val->intval = bq27x00_battery_cyct(di);
> + break;
> + case POWER_SUPPLY_PROP_ENERGY_NOW:
> + val->intval = bq27x00_battery_energy(di);
> + break;
> case POWER_SUPPLY_PROP_TEMP:
> val->intval = bq27x00_battery_temperature(di);
> break;
next prev parent reply other threads:[~2011-01-31 22:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-31 13:51 Fwd: [PATCH] bq27x00_battery: Add new properties Anton Vorontsov
2011-01-31 15:43 ` Rodolfo Giometti
2011-01-31 16:03 ` Anton Vorontsov
2011-01-31 18:07 ` Pali Rohár
2011-01-31 19:19 ` Lars-Peter Clausen
2011-01-31 19:22 ` Mark Brown
2011-01-31 19:35 ` Pali Rohár
2011-01-31 19:38 ` Mark Brown
2011-01-31 20:03 ` Pali Rohár
2011-01-31 20:04 ` Pali Rohár
2011-01-31 20:15 ` Anton Vorontsov
2011-01-31 20:51 ` Lars-Peter Clausen
2011-01-31 19:43 ` Pali Rohár
2011-01-31 22:28 ` Lars-Peter Clausen [this message]
2011-01-31 22:39 ` Pali Rohár
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D4737A4.4010203@metafoo.de \
--to=lars@metafoo.de \
--cc=cbouatmailru@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=notasas@gmail.com \
--cc=pali.rohar@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox