diff options
author | Xinyu Chen <xinyu.chen@freescale.com> | 2010-09-10 17:17:12 +0800 |
---|---|---|
committer | Xinyu Chen <xinyu.chen@freescale.com> | 2010-09-10 17:23:18 +0800 |
commit | daae245a544d8b23dfa74c6108c35cebef81b8e7 (patch) | |
tree | a35f6e1eb2b46e6a7431d4f071ebe5299917d093 /board/freescale/mx51_bbg | |
parent | 7bbe5d7a5203a07496ec372ab55563a2e230d03e (diff) | |
download | u-boot-imx-daae245a544d8b23dfa74c6108c35cebef81b8e7.zip u-boot-imx-daae245a544d8b23dfa74c6108c35cebef81b8e7.tar.gz u-boot-imx-daae245a544d8b23dfa74c6108c35cebef81b8e7.tar.bz2 |
ENGR00127368 UBOOT: Make the android recovery code common for platformsrel_imx_2.6.31_10.09.00
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 <xinyu.chen@freescale.com>
Diffstat (limited to 'board/freescale/mx51_bbg')
-rw-r--r-- | board/freescale/mx51_bbg/mx51_bbg.c | 156 |
1 files changed, 19 insertions, 137 deletions
diff --git a/board/freescale/mx51_bbg/mx51_bbg.c b/board/freescale/mx51_bbg/mx51_bbg.c index 30fed3d..83e8ca7 100644 --- a/board/freescale/mx51_bbg/mx51_bbg.c +++ b/board/freescale/mx51_bbg/mx51_bbg.c @@ -52,8 +52,8 @@ #include <asm/imx_iim.h> #endif -#ifdef CONFIG_FSL_ANDROID -#include <mxc_keyb.h> +#ifdef CONFIG_ANDROID_RECOVERY +#include "../common/recovery.h" #include <part.h> #include <ext2fs.h> #include <linux/mtd/mtd.h> @@ -873,131 +873,23 @@ int board_init(void) return 0; } -#ifdef BOARD_LATE_INIT -#if defined(CONFIG_FSL_ANDROID) && defined(CONFIG_MXC_KPD) -inline int waiting_for_func_key_pressing(void) -{ - struct kpp_key_info key_info = {0, 0}; - int switch_delay = CONFIG_ANDROID_BOOTMOD_DELAY; - int state = 0, boot_mode_switch = 0; - - mxc_kpp_init(); - - puts("Press home + power to enter recovery mode ...\n"); - - while ((switch_delay > 0) && (!boot_mode_switch)) { - int i; - - --switch_delay; - /* delay 100 * 10ms */ - for (i = 0; !boot_mode_switch && i < 100; ++i) { - /* A state machine to scan home + power key */ - /* Check for home + power */ - if (mxc_kpp_getc(&key_info)) { - switch (state) { - case 0: - /* First press */ - if (TEST_HOME_KEY_DEPRESS(key_info.val, key_info.evt)) { - /* Press Home */ - state = 1; - } else if (TEST_POWER_KEY_DEPRESS(key_info.val, key_info.evt)) { - /* Press Power */ - state = 2; - } else { - state = 0; - } - break; - case 1: - /* Home is already pressed, try to detect Power */ - if (TEST_POWER_KEY_DEPRESS(key_info.val, - key_info.evt)) { - /* Switch */ - boot_mode_switch = 1; - } else { - if (TEST_HOME_KEY_DEPRESS(key_info.val, - key_info.evt)) { - /* Not switch */ - state = 2; - } else - state = 0; - } - break; - case 2: - /* Power is already pressed, try to detect Home */ - if (TEST_HOME_KEY_DEPRESS(key_info.val, - key_info.evt)) { - /* Switch */ - boot_mode_switch = 1; - } else { - if (TEST_POWER_KEY_DEPRESS(key_info.val, - key_info.evt)) { - /* Not switch */ - state = 1; - } else - state = 0; - } - break; - default: - break; - } - - if (1 == boot_mode_switch) - return 1; - } - } - for (i = 0; i < 100; ++i) - udelay(10000); - } - - return 0; -} - -inline int switch_to_recovery_mode(void) -{ - char *env = NULL; - char *boot_args = NULL; - char *boot_cmd = NULL; - - printf("Boot mode switched to recovery mode!\n"); - - switch (get_boot_device()) { - case MMC_BOOT: - boot_args = CONFIG_ANDROID_RECOVERY_BOOTARGS_MMC; - boot_cmd = CONFIG_ANDROID_RECOVERY_BOOTCMD_MMC; - break; - case NAND_BOOT: - printf("Recovery mode not supported in NAND boot\n"); - return -1; - break; - case SPI_NOR_BOOT: - printf("Recovery mode not supported in SPI NOR boot\n"); - return -1; - break; - case UNKNOWN_BOOT: - default: - printf("Unknown boot device!\n"); - return -1; - break; - } - - env = getenv("bootargs_android_recovery"); - /* Set env to recovery mode */ - if (!env) - setenv("bootargs_android", boot_args); - else - setenv("bootargs_android", env); - - env = getenv("bootcmd_android_recovery"); - if (!env) - setenv("bootcmd_android", boot_cmd); - else - setenv("bootcmd_android", env); - setenv("bootcmd", "run bootcmd_android"); - - return 0; -} +#ifdef CONFIG_ANDROID_RECOVERY +struct reco_envs supported_reco_envs[END_BOOT] = { + { + .cmd = NULL, + .args = NULL, + }, + { + .cmd = NULL, + .args = NULL, + }, + { + .cmd = CONFIG_ANDROID_RECOVERY_BOOTCMD_MMC, + .args = CONFIG_ANDROID_RECOVERY_BOOTARGS_MMC, + }, +}; -inline int check_recovery_cmd_file(void) +int check_recovery_cmd_file(void) { disk_partition_t info; ulong part_length; @@ -1064,6 +956,7 @@ inline int check_recovery_cmd_file(void) } #endif +#ifdef BOARD_LATE_INIT int board_late_init(void) { #ifdef CONFIG_I2C_MXC @@ -1076,17 +969,6 @@ int board_late_init(void) setup_core_voltage_spi(); #endif -#if defined(CONFIG_FSL_ANDROID) && defined(CONFIG_MXC_KPD) - if (waiting_for_func_key_pressing()) - switch_to_recovery_mode(); - else { - if (check_recovery_cmd_file()) { - puts("Recovery command file founded!\n"); - switch_to_recovery_mode(); - } - } -#endif - return 0; } #endif |