Skip to content

Commit 383d0fc

Browse files
Venkat Reddy Tallabroonie
authored andcommitted
regulator: max77620: add support to configure MPOK
Adding support to configure regulator POK mapping bit to control nRST_IO and GPIO1 POK function. In tegra based platform which uses MAX20024 pmic, when some of regulators are configured FPS_NONE(flexible power sequencer) causes PMIC GPIO1 to go low which lead to various other rails turning off, to avoid this MPOK bit of those regulators need to be set to 0 so that PMIC GPIO1 will not go low. Signed-off-by: Venkat Reddy Talla <[email protected]> Acked-by: Lee Jones <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 9a40cb0 commit 383d0fc

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

drivers/regulator/max77620-regulator.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct max77620_regulator_pdata {
8080
int suspend_fps_pd_slot;
8181
int suspend_fps_pu_slot;
8282
int current_mode;
83+
int power_ok;
8384
int ramp_rate_setting;
8485
};
8586

@@ -350,11 +351,48 @@ static int max77620_set_slew_rate(struct max77620_regulator *pmic, int id,
350351
return 0;
351352
}
352353

354+
static int max77620_config_power_ok(struct max77620_regulator *pmic, int id)
355+
{
356+
struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id];
357+
struct max77620_regulator_info *rinfo = pmic->rinfo[id];
358+
struct max77620_chip *chip = dev_get_drvdata(pmic->dev->parent);
359+
u8 val, mask;
360+
int ret;
361+
362+
switch (chip->chip_id) {
363+
case MAX20024:
364+
if (rpdata->power_ok >= 0) {
365+
if (rinfo->type == MAX77620_REGULATOR_TYPE_SD)
366+
mask = MAX20024_SD_CFG1_MPOK_MASK;
367+
else
368+
mask = MAX20024_LDO_CFG2_MPOK_MASK;
369+
370+
val = rpdata->power_ok ? mask : 0;
371+
372+
ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr,
373+
mask, val);
374+
if (ret < 0) {
375+
dev_err(pmic->dev, "Reg 0x%02x update failed %d\n",
376+
rinfo->cfg_addr, ret);
377+
return ret;
378+
}
379+
}
380+
break;
381+
382+
default:
383+
break;
384+
}
385+
386+
return 0;
387+
}
388+
353389
static int max77620_init_pmic(struct max77620_regulator *pmic, int id)
354390
{
355391
struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id];
356392
int ret;
357393

394+
max77620_config_power_ok(pmic, id);
395+
358396
/* Update power mode */
359397
ret = max77620_regulator_get_power_mode(pmic, id);
360398
if (ret < 0)
@@ -594,6 +632,12 @@ static int max77620_of_parse_cb(struct device_node *np,
594632
np, "maxim,suspend-fps-power-down-slot", &pval);
595633
rpdata->suspend_fps_pd_slot = (!ret) ? pval : -1;
596634

635+
ret = of_property_read_u32(np, "maxim,power-ok-control", &pval);
636+
if (!ret)
637+
rpdata->power_ok = pval;
638+
else
639+
rpdata->power_ok = -1;
640+
597641
ret = of_property_read_u32(np, "maxim,ramp-rate-setting", &pval);
598642
rpdata->ramp_rate_setting = (!ret) ? pval : 0;
599643

@@ -806,6 +850,8 @@ static int max77620_regulator_resume(struct device *dev)
806850
for (id = 0; id < MAX77620_NUM_REGS; id++) {
807851
reg_pdata = &pmic->reg_pdata[id];
808852

853+
max77620_config_power_ok(pmic, id);
854+
809855
max77620_regulator_set_fps_slots(pmic, id, false);
810856
if (reg_pdata->active_fps_src < 0)
811857
continue;

include/linux/mfd/max77620.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,15 @@
180180
#define MAX77620_SD_CFG1_FPWM_SD_MASK BIT(2)
181181
#define MAX77620_SD_CFG1_FPWM_SD_SKIP 0
182182
#define MAX77620_SD_CFG1_FPWM_SD_FPWM BIT(2)
183+
#define MAX20024_SD_CFG1_MPOK_MASK BIT(1)
183184
#define MAX77620_SD_CFG1_FSRADE_SD_MASK BIT(0)
184185
#define MAX77620_SD_CFG1_FSRADE_SD_DISABLE 0
185186
#define MAX77620_SD_CFG1_FSRADE_SD_ENABLE BIT(0)
186187

187188
/* LDO_CNFG2 */
188189
#define MAX77620_LDO_POWER_MODE_MASK 0xC0
189190
#define MAX77620_LDO_POWER_MODE_SHIFT 6
191+
#define MAX20024_LDO_CFG2_MPOK_MASK BIT(2)
190192
#define MAX77620_LDO_CFG2_ADE_MASK BIT(1)
191193
#define MAX77620_LDO_CFG2_ADE_DISABLE 0
192194
#define MAX77620_LDO_CFG2_ADE_ENABLE BIT(1)

0 commit comments

Comments
 (0)