Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1325083 > unrolled thread
| Started by | Biao Huang <biao.huang@mediatek.com> |
|---|---|
| First post | 2016-02-03 10:30 +0100 |
| Last post | 2016-02-05 15:00 +0100 |
| Articles | 7 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/2] pinctrl: mediatek: Add direction control and gpio_request_enable Support Biao Huang <biao.huang@mediatek.com> - 2016-02-03 10:30 +0100
[PATCH 2/2] pinctrl: mediatek: Add gpio_request_enable support Biao Huang <biao.huang@mediatek.com> - 2016-02-03 10:30 +0100
Re: [PATCH 2/2] pinctrl: mediatek: Add gpio_request_enable support Linus Walleij <linus.walleij@linaro.org> - 2016-02-05 15:00 +0100
[PATCH 1/2] pinctrl: mediatek: fix direction control issue Biao Huang <biao.huang@mediatek.com> - 2016-02-03 10:30 +0100
Re: [PATCH 1/2] pinctrl: mediatek: fix direction control issue Hongzhou Yang <hongzhou.yang@mediatek.com> - 2016-02-04 04:20 +0100
Re: [PATCH 1/2] pinctrl: mediatek: fix direction control issue Linus Walleij <linus.walleij@linaro.org> - 2016-02-05 15:00 +0100
Re: [PATCH 1/2] pinctrl: mediatek: fix direction control issue Linus Walleij <linus.walleij@linaro.org> - 2016-02-05 15:00 +0100
| From | Biao Huang <biao.huang@mediatek.com> |
|---|---|
| Date | 2016-02-03 10:30 +0100 |
| Subject | [PATCH 0/2] pinctrl: mediatek: Add direction control and gpio_request_enable Support |
| Message-ID | <qY1V8-8wg-13@gated-at.bofh.it> |
1. Set direction to input when do input-enable/disable and input-schmitt-enable/disable properties. 2. Add gpio_request_enable support to set pin to gpio function. Biao Huang (2): pinctrl: mediatek: fix direction control issue pinctrl: mediatek: Add gpio_request_enable support drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) -- 1.7.9.5
[toc] | [next] | [standalone]
| From | Biao Huang <biao.huang@mediatek.com> |
|---|---|
| Date | 2016-02-03 10:30 +0100 |
| Subject | [PATCH 2/2] pinctrl: mediatek: Add gpio_request_enable support |
| Message-ID | <qY1V8-8wg-15@gated-at.bofh.it> |
| In reply to | #1325083 |
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
[toc] | [prev] | [next] | [standalone]
| From | Linus Walleij <linus.walleij@linaro.org> |
|---|---|
| Date | 2016-02-05 15:00 +0100 |
| Subject | Re: [PATCH 2/2] pinctrl: mediatek: Add gpio_request_enable support |
| Message-ID | <qYP5x-Xo-33@gated-at.bofh.it> |
| In reply to | #1325084 |
On Wed, Feb 3, 2016 at 2:24 AM, Biao Huang <biao.huang@mediatek.com> wrote: > 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> Patch applied to my devel-mt2701 branch. Yours, Linus Walleij
[toc] | [prev] | [next] | [standalone]
| From | Biao Huang <biao.huang@mediatek.com> |
|---|---|
| Date | 2016-02-03 10:30 +0100 |
| Subject | [PATCH 1/2] pinctrl: mediatek: fix direction control issue |
| Message-ID | <qY1Va-8wg-33@gated-at.bofh.it> |
| In reply to | #1325083 |
Since input-enable/disable and input-schmitt-enable/disable are workable when gpio direction is input, so add direction setting when do input-enable/disable and input-schmitt-enable/disable properties. Signed-off-by: Biao Huang <biao.huang@mediatek.com> --- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index 8cac73d..6eb01c9 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -352,6 +352,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev, ret = mtk_pconf_set_pull_select(pctl, pin, true, false, arg); break; case PIN_CONFIG_INPUT_ENABLE: + mtk_pmx_gpio_set_direction(pctldev, NULL, pin, true); ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param); break; case PIN_CONFIG_OUTPUT: @@ -359,6 +360,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev, ret = mtk_pmx_gpio_set_direction(pctldev, NULL, pin, false); break; case PIN_CONFIG_INPUT_SCHMITT_ENABLE: + mtk_pmx_gpio_set_direction(pctldev, NULL, pin, true); ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param); break; case PIN_CONFIG_DRIVE_STRENGTH: -- 1.7.9.5
[toc] | [prev] | [next] | [standalone]
| From | Hongzhou Yang <hongzhou.yang@mediatek.com> |
|---|---|
| Date | 2016-02-04 04:20 +0100 |
| Subject | Re: [PATCH 1/2] pinctrl: mediatek: fix direction control issue |
| Message-ID | <qYiCB-2XI-1@gated-at.bofh.it> |
| In reply to | #1325087 |
On Wed, 2016-02-03 at 09:24 +0800, Biao Huang wrote: > Since input-enable/disable and input-schmitt-enable/disable are > workable when gpio direction is input, so add direction setting > when do input-enable/disable and input-schmitt-enable/disable > properties. > > Signed-off-by: Biao Huang <biao.huang@mediatek.com> > --- > drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c > index 8cac73d..6eb01c9 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c > @@ -352,6 +352,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev, > ret = mtk_pconf_set_pull_select(pctl, pin, true, false, arg); > break; > case PIN_CONFIG_INPUT_ENABLE: > + mtk_pmx_gpio_set_direction(pctldev, NULL, pin, true); > ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param); Hi Linus, From pinctrl-bindings.txt, 'input-enable' property defined as following: input-enable - enable input on pin (no effect on output) Since input enable and input direction are two different settings on our SOC, could you tell me the exact meaning of this property? Input enable only? Or set input direction at the same time? Thanks, Hongzhou
[toc] | [prev] | [next] | [standalone]
| From | Linus Walleij <linus.walleij@linaro.org> |
|---|---|
| Date | 2016-02-05 15:00 +0100 |
| Subject | Re: [PATCH 1/2] pinctrl: mediatek: fix direction control issue |
| Message-ID | <qYP5w-Xo-5@gated-at.bofh.it> |
| In reply to | #1326360 |
On Thu, Feb 4, 2016 at 4:03 AM, Hongzhou Yang <hongzhou.yang@mediatek.com> wrote: > On Wed, 2016-02-03 at 09:24 +0800, Biao Huang wrote: >> Since input-enable/disable and input-schmitt-enable/disable are >> workable when gpio direction is input, so add direction setting >> when do input-enable/disable and input-schmitt-enable/disable >> properties. >> >> Signed-off-by: Biao Huang <biao.huang@mediatek.com> >> --- >> drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c >> index 8cac73d..6eb01c9 100644 >> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c >> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c >> @@ -352,6 +352,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev, >> ret = mtk_pconf_set_pull_select(pctl, pin, true, false, arg); >> break; >> case PIN_CONFIG_INPUT_ENABLE: >> + mtk_pmx_gpio_set_direction(pctldev, NULL, pin, true); >> ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param); > > Hi Linus, > > From pinctrl-bindings.txt, 'input-enable' property defined as following: > input-enable - enable input on pin (no effect on output) > > Since input enable and input direction are two different settings on our > SOC, What does this mean? How can input have a "direction"? Isn't the direction of an input always inbound, into the SoC? Please elaborate. > could you tell me the exact meaning of this property? Input enable > only? Or set input direction at the same time? This was added in commit 8ba3f4d00078e7a49c60c0bd6298f29402c3a0a0 "pinctrl: Adds slew-rate, input-enable/disable" by Sherman Yin so let's ask him first. I interpret it as if there is a single bit setting a pin to input, these two boolean flags toggle that bit, so it would be the first setting on your SoC in that case. Yours, Linus Walleij
[toc] | [prev] | [next] | [standalone]
| From | Linus Walleij <linus.walleij@linaro.org> |
|---|---|
| Date | 2016-02-05 15:00 +0100 |
| Subject | Re: [PATCH 1/2] pinctrl: mediatek: fix direction control issue |
| Message-ID | <qYP5w-Xo-17@gated-at.bofh.it> |
| In reply to | #1325087 |
On Wed, Feb 3, 2016 at 2:24 AM, Biao Huang <biao.huang@mediatek.com> wrote: > Since input-enable/disable and input-schmitt-enable/disable are > workable when gpio direction is input, so add direction setting > when do input-enable/disable and input-schmitt-enable/disable > properties. > > Signed-off-by: Biao Huang <biao.huang@mediatek.com> This patch applied for fixes. I see now that it was part of the mt2701 patch set, so sorry for missing it... Yours, Linus Walleij
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web