[PATCH] commands: Fix memtest return value

2013-09-02 Thread Christian Hemp
Signed-off-by: Christian Hemp c.h...@phytec.de
---
 commands/memtest.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/commands/memtest.c b/commands/memtest.c
index d2a1487..c82badc 100644
--- a/commands/memtest.c
+++ b/commands/memtest.c
@@ -236,7 +236,7 @@ out:
return 1;
} else {
printf(Memtest successful.\n);
-   return 1;
+   return 0;
}
 }
 
-- 
1.7.0.4


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


Re: [PATCH 1/3 for next] AM33xx: Cleanup of lowlevel code

2013-09-02 Thread Jan Lübbe
On Fri, 2013-08-23 at 09:00 +0200, Teresa Gámez wrote:
 There is a lot of duplicate lowlevel code between the
 am33xx boards. Move this code to am33xx_generic and
 create structs for sdram settings.
 
 Signed-off-by: Teresa Gámez t.ga...@phytec.de

Just for comparison, the current u-boot mainline does something similar:
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/include/asm/arch-am33xx/ddr_defs.h;hb=HEAD

-- 
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/4] ppc: add mpc85xx device tree fixup functions

2013-09-02 Thread Sascha Hauer
Hi Renaud,

On Fri, Aug 30, 2013 at 02:34:27PM +0100, Renaud Barbier wrote:
 +/* These properties specify whether the hardware supports the stashing
 + * of buffer descriptors in L2 cache.
 + */
 +static void fdt_add_enet_stashing(void *fdt)
 +{
 + struct device_node *node;
 +
 + node = of_find_compatible_node(fdt, NULL, gianfar);
 + while (node) {
 + of_set_property(node, bd-stash, NULL, 0, 1);
 + of_property_write_u32(node, rx-stash-len, 96);
 + of_property_write_u32(node, rx-stash-idx, 0);
 + node = of_find_compatible_node(node, NULL, gianfar);
 + }
 +}

Out of curiosity, why is this dynamically added and not part of the
static dts file?

 +
 +static int fdt_stdout_setup(struct device_node *blob)
 +{
 + struct device_node *node, *alias;
 + char sername[9] = { 0 };
 + const char *prop;
 + struct console_device *cdev;
 + int len;
 +
 + node = of_find_node_by_path(/chosen);
 + if (node == NULL)
 + node = of_create_node(blob, /chosen);

You should be able to call of_create_node() without checking for
existence first. If the node already exists of_create_node() will just
return that node.

 +
 + if (node == NULL) {
 + pr_err(%s: could not open /chosen node\n, __func__);
 + goto error;
 + }
 +
 + for_each_console(cdev)
 + if ((cdev-f_active  (CONSOLE_STDIN | CONSOLE_STDOUT)))
 + break;
 + if (cdev)
 + sprintf(sername, serial%d, cdev-dev-id);
 + else
 + sprintf(sername, serial%d, 0);
 +
 + alias = of_find_node_by_path_from(blob, /aliases);
 + if (!alias) {
 + pr_err(%s: could not get aliases node.\n, __func__);
 + goto error;
 + }
 + prop = of_get_property(alias, sername, len);
 + of_set_property(node, linux,stdout-path, prop, len, 1);
 + return 0;
 +error:
 + return 1;

Please return an error code.

 +}
 +
 +static void fdt_mac_setup(struct device_node *blob)
 +{
 + struct device_node *alias, *node;
 + const char *path, *tmp;
 + char mac[16], eth[12], *end;
 + unsigned char mac_addr[6];
 + struct device_d *dev;
 + int ix, idx = 0;
 +
 + alias = of_find_node_by_path_from(blob, /aliases);
 + if (!alias) {
 + pr_err(%s: Failed to get /aliases node\n, __func__);
 + return;
 + }
 +
 + sprintf(mac, eth%d.ethaddr, idx);
 + while ((tmp = getenv(mac)) != NULL) {
 + sprintf(eth, eth%d, idx);
 + dev = get_device_by_name(eth);
 +
 + /* If the parent id is not set correctly by
 +  * the board support, the wrong device path
 +  * may be obtained.
 +  */
 + sprintf(eth, ethernet%d, dev-parent-id);
 + path = of_get_property(alias, eth, NULL);
 + if (!path) {
 + idx++;
 + sprintf(mac, eth%d.ethaddr, idx);
 + continue;
 + }
 +
 + for (ix = 0; ix  6; ix++) {
 + mac_addr[ix] = tmp ? simple_strtoul(tmp, end, 16) : 0;
 + if (tmp)
 + tmp = (*end) ? end+1 : end;
 + }
 +
 + node = of_find_node_by_path_from(blob, path);
 + of_set_property(node, mac-address, mac_addr,
 + sizeof(mac_addr), 1);
 + of_set_property(node, local-mac-address, mac_addr,
 + sizeof(mac_addr), 1);
 + idx++;
 + sprintf(mac, eth%d.ethaddr, idx);
 + }
 +}

This function could be simplified by using of_find_node_by_alias().

We already have eth_of_fixup(). Would it be possible to use this by
changing it to something like this:

