Skip to content

Commit c5d3b64

Browse files
wenslinusw
authored andcommitted
pinctrl: mediatek: paris: Rework support for PIN_CONFIG_{INPUT,OUTPUT}_ENABLE
There is a misinterpretation of some of the PIN_CONFIG_* options in this driver library. PIN_CONFIG_OUTPUT_ENABLE should refer to a buffer or switch in the output direction of the electrical path. The MediaTek hardware does not have such a thing. The driver incorrectly maps this option to the GPIO function's direction. Likewise, PIN_CONFIG_INPUT_ENABLE should refer to a buffer or switch in the input direction. The hardware does have such a mechanism, and is mapped to the IES bit. The driver however sets the direction in addition to the IES bit, which is incorrect. On readback, the IES bit isn't even considered. Ironically, the driver does not support readback for PIN_CONFIG_OUTPUT, while its readback of PIN_CONFIG_{INPUT,OUTPUT}_ENABLE is what it should be doing for PIN_CONFIG_OUTPUT. Rework support for these three options, so that PIN_CONFIG_OUTPUT_ENABLE is completely removed, PIN_CONFIG_INPUT_ENABLE is only linked to the IES bit, and PIN_CONFIG_OUTPUT is linked to the GPIO function's direction and output level. Fixes: 8052509 ("pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindings") Signed-off-by: Chen-Yu Tsai <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Message-ID: <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 08f66a8 commit c5d3b64

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

drivers/pinctrl/mediatek/pinctrl-paris.c

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,21 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
165165
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SR, &ret);
166166
break;
167167
case PIN_CONFIG_INPUT_ENABLE:
168-
case PIN_CONFIG_OUTPUT_ENABLE:
168+
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_IES, &ret);
169+
if (!ret)
170+
err = -EINVAL;
171+
break;
172+
case PIN_CONFIG_OUTPUT:
169173
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &ret);
170174
if (err)
171175
break;
172-
/* CONFIG Current direction return value
173-
* ------------- ----------------- ----------------------
174-
* OUTPUT_ENABLE output 1 (= HW value)
175-
* input 0 (= HW value)
176-
* INPUT_ENABLE output 0 (= reverse HW value)
177-
* input 1 (= reverse HW value)
178-
*/
179-
if (param == PIN_CONFIG_INPUT_ENABLE)
180-
ret = !ret;
181176

177+
if (!ret) {
178+
err = -EINVAL;
179+
break;
180+
}
181+
182+
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DO, &ret);
182183
break;
183184
case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
184185
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &ret);
@@ -283,26 +284,9 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
283284
break;
284285
err = hw->soc->bias_set_combo(hw, desc, 0, arg);
285286
break;
286-
case PIN_CONFIG_OUTPUT_ENABLE:
287-
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT,
288-
MTK_DISABLE);
289-
/* Keep set direction to consider the case that a GPIO pin
290-
* does not have SMT control
291-
*/
292-
if (err != -ENOTSUPP)
293-
break;
294-
295-
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
296-
MTK_OUTPUT);
297-
break;
298287
case PIN_CONFIG_INPUT_ENABLE:
299288
/* regard all non-zero value as enable */
300289
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_IES, !!arg);
301-
if (err)
302-
break;
303-
304-
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
305-
MTK_INPUT);
306290
break;
307291
case PIN_CONFIG_SLEW_RATE:
308292
/* regard all non-zero value as enable */

0 commit comments

Comments
 (0)