add rk30 key drivers
authorkfx <kfx@rock-chips.com>
Wed, 8 Feb 2012 03:37:48 +0000 (11:37 +0800)
committerkfx <kfx@rock-chips.com>
Wed, 8 Feb 2012 03:37:48 +0000 (11:37 +0800)
arch/arm/mach-rk29/include/mach/key.h
arch/arm/mach-rk30/Makefile
arch/arm/mach-rk30/board-rk30sdk-key.c [new file with mode: 0755]
arch/arm/mach-rk30/devices.c
arch/arm/plat-rk/include/plat/key.h [new file with mode: 0755]
drivers/input/keyboard/Kconfig
drivers/input/keyboard/rk29_keys.c

index 5630497a2c5f35aa7b3a5e1cff98bd274909e307..37ee59ea18af84c740f014274aa566cd104c055a 100755 (executable)
@@ -1,30 +1,4 @@
 #ifndef __RK29_KEYS_H__
 #define __RK29_KEYS_H__
-#include <linux/input.h>
-
-#define DEFAULT_DEBOUNCE_INTERVAL      10  //10ms
-#define LONG_PRESS_COUNT                       100 //100 * 10 = 1000ms
-#define ONE_SEC_COUNT                          (1000/DEFAULT_DEBOUNCE_INTERVAL)
-
-#define ADC_SAMPLE_TIME                                10
-
-struct rk29_keys_button {
-       int code;               
-       int code_long_press;
-       int gpio;
-       int adc_value;
-       int adc_state;
-       int active_low;
-       char *desc;
-       int wakeup;     
-};
-
-
-struct rk29_keys_platform_data {
-       struct rk29_keys_button *buttons;
-       int nbuttons;
-       int chn;
-       int rep;
-};
-
+#include <plat/key.h>
 #endif
index b629368edd25819cf8536ffe6ebe5c2440b56d61..e925782826dcf353ddb387b7fda89e3759b6baa4 100644 (file)
@@ -10,4 +10,4 @@ ifndef CONFIG_DEBUG_LL
 obj-y += ../kernel/debug.o
 endif
 obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
-obj-$(CONFIG_MACH_RK30_SDK) += board-rk30-sdk.o
+obj-$(CONFIG_MACH_RK30_SDK) += board-rk30-sdk.o board-rk30sdk-key.o
diff --git a/arch/arm/mach-rk30/board-rk30sdk-key.c b/arch/arm/mach-rk30/board-rk30sdk-key.c
new file mode 100755 (executable)
index 0000000..0a8a109
--- /dev/null
@@ -0,0 +1,113 @@
+#include <mach/gpio.h>
+#include <plat/key.h>
+
+#define EV_ENCALL                              KEY_F4
+#define EV_MENU                                        KEY_F1
+
+#define PRESS_LEV_LOW                  1
+#define PRESS_LEV_HIGH                 0
+
+static struct rk29_keys_button key_button[] = {
+       {
+               .desc   = "menu",
+               .code   = EV_MENU,
+               .gpio   = RK30_PIN6_PA0,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "vol+",
+               .code   = KEY_VOLUMEUP,
+               .gpio   = RK30_PIN6_PA1,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "vol-",
+               .code   = KEY_VOLUMEDOWN,
+               .gpio   = RK30_PIN6_PA2,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "home",
+               .code   = KEY_HOME,
+               .gpio   = RK30_PIN6_PA3,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "search",
+               .code   = KEY_SEARCH,
+               .gpio   = RK30_PIN6_PA4,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "esc",
+               .code   = KEY_BACK,
+               .gpio   = RK30_PIN6_PA5,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "sensor",
+               .code   = KEY_CAMERA,
+               .gpio   = RK30_PIN6_PA6,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "play",
+               .code   = KEY_POWER,
+               .gpio   = RK30_PIN6_PA7,
+               .active_low = PRESS_LEV_LOW,
+               //.code_long_press = EV_ENCALL,
+               .wakeup = 1,
+       },
+#if 0
+       {
+               .desc   = "vol+",
+               .code   = KEY_VOLUMEDOWN,
+               .adc_value      = 95,
+               .gpio = INVALID_GPIO,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "vol-",
+               .code   = KEY_VOLUMEUP,
+               .adc_value      = 249,
+               .gpio = INVALID_GPIO,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "menu",
+               .code   = EV_MENU,
+               .adc_value      = 406,
+               .gpio = INVALID_GPIO,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "home",
+               .code   = KEY_HOME,
+               .code_long_press = KEY_F4,
+               .adc_value      = 561,
+               .gpio = INVALID_GPIO,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "esc",
+               .code   = KEY_ESC,
+               .adc_value      = 726,
+               .gpio = INVALID_GPIO,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "adkey6",
+               .code   = KEY_BACK,
+               .code_long_press = EV_ENCALL,
+               .adc_value      = 899,
+               .gpio = INVALID_GPIO,
+               .active_low = PRESS_LEV_LOW,
+       },
+#endif
+};
+struct rk29_keys_platform_data rk29_keys_pdata = {
+       .buttons        = key_button,
+       .nbuttons       = ARRAY_SIZE(key_button),
+       .chn    = -1,  //chn: 0-7, if do not use ADC,set 'chn' -1
+};
+
index 1572590ef9db5f616d495780a8c6c2c5cfbbef5c..8a9028bfedd621180d97f319eb661bcc93e82afa 100644 (file)
@@ -343,13 +343,25 @@ static struct platform_device device_nand = {
        .num_resources  = ARRAY_SIZE(resources_nand),
 };
 #endif
