mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 09/10] at91: add bootstrap version
Date: Tue, 22 Jan 2013 15:40:44 +0100	[thread overview]
Message-ID: <1358865645-22631-9-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1358865645-22631-1-git-send-email-plagnioj@jcrosoft.com>

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 <plagnioj@jcrosoft.com>
---
 arch/arm/mach-at91/Kconfig                  |    5 ++
 arch/arm/mach-at91/Makefile                 |    1 +
 arch/arm/mach-at91/bootstrap.c              |   95 +++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/bootstrap.h |   28 ++++++++
 4 files changed, 129 insertions(+)
 create mode 100644 arch/arm/mach-at91/bootstrap.c
 create mode 100644 arch/arm/mach-at91/include/mach/bootstrap.h

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 2e43b10..4323d7c 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -494,4 +494,9 @@ config CMD_AT91_BOOT_TEST
 
 endif
 
+config AT91_BOOTSTRAP
+	bool "at91 bootstrap"
+	depends on MACH_HAS_LOWLEVEL_INIT
+	select BOOTSTRAP
+
 endif
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 4404d23..634b160 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -1,6 +1,7 @@
 obj-y += setup.o clock.o gpio.o
 obj-$(CONFIG_CMD_AT91_BOOT_TEST) += boot_test_cmd.o
 
+obj-$(CONFIG_AT91_BOOTSTRAP) += bootstrap.o
 lowlevel_init-y = at91sam926x_lowlevel_init.o
 lowlevel_init-$(CONFIG_ARCH_AT91RM9200) = at91rm9200_lowlevel_init.o
 obj-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += $(lowlevel_init-y)
diff --git a/arch/arm/mach-at91/bootstrap.c b/arch/arm/mach-at91/bootstrap.c
new file mode 100644
index 0000000..5ee43ad
--- /dev/null
+++ b/arch/arm/mach-at91/bootstrap.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
+ *
+ * Under GPLv2
+ */
+
+#include <common.h>
+#include <bootstrap.h>
+#include <mach/bootstrap.h>
+#include <sizes.h>
+#include <malloc.h>
+#include <init.h>
+
+#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);
diff --git a/arch/arm/mach-at91/include/mach/bootstrap.h b/arch/arm/mach-at91/include/mach/bootstrap.h
new file mode 100644
index 0000000..a3d19dd
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/bootstrap.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
+ *
+ * Under GPLv2
+ */
+
+#ifndef __MACH_BOOTSTRAP_H__
+#define __MACH_BOOTSTRAP_H__
+
+#ifdef CONFIG_MTD_M25P80
+void * bootstrap_board_read_m25p80(void);
+#else
+static inline void * bootstrap_board_read_m25p80(void)
+{
+	return NULL;
+}
+#endif
+
+#ifdef CONFIG_MTD_DATAFLASH
+void * bootstrap_board_read_dataflash(void);
+#else
+static inline void * bootstrap_board_read_dataflash(void)
+{
+	return NULL;
+}
+#endif
+
+#endif /* __MACH_BOOTSTRAP_H__ */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-01-22 14:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-22 14:38 [PATCH 00/10 v7] at91: add bootstrap support Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40 ` [PATCH 01/10] filetype: add is_barebox_mips_head support Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40   ` [PATCH 02/10] filetype: add is_barebox_head Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40   ` [PATCH 03/10] at91: dump mux command: make it depends on COMMAND_SUPPORT Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40   ` [PATCH 04/10] at91: add test commamd to emulate bootrom boot Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40   ` [PATCH 05/10] at91sam926x: lowlevel add external boot support Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40   ` [PATCH 06/10] at91: sam926x: switch lowlevel param to c code Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40   ` [PATCH 07/10] at91: usb-a9263 add lowlevel init Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40   ` [PATCH 08/10] introduce common bootstrap code Jean-Christophe PLAGNIOL-VILLARD
2013-01-22 14:40   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-01-22 14:40   ` [PATCH 10/10] at91: usb_a9263: add bootstrap version Jean-Christophe PLAGNIOL-VILLARD
2013-01-23  7:33 ` [PATCH 00/10 v7] at91: add bootstrap support Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2013-01-21 14:28 [PATCH 00/10 v6] " Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 14:33 ` [PATCH 01/10] filetype: add is_barebox_mips_head support Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 14:33   ` [PATCH 09/10] at91: add bootstrap version Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:23 [PATCH 00/10 v5] at91: add bootstrap support Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27 ` [PATCH 01/10] filetype: add is_barebox_mips_head support Jean-Christophe PLAGNIOL-VILLARD
2013-01-21 10:27   ` [PATCH 09/10] at91: add bootstrap version Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358865645-22631-9-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox