From: Hsin-Yi Wang <hidden> Date: 2021-07-01 06:54:48
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 <redacted>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
On Thu, Jul 1, 2021 at 2:55 PM Hsin-Yi Wang [off-list ref] wrote:
quoted hunk
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 <redacted>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
@@ -926,9 +926,12 @@ int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,if(err)returnerr;}elseif(hw->soc->bias_set_combo){-err=hw->soc->bias_set_combo(hw,desc,pullup,arg);-if(err)-returnerr;+err=mtk_pinconf_bias_set_rev1(hw,desc,pullup);+if(err){+err=mtk_pinconf_bias_set(hw,desc,pullup);+if(err)+returnerr;
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
From: Hsin-Yi Wang <hidden> Date: 2021-07-01 08:17:24
On Thu, Jul 1, 2021 at 3:21 PM Chen-Yu Tsai [off-list ref] wrote:
On Thu, Jul 1, 2021 at 2:55 PM Hsin-Yi Wang [off-list ref] wrote:
quoted
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 <redacted>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
@@ -926,9 +926,12 @@ int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,if(err)returnerr;}elseif(hw->soc->bias_set_combo){-err=hw->soc->bias_set_combo(hw,desc,pullup,arg);-if(err)-returnerr;+err=mtk_pinconf_bias_set_rev1(hw,desc,pullup);+if(err){+err=mtk_pinconf_bias_set(hw,desc,pullup);+if(err)+returnerr;
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.