Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v7 0/7] Add support for the TI BQ25792 battery charger
@ 2026-06-02 20:10 Alexey Charkov
  2026-06-02 20:10 ` [PATCH v7 2/7] power: supply: bq257xx: Fix VSYSMIN clamping logic Alexey Charkov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexey Charkov @ 2026-06-02 20:10 UTC (permalink / raw)
  To: Chris Morgan, Mark Brown, Sebastian Reichel, Liam Girdwood,
	Lee Jones
  Cc: linux-kernel, Sebastian Reichel, linux-pm, Alexey Charkov, stable

This adds support for the TI BQ25792 battery charger, which is similar in
overall logic to the BQ25703A, but has a different register layout and
slightly different lower-level programming logic.

Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
Changes in v7:
- Rebase onto recent -next and dropped patches already applied by Mark and Lee
- Enable the Input Current Optimizer to improve reliability with unrecognized chargers
- Explicitly program the battery cell count at init time to alleviate transient glitches
  with the charger going into spurious battery overvoltage state due to misdetected
  battery cell count
- Handle return values of all regmap writes in the init function
- Link to v6: https://lore.kernel.org/r/20260331-bq25792-v6-0-0278fba33eb9@flipper.net

Changes in v6:
- Changed -EINVAL to -ENODEV for non-match cases in the MFD driver, to stay
  in line with what other drivers do in similar situations (Lee Jones)
- Link to v5: https://lore.kernel.org/r/20260324-bq25792-v5-0-0a2eb58cf11d@flipper.net

Changes in v5:
- Added non-OF match data and switched to i2c_get_match_data() to support
  non-OF platforms (Lee Jones)
- Shifted the types in the enum to start at 1 to avoid confusion with
  zero-initialized data and non-match cases (Lee Jones)
- Reinstated the const qualifier on the MFD cell array (Lee Jones)
- Link to v4: https://lore.kernel.org/r/20260311-bq25792-v4-0-7213415d9eec@flipper.net

Changes in v4:
- Avoid additional data structures and pass 'type' within the existing
  struct bq257xx_device instead (Lee Jones)
- Move comments for new struct fields to the patches where those fields
  are added (Sebastian Reichel)
- Collect tags from Sebastian Reichel (thanks!)
- Link to v3: https://lore.kernel.org/r/20260310-bq25792-v3-0-02f8e232d63b@flipper.net

Changes in v3:
- Move MFD cell definitions back out of the probe function (Lee Jones)
- Collect tags from Mark Brown, Krzysztof Kozlowski and Chris Morgan (thanks!)
- Enable ship FET functionality at init for BQ25792
- Link to v2: https://lore.kernel.org/r/20260306-bq25792-v2-0-6595249d6e6f@flipper.net

Changes in v2:
- Fix an error in DT schema (thanks Rob's bot)
- Ensure the broadest constraints for all variants remain in the common
  part of the schema, per writing-schema doc (thanks Krzysztof)
- Link to v1: https://lore.kernel.org/r/20260303-bq25792-v1-0-e6e5e0033458@flipper.net

---
Alexey Charkov (7):
      regulator: bq257xx: Drop the regulator_dev from the driver data
      power: supply: bq257xx: Fix VSYSMIN clamping logic
      power: supply: bq257xx: Make the default current limit a per-chip attribute
      power: supply: bq257xx: Consistently use indirect get/set helpers
      power: supply: bq257xx: Add fields for 'charging' and 'overvoltage' states
      regulator: bq257xx: Add support for BQ25792
      power: supply: bq257xx: Add support for BQ25792

 drivers/power/supply/bq257xx_charger.c | 580 ++++++++++++++++++++++++++++++++-
 drivers/regulator/bq257xx-regulator.c  | 106 +++++-
 include/linux/mfd/bq257xx.h            |  14 +
 3 files changed, 681 insertions(+), 19 deletions(-)
---
base-commit: 08484c504b55a98bd100527fbe10a3caf55ff3ff
change-id: 20260303-bq25792-0132ac86846d

Best regards,
--  
Alexey Charkov <alchark@flipper.net>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v7 2/7] power: supply: bq257xx: Fix VSYSMIN clamping logic
  2026-06-02 20:10 [PATCH v7 0/7] Add support for the TI BQ25792 battery charger Alexey Charkov
@ 2026-06-02 20:10 ` Alexey Charkov
  2026-06-03 20:52 ` [PATCH v7 0/7] Add support for the TI BQ25792 battery charger Sebastian Reichel
  2026-07-25 16:35 ` (subset) " Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Alexey Charkov @ 2026-06-02 20:10 UTC (permalink / raw)
  To: Chris Morgan, Mark Brown, Sebastian Reichel, Liam Girdwood,
	Lee Jones
  Cc: linux-kernel, Sebastian Reichel, linux-pm, Alexey Charkov, stable

