[PATCH 3/3] RFC: ARM: simone: Hacked in keys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This serves as an illustration of how to use the gpio-keys
in boardfiles with just a machine GPIO descriptor table.

It is a hack for the joystick connector on the entirely
boardfile-based SIM.ONE. It will probably not be applied.

Cc: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
Cc: Andy Shevchenko <andy@xxxxxxxxxxxxx>
Cc: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Cc: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
 arch/arm/mach-ep93xx/simone.c | 50 +++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/mach-ep93xx/simone.c b/arch/arm/mach-ep93xx/simone.c
index 41aa57581356..a3c3020da850 100644
--- a/arch/arm/mach-ep93xx/simone.c
+++ b/arch/arm/mach-ep93xx/simone.c
@@ -24,7 +24,10 @@
 #include <linux/spi/mmc_spi.h>
 #include <linux/platform_data/video-ep93xx.h>
 #include <linux/platform_data/spi-ep93xx.h>
+#include <linux/gpio/machine.h>
 #include <linux/gpio.h>
+#include <linux/input.h>
+#include <linux/gpio_keys.h>
 
 #include <mach/hardware.h>
 #include <mach/gpio-ep93xx.h>
@@ -34,6 +37,51 @@
 
 #include "soc.h"
 
+static struct gpio_keys_button simone_buttons[] = {
+	{
+		.code = KEY_ENTER,
+		.type = EV_KEY,
+		.active_low = 1,
+		.desc = "enter",
+	},
+	{
+		.code = KEY_UP,
+		.type = EV_KEY,
+		.active_low = 1,
+		.desc = "up",
+	},
+	{
+		.code = KEY_LEFT,
+		.type = EV_KEY,
+		.active_low = 1,
+		.desc = "left",
+	},
+};
+
+static struct gpio_keys_platform_data simone_keys_pdata = {
+	.buttons = simone_buttons,
+	.nbuttons = ARRAY_SIZE(simone_buttons),
+	.rep = 0,
+};
+
+static struct gpiod_lookup_table simone_keys_gpiod_table = {
+	.dev_id = "gpio-keys",
+	.table = {
+		/* Use local offsets on gpiochip/port "B" */
+		GPIO_LOOKUP_IDX("B", 0, "gpios", 0, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("B", 1, "gpios", 1, GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP_IDX("B", 2, "gpios", 2, GPIO_ACTIVE_LOW),
+	},
+};
+
+static struct platform_device simone_keys_device = {
+	.name = "gpio-keys",
+	.id = -1,
+	.dev = {
+		.platform_data = &simone_keys_pdata,
+	},
+};
+
 static struct ep93xx_eth_data __initdata simone_eth_data = {
 	.phy_id		= 1,
 };
@@ -107,6 +155,8 @@ static void __init simone_init_machine(void)
 			    ARRAY_SIZE(simone_i2c_board_info));
 	ep93xx_register_spi(&simone_spi_info, simone_spi_devices,
 			    ARRAY_SIZE(simone_spi_devices));
+	gpiod_add_lookup_table(&simone_keys_gpiod_table);
+	platform_device_register(&simone_keys_device);
 	simone_register_audio();
 }
 
-- 
2.17.1




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux