From daae245a544d8b23dfa74c6108c35cebef81b8e7 Mon Sep 17 00:00:00 2001 From: Xinyu Chen Date: Fri, 10 Sep 2010 17:17:12 +0800 Subject: ENGR00127368 UBOOT: Make the android recovery code common for platforms Move the android recovery codes into common/recovery.c. Cut the keypad detecting time. Now we only need detect there's POWER and HOME key pressing at the time scanning keyboard matrix. So user must hold these two keys when bootup to enter recovery mode. This can reduce the uboot boot time with recovery mode configured. Later /cache file checking for recovery command should be merged into the common/recovery.c Signed-off-by: Xinyu Chen --- drivers/input/mxc_keyb.c | 64 +++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 31 deletions(-) (limited to 'drivers') diff --git a/drivers/input/mxc_keyb.c b/drivers/input/mxc_keyb.c index ec65ab5..fae3b69 100644 --- a/drivers/input/mxc_keyb.c +++ b/drivers/input/mxc_keyb.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved. */ /* @@ -326,33 +326,40 @@ static int mxc_kpp_reset(void) return 0; } -int mxc_kpp_getc(struct kpp_key_info *key_info) +int mxc_kpp_getc(struct kpp_key_info **key_info) { int col, row; - static int key_cnt; + int key_cnt; unsigned short reg_val; short scancode = 0; + int index = 0; + struct kpp_key_info *keyi; reg_val = __raw_readw(KPSR); - if (!key_cnt) { - if (reg_val & KBD_STAT_KPKD) { - /* - * Disable key press(KDIE status bit) interrupt - */ - reg_val &= ~KBD_STAT_KDIE; - __raw_writew(reg_val, KPSR); + if (reg_val & KBD_STAT_KPKD) { + /* + * Disable key press(KDIE status bit) interrupt + */ + reg_val &= ~KBD_STAT_KDIE; + __raw_writew(reg_val, KPSR); #ifdef KPP_DEBUG - mxc_kpp_dump_regs(); + mxc_kpp_dump_regs(); #endif - key_cnt = mxc_kpp_scan_matrix(); - } else { - return 0; - } + key_cnt = mxc_kpp_scan_matrix(); + } else { + return 0; } + if (key_cnt <= 0) + return 0; + + *key_info = keyi = + (struct kpp_key_info *)malloc + (sizeof(struct kpp_key_info) * key_cnt); + /* * This switch case statement is the * implementation of state machine of debounc @@ -399,15 +406,16 @@ int mxc_kpp_getc(struct kpp_key_info *key_info) scancode = press_scancode[row][col]; - key_info->val = mxckpd_keycodes[scancode]; - key_info->evt = KDepress; + keyi[index].val = mxckpd_keycodes[scancode]; + keyi[index++].evt = KDepress; KPP_PRINTF("KStateFirstDown: scan=%d val=%d\n", scancode, mxckpd_keycodes[scancode]); + if (index >= key_cnt) + goto key_detect; + kpp_dev.iKeyState = KStateDown; press_scancode[row][col] = -1; - - goto key_detect; } } } @@ -420,29 +428,23 @@ int mxc_kpp_getc(struct kpp_key_info *key_info) scancode = scancode - MXC_KEYRELEASE; - key_info->val = mxckpd_keycodes[scancode]; - key_info->evt = KRelease; + keyi[index].val = mxckpd_keycodes[scancode]; + keyi[index++].evt = KRelease; KPP_PRINTF("KStateFirstUp: scan=%d val=%d\n", scancode, mxckpd_keycodes[scancode]); + if (index >= key_cnt) + goto key_detect; kpp_dev.iKeyState = KStateUp; release_scancode[row][col] = -1; - - goto key_detect; } } } - return 0; - key_detect: - /* udelay(KScanRate); */ - key_cnt = mxc_kpp_scan_matrix(); - - if (0 == key_cnt) - mxc_kpp_reset(); - return 1; + mxc_kpp_reset(); + return key_cnt; } /*! -- cgit v1.1