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@xxxxxxxxxxxxxxx> Cc: Matthew Garrett <matthew.garrett@xxxxxxxxxx> Cc: Grant Likely <grant.likely@xxxxxxxxxx> Cc: Linus Walleij <linus.walleij@xxxxxxxxxx> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx> Cc: Peter Waskiewicz <peter.p.waskiewicz.jr@xxxxxxxxx> Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> Cc: platform-driver-x86@xxxxxxxxxxxxxxx --- drivers/platform/x86/Kconfig | 18 +++++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/minnowboard-gpio.c | 115 ++++++++++++++++++++++++++++++++ 3 files changed, 134 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..c33c438 --- /dev/null +++ b/drivers/platform/x86/minnowboard-gpio.c @@ -0,0 +1,115 @@ +/* + * 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@xxxxxxxxxxxxxxx> + */ + +#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; + +#ifdef MODULE +#ifdef CONFIG_MINNOWBOARD_MODULE + if (request_module("minnowboard")) + goto out; +#endif +#endif + + /* 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.1.2 -- To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html