summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/mediatek
diff options
context:
space:
mode:
authorSean Wang <sean.wang@mediatek.com>2018-09-08 13:07:35 +0200
committerLinus Walleij <linus.walleij@linaro.org>2018-09-18 23:53:32 +0200
commit79348f6fb713a339be94ed14dfa210d5d20cf17d (patch)
treeceb22d31735488478d121ed27fd2862ce1d2db35 /drivers/pinctrl/mediatek
parentpinctrl: mediatek: add MT8183 pinctrl driver (diff)
downloadlinux-79348f6fb713a339be94ed14dfa210d5d20cf17d.tar.xz
linux-79348f6fb713a339be94ed14dfa210d5d20cf17d.zip
pinctrl: mediatek: extend advanced pull support in pinctrl-mtk-common-v2.c
Extend the advanced pull based on the legacy bias plus additional r0 and r1 to tweak the resistor level. Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/mediatek')
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 7cdd46f6671e..7d5f570d7211 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -476,6 +476,19 @@ int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PUPD, arg);
+ /* If PUPD register is not supported for that pin, let's fallback to
+ * general bias control.
+ */
+ if (err == -ENOTSUPP) {
+ if (hw->soc->bias_set) {
+ err = hw->soc->bias_set(hw, desc, pullup);
+ if (err)
+ return err;
+ } else {
+ return -ENOTSUPP;
+ }
+ }
+
return err;
}
@@ -487,12 +500,26 @@ int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw,
int err;
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PUPD, &t);
- if (err)
- return err;
- /* t == 0 supposes PULLUP for the customized PULL setup */
- if (pullup ^ !t)
- return -EINVAL;
+ /* If PUPD register is not supported for that pin, let's fallback to
+ * general bias control.
+ */
+ if (err == -ENOTSUPP) {
+ if (hw->soc->bias_get) {
+ err = hw->soc->bias_get(hw, desc, pullup, val);
+ if (err)
+ return err;
+ } else {
+ return -ENOTSUPP;
+ }
+ } else {
+ /* t == 0 supposes PULLUP for the customized PULL setup */
+ if (err)
+ return err;
+
+ if (pullup ^ !t)
+ return -EINVAL;
+ }
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_R0, &t);
if (err)