Skip to content

Commit b31dddc

Browse files
committed
[nrf fromtree] drivers: regulator: npm1300: workaround for LDO HW bug
There is a HW bug in nPM1300 LDO which causes the LDO output voltage to reach its target very slowly in specific cases. This is worked around by performing an additional i2c read shortly after an LDO is enabled. Signed-off-by: Sergei Ovchinnikov <[email protected]> (cherry picked from commit 2d34358)
1 parent ff01b5f commit b31dddc

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

drivers/regulator/regulator_npm1300.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct regulator_npm1300_config {
8787
struct gpio_dt_spec retention_gpios;
8888
struct gpio_dt_spec pwm_gpios;
8989
uint8_t soft_start;
90+
bool ldo_disable_workaround;
9091
};
9192

9293
struct regulator_npm1300_data {
@@ -357,19 +358,35 @@ int regulator_npm1300_set_mode(const struct device *dev, regulator_mode_t mode)
357358
int regulator_npm1300_enable(const struct device *dev)
358359
{
359360
const struct regulator_npm1300_config *config = dev->config;
361+
int ret;
360362

361363
switch (config->source) {
362364
case NPM1300_SOURCE_BUCK1:
363365
return mfd_npm1300_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_SET, 1U);
364366
case NPM1300_SOURCE_BUCK2:
365367
return mfd_npm1300_reg_write(config->mfd, BUCK_BASE, BUCK_OFFSET_EN_SET + 2U, 1U);
366368
case NPM1300_SOURCE_LDO1:
367-
return mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_SET, 1U);
369+
ret = mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_SET, 1U);
370+
break;
368371
case NPM1300_SOURCE_LDO2:
369-
return mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_SET + 2U, 1U);
372+
ret = mfd_npm1300_reg_write(config->mfd, LDSW_BASE, LDSW_OFFSET_EN_SET + 2U, 1U);
373+
break;
370374
default:
371375
return 0;
372376
}
377+
378+
if (ret < 0) {
379+
return ret;
380+
}
381+
382+
if (!config->ldo_disable_workaround) {
383+
uint8_t unused;
384+
385+
k_msleep(2);
386+
return mfd_npm1300_reg_read(config->mfd, LDSW_BASE, LDSW_OFFSET_STATUS, &unused);
387+
}
388+
389+
return ret;
373390
}
374391

375392
int regulator_npm1300_disable(const struct device *dev)
@@ -655,7 +672,8 @@ static DEVICE_API(regulator, api) = {
655672
.soft_start = DT_ENUM_IDX_OR(node_id, soft_start_microamp, UINT8_MAX), \
656673
.enable_gpios = GPIO_DT_SPEC_GET_OR(node_id, enable_gpios, {0}), \
657674
.retention_gpios = GPIO_DT_SPEC_GET_OR(node_id, retention_gpios, {0}), \
658-
.pwm_gpios = GPIO_DT_SPEC_GET_OR(node_id, pwm_gpios, {0})}; \
675+
.pwm_gpios = GPIO_DT_SPEC_GET_OR(node_id, pwm_gpios, {0}), \
676+
.ldo_disable_workaround = DT_PROP(node_id, nordic_ldo_disable_workaround)}; \
659677
\
660678
DEVICE_DT_DEFINE(node_id, regulator_npm1300_init, NULL, &data_##id, &config_##id, \
661679
POST_KERNEL, CONFIG_REGULATOR_NPM1300_INIT_PRIORITY, &api);

dts/bindings/regulator/nordic,npm1300-regulator.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,12 @@ child-binding:
9696
- 50000
9797
description: |
9898
Soft start current limit in microamps.
99+
100+
nordic,ldo-disable-workaround:
101+
type: boolean
102+
description: |
103+
Disable the SW workaround for LDO bug.
104+
When nPM1300 is in ULP mode, LDO is supplied from VSYS and
105+
then LDO is enabled, it can take long time until the LDO
106+
output has reached its target voltage. To avoid this, an i2c
107+
read is performed shortly after an LDO is enabled.

0 commit comments

Comments
 (0)