Commit fae82621 authored by Sam Shih's avatar Sam Shih Committed by Linus Walleij

pinctrl: mediatek: extend pinctrl-moore to support new bias functions

Commit fb34a9ae ("pinctrl: mediatek: support rsel feature")
introduced SoC specify 'pull_type' attribute to mtk_pinconf_bias_set_combo
and mtk_pinconf_bias_get_combo, and make the functions able to support
almost all Mediatek SoCs that use pinctrl-mtk-common-v2.c.

This patch enables pinctrl_moore to support these functions.
Signed-off-by: default avatarSam Shih <sam.shih@mediatek.com>
Signed-off-by: default avatarFrank Wunderlich <frank-w@public-files.de>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20221106080114.7426-6-linux@fw-web.deSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 3476b354
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* *
*/ */
#include <dt-bindings/pinctrl/mt65xx.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/pinctrl/consumer.h> #include <linux/pinctrl/consumer.h>
...@@ -108,7 +109,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, ...@@ -108,7 +109,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
{ {
struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev); struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
u32 param = pinconf_to_config_param(*config); u32 param = pinconf_to_config_param(*config);
int val, val2, err, reg, ret = 1; int val, val2, err, pullup, reg, ret = 1;
const struct mtk_pin_desc *desc; const struct mtk_pin_desc *desc;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin]; desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
...@@ -117,7 +118,13 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, ...@@ -117,7 +118,13 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
switch (param) { switch (param) {
case PIN_CONFIG_BIAS_DISABLE: case PIN_CONFIG_BIAS_DISABLE:
if (hw->soc->bias_disable_get) { if (hw->soc->bias_get_combo) {
err = hw->soc->bias_get_combo(hw, desc, &pullup, &ret);
if (err)
return err;
if (ret != MTK_PUPD_SET_R1R0_00 && ret != MTK_DISABLE)
return -EINVAL;
} else if (hw->soc->bias_disable_get) {
err = hw->soc->bias_disable_get(hw, desc, &ret); err = hw->soc->bias_disable_get(hw, desc, &ret);
if (err) if (err)
return err; return err;
...@@ -126,7 +133,15 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, ...@@ -126,7 +133,15 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
} }
break; break;
case PIN_CONFIG_BIAS_PULL_UP: case PIN_CONFIG_BIAS_PULL_UP:
if (hw->soc->bias_get) { if (hw->soc->bias_get_combo) {
err = hw->soc->bias_get_combo(hw, desc, &pullup, &ret);
if (err)
return err;
if (ret == MTK_PUPD_SET_R1R0_00 || ret == MTK_DISABLE)
return -EINVAL;
if (!pullup)
return -EINVAL;
} else if (hw->soc->bias_get) {
err = hw->soc->bias_get(hw, desc, 1, &ret); err = hw->soc->bias_get(hw, desc, 1, &ret);
if (err) if (err)
return err; return err;
...@@ -135,7 +150,15 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, ...@@ -135,7 +150,15 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
} }
break; break;
case PIN_CONFIG_BIAS_PULL_DOWN: case PIN_CONFIG_BIAS_PULL_DOWN:
if (hw->soc->bias_get) { if (hw->soc->bias_get_combo) {
err = hw->soc->bias_get_combo(hw, desc, &pullup, &ret);
if (err)
return err;
if (ret == MTK_PUPD_SET_R1R0_00 || ret == MTK_DISABLE)
return -EINVAL;
if (pullup)
return -EINVAL;
} else if (hw->soc->bias_get) {
err = hw->soc->bias_get(hw, desc, 0, &ret); err = hw->soc->bias_get(hw, desc, 0, &ret);
if (err) if (err)
return err; return err;
...@@ -238,7 +261,11 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, ...@@ -238,7 +261,11 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
switch (param) { switch (param) {
case PIN_CONFIG_BIAS_DISABLE: case PIN_CONFIG_BIAS_DISABLE:
if (hw->soc->bias_disable_set) { if (hw->soc->bias_set_combo) {
err = hw->soc->bias_set_combo(hw, desc, 0, MTK_DISABLE);
if (err)
return err;
} else if (hw->soc->bias_disable_set) {
err = hw->soc->bias_disable_set(hw, desc); err = hw->soc->bias_disable_set(hw, desc);
if (err) if (err)
return err; return err;
...@@ -247,7 +274,11 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, ...@@ -247,7 +274,11 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
} }
break; break;
case PIN_CONFIG_BIAS_PULL_UP: case PIN_CONFIG_BIAS_PULL_UP:
if (hw->soc->bias_set) { if (hw->soc->bias_set_combo) {
err = hw->soc->bias_set_combo(hw, desc, 1, arg);
if (err)
return err;
} else if (hw->soc->bias_set) {
err = hw->soc->bias_set(hw, desc, 1); err = hw->soc->bias_set(hw, desc, 1);
if (err) if (err)
return err; return err;
...@@ -256,7 +287,11 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, ...@@ -256,7 +287,11 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
} }
break; break;
case PIN_CONFIG_BIAS_PULL_DOWN: case PIN_CONFIG_BIAS_PULL_DOWN:
if (hw->soc->bias_set) { if (hw->soc->bias_set_combo) {
err = hw->soc->bias_set_combo(hw, desc, 0, arg);
if (err)
return err;
} else if (hw->soc->bias_set) {
err = hw->soc->bias_set(hw, desc, 0); err = hw->soc->bias_set(hw, desc, 0);
if (err) if (err)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment