u-boot/drivers/pinctrl/mediatek
Daniel Golle bcfb23ec7e pinctrl: mediatek: set R1/R0 in case pullen/pullsel succeeded
Commit dafe0fbfb0 ("pinctrl: mediatek: rewrite mtk_pinconf_set and
related functions") changed the logic deciding to set R0 and R1
registers for V1 devices.

Before:
	/* Also set PUPD/R0/R1 if the pin has them */
	err = mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_PUPD, !pullup);
	if (err != -EINVAL) {
		mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_R0, r0);
		mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_R1, r1);
	}

After:
	/* try pupd_r1_r0 if pullen_pullsel return error */
	err = mtk_pinconf_bias_set_pullen_pullsel(dev, pin, disable, pullup,
						  val);
	if (err)
		return mtk_pinconf_bias_set_pupd_r1_r0(dev, pin, disable,
						       pullup, val);

Tracing mtk_pinconf_bias_set_pullen_pullsel shows that the function
always either returns 0 in case of success or -EINVAL in case any error
has occurred. Hence the logic responsible of the decision to program R0
and R1 has been inverted.

This leads to problems on BananaPi R2 (MT7623N) when booting from
SDMMC, it turns out accessing eMMC no longer works since
U-Boot 2022.07:

MT7623> mmc dev 0
Card did not respond to voltage select! : -110

The problem wasn't detected for a long time as both eMMC and SDMMC work
fine if they are used to boot from, and hence R0 and R1 were already
setup by the bootrom and/or preloader.

Fix the logic to restore the originally intended and correct behavior
and also change the descriptive comment accordingly.

Fixes: dafe0fbfb0 ("pinctrl: mediatek: rewrite mtk_pinconf_set and related functions")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Tested-By: Frank Wunderlich <frank-w@public-files.de>
2023-05-03 09:05:24 -04:00
..
Kconfig pinctrl: mediatek: add pinctrl driver for MT7986 SoC 2022-09-23 15:09:15 -04:00
Makefile pinctrl: mediatek: add pinctrl driver for MT7986 SoC 2022-09-23 15:09:15 -04:00
pinctrl-mt7622.c WS cleanup: remove trailing empty lines 2021-09-30 08:08:56 -04:00
pinctrl-mt7623.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
pinctrl-mt7629.c pinctrl: mt7629: add jtag function and pin group 2021-03-20 16:24:27 -04:00
pinctrl-mt7981.c pinctrl: mediatek: add pinctrl driver for MT7981 SoC 2022-09-23 15:09:15 -04:00
pinctrl-mt7986.c pinctrl: mediatek: add pinctrl driver for MT7986 SoC 2022-09-23 15:09:15 -04:00
pinctrl-mt8512.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
pinctrl-mt8516.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
pinctrl-mt8518.c dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
pinctrl-mtk-common.c pinctrl: mediatek: set R1/R0 in case pullen/pullsel succeeded 2023-05-03 09:05:24 -04:00
pinctrl-mtk-common.h pinctrl: mediatek: add support for different types of IO pins 2022-05-05 09:29:58 -04:00