static int eth_of_fixup(struct device_node *root)
{
struct eth_device *edev;
struct device_node *node;
int ret;

/*
 * Add the mac-address property for each network device we
 * find a nodepath for and which has a valid mac address.
 */
list_for_each_entry(edev, netdev_list, list) {
if (!is_valid_ether_addr(edev-ethaddr)) {
dev_dbg(edev-dev, %s: no valid mac address, cannot 
fixup\n,
__func__);
continue;
}

if (edev-nodepath) {
node = of_find_node_by_path_from(root, edev-nodepath);
} else {
char eth[12];
sprintf(eth, ethernet%d, edev-dev.id);
node = of_find_node_by_alias(root, eth);
}

if (!node) {
dev_dbg(edev-dev, %s: no node to fixup\n, __func__);
continue;
}

ret = of_set_property(node, mac-address, edev-ethaddr, 6, 1);
 

Re: [PATCH] commands: Fix memtest return value

2013-09-02 Thread Sascha Hauer
On Mon, Sep 02, 2013 at 08:38:29AM +0200, Christian Hemp wrote:
 Signed-off-by: Christian Hemp c.h...@phytec.de

Applied, thanks

Sascha

 ---
  commands/memtest.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/commands/memtest.c b/commands/memtest.c
 index d2a1487..c82badc 100644
 --- a/commands/memtest.c
 +++ b/commands/memtest.c
 @@ -236,7 +236,7 @@ out:
   return 1;
   } else {
   printf(Memtest successful.\n);
 - return 1;
 + return 0;
   }
  }
  
 -- 
 1.7.0.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: [PATCH 1/1] arm: mmu: catch NULL pointer dereferences

