Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: uniphier: set input-enable before pin-muxing

While IECTRL is disabled, input signals are pulled-down internally.
If pin-muxing is set up first, glitch signals (Low to High transition)
might be input to hardware blocks.

Bad case scenario:
[1] The hardware block is already running before pinctrl is handled.
(the reset is de-asserted by default or by a firmware, for example)
[2] The pin-muxing is set up. The input signals to hardware block
are pulled-down by the chip-internal biasing.
[3] The pins are input-enabled. The signals from the board reach the
hardware block.

Actually, one invalid character is input to the UART blocks for such
SoCs as PH1-LD4, PH1-sLD8, where UART devices start to run at the
power on reset.

To avoid such problems, pins should be input-enabled before muxing.

Fixes: 6e9088920258 ("pinctrl: UniPhier: add UniPhier pinctrl core support")
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reported-by: Dai Okamura <okamura.dai@socionext.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Masahiro Yamada and committed by
Linus Walleij
bac7f4c1 e0548004

+7 -3
+7 -3
drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
··· 539 539 unsigned reg, reg_end, shift, mask; 540 540 int ret; 541 541 542 + /* some pins need input-enabling */ 543 + ret = uniphier_conf_pin_input_enable(pctldev, 544 + &pctldev->desc->pins[pin], 1); 545 + if (ret) 546 + return ret; 547 + 542 548 reg = UNIPHIER_PINCTRL_PINMUX_BASE + pin * mux_bits / 32 * reg_stride; 543 549 reg_end = reg + reg_stride; 544 550 shift = pin * mux_bits % 32; ··· 569 563 return ret; 570 564 } 571 565 572 - /* some pins need input-enabling */ 573 - return uniphier_conf_pin_input_enable(pctldev, 574 - &pctldev->desc->pins[pin], 1); 566 + return 0; 575 567 } 576 568 577 569 static int uniphier_pmx_set_mux(struct pinctrl_dev *pctldev,