uboot-mediatek: update to v2023.04
[openwrt/staging/jow.git] / package / boot / uboot-mediatek / patches / 001-pinctrl-mediatek-set-R1-R0-in-case-pullen-pullsel-su.patch
1 From patchwork Wed Apr 12 20:36:43 2023
2 Content-Type: text/plain; charset="utf-8"
3 MIME-Version: 1.0
4 Content-Transfer-Encoding: 7bit
5 X-Patchwork-Submitter: Daniel Golle <daniel@makrotopia.org>
6 X-Patchwork-Id: 1768270
7 Return-Path: <u-boot-bounces@lists.denx.de>
8 X-Original-To: incoming@patchwork.ozlabs.org
9 Delivered-To: patchwork-incoming@legolas.ozlabs.org
10 Date: Wed, 12 Apr 2023 21:36:43 +0100
11 From: Daniel Golle <daniel@makrotopia.org>
12 To: u-boot@lists.denx.de, Sam Shih <sam.shih@mediatek.com>,
13 GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>,
14 Chunfeng Yun <chunfeng.yun@mediatek.com>,
15 Weijie Gao <weijie.gao@mediatek.com>, Ryder Lee <ryder.lee@mediatek.com>,
16 Frank Wunderlich <frank-w@public-files.de>
17 Cc: Steven Liu =?utf-8?b?KOWKieS6uuixqik=?= <steven.liu@mediatek.com>,
18 John Crispin <john@phrozen.org>
19 Subject: [PATCH] pinctrl: mediatek: set R1/R0 in case pullen/pullsel succeeded
20 Message-ID: <ZDcWW7kLSLn1GMZ1@makrotopia.org>
21 MIME-Version: 1.0
22 Content-Disposition: inline
23 X-BeenThere: u-boot@lists.denx.de
24 X-Mailman-Version: 2.1.39
25 Precedence: list
26 List-Id: U-Boot discussion <u-boot.lists.denx.de>
27 Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
28
29 Commit dafe0fbfb0f3 ("pinctrl: mediatek: rewrite mtk_pinconf_set and
30 related functions") changed the logic deciding to set R0 and R1
31 registers for V1 devices.
32
33 Before:
34 /* Also set PUPD/R0/R1 if the pin has them */
35 err = mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_PUPD, !pullup);
36 if (err != -EINVAL) {
37 mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_R0, r0);
38 mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_R1, r1);
39 }
40
41 After:
42 /* try pupd_r1_r0 if pullen_pullsel return error */
43 err = mtk_pinconf_bias_set_pullen_pullsel(dev, pin, disable, pullup,
44 val);
45 if (err)
46 return mtk_pinconf_bias_set_pupd_r1_r0(dev, pin, disable,
47 pullup, val);
48
49 Tracing mtk_pinconf_bias_set_pullen_pullsel shows that the function
50 always either returns 0 in case of success or -EINVAL in case any error
51 has occurred. Hence the logic responsible of the decision to program R0
52 and R1 has been inverted.
53
54 This leads to problems on BananaPi R2 (MT7623N) when booting from
55 SDMMC, it turns out accessing eMMC no longer works since
56 U-Boot 2022.07:
57
58 MT7623> mmc dev 0
59 Card did not respond to voltage select! : -110
60
61 The problem wasn't detected for a long time as both eMMC and SDMMC work
62 fine if they are used to boot from, and hence R0 and R1 were already
63 setup by the bootrom and/or preloader.
64
65 Fix the logic to restore the originally intended and correct behavior
66 and also change the descriptive comment accordingly.
67
68 Fixes: dafe0fbfb0f3 ("pinctrl: mediatek: rewrite mtk_pinconf_set and related functions")
69 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
70 ---
71 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 4 ++--
72 1 file changed, 2 insertions(+), 2 deletions(-)
73
74 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
75 +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
76 @@ -349,10 +349,10 @@ int mtk_pinconf_bias_set_v1(struct udevi
77 {
78 int err;
79
80 - /* try pupd_r1_r0 if pullen_pullsel return error */
81 + /* set pupd_r1_r0 if pullen_pullsel succeeded */
82 err = mtk_pinconf_bias_set_pullen_pullsel(dev, pin, disable, pullup,
83 val);
84 - if (err)
85 + if (!err)
86 return mtk_pinconf_bias_set_pupd_r1_r0(dev, pin, disable,
87 pullup, val);
88