2013-09-02 Thread Sascha Hauer
On Sat, Aug 31, 2013 at 05:54:22PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 For high vectors if memory start at 0x0. We have to
 live without being able to catch NULL pointer dereferences.
 
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  arch/arm/cpu/mmu.c | 27 +--
  1 file changed, 21 insertions(+), 6 deletions(-)
 
 diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
 index e3ea3b6..2e69b16 100644
 --- a/arch/arm/cpu/mmu.c
 +++ b/arch/arm/cpu/mmu.c
 @@ -218,9 +218,9 @@ static int arm_mmu_remap_sdram(struct memory_bank *bank)
  /*
   * Map vectors and zero page
   */
 -static void vectors_init(void)
 +static void vectors_init(bool zero_valid_addr)
  {
 - u32 *exc, *zero = NULL;
 + u32 *exc;
   void *vectors;
   u32 cr;
  
 @@ -235,10 +235,19 @@ static void vectors_init(void)
* page table for the high vectors and zero page
*/
   exc = arm_create_pte(0xfff0);
 - zero = arm_create_pte(0x0);
  
 - /* Set the zero page to faulting */
 - zero[0] = 0;
 + /*
 +  * Memory start at 0x0. We have to
 +  * live without being able to catch NULL pointer dereferences
 +  */
 + if (!zero_valid_addr) {
 + u32 *zero = NULL;
 +
 + zero = arm_create_pte(0x0);
 +
 + /* Set the zero page to faulting */
 + zero[0] = 0;
 + }
   } else {
   /*
* Otherwise map the vectors to the zero page. We have to
 @@ -267,6 +276,7 @@ static int mmu_init(void)
  {
   struct memory_bank *bank;
   int i;
 + bool is_start_zero = 0;
  
   arm_set_cache_functions();
  
 @@ -303,7 +313,12 @@ static int mmu_init(void)
   create_sections(0, 0, PAGE_SIZE, PMD_SECT_AP_WRITE | PMD_SECT_AP_READ |
   PMD_TYPE_SECT);
  
 - vectors_init();
 + for_each_memory_bank(bank) {
 + if (bank-start == 0x0)
 + is_start_zero = 1;
 + }
 +
 + vectors_init(is_start_zero);

Why not add the check to vectors_init() instead of passing this as
argument?

I must say I'm not entirely happy with this approach. Being able to
catch NULL pointer derefs is really a good thing. When exactly does the
faulting zero SDRAM page become a problem for you? obviously something
like

cp /somehing /dev/ram0

does not work. Some care must probably be taken when setting up the
kernel parameters. Are these the problems or is there something else?

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 1/1] bootm: add global bootm.{image/initrd}.loadaddr support

2013-09-02 Thread Sascha Hauer
On Sun, Sep 01, 2013 at 08:04:47AM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 To be able to pass the loadaddr of the image and the initrd.
 
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com

Applied, thanks

Sascha

 ---
  commands/bootm.c | 22 +-
  1 file changed, 21 insertions(+), 1 deletion(-)
 
 diff --git a/commands/bootm.c b/commands/bootm.c
 index 6ce2ca9..60c2ece 100644
 --- a/commands/bootm.c
 +++ b/commands/bootm.c
 @@ -241,6 +241,19 @@ static char *bootm_image_name_and_no(const char *name, 
 int *no)
  #define BOOTM_OPTS BOOTM_OPTS_COMMON
  #endif
  
 +unsigned long long getenv_loadaddr(const char *name)
 +{
 + const char *valstr = getenv(name);
 +
 + if (!valstr)
 + return UIMAGE_SOME_ADDRESS;
 +
 + if (valstr[0] == '\0')
 + return UIMAGE_SOME_ADDRESS;
 +
 + return simple_strtoull(valstr, NULL, 0);
 +}
 +
  static int do_bootm(int argc, char *argv[])
  {
   int opt;
 @@ -260,6 +273,8 @@ static int do_bootm(int argc, char *argv[])
  
   oftree = getenv(global.bootm.oftree);
   os_file = getenv(global.bootm.image);
 + data.os_address = getenv_loadaddr(global.bootm.image.loadaddr);
 + data.initrd_address = getenv_loadaddr(global.bootm.initrd.loadaddr);
   if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD))
   initrd_file = getenv(global.bootm.initrd);
  
 @@ -436,9 +451,12 @@ static int bootm_init(void)
  {
  
   globalvar_add_simple(bootm.image);
 + globalvar_add_simple(bootm.image.loadaddr);
   globalvar_add_simple(bootm.oftree);
 - if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD))
 + if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD)) {
   globalvar_add_simple(bootm.initrd);
 + globalvar_add_simple(bootm.initrd.loadaddr);
 + }
  
   return 0;
  }
 @@ -470,7 +488,9 @@ BAREBOX_CMD_END
  
  BAREBOX_MAGICVAR(bootargs, Linux Kernel parameters);
  BAREBOX_MAGICVAR_NAMED(global_bootm_image, global.bootm.image, bootm 
 default boot image);
 +BAREBOX_MAGICVAR_NAMED(global_bootm_image_loadaddr, 
 global.bootm.image.loadaddr, bootm default boot image loadaddr);
  BAREBOX_MAGICVAR_NAMED(global_bootm_initrd, global.bootm.initrd, bootm 
 default initrd);
 +BAREBOX_MAGICVAR_NAMED(global_bootm_initrd_loadaddr, 
 global.bootm.initrd.loadaddr, bootm default initrd loadaddr);
  
  static struct binfmt_hook binfmt_uimage_hook = {
   .type = filetype_uimage,
 -- 
 1.8.4.rc1
 
 
 ___
 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: [PATCH 1/1] arm: mmu: catch NULL pointer dereferences

2013-09-02 Thread Jean-Christophe PLAGNIOL-VILLARD
On 11:05 Mon 02 Sep , Sascha Hauer wrote:
 On Sat, Aug 31, 2013 at 05:54:22PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
 wrote:
  For high vectors if memory start at 0x0. We have to
  live without being able to catch NULL pointer dereferences.
  
  Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
  ---
   arch/arm/cpu/mmu.c | 27 +--
   1 file changed, 21 insertions(+), 6 deletions(-)
  
  diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
  index e3ea3b6..2e69b16 100644
  --- a/arch/arm/cpu/mmu.c
  +++ b/arch/arm/cpu/mmu.c
  @@ -218,9 +218,9 @@ static int arm_mmu_remap_sdram(struct memory_bank *bank)
   /*
* Map vectors and zero page
*/
  -static void vectors_init(void)
  +static void vectors_init(bool zero_valid_addr)
   {
  -   u32 *exc, *zero = NULL;
  +   u32 *exc;
  void *vectors;
  u32 cr;
   
  @@ -235,10 +235,19 @@ static void vectors_init(void)
   * page table for the high vectors and zero page
   */
  exc = arm_create_pte(0xfff0);
  -   zero = arm_create_pte(0x0);
   
  -   /* Set the zero page to faulting */
  -   zero[0] = 0;
  +   /*
  +* Memory start at 0x0. We have to
  +* live without being able to catch NULL pointer dereferences
  +*/
  +   if (!zero_valid_addr) {
  +   u32 *zero = NULL;
  +
  +   zero = arm_create_pte(0x0);
  +
  +   /* Set the zero page to faulting */
  +   zero[0] = 0;
  +   }
  } else {
  /*
   * Otherwise map the vectors to the zero page. We have to
  @@ -267,6 +276,7 @@ static int mmu_init(void)
   {
  struct memory_bank *bank;
  int i;
  +   bool is_start_zero = 0;
   
  arm_set_cache_functions();
   
  @@ -303,7 +313,12 @@ static int mmu_init(void)
  create_sections(0, 0, PAGE_SIZE, PMD_SECT_AP_WRITE | PMD_SECT_AP_READ |
  PMD_TYPE_SECT);
   
  -   vectors_init();
  +   for_each_memory_bank(bank) {
  +   if (bank-start == 0x0)
  +   is_start_zero = 1;
  +   }
  +
  +   vectors_init(is_start_zero);
 
 Why not add the check to vectors_init() instead of passing this as
 argument?
 
 I must say I'm not entirely happy with this approach. Being able to
 catch NULL pointer derefs is really a good thing. When exactly does the
 faulting zero SDRAM page become a problem for you? obviously something
 like
 
 cp /somehing /dev/ram0
 
 does not work. Some care must probably be taken when setting up the
 kernel parameters. Are these the problems or is there something else?
yes it's get issue with uImage that get data load there :(

as I can not control the load addr from uImage :(

and on ux5x0 and arm board I have ddr starting at 0x0

Best Regards,
J.

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


[PATCH] PCM051: Fix muxing of MMC0 CD

2013-09-02 Thread Teresa Gámez
Card detect should be rather muxed as gpio then
mmc0_sdcd, as driver does not support this.

Signed-off-by: Teresa Gámez t.ga...@phytec.de
---
 arch/arm/boards/pcm051/mux.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/boards/pcm051/mux.c b/arch/arm/boards/pcm051/mux.c
index 6ef5af1..b54f3d5 100644
--- a/arch/arm/boards/pcm051/mux.c
+++ b/arch/arm/boards/pcm051/mux.c
@@ -10,7 +10,7 @@ static const struct module_pin_mux mmc0_pin_mux[] = {
{OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)},  /* MMC0_DAT0 */
{OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)},   /* MMC0_CLK */
{OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)},   /* MMC0_CMD */
-   {OFFSET(spi0_cs1), (MODE(5) | RXACTIVE | PULLUP_EN)},   /* MMC0_CD */
+   {OFFSET(spi0_cs1), (MODE(7) | RXACTIVE | PULLUP_EN)},   /* MMC0_CD */
{-1},
 };
 
