mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@linux.intel.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	peter.p.waskiewicz.jr@intel.com,
	andriy.shevchenko@linux.intel.com, danders@circuitco.com,
	vishal.l.verma@intel.com, dvhart@linux.intel.com
Cc: Matthew Garrett <matthew.garrett@nebula.com>,
	Grant Likely <grant.likely@linaro.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	platform-driver-x86@vger.kernel.org
Subject: [PATCH 6/8] minnowboard-keys: Bind MinnowBoard buttons to arrow keys
Date: Tue, 25 Jun 2013 18:53:26 -0700	[thread overview]
Message-ID: <1ded9714150de50fac7fb6ee82166fbcb5621f7d.1372211451.git.dvhart@linux.intel.com> (raw)
In-Reply-To: <cover.1372211451.git.dvhart@linux.intel.com>
In-Reply-To: <cover.1372211451.git.dvhart@linux.intel.com>

Configure the four buttons tied to the E6XX GPIO lines on the
MinnowBoard as keys using the gpio-keys-polled platform driver. From
left to right, bind them to LEFT, DOWN, UP, RIGHT, similar to the VI
directional keys.

This is separate from the minnowboard driver to provide users with the
flexibility to write kernel drivers for their own devices using these GPIO
lines.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Cc: Matthew Garrett <matthew.garrett@nebula.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Waskiewicz <peter.p.waskiewicz.jr@intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/Kconfig            |  14 +++++
 drivers/platform/x86/Makefile           |   1 +
 drivers/platform/x86/minnowboard-keys.c | 108 ++++++++++++++++++++++++++++++++
 3 files changed, 123 insertions(+)
 create mode 100644 drivers/platform/x86/minnowboard-keys.c

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index c8755cb..b9ff98c 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -50,6 +50,20 @@ config MINNOWBOARD_GPIO
 	  If you have a MinnowBoard, and want to experiment with the GPIO,
 	  say Y or M here.
 
+config MINNOWBOARD_KEYS
+	tristate "MinnowBoard GPIO Keys"
+	depends on MINNOWBOARD
+	depends on KEYBOARD_GPIO_POLLED
+	default n
+	---help---
+	  Configure the four buttons tied to the E6XX GPIO lines on the
+	  MinnowBoard as keys using the gpio-keys-polled platform driver. From
+	  left to right, bind them to LEFT, DOWN, UP, RIGHT, similar to the VI
+	  directional keys.
+
+	  If you have a MinnowBoard and want to use the buttons as arrow keys,
+	  say Y or M here.
+
 endif # MINNOWBOARD
 
 
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 4dac9f0..2f55903 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -4,6 +4,7 @@
 #
 obj-$(CONFIG_MINNOWBOARD)	+= minnowboard.o
 obj-$(CONFIG_MINNOWBOARD_GPIO)	+= minnowboard-gpio.o
+obj-$(CONFIG_MINNOWBOARD_KEYS)	+= minnowboard-keys.o
 obj-$(CONFIG_ASUS_LAPTOP)	+= asus-laptop.o
 obj-$(CONFIG_ASUS_WMI)		+= asus-wmi.o
 obj-$(CONFIG_ASUS_NB_WMI)	+= asus-nb-wmi.o
diff --git a/drivers/platform/x86/minnowboard-keys.c b/drivers/platform/x86/minnowboard-keys.c
new file mode 100644
index 0000000..de96df1
--- /dev/null
+++ b/drivers/platform/x86/minnowboard-keys.c
@@ -0,0 +1,108 @@
+/*
+ * MinnowBoard Linux platform driver
+ * Copyright (c) 2013, Intel Corporation.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Author: Darren Hart <dvhart@linux.intel.com>
+ */
+
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
+#include <linux/minnowboard.h>
+#include "minnowboard-gpio.h"
+
+/* VI-style direction keys seem like as good as anything */
+#define GPIO_BTN0_KEY KEY_LEFT
+#define GPIO_BTN1_KEY KEY_DOWN
+#define GPIO_BTN2_KEY KEY_UP
+#define GPIO_BTN3_KEY KEY_RIGHT
+
+/* Timing in milliseconds */
+#define GPIO_DEBOUNCE 1
+#define BUTTON_POLL_INTERVAL 300
+
+/* gpio-keys platform device structures */
+static struct gpio_keys_button minnow_buttons[] = {
+	{ .code = GPIO_BTN0_KEY, .gpio = GPIO_BTN0, .active_low = 1,
+	  .desc = "minnow_btn0", .type = EV_KEY, .wakeup = 0,
+	  .debounce_interval = GPIO_DEBOUNCE, .can_disable = true },
+	{ .code = GPIO_BTN1_KEY, .gpio = GPIO_BTN1, .active_low = 1,
+	  .desc = "minnow_btn1", .type = EV_KEY, .wakeup = 0,
+	  .debounce_interval = GPIO_DEBOUNCE, .can_disable = true },
+	{ .code = GPIO_BTN2_KEY, .gpio = GPIO_BTN2, .active_low = 1,
+	  .desc = "minnow_btn2", .type = EV_KEY, .wakeup = 0,
+	  .debounce_interval = GPIO_DEBOUNCE, .can_disable = true },
+	{ .code = GPIO_BTN3_KEY, .gpio = GPIO_BTN3, .active_low = 1,
+	  .desc = "minnow_btn3", .type = EV_KEY, .wakeup = 0,
+	  .debounce_interval = GPIO_DEBOUNCE, .can_disable = true },
+};
+
+static const struct gpio_keys_platform_data minnow_buttons_platform_data = {
+	.buttons = minnow_buttons,
+	.nbuttons = ARRAY_SIZE(minnow_buttons),
+	.poll_interval = BUTTON_POLL_INTERVAL,
+	.rep = 1,
+	.enable = NULL,
+	.disable = NULL,
+	.name = "minnow_buttons",
+};
+
+static struct platform_device minnow_gpio_buttons = {
+	.name = "gpio-keys-polled",
+	.id = -1,
+	.dev = {
+		.platform_data = (void *) &minnow_buttons_platform_data,
+	},
+};
+
+static int __init minnow_keys_module_init(void)
+{
+	int err;
+
+	err = -ENODEV;
+	if (!minnow_detect())
+		goto out;
+
+#ifdef MODULE
+#ifdef CONFIG_MINNOWBOARD_MODULE
+	if (request_module("minnowboard"))
+		goto out;
+#endif
+#endif
+
+	/* Export GPIO buttons to sysfs */
+	err = platform_device_register(&minnow_gpio_buttons);
+	if (err) {
+		pr_err("Failed to register gpio-keys-polled platform device\n");
+		goto out;
+	}
+
+ out:
+	return err;
+}
+
+static void __exit minnow_keys_module_exit(void)
+{
+	platform_device_unregister(&minnow_gpio_buttons);
+}
+
+module_init(minnow_keys_module_init);
+module_exit(minnow_keys_module_exit);
+
+MODULE_LICENSE("GPL");
-- 
1.8.1.2


  parent reply	other threads:[~2013-06-26  1:54 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-26  1:53 [PATCH 0/8] MinnowBoard support Darren Hart
2013-06-26  1:53 ` [PATCH 1/8] pch_gbe: Use PCH_GBE_PHY_REGS_LEN instead of 32 Darren Hart
2013-06-26  1:53 ` [PATCH 2/8] pch_uart: Add uart_clk selection for the MinnowBoard Darren Hart
2013-06-26  2:31   ` Greg Kroah-Hartman
2013-06-26  3:16     ` Darren Hart
2013-06-26  3:39       ` Greg Kroah-Hartman
2013-06-26  3:58         ` Darren Hart
2013-06-26  4:16           ` Greg Kroah-Hartman
2013-06-26  6:43           ` Jiri Slaby
2013-06-26  7:19             ` Darren Hart
2013-06-26  7:25               ` Jiri Slaby
2013-06-26 16:23                 ` Darren Hart
2013-06-26  1:53 ` [PATCH 3/8] gpio-sch: Add sch_gpio_resume_set_enable() Darren Hart
2013-06-26 21:24   ` Darren Hart
2013-06-26  1:53 ` [PATCH 4/8] minnowboard: Add base platform driver for the MinnowBoard Darren Hart
2013-06-26  4:00   ` Olof Johansson
2013-06-26  4:43     ` Darren Hart
2013-06-26  4:52       ` Matthew Garrett
2013-06-26  5:32         ` Darren Hart
2013-06-26  5:36           ` Matthew Garrett
2013-06-26  7:17             ` Darren Hart
2013-06-27  9:14   ` Linus Walleij
2013-06-28  5:43     ` Darren Hart
2013-07-04 16:26       ` Mark Brown
2013-07-20 17:37         ` Linus Walleij
2013-07-21 23:41           ` Mark Brown
2013-10-30 14:18             ` Darren Hart
2013-10-30 21:36               ` Mark Brown
2013-07-22  0:09         ` Grant Likely
2013-07-22  3:27           ` Darren Hart
2013-06-26  1:53 ` [PATCH 5/8] minnowboard-gpio: Export MinnowBoard expansion GPIO Darren Hart
2013-06-26  7:55   ` Andy Shevchenko
2013-06-26 16:21     ` Darren Hart
2013-06-27  8:18       ` Andy Shevchenko
2013-06-28  4:27         ` Darren Hart
2013-06-26  1:53 ` Darren Hart [this message]
2013-06-26  8:46   ` [PATCH 6/8] minnowboard-keys: Bind MinnowBoard buttons to arrow keys Andy Shevchenko
2013-06-26 16:28     ` Darren Hart
2013-06-26 17:16       ` Greg Kroah-Hartman
2013-06-26 17:23         ` Darren Hart
2013-06-26 19:57           ` Linus Walleij
2013-06-26 21:23             ` Darren Hart
2013-06-26  1:53 ` [PATCH 7/8] pci: Add CircuitCo VENDOR ID and MinnowBoard DEVICE ID Darren Hart
2013-06-26 16:32   ` Bjorn Helgaas
2013-06-26 17:15     ` Darren Hart
2013-06-26 19:37       ` Bjorn Helgaas
2013-06-26 21:16         ` Darren Hart
2013-06-26 21:30           ` Bjorn Helgaas
2013-06-26 21:30         ` H. Peter Anvin
2013-06-26 21:46           ` Bjorn Helgaas
2013-06-26 21:49             ` H. Peter Anvin
2013-06-26  1:53 ` [PATCH 8/8] pch_gbe: Add MinnowBoard support Darren Hart
2013-06-26  2:35   ` Bjorn Helgaas
2013-06-26  3:11     ` Darren Hart
2013-06-26  3:25     ` H. Peter Anvin
2013-06-28  5:37   ` Darren Hart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ded9714150de50fac7fb6ee82166fbcb5621f7d.1372211451.git.dvhart@linux.intel.com \
    --to=dvhart@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=danders@circuitco.com \
    --cc=grant.likely@linaro.org \
    --cc=hpa@zytor.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.garrett@nebula.com \
    --cc=peter.p.waskiewicz.jr@intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome