* [PATCH v4 0/3] Add Xiaomi 12 Lite 5G (taoyao) battery support
@ 2026-09-15 8:48 Stanislav Zaikin
2026-09-15 8:48 ` [PATCH v4 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible Stanislav Zaikin
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Stanislav Zaikin @ 2026-09-15 8:48 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Sebastian Reichel
Cc: linux-arm-msm, devicetree, linux-kernel, linux-pm, Stanislav Zaikin
Xiaomi 12 Lite 5G (taoyao) has an additional property with ID 12 that
breaks the parsing in qcom_battmgr. Fix that by introducing separate
maps for lookups properties in both directions.
The other approach that I tried is manual shifting properties:
+ if (battmgr->variant == QCOM_BATTMGR_TAOYAO && prop > BATT_CHG_CTRL_LIM_MAX)
+ prop++;
...
+ if (battmgr->variant == QCOM_BATTMGR_TAOYAO && property > BATT_CHG_CTRL_LIM_MAX + 1)
+ property--;
But I found that more obscure.
Will be happy to switch if the maintainers prefer this one.
Changes in v4:
- Added Konrad's r-b (patch #2)
- Dropped RFC tag
Changes in v3:
- Fix QCOM_BATTMGR_TAOYAO enum ordering (patch #2)
- Order in qcom_battmgr_of_variants[] is already right (no change)
- Revert the qcom,sm7325-pmic-glink SoC fallback (patch #1 and #3)
- Rephrased commit message (patch #3)
- Design question from v1/v2 still open: lookup tables vs. inline shift
Changes in v2:
- Keep the qcom,sm7325-pmic-glink SoC fallback in the compatible chain
of the taoyao pmic-glink node (review feedback, patch #1 and #3)
Stanislav Zaikin (3):
dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible
power: supply: qcom_battmgr: add Xiaomi taoyao support
arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific
pmic-glink compatible
.../bindings/soc/qcom/qcom,pmic-glink.yaml | 1 +
.../boot/dts/qcom/sm7325-xiaomi-taoyao.dts | 2 +-
drivers/power/supply/qcom_battmgr.c | 86 ++++++++++++++++++-
3 files changed, 84 insertions(+), 5 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible
2026-09-15 8:48 [PATCH v4 0/3] Add Xiaomi 12 Lite 5G (taoyao) battery support Stanislav Zaikin
@ 2026-09-15 8:48 ` Stanislav Zaikin
2026-09-17 10:07 ` Krzysztof Kozlowski
2026-09-15 8:49 ` [PATCH v4 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support Stanislav Zaikin
2026-09-15 8:49 ` [PATCH v4 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible Stanislav Zaikin
2 siblings, 1 reply; 7+ messages in thread
From: Stanislav Zaikin @ 2026-09-15 8:48 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Sebastian Reichel
Cc: linux-arm-msm, devicetree, linux-kernel, linux-pm, Stanislav Zaikin
Add the compatible string used by Xiaomi 12 Lite 5G (taoyao) so its
battery manager can be matched to a device-specific variant in
qcom_battmgr.
Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com>
---
Documentation/devicetree/bindings/soc/qcom/qcom,pmic-glink.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,pmic-glink.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,pmic-glink.yaml
index 16ad4f5698fc..8ca057c4e3e6 100644
--- a/Documentation/devicetree/bindings/soc/qcom/qcom,pmic-glink.yaml
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,pmic-glink.yaml
@@ -41,6 +41,7 @@ properties:
- items:
- enum:
- qcom,sm7325-pmic-glink
+ - xiaomi,taoyao-pmic-glink
- const: qcom,qcm6490-pmic-glink
- const: qcom,pmic-glink
- items:
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support
2026-09-15 8:48 [PATCH v4 0/3] Add Xiaomi 12 Lite 5G (taoyao) battery support Stanislav Zaikin
2026-09-15 8:48 ` [PATCH v4 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible Stanislav Zaikin
@ 2026-09-15 8:49 ` Stanislav Zaikin
2026-09-15 8:49 ` [PATCH v4 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible Stanislav Zaikin
2 siblings, 0 replies; 7+ messages in thread
From: Stanislav Zaikin @ 2026-09-15 8:49 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Sebastian Reichel
Cc: linux-arm-msm, devicetree, linux-kernel, linux-pm,
Stanislav Zaikin, Konrad Dybcio
The Xiaomi taoyao firmware defines an additional BATT_CONSTANT_CURRENT
property (ID 12) between BATT_CHG_CTRL_LIM_MAX and BATT_TEMP, shifting
all higher battery property IDs by one.
Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
drivers/power/supply/qcom_battmgr.c | 86 +++++++++++++++++++++++++++--
1 file changed, 82 insertions(+), 4 deletions(-)
diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index 490137a23d00..1ff079750807 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -23,6 +23,7 @@ enum qcom_battmgr_variant {
QCOM_BATTMGR_SC8280XP,
QCOM_BATTMGR_SM8350,
QCOM_BATTMGR_SM8550,
+ QCOM_BATTMGR_TAOYAO,
QCOM_BATTMGR_X1E80100,
};
@@ -451,16 +452,87 @@ static const u8 sm8350_bat_prop_map[] = {
[POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD] = BATT_CHG_CTRL_END_THR,
};
+/*
+ * Xiaomi Taoyao firmware has BATT_CONSTANT_CURRENT (ID 12) inserted
+ * between BATT_CHG_CTRL_LIM_MAX and BATT_TEMP, shifting all subsequent
+ * IDs by one.
+ */
+static const u8 taoyao_bat_prop_map[] = {
+ [POWER_SUPPLY_PROP_STATUS] = BATT_STATUS,
+ [POWER_SUPPLY_PROP_HEALTH] = BATT_HEALTH,
+ [POWER_SUPPLY_PROP_PRESENT] = BATT_PRESENT,
+ [POWER_SUPPLY_PROP_CHARGE_TYPE] = BATT_CHG_TYPE,
+ [POWER_SUPPLY_PROP_CAPACITY] = BATT_CAPACITY,
+ [POWER_SUPPLY_PROP_VOLTAGE_OCV] = BATT_VOLT_OCV,
+ [POWER_SUPPLY_PROP_VOLTAGE_NOW] = BATT_VOLT_NOW,
+ [POWER_SUPPLY_PROP_VOLTAGE_MAX] = BATT_VOLT_MAX,
+ [POWER_SUPPLY_PROP_CURRENT_NOW] = BATT_CURR_NOW,
+ [POWER_SUPPLY_PROP_TEMP] = BATT_TEMP + 1,
+ [POWER_SUPPLY_PROP_TECHNOLOGY] = BATT_TECHNOLOGY + 1,
+ [POWER_SUPPLY_PROP_CHARGE_COUNTER] = BATT_CHG_COUNTER + 1,
+ [POWER_SUPPLY_PROP_CYCLE_COUNT] = BATT_CYCLE_COUNT + 1,
+ [POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN] = BATT_CHG_FULL_DESIGN + 1,
+ [POWER_SUPPLY_PROP_CHARGE_FULL] = BATT_CHG_FULL + 1,
+ [POWER_SUPPLY_PROP_MODEL_NAME] = BATT_MODEL_NAME + 1,
+ [POWER_SUPPLY_PROP_TIME_TO_FULL_AVG] = BATT_TTF_AVG + 1,
+ [POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG] = BATT_TTE_AVG + 1,
+ [POWER_SUPPLY_PROP_INTERNAL_RESISTANCE] = BATT_RESISTANCE + 1,
+ [POWER_SUPPLY_PROP_STATE_OF_HEALTH] = BATT_SOH,
+ [POWER_SUPPLY_PROP_POWER_NOW] = BATT_POWER_NOW + 1,
+ [POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD] = BATT_CHG_CTRL_START_THR + 1,
+ [POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD] = BATT_CHG_CTRL_END_THR + 1,
+};
+
+/*
+ * Reverse mapping from Xiaomi Taoyao firmware property IDs to canonical
+ * kernel property IDs.
+ */
+static const u8 taoyao_to_canonical[] = {
+ [BATT_STATUS] = BATT_STATUS,
+ [BATT_HEALTH] = BATT_HEALTH,
+ [BATT_PRESENT] = BATT_PRESENT,
+ [BATT_CHG_TYPE] = BATT_CHG_TYPE,
+ [BATT_CAPACITY] = BATT_CAPACITY,
+ [BATT_SOH] = BATT_SOH,
+ [BATT_VOLT_OCV] = BATT_VOLT_OCV,
+ [BATT_VOLT_NOW] = BATT_VOLT_NOW,
+ [BATT_VOLT_MAX] = BATT_VOLT_MAX,
+ [BATT_CURR_NOW] = BATT_CURR_NOW,
+ [BATT_CHG_CTRL_LIM] = BATT_CHG_CTRL_LIM,
+ [BATT_CHG_CTRL_LIM_MAX] = BATT_CHG_CTRL_LIM_MAX,
+ [BATT_CHG_CTRL_LIM_MAX + 1] = 0xff, /* BATT_CONSTANT_CURRENT - never requested */
+ [BATT_TEMP + 1] = BATT_TEMP,
+ [BATT_TECHNOLOGY + 1] = BATT_TECHNOLOGY,
+ [BATT_CHG_COUNTER + 1] = BATT_CHG_COUNTER,
+ [BATT_CYCLE_COUNT + 1] = BATT_CYCLE_COUNT,
+ [BATT_CHG_FULL_DESIGN + 1] = BATT_CHG_FULL_DESIGN,
+ [BATT_CHG_FULL + 1] = BATT_CHG_FULL,
+ [BATT_MODEL_NAME + 1] = BATT_MODEL_NAME,
+ [BATT_TTF_AVG + 1] = BATT_TTF_AVG,
+ [BATT_TTE_AVG + 1] = BATT_TTE_AVG,
+ [BATT_RESISTANCE + 1] = BATT_RESISTANCE,
+ [BATT_POWER_NOW + 1] = BATT_POWER_NOW,
+ [BATT_POWER_AVG + 1] = BATT_POWER_AVG,
+ [BATT_CHG_CTRL_EN + 1] = BATT_CHG_CTRL_EN,
+ [BATT_CHG_CTRL_START_THR + 1] = BATT_CHG_CTRL_START_THR,
+ [BATT_CHG_CTRL_END_THR + 1] = BATT_CHG_CTRL_END_THR,
+};
+
static int qcom_battmgr_bat_sm8350_update(struct qcom_battmgr *battmgr,
enum power_supply_property psp)
{
unsigned int prop;
int ret;
- if (psp >= ARRAY_SIZE(sm8350_bat_prop_map))
- return -EINVAL;
-
- prop = sm8350_bat_prop_map[psp];
+ if (battmgr->variant == QCOM_BATTMGR_TAOYAO) {
+ if (psp >= ARRAY_SIZE(taoyao_bat_prop_map))
+ return -EINVAL;
+ prop = taoyao_bat_prop_map[psp];
+ } else {
+ if (psp >= ARRAY_SIZE(sm8350_bat_prop_map))
+ return -EINVAL;
+ prop = sm8350_bat_prop_map[psp];
+ }
mutex_lock(&battmgr->lock);
ret = qcom_battmgr_request_property(battmgr, BATTMGR_BAT_PROPERTY_GET, prop, 0);
@@ -1381,6 +1453,11 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
switch (opcode) {
case BATTMGR_BAT_PROPERTY_GET:
property = le32_to_cpu(resp->intval.property);
+
+ if (battmgr->variant == QCOM_BATTMGR_TAOYAO &&
+ property < ARRAY_SIZE(taoyao_to_canonical))
+ property = taoyao_to_canonical[property];
+
if (property == BATT_MODEL_NAME) {
if (payload_len != sizeof(resp->strval)) {
dev_warn(battmgr->dev,
@@ -1617,6 +1694,7 @@ static const struct of_device_id qcom_battmgr_of_variants[] = {
{ .compatible = "qcom,sc8280xp-pmic-glink", .data = (void *)QCOM_BATTMGR_SC8280XP },
{ .compatible = "qcom,sm8550-pmic-glink", .data = (void *)QCOM_BATTMGR_SM8550 },
{ .compatible = "qcom,x1e80100-pmic-glink", .data = (void *)QCOM_BATTMGR_X1E80100 },
+ { .compatible = "xiaomi,taoyao-pmic-glink", .data = (void *)QCOM_BATTMGR_TAOYAO },
/* Unmatched devices falls back to QCOM_BATTMGR_SM8350 */
{}
};
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible
2026-09-15 8:48 [PATCH v4 0/3] Add Xiaomi 12 Lite 5G (taoyao) battery support Stanislav Zaikin
2026-09-15 8:48 ` [PATCH v4 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible Stanislav Zaikin
2026-09-15 8:49 ` [PATCH v4 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support Stanislav Zaikin
@ 2026-09-15 8:49 ` Stanislav Zaikin
2026-09-17 11:31 ` Konrad Dybcio
2 siblings, 1 reply; 7+ messages in thread
From: Stanislav Zaikin @ 2026-09-15 8:49 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Sebastian Reichel
Cc: linux-arm-msm, devicetree, linux-kernel, linux-pm, Stanislav Zaikin
Switch taoyao to "xiaomi,taoyao-pmic-glink" compatible so
qcom_battmgr can identify the device and apply its taoyao-specific
battery property mapping, required because its firmware shifts
battery property IDs relative to the generic sm7325-pmic-glink
firmware.
Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com>
---
arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts b/arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts
index 6f8bc65bb99b..bc4dfa49ef38 100644
--- a/arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts
+++ b/arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts
@@ -72,7 +72,7 @@ key-volume-up {
};
pmic-glink {
- compatible = "qcom,sm7325-pmic-glink",
+ compatible = "xiaomi,taoyao-pmic-glink",
"qcom,qcm6490-pmic-glink",
"qcom,pmic-glink";
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible
2026-09-15 8:48 ` [PATCH v4 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible Stanislav Zaikin
@ 2026-09-17 10:07 ` Krzysztof Kozlowski
2026-09-18 7:54 ` Stanislav Zaikin
0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2026-09-17 10:07 UTC (permalink / raw)
To: Stanislav Zaikin
Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Sebastian Reichel, linux-arm-msm, devicetree,
linux-kernel, linux-pm
On Tue, Sep 15, 2026 at 10:48:59AM +0200, Stanislav Zaikin wrote:
> Add the compatible string used by Xiaomi 12 Lite 5G (taoyao) so its
> battery manager can be matched to a device-specific variant in
> qcom_battmgr.
Previously you were asked if the device is compatible with qcm6490. You
responded about something completely else - that you need qcm6490. That
was not the question if you need it or not. The question was are they
compatible and you have entire commit msg to explain that.
Instead, describing standard Linux device driver matching in commit msg
is redundant.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible
2026-09-15 8:49 ` [PATCH v4 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible Stanislav Zaikin
@ 2026-09-17 11:31 ` Konrad Dybcio
0 siblings, 0 replies; 7+ messages in thread
From: Konrad Dybcio @ 2026-09-17 11:31 UTC (permalink / raw)
To: Stanislav Zaikin, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Sebastian Reichel
Cc: linux-arm-msm, devicetree, linux-kernel, linux-pm
On 9/15/26 10:49 AM, Stanislav Zaikin wrote:
> Switch taoyao to "xiaomi,taoyao-pmic-glink" compatible so
> qcom_battmgr can identify the device and apply its taoyao-specific
> battery property mapping, required because its firmware shifts
> battery property IDs relative to the generic sm7325-pmic-glink
> firmware.
>
> Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com>
> ---
> arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts b/arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts
> index 6f8bc65bb99b..bc4dfa49ef38 100644
> --- a/arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts
> +++ b/arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts
> @@ -72,7 +72,7 @@ key-volume-up {
> };
>
> pmic-glink {
> - compatible = "qcom,sm7325-pmic-glink",
> + compatible = "xiaomi,taoyao-pmic-glink",
> "qcom,qcm6490-pmic-glink",
> "qcom,pmic-glink";
As krzk points out, this should be a standalone single compatible,
because it's neither going to work with qcm6490-pmic-glink nor with
qcom,pmic-glink
Konrad
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible
2026-09-17 10:07 ` Krzysztof Kozlowski
@ 2026-09-18 7:54 ` Stanislav Zaikin
0 siblings, 0 replies; 7+ messages in thread
From: Stanislav Zaikin @ 2026-09-18 7:54 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Sebastian Reichel, linux-arm-msm, devicetree,
linux-kernel, linux-pm
On 9/17/26 12:07 PM, Krzysztof Kozlowski wrote:
> On Tue, Sep 15, 2026 at 10:48:59AM +0200, Stanislav Zaikin wrote:
>> Add the compatible string used by Xiaomi 12 Lite 5G (taoyao) so its
>> battery manager can be matched to a device-specific variant in
>> qcom_battmgr.
>
> Previously you were asked if the device is compatible with qcm6490. You
> responded about something completely else - that you need qcm6490. That
> was not the question if you need it or not. The question was are they
> compatible and you have entire commit msg to explain that.
>
> Instead, describing standard Linux device driver matching in commit msg
> is redundant.
>
> Best regards,
> Krzysztof
>
Yes, apart from battmgr, the pmic-glink implementation on this device is
compatible with the QCM6490 platform (base communication & UCSI
implementation), and therefore should keep qcom,qcm6490-pmic-glink and
qcom,pmic-glink in the compatibles.
I will adjust the commit message in the v5 to:
dt-bindings: soc: qcom: qcom,pmic-glink: Document Xiaomi taoyao compatible
The taoyao is the device compatible with the QCM6490 platform (apart
from battmgr). The device also requires both UCSI_NO_PARTNER_PDOS &
UCSI_DELAY_DEVICE_PDOS quirks.
Document the PMIC GLINK firmware interface on the taoyao by using the
QCM6490 bindings as fallback.
--
Best regards,
Stanislav
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-18 7:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15 8:48 [PATCH v4 0/3] Add Xiaomi 12 Lite 5G (taoyao) battery support Stanislav Zaikin
2026-09-15 8:48 ` [PATCH v4 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible Stanislav Zaikin
2026-09-17 10:07 ` Krzysztof Kozlowski
2026-09-18 7:54 ` Stanislav Zaikin
2026-09-15 8:49 ` [PATCH v4 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support Stanislav Zaikin
2026-09-15 8:49 ` [PATCH v4 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible Stanislav Zaikin
2026-09-17 11:31 ` Konrad Dybcio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®