From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 05/12] ARM omap: add xload helper functions
Date: Mon, 11 Apr 2011 16:39:44 +0200 [thread overview]
Message-ID: <1302532791-20664-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1302532791-20664-1-git-send-email-s.hauer@pengutronix.de>
Add some common xload helper functions to determine the boot source
on omap3/4 and to load images from mmc and nand.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-omap/Makefile | 2 +-
arch/arm/mach-omap/include/mach/xload.h | 16 +++++++++
arch/arm/mach-omap/omap3_generic.c | 14 ++++++++
arch/arm/mach-omap/omap4_generic.c | 14 ++++++++
arch/arm/mach-omap/xload.c | 54 +++++++++++++++++++++++++++++++
5 files changed, 99 insertions(+), 1 deletions(-)
create mode 100644 arch/arm/mach-omap/include/mach/xload.h
create mode 100644 arch/arm/mach-omap/xload.c
diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile
index 9c31456..a4b9a55 100644
--- a/arch/arm/mach-omap/Makefile
+++ b/arch/arm/mach-omap/Makefile
@@ -25,4 +25,4 @@ obj-$(CONFIG_ARCH_OMAP3) += omap3_core.o omap3_generic.o
obj-$(CONFIG_ARCH_OMAP4) += omap4_generic.o omap4_clock.o
obj-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock_core.o omap3_clock.o
obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o
-obj-y += omap-uart.o gpio.o
+obj-y += omap-uart.o gpio.o xload.o
diff --git a/arch/arm/mach-omap/include/mach/xload.h b/arch/arm/mach-omap/include/mach/xload.h
new file mode 100644
index 0000000..844b57f
--- /dev/null
+++ b/arch/arm/mach-omap/include/mach/xload.h
@@ -0,0 +1,16 @@
+#ifndef _MACH_XLOAD_H
+#define _MACH_XLOAD_H
+
+void *omap_xload_boot_nand(int offset, int size);
+void *omap_xload_boot_mmc(void);
+
+enum omap_boot_src {
+ OMAP_BOOTSRC_UNKNOWN,
+ OMAP_BOOTSRC_MMC1,
+ OMAP_BOOTSRC_NAND,
+};
+
+enum omap_boot_src omap3_bootsrc(void);
+enum omap_boot_src omap4_bootsrc(void);
+
+#endif /* _MACH_XLOAD_H */
diff --git a/arch/arm/mach-omap/omap3_generic.c b/arch/arm/mach-omap/omap3_generic.c
index c1940d2..661a971 100644
--- a/arch/arm/mach-omap/omap3_generic.c
+++ b/arch/arm/mach-omap/omap3_generic.c
@@ -46,6 +46,7 @@
#include <mach/wdt.h>
#include <mach/sys_info.h>
#include <mach/syslib.h>
+#include <mach/xload.h>
/**
* @brief Reset the CPU
@@ -483,3 +484,16 @@ void a_init(void)
#endif
}
+
+#define OMAP3_TRACING_VECTOR1 0x4020ffb4
+
+enum omap_boot_src omap3_bootsrc(void)
+{
+ u32 bootsrc = readl(OMAP3_TRACING_VECTOR1);
+
+ if (bootsrc & (1 << 2))
+ return OMAP_BOOTSRC_NAND;
+ if (bootsrc & (1 << 6))
+ return OMAP_BOOTSRC_MMC1;
+ return OMAP_BOOTSRC_UNKNOWN;
+}
diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
index 45e6c86..e4838e9 100644
--- a/arch/arm/mach-omap/omap4_generic.c
+++ b/arch/arm/mach-omap/omap4_generic.c
@@ -5,6 +5,7 @@
#include <mach/omap4-silicon.h>
#include <mach/omap4-clock.h>
#include <mach/syslib.h>
+#include <mach/xload.h>
void __noreturn reset_cpu(unsigned long addr)
{
@@ -404,3 +405,16 @@ static int omap_vector_init(void)
return 0;
}
core_initcall(omap_vector_init);
+
+#define OMAP4_TRACING_VECTOR3 0x4030d048
+
+enum omap_boot_src omap4_bootsrc(void)
+{
+ u32 bootsrc = readl(OMAP4_TRACING_VECTOR3);
+
+ if (bootsrc & (1 << 3))
+ return OMAP_BOOTSRC_NAND;
+ if (bootsrc & (1 << 5))
+ return OMAP_BOOTSRC_MMC1;
+ return OMAP_BOOTSRC_UNKNOWN;
+}
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
new file mode 100644
index 0000000..216b9b5
--- /dev/null
+++ b/arch/arm/mach-omap/xload.c
@@ -0,0 +1,54 @@
+#include <common.h>
+#include <partition.h>
+#include <nand.h>
+#include <driver.h>
+#include <linux/mtd/mtd.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <mach/xload.h>
+#include <sizes.h>
+
+void *omap_xload_boot_nand(int offset, int size)
+{
+ int ret;
+ void *to = xmalloc(size);
+ struct cdev *cdev;
+
+ devfs_add_partition("nand0", offset, size, PARTITION_FIXED, "x");
+ dev_add_bb_dev("x", "bbx");
+
+ cdev = cdev_open("bbx", O_RDONLY);
+ if (!cdev) {
+ printf("failed to open nand\n");
+ return NULL;
+ }
+
+ ret = cdev_read(cdev, to, size, 0, 0);
+ if (ret != size) {
+ printf("failed to read from nand\n");
+ return NULL;
+ }
+
+ return to;
+}
+
+void *omap_xload_boot_mmc(void)
+{
+ int ret;
+ void *buf;
+ int len;
+
+ ret = mount("disk0.0", "fat", "/");
+ if (ret) {
+ printf("mounting sd card failed with %d\n", ret);
+ return NULL;
+ }
+
+ buf = read_file("/barebox.bin", &len);
+ if (!buf) {
+ printf("could not read barebox.bin from sd card\n");
+ return NULL;
+ }
+
+ return buf;
+}
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-04-11 14:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-11 14:39 OMAP4 support Sascha Hauer
2011-04-11 14:39 ` [PATCH 01/12] ARM omap: Add omap signGP tool and possibility to build ift images Sascha Hauer
2011-04-11 14:39 ` [PATCH 02/12] mci omap: hsmmc is also found on the omap3 Sascha Hauer
2011-04-11 14:39 ` [PATCH 03/12] ARM omap: make sr32 a static inline function Sascha Hauer
2011-04-11 14:39 ` [PATCH 04/12] ARM omap: Add omap4 support Sascha Hauer
2011-04-11 14:39 ` Sascha Hauer [this message]
2011-04-11 14:39 ` [PATCH 06/12] ARM omap4: panda board support Sascha Hauer
2011-04-12 8:18 ` Marc Kleine-Budde
2011-04-11 14:39 ` [PATCH 07/12] add panda defconfigs Sascha Hauer
2011-04-11 14:39 ` [PATCH 08/12] ARM omap4: Add pcm049 board support Sascha Hauer
2011-04-12 8:16 ` Marc Kleine-Budde
2011-04-11 14:39 ` [PATCH 09/12] ARM: add pcm049 defconfigs Sascha Hauer
2011-04-11 14:39 ` [PATCH 10/12] ARM omap beagle: Add noshell support for booting from MMC Sascha Hauer
2011-04-11 14:39 ` [PATCH 11/12] ARM omap beagle: update defconfig Sascha Hauer
2011-04-11 14:39 ` [PATCH 12/12] ARM beagle board: add xload defconfig Sascha Hauer
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=1302532791-20664-6-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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