标签:
Input platform device 一般是在板级bsp注册了的资源。
以gpio-keys为例:
#####################gpio_key.h##############################
#ifndef _GPIO_KEYS_H
#define _GPIO_KEYS_H
struct gpio_keys_button {
/* Configuration parameters */
unsigned int code; /* input event code (KEY_*, SW_*) */ //上报事件的code
int gpio; /* gpio num*/
int active_low; //是否低电平有效
const char *desc; /* 功能描述 */
unsigned int type; /* input event type (EV_KEY, EV_SW, EV_ABS) */
int wakeup; /* configure the button as a wake-up source */
int debounce_interval; /* debounce ticks interval in msecs *//* 去抖动间隔,单位微秒*/
int lock_interval; /* pause for a moment when the key is pressed */
bool can_disable;
int value; /* axis value for EV_ABS */
};
struct gpio_keys_platform_data {
struct gpio_keys_button *buttons;
int nbuttons;
unsigned int poll_interval; /* polling interval in msecs -
for polling driver only */
unsigned int rep:1; /* enable input subsystem auto repeat */
int (*enable)(struct device *dev);
void (*disable)(struct device *dev);
const char *name; /* input device name */
};
#endif
######################################################################
#ifdef CONFIG_KEYBOARD_GPIO
/*以下表明即将注册五个gpio button信息*/
static struct gpio_keys_button board_buttons[] = {
#ifdef GPIO_RECORD
{
.gpio = GPIO_RECORD,
.code = KEY_RECORD,
.desc = "record key",
.active_low = 1,
},
#endif
#ifdef GPIO_AP_STA
{
.gpio = GPIO_AP_STA,
.code = KEY_MODE,
.desc = "ap/sta shift",
.active_low = 1,
},
#endif
#ifdef GPIO_POWER
{
.gpio = GPIO_POWER,
.code = KEY_POWER,
.desc = "power wakeup",
.active_low = 1,
.wakeup = 1,
},
#endif
#ifdef GPIO_VOLUMEDOWN
{
.gpio = GPIO_VOLUMEDOWN,
.code = KEY_VOLUMEDOWN,
.desc = "volum down key",
.active_low = 1,
},
#endif
#ifdef GPIO_VOLUMEUP
{
.gpio = GPIO_VOLUMEUP,
.code = KEY_VOLUMEUP,
.desc = "volum up key",
.active_low = 1,
},
#endif
};
static struct gpio_keys_platform_data board_button_data = {
.buttons = board_buttons,
.nbuttons = ARRAY_SIZE(board_buttons),
};
static struct platform_device button_device = {
.name = "gpio-keys",
.id = -1,
.num_resources = 0,
.dev = {
.platform_data = &board_button_data,
}
};
#endif/* CONFIG_KEYBOARD_GPIO */
//注册platform button device
#ifdef CONFIG_KEYBOARD_GPIO
platform_device_register(&button_device);
#endif
linux 输入子系统(2) platform device
标签:
原文地址:http://www.cnblogs.com/xuyh/p/4863930.html