-- 
1.7.0.4


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


Re: [PATCH 2/4] ppc: add mpc85xx device tree fixup functions

2013-09-02 Thread Renaud Barbier
On 02/09/2013 09:49, Sascha Hauer wrote:
 Hi Renaud,
 
 On Fri, Aug 30, 2013 at 02:34:27PM +0100, Renaud Barbier wrote:
  +/* These properties specify whether the hardware supports the stashing
  + * of buffer descriptors in L2 cache.
  + */
  +static void fdt_add_enet_stashing(void *fdt)
  +{
  +  struct device_node *node;
  +
  +  node = of_find_compatible_node(fdt, NULL, gianfar);
  +  while (node) {
  +  of_set_property(node, bd-stash, NULL, 0, 1);
  +  of_property_write_u32(node, rx-stash-len, 96);
  +  of_property_write_u32(node, rx-stash-idx, 0);
  +  node = of_find_compatible_node(node, NULL, gianfar);
  +  }
  +}
 Out of curiosity, why is this dynamically added and not part of the
 static dts file?
 

I will have to quote the original comment from U-Boot as I cannot find
a reasonable explanation why it is done this way.


Original U-boot commit:
Date:   Tue Oct 7 08:09:50 2008 -0500
Have u-boot pass stashing parameters into device tree

Some cores don't support ethernet stashing at all, and some
instances have errata.  Adds 3 properties to gianfar nodes
which support stashing.  For now, just add this support to
85xx SoCs.



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


[PATCH 2/4] AT91: move have_intensity_bit into board setup

2013-09-02 Thread Darren Garnier
Signed-off-by: Darren Garnier dgarn...@reinrag.net
---
arch/arm/boards/at91sam9261ek/init.c | 2 ++
arch/arm/mach-at91/at91sam9261_devices.c | 2 --
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/at91sam9261ek/init.c 
b/arch/arm/boards/at91sam9261ek/init.c
index 00fc745..b420a48 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/init.c
@@ -223,6 +223,8 @@ static void ek_add_device_lcdc(void)

if (machine_is_at91sam9g10ek())
ek_lcdc_data.lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB;
+   else
+   ek_lcdc_data.has_intensity_bit = true;

