summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNitin Garg <nitin.garg@freescale.com>2012-12-11 11:10:36 -0600
committerNitin Garg <nitin.garg@freescale.com>2012-12-11 11:10:36 -0600
commitd31df11541ea0d1a0bf1ed7463fd30a25b65f98c (patch)
tree993a632a3ffa39be0f042fb036d1db53633aac16
parent07663772b10318e3d7f0aa3e410f0ff840780806 (diff)
ENGR00236620: Add Android fastboot and recovery reboot support
Add support for Android fastboot and recovery reboot commands for iMX5. Signed-off-by: Nitin Garg <nitin.garg@freescale.com>
-rw-r--r--board/freescale/mx53_smd/mx53_smd.c92
-rw-r--r--cpu/arm_cortexa8/mx53/generic.c40
-rw-r--r--include/configs/mx53_smd_android.h13
3 files changed, 53 insertions, 92 deletions
diff --git a/board/freescale/mx53_smd/mx53_smd.c b/board/freescale/mx53_smd/mx53_smd.c
index f3a5bb2666..73dc165f49 100644
--- a/board/freescale/mx53_smd/mx53_smd.c
+++ b/board/freescale/mx53_smd/mx53_smd.c
@@ -70,6 +70,7 @@
#include <linux/mtd/partitions.h>
#include <ubi_uboot.h>
#include <jffs2/load_kernel.h>
+#define GPIO_VOL_DN_KEY 14
#endif
DECLARE_GLOBAL_DATA_PTR;
@@ -1286,100 +1287,27 @@ int board_init(void)
int check_recovery_cmd_file(void)
{
- disk_partition_t info;
int button_pressed = 0;
- ulong part_length;
- int filelen = 0;
- char *env;
+ int recovery_mode = 0;
u32 reg;
- int i;
- /* 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;
- }
+ /* Enter Recovery Mode if Recovery Switch is set. */
+ recovery_mode = check_and_clean_recovery_flag();
- printf("Checking for recovery command file...\n");
- switch (get_boot_device()) {
- case MMC_BOOT:
- case SD_BOOT:
- {
- for (i = 0; i < 2; i++) {
- block_dev_desc_t *dev_desc = NULL;
- struct mmc *mmc = find_mmc_device(i);
-
- dev_desc = get_dev("mmc", i);
-
- if (NULL == dev_desc) {
- printf("** Block device MMC %d not supported\n", i);
- continue;
- }
-
- 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);
- continue;
- }
-
- part_length = ext2fs_set_blk_dev(dev_desc,
- CONFIG_ANDROID_CACHE_PARTITION_MMC);
- if (part_length == 0) {
- printf("** Bad partition - mmc %d:%d **\n", i,
- CONFIG_ANDROID_CACHE_PARTITION_MMC);
- ext2fs_close();
- continue;
- }
-
- if (!ext2fs_mount(part_length)) {
- printf("** Bad ext2 partition or "
- "disk - mmc %d:%d **\n",
- i, CONFIG_ANDROID_CACHE_PARTITION_MMC);
- ext2fs_close();
- continue;
- }
-
- filelen = ext2fs_open(CONFIG_ANDROID_RECOVERY_CMD_FILE);
-
- ext2fs_close();
- break;
- }
- }
- break;
- case NAND_BOOT:
- return 0;
- break;
- case SPI_NOR_BOOT:
- return 0;
- break;
- case UNKNOWN_BOOT:
- default:
- return 0;
- break;
- }
-
- /* Check Recovery Combo Button press or not.
- * @TODO: Need At least Two key, but in SMD board,
- * only can use one Volume key. */
+ /* Check Recovery Combo Button press or not. */
mxc_request_iomux(MX53_PIN_ATA_DATA14, IOMUX_CONFIG_ALT1);
+ /* Set GPIO direction to INPUT */
reg = readl(GPIO2_BASE_ADDR + GPIO_GDIR);
- reg &= ~(1<<14);
+ reg &= ~(1 << GPIO_VOL_DN_KEY);
writel(reg, GPIO2_BASE_ADDR + GPIO_GDIR);
+ /* Read GPIO status */
reg = readl(GPIO2_BASE_ADDR + GPIO_PSR);
- if (!(reg & (1 << 14))) { /* Vol - is low assert */
+ if (!(reg & (1 << GPIO_VOL_DN_KEY))) { /* Vol - is low assert */
button_pressed = 1;
printf("Recovery key pressed\n");
}
- return (filelen > 0 || button_pressed);
-
+ return recovery_mode || button_pressed;
}
#endif
diff --git a/cpu/arm_cortexa8/mx53/generic.c b/cpu/arm_cortexa8/mx53/generic.c
index 7a6d95e6dd..83dbd4bd0e 100644
--- a/cpu/arm_cortexa8/mx53/generic.c
+++ b/cpu/arm_cortexa8/mx53/generic.c
@@ -1213,12 +1213,48 @@ struct reco_envs supported_reco_envs[BOOT_DEV_NUM] = {
};
#endif
-#ifdef CONFIG_FASTBOOT
+#ifdef CONFIG_ANDROID_RECOVERY
+#define ANDROID_RECOVERY_BOOT (1 << 27)
/* check if the recovery bit is set by kernel, it can be set by kernel
+ * issue a command '# reboot recovery' */
+int check_and_clean_recovery_flag(void)
+{
+ int flag_set = 0;
+ u32 reg;
+ reg = readl(SRTC_BASE_ADDR + SRTC_LPGR);
+
+ flag_set = !!(reg & ANDROID_RECOVERY_BOOT);
+
+ /* clean it in case looping infinite here.... */
+ if (flag_set) {
+ printf("Recovery flag is set...\n");
+ reg &= ~ANDROID_RECOVERY_BOOT;
+ writel(reg, SRTC_BASE_ADDR + SRTC_LPGR);
+ }
+
+ return flag_set;
+}
+#endif
+
+#ifdef CONFIG_FASTBOOT
+#define ANDROID_FASTBOOT_BOOT (1 << 26)
+/* check if the fastboot bit is set by kernel, it can be set by kernel
* issue a command '# reboot fastboot' */
int fastboot_check_and_clean_flag(void)
{
- return 0;
+ int flag_set = 0;
+ u32 reg;
+ reg = readl(SRTC_BASE_ADDR + SRTC_LPGR);
+
+ flag_set = !!(reg & ANDROID_FASTBOOT_BOOT);
+
+ /* clean it in case looping infinite here.... */
+ if (flag_set) {
+ reg &= ~ANDROID_FASTBOOT_BOOT;
+ writel(reg, SRTC_BASE_ADDR + SRTC_LPGR);
+ }
+
+ return flag_set;
}
#endif
diff --git a/include/configs/mx53_smd_android.h b/include/configs/mx53_smd_android.h
index 704619ef2e..e6ce3efe9f 100644
--- a/include/configs/mx53_smd_android.h
+++ b/include/configs/mx53_smd_android.h
@@ -94,8 +94,8 @@
#define CONFIG_FASTBOOT_INTERFACE_STR "Android fastboot"
#define CONFIG_FASTBOOT_SERIAL_NUM "12345"
#define CONFIG_FASTBOOT_SATA_NO 0
-#define CONFIG_FASTBOOT_TRANSFER_BUF 0x80000000
-#define CONFIG_FASTBOOT_TRANSFER_BUF_SIZE 0x9400000 /* 148M byte */
+#define CONFIG_FASTBOOT_TRANSFER_BUF 0x78000000
+#define CONFIG_FASTBOOT_TRANSFER_BUF_SIZE 0x14000000 /* 320M byte */
#define CONFIG_CMD_BOOTI
#define CONFIG_ANDROID_RECOVERY
@@ -104,12 +104,9 @@
#define CONFIG_MTD_PARTITIONS
#define CONFIG_TIMESTAMP
-#define CONFIG_ANDROID_RECOVERY_BOOTARGS_MMC \
- "setenv bootargs ${bootargs} init=/init root=/dev/mmcblk0p4 rootfs=ext4 video=mxcdi1fb:RGB666,XGA ldb=di1 di1_primary"
-#define CONFIG_ANDROID_RECOVERY_BOOTCMD_MMC \
- "run bootargs_base bootargs_android_recovery; " \
- "mmc dev 1 0; " \
- "mmc read ${loadaddr} 0x800 0x2000;bootm"
+#define CONFIG_ANDROID_RECOVERY_BOOTARGS_MMC NULL
+#define CONFIG_ANDROID_RECOVERY_BOOTCMD_MMC \
+ "booti mmc1 recovery"
#define CONFIG_ANDROID_RECOVERY_CMD_FILE "/recovery/command"
#define CONFIG_ANDROID_BOOT_PARTITION_MMC -1