diff --git a/drivers/mfd/stmfx.c b/drivers/mfd/stmfx.c index 30f83efad318..eaf0d29e0258 100644 --- a/drivers/mfd/stmfx.c +++ b/drivers/mfd/stmfx.c @@ -304,6 +304,21 @@ irq_exit: return ret; } +static int stmfx_chip_wait_boot(struct stmfx *stmfx) +{ + unsigned long timeout_ms = 0; + unsigned int val; + int ret; + + while (1) { + ret = regmap_read(stmfx->map, STMFX_REG_FW_VERSION_MSB, &val); + if (ret != -ENXIO || timeout_ms > STMFX_BOOT_TIME_MS) + return ret; + mdelay(1); + timeout_ms++; + } +} + static int stmfx_chip_reset(struct stmfx *stmfx) { int ret; @@ -340,6 +355,11 @@ static int stmfx_chip_init(struct i2c_client *client) return ret; } } + ret = stmfx_chip_wait_boot(stmfx); + if (ret) { + dev_err(stmfx->dev, "Boot chip failed: %d\n", ret); + return ret; + } ret = regmap_read(stmfx->map, STMFX_REG_CHIP_ID, &id); if (ret) { @@ -513,6 +533,11 @@ static int stmfx_resume(struct device *dev) return ret; } } + ret = stmfx_chip_wait_boot(stmfx); + if (ret) { + dev_err(stmfx->dev, "Boot chip failed: %d\n", ret); + return ret; + } /* Reset STMFX - supply has been stopped during suspend */ ret = stmfx_chip_reset(stmfx);