Skip to contentSkip to conversation

ARM: mach-shmobile: lager: support GPIO switche

PATCH New Simon Horman 5 participants 16 messages May 13, 2013 – May 14, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ARM: mach-shmobile: lager: support GPIO switche

This short series adds support for accessing the 4 pins of SW2 as gpio keys 1 - 4.

As the gpio-keys driver requires IRQ_TYPE_EDGE_BOTH support for this has been added to the R-Car GPIO driver.

Simon Horman (3):
gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH
ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH
ARM: mach-shmobile: lager: support GPIO switches

 arch/arm/mach-shmobile/board-lager.c    | 22 ++++++++++++++++++++++
 arch/arm/mach-shmobile/setup-r8a7790.c  |  1 +
 drivers/gpio/gpio-rcar.c                | 27 ++++++++++++++++++++++-----
 include/linux/platform_data/gpio-rcar.h |  1 +
 4 files changed, 46 insertions(+), 5 deletions(-)
Signature · 1 line
1.8.2.1
#1 lore raw

PATCH 1/3 gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH

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. This patch has been lightly exercised using that driver on that board.

---
 drivers/gpio/gpio-rcar.c                | 27 ++++++++++++++++++++++-----
 include/linux/platform_data/gpio-rcar.h |  1 +
 2 files changed, 23 insertions(+), 5 deletions(-)
drivers/gpio/gpio-rcar.c +22 -5
index 0f3d647..33d8f6a 100644
@@ -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 irq_data *d)
 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;
 
@@ -111,6 +113,11 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p,
 	/* Select "Interrupt Input Mode" in IOINTSEL */
 	gpio_rcar_modify_bit(p, IOINTSEL, hwirq, true);
 
+	if (p->config.has_both_edge_trigger && !level_trigger) {
+		/* Select one edge or both edges in BOTHEDGE */
+		gpio_rcar_modify_bit(p, IOINTSEL, hwirq, both);
+	}
+
 	/* Write INTCLR in case of edge trigger */
 	if (!level_trigger)
 		gpio_rcar_write(p, INTCLR, BIT(hwirq));
@@ -127,16 +134,26 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type)
 
 	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;
include/linux/platform_data/gpio-rcar.h +1 -0
index cc472f6..dfea5c6 100644
@@ -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))
Signature · 1 line
1.8.2.1
maintainer
#2 lore raw

PATCH 1/3 gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH

Quoted 8 lines · Simon Horman

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. This patch has been lightly exercised using that driver on that board.

Quoted 5 lines
---
 drivers/gpio/gpio-rcar.c                | 27 ++++++++++++++++++++++-----
 include/linux/platform_data/gpio-rcar.h |  1 +
 2 files changed, 23 insertions(+), 5 deletions(-)

Thanks for the patch, Simon!