The minimal system voltage (VSYSMIN) is meant to protect the battery from
dangerous over-discharge. When the device tree provides a value for the
minimum design voltage of the battery, the user should not be allowed to
set a lower VSYSMIN, as that would defeat the purpose of this protection.

Flip the clamping logic when setting VSYSMIN to ensure that battery design
voltage is respected.

Cc: stable@vger.kernel.org
Fixes: 1cc017b7f9c7 ("power: supply: bq257xx: Add support for BQ257XX charger")
Tested-by: Chris Morgan <macromorgan@hotmail.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
 drivers/power/supply/bq257xx_charger.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/bq257xx_charger.c b/drivers/power/supply/bq257xx_charger.c
index 02c7d8b61e82..7ca4ae610902 100644
--- a/drivers/power/supply/bq257xx_charger.c
+++ b/drivers/power/supply/bq257xx_charger.c
@@ -128,9 +128,8 @@ static int bq25703_get_min_vsys(struct bq257xx_chg *pdata, int *intval)
  * @vsys: voltage value to set in uV.
  *
  * This function takes a requested minimum system voltage value, clamps
- * it between the minimum supported value by the charger and a user
- * defined minimum system value, and then writes the value to the
- * appropriate register.
+ * it between the user defined minimum system value and the maximum supported
+ * value by the charger, and then writes the value to the appropriate register.
  *
  * Return: Returns 0 on success or error if an error occurs.
  */
@@ -139,7 +138,7 @@ static int bq25703_set_min_vsys(struct bq257xx_chg *pdata, int vsys)
 	unsigned int reg;
 	int vsys_min = pdata->vsys_min;
 
