* [PATCH v3 1/3] dt-bindings: power: supply: bq27xxx: add generic compatible
2026-09-09 23:47 ` [PATCH v3 0/3] bq27xxx: support interchangeable OnePlus 6/6T fuel gauges Rinat Muhamedgaliev
@ 2026-09-09 23:47 ` Rinat Muhamedgaliev
2026-09-11 8:20 ` Krzysztof Kozlowski
2026-09-09 23:47 ` [PATCH v3 2/3] power: supply: bq27xxx: autodetect bq27411 and bq27541 Rinat Muhamedgaliev
` (2 subsequent siblings)
3 siblings, 1 reply; 21+ messages in thread
From: Rinat Muhamedgaliev @ 2026-09-09 23:47 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Sebastian Reichel
Cc: David Heidelberg, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, Andrew F . Davis, linux-arm-msm, devicetree,
linux-pm, linux-kernel, Rinat Muhamedgaliev
Add a generic compatible for I2C fuel gauges whose device type is
determined at probe time.
Signed-off-by: Rinat Muhamedgaliev <rinat.muhamedgaliev@gmail.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 bc05400..f2e0170 100644
--- a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
+++ b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
@@ -21,6 +21,7 @@ properties:
enum:
- ti,bq27200
- ti,bq27210
+ - ti,bq27xxx
- ti,bq27500 # deprecated, use revision specific property below
- ti,bq27510 # deprecated, use revision specific property below
- ti,bq27520 # deprecated, use revision specific property below
--
2.55.0
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH v3 1/3] dt-bindings: power: supply: bq27xxx: add generic compatible
2026-09-09 23:47 ` [PATCH v3 1/3] dt-bindings: power: supply: bq27xxx: add generic compatible Rinat Muhamedgaliev
@ 2026-09-11 8:20 ` Krzysztof Kozlowski
0 siblings, 0 replies; 21+ messages in thread
From: Krzysztof Kozlowski @ 2026-09-11 8:20 UTC (permalink / raw)
To: Rinat Muhamedgaliev
Cc: Bjorn Andersson, Konrad Dybcio, Sebastian Reichel,
David Heidelberg, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, Andrew F . Davis, linux-arm-msm, devicetree,
linux-pm, linux-kernel
On Thu, Sep 10, 2026 at 02:47:42AM +0300, Rinat Muhamedgaliev wrote:
> Add a generic compatible for I2C fuel gauges whose device type is
> determined at probe time.
Generic compatibles are not allowed. Existing ones should be used.
Do not attach (thread) your patchsets to some other threads (unrelated
or older versions). This buries them deep in the mailbox and might
interfere with applying entire sets. See also:
https://elixir.bootlin.com/linux/v6.16-rc2/source/Documentation/process/submitting-patches.rst#L830
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 2/3] power: supply: bq27xxx: autodetect bq27411 and bq27541
2026-09-09 23:47 ` [PATCH v3 0/3] bq27xxx: support interchangeable OnePlus 6/6T fuel gauges Rinat Muhamedgaliev
2026-09-09 23:47 ` [PATCH v3 1/3] dt-bindings: power: supply: bq27xxx: add generic compatible Rinat Muhamedgaliev
@ 2026-09-09 23:47 ` Rinat Muhamedgaliev
2026-09-10 0:09 ` David Heidelberg
2026-09-10 7:42 ` Konrad Dybcio
2026-09-09 23:47 ` [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible Rinat Muhamedgaliev
2026-09-10 0:08 ` [PATCH v3 0/3] bq27xxx: support interchangeable OnePlus 6/6T fuel gauges David Heidelberg
3 siblings, 2 replies; 21+ messages in thread
From: Rinat Muhamedgaliev @ 2026-09-09 23:47 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Sebastian Reichel
Cc: David Heidelberg, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, Andrew F . Davis, linux-arm-msm, devicetree,
linux-pm, linux-kernel, Rinat Muhamedgaliev
Some replaceable battery packs used by OnePlus 6 and OnePlus 6T
phones contain a bq27411, while others contain a bq27541. These
devices require different register maps.
Add support for the generic ti,bq27xxx compatible. At probe time,
issue the DeviceType control command and select the bq27411 or bq27541
register map from the returned value.
Signed-off-by: Rinat Muhamedgaliev <rinat.muhamedgaliev@gmail.com>
---
drivers/power/supply/bq27xxx_battery_i2c.c | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index 868e95f..718f8e8 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -16,6 +16,11 @@
static DEFINE_IDA(battery_id);
+#define BQ27XXX_REG_CTRL 0x00
+#define BQ27XXX_DEVICE_TYPE 0x0001
+#define BQ27411_DEVICE_TYPE 0x0421
+#define BQ27541_DEVICE_TYPE 0x0541
+
static irqreturn_t bq27xxx_battery_irq_handler_thread(int irq, void *data)
{
struct bq27xxx_device_info *di = data;
@@ -153,6 +158,32 @@ static void bq27xxx_battery_i2c_devm_ida_free(void *data)
ida_free(&battery_id, num);
}
+static int bq27xxx_battery_i2c_detect_chip(struct bq27xxx_device_info *di)
+{
+ int ret;
+
+ ret = di->bus.write(di, BQ27XXX_REG_CTRL, BQ27XXX_DEVICE_TYPE,
+ false);
+ if (ret < 0)
+ return ret;
+
+ ret = di->bus.read(di, BQ27XXX_REG_CTRL, false);
+ if (ret < 0)
+ return ret;
+
+ switch (ret) {
+ case BQ27411_DEVICE_TYPE:
+ di->chip = BQ27411;
+ return 0;
+ case BQ27541_DEVICE_TYPE:
+ di->chip = BQ27541;
+ return 0;
+ default:
+ dev_err(di->dev, "unsupported device type 0x%04x\n", ret);
+ return -ENODEV;
+ }
+}
+
static int bq27xxx_battery_i2c_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
@@ -188,6 +219,12 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client)
di->bus.read_bulk = bq27xxx_battery_i2c_bulk_read;
di->bus.write_bulk = bq27xxx_battery_i2c_bulk_write;
+ if (!di->chip) {
+ ret = bq27xxx_battery_i2c_detect_chip(di);
+ if (ret)
+ return ret;
+ }
+
ret = bq27xxx_battery_setup(di);
if (ret)
return ret;
@@ -225,6 +262,7 @@ static void bq27xxx_battery_i2c_remove(struct i2c_client *client)
}
static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
+ { "bq27xxx", 0 },
{ "bq27200", BQ27000 },
{ "bq27210", BQ27010 },
{ "bq27500", BQ2750X },
@@ -262,6 +300,7 @@ MODULE_DEVICE_TABLE(i2c, bq27xxx_i2c_id_table);
#ifdef CONFIG_OF
static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
+ { .compatible = "ti,bq27xxx" },
{ .compatible = "ti,bq27200" },
{ .compatible = "ti,bq27210" },
{ .compatible = "ti,bq27500" },
--
2.55.0
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH v3 2/3] power: supply: bq27xxx: autodetect bq27411 and bq27541
2026-09-09 23:47 ` [PATCH v3 2/3] power: supply: bq27xxx: autodetect bq27411 and bq27541 Rinat Muhamedgaliev
@ 2026-09-10 0:09 ` David Heidelberg
2026-09-10 7:42 ` Konrad Dybcio
1 sibling, 0 replies; 21+ messages in thread
From: David Heidelberg @ 2026-09-10 0:09 UTC (permalink / raw)
To: Rinat Muhamedgaliev, Bjorn Andersson, Konrad Dybcio,
Sebastian Reichel
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Pali Rohár,
Andrew F . Davis, linux-arm-msm, devicetree, linux-pm,
linux-kernel
On 10/09/2026 01:47, Rinat Muhamedgaliev wrote:
> Some replaceable battery packs used by OnePlus 6 and OnePlus 6T
> phones contain a bq27411, while others contain a bq27541. These
> devices require different register maps.
>
> Add support for the generic ti,bq27xxx compatible. At probe time,
> issue the DeviceType control command and select the bq27411 or bq27541
> register map from the returned value.
>
> Signed-off-by: Rinat Muhamedgaliev <rinat.muhamedgaliev@gmail.com>
> ---
> drivers/power/supply/bq27xxx_battery_i2c.c | 39 ++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
> index 868e95f..718f8e8 100644
> --- a/drivers/power/supply/bq27xxx_battery_i2c.c
> +++ b/drivers/power/supply/bq27xxx_battery_i2c.c
> @@ -16,6 +16,11 @@
>
> static DEFINE_IDA(battery_id);
>
> +#define BQ27XXX_REG_CTRL 0x00
> +#define BQ27XXX_DEVICE_TYPE 0x0001
> +#define BQ27411_DEVICE_TYPE 0x0421
> +#define BQ27541_DEVICE_TYPE 0x0541
> +
> static irqreturn_t bq27xxx_battery_irq_handler_thread(int irq, void *data)
> {
> struct bq27xxx_device_info *di = data;
> @@ -153,6 +158,32 @@ static void bq27xxx_battery_i2c_devm_ida_free(void *data)
> ida_free(&battery_id, num);
> }
>
> +static int bq27xxx_battery_i2c_detect_chip(struct bq27xxx_device_info *di)
> +{
> + int ret;
> +
> + ret = di->bus.write(di, BQ27XXX_REG_CTRL, BQ27XXX_DEVICE_TYPE,
> + false);
> + if (ret < 0)
> + return ret;
> +
> + ret = di->bus.read(di, BQ27XXX_REG_CTRL, false);
> + if (ret < 0)
> + return ret;
> +
> + switch (ret) {
> + case BQ27411_DEVICE_TYPE:
> + di->chip = BQ27411;
> + return 0;
> + case BQ27541_DEVICE_TYPE:
> + di->chip = BQ27541;
> + return 0;
> + default:
> + dev_err(di->dev, "unsupported device type 0x%04x\n", ret);
> + return -ENODEV;
> + }
> +}
> +
> static int bq27xxx_battery_i2c_probe(struct i2c_client *client)
> {
> const struct i2c_device_id *id = i2c_client_get_device_id(client);
> @@ -188,6 +219,12 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client)
> di->bus.read_bulk = bq27xxx_battery_i2c_bulk_read;
> di->bus.write_bulk = bq27xxx_battery_i2c_bulk_write;
>
> + if (!di->chip) {
> + ret = bq27xxx_battery_i2c_detect_chip(di);
> + if (ret)
> + return ret;
> + }
> +
> ret = bq27xxx_battery_setup(di);
> if (ret)
> return ret;
> @@ -225,6 +262,7 @@ static void bq27xxx_battery_i2c_remove(struct i2c_client *client)
> }
>
> static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
> + { "bq27xxx", 0 },
> { "bq27200", BQ27000 },
> { "bq27210", BQ27010 },
> { "bq27500", BQ2750X },
> @@ -262,6 +300,7 @@ MODULE_DEVICE_TABLE(i2c, bq27xxx_i2c_id_table);
>
> #ifdef CONFIG_OF
> static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
> + { .compatible = "ti,bq27xxx" },
Maybe some comment suggesting to use this compatible when autodetection is needed?
David
> { .compatible = "ti,bq27200" },
> { .compatible = "ti,bq27210" },
> { .compatible = "ti,bq27500" },
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 2/3] power: supply: bq27xxx: autodetect bq27411 and bq27541
2026-09-09 23:47 ` [PATCH v3 2/3] power: supply: bq27xxx: autodetect bq27411 and bq27541 Rinat Muhamedgaliev
2026-09-10 0:09 ` David Heidelberg
@ 2026-09-10 7:42 ` Konrad Dybcio
1 sibling, 0 replies; 21+ messages in thread
From: Konrad Dybcio @ 2026-09-10 7:42 UTC (permalink / raw)
To: Rinat Muhamedgaliev, Bjorn Andersson, Konrad Dybcio,
Sebastian Reichel
Cc: David Heidelberg, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, Andrew F . Davis, linux-arm-msm, devicetree,
linux-pm, linux-kernel
On 9/10/26 1:47 AM, Rinat Muhamedgaliev wrote:
> Some replaceable battery packs used by OnePlus 6 and OnePlus 6T
> phones contain a bq27411, while others contain a bq27541. These
> devices require different register maps.
>
> Add support for the generic ti,bq27xxx compatible. At probe time,
> issue the DeviceType control command and select the bq27411 or bq27541
> register map from the returned value.
>
> Signed-off-by: Rinat Muhamedgaliev <rinat.muhamedgaliev@gmail.com>
> ---
[...]
First off, please don't send new revisions as a reply to the
previous one, this creates very messy thread structures and confuses
tooling. You may use the b4 tool for easy management:
https://b4.docs.kernel.org/en/latest/
> static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
> + { "bq27xxx", 0 },
> { "bq27200", BQ27000 },
> { "bq27210", BQ27010 },
> { "bq27500", BQ2750X },
> @@ -262,6 +300,7 @@ MODULE_DEVICE_TABLE(i2c, bq27xxx_i2c_id_table);
>
> #ifdef CONFIG_OF
> static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = {
> + { .compatible = "ti,bq27xxx" },
I don't think we need a new compatible here, especially given wildcard
compatibles are very much not going to be accepted by the dt folks.
I think it's fine to add a chip_id readback mechanism that would be in
place regardless of the compatible and would say something to the lines
of: "detected another chip, proceeding based on chip_id"
Konrad
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible
2026-09-09 23:47 ` [PATCH v3 0/3] bq27xxx: support interchangeable OnePlus 6/6T fuel gauges Rinat Muhamedgaliev
2026-09-09 23:47 ` [PATCH v3 1/3] dt-bindings: power: supply: bq27xxx: add generic compatible Rinat Muhamedgaliev
2026-09-09 23:47 ` [PATCH v3 2/3] power: supply: bq27xxx: autodetect bq27411 and bq27541 Rinat Muhamedgaliev
@ 2026-09-09 23:47 ` Rinat Muhamedgaliev
2026-09-10 0:12 ` David Heidelberg
2026-09-11 8:21 ` Krzysztof Kozlowski
2026-09-10 0:08 ` [PATCH v3 0/3] bq27xxx: support interchangeable OnePlus 6/6T fuel gauges David Heidelberg
3 siblings, 2 replies; 21+ messages in thread
From: Rinat Muhamedgaliev @ 2026-09-09 23:47 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Sebastian Reichel
Cc: David Heidelberg, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, Andrew F . Davis, linux-arm-msm, devicetree,
linux-pm, linux-kernel, Rinat Muhamedgaliev
OnePlus 6 and OnePlus 6T battery packs may contain either a TI
bq27411 or bq27541 fuel gauge. Use the generic ti,bq27xxx compatible
so the driver can select the register map from DeviceType at probe
time.
Tested on OnePlus 6T (fajita) with a bq27541 (DeviceType 0x0541):
after booting the new kernel, the battery reported 4.360 V, 100% state
of charge, 27.8 C, and Full status.
Fixes: 12dfb002ca01 ("arm64: dts: qcom: sdm845-oneplus-*: add fuel gauge")
Signed-off-by: Rinat Muhamedgaliev <rinat.muhamedgaliev@gmail.com>
---
arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi | 4 ++--
arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts | 2 +-
arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
index 948a0dd..8c5cd94 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
@@ -790,8 +790,8 @@ &i2c10 {
status = "okay";
clock-frequency = <100000>;
- bq27441_fg: bq27441-battery@55 {
- compatible = "ti,bq27411";
+ bq27xxx_fg: fuel-gauge@55 {
+ compatible = "ti,bq27xxx";
status = "okay";
reg = <0x55>;
};
diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts b/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
index 5f01115..cf40842 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
@@ -44,7 +44,7 @@ main_cam_ois: main-cam-ois-regulator {
};
};
-&bq27441_fg {
+&bq27xxx_fg {
monitored-battery = <&battery>;
};
diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts b/arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts
index 7ffcad2..9436027 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts
+++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts
@@ -67,7 +67,7 @@ tfa9894_codec: tfa9894@34 {
};
-&bq27441_fg {
+&bq27xxx_fg {
monitored-battery = <&battery>;
};
--
2.55.0
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible
2026-09-09 23:47 ` [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible Rinat Muhamedgaliev
@ 2026-09-10 0:12 ` David Heidelberg
2026-09-11 8:21 ` Krzysztof Kozlowski
1 sibling, 0 replies; 21+ messages in thread
From: David Heidelberg @ 2026-09-10 0:12 UTC (permalink / raw)
To: Rinat Muhamedgaliev, Bjorn Andersson, Konrad Dybcio,
Sebastian Reichel
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Pali Rohár,
Andrew F . Davis, linux-arm-msm, devicetree, linux-pm,
linux-kernel
On 10/09/2026 01:47, Rinat Muhamedgaliev wrote:
> OnePlus 6 and OnePlus 6T battery packs may contain either a TI
> bq27411 or bq27541 fuel gauge. Use the generic ti,bq27xxx compatible
> so the driver can select the register map from DeviceType at probe
> time.
>
> Tested on OnePlus 6T (fajita) with a bq27541 (DeviceType 0x0541):
> after booting the new kernel, the battery reported 4.360 V, 100% state
> of charge, 27.8 C, and Full status.
>
> Fixes: 12dfb002ca01 ("arm64: dts: qcom: sdm845-oneplus-*: add fuel gauge")
>
> Signed-off-by: Rinat Muhamedgaliev <rinat.muhamedgaliev@gmail.com>
> ---
> arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi | 4 ++--
> arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts | 2 +-
> arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
> index 948a0dd..8c5cd94 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
> @@ -790,8 +790,8 @@ &i2c10 {
> status = "okay";
> clock-frequency = <100000>;
>
> - bq27441_fg: bq27441-battery@55 {
> - compatible = "ti,bq27411";
> + bq27xxx_fg: fuel-gauge@55 {
> + compatible = "ti,bq27xxx";
For new driver this would make definitely sense, but since we need backwards
compatibility (someone use new device-tree, but the old driver) you want to do
compatible = "ti,bq27xxx", "ti,bq27411";
here. The 27xxx will get evaluated first, if not available fallback to existing
driver.
> status = "okay";
> reg = <0x55>;
> };
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts b/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
> index 5f01115..cf40842 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
> @@ -44,7 +44,7 @@ main_cam_ois: main-cam-ois-regulator {
> };
> };
>
> -&bq27441_fg {
> +&bq27xxx_fg {
> monitored-battery = <&battery>;
> };
>
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts b/arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts
> index 7ffcad2..9436027 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts
> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts
> @@ -67,7 +67,7 @@ tfa9894_codec: tfa9894@34 {
>
> };
>
> -&bq27441_fg {
> +&bq27xxx_fg {
> monitored-battery = <&battery>;
> };
>
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible
2026-09-09 23:47 ` [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible Rinat Muhamedgaliev
2026-09-10 0:12 ` David Heidelberg
@ 2026-09-11 8:21 ` Krzysztof Kozlowski
2026-09-11 13:37 ` Andrew Davis
1 sibling, 1 reply; 21+ messages in thread
From: Krzysztof Kozlowski @ 2026-09-11 8:21 UTC (permalink / raw)
To: Rinat Muhamedgaliev
Cc: Bjorn Andersson, Konrad Dybcio, Sebastian Reichel,
David Heidelberg, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, Andrew F . Davis, linux-arm-msm, devicetree,
linux-pm, linux-kernel
On Thu, Sep 10, 2026 at 02:47:44AM +0300, Rinat Muhamedgaliev wrote:
> OnePlus 6 and OnePlus 6T battery packs may contain either a TI
> bq27411 or bq27541 fuel gauge. Use the generic ti,bq27xxx compatible
> so the driver can select the register map from DeviceType at probe
> time.
>
> Tested on OnePlus 6T (fajita) with a bq27541 (DeviceType 0x0541):
> after booting the new kernel, the battery reported 4.360 V, 100% state
> of charge, 27.8 C, and Full status.
>
> Fixes: 12dfb002ca01 ("arm64: dts: qcom: sdm845-oneplus-*: add fuel gauge")
What is the bug here? Your commit msg should be specific about it.
>
> Signed-off-by: Rinat Muhamedgaliev <rinat.muhamedgaliev@gmail.com>
> ---
> arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi | 4 ++--
> arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts | 2 +-
> arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
> index 948a0dd..8c5cd94 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
> @@ -790,8 +790,8 @@ &i2c10 {
> status = "okay";
> clock-frequency = <100000>;
>
> - bq27441_fg: bq27441-battery@55 {
> - compatible = "ti,bq27411";
> + bq27xxx_fg: fuel-gauge@55 {
> + compatible = "ti,bq27xxx";
And this is just breaking all users without any explanation.
> status = "okay";
> reg = <0x55>;
> };
> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts b/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
> index 5f01115..cf40842 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
> @@ -44,7 +44,7 @@ main_cam_ois: main-cam-ois-regulator {
> };
> };
>
> -&bq27441_fg {
> +&bq27xxx_fg {
No, irrelevant to the supposed bug here.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible
2026-09-11 8:21 ` Krzysztof Kozlowski
@ 2026-09-11 13:37 ` Andrew Davis
2026-09-11 18:41 ` David Heidelberg
` (2 more replies)
0 siblings, 3 replies; 21+ messages in thread
From: Andrew Davis @ 2026-09-11 13:37 UTC (permalink / raw)
To: Krzysztof Kozlowski, Rinat Muhamedgaliev
Cc: Bjorn Andersson, Konrad Dybcio, Sebastian Reichel,
David Heidelberg, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, linux-arm-msm, devicetree, linux-pm,
linux-kernel
On 9/11/26 3:21 AM, Krzysztof Kozlowski wrote:
> On Thu, Sep 10, 2026 at 02:47:44AM +0300, Rinat Muhamedgaliev wrote:
>> OnePlus 6 and OnePlus 6T battery packs may contain either a TI
>> bq27411 or bq27541 fuel gauge. Use the generic ti,bq27xxx compatible
>> so the driver can select the register map from DeviceType at probe
>> time.
>>
>> Tested on OnePlus 6T (fajita) with a bq27541 (DeviceType 0x0541):
>> after booting the new kernel, the battery reported 4.360 V, 100% state
>> of charge, 27.8 C, and Full status.
>>
>> Fixes: 12dfb002ca01 ("arm64: dts: qcom: sdm845-oneplus-*: add fuel gauge")
>
> What is the bug here? Your commit msg should be specific about it.
>
Commit msg seems pretty clear about the bug (to me at least), the DT
says the fuel gauge is a BQ27411 but that isn't the case, some shipped
with a BQ27541 fuel gauge.
(I do agree though this shouldn't have a fixes tag as back-porting this
without also back-porting the driver-side change would break users)
Since these fuel gauges often live on the battery pack and not the
device itself, folks changing their batteries might end up with
different fuel gauges, so having some detection method is going to
be helpful.
Rinat,
I'm not familiar with the bootflow on these devices, but is this something
you could detect in the bootloader and fixup the DT before it is passed
to kernel? That way the kernel gets a DT with the correct and specific
compatible to start with?
Andrew
>>
>> Signed-off-by: Rinat Muhamedgaliev <rinat.muhamedgaliev@gmail.com>
>> ---
>> arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi | 4 ++--
>> arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts | 2 +-
>> arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts | 2 +-
>> 3 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
>> index 948a0dd..8c5cd94 100644
>> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
>> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
>> @@ -790,8 +790,8 @@ &i2c10 {
>> status = "okay";
>> clock-frequency = <100000>;
>>
>> - bq27441_fg: bq27441-battery@55 {
>> - compatible = "ti,bq27411";
>> + bq27xxx_fg: fuel-gauge@55 {
>> + compatible = "ti,bq27xxx";
>
> And this is just breaking all users without any explanation.
>
>
>
>> status = "okay";
>> reg = <0x55>;
>> };
>> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts b/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
>> index 5f01115..cf40842 100644
>> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
>> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
>> @@ -44,7 +44,7 @@ main_cam_ois: main-cam-ois-regulator {
>> };
>> };
>>
>> -&bq27441_fg {
>> +&bq27xxx_fg {
>
> No, irrelevant to the supposed bug here.
>
> Best regards,
> Krzysztof
>
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible
2026-09-11 13:37 ` Andrew Davis
@ 2026-09-11 18:41 ` David Heidelberg
2026-09-11 20:00 ` David Heidelberg
2026-09-12 7:47 ` Krzysztof Kozlowski
2 siblings, 0 replies; 21+ messages in thread
From: David Heidelberg @ 2026-09-11 18:41 UTC (permalink / raw)
To: Andrew Davis, Krzysztof Kozlowski, Rinat Muhamedgaliev
Cc: Bjorn Andersson, Konrad Dybcio, Sebastian Reichel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Pali Rohár, linux-arm-msm,
devicetree, linux-pm, linux-kernel
On 11/09/2026 15:37, Andrew Davis wrote:
> On 9/11/26 3:21 AM, Krzysztof Kozlowski wrote:
>> On Thu, Sep 10, 2026 at 02:47:44AM +0300, Rinat Muhamedgaliev wrote:
>>> OnePlus 6 and OnePlus 6T battery packs may contain either a TI
>>> bq27411 or bq27541 fuel gauge. Use the generic ti,bq27xxx compatible
>>> so the driver can select the register map from DeviceType at probe
>>> time.
>>>
>>> Tested on OnePlus 6T (fajita) with a bq27541 (DeviceType 0x0541):
>>> after booting the new kernel, the battery reported 4.360 V, 100% state
>>> of charge, 27.8 C, and Full status.
>>>
>>> Fixes: 12dfb002ca01 ("arm64: dts: qcom: sdm845-oneplus-*: add fuel gauge")
>>
>> What is the bug here? Your commit msg should be specific about it.
>>
>
> Commit msg seems pretty clear about the bug (to me at least), the DT
> says the fuel gauge is a BQ27411 but that isn't the case, some shipped
> with a BQ27541 fuel gauge.
>
> (I do agree though this shouldn't have a fixes tag as back-porting this
> without also back-porting the driver-side change would break users)
>
> Since these fuel gauges often live on the battery pack and not the
> device itself, folks changing their batteries might end up with
> different fuel gauges, so having some detection method is going to
> be helpful.
>
> Rinat,
>
> I'm not familiar with the bootflow on these devices, but is this something
> you could detect in the bootloader and fixup the DT before it is passed
> to kernel? That way the kernel gets a DT with the correct and specific
> compatible to start with?
>
> Andrew
>
>>>
>>> Signed-off-by: Rinat Muhamedgaliev <rinat.muhamedgaliev@gmail.com>
>>> ---
>>> arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi | 4 ++--
>>> arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts | 2 +-
>>> arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts | 2 +-
>>> 3 files changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi b/arch/
>>> arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
>>> index 948a0dd..8c5cd94 100644
>>> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
>>> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
>>> @@ -790,8 +790,8 @@ &i2c10 {
>>> status = "okay";
>>> clock-frequency = <100000>;
>>> - bq27441_fg: bq27441-battery@55 {
>>> - compatible = "ti,bq27411";
>>> + bq27xxx_fg: fuel-gauge@55 {
>>> + compatible = "ti,bq27xxx";
>>
>> And this is just breaking all users without any explanation.
>>
>>
>>
>>> status = "okay";
>>> reg = <0x55>;
>>> };
>>> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts b/arch/
>>> arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
>>> index 5f01115..cf40842 100644
>>> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
>>> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
>>> @@ -44,7 +44,7 @@ main_cam_ois: main-cam-ois-regulator {
>>> };
>>> };
>>> -&bq27441_fg {
>>> +&bq27xxx_fg {
>>
>> No, irrelevant to the supposed bug here.
>>
>> Best regards,
>> Krzysztof
>>
>
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible
2026-09-11 13:37 ` Andrew Davis
2026-09-11 18:41 ` David Heidelberg
@ 2026-09-11 20:00 ` David Heidelberg
2026-09-12 7:47 ` Krzysztof Kozlowski
2 siblings, 0 replies; 21+ messages in thread
From: David Heidelberg @ 2026-09-11 20:00 UTC (permalink / raw)
To: Andrew Davis, Krzysztof Kozlowski, Rinat Muhamedgaliev
Cc: Bjorn Andersson, Konrad Dybcio, Sebastian Reichel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Pali Rohár, linux-arm-msm,
devicetree, linux-pm, linux-kernel
On 11/09/2026 15:37, Andrew Davis wrote:
> On 9/11/26 3:21 AM, Krzysztof Kozlowski wrote:
>> On Thu, Sep 10, 2026 at 02:47:44AM +0300, Rinat Muhamedgaliev wrote:
>>> OnePlus 6 and OnePlus 6T battery packs may contain either a TI
>>> bq27411 or bq27541 fuel gauge. Use the generic ti,bq27xxx compatible
>>> so the driver can select the register map from DeviceType at probe
>>> time.
>>>
>>> Tested on OnePlus 6T (fajita) with a bq27541 (DeviceType 0x0541):
>>> after booting the new kernel, the battery reported 4.360 V, 100% state
>>> of charge, 27.8 C, and Full status.
>>>
>>> Fixes: 12dfb002ca01 ("arm64: dts: qcom: sdm845-oneplus-*: add fuel gauge")
>>
>> What is the bug here? Your commit msg should be specific about it.
>>
>
> Commit msg seems pretty clear about the bug (to me at least), the DT
> says the fuel gauge is a BQ27411 but that isn't the case, some shipped
> with a BQ27541 fuel gauge.
>
> (I do agree though this shouldn't have a fixes tag as back-porting this
> without also back-porting the driver-side change would break users)
>
> Since these fuel gauges often live on the battery pack and not the
> device itself, folks changing their batteries might end up with
> different fuel gauges, so having some detection method is going to
> be helpful.
>
> Rinat,
>
> I'm not familiar with the bootflow on these devices, but is this something
> you could detect in the bootloader and fixup the DT before it is passed
> to kernel? That way the kernel gets a DT with the correct and specific
> compatible to start with?
Hello Andrew:
There are two possible bootflows:
a) from fastboot (we can't do anything)
b) from intermediate u-boot (we could do this)
While your suggestion seems to be the most correct, I'm not sure the
"complexity" here outweighs the pros of simply reporting
deb_warn your phones has different charging chip
and switching the behavior to the "replacement part" here.
In the future we'll need to add u-boot logic because of camera focus, where the
focus in some phones is on different i2c addr + from different vendor, where we
cannot do it so simply as here.
What do you think?
David>
> Andrew
>
>>>
>>> Signed-off-by: Rinat Muhamedgaliev <rinat.muhamedgaliev@gmail.com>
>>> ---
>>> arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi | 4 ++--
>>> arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts | 2 +-
>>> arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts | 2 +-
>>> 3 files changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi b/arch/
>>> arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
>>> index 948a0dd..8c5cd94 100644
>>> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
>>> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi
>>> @@ -790,8 +790,8 @@ &i2c10 {
>>> status = "okay";
>>> clock-frequency = <100000>;
>>> - bq27441_fg: bq27441-battery@55 {
>>> - compatible = "ti,bq27411";
>>> + bq27xxx_fg: fuel-gauge@55 {
>>> + compatible = "ti,bq27xxx";
>>
>> And this is just breaking all users without any explanation.
>>
>>
>>
>>> status = "okay";
>>> reg = <0x55>;
>>> };
>>> diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts b/arch/
>>> arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
>>> index 5f01115..cf40842 100644
>>> --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
>>> +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-enchilada.dts
>>> @@ -44,7 +44,7 @@ main_cam_ois: main-cam-ois-regulator {
>>> };
>>> };
>>> -&bq27441_fg {
>>> +&bq27xxx_fg {
>>
>> No, irrelevant to the supposed bug here.
>>
>> Best regards,
>> Krzysztof
>>
>
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible
2026-09-11 13:37 ` Andrew Davis
2026-09-11 18:41 ` David Heidelberg
2026-09-11 20:00 ` David Heidelberg
@ 2026-09-12 7:47 ` Krzysztof Kozlowski
2 siblings, 0 replies; 21+ messages in thread
From: Krzysztof Kozlowski @ 2026-09-12 7:47 UTC (permalink / raw)
To: Andrew Davis, Rinat Muhamedgaliev
Cc: Bjorn Andersson, Konrad Dybcio, Sebastian Reichel,
David Heidelberg, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Pali Rohár, linux-arm-msm, devicetree, linux-pm,
linux-kernel
On 11/09/2026 15:37, Andrew Davis wrote:
> On 9/11/26 3:21 AM, Krzysztof Kozlowski wrote:
>> On Thu, Sep 10, 2026 at 02:47:44AM +0300, Rinat Muhamedgaliev wrote:
>>> OnePlus 6 and OnePlus 6T battery packs may contain either a TI
>>> bq27411 or bq27541 fuel gauge. Use the generic ti,bq27xxx compatible
>>> so the driver can select the register map from DeviceType at probe
>>> time.
>>>
>>> Tested on OnePlus 6T (fajita) with a bq27541 (DeviceType 0x0541):
>>> after booting the new kernel, the battery reported 4.360 V, 100% state
>>> of charge, 27.8 C, and Full status.
>>>
>>> Fixes: 12dfb002ca01 ("arm64: dts: qcom: sdm845-oneplus-*: add fuel gauge")
>>
>> What is the bug here? Your commit msg should be specific about it.
>>
>
> Commit msg seems pretty clear about the bug (to me at least), the DT
> says the fuel gauge is a BQ27411 but that isn't the case, some shipped
> with a BQ27541 fuel gauge.
>
> (I do agree though this shouldn't have a fixes tag as back-porting this
> without also back-porting the driver-side change would break users)
But different model is not a bug by itself. If devices are compatible
how would it be a bug? if everything is working fine with different
model how would that be a bug?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 0/3] bq27xxx: support interchangeable OnePlus 6/6T fuel gauges
2026-09-09 23:47 ` [PATCH v3 0/3] bq27xxx: support interchangeable OnePlus 6/6T fuel gauges Rinat Muhamedgaliev
` (2 preceding siblings ...)
2026-09-09 23:47 ` [PATCH v3 3/3] arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible Rinat Muhamedgaliev
@ 2026-09-10 0:08 ` David Heidelberg
3 siblings, 0 replies; 21+ messages in thread
From: David Heidelberg @ 2026-09-10 0:08 UTC (permalink / raw)
To: Rinat Muhamedgaliev, Bjorn Andersson, Konrad Dybcio,
Sebastian Reichel
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Pali Rohár,
Andrew F . Davis, linux-arm-msm, devicetree, linux-pm,
linux-kernel
On 10/09/2026 01:47, Rinat Muhamedgaliev wrote:
> OnePlus 6 and OnePlus 6T battery packs may contain either a TI bq27411
> or bq27541 fuel gauge. The DTS compatible used until now selects only
> the bq27411 register map, while v2 proposed selecting bq27541 for every
> device. Neither static choice supports both original and replacement
> battery packs.
>
> Add a generic ti,bq27xxx compatible and have the I2C driver issue the
> DeviceType control command at probe time. It selects bq27411 for
> DeviceType 0x0421 and bq27541 for 0x0541.
>
> Tested on OnePlus 6T (fajita) with DeviceType 0x0541. After installing
> the kernel and rebooting, the fuel gauge reported 4.360 V, 100% state
> of charge, 27.8 C, and Full status.
>
> Changes in v3:
> - Replace the static bq27541 DTS change from v2 with runtime detection
> for both bq27411 and bq27541.
> - Add the generic compatible to the binding and I2C driver.
> - Split the change into binding, driver, and DTS patches.
Hello Rinat!
Happy to see this series.
Did you managed to get someone with the original bq27411 to test it?
Eventually we hang at on https://matrix.to/#/#sdm845:ixit.cz
Thanks
David
>
> Rinat Muhamedgaliev (3):
> dt-bindings: power: supply: bq27xxx: add generic compatible
> power: supply: bq27xxx: autodetect bq27411 and bq27541
> arm64: dts: qcom: sdm845-oneplus: use generic fuel gauge compatible
>
> .../bindings/power/supply/bq27xxx.yaml | 1 +
> .../boot/dts/qcom/sdm845-oneplus-common.dtsi | 4 +-
> .../dts/qcom/sdm845-oneplus-enchilada.dts | 2 +-
> .../boot/dts/qcom/sdm845-oneplus-fajita.dts | 2 +-
> drivers/power/supply/bq27xxx_battery_i2c.c | 39 +++++++++++++++++++
> 5 files changed, 44 insertions(+), 4 deletions(-)
>
^ permalink raw reply [flat|nested] 21+ messages in thread