* [PATCH v2 0/3] power: supply: bq27xxx: add bq27z746
@ 2026-08-18 9:48 Henrik Grimler
2026-08-18 9:48 ` [PATCH v2 1/3] dt-bindings: power: bq27xxx: bq27z561: allow interrupts property Henrik Grimler
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Henrik Grimler @ 2026-08-18 9:48 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, Andrew F. Davis, Chris Lapa, Dan Murphy
Cc: linux-pm, devicetree, linux-kernel, Sebastian Reichel, kernel,
Henrik Grimler
bq27z746 is similar to bq27z561 but with additional protection
functionality. The standard register set is identical, but the
extended registers accessed through AltManufacturerAccess has
differences.
While working on the series I also noticed that bq27z561 supports
interrupts, but the dt binding marks it as unsupported. Fix while at
it.
For reference the TRMs for the affected bq chips can be found at these
direct links:
- bq27z746: https://ti.com/lit/ug/sluuca6/sluuca6.pdf
- bq27z561: https://ti.com/lit/ug/sluubo7/sluubo7.pdf
Signed-off-by: Henrik Grimler <henrik.grimler@axis.com>
---
Changes in v2:
- Rebase and drop applied patches
- Add patch to add interrupt support for bq27z561, issue found thanks
to that Sashiko commented on it
- Describe differences between bq27z746 and bq27z561 in more detail
- Link to v1: https://lore.kernel.org/r/20260811-bq27z746-v1-0-3a4fa38205cc@axis.com
---
Henrik Grimler (3):
dt-bindings: power: bq27xxx: bq27z561: allow interrupts property
dt-bindings: power: bq27xxx: document bq27z746
power: supply: bq27xxx: add support for bq27z746
Documentation/devicetree/bindings/power/supply/bq27xxx.yaml | 2 +-
drivers/power/supply/bq27xxx_battery.c | 6 ++++++
drivers/power/supply/bq27xxx_battery_i2c.c | 2 ++
include/linux/power/bq27xxx_battery.h | 1 +
4 files changed, 10 insertions(+), 1 deletion(-)
---
base-commit: 2da28b059e0ddcd2e1956eeae383246207965573
change-id: 20260709-bq27z746-8dc4c2ec0948
Best regards,
--
Henrik Grimler <henrik.grimler@axis.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/3] dt-bindings: power: bq27xxx: bq27z561: allow interrupts property
2026-08-18 9:48 [PATCH v2 0/3] power: supply: bq27xxx: add bq27z746 Henrik Grimler
@ 2026-08-18 9:48 ` Henrik Grimler
2026-08-18 9:48 ` [PATCH v2 2/3] dt-bindings: power: bq27xxx: document bq27z746 Henrik Grimler
2026-08-18 9:48 ` [PATCH v2 3/3] power: supply: bq27xxx: add support for bq27z746 Henrik Grimler
2 siblings, 0 replies; 5+ messages in thread
From: Henrik Grimler @ 2026-08-18 9:48 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, Andrew F. Davis, Chris Lapa, Dan Murphy
Cc: linux-pm, devicetree, linux-kernel, Sebastian Reichel, kernel,
Henrik Grimler
According to the technical reference manual for bq27z561 it has
support for an interrupt on an INT pin. Remove it from the list of
devices without interrupt support to better describe the hardware.
Fixes: b4f7a727c29c ("dt-bindings: power: supply: bq27xxx: document optional interrupt")
Signed-off-by: Henrik Grimler <henrik.grimler@axis.com>
---
Documentation/devicetree/bindings/power/supply/bq27xxx.yaml | 1 -
1 file changed, 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
index bc05400186cf..d985ae632599 100644
--- a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
+++ b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
@@ -91,7 +91,6 @@ allOf:
- ti,bq27742
- ti,bq27545
- ti,bq27411
- - ti,bq27z561
- ti,bq28z610
- ti,bq34z100
- ti,bq78z100
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] dt-bindings: power: bq27xxx: document bq27z746
2026-08-18 9:48 [PATCH v2 0/3] power: supply: bq27xxx: add bq27z746 Henrik Grimler
2026-08-18 9:48 ` [PATCH v2 1/3] dt-bindings: power: bq27xxx: bq27z561: allow interrupts property Henrik Grimler
@ 2026-08-18 9:48 ` Henrik Grimler
2026-08-18 9:48 ` [PATCH v2 3/3] power: supply: bq27xxx: add support for bq27z746 Henrik Grimler
2 siblings, 0 replies; 5+ messages in thread
From: Henrik Grimler @ 2026-08-18 9:48 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, Andrew F. Davis, Chris Lapa, Dan Murphy
Cc: linux-pm, devicetree, linux-kernel, Sebastian Reichel, kernel,
Henrik Grimler
Add compatible for Texas Instruments bq27z746 fuel gauge, which is
similar to its sibling bq27z561. Unlike bq27z561, bq27z746 includes
some protection logic and can drive external MOSFETs. The register map
is a subset of the one found in bq27z561, with bq27z561 having six
extra registers at the end at 0x70 - 0x7A.
Among the ManufacturerAccess registers there are some more differences
mainly related to MOSFET control and deep sleep/shipping mode.
Signed-off-by: Henrik Grimler <henrik.grimler@axis.com>
---
Documentation/devicetree/bindings/power/supply/bq27xxx.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
index d985ae632599..79d1a3c8c685 100644
--- a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
+++ b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
@@ -47,6 +47,7 @@ properties:
- ti,bq27441
- ti,bq27621
- ti,bq27z561
+ - ti,bq27z746
- ti,bq28z610
- ti,bq34z100
- ti,bq78z100
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] power: supply: bq27xxx: add support for bq27z746
2026-08-18 9:48 [PATCH v2 0/3] power: supply: bq27xxx: add bq27z746 Henrik Grimler
2026-08-18 9:48 ` [PATCH v2 1/3] dt-bindings: power: bq27xxx: bq27z561: allow interrupts property Henrik Grimler
2026-08-18 9:48 ` [PATCH v2 2/3] dt-bindings: power: bq27xxx: document bq27z746 Henrik Grimler
@ 2026-08-18 9:48 ` Henrik Grimler
2026-08-18 9:57 ` sashiko-bot
2 siblings, 1 reply; 5+ messages in thread
From: Henrik Grimler @ 2026-08-18 9:48 UTC (permalink / raw)
To: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, Andrew F. Davis, Chris Lapa, Dan Murphy
Cc: linux-pm, devicetree, linux-kernel, Sebastian Reichel, kernel,
Henrik Grimler
bq27z746 is similar to bq27z561, but has additional battery protection
logic. The standard register map is a subset of the one found in
bq27z561. There are some more differences among the ManufacturerAccess
registers, but the ManufacturerAccess registers are currently not
handled by the driver in any way. Therefore use the same regs and
props for bq27z746 and bq27z561.
Signed-off-by: Henrik Grimler <henrik.grimler@axis.com>
---
drivers/power/supply/bq27xxx_battery.c | 6 ++++++
drivers/power/supply/bq27xxx_battery_i2c.c | 2 ++
include/linux/power/bq27xxx_battery.h | 1 +
3 files changed, 9 insertions(+)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 01c9ec1116fa..5aed8b24119b 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -37,6 +37,7 @@
* https://www.ti.com/product/bq27441-g1
* https://www.ti.com/product/bq27621-g1
* https://www.ti.com/product/bq27z561
+ * https://www.ti.com/product/bq27z746
* https://www.ti.com/product/bq28z610
* https://www.ti.com/product/bq34z100-g1
* https://www.ti.com/product/bq78z100
@@ -501,6 +502,7 @@ static u8
[BQ27XXX_REG_AP] = 0x22,
BQ27XXX_DM_REG_ROWS,
},
+#define bq27z746_regs bq27z561_regs
bq28z610_regs[BQ27XXX_REG_MAX] = {
[BQ27XXX_REG_CTRL] = 0x00,
[BQ27XXX_REG_TEMP] = 0x06,
@@ -836,6 +838,8 @@ static enum power_supply_property bq27z561_props[] = {
POWER_SUPPLY_PROP_MANUFACTURER,
};
+#define bq27z746_props bq27z561_props
+
static enum power_supply_property bq28z610_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_PRESENT,
@@ -994,6 +998,7 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
#endif
#define bq27z561_dm_regs NULL
+#define bq27z746_dm_regs NULL
#define bq28z610_dm_regs NULL
#define bq34z100_dm_regs NULL
#define bq78z100_dm_regs NULL
@@ -1052,6 +1057,7 @@ static struct {
[BQ27441] = BQ27XXX_DATA(bq27441, 0x80008000, BQ27XXX_O_UTOT | BQ27XXX_O_CFGUP | BQ27XXX_O_RAM),
[BQ27621] = BQ27XXX_DATA(bq27621, 0x80008000, BQ27XXX_O_UTOT | BQ27XXX_O_CFGUP | BQ27XXX_O_RAM),
[BQ27Z561] = BQ27XXX_DATA(bq27z561, 0 , BQ27Z561_O_BITS),
+ [BQ27Z746] = BQ27XXX_DATA(bq27z746, 0 , BQ27Z561_O_BITS),
[BQ28Z610] = BQ27XXX_DATA(bq28z610, 0 , BQ27Z561_O_BITS),
[BQ34Z100] = BQ27XXX_DATA(bq34z100, 0 , BQ27XXX_O_OTDC | BQ27XXX_O_SOC_SI | \
BQ27XXX_O_HAS_CI | BQ27XXX_O_MUL_CHEM),
diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index c4e7a9521d08..2a6b4534cb28 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -253,6 +253,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
{ .name = "bq27441", .driver_data = BQ27441 },
{ .name = "bq27621", .driver_data = BQ27621 },
{ .name = "bq27z561", .driver_data = BQ27Z561 },
+ { .name = "bq27z746", .driver_data = BQ27Z746 },
{ .name = "bq28z610", .driver_data = BQ28Z610 },
{ .name = "bq34z100", .driver_data = BQ34Z100 },
{ .name = "bq78z100", .driver_data = BQ78Z100 },
@@ -290,6 +291,7 @@ static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
{ .compatible = "ti,bq27441" },
{ .compatible = "ti,bq27621" },
{ .compatible = "ti,bq27z561" },
+ { .compatible = "ti,bq27z746" },
{ .compatible = "ti,bq28z610" },
{ .compatible = "ti,bq34z100" },
{ .compatible = "ti,bq78z100" },
diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
index d56e1276aafe..0b833c4bb583 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -33,6 +33,7 @@ enum bq27xxx_chip {
BQ27441,
BQ27621,
BQ27Z561,
+ BQ27Z746,
BQ28Z610,
BQ34Z100,
BQ78Z100,
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 3/3] power: supply: bq27xxx: add support for bq27z746
2026-08-18 9:48 ` [PATCH v2 3/3] power: supply: bq27xxx: add support for bq27z746 Henrik Grimler
@ 2026-08-18 9:57 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-08-18 9:57 UTC (permalink / raw)
To: Henrik Grimler; +Cc: conor+dt, devicetree, robh
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Potential null pointer dereference in `bq27xxx_battery_i2c_probe()` when retrieving the I2C device ID. The driver relies on `i2c_client_get_device_id()` without checking its return value.
--
--- Patch [3]: [PATCH v2 3/3] power: supply: bq27xxx: add support for bq27z746 ---
commit a0624890a79f9b2398a034239df6144de2c581e9
Author: Henrik Grimler <henrik.grimler@axis.com>
power: supply: bq27xxx: add support for bq27z746
bq27z746 is similar to bq27z561, but has additional battery protection
logic. The standard register map is a subset of the one found in
bq27z561.
> diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
> index c4e7a9521d086..2a6b4534cb28a 100644
> --- a/drivers/power/supply/bq27xxx_battery_i2c.c
> +++ b/drivers/power/supply/bq27xxx_battery_i2c.c
> @@ -253,6 +253,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
> { .name = "bq27441", .driver_data = BQ27441 },
> { .name = "bq27621", .driver_data = BQ27621 },
> { .name = "bq27z561", .driver_data = BQ27Z561 },
> + { .name = "bq27z746", .driver_data = BQ27Z746 },
[Severity: High]
This is a pre-existing issue, but adding a new device id highlights a
potential null pointer dereference in bq27xxx_battery_i2c_probe().
If a system integrator provides a Device Tree containing a valid fallback
compatible string (for example: compatible = "ti,unsupported-chip",
"ti,bq27z746";), probe could be called with client->name set to
"unsupported-chip".
Since "unsupported-chip" is not in the I2C ID table,
i2c_client_get_device_id() will return NULL:
static int bq27xxx_battery_i2c_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
...
name = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%ld", id->name, num);
...
di->chip = id->driver_data;
...
}
Does this code cause a kernel panic when id->name and id->driver_data are
accessed if id is NULL? Would it be safer to explicitly check if id is
valid, or use i2c_get_match_data() to retrieve the driver_data?
> { .name = "bq28z610", .driver_data = BQ28Z610 },
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260818-bq27z746-v2-0-0371e206665f@axis.com?part=3
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-18 9:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18 9:48 [PATCH v2 0/3] power: supply: bq27xxx: add bq27z746 Henrik Grimler
2026-08-18 9:48 ` [PATCH v2 1/3] dt-bindings: power: bq27xxx: bq27z561: allow interrupts property Henrik Grimler
2026-08-18 9:48 ` [PATCH v2 2/3] dt-bindings: power: bq27xxx: document bq27z746 Henrik Grimler
2026-08-18 9:48 ` [PATCH v2 3/3] power: supply: bq27xxx: add support for bq27z746 Henrik Grimler
2026-08-18 9:57 ` sashiko-bot
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.