]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-5.10/pinctrl-mediatek-paris-rework-support-for-pin_config.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / queue-5.10 / pinctrl-mediatek-paris-rework-support-for-pin_config.patch
CommitLineData
3e0dbc26
SL
1From b6607c0ca12cb3ce6bd09c62d87d400cf759badd Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Wed, 27 Mar 2024 17:13:34 +0800
4Subject: pinctrl: mediatek: paris: Rework support for
5 PIN_CONFIG_{INPUT,OUTPUT}_ENABLE
6
7From: Chen-Yu Tsai <wenst@chromium.org>
8
9[ Upstream commit c5d3b64c568a344e998830e0e94a7c04e372f89b ]
10
11There is a misinterpretation of some of the PIN_CONFIG_* options in this
12driver library. PIN_CONFIG_OUTPUT_ENABLE should refer to a buffer or
13switch in the output direction of the electrical path. The MediaTek
14hardware does not have such a thing. The driver incorrectly maps this
15option to the GPIO function's direction.
16
17Likewise, PIN_CONFIG_INPUT_ENABLE should refer to a buffer or switch in
18the input direction. The hardware does have such a mechanism, and is
19mapped to the IES bit. The driver however sets the direction in addition
20to the IES bit, which is incorrect. On readback, the IES bit isn't even
21considered.
22
23Ironically, the driver does not support readback for PIN_CONFIG_OUTPUT,
24while its readback of PIN_CONFIG_{INPUT,OUTPUT}_ENABLE is what it should
25be doing for PIN_CONFIG_OUTPUT.
26
27Rework support for these three options, so that PIN_CONFIG_OUTPUT_ENABLE
28is completely removed, PIN_CONFIG_INPUT_ENABLE is only linked to the IES
29bit, and PIN_CONFIG_OUTPUT is linked to the GPIO function's direction
30and output level.
31
32Fixes: 805250982bb5 ("pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindings")
33Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
34Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
35Message-ID: <20240327091336.3434141-3-wenst@chromium.org>
36Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
37Signed-off-by: Sasha Levin <sashal@kernel.org>
38---
39 drivers/pinctrl/mediatek/pinctrl-paris.c | 38 +++++++-----------------
40 1 file changed, 11 insertions(+), 27 deletions(-)
41
42diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
43index 95a71606c2865..7f1acfe1a413d 100644
44--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
45+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
46@@ -113,20 +113,21 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
47 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SR, &ret);
48 break;
49 case PIN_CONFIG_INPUT_ENABLE:
50- case PIN_CONFIG_OUTPUT_ENABLE:
51+ err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_IES, &ret);
52+ if (!ret)
53+ err = -EINVAL;
54+ break;
55+ case PIN_CONFIG_OUTPUT:
56 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &ret);
57 if (err)
58 break;
59- /* CONFIG Current direction return value
60- * ------------- ----------------- ----------------------
61- * OUTPUT_ENABLE output 1 (= HW value)
62- * input 0 (= HW value)
63- * INPUT_ENABLE output 0 (= reverse HW value)
64- * input 1 (= reverse HW value)
65- */
66- if (param == PIN_CONFIG_INPUT_ENABLE)
67- ret = !ret;
68
69+ if (!ret) {
70+ err = -EINVAL;
71+ break;
72+ }
73+
74+ err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DO, &ret);
75 break;
76 case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
77 err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &ret);
78@@ -204,26 +205,9 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
79 break;
80 err = hw->soc->bias_set_combo(hw, desc, 0, arg);
81 break;
82- case PIN_CONFIG_OUTPUT_ENABLE:
83- err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT,
84- MTK_DISABLE);
85- /* Keep set direction to consider the case that a GPIO pin
86- * does not have SMT control
87- */
88- if (err != -ENOTSUPP)
89- break;
90-
91- err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
92- MTK_OUTPUT);
93- break;
94 case PIN_CONFIG_INPUT_ENABLE:
95 /* regard all non-zero value as enable */
96 err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_IES, !!arg);
97- if (err)
98- break;
99-
100- err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
101- MTK_INPUT);
102 break;
103 case PIN_CONFIG_SLEW_RATE:
104 /* regard all non-zero value as enable */
105--
1062.43.0
107