[PATCH 2/6] power: supply: max77759: report charge voltage in uV
From: André Draszik
Date: Fri Nov 27 2026 - 14:10:09 EST
The max77759 charger power supply reports constant_charge_voltage_max
in millivolts instead of microvolts (for example
POWER_SUPPLY_CONSTANT_CHARGE_VOLTAGE_MAX=4300 instead of 4300000 in
sysfs), violating the power_supply ABI.
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX is defined in microvolts,
but chg_cv_prm_ranges, CHG_FV_DEFAULT_MV, get_float_voltage(), and
set_float_voltage_limit() operate in millivolts, and
max77759_charger_init() divides constant_charge_voltage_max_uv by 1000.
Convert chg_cv_prm_ranges and the float-voltage helpers to microvolts
so the driver reports and programs CONSTANT_CHARGE_VOLTAGE_MAX in uV.
Fixes: 70d7dd27f6dc ("power: supply: max77759: add charger driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: André Draszik <andre.draszik@xxxxxxxxxx>
---
drivers/power/supply/max77759_charger.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/power/supply/max77759_charger.c b/drivers/power/supply/max77759_charger.c
index a75005c0b582..6876ae0a8188 100644
--- a/drivers/power/supply/max77759_charger.c
+++ b/drivers/power/supply/max77759_charger.c
@@ -25,7 +25,7 @@
/* Default values for Fast Charge Current & Float Voltage */
#define CHG_CC_DEFAULT_UA 2266770
-#define CHG_FV_DEFAULT_MV 4300
+#define CHG_FV_DEFAULT_UV 4300000
#define MAX_NUM_RETRIES 3
#define PSY_WORK_RETRY_DELAY_MS 10
@@ -60,10 +60,10 @@ static const struct linear_range chgcc_limit_ranges[] = {
LINEAR_RANGE(200000, 0x3, 0x3C, 66670),
};
-/* Charge Termination Voltage Limits (in mV) */
+/* Charge Termination Voltage Limits (in uV) */
static const struct linear_range chg_cv_prm_ranges[] = {
- LINEAR_RANGE(3800, 0x38, 0x39, 100),
- LINEAR_RANGE(4000, 0x0, 0x32, 10),
+ LINEAR_RANGE(3800000, 0x38, 0x39, 100000),
+ LINEAR_RANGE(4000000, 0x0, 0x32, 10000),
};
/* USB input current limits (in uA) */
@@ -310,14 +310,14 @@ static int get_float_voltage(struct max77759_charger *chg)
return ret ? ret : val;
}
-static int set_float_voltage_limit(struct max77759_charger *chg, u32 fv_mv)
+static int set_float_voltage_limit(struct max77759_charger *chg, u32 fv_uv)
{
u32 regval;
bool found;
linear_range_get_selector_high_array(chg_cv_prm_ranges,
ARRAY_SIZE(chg_cv_prm_ranges),
- fv_mv, ®val, &found);
+ fv_uv, ®val, &found);
if (!found)
return -EINVAL;
@@ -555,10 +555,10 @@ static int max77759_charger_init(struct max77759_charger *chg)
return ret;
if (power_supply_get_battery_info(chg->psy, &info)) {
- fv = CHG_FV_DEFAULT_MV;
+ fv = CHG_FV_DEFAULT_UV;
fast_chg_curr = CHG_CC_DEFAULT_UA;
} else {
- fv = info->constant_charge_voltage_max_uv / 1000;
+ fv = info->constant_charge_voltage_max_uv;
fast_chg_curr = info->constant_charge_current_max_ua;
}
--
2.56.1.839.g22a8290db9-goog