* [PATCH] pinctrl: mediatek: Fix fallback behavior for bias_set_combo
@ 2021-07-01 6:54 Hsin-Yi Wang
2021-07-01 7:21 ` Chen-Yu Tsai
0 siblings, 1 reply; 3+ messages in thread
From: Hsin-Yi Wang @ 2021-07-01 6:54 UTC (permalink / raw)
To: Sean Wang, Linus Walleij, zhiyong.tao
Cc: Matthias Brugger, linux-mediatek, linux-gpio, linux-arm-kernel,
linux-kernel
Some pin doesn't support PUPD register, if it fails and fallbacks with
bias_set_combo case, it will call mtk_pinconf_bias_set_pupd_r1_r0() to
modify the PUPD pin again.
Since the general bias set are either PU/PD or PULLSEL/PULLEN, try
bias_set or bias_set_rev1 for this fallback case.
Fixes: 81bd1579b43e ("pinctrl: mediatek: Fix fallback call path")
Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 5b3b048725cc8..0cdff487836fa 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -926,9 +926,12 @@ int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,
if (err)
return err;
} else if (hw->soc->bias_set_combo) {
- err = hw->soc->bias_set_combo(hw, desc, pullup, arg);
- if (err)
- return err;
+ err = mtk_pinconf_bias_set_rev1(hw, desc, pullup);
+ if (err) {
+ err = mtk_pinconf_bias_set(hw, desc, pullup);
+ if (err)
+ return err;
+ }
} else {
return -ENOTSUPP;
}
--
2.32.0.93.g670b81a890-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: mediatek: Fix fallback behavior for bias_set_combo
2021-07-01 6:54 [PATCH] pinctrl: mediatek: Fix fallback behavior for bias_set_combo Hsin-Yi Wang
@ 2021-07-01 7:21 ` Chen-Yu Tsai
2021-07-01 8:16 ` Hsin-Yi Wang
0 siblings, 1 reply; 3+ messages in thread
From: Chen-Yu Tsai @ 2021-07-01 7:21 UTC (permalink / raw)
To: Hsin-Yi Wang
Cc: Sean Wang, Linus Walleij, zhiyong.tao, Matthias Brugger,
linux-mediatek, linux-gpio, linux-arm-kernel, linux-kernel
On Thu, Jul 1, 2021 at 2:55 PM Hsin-Yi Wang <hsinyi@chromium.org> wrote:
>
> Some pin doesn't support PUPD register, if it fails and fallbacks with
> bias_set_combo case, it will call mtk_pinconf_bias_set_pupd_r1_r0() to
> modify the PUPD pin again.
>
> Since the general bias set are either PU/PD or PULLSEL/PULLEN, try
> bias_set or bias_set_rev1 for this fallback case.
>
> Fixes: 81bd1579b43e ("pinctrl: mediatek: Fix fallback call path")
> Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
> ---
> drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> index 5b3b048725cc8..0cdff487836fa 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> @@ -926,9 +926,12 @@ int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,
> if (err)
> return err;
> } else if (hw->soc->bias_set_combo) {
> - err = hw->soc->bias_set_combo(hw, desc, pullup, arg);
> - if (err)
> - return err;
> + err = mtk_pinconf_bias_set_rev1(hw, desc, pullup);
> + if (err) {
> + err = mtk_pinconf_bias_set(hw, desc, pullup);
> + if (err)
> + return err;
You don't need to nest this. If mtk_pinconf_bias_set_rev1() succeeds,
err would be 0 and the following if blocks would all be skipped. So:
err = mtk_pinconf_bias_set_rev1();
if (err)
err = mtk_pinconf_bias_set();
if (err)
return err;
Moreover, maybe you should rework the test for hw->soc->bias_set_combo,
as it is no longer relevant to the code within the if block?
ChenYu
> + }
> } else {
> return -ENOTSUPP;
> }
> --
> 2.32.0.93.g670b81a890-goog
>
>
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: mediatek: Fix fallback behavior for bias_set_combo
2021-07-01 7:21 ` Chen-Yu Tsai
@ 2021-07-01 8:16 ` Hsin-Yi Wang
0 siblings, 0 replies; 3+ messages in thread
From: Hsin-Yi Wang @ 2021-07-01 8:16 UTC (permalink / raw)
To: Chen-Yu Tsai
Cc: Sean Wang, Linus Walleij, zhiyong.tao, Matthias Brugger,
moderated list:ARM/Mediatek SoC support, linux-gpio,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE, lkml
On Thu, Jul 1, 2021 at 3:21 PM Chen-Yu Tsai <wenst@chromium.org> wrote:
>
> On Thu, Jul 1, 2021 at 2:55 PM Hsin-Yi Wang <hsinyi@chromium.org> wrote:
> >
> > Some pin doesn't support PUPD register, if it fails and fallbacks with
> > bias_set_combo case, it will call mtk_pinconf_bias_set_pupd_r1_r0() to
> > modify the PUPD pin again.
> >
> > Since the general bias set are either PU/PD or PULLSEL/PULLEN, try
> > bias_set or bias_set_rev1 for this fallback case.
> >
> > Fixes: 81bd1579b43e ("pinctrl: mediatek: Fix fallback call path")
> > Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
> > ---
> > drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> > index 5b3b048725cc8..0cdff487836fa 100644
> > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> > @@ -926,9 +926,12 @@ int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,
> > if (err)
> > return err;
> > } else if (hw->soc->bias_set_combo) {
> > - err = hw->soc->bias_set_combo(hw, desc, pullup, arg);
> > - if (err)
> > - return err;
> > + err = mtk_pinconf_bias_set_rev1(hw, desc, pullup);
> > + if (err) {
> > + err = mtk_pinconf_bias_set(hw, desc, pullup);
> > + if (err)
> > + return err;
>
> You don't need to nest this. If mtk_pinconf_bias_set_rev1() succeeds,
> err would be 0 and the following if blocks would all be skipped. So:
>
> err = mtk_pinconf_bias_set_rev1();
> if (err)
> err = mtk_pinconf_bias_set();
> if (err)
> return err;
>
> Moreover, maybe you should rework the test for hw->soc->bias_set_combo,
> as it is no longer relevant to the code within the if block?
>
Thanks for the comments. It's addressed in v2.
We can try PU/PD and PULLSEL/PULLEN even for pins that don't support
them (eg. mt6797). They will return -ENOTSUPP in
mtk_hw_pin_field_lookup() so won't break current testing logic.
>
> ChenYu
>
> > + }
> > } else {
> > return -ENOTSUPP;
> > }
> > --
> > 2.32.0.93.g670b81a890-goog
> >
> >
> > _______________________________________________
> > Linux-mediatek mailing list
> > Linux-mediatek@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-01 8:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 6:54 [PATCH] pinctrl: mediatek: Fix fallback behavior for bias_set_combo Hsin-Yi Wang
2021-07-01 7:21 ` Chen-Yu Tsai
2021-07-01 8:16 ` Hsin-Yi Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).