-
+#ifdef CONFIG_KEYS_RK29
+extern struct rk29_keys_platform_data rk29_keys_pdata;
+static struct platform_device device_keys = {
+       .name           = "rk29-keypad",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &rk29_keys_pdata,
+       },
+};
+#endif
 static int __init rk30_init_devices(void)
 {
        rk30_init_uart();
        rk30_init_i2c();
 #ifdef CONFIG_MTD_NAND_RK29XX
        platform_device_register(&device_nand);
+#endif
+#ifdef CONFIG_KEYS_RK29
+       platform_device_register(&device_keys);
 #endif
         return 0;
 }
diff --git a/arch/arm/plat-rk/include/plat/key.h b/arch/arm/plat-rk/include/plat/key.h
new file mode 100755 (executable)
index 0000000..5630497
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __RK29_KEYS_H__
+#define __RK29_KEYS_H__
+#include <linux/input.h>
+
+#define DEFAULT_DEBOUNCE_INTERVAL      10  //10ms
+#define LONG_PRESS_COUNT                       100 //100 * 10 = 1000ms
+#define ONE_SEC_COUNT                          (1000/DEFAULT_DEBOUNCE_INTERVAL)
+
+#define ADC_SAMPLE_TIME                                10
+
+struct rk29_keys_button {
+       int code;               
+       int code_long_press;
+       int gpio;
+       int adc_value;
+       int adc_state;
+       int active_low;
+       char *desc;
+       int wakeup;     
+};
+
+
+struct rk29_keys_platform_data {
+       struct rk29_keys_button *buttons;
+       int nbuttons;
+       int chn;
+       int rep;
+};
+
+#endif
index 05ab0606bcd62d406b0b28e4b78270cfe1841cfb..a4d97463fb627e40aa8fcf29ecba3b9f5a932346 100644 (file)
@@ -14,7 +14,7 @@ if INPUT_KEYBOARD
 
 config KEYS_RK29
        tristate "rk29 keyboard"
-       depends on ARCH_RK29
+       depends on PLAT_RK
        default y
        help
          rk29 keyboard drivers(gpio and adc)
index 771e64dd01a6fabe29a4b2d6c451b928af52b277..b5881d5b5e93244ccec10089411d153ec4ac6825 100755 (executable)
@@ -24,9 +24,8 @@
 #include <linux/adc.h>
 
 #include <asm/gpio.h>
-#include <mach/key.h>
 #include <mach/board.h>
-
+#include <plat/key.h>
 
 #define EMPTY_ADVALUE                                  950
 #define DRIFT_ADVALUE                                  70