From nobody Sat Jul 25 03:20:56 2026 Received: from outbound.ci.icloud.com (ci-2001l-snip4-5.eps.apple.com [57.103.91.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D54C620B80B for ; Mon, 20 Jul 2026 01:12:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.91.118 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784509933; cv=none; b=HmKbmqBvSJZR2+VmP+dGEEgFrpoXNYBOP6gAFWl0n+n+6Xnxgz2qJrtbis1mtTXnSZhP885noB62zKJJix69j6yvDr6xM4OycRqg4P+a+aN4z0ni+v2fZCuI/f4Xd8txxYwZjlYO4OjllxVBwjeUJ7lVm0ZBBGWmIFWgNnOeHNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784509933; c=relaxed/simple; bh=WuWCkEdvrb2h4vS91JHngedGnQPfvRM7UhLzbRwVLHM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=imhGeulsN1RDCC8l42rYqGTDLPrclNUyPKUfdIiRIYOleJoXAASsB/j1r6P50BnlzM7KWQ0egFmUTa6MRdmQz8Gem5kiVohAakXWvlUgIsGvjOTfnU9yixM7xY6Mh9VlUH/d+xQwDNyvCHgkFKeRiSgzQhjPTGoyCckU/i4MWSM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=VjtoIe2Z; arc=none smtp.client-ip=57.103.91.118 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="VjtoIe2Z" Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-1 (Postfix) with ESMTPS id D632C18000F3; Mon, 20 Jul 2026 01:12:08 +0000 (UTC) X-ICL-RepId: 019f7d14-9572-7b08-8d1e-40d5255d4b78 X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQhPAEMGXAVeC1YBXwFLVxQEDloDVA5cBBcbXwJCH1sVSzhaDlsERxQXG1wAFw1WTVAbXwJCDxwTVhUTH1RWA0IZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1QG18CQg8cE1YVEwBeDw9MC0gBWwdcAEAJSQJcA18cQQtAA18GUh9CFA5aA1QOXAQXG18CQh9bFUs4Wg5bBEcUFxtcAAlLRglJHQ4EVAddBV0= Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1784509930; x=1787101930; bh=i8a/m1R9oqsx6t0nI7k2MPlYERLMh/6Ev5E/3vcDxuU=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=VjtoIe2ZksE4gm/hPr3wkUZDH4Se80zAUaNE1eiFcjjrfD4ZcUt02wa19CEwTmmVlaAPpTyRNGzg5Cq+EMU59FvhmqlOgUgaEtod/5SRM9JLQGYXbLXwIYCtYuUNHTmLC3nwk3e8NZHXRnljY6FAFeUeileIlMUFwW1YRslDomEWxo5njcB8BemkEt0VZWNffqDCwLi9OFbPTvrPYNhzqEQHYxc73QQIrCYGg77RgSJu+MRHrVKokv99k/qg7s+32h+4zOsnjSyopTNHH5VCfWn1OrUeRIoKNLRcrEbS2sNpYnyQTlhsm0CGppAvRyqi9+ft+oGC1YBVsqvHCT6VSw== Received: from bigre.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-1 (Postfix) with ESMTPSA id D9B791800096; Mon, 20 Jul 2026 01:12:07 +0000 (UTC) From: Vincent Cloutier To: Sebastian Reichel Cc: Hans de Goede , Krzysztof Kozlowski , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Rob Herring , Conor Dooley , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Cloutier Subject: [PATCH v2 1/4] power: supply: Add registration init callback Date: Sun, 19 Jul 2026 21:11:37 -0400 Message-ID: <20260720011144.1280219-2-vincent.cloutier@icloud.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260720011144.1280219-1-vincent.cloutier@icloud.com> References: <20260720011144.1280219-1-vincent.cloutier@icloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: wMXmgb0c-kUkJ7eoY8hNL-V5Lp7AI4a3 X-Proofpoint-ORIG-GUID: wMXmgb0c-kUkJ7eoY8hNL-V5Lp7AI4a3 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIwMDAwOSBTYWx0ZWRfX4Gy+6QqrNwhU QiNMHwFHNe0hiNBiCNl8kgv2Vo3uKDANk5P0NaCyckXNmCJ+FAcDC9jYJzFkGJOZH9/iTlM2KA/ sqNkW5VJrLoW7RHk3C+eyeSXMvra5Qwq5XYTg34JA3xpfaWp5MmI9/vhRB9Ygs3d8XiGysrK+8x kLCwySdGfYSj7BwgBZ9XsAratMjZDCoRKhKl9gLaVjWH/qsV4J91FbkzYRzhFT5W5+SezOX8WFh oFwrAr9Tok2MP/DYwffPIazzgNM1ifMOkXsw7592Bb83tl51NWUhTJ0mxB3OuJgYoMBIWPLsqxO 0g3qeRkQ7wgBmLZCTOe Content-Type: text/plain; charset="utf-8" From: Vincent Cloutier Some battery drivers need to consume monitored-battery data before their power_supply is visible. That lets them prepare hardware configuration from parsed battery information without racing userspace exposure. power_supply_get_battery_info() already runs in __power_supply_register() for battery devices before device_add(). Add an optional descriptor init callback after driver data and battery info are available. The callback runs in sleepable process context while the power supply is still unpublished. Require callbacks to return zero or a negative errno. Defensively reject positive returns so registration cannot return an invalid error pointer. Assisted-by: OpenCode:gpt-5.6-sol Signed-off-by: Vincent Cloutier --- drivers/power/supply/power_supply_core.c | 8 ++++++++ include/linux/power_supply.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/suppl= y/power_supply_core.c index 2532e221b2e1..3ed4c253706f 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -1624,6 +1624,14 @@ __power_supply_register(struct device *parent, init_rwsem(&psy->extensions_sem); INIT_LIST_HEAD(&psy->extensions); =20 + if (desc->init) { + rc =3D desc->init(psy); + if (WARN_ON_ONCE(rc > 0)) + rc =3D -EINVAL; + if (rc) + goto check_supplies_failed; + } + rc =3D device_add(dev); if (rc) goto device_add_failed; diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 7a5e4c3242a0..6042f5e1fdc2 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -281,6 +281,14 @@ struct power_supply_desc { int (*property_is_writeable)(struct power_supply *psy, enum power_supply_property psp); void (*external_power_changed)(struct power_supply *psy); + /* + * Optional registration-time initialization. This runs in sleepable + * process context after driver data and any battery info are available, + * but before the device is added. The callback must not publish changes + * because registration is not complete. Return 0 on success or a negative + * errno on failure. + */ + int (*init)(struct power_supply *psy); =20 /* * Set if thermal zone should not be created for this power supply. --=20 2.55.0 From nobody Sat Jul 25 03:20:56 2026 Received: from outbound.ci.icloud.com (ci-2001e-snip4-2.eps.apple.com [57.103.91.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B782F221D89 for ; Mon, 20 Jul 2026 01:12:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.91.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784509935; cv=none; b=cZJ0IzXwMZvHk1zXasyTPxzJbVxkzXrsNSnfwTbsCIkM18xV0RrzrgB++0q51RPBqRPNmdxnNnd/Vbr+KBSW7qcPUQFqvA9wLTbyh8pDv/iP/NaumNPH1fotTyCSGF7tlRhKxDCQeZfqdP5cx0WJEgXvac/bbJdv6bA9zJHI2So= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784509935; c=relaxed/simple; bh=MpCEGbVhBKIlAdc1p/tHkHq4S3ljcuQWEtg0SJcUGGk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VsmYze75qUzGFPj0KRCZ3s/yDeWmmaPFBEYIwPnnPUPYPp5OwZEGR1r6uYeOY75u3FLW369rJNKjeSZ1CaGP9IJQH2B9gf9LEC7iUXMqB71v++wzWjBIejVPMRJH+6nmcy1hRUYk+93mtX8PK6kuZ2TlfYnRedl49jpqyg3MsiE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=FX6jH22Y; arc=none smtp.client-ip=57.103.91.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="FX6jH22Y" Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-1 (Postfix) with ESMTPS id 7F8CB18000F2; Mon, 20 Jul 2026 01:12:09 +0000 (UTC) X-ICL-RepId: 019f7d14-97f4-747c-9027-41ab6da51e54 X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQhPAEMGXAVeC1YBXwFLVxQEDloDVA5cBBcbXwJCH1sVSzhaDlsERxQXG1wAFw1WTVAbXwJCDxwTVhUTH1RWA0IZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1QG18CQg8cE1YVEwBeDw9MC0gBWwdcAEAJSQJcA18cQQtAA18GUh9DFA5aA1QOXAQXG18CQh9bFUs4Wg5bBEcUFxtcAAlLRglJHQ4EVAddBV0= Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1784509931; x=1787101931; bh=vAAou0ItuODHJ7VRRr9+GAd58QJ1e8SPQzYumIVrkD8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=FX6jH22YIbhw5vblqmeiLPv8cEUHET1l17rXCXK936ASWDI8xrTAIZghEYaYIQkVYCS1aaqN0lrrq8j88nHlnB6FylYemSkgsctosW/Twh3AU5wq460Ykd+6MIydiR/IgXGsD622E0INBu5YIaQksSg/wWGImU5Ww/cFxiEDdRa+BCFqpRRKR08TVZeh37xWfhspggoWG/UVR4WJH4MKJ+2FvQZ5I+H80q1iGbqBQ+b+STAOgqeaQ5m4DZF2SuN8kAV9hkH3rtbSxHKl24YalLtqCnzLVnOGueA5lNjWOcoi5XqTLASRykXiJJs408ogBCJ3d0/Xa62/iGnasPjn/Q== Received: from bigre.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-1 (Postfix) with ESMTPSA id 804C618002C4; Mon, 20 Jul 2026 01:12:08 +0000 (UTC) From: Vincent Cloutier To: Sebastian Reichel Cc: Hans de Goede , Krzysztof Kozlowski , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Rob Herring , Conor Dooley , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Cloutier Subject: [PATCH v2 2/4] power: supply: max17042_battery: Initialize MAX17055 from battery info Date: Sun, 19 Jul 2026 21:11:38 -0400 Message-ID: <20260720011144.1280219-3-vincent.cloutier@icloud.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260720011144.1280219-1-vincent.cloutier@icloud.com> References: <20260720011144.1280219-1-vincent.cloutier@icloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 6QU3N45KQhPWYR2VwfoQYJZOaFU-sR5_ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIwMDAwOSBTYWx0ZWRfXzS1qDRVjivHK q+K0LvtzyDDng9e5BaWd5+aMGR7NwUDCimGBUdCWHlTfVFLf0i6gApxFxrehOVoyBWp3RUdyI9Q QawLu3oiyS7V4FE7kdWl5avS74z2vi0iAq8E6adwMdj0jvgwUnCf+iMjFI5Vr+Pm1db+2RDVgia 1wU/2lBDWPNlbCXNue6zysPRKqKK47qs2qslC391UAIpDDTrUVh3u3m53iSNdI0KrJhFh1sWVdE PJar5RQPy9bOlVt6j+KlDvZaNcYb7rzSYd29ScftEDg96oMjTSnQ3nzVMQPB713XrzfyQmiENdL QLSvEZ7HhLCqgceJ+fo X-Proofpoint-GUID: 6QU3N45KQhPWYR2VwfoQYJZOaFU-sR5_ From: Vincent Cloutier MAX17055 can use charge-full-design-microamp-hours and charge-term-current-microamp from monitored-battery for its POR configuration. Prepare quantized DesignCap, IChgTerm, and EZ Config dQAcc values in the power-supply registration callback after the core has parsed battery information. Validate all supplied values before changing the sparse configuration. Reject zero, values that quantize to zero, capacities that cannot produce dQAcc, and positive termination currents outside the signed register range. Limit this path to MAX17055 because the other supported gauges require complete characterization data. Follow the documented POR sequence. Wait for FSTAT.DNR, save HibCfg, exit hibernate, write stable battery registers once and verify them after 1 ms, issue command writes directly, poll until refresh clears, and restore HibCfg. Clear POR only after every step succeeds. Keep driver-backed properties unavailable while initialization is incomplete. If an I/O error interrupts the transaction, restore hibernate before the next attempt and retry periodically so a transient startup failure does not become permanent. Assisted-by: OpenCode:gpt-5.6-sol Signed-off-by: Vincent Cloutier --- drivers/power/supply/max17042_battery.c | 335 +++++++++++++++++++++--- include/linux/power/max17042_battery.h | 2 + 2 files changed, 306 insertions(+), 31 deletions(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply= /max17042_battery.c index d409d2f0d383..b25bf26135e0 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -62,18 +62,30 @@ #define MAX17042_RESISTANCE_LSB 1 / 4096 /* =CE=A9 */ #define MAX17042_TEMPERATURE_LSB 1 / 256 /* =C2=B0C */ =20 +#define MAX17055_DQACC_DIV 32 +#define MAX17055_DPACC_FACTOR 44138 +#define MAX17055_DPACC_VCHG_FACTOR 51200 +#define MAX17055_FSTAT_DNR_BIT BIT(0) +#define MAX17055_DNR_POLL_US 10000 +#define MAX17055_DNR_TIMEOUT_US 2000000 +#define MAX17055_INIT_RETRY_DELAY_MS 10000 +#define MAX17055_REFRESH_POLL_US 10000 +#define MAX17055_REFRESH_TIMEOUT_US 1000000 + struct max17042_chip { struct device *dev; struct regmap *regmap; struct power_supply *battery; enum max170xx_chip_type chip_type; struct max17042_config_data *config_data; - struct work_struct work; - int init_complete; + struct delayed_work work; int irq; int task_period; bool enable_current_sense; bool enable_por_init; + bool init_complete; + bool hib_restore_pending; + u16 hib_cfg; unsigned int r_sns; int vmin; /* in millivolts */ int vmax; /* in millivolts */ @@ -256,7 +268,7 @@ static int max17042_get_property(struct power_supply *p= sy, u32 data; u64 data64; =20 - if (!chip->init_complete) + if (!READ_ONCE(chip->init_complete)) return -EAGAIN; =20 switch (psp) { @@ -566,6 +578,24 @@ static int max17042_write_verify_reg(struct regmap *ma= p, u8 reg, u32 value) return ret; } =20 +static int max17055_write_verify_reg(struct regmap *map, u8 reg, u32 value) +{ + u32 read_value; + int ret; + + ret =3D regmap_write(map, reg, value); + if (ret) + return ret; + + usleep_range(1000, 2000); + + ret =3D regmap_read(map, reg, &read_value); + if (ret) + return ret; + + return read_value =3D=3D value ? 0 : -EIO; +} + static inline void max17042_override_por(struct regmap *map, u8 reg, u16 value) { @@ -801,8 +831,12 @@ static inline void max17042_override_por_values(struct= max17042_chip *chip) max17042_override_por(map, MAX17042_CONFIG, config->config); max17042_override_por(map, MAX17042_SHDNTIMER, config->shdntimer); =20 - max17042_override_por(map, MAX17042_DesignCap, config->design_cap); - max17042_override_por(map, MAX17042_ICHGTerm, config->ichgt_term); + if (chip->chip_type !=3D MAXIM_DEVICE_TYPE_MAX17055) { + max17042_override_por(map, MAX17042_DesignCap, + config->design_cap); + max17042_override_por(map, MAX17042_ICHGTerm, + config->ichgt_term); + } =20 max17042_override_por(map, MAX17042_AtRate, config->at_rate); max17042_override_por(map, MAX17042_LearnCFG, config->learn_cfg); @@ -812,8 +846,10 @@ static inline void max17042_override_por_values(struct= max17042_chip *chip) =20 max17042_override_por(map, MAX17042_FullCAP, config->fullcap); max17042_override_por(map, MAX17042_FullCAPNom, config->fullcapnom); - max17042_override_por(map, MAX17042_dQacc, config->dqacc); - max17042_override_por(map, MAX17042_dPacc, config->dpacc); + if (chip->chip_type !=3D MAXIM_DEVICE_TYPE_MAX17055) { + max17042_override_por(map, MAX17042_dQacc, config->dqacc); + max17042_override_por(map, MAX17042_dPacc, config->dpacc); + } =20 max17042_override_por(map, MAX17042_RCOMP0, config->rcomp0); max17042_override_por(map, MAX17042_TempCo, config->tcompc0); @@ -847,26 +883,162 @@ static inline void max17042_override_por_values(stru= ct max17042_chip *chip) max17042_override_por(map, MAX17055_ModelCfg, config->model_cfg); } =20 -static int max17042_init_chip(struct max17042_chip *chip) +static int max17055_override_battery_values(struct max17042_chip *chip) { + struct max17042_config_data *config =3D chip->config_data; struct regmap *map =3D chip->regmap; + unsigned int design_cap; + unsigned int model_cfg; + unsigned int dqacc; + u64 dpacc; int ret; =20 + if (config->design_cap) { + ret =3D max17055_write_verify_reg(map, MAX17042_DesignCap, + config->design_cap); + if (ret) + return ret; + } + + if (config->dqacc) { + ret =3D max17055_write_verify_reg(map, MAX17042_dQacc, + config->dqacc); + if (ret) + return ret; + } + + if (config->ichgt_term) { + ret =3D max17055_write_verify_reg(map, MAX17042_ICHGTerm, + config->ichgt_term); + if (ret) + return ret; + } + + if (!config->design_cap && !config->dqacc) + return 0; + + ret =3D regmap_read(map, MAX17042_DesignCap, &design_cap); + if (ret) + return ret; + + ret =3D regmap_read(map, MAX17042_dQacc, &dqacc); + if (ret) + return ret; + + ret =3D regmap_read(map, MAX17055_ModelCfg, &model_cfg); + if (ret) + return ret; + + if (!design_cap || !dqacc) + return -ERANGE; + + dpacc =3D (u64)dqacc * + (model_cfg & MAX17055_MODELCFG_VCHG_BIT ? + MAX17055_DPACC_VCHG_FACTOR : MAX17055_DPACC_FACTOR); + do_div(dpacc, design_cap); + if (dpacc > U16_MAX) + return -ERANGE; + + return max17055_write_verify_reg(map, MAX17042_dPacc, (u16)dpacc); +} + +static int max17055_restore_hibernate(struct max17042_chip *chip) +{ + int restore_hib_ret; + int soft_wakeup_ret; + + soft_wakeup_ret =3D regmap_write(chip->regmap, MAX17055_SoftWakeup, 0); + restore_hib_ret =3D max17055_write_verify_reg(chip->regmap, + MAX17055_HibCfg, + chip->hib_cfg); + if (!soft_wakeup_ret && !restore_hib_ret) + chip->hib_restore_pending =3D false; + + return soft_wakeup_ret ?: restore_hib_ret; +} + +static int max17055_init_chip(struct max17042_chip *chip) +{ + struct regmap *map =3D chip->regmap; + unsigned int hib_cfg; + unsigned int model_cfg; + unsigned int fstat; + int restore_ret; + int ret; + + if (chip->hib_restore_pending) { + ret =3D max17055_restore_hibernate(chip); + if (ret) + return ret; + } + + ret =3D regmap_read_poll_timeout(map, MAX17042_FSTAT, fstat, + !(fstat & MAX17055_FSTAT_DNR_BIT), + MAX17055_DNR_POLL_US, + MAX17055_DNR_TIMEOUT_US); + if (ret) + return ret; + + ret =3D regmap_read(map, MAX17055_HibCfg, &hib_cfg); + if (ret) + return ret; + + chip->hib_cfg =3D hib_cfg; + chip->hib_restore_pending =3D true; + + ret =3D regmap_write(map, MAX17055_SoftWakeup, 0x0090); + if (ret) + goto restore_hibernate; + + ret =3D max17055_write_verify_reg(map, MAX17055_HibCfg, 0); + if (ret) + goto restore_hibernate; + + ret =3D regmap_write(map, MAX17055_SoftWakeup, 0); + if (ret) + goto restore_hibernate; + max17042_override_por_values(chip); =20 + ret =3D max17055_override_battery_values(chip); + if (ret) + goto restore_hibernate; + + ret =3D regmap_write_bits(map, MAX17055_ModelCfg, + MAX17055_MODELCFG_REFRESH_BIT, + MAX17055_MODELCFG_REFRESH_BIT); + if (ret) + goto restore_hibernate; + + ret =3D regmap_read_poll_timeout(map, MAX17055_ModelCfg, model_cfg, + !(model_cfg & + MAX17055_MODELCFG_REFRESH_BIT), + MAX17055_REFRESH_POLL_US, + MAX17055_REFRESH_TIMEOUT_US); + +restore_hibernate: + restore_ret =3D max17055_restore_hibernate(chip); + if (restore_ret) + return restore_ret; + + return ret; +} + +static int max17042_init_chip(struct max17042_chip *chip) +{ + struct regmap *map =3D chip->regmap; + int ret; + if (chip->chip_type =3D=3D MAXIM_DEVICE_TYPE_MAX17055) { - regmap_write_bits(map, MAX17055_ModelCfg, - MAX17055_MODELCFG_REFRESH_BIT, - MAX17055_MODELCFG_REFRESH_BIT); - } + ret =3D max17055_init_chip(chip); + if (ret) + return ret; + } else { + max17042_override_por_values(chip); =20 - /* After Power up, the MAX17042 requires 500mS in order - * to perform signal debouncing and initial SOC reporting - */ - msleep(500); + /* Allow signal debouncing and initial SOC reporting. */ + msleep(500); =20 - if (chip->chip_type !=3D MAXIM_DEVICE_TYPE_MAX17055) { - /* Initialize configuration */ max17042_write_config_regs(chip); =20 /* write cell characterization data */ @@ -902,8 +1074,7 @@ static int max17042_init_chip(struct max17042_chip *ch= ip) } =20 /* Init complete, Clear the POR bit */ - regmap_update_bits(map, MAX17042_STATUS, STATUS_POR_BIT, 0x0); - return 0; + return regmap_clear_bits(map, MAX17042_STATUS, STATUS_POR_BIT); } =20 static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off) @@ -989,18 +1160,28 @@ static irqreturn_t max17042_thread_handler(int id, v= oid *dev) =20 static void max17042_init_worker(struct work_struct *work) { - struct max17042_chip *chip =3D container_of(work, + struct max17042_chip *chip =3D container_of(to_delayed_work(work), struct max17042_chip, work); - int ret; + int ret =3D 0; =20 /* Initialize registers according to values from config_data */ - if (chip->enable_por_init && chip->config_data) { + if (chip->enable_por_init && chip->config_data) ret =3D max17042_init_chip(chip); - if (ret) - return; + + if (ret) { + if (chip->chip_type =3D=3D MAXIM_DEVICE_TYPE_MAX17055) { + dev_warn_ratelimited(chip->dev, + "initialization failed: %d, retrying\n", ret); + queue_delayed_work(system_freezable_wq, &chip->work, + msecs_to_jiffies(MAX17055_INIT_RETRY_DELAY_MS)); + } else { + dev_err(chip->dev, "initialization failed: %d\n", ret); + } + return; } =20 - chip->init_complete =3D 1; + WRITE_ONCE(chip->init_complete, true); + power_supply_changed(chip->battery); } =20 #ifdef CONFIG_OF @@ -1060,6 +1241,93 @@ static int max17042_init_defaults(struct max17042_ch= ip *chip) return 0; } =20 +static int max17042_apply_battery_properties(struct max17042_chip *chip, + struct power_supply_battery_info *info) +{ + struct max17042_config_data *config; + struct device *dev =3D chip->dev; + bool have_design_cap; + bool have_ichgt_term; + u16 design_cap =3D 0; + u16 ichgt_term =3D 0; + u16 dqacc =3D 0; + u64 data64; + + if (!info || chip->chip_type !=3D MAXIM_DEVICE_TYPE_MAX17055) + return 0; + + have_design_cap =3D chip->enable_current_sense && + info->charge_full_design_uah >=3D 0; + have_ichgt_term =3D chip->enable_current_sense && + info->charge_term_current_ua >=3D 0; + if (!have_design_cap && !have_ichgt_term) + return 0; + + if (have_design_cap) { + if (!info->charge_full_design_uah) + return dev_err_probe(dev, -EINVAL, + "battery design capacity must be positive\n"); + + data64 =3D (u64)info->charge_full_design_uah * chip->r_sns; + do_div(data64, MAX17042_CAPACITY_LSB); + if (!data64) + return dev_err_probe(dev, -ERANGE, + "battery design capacity is too small for sense resistor\n"); + if (data64 > U16_MAX) + return dev_err_probe(dev, -ERANGE, + "battery design capacity exceeds register range\n"); + + design_cap =3D (u16)data64; + dqacc =3D design_cap / MAX17055_DQACC_DIV; + if (!dqacc) + return dev_err_probe(dev, -ERANGE, + "battery design capacity is too small for EZ config\n"); + } + + if (have_ichgt_term) { + if (!info->charge_term_current_ua) + return dev_err_probe(dev, -EINVAL, + "charge termination current must be positive\n"); + + data64 =3D (u64)info->charge_term_current_ua * chip->r_sns; + do_div(data64, MAX17042_CURRENT_LSB); + if (!data64) + return dev_err_probe(dev, -ERANGE, + "charge termination current is too small for sense resistor\n"); + if (data64 > S16_MAX) + return dev_err_probe(dev, -ERANGE, + "charge termination current exceeds positive register range\n"); + + ichgt_term =3D (u16)data64; + } + + config =3D chip->config_data; + if (!config) { + config =3D devm_kzalloc(dev, sizeof(*config), GFP_KERNEL); + if (!config) + return -ENOMEM; + } + + if (have_design_cap) { + config->design_cap =3D design_cap; + config->dqacc =3D dqacc; + } + if (have_ichgt_term) + config->ichgt_term =3D ichgt_term; + + chip->config_data =3D config; + chip->enable_por_init =3D true; + + return 0; +} + +static int max17042_init_battery(struct power_supply *psy) +{ + struct max17042_chip *chip =3D power_supply_get_drvdata(psy); + + return max17042_apply_battery_properties(chip, psy->battery_info); +} + static const struct regmap_config max17042_regmap_config =3D { .name =3D "max17042", .reg_bits =3D 8, @@ -1113,6 +1381,7 @@ static const struct power_supply_desc max17042_psy_de= sc =3D { .set_property =3D max17042_set_property, .property_is_writeable =3D max17042_property_is_writeable, .external_power_changed =3D power_supply_changed, + .init =3D max17042_init_battery, .properties =3D max17042_battery_props, .num_properties =3D ARRAY_SIZE(max17042_battery_props), }; @@ -1123,6 +1392,7 @@ static const struct power_supply_desc max17042_no_cur= rent_sense_psy_desc =3D { .get_property =3D max17042_get_property, .set_property =3D max17042_set_property, .property_is_writeable =3D max17042_property_is_writeable, + .init =3D max17042_init_battery, .properties =3D max17042_battery_props, .num_properties =3D ARRAY_SIZE(max17042_battery_props) - 2, }; @@ -1242,15 +1512,18 @@ static int max17042_probe(struct i2c_client *client= , struct device *dev, int irq =20 chip->irq =3D irq; =20 - regmap_read(chip->regmap, MAX17042_STATUS, &val); + ret =3D regmap_read(chip->regmap, MAX17042_STATUS, &val); + if (ret) + return dev_err_probe(dev, ret, "failed to read status\n"); + if (val & STATUS_POR_BIT) { - ret =3D devm_work_autocancel(dev, &chip->work, - max17042_init_worker); + ret =3D devm_delayed_work_autocancel(dev, &chip->work, + max17042_init_worker); if (ret) return ret; - schedule_work(&chip->work); + queue_delayed_work(system_freezable_wq, &chip->work, 0); } else { - chip->init_complete =3D 1; + WRITE_ONCE(chip->init_complete, true); } =20 return 0; diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/m= ax17042_battery.h index 13aeab1597c6..810e068eafd2 100644 --- a/include/linux/power/max17042_battery.h +++ b/include/linux/power/max17042_battery.h @@ -25,6 +25,7 @@ #define MAX17042_CHARACTERIZATION_DATA_SIZE 48 =20 #define MAX17055_MODELCFG_REFRESH_BIT BIT(15) +#define MAX17055_MODELCFG_VCHG_BIT BIT(10) =20 enum max17042_register { MAX17042_STATUS =3D 0x00, @@ -124,6 +125,7 @@ enum max17055_register { =20 MAX17055_ConvgCfg =3D 0x49, MAX17055_VFRemCap =3D 0x4A, + MAX17055_SoftWakeup =3D 0x60, =20 MAX17055_STATUS2 =3D 0xB0, MAX17055_POWER =3D 0xB1, --=20 2.55.0 From nobody Sat Jul 25 03:20:56 2026 Received: from outbound.ci.icloud.com (ci-2001a-snip4-4.eps.apple.com [57.103.91.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AF8D218E91 for ; Mon, 20 Jul 2026 01:12:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.91.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784509934; cv=none; b=huBTHQxgcmKJTwMMH6WwZJysteJiorOpJOocV4v1mcOKtTx6uyhY1XwevqinG/jv5T6QQ/7JEtrjdRfK2chYoYF9KEytLMqMGStriHjaQNRQU/Y97qqD2hYfZngOcTRGbBp+zWAiMszPhh8HNFfgEYMD2QQyKlzSzW6f7WlzoRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784509934; c=relaxed/simple; bh=zYPDk0dFuqI3SWYSbwOOATjyNJP19NdKD/Zid6+2nB0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RbuE14N20zoGHhigAPN5Zda/Zl4+KOfCdCZfrsHeHpZBcs0YxnYMiz3F5M2OambGci+Bo8V64XfQhAmS27VK8NN0pKSpnWK9Gsma70wagtrw8XIyv6pLE7yasKoFXpUm+Zp2UcTjcZgaXCoFdG4yuEEjUp6scexmNA1Tqsr9vuE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=cqpDaYjv; arc=none smtp.client-ip=57.103.91.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="cqpDaYjv" Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-1 (Postfix) with ESMTPS id 0D32618002CC; Mon, 20 Jul 2026 01:12:09 +0000 (UTC) X-ICL-RepId: 019f7d14-9a06-7b45-aae5-f5db25592786 X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQhPAEMGXAVeC1YBXwFLVxQEDloDVA5cBBcbXwJCH1sVSzhaDlsERxQXG1wAFw1WTVAbXwJCDxwTVhUTH1RWA0IZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1QG18CQg8cE1YVEwBeDw9MC0gBWwdcAEAJSQJcA18cQQtAA18GUh9EFA5aA1QOXAQXG18CQh9bFUs4Wg5bBEcUFxtcAAlLRglJHQ4EVAddBV0= Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1784509931; x=1787101931; bh=xVEkIySqC2w1VTBoBLzRmkBJvvkPdFwntWG87jLmjgU=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=cqpDaYjveEny/nal9+HhdXALvV7qV0pSegsO1UCkt8h17nAEjSZdQbAFKk95IAgMKE0vnXyT778gA0iE4iqbdYtk7LtQVU5jGtnexdOWGrXKzfvb0EkTSoln9LWxTwjNvvN/R7UKSfOIZEGlISwxI1i5sBVleiJIa0p1dTjRWTlhWB09MUaYWeq/ay6kY4yWLL7EwFzQ07HORcsf2QDBR++E2vVgSVp7skCd+p2D0wJZtBXzTSsGi1v0oDghMh64xy9Ntqec402/yxaOG461v1c+xpVUFQRUzIWokMyedtejxuinSd+ci/c3xBgXw2IIFRZrHSkeu57L1hbn9zhlBw== Received: from bigre.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-1 (Postfix) with ESMTPSA id 2562918000D0; Mon, 20 Jul 2026 01:12:09 +0000 (UTC) From: Vincent Cloutier To: Sebastian Reichel Cc: Hans de Goede , Krzysztof Kozlowski , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Rob Herring , Conor Dooley , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Cloutier Subject: [PATCH v2 3/4] power: supply: max17042_battery: Honor MAX17055 charge voltage Date: Sun, 19 Jul 2026 21:11:39 -0400 Message-ID: <20260720011144.1280219-4-vincent.cloutier@icloud.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260720011144.1280219-1-vincent.cloutier@icloud.com> References: <20260720011144.1280219-1-vincent.cloutier@icloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: LyABjPkAQbRT5k4bFAlS2Odj95fr4lDy X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIwMDAwOSBTYWx0ZWRfXyKUSy7wT73BT PVkVRz+qGnKaEwveD04JO6Jxu1s1HSTwSqlZVPaJdTCUoXBKixjUb0iIdffaEzAdjVGIG5OZdDQ xkDNftWM0siGgnXSCTNAs38k9o4PbBoiUS1SYO9WDDuEsve92Hzxieb7rxUuQiw/D2hukGV6Zd2 oV6mo10NIBk+Uli+QhjvM1lzf3/BaacYABZA9Pd8Xo6P/DVa8eWt90vwYacd5xHCk/Sp2lS67Ep Er8O0JG/h8ZdPPS9yT7+ucJwznTeWwaAXO6/RFX2Z4gyEnXxyh4z0CeCcVNrefGdvb1bpoBmRsq Ky+Ws2m72EsBYjytNVK X-Proofpoint-ORIG-GUID: LyABjPkAQbRT5k4bFAlS2Odj95fr4lDy Content-Type: text/plain; charset="utf-8" From: Vincent Cloutier MAX17055 ModelCfg.VChg selects the charge-voltage range used by EZ Config. Consume voltage-max-design-microvolt from monitored-battery and set VChg only when the value is strictly greater than 4.275 V. Reject an explicit zero voltage and preserve the register when the property is absent. Update only the VChg bit and verify its read-back so unrelated ModelCfg fields remain intact. Treat a VChg-only override as an accumulator change: read effective DesignCap and dQAcc, derive and verify the matching dPAcc, then request model refresh. This keeps voltage-only firmware descriptions coherent with the selected charge-voltage range. Assisted-by: OpenCode:gpt-5.6-sol Signed-off-by: Vincent Cloutier --- drivers/power/supply/max17042_battery.c | 42 +++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply= /max17042_battery.c index b25bf26135e0..0f6bf6d4c031 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -66,6 +66,7 @@ #define MAX17055_DPACC_FACTOR 44138 #define MAX17055_DPACC_VCHG_FACTOR 51200 #define MAX17055_FSTAT_DNR_BIT BIT(0) +#define MAX17055_VCHG_THRESHOLD_UV 4275000 #define MAX17055_DNR_POLL_US 10000 #define MAX17055_DNR_TIMEOUT_US 2000000 #define MAX17055_INIT_RETRY_DELAY_MS 10000 @@ -83,6 +84,7 @@ struct max17042_chip { int task_period; bool enable_current_sense; bool enable_por_init; + bool enable_vchg_override; bool init_complete; bool hib_restore_pending; u16 hib_cfg; @@ -879,7 +881,8 @@ static inline void max17042_override_por_values(struct = max17042_chip *chip) max17042_override_por(map, MAX17047_V_empty, config->vempty); } =20 - if (chip->chip_type =3D=3D MAXIM_DEVICE_TYPE_MAX17055) + if (chip->chip_type =3D=3D MAXIM_DEVICE_TYPE_MAX17055 && + !chip->enable_vchg_override) max17042_override_por(map, MAX17055_ModelCfg, config->model_cfg); } =20 @@ -914,7 +917,19 @@ static int max17055_override_battery_values(struct max= 17042_chip *chip) return ret; } =20 - if (!config->design_cap && !config->dqacc) + if (chip->enable_vchg_override) { + ret =3D regmap_update_bits(map, MAX17055_ModelCfg, + MAX17055_MODELCFG_VCHG_BIT, + config->model_cfg & + MAX17055_MODELCFG_VCHG_BIT); + if (ret) + return ret; + + usleep_range(1000, 2000); + } + + if (!config->design_cap && !config->dqacc && + !chip->enable_vchg_override) return 0; =20 ret =3D regmap_read(map, MAX17042_DesignCap, &design_cap); @@ -928,6 +943,10 @@ static int max17055_override_battery_values(struct max= 17042_chip *chip) ret =3D regmap_read(map, MAX17055_ModelCfg, &model_cfg); if (ret) return ret; + if (chip->enable_vchg_override && + (model_cfg & MAX17055_MODELCFG_VCHG_BIT) !=3D + (config->model_cfg & MAX17055_MODELCFG_VCHG_BIT)) + return -EIO; =20 if (!design_cap || !dqacc) return -ERANGE; @@ -1248,9 +1267,11 @@ static int max17042_apply_battery_properties(struct = max17042_chip *chip, struct device *dev =3D chip->dev; bool have_design_cap; bool have_ichgt_term; + bool have_vchg; u16 design_cap =3D 0; u16 ichgt_term =3D 0; u16 dqacc =3D 0; + u16 model_cfg =3D 0; u64 data64; =20 if (!info || chip->chip_type !=3D MAXIM_DEVICE_TYPE_MAX17055) @@ -1260,7 +1281,8 @@ static int max17042_apply_battery_properties(struct m= ax17042_chip *chip, info->charge_full_design_uah >=3D 0; have_ichgt_term =3D chip->enable_current_sense && info->charge_term_current_ua >=3D 0; - if (!have_design_cap && !have_ichgt_term) + have_vchg =3D info->voltage_max_design_uv >=3D 0; + if (!have_design_cap && !have_ichgt_term && !have_vchg) return 0; =20 if (have_design_cap) { @@ -1301,6 +1323,15 @@ static int max17042_apply_battery_properties(struct = max17042_chip *chip, ichgt_term =3D (u16)data64; } =20 + if (have_vchg) { + if (!info->voltage_max_design_uv) + return dev_err_probe(dev, -EINVAL, + "battery design voltage must be positive\n"); + + if (info->voltage_max_design_uv > MAX17055_VCHG_THRESHOLD_UV) + model_cfg =3D MAX17055_MODELCFG_VCHG_BIT; + } + config =3D chip->config_data; if (!config) { config =3D devm_kzalloc(dev, sizeof(*config), GFP_KERNEL); @@ -1314,6 +1345,11 @@ static int max17042_apply_battery_properties(struct = max17042_chip *chip, } if (have_ichgt_term) config->ichgt_term =3D ichgt_term; + if (have_vchg) { + config->model_cfg &=3D ~MAX17055_MODELCFG_VCHG_BIT; + config->model_cfg |=3D model_cfg; + chip->enable_vchg_override =3D true; + } =20 chip->config_data =3D config; chip->enable_por_init =3D true; --=20 2.55.0 From nobody Sat Jul 25 03:20:56 2026 Received: from outbound.ci.icloud.com (ci-2001a-snip4-7.eps.apple.com [57.103.91.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AEB0215F42 for ; Mon, 20 Jul 2026 01:12:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.91.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784509934; cv=none; b=eKHY+FO6hXMeg65wfRR7oTPp1fqfVayaJ/eF1h1TP3/8lnma5hgCoA0baa1duNm0l6j3lZaRvINjHPfP8dJDSFKx4iKjJFko62pWELeR4c7i48NiCuuLCjC3acQoeiu6xKaJCfgju9O+GKkB0uPlaBvMWCCfFJTghCaV/UMyt4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784509934; c=relaxed/simple; bh=25uNz86ljg3bAGG/Z1CmYUWk0Vh9f7VnCu0jiPAKa64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J6K9n9tPp5jTk8YX1NB/pNRBGDDBDAW3GxhJcxvQR7f8n40XMu4WFcbexR7Wj93uNW5F+o726n2IV7UKFJCe05ojMV99j6SFvwvNe/5KI3K5S3uy4gNgOEi0EerzKiF5Wl3lMvATdsxWTsv2YuONO1EhGVhUa1An5wo+TTb9bx0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=vjPe9IWb; arc=none smtp.client-ip=57.103.91.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="vjPe9IWb" Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-1 (Postfix) with ESMTPS id 7DEF518000C4; Mon, 20 Jul 2026 01:12:10 +0000 (UTC) X-ICL-RepId: 019f7d14-9bef-7f93-a50b-7015c6ec7745 X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQhPAEMGXAVeC1YBXwFLVxQEDloDVA5cBBcbXwJCH1sVSzhaDlsERxQXG1wAFw1WTVAbXwJCDxwTVhUTH1RWA0IZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1QG18CQg8cE1YVEwBeDw9MC0gBWwdcAEAJSQJcA18cQQtAA18GUh9FFA5aA1QOXAQXG18CQh9bFUs4Wg5bBEcUFxtcAAlLRglJHQ4EVAddBV0= Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1784509931; x=1787101931; bh=aG9BUpp65slEM0N5VcuPtHyAP0VgGPDHQ54DkQFv1ho=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=vjPe9IWbbrFoQ1FkDUm6oaYbWG9tm7MsB4Ob49ihQcSwlZb90LfKMod1GC+QLTqo3YMRU5r4DoBc0CkTzXyNKimANBu68AGMRYn2HAb+yKRLGxYGiNB3Ut1gniAo/0FmorExzeYrToIMx4BOnRw0VvjfL323HndJ1lQuslOD+wK9zckXSaVuBJWrkJjvtcF7Uj3Sg446kXchaAe641I/fjsWvXxAA6om1en6shUwK8XfCfL/mE2cmqLe+JWIVmD6Evp7cZkhMwYRatusrqfJ7j0ysOJCgkmSsdjLyz4+h1M2JOBUkyE1bidysU6+hglnWMgQ5uXZCLuwkBvV0XBirg== Received: from bigre.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-1 (Postfix) with ESMTPSA id B01A11800134; Mon, 20 Jul 2026 01:12:09 +0000 (UTC) From: Vincent Cloutier To: Sebastian Reichel Cc: Hans de Goede , Krzysztof Kozlowski , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Rob Herring , Conor Dooley , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Cloutier Subject: [PATCH v2 4/4] dt-bindings: power: supply: max17042: Allow monitored-battery Date: Sun, 19 Jul 2026 21:11:40 -0400 Message-ID: <20260720011144.1280219-5-vincent.cloutier@icloud.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260720011144.1280219-1-vincent.cloutier@icloud.com> References: <20260720011144.1280219-1-vincent.cloutier@icloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIwMDAwOSBTYWx0ZWRfX+CCnw437nyiv 05s5Bo9VjNgWPeq+TDKarJINq2yggAeNrYeTfK1Zh00gSAaA6Zg5ZabDRfmNX38wCrwXN2fuojM sBOPGsdGxFbQGtDPSQIzndYlGet0/UK6dtqA1h97R5UyDsZUGijC7AH4oY6MDkO99IMu5yJb8Sd 2GTQ0wzYCQCmVq/C4i0VNeaxKqc2sbASDMFBAamAYSVrAi52sWJtMxXfHnuMOTBXCC8taNLvuyD FIMUPXSLhG0WHEwJldxaw58lQGuAoJWRMiqKL1cCGfHBh6HBEbQR+wi8qcRZ3MQx8a2Yh9t+L0w cbVUl72OZegx5e/jcSV X-Proofpoint-ORIG-GUID: 60VVBBptR9frvyUs-UTawgJtqfbMp3Sg X-Proofpoint-GUID: 60VVBBptR9frvyUs-UTawgJtqfbMp3Sg Content-Type: text/plain; charset="utf-8" From: Vincent Cloutier The MAX17042 family binding references the generic power-supply schema, but its additionalProperties restriction means generic properties must also be admitted explicitly. Allow monitored-battery so these fuel gauges can reference the physical battery whose characteristics they consume. Assisted-by: OpenCode:gpt-5.6-sol Signed-off-by: Vincent Cloutier --- .../devicetree/bindings/power/supply/maxim,max17042.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.= yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml index 242b33f2bcba..ace684159e0e 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml @@ -67,6 +67,8 @@ properties: Voltage threshold to report battery as over voltage (in mV). Default is not to report over-voltage events. =20 + monitored-battery: true + power-supplies: true =20 required: --=20 2.55.0