mfd: twl6040: Fix device init errors for ACCCTL register
authorTony Lindgren <tony@atomide.com>
Thu, 14 Feb 2019 16:03:45 +0000 (08:03 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 15 Jun 2019 09:54:03 +0000 (11:54 +0200)
commit5540d0146151fb96d3eb065381b5f620641b384f
treebc9a5b6e3d55b91de0c360f1866313aee82c18cf
parent3b8892bea9eb4f7569b64887195ee70b5cfa941c
mfd: twl6040: Fix device init errors for ACCCTL register

[ Upstream commit 48171d0ea7caccf21c9ee3ae75eb370f2a756062 ]

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 <tony@atomide.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mfd/twl6040.c