summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorTerry Lv <r65388@freescale.com>2009-11-10 22:29:11 +0800
committerTerry Lv <r65388@freescale.com>2009-11-11 11:55:18 +0800
commit20710100e480543d36b76845c52cdec382f2b43a (patch)
tree240703f02b2f29379dfae9ca97df234e5d1057ce /board
parent34bc4951031059ccac23bf13fe261804f075880a (diff)
downloadu-boot-imx-20710100e480543d36b76845c52cdec382f2b43a.zip
u-boot-imx-20710100e480543d36b76845c52cdec382f2b43a.tar.gz
u-boot-imx-20710100e480543d36b76845c52cdec382f2b43a.tar.bz2
ENGR00118294: Misc changes for v2009.08 upgrade.
Misc changes for v2009.08 upgrade. Signed-off-by: Terry Lv <r65388@freescale.com>
Diffstat (limited to 'board')
-rw-r--r--board/freescale/mx25_3stack/mx25_3stack.c5
-rw-r--r--board/freescale/mx35_3stack/mx35_3stack.c6
-rw-r--r--board/freescale/mx51_3stack/mx51_3stack.c284
-rw-r--r--board/freescale/mx51_bbg/mx51_bbg.c343
4 files changed, 551 insertions, 87 deletions
diff --git a/board/freescale/mx25_3stack/mx25_3stack.c b/board/freescale/mx25_3stack/mx25_3stack.c
index f79b1b9..be1c571 100644
--- a/board/freescale/mx25_3stack/mx25_3stack.c
+++ b/board/freescale/mx25_3stack/mx25_3stack.c
@@ -32,6 +32,11 @@
#include <asm/arch/iomux.h>
#include <asm/arch/gpio.h>
+#ifdef CONFIG_CMD_MMC
+#include <mmc.h>
+#include <fsl_esdhc.h>
+#endif
+
DECLARE_GLOBAL_DATA_PTR;
static u32 system_rev;
diff --git a/board/freescale/mx35_3stack/mx35_3stack.c b/board/freescale/mx35_3stack/mx35_3stack.c
index cbd0756..bd6585b 100644
--- a/board/freescale/mx35_3stack/mx35_3stack.c
+++ b/board/freescale/mx35_3stack/mx35_3stack.c
@@ -31,6 +31,12 @@
#include <i2c.h>
#include <linux/types.h>
+#ifdef CONFIG_CMD_MMC
+#include <mmc.h>
+#include <fsl_esdhc.h>
+#endif
+
+
DECLARE_GLOBAL_DATA_PTR;
static u32 system_rev;
diff --git a/board/freescale/mx51_3stack/mx51_3stack.c b/board/freescale/mx51_3stack/mx51_3stack.c
index 8e315bd..067e653 100644
--- a/board/freescale/mx51_3stack/mx51_3stack.c
+++ b/board/freescale/mx51_3stack/mx51_3stack.c
@@ -34,11 +34,71 @@
#include "board-mx51_3stack.h"
#include <netdev.h>
+#ifdef CONFIG_CMD_MMC
+#include <mmc.h>
+#include <fsl_esdhc.h>
+#endif
+
+#ifdef CONFIG_FSL_ANDROID
+#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;
+static enum boot_device boot_dev;
u32 mx51_io_base_addr;
+static inline void setup_boot_device(void)
+{
+ uint *fis_addr = (uint *)IRAM_BASE_ADDR;
+
+ switch (*fis_addr) {
+ case NAND_FLASH_BOOT:
+ boot_dev = NAND_BOOT;
+ break;
+ case SPI_NOR_FLASH_BOOT:
+ boot_dev = SPI_NOR_BOOT;
+ break;
+ case MMC_FLASH_BOOT:
+ boot_dev = MMC_BOOT;
+ break;
+ default:
+ {
+ uint soc_sbmr = readl(SRC_BASE_ADDR + 0x4);
+ uint bt_mem_ctl = soc_sbmr & 0x00000003;
+ uint bt_mem_type = (soc_sbmr & 0x000000C0) >> 7;
+
+ switch (bt_mem_ctl) {
+ case 0x3:
+ if (bt_mem_type == 0)
+ boot_dev = MMC_BOOT;
+ else if (bt_mem_type == 3)
+ boot_dev = SPI_NOR_BOOT;
+ else
+ boot_dev = UNKNOWN_BOOT;
+ break;
+ case 0x1:
+ boot_dev = NAND_BOOT;
+ break;
+ default:
+ boot_dev = UNKNOWN_BOOT;
+ }
+ }
+ break;
+ }
+}
+
+enum boot_device get_boot_device(void)
+{
+ return boot_dev;
+}
+
u32 get_board_rev(void)
{
return system_rev;
@@ -160,7 +220,7 @@ static void setup_expio(void)
}
#if defined(CONFIG_MXC_ATA)
-int setup_ata()
+int setup_ata(void)
{
u32 pad;
@@ -455,6 +515,7 @@ void setup_core_voltages(void)
int board_init(void)
{
+ setup_boot_device();
setup_soc_rev();
gd->bd->bi_arch_number = MACH_TYPE_MX51_3DS; /* board id for linux */
@@ -472,15 +533,14 @@ int board_init(void)
}
#ifdef BOARD_LATE_INIT
-int board_late_init(void)
-{
+
#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;
-#endif
-#if defined(CONFIG_FSL_ANDROID) && defined(CONFIG_MXC_KPD)
mxc_kpp_init();
puts("Press home + power to enter recovery mode ...\n");
@@ -536,19 +596,197 @@ int board_late_init(void)
break;
}
- if (1 == boot_mode_switch) {
- printf("Boot mode switched to recovery mode!\n");
- /* Set env to recovery mode */
- setenv("bootargs_android", CONFIG_ANDROID_RECOVERY_BOOTARGS);
- setenv("bootcmd_android", CONFIG_ANDROID_RECOVERY_BOOTCMD);
- setenv("bootcmd", "run bootcmd_android");
- 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)
+{
+ printf("Boot mode switched to recovery mode!\n");
+
+ switch (get_boot_device()) {
+ case MMC_BOOT:
+ /* Set env to recovery mode */
+ setenv("bootargs_android", \
+ CONFIG_ANDROID_RECOVERY_BOOTARGS_MMC);
+ setenv("bootcmd_android", \
+ CONFIG_ANDROID_RECOVERY_BOOTCMD_MMC);
+ setenv("bootcmd", "run bootcmd_android");
+ break;
+ case NAND_BOOT:
+ setenv("bootargs_android", \
+ CONFIG_ANDROID_RECOVERY_BOOTARGS_NAND);
+ setenv("bootcmd_android", \
+ CONFIG_ANDROID_RECOVERY_BOOTCMD_NAND);
+ setenv("bootcmd", "run bootcmd_android");
+ 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;
+ }
+
+ return 0;
+}
+
+inline int check_recovery_cmd_file(void)
+{
+ disk_partition_t info;
+ ulong part_length;
+ int filelen;
+
+ switch (get_boot_device()) {
+ case MMC_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:
+ {
+ #if 0
+ struct mtd_device *dev_desc = NULL;
+ struct part_info *part = NULL;
+ struct mtd_partition mtd_part;
+ struct mtd_info *mtd_info;
+ char mtd_dev[16] = { 0 };
+ char mtd_buffer[80] = { 0 };
+ u8 pnum;
+ int err;
+ u8 read_test;
+
+ /* ========== ubi and mtd operations ========== */
+ if (mtdparts_init() != 0) {
+ printf("Error initializing mtdparts!\n");
+ return 0;
+ }
+
+ if (find_dev_and_part("nand", &dev_desc, &pnum, &part)) {
+ printf("Partition %s not found!\n", "nand");
+ return 0;
+ }
+ sprintf(mtd_dev, "%s%d",
+ MTD_DEV_TYPE(dev_desc->id->type),
+ dev_desc->id->num);
+ mtd_info = get_mtd_device_nm(mtd_dev);
+ if (IS_ERR(mtd_info)) {
+ printf("Partition %s not found on device %s!\n",
+ "nand", mtd_dev);
+ return 0;
+ }
+
+ sprintf(mtd_buffer, "mtd=%d", pnum);
+ memset(&mtd_part, 0, sizeof(mtd_part));
+ mtd_part.name = mtd_buffer;
+ mtd_part.size = part->size;
+ mtd_part.offset = part->offset;
+ add_mtd_partitions(&info, &mtd_part, 1);
+
+ err = ubi_mtd_param_parse(mtd_buffer, NULL);
+ if (err) {
+ del_mtd_partitions(&info);
+ return 0;
+ }
+
+ err = ubi_init();
+ if (err) {
+ del_mtd_partitions(&info);
+ return 0;
+ }
+
+ /* ========== ubifs operations ========== */
+ /* Init ubifs */
+ ubifs_init();
+
+ if (ubifs_mount(CONFIG_ANDROID_CACHE_PARTITION_NAND)) {
+ printf("Mount ubifs volume %s fail!\n",
+ CONFIG_ANDROID_CACHE_PARTITION_NAND);
+ return 0;
+ }
+
+ /* Try to read one byte for a read test. */
+ if (ubifs_load(CONFIG_ANDROID_RECOVERY_CMD_FILE,
+ &read_test, 1)) {
+ /* File not found */
+ filelen = 0;
+ } else
+ filelen = 1;
+ #endif
+ }
+ 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)
+{
+#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;
@@ -582,6 +820,24 @@ int checkboard(void)
printf("unknown");
}
printf("]\n");
+
+ printf("Boot Device: ");
+ switch (get_boot_device()) {
+ case NAND_BOOT:
+ printf("NAND\n");
+ break;
+ case SPI_NOR_BOOT:
+ printf("SPI NOR\n");
+ break;
+ case MMC_BOOT:
+ printf("MMC\n");
+ break;
+ case UNKNOWN_BOOT:
+ default:
+ printf("UNKNOWN\n");
+ break;
+ }
+
return 0;
}
@@ -687,7 +943,7 @@ int board_mmc_init(void)
#endif
#if defined(CONFIG_MXC_KPD)
-int setup_mxc_kpd()
+int setup_mxc_kpd(void)
{
mxc_request_iomux(MX51_PIN_KEY_COL0, IOMUX_CONFIG_ALT0);
mxc_request_iomux(MX51_PIN_KEY_COL1, IOMUX_CONFIG_ALT0);
diff --git a/board/freescale/mx51_bbg/mx51_bbg.c b/board/freescale/mx51_bbg/mx51_bbg.c
index 8ea4e2e..289e8c8 100644
--- a/board/freescale/mx51_bbg/mx51_bbg.c
+++ b/board/freescale/mx51_bbg/mx51_bbg.c
@@ -34,16 +34,74 @@
#include "board-imx51.h"
#include <asm/arch/imx_spi.h>
#include <asm/arch/imx_spi_pmic.h>
+
+#include <asm/errno.h>
+
+#ifdef CONFIG_CMD_MMC
+#include <mmc.h>
#include <fsl_esdhc.h>
+#endif
+#ifdef CONFIG_FSL_ANDROID
#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;
+static enum boot_device boot_dev;
u32 mx51_io_base_addr;
+static inline void setup_boot_device(void)
+{
+ uint *fis_addr = (uint *)IRAM_BASE_ADDR;
+
+ switch (*fis_addr) {
+ case NAND_FLASH_BOOT:
+ boot_dev = NAND_BOOT;
+ break;
+ case SPI_NOR_FLASH_BOOT:
+ boot_dev = SPI_NOR_BOOT;
+ break;
+ case MMC_FLASH_BOOT:
+ boot_dev = MMC_BOOT;
+ break;
+ default:
+ {
+ uint soc_sbmr = readl(SRC_BASE_ADDR + 0x4);
+ uint bt_mem_ctl = soc_sbmr & 0x00000003;
+ uint bt_mem_type = (soc_sbmr & 0x000000C0) >> 7;
+
+ switch (bt_mem_ctl) {
+ case 0x3:
+ if (bt_mem_type == 0)
+ boot_dev = MMC_BOOT;
+ else if (bt_mem_type == 3)
+ boot_dev = SPI_NOR_BOOT;
+ else
+ boot_dev = UNKNOWN_BOOT;
+ break;
+ case 0x1:
+ boot_dev = NAND_BOOT;
+ break;
+ default:
+ boot_dev = UNKNOWN_BOOT;
+ }
+ }
+ break;
+ }
+}
+
+enum boot_device get_boot_device(void)
+{
+ return boot_dev;
+}
+
u32 get_board_rev(void)
{
return system_rev;
@@ -440,15 +498,14 @@ u32 *imx_esdhc_base_addr;
int esdhc_gpio_init(void)
{
u32 interface_esdhc = 0;
- s32 status = 0;
- u32 pad = 0;
+ s32 status = 0;
+ u32 pad = 0;
+ uint soc_sbmr = readl(SRC_BASE_ADDR + 0x4);
- interface_esdhc = (readl(SRC_BASE_ADDR + 0x4) & (0x00180000)) >> 19;
-
- printf("interface_esdhc: %d\n", interface_esdhc);
+ interface_esdhc = (soc_sbmr & (0x00180000)) >> 19;
switch (interface_esdhc) {
- case 0:
+ case 0:
imx_esdhc_base_addr = (u32 *)MMC_SDHC1_BASE_ADDR;
pad = PAD_CTL_PUE_KEEPER | PAD_CTL_PKE_ENABLE | PAD_CTL_DRV_HIGH |
@@ -524,7 +581,7 @@ int board_mmc_init(void)
#endif
#if defined(CONFIG_MXC_KPD)
-int setup_mxc_kpd()
+int setup_mxc_kpd(void)
{
mxc_request_iomux(MX51_PIN_KEY_COL0, IOMUX_CONFIG_ALT0);
mxc_request_iomux(MX51_PIN_KEY_COL1, IOMUX_CONFIG_ALT0);
@@ -543,6 +600,7 @@ int setup_mxc_kpd()
int board_init(void)
{
+ setup_boot_device();
setup_soc_rev();
gd->bd->bi_arch_number = MACH_TYPE_MX51_BABBAGE; /* board id for linux */
@@ -557,17 +615,13 @@ int board_init(void)
}
#ifdef BOARD_LATE_INIT
-int board_late_init(void)
-{
#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;
-#endif
-
- power_init();
-#if defined(CONFIG_FSL_ANDROID) && defined(CONFIG_MXC_KPD)
mxc_kpp_init();
puts("Press home + power to enter recovery mode ...\n");
@@ -588,6 +642,7 @@ int board_late_init(void)
/* Press Home */
state = 1;
} else if (TEST_POWER_KEY_DEPRESS(key_info.val, key_info.evt)) {
+ /* Press Power */
state = 2;
} else {
state = 0;
@@ -597,12 +652,14 @@ int board_late_init(void)
/* 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))
- state = 1;
- else
+ key_info.evt)) {
+ /* Not switch */
+ state = 2;
+ } else
state = 0;
}
break;
@@ -610,12 +667,14 @@ int board_late_init(void)
/* 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))
- state = 2;
- else
+ key_info.evt)) {
+ /* Not switch */
+ state = 1;
+ } else
state = 0;
}
break;
@@ -623,79 +682,200 @@ int board_late_init(void)
break;
}
- if (1 == boot_mode_switch) {
- printf("Boot mode switched to recovery mode!\n");
- /* Set env to recovery mode */
- setenv("bootargs_android", CONFIG_ANDROID_RECOVERY_BOOTARGS);
- setenv("bootcmd_android", CONFIG_ANDROID_RECOVERY_BOOTCMD);
- setenv("bootcmd", "run bootcmd_android");
- break;
- }
+ if (1 == boot_mode_switch)
+ return 1;
}
}
for (i = 0; i < 100; ++i)
udelay(10000);
}
- /* Check CONFIG_ANDROID_RECOVERY_CMD_FILE to
- judge if need to enter recovery mode */
- {
- char *cmd_file_patch;
- block_dev_desc_t *dev_desc = NULL;
- disk_partition_t info;
- ulong part_length;
- int filelen;
+ return 0;
+}
- cmd_file_patch = getenv("android_recovery_cmd_file");
- if (!cmd_file_patch)
- cmd_file_patch = CONFIG_ANDROID_RECOVERY_CMD_FILE;
+inline int switch_to_recovery_mode(void)
+{
+ printf("Boot mode switched to recovery mode!\n");
+
+ switch (get_boot_device()) {
+ case MMC_BOOT:
+ /* Set env to recovery mode */
+ setenv("bootargs_android", \
+ CONFIG_ANDROID_RECOVERY_BOOTARGS_MMC);
+ setenv("bootcmd_android", \
+ CONFIG_ANDROID_RECOVERY_BOOTCMD_MMC);
+ setenv("bootcmd", "run bootcmd_android");
+ break;
+ case NAND_BOOT:
+ setenv("bootargs_android", \
+ CONFIG_ANDROID_RECOVERY_BOOTARGS_NAND);
+ setenv("bootcmd_android", \
+ CONFIG_ANDROID_RECOVERY_BOOTCMD_NAND);
+ setenv("bootcmd", "run bootcmd_android");
+ 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;
+ }
- dev_desc = get_dev("mmc", 0);
+ return 0;
+}
- if (dev_desc==NULL) {
- puts("** Block device MMC 0 not supported\n");
- return 1;
- }
+inline int check_recovery_cmd_file(void)
+{
+ disk_partition_t info;
+ ulong part_length;
+ int filelen;
- if (get_partition_info (dev_desc,
- CONFIG_ANDROID_CACHE_PARTITION,
- &info)) {
- printf("** Bad partition %d **\n",
- CONFIG_ANDROID_CACHE_PARTITION);
- return 1;
- }
+ switch (get_boot_device()) {
+ case MMC_BOOT:
+ {
+ block_dev_desc_t *dev_desc = NULL;
+ struct mmc *mmc = find_mmc_device(0);
- if ((part_length = \
- ext2fs_set_blk_dev(dev_desc,
- CONFIG_ANDROID_CACHE_PARTITION)) == 0) {
- printf("** Bad partition - mmc 0:%d **\n",
- CONFIG_ANDROID_CACHE_PARTITION);
- ext2fs_close();
- return 1;
- }
+ 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);
- if (!ext2fs_mount(part_length)) {
- printf ("** Bad ext2 partition or disk - mmc 0:%d **\n",
- CONFIG_ANDROID_CACHE_PARTITION);
ext2fs_close();
- return 1;
}
+ break;
+ case NAND_BOOT:
+ {
+ #if 0
+ struct mtd_device *dev_desc = NULL;
+ struct part_info *part = NULL;
+ struct mtd_partition mtd_part;
+ struct mtd_info *mtd_info;
+ char mtd_dev[16] = { 0 };
+ char mtd_buffer[80] = { 0 };
+ u8 pnum;
+ int err;
+ u8 read_test;
+
+ /* ========== ubi and mtd operations ========== */
+ if (mtdparts_init() != 0) {
+ printf("Error initializing mtdparts!\n");
+ return 0;
+ }
- filelen = ext2fs_open(CONFIG_ANDROID_RECOVERY_CMD_FILE);
+ if (find_dev_and_part("nand", &dev_desc, &pnum, &part)) {
+ printf("Partition %s not found!\n", "nand");
+ return 0;
+ }
+ sprintf(mtd_dev, "%s%d",
+ MTD_DEV_TYPE(dev_desc->id->type),
+ dev_desc->id->num);
+ mtd_info = get_mtd_device_nm(mtd_dev);
+ if (IS_ERR(mtd_info)) {
+ printf("Partition %s not found on device %s!\n",
+ "nand", mtd_dev);
+ return 0;
+ }
- if (filelen > 0) {
- puts("Recovery command file founded, switch to recovery mode!\n");
- /* Set env to recovery mode */
- setenv("bootargs_android", CONFIG_ANDROID_RECOVERY_BOOTARGS);
- setenv("bootcmd_android", CONFIG_ANDROID_RECOVERY_BOOTCMD);
- setenv("bootcmd", "run bootcmd_android");
- } else {
- puts("Recovery command file not found, normal boot!\n");
+ sprintf(mtd_buffer, "mtd=%d", pnum);
+ memset(&mtd_part, 0, sizeof(mtd_part));
+ mtd_part.name = mtd_buffer;
+ mtd_part.size = part->size;
+ mtd_part.offset = part->offset;
+ add_mtd_partitions(&info, &mtd_part, 1);
+
+ err = ubi_mtd_param_parse(mtd_buffer, NULL);
+ if (err) {
+ del_mtd_partitions(&info);
+ return 0;
+ }
+
+ err = ubi_init();
+ if (err) {
+ del_mtd_partitions(&info);
+ return 0;
+ }
+
+ /* ========== ubifs operations ========== */
+ /* Init ubifs */
+ ubifs_init();
+
+ if (ubifs_mount(CONFIG_ANDROID_CACHE_PARTITION_NAND)) {
+ printf("Mount ubifs volume %s fail!\n",
+ CONFIG_ANDROID_CACHE_PARTITION_NAND);
+ return 0;
+ }
+
+ /* Try to read one byte for a read test. */
+ if (ubifs_load(CONFIG_ANDROID_RECOVERY_CMD_FILE,
+ &read_test, 1)) {
+ /* File not found */
+ filelen = 0;
+ } else
+ filelen = 1;
+ #endif
}
+ break;
+ case SPI_NOR_BOOT:
+ return 0;
+ break;
+ case UNKNOWN_BOOT:
+ default:
+ return 0;
+ break;
+ }
- ext2fs_close();
+ return (filelen > 0) ? 1 : 0;
+
+}
+#endif
+
+int board_late_init(void)
+{
+ power_init();
+
+#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;
@@ -733,6 +913,23 @@ int checkboard(void)
printf("unknown");
}
printf("]\n");
+
+ printf("Boot Device: ");
+ switch (get_boot_device()) {
+ case NAND_BOOT:
+ printf("NAND\n");
+ break;
+ case SPI_NOR_BOOT:
+ printf("SPI NOR\n");
+ break;
+ case MMC_BOOT:
+ printf("MMC\n");
+ break;
+ case UNKNOWN_BOOT:
+ default:
+ printf("UNKNOWN\n");
+ break;
+ }
return 0;
}