diff mbox series

[v1,1/1] pinctrl: mediatek: refine mtk_pmx_get_funcs_cnt()

Message ID 1597916439-26376-1-git-send-email-light.hsieh@mediatek.com
State New
Headers show
Series [v1,1/1] pinctrl: mediatek: refine mtk_pmx_get_funcs_cnt() | expand

Commit Message

Light Hsieh (謝明燈) Aug. 20, 2020, 9:40 a.m. UTC
From: Light Hsieh <light.hsieh@mediatek.com>


Refine implementation of mtk_pmx_get_funcs_cnt().
The original implementation always return ARRAY_SIZE(mtk_gpio_functions)
which is 16.

However, MT6765/MT6779 only support 8 functions per GPIO pin. So returning
16 is improper. The new implementation check member nfuncs of struct
mtk_pin_soc for a platform. If nfuncs is not zero, return nfuncs.
If nfuncs is zero, fallback to original implementation by returning
ARRAY_SIZE(mtk_gpio_functions).

Signed-off-by: Light Hsieh <light.hsieh@mediatek.com>

---
 drivers/pinctrl/mediatek/pinctrl-mt6765.c | 1 +
 drivers/pinctrl/mediatek/pinctrl-mt6779.c | 1 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  | 4 ++++
 3 files changed, 6 insertions(+)

-- 
1.8.1.1.dirty
diff mbox series

Patch

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt6765.c b/drivers/pinctrl/mediatek/pinctrl-mt6765.c
index 2c59d39..8d9f3ea 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt6765.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt6765.c
@@ -1069,6 +1069,7 @@ 
 	.pins = mtk_pins_mt6765,
 	.npins = ARRAY_SIZE(mtk_pins_mt6765),
 	.ngrps = ARRAY_SIZE(mtk_pins_mt6765),
+	.nfuncs = 8,
 	.eint_hw = &mt6765_eint_hw,
 	.gpio_m = 0,
 	.base_names = mt6765_pinctrl_register_base_names,
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt6779.c b/drivers/pinctrl/mediatek/pinctrl-mt6779.c
index bb0851c..1f26adb 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt6779.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt6779.c
@@ -744,6 +744,7 @@ 
 	.pins = mtk_pins_mt6779,
 	.npins = ARRAY_SIZE(mtk_pins_mt6779),
 	.ngrps = ARRAY_SIZE(mtk_pins_mt6779),
+	.nfuncs = 8,
 	.eint_hw = &mt6779_eint_hw,
 	.gpio_m = 0,
 	.ies_present = true,
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index a23c182..96f9f86 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -657,6 +657,10 @@  static void mtk_pctrl_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
 
 static int mtk_pmx_get_funcs_cnt(struct pinctrl_dev *pctldev)
 {
+	struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
+ 
+	if (hw->soc->nfuncs)
+		return (int)hw->soc->nfuncs;
 	return ARRAY_SIZE(mtk_gpio_functions);
 }