diff options
Diffstat (limited to 'src/target/firmware')
-rw-r--r-- | src/target/firmware/board/compal/keymap.h | 27 | ||||
-rw-r--r-- | src/target/firmware/board/compal_e86/init.c | 3 | ||||
-rwxr-xr-x | src/target/firmware/board/compal_e88/init.c | 3 | ||||
-rw-r--r-- | src/target/firmware/board/compal_e99/init.c | 3 | ||||
-rw-r--r-- | src/target/firmware/board/gta0x/init.c | 3 | ||||
-rw-r--r-- | src/target/firmware/board/pirelli_dpl10/init.c | 3 | ||||
-rw-r--r-- | src/target/firmware/board/pirelli_dpl10/keymap.h | 28 | ||||
-rw-r--r-- | src/target/firmware/board/se_j100/init.c | 3 | ||||
-rw-r--r-- | src/target/firmware/calypso/keypad.c | 67 | ||||
-rw-r--r-- | src/target/firmware/include/keypad.h | 30 |
10 files changed, 90 insertions, 80 deletions
diff --git a/src/target/firmware/board/compal/keymap.h b/src/target/firmware/board/compal/keymap.h new file mode 100644 index 00000000..ce8f9c24 --- /dev/null +++ b/src/target/firmware/board/compal/keymap.h @@ -0,0 +1,27 @@ +/* keymap for the Compal C1xx phones */ + +static const uint8_t keymap[] = { + [KEY_0] = 13, + [KEY_1] = 15, + [KEY_2] = 10, + [KEY_3] = 5, + [KEY_4] = 16, + [KEY_5] = 11, + [KEY_6] = 6, + [KEY_7] = 17, + [KEY_8] = 12, + [KEY_9] = 7, + [KEY_STAR] = 18, + [KEY_HASH] = 8, + [KEY_MENU] = 14, + [KEY_LEFT_SB] = 19, + [KEY_RIGHT_SB] = 9, + [KEY_UP] = 1, + [KEY_DOWN] = 2, + [KEY_LEFT] = 3, + [KEY_RIGHT] = 4, + [KEY_OK] = 0, + [KEY_POWER] = 24, + [KEY_MINUS] = 30, /* not existent */ + [KEY_PLUS] = 31, /* not existent */ +}; diff --git a/src/target/firmware/board/compal_e86/init.c b/src/target/firmware/board/compal_e86/init.c index 336eb43b..fed9f85a 100644 --- a/src/target/firmware/board/compal_e86/init.c +++ b/src/target/firmware/board/compal_e86/init.c @@ -47,6 +47,7 @@ #include <rf/trf6151.h> #include <fb/framebuffer.h> +#include "../compal/keymap.h" #define ARMIO_LATCH_OUT 0xfffe4802 #define IO_CNTL_REG 0xfffe4804 @@ -138,7 +139,7 @@ void board_init(int with_irq) bl_level(0); /* Initialize keypad driver */ - keypad_init(with_irq); + keypad_init(keymap, with_irq); /* Initialize ABB driver (uses SPI) */ twl3025_init(); diff --git a/src/target/firmware/board/compal_e88/init.c b/src/target/firmware/board/compal_e88/init.c index 21a23a16..04ae4588 100755 --- a/src/target/firmware/board/compal_e88/init.c +++ b/src/target/firmware/board/compal_e88/init.c @@ -46,6 +46,7 @@ #include <rf/trf6151.h> #include <fb/framebuffer.h> #include <battery/compal_e88.h> +#include "../compal/keymap.h" #define ARMIO_LATCH_OUT 0xfffe4802 #define IO_CNTL_REG 0xfffe4804 @@ -134,7 +135,7 @@ void board_init(int with_irq) bl_level(50); /* Initialize keypad driver */ - keypad_init(with_irq); + keypad_init(keymap, with_irq); /* Initialize ABB driver (uses SPI) */ twl3025_init(); diff --git a/src/target/firmware/board/compal_e99/init.c b/src/target/firmware/board/compal_e99/init.c index cb8d3217..7cc3c67d 100644 --- a/src/target/firmware/board/compal_e99/init.c +++ b/src/target/firmware/board/compal_e99/init.c @@ -47,6 +47,7 @@ #include <rf/trf6151.h> #include <fb/framebuffer.h> +#include "../compal/keymap.h" #define ARMIO_LATCH_OUT 0xfffe4802 #define IO_CNTL_REG 0xfffe4804 @@ -139,7 +140,7 @@ void board_init(int with_irq) fb_init(); /* Initialize keypad driver */ - keypad_init(with_irq); + keypad_init(keymap, with_irq); /* Initialize ABB driver (uses SPI) */ twl3025_init(); diff --git a/src/target/firmware/board/gta0x/init.c b/src/target/firmware/board/gta0x/init.c index 8b907e3c..4f49e802 100644 --- a/src/target/firmware/board/gta0x/init.c +++ b/src/target/firmware/board/gta0x/init.c @@ -44,6 +44,7 @@ #include <abb/twl3025.h> #include <rf/trf6151.h> +#include "../compal/keymap.h" #define ARMIO_LATCH_OUT 0xfffe4802 #define IO_CNTL_REG 0xfffe4804 @@ -130,7 +131,7 @@ void board_init(int with_irq) bl_level(50); /* Initialize keypad driver */ - keypad_init(with_irq); + keypad_init(keymap, with_irq); /* Initialize ABB driver (uses SPI) */ twl3025_init(); diff --git a/src/target/firmware/board/pirelli_dpl10/init.c b/src/target/firmware/board/pirelli_dpl10/init.c index d822b80c..ea62f090 100644 --- a/src/target/firmware/board/pirelli_dpl10/init.c +++ b/src/target/firmware/board/pirelli_dpl10/init.c @@ -47,6 +47,7 @@ #include <rf/trf6151.h> #include <fb/framebuffer.h> +#include "keymap.h" #define ARMIO_LATCH_OUT 0xfffe4802 #define IO_CNTL_REG 0xfffe4804 @@ -142,7 +143,7 @@ void board_init(int with_irq) fb_init(); /* Initialize keypad driver */ - keypad_init(with_irq); + keypad_init(keymap, with_irq); /* Initialize ABB driver (uses SPI) */ twl3025_init(); diff --git a/src/target/firmware/board/pirelli_dpl10/keymap.h b/src/target/firmware/board/pirelli_dpl10/keymap.h new file mode 100644 index 00000000..b85621bd --- /dev/null +++ b/src/target/firmware/board/pirelli_dpl10/keymap.h @@ -0,0 +1,28 @@ +/* keymap for the Pirelli DP-L10 */ + +static const uint8_t keymap[] = { + [KEY_0] = 18, + [KEY_1] = 4, + [KEY_2] = 3, + [KEY_3] = 2, + [KEY_4] = 9, + [KEY_5] = 8, + [KEY_6] = 7, + [KEY_7] = 14, + [KEY_8] = 13, + [KEY_9] = 12, + [KEY_STAR] = 19, + [KEY_HASH] = 17, + [KEY_MENU] = 0, + [KEY_LEFT_SB] = 1, + [KEY_RIGHT_SB] = 6, + [KEY_UP] = 15, + [KEY_DOWN] = 16, + [KEY_LEFT] = 5, + [KEY_RIGHT] = 10, + [KEY_OK] = 11, +/* power button is not connected, we use the camera button instead */ + [KEY_POWER] = 23, + [KEY_MINUS] = 22, + [KEY_PLUS] = 21, +}; diff --git a/src/target/firmware/board/se_j100/init.c b/src/target/firmware/board/se_j100/init.c index 402684b0..0ae477a4 100644 --- a/src/target/firmware/board/se_j100/init.c +++ b/src/target/firmware/board/se_j100/init.c @@ -47,6 +47,7 @@ #include <rf/trf6151.h> #include <fb/framebuffer.h> +#include "../compal/keymap.h" #define ARMIO_LATCH_OUT 0xfffe4802 #define IO_CNTL_REG 0xfffe4804 @@ -138,7 +139,7 @@ void board_init(int with_irq) bl_level(50); /* Initialize keypad driver */ - keypad_init(with_irq); + keypad_init(keymap, with_irq); /* Initialize ABB driver (uses SPI) */ twl3025_init(); diff --git a/src/target/firmware/calypso/keypad.c b/src/target/firmware/calypso/keypad.c index f2dea9df..937f8bd8 100644 --- a/src/target/firmware/calypso/keypad.c +++ b/src/target/firmware/calypso/keypad.c @@ -1,6 +1,7 @@ /* Driver for the keypad attached to the TI Calypso */ /* (C) 2010 by roh <roh@hyte.de> + * (C) 2013 by Steve Markgraf <steve@steve-m.de> * * All Rights Reserved * @@ -33,7 +34,6 @@ #include <abb/twl3025.h> #include <comm/timer.h> - #define KBR_LATCH_REG 0xfffe480a #define KBC_REG 0xfffe480c #define KBD_GPIO_INT 0xfffe4816 @@ -51,23 +51,17 @@ void emit_key(uint8_t key, uint8_t state) } volatile uint32_t lastbuttons = 0; +static const uint8_t *btn_map; unsigned long power_hold = 0; -#define BTN_TO_KEY(name) \ - ((diff & BTN_##name) == BTN_##name) \ - { \ - key = KEY_##name; \ - diff = diff & ~BTN_##name; \ - state = (buttons & BTN_##name) ? PRESSED : RELEASED; \ - } - void dispatch_buttons(uint32_t buttons) { + int i; uint8_t state; - if ((buttons & BTN_POWER)) { + if ((buttons & (1 << btn_map[KEY_POWER]))) { /* hold button 500ms to shut down */ - if ((lastbuttons & BTN_POWER)) { + if ((lastbuttons & (1 << btn_map[KEY_POWER]))) { unsigned long elapsed = jiffies - power_hold; if (elapsed > 50) twl3025_power_off(); @@ -80,37 +74,11 @@ void dispatch_buttons(uint32_t buttons) return; uint32_t diff = buttons ^ lastbuttons; - uint8_t key=KEY_INV; - - while (diff != 0) - { - if BTN_TO_KEY(POWER) - else if BTN_TO_KEY(0) - else if BTN_TO_KEY(1) - else if BTN_TO_KEY(2) - else if BTN_TO_KEY(3) - else if BTN_TO_KEY(4) - else if BTN_TO_KEY(5) - else if BTN_TO_KEY(6) - else if BTN_TO_KEY(7) - else if BTN_TO_KEY(8) - else if BTN_TO_KEY(9) - else if BTN_TO_KEY(STAR) - else if BTN_TO_KEY(HASH) - else if BTN_TO_KEY(MENU) - else if BTN_TO_KEY(LEFT_SB) - else if BTN_TO_KEY(RIGHT_SB) - else if BTN_TO_KEY(UP) - else if BTN_TO_KEY(DOWN) - else if BTN_TO_KEY(LEFT) - else if BTN_TO_KEY(RIGHT) - else if BTN_TO_KEY(OK) - else - { - printf("\nunknown keycode: 0x%08x\n", diff); - break; + for (i = 0; i < BUTTON_CNT; i++) { + if (diff & (1 << btn_map[i])) { + state = (buttons & (1 << btn_map[i])) ? PRESSED : RELEASED; + emit_key(i, state); } - emit_key(key, state); } lastbuttons = buttons; } @@ -125,8 +93,9 @@ static void keypad_irq(__unused enum irq_nr nr) irq_disable(IRQ_KEYPAD_GPIO); } -void keypad_init(uint8_t interrupts) +void keypad_init(const uint8_t *keymap, uint8_t interrupts) { + btn_map = keymap; lastbuttons = 0; polling = 0; writew(0, KBD_GPIO_MASKIT); @@ -184,13 +153,14 @@ void keypad_poll() } col++; - if (col > 4) { + if (col > 5) { + uint32_t pwr_mask = (1 << btn_map[KEY_POWER]); col = 0; /* if power button, ignore other states */ - if (buttons & BTN_POWER) - buttons = lastbuttons | BTN_POWER; - else if (lastbuttons & BTN_POWER) - buttons = lastbuttons & ~BTN_POWER; + if (buttons & pwr_mask) + buttons = lastbuttons | pwr_mask; + else if (lastbuttons & pwr_mask) + buttons = lastbuttons & ~pwr_mask; dispatch_buttons(buttons); if (buttons == 0) { writew(0x0, KBC_REG); @@ -198,10 +168,9 @@ void keypad_poll() return; } } - if (col == 4) + if (col == 5) writew(0xff, KBC_REG); else writew(0x1f & ~(0x1 << col ), KBC_REG); } - diff --git a/src/target/firmware/include/keypad.h b/src/target/firmware/include/keypad.h index e2e6519f..9e9acfe9 100644 --- a/src/target/firmware/include/keypad.h +++ b/src/target/firmware/include/keypad.h @@ -1,30 +1,6 @@ #ifndef _KEYPAD_H #define _KEYPAD_H -enum buttons { - BTN_0 = 0x00002000, - BTN_1 = 0x00008000, - BTN_2 = 0x00000400, - BTN_3 = 0x00000020, - BTN_4 = 0x00010000, - BTN_5 = 0x00000800, - BTN_6 = 0x00000040, - BTN_7 = 0x00020000, - BTN_8 = 0x00001000, - BTN_9 = 0x00000080, - BTN_STAR = 0x00040000, - BTN_HASH = 0x00000100, - BTN_MENU = 0x00004000, - BTN_LEFT_SB = 0x00080000, - BTN_RIGHT_SB = 0x00000200, - BTN_UP = 0x00000002, - BTN_DOWN = 0x00000004, - BTN_LEFT = 0x00000008, - BTN_RIGHT = 0x00000010, - BTN_OK = 0x00000001, - BTN_POWER = 0x01000000, -}; - enum key_codes { KEY_0 = 0, KEY_1, @@ -47,15 +23,19 @@ enum key_codes { KEY_RIGHT, KEY_OK, //green off-hook KEY_POWER, //red on-hook + KEY_MINUS, + KEY_PLUS, KEY_INV = 0xFF }; +#define BUTTON_CNT 23 + enum key_states { PRESSED, RELEASED, }; -void keypad_init(uint8_t interrupts); +void keypad_init(const uint8_t *keymap, uint8_t interrupts); void keypad_poll(); |