]>
Commit | Line | Data |
---|---|---|
3e0dbc26 SL |
1 | From b6607c0ca12cb3ce6bd09c62d87d400cf759badd Mon Sep 17 00:00:00 2001 |
2 | From: Sasha Levin <sashal@kernel.org> | |
3 | Date: Wed, 27 Mar 2024 17:13:34 +0800 | |
4 | Subject: pinctrl: mediatek: paris: Rework support for | |
5 | PIN_CONFIG_{INPUT,OUTPUT}_ENABLE | |
6 | ||
7 | From: Chen-Yu Tsai <wenst@chromium.org> | |
8 | ||
9 | [ Upstream commit c5d3b64c568a344e998830e0e94a7c04e372f89b ] | |
10 | ||
11 | There is a misinterpretation of some of the PIN_CONFIG_* options in this | |
12 | driver library. PIN_CONFIG_OUTPUT_ENABLE should refer to a buffer or | |
13 | switch in the output direction of the electrical path. The MediaTek | |
14 | hardware does not have such a thing. The driver incorrectly maps this | |
15 | option to the GPIO function's direction. | |
16 | ||
17 | Likewise, PIN_CONFIG_INPUT_ENABLE should refer to a buffer or switch in | |
18 | the input direction. The hardware does have such a mechanism, and is | |
19 | mapped to the IES bit. The driver however sets the direction in addition | |
20 | to the IES bit, which is incorrect. On readback, the IES bit isn't even | |
21 | considered. | |
22 | ||
23 | Ironically, the driver does not support readback for PIN_CONFIG_OUTPUT, | |
24 | while its readback of PIN_CONFIG_{INPUT,OUTPUT}_ENABLE is what it should | |
25 | be doing for PIN_CONFIG_OUTPUT. | |
26 | ||
27 | Rework support for these three options, so that PIN_CONFIG_OUTPUT_ENABLE | |
28 | is completely removed, PIN_CONFIG_INPUT_ENABLE is only linked to the IES | |
29 | bit, and PIN_CONFIG_OUTPUT is linked to the GPIO function's direction | |
30 | and output level. | |
31 | ||
32 | Fixes: 805250982bb5 ("pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindings") | |
33 | Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> | |
34 | Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> | |
35 | Message-ID: <20240327091336.3434141-3-wenst@chromium.org> | |
36 | Signed-off-by: Linus Walleij <linus.walleij@linaro.org> | |
37 | Signed-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 | ||
42 | diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c | |
43 | index 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 | -- | |
106 | 2.43.0 | |
107 |