linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: "Angus Ainslie (Purism)" <angus@akkea.ca>
Cc: angus.ainslie@puri.sm, Sebastian Reichel <sre@kernel.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/4] power: bq25890_charger.c: Read back the current battery voltage
Date: Thu, 26 Jul 2018 09:03:50 +0200	[thread overview]
Message-ID: <CAJKOXPc1amTiPKNU02OruOpw+GA6DrZgv1+HhqZ14OZYpA2-YA@mail.gmail.com> (raw)
In-Reply-To: <20180725194630.10414-5-angus@akkea.ca>

On 25 July 2018 at 21:46, Angus Ainslie (Purism) <angus@akkea.ca> wrote:
> The part has the capability of reading the current battery voltage
>
> Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
> ---
>  drivers/power/supply/bq25890_charger.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
> index f4cf2987996b..60ccd6c2b7ad 100644
> --- a/drivers/power/supply/bq25890_charger.c
> +++ b/drivers/power/supply/bq25890_charger.c
> @@ -464,6 +464,20 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
>                 val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM);
>                 break;
>
> +       case POWER_SUPPLY_PROP_VOLTAGE_NOW:
> +               if (!state.online) {
> +                       val->intval = 0;
> +                       break;
> +               }

You use state from cached value (from last interrupt) but the voltage
is read directly from registers. The driver follows this convention in
few other places so maybe it is okay. It depends how accurately the
interrupts are generated - on every change? IOW, is always guaranteed
that state will be consistent with values read below?

Best regards,
Krzysztof

> +
> +               ret = bq25890_field_read(bq, F_SYSV); /* read measured value */
> +               if (ret < 0)
> +                       return ret;
> +
> +               /* converted_val = 2.304V + ADC_val * 20mV (table 10.3.15) */
> +               val->intval = 2304000 + ret * 20000;
> +               break;
> +
>         default:
>                 return -EINVAL;
>         }
> @@ -672,6 +686,7 @@ static enum power_supply_property bq25890_power_supply_props[] = {
>         POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
>         POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
>         POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
> +       POWER_SUPPLY_PROP_VOLTAGE_NOW,
>  };
>
>  static char *bq25890_charger_supplied_to[] = {
> --
> 2.17.1
>

  reply	other threads:[~2018-07-26  7:03 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-23 13:51 [PATCH] bq25890_charger.c : add the BQ25896 part Angus Ainslie
2018-07-25  9:58 ` Krzysztof Kozlowski
2018-07-25 12:17   ` Angus Ainslie
2018-07-26  6:37     ` Krzysztof Kozlowski
2018-07-25 19:46   ` [PATCH v2 0/4] Add the BQ25896 charger IC Angus Ainslie (Purism)
2018-07-25 19:46     ` [PATCH v2 1/4] power: bq25890_charger.c: Add debugging output of failed initialization Angus Ainslie (Purism)
2018-07-26  6:44       ` Krzysztof Kozlowski
2018-07-25 19:46     ` [PATCH v2 2/4] power: bq25890_charger.c: Remove unused table Angus Ainslie (Purism)
2018-07-26  6:51       ` Krzysztof Kozlowski
2018-07-27 15:26         ` Angus Ainslie
2018-07-31  6:40           ` Krzysztof Kozlowski
2018-07-25 19:46     ` [PATCH v2 3/4] power: bq25890_charger.c: Add the BQ25896 part Angus Ainslie (Purism)
2018-07-26  6:56       ` Krzysztof Kozlowski
2018-07-25 19:46     ` [PATCH v2 4/4] power: bq25890_charger.c: Read back the current battery voltage Angus Ainslie (Purism)
2018-07-26  7:03       ` Krzysztof Kozlowski [this message]
2018-07-27 15:30         ` Angus Ainslie
2018-07-31 16:43   ` [PATCH v3 0/4] Add the BQ25896 charger IC Angus Ainslie (Purism)
2018-07-31 16:43     ` [PATCH v3 1/4] power: bq25890_charger.c: Add debugging output of failed initialization Angus Ainslie (Purism)
2018-07-31 16:57       ` Krzysztof Kozlowski
2018-07-31 18:16         ` Angus Ainslie
2018-07-31 16:43     ` [PATCH v3 2/4] power: bq25890_charger.c: Remove unused table entries Angus Ainslie (Purism)
2018-07-31 16:58       ` Krzysztof Kozlowski
2018-07-31 16:43     ` [PATCH v3 3/4] power: bq25890_charger.c: Add the BQ25896 part Angus Ainslie (Purism)
2018-07-31 17:00       ` Krzysztof Kozlowski
2018-07-31 16:43     ` [PATCH v3 4/4] power: bq25890_charger.c: Read back the current battery voltage Angus Ainslie (Purism)
2018-07-31 17:02       ` Krzysztof Kozlowski
2018-07-31 17:49   ` [PATCH v4 0/4] Add the BQ25896 charger IC Angus Ainslie (Purism)
2018-07-31 17:49     ` [PATCH v4 1/4] power: bq25890_charger.c: Add debugging output of failed initialization Angus Ainslie (Purism)
2018-07-31 17:49     ` [PATCH v4 2/4] power: bq25890_charger.c: Remove unused table entries Angus Ainslie (Purism)
2018-07-31 17:49     ` [PATCH v4 3/4] power: bq25890_charger.c: Add the BQ25896 part Angus Ainslie (Purism)
2018-07-31 17:49     ` [PATCH v4 4/4] power: bq25890_charger.c: Read back the current battery voltage Angus Ainslie (Purism)
2018-08-30 21:46     ` [PATCH v4 0/4] Add the BQ25896 charger IC Sebastian Reichel

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=CAJKOXPc1amTiPKNU02OruOpw+GA6DrZgv1+HhqZ14OZYpA2-YA@mail.gmail.com \
    --to=krzk@kernel.org \
    --cc=angus.ainslie@puri.sm \
    --cc=angus@akkea.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).