Skip to content

Commit 74cc379

Browse files
VCASTMashishverma2691
authored andcommitted
mfd: stmfx: wait boot time after a regulator enable
STMFX has a boot time of 10ms between reset and first register access. But this delay is not yet respected after a regulator_enable, and sometimes register access could failed with -ENXIO. As we cannot get the time since the regulator was enabled, we poll every 1ms the STMFX_REG_FW_VERSION_MSB, to wait the completed boot of chip. A timeout is set to 10ms. Change-Id: I2eeeccac00fc6087d60cd30dbb7fad4c30a72e1b Signed-off-by: Valentin Caron <valentin.caron@foss.st.com> Signed-off-by: Deepak kumar <deepak.kumar01@st.com> Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/369823 Domain-Review: Amelie DELAUNAY <amelie.delaunay@foss.st.com> ACI: CIBUILD <MDG-smet-aci-builds@list.st.com> ACI: CITOOLS <MDG-smet-aci-reviews@list.st.com> Reviewed-by: Amelie DELAUNAY <amelie.delaunay@foss.st.com>
1 parent 8e3e0ee commit 74cc379

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/mfd/stmfx.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,21 @@ static int stmfx_irq_init(struct i2c_client *client)
304304
return ret;
305305
}
306306

307+
static int stmfx_chip_wait_boot(struct stmfx *stmfx)
308+
{
309+
unsigned long timeout_ms = 0;
310+
unsigned int val;
311+
int ret;
312+
313+
while (1) {
314+
ret = regmap_read(stmfx->map, STMFX_REG_FW_VERSION_MSB, &val);
315+
if (ret != -ENXIO || timeout_ms > STMFX_BOOT_TIME_MS)
316+
return ret;
317+
mdelay(1);
318+
timeout_ms++;
319+
}
320+
}
321+
307322
static int stmfx_chip_reset(struct stmfx *stmfx)
308323
{
309324
int ret;
@@ -340,6 +355,11 @@ static int stmfx_chip_init(struct i2c_client *client)
340355
return ret;
341356
}
342357
}
358+
ret = stmfx_chip_wait_boot(stmfx);
359+
if (ret) {
360+
dev_err(stmfx->dev, "Boot chip failed: %d\n", ret);
361+
return ret;
362+
}
343363

344364
ret = regmap_read(stmfx->map, STMFX_REG_CHIP_ID, &id);
345365
if (ret) {
@@ -504,6 +524,11 @@ static int stmfx_resume(struct device *dev)
504524
return ret;
505525
}
506526
}
527+
ret = stmfx_chip_wait_boot(stmfx);
528+
if (ret) {
529+
dev_err(stmfx->dev, "Boot chip failed: %d\n", ret);
530+
return ret;
531+
}
507532

508533
/* Reset STMFX - supply has been stopped during suspend */
509534
ret = stmfx_chip_reset(stmfx);

0 commit comments

Comments
 (0)