上·志

上下求索,志在千里。

导航

S3C6410(Real6410) Linux 6x6矩阵键盘驱动移植

Posted on 2012-09-01 11:41  Shangzhi  阅读(850)  评论(0编辑  收藏  举报

S3C6410(Real6410) Linux 6x6矩阵键盘驱动移植

BY: zsz @ 2012.06.01

Real6410默认的键盘驱动是gpio键盘驱动,现在要取消gpio键盘,实现矩阵键盘。6410的矩阵键盘驱动对应的是samsung-keypad.c,位于driver/input/keyboard目录,可按照下面步骤进行移植。

1、 arch/arm/mach-s3c64xx/mach-real6410.c中签加

添加头文件:

#include <plat/keypad.h>

添加struct定义

static uint32_t smdk6410_keymap[] __initdata = {

         /* KEY(row, col, keycode) */

         /*S00(0,0),               S01(0,1),                   S02(0,2),           S03(0,3)*/

         KEY(0, 0, KEY_F1), KEY(0, 1, KEY_F2), KEY(0, 2, KEY_F3),   KEY(0,3,KEY_F4),

         /*S04(0,4),               S05(0,5),                   S06(4,0),           S07(5,0)*/

         KEY(0, 4, KEY_1),    KEY(0, 5, KEY_2),    KEY(4, 0, KEY_3),     KEY(5,0,KEY_UP),

         /*S08(1,0),               S09(1,1),           S0A(1,2),           S0B(1,3)*/

         KEY(1, 0, KEY_F5), KEY(1, 1, KEY_F6), KEY(1, 2, KEY_F7),   KEY(1,3,KEY_F8),

         /*S0C(1,4),               S0D(1,5),           S0E(4,1),           S0F(5,1)*/

         KEY(1, 4, KEY_4),    KEY(1, 5, KEY_5),    KEY(4, 1, KEY_6),     KEY(5,1,KEY_LEFT),

         /*S10(2,0),               S11(2,1),           S12(2,2),           S13(2,3)*/

         KEY(2, 0, KEY_F9), KEY(2, 1, KEY_F10),         KEY(2, 2, KEY_F11), KEY(2,3,KEY_F12),

         /*S14(2,4),               S15(2,5),           S16(4,2),           S17(5,2)*/

         KEY(2, 4, KEY_7),    KEY(2, 5, KEY_8),    KEY(4, 2, KEY_9),     KEY(5,2,KEY_DOWN),

         /*S18(3,0),               S19(3,1),           S1A(3,2),           S1B(3,3)*/

         KEY(3, 0, KEY_DOT),       KEY(3, 1, KEY_0),    KEY(3, 2, KEY_MINUS),    KEY(3,3,KEY_ESC),

         /*S1C(3,4),               S1D(3,5),                    S1E(4,3),           S1F(5,3)*/

         KEY(3, 4, KEY_TAB),        KEY(3, 5, KEY_BACKSPACE),  KEY(4, 3, KEY_ENTER),    KEY(5,3,KEY_RIGHT)

};

 

static struct matrix_keymap_data smdk6410_keymap_data __initdata = {

         .keymap            = smdk6410_keymap,

         .keymap_size = ARRAY_SIZE(smdk6410_keymap),

};

 

static struct samsung_keypad_platdata smdk6410_keypad_data __initdata = {

         .keymap_data = &smdk6410_keymap_data,

         .rows                 = 6,

         .cols          = 6,

};

2、 static struct platform_device *real6410_devices[] __initdata结构中增加

&samsung_device_keypad,

同时屏蔽&s3c_device_gpio_button,

/*

         &s3c_device_gpio_button,

*/

3、在static void __init real6410_machine_init(void)函数中加上

         samsung_keypad_set_platdata(&smdk6410_keypad_data);

   设置键盘参数。samsung_keypad_set_platdataarch/arm/plat-samsung/dev-keypap.c中实现。

4、 修改配置,在linux目录下执行make xconfig, 进入input device support->keyboards, 取消掉S3C6410 GPIO Buttons

选上Samsung keypad support

保存并退出xconfig,重新make即可。