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>
static int stpmu1_buck_set_enable(struct udevice *dev, bool enable)
{
struct dm_regulator_uclass_platdata *uc_pdata;
static int stpmu1_buck_set_enable(struct udevice *dev, bool enable)
{
struct dm_regulator_uclass_platdata *uc_pdata;
+ int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS :
+ STPMU1_DEFAULT_STOP_DELAY_MS;
int ret, uv;
/* if regulator is already in the wanted state, nothing to do */
int ret, uv;
/* if regulator is already in the wanted state, nothing to do */
ret = pmic_clrsetbits(dev->parent,
STPMU1_BUCKX_CTRL_REG(dev->driver_data - 1),
STPMU1_BUCK_EN, enable ? STPMU1_BUCK_EN : 0);
ret = pmic_clrsetbits(dev->parent,
STPMU1_BUCKX_CTRL_REG(dev->driver_data - 1),
STPMU1_BUCK_EN, enable ? STPMU1_BUCK_EN : 0);
- if (enable)
- mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS);
static int stpmu1_ldo_set_enable(struct udevice *dev, bool enable)
{
struct dm_regulator_uclass_platdata *uc_pdata;
static int stpmu1_ldo_set_enable(struct udevice *dev, bool enable)
{
struct dm_regulator_uclass_platdata *uc_pdata;
+ int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS :
+ STPMU1_DEFAULT_STOP_DELAY_MS;
int ret, uv;
/* if regulator is already in the wanted state, nothing to do */
int ret, uv;
/* if regulator is already in the wanted state, nothing to do */
ret = pmic_clrsetbits(dev->parent,
STPMU1_LDOX_CTRL_REG(dev->driver_data - 1),
STPMU1_LDO_EN, enable ? STPMU1_LDO_EN : 0);
ret = pmic_clrsetbits(dev->parent,
STPMU1_LDOX_CTRL_REG(dev->driver_data - 1),
STPMU1_LDO_EN, enable ? STPMU1_LDO_EN : 0);
- if (enable)
- mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS);
static int stpmu1_vref_ddr_set_enable(struct udevice *dev, bool enable)
{
static int stpmu1_vref_ddr_set_enable(struct udevice *dev, bool enable)
{
+ int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS :
+ STPMU1_DEFAULT_STOP_DELAY_MS;
int ret;
/* if regulator is already in the wanted state, nothing to do */
int ret;
/* if regulator is already in the wanted state, nothing to do */
ret = pmic_clrsetbits(dev->parent, STPMU1_VREF_CTRL_REG,
STPMU1_VREF_EN, enable ? STPMU1_VREF_EN : 0);
ret = pmic_clrsetbits(dev->parent, STPMU1_VREF_CTRL_REG,
STPMU1_VREF_EN, enable ? STPMU1_VREF_EN : 0);
- if (enable)
- mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS);
static int stpmu1_pwr_sw_set_enable(struct udevice *dev, bool enable)
{
uint mask = 1 << dev->driver_data;
static int stpmu1_pwr_sw_set_enable(struct udevice *dev, bool enable)
{
uint mask = 1 << dev->driver_data;
+ int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS :
+ STPMU1_DEFAULT_STOP_DELAY_MS;
int ret;
ret = pmic_reg_read(dev->parent, STPMU1_USB_CTRL_REG);
int ret;
ret = pmic_reg_read(dev->parent, STPMU1_USB_CTRL_REG);
ret = pmic_clrsetbits(dev->parent, STPMU1_USB_CTRL_REG,
mask, enable ? mask : 0);
ret = pmic_clrsetbits(dev->parent, STPMU1_USB_CTRL_REG,
mask, enable ? mask : 0);
- if (enable)
- mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS);
#define STPMU1_NVM_USER_STATUS_ERROR BIT(1)
#define STPMU1_DEFAULT_START_UP_DELAY_MS 1
#define STPMU1_NVM_USER_STATUS_ERROR BIT(1)
#define STPMU1_DEFAULT_START_UP_DELAY_MS 1
+#define STPMU1_DEFAULT_STOP_DELAY_MS 5
#define STPMU1_USB_BOOST_START_UP_DELAY_MS 10
enum {
#define STPMU1_USB_BOOST_START_UP_DELAY_MS 10
enum {