Add driver for TI BQ25630 charger
Subsystems (2)
v3 cover Add driver for TI BQ25630 charger
This patch series contains a fully working driver for the basic functionality for the new TI BQ25630 charger (see datasheet [1]). The other "advanced" functionalities such as USB OTG, BATFET control and liquid detection, will be handled in separate patches (after necessary framework changes) according to the design discussions in the first RFC version.
[1] https://www.ti.com/lit/gpn/bq25630
Changes in v3:
[power]
* Sort variable declarations in reverse x-mas tree order in read/write property functions.
[dt-bindings]
* Drop description for property reg.
* Remove | in description for property interrupts.
* Remove monitored-battery from properties.
* Use unevaluatedProperties: false instead of additionalProperties: false.
Link to v2: https://lore.kernel.org/lkml/[email protected]/
Changes in v2:
[power]
* Fix return value check for data->regmap16be initialization in probe (check was wrongly for data->regmap16le).
* Remove TODO-comment about BATFET sysfs ABI (we will add a new sysfs ABI entry in the framework for this).
* Check registers BQ25630_REG_CHARGER_STATUS_X as well in IRQ handler. Because there might be changes that is not necessarily *only* triggered from hardware faults. For example, manually enabling/disabling with echo 0 > /online.
[dt-bindings]
* Rename file with ti, prefix.
* Remove battery-node in example.
Link to v1: https://lore.kernel.org/lkml/[email protected]/
Waqar Hameed (2):
dt-bindings: power: supply: Add TI BQ25630 charger
power: supply: Add driver for TI BQ25630 charger
.../bindings/power/supply/ti,bq25630.yaml | 55 + drivers/power/supply/Kconfig | 7 + drivers/power/supply/Makefile | 1 + drivers/power/supply/bq25630_charger.c | 1073 +++++++++++++++++ 4 files changed, 1136 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml create mode 100644 drivers/power/supply/bq25630_charger.c
base-commit: ab9de95c9cf952332ab79453b4b5d1bfca8e514f
Signature · 1 line
2.43.0
PATCH v3 1/2 dt-bindings: power: supply: Add TI BQ25630 charger
Add devicetree bindings for the TI BQ25630 battery charger. It's I2C controlled and sends interrupts.
--- .../bindings/power/supply/ti,bq25630.yaml | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +55 -0
@@ -0,0 +1,55 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/ti,bq25630.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TI BQ25630 battery charger + +maintainers: + - Waqar Hameed <[email protected]> + +description: | + I2C controlled single cell Li-ion and Li-polymer 5A buck charger. + Datasheet: https://www.ti.com/lit/gpn/bq25630 + +allOf: + - $ref: power-supply.yaml# + +properties: + compatible: + const: ti,bq25630 + + reg: + const: 0x6b + + interrupts: + maxItems: 1 + description: + Device sends active low 256 µs pulse. Type should therefore be + IRQ_TYPE_EDGE_FALLING. + +required: + - compatible + - reg + - interrupts + - monitored-battery + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { + compatible = "ti,bq25630"; + reg = <0x6b>; + interrupts = <13 IRQ_TYPE_EDGE_FALLING>; + monitored-battery = <&bat>; + }; + }; +...
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v3 1/2] dt-bindings: power: supply: Add TI BQ25630 charger
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The devicetree binding example references an undefined phandle label `&bat`, which will cause `dtc`…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The devicetree binding example references an undefined phandle label &bat, which will cause dtc compilation to fail during make dt_binding_check. --
commit 4d0f17bc3ce487f6e8027b9ef945b17aba3d6bee
Author: Waqar Hameed <[email protected]>
dt-bindings: power: supply: Add TI BQ25630 charger
This commit adds devicetree bindings for the TI BQ25630 battery charger. It defines standard properties for I2C and interrupts, and sets up requirements for a monitored battery reference.
Quoted 5 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 52
Quoted 13 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +13
-0+examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { + compatible = "ti,bq25630"; + reg = <0x6b>; + interrupts = <13 IRQ_TYPE_EDGE_FALLING>; + monitored-battery = <&bat>;
[Severity: Low]
Does this example reference an undefined phandle label?
Looking at the example scope, the node with the bat label is not defined anywhere. Could this cause dtc compilation to fail with a 'Reference to non-existent node or label' error during make dt_binding_check?
Quoted 3 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +3
-0+ }; + }; +...
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v3 1/2] dt-bindings: power: supply: Add TI BQ25630 charger
Quoted 41 lines · On Sun, Jun 28, 2026 at 22:07 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The devicetree binding example references an undefined phandle label&bat, which will causedtccompilation to fail duringmake dt_binding_check.
--commit
4d0f17bc3ce487f6e8027b9ef945b17aba3d6bee
Author: Waqar Hameed <[email protected]>dt-bindings: power: supply: Add TI BQ25630 charger
This commit adds devicetree bindings for the TI BQ25630 battery charger. It defines standard properties for I2C and interrupts, and sets up requirements for a monitored battery reference.
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +0
-0[ ... ]
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 52
Quoted 13 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +13
-0+examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + charger@6b { + compatible = "ti,bq25630"; + reg = <0x6b>; + interrupts = <13 IRQ_TYPE_EDGE_FALLING>; + monitored-battery = <&bat>;[Severity: Low]
Does this example reference an undefined phandle label?
Quoted 3 lines
Looking at the example scope, the node with the bat label is not defined anywhere. Could this cause dtc compilation to fail with a 'Reference to non-existent node or label' error during make
dt_binding_check?
No, make dt_binding_check passes. This was discussed in first patchset [1].
Quoted 4 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 55
Quoted 4 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +3
-0+ }; + }; +...
PATCH v3 2/2 power: supply: Add driver for TI BQ25630 charger
In reply to Waqar HameedTI BQ25630 is a battery charger that is I2C controlled. Despite its model name, it is rather different from the other devices in the BQ256xx family; it has a completely different register layout and some other additional functionality (see the datasheet for more details [1]).
The most "annoying" thing is that it has two different register lengths:
8-bit and 16-bit. Moreover, the 16-bit registers are further partitioned into either being little- or big-endian... Luckily, regmap has support for multiple regmap_configs (by setting unique names). Therefore, use three different regmap_configs for the corresponding registers. ADC functionality has been left out, due to it not having any real-world use-cases.
The enum power_supply_property values are straightforward to map. Some properties are clamped (e.g. voltage/current ranges). Common bq25630_read/write_limit() functions for this are therefore suitable.
Interrupts are sent whenever a state change is detected. Save the state status registers in bq25630_data and memcmp() this in order to decide if power_supply_changed() should be called or not. The actual state values are in (and fetched from) the other power_supply_property-mapped registers.
[1] https://www.ti.com/lit/gpn/bq25630
--- drivers/power/supply/Kconfig | 7 + drivers/power/supply/Makefile | 1 + drivers/power/supply/bq25630_charger.c | 1073 ++++++++++++++++++++++++ 3 files changed, 1081 insertions(+) create mode 100644 drivers/power/supply/bq25630_charger.c
drivers/power/supply/Kconfig +7 -0
@@ -839,6 +839,13 @@ config CHARGER_BQ25980 Say Y to enable support for the TI BQ25980, BQ25975 and BQ25960 series of fast battery chargers. +config CHARGER_BQ25630 + tristate "TI BQ25630 battery charger driver" + depends on I2C + select REGMAP_I2C + help + Say Y to enable support for the TI BQ25630 battery charger. + config CHARGER_BQ256XX tristate "TI BQ256XX battery charger driver" depends on I2C
drivers/power/supply/Makefile +1 -0
@@ -105,6 +105,7 @@ obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o obj-$(CONFIG_CHARGER_BQ257XX) += bq257xx_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_BQ25980) += bq25980_charger.o +obj-$(CONFIG_CHARGER_BQ25630) += bq25630_charger.o obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o obj-$(CONFIG_CHARGER_RK817) += rk817_charger.o obj-$(CONFIG_CHARGER_S2M) += s2m-charger.o
drivers/power/supply/bq25630_charger.c new file +1073 -0
1,073 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v3 2/2] power: supply: Add driver for TI BQ25630 charger
Hi,
Quoted 33 lines · Waqar Hameed
TI BQ25630 is a battery charger that is I2C controlled. Despite its model name, it is rather different from the other devices in the BQ256xx family; it has a completely different register layout and some other additional functionality (see the datasheet for more details [1]).
The most "annoying" thing is that it has two different register lengths:
8-bit and 16-bit. Moreover, the 16-bit registers are further partitioned into either being little- or big-endian... Luckily,regmaphas support for multipleregmap_configs (by setting unique names). Therefore, use three differentregmap_configs for the corresponding registers. ADC functionality has been left out, due to it not having any real-world use-cases.The
enum power_supply_propertyvalues are straightforward to map. Some properties are clamped (e.g. voltage/current ranges). Commonbq25630_read/write_limit()functions for this are therefore suitable.Interrupts are sent whenever a state change is detected. Save the state status registers in
bq25630_dataandmemcmp()this in order to decide ifpower_supply_changed()should be called or not. The actual state values are in (and fetched from) the otherpower_supply_property-mapped registers.[1] https://www.ti.com/lit/gpn/bq25630
Signed-off-by Waqar Hameed <[email protected]>--- drivers/power/supply/Kconfig | 7 + drivers/power/supply/Makefile | 1 + drivers/power/supply/bq25630_charger.c | 1073 ++++++++++++++++++++++++ 3 files changed, 1081 insertions(+) create mode 100644 drivers/power/supply/bq25630_charger.c
[...]
drivers/power/supply/bq25630_charger.c line 953
Quoted 3 lines
drivers/power/supply/bq25630_charger.c new file +3
-0+static const struct power_supply_desc bq25630_charger_psy_desc = { + .name =BQ25630_DRV_NAME , + .type =POWER_SUPPLY_TYPE_USB_TYPE_C ,
Just POWER_SUPPLY_TYPE_USB, other USB details should be done via USB_TYPES (as you do already). I just cannot remove those types because they are used by some old drivers and exposed to userspace and thus ABI. I guesss I should add a _DEPRECATED to the in-kernel name.
I will fix that up while applying.
Greetings,
-- Sebastian
Re: [PATCH v3 2/2] power: supply: Add driver for TI BQ25630 charger
On Sat, Jul 25, 2026 at 02:57 +0200 Sebastian Reichel <[email protected]> wrote:
[...]
Quoted 9 lines
drivers/power/supply/bq25630_charger.c line 953
Quoted 3 lines
drivers/power/supply/bq25630_charger.c new file +3
-0+static const struct power_supply_desc bq25630_charger_psy_desc = { + .name =BQ25630_DRV_NAME , + .type =POWER_SUPPLY_TYPE_USB_TYPE_C ,Just
POWER_SUPPLY_TYPE_USB, other USB details should be done viaUSB_TYPES(as you do already). I just cannot remove those types because they are used by some old drivers and exposed to userspace and thus ABI. I guesss I should add a_DEPRECATEDto the in-kernel name.
Yeah, maybe we should do that. It would surely help the next person :)
Quoted 2 lines
I will fix that up while applying.
Thanks!
Sebastian Reichel
AppliedQuoted 8 lines · Waqar Hameed
This patch series contains a fully working driver for the basic functionality for the new TI BQ25630 charger (see datasheet [1]). The other "advanced" functionalities such as USB OTG, BATFET control and liquid detection, will be handled in separate patches (after necessary framework changes) according to the design discussions in the first RFC version.
[...]
Applied, thanks!
[1/2] dt-bindings: power: supply: Add TI BQ25630 charger
commit: 7380075135496df3b07a61c002928af0582b2bf6
[2/2] power: supply: Add driver for TI BQ25630 charger
commit: 81a10126cb33d553e9b08a5c09b0cb9835cab2d7Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>