mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] power: supply: bq24190: Fix NTC status decoding for BQ24193
@ 2026-10-26  6:25 Patrick Fischer via B4 Relay
  2026-11-09  0:08 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Fischer via B4 Relay @ 2026-10-26  6:25 UTC (permalink / raw)
  To: Sebastian Reichel, Aaron Kling
  Cc: Svyatoslav Ryhel, linux-pm, linux-tegra, linux-kernel, Patrick Fischer

From: Patrick Fischer <admin@tsv-stahl-riesa.de>

The BQ24193 has a single thermistor input and applies the JEITA
temperature profile. Its NTC_FAULT field in REG09 is encoded
differently from the BQ24190, which has two TS inputs:

  NTC_FAULT  BQ24190    BQ24193
  000        Normal     Normal
  010        TS1 Hot    Warm
  011        TS2 Cold   Cool
  101        Both Cold  Cold
  110        Both Hot   Hot

(BQ24190/2/2I datasheet SLUSAW5B, table 17; BQ24193 datasheet
SLUSBG7A, table 16.)

Warm (45-60 C at the TS pin) and Cool (0-10 C) are not faults. The
charger keeps charging at a reduced charge voltage or charge current.
The BQ24193 uses bq24190_charger_get_ntc_status() though, so a warm
battery is reported as POWER_SUPPLY_HEALTH_OVERHEAT and a cool one as
POWER_SUPPLY_HEALTH_COLD.

Add a BQ24193 decoder that reports POWER_SUPPLY_HEALTH_WARM and
POWER_SUPPLY_HEALTH_COOL for these states. Cold and Hot are unchanged.

On an NVIDIA Tegra Note 7 (P1640) REG09 reads 0x02 after a few minutes
on USB power. The battery keeps charging, but the charger reports
health "Overheat". With this patch it reports "Warm" in that state and
"Good" while REG09 reads 0x00.

Fixes: afe5301bfbaa ("power: bq24190: Add BQ24193 support")
Signed-off-by: Patrick Fischer <admin@tsv-stahl-riesa.de>
---
I kept this a pure decoding fix. Two things stay as they are and could
be follow-ups if you want them:

- The interrupt handler still logs a change to Warm or Cool as
  "Fault: ... ntc 1", as it does for every change of REG09.
- bq24190_charger_get_health() checks the NTC bits first, so while the
  battery is warm or cool the charger health hides a charge fault or
  battery over-voltage.

Tool use (see Documentation/process/generated-content.rst): this patch,
its changelog and this note were prepared with an LLM coding assistant
(Claude Code). It compared the driver with both datasheets and wrote the
code change and the texts from my register dumps and instructions. I
reviewed the change and ran the test on the device.
---
 drivers/power/supply/bq24190_charger.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 4bea6fd83c36..350cf79a0744 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -999,6 +999,30 @@ static int bq24190_charger_get_ntc_status(u8 value)
 	return health;
 }
 
