All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Sebastian Reichel <sre@kernel.org>, Marcus Cooper <codekipper@gmail.com>
Cc: linux-pm@vger.kernel.org, Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 02/11] power: supply: ab8500: Swap max and overvoltage
Date: Thu, 27 Jan 2022 02:12:27 +0100	[thread overview]
Message-ID: <20220127011236.332687-3-linus.walleij@linaro.org> (raw)
In-Reply-To: <20220127011236.332687-1-linus.walleij@linaro.org>

We should terminate charging when we reach the voltage_max_design_uv
not overvoltage_limit_uv, this is an abuse of that struct member.

The overvoltage limit is actually not configurable on the AB8500,
it is fixed to 4.75 V so drop a comment about that in the code.

Fixes: 2a5f41830aad ("power: supply: ab8500: Standardize voltages")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/power/supply/ab8500_bmdata.c   | 8 +++-----
 drivers/power/supply/ab8500_chargalg.c | 2 +-
 drivers/power/supply/ab8500_fg.c       | 8 +++++++-
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/power/supply/ab8500_bmdata.c b/drivers/power/supply/ab8500_bmdata.c
index 7133cce6a25a..62b63f0437dd 100644
--- a/drivers/power/supply/ab8500_bmdata.c
+++ b/drivers/power/supply/ab8500_bmdata.c
@@ -186,13 +186,11 @@ int ab8500_bm_of_probe(struct power_supply *psy,
 	 * fall back to safe defaults.
 	 */
 	if ((bi->voltage_min_design_uv < 0) ||
-	    (bi->voltage_max_design_uv < 0) ||
-	    (bi->overvoltage_limit_uv < 0)) {
+	    (bi->voltage_max_design_uv < 0)) {
 		/* Nominal voltage is 3.7V for unknown batteries */
 		bi->voltage_min_design_uv = 3700000;
-		bi->voltage_max_design_uv = 3700000;
-		/* Termination voltage (overcharge limit) 4.05V */
-		bi->overvoltage_limit_uv = 4050000;
+		/* Termination voltage 4.05V */
+		bi->voltage_max_design_uv = 4050000;
 	}
 
 	if (bi->constant_charge_current_max_ua < 0)
diff --git a/drivers/power/supply/ab8500_chargalg.c b/drivers/power/supply/ab8500_chargalg.c
index c4a2fe07126c..bcf85ae6828e 100644
--- a/drivers/power/supply/ab8500_chargalg.c
+++ b/drivers/power/supply/ab8500_chargalg.c
@@ -802,7 +802,7 @@ static void ab8500_chargalg_end_of_charge(struct ab8500_chargalg *di)
 	if (di->charge_status == POWER_SUPPLY_STATUS_CHARGING &&
 		di->charge_state == STATE_NORMAL &&
 		!di->maintenance_chg && (di->batt_data.volt_uv >=
-		di->bm->bi->overvoltage_limit_uv ||
+		di->bm->bi->voltage_max_design_uv ||
 		di->events.usb_cv_active || di->events.ac_cv_active) &&
 		di->batt_data.avg_curr_ua <
 		di->bm->bi->charge_term_current_ua &&
diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
index b0919a6a6587..236fd9f9d6f1 100644
--- a/drivers/power/supply/ab8500_fg.c
+++ b/drivers/power/supply/ab8500_fg.c
@@ -2263,7 +2263,13 @@ static int ab8500_fg_init_hw_registers(struct ab8500_fg *di)
 {
 	int ret;
 
-	/* Set VBAT OVV threshold */
+	/*
+	 * Set VBAT OVV (overvoltage) threshold to 4.75V (typ) this is what
+	 * the hardware supports, nothing else can be configured in hardware.
+	 * See this as an "outer limit" where the charger will certainly
+	 * shut down. Other (lower) overvoltage levels need to be implemented
+	 * in software.
+	 */
 	ret = abx500_mask_and_set_register_interruptible(di->dev,
 		AB8500_CHARGER,
 		AB8500_BATT_OVV,
-- 
2.34.1


  parent reply	other threads:[~2022-01-27  1:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27  1:12 [PATCH 00/11] AB8500 charging fixes Linus Walleij
2022-01-27  1:12 ` [PATCH 01/11] power: supply: ab8500: Drop BATCTRL thermal mode Linus Walleij
2022-01-27  1:12 ` Linus Walleij [this message]
2022-01-27  1:12 ` [PATCH 03/11] power: supply: ab8500: Integrate thermal zone Linus Walleij
2022-01-27  1:12 ` [PATCH 04/11] power: supply: ab8500_fg: Break loop for measurement Linus Walleij
2022-01-27  1:12 ` [PATCH 05/11] power: supply: ab8500_fg: Break out load compensated voltage Linus Walleij
2022-01-27 22:31   ` kernel test robot
2022-01-27  1:12 ` [PATCH 06/11] power: supply: ab8500_fg: Safeguard " Linus Walleij
2022-01-27  1:12 ` [PATCH 07/11] power: supply: ab8500_fg: Drop useless parameter Linus Walleij
2022-01-27  1:12 ` [PATCH 08/11] power: supply: ab8500_chargalg: Drop charging step Linus Walleij
2022-01-27  1:12 ` [PATCH 09/11] power: supply: ab8500_chargalg: Drop enable/disable sysfs Linus Walleij
2022-01-27  1:12 ` [PATCH 10/11] power: supply: ab8500_charger: Restrict ADC retrieveal Linus Walleij
2022-01-27  1:12 ` [PATCH 11/11] power: supply: ab8500_charger: Fix VBAT interval check Linus Walleij

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=20220127011236.332687-3-linus.walleij@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=codekipper@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.