Commit 844f9bf1eea75ff1ac1b1552ec4cac32ba829abb
Committed by
Tom Rini
1 parent
a1b2faed7c
Exists in
smarc_8mq_lf_v2020.04
and in
12 other branches
power: regulator: stpmu1: add power off delay
This patch adds a delay when regulators are disabled. This delay is set to 5 ms to cover all use cases. The worst use case actually seen is during a SD card power cycle. Signed-off-by: Christophe Kerello <christophe.kerello@st.com> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Showing 2 changed files with 13 additions and 8 deletions Side-by-side Diff
drivers/power/regulator/stpmu1.c
... | ... | @@ -183,6 +183,8 @@ |
183 | 183 | static int stpmu1_buck_set_enable(struct udevice *dev, bool enable) |
184 | 184 | { |
185 | 185 | struct dm_regulator_uclass_platdata *uc_pdata; |
186 | + int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS : | |
187 | + STPMU1_DEFAULT_STOP_DELAY_MS; | |
186 | 188 | int ret, uv; |
187 | 189 | |
188 | 190 | /* if regulator is already in the wanted state, nothing to do */ |
... | ... | @@ -199,8 +201,7 @@ |
199 | 201 | ret = pmic_clrsetbits(dev->parent, |
200 | 202 | STPMU1_BUCKX_CTRL_REG(dev->driver_data - 1), |
201 | 203 | STPMU1_BUCK_EN, enable ? STPMU1_BUCK_EN : 0); |
202 | - if (enable) | |
203 | - mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS); | |
204 | + mdelay(delay); | |
204 | 205 | |
205 | 206 | return ret; |
206 | 207 | } |
... | ... | @@ -361,6 +362,8 @@ |
361 | 362 | static int stpmu1_ldo_set_enable(struct udevice *dev, bool enable) |
362 | 363 | { |
363 | 364 | struct dm_regulator_uclass_platdata *uc_pdata; |
365 | + int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS : | |
366 | + STPMU1_DEFAULT_STOP_DELAY_MS; | |
364 | 367 | int ret, uv; |
365 | 368 | |
366 | 369 | /* if regulator is already in the wanted state, nothing to do */ |
... | ... | @@ -377,8 +380,7 @@ |
377 | 380 | ret = pmic_clrsetbits(dev->parent, |
378 | 381 | STPMU1_LDOX_CTRL_REG(dev->driver_data - 1), |
379 | 382 | STPMU1_LDO_EN, enable ? STPMU1_LDO_EN : 0); |
380 | - if (enable) | |
381 | - mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS); | |
383 | + mdelay(delay); | |
382 | 384 | |
383 | 385 | return ret; |
384 | 386 | } |
... | ... | @@ -489,6 +491,8 @@ |
489 | 491 | |
490 | 492 | static int stpmu1_vref_ddr_set_enable(struct udevice *dev, bool enable) |
491 | 493 | { |
494 | + int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS : | |
495 | + STPMU1_DEFAULT_STOP_DELAY_MS; | |
492 | 496 | int ret; |
493 | 497 | |
494 | 498 | /* if regulator is already in the wanted state, nothing to do */ |
... | ... | @@ -497,8 +501,7 @@ |
497 | 501 | |
498 | 502 | ret = pmic_clrsetbits(dev->parent, STPMU1_VREF_CTRL_REG, |
499 | 503 | STPMU1_VREF_EN, enable ? STPMU1_VREF_EN : 0); |
500 | - if (enable) | |
501 | - mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS); | |
504 | + mdelay(delay); | |
502 | 505 | |
503 | 506 | return ret; |
504 | 507 | } |
... | ... | @@ -610,6 +613,8 @@ |
610 | 613 | static int stpmu1_pwr_sw_set_enable(struct udevice *dev, bool enable) |
611 | 614 | { |
612 | 615 | uint mask = 1 << dev->driver_data; |
616 | + int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS : | |
617 | + STPMU1_DEFAULT_STOP_DELAY_MS; | |
613 | 618 | int ret; |
614 | 619 | |
615 | 620 | ret = pmic_reg_read(dev->parent, STPMU1_USB_CTRL_REG); |
... | ... | @@ -633,8 +638,7 @@ |
633 | 638 | |
634 | 639 | ret = pmic_clrsetbits(dev->parent, STPMU1_USB_CTRL_REG, |
635 | 640 | mask, enable ? mask : 0); |
636 | - if (enable) | |
637 | - mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS); | |
641 | + mdelay(delay); | |
638 | 642 | |
639 | 643 | return ret; |
640 | 644 | } |
include/power/stpmu1.h