Re: [PATCH] [OpenRISC] Add __ashrdi3 and remove link to libgcc

2012-09-05 Thread Sascha Hauer
Hi Franck,

On Wed, Sep 05, 2012 at 10:37:26PM +0200, Franck Jullien wrote:
> In a previous patch, Sascha needed to add __ashrdi3 and then linked to
> libgcc. This patch add the ashrdi3 function in the arch/openrisc/lib
> directory and remove the libgcc link.

Does this fix any regressions or is it just a do-the-right-thing patch?

> 
> Signed-off-by: Franck Jullien 
> ---
>  arch/openrisc/Makefile  |4 +-
>  arch/openrisc/lib/Makefile  |1 +
>  arch/openrisc/lib/ashrdi3.S |   59 
> +++
>  3 files changed, 62 insertions(+), 2 deletions(-)
>  create mode 100644 arch/openrisc/lib/ashrdi3.S
> 
> diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile
> index 1f4b175..9e88a51 100644
> --- a/arch/openrisc/Makefile
> +++ b/arch/openrisc/Makefile
> @@ -1,6 +1,6 @@
>  CPPFLAGS += -D__OR1K__ -ffixed-r10 -mhard-mul -mhard-div
>  
> -LIBGCC  := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
> +#LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)

Can we remove the line instead?

>  
>  board-$(CONFIG_GENERIC) := generic
>  
> @@ -20,6 +20,6 @@ common-y += $(BOARD)
>  common-y += arch/openrisc/lib/
>  common-y += arch/openrisc/cpu/
>  
> -common-y  += $(LIBGCC)
> +#common-y += $(LIBGCC)

ditto.

Sascha

-- 
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- |

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


barebox ascii art

2012-09-05 Thread Antony Pavlov
Hi, all!

I have made some barebox ascii art based on design by Valery VILLARD.
Use monospace font to see it.



  ##   ##
  ##   ##
  ##   ##
  ## ######   ##   ## ###   ##### ##
  ##   ###### ######  ##  ###  ##   ##### ### #
  ## ##  ####   ##   ####  ## ##  ##   ##   ### ###
  ## ## ##  ## ##   ##   ###   ## ## ## ##   #
  ## ## ##  ## ##   ## ## ## ## ##  ##   ##
   ##   ##   ## ## ######   ##   ##   ##   ##  ## ##
   ### ## ###   ## ## ##  ##### ## ## ##   #   #
    ## ##       ##### ##


  ##
  ##
  # ## ##  #   ##  # ## ##   ##  ##
  #   #   #  ###  #  # #   #   #  #   #  #
  ## #   #   #   #  #  ## ##   ##
  ## ## ## ## ##  #  #
  #   #   #   # # #  # #   #   #  #  ##
   ### ## # #  ##   ### ##   ##  ##


-- 
Best regards,
  Antony Pavlov

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


[PATCH 09/12] graphic_utils: add rgba support

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
this will allow to render rgba image with or without hw support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 include/graphic_utils.h |4 ++
 lib/graphic_utils.c |  116 +--
 2 files changed, 116 insertions(+), 4 deletions(-)

diff --git a/include/graphic_utils.h b/include/graphic_utils.h
index 6d555b2..7cb0b2f 100644
--- a/include/graphic_utils.h
+++ b/include/graphic_utils.h
@@ -7,7 +7,11 @@
 #ifndef __GRAPHIC_UTILS_H__
 #define __GRAPHIC_UTILS_H__
 
+void rgba_blend(struct fb_info *info, void *image, void* dest, int height,
+   int width, int startx, int starty, bool is_rgba);
+void set_pixel(struct fb_info *info, void *adr, u32 px);
 void set_rgb_pixel(struct fb_info *info, void *adr, int r, int g, int b);
+void set_rgba_pixel(struct fb_info *info, void *adr, int r, int g, int b, int 
a);
 void memset_pixel(struct fb_info *info, void* buf, u32 color, size_t size);
 
 #endif /* __GRAPHIC_UTILS_H__ */
diff --git a/lib/graphic_utils.c b/lib/graphic_utils.c
index 2e174d8..4d627b2 100644
--- a/lib/graphic_utils.c
+++ b/lib/graphic_utils.c
@@ -62,14 +62,39 @@ void memset_pixel(struct fb_info *info, void* buf, u32 
color, size_t size)
}
 }
 
-void set_rgb_pixel(struct fb_info *info, void *adr, int r, int g, int b)
+static void get_rgb_pixel(struct fb_info *info, void *adr, int *r ,int *g, int 
*b)
 {
u32 px;
+   u32 rmask, gmask, bmask;
 
-   px = (r >> (8 - info->red.length)) << info->red.offset |
-   (g >> (8 - info->green.length)) << info->green.offset |
-   (b >> (8 - info->blue.length)) << info->blue.offset;
+   switch (info->bits_per_pixel) {
+   case 16:
+   px = *(u16 *)adr;
+   break;
+   case 32:
+   px = *(u32 *)adr;
+   break;
+   case 8:
+   default:
+   return;
+   }
+
+   rmask = (0xff >> (8 - info->blue.length)) << info->blue.offset |
+   (0xff >> (8 - info->green.length)) << info->green.offset;
+
+   gmask = (0xff >> (8 - info->red.length)) << info->red.offset |
+   (0xff >> (8 - info->blue.length)) << info->blue.offset;
+
+   bmask = (0xff >> (8 - info->red.length)) << info->red.offset |
+   (0xff >> (8 - info->green.length)) << info->green.offset;
 
+   *r = ((px & ~rmask) >> info->red.offset) << (8 - info->red.length);
+   *g = ((px & ~gmask) >> info->green.offset) << (8 - info->green.length);
+   *b = ((px & ~bmask) >> info->blue.offset) << (8 - info->blue.length);
+}
+
+void set_pixel(struct fb_info *info, void *adr, u32 px)
+{
switch (info->bits_per_pixel) {
case 8:
break;
@@ -81,3 +106,86 @@ void set_rgb_pixel(struct fb_info *info, void *adr, int r, 
int g, int b)
break;
}
 }
