Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1391285 > unrolled thread
| Started by | Laxman Dewangan <ldewangan@nvidia.com> |
|---|---|
| First post | 2016-04-29 18:40 +0200 |
| Last post | 2016-04-30 13:20 +0200 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH V2] gpio: tegra: Implement gpio_get_direction callback Laxman Dewangan <ldewangan@nvidia.com> - 2016-04-29 18:40 +0200
Re: [PATCH V2] gpio: tegra: Implement gpio_get_direction callback Stephen Warren <swarren@wwwdotorg.org> - 2016-04-29 18:50 +0200
Re: [PATCH V2] gpio: tegra: Implement gpio_get_direction callback Jon Hunter <jonathanh@nvidia.com> - 2016-04-29 19:20 +0200
Re: [PATCH V2] gpio: tegra: Implement gpio_get_direction callback Linus Walleij <linus.walleij@linaro.org> - 2016-04-30 13:20 +0200
| From | Laxman Dewangan <ldewangan@nvidia.com> |
|---|---|
| Date | 2016-04-29 18:40 +0200 |
| Subject | [PATCH V2] gpio: tegra: Implement gpio_get_direction callback |
| Message-ID | <rtjCr-LR-33@gated-at.bofh.it> |
Implement gpio_get_direction() callback for Tegra GPIO.
The direction is only valid if the pin is configured as
GPIO. If pin is not configured in GPIO mode then this
function return error.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
This patch is based on discussion on series
Re: [PATCH V5 0/4] gpio: tegra: Cleanups and support for debounce
From Linus W:
It would be nice if you also implement .get_direction() which makes
debugfs and initial reading of the state of the lines more accurate.
V1->V2:
- Rearrange the calls to optimise the register access and avoid
much indenting based on Stephen's and Jon review.
drivers/gpio/gpio-tegra.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index b3ddd92..ec891a27 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -191,6 +191,21 @@ static int tegra_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
return 0;
}
+static int tegra_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+ struct tegra_gpio_info *tgi = gpiochip_get_data(chip);
+ u32 pin_mask = BIT(GPIO_BIT(offset));
+ u32 cnf, oe;
+
+ cnf = tegra_gpio_readl(tgi, GPIO_CNF(tgi, offset));
+ if (!(cnf & pin_mask))
+ return -EINVAL;
+
+ oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
+
+ return (oe & pin_mask) ? GPIOF_DIR_OUT : GPIOF_DIR_IN;
+}
+
static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
unsigned int debounce)
{
@@ -575,6 +590,7 @@ static int tegra_gpio_probe(struct platform_device *pdev)
tgi->gc.get = tegra_gpio_get;
tgi->gc.direction_output = tegra_gpio_direction_output;
tgi->gc.set = tegra_gpio_set;
+ tgi->gc.get_direction = tegra_gpio_get_direction;
tgi->gc.to_irq = tegra_gpio_to_irq;
tgi->gc.base = 0;
tgi->gc.ngpio = tgi->bank_count * 32;
--
2.1.4
[toc] | [next] | [standalone]
| From | Stephen Warren <swarren@wwwdotorg.org> |
|---|---|
| Date | 2016-04-29 18:50 +0200 |
| Message-ID | <rtjM6-PX-7@gated-at.bofh.it> |
| In reply to | #1391285 |
On 04/29/2016 10:25 AM, Laxman Dewangan wrote: > Implement gpio_get_direction() callback for Tegra GPIO. > The direction is only valid if the pin is configured as > GPIO. If pin is not configured in GPIO mode then this > function return error. Reviewed-by: Stephen Warren <swarren@nvidia.com>
[toc] | [prev] | [next] | [standalone]
| From | Jon Hunter <jonathanh@nvidia.com> |
|---|---|
| Date | 2016-04-29 19:20 +0200 |
| Message-ID | <rtkf8-1iT-1@gated-at.bofh.it> |
| In reply to | #1391285 |
On 29/04/16 17:25, Laxman Dewangan wrote:
> Implement gpio_get_direction() callback for Tegra GPIO.
> The direction is only valid if the pin is configured as
> GPIO. If pin is not configured in GPIO mode then this
> function return error.
>
> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
>
> ---
> This patch is based on discussion on series
> Re: [PATCH V5 0/4] gpio: tegra: Cleanups and support for debounce
> From Linus W:
> It would be nice if you also implement .get_direction() which makes
> debugfs and initial reading of the state of the lines more accurate.
>
> V1->V2:
> - Rearrange the calls to optimise the register access and avoid
> much indenting based on Stephen's and Jon review.
>
> drivers/gpio/gpio-tegra.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index b3ddd92..ec891a27 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -191,6 +191,21 @@ static int tegra_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
> return 0;
> }
>
> +static int tegra_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
> +{
> + struct tegra_gpio_info *tgi = gpiochip_get_data(chip);
> + u32 pin_mask = BIT(GPIO_BIT(offset));
> + u32 cnf, oe;
> +
> + cnf = tegra_gpio_readl(tgi, GPIO_CNF(tgi, offset));
> + if (!(cnf & pin_mask))
> + return -EINVAL;
> +
> + oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
> +
> + return (oe & pin_mask) ? GPIOF_DIR_OUT : GPIOF_DIR_IN;
> +}
> +
> static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> unsigned int debounce)
> {
> @@ -575,6 +590,7 @@ static int tegra_gpio_probe(struct platform_device *pdev)
> tgi->gc.get = tegra_gpio_get;
> tgi->gc.direction_output = tegra_gpio_direction_output;
> tgi->gc.set = tegra_gpio_set;
> + tgi->gc.get_direction = tegra_gpio_get_direction;
> tgi->gc.to_irq = tegra_gpio_to_irq;
> tgi->gc.base = 0;
> tgi->gc.ngpio = tgi->bank_count * 32;
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Cheers
Jon
[toc] | [prev] | [next] | [standalone]
| From | Linus Walleij <linus.walleij@linaro.org> |
|---|---|
| Date | 2016-04-30 13:20 +0200 |
| Message-ID | <rtB6i-6QV-11@gated-at.bofh.it> |
| In reply to | #1391285 |
On Fri, Apr 29, 2016 at 6:25 PM, Laxman Dewangan <ldewangan@nvidia.com> wrote: > Implement gpio_get_direction() callback for Tegra GPIO. > The direction is only valid if the pin is configured as > GPIO. If pin is not configured in GPIO mode then this > function return error. > > Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Patch applied with Stephen's and Jon's Review/ACK tags. Yours, Linus Walleij
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web