Change in ...osmocom-bb[master]: fw/keypad: Poll Iota powerbutton if required

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Aug 27 12:08:05 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmocom-bb/+/15150 )

Change subject: fw/keypad: Poll Iota powerbutton if required
......................................................................

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
---
M src/target/firmware/board/compal/keymap.h
M src/target/firmware/board/pirelli_dpl10/keymap.h
M src/target/firmware/calypso/keypad.c
M src/target/firmware/include/keypad.h
4 files changed, 27 insertions(+), 8 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/target/firmware/board/compal/keymap.h b/src/target/firmware/board/compal/keymap.h
index ce8f9c2..fe0e303 100644
--- a/src/target/firmware/board/compal/keymap.h
+++ b/src/target/firmware/board/compal/keymap.h
@@ -23,5 +23,6 @@
 	[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 b85621b..b06f17d 100644
--- a/src/target/firmware/board/pirelli_dpl10/keymap.h
+++ b/src/target/firmware/board/pirelli_dpl10/keymap.h
@@ -21,8 +21,9 @@
 	[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 937f8bd..c3c1810 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 at hyte.de>
- * (C) 2013 by Steve Markgraf <steve at steve-m.de>
+ * (C) 2013-19 by Steve Markgraf <steve at steve-m.de>
  *
  * All Rights Reserved
  *
@@ -119,6 +119,15 @@
 	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 @@
 
 	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 @@
 		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 @@
 		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 9e9acfe..2ad9889 100644
--- a/src/target/firmware/include/keypad.h
+++ b/src/target/firmware/include/keypad.h
@@ -25,11 +25,11 @@
 	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,

-- 
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/15150
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I904baf40d621bd680b602b88d12ff462b3c17596
Gerrit-Change-Number: 15150
Gerrit-PatchSet: 1
Gerrit-Owner: steve-m <steve at steve-m.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190827/07246850/attachment.htm>


More information about the gerrit-log mailing list