From: Javier Martinez Canillas Date: Tue, 26 Aug 2014 11:37:41 +0000 (+0200) Subject: regulator: max77802: set opmode to normal if off is read from hw X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=aea8dfb9f32bf90dd6fd00758978b50efdc08df5;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git regulator: max77802: set opmode to normal if off is read from hw The max77802 driver reads the default operating mode (opmode) set for regulators when enabled from the hardware registers. But if a regulator is disabled and the system warm restarted, the hardware reports OFF as the opmode so the regulator is not enabled. Default to operating mode NORMAL if OFF is read from the hardware register. Reported-by: Yuvaraj Cd Signed-off-by: Javier Martinez Canillas Reviewed-by: Doug Anderson Tested-by: Yuvaraj Kumar CD Signed-off-by: Mark Brown --- diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index ad1caa902ef0..967e10934d3e 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -540,7 +540,17 @@ static int max77802_pmic_probe(struct platform_device *pdev) config.of_node = pdata->regulators[i].of_node; ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); - max77802->opmode[id] = val >> shift & MAX77802_OPMODE_MASK; + val = val >> shift & MAX77802_OPMODE_MASK; + + /* + * If the regulator is disabled and the system warm rebooted, + * the hardware reports OFF as the regulator operating mode. + * Default to operating mode NORMAL in that case. + */ + if (val == MAX77802_OPMODE_OFF) + max77802->opmode[id] = MAX77802_OPMODE_NORMAL; + else + max77802->opmode[id] = val; rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config);