On Sat, Feb 1, 2025 at 7:17 AM Chris Morgan <macroalpha82@xxxxxxxxx> wrote: > > From: Chris Morgan <macromorgan@xxxxxxxxxxx> > > 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 <macromorgan@xxxxxxxxxxx> > --- > drivers/power/supply/axp20x_battery.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c > index 3c3158f31a48..345a1bbe50ad 100644 > --- a/drivers/power/supply/axp20x_battery.c > +++ b/drivers/power/supply/axp20x_battery.c > @@ -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,22 @@ 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. AFAICT this function won't get run if there is no "monitored-battery" property under the PMIC node. So if someone were to unfortunately have a dev board that has a PMIC with incorrect efuse values, this won't save them. This should be exceedingly rare, so I only ask that you mention this in the comment so if someone does unfortunately run into it they will have some clue. Thanks ChenYu > + */ > + 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"); > -- > 2.43.0 >