Re: [PATCH v2] regulator: max14577: Add set_mode/get_mode for MAX77836 LDOs

From: Mark Brown

Date: Tue Jun 16 2026 - 12:49:04 EST


On Mon, Jun 15, 2026 at 07:50:08PM +0100, Jad Keskes wrote:
> The MAX77836 LDOs support two operating modes via the PWRMD field in
> CNFG1_LDO registers: normal and low-power (5 mA max load, reduced
> quiescent current). Implement the get_mode and set_mode callbacks
> so consumers can switch between them.

> +static int max77836_ldo_set_mode(struct regulator_dev *rdev,
> + unsigned int mode)
> +{
> + unsigned int val;
> +
> + switch (mode) {
> + case REGULATOR_MODE_NORMAL:
> + val = MAX77836_CNFG1_LDO_PWRMD_NORMAL;
> + break;
> + case REGULATOR_MODE_IDLE:
> + val = MAX77836_CNFG1_LDO_PWRMD_LPM;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
> + MAX77836_CNFG1_LDO_PWRMD_MASK, val);
> +}

Since this is the same register we're using for enable this will fight
with enable, setting the mode will enable the regulator and enabling
or disabling will overwrite the mode. You'll need to store the mode in
the driver data and have a custom enable operation which applies the
current mode when enabling rather than a fixed value.

You should also add a of_map_mode() operation so the mode can be set
from DT.

Attachment: signature.asc
Description: PGP signature