summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorTerry Lv <r65388@freescale.com>2010-09-15 22:29:07 +0800
committerTerry Lv <r65388@freescale.com>2010-09-20 13:25:43 +0800
commit71ba5d33991342c566b92961b5c98e99861e20c0 (patch)
treeea4f11cddc74960823c08a2811c92ba48bd3b038 /board
parent6537dffd192344d8c786a037bce9f41db5448fc9 (diff)
downloadu-boot-imx-71ba5d33991342c566b92961b5c98e99861e20c0.zip
u-boot-imx-71ba5d33991342c566b92961b5c98e99861e20c0.tar.gz
u-boot-imx-71ba5d33991342c566b92961b5c98e99861e20c0.tar.bz2
ENGR00131578: Add android recovery mode support for mx53
Add android recovery mode support for mx53. Signed-off-by: Terry Lv <r65388@freescale.com>
Diffstat (limited to 'board')
-rw-r--r--board/freescale/common/recovery.c32
-rw-r--r--board/freescale/mx51_3stack/mx51_3stack.c5
-rw-r--r--board/freescale/mx51_bbg/mx51_bbg.c3
-rw-r--r--board/freescale/mx53_evk/mx53_evk.c151
4 files changed, 173 insertions, 18 deletions
diff --git a/board/freescale/common/recovery.c b/board/freescale/common/recovery.c
index d133a9d..9f488b8 100644
--- a/board/freescale/common/recovery.c
+++ b/board/freescale/common/recovery.c
@@ -11,19 +11,19 @@
#include <common.h>
#include <malloc.h>
#include "recovery.h"
-
-#ifndef CONFIG_MXC_KPD
-#error "error! keypad must be configured to support recovery"
-#endif
+#ifdef CONFIG_MXC_KPD
#include <mxc_keyb.h>
+#endif
+
+extern int check_recovery_cmd_file(void);
+extern enum boot_device get_boot_device(void);
+
+#ifdef CONFIG_MXC_KPD
#define PRESSED_HOME 0x01
#define PRESSED_POWER 0x02
#define RECOVERY_KEY_MASK (PRESSED_HOME | PRESSED_POWER)
-extern int check_recovery_cmd_file(void);
-extern enum boot_device get_boot_device(void);
-
inline int test_key(int value, struct kpp_key_info *ki)
{
return (ki->val == value) && (ki->evt == KDepress);
@@ -57,6 +57,13 @@ int check_key_pressing(void)
return 0;
}
+#else
+/* If not using mxc keypad, currently we will detect power key on board */
+int check_key_pressing(void)
+{
+ return 0;
+}
+#endif
extern struct reco_envs supported_reco_envs[];
@@ -78,17 +85,16 @@ void setup_recovery_env(void)
env = getenv("bootargs_android_recovery");
/* Set env to recovery mode */
if (!env)
- setenv("bootargs_android", boot_args);
+ setenv("bootargs_android_recovery", boot_args);
else
- setenv("bootargs_android", env);
+ setenv("bootargs_android_recovery", env);
env = getenv("bootcmd_android_recovery");
if (!env)
- setenv("bootcmd_android", boot_cmd);
+ setenv("bootcmd_android_recovery", boot_cmd);
else
- setenv("bootcmd_android", env);
- setenv("bootcmd", "run bootcmd_android");
-
+ setenv("bootcmd_android_recovery", env);
+ setenv("bootcmd", "run bootcmd_android_recovery");
}
/* export to lib_arm/board.c */
diff --git a/board/freescale/mx51_3stack/mx51_3stack.c b/board/freescale/mx51_3stack/mx51_3stack.c
index 77da23c..4c773ad 100644
--- a/board/freescale/mx51_3stack/mx51_3stack.c
+++ b/board/freescale/mx51_3stack/mx51_3stack.c
@@ -29,7 +29,6 @@
#include <asm/arch/mx51_pins.h>
#include <asm/arch/iomux.h>
#include <i2c.h>
-#include <asm/arch/keypad.h>
#include "board-mx51_3stack.h"
#include <netdev.h>
@@ -613,7 +612,7 @@ int board_init(void)
}
#ifdef CONFIG_ANDROID_RECOVERY
-struct reco_envs supported_reco_envs[END_BOOT] = {
+struct reco_envs supported_reco_envs[BOOT_DEV_NUM] = {
{
.cmd = CONFIG_ANDROID_RECOVERY_BOOTCMD_NAND,
.args = CONFIG_ANDROID_RECOVERY_BOOTARGS_NAND,
@@ -759,7 +758,7 @@ static int check_nand_recovery_cmd_file(char *mtd_part_name,
return filelen;
}
-static int check_recovery_cmd_file(void)
+int check_recovery_cmd_file(void)
{
int if_exist = 0;
char *env = NULL;
diff --git a/board/freescale/mx51_bbg/mx51_bbg.c b/board/freescale/mx51_bbg/mx51_bbg.c
index 83e8ca7..e90337b 100644
--- a/board/freescale/mx51_bbg/mx51_bbg.c
+++ b/board/freescale/mx51_bbg/mx51_bbg.c
@@ -29,7 +29,6 @@
#include <asm/arch/iomux.h>
#include <asm/errno.h>
#include <i2c.h>
-#include <asm/arch/keypad.h>
#include "board-imx51.h"
#ifdef CONFIG_IMX_ECSPI
#include <imx_spi.h>
@@ -874,7 +873,7 @@ int board_init(void)
}
#ifdef CONFIG_ANDROID_RECOVERY
-struct reco_envs supported_reco_envs[END_BOOT] = {
+struct reco_envs supported_reco_envs[BOOT_DEV_NUM] = {
{
.cmd = NULL,
.args = NULL,
diff --git a/board/freescale/mx53_evk/mx53_evk.c b/board/freescale/mx53_evk/mx53_evk.c
index 2f5c4b1..92b6ce9 100644
--- a/board/freescale/mx53_evk/mx53_evk.c
+++ b/board/freescale/mx53_evk/mx53_evk.c
@@ -52,6 +52,16 @@
#include <asm/clock.h>
#endif
+#ifdef CONFIG_ANDROID_RECOVERY
+#include "../common/recovery.h"
+#include <part.h>
+#include <ext2fs.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <ubi_uboot.h>
+#include <jffs2/load_kernel.h>
+#endif
+
DECLARE_GLOBAL_DATA_PTR;
static u32 system_rev;
@@ -647,6 +657,26 @@ static void setup_fec(void)
}
#endif
+#if defined(CONFIG_MXC_KPD)
+int setup_mxc_kpd(void)
+{
+ mxc_request_iomux(MX53_PIN_KEY_COL0, IOMUX_CONFIG_ALT0);
+ mxc_request_iomux(MX53_PIN_KEY_COL1, IOMUX_CONFIG_ALT0);
+ mxc_request_iomux(MX53_PIN_KEY_COL2, IOMUX_CONFIG_ALT0);
+ mxc_request_iomux(MX53_PIN_KEY_COL3, IOMUX_CONFIG_ALT0);
+ mxc_request_iomux(MX53_PIN_KEY_COL4, IOMUX_CONFIG_ALT0);
+ mxc_request_iomux(MX53_PIN_GPIO_19, IOMUX_CONFIG_ALT0);
+ mxc_request_iomux(MX53_PIN_KEY_ROW0, IOMUX_CONFIG_ALT0);
+ mxc_request_iomux(MX53_PIN_KEY_ROW1, IOMUX_CONFIG_ALT0);
+ mxc_request_iomux(MX53_PIN_KEY_ROW2, IOMUX_CONFIG_ALT0);
+ mxc_request_iomux(MX53_PIN_KEY_ROW3, IOMUX_CONFIG_ALT0);
+ mxc_request_iomux(MX53_PIN_KEY_ROW4, IOMUX_CONFIG_ALT0);
+
+ return 0;
+}
+#endif
+
+
#ifdef CONFIG_CMD_MMC
struct fsl_esdhc_cfg esdhc_cfg[2] = {
@@ -776,6 +806,127 @@ int board_init(void)
return 0;
}
+
+#ifdef CONFIG_ANDROID_RECOVERY
+struct reco_envs supported_reco_envs[BOOT_DEV_NUM] = {
+ {
+ .cmd = NULL,
+ .args = NULL,
+ },
+ {
+ .cmd = NULL,
+ .args = NULL,
+ },
+ {
+ .cmd = NULL,
+ .args = NULL,
+ },
+ {
+ .cmd = NULL,
+ .args = NULL,
+ },
+ {
+ .cmd = NULL,
+ .args = NULL,
+ },
+ {
+ .cmd = NULL,
+ .args = NULL,
+ },
+ {
+ .cmd = CONFIG_ANDROID_RECOVERY_BOOTCMD_MMC,
+ .args = CONFIG_ANDROID_RECOVERY_BOOTCMD_MMC,
+ },
+ {
+ .cmd = CONFIG_ANDROID_RECOVERY_BOOTCMD_MMC,
+ .args = CONFIG_ANDROID_RECOVERY_BOOTARGS_MMC,
+ },
+ {
+ .cmd = NULL,
+ .args = NULL,
+ },
+};
+
+int check_recovery_cmd_file(void)
+{
+ disk_partition_t info;
+ ulong part_length;
+ int filelen;
+ char *env;
+
+ /* For test only */
+ /* When detecting android_recovery_switch,
+ * enter recovery mode directly */
+ env = getenv("android_recovery_switch");
+ if (!strcmp(env, "1")) {
+ printf("Env recovery detected!\nEnter recovery mode!\n");
+ return 1;
+ }
+
+ printf("Checking for recovery command file...\n");
+ switch (get_boot_device()) {
+ case MMC_BOOT:
+ case SD_BOOT:
+ {
+ block_dev_desc_t *dev_desc = NULL;
+ struct mmc *mmc = find_mmc_device(0);
+
+ dev_desc = get_dev("mmc", 0);
+
+ if (NULL == dev_desc) {
+ puts("** Block device MMC 0 not supported\n");
+ return 0;
+ }
+
+ mmc_init(mmc);
+
+ if (get_partition_info(dev_desc,
+ CONFIG_ANDROID_CACHE_PARTITION_MMC,
+ &info)) {
+ printf("** Bad partition %d **\n",
+ CONFIG_ANDROID_CACHE_PARTITION_MMC);
+ return 0;
+ }
+
+ part_length = ext2fs_set_blk_dev(dev_desc,
+ CONFIG_ANDROID_CACHE_PARTITION_MMC);
+ if (part_length == 0) {
+ printf("** Bad partition - mmc 0:%d **\n",
+ CONFIG_ANDROID_CACHE_PARTITION_MMC);
+ ext2fs_close();
+ return 0;
+ }
+
+ if (!ext2fs_mount(part_length)) {
+ printf("** Bad ext2 partition or "
+ "disk - mmc 0:%d **\n",
+ CONFIG_ANDROID_CACHE_PARTITION_MMC);
+ ext2fs_close();
+ return 0;
+ }
+
+ filelen = ext2fs_open(CONFIG_ANDROID_RECOVERY_CMD_FILE);
+
+ ext2fs_close();
+ }
+ break;
+ case NAND_BOOT:
+ return 0;
+ break;
+ case SPI_NOR_BOOT:
+ return 0;
+ break;
+ case UNKNOWN_BOOT:
+ default:
+ return 0;
+ break;
+ }
+
+ return (filelen > 0) ? 1 : 0;
+
+}
+#endif
+
int board_late_init(void)
{
return 0;