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的更多相关文章

  1. Linux输入子系统详解

    input输入子系统框架  linux输入子系统(linux input subsystem)从上到下由三层实现,分别为:输入子系统事件处理层(EventHandler).输入子系统核心层(Input ...

  2. linux输入子系统

    linux输入子系统(linux input subsystem)从上到下由三层实现,分别为:输入子系统事件处理层(EventHandler).输入子系统核心层(InputCore)和输入子系统设备驱 ...

  3. linux输入子系统(input subsystem)之evdev.c事件处理过程

    1.代码 input_subsys.drv.c 在linux输入子系统(input subsystem)之按键输入和LED控制的基础上有小改动,input_subsys_test.c不变. input ...

  4. Linux输入子系统(转)

    Linux输入子系统(Input Subsystem) 1.1.input子系统概述 输入设备(如按键,键盘,触摸屏,鼠标等)是典型的字符设备,其一般的工作机制是低层在按键,触摸等动作发生时产生一个中 ...

  5. Linux输入子系统(Input Subsystem)

    Linux输入子系统(Input Subsystem) http://blog.csdn.net/lbmygf/article/details/7360084 input子系统分析  http://b ...

  6. Linux输入子系统框架分析(1)

    在Linux下的输入设备键盘.触摸屏.鼠标等都能够用输入子系统来实现驱动.输入子系统分为三层,核心层和设备驱动层.事件层.核心层和事件层由Linux输入子系统本身实现,设备驱动层由我们实现.我们在设备 ...

  7. linux输入子系统概念介绍

    在此文章之前,我们讲解的都是简单的字符驱动,涉及的内容有字符驱动的框架.自动创建设备节点.linux中断.poll机制.异步通知.同步互斥.非阻塞.定时器去抖动. 上一节文章链接:http://blo ...

  8. linux输入子系统简述【转】

    本文转载自:http://blog.csdn.net/xubin341719/article/details/7678035 1,linux输入子系统简述 其实驱动这部分大多还是转载别人的,linux ...

  9. 7.Linux 输入子系统分析

    为什么要引入输入子系统? 在前面我们写了一些简单的字符设备的驱动程序,我们是怎么样打开一个设备并操作的呢? 一般都是在执行应用程序时,open一个特定的设备文件,如:/dev/buttons .... ...

随机推荐

  1. linux下c++sleep函数

    #include <iostream> #include <unistd.h> using namespace std; int main(){ int i; ]; memse ...

  2. OSPF 提升 一 ----基础

    ospf  ccnp内容   一  link-state protocols      IGP   开放式的最短路径优先协议     公有协议 支持中到大型的网络    spf算法 链路状态协议 1. ...

  3. ospf 提升 二 ---LSA

    ospf ABR和ASBR的区别 官方建议中大型网络的规模参考   根据spf算法   而不是路由器的硬件性能强弱 a ABR最多关联3个区域 b 单区域内路由器最多50台 c 一台运行ospf的路由 ...

  4. ubuntu系统下如何禁用笔记本触摸板

    命令行方式,得每次用终端输入命令行设置,不方便. sudo rmmod psmouse          # 用来禁用触摸板 sudo modprobe psmouse     # 用来启用触摸板 想 ...

  5. POJ 1056 IMMEDIATE DECODABILITY

    IMMEDIATE DECODABILITY Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9630   Accepted: ...

  6. rabbitmq php 学习

    参考文档:http://www.cnblogs.com/phpinfo/p/4104551...http://blog.csdn.net/historyasamirror/ar... 依赖包安装 yu ...

  7. [luoguP3960] 列队(动态开点线段树)

    传送门 有splay的做法,有树状数组的做法... 最好理解的还是线段树的做法. 一开始我是这样想的,如果移动某一个人,只有当前行和最后一列会受到影响,感觉就像是个线段树,树状数组什么的. 然而接下来 ...

  8. Spring JdbcTemplate 与 事务管理 学习

    Spring的JDBC框架能够承担资源管理和异常处理的工作,从而简化我们的JDBC代码, 让我们只需编写从数据库读写数据所必需的代码.Spring把数据访问的样板代码隐藏到模板类之下, 结合Sprin ...

  9. POJ1861 Network

    Time Limit: 1000MS   Memory Limit: 30000KB   64bit IO Format: %lld & %llu Description Andrew is ...

  10. jQuery事件委托之Safari失效的解决办法--摘抄

    什么是事件委托 事件委托是Jquery中一种事件绑定的方式,不同于常见的事件绑定方式将事件绑定在目标元素上,而是将事件绑定在父级元素上通过事件冒泡来执行绑定函数. //常见的事件绑定(Jquery) ...