-	vsys = clamp(vsys, BQ25703_MINVSYS_MIN_UV, vsys_min);
+	vsys = clamp(vsys, vsys_min, BQ25703_MINVSYS_MAX_UV);
 	reg = ((vsys - BQ25703_MINVSYS_MIN_UV) / BQ25703_MINVSYS_STEP_UV);
 	reg = FIELD_PREP(BQ25703_MINVSYS_MASK, reg);
 

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v7 0/7] Add support for the TI BQ25792 battery charger
  2026-06-02 20:10 [PATCH v7 0/7] Add support for the TI BQ25792 battery charger Alexey Charkov
  2026-06-02 20:10 ` [PATCH v7 2/7] power: supply: bq257xx: Fix VSYSMIN clamping logic Alexey Charkov
@ 2026-06-03 20:52 ` Sebastian Reichel
  2026-07-25 16:35 ` (subset) " Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2026-06-03 20:52 UTC (permalink / raw)
  To: Alexey Charkov
  Cc: Chris Morgan, Mark Brown, Liam Girdwood, Lee Jones, linux-kernel,
	linux-pm, stable

[-- Attachment #1: Type: text/plain, Size: 3776 bytes --]

Hi,

On Wed, Jun 03, 2026 at 12:10:48AM +0400, Alexey Charkov wrote:
> This adds support for the TI BQ25792 battery charger, which is similar in
> overall logic to the BQ25703A, but has a different register layout and
> slightly different lower-level programming logic.
> 
> Signed-off-by: Alexey Charkov <alchark@flipper.net>
> ---
> Changes in v7:
> - Rebase onto recent -next and dropped patches already applied by Mark and Lee
> - Enable the Input Current Optimizer to improve reliability with unrecognized chargers
> - Explicitly program the battery cell count at init time to alleviate transient glitches
>   with the charger going into spurious battery overvoltage state due to misdetected
>   battery cell count
> - Handle return values of all regmap writes in the init function
> - Link to v6: https://lore.kernel.org/r/20260331-bq25792-v6-0-0278fba33eb9@flipper.net
> 
> Changes in v6:
> - Changed -EINVAL to -ENODEV for non-match cases in the MFD driver, to stay
>   in line with what other drivers do in similar situations (Lee Jones)
> - Link to v5: https://lore.kernel.org/r/20260324-bq25792-v5-0-0a2eb58cf11d@flipper.net
> 
> Changes in v5:
> - Added non-OF match data and switched to i2c_get_match_data() to support
>   non-OF platforms (Lee Jones)
> - Shifted the types in the enum to start at 1 to avoid confusion with
>   zero-initialized data and non-match cases (Lee Jones)
> - Reinstated the const qualifier on the MFD cell array (Lee Jones)
> - Link to v4: https://lore.kernel.org/r/20260311-bq25792-v4-0-7213415d9eec@flipper.net
> 
> Changes in v4:
> - Avoid additional data structures and pass 'type' within the existing
>   struct bq257xx_device instead (Lee Jones)
> - Move comments for new struct fields to the patches where those fields
>   are added (Sebastian Reichel)
> - Collect tags from Sebastian Reichel (thanks!)
> - Link to v3: https://lore.kernel.org/r/20260310-bq25792-v3-0-02f8e232d63b@flipper.net
> 
> Changes in v3:
> - Move MFD cell definitions back out of the probe function (Lee Jones)
> - Collect tags from Mark Brown, Krzysztof Kozlowski and Chris Morgan (thanks!)
> - Enable ship FET functionality at init for BQ25792
> - Link to v2: https://lore.kernel.org/r/20260306-bq25792-v2-0-6595249d6e6f@flipper.net
> 
> Changes in v2:
> - Fix an error in DT schema (thanks Rob's bot)
> - Ensure the broadest constraints for all variants remain in the common
>   part of the schema, per writing-schema doc (thanks Krzysztof)
> - Link to v1: https://lore.kernel.org/r/20260303-bq25792-v1-0-e6e5e0033458@flipper.net
> 
> ---
> Alexey Charkov (7):
>       regulator: bq257xx: Drop the regulator_dev from the driver data
>       power: supply: bq257xx: Fix VSYSMIN clamping logic
>       power: supply: bq257xx: Make the default current limit a per-chip attribute
>       power: supply: bq257xx: Consistently use indirect get/set helpers
>       power: supply: bq257xx: Add fields for 'charging' and 'overvoltage' states

I merged patches 2-5.

>       regulator: bq257xx: Add support for BQ25792
>       power: supply: bq257xx: Add support for BQ25792

This one updates the MFD header and does not apply to me tree. It
will have to wait a cycle, as there is not enough time to sync with
Lee how to proceed :)

Greetings,

-- Sebastian

> 
>  drivers/power/supply/bq257xx_charger.c | 580 ++++++++++++++++++++++++++++++++-
>  drivers/regulator/bq257xx-regulator.c  | 106 +++++-
>  include/linux/mfd/bq257xx.h            |  14 +
>  3 files changed, 681 insertions(+), 19 deletions(-)
> ---
> base-commit: 08484c504b55a98bd100527fbe10a3caf55ff3ff
> change-id: 20260303-bq25792-0132ac86846d
> 
> Best regards,
> --  
> Alexey Charkov <alchark@flipper.net>
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: (subset) [PATCH v7 0/7] Add support for the TI BQ25792 battery charger
  2026-06-02 20:10 [PATCH v7 0/7] Add support for the TI BQ25792 battery charger Alexey Charkov
  2026-06-02 20:10 ` [PATCH v7 2/7] power: supply: bq257xx: Fix VSYSMIN clamping logic Alexey Charkov
  2026-06-03 20:52 ` [PATCH v7 0/7] Add support for the TI BQ25792 battery charger Sebastian Reichel
@ 2026-07-25 16:35 ` Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2026-07-25 16:35 UTC (permalink / raw)
  To: Chris Morgan, Mark Brown, Sebastian Reichel, Liam Girdwood,
	Lee Jones, Alexey Charkov
  Cc: linux-kernel, linux-pm, stable


On Wed, 03 Jun 2026 00:10:48 +0400, Alexey Charkov wrote:
> This adds support for the TI BQ25792 battery charger, which is similar in
> overall logic to the BQ25703A, but has a different register layout and
> slightly different lower-level programming logic.
> 
> 

Applied, thanks!

[7/7] power: supply: bq257xx: Add support for BQ25792
      commit: 13cf94703737b4b9a6826987b46020df0642b1e0

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-25 16:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-02 20:10 [PATCH v7 0/7] Add support for the TI BQ25792 battery charger Alexey Charkov
2026-06-02 20:10 ` [PATCH v7 2/7] power: supply: bq257xx: Fix VSYSMIN clamping logic Alexey Charkov
2026-06-03 20:52 ` [PATCH v7 0/7] Add support for the TI BQ25792 battery charger Sebastian Reichel
2026-07-25 16:35 ` (subset) " Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox