[linux-yocto] [PATCH 2/4] minnow-io: Add feature for MinnowBoard GPIO keys and LEDs

Darren Hart dvhart at linux.intel.com
Mon Nov 11 15:25:09 PST 2013


The MinnowBoard GPIO keys and leds drivers are not upstreamable in their
current form, but the ACPI device description support for the correct
implementation is not yet available. Include these "boardfiles" as a
feature until such time as the proper ACPI description becomes
available.

Signed-off-by: Darren Hart <dvhart at linux.intel.com>
---
 ...1-gpio-sch-Add-sch_gpio_resume_set_enable.patch |   71 ++++
 ...-Add-base-platform-driver-for-the-MinnowB.patch |  369 ++++++++++++++++++++
 ...rd-gpio-Export-MinnowBoard-expansion-GPIO.patch |  182 ++++++++++
 ...-keys-Bind-MinnowBoard-buttons-to-arrow-k.patch |  172 +++++++++
 .../kernel-cache/features/minnow-io/minnow-io.cfg  |   20 ++
 .../kernel-cache/features/minnow-io/minnow-io.scc  |    7 +
 6 files changed, 821 insertions(+)
 create mode 100644 meta/cfg/kernel-cache/features/minnow-io/0001-gpio-sch-Add-sch_gpio_resume_set_enable.patch
 create mode 100644 meta/cfg/kernel-cache/features/minnow-io/0002-minnowboard-Add-base-platform-driver-for-the-MinnowB.patch
 create mode 100644 meta/cfg/kernel-cache/features/minnow-io/0003-minnowboard-gpio-Export-MinnowBoard-expansion-GPIO.patch
 create mode 100644 meta/cfg/kernel-cache/features/minnow-io/0004-minnowboard-keys-Bind-MinnowBoard-buttons-to-arrow-k.patch
 create mode 100644 meta/cfg/kernel-cache/features/minnow-io/minnow-io.cfg
 create mode 100644 meta/cfg/kernel-cache/features/minnow-io/minnow-io.scc

