//--------------------------------------------------------------------------------------------
// 作者:longtian635241([email protected])
// 论坛ID:idea6410
// 版权:idea6410
// 平台:友坚idea6410开发板
// 发布日期:2012-11-22
// 最后修改:2012-11-22
//http://www.urbetter.com/main.asp
//----------------------------------------------------------------------------------------------
/* gpio buttons */
static struct gpio_keys_button gpio_buttons[] = {
{
.gpio = S3C64XX_GPN(0),
//.code = 25,
.code = KEY_UP,
.desc = "BUTTON1",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(1),
//.code = 42,
.code = KEY_LEFT,
.desc = "BUTTON2",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(2),
//.code = 50,
.code = KEY_RIGHT,
.desc = "BUTTON3",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(3),
//.code = 10,
.code = KEY_DOWN,
.desc = "BUTTON4",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(4),
//.code = 24,
.code = KEY_ESC,
.desc = "BUTTON5",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(5),
//.code = 38,
.code = KEY_ENTER,
.desc = "BUTTON6",
.active_low = 1,
.wakeup = 0,
}
};
static struct gpio_keys_platform_data gpio_button_data = {
.buttons = gpio_buttons,
.nbuttons = ARRAY_SIZE(gpio_buttons),
};
static struct platform_device gpio_button_device = {
.name = "gpio-keys",
.id = -1,
.num_resources = 0,
.dev = {
.platform_data = &gpio_button_data,
}
};
idea6410的GIPO-KEYS,也就是单板上面的6个按键功能的实现:
需要添加头文件:
#include <linux/gpio_keys.h>,(默认已有)
#include <linux/input.h>
Device Drivers --->
Input device support --->
[*] Keyboards --->
<*> GPIO Buttons
编译通过可测试没有反应,查看串口信息显示:
gpio-keys gpio-keys: Failed to request GPIO 149, error -16
gpio-keys: probe of gpio-keys failed with error -16
修改:drivers/input/keyboard/gpio_keys.c
error = gpio_request(button->gpio, desc);
if (error < 0) {
dev_err(dev, "Failed to request GPIO %d, error %d\n",
button->gpio, error);
return error;
}
修改为:
error = gpio_request(button->gpio, desc);
//add by hcm
// if (error < 0) {
if (error > 0) {
dev_err(dev, "Failed to request GPIO %d, error %d\n",
button->gpio, error);
return error;
}
第二种方法:
1、从友坚的urbetter-linux2.6.28-v1.0/drivers/input/keyboard下将s3c-button.c拷贝到Y:\linux-3.6.6\drivers\input\keyboard下面
2、修改Y:\linux-3.6.6\drivers\input\keyboard\Kconfig,在最后一行endif前加入:
#add by chm
config KEYBOARD_S3C_BUTTON
tristate "S3C Buttons"
depends on GENERIC_GPIO
help
This driver implements support for buttons connected
to GPIO pins of various CPUs.
To compile this driver as a module, choose M here: the
module will be called.
3、修改Y:\linux-3.6.6\drivers\input\keyboard\Makefile在最后加入:
#add by hcm
obj-$(CONFIG_KEYBOARD_S3C_BUTTON) += s3c-button.o
4、make menuconfig
Device Drivers --->
Input device support --->
[*] Keyboards --->
<*> S3C Buttons
5、编译即可!
驱动下载地址:http://download.csdn.net/detail/longtian635241/4797626