1 From fae82621ac33e2a4a96220c56e90d1ec6237d394 Mon Sep 17 00:00:00 2001
2 From: Sam Shih <sam.shih@mediatek.com>
3 Date: Sun, 6 Nov 2022 09:01:12 +0100
4 Subject: [PATCH] pinctrl: mediatek: extend pinctrl-moore to support new bias
7 Commit fb34a9ae383a ("pinctrl: mediatek: support rsel feature")
8 introduced SoC specify 'pull_type' attribute to mtk_pinconf_bias_set_combo
9 and mtk_pinconf_bias_get_combo, and make the functions able to support
10 almost all Mediatek SoCs that use pinctrl-mtk-common-v2.c.
12 This patch enables pinctrl_moore to support these functions.
14 Signed-off-by: Sam Shih <sam.shih@mediatek.com>
15 Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
16 Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
17 Link: https://lore.kernel.org/r/20221106080114.7426-6-linux@fw-web.de
18 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
20 drivers/pinctrl/mediatek/pinctrl-moore.c | 49 ++++++++++++++++++++----
21 1 file changed, 42 insertions(+), 7 deletions(-)
23 --- a/drivers/pinctrl/mediatek/pinctrl-moore.c
24 +++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
29 +#include <dt-bindings/pinctrl/mt65xx.h>
30 #include <linux/gpio/driver.h>
31 #include "pinctrl-moore.h"
33 @@ -105,7 +106,7 @@ static int mtk_pinconf_get(struct pinctr
35 struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
36 u32 param = pinconf_to_config_param(*config);
37 - int val, val2, err, reg, ret = 1;
38 + int val, val2, err, pullup, reg, ret = 1;
39 const struct mtk_pin_desc *desc;
41 desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
42 @@ -114,7 +115,13 @@ static int mtk_pinconf_get(struct pinctr
45 case PIN_CONFIG_BIAS_DISABLE:
46 - if (hw->soc->bias_disable_get) {
47 + if (hw->soc->bias_get_combo) {
48 + err = hw->soc->bias_get_combo(hw, desc, &pullup, &ret);
51 + if (ret != MTK_PUPD_SET_R1R0_00 && ret != MTK_DISABLE)
53 + } else if (hw->soc->bias_disable_get) {
54 err = hw->soc->bias_disable_get(hw, desc, &ret);
57 @@ -123,7 +130,15 @@ static int mtk_pinconf_get(struct pinctr
60 case PIN_CONFIG_BIAS_PULL_UP:
61 - if (hw->soc->bias_get) {
62 + if (hw->soc->bias_get_combo) {
63 + err = hw->soc->bias_get_combo(hw, desc, &pullup, &ret);
66 + if (ret == MTK_PUPD_SET_R1R0_00 || ret == MTK_DISABLE)
70 + } else if (hw->soc->bias_get) {
71 err = hw->soc->bias_get(hw, desc, 1, &ret);
74 @@ -132,7 +147,15 @@ static int mtk_pinconf_get(struct pinctr
77 case PIN_CONFIG_BIAS_PULL_DOWN:
78 - if (hw->soc->bias_get) {
79 + if (hw->soc->bias_get_combo) {
80 + err = hw->soc->bias_get_combo(hw, desc, &pullup, &ret);
83 + if (ret == MTK_PUPD_SET_R1R0_00 || ret == MTK_DISABLE)
87 + } else if (hw->soc->bias_get) {
88 err = hw->soc->bias_get(hw, desc, 0, &ret);
91 @@ -235,7 +258,11 @@ static int mtk_pinconf_set(struct pinctr
94 case PIN_CONFIG_BIAS_DISABLE:
95 - if (hw->soc->bias_disable_set) {
96 + if (hw->soc->bias_set_combo) {
97 + err = hw->soc->bias_set_combo(hw, desc, 0, MTK_DISABLE);
100 + } else if (hw->soc->bias_disable_set) {
101 err = hw->soc->bias_disable_set(hw, desc);
104 @@ -244,7 +271,11 @@ static int mtk_pinconf_set(struct pinctr
107 case PIN_CONFIG_BIAS_PULL_UP:
108 - if (hw->soc->bias_set) {
109 + if (hw->soc->bias_set_combo) {
110 + err = hw->soc->bias_set_combo(hw, desc, 1, arg);
113 + } else if (hw->soc->bias_set) {
114 err = hw->soc->bias_set(hw, desc, 1);
117 @@ -253,7 +284,11 @@ static int mtk_pinconf_set(struct pinctr
120 case PIN_CONFIG_BIAS_PULL_DOWN:
121 - if (hw->soc->bias_set) {
122 + if (hw->soc->bias_set_combo) {
123 + err = hw->soc->bias_set_combo(hw, desc, 0, arg);
126 + } else if (hw->soc->bias_set) {
127 err = hw->soc->bias_set(hw, desc, 0);