Quoted 14 lines
drivers/gpio/gpio-rcar.c +1 -0
index 0f3d647..33d8f6a 100644
@@ -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)
 {
@@ -111,6 +113,11 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p,
        /* Select "Interrupt Input Mode" in IOINTSEL */

drivers/gpio/gpio-rcar.c static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p, · line 123

Quoted 10 lines
drivers/gpio/gpio-rcar.c +5 -0
        gpio_rcar_modify_bit(p, IOINTSEL, hwirq, true);
 
+       if (p->config.has_both_edge_trigger && !level_trigger) {
+               /* Select one edge or both edges in BOTHEDGE */
+               gpio_rcar_modify_bit(p, IOINTSEL, hwirq, both);
+       }
+
        /* Write INTCLR in case of edge trigger */
        if (!level_trigger)
                gpio_rcar_write(p, INTCLR, BIT(hwirq));

In your hunk above I suspect you want to setup the BOTHEDGE register instead of IOINTSEL.

Also, I wonder how BOTHEDGE should be set in the case of level trigger. Say that the user first selects edge trigger and then reconfigures to level, then you probably want to make sure the BOTHEDGE register is cleared.

So may want to do something like this (untested):

       if (p->config.has_both_edge_trigger) {
               /* Select one edge or both edges in BOTHEDGE */
               gpio_rcar_modify_bit(p, BOTHEDGE, hwirq, both);
       }

Also, please double check that the register access sequences in the documentation are still kept, please see "6.7.1 Setting Edge-Sensitive Interrupt Input Mode" in the H2 data sheet. It looks like you want to move this setting so it happens before IOINTSEL.

Thanks!

/ magnus

#3 lore raw

PATCH 1/3 gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH

Quoted 34 lines · Magnus Damm
Quoted 8 lines · Simon Horman

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. This patch has been lightly exercised using that driver on that board.

Quoted 5 lines
---
 drivers/gpio/gpio-rcar.c                | 27 ++++++++++++++++++++++-----
 include/linux/platform_data/gpio-rcar.h |  1 +
 2 files changed, 23 insertions(+), 5 deletions(-)

Thanks for the patch, Simon!

Quoted 16 lines
drivers/gpio/gpio-rcar.c +1 -0
index 0f3d647..33d8f6a 100644
@@ -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)
 {
@@ -111,6 +113,11 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p,
        /* Select "Interrupt Input Mode" in IOINTSEL */
        gpio_rcar_modify_bit(p, IOINTSEL, hwirq, true);
 
Quoted 11 lines

drivers/gpio/gpio-rcar.c static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p, · line 123

Quoted 8 lines
drivers/gpio/gpio-rcar.c +5 -0
+       if (p->config.has_both_edge_trigger && !level_trigger) {
+               /* Select one edge or both edges in BOTHEDGE */
+               gpio_rcar_modify_bit(p, IOINTSEL, hwirq, both);
+       }
+
        /* Write INTCLR in case of edge trigger */
        if (!level_trigger)
                gpio_rcar_write(p, INTCLR, BIT(hwirq));

In your hunk above I suspect you want to setup the BOTHEDGE register instead of IOINTSEL.

Thanks, I will fix that.

Quoted 11 lines

Also, I wonder how BOTHEDGE should be set in the case of level trigger. Say that the user first selects edge trigger and then reconfigures to level, then you probably want to make sure the BOTHEDGE register is cleared.

So may want to do something like this (untested):

       if (p->config.has_both_edge_trigger) {
               /* Select one edge or both edges in BOTHEDGE */
               gpio_rcar_modify_bit(p, BOTHEDGE, hwirq, both);
       }

Sure, if you think so.

Quoted 4 lines

Also, please double check that the register access sequences in the documentation are still kept, please see "6.7.1 Setting Edge-Sensitive Interrupt Input Mode" in the H2 data sheet. It looks like you want to move this setting so it happens before IOINTSEL.

Thanks, I will fix that.

#4 lore raw

PATCH 2/3 ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH

In reply to Simon Horman

"gpio-rcar: Support IRQ_TYPE_EDGE_BOTH" adds support to the R-Car GPIO driver for IRQ_TYPE_EDGE_BOTH. 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.

As the r8a7790 SoC hardware supports this feature enable it.

---

This patch has a build-time dependency on
"gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH".

---
 arch/arm/mach-shmobile/setup-r8a7790.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-shmobile/setup-r8a7790.c +1 -0
index eeef5f6..b461d93 100644
@@ -45,6 +45,7 @@ static struct gpio_rcar_config r8a7790_gpio##idx##_platform_data = {	\
 	.irq_base	= 0,						\
 	.number_of_pins	= 32,						\
 	.pctl_name	= "pfc-r8a7790",				\
+	.has_both_edge_trigger = 1,					\
 };									\
 
 R8A7790_GPIO(0);
Signature · 1 line
1.8.2.1
#5 lore raw

PATCH 2/3 ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH

Hi Simon,

Quoted 5 lines · On Monday 13 May 2013 17:53:52 Simon Horman wrote:

"gpio-rcar: Support IRQ_TYPE_EDGE_BOTH" adds support to the R-Car GPIO driver for IRQ_TYPE_EDGE_BOTH. 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.

What about moving this information to a platform ID table in the gpio-rcar driver ?

Quoted 17 lines

As the r8a7790 SoC hardware supports this feature enable it.

---

This patch has a build-time dependency on
"gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH".

---
 arch/arm/mach-shmobile/setup-r8a7790.c | 1 +
 1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/setup-r8a7790.c index eeef5f6..b461d93 100644

arch/arm/mach-shmobile/setup-r8a7790.c static struct gpio_rcar_config · line 45

Quoted 1 line
arch/arm/mach-shmobile/setup-r8a7790.c +0 -0
@@ -45,6 +45,7 @@ static struct gpio_rcar_config
 r8a7790_gpio##idx##_platform_data = {	\ .irq_base	= 0,						

\

Quoted 6 lines
arch/arm/mach-shmobile/setup-r8a7790.c +1 -0
 	.number_of_pins	= 32,						\
 	.pctl_name	= "pfc-r8a7790",				\
+	.has_both_edge_trigger = 1,					\
 };									\
 
 R8A7790_GPIO(0);
Signature · 3 lines
Regards,

Laurent Pinchart
#6 lore raw

PATCH 2/3 ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH

Quoted 11 lines · Laurent Pinchart

Hi Simon,

Quoted 5 lines · On Monday 13 May 2013 17:53:52 Simon Horman wrote:

"gpio-rcar: Support IRQ_TYPE_EDGE_BOTH" adds support to the R-Car GPIO driver for IRQ_TYPE_EDGE_BOTH. 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.

What about moving this information to a platform ID table in the gpio-rcar driver ?

Magnus, do you have an opinion on this?

Quoted 35 lines
Quoted 17 lines

As the r8a7790 SoC hardware supports this feature enable it.

---

This patch has a build-time dependency on
"gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH".

---
 arch/arm/mach-shmobile/setup-r8a7790.c | 1 +
 1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/setup-r8a7790.c index eeef5f6..b461d93 100644

arch/arm/mach-shmobile/setup-r8a7790.c static struct gpio_rcar_config · line 45

Quoted 1 line
arch/arm/mach-shmobile/setup-r8a7790.c +0 -0
@@ -45,6 +45,7 @@ static struct gpio_rcar_config
 r8a7790_gpio##idx##_platform_data = {	\ .irq_base	= 0,						

\

Quoted 6 lines
arch/arm/mach-shmobile/setup-r8a7790.c +1 -0
 	.number_of_pins	= 32,						\
 	.pctl_name	= "pfc-r8a7790",				\
+	.has_both_edge_trigger = 1,					\
 };									\
 
 R8A7790_GPIO(0);
Signature · 8 lines
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#7 lore raw

PATCH 2/3 ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH

Hi Simon, Laurent,

Quoted 10 lines · Simon Horman
Quoted 9 lines · Laurent Pinchart

Hi Simon,

Quoted 5 lines · On Monday 13 May 2013 17:53:52 Simon Horman wrote:

"gpio-rcar: Support IRQ_TYPE_EDGE_BOTH" adds support to the R-Car GPIO driver for IRQ_TYPE_EDGE_BOTH. 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.

Quoted 4 lines
Quoted 2 lines

What about moving this information to a platform ID table in the gpio-rcar driver ?

Magnus, do you have an opinion on this?

I don't mind so much as long as we:
a) can control things freely per driver instance and
b) don't have to update all drivers for every new SoC

The current approach allows for that, so as an example if we can have two slightly different GPIO hardware blocks then we can setup two GPIO controller driver instances where the configuration can be selected per-instance. Perhaps Laurent's proposal would allow for this too, I'm not sure.

On top of that I'd like to avoid doing per-SoC string matching in drivers. Those would force us to update every darn driver for every new SoC. It is better to try to use a per-hardware device version in the drivers and then configure each SoC to use the appropriate version.

Thanks,

/ magnus

#8 lore raw

PATCH 2/3 ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH

Hi Magnus,

Quoted 21 lines · On Tuesday 14 May 2013 15:01:01 Magnus Damm wrote:
Quoted 10 lines · Simon Horman
Quoted 9 lines · Laurent Pinchart

Hi Simon,

Quoted 5 lines · On Monday 13 May 2013 17:53:52 Simon Horman wrote:

"gpio-rcar: Support IRQ_TYPE_EDGE_BOTH" adds support to the R-Car GPIO driver for IRQ_TYPE_EDGE_BOTH. 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.

Quoted 4 lines
Quoted 2 lines

What about moving this information to a platform ID table in the gpio-rcar driver ?

Magnus, do you have an opinion on this?

I don't mind so much as long as we:
a) can control things freely per driver instance and
b) don't have to update all drivers for every new SoC

Quoted 5 lines

The current approach allows for that, so as an example if we can have two slightly different GPIO hardware blocks then we can setup two GPIO controller driver instances where the configuration can be selected per-instance. Perhaps Laurent's proposal would allow for this too, I'm not sure.

I agree that parameters related to the instantiation of a GPIO IP core in a SoC should come from DT. Parameters related to the IP core version (usch as the ability to trigger on both edges) should in my opinion be computed by the GPIO driver based on the IP core version number.

Quoted 4 lines

On top of that I'd like to avoid doing per-SoC string matching in drivers. Those would force us to update every darn driver for every new SoC. It is better to try to use a per-hardware device version in the drivers and then configure each SoC to use the appropriate version.

Agreed. Are the version numbers for the GPIO IP core available ?

Signature · 3 lines
Regards,

Laurent Pinchart
#9 lore raw

PATCH 3/3 ARM: mach-shmobile: lager: support GPIO switches

In reply to Simon Horman

The lager board has pins 1 - 4 of SW2 wired up to GPIO pins. This patch allows access to those pins as KEYS 1 - 4 using gpio-keys.

---

This patch has run time dependencies on
1. "gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH"
2. "ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH"

Without those dependencies satisfied the gpio-keys driver will fail to be initialise itself. The boot should be otherwise successful and the board otherwise functional.

---
 arch/arm/mach-shmobile/board-lager.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/arm/mach-shmobile/board-lager.c +22 -0
index 6a1ba38..4d1b42b 100644
@@ -18,7 +18,10 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
 #include <linux/interrupt.h>
+#include <linux/input.h>
 #include <linux/irqchip.h>
 #include <linux/kernel.h>
 #include <linux/leds.h>
@@ -52,6 +55,22 @@ static struct gpio_led_platform_data lager_leds_pdata = {
 	.num_leds	= ARRAY_SIZE(lager_leds),
 };
 
+/* GPIO KEY */
+#define GPIO_KEY(c, g, d, ...) \
+	{ .code = c, .gpio = g, .desc = d, .active_low = 1 }
+
+static struct gpio_keys_button gpio_buttons[] = {
+	GPIO_KEY(KEY_4,		RCAR_GP_PIN(1, 28),	"SW2-pin4"),
+	GPIO_KEY(KEY_3,		RCAR_GP_PIN(1, 26),	"SW2-pin3"),
+	GPIO_KEY(KEY_2,		RCAR_GP_PIN(1, 24),	"SW2-pin2"),
+	GPIO_KEY(KEY_1,		RCAR_GP_PIN(1, 14),	"SW2-pin1"),
+};
+
+static struct gpio_keys_platform_data lager_keys_pdata = {
+	.buttons	= gpio_buttons,
+	.nbuttons	= ARRAY_SIZE(gpio_buttons),
+};
+
 static const struct pinctrl_map lager_pinctrl_map[] = {
 	/* SCIF0 (CN19: DEBUG SERIAL0) */
 	PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",
@@ -73,6 +92,9 @@ static void __init lager_add_standard_devices(void)
 	platform_device_register_data(&platform_bus, "leds-gpio", -1,
 				      &lager_leds_pdata,
 				      sizeof(lager_leds_pdata));
+	platform_device_register_data(&platform_bus, "gpio-keys", -1,
+				      &lager_keys_pdata,
+				      sizeof(lager_keys_pdata));
 }
 
 static const char *lager_boards_compat_dt[] __initdata = {
Signature · 1 line
1.8.2.1
#10 lore raw

PATCH 3/3 ARM: mach-shmobile: lager: support GPIO switches

Quoted 5 lines · Simon Horman

The lager board has pins 1 - 4 of SW2 wired up to GPIO pins. This patch allows access to those pins as KEYS 1 - 4 using gpio-keys.

[...]

Quoted 4 lines
arch/arm/mach-shmobile/board-lager.c +0 -0
index 6a1ba38..4d1b42b 100644

[...]

Quoted 6 lines
arch/arm/mach-shmobile/board-lager.c +2 -0
@@ -52,6 +55,22 @@ static struct gpio_led_platform_data lager_leds_pdata = {
  	.num_leds	= ARRAY_SIZE(lager_leds),
  };
 
+/* GPIO KEY */
+#define GPIO_KEY(c, g, d, ...) \

arch/arm/mach-shmobile/board-lager.c static struct gpio_led_platform_data lager_leds_pdata = { · line 69

Quoted 10 lines
arch/arm/mach-shmobile/board-lager.c +10 -0
+	{ .code = c, .gpio = g, .desc = d, .active_low = 1 }
+
+static struct gpio_keys_button gpio_buttons[] = {
+	GPIO_KEY(KEY_4,		RCAR_GP_PIN(1, 28),	"SW2-pin4"),
+	GPIO_KEY(KEY_3,		RCAR_GP_PIN(1, 26),	"SW2-pin3"),
+	GPIO_KEY(KEY_2,		RCAR_GP_PIN(1, 24),	"SW2-pin2"),
+	GPIO_KEY(KEY_1,		RCAR_GP_PIN(1, 14),	"SW2-pin1"),
+};
+
+static struct gpio_keys_platform_data lager_keys_pdata = {

You forgot to annotate this with __initdata.

Quoted 8 lines
arch/arm/mach-shmobile/board-lager.c +4 -0
+	.buttons	= gpio_buttons,
+	.nbuttons	= ARRAY_SIZE(gpio_buttons),
+};
+
  static const struct pinctrl_map lager_pinctrl_map[] = {
  	/* SCIF0 (CN19: DEBUG SERIAL0) */
  	PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",

arch/arm/mach-shmobile/board-lager.c static void __init lager_add_standard_devices(void) · line 98

Quoted 7 lines
arch/arm/mach-shmobile/board-lager.c +3 -0
@@ -73,6 +92,9 @@ static void __init lager_add_standard_devices(void)
  	platform_device_register_data(&platform_bus, "leds-gpio", -1,
  				      &lager_leds_pdata,
  				      sizeof(lager_leds_pdata));
+	platform_device_register_data(&platform_bus, "gpio-keys", -1,
+				      &lager_keys_pdata,
+				      sizeof(lager_keys_pdata));
  }

WBR, Sergei

#11 lore raw

PATCH 3/3 ARM: mach-shmobile: lager: support GPIO switches

In reply to Simon Horman

Hi Simon,

Thank you for the patch.

Quoted 27 lines · On Monday 13 May 2013 17:53:53 Simon Horman wrote:

The lager board has pins 1 - 4 of SW2 wired up to GPIO pins. This patch allows access to those pins as KEYS 1 - 4 using gpio-keys.

---

This patch has run time dependencies on
1. "gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH"
2. "ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH"

Without those dependencies satisfied the gpio-keys driver will fail to be initialise itself. The boot should be otherwise successful and the board otherwise functional.

---
 arch/arm/mach-shmobile/board-lager.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/board-lager.c index 6a1ba38..4d1b42b 100644

arch/arm/mach-shmobile/board-lager.c +0 -0
@@ -18,7 +18,10 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 

USA */

arch/arm/mach-shmobile/board-lager.c line 24

Quoted 4 lines
arch/arm/mach-shmobile/board-lager.c +3 -0
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
 #include <linux/interrupt.h>
+#include <linux/input.h>

My dictionary lists input before interrupt :-)

Quoted 13 lines

#include <linux/irqchip.h>
#include <linux/kernel.h>
#include <linux/leds.h>

arch/arm/mach-shmobile/board-lager.c +6 -0
@@ -52,6 +55,22 @@ static struct gpio_led_platform_data lager_leds_pdata = {
 .num_leds	= ARRAY_SIZE(lager_leds),
 };
 
+/* GPIO KEY */
+#define GPIO_KEY(c, g, d, ...) \
+	{ .code = c, .gpio = g, .desc = d, .active_low = 1 }
+
+static struct gpio_keys_button gpio_buttons[] = {
+	GPIO_KEY(KEY_4,		RCAR_GP_PIN(1, 28),	"SW2-pin4"),

arch/arm/mach-shmobile/board-lager.c static struct gpio_led_platform_data lager_leds_pdata = { · line 73

Quoted 10 lines
arch/arm/mach-shmobile/board-lager.c +10 -0
+	GPIO_KEY(KEY_3,		RCAR_GP_PIN(1, 26),	"SW2-pin3"),
+	GPIO_KEY(KEY_2,		RCAR_GP_PIN(1, 24),	"SW2-pin2"),
+	GPIO_KEY(KEY_1,		RCAR_GP_PIN(1, 14),	"SW2-pin1"),
+};
+
+static struct gpio_keys_platform_data lager_keys_pdata = {
+	.buttons	= gpio_buttons,
+	.nbuttons	= ARRAY_SIZE(gpio_buttons),
+};
+

Could you please also update the lager dts file ?

Quoted 13 lines
arch/arm/mach-shmobile/board-lager.c +3 -0
 static const struct pinctrl_map lager_pinctrl_map[] = {
 	/* SCIF0 (CN19: DEBUG SERIAL0) */
 	PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",
@@ -73,6 +92,9 @@ static void __init lager_add_standard_devices(void)
 	platform_device_register_data(&platform_bus, "leds-gpio", -1,
 				      &lager_leds_pdata,
 				      sizeof(lager_leds_pdata));
+	platform_device_register_data(&platform_bus, "gpio-keys", -1,
+				      &lager_keys_pdata,
+				      sizeof(lager_keys_pdata));
 }
 
 static const char *lager_boards_compat_dt[] __initdata = {
Signature · 3 lines
Regards,

Laurent Pinchart
#12 lore raw

PATCH 3/3 ARM: mach-shmobile: lager: support GPIO switches

Quoted 32 lines · Laurent Pinchart

Hi Simon,

Thank you for the patch.

Quoted 27 lines · On Monday 13 May 2013 17:53:53 Simon Horman wrote:

The lager board has pins 1 - 4 of SW2 wired up to GPIO pins. This patch allows access to those pins as KEYS 1 - 4 using gpio-keys.

---

This patch has run time dependencies on
1. "gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH"
2. "ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH"

Without those dependencies satisfied the gpio-keys driver will fail to be initialise itself. The boot should be otherwise successful and the board otherwise functional.

---
 arch/arm/mach-shmobile/board-lager.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/board-lager.c index 6a1ba38..4d1b42b 100644

arch/arm/mach-shmobile/board-lager.c +0 -0
@@ -18,7 +18,10 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 

USA */

Quoted 6 lines

arch/arm/mach-shmobile/board-lager.c line 24

Quoted 4 lines
arch/arm/mach-shmobile/board-lager.c +3 -0
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
 #include <linux/interrupt.h>
+#include <linux/input.h>

My dictionary lists input before interrupt :-)

Thanks, I will fix that.

Quoted 17 lines
Quoted 17 lines

#include <linux/irqchip.h>
#include <linux/kernel.h>
#include <linux/leds.h>

arch/arm/mach-shmobile/board-lager.c +10 -0
@@ -52,6 +55,22 @@ static struct gpio_led_platform_data lager_leds_pdata = {
 .num_leds	= ARRAY_SIZE(lager_leds),
 };
 
+/* GPIO KEY */
+#define GPIO_KEY(c, g, d, ...) \
+	{ .code = c, .gpio = g, .desc = d, .active_low = 1 }
+
+static struct gpio_keys_button gpio_buttons[] = {
+	GPIO_KEY(KEY_4,		RCAR_GP_PIN(1, 28),	"SW2-pin4"),
+	GPIO_KEY(KEY_3,		RCAR_GP_PIN(1, 26),	"SW2-pin3"),
+	GPIO_KEY(KEY_2,		RCAR_GP_PIN(1, 24),	"SW2-pin2"),
+	GPIO_KEY(KEY_1,		RCAR_GP_PIN(1, 14),	"SW2-pin1"),
+};
Quoted 8 lines

arch/arm/mach-shmobile/board-lager.c static struct gpio_led_platform_data lager_leds_pdata = { · line 73

Quoted 6 lines
arch/arm/mach-shmobile/board-lager.c +6 -0
+
+static struct gpio_keys_platform_data lager_keys_pdata = {
+	.buttons	= gpio_buttons,
+	.nbuttons	= ARRAY_SIZE(gpio_buttons),
+};
+

Could you please also update the lager dts file ?

I wonder if in that case we can remove the C code above. And probably the C code for the GPIO leds too.

Magnus, could you clarify how you would like
C-code and DTS to look on the lager board?

Quoted 13 lines
Quoted 13 lines
arch/arm/mach-shmobile/board-lager.c +3 -0
 static const struct pinctrl_map lager_pinctrl_map[] = {
 	/* SCIF0 (CN19: DEBUG SERIAL0) */
 	PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",
@@ -73,6 +92,9 @@ static void __init lager_add_standard_devices(void)
 	platform_device_register_data(&platform_bus, "leds-gpio", -1,
 				      &lager_leds_pdata,
 				      sizeof(lager_leds_pdata));
+	platform_device_register_data(&platform_bus, "gpio-keys", -1,
+				      &lager_keys_pdata,
+				      sizeof(lager_keys_pdata));
 }
 
 static const char *lager_boards_compat_dt[] __initdata = {
maintainer
#13 lore raw

PATCH 3/3 ARM: mach-shmobile: lager: support GPIO switches

Hi Simon and Laurent,

Quoted 68 lines · Simon Horman
Quoted 32 lines · Laurent Pinchart

Hi Simon,

Thank you for the patch.

Quoted 27 lines · On Monday 13 May 2013 17:53:53 Simon Horman wrote:

The lager board has pins 1 - 4 of SW2 wired up to GPIO pins. This patch allows access to those pins as KEYS 1 - 4 using gpio-keys.

---

This patch has run time dependencies on
1. "gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH"
2. "ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH"

Without those dependencies satisfied the gpio-keys driver will fail to be initialise itself. The boot should be otherwise successful and the board otherwise functional.

---
 arch/arm/mach-shmobile/board-lager.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/board-lager.c index 6a1ba38..4d1b42b 100644

arch/arm/mach-shmobile/board-lager.c +0 -0
@@ -18,7 +18,10 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

USA */

Quoted 6 lines

arch/arm/mach-shmobile/board-lager.c line 24

Quoted 4 lines
arch/arm/mach-shmobile/board-lager.c +3 -0
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
 #include <linux/interrupt.h>
+#include <linux/input.h>

My dictionary lists input before interrupt :-)

Thanks, I will fix that.

Quoted 17 lines
Quoted 17 lines

#include <linux/irqchip.h>
#include <linux/kernel.h>
#include <linux/leds.h>

arch/arm/mach-shmobile/board-lager.c +10 -0
@@ -52,6 +55,22 @@ static struct gpio_led_platform_data lager_leds_pdata = {
 .num_leds   = ARRAY_SIZE(lager_leds),
 };
 
+/* GPIO KEY */
+#define GPIO_KEY(c, g, d, ...) \
+   { .code = c, .gpio = g, .desc = d, .active_low = 1 }
+
+static struct gpio_keys_button gpio_buttons[] = {
+   GPIO_KEY(KEY_4,         RCAR_GP_PIN(1, 28),     "SW2-pin4"),
+   GPIO_KEY(KEY_3,         RCAR_GP_PIN(1, 26),     "SW2-pin3"),
+   GPIO_KEY(KEY_2,         RCAR_GP_PIN(1, 24),     "SW2-pin2"),
+   GPIO_KEY(KEY_1,         RCAR_GP_PIN(1, 14),     "SW2-pin1"),
+};
Quoted 8 lines

arch/arm/mach-shmobile/board-lager.c static struct gpio_led_platform_data lager_leds_pdata = { · line 73

Quoted 6 lines
arch/arm/mach-shmobile/board-lager.c +6 -0
+
+static struct gpio_keys_platform_data lager_keys_pdata = {
+   .buttons        = gpio_buttons,
+   .nbuttons       = ARRAY_SIZE(gpio_buttons),
+};
+

Could you please also update the lager dts file ?

Quoted 5 lines

I wonder if in that case we can remove the C code above. And probably the C code for the GPIO leds too.

Magnus, could you clarify how you would like
C-code and DTS to look on the lager board?

I'd like C and DTS to coexist in parallel until we can ditch C fully. I believe there is a need for us to be able to back port the C code. For the future we want to use DTS.

To support DTS for Lager I think you should create a -reference DTS file for Lager where you put the DT version of your GPIO LED / switch code. At the time when we can configure the PFC via PINCTRL DT then I believe we should be able to replace most of the platform device code with DT versions. At that we should hopefully be able to ditch all the C board code, or maybe we need to keep some around until we have the common clocks going...

Thanks,

/ magnus

#14 lore raw

PATCH 3/3 ARM: mach-shmobile: lager: support GPIO switches

Quoted 81 lines · Magnus Damm

Hi Simon and Laurent,

Quoted 68 lines · Simon Horman
Quoted 32 lines · Laurent Pinchart

Hi Simon,

Thank you for the patch.

Quoted 27 lines · On Monday 13 May 2013 17:53:53 Simon Horman wrote:

The lager board has pins 1 - 4 of SW2 wired up to GPIO pins. This patch allows access to those pins as KEYS 1 - 4 using gpio-keys.

---

This patch has run time dependencies on
1. "gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH"
2. "ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH"

Without those dependencies satisfied the gpio-keys driver will fail to be initialise itself. The boot should be otherwise successful and the board otherwise functional.

---
 arch/arm/mach-shmobile/board-lager.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/board-lager.c index 6a1ba38..4d1b42b 100644

arch/arm/mach-shmobile/board-lager.c +0 -0
@@ -18,7 +18,10 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301

USA */

Quoted 6 lines

arch/arm/mach-shmobile/board-lager.c line 24

Quoted 4 lines
arch/arm/mach-shmobile/board-lager.c +3 -0
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
 #include <linux/interrupt.h>
+#include <linux/input.h>

My dictionary lists input before interrupt :-)

Thanks, I will fix that.

Quoted 17 lines
Quoted 17 lines

#include <linux/irqchip.h>
#include <linux/kernel.h>
#include <linux/leds.h>

arch/arm/mach-shmobile/board-lager.c +10 -0
@@ -52,6 +55,22 @@ static struct gpio_led_platform_data lager_leds_pdata = {
 .num_leds   = ARRAY_SIZE(lager_leds),
 };
 
+/* GPIO KEY */
+#define GPIO_KEY(c, g, d, ...) \
+   { .code = c, .gpio = g, .desc = d, .active_low = 1 }
+
+static struct gpio_keys_button gpio_buttons[] = {
+   GPIO_KEY(KEY_4,         RCAR_GP_PIN(1, 28),     "SW2-pin4"),
+   GPIO_KEY(KEY_3,         RCAR_GP_PIN(1, 26),     "SW2-pin3"),
+   GPIO_KEY(KEY_2,         RCAR_GP_PIN(1, 24),     "SW2-pin2"),
+   GPIO_KEY(KEY_1,         RCAR_GP_PIN(1, 14),     "SW2-pin1"),
+};
Quoted 8 lines

arch/arm/mach-shmobile/board-lager.c static struct gpio_led_platform_data lager_leds_pdata = { · line 73

Quoted 6 lines
arch/arm/mach-shmobile/board-lager.c +6 -0
+
+static struct gpio_keys_platform_data lager_keys_pdata = {
+   .buttons        = gpio_buttons,
+   .nbuttons       = ARRAY_SIZE(gpio_buttons),
+};
+

Could you please also update the lager dts file ?

Quoted 5 lines

I wonder if in that case we can remove the C code above. And probably the C code for the GPIO leds too.

Magnus, could you clarify how you would like
C-code and DTS to look on the lager board?

I'd like C and DTS to coexist in parallel until we can ditch C fully. I believe there is a need for us to be able to back port the C code. For the future we want to use DTS.

Quoted 7 lines

To support DTS for Lager I think you should create a -reference DTS file for Lager where you put the DT version of your GPIO LED / switch code. At the time when we can configure the PFC via PINCTRL DT then I believe we should be able to replace most of the platform device code with DT versions. At that we should hopefully be able to ditch all the C board code, or maybe we need to keep some around until we have the common clocks going...

Hi Magnus,

thanks for the clarification. That all sounds reasonable and I will see about making it so.

#15 lore raw

PATCH 3/3 ARM: mach-shmobile: lager: support GPIO switches

In reply to Magnus Damm

Hi Magnus,

Quoted 84 lines · On Tuesday 14 May 2013 15:09:08 Magnus Damm wrote:
Quoted 73 lines · Simon Horman
Quoted 33 lines · Laurent Pinchart
Quoted 32 lines · On Monday 13 May 2013 17:53:53 Simon Horman wrote:

The lager board has pins 1 - 4 of SW2 wired up to GPIO pins. This patch allows access to those pins as KEYS 1 - 4 using gpio-keys.

---

This patch has run time dependencies on
1. "gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH"
2. "ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH"

Without those dependencies satisfied the gpio-keys driver will fail to be initialise itself. The boot should be otherwise successful and the board otherwise functional.
---

 arch/arm/mach-shmobile/board-lager.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
(quoted diff) +0 -0

b/arch/arm/mach-shmobile/board-lager.c index 6a1ba38..4d1b42b 100644

arch/arm/mach-shmobile/board-lager.c +0 -0
@@ -18,7 +18,10 @@
 
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
  02110-1301
 

USA */

Quoted 8 lines

arch/arm/mach-shmobile/board-lager.c line 24

Quoted 6 lines
arch/arm/mach-shmobile/board-lager.c +3 -0
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
 
 #include <linux/interrupt.h>
 
+#include <linux/input.h>

My dictionary lists input before interrupt :-)

Thanks, I will fix that.

Quoted 19 lines
Quoted 19 lines

#include <linux/irqchip.h>
#include <linux/kernel.h>
#include <linux/leds.h>

arch/arm/mach-shmobile/board-lager.c +10 -0
@@ -52,6 +55,22 @@ static struct gpio_led_platform_data
 lager_leds_pdata = { .num_leds   = ARRAY_SIZE(lager_leds),
 
 };
 
+/* GPIO KEY */
+#define GPIO_KEY(c, g, d, ...) \
+   { .code = c, .gpio = g, .desc = d, .active_low = 1 }
+
+static struct gpio_keys_button gpio_buttons[] = {
+   GPIO_KEY(KEY_4,         RCAR_GP_PIN(1, 28),     "SW2-pin4"),
+   GPIO_KEY(KEY_3,         RCAR_GP_PIN(1, 26),     "SW2-pin3"),
+   GPIO_KEY(KEY_2,         RCAR_GP_PIN(1, 24),     "SW2-pin2"),
+   GPIO_KEY(KEY_1,         RCAR_GP_PIN(1, 14),     "SW2-pin1"),
+};
Quoted 8 lines

arch/arm/mach-shmobile/board-lager.c static struct gpio_led_platform_data lager_leds_pdata = { · line 73

Quoted 6 lines
arch/arm/mach-shmobile/board-lager.c +6 -0
+
+static struct gpio_keys_platform_data lager_keys_pdata = {
+   .buttons        = gpio_buttons,
+   .nbuttons       = ARRAY_SIZE(gpio_buttons),
+};
+

Could you please also update the lager dts file ?

Quoted 5 lines

I wonder if in that case we can remove the C code above. And probably the C code for the GPIO leds too.

Magnus, could you clarify how you would like
C-code and DTS to look on the lager board?

I'd like C and DTS to coexist in parallel until we can ditch C fully. I believe there is a need for us to be able to back port the C code. For the future we want to use DTS.

Quoted 5 lines

To support DTS for Lager I think you should create a -reference DTS file for Lager where you put the DT version of your GPIO LED / switch code. At the time when we can configure the PFC via PINCTRL DT then I believe we should be able to replace most of the platform device code with DT versions.

I've sent an RFC for gpio-rcar DT bindings, and I'll send one for sh-pfc in the next few days. DT support for GPIO and PINCTRL should then hopefully be available very soon.

Quoted 1 line

At that we should hopefully be able to ditch all the C board code,

Will we also ditch non-reference board files ?

Quoted 2 lines

or maybe we need to keep some around until we have the common clocks going...

What's the status of CCF support development in sh-mobile ?

Signature · 3 lines
Regards,

Laurent Pinchart