这几天看输入子系统,以下是在友善Tiny6410开发板上的基于输入子系统的GPIO按键驱动配置。GPN(5)在LCD Power里被占用了,故会在驱动加载时,提示error -16,即EBUSY。注释掉后,即可使用。
- diff -uNr linux-2.6.38/arch/arm/mach-s3c64xx/mach-mini6410.c linux-2.6.38-jason//arch/arm/mach-s3c64xx/mach-mini6410.c
-
--- linux-2.6.38/arch/arm/mach-s3c64xx/mach-mini6410.c 2011-07-18 12:10:46.000000000 +0800
-
+++ linux-2.6.38-jason//arch/arm/mach-s3c64xx/mach-mini6410.c 2011-12-02 16:16:22.725178722 +0800
-
@@ -32,6 +32,8 @@
-
#include <linux/mtd/mtd.h>
-
#include <linux/mtd/partitions.h>
-
#include <linux/proc_fs.h>
-
+#include <linux/gpio_keys.h> //add by Jason
-
+#include <linux/input.h> //add by Jason
-
-
#include <video/platform_lcd.h>
-
-
@@ -333,7 +335,75 @@
-
#endif
-
};
-
-
+/* Tiny6410 Buttons */
-
+static struct gpio_keys_button tiny6410_buttons[] = { //add by Jason
-
+ {
-
+ .gpio = S3C64XX_GPN(0),
-
+ .code = KEY_1,
-
+ .desc = "key1",
-
+ .active_low = 1,
-
+ },
-
+ {
-
+ .gpio = S3C64XX_GPN(1),
-
+ .code = KEY_2,
-
+ .desc = "key2",
-
+ .active_low = 1,
-
+ },
-
+ {
-
+ .gpio = S3C64XX_GPN(2),
-
+ .code = KEY_3,
-
+ .desc = "key3",
-
+ .active_low = 1,
-
+ },
-
+ {
-
+ .gpio = S3C64XX_GPN(3),
-
+ .code = KEY_4,
-
+ .desc = "key4",
-
+ .active_low = 1,
-
+ },
-
+ {
-
+ .gpio = S3C64XX_GPN(4),
-
+ .code = KEY_5,
-
+ .desc = "key5",
-
+ .active_low = 1,
-
+ },
-
+ /* be used by LCD
-
+ {
-
+ .gpio = S3C64XX_GPN(5),
-
+ .code = KEY_6,
-
+ .desc = "key6",
-
+ .active_low = 1,
-
+ },
-
+ */
-
+ {
-
+ .gpio = S3C64XX_GPL(11),
-
+ .code = KEY_7,
-
+ .desc = "key7",
-
+ .active_low = 1,
-
+ },
-
+ {
-
+ .gpio = S3C64XX_GPL(12),
-
+ .code = KEY_8,
-
+ .desc = "key8",
-
+ .active_low = 1,
-
+ },
-
+};
-
+
-
+static struct gpio_keys_platform_data tiny6410_button_data = { //add by Jason
-
+ .buttons = tiny6410_buttons,
-
+ .nbuttons = ARRAY_SIZE(tiny6410_buttons),
-
+};
-
+
-
+static struct platform_device tiny6410_device_button = { //add by Jason
-
+ .name = "gpio-keys",
-
+ .id = -1,
-
+ .dev = {
-
+ .platform_data = &tiny6410_button_data,
-
+ }
-
+};
-
+
-
static struct platform_device *mini6410_devices[] __initdata = {
-
+ &tiny6410_device_button, //add by Jason
-
#ifdef CONFIG_MINI6410_SD_CH0
-
&s3c_device_hsmmc0,
-
#endif
-
diff -uNr linux-2.6.38/drivers/input/keyboard/gpio_keys.c linux-2.6.38-jason//drivers/input/keyboard/gpio_keys.c
-
--- linux-2.6.38/drivers/input/keyboard/gpio_keys.c 2011-03-18 17:02:19.000000000 +0800
-
+++ linux-2.6.38-jason//drivers/input/keyboard/gpio_keys.c 2011-12-02 15:42:44.369090912 +0800
-
@@ -373,8 +373,8 @@
-
-
error = gpio_request(button->gpio, desc);
-
if (error < 0) {
-
- dev_err(dev, "failed to request GPIO %d, error %d\n",
-
- button->gpio, error);
-
+ dev_err(dev, "failed to request GPIO %d, error %d\ndesc = %s",
-
+ button->gpio, error, desc);
-
goto fail2;
-
}
阅读(4244) | 评论(0) | 转发(0) |