Add driver for TI BQ25630 charger
Subsystems (2)
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]). However, some functionality has no straightforward implementation. The following features have therefore been left out and hopefully we can have some design discussions to reach a clear resolution for the next patch version (hence the RFC tag):
1. The USB OTG functionality (i.e. power *out* from the device) would probably need a minor refactorization to use the MFD sub-system to also register a regulator driver. Looking at the bq257xx driver, this should be the preferred design?
2. Other drivers add a custom sysfs attributes for BATFET control. See for example rt9471 and bq24190. Is this the preferred approach? Should we add a new power sysfs class ABI for this? (There is a TODO left in the code for this.)
I reckon it is quite common to have BATFET control for chargers, i.e. being able to set them in "ship mode", "stand-by mode", "shutdown mode" or "idle mode" (example values taken from the BATFET_CTRL register field from datasheet [1])?
3. This device has liquid detection and corrosion mitigation. I couldn't find any existing device driver with this kind of functionality. The datasheet [1] even mentions "patent pending", although it refers to the USB type-C Specification 2.3... :)
When liquid is detected in the charging port, an interrupt is fired. Likewise, an interrupt can be fired when the port is dry enough (according to some configured threshold value). My initial thought was that maybe we can add "liquid detected" to the health sysfs ABI? However, the question still remains though how one should enable/disable and set threshold values for this (new power class sysfs ABI or a custom one only for this driver)?
[1] https://www.ti.com/lit/gpn/bq25630
Waqar Hameed (2):
dt-bindings: power: supply: Add TI BQ25630 charger
power: supply: Add driver for TI BQ25630 charger
.../bindings/power/supply/bq25630.yaml | 68 ++ drivers/power/supply/Kconfig | 7 + drivers/power/supply/Makefile | 1 + drivers/power/supply/bq25630_charger.c | 1074 +++++++++++++++++ 4 files changed, 1150 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq25630.yaml create mode 100644 drivers/power/supply/bq25630_charger.c
base-commit: f4d0ec0aa20d49f09dc01d82894ce80d72de0560
Signature · 1 line
2.39.5
RFC PATCH 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/bq25630.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq25630.yaml
Documentation/devicetree/bindings/power/supply/bq25630.yaml new file +68 -0
@@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/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> + + bat: battery { + compatible = "simple-battery"; + voltage-min-design-microvolt = <1800000>; + constant-charge-current-max-microamp = <1344000>; + constant-charge-voltage-max-microvolt = <3700000>; + charge-term-current-microamp = <128000>; + precharge-current-microamp = <1000000>; + }; + + 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.39.5
Re: [RFC PATCH 1/2] dt-bindings: power: supply: Add TI BQ25630 charger
Documentation/devicetree/bindings/power/supply/bq25630.yaml
Quoted 14 lines · Waqar Hameed
Add devicetree bindings for the TI BQ25630 battery charger. It's I2C controlled and sends interrupts.
Signed-off-by Waqar Hameed <[email protected]>--- .../bindings/power/supply/bq25630.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq25630.yamlDocumentation/devicetree/bindings/power/supply/bq25630.yaml new file +0
-0
Filename is missing "ti," to match the compatible.
Quoted 46 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml new file +45
-0@@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/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: + - |
Documentation/devicetree/bindings/power/supply/bq25630.yaml line 55
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml new file +10
-0+ #include <dt-bindings/interrupt-controller/irq.h> + + bat: battery { + compatible = "simple-battery"; + voltage-min-design-microvolt = <1800000>; + constant-charge-current-max-microamp = <1344000>; + constant-charge-voltage-max-microvolt = <3700000>; + charge-term-current-microamp = <128000>; + precharge-current-microamp = <1000000>; + };
This whole battery node can go, the tooling will falsify the phandle.
I wouldn't ack this anyway cos you're looking for RFC feedback, but the binding looks pretty sane (although when it's simple enough it should!). Marking it cr from a dt pov cos of the filename.
pw-bot: changes-requested
Cheers,
Conor.
Quoted 16 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml new file +13
-0+ + 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.39.5
Re: [RFC PATCH 1/2] dt-bindings: power: supply: Add TI BQ25630 charger
Quoted 10 lines · On Fri, Feb 27, 2026 at 17:31 +0000 Conor Dooley <[email protected]> wrote:
Quoted 9 lines · Waqar Hameed
Add devicetree bindings for the TI BQ25630 battery charger. It's I2C controlled and sends interrupts.
Signed-off-by Waqar Hameed <[email protected]>--- .../bindings/power/supply/bq25630.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq25630.yaml
Quoted 7 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml
Quoted 5 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml new file +0
-0Filename is missing "ti," to match the compatible.
The majority of TI devices in this folder do not contain the ti, prefix, so I just followed that. But I'll make sure to add it in the next version then!
[...]
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml new file +6
-0+examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + bat: battery { + compatible = "simple-battery";
Quoted 8 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml line 55
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml new file +6
-0+ voltage-min-design-microvolt = <1800000>; + constant-charge-current-max-microamp = <1344000>; + constant-charge-voltage-max-microvolt = <3700000>; + charge-term-current-microamp = <128000>; + precharge-current-microamp = <1000000>; + };This whole battery node can go,
Alright, will remove in the next version!
Quoted 1 line
the tooling will falsify the phandle.
I'm guessing you mean that when extracting the example, the insertion of /plugin/ to the *.example.dts-file will "falsify the phandle"?
There are some other examples in this folder that include this node. Not sure if it's worth the churn to fix those as well to help the next person?
[...]
Re: [RFC PATCH 1/2] dt-bindings: power: supply: Add TI BQ25630 charger
Quoted 41 lines · Waqar Hameed
Quoted 10 lines · On Fri, Feb 27, 2026 at 17:31 +0000 Conor Dooley <[email protected]> wrote:
Quoted 9 lines · Waqar Hameed
Add devicetree bindings for the TI BQ25630 battery charger. It's I2C controlled and sends interrupts.
Signed-off-by Waqar Hameed <[email protected]>--- .../bindings/power/supply/bq25630.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq25630.yamlQuoted 7 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml
Quoted 5 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml new file +0
-0Filename is missing "ti," to match the compatible.
The majority of TI devices in this folder do not contain the
ti,prefix, so I just followed that. But I'll make sure to add it in the next version then![...]
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml new file +6
-0+examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + bat: battery { + compatible = "simple-battery";Quoted 8 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml line 55
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/bq25630.yaml new file +6
-0+ voltage-min-design-microvolt = <1800000>; + constant-charge-current-max-microamp = <1344000>; + constant-charge-voltage-max-microvolt = <3700000>; + charge-term-current-microamp = <128000>; + precharge-current-microamp = <1000000>; + };This whole battery node can go,
Quoted 6 lines
Alright, will remove in the next version!
Quoted 1 line
the tooling will falsify the phandle.
I'm guessing you mean that when extracting the example, the insertion of
/plugin/to the*.example.dts-file will "falsify the phandle"?
I'll be honest, I don't know exactly what the mechanism is that fakes the phandles, but it means that any sort of generic device doesn't need to be included in the example.
Quoted 3 lines
There are some other examples in this folder that include this node. Not sure if it's worth the churn to fix those as well to help the next person?
Probably isn't worth the churn /shrug
Re: [RFC PATCH 1/2] dt-bindings: power: supply: Add TI BQ25630 charger
Quoted 1 line · On Mon, Mar 02, 2026 at 17:47 +0000 Conor Dooley <[email protected]> wrote:
On Mon, Mar 02, 2026 at 02:44:19PM +0100, Waqar Hameed wrote:
[...]
Quoted 6 lines
Quoted 2 lines
I'm guessing you mean that when extracting the example, the insertion of
/plugin/to the*.example.dts-file will "falsify the phandle"?I'll be honest, I don't know exactly what the mechanism is that fakes the phandles, but it means that any sort of generic device doesn't need to be included in the example.
Haha alright. I appreciate the honesty :)
I'll stick to my explanation for now then, since it makes sense for me at least (someone otherwise please correct me).
Quoted 6 lines
Quoted 4 lines
There are some other examples in this folder that include this node. Not sure if it's worth the churn to fix those as well to help the next person?
Probably isn't worth the churn /shrug
Alright, let's leave it then.
RFC PATCH 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 | 1074 ++++++++++++++++++++++++ 3 files changed, 1082 insertions(+) create mode 100644 drivers/power/supply/bq25630_charger.c
drivers/power/supply/Kconfig +7 -0
@@ -817,6 +817,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
@@ -104,6 +104,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 +1074 -0
1,074 lines not on this page · raw message
Signature · 1 line
2.39.5
Quoted 35 lines · On Fri, Feb 27, 2026 at 16:35 +0100 Waqar Hameed <[email protected]> wrote:
This patch series contains a fully working driver for the basic functionality for the new TI BQ25630 charger (see datasheet [1]). However, some functionality has no straightforward implementation. The following features have therefore been left out and hopefully we can have some design discussions to reach a clear resolution for the next patch version (hence the RFC tag):
1. The USB OTG functionality (i.e. power *out* from the device) would probably need a minor refactorization to use the MFD sub-system to also register a regulator driver. Looking at the bq257xx driver, this should be the preferred design?
2. Other drivers add a custom
sysfsattributes for BATFET control. See for example rt9471 and bq24190. Is this the preferred approach? Should we add a new powersysfsclass ABI for this? (There is a TODO left in the code for this.)I reckon it is quite common to have BATFET control for chargers, i.e. being able to set them in "ship mode", "stand-by mode", "shutdown mode" or "idle mode" (example values taken from the
BATFET_CTRLregister field from datasheet [1])?3. This device has liquid detection and corrosion mitigation. I couldn't find any existing device driver with this kind of functionality. The datasheet [1] even mentions "patent pending", although it refers to the USB type-C Specification 2.3... :)
When liquid is detected in the charging port, an interrupt is fired. Likewise, an interrupt can be fired when the port is dry enough (according to some configured threshold value). My initial thought was that maybe we can add "liquid detected" to the
healthsysfsABI? However, the question still remains though how one should enable/disable and set threshold values for this (new power classsysfsABI or a custom one only for this driver)?
Quoted 1 line
[...]
Friendly ping incoming!
Hi,
Quoted 3 lines · Waqar Hameed
Quoted 2 lines · On Fri, Feb 27, 2026 at 16:35 +0100 Waqar Hameed <[email protected]> wrote:
This patch series contains a fully working driver for the basic functionality for the new TI BQ25630 charger (see datasheet [1]).
Driver itself LGTM. I think it would be sensible to merge that while the extra features are being prepared, but the DT binding must be fixed first :)
Quoted 9 lines
Quoted 9 lines
However, some functionality has no straightforward implementation. The following features have therefore been left out and hopefully we can have some design discussions to reach a clear resolution for the next patch version (hence the RFC tag):
1. The USB OTG functionality (i.e. power *out* from the device) would probably need a minor refactorization to use the MFD sub-system to also register a regulator driver. Looking at the bq257xx driver, this should be the preferred design?
If the regulator is the only part making this a MFD, just create it in the charger driver itself. There are a few examples, just grep for 'struct regulator_ops' in drivers/power/supply.
Quoted 9 lines
Quoted 9 lines
2. Other drivers add a custom
sysfsattributes for BATFET control. See for example rt9471 and bq24190. Is this the preferred approach? Should we add a new powersysfsclass ABI for this? (There is a TODO left in the code for this.)I reckon it is quite common to have BATFET control for chargers, i.e. being able to set them in "ship mode", "stand-by mode", "shutdown mode" or "idle mode" (example values taken from the
BATFET_CTRLregister field from datasheet [1])?
Yes. I usually ask to use custom properties until there are a few users to avoid cluttering the general ABI. I think BATFET is a good candidate. Please add a new property for that one.
Quoted 4 lines
Quoted 4 lines
3. This device has liquid detection and corrosion mitigation. I couldn't find any existing device driver with this kind of functionality. The datasheet [1] even mentions "patent pending", although it refers to the USB type-C Specification 2.3... :)
This is something I also expect to see in more devices; I know a couple of Android devices offer this. But indeed nothing has been submitted so far.
Quoted 5 lines
Quoted 5 lines
When liquid is detected in the charging port, an interrupt is fired. Likewise, an interrupt can be fired when the port is dry enough (according to some configured threshold value). My initial thought was that maybe we can add "liquid detected" to the
healthsysfsABI?
Sounds good to me.
Quoted 5 lines
Quoted 5 lines
However, the question still remains though how one should enable/disable and set threshold values for this (new power class
sysfsABI or a custom one only for this driver)?
I had a quick look at the datasheet. I think a new standard property would be sensible:
LIQUID_DETECTION_CONTROL with possible values
off = Not liquid detection is being performed
auto = Periodic liquid detection checks are being done once = Writing this will perform a single check (and return to off)
For the other controls I'm not sure how generalized they are. E.g. for TLQD and ILQD it offers 4 steps, but not explicit current (seconds and amps). OTOH for the voltage explicit values are listed. Maybe just leave them to the default until somebody actually need this configurable?
Quoted 1 line
Friendly ping incoming!
Sorry for being slow with reviews, I was quite busy and out of office in the whole May. I suggest that the 3 things are being send on top of the updaed base driver :)
Greetings,
-- Sebastian
Quoted 1 line · On Tue, Jun 02, 2026 at 18:17 +0200 Sebastian Reichel…
On Wed, May 20, 2026 at 05:49:38PM +0200, Waqar Hameed wrote:
[...]
Quoted 3 lines
Driver itself LGTM. I think it would be sensible to merge that while the extra features are being prepared, but the DT binding must be fixed first :)
Sounds reasonable! I'm doing a thorough testing of this right now (with some minor issues found) and will send an updated version of that soon so we can have the base functionality merged.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
However, some functionality has no straightforward implementation. The following features have therefore been left out and hopefully we can have some design discussions to reach a clear resolution for the next patch version (hence the RFC tag):
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
1. The USB OTG functionality (i.e. power *out* from the device) would probably need a minor refactorization to use the MFD sub-system to also register a regulator driver. Looking at the bq257xx driver, this should be the preferred design?
If the regulator is the only part making this a MFD, just create it in the charger driver itself. There are a few examples, just grep for 'struct
regulator_ops' indrivers/power/supply.
Alright, will do that!
Quoted 24 lines
Quoted 10 lines
Quoted 10 lines
2. Other drivers add a custom
sysfsattributes for BATFET control. See for example rt9471 and bq24190. Is this the preferred approach? Should we add a new powersysfsclass ABI for this? (There is a TODO left in the code for this.)I reckon it is quite common to have BATFET control for chargers, i.e. being able to set them in "ship mode", "stand-by mode", "shutdown mode" or "idle mode" (example values taken from the
BATFET_CTRLregister field from datasheet [1])?Yes. I usually ask to use custom properties until there are a few users to avoid cluttering the general ABI. I think BATFET is a good candidate. Please add a new property for that one.
Quoted 4 lines
Quoted 4 lines
3. This device has liquid detection and corrosion mitigation. I couldn't find any existing device driver with this kind of functionality. The datasheet [1] even mentions "patent pending", although it refers to the USB type-C Specification 2.3... :)
This is something I also expect to see in more devices; I know a couple of Android devices offer this. But indeed nothing has been submitted so far.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
When liquid is detected in the charging port, an interrupt is fired. Likewise, an interrupt can be fired when the port is dry enough (according to some configured threshold value). My initial thought was that maybe we can add "liquid detected" to the
healthsysfsABI?Sounds good to me.
I'll send these as separate patches then.
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
However, the question still remains though how one should enable/disable and set threshold values for this (new power class
sysfsABI or a custom one only for this driver)?
Quoted 7 lines
I had a quick look at the datasheet. I think a new standard property would be sensible:
LIQUID_DETECTION_CONTROLwith possible values
off = Not liquid detection is being performed
auto = Periodic liquid detection checks are being done once = Writing this will perform a single check (and return to off)
I think this sounds reasonable. Most future devices (if not all?) would probably be covered with these three states.
Quoted 6 lines
For the other controls I'm not sure how generalized they are. E.g. for TLQD and ILQD it offers 4 steps, but not explicit current (seconds and amps). OTOH for the voltage explicit values are listed. Maybe just leave them to the default until somebody actually need this configurable?
The USB specification actually lists several different methods [1]. I agree that the wisest right now is to just leave this and wait for more data points (from how other devices will expose this).
Quoted 5 lines
Quoted 2 lines
Friendly ping incoming!
Sorry for being slow with reviews, I was quite busy and out of office in the whole May.
No worries! I know how the workload can be as a maintainer (especially if you're all by yourself). Thank you for taking your time! :)
Quoted 2 lines
I suggest that the 3 things are being send on top of the updaed base driver :)
Yes, let's do baby steps here and merge base functionality first (as discussed above) before adding all these extra features.
[1] USB Type-C Spec R2.4 - October 2024.pdf, A.3, p. 351. https://usb.org/sites/default/files/USB%20Type-C%202.4%20Release%20202410.zip