]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.51/mfd-twl6040-fix-device-init-errors-for-accctl-regist.patch
Linux 4.19.51
[thirdparty/kernel/stable-queue.git] / releases / 4.19.51 / mfd-twl6040-fix-device-init-errors-for-accctl-regist.patch
CommitLineData
37554d48
SL
1From f3b99329c00ef7bd821477400e306a0a6f8128e6 Mon Sep 17 00:00:00 2001
2From: Tony Lindgren <tony@atomide.com>
3Date: Thu, 14 Feb 2019 08:03:45 -0800
4Subject: mfd: twl6040: Fix device init errors for ACCCTL register
5
6[ Upstream commit 48171d0ea7caccf21c9ee3ae75eb370f2a756062 ]
7
8I noticed that we can get a -EREMOTEIO errors on at least omap4 duovero:
9
10twl6040 0-004b: Failed to write 2d = 19: -121
11
12And then any following register access will produce errors.
13
14There 2d offset above is register ACCCTL that gets written on twl6040
15powerup. With error checking added to the related regcache_sync() call,
16the -EREMOTEIO error is reproducable on twl6040 powerup at least
17duovero.
18
19To fix the error, we need to wait until twl6040 is accessible after the
20powerup. Based on tests on omap4 duovero, we need to wait over 8ms after
21powerup before register write will complete without failures. Let's also
22make sure we warn about possible errors too.
23
24Note that we have twl6040_patch[] reg_sequence with the ACCCTL register
25configuration and regcache_sync() will write the new value to ACCCTL.
26
27Signed-off-by: Tony Lindgren <tony@atomide.com>
28Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
29Signed-off-by: Lee Jones <lee.jones@linaro.org>
30Signed-off-by: Sasha Levin <sashal@kernel.org>
31---
32 drivers/mfd/twl6040.c | 13 ++++++++++++-
33 1 file changed, 12 insertions(+), 1 deletion(-)
34
35diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c
36index dd19f17a1b63..2b8c479dbfa6 100644
37--- a/drivers/mfd/twl6040.c
38+++ b/drivers/mfd/twl6040.c
39@@ -322,8 +322,19 @@ int twl6040_power(struct twl6040 *twl6040, int on)
40 }
41 }
42
43+ /*
44+ * Register access can produce errors after power-up unless we
45+ * wait at least 8ms based on measurements on duovero.
46+ */
47+ usleep_range(10000, 12000);
48+
49 /* Sync with the HW */
50- regcache_sync(twl6040->regmap);
51+ ret = regcache_sync(twl6040->regmap);
52+ if (ret) {
53+ dev_err(twl6040->dev, "Failed to sync with the HW: %i\n",
54+ ret);
55+ goto out;
56+ }
57
58 /* Default PLL configuration after power up */
59 twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL;
60--
612.20.1
62