From: "André Draszik" <andre.draszik@linaro.org>
To: amitsd@google.com, Sebastian Reichel <sre@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Lee Jones <lee@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Badhri Jagan Sridharan <badhri@google.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Peter Griffin <peter.griffin@linaro.org>,
Tudor Ambarus <tudor.ambarus@linaro.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Mark Brown <broonie@kernel.org>,
Matti Vaittinen <mazziesaccount@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
devicetree@vger.kernel.org, linux-usb@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org,
RD Babiera <rdbabiera@google.com>, Kyle Tso <kyletso@google.com>
Subject: Re: [PATCH v6 5/6] power: supply: max77759: add charger driver
Date: Tue, 17 Feb 2026 13:14:14 +0000 [thread overview]
Message-ID: <0b6e7cb7223e553d9b53df464959e97fd3d1ce43.camel@linaro.org> (raw)
In-Reply-To: <20260214-max77759-charger-v6-5-28c09bda74b4@google.com>
Hi Amit,
All below comments are only minor, feel free to ignore them.
On Sat, 2026-02-14 at 03:12 +0000, Amit Sunil Dhamne via B4 Relay wrote:
> From: Amit Sunil Dhamne <amitsd@google.com>
>
> Add support for MAX77759 battery charger driver. This is a 4A 1-Cell
> Li+/LiPoly dual input switch mode charger. While the device can support
> USB & wireless charger inputs, this implementation only supports USB
> input. This implementation supports both buck and boost modes.
>
> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
> ---
> MAINTAINERS | 6 +
> drivers/power/supply/Kconfig | 11 +
> drivers/power/supply/Makefile | 1 +
> drivers/power/supply/max77759_charger.c | 768 ++++++++++++++++++++++++++++++++
> 4 files changed, 786 insertions(+)
[...]
> diff --git a/drivers/power/supply/max77759_charger.c b/drivers/power/supply/max77759_charger.c
> new file mode 100644
> index 000000000000..d4e02764ba04
> --- /dev/null
> +++ b/drivers/power/supply/max77759_charger.c
> @@ -0,0 +1,768 @@
[...]
> +
> +/* USB input current limits (in uA) */
> +static const struct linear_range chgin_ilim_ranges[] = {
> + LINEAR_RANGE(100000, 0x3, 0x7F, 25000),
> +};
Shouldn't this one also have a entry for 0x00...0x02:
LINEAR_RANGE(100000, 0x0, 0x2, 0),
Then you can also drop the umax() call in get_input_current_limit().
Ah, I see now there is no linear_range_get_selector_within_array(),
meaning the code is fine as-is, unless you want to add that as
well :-)
[...]
> +static int max77759_charger_init(struct max77759_charger *chg)
> +{
> + struct power_supply_battery_info *info;
> + u32 regval, fast_chg_curr, fv;
> + int ret;
> +
> + ret = regmap_read(chg->regmap, MAX77759_CHGR_REG_CHG_CNFG_00, ®val);
> + if (ret)
> + return ret;
> +
> + chg->mode = FIELD_GET(MAX77759_CHGR_REG_CHG_CNFG_00_MODE, regval);
> + ret = charger_set_mode(chg, MAX77759_CHGR_MODE_OFF);
> + if (ret)
> + return ret;
> +
> + if (power_supply_get_battery_info(chg->psy, &info)) {
> + fv = CHG_FV_DEFAULT_MV;
> + fast_chg_curr = CHG_CC_DEFAULT_UA;
> + } else {
> + fv = info->constant_charge_voltage_max_uv / 1000;
> + fast_chg_curr = info->constant_charge_current_max_ua;
> + }
> +
> + ret = set_fast_charge_current_limit(chg, fast_chg_curr);
> + if (ret)
> + return ret;
> +
> + ret = set_float_voltage_limit(chg, fv);
> + if (ret)
> + return ret;
> +
> + ret = unlock_prot_regs(chg, true);
> + if (ret)
> + return ret;
> +
> + /* Disable wireless charging input */
> + ret = regmap_update_bits(chg->regmap, MAX77759_CHGR_REG_CHG_CNFG_12,
> + MAX77759_CHGR_REG_CHG_CNFG_12_WCINSEL, 0);
> + if (ret)
> + return ret;
> +
> + ret = regmap_update_bits(chg->regmap, MAX77759_CHGR_REG_CHG_CNFG_18,
> + MAX77759_CHGR_REG_CHG_CNFG_18_WDTEN, 0);
> + if (ret)
> + return ret;
> +
> + return unlock_prot_regs(chg, false);
Should early error returns here try to lock the protection again? Something
like:
+ ret = unlock_prot_regs(chg, true);
+ if (ret)
+ return ret;
+
+ /* Disable wireless charging input */
+ ret = regmap_update_bits(chg->regmap, MAX77759_CHGR_REG_CHG_CNFG_12,
+ MAX77759_CHGR_REG_CHG_CNFG_12_WCINSEL, 0);
+ if (ret)
+ goto relock;
+
+ ret = regmap_update_bits(chg->regmap, MAX77759_CHGR_REG_CHG_CNFG_18,
+ MAX77759_CHGR_REG_CHG_CNFG_18_WDTEN, 0);
+ if (ret)
+ goto relock;
+
+ return unlock_prot_regs(chg, false);
+
+relock:
+ (void) unlock_prot_regs(chg, false);
+ return ret;
I guess if one of the regmap_update_bits() failed, then locking the
registers might not work either, so I have no strong opinion on
adding that.
With or without updates:
Reviewed-by: André Draszik <andre.draszik@linaro.org>
Cheers,
Andre'
next prev parent reply other threads:[~2026-02-17 13:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-14 3:12 [PATCH v6 0/6] Introduce MAX77759 " Amit Sunil Dhamne via B4 Relay
2026-02-14 3:12 ` [PATCH v6 1/6] dt-bindings: mfd: maxim,max77759: reference power-supply schema and add regulator property Amit Sunil Dhamne via B4 Relay
2026-02-14 3:12 ` [PATCH v6 2/6] dt-bindings: usb: maxim,max33359: Add supply property for vbus Amit Sunil Dhamne via B4 Relay
2026-02-14 3:12 ` [PATCH v6 3/6] mfd: max77759: add register bitmasks and modify irq configs for charger Amit Sunil Dhamne via B4 Relay
2026-02-17 12:30 ` André Draszik
2026-02-14 3:12 ` [PATCH v6 4/6] lib/linear_ranges: Add linear_range_get_selector_high_array Amit Sunil Dhamne via B4 Relay
2026-02-16 13:58 ` Matti Vaittinen
2026-02-18 1:45 ` Amit Sunil Dhamne
2026-02-18 8:17 ` Matti Vaittinen
2026-02-18 20:05 ` Amit Sunil Dhamne
2026-02-14 3:12 ` [PATCH v6 5/6] power: supply: max77759: add charger driver Amit Sunil Dhamne via B4 Relay
2026-02-14 8:56 ` kernel test robot
2026-02-17 13:14 ` André Draszik [this message]
2026-02-18 5:35 ` Amit Sunil Dhamne
2026-02-14 3:12 ` [PATCH v6 6/6] usb: typec: tcpm/tcpci_maxim: deprecate WAR for setting charger mode Amit Sunil Dhamne via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0b6e7cb7223e553d9b53df464959e97fd3d1ce43.camel@linaro.org \
--to=andre.draszik@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=alim.akhtar@samsung.com \
--cc=amitsd@google.com \
--cc=badhri@google.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=krzk+dt@kernel.org \
--cc=kyletso@google.com \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=peter.griffin@linaro.org \
--cc=rdbabiera@google.com \
--cc=robh@kernel.org \
--cc=sre@kernel.org \
--cc=tudor.ambarus@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®