summaryrefslogtreecommitdiff
path: root/board/freescale/common/recovery.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/freescale/common/recovery.c')
-rw-r--r--board/freescale/common/recovery.c55
1 files changed, 37 insertions, 18 deletions
diff --git a/board/freescale/common/recovery.c b/board/freescale/common/recovery.c
index df3f367..5704e09 100644
--- a/board/freescale/common/recovery.c
+++ b/board/freescale/common/recovery.c
@@ -25,6 +25,7 @@
#include <mxc_keyb.h>
#endif
+extern int check_powerkey_pressed(void);
extern int check_recovery_cmd_file(void);
extern enum boot_device get_boot_device(void);
@@ -41,31 +42,49 @@ inline int test_key(int value, struct kpp_key_info *ki)
int check_key_pressing(void)
{
- struct kpp_key_info *key_info;
+ struct kpp_key_info *key_info = NULL;
int state = 0, keys, i;
+ int ret = 0;
+
mxc_kpp_init();
+ /* due to glitch suppression circuit,
+ wait sometime to let all keys scanned. */
+ udelay(1000);
+ keys = mxc_kpp_getc(&key_info);
+ if (!check_powerkey_pressed())
+ keys = 0;
+
+#ifdef CONFIG_MX6SL_EVK
+ /* For mx6sl-evk, hold power+vol_down when boot
+ will enter recovery mode */
+ printf("Detecting VOL_DOWN+POWER key for recovery(%d:%d) ...\n",
+ keys, keys ? key_info->val : 0);
+ if (keys > 0) {
+ for (i = 0; i < keys; i++) {
+ if (test_key(CONFIG_VOL_DOWN_KEY, &key_info[i])) {
+ ret = 1;
+ break;
+ }
+ }
+ }
+#else
puts("Detecting HOME+POWER key for recovery ...\n");
-
- /* Check for home + power */
- keys = mxc_kpp_getc(&key_info);
- if (keys < 2)
- return 0;
-
- for (i = 0; i < keys; i++) {
- if (test_key(CONFIG_POWER_KEY, &key_info[i]))
- state |= PRESSED_HOME;
- else if (test_key(CONFIG_HOME_KEY, &key_info[i]))
- state |= PRESSED_POWER;
+ if (keys > 1) {
+ for (i = 0; i < keys; i++) {
+ if (test_key(CONFIG_POWER_KEY, &key_info[i]))
+ state |= PRESSED_HOME;
+ else if (test_key(CONFIG_HOME_KEY, &key_info[i]))
+ state |= PRESSED_POWER;
+ }
}
-
- free(key_info);
-
if ((state & RECOVERY_KEY_MASK) == RECOVERY_KEY_MASK)
- return 1;
-
- return 0;
+ ret = 1;
+#endif
+ if (key_info)
+ free(key_info);
+ return ret;
}
#else
/* If not using mxc keypad, currently we will detect power key on board */