Fix RG35XX Battery Charging Issues
Subsystems (5)
v2 cover Fix RG35XX Battery Charging Issues
From: Chris Morgan <[email protected]>
The Anbernic RG35XX devices sometimes fail to charge when the register for the battery temperature sensor is set to the incorrect value either by user error or an incorrectly programmed efuse. Allow users to hard-code if a temperature sensor is not present (which is the case for all Anbernic RGxx series devices) to prevent this issue from causing problems. Additionally, a bug was identified with the handling of PMU faults while this fix was being tested.
Note that the MFD updates to the writeable regs are required build dependencies of the battery fix, as it defines a register that was previously not defined or writeable.
Changes from V1:
- Updated cover letter to note that the MFD updates are build dependencies.
- Removed patch for "power: supply: axp20x_battery: Fix fault handling for AXP717" as it has already been accepted upstream.
- Simplified binding documentation with a "not" statement.
- Corrected writeable regs in MFD driver.
- Updated comment in driver to note a correctly defined device tree with a simple-battery node is required to apply the thermistor fix.
Chris Morgan (4):
dt-bindings: power: supply: axp20x-battery: Add
x-powers,no-thermistor
mfd: axp20x: AXP717: Add AXP717_TS_PIN_CFG to writeable regs
power: supply: axp20x_battery: Update temp sensor for AXP717 from
device tree
arm64: dts: allwinner: rg35xx: Add no-thermistor property for battery
.../x-powers,axp20x-battery-power-supply.yaml | 20 +++++++++++++++--- .../sun50i-h700-anbernic-rg35xx-2024.dts | 1 + drivers/mfd/axp20x.c | 1 + drivers/power/supply/axp20x_battery.c | 21 +++++++++++++++++++ include/linux/mfd/axp20x.h | 1 + 5 files changed, 41 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/4 dt-bindings: power: supply: axp20x-battery: Add x-powers,no-thermistor
From: Chris Morgan <[email protected]>
Add the vendor specific boolean property of x-powers,no-thermistor. This property optionally describes hardware where no thermistor is present on the battery and is specific to the AXP717. In rare circumstances this value can be set incorrectly in the efuse of the PMIC, and if it is not hard-coded the device will fail to charge.
--- .../x-powers,axp20x-battery-power-supply.yaml | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml +17 -3
@@ -14,9 +14,6 @@ maintainers: - Chen-Yu Tsai <[email protected]> - Sebastian Reichel <[email protected]> -allOf: - - $ref: power-supply.yaml# - properties: compatible: oneOf:
@@ -35,7 +32,24 @@ properties: this gauge. $ref: /schemas/types.yaml#/definitions/phandle + x-powers,no-thermistor: + type: boolean + description: Indicates that no thermistor is connected to the TS pin + required: - compatible +allOf: + - $ref: power-supply.yaml# + - if: + not: + properties: + compatible: + contains: + enum: + - x-powers,axp717-battery-power-supply + then: + properties: + x-powers,no-thermistor: false + additionalProperties: false
Signature · 1 line
2.43.0
Re: [PATCH V2 1/4] dt-bindings: power: supply: axp20x-battery: Add x-powers,no-thermistor
Hi,
Quoted 11 lines · Chris Morgan
From: Chris Morgan <[email protected]>
Add the vendor specific boolean property of x-powers,no-thermistor. This property optionally describes hardware where no thermistor is present on the battery and is specific to the AXP717. In rare circumstances this value can be set incorrectly in the efuse of the PMIC, and if it is not hard-coded the device will fail to charge.
Signed-off-by Chris Morgan <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>---
-- Sebastian
Quoted 46 lines
.../x-powers,axp20x-battery-power-supply.yaml | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml +17
-3@@ -14,9 +14,6 @@ maintainers: - Chen-Yu Tsai <[email protected]> - Sebastian Reichel <[email protected]> -allOf: - - $ref: power-supply.yaml# - properties: compatible: oneOf:@@ -35,7 +32,24 @@ properties: this gauge. $ref: /schemas/types.yaml#/definitions/phandle + x-powers,no-thermistor: + type: boolean + description: Indicates that no thermistor is connected to the TS pin + required: - compatible +allOf: + - $ref: power-supply.yaml# + - if: + not: + properties: + compatible: + contains: + enum: + - x-powers,axp717-battery-power-supply + then: + properties: + x-powers,no-thermistor: false + additionalProperties: falseSignature · 1 line
2.43.0
PATCH v2 2/4 mfd: axp20x: AXP717: Add AXP717_TS_PIN_CFG to writeable regs
In reply to Chris MorganFrom: Chris Morgan <[email protected]>
Add AXP717_TS_PIN_CFG (register 0x50) to the table of writeable registers so that the temperature sensor can be configured by the battery driver.
--- drivers/mfd/axp20x.c | 1 + include/linux/mfd/axp20x.h | 1 + 2 files changed, 2 insertions(+)
drivers/mfd/axp20x.c +1 -0
@@ -224,6 +224,7 @@ static const struct regmap_range axp717_writeable_ranges[] = {regmap_reg_range (AXP717_VSYS_V_POWEROFF ,AXP717_VSYS_V_POWEROFF ),regmap_reg_range (AXP717_IRQ0_EN ,AXP717_IRQ4_EN ),regmap_reg_range (AXP717_IRQ0_STATE ,AXP717_IRQ4_STATE ), +regmap_reg_range (AXP717_TS_PIN_CFG ,AXP717_TS_PIN_CFG ),regmap_reg_range (AXP717_ICC_CHG_SET ,AXP717_CV_CHG_SET ),regmap_reg_range (AXP717_DCDC_OUTPUT_CONTROL ,AXP717_CPUSLDO_CONTROL ), regmap_reg_range(AXP717_ADC_CH_EN_CONTROL, AXP717_ADC_CH_EN_CONTROL),
include/linux/mfd/axp20x.h +1 -0
@@ -137,6 +137,7 @@ enum axp20x_variants {#define AXP717_IRQ2_STATE 0x4a#define AXP717_IRQ3_STATE 0x4b#define AXP717_IRQ4_STATE 0x4c +#define AXP717_TS_PIN_CFG 0x50#define AXP717_ICC_CHG_SET 0x62#define AXP717_ITERM_CHG_SET 0x63#define AXP717_CV_CHG_SET 0x64
Signature · 1 line
2.43.0
Re: (subset) [PATCH V2 2/4] mfd: axp20x: AXP717: Add AXP717_TS_PIN_CFG to writeable regs
Quoted 5 lines · Chris Morgan
Add
AXP717_TS_PIN_CFG(register0x50) to the table of writeable registers so that the temperature sensor can be configured by the battery driver.
Applied, thanks!
[2/4] mfd: axp20x: AXP717: Add AXP717_TS_PIN_CFG to writeable regs
commit: ab797d7faf4c28328d2e45b09991f47a9b8e08aa
--
Lee Jones [李琼斯]
Re: (subset) [PATCH V2 2/4] mfd: axp20x: AXP717: Add AXP717_TS_PIN_CFG to writeable regs
Hello Lee,
Quoted 11 lines · Lee Jones
Quoted 5 lines · Chris Morgan
Add
AXP717_TS_PIN_CFG(register0x50) to the table of writeable registers so that the temperature sensor can be configured by the battery driver.Applied, thanks!
[2/4] mfd: axp20x: AXP717: Add
AXP717_TS_PIN_CFGto writeable regscommit: ab797d7faf4c28328d2e45b09991f47a9b8e08aa
Patch 3/4 has a dependency on this one. As you probably haven't done an immutable branch for this one, please also pick up 1/4 and 3/4. I just provided Acked-by to them.
Greetings,
-- Sebastian
Lee Jones
maintainerRe: (subset) [PATCH V2 2/4] mfd: axp20x: AXP717: Add AXP717_TS_PIN_CFG to writeable regs
Quoted 10 lines · Sebastian Reichel
Hello Lee,
Quoted 7 lines · Lee Jones
Quoted 5 lines · Chris Morgan
Add
AXP717_TS_PIN_CFG(register0x50) to the table of writeable registers so that the temperature sensor can be configured by the battery driver.
Quoted 8 lines
Quoted 4 lines
Applied, thanks!
[2/4] mfd: axp20x: AXP717: Add
AXP717_TS_PIN_CFGto writeable regscommit: ab797d7faf4c28328d2e45b09991f47a9b8e08aaPatch 3/4 has a dependency on this one. As you probably haven't done an immutable branch for this one, please also pick up 1/4 and 3/4. I just provided Acked-by to them.
Here you go: :)
The following changes since commit 2014c95afecee3e76ca4a56956a936e23283f05b:
Linux 6.14-rc1 (2025-02-02 15:39:26 -0800)
are available in the Git repository at:
ssh://[email protected]/pub/scm/linux/kernel/git/lee/mfd.git tags/ib-mfd-power-v6.15
for you to fetch changes up to bfad07fe298bfba0c7ddab87c5b5325970203a1e:
mfd: axp20x: AXP717: Add AXP717_TS_PIN_CFG to writeable regs (2025-02-20 16:05:09 +0000)
----------------------------------------------------------------
Immutable branch between MFD and Power due for the v6.15 merge window
----------------------------------------------------------------
Chris Morgan (1):
mfd: axp20x: AXP717: Add AXP717_TS_PIN_CFG to writeable regs
drivers/mfd/axp20x.c | 1 + include/linux/mfd/axp20x.h | 1 + 2 files changed, 2 insertions(+)
Signature · 1 line
Lee Jones [李琼斯]
PATCH v2 3/4 power: supply: axp20x_battery: Update temp sensor for AXP717 from device tree
In reply to Chris MorganFrom: Chris Morgan <[email protected]>
Allow a boolean property of "x-powers,no-thermistor" to specify devices where the ts pin is not connected to anything. This works around an issue found with some devices where the efuse is not programmed correctly from the factory or when the register gets set erroneously.
--- drivers/power/supply/axp20x_battery.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/power/supply/axp20x_battery.c +21 -0
@@ -89,6 +89,8 @@#define AXP717_BAT_CC_MIN_UA 0#define AXP717_BAT_CC_MAX_UA 3008000 +#define AXP717_TS_PIN_DISABLE BIT(4) +struct axp20x_batt_ps ;struct axp_data {
@@ -117,6 +119,7 @@ struct axp20x_batt_ps {/* Maximum constant charge current */ unsigned int max_ccc;const struct axp_data *data; +bool ts_disable; }; static int axp20x_battery_get_max_voltage(struct axp20x_batt_ps *axp20x_batt,
@@ -984,6 +987,24 @@ static void axp717_set_battery_info(struct platform_device *pdev,int ccc = info->constant_charge_current_max_ua;int val; + axp_batt->ts_disable = (device_property_read_bool (axp_batt->dev, +"x-powers,no-thermistor" )); + +/* +* Under rare conditions an incorrectly programmed efuse for +* the temp sensor on the PMIC may trigger a fault condition. +* Allow users to hard-code if the ts pin is not used to work +* around this problem. Note that this requires the battery +* be correctly defined in the device tree with a monitored +* battery node. +*/ +if (axp_batt->ts_disable) { +regmap_update_bits (axp_batt->regmap, +AXP717_TS_PIN_CFG , +AXP717_TS_PIN_DISABLE , +AXP717_TS_PIN_DISABLE ); + } +if (vmin >0 &&axp717_set_voltage_min_design (axp_batt, vmin))dev_err (&pdev->dev,"couldn't set voltage_min_design\n" );
Signature · 1 line
2.43.0
Re: [PATCH V2 3/4] power: supply: axp20x_battery: Update temp sensor for AXP717 from device tree
Tested on Allwinner H700 devices.
Quoted 58 lines · Chris Morgan
From: Chris Morgan <[email protected]>
Allow a boolean property of "x-powers,no-thermistor" to specify devices where the ts pin is not connected to anything. This works around an issue found with some devices where the efuse is not programmed correctly from the factory or when the register gets set erroneously.
Signed-off-by Chris Morgan <[email protected]>--- drivers/power/supply/axp20x_battery.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/power/supply/axp20x_battery.c +21
-0@@ -89,6 +89,8 @@#define AXP717_BAT_CC_MIN_UA 0#define AXP717_BAT_CC_MAX_UA 3008000 +#define AXP717_TS_PIN_DISABLE BIT(4) +struct axp20x_batt_ps ;struct axp_data {@@ -117,6 +119,7 @@ struct axp20x_batt_ps {/* Maximum constant charge current */ unsigned int max_ccc;const struct axp_data *data; +bool ts_disable; }; static int axp20x_battery_get_max_voltage(struct axp20x_batt_ps *axp20x_batt,@@ -984,6 +987,24 @@ static void axp717_set_battery_info(struct platform_device *pdev,int ccc = info->constant_charge_current_max_ua;int val; + axp_batt->ts_disable = (device_property_read_bool (axp_batt->dev, +"x-powers,no-thermistor" )); + +/* +* Under rare conditions an incorrectly programmed efuse for +* the temp sensor on the PMIC may trigger a fault condition. +* Allow users to hard-code if the ts pin is not used to work +* around this problem. Note that this requires the battery +* be correctly defined in the device tree with a monitored +* battery node. +*/ +if (axp_batt->ts_disable) { +regmap_update_bits (axp_batt->regmap, +AXP717_TS_PIN_CFG , +AXP717_TS_PIN_DISABLE , +AXP717_TS_PIN_DISABLE ); + } +if (vmin >0 &&axp717_set_voltage_min_design (axp_batt, vmin))dev_err (&pdev->dev,"couldn't set voltage_min_design\n" );
Re: [PATCH V2 3/4] power: supply: axp20x_battery: Update temp sensor for AXP717 from device tree
In reply to Chris MorganHi,
Quoted 9 lines · Chris Morgan
From: Chris Morgan <[email protected]>
Allow a boolean property of "x-powers,no-thermistor" to specify devices where the ts pin is not connected to anything. This works around an issue found with some devices where the efuse is not programmed correctly from the factory or when the register gets set erroneously.
Signed-off-by Chris Morgan <[email protected]>---
-- Sebastian
Quoted 52 lines
drivers/power/supply/axp20x_battery.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/power/supply/axp20x_battery.c +21
-0@@ -89,6 +89,8 @@#define AXP717_BAT_CC_MIN_UA 0#define AXP717_BAT_CC_MAX_UA 3008000 +#define AXP717_TS_PIN_DISABLE BIT(4) +struct axp20x_batt_ps ;struct axp_data {@@ -117,6 +119,7 @@ struct axp20x_batt_ps {/* Maximum constant charge current */ unsigned int max_ccc;const struct axp_data *data; +bool ts_disable; }; static int axp20x_battery_get_max_voltage(struct axp20x_batt_ps *axp20x_batt,@@ -984,6 +987,24 @@ static void axp717_set_battery_info(struct platform_device *pdev,int ccc = info->constant_charge_current_max_ua;int val; + axp_batt->ts_disable = (device_property_read_bool (axp_batt->dev, +"x-powers,no-thermistor" )); + +/* +* Under rare conditions an incorrectly programmed efuse for +* the temp sensor on the PMIC may trigger a fault condition. +* Allow users to hard-code if the ts pin is not used to work +* around this problem. Note that this requires the battery +* be correctly defined in the device tree with a monitored +* battery node. +*/ +if (axp_batt->ts_disable) { +regmap_update_bits (axp_batt->regmap, +AXP717_TS_PIN_CFG , +AXP717_TS_PIN_DISABLE , +AXP717_TS_PIN_DISABLE ); + } +if (vmin >0 &&axp717_set_voltage_min_design (axp_batt, vmin))dev_err (&pdev->dev,"couldn't set voltage_min_design\n" );Signature · 1 line
2.43.0
PATCH v2 4/4 arm64: dts: allwinner: rg35xx: Add no-thermistor property for battery
In reply to Chris MorganFrom: Chris Morgan <[email protected]>
Add the property of x-powers,no-thermistor for the battery of the Anbernic RG35XX series of H700 devices.
--- .../boot/dts/allwinner/sun50i-h700-anbernic-rg35xx-2024.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/allwinner/sun50i-h700-anbernic-rg35xx-2024.dts +1 -0
@@ -237,6 +237,7 @@ axp_adc: adc { battery_power: battery-power { compatible = "x-powers,axp717-battery-power-supply"; monitored-battery = <&battery>; + x-powers,no-thermistor; }; regulators {
Signature · 1 line
2.43.0
Re: [PATCH V2 4/4] arm64: dts: allwinner: rg35xx: Add no-thermistor property for battery
Dne torek, 4. februar 2025 ob 16:58:34 Srednjeevropski standardni čas je Chris Morgan napisal(a):
Quoted 6 lines
From: Chris Morgan <[email protected]>
Add the property of x-powers,no-thermistor for the battery of the Anbernic RG35XX series of H700 devices.
Signed-off-by Chris Morgan <[email protected]>
Best regards,
Jernej
Sebastian Reichel
AppliedRe: (subset) [PATCH V2 0/4] Fix RG35XX Battery Charging Issues
In reply to Chris MorganQuoted 11 lines · Chris Morgan
From: Chris Morgan <[email protected]>
The Anbernic RG35XX devices sometimes fail to charge when the register for the battery temperature sensor is set to the incorrect value either by user error or an incorrectly programmed efuse. Allow users to hard-code if a temperature sensor is not present (which is the case for all Anbernic RGxx series devices) to prevent this issue from causing problems. Additionally, a bug was identified with the handling of PMU faults while this fix was being tested.
[...]
Applied, thanks!
[1/4] dt-bindings: power: supply: axp20x-battery: Add x-powers,no-thermistor
commit: 626006541069d4d595128f03cc3a1b70a482805c
[3/4] power: supply: axp20x_battery: Update temp sensor for AXP717 from device tree
commit: bbcfe510ecd47f2db4c8653c7dfa9dc7a55b1583Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>
Chen-Yu Tsai
AppliedRe: (subset) [PATCH V2 0/4] Fix RG35XX Battery Charging Issues
In reply to Chris MorganQuoted 11 lines · Chris Morgan
From: Chris Morgan <[email protected]>
The Anbernic RG35XX devices sometimes fail to charge when the register for the battery temperature sensor is set to the incorrect value either by user error or an incorrectly programmed efuse. Allow users to hard-code if a temperature sensor is not present (which is the case for all Anbernic RGxx series devices) to prevent this issue from causing problems. Additionally, a bug was identified with the handling of PMU faults while this fix was being tested.
[...]
Applied to dt-for-6.15 in [email protected]:linux-sunxi/linux-sunxi.git, thanks!
[4/4] arm64: dts: allwinner: rg35xx: Add no-thermistor property for battery
commit: c2eedcafb0e2613d44f57d7a8b416d752d76a15f
Best regards,
Signature · 1 line
Chen-Yu Tsai <[email protected]>