From 16dd7a780e64bc3651f733406ef05677e31eb08e Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Sun, 15 Nov 2026 11:01:04 -0500 Subject: [PATCH] power: supply: max77759: let the charger set its own input current With no Type-C port controller to report the source, the driver charges at default_ilim_ua and relies on the charger to raise the input current itself, following the Rp the source advertises. It can do that only while NO_AUTOIBUS (CHG_CNFG_09 bit 7) is clear, and nothing in the driver ever cleared it. Something before the kernel can leave the bit set, most likely the bootloader: the one case seen was a Pixel 7 Pro that booted from an empty battery, with CHG_CNFG_09 reading 0x93, the 500 mA limit with NO_AUTOIBUS set. The input stayed at 500 mA, which a phone in use draws in full, so the battery current sat between -145 and +26 mA on the cable. Clearing the bit by hand (0x13, also its power-on value) took it to +1.41 A within a second, and it stayed there. Google's driver sets NO_AUTOIBUS, but it also programs the input limit from the source its USB-PD stack negotiated. This driver doesn't know the source on the default path, so clear the bit there. A failure only warns: failing the probe would leave the charger running without the temperature guard. The found: and probed: lines show "(NO_AUTOIBUS set)" while it is set, so a log tells the two cases apart. psy_work_item() doesn't touch the bit; probe clears it on any phone with default_ilim_ua set, with or without TCPM (none has both today). On a boot with the bit already clear, the regmap cache, filled from the hardware at MFD probe, skips the write. Fixes: f9c0e84d2f14 ("power: supply: max77759: charge at a default input limit without a source report") Link: https://github.com/derekross/omarchy-mobile/issues/169 Assisted-by: Claude Opus 5.5 --- drivers/power/supply/max77759_charger.c | 22 +++++++++++++++++++--- include/linux/mfd/max77759.h | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/max77759_charger.c b/drivers/power/supply/max77759_charger.c index a264e828f7..5e8bc7b4b6 100644 --- a/drivers/power/supply/max77759_charger.c +++ b/drivers/power/supply/max77759_charger.c @@ -786,6 +786,14 @@ static void max_tcpci_unregister_psy_notifier(void *nb) * Without a Type-C port controller nothing ever reports a source, so start * charging at the default input current limit right away, as the * bootloader left it (CHG_BUCK_ON). + * + * Nothing here learns what the source can give, so let the charger raise + * its input current from what the source advertises: clear NO_AUTOIBUS. + * Something before us can leave it set (it was, at a boot from a flat + * battery), and then the input stays at the default limit, which a phone + * in use draws in full, so the battery gains nothing on the cable. If the + * write fails, carry on at the default limit rather than fail the probe + * and lose the temperature guard. */ static int max77759_charger_start_default(struct max77759_charger *chg) { @@ -795,6 +803,11 @@ static int max77759_charger_start_default(struct max77759_charger *chg) if (ret) return ret; + ret = regmap_update_bits(chg->regmap, MAX77759_CHGR_REG_CHG_CNFG_09, + MAX77759_CHGR_REG_CHG_CNFG_09_NO_AUTOIBUS, 0); + if (ret) + dev_warn(chg->dev, "Failed to clear NO_AUTOIBUS, ret=%d\n", ret); + return charger_set_mode(chg, MAX77759_CHGR_MODE_CHG_BUCK_ON); } @@ -985,13 +998,16 @@ static void max77759_charger_log_state(struct max77759_charger *chg, int fv = get_float_voltage(chg); int cc = get_fast_charge_current(chg); int ilim = get_input_current_limit(chg); - u32 cnfg_00 = 0; + u32 cnfg_00 = 0, cnfg_09 = 0; regmap_read(chg->regmap, MAX77759_CHGR_REG_CHG_CNFG_00, &cnfg_00); + regmap_read(chg->regmap, MAX77759_CHGR_REG_CHG_CNFG_09, &cnfg_09); dev_info(chg->dev, - "%s: mode %#lx, float voltage %d mV, fast charge %d uA, input limit %d uA\n", + "%s: mode %#lx, float voltage %d mV, fast charge %d uA, input limit %d uA%s\n", when, FIELD_GET(MAX77759_CHGR_REG_CHG_CNFG_00_MODE, cnfg_00), - fv, cc, ilim); + fv, cc, ilim, + cnfg_09 & MAX77759_CHGR_REG_CHG_CNFG_09_NO_AUTOIBUS ? + " (NO_AUTOIBUS set)" : ""); } static int max77759_charger_probe(struct platform_device *pdev) diff --git a/include/linux/mfd/max77759.h b/include/linux/mfd/max77759.h index 4c04a600a6..7e38fe109a 100644 --- a/include/linux/mfd/max77759.h +++ b/include/linux/mfd/max77759.h @@ -104,6 +104,7 @@ #define MAX77759_CHGR_REG_CHG_CNFG_08 0xc1 #define MAX77759_CHGR_REG_CHG_CNFG_09 0xc2 #define MAX77759_CHGR_REG_CHG_CNFG_09_CHGIN_ILIM GENMASK(6, 0) +#define MAX77759_CHGR_REG_CHG_CNFG_09_NO_AUTOIBUS BIT(7) #define MAX77759_CHGR_REG_CHG_CNFG_10 0xc3 #define MAX77759_CHGR_REG_CHG_CNFG_11 0xc4 #define MAX77759_CHGR_REG_CHG_CNFG_12 0xc5