Skip to contentSkip to conversation

Add driver for TI BQ25630 charger

PATCH New Waqar Hameed 3 participants 8 messages Jun 18 – Jun 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 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 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     |   59 +
 drivers/power/supply/Kconfig                  |    7 +
 drivers/power/supply/Makefile                 |    1 +
 drivers/power/supply/bq25630_charger.c        | 1073 +++++++++++++++++
 4 files changed, 1140 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml
 create mode 100644 drivers/power/supply/bq25630_charger.c

base-commit: e771677c937da5808f7b6c1f0e4a97ec1a84f8a8
prerequisite-patch-id: 7dfa938b45374a748d43880f3e8416e665134104
prerequisite-patch-id: c22d643d2a260a8dbcc92df0754cfdb480879578
prerequisite-patch-id: 12e94680b398a795657d3d2addcf55bed5ce62de

Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 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     | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +59 -0
new file mode 100644
index 0000000000000..1e2c7aacb26d8
@@ -0,0 +1,59 @@
+# 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
+    description:
+      Device I2C address.
+
+  interrupts:
+    maxItems: 1
+    description: |
+      Device sends active low 256 µs pulse. Type should therefore be
+      IRQ_TYPE_EDGE_FALLING.
+
+  monitored-battery: true
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - monitored-battery
+
+additionalProperties: 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
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] dt-bindings: power: supply: Add TI BQ25630 charger

Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 26

Quoted 11 lines · Waqar Hameed
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +11 -0
+allOf:
+  - $ref: power-supply.yaml#
+
+properties:
+  compatible:
+    const: ti,bq25630
+
+  reg:
+    const: 0x6b
+    description:
+      Device I2C address.

Drop description, obvious.

Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 30

Quoted 4 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +4 -0
+
+  interrupts:
+    maxItems: 1
+    description: |

Do not need '|' unless you need to preserve formatting.

Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 34

Quoted 4 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +4 -0
+      Device sends active low 256 µs pulse. Type should therefore be
+      IRQ_TYPE_EDGE_FALLING.
+
+  monitored-battery: true

Drop this one

Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 42

Quoted 8 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +8 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - monitored-battery
+
+additionalProperties: false

And here use 'unevaluatedProperties: false' instead.

With these fixed:

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v2 1/2] dt-bindings: power: supply: Add TI BQ25630 charger

Quoted 14 lines · On Mon, Jun 22, 2026 at 13:06 +0200 Krzysztof Kozlowski <[email protected]> wrote:

Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 26

Quoted 11 lines · Waqar Hameed
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +11 -0
+allOf:
+  - $ref: power-supply.yaml#
+
+properties:
+  compatible:
+    const: ti,bq25630
+
+  reg:
+    const: 0x6b
+    description:
+      Device I2C address.

Drop description, obvious.

I see that several others actually don't have a description for this property. I'll drop it!

Quoted 7 lines

Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 30

Quoted 5 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +4 -0
+
+  interrupts:
+    maxItems: 1
+    description: |

Do not need '|' unless you need to preserve formatting.

Right, let's remove it.

Quoted 7 lines

Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 34

Quoted 5 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +4 -0
+      Device sends active low 256 µs pulse. Type should therefore be
+      IRQ_TYPE_EDGE_FALLING.
+
+  monitored-battery: true

Drop this one

I was actually unsure about this one, but several other bindings had this one. We can remove it.

Quoted 11 lines

Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 42

Quoted 9 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +8 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - monitored-battery
+
+additionalProperties: false

And here use 'unevaluatedProperties: false' instead.

Hm, reading the documentation [1], unevaluatedProperties should be used, because of the "include" of power-supply.yaml. I'll change to that.

However, there are tons of other places where additionalProperties is used instead _with_ a reference to power-supply.yaml (which is what I followed). Are all of them actually "wrong" then?

Quoted 4 lines

With these fixed:

Thank you for your review Krzysztof!

[1] Documentation/devicetree/bindings/writing-schema.rst

#4 lore raw

Re: [PATCH v2 1/2] dt-bindings: power: supply: Add TI BQ25630 charger

Quoted 11 lines · Waqar Hameed
Quoted 10 lines

Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 42

Quoted 8 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +8 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - monitored-battery
+
+additionalProperties: false

And here use 'unevaluatedProperties: false' instead.

Quoted 7 lines

Hm, reading the documentation [1], unevaluatedProperties should be used, because of the "include" of power-supply.yaml. I'll change to that.

However, there are tons of other places where additionalProperties is used instead _with_ a reference to power-supply.yaml (which is what I followed). Are all of them actually "wrong" then?

No, they are not wrong, but usually preferred is to allow all properties from referenced power-supply schema.

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH v2 1/2] dt-bindings: power: supply: Add TI BQ25630 charger

Quoted 16 lines · On Thu, Jun 25, 2026 at 14:10 +0200 Krzysztof Kozlowski <[email protected]> wrote:
Quoted 15 lines · Waqar Hameed
Quoted 10 lines

Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml line 42

Quoted 8 lines
Documentation/devicetree/bindings/power/supply/ti,bq25630.yaml new file +8 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - monitored-battery
+
+additionalProperties: false

And here use 'unevaluatedProperties: false' instead.

Hm, reading the documentation [1], unevaluatedProperties should be used, because of the "include" of power-supply.yaml. I'll change to that.

Quoted 6 lines
Quoted 3 lines

However, there are tons of other places where additionalProperties is used instead _with_ a reference to power-supply.yaml (which is what I followed). Are all of them actually "wrong" then?

No, they are not wrong, but usually preferred is to allow all properties from referenced power-supply schema.

Ah ok, I can see why it's more preferable to be more "permissive" with unevaluatedProperties. Thanks!

#6 lore raw

PATCH v2 2/2 power: supply: Add driver for TI BQ25630 charger

In reply to 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, 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

Change-Id I286c7a2f279cc28375a0c611a490fe7c8f77c08a
---
 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
index 83392ed6a8da9..0466bec6cddcd 100644
@@ -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
index 7ee839dca7f33..8d9381366ceb6 100644
@@ -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_SMB347)	+= smb347-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
#7 lore raw

Re: [PATCH v2 2/2] power: supply: Add driver for TI BQ25630 charger

Quoted 23 lines · On Thu, Jun 18, 2026 at 15:37 +0200 Waqar Hameed <[email protected]> wrote:

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, 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.

Quoted 3 lines

[1] https://www.ti.com/lit/gpn/bq25630

Change-Id: I286c7a2f279cc28375a0c611a490fe7c8f77c08a

Please strip this unnecessary footer...

Quoted 1 line

[...]