+static int bq24193_charger_get_ntc_status(u8 value)
+{
+	int health;
+
+	switch (value >> BQ24190_REG_F_NTC_FAULT_SHIFT & 0x7) {
+	case 0x2: /* Warm */
+		health = POWER_SUPPLY_HEALTH_WARM;
+		break;
+	case 0x3: /* Cool */
+		health = POWER_SUPPLY_HEALTH_COOL;
+		break;
+	case 0x5: /* Cold */
+		health = POWER_SUPPLY_HEALTH_COLD;
+		break;
+	case 0x6: /* Hot */
+		health = POWER_SUPPLY_HEALTH_OVERHEAT;
+		break;
+	default:
+		health = POWER_SUPPLY_HEALTH_UNKNOWN;
+	}
+
+	return health;
+}
+
 static int bq24296_charger_get_ntc_status(u8 value)
 {
 	int health;
@@ -2013,7 +2037,7 @@ static const struct bq24190_chip_info bq24190_chip_info_tbl[] = {
 		.check_chip = bq24190_check_chip,
 		.set_chg_config = bq24190_battery_set_chg_config,
 		.ntc_fault_mask = BQ24190_REG_F_NTC_FAULT_MASK,
-		.get_ntc_status = bq24190_charger_get_ntc_status,
+		.get_ntc_status = bq24193_charger_get_ntc_status,
 		.set_otg_vbus = bq24190_set_otg_vbus,
 	},
 	[BQ24196] = {

---
base-commit: 734bef548a96e8774d6eef5dfa2026c6edc4e80b
change-id: 20261023-upstream-bq24190-ntc-f35ec3323449

Best regards,
--  
Patrick Fischer <admin@tsv-stahl-riesa.de>



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

* Re: [PATCH] power: supply: bq24190: Fix NTC status decoding for BQ24193
  2026-10-26  6:25 [PATCH] power: supply: bq24190: Fix NTC status decoding for BQ24193 Patrick Fischer via B4 Relay
@ 2026-11-09  0:08 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2026-11-09  0:08 UTC (permalink / raw)
  To: admin; +Cc: Aaron Kling, Svyatoslav Ryhel, linux-pm, linux-tegra, linux-kernel

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

Hi,

On Mon, Oct 26, 2026 at 07:25:05AM +0100, Patrick Fischer via B4 Relay wrote:
> From: Patrick Fischer <admin@tsv-stahl-riesa.de>
> 
> The BQ24193 has a single thermistor input and applies the JEITA
> temperature profile. Its NTC_FAULT field in REG09 is encoded
> differently from the BQ24190, which has two TS inputs:
> 
>   NTC_FAULT  BQ24190    BQ24193
>   000        Normal     Normal
>   010        TS1 Hot    Warm
>   011        TS2 Cold   Cool
>   101        Both Cold  Cold
>   110        Both Hot   Hot
> 
> (BQ24190/2/2I datasheet SLUSAW5B, table 17; BQ24193 datasheet
> SLUSBG7A, table 16.)
> 
> Warm (45-60 C at the TS pin) and Cool (0-10 C) are not faults. The
> charger keeps charging at a reduced charge voltage or charge current.
> The BQ24193 uses bq24190_charger_get_ntc_status() though, so a warm
> battery is reported as POWER_SUPPLY_HEALTH_OVERHEAT and a cool one as
> POWER_SUPPLY_HEALTH_COLD.
> 
> Add a BQ24193 decoder that reports POWER_SUPPLY_HEALTH_WARM and
> POWER_SUPPLY_HEALTH_COOL for these states. Cold and Hot are unchanged.
> 
> On an NVIDIA Tegra Note 7 (P1640) REG09 reads 0x02 after a few minutes
> on USB power. The battery keeps charging, but the charger reports
> health "Overheat". With this patch it reports "Warm" in that state and
> "Good" while REG09 reads 0x00.
> 
> Fixes: afe5301bfbaa ("power: bq24190: Add BQ24193 support")
> Signed-off-by: Patrick Fischer <admin@tsv-stahl-riesa.de>
> ---
> I kept this a pure decoding fix. Two things stay as they are and could
> be follow-ups if you want them:
> 
> - The interrupt handler still logs a change to Warm or Cool as
>   "Fault: ... ntc 1", as it does for every change of REG09.
> - bq24190_charger_get_health() checks the NTC bits first, so while the
>   battery is warm or cool the charger health hides a charge fault or
>   battery over-voltage.
> 
> Tool use (see Documentation/process/generated-content.rst): this patch,
> its changelog and this note were prepared with an LLM coding assistant
> (Claude Code). It compared the driver with both datasheets and wrote the
> code change and the texts from my register dumps and instructions. I
> reviewed the change and ran the test on the device.
> ---

Looks like bq24190_charger_get_ntc_status can just be updated to
handle a single temperature sensor as warm/cool and dual-sensor as
overheat/cold?

Greetings,

-- Sebastian

>  drivers/power/supply/bq24190_charger.c | 26 +++++++++++++++++++++++++-
>  1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> index 4bea6fd83c36..350cf79a0744 100644
> --- a/drivers/power/supply/bq24190_charger.c
> +++ b/drivers/power/supply/bq24190_charger.c
> @@ -999,6 +999,30 @@ static int bq24190_charger_get_ntc_status(u8 value)
>  	return health;
>  }
>  
> +static int bq24193_charger_get_ntc_status(u8 value)
> +{
> +	int health;
> +
> +	switch (value >> BQ24190_REG_F_NTC_FAULT_SHIFT & 0x7) {
> +	case 0x2: /* Warm */
> +		health = POWER_SUPPLY_HEALTH_WARM;
> +		break;
> +	case 0x3: /* Cool */
> +		health = POWER_SUPPLY_HEALTH_COOL;
> +		break;
> +	case 0x5: /* Cold */
> +		health = POWER_SUPPLY_HEALTH_COLD;
> +		break;
> +	case 0x6: /* Hot */
> +		health = POWER_SUPPLY_HEALTH_OVERHEAT;
> +		break;
> +	default:
> +		health = POWER_SUPPLY_HEALTH_UNKNOWN;
> +	}
> +
> +	return health;
> +}
> +
>  static int bq24296_charger_get_ntc_status(u8 value)
>  {
>  	int health;
> @@ -2013,7 +2037,7 @@ static const struct bq24190_chip_info bq24190_chip_info_tbl[] = {
>  		.check_chip = bq24190_check_chip,
>  		.set_chg_config = bq24190_battery_set_chg_config,
>  		.ntc_fault_mask = BQ24190_REG_F_NTC_FAULT_MASK,
> -		.get_ntc_status = bq24190_charger_get_ntc_status,
> +		.get_ntc_status = bq24193_charger_get_ntc_status,
>  		.set_otg_vbus = bq24190_set_otg_vbus,
>  	},
>  	[BQ24196] = {
> 
> ---
> base-commit: 734bef548a96e8774d6eef5dfa2026c6edc4e80b
> change-id: 20261023-upstream-bq24190-ntc-f35ec3323449
> 
> Best regards,
> --  
> Patrick Fischer <admin@tsv-stahl-riesa.de>
> 
> 

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

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

end of thread, other threads:[~2026-11-09  0:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26  6:25 [PATCH] power: supply: bq24190: Fix NTC status decoding for BQ24193 Patrick Fischer via B4 Relay
2026-11-09  0:08 ` Sebastian Reichel

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

all inboxes | Powered by JetHome®