diff --git a/meta/cfg/kernel-cache/features/minnow-io/0001-gpio-sch-Add-sch_gpio_resume_set_enable.patch b/meta/cfg/kernel-cache/features/minnow-io/0001-gpio-sch-Add-sch_gpio_resume_set_enable.patch
new file mode 100644
index 0000000..c896ffd
--- /dev/null
+++ b/meta/cfg/kernel-cache/features/minnow-io/0001-gpio-sch-Add-sch_gpio_resume_set_enable.patch
@@ -0,0 +1,71 @@
+From c018204ed1246c0c2129cc2d48f444d89e926034 Mon Sep 17 00:00:00 2001
+Message-Id: <c018204ed1246c0c2129cc2d48f444d89e926034.1383605156.git.darren at dvhart.com>
+From: Darren Hart <dvhart at linux.intel.com>
+Date: Sat, 18 May 2013 14:45:54 -0700
+Subject: [PATCH 1/4] gpio-sch: Add sch_gpio_resume_set_enable()
+
+Allow for enabling and disabling of the resume well GPIOs. The E6xx Atom
+CPUs multiplex the resume GPIO 2:0 lines with LVDS and individual board
+drivers need to be able to enable or disable the lines appropriately.
+
+Unfortunately, the information regarding if the pins are being used for
+LVDS or GPIO is board specific and may not be available to the gpio-sch
+driver at probe time.
+
+Signed-off-by: Darren Hart <dvhart at linux.intel.com>
+---
+ drivers/gpio/gpio-sch.c  | 24 ++++++++++++++++++++++++
+ include/linux/gpio-sch.h |  6 ++++++
+ 2 files changed, 30 insertions(+)
+ create mode 100644 include/linux/gpio-sch.h
+
+diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
+index 5af6571..90785f8 100644
+--- a/drivers/gpio/gpio-sch.c
++++ b/drivers/gpio/gpio-sch.c
+@@ -41,6 +41,30 @@ static DEFINE_SPINLOCK(gpio_lock);
+ 
+ static unsigned short gpio_ba;
+ 
++void sch_gpio_resume_set_enable(unsigned gpio_num, int val)
++{
++	u8 curr_en;
++	unsigned short offset, bit;
++
++	spin_lock(&gpio_lock);
++
++	offset = RGEN + gpio_num / 8;
++	bit = gpio_num % 8;
++
++	curr_en = inb(gpio_ba + offset);
++
++	if (val) {
++		if (!(curr_en & (1 << bit)))
++			outb(curr_en | (1 << bit), gpio_ba + offset);
++	} else {
++		if ((curr_en & (1 << bit)))
++			outb(curr_en & ~(1 << bit), gpio_ba + offset);
++	}
++
++	spin_unlock(&gpio_lock);
++}
++EXPORT_SYMBOL_GPL(sch_gpio_resume_set_enable);
++
+ static int sch_gpio_core_direction_in(struct gpio_chip *gc, unsigned  gpio_num)
+ {
+ 	u8 curr_dirs;
+diff --git a/include/linux/gpio-sch.h b/include/linux/gpio-sch.h
+new file mode 100644
+index 0000000..79e042f
+--- /dev/null
++++ b/include/linux/gpio-sch.h
+@@ -0,0 +1,6 @@
++#ifndef _LINUX_GPIO_SCH_
++#define _LINUX_GPIO_SCH_
++
++void sch_gpio_resume_set_enable(unsigned gpio_num, int val);
++
++#endif /* _LINUX_GPIO_SCH_ */
+-- 
+1.8.3.1
+
diff --git a/meta/cfg/kernel-cache/features/minnow-io/0002-minnowboard-Add-base-platform-driver-for-the-MinnowB.patch b/meta/cfg/kernel-cache/features/minnow-io/0002-minnowboard-Add-base-platform-driver-for-the-MinnowB.patch
new file mode 100644
index 0000000..9be6cec
--- /dev/null
+++ b/meta/cfg/kernel-cache/features/minnow-io/0002-minnowboard-Add-base-platform-driver-for-the-MinnowB.patch
@@ -0,0 +1,369 @@
+From de5425c806cb4ca81666097fe70ee39b8a53877a Mon Sep 17 00:00:00 2001
+Message-Id: <de5425c806cb4ca81666097fe70ee39b8a53877a.1383605156.git.darren at dvhart.com>
+In-Reply-To: <c018204ed1246c0c2129cc2d48f444d89e926034.1383605156.git.darren at dvhart.com>
+References: <c018204ed1246c0c2129cc2d48f444d89e926034.1383605156.git.darren at dvhart.com>
+From: Darren Hart <dvhart at linux.intel.com>
+Date: Sat, 18 May 2013 14:45:57 -0700
+Subject: [PATCH 2/4] minnowboard: Add base platform driver for the MinnowBoard
+
+The MinnowBoard (http://www.minnowboard.org) is an Intel Atom (E6xx) plus EG20T
+PCH development board. It uses a few GPIO lines for specific purposes and
+exposes the rest to the user.
+
+Request the dedicated GPIO lines:
+	HWID
+	LVDS_DETECT
+	LED0
+	LED1
+
+Setup platform drivers for the MinnowBoard LEDs using the leds-gpio
+driver. Setup led0 and led1 with heartbeat and mmc0 default triggers
+respectively.
+
+GPIO lines SUS[0-4] are dual purpose, either for LVDS signaling or as
+user GPIO. Determine which via the LVDS_DETECT signal and enable or
+disable them accordingly.
+
+Provide a minimal public interface:
+	minnow_detect()
+	minnow_lvds_detect()
+	minnow_hwid()
+
+Signed-off-by: Darren Hart <dvhart at linux.intel.com>
+---
+ drivers/platform/x86/Kconfig            |  20 ++++
+ drivers/platform/x86/Makefile           |   1 +
+ drivers/platform/x86/minnowboard-gpio.h |  58 +++++++++++
+ drivers/platform/x86/minnowboard.c      | 167 ++++++++++++++++++++++++++++++++
+ include/linux/minnowboard.h             |  37 +++++++
+ 5 files changed, 283 insertions(+)
+ create mode 100644 drivers/platform/x86/minnowboard-gpio.h
+ create mode 100644 drivers/platform/x86/minnowboard.c
+ create mode 100644 include/linux/minnowboard.h
+
+diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
+index 8577261..154dbf6 100644
+--- a/drivers/platform/x86/Kconfig
++++ b/drivers/platform/x86/Kconfig
+@@ -15,6 +15,26 @@ menuconfig X86_PLATFORM_DEVICES
+ 
+ if X86_PLATFORM_DEVICES
+ 
++config MINNOWBOARD
++	tristate "MinnowBoard GPIO and LVDS support"
++	depends on LPC_SCH
++	depends on GPIO_SCH
++	depends on GPIO_PCH
++	depends on LEDS_GPIO
++	default n
++	---help---
++	  This driver configures the MinnowBoard fixed functionality GPIO lines.
++
++	  It ensures that the E6XX SUS GPIOs muxed with LVDS signals (SUS[0:2])
++	  are disabled if the LVDS_DETECT signal is asserted.
++
++	  If LED_TRIGGER* are enabled, LED0 will use the heartbeat trigger and
++	  LED1 will use the mmc0 trigger.
++
++	  The Minnow Hardware ID is read from the GPIO HWID lines and logged.
++
++	  If you have a MinnowBoard, say Y or M here.
++
+ config ACER_WMI
+ 	tristate "Acer WMI Laptop Extras"
+ 	depends on ACPI
+diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
+index ef0ec74..45ede1c 100644
+--- a/drivers/platform/x86/Makefile
++++ b/drivers/platform/x86/Makefile
+@@ -2,6 +2,7 @@
+ # Makefile for linux/drivers/platform/x86
+ # x86 Platform-Specific Drivers
+ #
++obj-$(CONFIG_MINNOWBOARD)	+= minnowboard.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-gpio.h b/drivers/platform/x86/minnowboard-gpio.h
+new file mode 100644
+index 0000000..6c6f298
+--- /dev/null
++++ b/drivers/platform/x86/minnowboard-gpio.h
+@@ -0,0 +1,58 @@
++/*
++ * 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 at linux.intel.com>
++ */
++
++/* MinnowBoard GPIO definitions */
++#define GPIO_BTN0 0
++#define GPIO_BTN1 1
++#define GPIO_BTN2 2
++#define GPIO_BTN3 3
++
++#define GPIO_PROG_VOLTAGE 4
++
++/*
++ * If !LVDS_DETECT, the AUX lines are available as GPIO,
++ * otherwise they are used for LVDS signals.
++ */
++#define GPIO_AUX0 5
++#define GPIO_AUX1 6
++#define GPIO_AUX2 7
++#define GPIO_AUX3 8
++#define GPIO_AUX4 9
++
++#define GPIO_LED0 10
++#define GPIO_LED1 11
++
++#define GPIO_USB_VBUS_DETECT 12
++
++#define GPIO_PCH0 244
++#define GPIO_PCH1 245
++#define GPIO_PCH2 246
++#define GPIO_PCH3 247
++#define GPIO_PCH4 248
++#define GPIO_PCH5 249
++#define GPIO_PCH6 250
++#define GPIO_PCH7 251
++
++#define GPIO_HWID0 252
++#define GPIO_HWID1 253
++#define GPIO_HWID2 254
++
++#define GPIO_LVDS_DETECT 255
+diff --git a/drivers/platform/x86/minnowboard.c b/drivers/platform/x86/minnowboard.c
+new file mode 100644
+index 0000000..535f88d
+--- /dev/null
++++ b/drivers/platform/x86/minnowboard.c
+@@ -0,0 +1,167 @@
++/*
++ * 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 at linux.intel.com>
++ */
++
++#define pr_fmt(fmt) "MinnowBoard: " fmt
++
++#include <linux/platform_device.h>
++#include <linux/module.h>
++#include <linux/dmi.h>
++#include <linux/input.h>
++#include <linux/gpio.h>
++#include <linux/leds.h>
++#include <linux/gpio-sch.h>
++#include <linux/delay.h>
++#include <linux/minnowboard.h>
++#include "minnowboard-gpio.h"
++
++static int minnow_hwid_val = -1;
++
++/* leds-gpio platform device structures */
++static const struct gpio_led minnow_leds[] = {
++	{ .name = "minnow_led0", .gpio = GPIO_LED0, .active_low = 0,
++	  .retain_state_suspended = 1, .default_state = LEDS_GPIO_DEFSTATE_ON,
++	  .default_trigger = "heartbeat"},
++	{ .name = "minnow_led1", .gpio = GPIO_LED1, .active_low = 0,
++	  .retain_state_suspended = 1, .default_state = LEDS_GPIO_DEFSTATE_ON,
++	  .default_trigger = "mmc0"},
++};
++
++static struct gpio_led_platform_data minnow_leds_platform_data = {
++	.num_leds = ARRAY_SIZE(minnow_leds),
++	.leds = (void *) minnow_leds,
++};
++
++static struct platform_device minnow_gpio_leds = {
++	.name =	"leds-gpio",
++	.id = -1,
++	.dev = {
++		.platform_data = &minnow_leds_platform_data,
++	},
++};
++
++static struct gpio hwid_gpios[] = {
++	{ GPIO_HWID0, GPIOF_DIR_IN | GPIOF_EXPORT, "minnow_gpio_hwid0" },
++	{ GPIO_HWID1, GPIOF_DIR_IN | GPIOF_EXPORT, "minnow_gpio_hwid1" },
++	{ GPIO_HWID2, GPIOF_DIR_IN | GPIOF_EXPORT, "minnow_gpio_hwid2" },
++};
++
++int minnow_hwid(void)
++{
++	/* This should never be called prior to minnow_init_module() */
++	WARN_ON_ONCE(minnow_hwid_val == -1);
++	return minnow_hwid_val;
++}
++EXPORT_SYMBOL_GPL(minnow_hwid);
++
++bool minnow_detect(void)
++{
++	const char *cmp;
++
++	cmp = dmi_get_system_info(DMI_BOARD_NAME);
++	if (cmp && strstr(cmp, "MinnowBoard"))
++		return true;
++
++	return false;
++}
++EXPORT_SYMBOL_GPL(minnow_detect);
++
++bool minnow_lvds_detect(void)
++{
++	return !!gpio_get_value(GPIO_LVDS_DETECT);
++}
++EXPORT_SYMBOL_GPL(minnow_lvds_detect);
++
++
++static int __init minnow_module_init(void)
++{
++	int err, val, i;
++
++	err = -ENODEV;
++	if (!minnow_detect())
++		goto out;
++
++#ifdef MODULE
++/* Load any implicit dependencies that are not built-in */
++#ifdef CONFIG_LPC_SCH_MODULE
++	if (request_module("lpc_sch"))
++		goto out;
++#endif
++#ifdef CONFIG_GPIO_SCH_MODULE
++	if (request_module("gpio-sch"))
++		goto out;
++#endif
++#ifdef CONFIG_GPIO_PCH_MODULE
++	if (request_module("gpio-pch"))
++		goto out;
++#endif
++#endif
++
++	/* HWID GPIOs */
++	err = gpio_request_array(hwid_gpios, ARRAY_SIZE(hwid_gpios));
++	if (err) {
++		pr_err("Failed to request hwid GPIO lines\n");
++		goto out;
++	}
++	minnow_hwid_val = (!!gpio_get_value(GPIO_HWID0)) |
++			  (!!gpio_get_value(GPIO_HWID1) << 1) |
++			  (!!gpio_get_value(GPIO_HWID2) << 2);
++
++	pr_info("Hardware ID: %d\n", minnow_hwid_val);
++
++	err = gpio_request_one(GPIO_LVDS_DETECT, GPIOF_DIR_IN | GPIOF_EXPORT,
++			       "minnow_lvds_detect");
++	if (err) {
++		pr_err("Failed to request LVDS_DETECT GPIO line (%d)\n",
++		       GPIO_LVDS_DETECT);
++		goto out;
++	}
++
++	/* Disable the GPIO lines if LVDS is detected */
++	val = minnow_lvds_detect() ? 1 : 0;
++	pr_info("Aux GPIO lines %s\n", val ? "Disabled" : "Enabled");
++	for (i = 0; i < 5; i++)
++		sch_gpio_resume_set_enable(i, !val);
++
++	/* GPIO LEDs */
++	err = platform_device_register(&minnow_gpio_leds);
++	if (err) {
++		pr_err("Failed to register leds-gpio platform device\n");
++		goto out_lvds;
++	}
++	goto out;
++
++ out_lvds:
++	gpio_free(GPIO_LVDS_DETECT);
++
++ out:
++	return err;
++}
++
++static void __exit minnow_module_exit(void)
++{
++	gpio_free(GPIO_LVDS_DETECT);
++	platform_device_unregister(&minnow_gpio_leds);
++}
++
++module_init(minnow_module_init);
++module_exit(minnow_module_exit);
++
++MODULE_LICENSE("GPL");
+diff --git a/include/linux/minnowboard.h b/include/linux/minnowboard.h
+new file mode 100644
+index 0000000..d3608b8
+--- /dev/null
++++ b/include/linux/minnowboard.h
+@@ -0,0 +1,37 @@
++/*
++ * 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 at linux.intel.com>
++ */
++
++#ifndef _LINUX_MINNOWBOARD_H
++#define _LINUX_MINNOWBOARD_H
++
++#if defined(CONFIG_MINNOWBOARD) || defined(CONFIG_MINNOWBOARD_MODULE)
++bool minnow_detect(void);
++bool minnow_lvds_detect(void);
++int minnow_hwid(void);
++void minnow_phy_reset(void);
++#else
++#define minnow_detect() (false)
++#define minnow_lvds_detect() (false)
++#define minnow_hwid() (-1)
++#define minnow_phy_reset() do { } while (0)
++#endif /* MINNOWBOARD */
++
++#endif /* _LINUX_MINNOWBOARD_H */
+-- 
+1.8.3.1
+
diff --git a/meta/cfg/kernel-cache/features/minnow-io/0003-minnowboard-gpio-Export-MinnowBoard-expansion-GPIO.patch b/meta/cfg/kernel-cache/features/minnow-io/0003-minnowboard-gpio-Export-MinnowBoard-expansion-GPIO.patch
new file mode 100644
index 0000000..331de98
--- /dev/null
+++ b/meta/cfg/kernel-cache/features/minnow-io/0003-minnowboard-gpio-Export-MinnowBoard-expansion-GPIO.patch
@@ -0,0 +1,182 @@
+From 5d8dc9ea4644423ea4b8c57495ccf93efc1c51e1 Mon Sep 17 00:00:00 2001
+Message-Id: <5d8dc9ea4644423ea4b8c57495ccf93efc1c51e1.1383605156.git.darren at dvhart.com>
+In-Reply-To: <c018204ed1246c0c2129cc2d48f444d89e926034.1383605156.git.darren at dvhart.com>
+References: <c018204ed1246c0c2129cc2d48f444d89e926034.1383605156.git.darren at dvhart.com>
+From: Darren Hart <dvhart at linux.intel.com>
+Date: Sat, 18 May 2013 14:45:58 -0700
+Subject: [PATCH 3/4] minnowboard-gpio: Export MinnowBoard expansion GPIO
+
+Request and export the user-configurable GPIO lines to sysfs. This provides a
+label readable in /debugfs/gpio and a simple interface for experimenting with
+GPIO on the MinnowBoard.
+
+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 at linux.intel.com>
+---
+ drivers/platform/x86/Kconfig            |  18 ++++++
+ drivers/platform/x86/Makefile           |   1 +
+ drivers/platform/x86/minnowboard-gpio.c | 108 ++++++++++++++++++++++++++++++++
+ 3 files changed, 127 insertions(+)
+ create mode 100644 drivers/platform/x86/minnowboard-gpio.c
+
+diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
+index 154dbf6..c8755cb 100644
+--- a/drivers/platform/x86/Kconfig
++++ b/drivers/platform/x86/Kconfig
+@@ -35,6 +35,24 @@ config MINNOWBOARD
+ 
+ 	  If you have a MinnowBoard, say Y or M here.
+ 
++if MINNOWBOARD
++config MINNOWBOARD_GPIO
++	tristate "MinnowBoard Expansion GPIO"
++	depends on MINNOWBOARD
++	default n
++	---help---
++	  Export the EG20T (gpio-pch) lines on the expansion connector to sysfs
++	  for easy manipulation from userspace. These will be named
++	  "minnow_gpio_pch[0-7]". If LVDS is not in use, export the E6XX
++	  (gpio-sch) lines on the expansion connector to sysfs, these will be
++	  named "minnow_gpio_aux[0-4]".
++
++	  If you have a MinnowBoard, and want to experiment with the GPIO,
++	  say Y or M here.
++
++endif # MINNOWBOARD
++
++
+ config ACER_WMI
+ 	tristate "Acer WMI Laptop Extras"
+ 	depends on ACPI
+diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
+index 45ede1c..4dac9f0 100644
+--- a/drivers/platform/x86/Makefile
++++ b/drivers/platform/x86/Makefile
+@@ -3,6 +3,7 @@
+ # x86 Platform-Specific Drivers
+ #
+ obj-$(CONFIG_MINNOWBOARD)	+= minnowboard.o
++obj-$(CONFIG_MINNOWBOARD_GPIO)	+= minnowboard-gpio.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-gpio.c b/drivers/platform/x86/minnowboard-gpio.c
+new file mode 100644
+index 0000000..0c6ff85
+--- /dev/null
++++ b/drivers/platform/x86/minnowboard-gpio.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 at 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"
++
++static struct gpio expansion_gpios[] = {
++	{ GPIO_PCH0, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_pch0" },
++	{ GPIO_PCH1, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_pch1" },
++	{ GPIO_PCH2, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_pch2" },
++	{ GPIO_PCH3, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_pch3" },
++	{ GPIO_PCH4, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_pch4" },
++	{ GPIO_PCH5, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_pch5" },
++	{ GPIO_PCH6, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_pch6" },
++	{ GPIO_PCH7, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_pch7" },
++};
++
++static struct gpio expansion_aux_gpios[] = {
++	{ GPIO_AUX0, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_aux0" },
++	{ GPIO_AUX1, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_aux1" },
++	{ GPIO_AUX2, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_aux2" },
++	{ GPIO_AUX3, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_aux3" },
++	{ GPIO_AUX4, GPIOF_DIR_IN | GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE,
++	  "minnow_gpio_aux4" },
++};
++
++static int __init minnow_gpio_module_init(void)
++{
++	int err;
++
++	err = -ENODEV;
++	if (!minnow_detect())
++		goto out;
++
++	/* Auxillary Expansion GPIOs */
++	if (!minnow_lvds_detect()) {
++		pr_debug("LVDS_DETECT not asserted, configuring Aux GPIO lines\n");
++		err = gpio_request_array(expansion_aux_gpios,
++					 ARRAY_SIZE(expansion_aux_gpios));
++		if (err) {
++			pr_err("Failed to request expansion aux GPIO lines\n");
++			goto out;
++		}
++	} else {
++		pr_debug("LVDS_DETECT asserted, ignoring aux GPIO lines\n");
++	}
++
++	/* Expansion GPIOs */
++	err = gpio_request_array(expansion_gpios, ARRAY_SIZE(expansion_gpios));
++	if (err) {
++		pr_err("Failed to request expansion GPIO lines\n");
++		if (minnow_lvds_detect())
++			gpio_free_array(expansion_aux_gpios,
++					ARRAY_SIZE(expansion_aux_gpios));
++		goto out;
++	}
++
++ out:
++	return err;
++}
++
++static void __exit minnow_gpio_module_exit(void)
++{
++	if (minnow_lvds_detect())
++		gpio_free_array(expansion_aux_gpios,
++				ARRAY_SIZE(expansion_aux_gpios));
++	gpio_free_array(expansion_gpios, ARRAY_SIZE(expansion_gpios));
++}
++
++module_init(minnow_gpio_module_init);
++module_exit(minnow_gpio_module_exit);
++
++MODULE_LICENSE("GPL");
+-- 
+1.8.3.1
+
diff --git a/meta/cfg/kernel-cache/features/minnow-io/0004-minnowboard-keys-Bind-MinnowBoard-buttons-to-arrow-k.patch b/meta/cfg/kernel-cache/features/minnow-io/0004-minnowboard-keys-Bind-MinnowBoard-buttons-to-arrow-k.patch
new file mode 100644
index 0000000..87495e6
--- /dev/null
+++ b/meta/cfg/kernel-cache/features/minnow-io/0004-minnowboard-keys-Bind-MinnowBoard-buttons-to-arrow-k.patch
@@ -0,0 +1,172 @@
+From f2e8f76ba6fdf47967d6dd0edc3332b0de3f488d Mon Sep 17 00:00:00 2001
+Message-Id: <f2e8f76ba6fdf47967d6dd0edc3332b0de3f488d.1383605156.git.darren at dvhart.com>
+In-Reply-To: <c018204ed1246c0c2129cc2d48f444d89e926034.1383605156.git.darren at dvhart.com>
+References: <c018204ed1246c0c2129cc2d48f444d89e926034.1383605156.git.darren at dvhart.com>
+From: Darren Hart <dvhart at linux.intel.com>
+Date: Sat, 18 May 2013 14:45:59 -0700
+Subject: [PATCH 4/4] minnowboard-keys: Bind MinnowBoard buttons to arrow keys
+
+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 at linux.intel.com>
+---
+ drivers/platform/x86/Kconfig            |  14 +++++
+ drivers/platform/x86/Makefile           |   1 +
+ drivers/platform/x86/minnowboard-keys.c | 101 ++++++++++++++++++++++++++++++++
+ 3 files changed, 116 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..319507a
+--- /dev/null
++++ b/drivers/platform/x86/minnowboard-keys.c
+@@ -0,0 +1,101 @@
++/*
++ * 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 at 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;
++
++	/* 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.3.1
+
diff --git a/meta/cfg/kernel-cache/features/minnow-io/minnow-io.cfg b/meta/cfg/kernel-cache/features/minnow-io/minnow-io.cfg
new file mode 100644
index 0000000..9bfe5c1
--- /dev/null
+++ b/meta/cfg/kernel-cache/features/minnow-io/minnow-io.cfg
@@ -0,0 +1,20 @@
+CONFIG_MINNOWBOARD=y
+CONFIG_MINNOWBOARD_GPIO=m
+CONFIG_MINNOWBOARD_KEYS=m
+
+# GPIO Support
+CONFIG_GPIO_SYSFS=y
+CONFIG_GPIOLIB=y
+
+CONFIG_GPIO_GENERIC=y
+CONFIG_GPIO_GENERIC_PLATFORM=y
+CONFIG_MFD_CORE=y
+CONFIG_LPC_SCH=y
+CONFIG_GPIO_SCH=y
+CONFIG_GPIO_PCH=y
+
+# Userland interfaces
+CONFIG_INPUT_EVDEV=y
+
+# Input Device Drivers
+CONFIG_KEYBOARD_GPIO_POLLED=y
diff --git a/meta/cfg/kernel-cache/features/minnow-io/minnow-io.scc b/meta/cfg/kernel-cache/features/minnow-io/minnow-io.scc
new file mode 100644
index 0000000..01c66dc
--- /dev/null
+++ b/meta/cfg/kernel-cache/features/minnow-io/minnow-io.scc
@@ -0,0 +1,7 @@
+# Depends on EG20T and Tunnel Creek GPIO (LPC, SCH, etc.)
+kconf hardware minnow-io.cfg
+
+patch 0001-gpio-sch-Add-sch_gpio_resume_set_enable.patch
+patch 0002-minnowboard-Add-base-platform-driver-for-the-MinnowB.patch
+patch 0003-minnowboard-gpio-Export-MinnowBoard-expansion-GPIO.patch
+patch 0004-minnowboard-keys-Bind-MinnowBoard-buttons-to-arrow-k.patch
-- 
1.7.9.5




More information about the linux-yocto mailing list