Skip to contentSkip to conversation

ARM: shmobile: r8a7791 and Koelsch GPIO/PFC support

PATCH New Magnus Damm 2 participants 19 messages Oct 8, 2013 – Oct 9, 2013

Subsystems (5)
lore
Share & tools
lore

Magnus Damm

author maintainer
#0 lore raw

cover ARM: shmobile: r8a7791 and Koelsch GPIO/PFC support

ARM: shmobile: r8a7791 and Koelsch GPIO/PFC support

[PATCH 01/08] ARM: shmobile: r8a7791 PFC device tree node [PATCH 02/08] ARM: shmobile: r8a7791 PFC platform device support [PATCH 03/08] ARM: shmobile: Select GPIO in case of the r8a7791 SoC [PATCH 04/08] ARM: shmobile: r8a7791 GPIO device tree node [PATCH 05/08] ARM: shmobile: r8a7791 GPIO platform device support [PATCH 06/08] ARM: shmobile: Enable PFC/GPIO on the Koelsch board [PATCH 07/08] ARM: shmobile: Add Koelsch LED6, LED7 and LED8 support [PATCH 08/08] ARM: shmobile: Add Koelsch SW2 support

This series includes PFC and GPIO support for the r8a7791 SoC and the Koelsch board. The GPIO portion can be tested through LEDs and GPIO switches on the Koelsch board. PFC tables will be submitted separately.

---

Written against renesas.git tag renesas-devel-20131004

 arch/arm/boot/dts/r8a7791.dtsi                |  102 +++++++++++++++++++++++++
 arch/arm/mach-shmobile/Kconfig                |    1 
 arch/arm/mach-shmobile/board-koelsch.c        |   50 ++++++++++++
 arch/arm/mach-shmobile/include/mach/r8a7791.h |    1 
 arch/arm/mach-shmobile/setup-r8a7791.c        |   53 ++++++++++++
 5 files changed, 207 insertions(+)
author maintainer
#1 lore raw

PATCH 1/8 ARM: shmobile: r8a7791 PFC device tree node

From: Magnus Damm <[email protected]>

Add a DT node for the r8a7791 PFC device.

---

 arch/arm/boot/dts/r8a7791.dtsi |    6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/r8a7791.dtsi +6 -0
@@ -71,4 +71,10 @@
 			      <0 16 4>,
 			      <0 17 4>;
 	};
+
+	pfc: pfc at e6060000 {
+		compatible = "renesas,pfc-r8a7791";
+		reg = <0 0xe6060000 0 0x250>;
+		#gpio-range-cells = <3>;
+	};
 };
author maintainer
#3 lore raw

PATCH 2/8 ARM: shmobile: r8a7791 PFC platform device support

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Add a platform device for the r8a7791 PFC device.

---

 arch/arm/mach-shmobile/include/mach/r8a7791.h |    1 +
 arch/arm/mach-shmobile/setup-r8a7791.c        |   13 +++++++++++++
 2 files changed, 14 insertions(+)
arch/arm/mach-shmobile/include/mach/r8a7791.h +1 -0
@@ -4,6 +4,7 @@
 void r8a7791_add_standard_devices(void);
 void r8a7791_add_dt_devices(void);
 void r8a7791_clock_init(void);
+void r8a7791_pinmux_init(void);
 void r8a7791_init_early(void);
 extern struct smp_operations r8a7791_smp_ops;
 
arch/arm/mach-shmobile/setup-r8a7791.c +13 -0
@@ -31,6 +31,19 @@
 #include <mach/rcar-gen2.h>
 #include <asm/mach/arch.h>
 
+static const struct resource pfc_resources[] __initconst = {
+	DEFINE_RES_MEM(0xe6060000, 0x250),
+};
+
+#define r8a7791_register_pfc()						\
+	platform_device_register_simple("pfc-r8a7791", -1, pfc_resources, \
+					ARRAY_SIZE(pfc_resources))
+
+void __init r8a7791_pinmux_init(void)
+{
+	r8a7791_register_pfc();
+}
+
 #define SCIF_COMMON(scif_type, baseaddr, irq)			\
 	.type		= scif_type,				\
 	.mapbase	= baseaddr,				\
author maintainer
#5 lore raw

PATCH 3/8 ARM: shmobile: Select GPIO in case of the r8a7791 SoC

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Make it possible to build GPIO on r8a7791.

---

 arch/arm/mach-shmobile/Kconfig |    1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-shmobile/Kconfig +1 -0
@@ -97,6 +97,7 @@ config ARCH_R8A7790
 
 config ARCH_R8A7791
 	bool "R-Car M2 (R8A77910)"
+	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARM_GIC
 	select CPU_V7
 	select SH_CLK_CPG
author maintainer
#7 lore raw

PATCH 4/8 ARM: shmobile: r8a7791 GPIO device tree node

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Add GPIO controllers to the r8a7791 DTSI file.

---

 arch/arm/boot/dts/r8a7791.dtsi |   96 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)
arch/arm/boot/dts/r8a7791.dtsi +96 -0
@@ -46,6 +46,102 @@
 		interrupts = <1 9 0xf04>;
 	};
 
+	gpio0: gpio at ffc40000 {
+		compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
+		reg = <0 0xffc40000 0 0x50>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 4 0x4>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		gpio-ranges = <&pfc 0 0 32>;
+		#interrupt-cells = <2>;
+		interrupt-controller;
+	};
+
+	gpio1: gpio at ffc41000 {
+		compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
+		reg = <0 0xffc41000 0 0x50>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 5 0x4>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		gpio-ranges = <&pfc 0 32 32>;
+		#interrupt-cells = <2>;
+		interrupt-controller;
+	};
+
+	gpio2: gpio at ffc42000 {
+		compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
+		reg = <0 0xffc42000 0 0x50>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 6 0x4>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		gpio-ranges = <&pfc 0 64 32>;
+		#interrupt-cells = <2>;
+		interrupt-controller;
+	};
+
+	gpio3: gpio at ffc43000 {
+		compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
+		reg = <0 0xffc43000 0 0x50>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 7 0x4>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		gpio-ranges = <&pfc 0 96 32>;
+		#interrupt-cells = <2>;
+		interrupt-controller;
+	};
+
+	gpio4: gpio at ffc44000 {
+		compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
+		reg = <0 0xffc44000 0 0x50>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 8 0x4>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		gpio-ranges = <&pfc 0 128 32>;
+		#interrupt-cells = <2>;
+		interrupt-controller;
+	};
+
+	gpio5: gpio at ffc45000 {
+		compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
+		reg = <0 0xffc45000 0 0x50>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 9 0x4>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		gpio-ranges = <&pfc 0 160 32>;
+		#interrupt-cells = <2>;
+		interrupt-controller;
+	};
+
+	gpio6: gpio at ffc45400 {
+		compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
+		reg = <0 0xffc45400 0 0x50>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 10 0x4>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		gpio-ranges = <&pfc 0 192 32>;
+		#interrupt-cells = <2>;
+		interrupt-controller;
+	};
+
+	gpio7: gpio at ffc45800 {
+		compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
+		reg = <0 0xffc45800 0 0x50>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 11 0x4>;
+		#gpio-cells = <2>;
+		gpio-controller;
+		gpio-ranges = <&pfc 0 224 26>;
+		#interrupt-cells = <2>;
+		interrupt-controller;
+	};
+
 	timer {
 		compatible = "arm,armv7-timer";
 		interrupts = <1 13 0xf08>,
author maintainer
#9 lore raw

PATCH 5/8 ARM: shmobile: r8a7791 GPIO platform device support

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Add GPIO controller platform devices for the r8a7791 SoC.

---

 arch/arm/mach-shmobile/setup-r8a7791.c |   40 ++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
arch/arm/mach-shmobile/setup-r8a7791.c +40 -0
@@ -22,6 +22,7 @@
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/of_platform.h>
+#include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_data/irq-renesas-irqc.h>
 #include <linux/serial_sci.h>
 #include <linux/sh_timer.h>
@@ -39,9 +40,48 @@ static const struct resource pfc_resourc
 	platform_device_register_simple("pfc-r8a7791", -1, pfc_resources, \
 					ARRAY_SIZE(pfc_resources))
 
+#define R8A7791_GPIO(idx, base, nr)					\
+static const struct resource r8a7791_gpio##idx##_resources[] __initconst = { \
+	DEFINE_RES_MEM((base), 0x50),					\
+	DEFINE_RES_IRQ(gic_spi(4 + (idx))),				\
+};									\
+									\
+static const struct gpio_rcar_config					\
+r8a7791_gpio##idx##_platform_data __initconst = {			\
+	.gpio_base	= 32 * (idx),					\
+	.irq_base	= 0,						\
+	.number_of_pins	= (nr),						\
+	.pctl_name	= "pfc-r8a7791",				\
+	.has_both_edge_trigger = 1,					\
+};									\
+
+R8A7791_GPIO(0, 0xe6050000, 32);
+R8A7791_GPIO(1, 0xe6051000, 32);
+R8A7791_GPIO(2, 0xe6052000, 32);
+R8A7791_GPIO(3, 0xe6053000, 32);
+R8A7791_GPIO(4, 0xe6054000, 32);
+R8A7791_GPIO(5, 0xe6055000, 32);
+R8A7791_GPIO(6, 0xe6055400, 32);
+R8A7791_GPIO(7, 0xe6055800, 26);
+
+#define r8a7791_register_gpio(idx)					\
+	platform_device_register_resndata(&platform_bus, "gpio_rcar", idx, \
+		r8a7791_gpio##idx##_resources,				\
+		ARRAY_SIZE(r8a7791_gpio##idx##_resources),		\
+		&r8a7791_gpio##idx##_platform_data,			\
+		sizeof(r8a7791_gpio##idx##_platform_data))
+
 void __init r8a7791_pinmux_init(void)
 {
 	r8a7791_register_pfc();
+	r8a7791_register_gpio(0);
+	r8a7791_register_gpio(1);
+	r8a7791_register_gpio(2);
+	r8a7791_register_gpio(3);
+	r8a7791_register_gpio(4);
+	r8a7791_register_gpio(5);
+	r8a7791_register_gpio(6);
+	r8a7791_register_gpio(7);
 }
 
 #define SCIF_COMMON(scif_type, baseaddr, irq)			\
author maintainer
#12 lore raw

PATCH 6/8 ARM: shmobile: Enable PFC/GPIO on the Koelsch board

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Enable r8a7791 PFC and GPIO on the Koelsch board.

---

 arch/arm/mach-shmobile/board-koelsch.c |    1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-shmobile/board-koelsch.c +1 -0
@@ -30,6 +30,7 @@
 static void __init koelsch_add_standard_devices(void)
 {
 	r8a7791_clock_init();
+	r8a7791_pinmux_init();
 	r8a7791_add_standard_devices();
 }
 
author maintainer
#14 lore raw

PATCH 7/8 ARM: shmobile: Add Koelsch LED6, LED7 and LED8 support

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Enable Koelsch LEDs for GPIO output testing purpose.

---

 arch/arm/mach-shmobile/board-koelsch.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
arch/arm/mach-shmobile/board-koelsch.c +27 -0
@@ -20,6 +20,8 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/leds.h>
+#include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_device.h>
 #include <mach/common.h>
 #include <mach/r8a7791.h>
@@ -27,11 +29,36 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
+/* LEDS */
+static struct gpio_led koelsch_leds[] = {
+	{
+		.name		= "led8",
+		.gpio		= RCAR_GP_PIN(2, 21),
+		.default_state	= LEDS_GPIO_DEFSTATE_ON,
+	}, {
+		.name		= "led7",
+		.gpio		= RCAR_GP_PIN(2, 20),
+		.default_state	= LEDS_GPIO_DEFSTATE_ON,
+	}, {
+		.name		= "led6",
+		.gpio		= RCAR_GP_PIN(2, 19),
+		.default_state	= LEDS_GPIO_DEFSTATE_ON,
+	},
+};
+
+static const struct gpio_led_platform_data koelsch_leds_pdata __initconst = {
+	.leds		= koelsch_leds,
+	.num_leds	= ARRAY_SIZE(koelsch_leds),
+};
+
 static void __init koelsch_add_standard_devices(void)
 {
 	r8a7791_clock_init();
 	r8a7791_pinmux_init();
 	r8a7791_add_standard_devices();
+	platform_device_register_data(&platform_bus, "leds-gpio", -1,
+				      &koelsch_leds_pdata,
+				      sizeof(koelsch_leds_pdata));
 }
 
 static const char * const koelsch_boards_compat_dt[] __initconst = {
#15 lore raw

PATCH 7/8 ARM: shmobile: Add Koelsch LED6, LED7 and LED8 support

Quoted 5 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Enable Koelsch LEDs for GPIO output testing purpose.

Hi Magnus,

this patch does not seem to apply on top of renesas-devel-20131004. Could you please rebase it and the following on top of renesas-devel-20131004 or the latest devel tag?

Thanks

Quoted 58 lines

---

 arch/arm/mach-shmobile/board-koelsch.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
arch/arm/mach-shmobile/board-koelsch.c +27 -1
@@ -20,6 +20,8 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/leds.h>
+#include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_device.h>
 #include <mach/common.h>
 #include <mach/r8a7791.h>
@@ -27,11 +29,36 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
+/* LEDS */
+static struct gpio_led koelsch_leds[] = {
+	{
+		.name		= "led8",
+		.gpio		= RCAR_GP_PIN(2, 21),
+		.default_state	= LEDS_GPIO_DEFSTATE_ON,
+	}, {
+		.name		= "led7",
+		.gpio		= RCAR_GP_PIN(2, 20),
+		.default_state	= LEDS_GPIO_DEFSTATE_ON,
+	}, {
+		.name		= "led6",
+		.gpio		= RCAR_GP_PIN(2, 19),
+		.default_state	= LEDS_GPIO_DEFSTATE_ON,
+	},
+};
+
+static const struct gpio_led_platform_data koelsch_leds_pdata __initconst = {
+	.leds		= koelsch_leds,
+	.num_leds	= ARRAY_SIZE(koelsch_leds),
+};
+
 static void __init koelsch_add_standard_devices(void)
 {
 	r8a7791_clock_init();
 	r8a7791_pinmux_init();
 	r8a7791_add_standard_devices();
+	platform_device_register_data(&platform_bus, "leds-gpio", -1,
+				      &koelsch_leds_pdata,
+				      sizeof(koelsch_leds_pdata));
 }
 
 static const char * const koelsch_boards_compat_dt[] __initconst = {
--

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

#16 lore raw

PATCH 7/8 ARM: shmobile: Add Koelsch LED6, LED7 and LED8 support

Quoted 5 lines · Simon Horman
Quoted 4 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Enable Koelsch LEDs for GPIO output testing purpose.

Quoted 7 lines
Quoted 1 line

Hi Magnus,

this patch does not seem to apply on top of renesas-devel-20131004. Could you please rebase it and the following on top of renesas-devel-20131004 or the latest devel tag?

Scratch that, I see that my problem was that I was missing the previous patch.

I have now queued up this patch.

author maintainer
#17 lore raw

PATCH 8/8 ARM: shmobile: Add Koelsch SW2 support

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Enable Koelsch GPIO switch for GPIO input and IRQ testing purpose.

---

 arch/arm/mach-shmobile/board-koelsch.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/arm/mach-shmobile/board-koelsch.c +22 -0
@@ -19,6 +19,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
 #include <linux/kernel.h>
 #include <linux/leds.h>
 #include <linux/platform_data/gpio-rcar.h>
@@ -51,6 +54,22 @@ static const struct gpio_led_platform_da
 	.num_leds	= ARRAY_SIZE(koelsch_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(5, 3),	"SW2-pin4"),
+	GPIO_KEY(KEY_3,		RCAR_GP_PIN(5, 2),	"SW2-pin3"),
+	GPIO_KEY(KEY_2,		RCAR_GP_PIN(5, 1),	"SW2-pin2"),
+	GPIO_KEY(KEY_1,		RCAR_GP_PIN(5, 0),	"SW2-pin1"),
+};
+
+static const struct gpio_keys_platform_data koelsch_keys_pdata __initconst = {
+	.buttons	= gpio_buttons,
+	.nbuttons	= ARRAY_SIZE(gpio_buttons),
+};
+
 static void __init koelsch_add_standard_devices(void)
 {
 	r8a7791_clock_init();
@@ -59,6 +78,9 @@ static void __init koelsch_add_standard_
 	platform_device_register_data(&platform_bus, "leds-gpio", -1,
 				      &koelsch_leds_pdata,
 				      sizeof(koelsch_leds_pdata));
+	platform_device_register_data(&platform_bus, "gpio-keys", -1,
+				      &koelsch_keys_pdata,
+				      sizeof(koelsch_keys_pdata));
 }
 
 static const char * const koelsch_boards_compat_dt[] __initconst = {
#18 lore raw

PATCH 8/8 ARM: shmobile: Add Koelsch SW2 support

Quoted 3 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Enable Koelsch GPIO switch for GPIO input and IRQ testing purpose.

Thanks, I have queued this up.