From ea023b9b7ba466f93b21c6f4d0532a2c49ac24c2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Tue, 22 Jan 2013 15:40:44 +0100 Subject: at91: add bootstrap version This will allow to boot from NAND/MMC and others. This version of bootstrap is a non shell version of barebox compressed by the pbl. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Sascha Hauer --- arch/arm/mach-at91/bootstrap.c | 95 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 arch/arm/mach-at91/bootstrap.c (limited to 'arch/arm/mach-at91/bootstrap.c') diff --git a/arch/arm/mach-at91/bootstrap.c b/arch/arm/mach-at91/bootstrap.c new file mode 100644 index 0000000000..5ee43adb4d --- /dev/null +++ b/arch/arm/mach-at91/bootstrap.c @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD + * + * Under GPLv2 + */ + +#include +#include +#include +#include +#include +#include + +#if defined(CONFIG_MCI_ATMEL) +#define is_mmc() 1 +#else +#define is_mmc() 0 +#endif + +#ifdef CONFIG_NAND_ATMEL +#define is_nand() 1 +#else +#define is_nand() 0 +#endif + +#ifdef CONFIG_MTD_M25P80 +#define is_m25p80() 1 +#else +#define is_m25p80() 0 +#endif + +#ifdef CONFIG_MTD_DATAFLASH +#define is_dataflash() 1 +#else +#define is_dataflash() 0 +#endif + +static void boot_seq(bool is_barebox) +{ + char *name = is_barebox ? "barebox" : "unknown"; + int (*func)(void) = NULL; + + if (is_m25p80()) { + func = bootstrap_board_read_m25p80(); + printf("Boot %s from m25p80\n", name); + bootstrap_boot(func, is_barebox); + bootstrap_err("... failed\n"); + free(func); + } + if (is_dataflash()) { + printf("Boot %s from dataflash\n", name); + func = bootstrap_board_read_dataflash(); + bootstrap_boot(func, is_barebox); + bootstrap_err("... failed\n"); + free(func); + } + if (is_nand()) { + printf("Boot %s from nand\n", name); + func = bootstrap_read_devfs("nand0", true, SZ_128K, SZ_256K, SZ_1M); + bootstrap_boot(func, is_barebox); + bootstrap_err("... failed\n"); + free(func); + } +} + +static int at91_bootstrap(void) +{ + int (*func)(void) = NULL; + + if (is_mmc()) { + printf("Boot from mmc\n"); + func = bootstrap_read_disk("disk0.0", NULL); + bootstrap_boot(func, false); + bootstrap_err("... failed\n"); + free(func); + } + + /* First only bootstrap_boot a barebox */ + boot_seq(true); + /* Second bootstrap_boot any */ + boot_seq(false); + + bootstrap_err("bootstrap_booting failed\n"); + while (1); + + return 0; +} + +static int at91_set_bootstrap(void) +{ + barebox_main = at91_bootstrap; + + return 0; +} +late_initcall(at91_set_bootstrap); -- cgit v1.2.3