All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] gpio: omap: implement get_direction
@ 2014-04-24  6:57 ` yegorslists at googlemail.com
  0 siblings, 0 replies; 12+ messages in thread
From: yegorslists @ 2014-04-24  6:57 UTC (permalink / raw)
  To: linux-gpio
  Cc: linux-arm-kernel, linux-omap, tony, linus.walleij, Yegor Yefremov

From: Yegor Yefremov <yegorslists@googlemail.com>

This patch implements gpio_chip's get_direction() routine, that
lets other drivers get particular GPIOs direction using
struct gpio_desc.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
---
Changes:
	v3: get rid of _get_gpio_direction() (Linus Walleij)
	v2: rework return value calculation
 drivers/gpio/gpio-omap.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 19b886c..62c12e4 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -27,6 +27,7 @@
 #include <linux/irqdomain.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/gpio.h>
+#include <linux/bitops.h>
 #include <linux/platform_data/gpio-omap.h>
 
 #define OFF_MODE	1
@@ -936,6 +937,21 @@ static inline void mpuio_init(struct gpio_bank *bank)
 
 /*---------------------------------------------------------------------*/
 
+static int gpio_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+	struct gpio_bank *bank;
+	unsigned long flags;
+	void __iomem *reg;
+	int dir;
+
+	bank = container_of(chip, struct gpio_bank, chip);
+	reg = bank->base + bank->regs->direction;
+	spin_lock_irqsave(&bank->lock, flags);
+	dir = !!(readl_relaxed(reg) & BIT(offset));
+	spin_unlock_irqrestore(&bank->lock, flags);
+	return dir;
+}
+
 static int gpio_input(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_bank *bank;
@@ -1092,6 +1108,7 @@ static void omap_gpio_chip_init(struct gpio_bank *bank)
 	 */
 	bank->chip.request = omap_gpio_request;
 	bank->chip.free = omap_gpio_free;
+	bank->chip.get_direction = gpio_get_direction;
 	bank->chip.direction_input = gpio_input;
 	bank->chip.get = gpio_get;
 	bank->chip.direction_output = gpio_output;
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3] gpio: omap: implement get_direction
@ 2014-04-24  6:57 ` yegorslists at googlemail.com
  0 siblings, 0 replies; 12+ messages in thread
From: yegorslists at googlemail.com @ 2014-04-24  6:57 UTC (permalink / raw)
  To: linux-arm-kernel

From: Yegor Yefremov <yegorslists@googlemail.com>

This patch implements gpio_chip's get_direction() routine, that
lets other drivers get particular GPIOs direction using
struct gpio_desc.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
---
Changes:
	v3: get rid of _get_gpio_direction() (Linus Walleij)
	v2: rework return value calculation
 drivers/gpio/gpio-omap.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 19b886c..62c12e4 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -27,6 +27,7 @@
 #include <linux/irqdomain.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/gpio.h>
+#include <linux/bitops.h>
 #include <linux/platform_data/gpio-omap.h>
 
 #define OFF_MODE	1
@@ -936,6 +937,21 @@ static inline void mpuio_init(struct gpio_bank *bank)
 
 /*---------------------------------------------------------------------*/
 
+static int gpio_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+	struct gpio_bank *bank;
+	unsigned long flags;
+	void __iomem *reg;
+	int dir;
+
+	bank = container_of(chip, struct gpio_bank, chip);
+	reg = bank->base + bank->regs->direction;
+	spin_lock_irqsave(&bank->lock, flags);
+	dir = !!(readl_relaxed(reg) & BIT(offset));
+	spin_unlock_irqrestore(&bank->lock, flags);
+	return dir;
+}
+
 static int gpio_input(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_bank *bank;
@@ -1092,6 +1108,7 @@ static void omap_gpio_chip_init(struct gpio_bank *bank)
 	 */
 	bank->chip.request = omap_gpio_request;
 	bank->chip.free = omap_gpio_free;
+	bank->chip.get_direction = gpio_get_direction;
 	bank->chip.direction_input = gpio_input;
 	bank->chip.get = gpio_get;
 	bank->chip.direction_output = gpio_output;
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] gpio: omap: implement get_direction
  2014-04-24  6:57 ` yegorslists at googlemail.com
@ 2014-04-24 13:13   ` Linus Walleij
  -1 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2014-04-24 13:13 UTC (permalink / raw)
  To: yegorslists, Kevin Hilman, Santosh Shilimkar
  Cc: linux-gpio, linux-arm-kernel, Linux-OMAP, ext Tony Lindgren

