From 93e9012f40f75b8ab8a37deaf532b3c5e9b527c6 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Mon, 21 Jan 2008 01:04:20 -0500 Subject: Input: add Tosa keyboard driver Add keyboard support on tosa (Sharp Zaurus SL-6000x). Largely based on patches by Dirk Opfer. Signed-off-by: Dmitry Baryshkov Signed-off-by: Dmitry Torokhov --- include/asm-arm/arch-pxa/tosa.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'include/asm-arm/arch-pxa') diff --git a/include/asm-arm/arch-pxa/tosa.h b/include/asm-arm/arch-pxa/tosa.h index c3364a2c475..c05e4faf85a 100644 --- a/include/asm-arm/arch-pxa/tosa.h +++ b/include/asm-arm/arch-pxa/tosa.h @@ -163,4 +163,34 @@ extern struct platform_device tosascoop_jc_device; extern struct platform_device tosascoop_device; + +#define TOSA_KEY_SYNC KEY_102ND /* ??? */ + + +#ifndef CONFIG_KEYBOARD_TOSA_USE_EXT_KEYCODES +#define TOSA_KEY_RECORD KEY_YEN +#define TOSA_KEY_ADDRESSBOOK KEY_KATAKANA +#define TOSA_KEY_CANCEL KEY_ESC +#define TOSA_KEY_CENTER KEY_HIRAGANA +#define TOSA_KEY_OK KEY_HENKAN +#define TOSA_KEY_CALENDAR KEY_KATAKANAHIRAGANA +#define TOSA_KEY_HOMEPAGE KEY_HANGEUL +#define TOSA_KEY_LIGHT KEY_MUHENKAN +#define TOSA_KEY_MENU KEY_HANJA +#define TOSA_KEY_FN KEY_RIGHTALT +#define TOSA_KEY_MAIL KEY_ZENKAKUHANKAKU +#else +#define TOSA_KEY_RECORD KEY_RECORD +#define TOSA_KEY_ADDRESSBOOK KEY_ADDRESSBOOK +#define TOSA_KEY_CANCEL KEY_CANCEL +#define TOSA_KEY_CENTER KEY_SELECT /* ??? */ +#define TOSA_KEY_OK KEY_OK +#define TOSA_KEY_CALENDAR KEY_CALENDAR +#define TOSA_KEY_HOMEPAGE KEY_HOMEPAGE +#define TOSA_KEY_LIGHT KEY_KBDILLUMTOGGLE +#define TOSA_KEY_MENU KEY_MENU +#define TOSA_KEY_FN KEY_FN +#define TOSA_KEY_MAIL KEY_MAIL +#endif + #endif /* _ASM_ARCH_TOSA_H_ */ -- cgit v1.2.3 From 0e5f11aa80bd01d048f374cc64ef0819ad7d86f2 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Thu, 31 Jan 2008 00:56:46 -0500 Subject: Input: pxa27x_keypad - rename the driver (was pxa27x_keyboard) The controller should really be called keypad, and also align the naming of functions and structures to use "pxa27x_keypad" as prefix, instead of "pxakbd". Signed-off-by: Eric Miao Signed-off-by: Dmitry Torokhov --- include/asm-arm/arch-pxa/pxa27x_keyboard.h | 13 ------------- include/asm-arm/arch-pxa/pxa27x_keypad.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 include/asm-arm/arch-pxa/pxa27x_keyboard.h create mode 100644 include/asm-arm/arch-pxa/pxa27x_keypad.h (limited to 'include/asm-arm/arch-pxa') diff --git a/include/asm-arm/arch-pxa/pxa27x_keyboard.h b/include/asm-arm/arch-pxa/pxa27x_keyboard.h deleted file mode 100644 index 3aaff923b2c..00000000000 --- a/include/asm-arm/arch-pxa/pxa27x_keyboard.h +++ /dev/null @@ -1,13 +0,0 @@ -#define PXAKBD_MAXROW 8 -#define PXAKBD_MAXCOL 8 - -struct pxa27x_keyboard_platform_data { - int nr_rows, nr_cols; - int keycodes[PXAKBD_MAXROW][PXAKBD_MAXCOL]; - int gpio_modes[PXAKBD_MAXROW + PXAKBD_MAXCOL]; - -#ifdef CONFIG_PM - u32 reg_kpc; - u32 reg_kprec; -#endif -}; diff --git a/include/asm-arm/arch-pxa/pxa27x_keypad.h b/include/asm-arm/arch-pxa/pxa27x_keypad.h new file mode 100644 index 00000000000..f19f74adde0 --- /dev/null +++ b/include/asm-arm/arch-pxa/pxa27x_keypad.h @@ -0,0 +1,13 @@ +#define PXAKBD_MAXROW 8 +#define PXAKBD_MAXCOL 8 + +struct pxa27x_keypad_platform_data { + int nr_rows, nr_cols; + int keycodes[PXAKBD_MAXROW][PXAKBD_MAXCOL]; + int gpio_modes[PXAKBD_MAXROW + PXAKBD_MAXCOL]; + +#ifdef CONFIG_PM + u32 reg_kpc; + u32 reg_kprec; +#endif +}; -- cgit v1.2.3 From 1a1cd739a4b985f87c47e2809db7e240dba2c385 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Thu, 31 Jan 2008 00:58:00 -0500 Subject: Input: pxa27x_keypad - remove pin configuration from the driver The pin configurations will slowly be moved to the board specific code at initialization thus to make the driver more generic. Signed-off-by: Eric Miao Signed-off-by: Dmitry Torokhov --- include/asm-arm/arch-pxa/pxa27x_keypad.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/asm-arm/arch-pxa') diff --git a/include/asm-arm/arch-pxa/pxa27x_keypad.h b/include/asm-arm/arch-pxa/pxa27x_keypad.h index f19f74adde0..ef17db6d791 100644 --- a/include/asm-arm/arch-pxa/pxa27x_keypad.h +++ b/include/asm-arm/arch-pxa/pxa27x_keypad.h @@ -4,7 +4,6 @@ struct pxa27x_keypad_platform_data { int nr_rows, nr_cols; int keycodes[PXAKBD_MAXROW][PXAKBD_MAXCOL]; - int gpio_modes[PXAKBD_MAXROW + PXAKBD_MAXCOL]; #ifdef CONFIG_PM u32 reg_kpc; -- cgit v1.2.3 From 1814db69698479eec2c000a43c83b5f263f6fbb6 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Thu, 31 Jan 2008 00:58:37 -0500 Subject: Input: pxa27x_keypad - introduce driver structure and use KEY() to define matrix keys 1. Introduce the "struct pxa27x_keypad" structure for driver specific information, such as "struct clk", generated matrix key codes and so on 2. Use KEY() macro to define matrix keys, instead of original 8x8 map this makes definition easier with keypad where keys are sparse 3. Keep a generated array in "struct pxa27x_keypad" for fast lookup 4. Separate the matrix scan into a dedicated function for readability and report only those keys whose state has been changed, instead of report all states 5. Make use of KPAS to decide the faster path if only one key has been detected Signed-off-by: Eric Miao Signed-off-by: Dmitry Torokhov --- include/asm-arm/arch-pxa/pxa27x_keypad.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'include/asm-arm/arch-pxa') diff --git a/include/asm-arm/arch-pxa/pxa27x_keypad.h b/include/asm-arm/arch-pxa/pxa27x_keypad.h index ef17db6d791..1b1bf9fe6d8 100644 --- a/include/asm-arm/arch-pxa/pxa27x_keypad.h +++ b/include/asm-arm/arch-pxa/pxa27x_keypad.h @@ -1,12 +1,25 @@ -#define PXAKBD_MAXROW 8 -#define PXAKBD_MAXCOL 8 +#ifndef __ASM_ARCH_PXA27x_KEYPAD_H +#define __ASM_ARCH_PXA27x_KEYPAD_H + +#include + +#define MAX_MATRIX_KEY_ROWS (8) +#define MAX_MATRIX_KEY_COLS (8) struct pxa27x_keypad_platform_data { - int nr_rows, nr_cols; - int keycodes[PXAKBD_MAXROW][PXAKBD_MAXCOL]; + + /* code map for the matrix keys */ + unsigned int matrix_key_rows; + unsigned int matrix_key_cols; + unsigned int *matrix_key_map; + int matrix_key_map_size; #ifdef CONFIG_PM u32 reg_kpc; u32 reg_kprec; #endif }; + +#define KEY(row, col, val) (((row) << 28) | ((col) << 24) | (val)) + +#endif /* __ASM_ARCH_PXA27x_KEYPAD_H */ -- cgit v1.2.3 From d7416f9eaa5427f47648973aac3a65e7a0eeda04 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Thu, 31 Jan 2008 00:58:52 -0500 Subject: Input: pxa27x_keypad - introduce pxa27x_keypad_config() Introduce pxa27x_keypad_config() for keypad registers configuration and remove the reg_kpc, reg_kprec from platform data structure so that configurations of keypad registers can be centralized to a single function. It can also be re-used when resuming. Signed-off-by: Eric Miao Signed-off-by: Dmitry Torokhov --- include/asm-arm/arch-pxa/pxa27x_keypad.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include/asm-arm/arch-pxa') diff --git a/include/asm-arm/arch-pxa/pxa27x_keypad.h b/include/asm-arm/arch-pxa/pxa27x_keypad.h index 1b1bf9fe6d8..23f4ebc4102 100644 --- a/include/asm-arm/arch-pxa/pxa27x_keypad.h +++ b/include/asm-arm/arch-pxa/pxa27x_keypad.h @@ -13,11 +13,6 @@ struct pxa27x_keypad_platform_data { unsigned int matrix_key_cols; unsigned int *matrix_key_map; int matrix_key_map_size; - -#ifdef CONFIG_PM - u32 reg_kpc; - u32 reg_kprec; -#endif }; #define KEY(row, col, val) (((row) << 28) | ((col) << 24) | (val)) -- cgit v1.2.3 From 62059d9e912717abbfb875440621d935d091f289 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Thu, 31 Jan 2008 00:59:03 -0500 Subject: Input: pxa27x_keypad - enable rotary encoders and direct keys 1. Rotary encoder events can be configured either as relative events as the legacy code does or as any specified key code, this is useful on some platform which uses the rotary keys as KEY_{UP/DOWN/LEFT/RIGHT} 2. Add support for direct keys, the corresponding keycodes for each direct key can now be specified within the platform data 3. Remove the direct/rotary key detection code from the IRQ handler to dedicated functions to improve readability Signed-off-by: Eric Miao Signed-off-by: Dmitry Torokhov --- include/asm-arm/arch-pxa/pxa27x_keypad.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'include/asm-arm/arch-pxa') diff --git a/include/asm-arm/arch-pxa/pxa27x_keypad.h b/include/asm-arm/arch-pxa/pxa27x_keypad.h index 23f4ebc4102..6b832329ebc 100644 --- a/include/asm-arm/arch-pxa/pxa27x_keypad.h +++ b/include/asm-arm/arch-pxa/pxa27x_keypad.h @@ -6,6 +6,20 @@ #define MAX_MATRIX_KEY_ROWS (8) #define MAX_MATRIX_KEY_COLS (8) +/* pxa3xx keypad platform specific parameters + * + * NOTE: + * 1. direct_key_num indicates the number of keys in the direct keypad + * _plus_ the number of rotary-encoder sensor inputs, this can be + * left as 0 if only rotary encoders are enabled, the driver will + * automatically calculate this + * + * 2. direct_key_map is the key code map for the direct keys, if rotary + * encoder(s) are enabled, direct key 0/1(2/3) will be ignored + * + * 3. rotary can be either interpreted as a relative input event (e.g. + * REL_WHEEL/REL_HWHEEL) or specific keys (e.g. UP/DOWN/LEFT/RIGHT) + */ struct pxa27x_keypad_platform_data { /* code map for the matrix keys */ @@ -13,6 +27,22 @@ struct pxa27x_keypad_platform_data { unsigned int matrix_key_cols; unsigned int *matrix_key_map; int matrix_key_map_size; + + /* direct keys */ + int direct_key_num; + unsigned int direct_key_map[8]; + + /* rotary encoders 0 */ + int enable_rotary0; + int rotary0_rel_code; + int rotary0_up_key; + int rotary0_down_key; + + /* rotary encoders 1 */ + int enable_rotary1; + int rotary1_rel_code; + int rotary1_up_key; + int rotary1_down_key; }; #define KEY(row, col, val) (((row) << 28) | ((col) << 24) | (val)) -- cgit v1.2.3 From 76cb44e1a853f9c438ccf62eb5006f089430da72 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Thu, 31 Jan 2008 00:59:23 -0500 Subject: Input: pxa27x_keypad - add debounce_interval to the keypad platform data Currently, only one debounce_interval is introduced for both direct and matrix keys. This is true in most cases, although the keypad controller supports different debounce for direct/matrix keys. Some platforms do require this to be tuned, instead of the default reset value of 100ms. Rotary encoder will always use zero debounce time for now to achieve certain sensitivity. Signed-off-by: Eric Miao Signed-off-by: Dmitry Torokhov --- include/asm-arm/arch-pxa/pxa27x_keypad.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/asm-arm/arch-pxa') diff --git a/include/asm-arm/arch-pxa/pxa27x_keypad.h b/include/asm-arm/arch-pxa/pxa27x_keypad.h index 6b832329ebc..644f7609b52 100644 --- a/include/asm-arm/arch-pxa/pxa27x_keypad.h +++ b/include/asm-arm/arch-pxa/pxa27x_keypad.h @@ -19,6 +19,9 @@ * * 3. rotary can be either interpreted as a relative input event (e.g. * REL_WHEEL/REL_HWHEEL) or specific keys (e.g. UP/DOWN/LEFT/RIGHT) + * + * 4. matrix key and direct key will use the same debounce_interval by + * default, which should be sufficient in most cases */ struct pxa27x_keypad_platform_data { @@ -43,6 +46,9 @@ struct pxa27x_keypad_platform_data { int rotary1_rel_code; int rotary1_up_key; int rotary1_down_key; + + /* key debounce interval */ + unsigned int debounce_interval; }; #define KEY(row, col, val) (((row) << 28) | ((col) << 24) | (val)) -- cgit v1.2.3