+
+void set_rgb_pixel(struct fb_info *info, void *adr, int r, int g, int b)
+{
+   u32 px;
+
+   px = (r >> (8 - info->red.length)) << info->red.offset |
+   (g >> (8 - info->green.length)) << info->green.offset |
+   (b >> (8 - info->blue.length)) << info->blue.offset;
+
+   set_pixel(info, adr, px);
+}
+
+static int alpha_mux(int s, int d, int a)
+{
+   return (d * a + s * (255 - a)) >> 8;
+}
+
+void set_rgba_pixel(struct fb_info *info, void *adr, int r, int g, int b, int 
a)
+{
+   u32 px = 0x0;
+
+   if (!a)
+   return;
+
+   if (a != 0xff) {
+   if (info->transp.length) {
+   px |= (a >> (8 - info->transp.length)) << 
info->transp.offset;
+   } else {
+   int sr = 0;
+   int sg = 0;
+   int sb = 0;
+
+   get_rgb_pixel(info, adr, &sr, &sg, &sb);
+
+   r = alpha_mux(sr, r, a);
+   g = alpha_mux(sg, g, a);
+   b = alpha_mux(sb, b, a);
+
+   set_rgb_pixel(info, adr, r, g, b);
+
+   return;
+   }
+   }
+
+   px |= (r >> (8 - info->red.length)) << info->red.offset |
+   (g >> (8 - info->green.length)) << info->green.offset |
+   (b >> (8 - info->blue.length)) << info->blue.offset;
+
+   set_pixel(info, adr, px);
+}
+
+void rgba_blend(struct fb_info *info, void *image, void* buf, int height,
+   int width, int startx, int starty, bool is_rgba)
+{
+   unsigned char *adr;
+   int x, y;
+   int xres;
+   int img_byte_per_pixel = 3;
+
+   if (is_rgba)
+   img_byte_per_pixel++;
+
+   xres = info->xres;
+
+   for (y = 0; y < height; y++) {
+   adr = buf + ((y + starty) * xres + startx) *
+   (info->bits_per_pixel >> 3);
+
+   for (x = 0; x < width; x++) {
+   char *pixel;
+
+   pixel = image;
+   if (is_rgba)
+

[PATCH 12/12] png: add picoPNG lib support

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
This is an alternative to LodePNG take from http://forge.voodooprojects.org/
which is base on picoPNG C++ wrote by Lode Vandevenne. The same author as
LodePNG.

PicoPNG only support RGBA PNG8

The source code of picopng.c was just adapat to be compliant to C89 and drop
the interanal ZLIB support. Coding style untouched.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 lib/Kconfig|   19 ++
 lib/Makefile   |3 +-
 lib/picopng.c  |  810 
 lib/picopng.h  |   34 +++
 lib/png_pico.c |  152 +++
 5 files changed, 1017 insertions(+), 1 deletion(-)
 create mode 100644 lib/picopng.c
 create mode 100644 lib/picopng.h
 create mode 100644 lib/png_pico.c

diff --git a/lib/Kconfig b/lib/Kconfig
index 0013b5a..8f05fa4 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -51,6 +51,25 @@ config PNG
bool "png"
select ZLIB
 
+if PNG
+
+choice
+   prompt "PNG Lib"
+
+config LODEPNG
+   bool "lodePNG"
+   help
+ Mostly PNG support
+
+config PICOPNG
+   bool "picoPNG"
+   help
+ Support only RGBA PNG8
+
+endchoice
+
+endif
+
 endif
 
 endmenu
diff --git a/lib/Makefile b/lib/Makefile
index 4944319..733bd8c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -37,4 +37,5 @@ obj-$(CONFIG_QSORT)   += qsort.o
 obj-$(CONFIG_BMP)  += bmp.o
 obj-$(CONFIG_IMAGE_RENDERER)   += image_renderer.o graphic_utils.o
 obj-$(CONFIG_IMAGE_RENDERER)   += image_renderer.o
-obj-$(CONFIG_PNG)  += png.o lodepng.o
+obj-$(CONFIG_LODEPNG)  += png_lode.o lodepng.o
+obj-$(CONFIG_PICOPNG)  += png_pico.o picopng.o
diff --git a/lib/picopng.c b/lib/picopng.c
new file mode 100644
index 000..77cd81c
--- /dev/null
+++ b/lib/picopng.c
@@ -0,0 +1,810 @@
+// picoPNG version 20080503 (cleaned up and ported to c by kaitek)
+// Copyright (c) 2005-2008 Lode Vandevenne
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+//   1. The origin of this software must not be misrepresented; you must not
+//  claim that you wrote the original software. If you use this software
+//  in a product, an acknowledgment in the product documentation would be
+//  appreciated but is not required.
+//   2. Altered source versions must be plainly marked as such, and must not be
+//  misrepresented as being the original software.
+//   3. This notice may not be removed or altered from any source distribution.
+
+#include 
+#include 
+#include "picopng.h"
+
+/*/
+
+typedef struct png_alloc_node {
+   struct png_alloc_node *prev, *next;
+   void *addr;
+   size_t size;
+} png_alloc_node_t;
+
+png_alloc_node_t *png_alloc_head = NULL;
+png_alloc_node_t *png_alloc_tail = NULL;
+
+png_alloc_node_t *png_alloc_find_node(void *addr)
+{
+   png_alloc_node_t *node;
+   for (node = png_alloc_head; node; node = node->next)
+   if (node->addr == addr)
+   break;
+   return node;
+}
+
+void png_alloc_add_node(void *addr, size_t size)
+{
+   png_alloc_node_t *node;
+   if (png_alloc_find_node(addr))
+   return;
+   node = malloc(sizeof (png_alloc_node_t));
+   node->addr = addr;
+   node->size = size;
+   node->prev = png_alloc_tail;
+   node->next = NULL;
+   png_alloc_tail = node;
+   if (node->prev)
+   node->prev->next = node;
+   if (!png_alloc_head)
+   png_alloc_head = node;
+}
+
+void png_alloc_remove_node(png_alloc_node_t *node)
+{
+   if (node->prev)
+   node->prev->next = node->next;
+   if (node->next)
+   node->next->prev = node->prev;
+   if (node == png_alloc_head)
+   png_alloc_head = node->next;
+   if (node == png_alloc_tail)
+   png_alloc_tail = node->prev;
+   node->prev = node->next = node->addr = NULL;
+   free(node);
+}
+
+void *png_alloc_malloc(size_t size)
+{
+   void *addr = malloc(size);
+   png_alloc_add_node(addr, size);
+   return addr;
+}
+
+void *png_alloc_realloc(void *addr, size_t size)
+{
+   void *new_addr;
+   if (!addr)
+   return png_alloc_malloc(size);
+   new_addr = realloc(addr, size);
+   if (new_addr != addr) {
+   png_alloc_node_t *old_node;
+   old_node = png_alloc_find_node(addr);
+   png_alloc_remove_node(old_node);
+   png_alloc_add_node(new_addr, size);
+   }
+   return new_addr;
+}
+
+void png_alloc_free(void *addr)
+{
+   png_alloc_node_t *node = png_alloc_find_node(addr);
+   if

[PATCH 08/12] Introduce graphic utils

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
to Factorise pixel rendering

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 commands/splash.c|   61 +-
 include/graphic_utils.h  |   13 
 include/image_renderer.h |   20 ---
 lib/Makefile |1 +
 lib/bmp.c|5 +--
 lib/graphic_utils.c  |   83 ++
 6 files changed, 101 insertions(+), 82 deletions(-)
 create mode 100644 include/graphic_utils.h
 create mode 100644 lib/graphic_utils.c

diff --git a/commands/splash.c b/commands/splash.c
index 4bddc6c..f4b975b 100644
--- a/commands/splash.c
+++ b/commands/splash.c
@@ -8,66 +8,7 @@
 #include 
 #include 
 #include 
-
-static u32 get_pixel(struct fb_info *info, u32 color)
-{
-   u32 px;
-   u8 t = (color >> 24) & 0xff;
-   u8 r = (color >> 16) & 0xff;
-   u8 g = (color >> 8 ) & 0xff;
-   u8 b = (color >> 0 ) & 0xff;
-
-   if (info->grayscale) {
-px = (r | g | b) ? 0x : 0x0;
-return px;
-   }
-
-   px = (t >> (8 - info->transp.length)) << info->transp.offset |
-(r >> (8 - info->red.length)) << info->red.offset |
-(g >> (8 - info->green.length)) << info->green.offset |
-(b >> (8 - info->blue.length)) << info->blue.offset;
-
-   return px;
-}
-
-static void memsetw(void *s, u16 c, size_t n)
-{
-   size_t i;
-   u16* tmp = s;
-
-   for (i = 0; i < n; i++)
-   *tmp++ = c;
-}
-
-static void memsetl(void *s, u32 c, size_t n)
-{
-   size_t i;
-   u32* tmp = s;
-
-   for (i = 0; i < n; i++)
-   *tmp++ = c;
-}
-
-static void memset_pixel(struct fb_info *info, void* buf, u32 color, size_t 
size)
-{
-   u32 px;
-   u8 *screen = buf;
-
-   px = get_pixel(info, color);
-
-   switch (info->bits_per_pixel) {
-   case 8:
-   memset(screen, (uint8_t)px, size);
-   break;
-   case 16:
-   memsetw(screen, (uint16_t)px, size);
-   break;
-   case 32:
-   case 24:
-   memsetl(screen, px, size);
-   break;
-   }
-}
+#include 
 
 static int do_splash(int argc, char *argv[])
 {
diff --git a/include/graphic_utils.h b/include/graphic_utils.h
new file mode 100644
index 000..6d555b2
--- /dev/null
+++ b/include/graphic_utils.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD 
+ *
+ * GPL v2
+ */
+
+#ifndef __GRAPHIC_UTILS_H__
+#define __GRAPHIC_UTILS_H__
+
+void set_rgb_pixel(struct fb_info *info, void *adr, int r, int g, int b);
+void memset_pixel(struct fb_info *info, void* buf, u32 color, size_t size);
+
+#endif /* __GRAPHIC_UTILS_H__ */
diff --git a/include/image_renderer.h b/include/image_renderer.h
index a93242c..d735cf7 100644
--- a/include/image_renderer.h
+++ b/include/image_renderer.h
@@ -19,26 +19,6 @@ struct image_renderer {
struct list_head list;
 };
 
-static inline void set_pixel(struct fb_info *info, void *adr, int r, int g, 
int b)
-{
-   u32 px;
-
-   px = (r >> (8 - info->red.length)) << info->red.offset |
-   (g >> (8 - info->green.length)) << info->green.offset |
-   (b >> (8 - info->blue.length)) << info->blue.offset;
-
-   switch (info->bits_per_pixel) {
-   case 8:
-   break;
-   case 16:
-   *(u16 *)adr = px;
-   break;
-   case 32:
-   *(u32 *)adr = px;
-   break;
-   }
-}
-
 #ifdef CONFIG_IMAGE_RENDERER
 int image_renderer_register(struct image_renderer *ir);
 void image_render_unregister(struct image_renderer *ir);
diff --git a/lib/Makefile b/lib/Makefile
index 8fbae8a..96b7c56 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -35,4 +35,5 @@ obj-$(CONFIG_BCH) += bch.o
 obj-$(CONFIG_BITREV)   += bitrev.o
 obj-$(CONFIG_QSORT)+= qsort.o
 obj-$(CONFIG_BMP)  += bmp.o
+obj-$(CONFIG_IMAGE_RENDERER)   += image_renderer.o graphic_utils.o
 obj-$(CONFIG_IMAGE_RENDERER)   += image_renderer.o
diff --git a/lib/bmp.c b/lib/bmp.c
index 573cf97..8986930 100644
--- a/lib/bmp.c
+++ b/lib/bmp.c
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int bmp_renderer(struct fb_info *info, void* data, int size, void* fb,
int startx, int starty, void* offscreenbuf)
@@ -57,7 +58,7 @@ static int bmp_renderer(struct fb_info *info, void* data, int 
size, void* fb,
 
pixel = *image;
 
-   set_pixel(info, adr, color_table[pixel].red,
+   set_rgb_pixel(info, adr, color_table[pixel].red,
color_table[pixel].green,
color_table[pixel].blue);
adr += info->bits_per_pixel >> 3;
@@ -79,7 +80,7 @@ static int bmp_renderer(struct fb_info *info, void* data, int 
size, void* fb,
 
 

[PATCH 10/12] filetype: add PNG support

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 common/filetype.c  |3 +++
 include/filetype.h |1 +
 2 files changed, 4 insertions(+)

diff --git a/common/filetype.c b/common/filetype.c
index 5710394..0eaf119 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -71,6 +71,7 @@ static int is_fat(u8 *buf)
 enum filetype file_detect_type(void *_buf)
 {
u32 *buf = _buf;
+   u64 *buf64 = _buf;
u8 *buf8 = _buf;
 
if (strncmp(buf8, "#!/bin/sh", 9) == 0)
@@ -103,6 +104,8 @@ enum filetype file_detect_type(void *_buf)
return filetype_fat;
if (strncmp(buf8, "BM", 2) == 0)
return filetype_bmp;
+   if (buf64[0] == le64_to_cpu(0x0a1a0a0d474e5089ull))
+   return filetype_png;
 
return filetype_unknown;
 }
diff --git a/include/filetype.h b/include/filetype.h
index 6c97159..2924032 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -20,6 +20,7 @@ enum filetype {
filetype_mips_barebox,
filetype_fat,
filetype_bmp,
+   filetype_png,
 };
 
 const char *file_type_to_string(enum filetype f);
-- 
1.7.10.4


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


[PATCH 02/12] bmp: rename it to splash

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
so be can add more format support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 Documentation/commands.dox |2 +-
 arch/arm/boards/eukrea_cpuimx25/env/bin/init_board |4 ++--
 arch/arm/boards/eukrea_cpuimx27/env/bin/init   |4 ++--
 arch/arm/boards/eukrea_cpuimx35/env/bin/init_board |4 ++--
 arch/arm/boards/eukrea_cpuimx51/env/bin/init_board |4 ++--
 arch/arm/boards/karo-tx25/env/bin/init_board   |2 +-
 arch/arm/boards/mioa701/env/bin/init   |2 +-
 arch/arm/configs/chumbyone_defconfig   |2 +-
 arch/arm/configs/cupid_defconfig   |2 +-
 arch/arm/configs/eukrea_cpuimx25_defconfig |2 +-
 arch/arm/configs/eukrea_cpuimx27_defconfig |2 +-
 arch/arm/configs/eukrea_cpuimx35_defconfig |2 +-
 arch/arm/configs/freescale_mx35_3stack_defconfig   |2 +-
 arch/arm/configs/imx28evk_defconfig|2 +-
 arch/arm/configs/mioa701_defconfig |2 +-
 arch/arm/configs/neso_defconfig|2 +-
 arch/arm/configs/pcm027_defconfig  |2 +-
 arch/arm/configs/pcm038_defconfig  |2 +-
 arch/arm/configs/tx25stk5_defconfig|2 +-
 arch/arm/configs/tx28stk5_defconfig|2 +-
 commands/Kconfig   |4 ++--
 commands/Makefile  |2 +-
 commands/{bmp.c => splash.c}   |   12 ++--
 23 files changed, 33 insertions(+), 33 deletions(-)
 rename commands/{bmp.c => splash.c} (95%)

diff --git a/Documentation/commands.dox b/Documentation/commands.dox
index 5ef7829..d8cfa6b 100644
--- a/Documentation/commands.dox
+++ b/Documentation/commands.dox
@@ -18,7 +18,6 @@ available in @a Barebox:
 @li @subpage _name
 @li @subpage addpart_command
 @li @subpage alternate
-@li @subpage bmp_command
 @li @subpage bootm_command
 @li @subpage bootu
 @li @subpage bootz
@@ -95,6 +94,7 @@ available in @a Barebox:
 @li @subpage sh
 @li @subpage sleep
 @li @subpage source
+@li @subpage splash_command
 @li @subpage test
 @li @subpage timeout
 @li @subpage true
diff --git a/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board 
b/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board
index ff3365d..58e07e0 100644
--- a/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board
+++ b/arch/arm/boards/eukrea_cpuimx25/env/bin/init_board
@@ -1,11 +1,11 @@
 #!/bin/sh
 
 if [ -f /env/logo.bmp ]; then
-   bmp /env/logo.bmp
+   splash /env/logo.bmp
fb0.enable=1
 elif [ -f /env/logo.bmp.lzo ]; then
uncompress /env/logo.bmp.lzo /logo.bmp
-   bmp /logo.bmp
+   splash /logo.bmp
fb0.enable=1
 fi
 
diff --git a/arch/arm/boards/eukrea_cpuimx27/env/bin/init 
b/arch/arm/boards/eukrea_cpuimx27/env/bin/init
index f84ace9..cd74974 100644
--- a/arch/arm/boards/eukrea_cpuimx27/env/bin/init
+++ b/arch/arm/boards/eukrea_cpuimx27/env/bin/init
@@ -17,11 +17,11 @@ if [ -e /dev/nand0 ]; then
 fi
 
 if [ -f /env/logo.bmp ]; then
-   bmp /env/logo.bmp
+   splash /env/logo.bmp
fb0.enable=1
 elif [ -f /env/logo.bmp.lzo ]; then
uncompress /env/logo.bmp.lzo /logo.bmp
-   bmp /logo.bmp
+   splash /logo.bmp
fb0.enable=1
 fi
 
diff --git a/arch/arm/boards/eukrea_cpuimx35/env/bin/init_board 
b/arch/arm/boards/eukrea_cpuimx35/env/bin/init_board
index 89fd9a9..2a07a84 100644
--- a/arch/arm/boards/eukrea_cpuimx35/env/bin/init_board
+++ b/arch/arm/boards/eukrea_cpuimx35/env/bin/init_board
@@ -1,12 +1,12 @@
 #!/bin/sh
 
 if [ -f /env/logo.bmp ]; then
-   bmp /env/logo.bmp
+   splash /env/logo.bmp
fb0.enable=1
gpio_set_value 1 1
 elif [ -f /env/logo.bmp.lzo ]; then
uncompress /env/logo.bmp.lzo /logo.bmp
-   bmp /logo.bmp
+   splash /logo.bmp
fb0.enable=1
gpio_set_value 1 1
 fi
diff --git a/arch/arm/boards/eukrea_cpuimx51/env/bin/init_board 
b/arch/arm/boards/eukrea_cpuimx51/env/bin/init_board
index cb624e5..0af6582 100644
--- a/arch/arm/boards/eukrea_cpuimx51/env/bin/init_board
+++ b/arch/arm/boards/eukrea_cpuimx51/env/bin/init_board
@@ -1,12 +1,12 @@
 #!/bin/sh
 
 if [ -f /env/logo.bmp ]; then
-   bmp /env/logo.bmp
+   splash /env/logo.bmp
fb0.enable=1
gpio_set_value 1 1
 elif [ -f /env/logo.bmp.lzo ]; then
uncompress /env/logo.bmp.lzo /logo.bmp
-   bmp /logo.bmp
+   splash /logo.bmp
fb0.enable=1
gpio_set_value 1 1
 fi
diff --git a/arch/arm/boards/karo-tx25/env/bin/init_board 
b/arch/arm/boards/karo-tx25/env/bin/init_board
index b17c55d..1f35c96 100644
--- a/arch/arm/boards/karo-tx25/env/bin/init_board
+++ b/arch/arm/boards/karo-tx25/env/bin/init_board
@@ -1,6 +1,6 @@
 
 if [ -e /dev/fb0 -a -e /env/splash.bmp ]; then
-   bmp /env/splash.bmp
+   splash /env/splash.bmp
fb0.enable=1
 fi
 
diff --git a/arch/arm/boards/mioa701/env/bin/init 
b/arch/arm/boards/mioa701/e

[PATCH 06/12] splash/bmp: switch to image_renderer

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 commands/Kconfig  |1 +
 commands/splash.c |   10 +++
 lib/Kconfig   |1 +
 lib/bmp.c |   63 +
 {include => lib}/bmp_layout.h |0
 5 files changed, 26 insertions(+), 49 deletions(-)
 rename {include => lib}/bmp_layout.h (100%)

diff --git a/commands/Kconfig b/commands/Kconfig
index 9107a3e..97993c1 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -538,6 +538,7 @@ config CMD_LSMOD
 config CMD_SPLASH
bool
depends on VIDEO
+   select IMAGE_RENDERER
select BMP
prompt "splash"
help
diff --git a/commands/splash.c b/commands/splash.c
index ad73778..88a6cf1 100644
--- a/commands/splash.c
+++ b/commands/splash.c
@@ -7,7 +7,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 static int do_splash(int argc, char *argv[])
 {
@@ -15,7 +15,7 @@ static int do_splash(int argc, char *argv[])
char *fbdev = "/dev/fb0";
void *fb;
struct fb_info info;
-   char *bmpfile;
+   char *image_file;
int startx = -1, starty = -1;
int xres, yres;
int offscreen = 0;
@@ -40,7 +40,7 @@ static int do_splash(int argc, char *argv[])
printf("no filename given\n");
return 1;
}
-   bmpfile = argv[optind];
+   image_file = argv[optind];
 
fd = open(fbdev, O_RDWR);
if (fd < 0) {
@@ -75,8 +75,8 @@ static int do_splash(int argc, char *argv[])
memcpy(offscreenbuf, fb, fbsize);
}
 
-   if (bmp_render_file(&info, bmpfile, fb, startx, starty, xres, yres,
-   offscreenbuf) < 0)
+   if (image_renderer_file(&info, image_file, fb, startx, starty,
+   offscreenbuf) < 0)
ret = 1;
 
if (offscreenbuf)
diff --git a/lib/Kconfig b/lib/Kconfig
index e74189d..9ec2095 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -43,5 +43,6 @@ config IMAGE_RENDERER
 
 config BMP
bool
+   depends on IMAGE_RENDERER
 
 endmenu
diff --git a/lib/bmp.c b/lib/bmp.c
index 776d3b3..573cf97 100644
--- a/lib/bmp.c
+++ b/lib/bmp.c
@@ -1,54 +1,23 @@
 #include 
-#include 
 #include 
-#include 
 #include 
-#include 
+#include "bmp_layout.h"
 #include 
+#include 
+#include 
 
-static inline void set_pixel(struct fb_info *info, void *adr, int r, int g, 
int b)
+static int bmp_renderer(struct fb_info *info, void* data, int size, void* fb,
+   int startx, int starty, void* offscreenbuf)
 {
-   u32 px;
-
-   px = (r >> (8 - info->red.length)) << info->red.offset |
-   (g >> (8 - info->green.length)) << info->green.offset |
-   (b >> (8 - info->blue.length)) << info->blue.offset;
-
-   switch (info->bits_per_pixel) {
-   case 8:
-   break;
-   case 16:
-   *(u16 *)adr = px;
-   break;
-   case 32:
-   *(u32 *)adr = px;
-   break;
-   }
-}
-
-int bmp_render_file(struct fb_info *info, const char* bmpfile, void* fb,
-   int startx, int starty, int xres, int yres, void* 
offscreenbuf)
-{
-   struct bmp_image *bmp;
+   struct bmp_image *bmp = data;
int sw, sh, width, height;
int bits_per_pixel, fbsize;
-   int bmpsize;
-   int ret = 0;
void *adr, *buf;
char *image;
+   int xres, yres;
 
-   bmp = read_file(bmpfile, &bmpsize);
-   if (!bmp) {
-   printf("unable to read %s\n", bmpfile);
-   return -ENOMEM;
-   }
-
-   if (bmp->header.signature[0] != 'B' ||
- bmp->header.signature[1] != 'M') {
-   printf("No valid bmp file\n");
-   ret = -EINVAL;
-   goto err;
-   }
+   xres = info->xres;
+   yres = info->yres;
 
sw = le32_to_cpu(bmp->header.width);
sh = le32_to_cpu(bmp->header.height);
@@ -123,10 +92,16 @@ int bmp_render_file(struct fb_info *info, const char* 
bmpfile, void* fb,
if (offscreenbuf)
memcpy(fb, offscreenbuf, fbsize);
 
-   free(bmp);
return sh;
+}
 
-err:
-   free(bmp);
-   return ret;
+static struct image_renderer bmp = {
+   .type = filetype_bmp,
+   .renderer = bmp_renderer,
+};
+
+static int bmp_init(void)
+{
+   return image_renderer_register(&bmp);
 }
+fs_initcall(bmp_init);
diff --git a/include/bmp_layout.h b/lib/bmp_layout.h
similarity index 100%
rename from include/bmp_layout.h
rename to lib/bmp_layout.h
-- 
1.7.10.4


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


[PATCH 07/12] splash: add support to set a background color

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to reset the screen to a default color when using transparent
PNG.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 commands/splash.c |   79 +++--
 1 file changed, 76 insertions(+), 3 deletions(-)

diff --git a/commands/splash.c b/commands/splash.c
index 88a6cf1..4bddc6c 100644
--- a/commands/splash.c
+++ b/commands/splash.c
@@ -9,6 +9,66 @@
 #include 
 #include 
 
+static u32 get_pixel(struct fb_info *info, u32 color)
+{
+   u32 px;
+   u8 t = (color >> 24) & 0xff;
+   u8 r = (color >> 16) & 0xff;
+   u8 g = (color >> 8 ) & 0xff;
+   u8 b = (color >> 0 ) & 0xff;
+
+   if (info->grayscale) {
+px = (r | g | b) ? 0x : 0x0;
+return px;
+   }
+
+   px = (t >> (8 - info->transp.length)) << info->transp.offset |
+(r >> (8 - info->red.length)) << info->red.offset |
+(g >> (8 - info->green.length)) << info->green.offset |
+(b >> (8 - info->blue.length)) << info->blue.offset;
+
+   return px;
+}
+
+static void memsetw(void *s, u16 c, size_t n)
+{
+   size_t i;
+   u16* tmp = s;
+
+   for (i = 0; i < n; i++)
+   *tmp++ = c;
+}
+
+static void memsetl(void *s, u32 c, size_t n)
+{
+   size_t i;
+   u32* tmp = s;
+
+   for (i = 0; i < n; i++)
+   *tmp++ = c;
+}
+
+static void memset_pixel(struct fb_info *info, void* buf, u32 color, size_t 
size)
+{
+   u32 px;
+   u8 *screen = buf;
+
+   px = get_pixel(info, color);
+
+   switch (info->bits_per_pixel) {
+   case 8:
+   memset(screen, (uint8_t)px, size);
+   break;
+   case 16:
+   memsetw(screen, (uint16_t)px, size);
+   break;
+   case 32:
+   case 24:
+   memsetl(screen, px, size);
+   break;
+   }
+}
+
 static int do_splash(int argc, char *argv[])
 {
int ret, opt, fd;
@@ -19,13 +79,19 @@ static int do_splash(int argc, char *argv[])
int startx = -1, starty = -1;
int xres, yres;
int offscreen = 0;
+   u32 bg_color = 0x;
+   bool do_bg = false;
void *offscreenbuf = NULL;
 
-   while((opt = getopt(argc, argv, "f:x:y:o")) > 0) {
+   while((opt = getopt(argc, argv, "f:x:y:ob:")) > 0) {
switch(opt) {
case 'f':
fbdev = optarg;
break;
+   case 'b':
+   bg_color = simple_strtoul(optarg, NULL, 0);
+   do_bg = true;
+   break;
case 'x':
startx = simple_strtoul(optarg, NULL, 0);
break;
@@ -71,8 +137,14 @@ static int do_splash(int argc, char *argv[])
 
fbsize = xres * yres * (info.bits_per_pixel >> 3);
offscreenbuf = malloc(fbsize);
-   if (offscreenbuf)
-   memcpy(offscreenbuf, fb, fbsize);
+   if (offscreenbuf) {
+   if (do_bg)
+   memset_pixel(&info, offscreenbuf, bg_color, 
xres * yres);
+   else
+   memcpy(offscreenbuf, fb, fbsize);
+   }
+   } else if (do_bg) {
+   memset_pixel(&info, fb, bg_color, xres * yres);
}
 
if (image_renderer_file(&info, image_file, fb, startx, starty,
@@ -98,6 +170,7 @@ BAREBOX_CMD_HELP_SHORT("Show the bitmap FILE on the 
framebuffer.\n")
 BAREBOX_CMD_HELP_OPT  ("-f ",   "framebuffer device (/dev/fb0)\n")
 BAREBOX_CMD_HELP_OPT  ("-x ", "x offset (default center)\n")
 BAREBOX_CMD_HELP_OPT  ("-y ", "y offset (default center)\n")
+BAREBOX_CMD_HELP_OPT  ("-b ", "backgroung color\n")
 BAREBOX_CMD_HELP_OPT  ("-o","render offscreen\n")
 BAREBOX_CMD_HELP_END
 
-- 
1.7.10.4


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


[PATCH 04/12] introduce image_renderer framework

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to support bmp and png

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 include/image_renderer.h |   62 +++
 lib/Kconfig  |3 ++
 lib/Makefile |1 +
 lib/image_renderer.c |   73 ++
 4 files changed, 139 insertions(+)
 create mode 100644 include/image_renderer.h
 create mode 100644 lib/image_renderer.c

diff --git a/include/image_renderer.h b/include/image_renderer.h
new file mode 100644
index 000..a93242c
--- /dev/null
+++ b/include/image_renderer.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD 
+ *
+ * GPL v2
+ */
+
+#ifndef __IMAGE_RENDER_H__
+#define __IMAGE_RENDER_H__
+
+#include 
+#include 
+#include 
+
+struct image_renderer {
+   enum filetype type;
+   int (*renderer)(struct fb_info *info, void* data, int size, void* fb,
+   int startx, int starty, void* offscreenbuf);
+
+   struct list_head list;
+};
+
+static inline void set_pixel(struct fb_info *info, void *adr, int r, int g, 
int b)
+{
+   u32 px;
+
+   px = (r >> (8 - info->red.length)) << info->red.offset |
+   (g >> (8 - info->green.length)) << info->green.offset |
+   (b >> (8 - info->blue.length)) << info->blue.offset;
+
+   switch (info->bits_per_pixel) {
+   case 8:
+   break;
+   case 16:
+   *(u16 *)adr = px;
+   break;
+   case 32:
+   *(u32 *)adr = px;
+   break;
+   }
+}
+
+#ifdef CONFIG_IMAGE_RENDERER
+int image_renderer_register(struct image_renderer *ir);
+void image_render_unregister(struct image_renderer *ir);
+
+int image_renderer_file(struct fb_info *info, const char* bmpfile, void* fb,
+   int startx, int starty, void* offscreenbuf);
+#else
+static inline int image_renderer_register(struct image_renderer *ir)
+{
+   return -EINVAL;
+}
+static inline void image_renderer_unregister(struct image_renderer *ir) {}
+
+static inline int image_renderer_file(struct fb_info *info, const char* file, 
void* fb,
+   int startx, int starty, void* offscreenbuf)
+{
+   return -EINVAL;
+}
+#endif
+
+#endif /* __IMAGE_RENDERER_H__ */
diff --git a/lib/Kconfig b/lib/Kconfig
index 93e360b..e74189d 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -38,6 +38,9 @@ config BITREV
 config QSORT
bool
 
+config IMAGE_RENDERER
+   bool
+
 config BMP
bool
 
diff --git a/lib/Makefile b/lib/Makefile
index df4b5e5..8fbae8a 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -35,3 +35,4 @@ obj-$(CONFIG_BCH) += bch.o
 obj-$(CONFIG_BITREV)   += bitrev.o
 obj-$(CONFIG_QSORT)+= qsort.o
 obj-$(CONFIG_BMP)  += bmp.o
+obj-$(CONFIG_IMAGE_RENDERER)   += image_renderer.o
diff --git a/lib/image_renderer.c b/lib/image_renderer.c
new file mode 100644
index 000..e8d4ab5
--- /dev/null
+++ b/lib/image_renderer.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD 
+ *
+ * GPL v2
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static LIST_HEAD(image_renderers);
+
+static struct image_renderer *get_renderer(void* buf)
+{
+   struct image_renderer *ir;
+   enum filetype type = file_detect_type(buf);
+
+   list_for_each_entry(ir, &image_renderers, list) {
+   if (ir->type == type)
+   return ir;
+   }
+
+   return NULL;
+}
+
+int image_renderer_file(struct fb_info *info, const char* file, void* fb,
+   int startx, int starty, void* offscreenbuf)
+{
+   void *data;
+   int size;
+   struct image_renderer *ir;
+   int ret;
+
+   data = read_file(file, &size);
+   if (!data) {
+   printf("unable to read %s\n", file);
+   return -ENOMEM;
+   }
+
+   ir = get_renderer(data);
+   if (!ir) {
+   ret = -ENOENT;
+   goto out;
+   }
+
+   ret = ir->renderer(info, data, size, fb, startx, starty, offscreenbuf);
+
+out:
+   free(data);
+
+   return ret;
+}
+
+int image_renderer_register(struct image_renderer *ir)
+{
+   if (!ir || !ir->type || !ir->renderer)
+   return -EIO;
+
+   list_add_tail(&ir->list, &image_renderers);
+
+   return 0;
+}
+
+void image_renderer_unregister(struct image_renderer *ir)
+{
+   if (!ir)
+   return;
+
+   list_del(&ir->list);
+}
-- 
1.7.10.4


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


[PATCH 03/12] bmp: split bmp rending in lib/bmp.c

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
So we can add other format support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 commands/Kconfig |1 +
 commands/splash.c|  124 +--
 include/bmp_layout.h |   11 +
 lib/Kconfig  |3 ++
 lib/Makefile |1 +
 lib/bmp.c|  132 ++
 6 files changed, 159 insertions(+), 113 deletions(-)
 create mode 100644 lib/bmp.c

diff --git a/commands/Kconfig b/commands/Kconfig
index c4623fa..9107a3e 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -538,6 +538,7 @@ config CMD_LSMOD
 config CMD_SPLASH
bool
depends on VIDEO
+   select BMP
prompt "splash"
help
  show bmp files on framebuffer devices
diff --git a/commands/splash.c b/commands/splash.c
index 6526b20..ad73778 100644
--- a/commands/splash.c
+++ b/commands/splash.c
@@ -8,43 +8,18 @@
 #include 
 #include 
 #include 
-#include 
-
-static inline void set_pixel(struct fb_info *info, void *adr, int r, int g, 
int b)
-{
-   u32 px;
-
-   px = (r >> (8 - info->red.length)) << info->red.offset |
-   (g >> (8 - info->green.length)) << info->green.offset |
-   (b >> (8 - info->blue.length)) << info->blue.offset;
-
-   switch (info->bits_per_pixel) {
-   case 8:
-   break;
-   case 16:
-   *(u16 *)adr = px;
-   break;
-   case 32:
-   *(u32 *)adr = px;
-   break;
-   }
-}
 
 static int do_splash(int argc, char *argv[])
 {
int ret, opt, fd;
char *fbdev = "/dev/fb0";
-   void *fb, *offscreenbuf = NULL;
+   void *fb;
struct fb_info info;
-   struct bmp_image *bmp;
char *bmpfile;
-   int bmpsize;
-   char *image;
-   int sw, sh, width, height, startx = -1, starty = -1;
-   int bits_per_pixel, fbsize;
+   int startx = -1, starty = -1;
int xres, yres;
int offscreen = 0;
-   void *adr, *buf;
+   void *offscreenbuf = NULL;
 
while((opt = getopt(argc, argv, "f:x:y:o")) > 0) {
switch(opt) {
@@ -88,105 +63,28 @@ static int do_splash(int argc, char *argv[])
xres = info.xres;
yres = info.yres;
 
-   bmp = read_file(bmpfile, &bmpsize);
-   if (!bmp) {
-   printf("unable to read %s\n", bmpfile);
-   goto failed_memmap;
-   }
-
-   if (bmp->header.signature[0] != 'B' ||
- bmp->header.signature[1] != 'M') {
-   printf("No valid bmp file\n");
-   }
-
-   sw = le32_to_cpu(bmp->header.width);
-   sh = le32_to_cpu(bmp->header.height);
-
-   if (startx < 0) {
-   startx = (xres - sw) / 2;
-   if (startx < 0)
-   startx = 0;
-   }
-
-   if (starty < 0) {
-   starty = (yres - sh) / 2;
-   if (starty < 0)
-   starty = 0;
-   }
-
-   width = min(sw, xres - startx);
-   height = min(sh, yres - starty);
-
-   bits_per_pixel = le16_to_cpu(bmp->header.bit_count);
-   fbsize = xres * yres * (info.bits_per_pixel >> 3);
-
if (offscreen) {
+   int fbsize;
/* Don't fail if malloc fails, just continue rendering directly
 * on the framebuffer
 */
+
+   fbsize = xres * yres * (info.bits_per_pixel >> 3);
offscreenbuf = malloc(fbsize);
if (offscreenbuf)
memcpy(offscreenbuf, fb, fbsize);
}
 
-   buf = offscreenbuf ? offscreenbuf : fb;
-
-   if (bits_per_pixel == 8) {
-   int x, y;
-   struct bmp_color_table_entry *color_table = bmp->color_table;
-
-   for (y = 0; y < height; y++) {
-   image = (char *)bmp +
-   le32_to_cpu(bmp->header.data_offset);
-   image += (sh - y - 1) * sw * (bits_per_pixel >> 3);
-   adr = buf + ((y + starty) * xres + startx) *
-   (info.bits_per_pixel >> 3);
-   for (x = 0; x < width; x++) {
-   int pixel;
+   if (bmp_render_file(&info, bmpfile, fb, startx, starty, xres, yres,
+   offscreenbuf) < 0)
+   ret = 1;
 
-   pixel = *image;
-
-   set_pixel(&info, adr, color_table[pixel].red,
-   color_table[pixel].green,
-   color_table[pixel].blue);
-   adr += info.bits_per_pixel >> 3;
-
-   image += bits_per_pixel >> 3;
-   }
-   }
-   } else if (bits_per_pixel == 24) {
-   int x, y;
-
-   for (y = 0; y < height; y++) {
-

[PATCH 01/12] add barebox logo

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
in logo/ you will found the barebox logo with color or white
in:
 - bmp (black background)
 - png24 (transparent or black background)
 - png8 (black background)

for the following size
 - 100x100
 - 200x200
 - 400x400
 - 600x600
 - 800x800
 - 900x900

The logo are origanize in a way to be able to include them in the envfs
by just point as it.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 logo/bmp/100x100/color/blackbg/barebox.bmp   |  Bin 0 -> 30056 bytes
 logo/bmp/100x100/white/blackbg/barebox.bmp   |  Bin 0 -> 30056 bytes
 logo/bmp/200x200/color/blackbg/barebox.bmp   |  Bin 0 -> 120056 bytes
 logo/bmp/200x200/white/blackbg/barebox.bmp   |  Bin 0 -> 120056 bytes
 logo/bmp/400x400/color/blackbg/barebox.bmp   |  Bin 0 -> 480056 bytes
 logo/bmp/400x400/white/blackbg/barebox.bmp   |  Bin 0 -> 480056 bytes
 logo/bmp/600x600/color/blackbg/barebox.bmp   |  Bin 0 -> 1080056 bytes
 logo/bmp/600x600/while/blackbg/barebox.bmp   |  Bin 0 -> 1080056 bytes
 logo/bmp/800x800/color/blackbg/barebox.bmp   |  Bin 0 -> 1920056 bytes
 logo/bmp/800x800/white/blackbg/barebox.bmp   |  Bin 0 -> 1920056 bytes
 logo/bmp/900x900/color/blackbg/barebox.bmp   |  Bin 0 -> 2430056 bytes
 logo/bmp/900x900/white/blackbg/barebox.bmp   |  Bin 0 -> 2430056 bytes
 logo/png24/100x100/color/barebox.png |  Bin 0 -> 22724 bytes
 logo/png24/100x100/color/blackbg/barebox.png |  Bin 0 -> 19254 bytes
 logo/png24/100x100/white/barebox.png |  Bin 0 -> 12053 bytes
 logo/png24/100x100/white/blackbg/barebox.png |  Bin 0 -> 10940 bytes
 logo/png24/200x200/color/barebox.png |  Bin 0 -> 71557 bytes
 logo/png24/200x200/color/blackbg/barebox.png |  Bin 0 -> 60836 bytes
 logo/png24/200x200/white/barebox.png |  Bin 0 -> 31132 bytes
 logo/png24/200x200/white/blackbg/barebox.png |  Bin 0 -> 28578 bytes
 logo/png24/400x400/color/barebox.png |  Bin 0 -> 217170 bytes
 logo/png24/400x400/color/blackbg/barebox.png |  Bin 0 -> 188172 bytes
 logo/png24/400x400/white/barebox.png |  Bin 0 -> 78591 bytes
 logo/png24/400x400/white/blackbg/barebox.png |  Bin 0 -> 72957 bytes
 logo/png24/600x600/color/barebox.png |  Bin 0 -> 406788 bytes
 logo/png24/600x600/color/blackbg/barebox.png |  Bin 0 -> 353328 bytes
 logo/png24/600x600/while/barebox.png |  Bin 0 -> 137235 bytes
 logo/png24/600x600/while/blackbg/barebox.png |  Bin 0 -> 130454 bytes
 logo/png24/800x800/color/barebox.png |  Bin 0 -> 627433 bytes
 logo/png24/800x800/color/blackbg/barebox.png |  Bin 0 -> 547772 bytes
 logo/png24/800x800/white/barebox.png |  Bin 0 -> 210397 bytes
 logo/png24/800x800/white/blackbg/barebox.png |  Bin 0 -> 198356 bytes
 logo/png24/900x900/color/barebox.png |  Bin 0 -> 713120 bytes
 logo/png24/900x900/color/blackbg/barebox.png |  Bin 0 -> 611586 bytes
 logo/png24/900x900/white/barebox.png |  Bin 0 -> 204449 bytes
 logo/png24/900x900/white/blackbg/barebox.png |  Bin 0 -> 190770 bytes
 logo/png8/100x100/color/blackbg/barebox.png  |  Bin 0 -> 8279 bytes
 logo/png8/100x100/white/blackbg/barebox.png  |  Bin 0 -> 6089 bytes
 logo/png8/200x200/color/blackbg/barebox.png  |  Bin 0 -> 23616 bytes
 logo/png8/200x200/white/blackbg/barebox.png  |  Bin 0 -> 14838 bytes
 logo/png8/400x400/color/blackbg/barebox.png  |  Bin 0 -> 71295 bytes
 logo/png8/400x400/white/blackbg/barebox.png  |  Bin 0 -> 38480 bytes
 logo/png8/600x600/color/blackbg/barebox.png  |  Bin 0 -> 130709 bytes
 logo/png8/600x600/while/blackbg/barebox.png  |  Bin 0 -> 68648 bytes
 logo/png8/800x800/color/blackbg/barebox.png  |  Bin 0 -> 205281 bytes
 logo/png8/800x800/white/blackbg/barebox.png  |  Bin 0 -> 104173 bytes
 logo/png8/900x900/color/blackbg/barebox.png  |  Bin 0 -> 236679 bytes
 logo/png8/900x900/white/blackbg/barebox.png  |  Bin 0 -> 106472 bytes
 48 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 logo/bmp/100x100/color/blackbg/barebox.bmp
 create mode 100644 logo/bmp/100x100/white/blackbg/barebox.bmp
 create mode 100644 logo/bmp/200x200/color/blackbg/barebox.bmp
 create mode 100644 logo/bmp/200x200/white/blackbg/barebox.bmp
 create mode 100644 logo/bmp/400x400/color/blackbg/barebox.bmp
 create mode 100644 logo/bmp/400x400/white/blackbg/barebox.bmp
 create mode 100644 logo/bmp/600x600/color/blackbg/barebox.bmp
 create mode 100644 logo/bmp/600x600/while/blackbg/barebox.bmp
 create mode 100644 logo/bmp/800x800/color/blackbg/barebox.bmp
 create mode 100644 logo/bmp/800x800/white/blackbg/barebox.bmp
 create mode 100644 logo/bmp/900x900/color/blackbg/barebox.bmp
 create mode 100644 logo/bmp/900x900/white/blackbg/barebox.bmp
 create mode 100644 logo/png24/100x100/color/barebox.png
 create mode 100644 logo/png24/100x100/color/blackbg/barebox.png
 create mode 100644 logo/png24/100x100/white/barebox.png
 create mode 100644 logo/png24/100x100/white/blackbg/barebox.png
 create mode 100644 logo/png24/200x200/color/barebox.png
 create mode 100644 logo/png24/200x200/color/blackbg/barebox.png
 create mode 100644 logo/png24/200

[PATCH 05/12] filetype: add BMP support

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 common/filetype.c  |2 ++
 include/filetype.h |1 +
 2 files changed, 3 insertions(+)

diff --git a/common/filetype.c b/common/filetype.c
index e736d43..5710394 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -101,6 +101,8 @@ enum filetype file_detect_type(void *_buf)
return filetype_mips_barebox;
if (is_fat(buf8))
return filetype_fat;
+   if (strncmp(buf8, "BM", 2) == 0)
+   return filetype_bmp;
 
return filetype_unknown;
 }
diff --git a/include/filetype.h b/include/filetype.h
index 179ec0f..6c97159 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -19,6 +19,7 @@ enum filetype {
filetype_sh,
filetype_mips_barebox,
filetype_fat,
+   filetype_bmp,
 };
 
 const char *file_type_to_string(enum filetype f);
-- 
1.7.10.4


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


[PATCH 00/12] add PNG support

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
Hi,

please pull
The following changes since commit f77269a819b1306aa9e0721a2159693fe307142d:

  Merge branch 'for-next/usb' (2012-09-05 12:59:59 +0200)

are available in the git repository at:


  git://git.jcrosoft.org/barebox.git tags/png

for you to fetch changes up to 8e19449313dd5f5c8d78194485901a5533961726:

  png: add picoPNG lib support (2012-09-06 13:56:59 +0800)


Introduce PNG support

This will allow to reduce the binary size and support transparent image
png + png8 is 50% less than lzo + bmp (same image)

 - rename bmp to splash
 - add background support (usefull for transparent image)
 - add LodePNG and PicoPNG

PicoPNG only support PNG8 RGBA where LodePNG support most of the PNG (PNG24 &
PNG8). PicoPNG is ~5KiB smaller than LodePNG.

Attention the coding style on both PicoPNG and LodePNG are untouched for
maintainance purpose.

Use LodePNG version 20120729 from http://lodev.org/lodepng/
Use from http://forge.voodooprojects.org/
which is base on picoPNG C++ wrote by Lode Vandevenne. The same author as
LodePNG.

This patch series also include the barebox logo
in logo/ you will found the barebox logo with color or white
in:
 - bmp (black background)
 - png24 (transparent or black background)
 - png8 (black background)

for the following size
 - 100x100
 - 200x200
 - 400x400
 - 600x600
 - 800x800
 - 900x900

The logo are origanize in a way to be able to include them in the envfs
by just point as it.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 


Jean-Christophe PLAGNIOL-VILLARD (12):
  add barebox logo
  bmp: rename it to splash
  bmp: split bmp rending in lib/bmp.c
  introduce image_renderer framework
  filetype: add BMP support
  splash/bmp: switch to image_renderer
  splash: add support to set a background color
  Introduce graphic utils
  graphic_utils: add rgba support
  filetype: add PNG support
  add PNG support
  png: add picoPNG lib support

 Documentation/commands.dox |2 +-
 arch/arm/boards/eukrea_cpuimx25/env/bin/init_board |4 +-
 arch/arm/boards/eukrea_cpuimx27/env/bin/init   |4 +-
 arch/arm/boards/eukrea_cpuimx35/env/bin/init_board |4 +-
 arch/arm/boards/eukrea_cpuimx51/env/bin/init_board |4 +-
 arch/arm/boards/karo-tx25/env/bin/init_board   |2 +-
 arch/arm/boards/mioa701/env/bin/init   |2 +-
 arch/arm/configs/chumbyone_defconfig   |2 +-
 arch/arm/configs/cupid_defconfig   |2 +-
 arch/arm/configs/eukrea_cpuimx25_defconfig |2 +-
 arch/arm/configs/eukrea_cpuimx27_defconfig |2 +-
 arch/arm/configs/eukrea_cpuimx35_defconfig |2 +-
 arch/arm/configs/freescale_mx35_3stack_defconfig   |2 +-
 arch/arm/configs/imx28evk_defconfig|2 +-
 arch/arm/configs/mioa701_defconfig |2 +-
 arch/arm/configs/neso_defconfig|2 +-
 arch/arm/configs/pcm027_defconfig  |2 +-
 arch/arm/configs/pcm038_defconfig  |2 +-
 arch/arm/configs/tx25stk5_defconfig|2 +-
 arch/arm/configs/tx28stk5_defconfig|2 +-
 commands/Kconfig   |5 +-
 commands/Makefile  |2 +-
 commands/bmp.c |  221 --
 commands/splash.c  |  133 
 common/filetype.c  |5 +
 include/filetype.h |2 +
 include/graphic_utils.h|   17 +
 include/image_renderer.h   |   42 +
 lib/Kconfig|   34 +
 lib/Makefile   |5 +
 lib/bmp.c  |  108 +++
 {include => lib}/bmp_layout.h  |   11 +
 lib/graphic_utils.c|  191 +
 lib/image_renderer.c   |   73 ++
 lib/lodepng.c  | 5928 

 lib/lodepng.h  | 1640 
+++
 lib/picopng.c  |  810 +++
 lib/picopng.h  |   34 +
 lib/png_lode.c |  181 +
 lib/png_pico.c |  152 
 logo/bmp/100x100/color/blackbg/barebox.bmp |  Bin 0 -> 30056 bytes
 logo/bmp/100x100/white/blackbg/barebox.bmp |  Bin 0 -> 30056 bytes
 logo/bmp/200x200/color/blackbg/barebox.bmp |  Bin 0 -> 120056 bytes
 logo/bmp/200

[PATCH] [OpenRISC] Add __ashrdi3 and remove link to libgcc

2012-09-05 Thread Franck Jullien
In a previous patch, Sascha needed to add __ashrdi3 and then linked to
libgcc. This patch add the ashrdi3 function in the arch/openrisc/lib
directory and remove the libgcc link.

Signed-off-by: Franck Jullien 
---
 arch/openrisc/Makefile  |4 +-
 arch/openrisc/lib/Makefile  |1 +
 arch/openrisc/lib/ashrdi3.S |   59 +++
 3 files changed, 62 insertions(+), 2 deletions(-)
 create mode 100644 arch/openrisc/lib/ashrdi3.S

diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile
index 1f4b175..9e88a51 100644
--- a/arch/openrisc/Makefile
+++ b/arch/openrisc/Makefile
@@ -1,6 +1,6 @@
 CPPFLAGS += -D__OR1K__ -ffixed-r10 -mhard-mul -mhard-div
 
-LIBGCC  := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
+#LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 board-$(CONFIG_GENERIC) := generic
 
@@ -20,6 +20,6 @@ common-y += $(BOARD)
 common-y += arch/openrisc/lib/
 common-y += arch/openrisc/cpu/
 
-common-y  += $(LIBGCC)
+#common-y += $(LIBGCC)
 
 lds-y += arch/openrisc/cpu/barebox.lds
diff --git a/arch/openrisc/lib/Makefile b/arch/openrisc/lib/Makefile
index aaf93cb..0b3cc50 100644
--- a/arch/openrisc/lib/Makefile
+++ b/arch/openrisc/lib/Makefile
@@ -4,3 +4,4 @@ obj-y += cpuinfo.o
 obj-y += muldi3.o
 obj-y += lshrdi3.o
 obj-y += ashldi3.o
+obj-y += ashrdi3.o
diff --git a/arch/openrisc/lib/ashrdi3.S b/arch/openrisc/lib/ashrdi3.S
new file mode 100644
index 000..c656d9f
--- /dev/null
+++ b/arch/openrisc/lib/ashrdi3.S
@@ -0,0 +1,59 @@
+/*
+ * (C) Copyright 2012 - Franck JULLIEN 
+ *
+ * Extracted from gcc generated assembly.
+ *
+ * Extended precision shifts.
+ *
+ * R3/R4 (MSW, LSW) has 64 bit value
+ * R5has shift count
+ * result in R11/R12
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+.globl __ashrdi3
+
+__ashrdi3:
+   l.sfeqi r5,0x0  /* if count = 0, go out 
  */
+   l.bf out
+
+   l.addi r6,r0,0x20   /* r6 = 32  
  */
+   l.sub r6,r6,r5  /* r6 = 32 - count  
  */
+   l.sfgtsi r6,0x0 /* if count >= 32   
  */
+   l.bnf more_than_32  /* branch to more_than_32   
  */
+   l.nop 0x0
+
+
+ less_than_32:
+   l.sll r6,r3,r6  /* r6 gets the bits moved from MSW to 
LSW */
+   l.srl r4,r4,r5  /* shift LSW
  */
+   l.sra r5,r3,r5  /* shift MSW to r5  
  */
+   l.or r4,r6,r4   /* LSW gets bits shifted from MSW   
  */
+   l.ori r3,r5,0x0 /* r3 = MSW 
  */
+
+ out:
+   l.ori r11,r3,0x0
+   l.jr r9
+   l.ori r12,r4,0x0
+
+ more_than_32:
+   l.srai r5,r3,0x1f   /* r5 = MSW sign extended   
  */
+   l.sub r4,r0,r6  /* r4 = -r6, the number of bits above 
32  */
+   l.sra r4,r3,r4  /* LSW gets bits shifted from MSB   
  */
+   l.j out /* go out   
  */
+   l.ori r3,r5,0x0 /* r3 = MSW 
  */
-- 
1.7.1


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


Re: [PATCH 2/8] Makefile: add target to produce a SPL compatible uimage

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
On 21:10 Wed 05 Sep , Jan Luebbe wrote:
> On Wed, Sep 05, 2012 at 08:05:16PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
> wrote:
> > On 17:52 Wed 05 Sep , Jan Luebbe wrote:
> > > +barebox.img: barebox.bin FORCE
> > > + $(call if_changed,barebox_mkimage)
> > this will not work whit the PBL
> > 
> > please fix it
> 
> PBL is the preloader for the compressed barebox image?
> 
> While using that in an uImage doesn't seem very useful, how
> would I fix it?

so why do we do it to for the kernel?

As I already said check $(KBUILD_IMAGE)

Best Regards,
J.

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


Re: [PATCH 2/8] Makefile: add target to produce a SPL compatible uimage

2012-09-05 Thread Jan Luebbe
On Wed, Sep 05, 2012 at 08:05:16PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> On 17:52 Wed 05 Sep , Jan Luebbe wrote:
> > +barebox.img: barebox.bin FORCE
> > +   $(call if_changed,barebox_mkimage)
> this will not work whit the PBL
> 
> please fix it

PBL is the preloader for the compressed barebox image?

While using that in an uImage doesn't seem very useful, how
would I fix it?

Regards,
Jan
-- 
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- |

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


Re: [PATCH 1/2] mtd: fix compiler warnings

2012-09-05 Thread Alexander Aring
Hi,

I saw it on sandbox platform. Does this depend on 32 bit or 64 bit system?

I found this for __kernel_size_t:
arch/sandbox/include/asm/posix_types.h:18:typedef unsigned long
__kernel_size_t;

so we need to change this to:
typedef unsigned int__kernel_size_t;

but in mips arch there is unsigned long, too.

Regards
Alex

2012/9/5 Jan Lübbe 

> Hi,
>
> On Mon, 2012-09-03 at 07:58 +0200, Alexander Aring wrote:
> > Fix some compiler warnings.
> > --- a/drivers/mtd/core.c
> > +++ b/drivers/mtd/core.c
> > @@ -79,7 +79,7 @@ static ssize_t mtd_write(struct cdev* cdev, const void
> *buf, size_t _count,
> >   return -EINVAL;
> >   }
> >
> > - dev_dbg(cdev->dev, "write: 0x%08lx 0x%08x\n", offset, count);
> > + dev_dbg(cdev->dev, "write: 0x%08lx 0x%08lx\n", offset, count);
> >   while (count) {
>
> This causes some new warnings for me:
> drivers/mtd/core.c: In function 'mtd_write':
> drivers/mtd/core.c:82:2: warning: format '%08lx' expects type 'long
> unsigned int', but argument 5 has type 'size_t'
> drivers/mtd/core.c:102:4: warning: format '%08lx' expects type 'long
> unsigned int', but argument 5 has type 'size_t'
> drivers/mtd/core.c:102:4: warning: format '%08lx' expects type 'long
> unsigned int', but argument 6 has type 'size_t'
>
> They go away when reverting this. It seems that different achitectures
> have different ideas about size_t:
> ./include/linux/types.h:54:typedef __kernel_size_t  size_t;
> ./arch/ppc/include/asm/posix_types.h:17:typedef unsigned int
>  __kernel_size_t;
> ./arch/blackfin/include/asm/posix_types.h:45:typedef unsigned int
> __kernel_size_t;
> ./arch/mips/include/asm/posix_types.h:34:typedef unsigned int
> __kernel_size_t;
> ./arch/mips/include/asm/posix_types.h:39:typedef unsigned long
>  __kernel_size_t;
> ./arch/x86/include/asm/posix_types.h:34:typedef unsigned int
>  __kernel_size_t;
> ./arch/sandbox/include/asm/posix_types.h:18:typedef unsigned long
> __kernel_size_t;
> ./arch/nios2/include/asm/posix_types.h:30:typedef unsigned int
>  __kernel_size_t;
> ./arch/openrisc/include/asm/posix_types.h:28:typedef unsigned int
> __kernel_size_t;
> ./arch/arm/include/asm/posix_types.h:30:typedef unsigned int
>  __kernel_size_t;
>
> On which arch did you see the warnings with the original code?
>
> Regards,
> Jan
> --
> 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- |
>
>
___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/8] Makefile: add target to produce a SPL compatible uimage

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
On 17:52 Wed 05 Sep , Jan Luebbe wrote:
> Signed-off-by: Jan Luebbe 
> ---
>  Makefile |   10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index c6264d3..69e28e3 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -680,6 +680,16 @@ ifndef CONFIG_PBL_IMAGE
>   $(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
>  endif
>  
> +# For development provide a target which makes barebox loadable by an
> +# unmodified u-boot
> +quiet_cmd_barebox_mkimage = MKIMAGE $@
> +  cmd_barebox_mkimage = $(srctree)/scripts/mkimage -A $(ARCH) -T 
> firmware -C none \
> + -O barebox -a $(CONFIG_TEXT_BASE) -e $(CONFIG_TEXT_BASE) \
> + -n "barebox $(KERNELRELEASE)" -d $< $@
> +
> +barebox.img: barebox.bin FORCE
> + $(call if_changed,barebox_mkimage)
this will not work whit the PBL

please fix it

Best Regards,
J.

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


Re: [PATCH 8/8] drivers/spi: add driver for the Multichannel SPI controller found in TI SoCs

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
On 17:52 Wed 05 Sep , Jan Luebbe wrote:
> Also create devices for OMAP3.
> 
> Signed-off-by: Jan Luebbe 
Again NACK

Drop the struct  on the reg

Best Regards,
J.
> ---
>  arch/arm/mach-omap/include/mach/mcspi.h |   11 +
>  arch/arm/mach-omap/include/mach/omap3-devices.h |   32 ++
>  drivers/spi/Kconfig |6 +
>  drivers/spi/Makefile|1 +
>  drivers/spi/omap3_spi.c |  399 
> +++
>  drivers/spi/omap3_spi.h |  100 ++
>  6 files changed, 549 insertions(+)
>  create mode 100644 arch/arm/mach-omap/include/mach/mcspi.h
>  create mode 100644 arch/arm/mach-omap/include/mach/omap3-devices.h
>  create mode 100644 drivers/spi/omap3_spi.c
>  create mode 100644 drivers/spi/omap3_spi.h
> 
> diff --git a/arch/arm/mach-omap/include/mach/mcspi.h 
> b/arch/arm/mach-omap/include/mach/mcspi.h
> new file mode 100644
> index 000..dbde67a
> --- /dev/null
> +++ b/arch/arm/mach-omap/include/mach/mcspi.h
> @@ -0,0 +1,11 @@
> +#ifndef __OMAP_MCSPI_H
> +#define  __OMAP_MCSPI_H
> +
> +#define OMAP3_MCSPI1_BASE0x48098000
> +#define OMAP3_MCSPI2_BASE0x4809A000
> +#define OMAP3_MCSPI3_BASE0x480B8000
> +#define OMAP3_MCSPI4_BASE0x480BA000
> +
> +int mcspi_devices_init(void);
> +
> +#endif /* __OMAP_MCSPI_H */
> diff --git a/arch/arm/mach-omap/include/mach/omap3-devices.h 
> b/arch/arm/mach-omap/include/mach/omap3-devices.h
> new file mode 100644
> index 000..8a6b324
> --- /dev/null
> +++ b/arch/arm/mach-omap/include/mach/omap3-devices.h
> @@ -0,0 +1,32 @@
> +#include 
> +#include 
> +
> +#include 
> +
> +/* the device numbering is the same as in the device tree */
> +
> +static inline struct device_d *omap3_add_spi(int id, resource_size_t start)
> +{
> + return add_generic_device("omap3_spi", id, NULL, start, SZ_4K,
> +IORESOURCE_MEM, NULL);
> +}
> +
> +static inline struct device_d *omap3_add_spi1(void)
> +{
> + return omap3_add_spi(1, OMAP3_MCSPI1_BASE);
> +}
> +
> +static inline struct device_d *omap3_add_spi2(void)
> +{
> + return omap3_add_spi(2, OMAP3_MCSPI2_BASE);
> +}
> +
> +static inline struct device_d *omap3_add_spi3(void)
> +{
> + return omap3_add_spi(3, OMAP3_MCSPI3_BASE);
> +}
> +
> +static inline struct device_d *omap3_add_spi4(void)
> +{
> + return omap3_add_spi(4, OMAP3_MCSPI4_BASE);
> +}
> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
> index b5c55a4..dc17ead 100644
> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -34,4 +34,10 @@ config DRIVER_SPI_ATMEL
>   depends on ARCH_AT91
>   depends on SPI
>  
> +
> +config DRIVER_SPI_OMAP3
> + bool "OMAP3 McSPI Master driver"
> + depends on ARCH_OMAP3
> + depends on SPI
> +
>  endmenu
> diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
> index 101652f..b53061e 100644
> --- a/drivers/spi/Makefile
> +++ b/drivers/spi/Makefile
> @@ -2,3 +2,4 @@ obj-$(CONFIG_SPI) += spi.o
>  obj-$(CONFIG_DRIVER_SPI_IMX) += imx_spi.o
>  obj-$(CONFIG_DRIVER_SPI_ALTERA) += altera_spi.o
>  obj-$(CONFIG_DRIVER_SPI_ATMEL) += atmel_spi.o
> +obj-$(CONFIG_DRIVER_SPI_OMAP3) += omap3_spi.o
> diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
> new file mode 100644
> index 000..c789bba
> --- /dev/null
> +++ b/drivers/spi/omap3_spi.c
> @@ -0,0 +1,399 @@
> +/*
> + * Copyright (C) 2012 Jan Luebbe 
> + *
> + * Copyright (C) 2010 Dirk Behme 
> + *
> + * Driver for McSPI controller on OMAP3. Based on davinci_spi.c
> + * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
> + *
> + * Copyright (C) 2007 Atmel Corporation
> + *
> + * Parts taken from linux/drivers/spi/omap2_mcspi.c
> + * Copyright (C) 2005, 2006 Nokia Corporation
> + *
> + * Modified by Ruslan Araslanov 
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "omap3_spi.h"
> +
> +#define WORD_LEN 8
> +#define SPI_WAIT_TIMEOUT MSECOND
> +
> +#define SPI_XFER_BEGIN  0x01/* Assert CS before transfer 
> */
> +#define SPI_XFE

Re: [PATCH 6/8] drivers/net: add driver for the EMAC device found in some TI SoCs

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
On 17:52 Wed 05 Sep , Jan Luebbe wrote:
> Signed-off-by: Jan Luebbe 
Again NACK

drop the struct  on hte reg

Best Regards,
J.
> ---
>  arch/arm/mach-omap/include/mach/emac_defs.h |   53 +++
>  drivers/net/Kconfig |5 +
>  drivers/net/Makefile|1 +
>  drivers/net/davinci_emac.c  |  615 
> +++
>  drivers/net/davinci_emac.h  |  318 ++
>  5 files changed, 992 insertions(+)
>  create mode 100644 arch/arm/mach-omap/include/mach/emac_defs.h
>  create mode 100644 drivers/net/davinci_emac.c
>  create mode 100644 drivers/net/davinci_emac.h
> 
> diff --git a/arch/arm/mach-omap/include/mach/emac_defs.h 
> b/arch/arm/mach-omap/include/mach/emac_defs.h
> new file mode 100644
> index 000..ef930fc
> --- /dev/null
> +++ b/arch/arm/mach-omap/include/mach/emac_defs.h
> @@ -0,0 +1,53 @@
> +/*
> + * Copyright (C) 2007 Sergey Kubushyn 
> + *
> + * Based on:
> + *
> + * 
> 
> + *
> + * dm644x_emac.h
> + *
> + * TI DaVinci (DM644X) EMAC peripheral driver header for DV-EVM
> + *
> + * Copyright (C) 2005 Texas Instruments.
> + *
> + * 
> 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + * 
> 
> +
> + * Modifications:
> + * ver. 1.0: Sep 2005, TI PSP Team - Created EMAC version for uBoot.
> + *
> + */
> +
> +#ifndef _AM3517_EMAC_H_
> +#define _AM3517_EMAC_H_
> +
> +#define EMAC_BASE_ADDR 0x5C01
> +#define EMAC_WRAPPER_BASE_ADDR 0x5C00
> +#define EMAC_WRAPPER_RAM_ADDR  0x5C02
> +#define EMAC_MDIO_BASE_ADDR0x5C03
> +#define EMAC_HW_RAM_ADDR   0x01E2
> +
> +#define EMAC_MDIO_BUS_FREQ 16600   /* 166 MHZ check */
> +#define EMAC_MDIO_CLOCK_FREQ   100 /* 2.0 MHz */
> +
> +/* SOFTRESET macro definition interferes with emac_regs structure definition 
> */
> +#undef SOFTRESET
> +
> +#define DAVINCI_EMAC_VERSION2
> +
> +#endif  /* _AM3517_EMAC_H_ */
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index dac1eb9..bfde54b 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -43,6 +43,11 @@ config DRIVER_NET_SMC9
> This option enables support for the SMSC LAN91C111
> ethernet chip.
>  
> +config DRIVER_NET_DAVINCI_EMAC
> + bool "TI Davinci/OMAP EMAC ethernet driver"
> + depends on ARCH_DAVINCI || ARCH_OMAP3
> + select MIIDEV
> +
>  config DRIVER_NET_DM9K
>   bool "Davicom dm9k[E|A|B] ethernet driver"
>   depends on HAS_DM9000
> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
> index 951a220..52611f8 100644
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -1,6 +1,7 @@
>  obj-$(CONFIG_DRIVER_NET_CS8900)  += cs8900.o
>  obj-$(CONFIG_DRIVER_NET_SMC911X) += smc911x.o
>  obj-$(CONFIG_DRIVER_NET_SMC9)+= smc9.o
> +obj-$(CONFIG_DRIVER_NET_DAVINCI_EMAC)+= davinci_emac.o
>  obj-$(CONFIG_DRIVER_NET_DM9K)+= dm9k.o
>  obj-$(CONFIG_DRIVER_NET_NETX)+= netx_eth.o
>  obj-$(CONFIG_DRIVER_NET_AT91_ETHER)  += at91_ether.o
> diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
> new file mode 100644
> index 000..3615f96
> --- /dev/null
> +++ b/drivers/net/davinci_emac.c
> @@ -0,0 +1,615 @@
> +/*
> + * Copyright (C) 2012 Jan Luebbe 
> + *
> + * Ethernet driver for TI TMS320DM644x (DaVinci) chips.
> + *
> + * Copyright (C) 2007 Sergey Kubushyn 
> + *
> + * Parts shamelessly stolen from TI's dm644x_emac.c. Original copyright
> + * follows:
> + *
> + * 
> 
> + *
> + * dm644x_emac.c
> + *
> + * TI DaVinci (DM644X) EMAC peripheral driver source for DV-EVM
> + *
> + * Copyright (C) 2005 Texas Instruments.
> + *
> + * 
> 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Softwar

[PATCH 6/8] drivers/net: add driver for the EMAC device found in some TI SoCs

2012-09-05 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---
 arch/arm/mach-omap/include/mach/emac_defs.h |   53 +++
 drivers/net/Kconfig |5 +
 drivers/net/Makefile|1 +
 drivers/net/davinci_emac.c  |  615 +++
 drivers/net/davinci_emac.h  |  318 ++
 5 files changed, 992 insertions(+)
 create mode 100644 arch/arm/mach-omap/include/mach/emac_defs.h
 create mode 100644 drivers/net/davinci_emac.c
 create mode 100644 drivers/net/davinci_emac.h

diff --git a/arch/arm/mach-omap/include/mach/emac_defs.h 
b/arch/arm/mach-omap/include/mach/emac_defs.h
new file mode 100644
index 000..ef930fc
--- /dev/null
+++ b/arch/arm/mach-omap/include/mach/emac_defs.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2007 Sergey Kubushyn 
+ *
+ * Based on:
+ *
+ * 
+ *
+ * dm644x_emac.h
+ *
+ * TI DaVinci (DM644X) EMAC peripheral driver header for DV-EVM
+ *
+ * Copyright (C) 2005 Texas Instruments.
+ *
+ * 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * 
+
+ * Modifications:
+ * ver. 1.0: Sep 2005, TI PSP Team - Created EMAC version for uBoot.
+ *
+ */
+
+#ifndef _AM3517_EMAC_H_
+#define _AM3517_EMAC_H_
+
+#define EMAC_BASE_ADDR 0x5C01
+#define EMAC_WRAPPER_BASE_ADDR 0x5C00
+#define EMAC_WRAPPER_RAM_ADDR  0x5C02
+#define EMAC_MDIO_BASE_ADDR0x5C03
+#define EMAC_HW_RAM_ADDR   0x01E2
+
+#define EMAC_MDIO_BUS_FREQ 16600   /* 166 MHZ check */
+#define EMAC_MDIO_CLOCK_FREQ   100 /* 2.0 MHz */
+
+/* SOFTRESET macro definition interferes with emac_regs structure definition */
+#undef SOFTRESET
+
+#define DAVINCI_EMAC_VERSION2
+
+#endif  /* _AM3517_EMAC_H_ */
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index dac1eb9..bfde54b 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -43,6 +43,11 @@ config DRIVER_NET_SMC9
  This option enables support for the SMSC LAN91C111
  ethernet chip.
 
+config DRIVER_NET_DAVINCI_EMAC
+   bool "TI Davinci/OMAP EMAC ethernet driver"
+   depends on ARCH_DAVINCI || ARCH_OMAP3
+   select MIIDEV
+
 config DRIVER_NET_DM9K
bool "Davicom dm9k[E|A|B] ethernet driver"
depends on HAS_DM9000
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 951a220..52611f8 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -1,6 +1,7 @@
 obj-$(CONFIG_DRIVER_NET_CS8900)+= cs8900.o
 obj-$(CONFIG_DRIVER_NET_SMC911X)   += smc911x.o
 obj-$(CONFIG_DRIVER_NET_SMC9)  += smc9.o
+obj-$(CONFIG_DRIVER_NET_DAVINCI_EMAC)  += davinci_emac.o
 obj-$(CONFIG_DRIVER_NET_DM9K)  += dm9k.o
 obj-$(CONFIG_DRIVER_NET_NETX)  += netx_eth.o
 obj-$(CONFIG_DRIVER_NET_AT91_ETHER)+= at91_ether.o
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
new file mode 100644
index 000..3615f96
--- /dev/null
+++ b/drivers/net/davinci_emac.c
@@ -0,0 +1,615 @@
+/*
+ * Copyright (C) 2012 Jan Luebbe 
+ *
+ * Ethernet driver for TI TMS320DM644x (DaVinci) chips.
+ *
+ * Copyright (C) 2007 Sergey Kubushyn 
+ *
+ * Parts shamelessly stolen from TI's dm644x_emac.c. Original copyright
+ * follows:
+ *
+ * 
+ *
+ * dm644x_emac.c
+ *
+ * TI DaVinci (DM644X) EMAC peripheral driver source for DV-EVM
+ *
+ * Copyright (C) 2005 Texas Instruments.
+ *
+ * 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ *  You should have received a c

[PATCH 3/8] scripts: add tool to create image for SPI boot on AM35xx

2012-09-05 Thread Jan Luebbe
Booting from SPI on an AM35xx (and possibly other TI SOCs) requires
a special format:

- 32 bit image size in big-endian
- 32 bit load address in big-endian
- binary image converted from little- to big-endian

The mk-am35xx-spi-image tool converts barebox.bin to
this format.

Signed-off-by: Jan Luebbe 
---
 arch/arm/Makefile |8 +++
 arch/arm/mach-omap/Kconfig|7 ++
 scripts/.gitignore|1 +
 scripts/Makefile  |2 +-
 scripts/mk-am35xx-spi-image.c |  141 +
 5 files changed, 158 insertions(+), 1 deletion(-)
 create mode 100644 scripts/mk-am35xx-spi-image.c

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 8e660be..e40b67e 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -221,6 +221,14 @@ archclean:
 
 KBUILD_IMAGE := $(KBUILD_BINARY)
 
+barebox.spi: barebox.bin
+   @echo "  SPI" $@
+   $(Q)scripts/mk-am35xx-spi-image barebox.bin > barebox.spi
+
+ifeq ($(CONFIG_OMAP_BUILD_SPI),y)
+all: barebox.spi
+endif
+
 archprepare: maketools
 maketools:
$(Q)$(MAKE) $(build)=arch/arm/tools include/generated/mach-types.h
diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index d735284..a781287 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -91,6 +91,13 @@ config OMAP_BUILD_IFT
prompt "build ift binary"
bool
 
+config OMAP_BUILD_SPI
+   prompt "build SPI binary"
+   bool
+   help
+ Say Y here if you want to build an barebox.spi image as used
+ on the AM35xx chips when booting form SPI NOR flash.
+
 config ARCH_TEXT_BASE
hex
default 0x80e8 if MACH_OMAP343xSDP
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 6e63f85..3f1cbdb 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -2,6 +2,7 @@ bareboxenv
 bin2c
 gen_netx_image
 kallsyms
+mk-am35xx-spi-image
 mkimage
 mkublheader
 omap_signGP
diff --git a/scripts/Makefile b/scripts/Makefile
index 7ca5e29..55ccdac 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -9,7 +9,7 @@ hostprogs-y  += bin2c
 hostprogs-y  += mkimage
 hostprogs-y  += bareboxenv
 hostprogs-$(CONFIG_ARCH_NETX)+= gen_netx_image
-hostprogs-$(CONFIG_ARCH_OMAP)+= omap_signGP
+hostprogs-$(CONFIG_ARCH_OMAP)+= omap_signGP mk-am35xx-spi-image
 hostprogs-$(CONFIG_ARCH_S5PCxx)  += s5p_cksum
 hostprogs-$(CONFIG_ARCH_DAVINCI) += mkublheader
 
diff --git a/scripts/mk-am35xx-spi-image.c b/scripts/mk-am35xx-spi-image.c
new file mode 100644
index 000..ec311fd
--- /dev/null
+++ b/scripts/mk-am35xx-spi-image.c
@@ -0,0 +1,141 @@
+/*
+ * mk-am35xx-spi-image.c - convert a barebox image for SPI loading on AM35xx
+ *
+ * Copyright (C) 2012 Jan Luebbe 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+/**
+ * @file
+ * @brief convert a barebox image for SPI loading on AM35xx
+ *
+ * FileName: scripts/mk-am35xx-spi-image.c
+ *
+ * Booting from SPI on an AM35xx (and possibly other TI SOCs) requires
+ * a special format:
+ *
+ * - 32 bit image size in big-endian
+ * - 32 bit load address in big-endian
+ * - binary image converted from little- to big-endian
+ *
+ * This tool converts barebox.bin to the required format.
+ */
+
+#define _BSD_SOURCE
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+void usage(char *prgname)
+{
+   printf("usage: %s [OPTION] FILE > IMAGE\n"
+  "\n"
+  "options:\n"
+  "  -a  memory address for the loaded image in SRAM\n",
+  prgname);
+}
+
+int main(int argc, char *argv[])
+{
+   FILE *input;
+   int opt;
+   off_t pos;
+   size_t size;
+   uint32_t addr = 0x4020;
+   uint32_t temp;
+
+   while((opt = getopt(argc, argv, "a:")) != -1) {
+   switch (opt) {
+   case 'a':
+   addr = strtoul(optarg, NULL, 0);
+   break;
+   }
+   }
+
+   if (optind >= argc) {
+   usage(argv[0]);
+   exit(1);
+   }
+
+   input = fopen(argv[optind], "r");
+   if (input == NULL) {
+   perror("fopen");
+   exit(EXIT_FA

[PATCH 8/8] drivers/spi: add driver for the Multichannel SPI controller found in TI SoCs

2012-09-05 Thread Jan Luebbe
Also create devices for OMAP3.

Signed-off-by: Jan Luebbe 
---
 arch/arm/mach-omap/include/mach/mcspi.h |   11 +
 arch/arm/mach-omap/include/mach/omap3-devices.h |   32 ++
 drivers/spi/Kconfig |6 +
 drivers/spi/Makefile|1 +
 drivers/spi/omap3_spi.c |  399 +++
 drivers/spi/omap3_spi.h |  100 ++
 6 files changed, 549 insertions(+)
 create mode 100644 arch/arm/mach-omap/include/mach/mcspi.h
 create mode 100644 arch/arm/mach-omap/include/mach/omap3-devices.h
 create mode 100644 drivers/spi/omap3_spi.c
 create mode 100644 drivers/spi/omap3_spi.h

diff --git a/arch/arm/mach-omap/include/mach/mcspi.h 
b/arch/arm/mach-omap/include/mach/mcspi.h
new file mode 100644
index 000..dbde67a
--- /dev/null
+++ b/arch/arm/mach-omap/include/mach/mcspi.h
@@ -0,0 +1,11 @@
+#ifndef __OMAP_MCSPI_H
+#define  __OMAP_MCSPI_H
+
+#define OMAP3_MCSPI1_BASE  0x48098000
+#define OMAP3_MCSPI2_BASE  0x4809A000
+#define OMAP3_MCSPI3_BASE  0x480B8000
+#define OMAP3_MCSPI4_BASE  0x480BA000
+
+int mcspi_devices_init(void);
+
+#endif /* __OMAP_MCSPI_H */
diff --git a/arch/arm/mach-omap/include/mach/omap3-devices.h 
b/arch/arm/mach-omap/include/mach/omap3-devices.h
new file mode 100644
index 000..8a6b324
--- /dev/null
+++ b/arch/arm/mach-omap/include/mach/omap3-devices.h
@@ -0,0 +1,32 @@
+#include 
+#include 
+
+#include 
+
+/* the device numbering is the same as in the device tree */
+
+static inline struct device_d *omap3_add_spi(int id, resource_size_t start)
+{
+   return add_generic_device("omap3_spi", id, NULL, start, SZ_4K,
+  IORESOURCE_MEM, NULL);
+}
+
+static inline struct device_d *omap3_add_spi1(void)
+{
+   return omap3_add_spi(1, OMAP3_MCSPI1_BASE);
+}
+
+static inline struct device_d *omap3_add_spi2(void)
+{
+   return omap3_add_spi(2, OMAP3_MCSPI2_BASE);
+}
+
+static inline struct device_d *omap3_add_spi3(void)
+{
+   return omap3_add_spi(3, OMAP3_MCSPI3_BASE);
+}
+
+static inline struct device_d *omap3_add_spi4(void)
+{
+   return omap3_add_spi(4, OMAP3_MCSPI4_BASE);
+}
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index b5c55a4..dc17ead 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -34,4 +34,10 @@ config DRIVER_SPI_ATMEL
depends on ARCH_AT91
depends on SPI
 
+
+config DRIVER_SPI_OMAP3
+   bool "OMAP3 McSPI Master driver"
+   depends on ARCH_OMAP3
+   depends on SPI
+
 endmenu
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 101652f..b53061e 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_SPI) += spi.o
 obj-$(CONFIG_DRIVER_SPI_IMX) += imx_spi.o
 obj-$(CONFIG_DRIVER_SPI_ALTERA) += altera_spi.o
 obj-$(CONFIG_DRIVER_SPI_ATMEL) += atmel_spi.o
+obj-$(CONFIG_DRIVER_SPI_OMAP3) += omap3_spi.o
diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
new file mode 100644
index 000..c789bba
--- /dev/null
+++ b/drivers/spi/omap3_spi.c
@@ -0,0 +1,399 @@
+/*
+ * Copyright (C) 2012 Jan Luebbe 
+ *
+ * Copyright (C) 2010 Dirk Behme 
+ *
+ * Driver for McSPI controller on OMAP3. Based on davinci_spi.c
+ * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Copyright (C) 2007 Atmel Corporation
+ *
+ * Parts taken from linux/drivers/spi/omap2_mcspi.c
+ * Copyright (C) 2005, 2006 Nokia Corporation
+ *
+ * Modified by Ruslan Araslanov 
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "omap3_spi.h"
+
+#define WORD_LEN   8
+#define SPI_WAIT_TIMEOUT MSECOND
+
+#define SPI_XFER_BEGIN  0x01/* Assert CS before transfer */
+#define SPI_XFER_END0x02/* Deassert CS after transfer 
*/
+
+static void spi_reset(struct spi_master *master)
+{
+   struct omap3_spi_master *omap3_master = container_of(master, struct 
omap3_spi_master, master);
+   struct mcspi __iomem *regs = omap3_master->regs;
+   unsigned int tmp;
+
+   writel(OMAP3_MCSPI_SYSCONFIG_SOFTRESET, ®s->sysconfig);
+   do 

[PATCH 5/8] drivers/net/ksz8864rmn: add driver for Micrel KSZ8864RMN Ethernet Switch

2012-09-05 Thread Jan Luebbe
It starts the switch and provides basic access to the registers.

This driver could also work with some other Micrel switches, possibly
with some small changes.

Signed-off-by: Jan Luebbe 
---
 drivers/net/Kconfig  |7 ++
 drivers/net/Makefile |1 +
 drivers/net/ksz8864rmn.c |  233 ++
 3 files changed, 241 insertions(+)
 create mode 100644 drivers/net/ksz8864rmn.c

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 3c5f729..dac1eb9 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -125,5 +125,12 @@ config DRIVER_NET_GIANFAR
 
 source "drivers/net/usb/Kconfig"
 
+config DRIVER_NET_MICREL
+   depends on SPI
+   bool "Micrel KSZ8864RMN Ethernet Switch driver"
+   help
+ This option enables support for enabling the Micrel
+ KSZ8864RMN Ethernet Switch over SPI.
+
 endmenu
 
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 4d960e8..951a220 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_DRIVER_NET_TSE)  += altera_tse.o
 obj-$(CONFIG_DRIVER_NET_KS8851_MLL)+= ks8851_mll.o
 obj-$(CONFIG_DRIVER_NET_DESIGNWARE)+= designware.o
 obj-$(CONFIG_DRIVER_NET_GIANFAR)   += gianfar.o
+obj-$(CONFIG_DRIVER_NET_MICREL)+= ksz8864rmn.o
diff --git a/drivers/net/ksz8864rmn.c b/drivers/net/ksz8864rmn.c
new file mode 100644
index 000..5851463
--- /dev/null
+++ b/drivers/net/ksz8864rmn.c
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2012 Jan Luebbe, Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define REG_ID00x00
+#define REG_ID10x01
+
+#define REG_GC00   0x02
+#define REG_GC01   0x03
+#define REG_GC02   0x04
+#define REG_GC03   0x05
+#define REG_GC04   0x06
+#define REG_GC05   0x07
+#define REG_GC06   0x08
+#define REG_GC07   0x09
+#define REG_GC08   0x0a
+#define REG_GC09   0x0b
+#define REG_GC10   0x0c
+#define REG_GC11   0x0d
+
+#define REG_PSTAT1(p)  (0x10 * p + 0xe)
+#define REG_PSTAT2(p)  (0x10 * p + 0xf)
+
+#define CMD_WRITE  0x02
+#define CMD_READ   0x03
+
+struct micrel_switch_priv {
+   struct cdev cdev;
+   struct spi_device   *spi;
+};
+
+static int micrel_switch_read_reg(struct spi_device *spi, uint8_t reg)
+{
+   uint8_t tx[2];
+   uint8_t rx[1];
+   int ret;
+
+   tx[0] = CMD_READ;
+   tx[1] = reg;
+
+   ret = spi_write_then_read(spi, tx, 2, rx, 1);
+   if (ret < 0)
+   return ret;
+
+   return rx[0];
+}
+
+static void micrel_switch_write_reg(struct spi_device *spi, uint8_t reg, 
uint8_t val)
+{
+   uint8_t tx[3];
+
+   tx[0] = CMD_WRITE;
+   tx[1] = reg;
+   tx[2] = val;
+
+   spi_write_then_read(spi, tx, 3, NULL, 0);
+}
+
+static int micrel_switch_enable_set(struct device_d *dev, struct param_d 
*param,
+   const char *val)
+{
+   struct spi_device *spi = (struct spi_device *)dev->type_data;
+   int enable;
+   char *new;
+
+   if (!val)
+   return dev_param_set_generic(dev, param, NULL);
+
+   enable = simple_strtoul(val, NULL, 0);
+
+   if (enable) {
+   micrel_switch_write_reg(spi, REG_ID1, 1);
+   new = "1";
+   } else {
+   micrel_switch_write_reg(spi, REG_ID1, 0);
+   new = "0";
+   }
+
+   dev_param_set_generic(dev, param, new);
+
+   return 0;
+}
+
+static void micrel_switch_print_reg(struct spi_device *spi, const char *name, 
uint8_t reg)
+{
+   uint8_t tx[2];
+   uint8_t rx[1];
+   int ret;
+
+   tx[0] = CMD_READ;
+   tx[1] = reg;
+
+   ret = spi_write_then_read(spi, tx, 2, rx, 1);
+   if (ret < 0)
+   printf("%s@0x%02x: SPI error\n", name, reg);
+
+   printf("%s@0x%02x: 0x%02x\n", name, reg, rx[0]);
+}
+
+static void micrel_switch_info(struct device_d *dev)
+{
+   struct spi_device *spi = (struct spi_device *)dev->type_data;
+
+   printf("Registers:\n");
+   micrel_switch_print_re

[PATCH 7/8] omap3: remove unused coded for clock configuration

2012-09-05 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---
 arch/arm/mach-omap/Kconfig   |   17 -
 arch/arm/mach-omap/omap3_clock.c |   14 +-
 2 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index a781287..98750c4 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -52,20 +52,7 @@ config ARCH_OMAP4
 
 endchoice
 
-### Generic Clock configurations to be enabled by Mach - invisible to enable.
-config OMAP_CLOCK_UART
-   bool
-config OMAP_CLOCK_UART2
-   bool
-config OMAP_CLOCK_UART3
-   bool
-config OMAP_CLOCK_I2C
-   bool
-
 # Blind enable all possible clocks.. think twice before you do this.
-config OMAP_CLOCK_ALL
-   bool
-
 config OMAP_CLOCK_SOURCE_S32K
bool
 
@@ -117,14 +104,12 @@ choice
 
 config MACH_OMAP343xSDP
bool "Texas Instrument's SDP343x"
-   select OMAP_CLOCK_ALL
depends on ARCH_OMAP3
help
  Say Y here if you are using SDP343x platform
 
 config MACH_BEAGLE
bool "Texas Instrument's Beagle Board"
-   select OMAP_CLOCK_ALL
select HAVE_NOSHELL
depends on ARCH_OMAP3
  help
@@ -132,7 +117,6 @@ config MACH_BEAGLE
 
 config MACH_OMAP3EVM
bool "Texas Instrument's OMAP3 EVM"
-   select OMAP_CLOCK_ALL
select HAVE_NOSHELL
depends on ARCH_OMAP3
  help
@@ -157,7 +141,6 @@ config MACH_PCM049
 
 config MACH_PCAAL1
bool "Phytec phyCARD-A-L1"
-   select OMAP_CLOCK_ALL
select HAVE_NOSHELL
depends on ARCH_OMAP3
  help
diff --git a/arch/arm/mach-omap/omap3_clock.c b/arch/arm/mach-omap/omap3_clock.c
index 646235e..463633a 100644
--- a/arch/arm/mach-omap/omap3_clock.c
+++ b/arch/arm/mach-omap/omap3_clock.c
@@ -674,18 +674,6 @@ static void per_clocks_enable(void)
/* Enable the ICLK for 32K Sync Timer as its used in udelay */
sr32(CM_REG(ICLKEN_WKUP), 2, 1, 0x1);
 
-#ifdef CONFIG_OMAP_CLOCK_UART
-   /* Enable UART1 clocks */
-   sr32(CM_REG(FCLKEN1_CORE), 13, 1, 0x1);
-   sr32(CM_REG(ICLKEN1_CORE), 13, 1, 0x1);
-#endif
-#ifdef CONFIG_OMAP_CLOCK_I2C
-   /* Turn on all 3 I2C clocks */
-   sr32(CM_REG(FCLKEN1_CORE), 15, 3, 0x7);
-   sr32(CM_REG(ICLKEN1_CORE), 15, 3, 0x7); /* I2C1,2,3 = on */
-#endif
-
-#ifdef CONFIG_OMAP_CLOCK_ALL
 #define FCK_IVA2_ON0x0001
 #define FCK_CORE1_ON   0x03fffe29
 #define ICK_CORE1_ON   0x3ffb
@@ -710,7 +698,7 @@ static void per_clocks_enable(void)
sr32(CM_REG(ICLKEN_CAM), 0, 32, ICK_CAM_ON);
sr32(CM_REG(FCLKEN_PER), 0, 32, FCK_PER_ON);
sr32(CM_REG(ICLKEN_PER), 0, 32, ICK_PER_ON);
-#endif
+
/* Settle down my friend */
sdelay(1000);
 }
-- 
1.7.10.4


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


[PATCH 4/8] common: split out meminfo output and make it optional

2012-09-05 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---
 common/Kconfig   |4 
 common/Makefile  |1 +
 common/meminfo.c |   23 +++
 common/startup.c |   21 -
 include/common.h |4 ++--
 5 files changed, 30 insertions(+), 23 deletions(-)
 create mode 100644 common/meminfo.c

diff --git a/common/Kconfig b/common/Kconfig
index b97392c..c1aaabe 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -96,6 +96,10 @@ config BANNER
bool "display banner"
default y
 
+config MEMINFO
+   bool "display memory info"
+   default y
+
 config ENVIRONMENT_VARIABLES
bool "environment variables support"
 
diff --git a/common/Makefile b/common/Makefile
index df9f301..68582b7 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_MALLOC_TLSF) += tlsf.o
 obj-$(CONFIG_MALLOC_DUMMY) += dummy_malloc.o
 obj-y += clock.o
 obj-$(CONFIG_BANNER) += version.o
+obj-$(CONFIG_MEMINFO) += meminfo.o
 obj-$(CONFIG_COMMAND_SUPPORT) += command.o
 obj-$(CONFIG_CONSOLE_FULL) += console.o
 obj-$(CONFIG_CONSOLE_SIMPLE) += console_simple.o
diff --git a/common/meminfo.c b/common/meminfo.c
new file mode 100644
index 000..06fce5a
--- /dev/null
+++ b/common/meminfo.c
@@ -0,0 +1,23 @@
+#include 
+#include 
+#include 
+#include 
+
+static int display_meminfo(void)
+{
+   ulong mstart = mem_malloc_start();
+   ulong mend   = mem_malloc_end();
+   ulong msize  = mend - mstart + 1;
+
+   debug("barebox code: 0x%p -> 0x%p\n", _stext, _etext);
+   debug("bss segment:  0x%p -> 0x%p\n", __bss_start, __bss_stop);
+   printf("malloc space: 0x%08lx -> 0x%08lx (size %s)\n",
+   mstart, mend, size_human_readable(msize));
+#ifdef CONFIG_ARM
+   printf("stack space:  0x%08x -> 0x%08x (size %s)\n",
+   STACK_BASE, STACK_BASE + STACK_SIZE,
+   size_human_readable(STACK_SIZE));
+#endif
+   return 0;
+}
+late_initcall(display_meminfo);
diff --git a/common/startup.c b/common/startup.c
index abd1b77..e639d05 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -33,34 +33,15 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[],
  __barebox_initcalls_end[];
 
-static void display_meminfo(void)
-{
-   ulong mstart = mem_malloc_start();
-   ulong mend   = mem_malloc_end();
-   ulong msize  = mend - mstart + 1;
-
-   debug("barebox code: 0x%p -> 0x%p\n", _stext, _etext);
-   debug("bss segment:  0x%p -> 0x%p\n", __bss_start, __bss_stop);
-   printf("Malloc space: 0x%08lx -> 0x%08lx (size %s)\n",
-   mstart, mend, size_human_readable(msize));
-#ifdef CONFIG_ARM
-   printf("Stack space : 0x%08x -> 0x%08x (size %s)\n",
-   STACK_BASE, STACK_BASE + STACK_SIZE,
-   size_human_readable(STACK_SIZE));
-#endif
-}
-
 #ifdef CONFIG_DEFAULT_ENVIRONMENT
 #include 
 
@@ -128,8 +109,6 @@ void start_barebox (void)
 
debug("initcalls done\n");
 
-   display_meminfo();
-
 #ifdef CONFIG_ENV_HANDLING
if (envfs_load(default_environment_path, "/env")) {
 #ifdef CONFIG_DEFAULT_ENVIRONMENT
diff --git a/include/common.h b/include/common.h
index df12083..30c1dc6 100644
--- a/include/common.h
+++ b/include/common.h
@@ -150,11 +150,11 @@ static inline void dump_stack(void)
 #define MEMAREA_SIZE_SPECIFIED 1
 
 struct memarea_info {
-struct device_d *device;
+   struct device_d *device;
unsigned long start;
unsigned long end;
unsigned long size;
-unsigned long flags;
+   unsigned long flags;
 };
 
 int parse_area_spec(const char *str, loff_t *start, loff_t *size);
-- 
1.7.10.4


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


Prepare support for TI AM35xx

2012-09-05 Thread Jan Luebbe
Hi all,

these patches prepare for TI AM35xx support and have have been tested
together with the board code.

The patches should apply individually to the current master (=next).

Thanks again to Jean-Christophe Plagniol-Villard and Sacha Hauer for
their reviews.

Best regards,
Jan


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


[PATCH 2/8] Makefile: add target to produce a SPL compatible uimage

2012-09-05 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---
 Makefile |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/Makefile b/Makefile
index c6264d3..69e28e3 100644
--- a/Makefile
+++ b/Makefile
@@ -680,6 +680,16 @@ ifndef CONFIG_PBL_IMAGE
$(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
 endif
 
+# For development provide a target which makes barebox loadable by an
+# unmodified u-boot
+quiet_cmd_barebox_mkimage = MKIMAGE $@
+  cmd_barebox_mkimage = $(srctree)/scripts/mkimage -A $(ARCH) -T firmware 
-C none \
+   -O barebox -a $(CONFIG_TEXT_BASE) -e $(CONFIG_TEXT_BASE) \
+   -n "barebox $(KERNELRELEASE)" -d $< $@
+
+barebox.img: barebox.bin FORCE
+   $(call if_changed,barebox_mkimage)
+
 ifdef CONFIG_X86
 barebox.S: barebox
 ifdef CONFIG_X86_HDBOOT
-- 
1.7.10.4


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


[PATCH 1/8] drivers/nor/m25p80: add JEDEC ID for Micron/Numonyx SPI NOR flash

2012-09-05 Thread Jan Luebbe
Signed-off-by: Jan Luebbe 
---
 drivers/nor/m25p80.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/nor/m25p80.c b/drivers/nor/m25p80.c
index 5713ad5..61f2195 100644
--- a/drivers/nor/m25p80.c
+++ b/drivers/nor/m25p80.c
@@ -648,6 +648,9 @@ static const struct spi_device_id m25p_ids[] = {
{ "cat25c09", CAT25_INFO( 128, 8, 32, 2) },
{ "cat25c17", CAT25_INFO( 256, 8, 32, 2) },
{ "cat25128", CAT25_INFO(2048, 8, 64, 2) },
+
+   /* Micron */
+   { "n25q128", INFO(0x20ba18, 0, 64 * 1024, 256, 0) },
{ },
 };
 
-- 
1.7.10.4


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


Re: [PATCH 1/2] mtd: fix compiler warnings

2012-09-05 Thread Jan Lübbe
Hi,

On Mon, 2012-09-03 at 07:58 +0200, Alexander Aring wrote:
> Fix some compiler warnings.
> --- a/drivers/mtd/core.c
> +++ b/drivers/mtd/core.c
> @@ -79,7 +79,7 @@ static ssize_t mtd_write(struct cdev* cdev, const void 
> *buf, size_t _count,
>   return -EINVAL;
>   }
>  
> - dev_dbg(cdev->dev, "write: 0x%08lx 0x%08x\n", offset, count);
> + dev_dbg(cdev->dev, "write: 0x%08lx 0x%08lx\n", offset, count);
>   while (count) {

This causes some new warnings for me:
drivers/mtd/core.c: In function 'mtd_write':
drivers/mtd/core.c:82:2: warning: format '%08lx' expects type 'long unsigned 
int', but argument 5 has type 'size_t'
drivers/mtd/core.c:102:4: warning: format '%08lx' expects type 'long unsigned 
int', but argument 5 has type 'size_t'
drivers/mtd/core.c:102:4: warning: format '%08lx' expects type 'long unsigned 
int', but argument 6 has type 'size_t'

They go away when reverting this. It seems that different achitectures
have different ideas about size_t:
./include/linux/types.h:54:typedef __kernel_size_t  size_t;
./arch/ppc/include/asm/posix_types.h:17:typedef unsigned int__kernel_size_t;
./arch/blackfin/include/asm/posix_types.h:45:typedef unsigned int 
__kernel_size_t;
./arch/mips/include/asm/posix_types.h:34:typedef unsigned int   __kernel_size_t;
./arch/mips/include/asm/posix_types.h:39:typedef unsigned long  __kernel_size_t;
./arch/x86/include/asm/posix_types.h:34:typedef unsigned int__kernel_size_t;
./arch/sandbox/include/asm/posix_types.h:18:typedef unsigned long   
__kernel_size_t;
./arch/nios2/include/asm/posix_types.h:30:typedef unsigned int  
__kernel_size_t;
./arch/openrisc/include/asm/posix_types.h:28:typedef unsigned int   
__kernel_size_t;
./arch/arm/include/asm/posix_types.h:30:typedef unsigned int
__kernel_size_t;

On which arch did you see the warnings with the original code?

Regards,
Jan
-- 
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- |


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


[PATCH 1/1] uncompress: drop wrong BUG(uncompress_size)

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
As uncompress_size is a static and will set if call uncompress_size multiple
time.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 lib/uncompress.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/lib/uncompress.c b/lib/uncompress.c
index cdfebe9..3cf98dd 100644
--- a/lib/uncompress.c
+++ b/lib/uncompress.c
@@ -80,8 +80,6 @@ int uncompress(unsigned char *inbuf, int len,
int ret;
char *err;
 
-   BUG_ON(uncompress_size);
-
if (inbuf) {
ft = file_detect_type(inbuf);
uncompress_buf = NULL;
-- 
1.7.10.4


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


v2012.09.0

2012-09-05 Thread Sascha Hauer

Got it. We have a september release. Thank you all for working on
barebox and making this bootloader better.

Have fun!

Sascha


Alexander Shiyan (7):
  PCM970: Add MMC support
  PCM038: Read UID from fuses and pass this value to kernel as serial number
  mc13xxx: Define maximum SPI clock frequency global to driver
  tx51: Unused mc13xxx.h include removed
  mc13xxx: Added dummy definitions if CONFIG_MFD_MC13XXX is not set
  PCM038: Added setup for OTG host pins
  i.MX: Removed unused declaration for imx_iim_get_mac

Alexey Galakhov (2):
  S5P DRAM support
  Add FriendlyArm Tiny210 board (S5PV210)

Antony Pavlov (6):
  MIPS: malta: register memory bank
  MIPS: remove unused processor-specific constants and macros
  serial_ns16550: change the driver's name
  MIPS: add initial exceptions handling
  commands: memset: fix help message
  commands/digest: don't print checksum for non-existing files

Bernhard Walle (1):
  lib/Kconfig: Fix alignment of arrows in label

Christian Kapeller (2):
  input: Add i.MX matrix keypad driver
  input: add i.MX51 platform code for matrix keypad driver

Eric Bénard (6):
  string: add strim for ONFI code
  nand_base: add ONFI flash detection
  nand_imx: update to support onfi & 4k flashs
  eukrea_cpuimx35: fix USB host
  m25p80: wait for flash before returning after erase
  stringlist: fix division by zero

Jan Luebbe (1):
  scripts/mkublheader: add program to produce an UBL image header

Jan Weitzel (1):
  gpmc: Add reset to gpmc_generic_init

Jean-Christophe PLAGNIOL-VILLARD (8):
  stddev: make it selectable via Kconfig
  kbuild: Init all relevant variables used in kbuild files
  decompress_unlzo: define decompress_unlzo as decompress
  arm/bootm: fix initrd_start init
  bootm: do not load the initrd in the common code
  uimage_sdram_flush: fix resource start
  uimage_laod: fix ramdisk support
  nhk8815: fix nand IO_DATA end resource

Juergen Beisert (23):
  Enable a way to provide the reason for "being here"
  ARM/Samsung: add support to detect the reset source
  ARM/i.MX: add support to detect the reset source
  ARM/MXS: add reset cause detection
  ARM/Samsung: add the vendor FriendlyARM to the board's directory name
  ARM/Samsung: List only really supported S3C24xx SoCs
  ARM/Samsung: follow the name style of the other source files in this 
directory
  Samsung/serial: remove more ugly ifdef lines
  Samsung/serial: make the code more readable
  Samsung/serial: there is no need to ifdef these register defines
  Samsung/serial: there is no need to ifdef the slot table
  Samsung/serial: move the decision about an improved UART into Kconfig
  Samsung/serial: unify UCON register settings
  Samsung/serial: make the clock source configureable
  ARM/Samsung: add S3C6410 SoC iomap
  ARM/Samsung: adapt the generic timer driver to support the S3C6410 SoC
  ARM/Samsung: add the clock tree support for the S3C6410 SoC
  ARM/Samsung: add GPIO handling support for the S3C6410 SoC
  ARM/Samsung: add generic S3C6410 SoC specific functions
  ARM/Samsung: add the S3C6410 SoC
  ARM/Samsung: add the Mini6410 platform as a user of the S3C6410 SoC
  ARM/Samsung: add the Tiny6410 platform as a user of the S3C6410 SoC
  serial Samsung: add the S3C64xx requirements

Juergen Kilb (3):
  Added SDR-size auto detection.
  pca-a-l1: added memory device for int. 60kB RAM.
  phyCARD-A-L1: Create xload configuration.

Marc Kleine-Budde (1):
  usb: gadget: enable for MXS

Marc Reilly (2):
  imx35: mmc clock has 6 bit divider, not 3_3
  i2c: add platform_data for i2c_board_info

Maxime Ripard (2):
  Add bootargs script to boot on ext filesystems
  Add support for the Crystalfontz CFA-10036 board

Sascha Hauer (82):
  ARM tqma53: Add standard flash header
  ARM tqma53: switch to new environment
  hush getopt: shift argv arguments
  defenv-2: Add usage information for bootargs scripts
  defenv-2: improve boot script
  lzo: Allow for static inlining
  ARM lds: remove unused got
  ARM: remove board linker script option
  ARM: remove exception vectors from boards
  ARM startup: calculate offset instead of runtime address
  ARM ep93xx: Get rid of special handling in linker file
  ARM boards: Use _text rather than TEXT_BASE
  ARM: Separate assembler functions into their own section
  ARM at91rm9200: remove SoC specific copying of exception vectors
  ARM: move exception vector table to exceptions.S
  kconfig: fix IS_ENABLED to not require all options to be defined
  USB: Fix typo tranceiver -> transceiver
  ARM: let armlinux_set_* depend on the correct option
  bootm: Fix undefined reference to of_fix_tree
  uimage: intro

Re: MLO doesn't work, rest is ok

2012-09-05 Thread Norbert Roos

On 09/05/2012 01:46 PM, Jan Weitzel wrote:


I used gcc-linaro-4.5 with gcc-4.6.2 it stops working here also.


I will try it with an older version then.

Thank you all for your help!

Norbert


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


Re: MLO doesn't work, rest is ok

2012-09-05 Thread Norbert Roos

On 09/05/2012 01:18 PM, Anand Gadiyar wrote:


What is the size of the generated MLO file?


38312, so it's not a size problem.

Norbert

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


Re: MLO doesn't work, rest is ok

2012-09-05 Thread Norbert Roos

On 09/05/2012 01:15 PM, Sascha Hauer wrote:


Maybe you could try an older toolchain. There are some dark memories in
my mind, but it could also be that my mind is fooling me...


Ok, i will try this..


The MLO is generated from barebox.bin with the omap_signGP tool. It
seems the header is 520byte in size. You could compare these between
both images.


Both configuration headers are the same.


I don't know though if this is enough for the OMAP ROM code
to detect a valid image.


Meanwhile, i took a look at the MLO. The configuration header is ok, the 
image size in the GP header is correct, and the loading address is the 
same like in the working MLO. The first instruction in the image differs 
from the working one (the others too, of course).


So the MLO should at least get loaded and started.. strange.

Norbert


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


[PATCH 7/7] defaultenv-2: add boot sequence

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
Boot will boot run sequentially the script in /env/boot.d

drop global.boot.default as we start the boot sequence by default

update the current board using the defaultenv-2 at the sametime

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 .../arm/boards/crystalfontz-cfa10036/env/boot.d/01 |1 +
 .../arm/boards/crystalfontz-cfa10036/env/boot.d/02 |1 +
 .../arm/boards/crystalfontz-cfa10036/env/boot.d/03 |1 +
 .../boards/crystalfontz-cfa10036/env/init/general  |3 --
 .../boards/freescale-mx6-sabrelite/env/boot.d/01   |1 +
 .../boards/freescale-mx6-sabrelite/env/boot.d/02   |1 +
 arch/arm/boards/pcm038/env/boot.d/01   |1 +
 arch/arm/boards/pcm038/env/boot.d/02   |1 +
 arch/arm/boards/pcm038/env/boot.d/03   |1 +
 arch/arm/boards/tqma53/env/boot.d/01   |1 +
 arch/arm/boards/tqma53/env/boot.d/02   |1 +
 defaultenv-2/base/bin/boot |   51 +---
 defaultenv-2/base/init/general |3 --
 13 files changed, 55 insertions(+), 12 deletions(-)
 create mode 12 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/01
 create mode 12 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/02
 create mode 12 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/03
 create mode 12 arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/01
 create mode 12 arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/02
 create mode 12 arch/arm/boards/pcm038/env/boot.d/01
 create mode 12 arch/arm/boards/pcm038/env/boot.d/02
 create mode 12 arch/arm/boards/pcm038/env/boot.d/03
 create mode 12 arch/arm/boards/tqma53/env/boot.d/01
 create mode 12 arch/arm/boards/tqma53/env/boot.d/02

diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/01 
b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/01
new file mode 12
index 000..1e6fecc
--- /dev/null
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/01
@@ -0,0 +1 @@
+../boot/mmc-ext3
\ No newline at end of file
diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/02 
b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/02
new file mode 12
index 000..70b8ea3
--- /dev/null
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/02
@@ -0,0 +1 @@
+../boot/net
\ No newline at end of file
diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/03 
b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/03
new file mode 12
index 000..b41f2fd
--- /dev/null
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/boot.d/03
@@ -0,0 +1 @@
+../boot/initrd
\ No newline at end of file
diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/init/general 
b/arch/arm/boards/crystalfontz-cfa10036/env/init/general
index 5cb3a75..125de5d 100644
--- a/arch/arm/boards/crystalfontz-cfa10036/env/init/general
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/init/general
@@ -7,6 +7,3 @@ fi
 
 # timeout in seconds before the default boot entry is started
 global.autoboot_timeout=3
-
-# default boot entry (one of /env/boot/*)
-global.boot.default=mmc-ext3
diff --git a/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/01 
b/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/01
new file mode 12
index 000..70b8ea3
--- /dev/null
+++ b/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/01
@@ -0,0 +1 @@
+../boot/net
\ No newline at end of file
diff --git a/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/02 
b/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/02
new file mode 12
index 000..b41f2fd
--- /dev/null
+++ b/arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/02
@@ -0,0 +1 @@
+../boot/initrd
\ No newline at end of file
diff --git a/arch/arm/boards/pcm038/env/boot.d/01 
b/arch/arm/boards/pcm038/env/boot.d/01
new file mode 12
index 000..d1b275c
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/boot.d/01
@@ -0,0 +1 @@
+../boot/nand-ubi
\ No newline at end of file
diff --git a/arch/arm/boards/pcm038/env/boot.d/02 
b/arch/arm/boards/pcm038/env/boot.d/02
new file mode 12
index 000..70b8ea3
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/boot.d/02
@@ -0,0 +1 @@
+../boot/net
\ No newline at end of file
diff --git a/arch/arm/boards/pcm038/env/boot.d/03 
b/arch/arm/boards/pcm038/env/boot.d/03
new file mode 12
index 000..b41f2fd
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/boot.d/03
@@ -0,0 +1 @@
+../boot/initrd
\ No newline at end of file
diff --git a/arch/arm/boards/tqma53/env/boot.d/01 
b/arch/arm/boards/tqma53/env/boot.d/01
new file mode 12
index 000..70b8ea3
--- /dev/null
+++ b/arch/arm/boards/tqma53/env/boot.d/01
@@ -0,0 +1 @@
+../boot/net
\ No newline at end of file
diff --git a/arch/arm/boards/tqma53/env/boot.d/02 
b/arch/arm/boards/tqma53/env/boot.d/02
new file mode 12
index 000..b41f2fd
--- /dev/null
+++ b/arch/arm/boards/tqma53/env/boot.d/02
@@ -0,0 +1 @@
+../boot/initrd
\ No newline at end of file
diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/

[PATCH 4/7] defaultenv-2: boot reset linux.bootargs.dyn. and bootm. globarvar

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
This is need for boot sequence to do not have the previous boot param.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 defaultenv-2/base/bin/boot |4 
 1 file changed, 4 insertions(+)

diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
index 4ebda3f..103eb87 100644
--- a/defaultenv-2/base/bin/boot
+++ b/defaultenv-2/base/bin/boot
@@ -33,6 +33,10 @@ while getopt "vdhl" opt; do
fi
 done
 
+# clear linux.bootargs.dyn.* and bootm.*
+global -r linux.bootargs.dyn.
+global -r bootm.
+
 if [ $# = 0 ]; then
scr="$global.boot.default"
 else
-- 
1.7.10.4


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


[PATCH 3/7] defaultenv-2: boot use global.linux.bootargs.dyn for dynamic globarvar

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
linux.bootargs.dyn.* will be clearer at the beginning of boot

This is need for boot sequence to do not have the previous boot param.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 defaultenv-2/base/bin/bootargs-ip  |4 ++--
 defaultenv-2/base/bin/bootargs-ip-barebox  |2 +-
 defaultenv-2/base/bin/bootargs-ip-dhcp |2 +-
 defaultenv-2/base/bin/bootargs-ip-none |2 +-
 defaultenv-2/base/bin/bootargs-root-disk   |2 +-
 defaultenv-2/base/bin/bootargs-root-ext|2 +-
 defaultenv-2/base/bin/bootargs-root-initrd |2 +-
 defaultenv-2/base/bin/bootargs-root-jffs2  |2 +-
 defaultenv-2/base/bin/bootargs-root-nfs|2 +-
 defaultenv-2/base/bin/bootargs-root-ubi|2 +-
 defaultenv-2/base/bin/init |5 +++--
 defaultenv-2/base/boot/initrd  |2 +-
 12 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/defaultenv-2/base/bin/bootargs-ip 
b/defaultenv-2/base/bin/bootargs-ip
index 15041c6..2d4486c 100644
--- a/defaultenv-2/base/bin/bootargs-ip
+++ b/defaultenv-2/base/bin/bootargs-ip
@@ -5,7 +5,7 @@
 . /env/network/eth0
 
 if [ $ip = dhcp ]; then
-   global.linux.bootargs.ip="ip=dhcp"
+   global.linux.bootargs.dyn.ip="ip=dhcp"
 else
-   global.linux.bootargs.ip="ip=$ipaddr:$serverip:$gateway:$netmask::eth0:"
+   
global.linux.bootargs.dyn.ip="ip=$ipaddr:$serverip:$gateway:$netmask::eth0:"
 fi
diff --git a/defaultenv-2/base/bin/bootargs-ip-barebox 
b/defaultenv-2/base/bin/bootargs-ip-barebox
index 986c142..5a3b984 100644
--- a/defaultenv-2/base/bin/bootargs-ip-barebox
+++ b/defaultenv-2/base/bin/bootargs-ip-barebox
@@ -4,4 +4,4 @@
 
 ifup eth0
 
-global.linux.bootargs.ip="ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
+global.linux.bootargs.dyn.ip="ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
diff --git a/defaultenv-2/base/bin/bootargs-ip-dhcp 
b/defaultenv-2/base/bin/bootargs-ip-dhcp
index c542b24..dec8ae4 100644
--- a/defaultenv-2/base/bin/bootargs-ip-dhcp
+++ b/defaultenv-2/base/bin/bootargs-ip-dhcp
@@ -2,4 +2,4 @@
 
 # Do dhcp in Linux
 
-global.linux.bootargs.ip="ip=dhcp"
+global.linux.bootargs.dyn.ip="ip=dhcp"
diff --git a/defaultenv-2/base/bin/bootargs-ip-none 
b/defaultenv-2/base/bin/bootargs-ip-none
index c010154..88aaa21 100644
--- a/defaultenv-2/base/bin/bootargs-ip-none
+++ b/defaultenv-2/base/bin/bootargs-ip-none
@@ -2,4 +2,4 @@
 
 # disable ip setup in Linux
 
-global.linux.bootargs.ip="ip=none"
+global.linux.bootargs.dyn.ip="ip=none"
diff --git a/defaultenv-2/base/bin/bootargs-root-disk 
b/defaultenv-2/base/bin/bootargs-root-disk
index df8750e..aa60cf3 100644
--- a/defaultenv-2/base/bin/bootargs-root-disk
+++ b/defaultenv-2/base/bin/bootargs-root-disk
@@ -23,4 +23,4 @@ if [ -z "${fstype}" ]; then
exit 1
 fi
 
-global.linux.bootargs.root="root=/dev/$part rootfstype=$fstype rootwait"
+global.linux.bootargs.dyn.root="root=/dev/$part rootfstype=$fstype rootwait"
diff --git a/defaultenv-2/base/bin/bootargs-root-ext 
b/defaultenv-2/base/bin/bootargs-root-ext
index 45fcd5a..dbdddb9 100644
--- a/defaultenv-2/base/bin/bootargs-root-ext
+++ b/defaultenv-2/base/bin/bootargs-root-ext
@@ -9,4 +9,4 @@ while getopt "m:r:" opt; do
fi
 done
 
-global.linux.bootargs.root="root=/dev/$part rootfstype=ext$type rootwait"
+global.linux.bootargs.dyn.root="root=/dev/$part rootfstype=ext$type rootwait"
diff --git a/defaultenv-2/base/bin/bootargs-root-initrd 
b/defaultenv-2/base/bin/bootargs-root-initrd
index 7072cea..cc711a1 100644
--- a/defaultenv-2/base/bin/bootargs-root-initrd
+++ b/defaultenv-2/base/bin/bootargs-root-initrd
@@ -13,4 +13,4 @@ while getopt "i:h" opt; do
fi
 done
 
-global.linux.bootargs.root="root=/dev/ram0 rdinit=${rdinit}"
+global.linux.bootargs.dyn.root="root=/dev/ram0 rdinit=${rdinit}"
diff --git a/defaultenv-2/base/bin/bootargs-root-jffs2 
b/defaultenv-2/base/bin/bootargs-root-jffs2
index 74d59af..a8eb5e7 100644
--- a/defaultenv-2/base/bin/bootargs-root-jffs2
+++ b/defaultenv-2/base/bin/bootargs-root-jffs2
@@ -18,4 +18,4 @@ if [ -z "$mtd" ]; then
exit 1
 fi
 
-global.linux.bootargs.root="root=$mtd rootfstype=jffs2"
+global.linux.bootargs.dyn.root="root=$mtd rootfstype=jffs2"
diff --git a/defaultenv-2/base/bin/bootargs-root-nfs 
b/defaultenv-2/base/bin/bootargs-root-nfs
index 27bb6c4..355f93d 100644
--- a/defaultenv-2/base/bin/bootargs-root-nfs
+++ b/defaultenv-2/base/bin/bootargs-root-nfs
@@ -17,4 +17,4 @@ if [ -n ${serverip} ]; then
nfsroot="$serverip:$nfsroot"
 fi
 
-global.linux.bootargs.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
+global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
diff --git a/defaultenv-2/base/bin/bootargs-root-ubi 
b/defaultenv-2/base/bin/bootargs-root-ubi
index fb7f328..4260336 100644
--- a/defaultenv-2/base/bin/bootargs-root-ubi
+++ b/defaultenv-2/base/bin/bootargs-root-ubi
@@ -21,4 +21,4 @@ if [ -z "$mtd" ]; then
exit 1
 fi
 
-global.linux.bootargs.root="r

[PATCH 6/7] defaultenv-2/ansi-colors: export color only if enable

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to do not check it everywhere

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 defaultenv-2/base/data/ansi-colors |4 
 defaultenv-2/menu/menu/mainmenu|4 +---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/defaultenv-2/base/data/ansi-colors 
b/defaultenv-2/base/data/ansi-colors
index c71b6b7..6365329 100644
--- a/defaultenv-2/base/data/ansi-colors
+++ b/defaultenv-2/base/data/ansi-colors
@@ -1,5 +1,9 @@
 #!/bin/sh
 
+if [ ${global.allow_color} != "true" ]; then
+   exit
+fi
+
 # Colors
 export RED='\e[1;31m'
 export BLUE='\e[1;34m'
diff --git a/defaultenv-2/menu/menu/mainmenu b/defaultenv-2/menu/menu/mainmenu
index d7b0033..5bd7027 100644
--- a/defaultenv-2/menu/menu/mainmenu
+++ b/defaultenv-2/menu/menu/mainmenu
@@ -3,9 +3,7 @@
 savepath=$PATH
 export menupath=$PATH:/env/menu
 
-if [ ${global.allow_color} = "true" ]; then
-   . /env/data/ansi-colors
-fi
+. /env/data/ansi-colors
 
 while true; do
export PATH=${menupath}
-- 
1.7.10.4


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


[PATCH 2/7] globalvar: add support to set a value to of all globalvars beginning with 'match'

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
via c global_reset_match and global -r

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 commands/global.c   |   58 ---
 common/globalvar.c  |   10 +
 include/globalvar.h |3 +++
 3 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/commands/global.c b/commands/global.c
index de6b13e..cb22e63 100644
--- a/commands/global.c
+++ b/commands/global.c
@@ -24,25 +24,26 @@
 #include 
 #include 
 #include 
+#include 
 
-static int do_global(int argc, char *argv[])
+static int do_global_add(int argc, char *argv[])
 {
int ret;
char *value;
 
-   if (argc != 2)
+   if (argc != 1)
return COMMAND_ERROR_USAGE;
 
-   value = strchr(argv[1], '=');
+   value = strchr(argv[0], '=');
if (value) {
*value = 0;
value++;
}
 
-   ret = globalvar_add_simple(argv[1]);
+   ret = globalvar_add_simple(argv[0]);
 
if (value) {
-   char *name = asprintf("global.%s", argv[1]);
+   char *name = asprintf("global.%s", argv[0]);
ret = setenv(name, value);
free(name);
}
@@ -50,13 +51,56 @@ static int do_global(int argc, char *argv[])
return ret ? 1 : 0;
 }
 
+static int do_global_reset(int argc, char *argv[])
+{
+   char *value;
+
+   if (argc != 1)
+   return COMMAND_ERROR_USAGE;
+
+   value = strchr(argv[0], '=');
+   if (value) {
+   *value = 0;
+   value++;
+   } else {
+   value = "";
+   }
+
+   globalvar_reset_match(argv[0], value);
+
+   return 0;
+}
+
+static int do_global(int argc, char *argv[])
+{
+   int opt;
+   int do_reset = 0;
+
+   while ((opt = getopt(argc, argv, "r")) > 0) {
+   switch (opt) {
+   case 'r':
+   do_reset = 1;
+   break;
+   }
+   }
+
+   argc -= optind;
+   argv += optind;
+
+   if (do_reset)
+   return do_global_reset(argc, argv);
+
+   return do_global_add(argc, argv);
+}
+
 BAREBOX_CMD_HELP_START(global)
-BAREBOX_CMD_HELP_USAGE("global [=[=, optionally set 
to \n")
+BAREBOX_CMD_HELP_SHORT("-r to set a value to of all globalvars beginning with 
'match'")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(global)
.cmd= do_global,
-   .usage  = "create global variables",
+   .usage  = "create or reset global variables",
BAREBOX_CMD_HELP(cmd_global_help)
 BAREBOX_CMD_END
diff --git a/common/globalvar.c b/common/globalvar.c
index 71296ff..99f055e 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -46,6 +46,16 @@ char *globalvar_get_match(const char *match, const char 
*seperator)
return val;
 }
 
+void globalvar_reset_match(const char *match, const char *val)
+{
+   struct param_d *param;
+
+   list_for_each_entry(param, &global_device.parameters, list) {
+   if (!strncmp(match, param->name, strlen(match)))
+   dev_set_param(&global_device, param->name, val);
+   }
+}
+
 /*
  * globalvar_add_simple
  *
diff --git a/include/globalvar.h b/include/globalvar.h
index a127a05..1935f83 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -9,6 +9,7 @@ int globalvar_add(const char *name,
const char *(*get)(struct device_d *, struct param_d *p),
unsigned long flags);
 char *globalvar_get_match(const char *match, const char *seperator);
+void globalvar_reset_match(const char *match, const char *val);
 #else
 static inline int globalvar_add_simple(const char *name)
 {
@@ -27,6 +28,8 @@ static inline char *globalvar_get_match(const char *match, 
const char *seperator
 {
return NULL;
 }
+
+static inline void globalvar_reset_match(const char *match, const char *val) {}
 #endif
 
 #endif /* __GLOBALVAR_H */
-- 
1.7.10.4


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


[PATCH 5/7] echo: always allow to pass -e option

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to do not taint if not enabled

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 commands/echo.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/commands/echo.c b/commands/echo.c
index a19d992..566f5c2 100644
--- a/commands/echo.c
+++ b/commands/echo.c
@@ -66,11 +66,11 @@ static int do_echo(int argc, char *argv[])
goto no_optarg_out;
optind++;
break;
-#ifdef CONFIG_CMD_ECHO_E
case 'e':
+#ifdef CONFIG_CMD_ECHO_E
process_escape = 1;
-   break;
 #endif
+   break;
default:
goto exit_parse;
}
-- 
1.7.10.4


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


[PATCH 1/7] globalbar: add inline when not enabled

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 include/globalvar.h |   20 
 1 file changed, 20 insertions(+)

diff --git a/include/globalvar.h b/include/globalvar.h
index 7cc3976..a127a05 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -1,6 +1,7 @@
 #ifndef __GLOBALVAR_H
 #define __GLOBALVAR_H
 
+#ifdef CONFIG_GLOBALVAR
 int globalvar_add_simple(const char *name);
 
 int globalvar_add(const char *name,
@@ -8,5 +9,24 @@ int globalvar_add(const char *name,
const char *(*get)(struct device_d *, struct param_d *p),
unsigned long flags);
 char *globalvar_get_match(const char *match, const char *seperator);
+#else
+static inline int globalvar_add_simple(const char *name)
+{
+   return 0;
+}
+
+static inline int globalvar_add(const char *name,
+   int (*set)(struct device_d *dev, struct param_d *p, const char 
*val),
+   const char *(*get)(struct device_d *, struct param_d *p),
+   unsigned long flags)
+{
+   return 0;
+}
+
+static inline char *globalvar_get_match(const char *match, const char 
*seperator)
+{
+   return NULL;
+}
+#endif
 
 #endif /* __GLOBALVAR_H */
-- 
1.7.10.4


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


[PATCH 0/7 v2] defaultenv-2: add boot sequence

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
HI,

v2:

  drop global.boot.default as we start the boot sequence by default
  update ansi-colors
  allow to always pass -e to echo

this patch series depends on fs-symlink send previously

please pull
The following changes since commit b65e60792376bb209adfa128e1783cf67af9f13b:

  defautenv: add support of symlink (2012-09-05 03:22:14 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git tags/defaultenv-2-boot-sequence

for you to fetch changes up to 15dd5521e4aeb6061ae258251967e2f89b237f5f:

  defaultenv-2: add boot sequence (2012-09-05 20:16:01 +0800)


defaultenv-2: add boot sequence

Boot will boot run sequentially the script in /env/boot.d
We store symlink in /env/boot.d on /env/boot

drop global.boot.default
start the boot sequence by default

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 


Jean-Christophe PLAGNIOL-VILLARD (7):
  globalbar: add inline when not enabled
  globalvar: add support to set a value to of all globalvars beginning with 
'match'
  defaultenv-2: boot use global.linux.bootargs.dyn for dynamic globarvar
  defaultenv-2: boot reset linux.bootargs.dyn. and bootm. globarvar
  echo: always allow to pass -e option
  defaultenv-2/ansi-colors: export color only if enable
  defaultenv-2: add boot sequence

 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/01|1 +
 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/02|1 +
 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/03|1 +
 arch/arm/boards/crystalfontz-cfa10036/env/init/general |3 ---
 arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/01  |1 +
 arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/02  |1 +
 arch/arm/boards/pcm038/env/boot.d/01   |1 +
 arch/arm/boards/pcm038/env/boot.d/02   |1 +
 arch/arm/boards/pcm038/env/boot.d/03   |1 +
 arch/arm/boards/tqma53/env/boot.d/01   |1 +
 arch/arm/boards/tqma53/env/boot.d/02   |1 +
 commands/echo.c|4 ++--
 commands/global.c  |   58 
+++---
 common/globalvar.c |   10 ++
 defaultenv-2/base/bin/boot |   55 
+--
 defaultenv-2/base/bin/bootargs-ip  |4 ++--
 defaultenv-2/base/bin/bootargs-ip-barebox  |2 +-
 defaultenv-2/base/bin/bootargs-ip-dhcp |2 +-
 defaultenv-2/base/bin/bootargs-ip-none |2 +-
 defaultenv-2/base/bin/bootargs-root-disk   |2 +-
 defaultenv-2/base/bin/bootargs-root-ext|2 +-
 defaultenv-2/base/bin/bootargs-root-initrd |2 +-
 defaultenv-2/base/bin/bootargs-root-jffs2  |2 +-
 defaultenv-2/base/bin/bootargs-root-nfs|2 +-
 defaultenv-2/base/bin/bootargs-root-ubi|2 +-
 defaultenv-2/base/bin/init |5 +++--
 defaultenv-2/base/boot/initrd  |2 +-
 defaultenv-2/base/data/ansi-colors |4 
 defaultenv-2/base/init/general |3 ---
 defaultenv-2/menu/menu/mainmenu|4 +---
 include/globalvar.h|   23 
+++
 31 files changed, 165 insertions(+), 38 deletions(-)
 create mode 12 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/01
 create mode 12 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/02
 create mode 12 arch/arm/boards/crystalfontz-cfa10036/env/boot.d/03
 create mode 12 arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/01
 create mode 12 arch/arm/boards/freescale-mx6-sabrelite/env/boot.d/02
 create mode 12 arch/arm/boards/pcm038/env/boot.d/01
 create mode 12 arch/arm/boards/pcm038/env/boot.d/02
 create mode 12 arch/arm/boards/pcm038/env/boot.d/03
 create mode 12 arch/arm/boards/tqma53/env/boot.d/01
 create mode 12 arch/arm/boards/tqma53/env/boot.d/02

Best Regards,
J.

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


Re: MLO doesn't work, rest is ok

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
On 13:15 Wed 05 Sep , Sascha Hauer wrote:
> On Wed, Sep 05, 2012 at 01:01:54PM +0200, Norbert Roos wrote:
> > On 09/05/2012 12:53 PM, Sascha Hauer wrote:
> > 
> > >What gcc version do you have?
> > 
> > gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
> 
> Maybe you could try an older toolchain. There are some dark memories in
> my mind, but it could also be that my mind is fooling me...
> 
> > 
> > Is there something which i could quickly check in the MLO, a
> > checksum for example? Only if you know something, otherwise i can
> > look it up in the OMAP manual, what he is doing to accept the MLO.
> > 
> > As i said, it seems he doesn't like the MLO, because he's skipping
> > to the next boot source..
> 
> The MLO is generated from barebox.bin with the omap_signGP tool. It
> seems the header is 520byte in size. You could compare these between
> both images. I don't know though if this is enough for the OMAP ROM code
> to detect a valid image.
maybe too big we need to set the BAREBOX_MAX_IMAGE_SIZE
IIRC it's 54KiB

Best Regards,
J.

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


Re: Suspected ##SPAM## -:Re: [PATCH v4] xload: get barebox size from barebox_arm_head

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
On 13:37 Wed 05 Sep , Jan Weitzel wrote:
> Am Mittwoch, den 05.09.2012, 12:34 +0200 schrieb Jean-Christophe
> PLAGNIOL-VILLARD:
> > On 10:22 Wed 05 Sep , Jan Weitzel wrote:
> > > Add functions to read the barebox_arm_head, check barebox magicword
> > > and read out the barebox image size.
> > > Create a inital partion of 1Mb to access the barebox image on nand.
> > > 
> > > Signed-off-by: Jan Weitzel 
> > > ---
> > > v2: remove fall back if header read fail 
> > > v3: fix header check, rebase master 
> > > v4: factorize barebox detection
> > > 
> > >  arch/arm/include/asm/barebox-arm-head.h |9 +
> > >  arch/arm/mach-omap/include/mach/xload.h |2 +-
> > >  arch/arm/mach-omap/xload.c  |   57 
> > > --
> > >  common/filetype.c   |3 +-
> > this con not work
> > 
> > common/filetype is use accross ARCH
> > 
> > is_barebox_arm_head need to be a inline returning false if not arm
> this is why I use the ugly #include
> "../arch/arm/include/asm/barebox-arm-head.h". By now we can detect
> filetype_arm_barebox even on non arm architectures. Is breaking this OK?
no it's not

> Jan
> > 
> > Best Regards,
> > J.
> > >  4 files changed, 65 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/arch/arm/include/asm/barebox-arm-head.h 
> > > b/arch/arm/include/asm/barebox-arm-head.h
> > > index 2c250e9..42bd239 100644
> > > --- a/arch/arm/include/asm/barebox-arm-head.h
> > > +++ b/arch/arm/include/asm/barebox-arm-head.h
> > > @@ -1,6 +1,15 @@
> > >  #ifndef __ASM_ARM_HEAD_H
> > >  #define __ASM_ARM_HEAD_H
> > >  
> > > +#define ARM_HEAD_SIZE0x30
> > > +#define HEAD_MAGICWORD_OFFSET0x20
> > > +#define HEAD_SIZE_OFFSET 0x2C
> > > +
> > > +static inline int is_barebox_arm_head(const char *head)
> > > +{
> > > + return !strcmp(head + HEAD_MAGICWORD_OFFSET, "barebox");
> > > +}
put this in flietype.h

Best Regards,
J.

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


Re: MLO doesn't work, rest is ok

2012-09-05 Thread Jan Weitzel
Am Mittwoch, den 05.09.2012, 13:15 +0200 schrieb Sascha Hauer:
> On Wed, Sep 05, 2012 at 01:01:54PM +0200, Norbert Roos wrote:
> > On 09/05/2012 12:53 PM, Sascha Hauer wrote:
> > 
> > >What gcc version do you have?
> > 
> > gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
> 
> Maybe you could try an older toolchain. There are some dark memories in
> my mind, but it could also be that my mind is fooling me...
I used gcc-linaro-4.5 with gcc-4.6.2 it stops working here also.
Jan

> > 
> > Is there something which i could quickly check in the MLO, a
> > checksum for example? Only if you know something, otherwise i can
> > look it up in the OMAP manual, what he is doing to accept the MLO.
> > 
> > As i said, it seems he doesn't like the MLO, because he's skipping
> > to the next boot source..
> 
> The MLO is generated from barebox.bin with the omap_signGP tool. It
> seems the header is 520byte in size. You could compare these between
> both images. I don't know though if this is enough for the OMAP ROM code
> to detect a valid image.
> 
> Sascha
> 



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


Re: Suspected ##SPAM## -:Re: [PATCH v4] xload: get barebox size from barebox_arm_head

2012-09-05 Thread Jan Weitzel
Am Mittwoch, den 05.09.2012, 12:34 +0200 schrieb Jean-Christophe
PLAGNIOL-VILLARD:
> On 10:22 Wed 05 Sep , Jan Weitzel wrote:
> > Add functions to read the barebox_arm_head, check barebox magicword
> > and read out the barebox image size.
> > Create a inital partion of 1Mb to access the barebox image on nand.
> > 
> > Signed-off-by: Jan Weitzel 
> > ---
> > v2: remove fall back if header read fail 
> > v3: fix header check, rebase master 
> > v4: factorize barebox detection
> > 
> >  arch/arm/include/asm/barebox-arm-head.h |9 +
> >  arch/arm/mach-omap/include/mach/xload.h |2 +-
> >  arch/arm/mach-omap/xload.c  |   57 
> > --
> >  common/filetype.c   |3 +-
> this con not work
> 
> common/filetype is use accross ARCH
> 
> is_barebox_arm_head need to be a inline returning false if not arm
this is why I use the ugly #include
"../arch/arm/include/asm/barebox-arm-head.h". By now we can detect
filetype_arm_barebox even on non arm architectures. Is breaking this OK?
Jan
> 
> Best Regards,
> J.
> >  4 files changed, 65 insertions(+), 6 deletions(-)
> > 
> > diff --git a/arch/arm/include/asm/barebox-arm-head.h 
> > b/arch/arm/include/asm/barebox-arm-head.h
> > index 2c250e9..42bd239 100644
> > --- a/arch/arm/include/asm/barebox-arm-head.h
> > +++ b/arch/arm/include/asm/barebox-arm-head.h
> > @@ -1,6 +1,15 @@
> >  #ifndef __ASM_ARM_HEAD_H
> >  #define __ASM_ARM_HEAD_H
> >  
> > +#define ARM_HEAD_SIZE  0x30
> > +#define HEAD_MAGICWORD_OFFSET  0x20
> > +#define HEAD_SIZE_OFFSET   0x2C
> > +
> > +static inline int is_barebox_arm_head(const char *head)
> > +{
> > +   return !strcmp(head + HEAD_MAGICWORD_OFFSET, "barebox");
> > +}
> > +
> >  static inline void barebox_arm_head(void)
> >  {
> > __asm__ __volatile__ (
> > diff --git a/arch/arm/mach-omap/include/mach/xload.h 
> > b/arch/arm/mach-omap/include/mach/xload.h
> > index 844b57f..26f1b68 100644
> > --- a/arch/arm/mach-omap/include/mach/xload.h
> > +++ b/arch/arm/mach-omap/include/mach/xload.h
> > @@ -1,7 +1,7 @@
> >  #ifndef _MACH_XLOAD_H
> >  #define _MACH_XLOAD_H
> >  
> > -void *omap_xload_boot_nand(int offset, int size);
> > +void *omap_xload_boot_nand(int offset);
> >  void *omap_xload_boot_mmc(void);
> >  
> >  enum omap_boot_src {
> > diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
> > index 13024ab..5f9ca26 100644
> > --- a/arch/arm/mach-omap/xload.c
> > +++ b/arch/arm/mach-omap/xload.c
> > @@ -7,16 +7,65 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  
> > -void *omap_xload_boot_nand(int offset, int size)
> > +void *read_image_head(const char *name)
> >  {
> > +   void *header = xmalloc(ARM_HEAD_SIZE);
> > +   struct cdev *cdev;
> > int ret;
> > -   void *to = xmalloc(size);
> > +
> > +   cdev = cdev_open(name, O_RDONLY);
> > +   if (!cdev) {
> > +   printf("failed to open partition\n");
> > +   return NULL;
> > +   }
> > +
> > +   ret = cdev_read(cdev, header, ARM_HEAD_SIZE, 0, 0);
> > +   cdev_close(cdev);
> > +
> > +   if (ret != ARM_HEAD_SIZE) {
> > +   printf("failed to read from partition\n");
> > +   return NULL;
> > +   }
> > +
> > +   return header;
> > +}
> > +
> > +unsigned int get_image_size(void *head)
> > +{
> > +   unsigned int ret = 0;
> > +   unsigned int *psize = head + HEAD_SIZE_OFFSET;
> > +
> > +   if (is_barebox_arm_head(head))
> > +   ret = *psize;
> > +   debug("Detected barebox image size %u\n", ret);
> > +
> > +   return ret;
> > +}
> > +
> > +void *omap_xload_boot_nand(int offset)
> > +{
> > +   int ret;
> > +   int size;
> > +   void *to, *header;
> > struct cdev *cdev;
> >  
> > -   devfs_add_partition("nand0", offset, size, DEVFS_PARTITION_FIXED, "x");
> > +   devfs_add_partition("nand0", offset, SZ_1M, DEVFS_PARTITION_FIXED, "x");
> > dev_add_bb_dev("x", "bbx");
> >  
> > +   header = read_image_head("bbx");
> > +   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("bbx", O_RDONLY);
> > if (!cdev) {
> > printf("failed to open nand\n");
> > @@ -80,7 +129,7 @@ int run_shell(void)
> > printf("unknown boot source. Fall back to nand\n");
> > case OMAP_BOOTSRC_NAND:
> > printf("booting from NAND\n");
> > -   func = omap_xload_boot_nand(SZ_128K, SZ_256K);
> > +   func = omap_xload_boot_nand(SZ_128K);
> > break;
> > }
> >  
> > diff --git a/common/filetype.c b/common/filetype.c
> > index 1a5b82d..a95e4fd 100644
> > --- a/common/filetype.c
> > +++ b/common/filetype.c
> > @@ -25,6 +25,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include "../arch/arm/include/asm/barebox-arm-head.h"
> >  
> >  static const char *filetype_str[] = {
> > [file

Re: MLO doesn't work, rest is ok

2012-09-05 Thread Anand Gadiyar
On Wed, Sep 5, 2012 at 4:31 PM, Norbert Roos wrote:

> On 09/05/2012 12:53 PM, Sascha Hauer wrote:
>
>  What gcc version do you have?
>>
>
> gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
>
> Is there something which i could quickly check in the MLO, a checksum for
> example? Only if you know something, otherwise i can look it up in the OMAP
> manual, what he is doing to accept the MLO.
>
> As i said, it seems he doesn't like the MLO, because he's skipping to the
> next boot source..
>



What is the size of the generated MLO file?

- Anand
___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: MLO doesn't work, rest is ok

2012-09-05 Thread Sascha Hauer
On Wed, Sep 05, 2012 at 01:01:54PM +0200, Norbert Roos wrote:
> On 09/05/2012 12:53 PM, Sascha Hauer wrote:
> 
> >What gcc version do you have?
> 
> gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

Maybe you could try an older toolchain. There are some dark memories in
my mind, but it could also be that my mind is fooling me...

> 
> Is there something which i could quickly check in the MLO, a
> checksum for example? Only if you know something, otherwise i can
> look it up in the OMAP manual, what he is doing to accept the MLO.
> 
> As i said, it seems he doesn't like the MLO, because he's skipping
> to the next boot source..

The MLO is generated from barebox.bin with the omap_signGP tool. It
seems the header is 520byte in size. You could compare these between
both images. I don't know though if this is enough for the OMAP ROM code
to detect a valid image.

Sascha

-- 
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- |

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


Re: MLO doesn't work, rest is ok

2012-09-05 Thread Norbert Roos

On 09/05/2012 12:53 PM, Sascha Hauer wrote:


What gcc version do you have?


gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

Is there something which i could quickly check in the MLO, a checksum 
for example? Only if you know something, otherwise i can look it up in 
the OMAP manual, what he is doing to accept the MLO.


As i said, it seems he doesn't like the MLO, because he's skipping to 
the next boot source..


Norbert

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


Re: MLO doesn't work, rest is ok

2012-09-05 Thread Sascha Hauer
On Wed, Sep 05, 2012 at 12:00:56PM +0200, Norbert Roos wrote:
> On 09/05/2012 11:41 AM, Jan Weitzel wrote:
> 
> >I just test it here it works.
> 
> Did another test - still doesn't work:
> 
> tar xfj barebox-2012.08.0.tar.bz2
> cd barebox-2012.08.0
> export ARCH=arm
> export CROSS_COMPILE=arm-linux-gnueabi-
> make pcm049_xload_defconfig
> make
> cp MLO barebox.bin 
> 
> >Did you use pcm049_xload_defconfig?
> 
> Yes
> 
> >SD card layout ok?
> 
> As described in various places. A downloaded MLO does work.
> 
> >Special nand mounted?
> 
> What is this? NAND is enabled in the config...

I think it even doesn't have to be enabled in the config. You won't be
able to boot the second stage barebox from Nand then of course, but
still you should see some output from the first stage.

What gcc version do you have?

Sascha


-- 
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- |

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


Re: [PATCH v4] xload: get barebox size from barebox_arm_head

2012-09-05 Thread Jean-Christophe PLAGNIOL-VILLARD
On 10:22 Wed 05 Sep , Jan Weitzel wrote:
> Add functions to read the barebox_arm_head, check barebox magicword
> and read out the barebox image size.
> Create a inital partion of 1Mb to access the barebox image on nand.
> 
> Signed-off-by: Jan Weitzel 
> ---
> v2: remove fall back if header read fail 
> v3: fix header check, rebase master 
> v4: factorize barebox detection
> 
>  arch/arm/include/asm/barebox-arm-head.h |9 +
>  arch/arm/mach-omap/include/mach/xload.h |2 +-
>  arch/arm/mach-omap/xload.c  |   57 --
>  common/filetype.c   |3 +-
this con not work

common/filetype is use accross ARCH

is_barebox_arm_head need to be a inline returning false if not arm

Best Regards,
J.
>  4 files changed, 65 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/include/asm/barebox-arm-head.h 
> b/arch/arm/include/asm/barebox-arm-head.h
> index 2c250e9..42bd239 100644
> --- a/arch/arm/include/asm/barebox-arm-head.h
> +++ b/arch/arm/include/asm/barebox-arm-head.h
> @@ -1,6 +1,15 @@
>  #ifndef __ASM_ARM_HEAD_H
>  #define __ASM_ARM_HEAD_H
>  
> +#define ARM_HEAD_SIZE0x30
> +#define HEAD_MAGICWORD_OFFSET0x20
> +#define HEAD_SIZE_OFFSET 0x2C
> +
> +static inline int is_barebox_arm_head(const char *head)
> +{
> + return !strcmp(head + HEAD_MAGICWORD_OFFSET, "barebox");
> +}
> +
>  static inline void barebox_arm_head(void)
>  {
>   __asm__ __volatile__ (
> diff --git a/arch/arm/mach-omap/include/mach/xload.h 
> b/arch/arm/mach-omap/include/mach/xload.h
> index 844b57f..26f1b68 100644
> --- a/arch/arm/mach-omap/include/mach/xload.h
> +++ b/arch/arm/mach-omap/include/mach/xload.h
> @@ -1,7 +1,7 @@
>  #ifndef _MACH_XLOAD_H
>  #define _MACH_XLOAD_H
>  
> -void *omap_xload_boot_nand(int offset, int size);
> +void *omap_xload_boot_nand(int offset);
>  void *omap_xload_boot_mmc(void);
>  
>  enum omap_boot_src {
> diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
> index 13024ab..5f9ca26 100644
> --- a/arch/arm/mach-omap/xload.c
> +++ b/arch/arm/mach-omap/xload.c
> @@ -7,16 +7,65 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
> -void *omap_xload_boot_nand(int offset, int size)
> +void *read_image_head(const char *name)
>  {
> + void *header = xmalloc(ARM_HEAD_SIZE);
> + struct cdev *cdev;
>   int ret;
> - void *to = xmalloc(size);
> +
> + cdev = cdev_open(name, O_RDONLY);
> + if (!cdev) {
> + printf("failed to open partition\n");
> + return NULL;
> + }
> +
> + ret = cdev_read(cdev, header, ARM_HEAD_SIZE, 0, 0);
> + cdev_close(cdev);
> +
> + if (ret != ARM_HEAD_SIZE) {
> + printf("failed to read from partition\n");
> + return NULL;
> + }
> +
> + return header;
> +}
> +
> +unsigned int get_image_size(void *head)
> +{
> + unsigned int ret = 0;
> + unsigned int *psize = head + HEAD_SIZE_OFFSET;
> +
> + if (is_barebox_arm_head(head))
> + ret = *psize;
> + debug("Detected barebox image size %u\n", ret);
> +
> + return ret;
> +}
> +
> +void *omap_xload_boot_nand(int offset)
> +{
> + int ret;
> + int size;
> + void *to, *header;
>   struct cdev *cdev;
>  
> - devfs_add_partition("nand0", offset, size, DEVFS_PARTITION_FIXED, "x");
> + devfs_add_partition("nand0", offset, SZ_1M, DEVFS_PARTITION_FIXED, "x");
>   dev_add_bb_dev("x", "bbx");
>  
> + header = read_image_head("bbx");
> + 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("bbx", O_RDONLY);
>   if (!cdev) {
>   printf("failed to open nand\n");
> @@ -80,7 +129,7 @@ int run_shell(void)
>   printf("unknown boot source. Fall back to nand\n");
>   case OMAP_BOOTSRC_NAND:
>   printf("booting from NAND\n");
> - func = omap_xload_boot_nand(SZ_128K, SZ_256K);
> + func = omap_xload_boot_nand(SZ_128K);
>   break;
>   }
>  
> diff --git a/common/filetype.c b/common/filetype.c
> index 1a5b82d..a95e4fd 100644
> --- a/common/filetype.c
> +++ b/common/filetype.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include "../arch/arm/include/asm/barebox-arm-head.h"
>  
>  static const char *filetype_str[] = {
>   [filetype_unknown] = "unknown",
> @@ -57,7 +58,7 @@ enum filetype file_detect_type(void *_buf)
>  
>   if (strncmp(buf8, "#!/bin/sh", 9) == 0)
>   return filetype_sh;
> - if (buf[8] == 0x65726162 && buf[9] == 0x00786f62)
> + if (is_barebox_arm_head(_buf))
>   return filetype_arm_barebox;
>   if (buf[9] == 0x016f2818 || buf[9] == 0x18286f01)
>   return filetype_arm_zimage;
> -- 
> 1.7.0.4
> 

__

Re: MLO doesn't work, rest is ok

2012-09-05 Thread Norbert Roos

On 09/05/2012 11:41 AM, Jan Weitzel wrote:


I just test it here it works.


Did another test - still doesn't work:

tar xfj barebox-2012.08.0.tar.bz2
cd barebox-2012.08.0
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
make pcm049_xload_defconfig
make
cp MLO barebox.bin 


Did you use pcm049_xload_defconfig?


Yes


SD card layout ok?


As described in various places. A downloaded MLO does work.


Special nand mounted?


What is this? NAND is enabled in the config...

Thank you so far
Norbert

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


Re: [PATCH v4 0/2] Add stmpe mfd

2012-09-05 Thread Sascha Hauer
On Wed, Sep 05, 2012 at 10:23:51AM +0200, Steffen Trumtrar wrote:
> Hi,
> 
> another day, another patch version. This version includes the following 
> requests by
> Sascha and Marc (Thanks again):
>   - remove all the iomem stuff in add_generic_device in stmpe-i2c.c
>   - allocate stmpe_client_info for every device, not just one
>   - remove unused struct fields
>   - remove extern for prototypes
> 
> Regards,
> Steffen
> 
> 
> Steffen Trumtrar (2):
>   mfd: add stmpe-i2c driver
>   gpio: add driver for stmpe io-expander

Applied, thanks

Sascha

> 
>  drivers/Kconfig   |1 +
>  drivers/gpio/Kconfig  |9 +++
>  drivers/gpio/Makefile |2 +
>  drivers/gpio/gpio-stmpe.c |  161 
> +
>  drivers/mfd/Kconfig   |4 ++
>  drivers/mfd/Makefile  |1 +
>  drivers/mfd/stmpe-i2c.c   |  153 ++
>  include/mfd/stmpe-i2c.h   |   53 +++
>  8 files changed, 384 insertions(+)
>  create mode 100644 drivers/gpio/Kconfig
>  create mode 100644 drivers/gpio/Makefile
>  create mode 100644 drivers/gpio/gpio-stmpe.c
>  create mode 100644 drivers/mfd/stmpe-i2c.c
>  create mode 100644 include/mfd/stmpe-i2c.h
> 
> -- 
> 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- |

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


Re: MLO doesn't work, rest is ok

2012-09-05 Thread Jan Weitzel
Am Mittwoch, den 05.09.2012, 11:25 +0200 schrieb Norbert Roos:
> On 09/05/2012 08:12 AM, Jan Weitzel wrote:
> 
> >> I just wanted to try the freshly generated MLO and barebox.bin on my
> >> Phytec PCM049 board (OMAP4 based). Copied both files to the FAT
> >> partition on the SD card.
> >>
> >> Unfortunately it doesn't boot, after trying to boot from SD card the ROM
> >> boot loader oviously skips to booting from UART.
> >
> > Hi,
> > which barebox version? Is the board with OMAP4460?
> 
> barebox is 2012.08.0, OMAP4430.

I just test it here it works. Did you use pcm049_xload_defconfig? SD
card layout ok? Special nand mounted? Maybe you ask at supp...@phytec.de
Jan

> bye
> Norbert
> 
> 
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox



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


Re: [PATCH 09/10] omap3: allow enabling clocks for UART3, MMC1 and SPI

2012-09-05 Thread Jan Lübbe
On Tue, 2012-09-04 at 10:48 +0200, Sascha Hauer wrote:
> On Mon, Sep 03, 2012 at 01:46:04PM +0200, Jan Luebbe wrote:
> > Signed-off-by: Jan Luebbe 
> > ---
> >  arch/arm/mach-omap/Kconfig   |4 
> >  arch/arm/mach-omap/omap3_clock.c |   35 +--
> >  2 files changed, 29 insertions(+), 10 deletions(-)
> > 
> > diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
> > index a781287..82fa46b 100644
> > --- a/arch/arm/mach-omap/Kconfig
> > +++ b/arch/arm/mach-omap/Kconfig
> > @@ -61,6 +61,10 @@ config OMAP_CLOCK_UART3
> > bool
> >  config OMAP_CLOCK_I2C
> > bool
> > +config OMAP_CLOCK_MMC1
> > +   bool
> > +config OMAP_CLOCK_SPI
> > +   bool
> 
> A Kconfig entry for enabling a clock is overkill. Please do not continue
> this.
> 
> Right now we have:
> 
> config OMAP_CLOCK_UART
>   bool
> config OMAP_CLOCK_UART2
>   bool
> config OMAP_CLOCK_UART3
>   bool
> config OMAP_CLOCK_I2C
>   bool
> 
> And it's completely unused, so can be simply removed.

What should I do instead? Enable all clocks? Or enable just the clocks
for which drivers have been enabled in Kconfig?

Thanks,
Jan
-- 
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- |


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


Re: MLO doesn't work, rest is ok

2012-09-05 Thread Norbert Roos

On 09/05/2012 08:12 AM, Jan Weitzel wrote:


I just wanted to try the freshly generated MLO and barebox.bin on my
Phytec PCM049 board (OMAP4 based). Copied both files to the FAT
partition on the SD card.

Unfortunately it doesn't boot, after trying to boot from SD card the ROM
boot loader oviously skips to booting from UART.


Hi,
which barebox version? Is the board with OMAP4460?


barebox is 2012.08.0, OMAP4430.

bye
Norbert


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


Re: [PATCH 10/10] drivers/spi: add driver for the Multichannel SPI controller found in TI SoCs

2012-09-05 Thread Jan Lübbe
Hi,

On Tue, 2012-09-04 at 10:58 +0200, Sascha Hauer wrote:
> > + for (i = 0; i < len; i++) {
> > + /* wait till TX register is empty (TXS == 1) */
> > + while
> (!(readl(®s->channel[spi->chip_select].chstat) &
> > +  OMAP3_MCSPI_CHSTAT_TXS)) {
> > + if (--timeout <= 0) {
> > + printf("SPI TXS timed out, status=0x%
> 08x\n",
> > +
> readl(®s->channel[spi->chip_select].chstat));
> > + return -1;
> > + }
> > + }
> 
> Please use a well defined timeout rather than 'poll a million times' 

I tried using is_timeout like this:
timer_start = get_time_ns();
while (!(readl(®s->channel[spi->chip_select].chstat) &
 OMAP3_MCSPI_CHSTAT_TXS)) {
if (is_timeout(timer_start, SPI_WAIT_TIMEOUT)) {
printf("SPI TXS timed out, status=0x%08x\n",
   
readl(®s->channel[spi->chip_select].chstat));
return -1;
}
}

With SPI_WAIT_TIMEOUT = MSECOND this results in ~23% more time needed
for reading/writing:

With a simple counter:
barebox@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 12639ms
barebox@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 12639ms
barebox@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 12659ms

With is_timeout():
barebox@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 15561ms
barebox@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 15564ms
barebox@KSP-0500:/ time cp /dev/m25p0.norkernel /dev/null
time: 15568ms

Is this really acceptable? Is there a way to avoid the overhead of
calling several functions for each loop?

Regards,
Jan
-- 
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- |


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


[PATCH v4 1/2] mfd: add stmpe-i2c driver

2012-09-05 Thread Steffen Trumtrar
The stmpe mfds can be connected via i2c and spi. This driver provides the basic
infrastructure for the i2c kind. It can be added as a normal i2c-device in the
board code. To enable functions a platform_data struct has to be provided, that
describes what parts of the chip are to be used.

Signed-off-by: Steffen Trumtrar 
---
 drivers/mfd/Kconfig |4 ++
 drivers/mfd/Makefile|1 +
 drivers/mfd/stmpe-i2c.c |  153 +++
 include/mfd/stmpe-i2c.h |   53 
 4 files changed, 211 insertions(+)
 create mode 100644 drivers/mfd/stmpe-i2c.c
 create mode 100644 include/mfd/stmpe-i2c.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index af67935..20eef86 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -33,4 +33,8 @@ config I2C_TWL6030
select I2C_TWLCORE
bool "TWL6030 driver"
 
+config I2C_STMPE
+   depends on I2C
+   bool "STMPE-i2c driver"
+
 endmenu
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index e11223b..792ae2d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_I2C_LP3972) += lp3972.o
 obj-$(CONFIG_I2C_TWLCORE) += twl-core.o
 obj-$(CONFIG_I2C_TWL4030) += twl4030.o
 obj-$(CONFIG_I2C_TWL6030) += twl6030.o
+obj-$(CONFIG_I2C_STMPE) += stmpe-i2c.o
diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
new file mode 100644
index 000..4af8b7b
--- /dev/null
+++ b/drivers/mfd/stmpe-i2c.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2012 Pengutronix
+ * Steffen Trumtrar 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define DRIVERNAME "stmpe-i2c"
+
+#define to_stmpe(a)container_of(a, struct stmpe, cdev)
+
+int stmpe_reg_read(struct stmpe *stmpe, u32 reg, u8 *val)
+{
+   int ret;
+
+   ret = i2c_read_reg(stmpe->client, reg, val, 1);
+
+   return ret == 1 ? 0 : ret;
+}
+EXPORT_SYMBOL(stmpe_reg_read)
+
+int stmpe_reg_write(struct stmpe *stmpe, u32 reg, u8 val)
+{
+   int ret;
+
+   ret = i2c_write_reg(stmpe->client, reg, &val, 1);
+
+   return ret == 1 ? 0 : ret;
+}
+EXPORT_SYMBOL(stmpe_reg_write)
+
+int stmpe_set_bits(struct stmpe *stmpe, u32 reg, u8 mask, u8 val)
+{
+   u8 tmp;
+   int err;
+
+   err = stmpe_reg_read(stmpe, reg, &tmp);
+   tmp = (tmp & ~mask) | val;
+
+   if (!err)
+   err = stmpe_reg_write(stmpe, reg, tmp);
+
+   return err;
+}
+EXPORT_SYMBOL(stmpe_set_bits);
+
+static ssize_t stmpe_read(struct cdev *cdev, void *_buf, size_t count, loff_t 
offset, ulong flags)
+{
+   struct stmpe *stmpe = to_stmpe(cdev);
+   u8 *buf = _buf;
+   size_t i = count;
+   int err;
+
+   while (i) {
+   err = stmpe_reg_read(stmpe, offset, buf);
+   if (err)
+   return (ssize_t)err;
+   buf++;
+   i--;
+   offset++;
+   }
+
+   return count;
+}
+
+static ssize_t stmpe_write(struct cdev *cdev, const void *_buf, size_t count, 
loff_t offset, ulong flags)
+{
+   struct stmpe *stmpe = to_stmpe(cdev);
+   const u8 *buf = _buf;
+   size_t i = count;
+   int err;
+
+   while (i) {
+   err = stmpe_reg_write(stmpe, offset, *buf);
+   if (err)
+   return (ssize_t)err;
+   buf++;
+   i--;
+   offset++;
+   }
+
+   return count;
+}
+
+static struct file_operations stmpe_fops = {
+   .lseek  = dev_lseek_default,
+   .read   = stmpe_read,
+   .write  = stmpe_write,
+};
+
+static int stmpe_probe(struct device_d *dev)
+{
+   struct stmpe_platform_data *pdata = dev->platform_data;
+   struct stmpe *stmpe_dev;
+   struct stmpe_client_info *i2c_ci;
+
+   if (!pdata) {
+   dev_dbg(dev, "no platform data\n");
+   return -ENODEV;
+   }
+
+   stmpe_dev = xzalloc(sizeof(struct stmpe));
+   stmpe_dev->cdev.name = DRIVERNAME;
+   stmpe_dev->client = to_i2c_client(dev);
+   stmpe_dev->cdev.size = 191; /* 191 known registers */
+   stmpe_dev->cdev.dev = dev;
+   stmpe_dev->cdev.ops = &stmpe_fops;
+   stmpe_dev->pdata = pdata;
+   dev->priv = stmpe_dev;
+
+   i2c_ci = xzalloc(sizeof(struct stmpe_client_info));
+   i2c_ci->stmpe = stmpe_dev;
+   i2c_ci->read_reg = stmpe_reg_read;
+   i2c_ci->write_reg = stmpe_reg_write;
+
+   i

[PATCH v4 2/2] gpio: add driver for stmpe io-expander

2012-09-05 Thread Steffen Trumtrar
Signed-off-by: Steffen Trumtrar 
---
 drivers/Kconfig   |1 +
 drivers/gpio/Kconfig  |9 +++
 drivers/gpio/Makefile |2 +
 drivers/gpio/gpio-stmpe.c |  161 +
 4 files changed, 173 insertions(+)
 create mode 100644 drivers/gpio/Kconfig
 create mode 100644 drivers/gpio/Makefile
 create mode 100644 drivers/gpio/gpio-stmpe.c

diff --git a/drivers/Kconfig b/drivers/Kconfig
index 883b0e7..adf8fcd 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -18,5 +18,6 @@ source "drivers/input/Kconfig"
 source "drivers/watchdog/Kconfig"
 source "drivers/pwm/Kconfig"
 source "drivers/dma/Kconfig"
+source "drivers/gpio/Kconfig"
 
 endmenu
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
new file mode 100644
index 000..acfd4ef
--- /dev/null
+++ b/drivers/gpio/Kconfig
@@ -0,0 +1,9 @@
+menu "GPIO  "
+
+config STMPE_GPIO
+   depends on I2C
+   depends on GPIOLIB
+   select I2C_STMPE
+   bool "STMPE GPIO Expander"
+
+endmenu
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
new file mode 100644
index 000..da1bc21
--- /dev/null
+++ b/drivers/gpio/Makefile
@@ -0,0 +1,2 @@
+obj-y += gpio.o
+obj-$(CONFIG_STMPE_GPIO) += gpio-stmpe.o
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
new file mode 100644
index 000..fa3b041
--- /dev/null
+++ b/drivers/gpio/gpio-stmpe.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2012 Pengutronix
+ * Steffen Trumtrar 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GPIO_BASE  0x80
+#define GPIO_SET   (GPIO_BASE + 0x02)
+#define GPIO_CLR   (GPIO_BASE + 0x04)
+#define GPIO_MP(GPIO_BASE + 0x06)
+#define GPIO_SET_DIR   (GPIO_BASE + 0x08)
+#define GPIO_ED(GPIO_BASE + 0x0a)
+#define GPIO_RE(GPIO_BASE + 0x0c)
+#define GPIO_FE(GPIO_BASE + 0x0e)
+#define GPIO_PULL_UP   (GPIO_BASE + 0x10)
+#define GPIO_AF(GPIO_BASE + 0x12)
+#define GPIO_LT(GPIO_BASE + 0x16)
+
+#define OFFSET(gpio)   (0xff & (1 << (gpio)) ? 1 : 0)
+
+struct stmpe_gpio_chip {
+   struct gpio_chip chip;
+   struct stmpe_client_info *ci;
+};
+
+static void stmpe_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int 
value)
+{
+   struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct 
stmpe_gpio_chip, chip);
+   struct stmpe_client_info *ci = (struct stmpe_client_info 
*)stmpegpio->ci;
+   int ret;
+   u8 val;
+
+   ci->read_reg(ci->stmpe, GPIO_MP + OFFSET(gpio), &val);
+
+   val |= 1 << (gpio % 8);
+
+   if (value)
+   ret = ci->write_reg(ci->stmpe, GPIO_SET + OFFSET(gpio), val);
+   else
+   ret = ci->write_reg(ci->stmpe, GPIO_CLR + OFFSET(gpio), val);
+
+   if (ret)
+   dev_err(chip->dev, "write failed!\n");
+}
+
+static int stmpe_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
+{
+   struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct 
stmpe_gpio_chip, chip);
+   struct stmpe_client_info *ci = (struct stmpe_client_info 
*)stmpegpio->ci;
+   int ret;
+   u8 val;
+
+   ci->read_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), &val);
+   val &= ~(1 << (gpio % 8));
+   ret = ci->write_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), val);
+
+   if (ret)
+   dev_err(chip->dev, "couldn't change direction. Write 
failed!\n");
+
+   return ret;
+}
+
+static int stmpe_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, 
int value)
+{
+   struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct 
stmpe_gpio_chip, chip);
+   struct stmpe_client_info *ci = (struct stmpe_client_info 
*)stmpegpio->ci;
+   int ret;
+   u8 val;
+
+   ci->read_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), &val);
+   val |= 1 << (gpio % 8);
+   ret = ci->write_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), val);
+
+   stmpe_gpio_set_value(chip, gpio, value);
+
+   if (ret)
+   dev_err(chip->dev, "couldn't change direction. Write 
failed!\n");
+
+   return ret;
+}
+
+static int stmpe_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
+{
+   struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct 
stmpe_gpio_chip, chip);
+   struct stmpe_client_info *ci = (struct stmpe_client_info 
*)stmpegpio->ci;
+   u8 val;
+   int ret;
+
+   ret = ci->read_reg(c

[PATCH v4 0/2] Add stmpe mfd

2012-09-05 Thread Steffen Trumtrar
Hi,

another day, another patch version. This version includes the following 
requests by
Sascha and Marc (Thanks again):
- remove all the iomem stuff in add_generic_device in stmpe-i2c.c
- allocate stmpe_client_info for every device, not just one
- remove unused struct fields
- remove extern for prototypes

Regards,
Steffen


Steffen Trumtrar (2):
  mfd: add stmpe-i2c driver
  gpio: add driver for stmpe io-expander

 drivers/Kconfig   |1 +
 drivers/gpio/Kconfig  |9 +++
 drivers/gpio/Makefile |2 +
 drivers/gpio/gpio-stmpe.c |  161 +
 drivers/mfd/Kconfig   |4 ++
 drivers/mfd/Makefile  |1 +
 drivers/mfd/stmpe-i2c.c   |  153 ++
 include/mfd/stmpe-i2c.h   |   53 +++
 8 files changed, 384 insertions(+)
 create mode 100644 drivers/gpio/Kconfig
 create mode 100644 drivers/gpio/Makefile
 create mode 100644 drivers/gpio/gpio-stmpe.c
 create mode 100644 drivers/mfd/stmpe-i2c.c
 create mode 100644 include/mfd/stmpe-i2c.h

-- 
1.7.10.4


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


[PATCH v4] xload: get barebox size from barebox_arm_head

2012-09-05 Thread Jan Weitzel
Add functions to read the barebox_arm_head, check barebox magicword
and read out the barebox image size.
Create a inital partion of 1Mb to access the barebox image on nand.

Signed-off-by: Jan Weitzel 
---
v2: remove fall back if header read fail 
v3: fix header check, rebase master 
v4: factorize barebox detection

 arch/arm/include/asm/barebox-arm-head.h |9 +
 arch/arm/mach-omap/include/mach/xload.h |2 +-
 arch/arm/mach-omap/xload.c  |   57 --
 common/filetype.c   |3 +-
 4 files changed, 65 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/barebox-arm-head.h 
b/arch/arm/include/asm/barebox-arm-head.h
index 2c250e9..42bd239 100644
--- a/arch/arm/include/asm/barebox-arm-head.h
+++ b/arch/arm/include/asm/barebox-arm-head.h
@@ -1,6 +1,15 @@
 #ifndef __ASM_ARM_HEAD_H
 #define __ASM_ARM_HEAD_H
 
+#define ARM_HEAD_SIZE  0x30
+#define HEAD_MAGICWORD_OFFSET  0x20
+#define HEAD_SIZE_OFFSET   0x2C
+
+static inline int is_barebox_arm_head(const char *head)
+{
+   return !strcmp(head + HEAD_MAGICWORD_OFFSET, "barebox");
+}
+
 static inline void barebox_arm_head(void)
 {
__asm__ __volatile__ (
diff --git a/arch/arm/mach-omap/include/mach/xload.h 
b/arch/arm/mach-omap/include/mach/xload.h
index 844b57f..26f1b68 100644
--- a/arch/arm/mach-omap/include/mach/xload.h
+++ b/arch/arm/mach-omap/include/mach/xload.h
@@ -1,7 +1,7 @@
 #ifndef _MACH_XLOAD_H
 #define _MACH_XLOAD_H
 
-void *omap_xload_boot_nand(int offset, int size);
+void *omap_xload_boot_nand(int offset);
 void *omap_xload_boot_mmc(void);
 
 enum omap_boot_src {
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 13024ab..5f9ca26 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -7,16 +7,65 @@
 #include 
 #include 
 #include 
+#include 
 
-void *omap_xload_boot_nand(int offset, int size)
+void *read_image_head(const char *name)
 {
+   void *header = xmalloc(ARM_HEAD_SIZE);
+   struct cdev *cdev;
int ret;
-   void *to = xmalloc(size);
+
+   cdev = cdev_open(name, O_RDONLY);
+   if (!cdev) {
+   printf("failed to open partition\n");
+   return NULL;
+   }
+
+   ret = cdev_read(cdev, header, ARM_HEAD_SIZE, 0, 0);
+   cdev_close(cdev);
+
+   if (ret != ARM_HEAD_SIZE) {
+   printf("failed to read from partition\n");
+   return NULL;
+   }
+
+   return header;
+}
+
+unsigned int get_image_size(void *head)
+{
+   unsigned int ret = 0;
+   unsigned int *psize = head + HEAD_SIZE_OFFSET;
+
+   if (is_barebox_arm_head(head))
+   ret = *psize;
+   debug("Detected barebox image size %u\n", ret);
+
+   return ret;
+}
+
+void *omap_xload_boot_nand(int offset)
+{
+   int ret;
+   int size;
+   void *to, *header;
struct cdev *cdev;
 
-   devfs_add_partition("nand0", offset, size, DEVFS_PARTITION_FIXED, "x");
+   devfs_add_partition("nand0", offset, SZ_1M, DEVFS_PARTITION_FIXED, "x");
dev_add_bb_dev("x", "bbx");
 
+   header = read_image_head("bbx");
+   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("bbx", O_RDONLY);
if (!cdev) {
printf("failed to open nand\n");
@@ -80,7 +129,7 @@ int run_shell(void)
printf("unknown boot source. Fall back to nand\n");
case OMAP_BOOTSRC_NAND:
printf("booting from NAND\n");
-   func = omap_xload_boot_nand(SZ_128K, SZ_256K);
+   func = omap_xload_boot_nand(SZ_128K);
break;
}
 
diff --git a/common/filetype.c b/common/filetype.c
index 1a5b82d..a95e4fd 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include "../arch/arm/include/asm/barebox-arm-head.h"
 
 static const char *filetype_str[] = {
[filetype_unknown] = "unknown",
@@ -57,7 +58,7 @@ enum filetype file_detect_type(void *_buf)
 
if (strncmp(buf8, "#!/bin/sh", 9) == 0)
return filetype_sh;
-   if (buf[8] == 0x65726162 && buf[9] == 0x00786f62)
+   if (is_barebox_arm_head(_buf))
return filetype_arm_barebox;
if (buf[9] == 0x016f2818 || buf[9] == 0x18286f01)
return filetype_arm_zimage;
-- 
1.7.0.4


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