On Thu, Apr 24, 2014 at 8:57 AM,  <yegorslists@googlemail.com> wrote:

> From: Yegor Yefremov <yegorslists@googlemail.com>
>
> This patch implements gpio_chip's get_direction() routine, that
> lets other drivers get particular GPIOs direction using
> struct gpio_desc.
>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
> ---
> Changes:
>         v3: get rid of _get_gpio_direction() (Linus Walleij)
>         v2: rework return value calculation

Looks good to me, Kevin, Santosh?

Part of me wants to list Javier as maintainer for this driver.

> +static int gpio_get_direction(struct gpio_chip *chip, unsigned offset)
> +{
> +       struct gpio_bank *bank;
> +       unsigned long flags;
> +       void __iomem *reg;
> +       int dir;

That is a bool, actually. But no big deal.

> +
> +       bank = container_of(chip, struct gpio_bank, chip);
> +       reg = bank->base + bank->regs->direction;
> +       spin_lock_irqsave(&bank->lock, flags);
> +       dir = !!(readl_relaxed(reg) & BIT(offset));
> +       spin_unlock_irqrestore(&bank->lock, flags);
> +       return dir;
> +}

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] gpio: omap: implement get_direction
@ 2014-04-24 13:13   ` Linus Walleij
  0 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2014-04-24 13:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 24, 2014 at 8:57 AM,  <yegorslists@googlemail.com> wrote:

> From: Yegor Yefremov <yegorslists@googlemail.com>
>
> This patch implements gpio_chip's get_direction() routine, that
> lets other drivers get particular GPIOs direction using
> struct gpio_desc.
>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
> ---
> Changes:
>         v3: get rid of _get_gpio_direction() (Linus Walleij)
>         v2: rework return value calculation

Looks good to me, Kevin, Santosh?

Part of me wants to list Javier as maintainer for this driver.

> +static int gpio_get_direction(struct gpio_chip *chip, unsigned offset)
> +{
> +       struct gpio_bank *bank;
> +       unsigned long flags;
> +       void __iomem *reg;
> +       int dir;

That is a bool, actually. But no big deal.

> +
> +       bank = container_of(chip, struct gpio_bank, chip);
> +       reg = bank->base + bank->regs->direction;
> +       spin_lock_irqsave(&bank->lock, flags);
> +       dir = !!(readl_relaxed(reg) & BIT(offset));
> +       spin_unlock_irqrestore(&bank->lock, flags);
> +       return dir;
> +}

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] gpio: omap: implement get_direction
  2014-04-24 13:13   ` Linus Walleij
@ 2014-04-24 13:29     ` Santosh Shilimkar
  -1 siblings, 0 replies; 12+ messages in thread
From: Santosh Shilimkar @ 2014-04-24 13:29 UTC (permalink / raw)
  To: Linus Walleij, yegorslists, Kevin Hilman
  Cc: linux-gpio, linux-arm-kernel, Linux-OMAP, ext Tony Lindgren

On Thursday 24 April 2014 09:13 AM, Linus Walleij wrote:
> On Thu, Apr 24, 2014 at 8:57 AM,  <yegorslists@googlemail.com> wrote:
> 
>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>
>> This patch implements gpio_chip's get_direction() routine, that
>> lets other drivers get particular GPIOs direction using
>> struct gpio_desc.
>>
>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>> Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
>> ---
>> Changes:
>>         v3: get rid of _get_gpio_direction() (Linus Walleij)
>>         v2: rework return value calculation
> 
> Looks good to me, Kevin, Santosh?
> 
Looks fine to me as well.
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

> Part of me wants to list Javier as maintainer for this driver.
> 
Am ok with it as well.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] gpio: omap: implement get_direction
@ 2014-04-24 13:29     ` Santosh Shilimkar
  0 siblings, 0 replies; 12+ messages in thread
From: Santosh Shilimkar @ 2014-04-24 13:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Thursday 24 April 2014 09:13 AM, Linus Walleij wrote:
> On Thu, Apr 24, 2014 at 8:57 AM,  <yegorslists@googlemail.com> wrote:
> 
>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>
>> This patch implements gpio_chip's get_direction() routine, that
>> lets other drivers get particular GPIOs direction using
>> struct gpio_desc.
>>
>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>> Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
>> ---
>> Changes:
>>         v3: get rid of _get_gpio_direction() (Linus Walleij)
>>         v2: rework return value calculation
> 
> Looks good to me, Kevin, Santosh?
> 
Looks fine to me as well.
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