at91_add_device_lcdc(ek_lcdc_data);
}
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c 
b/arch/arm/mach-at91/at91sam9261_devices.c
index b522afb..ba52e56 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -218,8 +218,6 @@ void __init at91_add_device_lcdc(struct 
atmel_lcdfb_platform_data *data)
{
BUG_ON(!data);

-   data-have_intensity_bit = true;
-
#if defined(CONFIG_FB_ATMEL_STN)
at91_set_A_periph(AT91_PIN_PB0, 0); /* LCDVSYNC */
at91_set_A_periph(AT91_PIN_PB1, 0); /* LCDHSYNC */
-- 
1.8.3.1



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


[PATCH 1/4] mtd: fix erasesize math for non power-of-2 devices

2013-09-02 Thread Darren Garnier
Signed-off-by: Darren Garnier dgarn...@reinrag.net
---
drivers/mtd/core.c | 19 ---
fs/devfs-core.c|  4 ++--
2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 70036aa..ed9658b 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -25,6 +25,7 @@
#include ioctl.h
#include nand.h
#include errno.h
+#include linux/math64.h

#include mtd.h

@@ -82,9 +83,6 @@ static ssize_t mtd_op_read(struct cdev *cdev, void* buf, 
size_t count,
return retlen;
}

-#define NOTALIGNED(x) (x  (mtd-writesize - 1)) != 0
-#define MTDPGALG(x) ((x)  ~(mtd-writesize - 1))
-
#ifdef CONFIG_MTD_WRITE
static ssize_t mtd_op_write(struct cdev* cdev, const void *buf, size_t _count,
  loff_t _offset, ulong flags)
@@ -112,15 +110,22 @@ static struct mtd_erase_region_info 
*mtd_find_erase_region(struct mtd_info *mtd,
return NULL;
}

+#define ALIGNED_OFFSET(offset, bs) ((bs  (bs-1)) == 0) ? \
+   offset 
 ~(bs-1) : \
+   bs * 
div_u64(offset,bs)
+#define ALIGNED_COUNT(count, bs) ((bs  (bs-1)) == 0) ? \
+   
ALIGN(count,bs) : \
+   bs * 
div_u64(count+(bs-1),bs)
+
static int mtd_erase_align(struct mtd_info *mtd, size_t *count, loff_t *offset)
{
struct mtd_erase_region_info *e;
loff_t ofs;

if (mtd-numeraseregions == 0) {
-   ofs = *offset  ~(mtd-erasesize - 1);
+   ofs = ALIGNED_OFFSET(*offset, mtd-erasesize);
*count += (*offset - ofs);
-   *count = ALIGN(*count, mtd-erasesize);
+   *count = ALIGNED_COUNT(*count, mtd-erasesize);
*offset = ofs;
return 0;
}
@@ -129,14 +134,14 @@ static int mtd_erase_align(struct mtd_info *mtd, size_t 
*count, loff_t *offset)
if (!e)
return -EINVAL;

-   ofs = *offset  ~(e-erasesize - 1);
+   ofs = ALIGNED_OFFSET(*offset, mtd-erasesize);
*count += (*offset - ofs);

e = mtd_find_erase_region(mtd, *offset + *count);
if (!e)
return -EINVAL;

-   *count = ALIGN(*count, e-erasesize);
+   *count = ALIGNED_COUNT(*count, e-erasesize);
*offset = ofs;

return 0;
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index a92d434..757c9b7 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -24,6 +24,7 @@
#include ioctl.h
#include linux/err.h
#include linux/mtd/mtd.h
+#include linux/math64.h

LIST_HEAD(cdev_list);

@@ -197,11 +198,10 @@ static int partition_ioctl(struct cdev *cdev, int 
request, void *buf)
case MEMGETREGIONINFO:
if (cdev-mtd) {
struct region_info_user *reg = buf;
-   int erasesize_shift = ffs(cdev-mtd-erasesize) - 1;

reg-offset = cdev-offset;
reg-erasesize = cdev-mtd-erasesize;
-   reg-numblocks = cdev-size  erasesize_shift;
+   reg-numblocks = div_u64(cdev-size, 
cdev-mtd-erasesize);
reg-regionindex = cdev-mtd-index;
}
break;
-- 
1.8.3.1



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


[PATCH 0/4] ARM: support for CPODC2 board

2013-09-02 Thread Darren Garnier
I'm a little new to contributing upstream, so please bear with me.

These are patches against the next that allow for a beautifully functional 
build of barebox
for the CPO Science DataCollector II device.  Kudos to the barebox team for a 
very functional 
piece of software.

In case you are wondering, the CPO DC2 is an at91sam9261 and at91sam9g10 based 
board used
for taking scientific measurements in a middle school classroom setting.  Its 
similar to the Atmel ek
board, except it has a co-processor MCU for the data taking (and backlight 
control.)

Besides adding the board support, I found a couple of places where changes in 
the tree were required.

First, MTD was assuming for eraseblocks that they are a power of two. This is 
not the case for Atmel DataFlash.

Second, for the at91sam9261 soc, not all have intensity bit... so this was 
taken out of the mach-at91 and 
put into the board file where it belonged.

The third patch are small changes to the build system that should be portable 
and allow it to run on MacOSX 10.8.

Finally, the fourth patch is my board support.


Darren Garnier (4):
 mtd: fix erasesize math for non power-of-2 devices
 AT91: move have_intensity_bit into board setup
 small tweeks to build system for compatibility on MacOS X
 ARM: support for CPO Science DataCollector II

Makefile  |   6 +-
arch/arm/boards/Makefile  |   1 +
arch/arm/boards/at91sam9261ek/init.c  |   2 +
arch/arm/boards/cpodc2/Makefile   |   4 +
arch/arm/boards/cpodc2/env/boot/dataflash |  10 +
arch/arm/boards/cpodc2/env/boot/net-usb   |  22 ++
arch/arm/boards/cpodc2/env/config-board   |   6 +
arch/arm/boards/cpodc2/env/dfu.png| Bin 0 - 1669 bytes
arch/arm/boards/cpodc2/env/init/automount |  12 +
arch/arm/boards/cpodc2/env/init/msp430|  10 +
arch/arm/boards/cpodc2/env/init/mtdparts  |  19 ++
arch/arm/boards/cpodc2/env/init/splash|   8 +
arch/arm/boards/cpodc2/env/init/usb   |  55 
arch/arm/boards/cpodc2/env/splash.png | Bin 0 - 1356 bytes
arch/arm/boards/cpodc2/env/usb.png| Bin 0 - 339 bytes
arch/arm/boards/cpodc2/init.c | 364 +
arch/arm/boards/cpodc2/lowlevel_init.c| 108 +++
arch/arm/boards/cpodc2/msp430.c   | 513 ++
arch/arm/boards/cpodc2/msp430.h   |  23 ++
arch/arm/configs/cpodc2_defconfig |  96 ++
arch/arm/mach-at91/Kconfig|  24 ++
arch/arm/mach-at91/at91sam9261_devices.c  |   2 -
drivers/mtd/core.c|  19 +-
fs/devfs-core.c   |   4 +-
scripts/genenv|   3 +-
25 files changed, 1296 insertions(+), 15 deletions(-)
create mode 100644 arch/arm/boards/cpodc2/Makefile
create mode 100755 arch/arm/boards/cpodc2/env/boot/dataflash
create mode 100755 arch/arm/boards/cpodc2/env/boot/net-usb
create mode 100755 arch/arm/boards/cpodc2/env/config-board
create mode 100644 arch/arm/boards/cpodc2/env/dfu.png
create mode 100755 arch/arm/boards/cpodc2/env/init/automount
create mode 100644 arch/arm/boards/cpodc2/env/init/msp430
create mode 100755 arch/arm/boards/cpodc2/env/init/mtdparts
create mode 100755 arch/arm/boards/cpodc2/env/init/splash
create mode 100755 arch/arm/boards/cpodc2/env/init/usb
create mode 100644 arch/arm/boards/cpodc2/env/splash.png
create mode 100644 arch/arm/boards/cpodc2/env/usb.png
create mode 100644 arch/arm/boards/cpodc2/init.c
create mode 100644 arch/arm/boards/cpodc2/lowlevel_init.c
create mode 100644 arch/arm/boards/cpodc2/msp430.c
create mode 100644 arch/arm/boards/cpodc2/msp430.h
create mode 100644 arch/arm/configs/cpodc2_defconfig

-- 
1.8.3.1


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


[PATCH 3/4] small tweeks to build system for compatibility on MacOS X

2013-09-02 Thread Darren Garnier
Signed-off-by: Darren Garnier dgarn...@reinrag.net
---
Makefile   | 6 +++---
scripts/genenv | 3 ++-
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 397c54a..ff17d8f 100644
--- a/Makefile
+++ b/Makefile
@@ -577,7 +577,7 @@ define rule_barebox__
$(cmd_sysmap) $@ System.map; \
if [ $$? -ne 0 ]; then   \
rm -f $@;\
-   /bin/false;  \
+   false;   \
fi;
endef

@@ -614,7 +614,7 @@ define verify_kallsyms
$(Q)cmp -s System.map .tmp_System.map || \
(echo Inconsistent kallsyms data;\
 echo Try setting CONFIG_KALLSYMS_EXTRA_PASS;\
-rm .tmp_kallsyms* ; /bin/false )
+rm .tmp_kallsyms* ; false )
endef

# Update barebox version before link
@@ -782,7 +782,7 @@ ifneq ($(KBUILD_SRC),)
$(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
echo   $(srctree) is not clean, please run 'make mrproper';\
echo   in the '$(srctree)' directory.;\
-   /bin/false; \
+   false; \
fi;
$(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
$(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/barebox.h ]; then  \
diff --git a/scripts/genenv b/scripts/genenv
index 374db6d..b3b6ec5 100755
--- a/scripts/genenv
+++ b/scripts/genenv
@@ -24,7 +24,8 @@ for i in $*; do
done
)

-find $tempdir -name '.svn' -o -name '*~' | xargs --no-run-if-empty rm -r
+#find $tempdir -name '.svn' -o -name '*~' | xargs --no-run-if-empty rm -r
+find $tempdir -name '.svn' -o -name '*~' -delete

$objtree/scripts/bareboxenv -s $tempdir $target

-- 
1.8.3.1



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


[PATCH 4/4] ARM: support for CPO Science DataCollector II

2013-09-02 Thread Darren Garnier
Signed-off-by: Darren Garnier dgarn...@reinrag.net
---
arch/arm/boards/Makefile  |   1 +
arch/arm/boards/cpodc2/Makefile   |   4 +
arch/arm/boards/cpodc2/env/boot/dataflash |  10 +
arch/arm/boards/cpodc2/env/boot/net-usb   |  22 ++
arch/arm/boards/cpodc2/env/config-board   |   6 +
arch/arm/boards/cpodc2/env/dfu.png| Bin 0 - 1669 bytes
arch/arm/boards/cpodc2/env/init/automount |  12 +
arch/arm/boards/cpodc2/env/init/msp430|  10 +
arch/arm/boards/cpodc2/env/init/mtdparts  |  19 ++
arch/arm/boards/cpodc2/env/init/splash|   8 +
arch/arm/boards/cpodc2/env/init/usb   |  55 
arch/arm/boards/cpodc2/env/splash.png | Bin 0 - 1356 bytes
arch/arm/boards/cpodc2/env/usb.png| Bin 0 - 339 bytes
arch/arm/boards/cpodc2/init.c | 364 +
arch/arm/boards/cpodc2/lowlevel_init.c| 108 +++
arch/arm/boards/cpodc2/msp430.c   | 513 ++
arch/arm/boards/cpodc2/msp430.h   |  23 ++
arch/arm/configs/cpodc2_defconfig |  96 ++
arch/arm/mach-at91/Kconfig|  24 ++
19 files changed, 1275 insertions(+)
create mode 100644 arch/arm/boards/cpodc2/Makefile
create mode 100755 arch/arm/boards/cpodc2/env/boot/dataflash
create mode 100755 arch/arm/boards/cpodc2/env/boot/net-usb
create mode 100755 arch/arm/boards/cpodc2/env/config-board
create mode 100644 arch/arm/boards/cpodc2/env/dfu.png
create mode 100755 arch/arm/boards/cpodc2/env/init/automount
create mode 100644 arch/arm/boards/cpodc2/env/init/msp430
create mode 100755 arch/arm/boards/cpodc2/env/init/mtdparts
create mode 100755 arch/arm/boards/cpodc2/env/init/splash
create mode 100755 arch/arm/boards/cpodc2/env/init/usb
create mode 100644 arch/arm/boards/cpodc2/env/splash.png
create mode 100644 arch/arm/boards/cpodc2/env/usb.png
create mode 100644 arch/arm/boards/cpodc2/init.c
create mode 100644 arch/arm/boards/cpodc2/lowlevel_init.c
create mode 100644 arch/arm/boards/cpodc2/msp430.c
create mode 100644 arch/arm/boards/cpodc2/msp430.h
create mode 100644 arch/arm/configs/cpodc2_defconfig

diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 38ef512..0c93187 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_MACH_CCMX51) += ccxmx51/
obj-$(CONFIG_MACH_CFA10036) += crystalfontz-cfa10036/
obj-$(CONFIG_MACH_CHUMBY)   += chumby_falconwing/
obj-$(CONFIG_MACH_CLEP7212) += clep7212/
+obj-$(CONFIG_MACH_CPODC2)  += cpodc2/
obj-$(CONFIG_MACH_DFI_FS700_M60)+= dfi-fs700-m60/
obj-$(CONFIG_MACH_DSS11)+= dss11/
obj-$(CONFIG_MACH_EDB93012) += edb93xx/
diff --git a/arch/arm/boards/cpodc2/Makefile b/arch/arm/boards/cpodc2/Makefile
new file mode 100644
index 000..2bfa4fa
--- /dev/null
+++ b/arch/arm/boards/cpodc2/Makefile
@@ -0,0 +1,4 @@
+obj-y += init.o
+obj-$(CONFIG_CPODC2_MSP430) += msp430.o
+
+lwl-$(CONFIG_HAVE_AT91_LOWLEVEL_INIT) += lowlevel_init.o
diff --git a/arch/arm/boards/cpodc2/env/boot/dataflash 
b/arch/arm/boards/cpodc2/env/boot/dataflash
new file mode 100755
index 000..bc59750
--- /dev/null
+++ b/arch/arm/boards/cpodc2/env/boot/dataflash
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ $1 = menu ]; then
+   boot-menu-add-entry $0 dataflash
+   exit
+fi
+
+global.bootm.image=/dev/dataflash0.kernel
+#global.bootm.oftree=/env/oftree
+global.linux.bootargs.dyn.root=root=ubi0:rootfs ubi.mtd=nand0.root 
rootfstype=ubifs
diff --git a/arch/arm/boards/cpodc2/env/boot/net-usb 
b/arch/arm/boards/cpodc2/env/boot/net-usb
new file mode 100755
index 000..6e341a0
--- /dev/null
+++ b/arch/arm/boards/cpodc2/env/boot/net-usb
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ $1 = menu ]; then
+   boot-menu-add-entry $0 network (tftp, nfs) (usb ethernet)
+   exit
+fi
+
+usb -f
+ethact eth1
+
+if [ $? -ne 0 ]; then
+   echo ERROR: usb ethernet not found
+   exit 1
+fi
+
+path=/mnt/tftp
+
+global.bootm.image=${path}/${global.user}-linux-${global.hostname}
+#global.bootm.oftree=${path}/${global.user}-oftree-${global.hostname}
+nfsroot=/home/${global.user}/nfsroot/${global.hostname}
+bootargs-ip
+global.linux.bootargs.dyn.root=root=/dev/nfs nfsroot=$nfsroot,v3,tcp
diff --git a/arch/arm/boards/cpodc2/env/config-board 
b/arch/arm/boards/cpodc2/env/config-board
new file mode 100755
index 000..8ee2290
--- /dev/null
+++ b/arch/arm/boards/cpodc2/env/config-board
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+global.hostname=cpodc2
+global.user=cpodc2
+global.autoboot_timeout=1
+global.boot.default=dataflash
diff --git a/arch/arm/boards/cpodc2/env/dfu.png 
b/arch/arm/boards/cpodc2/env/dfu.png
new file mode 100644
index 
..a8f2cdd96c739efb4d8985a51f76499f31c6a05e
GIT binary patch
literal 1669
zcmZ`)XH-*Z5PcF@l_o{1peRL}lH_uSy2c|389EeixSW$2nig6^csQ~60xD?xki_;

[PATCH] MIPS: qemu-malta: switch to devicetree

2013-09-02 Thread Antony Pavlov
Signed-off-by: Antony Pavlov antonynpav...@gmail.com
---
 arch/mips/boards/qemu-malta/init.c | 31 ++-
 arch/mips/configs/qemu-malta_defconfig |  1 +
 arch/mips/dts/qemu-malta.dts   | 33 +
 3 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/arch/mips/boards/qemu-malta/init.c 
b/arch/mips/boards/qemu-malta/init.c
index ddc90dc..4d12495 100644
--- a/arch/mips/boards/qemu-malta/init.c
+++ b/arch/mips/boards/qemu-malta/init.c
@@ -17,39 +17,12 @@
  */
 
 #include common.h
-#include types.h
-#include driver.h
 #include init.h
-#include ns16550.h
-#include mach/hardware.h
-#include partition.h
-#include sizes.h
 
-static int malta_devices_init(void)
+static int malta_core_init(void)
 {
-   add_cfi_flash_device(0, 0x1e00, SZ_4M, 0);
-
-   devfs_add_partition(nor0, 0x0, SZ_512K, DEVFS_PARTITION_FIXED, 
self);
-   devfs_add_partition(nor0, SZ_512K, SZ_64K, DEVFS_PARTITION_FIXED, 
env0);
-
-   return 0;
-}
-device_initcall(malta_devices_init);
-
-static struct NS16550_plat serial_plat = {
-   .clock = 1843200, /* no matter for emulated port */
-   .shift = 0,
-};
-
-static int malta_console_init(void)
-{
-   barebox_set_model(qemu malta);
barebox_set_hostname(malta);
 
-   /* Register the serial port */
-   add_ns16550_device(DEVICE_ID_DYNAMIC, MALTA_PIIX4_UART0, 8,
-   IORESOURCE_MEM_8BIT, serial_plat);
-
return 0;
 }
-console_initcall(malta_console_init);
+core_initcall(malta_core_init);
diff --git a/arch/mips/configs/qemu-malta_defconfig 
b/arch/mips/configs/qemu-malta_defconfig
index 18c840d..1b9ee9a 100644
--- a/arch/mips/configs/qemu-malta_defconfig
+++ b/arch/mips/configs/qemu-malta_defconfig
@@ -54,6 +54,7 @@ CONFIG_NET_PING=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_NET_RESOLV=y
 CONFIG_OFDEVICE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
 # CONFIG_SPI is not set
 CONFIG_MTD=y
 CONFIG_DRIVER_CFI=y
diff --git a/arch/mips/dts/qemu-malta.dts b/arch/mips/dts/qemu-malta.dts
index c4dcf05..4057729 100644
--- a/arch/mips/dts/qemu-malta.dts
+++ b/arch/mips/dts/qemu-malta.dts
@@ -6,7 +6,40 @@
model = qemu malta;
compatible = qemu,malta;
 
+   chosen {
+   environment@0 {
+   compatible = barebox,environment;
+   device-path = nor0, partname:barebox-environment;
+   };
+   };
+
memory {
reg = 0x 0x1000;
};
+
+   uart0: serial@b3f8 {
+   compatible = ns16550a;
+   reg = 0xb3f8 0x08;
+   reg-shift = 0;
+   /* no matter for emulated port */
+   clock-frequency = 1843200;
+   };
+
+   nor0: flash@be00 {
+   #address-cells = 1;
+   #size-cells = 1;
+   compatible = cfi-flash;
+   reg = 0xbe00 0x0040;
+
+   partition@0 {
+   label = barebox;
+   reg = 0 0x8;
+   read-only;
+   };
+
+   partition@8 {
+   label = barebox-environment;
+   reg = 0x8 0x1;
+   };
+   };
 };
-- 
1.8.4.rc3


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


Re: [PATCH] MIPS: qemu-malta: switch to devicetree

2013-09-02 Thread Antony Pavlov
On Tue,  3 Sep 2013 08:33:33 +0400
Antony Pavlov antonynpav...@gmail.com wrote:

 Signed-off-by: Antony Pavlov antonynpav...@gmail.com
 ---
  arch/mips/boards/qemu-malta/init.c | 31 ++-
  arch/mips/configs/qemu-malta_defconfig |  1 +
  arch/mips/dts/qemu-malta.dts   | 33 +
  3 files changed, 36 insertions(+), 29 deletions(-)
 
 diff --git a/arch/mips/boards/qemu-malta/init.c 
 b/arch/mips/boards/qemu-malta/init.c
 index ddc90dc..4d12495 100644
 --- a/arch/mips/boards/qemu-malta/init.c
 +++ b/arch/mips/boards/qemu-malta/init.c
 @@ -17,39 +17,12 @@
   */
  
  #include common.h
 -#include types.h
 -#include driver.h
  #include init.h
 -#include ns16550.h
 -#include mach/hardware.h
 -#include partition.h
 -#include sizes.h
  
 -static int malta_devices_init(void)
 +static int malta_core_init(void)
  {
 - add_cfi_flash_device(0, 0x1e00, SZ_4M, 0);
 -
 - devfs_add_partition(nor0, 0x0, SZ_512K, DEVFS_PARTITION_FIXED, 
 self);
 - devfs_add_partition(nor0, SZ_512K, SZ_64K, DEVFS_PARTITION_FIXED, 
 env0);
 -
 - return 0;
 -}
 -device_initcall(malta_devices_init);
 -
 -static struct NS16550_plat serial_plat = {
 - .clock = 1843200, /* no matter for emulated port */
 - .shift = 0,
 -};
 -
 -static int malta_console_init(void)
 -{
 - barebox_set_model(qemu malta);
   barebox_set_hostname(malta);


May be it is reasonable to add hostname support to dts?

The lonely barebox_set_hostname() in the malta board code looks very 
pathetically :)

 - /* Register the serial port */
 - add_ns16550_device(DEVICE_ID_DYNAMIC, MALTA_PIIX4_UART0, 8,
 - IORESOURCE_MEM_8BIT, serial_plat);
 -
   return 0;
  }
 -console_initcall(malta_console_init);
 +core_initcall(malta_core_init);
 diff --git a/arch/mips/configs/qemu-malta_defconfig 
 b/arch/mips/configs/qemu-malta_defconfig
 index 18c840d..1b9ee9a 100644
 --- a/arch/mips/configs/qemu-malta_defconfig
 +++ b/arch/mips/configs/qemu-malta_defconfig
 @@ -54,6 +54,7 @@ CONFIG_NET_PING=y
  CONFIG_NET_NETCONSOLE=y
  CONFIG_NET_RESOLV=y
  CONFIG_OFDEVICE=y
 +CONFIG_OF_BAREBOX_DRIVERS=y
  # CONFIG_SPI is not set
  CONFIG_MTD=y
  CONFIG_DRIVER_CFI=y
 diff --git a/arch/mips/dts/qemu-malta.dts b/arch/mips/dts/qemu-malta.dts
 index c4dcf05..4057729 100644
 --- a/arch/mips/dts/qemu-malta.dts
 +++ b/arch/mips/dts/qemu-malta.dts
 @@ -6,7 +6,40 @@
   model = qemu malta;
   compatible = qemu,malta;
  
 + chosen {
 + environment@0 {
 + compatible = barebox,environment;
 + device-path = nor0, partname:barebox-environment;
 + };
 + };
 +
   memory {
   reg = 0x 0x1000;
   };
 +
 + uart0: serial@b3f8 {
 + compatible = ns16550a;
 + reg = 0xb3f8 0x08;
 + reg-shift = 0;
 + /* no matter for emulated port */
 + clock-frequency = 1843200;
 + };
 +
 + nor0: flash@be00 {
 + #address-cells = 1;
 + #size-cells = 1;
 + compatible = cfi-flash;
 + reg = 0xbe00 0x0040;
 +
 + partition@0 {
 + label = barebox;
 + reg = 0 0x8;
 + read-only;
 + };
 +
 + partition@8 {
 + label = barebox-environment;
 + reg = 0x8 0x1;
 + };
 + };
  };
 -- 
 1.8.4.rc3
 


-- 
-- 
Best regards,
  Antony Pavlov

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