diff options
author | LiGang <b41990@freescale.com> | 2012-10-30 13:47:15 +0800 |
---|---|---|
committer | LiGang <b41990@freescale.com> | 2012-10-30 13:47:15 +0800 |
commit | 07a5dceee3891fd56d82f98d9b3547f16d36e2f6 (patch) | |
tree | 054d018b15fcad2714997cd19c2a84a915532fce /board | |
parent | a7decba6225c7691919ad5798627c970f447da14 (diff) | |
download | u-boot-imx-07a5dceee3891fd56d82f98d9b3547f16d36e2f6.zip u-boot-imx-07a5dceee3891fd56d82f98d9b3547f16d36e2f6.tar.gz u-boot-imx-07a5dceee3891fd56d82f98d9b3547f16d36e2f6.tar.bz2 |
ENGR00230967 Enable recovery mode by keys when boot
1. Add matrix key support
2. Add recovery mode support by pressing power key and volume down key
when boot
SW10 on MX6SL-EVK board configed as volume down key.
SW1 on MX6SL-EVK board configed as power key
Signed-off-by: LiGang <b41990@freescale.com>
Diffstat (limited to 'board')
-rw-r--r-- | board/freescale/common/recovery.c | 55 | ||||
-rw-r--r-- | board/freescale/mx6sl_evk/mx6sl_evk.c | 31 |
2 files changed, 68 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 */ diff --git a/board/freescale/mx6sl_evk/mx6sl_evk.c b/board/freescale/mx6sl_evk/mx6sl_evk.c index 45d5dd2..3570601 100644 --- a/board/freescale/mx6sl_evk/mx6sl_evk.c +++ b/board/freescale/mx6sl_evk/mx6sl_evk.c @@ -69,6 +69,8 @@ static enum boot_device boot_dev; #define USB_OTG_PWR IMX_GPIO_NR(4, 0) #define USB_H1_PWR IMX_GPIO_NR(4, 2) +#define GPIO_POWER_KEY IMX_GPIO_NR(3, 18) + static inline void setup_boot_device(void) { @@ -993,6 +995,35 @@ static int setup_pmic_voltages(void) } #endif +#ifdef CONFIG_MXC_KPD +int setup_mxc_kpd(void) +{ + mxc_iomux_v3_setup_pad(MX6SL_PAD_KEY_COL0__KPP_COL_0); + mxc_iomux_v3_setup_pad(MX6SL_PAD_KEY_COL1__KPP_COL_1); + mxc_iomux_v3_setup_pad(MX6SL_PAD_KEY_COL2__KPP_COL_2); + mxc_iomux_v3_setup_pad(MX6SL_PAD_KEY_COL3__KPP_COL_3); + + mxc_iomux_v3_setup_pad(MX6SL_PAD_KEY_ROW0__KPP_ROW_0); + mxc_iomux_v3_setup_pad(MX6SL_PAD_KEY_ROW1__KPP_ROW_1); + mxc_iomux_v3_setup_pad(MX6SL_PAD_KEY_ROW2__KPP_ROW_2); + mxc_iomux_v3_setup_pad(MX6SL_PAD_KEY_ROW3__KPP_ROW_3); + + return 0; +} + +int check_powerkey_pressed(void) +{ + mxc_iomux_v3_setup_pad(MX6SL_PAD_WDOG_B__GPIO_3_18); + gpio_direction_input(GPIO_POWER_KEY); + udelay(5); + if (gpio_get_value(GPIO_POWER_KEY) == 0) + return 1; + return 0; +} + +#endif + + int board_init(void) { mxc_iomux_v3_init((void *)IOMUXC_BASE_ADDR); |