> Part of me wants to list Javier as maintainer for this driver.
> 
Am ok with it as well.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] gpio: omap: implement get_direction
  2014-04-24  6:57 ` yegorslists at googlemail.com
@ 2014-04-24 13:35   ` Linus Walleij
  -1 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2014-04-24 13:35 UTC (permalink / raw)
  To: yegorslists; +Cc: linux-gpio, linux-arm-kernel, Linux-OMAP, ext Tony Lindgren

On Thu, Apr 24, 2014 at 8:57 AM,  <yegorslists@googlemail.com> wrote:

> From: Yegor Yefremov <yegorslists@googlemail.com>
>
> This patch implements gpio_chip's get_direction() routine, that
> lets other drivers get particular GPIOs direction using
> struct gpio_desc.
>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
> ---
> Changes:
>         v3: get rid of _get_gpio_direction() (Linus Walleij)
>         v2: rework return value calculation

This v3 version applied with Santosh's ACK.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] gpio: omap: implement get_direction
@ 2014-04-24 13:35   ` Linus Walleij
  0 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2014-04-24 13:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 24, 2014 at 8:57 AM,  <yegorslists@googlemail.com> wrote:

> From: Yegor Yefremov <yegorslists@googlemail.com>
>
> This patch implements gpio_chip's get_direction() routine, that
> lets other drivers get particular GPIOs direction using
> struct gpio_desc.
>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
> ---
> Changes:
>         v3: get rid of _get_gpio_direction() (Linus Walleij)
>         v2: rework return value calculation

This v3 version applied with Santosh's ACK.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] gpio: omap: implement get_direction
  2014-04-24 13:29     ` Santosh Shilimkar
@ 2014-04-24 16:42       ` Tony Lindgren
  -1 siblings, 0 replies; 12+ messages in thread
From: Tony Lindgren @ 2014-04-24 16:42 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: Linus Walleij, yegorslists, Kevin Hilman, linux-gpio,
	linux-arm-kernel, Linux-OMAP

* Santosh Shilimkar <santosh.shilimkar@ti.com> [140424 06:30]:
> On Thursday 24 April 2014 09:13 AM, Linus Walleij wrote:
> > On Thu, Apr 24, 2014 at 8:57 AM,  <yegorslists@googlemail.com> wrote:
> > 
> >> From: Yegor Yefremov <yegorslists@googlemail.com>
> >>
> >> This patch implements gpio_chip's get_direction() routine, that
> >> lets other drivers get particular GPIOs direction using
> >> struct gpio_desc.
> >>
> >> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> >> Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
> >> ---
> >> Changes:
> >>         v3: get rid of _get_gpio_direction() (Linus Walleij)
> >>         v2: rework return value calculation
> > 
> > Looks good to me, Kevin, Santosh?
> > 
> Looks fine to me as well.
> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

OK finally got around testing gpio/for-next here. Could not use
todays linux next as it's broken again for whatever reasons and
does not even compile for me.

Boot tested gpio/next on few omap1 boards: h2, osk and 770 and
things behave the same way as earlier for me on these boards.
Also made sure the PM does not break as tested on n900 with the
GPIO changes. So for the following patches, feel free to add:

cb2a5fb059b5 gpio: do not set up hardware for IRQ_TYPE_NONE
da09ceae78f7 gpio: omap: implement get_direction
d04b76626e94 gpio: omap: convert driver to use gpiolib irqchip
d4094cd7577c gpio: omap: check gpiochip_add() return value
820eade1b7f3 gpio: omap: convert to use irq_domain_add_simple()
717f70e39a98 gpio: omap: Use devm_ioremap_resource()

Tested-by: Tony Lindgren <tony@atomide.com>

Naturally no need to go back to edit the commits for my acks
unless there are other reasons to redo the branches.

> > Part of me wants to list Javier as maintainer for this driver.
> > 
> Am ok with it as well.

That sounds good to me too, looks like Javier is doing a good job
on that already :)

Regards,

Tony 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] gpio: omap: implement get_direction
@ 2014-04-24 16:42       ` Tony Lindgren
  0 siblings, 0 replies; 12+ messages in thread
From: Tony Lindgren @ 2014-04-24 16:42 UTC (permalink / raw)
  To: linux-arm-kernel

