* [PATCH v2] gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH
@ 2013-05-24 9:47 Magnus Damm
2013-05-25 0:10 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Magnus Damm @ 2013-05-24 9:47 UTC (permalink / raw)
To: linux-arm-kernel
From: Simon Horman <horms+renesas@verge.net.au>
As hardware support for this feature is not universal for all SoCs a flag,
has_both_edge_trigger, has been added to the platform data of the driver to
allow this feature to be enabled.
The motivation for this is to allow use of the gpio-keys driver on the
lager board which is based on the r8a7790 SoC. The V2 of this patch has been
fully exercised using that driver on that board.
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Magnus Damm <damm@opensource.se>
---
Changes since V1:
- Modified code to always set BOTHEDGE register if available
- Set BOTHEDGE before IOINTSEL
- Successfully tested triggering on both edges with SW2 on Lager
drivers/gpio/gpio-rcar.c | 26 +++++++++++++++++++++-----
include/linux/platform_data/gpio-rcar.h | 1 +
2 files changed, 22 insertions(+), 5 deletions(-)
--- 0001/drivers/gpio/gpio-rcar.c
+++ work/drivers/gpio/gpio-rcar.c 2013-05-24 18:39:54.000000000 +0900
@@ -49,6 +49,7 @@ struct gpio_rcar_priv {
#define POSNEG 0x20
#define EDGLEVEL 0x24
#define FILONOFF 0x28
+#define BOTHEDGE 0x4c
static inline u32 gpio_rcar_read(struct gpio_rcar_priv *p, int offs)
{
@@ -91,7 +92,8 @@ static void gpio_rcar_irq_enable(struct
static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p,
unsigned int hwirq,
bool active_high_rising_edge,
- bool level_trigger)
+ bool level_trigger,
+ bool both)
{
unsigned long flags;
@@ -108,6 +110,10 @@ static void gpio_rcar_config_interrupt_i
/* Configure edge or level trigger in EDGLEVEL */
gpio_rcar_modify_bit(p, EDGLEVEL, hwirq, !level_trigger);
+ /* Select one edge or both edges in BOTHEDGE */
+ if (p->config.has_both_edge_trigger)
+ gpio_rcar_modify_bit(p, BOTHEDGE, hwirq, both);
+
/* Select "Interrupt Input Mode" in IOINTSEL */
gpio_rcar_modify_bit(p, IOINTSEL, hwirq, true);
@@ -127,16 +133,26 @@ static int gpio_rcar_irq_set_type(struct
switch (type & IRQ_TYPE_SENSE_MASK) {
case IRQ_TYPE_LEVEL_HIGH:
- gpio_rcar_config_interrupt_input_mode(p, hwirq, true, true);
+ gpio_rcar_config_interrupt_input_mode(p, hwirq, true, true,
+ false);
break;
case IRQ_TYPE_LEVEL_LOW:
- gpio_rcar_config_interrupt_input_mode(p, hwirq, false, true);
+ gpio_rcar_config_interrupt_input_mode(p, hwirq, false, true,
+ false);
break;
case IRQ_TYPE_EDGE_RISING:
- gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false);
+ gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false,
+ false);
break;
case IRQ_TYPE_EDGE_FALLING:
- gpio_rcar_config_interrupt_input_mode(p, hwirq, false, false);
+ gpio_rcar_config_interrupt_input_mode(p, hwirq, false, false,
+ false);
+ break;
+ case IRQ_TYPE_EDGE_BOTH:
+ if (!p->config.has_both_edge_trigger)
+ return -EINVAL;
+ gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false,
+ true);
break;
default:
return -EINVAL;
--- 0001/include/linux/platform_data/gpio-rcar.h
+++ work/include/linux/platform_data/gpio-rcar.h 2013-05-24 18:25:06.000000000 +0900
@@ -21,6 +21,7 @@ struct gpio_rcar_config {
unsigned int irq_base;
unsigned int number_of_pins;
const char *pctl_name;
+ unsigned has_both_edge_trigger:1;
};
#define RCAR_GP_PIN(bank, pin) (((bank) * 32) + (pin))
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v2] gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH
2013-05-24 9:47 [PATCH v2] gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH Magnus Damm
@ 2013-05-25 0:10 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2013-05-25 0:10 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, May 24, 2013 at 06:47:24PM +0900, Magnus Damm wrote:
> From: Simon Horman <horms+renesas@verge.net.au>
>
> As hardware support for this feature is not universal for all SoCs a flag,
> has_both_edge_trigger, has been added to the platform data of the driver to
> allow this feature to be enabled.
>
> The motivation for this is to allow use of the gpio-keys driver on the
> lager board which is based on the r8a7790 SoC. The V2 of this patch has been
> fully exercised using that driver on that board.
>
> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
> Signed-off-by: Magnus Damm <damm@opensource.se>
Thanks, I will queue this up for v3.11 in the gpio-rcar branch.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-25 0:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-24 9:47 [PATCH v2] gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH Magnus Damm
2013-05-25 0:10 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox