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. 大数据学习——scala入门程序

    安装scala.msi https://blog.csdn.net/sinat_32867867/article/details/80305302 notepad++ object HelloScal ...

  2. Leetcode 368.最大整除子集

    最大整除子集 给出一个由无重复的正整数组成的集合,找出其中最大的整除子集,子集中任意一对 (Si,Sj) 都要满足:Si % Sj = 0 或 Sj % Si = 0. 如果有多个目标子集,返回其中任 ...

  3. PTA 07-图6 旅游规划 (25分)

    题目地址 https://pta.patest.cn/pta/test/15/exam/4/question/717 5-9 旅游规划   (25分) 有了一张自驾旅游路线图,你会知道城市间的高速公路 ...

  4. UOJ 274 【清华集训2016】温暖会指引我们前行 ——Link-Cut Tree

    魔法森林高清重置, 只需要维护关于t的最大生成树,然后链上边权求和即可. 直接上LCT 调了将近2h 吃枣药丸 #include <cstdio> #include <cstring ...

  5. 基于SEDA的异步框架设计与实现

    基于SEDA的异步框架设计与实现 二.为什么使用SEDA 目前,面对并发环境,主流互联网服务器编程模型有两种:多线程模型以及事件驱动模型.但是这两个模型都不足以解决这个问题.我们来首先看一下这两种编程 ...

  6. CentOS7关于网络的设置

    装好CentOS7后,我们一开始是上不了网的 这时候,可以输入命令dhclient,可以自动获取一个IP地址,再用命令ip addr查看IP 不过这时候获取的IP是动态的,下次重启系统后,IP地址也会 ...

  7. 王室联邦(bzoj 1086)

    Description “余”人国的国王想重新编制他的国家.他想把他的国家划分成若干个省,每个省都由他们王室联邦的一个成员来管理.他的国家有n个城市,编号为1..n.一些城市之间有道路相连,任意两个不 ...

  8. 标准C程序设计七---26

    Linux应用             编程深入            语言编程 标准C程序设计七---经典C11程序设计    以下内容为阅读:    <标准C程序设计>(第7版) 作者 ...

  9. mysql合并和时间函数

    sql:利用group_concat()方法,参数为需要合并的字段,合并的字段分隔符默认为逗号,可通过参数separator指定,该方法往往配合group by 一起使用.利用group_concat ...

  10. LeetCode OJ--Evaluate Reverse Polish Notation

    http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/ 栈使用 #include <iostream> #inc ...