From: Biao Huang <biao.huang@mediatek.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
<linux-gpio@vger.kernel.org>, <srv_heupstream@mediatek.com>,
Yingjoe Chen <yingjoe.chen@mediatek.com>,
Hongzhou Yang <hongzhou.yang@mediatek.com>,
Eddie Huang <eddie.huang@mediatek.com>,
Biao Huang <biao.huang@mediatek.com>
Subject: [PATCH 2/2] pinctrl: mediatek: Add gpio_request_enable support
Date: Wed, 3 Feb 2016 09:24:46 +0800 [thread overview]
Message-ID: <1454462686-770-3-git-send-email-biao.huang@mediatek.com> (raw)
In-Reply-To: <1454462686-770-1-git-send-email-biao.huang@mediatek.com>
Implement the .gpio_request_enable() callbacks in struct pinmux_ops
in mediatek pinctrl driver. Make sure that when gpio_request is called,
GPIO on the pin is enabled.
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 36 +++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index 6eb01c9..cbc2204 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -43,6 +43,7 @@
#define MAX_GPIO_MODE_PER_REG 5
#define GPIO_MODE_BITS 3
+#define GPIO_MODE_PREFIX "GPIO"
static const char * const mtk_gpio_functions[] = {
"func0", "func1", "func2", "func3",
@@ -735,12 +736,47 @@ static int mtk_pmx_set_mux(struct pinctrl_dev *pctldev,
return 0;
}
+static int mtk_pmx_find_gpio_mode(struct mtk_pinctrl *pctl,
+ unsigned offset)
+{
+ const struct mtk_desc_pin *pin = pctl->devdata->pins + offset;
+ const struct mtk_desc_function *func = pin->functions;
+
+ while (func && func->name) {
+ if (!strncmp(func->name, GPIO_MODE_PREFIX,
+ sizeof(GPIO_MODE_PREFIX)-1))
+ return func->muxval;
+ func++;
+ }
+ return -EINVAL;
+}
+
+static int mtk_pmx_gpio_request_enable(struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned offset)
+{
+ unsigned long muxval;
+ struct mtk_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
+
+ muxval = mtk_pmx_find_gpio_mode(pctl, offset);
+
+ if (muxval < 0) {
+ dev_err(pctl->dev, "invalid gpio pin %d.\n", offset);
+ return -EINVAL;
+ }
+
+ mtk_pmx_set_mode(pctldev, offset, muxval);
+
+ return 0;
+}
+
static const struct pinmux_ops mtk_pmx_ops = {
.get_functions_count = mtk_pmx_get_funcs_cnt,
.get_function_name = mtk_pmx_get_func_name,
.get_function_groups = mtk_pmx_get_func_groups,
.set_mux = mtk_pmx_set_mux,
.gpio_set_direction = mtk_pmx_gpio_set_direction,
+ .gpio_request_enable = mtk_pmx_gpio_request_enable,
};
static int mtk_gpio_direction_input(struct gpio_chip *chip,
--
1.7.9.5
next prev parent reply other threads:[~2016-02-03 9:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-03 1:24 [PATCH 0/2] pinctrl: mediatek: Add direction control and gpio_request_enable Support Biao Huang
2016-02-03 1:24 ` [PATCH 1/2] pinctrl: mediatek: fix direction control issue Biao Huang
2016-02-04 3:03 ` Hongzhou Yang
2016-02-05 13:52 ` Linus Walleij
2016-02-12 2:07 ` Hongzhou Yang
2016-02-16 8:54 ` Yingjoe Chen
2016-02-16 12:28 ` Linus Walleij
2016-02-05 13:56 ` Linus Walleij
2016-02-03 1:24 ` Biao Huang [this message]
2016-02-05 13:58 ` [PATCH 2/2] pinctrl: mediatek: Add gpio_request_enable support Linus Walleij
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=1454462686-770-3-git-send-email-biao.huang@mediatek.com \
--to=biao.huang@mediatek.com \
--cc=eddie.huang@mediatek.com \
--cc=hongzhou.yang@mediatek.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=srv_heupstream@mediatek.com \
--cc=yingjoe.chen@mediatek.com \
/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