Skip to content

Commit 59e1b23

Browse files
tmlindgregkh
authored andcommitted
mfd: twl6040: Fix device init errors for ACCCTL register
[ Upstream commit 48171d0 ] I noticed that we can get a -EREMOTEIO errors on at least omap4 duovero: twl6040 0-004b: Failed to write 2d = 19: -121 And then any following register access will produce errors. There 2d offset above is register ACCCTL that gets written on twl6040 powerup. With error checking added to the related regcache_sync() call, the -EREMOTEIO error is reproducable on twl6040 powerup at least duovero. To fix the error, we need to wait until twl6040 is accessible after the powerup. Based on tests on omap4 duovero, we need to wait over 8ms after powerup before register write will complete without failures. Let's also make sure we warn about possible errors too. Note that we have twl6040_patch[] reg_sequence with the ACCCTL register configuration and regcache_sync() will write the new value to ACCCTL. Signed-off-by: Tony Lindgren <[email protected]> Acked-by: Peter Ujfalusi <[email protected]> Signed-off-by: Lee Jones <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 381a968 commit 59e1b23

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/mfd/twl6040.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,19 @@ int twl6040_power(struct twl6040 *twl6040, int on)
322322
}
323323
}
324324

325+
/*
326+
* Register access can produce errors after power-up unless we
327+
* wait at least 8ms based on measurements on duovero.
328+
*/
329+
usleep_range(10000, 12000);
330+
325331
/* Sync with the HW */
326-
regcache_sync(twl6040->regmap);
332+
ret = regcache_sync(twl6040->regmap);
333+
if (ret) {
334+
dev_err(twl6040->dev, "Failed to sync with the HW: %i\n",
335+
ret);
336+
goto out;
337+
}
327338

328339
/* Default PLL configuration after power up */
329340
twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL;

0 commit comments

Comments
 (0)