From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Sebastian Reichel <sre@kernel.org>,
Marcus Cooper <codekipper@gmail.com>
Cc: linux-pm@vger.kernel.org
Subject: Re: [PATCH 2/2] power: supply: ab8500: Exit maintenance if too low voltage
Date: Tue, 19 Apr 2022 12:26:31 +0300 [thread overview]
Message-ID: <36001b47-99fc-1b49-49e7-018f81b717c4@gmail.com> (raw)
In-Reply-To: <20220415203638.361074-2-linus.walleij@linaro.org>
Hi deee Ho Linus,
On 4/15/22 23:36, Linus Walleij wrote:
> The maintenance charging is supposedly designed such that the
> maintenance current compensates for the battery discharge curve,
> and as the charging progress from CC/CV -> maintenance A ->
> maintenance B states, we end up on a reasonable voltage to
> restart ordinary CC/CV charging after the safety timer at the
> maintenance B state exits.
>
> However: old batteries discharge quicker, and in an old
> battery we might not get to the expiration of the maintenance B
> timer before the battery is completely depleted and the system
> powers off with an empty battery.
>
> This is hardly the desire of anyone leaving their phone in the
> charger for a few days!
>
> Introduce a second clause in both maintenance states such that
> we exit the state and return to ordinary CC/CV charging if
> the voltage drops below charge_restart_voltage_uv or 95%
> if this is not defined for the battery.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/power/supply/ab8500_chargalg.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/power/supply/ab8500_chargalg.c b/drivers/power/supply/ab8500_chargalg.c
> index b9622eb9fc72..1b23b5261881 100644
> --- a/drivers/power/supply/ab8500_chargalg.c
> +++ b/drivers/power/supply/ab8500_chargalg.c
> @@ -1514,6 +1514,14 @@ static void ab8500_chargalg_algorithm(struct ab8500_chargalg *di)
> ab8500_chargalg_stop_maintenance_timer(di);
> ab8500_chargalg_state_to(di, STATE_MAINTENANCE_B_INIT);
> }
> + /*
> + * This happens if the voltage drops too quickly during
> + * maintenance charging, especially in older batteries.
> + */
> + if (ab8500_chargalg_time_to_restart(di)) {
> + ab8500_chargalg_state_to(di, STATE_NORMAL_INIT);
> + dev_info(di->dev, "restarted charging from maintenance state A - battery getting old?\n");
> + }
> break;
>
> case STATE_MAINTENANCE_B_INIT:
> @@ -1538,6 +1546,14 @@ static void ab8500_chargalg_algorithm(struct ab8500_chargalg *di)
> ab8500_chargalg_stop_maintenance_timer(di);
> ab8500_chargalg_state_to(di, STATE_NORMAL_INIT);
> }
> + /*
> + * This happens if the voltage drops too quickly during
> + * maintenance charging, especially in older batteries.
> + */
> + if (ab8500_chargalg_time_to_restart(di)) {
> + ab8500_chargalg_state_to(di, STATE_NORMAL_INIT);
> + dev_info(di->dev, "restarted charging from maintenance state B - battery getting old?\n");
> + }
> break;
>
> case STATE_TEMP_LOWHIGH_INIT:
Probably just a matter of taste (like underscores in private function
names ;] ) - I would prefer combining the cases for INITs to something like:
case STATE_MAINTENANCE_A_INIT:
case STATE_MAINTENANCE_B_INIT:
mt = power_supply_get_maintenance_charging_setting(bi,
(di->charge_state == STATE_MAINTENANCE_B_INIT));
...
ab8500_chargalg_state_to(di, di->charge_state + 1);
break;
That would slightly reduce the code although at the cost of additional
arithmetics. I'm leaving this to you though.
FWIW: After someone telling me that I should not worry about the cold
weather (ref. my comment for the patch 1/2)
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Best Regards
-- Matti
next prev parent reply other threads:[~2022-04-19 9:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-15 20:36 [PATCH 1/2] power: supply: ab8500: Respect charge_restart_voltage_uv Linus Walleij
2022-04-15 20:36 ` [PATCH 2/2] power: supply: ab8500: Exit maintenance if too low voltage Linus Walleij
2022-04-19 9:26 ` Matti Vaittinen [this message]
2022-04-19 9:44 ` Matti Vaittinen
2022-05-05 20:22 ` Linus Walleij
2022-04-19 8:50 ` [PATCH 1/2] power: supply: ab8500: Respect charge_restart_voltage_uv Vaittinen, Matti
2022-05-05 20:17 ` Linus Walleij
2022-05-06 5:38 ` Vaittinen, Matti
2022-05-09 10:33 ` Linus Walleij
2022-05-09 13:27 ` Vaittinen, Matti
2022-05-20 21:36 ` Linus Walleij
2022-06-09 20:12 ` 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=36001b47-99fc-1b49-49e7-018f81b717c4@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=codekipper@gmail.com \
--cc=linus.walleij@linaro.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