The Input platform device is typically a resource registered in the board-level BSP.
Take Gpio-keys as an example:
#################### #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_*) *//Escalation event code
int Gpio; /* Gpio num*/
int active_low; is low-level active
const char *DESC; /* Function Description */
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 *//* jitter interval, in microseconds per unit */
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
/* below indicates that five Gpio button information will be registered */
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 */
Registering Platform button device
#ifdef Config_keyboard_gpio
Platform_device_register (&button_device);
#endif
Linux input Subsystem (2) platform device