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
This commit is contained in:
Steve Markgraf 2019-08-11 12:39:32 +02:00
parent da7cd7408a
commit a94fc842d3
4 changed files with 27 additions and 8 deletions

View File

@ -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 */
};

View File

@ -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,
};

View File

@ -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);
}

View File

@ -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,