字體:小 中 大 |
|
|
|
| 2017/12/04 14:14:16瀏覽602|回應0|推薦0 | |
imx6 GPIO button/key
是模組化了,
driver在
BSP/kernel_imx/drivers/input/keyboard/gpio_keys.c
使用方式,
在board-mx6q_sabresd.h設定錫球引出功能,
在board-mx6q_sabresd.c設定GPIO參數, imx6q_add_device_buttons()註冊button.
//---board-mx6q_sabresd.h
MX6Q_PAD_EIM_D29__GPIO_3_29, /* power off */
MX6Q_PAD_GPIO_4__GPIO_1_4, /* Volume Up */
MX6Q_PAD_GPIO_5__GPIO_1_5, /* Volume Down */
//---board-mx6q_sabresd.c
#define SABRESD_VOLUME_UP IMX_GPIO_NR(1, 4)
#define SABRESD_VOLUME_DN IMX_GPIO_NR(1, 5)
#define SABRESD_POWER_OFF IMX_GPIO_NR(3, 29)
.....
static struct gpio_keys_button sabresd_buttons[] = {
GPIO_BUTTON(SABRESD_VOLUME_UP, KEY_VOLUMEUP, 1, "volume-up", 0, 1),
GPIO_BUTTON(SABRESD_VOLUME_DN, KEY_VOLUMEDOWN, 1, "volume-down", 0, 1),
GPIO_BUTTON(SABRESD_POWER_OFF, KEY_POWER, 1, "power-key", 1, 1),
};
static struct gpio_keys_platform_data sabresd_button_data = {
.buttons = new_sabresd_buttons,
.nbuttons = ARRAY_SIZE(new_sabresd_buttons),
static struct platform_device sabresd_button_device = {
.name = "gpio-keys",
.id = -1,
.num_resources = 0,
};
.....
static void __init imx6q_add_device_buttons(void)
{
platform_device_add_data(&sabresd_button_device,
&sabresd_button_data,
sizeof(sabresd_button_data));
platform_device_register(&sabresd_button_device);
}
.....
static void __init mx6_sabresd_board_init(void)
{
.....
imx6q_add_device_buttons();
//---debug
dmesg | grep key
<6>input: gpio-keys as /devices/platform/gpio-keys/input/input0
dmesg | grep input
<6>input: gpio-keys as /devices/platform/gpio-keys/input/input0
<6>input: tq_hs0038 as /devices/virtual/input/input1
<6>input: goodix-ts as /devices/virtual/input/input2
<6>input: TSC2007 Touchscreen as /devices/virtual/input/input3
cat /proc/bus/input/devices
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="gpio-keys"
P: Phys=gpio-keys/input0
S: Sysfs=/devices/platform/gpio-keys/input/input0
U: Uniq=
H: Handlers=kbd event0
B: PROP=0
B: EV=3
B: KEY=1000 0 0 0 0 10000002
cat /sys/devices/platform/gpio-keys/input/input0/name
gpio-keys
cat /proc/interrupts
284: 0 0 0 0 GPIO btn home
286: 0 0 0 0 GPIO btn esc
336: 1148 0 0 0 GPIO btn volume-up
357: 0 0 0 0 GPIO btn enter
//若本文章對你有幫助,買個魚罐頭餵街貓吧.
|
|
| ( 心情隨筆|心情日記 ) |










