diff options
author | Steve Markgraf <steve@steve-m.de> | 2019-08-11 12:39:32 +0200 |
---|---|---|
committer | Steve Markgraf <steve@steve-m.de> | 2019-08-11 13:33:29 +0200 |
commit | a94fc842d33267f0e0e64c117e98a81ac3ae653a (patch) | |
tree | 6900c900e061dd619e0fdfc484f5b5c3ec687b69 /src/target/firmware | |
parent | da7cd7408a7230ea474353b54b889ae877354326 (diff) |
fw/keypad: Poll Iota powerbutton if required
This commit adds polling of the TWL3025 PWON
signal. If the powerbutton is pressed on targets
that use it (Pirelli DP-L10, Huawei GTM900-B),
a normal keypad scanning cycle is started in order
to preserve the timing, required for the 500ms
power off press duration for example.
Change-Id: I904baf40d621bd680b602b88d12ff462b3c17596
Diffstat (limited to 'src/target/firmware')
-rw-r--r-- | src/target/firmware/board/compal/keymap.h | 3 | ||||
-rw-r--r-- | src/target/firmware/board/pirelli_dpl10/keymap.h | 5 | ||||
-rw-r--r-- | src/target/firmware/calypso/keypad.c | 23 | ||||
-rw-r--r-- | src/target/firmware/include/keypad.h | 4 |
4 files changed, 27 insertions, 8 deletions
diff --git a/src/target/firmware/board/compal/keymap.h b/src/target/firmware/board/compal/keymap.h index ce8f9c24..fe0e3039 100644 --- a/src/target/firmware/board/compal/keymap.h +++ b/src/target/firmware/board/compal/keymap.h @@ -23,5 +23,6 @@ static const uint8_t keymap[] = { [KEY_OK] = 0, [KEY_POWER] = 24, [KEY_MINUS] = 30, /* not existent */ - [KEY_PLUS] = 31, /* not existent */ + [KEY_PLUS] = 30, /* not existent */ + [KEY_CAMERA] = 30, /* not existent */ }; diff --git a/src/target/firmware/board/pirelli_dpl10/keymap.h b/src/target/firmware/board/pirelli_dpl10/keymap.h index b85621bd..b06f17d3 100644 --- a/src/target/firmware/board/pirelli_dpl10/keymap.h +++ b/src/target/firmware/board/pirelli_dpl10/keymap.h @@ -21,8 +21,9 @@ static const uint8_t keymap[] = { [KEY_LEFT] = 5, [KEY_RIGHT] = 10, [KEY_OK] = 11, -/* power button is not connected, we use the camera button instead */ - [KEY_POWER] = 23, +/* power button is not connected to keypad scan matrix but to TWL3025 */ + [KEY_POWER] = 31, [KEY_MINUS] = 22, [KEY_PLUS] = 21, + [KEY_CAMERA] = 23, }; diff --git a/src/target/firmware/calypso/keypad.c b/src/target/firmware/calypso/keypad.c index 937f8bd8..c3c1810b 100644 --- a/src/target/firmware/calypso/keypad.c +++ b/src/target/firmware/calypso/keypad.c @@ -1,7 +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> + * (C) 2013-19 by Steve Markgraf <steve@steve-m.de> * * All Rights Reserved * @@ -119,6 +119,15 @@ void keypad_poll() static uint16_t reg; static uint16_t col; static uint32_t buttons = 0, debounce1 = 0, debounce2 = 0; + uint8_t use_iota_pwrbtn = (btn_map[KEY_POWER] == 31); + uint32_t pwr_mask = (1 << btn_map[KEY_POWER]); + + /* only read Iota powerbutton if it was not yet pressed */ + if (use_iota_pwrbtn && !(buttons & pwr_mask) && twl3025_get_pwon()) { + buttons |= pwr_mask; + if (!polling) + polling = 1; + } if (with_interrupts && !polling) return; @@ -154,7 +163,6 @@ void keypad_poll() col++; if (col > 5) { - uint32_t pwr_mask = (1 << btn_map[KEY_POWER]); col = 0; /* if power button, ignore other states */ if (buttons & pwr_mask) @@ -162,6 +170,16 @@ void keypad_poll() else if (lastbuttons & pwr_mask) buttons = lastbuttons & ~pwr_mask; dispatch_buttons(buttons); + + /* check if powerbutton connected to Iota was released */ + if (use_iota_pwrbtn && (buttons & pwr_mask) && !twl3025_get_pwon()) { + buttons &= ~pwr_mask; + + /* dispatch buttons again so we do not loose + * very short powerbutton presses */ + dispatch_buttons(buttons); + } + if (buttons == 0) { writew(0x0, KBC_REG); polling = 3; @@ -172,5 +190,4 @@ void keypad_poll() 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 9e9acfe9..2ad9889a 100644 --- a/src/target/firmware/include/keypad.h +++ b/src/target/firmware/include/keypad.h @@ -25,11 +25,11 @@ enum key_codes { KEY_POWER, //red on-hook KEY_MINUS, KEY_PLUS, + KEY_CAMERA, + BUTTON_CNT, KEY_INV = 0xFF }; -#define BUTTON_CNT 23 - enum key_states { PRESSED, RELEASED, |