目前有客户咨询335x系列的开发板上的按键设备名keypad是怎样生成的,因为在内核驱动中找不到相对应的名字。 在内核中按键的名字使用的是gpio-keys,然后在文件系统中进行了一个系统连接名字就变成了keypad. 具体的文件是/etc/udev/rules.d/local.rules文件 该文件中的以下语句就是生成keypad的链接命令 # Create a symlink to any gpio-keys input device SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{name}=="gpio-keys", SYMLINK+="input/keypad" ######################################################################## 335按键添加方法 ****************************************************************** arch/arm/mach-omap2/board-am335xevm.c static struct pinmux_config gpio_keys_pin_mux_forlinx[] = { #if defined(CONFIG_OK335XD) {"gpmc_a4.gpio1_20", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_a5.gpio1_21", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_a6.gpio1_22", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_a7.gpio1_23", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_a8.gpio1_24", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_a9.gpio1_25", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, #elif defined(CONFIG_OK335XS) {"xdma_event_intr0.gpio0_19", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_csn3.gpio2_0", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"mcasp0_fsx.gpio3_15", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_csn1.gpio1_30", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"mcasp0_aclkx.gpio3_14", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, #elif defined(CONFIG_OK335XS2) {"gpmc_a4.gpio1_20", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_a5.gpio1_21", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {"gpmc_a6.gpio1_22", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, #endif {NULL, 0}, }; ++此处添加自己按键的pinmux定义++ {"gpmc_a10.gpio1_26", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, =========================================================== static void keys_init(int evm_id, int profile) { int err; setup_pin_mux(gpio_keys_pin_mux_forlinx); err = platform_device_register(&am335x_evm_gpio_keys_forlinx); if (err) pr_err("failed to register gpio key device\n"); } static struct platform_device am335x_evm_gpio_keys_forlinx = { .name = "gpio-keys", .id = -1, .dev = { .platform_data = &am335x_evm_gpio_key_info_forlinx, }, }; static struct gpio_keys_platform_data am335x_evm_gpio_key_info_forlinx = { .buttons = am335x_evm_gpio_buttons_forlinx, .nbuttons = ARRAY_SIZE(am335x_evm_gpio_buttons_forlinx), }; static struct gpio_keys_button am335x_evm_gpio_buttons_forlinx[] = { #if defined(CONFIG_OK335XD) { .code = BTN_0, .gpio = GPIO_TO_PIN(1, 20), .desc = "SW1", }, { .code = BTN_1, .gpio = GPIO_TO_PIN(1, 21), .desc = "SW2", }, { .code = BTN_2, .gpio = GPIO_TO_PIN(1, 22), .desc = "SW3", .wakeup = 1, }, { .code = BTN_3, .gpio = GPIO_TO_PIN(1, 23), .desc = "SW4", }, { .code = BTN_4, .gpio = GPIO_TO_PIN(1, 24), .desc = "SW5", .wakeup = 1, }, { .code = BTN_5, .gpio = GPIO_TO_PIN(1, 25), .desc = "SW6", }, ++此处添加自己gpio对应按键定义++ { .code = BTN_6, .gpio = GPIO_TO_PIN(1, 26), .desc = "SW7", }, =========================================================== #elif defined(CONFIG_OK335XS) { .code = BTN_0, .gpio = GPIO_TO_PIN(0, 19), .desc = "SW1", }, { .code = BTN_1, .gpio = GPIO_TO_PIN(2, 0), .desc = "SW2", }, { .code = BTN_2, .gpio = GPIO_TO_PIN(3, 15), .desc = "SW3", .wakeup = 1, }, { .code = BTN_3, .gpio = GPIO_TO_PIN(1, 30), .desc = "SW4", }, { .code = BTN_4, .gpio = GPIO_TO_PIN(3, 14), .desc = "SW5", .wakeup = 1, }, #elif defined(CONFIG_OK335XS2) { .code = BTN_0, .gpio = GPIO_TO_PIN(1, 20), .desc = "SW1", }, { .code = BTN_1, .gpio = GPIO_TO_PIN(1, 21), .desc = "SW2", }, { .code = BTN_2, .gpio = GPIO_TO_PIN(1, 22), .desc = "SW3", .wakeup = 1, }, #endif }; 至此按键添加完毕,但事情是否做完了呢,还没有,我们用到了gpmc_a10这个管脚,需要将其他用到这个引脚的地方注释掉,保证没有其他功能占用 检测了一下gpmc_a10这个脚有一些其他的pinmux定义,但是都没完成初始化,不会产生影响 ps: { .code = BTN_0, .gpio = GPIO_TO_PIN(1, 20), .desc = "SW1", }, 这个BTN_0指的是什么呢,这需要看一下include/linux/input.h,这里定义了按键的键值 |
|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )
GMT+8, 2024-11-22 11:42
Powered by Discuz! X3.4
© 2001-2013 Comsenz Inc.