* Santosh Shilimkar <santosh.shilimkar@ti.com> [140424 06:30]:
> On Thursday 24 April 2014 09:13 AM, Linus Walleij wrote:
> > On Thu, Apr 24, 2014 at 8:57 AM,  <yegorslists@googlemail.com> wrote:
> > 
> >> From: Yegor Yefremov <yegorslists@googlemail.com>
> >>
> >> This patch implements gpio_chip's get_direction() routine, that
> >> lets other drivers get particular GPIOs direction using
> >> struct gpio_desc.
> >>
> >> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> >> Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
> >> ---
> >> Changes:
> >>         v3: get rid of _get_gpio_direction() (Linus Walleij)
> >>         v2: rework return value calculation
> > 
> > Looks good to me, Kevin, Santosh?
> > 
> Looks fine to me as well.
> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

OK finally got around testing gpio/for-next here. Could not use
todays linux next as it's broken again for whatever reasons and
does not even compile for me.

Boot tested gpio/next on few omap1 boards: h2, osk and 770 and
things behave the same way as earlier for me on these boards.
Also made sure the PM does not break as tested on n900 with the
GPIO changes. So for the following patches, feel free to add:

cb2a5fb059b5 gpio: do not set up hardware for IRQ_TYPE_NONE
da09ceae78f7 gpio: omap: implement get_direction
d04b76626e94 gpio: omap: convert driver to use gpiolib irqchip
d4094cd7577c gpio: omap: check gpiochip_add() return value
820eade1b7f3 gpio: omap: convert to use irq_domain_add_simple()
717f70e39a98 gpio: omap: Use devm_ioremap_resource()

Tested-by: Tony Lindgren <tony@atomide.com>

Naturally no need to go back to edit the commits for my acks
unless there are other reasons to redo the branches.

> > Part of me wants to list Javier as maintainer for this driver.
> > 
> Am ok with it as well.

That sounds good to me too, looks like Javier is doing a good job
on that already :)

Regards,

Tony 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] gpio: omap: implement get_direction
  2014-04-24 13:13   ` Linus Walleij
@ 2014-04-24 22:25     ` Kevin Hilman
  -1 siblings, 0 replies; 12+ messages in thread
From: Kevin Hilman @ 2014-04-24 22:25 UTC (permalink / raw)
  To: Linus Walleij
  Cc: yegorslists, Santosh Shilimkar, linux-gpio, linux-arm-kernel,
	Linux-OMAP, ext Tony Lindgren

Linus Walleij <linus.walleij@linaro.org> writes:

> On Thu, Apr 24, 2014 at 8:57 AM,  <yegorslists@googlemail.com> wrote:
>
>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>
>> This patch implements gpio_chip's get_direction() routine, that
>> lets other drivers get particular GPIOs direction using
>> struct gpio_desc.
>>
>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>> Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
>> ---
>> Changes:
>>         v3: get rid of _get_gpio_direction() (Linus Walleij)
>>         v2: rework return value calculation
>
> Looks good to me, Kevin, Santosh?

Reviewed-by: Kevin Hilman <khilman@linaro.org>

> Part of me wants to list Javier as maintainer for this driver.

That's fine with me. 

Kevin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] gpio: omap: implement get_direction
@ 2014-04-24 22:25     ` Kevin Hilman
  0 siblings, 0 replies; 12+ messages in thread
From: Kevin Hilman @ 2014-04-24 22:25 UTC (permalink / raw)
  To: linux-arm-kernel

Linus Walleij <linus.walleij@linaro.org> writes:

> On Thu, Apr 24, 2014 at 8:57 AM,  <yegorslists@googlemail.com> wrote:
>
>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>
>> This patch implements gpio_chip's get_direction() routine, that
>> lets other drivers get particular GPIOs direction using
>> struct gpio_desc.
>>
>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>> Acked-by: Javier Martinez Canillas <javier@dowhile0.org>
>> ---
>> Changes:
>>         v3: get rid of _get_gpio_direction() (Linus Walleij)
>>         v2: rework return value calculation
>
> Looks good to me, Kevin, Santosh?

Reviewed-by: Kevin Hilman <khilman@linaro.org>

> Part of me wants to list Javier as maintainer for this driver.

That's fine with me. 

Kevin

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-04-24 22:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-24  6:57 [PATCH v3] gpio: omap: implement get_direction yegorslists
2014-04-24  6:57 ` yegorslists at googlemail.com
2014-04-24 13:13 ` Linus Walleij
2014-04-24 13:13   ` Linus Walleij
2014-04-24 13:29   ` Santosh Shilimkar
2014-04-24 13:29     ` Santosh Shilimkar
2014-04-24 16:42     ` Tony Lindgren
2014-04-24 16:42       ` Tony Lindgren
2014-04-24 22:25   ` Kevin Hilman
2014-04-24 22:25     ` Kevin Hilman
2014-04-24 13:35 ` Linus Walleij
2014-04-24 13:35   ` 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.