* [PATCH V2] gpio: tegra: Implement gpio_get_direction callback
@ 2016-04-29 16:25 ` Laxman Dewangan
0 siblings, 0 replies; 7+ messages in thread
From: Laxman Dewangan @ 2016-04-29 16:25 UTC (permalink / raw)
To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
swarren-3lzwWm7+Weoh9ZMKESR00Q,
thierry.reding-Re5JQEeQqe8AvxtiuMwx3w
Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Laxman Dewangan
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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2] gpio: tegra: Implement gpio_get_direction callback
@ 2016-04-29 16:25 ` Laxman Dewangan
0 siblings, 0 replies; 7+ messages in thread
From: Laxman Dewangan @ 2016-04-29 16:25 UTC (permalink / raw)
To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
swarren-3lzwWm7+Weoh9ZMKESR00Q,
thierry.reding-Re5JQEeQqe8AvxtiuMwx3w
Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Laxman Dewangan
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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V2] gpio: tegra: Implement gpio_get_direction callback
@ 2016-04-29 16:25 ` Laxman Dewangan
0 siblings, 0 replies; 7+ messages in thread
From: Laxman Dewangan @ 2016-04-29 16:25 UTC (permalink / raw)
To: linus.walleij, swarren, thierry.reding
Cc: linux-gpio, linux-tegra, linux-kernel, Laxman Dewangan
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V2] gpio: tegra: Implement gpio_get_direction callback
2016-04-29 16:25 ` Laxman Dewangan
(?)
(?)
@ 2016-04-29 16:47 ` Stephen Warren
-1 siblings, 0 replies; 7+ messages in thread
From: Stephen Warren @ 2016-04-29 16:47 UTC (permalink / raw)
To: Laxman Dewangan
Cc: linus.walleij, thierry.reding, linux-gpio, linux-tegra, linux-kernel
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2] gpio: tegra: Implement gpio_get_direction callback
2016-04-29 16:25 ` Laxman Dewangan
@ 2016-04-29 17:15 ` Jon Hunter
-1 siblings, 0 replies; 7+ messages in thread
From: Jon Hunter @ 2016-04-29 17:15 UTC (permalink / raw)
To: Laxman Dewangan, linus.walleij, swarren, thierry.reding
Cc: linux-gpio, linux-tegra, linux-kernel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2] gpio: tegra: Implement gpio_get_direction callback
@ 2016-04-29 17:15 ` Jon Hunter
0 siblings, 0 replies; 7+ messages in thread
From: Jon Hunter @ 2016-04-29 17:15 UTC (permalink / raw)
To: Laxman Dewangan, linus.walleij, swarren, thierry.reding
Cc: linux-gpio, linux-tegra, linux-kernel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2] gpio: tegra: Implement gpio_get_direction callback
2016-04-29 16:25 ` Laxman Dewangan
` (3 preceding siblings ...)
(?)
@ 2016-04-30 11:16 ` Linus Walleij
-1 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2016-04-30 11:16 UTC (permalink / raw)
To: Laxman Dewangan
Cc: Stephen Warren, Thierry Reding, linux-gpio, linux-tegra, linux-kernel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-04-30 11:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29 16:25 [PATCH V2] gpio: tegra: Implement gpio_get_direction callback Laxman Dewangan
2016-04-29 16:25 ` Laxman Dewangan
2016-04-29 16:25 ` Laxman Dewangan
2016-04-29 16:47 ` Stephen Warren
2016-04-29 17:15 ` Jon Hunter
2016-04-29 17:15 ` Jon Hunter
2016-04-30 11:16 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.