From: "Teresa Gámez" <t.gamez@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCHv2 11/12] ARM OMAP: get barebox partion information from boardcode
Date: Tue, 9 Jul 2013 11:23:21 +0200 [thread overview]
Message-ID: <1373361802-31080-11-git-send-email-t.gamez@phytec.de> (raw)
In-Reply-To: <1373361802-31080-1-git-send-email-t.gamez@phytec.de>
The size and offset of the barebox partition in nand and spi nor flash
may vary on different boards. Make it possible to pass this information
over boardfile if needed.
Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
arch/arm/mach-omap/include/mach/generic.h | 16 ++++++++++++
arch/arm/mach-omap/xload.c | 38 +++++++++++++++++++++++-----
2 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-omap/include/mach/generic.h b/arch/arm/mach-omap/include/mach/generic.h
index 9c474e2..3314faf 100644
--- a/arch/arm/mach-omap/include/mach/generic.h
+++ b/arch/arm/mach-omap/include/mach/generic.h
@@ -33,6 +33,22 @@
#define cpu_is_am33xx() (0)
#endif
+struct omap_barebox_part {
+ unsigned int nand_offset;
+ unsigned int nand_size;
+ unsigned int nor_offset;
+ unsigned int nor_size;
+};
+
+#ifdef CONFIG_SHELL_NONE
+int omap_set_barebox_part(struct omap_barebox_part *part);
+#else
+static inline int omap_set_barebox_part(struct omap_barebox_part *part)
+{
+ return 0;
+}
+#endif
+
extern uint32_t omap_bootinfo[3];
void omap_save_bootinfo(void);
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 3dbdef5..76746e2 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -11,6 +11,15 @@
#include <filetype.h>
#include <mach/generic.h>
+struct omap_barebox_part *barebox_part;
+
+static struct omap_barebox_part default_part = {
+ .nand_offset = SZ_128K,
+ .nand_size = SZ_1M,
+ .nor_offset = SZ_128K,
+ .nor_size = SZ_1M,
+};
+
static void *read_image_head(const char *name)
{
void *header = xmalloc(ARM_HEAD_SIZE);
@@ -46,14 +55,15 @@ static unsigned int get_image_size(void *head)
return ret;
}
-static void *omap_xload_boot_nand(int offset)
+static void *omap_xload_boot_nand(int offset, int part_size)
{
int ret;
int size;
void *to, *header;
struct cdev *cdev;
- devfs_add_partition("nand0", offset, SZ_1M, DEVFS_PARTITION_FIXED, "x");
+ devfs_add_partition("nand0", offset, part_size,
+ DEVFS_PARTITION_FIXED, "x");
dev_add_bb_dev("x", "bbx");
header = read_image_head("bbx");
@@ -105,14 +115,15 @@ static void *omap_xload_boot_mmc(void)
return buf;
}
-static void *omap_xload_boot_spi(int offset)
+static void *omap_xload_boot_spi(int offset, int part_size)
{
int ret;
int size;
void *to, *header;
struct cdev *cdev;
- devfs_add_partition("m25p0", offset, SZ_1M, DEVFS_PARTITION_FIXED, "x");
+ devfs_add_partition("m25p0", offset, part_size,
+ DEVFS_PARTITION_FIXED, "x");
header = read_image_head("x");
if (header == NULL)
@@ -167,6 +178,9 @@ static __noreturn int omap_xload(void)
int (*func)(void *) = NULL;
uint32_t *arg;
+ if (!barebox_part)
+ barebox_part = &default_part;
+
switch (bootsource_get())
{
case BOOTSOURCE_MMC:
@@ -183,15 +197,18 @@ static __noreturn int omap_xload(void)
}
case BOOTSOURCE_NAND:
printf("booting from NAND\n");
- func = omap_xload_boot_nand(SZ_128K);
+ func = omap_xload_boot_nand(barebox_part->nand_offset,
+ barebox_part->nand_size);
break;
case BOOTSOURCE_SPI:
printf("booting from SPI\n");
- func = omap_xload_boot_spi(SZ_128K);
+ func = omap_xload_boot_spi(barebox_part->nor_offset,
+ barebox_part->nor_size);
break;
default:
printf("unknown boot source. Fall back to nand\n");
- func = omap_xload_boot_nand(SZ_128K);
+ func = omap_xload_boot_nand(barebox_part->nand_offset,
+ barebox_part->nand_size);
break;
}
@@ -208,6 +225,13 @@ static __noreturn int omap_xload(void)
while (1);
}
+int omap_set_barebox_part(struct omap_barebox_part *part)
+{
+ barebox_part = part;
+
+ return 0;
+}
+
static int omap_set_xload(void)
{
barebox_main = omap_xload;
--
1.7.0.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-07-09 9:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-09 9:23 [PATCHv2 01/12] ARM: OMAP: AM33xx: Add basic NAND support Teresa Gámez
2013-07-09 9:23 ` [PATCHv2 02/12] PCM051: Add basic nand support Teresa Gámez
2013-07-09 9:23 ` [PATCHv2 03/12] ARM: AM33xx: Add gpio support Teresa Gámez
2013-07-09 9:23 ` [PATCHv2 04/12] PCM051: Add muxing for user led and btn Teresa Gámez
2013-07-09 9:23 ` [PATCHv2 05/12] PCM051: Update pcm051_defconfig Teresa Gámez
2013-07-09 9:23 ` [PATCHv2 06/12] PCM051: Rename SPI NOR device Teresa Gámez
2013-07-09 9:23 ` [PATCHv2 07/12] ARM: AM33xx: Enable clock for all GPIO banks Teresa Gámez
2013-07-09 9:23 ` [PATCHv2 08/12] PCM051: Add first stage support Teresa Gámez
2013-07-10 7:21 ` Teresa Gamez
2013-07-10 21:31 ` Sascha Hauer
2013-07-09 9:23 ` [PATCHv2 09/12] ARM: AM33xx: Make mpu pll configurable by lowlevel board code Teresa Gámez
2013-07-09 9:23 ` [PATCHv2 10/12] arm: omap: store boot source info from ROM loader Teresa Gámez
2013-07-09 9:23 ` Teresa Gámez [this message]
2013-07-09 9:23 ` [PATCHv2 12/12] PCM051: Pass barebox partition information Teresa Gámez
2013-07-09 17:33 ` [PATCHv2 01/12] ARM: OMAP: AM33xx: Add basic NAND support 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=1373361802-31080-11-git-send-email-t.gamez@phytec.de \
--to=t.gamez@phytec.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