mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] xload: make internal functions static
@ 2012-09-11 11:43 Jan Luebbe
  2012-09-11 11:43 ` [PATCH 2/2] xload: add SPI as a boot mode Jan Luebbe
  2012-09-11 13:55 ` [PATCH 1/2] xload: make internal functions static Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Luebbe @ 2012-09-11 11:43 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 arch/arm/mach-omap/include/mach/xload.h |    3 ---
 arch/arm/mach-omap/xload.c              |    8 ++++----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap/include/mach/xload.h b/arch/arm/mach-omap/include/mach/xload.h
index 26f1b68..9294477 100644
--- a/arch/arm/mach-omap/include/mach/xload.h
+++ b/arch/arm/mach-omap/include/mach/xload.h
@@ -1,9 +1,6 @@
 #ifndef _MACH_XLOAD_H
 #define _MACH_XLOAD_H
 
-void *omap_xload_boot_nand(int offset);
-void *omap_xload_boot_mmc(void);
-
 enum omap_boot_src {
 	OMAP_BOOTSRC_UNKNOWN,
 	OMAP_BOOTSRC_MMC1,
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 0afeea9..18a90c9 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -9,7 +9,7 @@
 #include <sizes.h>
 #include <filetype.h>
 
-void *read_image_head(const char *name)
+static void *read_image_head(const char *name)
 {
 	void *header = xmalloc(ARM_HEAD_SIZE);
 	struct cdev *cdev;
@@ -32,7 +32,7 @@ void *read_image_head(const char *name)
 	return header;
 }
 
-unsigned int get_image_size(void *head)
+static unsigned int get_image_size(void *head)
 {
 	unsigned int ret = 0;
 	unsigned int *psize = head + ARM_HEAD_SIZE_OFFSET;
@@ -44,7 +44,7 @@ unsigned int get_image_size(void *head)
 	return ret;
 }
 
-void *omap_xload_boot_nand(int offset)
+static void *omap_xload_boot_nand(int offset)
 {
 	int ret;
 	int size;
@@ -81,7 +81,7 @@ void *omap_xload_boot_nand(int offset)
 	return to;
 }
 
-void *omap_xload_boot_mmc(void)
+static void *omap_xload_boot_mmc(void)
 {
 	int ret;
 	void *buf;
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] xload: add SPI as a boot mode
  2012-09-11 11:43 [PATCH 1/2] xload: make internal functions static Jan Luebbe
@ 2012-09-11 11:43 ` Jan Luebbe
  2012-09-11 13:55 ` [PATCH 1/2] xload: make internal functions static Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Luebbe @ 2012-09-11 11:43 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 arch/arm/mach-omap/include/mach/xload.h |    1 +
 arch/arm/mach-omap/xload.c              |   40 +++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/arch/arm/mach-omap/include/mach/xload.h b/arch/arm/mach-omap/include/mach/xload.h
index 9294477..63b68df 100644
--- a/arch/arm/mach-omap/include/mach/xload.h
+++ b/arch/arm/mach-omap/include/mach/xload.h
@@ -5,6 +5,7 @@ enum omap_boot_src {
 	OMAP_BOOTSRC_UNKNOWN,
 	OMAP_BOOTSRC_MMC1,
 	OMAP_BOOTSRC_NAND,
+	OMAP_BOOTSRC_SPI1,
 };
 
 enum omap_boot_src omap3_bootsrc(void);
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 18a90c9..9fa8221 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -103,6 +103,42 @@ static void *omap_xload_boot_mmc(void)
 	return buf;
 }
 
