* [RFC PATCH v2 0/3] Add Xiaomi 12 Lite 5G (taoyao) battery support
@ 2026-08-18 15:10 user.email
2026-08-18 15:10 ` [PATCH v2 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible user.email
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: user.email @ 2026-08-18 15:10 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
From: Stanislav Zaikin <zstaseg@gmail.com>
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 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 | 5 ++
.../boot/dts/qcom/sm7325-xiaomi-taoyao.dts | 3 +-
drivers/power/supply/qcom_battmgr.c | 86 ++++++++++++++++++-
3 files changed, 89 insertions(+), 5 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v2 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible 2026-08-18 15:10 [RFC PATCH v2 0/3] Add Xiaomi 12 Lite 5G (taoyao) battery support user.email @ 2026-08-18 15:10 ` user.email 2026-08-18 15:10 ` [PATCH v2 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support user.email 2026-08-18 15:10 ` [PATCH v2 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible user.email 2 siblings, 0 replies; 9+ messages in thread From: user.email @ 2026-08-18 15:10 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 From: Stanislav Zaikin <zstaseg@gmail.com> 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> --- .../devicetree/bindings/soc/qcom/qcom,pmic-glink.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,pmic-glink.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,pmic-glink.yaml index 16ad4f5698fc..3a74b5e51e9d 100644 --- a/Documentation/devicetree/bindings/soc/qcom/qcom,pmic-glink.yaml +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,pmic-glink.yaml @@ -43,6 +43,11 @@ properties: - qcom,sm7325-pmic-glink - const: qcom,qcm6490-pmic-glink - const: qcom,pmic-glink + - items: + - const: xiaomi,taoyao-pmic-glink + - const: qcom,sm7325-pmic-glink + - const: qcom,qcm6490-pmic-glink + - const: qcom,pmic-glink - items: - enum: - qcom,eliza-pmic-glink -- 2.53.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support 2026-08-18 15:10 [RFC PATCH v2 0/3] Add Xiaomi 12 Lite 5G (taoyao) battery support user.email 2026-08-18 15:10 ` [PATCH v2 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible user.email @ 2026-08-18 15:10 ` user.email 2026-08-19 7:11 ` Krzysztof Kozlowski 2026-08-18 15:10 ` [PATCH v2 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible user.email 2 siblings, 1 reply; 9+ messages in thread From: user.email @ 2026-08-18 15:10 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 From: Stanislav Zaikin <zstaseg@gmail.com> 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> --- 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..390d7c75e36f 100644 --- a/drivers/power/supply/qcom_battmgr.c +++ b/drivers/power/supply/qcom_battmgr.c @@ -24,6 +24,7 @@ enum qcom_battmgr_variant { QCOM_BATTMGR_SM8350, QCOM_BATTMGR_SM8550, QCOM_BATTMGR_X1E80100, + QCOM_BATTMGR_TAOYAO, }; #define BATTMGR_BAT_STATUS 0x1 @@ -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 related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support 2026-08-18 15:10 ` [PATCH v2 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support user.email @ 2026-08-19 7:11 ` Krzysztof Kozlowski 2026-08-19 8:37 ` Stanislav Zaikin 0 siblings, 1 reply; 9+ messages in thread From: Krzysztof Kozlowski @ 2026-08-19 7:11 UTC (permalink / raw) To: user.email Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sebastian Reichel, linux-arm-msm, devicetree, linux-kernel, linux-pm On Tue, Aug 18, 2026 at 05:10:38PM +0200, user.email wrote: > From: Stanislav Zaikin <zstaseg@gmail.com> > > 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> > --- > 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..390d7c75e36f 100644 > --- a/drivers/power/supply/qcom_battmgr.c > +++ b/drivers/power/supply/qcom_battmgr.c > @@ -24,6 +24,7 @@ enum qcom_battmgr_variant { > QCOM_BATTMGR_SM8350, > QCOM_BATTMGR_SM8550, > QCOM_BATTMGR_X1E80100, > + QCOM_BATTMGR_TAOYAO, T < X, do not introduce entries in random order > }; > > #define BATTMGR_BAT_STATUS 0x1 > @@ -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]; So device is or is not compatible with sm7325? Above code suggests that it is not. How does it work when bound by sm7325 compatible? > + > 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 }, And here as well wrong order > /* Unmatched devices falls back to QCOM_BATTMGR_SM8350 */ > {} > }; > -- > 2.53.0 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support 2026-08-19 7:11 ` Krzysztof Kozlowski @ 2026-08-19 8:37 ` Stanislav Zaikin 2026-08-19 8:46 ` Konrad Dybcio 2026-08-19 8:46 ` Krzysztof Kozlowski 0 siblings, 2 replies; 9+ messages in thread From: Stanislav Zaikin @ 2026-08-19 8:37 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 8/19/26 9:11 AM, Krzysztof Kozlowski wrote: > On Tue, Aug 18, 2026 at 05:10:38PM +0200, user.email wrote: >> From: Stanislav Zaikin <zstaseg@gmail.com> >> >> 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> >> --- >> 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..390d7c75e36f 100644 >> --- a/drivers/power/supply/qcom_battmgr.c >> +++ b/drivers/power/supply/qcom_battmgr.c >> @@ -24,6 +24,7 @@ enum qcom_battmgr_variant { >> QCOM_BATTMGR_SM8350, >> QCOM_BATTMGR_SM8550, >> QCOM_BATTMGR_X1E80100, >> + QCOM_BATTMGR_TAOYAO, > > T < X, do not introduce entries in random order Hello Krzysztof, Thank you for the review. Will fix in v3. >> @@ -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]; > > So device is or is not compatible with sm7325? Above code suggests that > it is not. How does it work when bound by sm7325 compatible? The device is sm7325-based and when bound to sm7325-pmic-glink it falls back to QCOM_BATTMGR_SM8350 property map. However, due to shifted property IDs baked into taoyao's firmware the parsing of roughly the 2nd half of properties is broken. And any userspace process that reads the battery properties via sysfs suffers from 1s timeouts and it basically hangs my DE. Since this is an RFC: do you think this approach is better than what I described in cover letter? (manually shifting property IDs) >> @@ -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 }, > > And here as well wrong order Will fix in v3. -- Best regards, Stanislav ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support 2026-08-19 8:37 ` Stanislav Zaikin @ 2026-08-19 8:46 ` Konrad Dybcio 2026-08-19 8:46 ` Krzysztof Kozlowski 1 sibling, 0 replies; 9+ messages in thread From: Konrad Dybcio @ 2026-08-19 8:46 UTC (permalink / raw) To: Stanislav Zaikin, Krzysztof Kozlowski Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sebastian Reichel, linux-arm-msm, devicetree, linux-kernel, linux-pm On 8/19/26 10:37 AM, Stanislav Zaikin wrote: > On 8/19/26 9:11 AM, Krzysztof Kozlowski wrote: >> On Tue, Aug 18, 2026 at 05:10:38PM +0200, user.email wrote: >>> From: Stanislav Zaikin <zstaseg@gmail.com> >>> >>> 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> >>> --- >>> 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..390d7c75e36f 100644 >>> --- a/drivers/power/supply/qcom_battmgr.c >>> +++ b/drivers/power/supply/qcom_battmgr.c >>> @@ -24,6 +24,7 @@ enum qcom_battmgr_variant { >>> QCOM_BATTMGR_SM8350, >>> QCOM_BATTMGR_SM8550, >>> QCOM_BATTMGR_X1E80100, >>> + QCOM_BATTMGR_TAOYAO, >> >> T < X, do not introduce entries in random order > > Hello Krzysztof, > Thank you for the review. > > Will fix in v3. > >>> @@ -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]; >> >> So device is or is not compatible with sm7325? Above code suggests that >> it is not. How does it work when bound by sm7325 compatible? > > The device is sm7325-based and when bound to sm7325-pmic-glink it falls back to QCOM_BATTMGR_SM8350 property map. However, due to shifted property IDs baked into taoyao's firmware the parsing of roughly the 2nd half of properties is broken. > > And any userspace process that reads the battery properties via sysfs suffers from 1s timeouts and it basically hangs my DE. > > Since this is an RFC: do you think this approach is better than what I described in cover letter? (manually shifting property IDs) Krzysztof is trying to say that even though the device is based on the 7325 SoC, what the kernel today knows as "pmic glink on sm7325" is not compatible with the customized firmware on your device, so the fallback compatible should be dropped, as it suggests that is the case Konrad ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support 2026-08-19 8:37 ` Stanislav Zaikin 2026-08-19 8:46 ` Konrad Dybcio @ 2026-08-19 8:46 ` Krzysztof Kozlowski 1 sibling, 0 replies; 9+ messages in thread From: Krzysztof Kozlowski @ 2026-08-19 8:46 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 19/08/2026 10:37, Stanislav Zaikin wrote: > On 8/19/26 9:11 AM, Krzysztof Kozlowski wrote: >> On Tue, Aug 18, 2026 at 05:10:38PM +0200, user.email wrote: >>> From: Stanislav Zaikin <zstaseg@gmail.com> >>> >>> 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> >>> --- >>> 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..390d7c75e36f 100644 >>> --- a/drivers/power/supply/qcom_battmgr.c >>> +++ b/drivers/power/supply/qcom_battmgr.c >>> @@ -24,6 +24,7 @@ enum qcom_battmgr_variant { >>> QCOM_BATTMGR_SM8350, >>> QCOM_BATTMGR_SM8550, >>> QCOM_BATTMGR_X1E80100, >>> + QCOM_BATTMGR_TAOYAO, >> >> T < X, do not introduce entries in random order > > Hello Krzysztof, > Thank you for the review. > > Will fix in v3. > >>> @@ -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]; >> >> So device is or is not compatible with sm7325? Above code suggests that >> it is not. How does it work when bound by sm7325 compatible? > > The device is sm7325-based and when bound to sm7325-pmic-glink it falls > back to QCOM_BATTMGR_SM8350 property map. However, due to shifted > property IDs baked into taoyao's firmware the parsing of roughly the 2nd > half of properties is broken. > > And any userspace process that reads the battery properties via sysfs > suffers from 1s timeouts and it basically hangs my DE. So basically it is not compatible with sm7325-pmic-glink and it should be expressed/fixed. I wonder though how was the DTS even tested in this matter. > > Since this is an RFC: do you think this approach is better than what I > described in cover letter? (manually shifting property IDs) Every patch is RFC... or are you saying this is a RFC in a meaning it is not ready for review? > >>> @@ -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 }, >> >> And here as well wrong order > > Will fix in v3. > > -- > Best regards, > Stanislav > Best regards, Krzysztof ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible 2026-08-18 15:10 [RFC PATCH v2 0/3] Add Xiaomi 12 Lite 5G (taoyao) battery support user.email 2026-08-18 15:10 ` [PATCH v2 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible user.email 2026-08-18 15:10 ` [PATCH v2 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support user.email @ 2026-08-18 15:10 ` user.email 2026-08-19 7:13 ` Krzysztof Kozlowski 2 siblings, 1 reply; 9+ messages in thread From: user.email @ 2026-08-18 15:10 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 From: Stanislav Zaikin <zstaseg@gmail.com> Switch taoyao to its own compatible so qcom_battmgr can select the taoyao-specific property mapping added in the previous patch. Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com> --- arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts | 3 ++- 1 file changed, 2 insertions(+), 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..6621cb40e710 100644 --- a/arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts +++ b/arch/arm64/boot/dts/qcom/sm7325-xiaomi-taoyao.dts @@ -72,7 +72,8 @@ key-volume-up { }; pmic-glink { - compatible = "qcom,sm7325-pmic-glink", + compatible = "xiaomi,taoyao-pmic-glink", + "qcom,sm7325-pmic-glink", "qcom,qcm6490-pmic-glink", "qcom,pmic-glink"; -- 2.53.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible 2026-08-18 15:10 ` [PATCH v2 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible user.email @ 2026-08-19 7:13 ` Krzysztof Kozlowski 0 siblings, 0 replies; 9+ messages in thread From: Krzysztof Kozlowski @ 2026-08-19 7:13 UTC (permalink / raw) To: user.email Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sebastian Reichel, linux-arm-msm, devicetree, linux-kernel, linux-pm On Tue, Aug 18, 2026 at 05:10:39PM +0200, user.email wrote: > From: Stanislav Zaikin <zstaseg@gmail.com> > > Switch taoyao to its own compatible so qcom_battmgr can select the > taoyao-specific property mapping added in the previous patch. How is it going to be a "previous patch"? Previous patch is a different DTS commit - look at the DTS branch of qcom soc or any other soc tree. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-08-19 8:46 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-18 15:10 [RFC PATCH v2 0/3] Add Xiaomi 12 Lite 5G (taoyao) battery support user.email 2026-08-18 15:10 ` [PATCH v2 1/3] dt-bindings: soc: qcom: add xiaomi,taoyao-pmic-glink compatible user.email 2026-08-18 15:10 ` [PATCH v2 2/3] power: supply: qcom_battmgr: add Xiaomi taoyao support user.email 2026-08-19 7:11 ` Krzysztof Kozlowski 2026-08-19 8:37 ` Stanislav Zaikin 2026-08-19 8:46 ` Konrad Dybcio 2026-08-19 8:46 ` Krzysztof Kozlowski 2026-08-18 15:10 ` [PATCH v2 3/3] arm64: dts: qcom: sm7325-xiaomi-taoyao: switch to device-specific pmic-glink compatible user.email 2026-08-19 7:13 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox