]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.61/pinctrl-mxs-atomically-switch-mux-and-drive-strength-config.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 3.18.61 / pinctrl-mxs-atomically-switch-mux-and-drive-strength-config.patch
1 From da6c2addf66d7ff7d0b090d6267d4292f951e4e6 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
3 Date: Thu, 18 May 2017 11:23:55 +0200
4 Subject: pinctrl: mxs: atomically switch mux and drive strength config
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
10
11 commit da6c2addf66d7ff7d0b090d6267d4292f951e4e6 upstream.
12
13 To set the mux mode of a pin two bits must be set. Up to now this is
14 implemented using the following idiom:
15
16 writel(mask, reg + CLR);
17 writel(value, reg + SET);
18
19 . This however results in the mux mode being 0 between the two writes.
20
21 On my machine there is an IC's reset pin connected to LCD_D20. The
22 bootloader configures this pin as GPIO output-high (i.e. not holding the
23 IC in reset). When Linux reconfigures the pin to GPIO the short time
24 LCD_D20 is muxed as LCD_D20 instead of GPIO_1_20 is enough to confuse
25 the connected IC.
26
27 The same problem is present for the pin's drive strength setting which is
28 reset to low drive strength before using the right value.
29
30 So instead of relying on the hardware to modify the register setting
31 using two writes implement the bit toggling using read-modify-write.
32
33 Fixes: 17723111e64f ("pinctrl: add pinctrl-mxs support")
34 Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
35 Acked-by: Shawn Guo <shawnguo@kernel.org>
36 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
37 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
38
39 ---
40 drivers/pinctrl/freescale/pinctrl-mxs.c | 16 ++++++++++++----
41 1 file changed, 12 insertions(+), 4 deletions(-)
42
43 --- a/drivers/pinctrl/freescale/pinctrl-mxs.c
44 +++ b/drivers/pinctrl/freescale/pinctrl-mxs.c
45 @@ -195,6 +195,16 @@ static int mxs_pinctrl_get_func_groups(s
46 return 0;
47 }
48
49 +static void mxs_pinctrl_rmwl(u32 value, u32 mask, u8 shift, void __iomem *reg)
50 +{
51 + u32 tmp;
52 +
53 + tmp = readl(reg);
54 + tmp &= ~(mask << shift);
55 + tmp |= value << shift;
56 + writel(tmp, reg);
57 +}
58 +
59 static int mxs_pinctrl_set_mux(struct pinctrl_dev *pctldev, unsigned selector,
60 unsigned group)
61 {
62 @@ -212,8 +222,7 @@ static int mxs_pinctrl_set_mux(struct pi
63 reg += bank * 0x20 + pin / 16 * 0x10;
64 shift = pin % 16 * 2;
65
66 - writel(0x3 << shift, reg + CLR);
67 - writel(g->muxsel[i] << shift, reg + SET);
68 + mxs_pinctrl_rmwl(g->muxsel[i], 0x3, shift, reg);
69 }
70
71 return 0;
72 @@ -280,8 +289,7 @@ static int mxs_pinconf_group_set(struct
73 /* mA */
74 if (config & MA_PRESENT) {
75 shift = pin % 8 * 4;
76 - writel(0x3 << shift, reg + CLR);
77 - writel(ma << shift, reg + SET);
78 + mxs_pinctrl_rmwl(ma, 0x3, shift, reg);
79 }
80
81 /* vol */