+static void *omap_xload_boot_spi(int offset)
+{
+	int ret;
+	int size;
+	void *to, *header;
+	struct cdev *cdev;
+
+	devfs_add_partition("m25p0", offset, SZ_1M, DEVFS_PARTITION_FIXED, "x");
+
+	header = read_image_head("x");
+	if (header == NULL)
+		return NULL;
+
+	size = get_image_size(header);
+	if (!size) {
+		printf("failed to get image size\n");
+		return NULL;
+	}
+
+	to = xmalloc(size);
+
+	cdev = cdev_open("x", O_RDONLY);
+	if (!cdev) {
+		printf("failed to open spi flash\n");
+		return NULL;
+	}
+
+	ret = cdev_read(cdev, to, size, 0, 0);
+	if (ret != size) {
+		printf("failed to read from spi flash\n");
+		return NULL;
+	}
+
+	return to;
+}
+
 enum omap_boot_src omap_bootsrc(void)
 {
 #if defined(CONFIG_ARCH_OMAP3)
@@ -131,6 +167,10 @@ int run_shell(void)
 		printf("booting from NAND\n");
 		func = omap_xload_boot_nand(SZ_128K);
 		break;
+	case OMAP_BOOTSRC_SPI1:
+		printf("booting from SPI1\n");
+		func = omap_xload_boot_spi(SZ_128K);
+		break;
 	}
 
 	if (!func) {
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] xload: make internal functions static
  2012-09-11 11:43 [PATCH 1/2] xload: make internal functions static Jan Luebbe
  2012-09-11 11:43 ` [PATCH 2/2] xload: add SPI as a boot mode Jan Luebbe
@ 2012-09-11 13:55 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-09-11 13:55 UTC (permalink / raw)
  To: Jan Luebbe; +Cc: barebox

On Tue, Sep 11, 2012 at 01:43:27PM +0200, Jan Luebbe wrote:
> Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
> ---
>  arch/arm/mach-omap/include/mach/xload.h |    3 ---
>  arch/arm/mach-omap/xload.c              |    8 ++++----
>  2 files changed, 4 insertions(+), 7 deletions(-)

Applied (both), thanks

Sascha

> 
> diff --git a/arch/arm/mach-omap/include/mach/xload.h b/arch/arm/mach-omap/include/mach/xload.h
> index 26f1b68..9294477 100644
> --- a/arch/arm/mach-omap/include/mach/xload.h
> +++ b/arch/arm/mach-omap/include/mach/xload.h
> @@ -1,9 +1,6 @@
>  #ifndef _MACH_XLOAD_H
>  #define _MACH_XLOAD_H
>  
> -void *omap_xload_boot_nand(int offset);
> -void *omap_xload_boot_mmc(void);
> -
>  enum omap_boot_src {
>  	OMAP_BOOTSRC_UNKNOWN,
>  	OMAP_BOOTSRC_MMC1,
> diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
> index 0afeea9..18a90c9 100644
> --- a/arch/arm/mach-omap/xload.c
> +++ b/arch/arm/mach-omap/xload.c
> @@ -9,7 +9,7 @@
>  #include <sizes.h>
>  #include <filetype.h>
>  
> -void *read_image_head(const char *name)
> +static void *read_image_head(const char *name)
>  {
>  	void *header = xmalloc(ARM_HEAD_SIZE);
>  	struct cdev *cdev;
> @@ -32,7 +32,7 @@ void *read_image_head(const char *name)
>  	return header;
>  }
>  
> -unsigned int get_image_size(void *head)
> +static unsigned int get_image_size(void *head)
>  {
>  	unsigned int ret = 0;
>  	unsigned int *psize = head + ARM_HEAD_SIZE_OFFSET;
> @@ -44,7 +44,7 @@ unsigned int get_image_size(void *head)
>  	return ret;
>  }
>  
> -void *omap_xload_boot_nand(int offset)
> +static void *omap_xload_boot_nand(int offset)
>  {
>  	int ret;
>  	int size;
> @@ -81,7 +81,7 @@ void *omap_xload_boot_nand(int offset)
>  	return to;
>  }
>  
> -void *omap_xload_boot_mmc(void)
> +static void *omap_xload_boot_mmc(void)
>  {
>  	int ret;
>  	void *buf;
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-11 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-11 11:43 [PATCH 1/2] xload: make internal functions static Jan Luebbe
2012-09-11 11:43 ` [PATCH 2/2] xload: add SPI as a boot mode Jan Luebbe
2012-09-11 13:55 ` [PATCH 1/2] xload: make internal functions static Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox