From: <light.hsieh@mediatek.com>
To: <linus.walleij@linaro.org>
Cc: <linux-mediatek@lists.infradead.org>,
<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<sean.wang@kernel.org>, <kuohong.wang@mediatek.com>,
Light Hsieh <light.hsieh@mediatek.com>
Subject: [PATCH v1 1/1] pinctrl: mediatek: refine mtk_pmx_get_funcs_cnt()
Date: Thu, 20 Aug 2020 17:40:39 +0800 [thread overview]
Message-ID: <1597916439-26376-1-git-send-email-light.hsieh@mediatek.com> (raw)
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(+)
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);
}
--
1.8.1.1.dirty
reply other threads:[~2020-08-20 13:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1597916439-26376-1-git-send-email-light.hsieh@mediatek.com \
--to=light.hsieh@mediatek.com \
--cc=kuohong.wang@mediatek.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=sean.wang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).