Re: [PATCH] ubi: add setting devnum to ubiattach

2014-09-01 Thread Sascha Hauer
On Thu, Aug 28, 2014 at 03:27:11PM +0400, Antony Pavlov wrote:
   BAREBOX_CMD_START(ubiattach)
  .cmd= do_ubiattach,
  BAREBOX_CMD_DESC(attach mtd device to UBI)
  -   BAREBOX_CMD_OPTS([-O] MTDDEV)
  +   BAREBOX_CMD_OPTS([-dO] MTDDEV)
 
 Can we use a more accurate variant? Something like this one:

BAREBOX_CMD_OPTS for other commands look like Michael did it. The full
option semantics is still in the full help text.

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: [BUG] readline history

2014-09-01 Thread Sascha Hauer
Hi Teresa,

On Thu, Aug 28, 2014 at 09:50:05AM +0200, Teresa Gamez wrote:
 Hello Sascha,
 
 I noticed a bug on the latest master.
 When no history is present and I hit the arrow up key, I get:
 
 unable to handle NULL pointer dereference at address 0x0001
 pc : [9fe243ba]lr : [9fe268cf]
 sp : 99d0  ip : 0016  fp : 0002
 r10: 0001  r9 : 9fe549dc  r8 : 9fe65d08
 r7 : 0400  r6 : 0001  r5 :   r4 : 9fe66258
 r3 :   r2 :   r1 : 0001  r0 : 9fe66258
 Flags: nZCv  IRQs off  FIQs on  Mode SVC_32
 [9fe243ba] (strcpy+0xa/0xe) from [9fe268cf] (readline+0x363/0x4e0)
 [9fe268cf] (readline+0x363/0x4e0) from [9fe05469] (file_get
 +0x49/0x110)
 
 I could bisect it to this commit:
 
 
 ada160a34a1ec8421d5bb7b9dd746294668a5130 is the first bad commit
 commit ada160a34a1ec8421d5bb7b9dd746294668a5130
 Author: Sascha Hauer s.ha...@pengutronix.de
 Date:   Tue Jul 29 11:54:26 2014 +0200

Damned. While working on that patch I had exactly this problem and
thought I tested this case. Apparantly I didn't :(

The following should fix this:

Sascha

From 7fd0d972f71610c25276ca387164b1fd71fb74be Mon Sep 17 00:00:00 2001
From: Sascha Hauer s.ha...@pengutronix.de
Date: Mon, 1 Sep 2014 10:21:44 +0200
Subject: [PATCH] readline: Fix history prev when history is empty

We cannot use list_entry() on an empty list. Without history
we have to return an empty line. This fixes a crash when the
cursor up button is pressed and no command has been entered
previously. Broken since:

commit ada160a34a1ec8421d5bb7b9dd746294668a5130
Author: Sascha Hauer s.ha...@pengutronix.de
Date:   Tue Jul 29 11:54:26 2014 +0200

readline: reimplement history functions

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
Reported-by: Teresa Gamez t.ga...@phytec.de
---
 lib/readline.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/readline.c b/lib/readline.c
index b70bca8..e855abd 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -68,6 +68,9 @@ static const char *hist_prev(void)
struct history *history;
 
if (history_current-prev == history_list) {
+   if (list_empty(history_list))
+   return ;
+
history = list_entry(history_current, struct history, list);
getcmd_cbeep();
return history-line;
-- 
2.1.0

-- 
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: [BUG] readline history

2014-09-01 Thread Alexander Aring
Hi Sascha,

On Mon, Sep 01, 2014 at 10:30:33AM +0200, Sascha Hauer wrote:
 Hi Teresa,
 
 On Thu, Aug 28, 2014 at 09:50:05AM +0200, Teresa Gamez wrote:
  Hello Sascha,
  
  I noticed a bug on the latest master.
  When no history is present and I hit the arrow up key, I get:
  
  unable to handle NULL pointer dereference at address 0x0001
  pc : [9fe243ba]lr : [9fe268cf]
  sp : 99d0  ip : 0016  fp : 0002
  r10: 0001  r9 : 9fe549dc  r8 : 9fe65d08
  r7 : 0400  r6 : 0001  r5 :   r4 : 9fe66258
  r3 :   r2 :   r1 : 0001  r0 : 9fe66258
  Flags: nZCv  IRQs off  FIQs on  Mode SVC_32
  [9fe243ba] (strcpy+0xa/0xe) from [9fe268cf] (readline+0x363/0x4e0)
  [9fe268cf] (readline+0x363/0x4e0) from [9fe05469] (file_get
  +0x49/0x110)
  
  I could bisect it to this commit:
  
  
  ada160a34a1ec8421d5bb7b9dd746294668a5130 is the first bad commit
  commit ada160a34a1ec8421d5bb7b9dd746294668a5130
  Author: Sascha Hauer s.ha...@pengutronix.de
  Date:   Tue Jul 29 11:54:26 2014 +0200
 
 Damned. While working on that patch I had exactly this problem and
 thought I tested this case. Apparantly I didn't :(
 
 The following should fix this:
 
 Sascha
 
 From 7fd0d972f71610c25276ca387164b1fd71fb74be Mon Sep 17 00:00:00 2001
 From: Sascha Hauer s.ha...@pengutronix.de
 Date: Mon, 1 Sep 2014 10:21:44 +0200
 Subject: [PATCH] readline: Fix history prev when history is empty
 
 We cannot use list_entry() on an empty list. Without history
 we have to return an empty line. This fixes a crash when the
 cursor up button is pressed and no command has been entered
 previously. Broken since:
 
 commit ada160a34a1ec8421d5bb7b9dd746294668a5130
 Author: Sascha Hauer s.ha...@pengutronix.de
 Date:   Tue Jul 29 11:54:26 2014 +0200
 
 readline: reimplement history functions
 
 Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
 Reported-by: Teresa Gamez t.ga...@phytec.de
 ---
  lib/readline.c | 3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/lib/readline.c b/lib/readline.c
 index b70bca8..e855abd 100644
 --- a/lib/readline.c
 +++ b/lib/readline.c
 @@ -68,6 +68,9 @@ static const char *hist_prev(void)
   struct history *history;
  
   if (history_current-prev == history_list) {
 + if (list_empty(history_list))
 + return ;
 +

what's about to ring the terminal bell when this happen?

- Alex

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


Re: [PATCH] ubiformat: Include missing header

2014-09-01 Thread Sascha Hauer
On Sat, Aug 23, 2014 at 04:23:48PM -0300, Ezequiel Garcia wrote:
 Currently this warning is found when compiling ubiformat.c
 
   CC  commands/ubiformat.o
 commands/ubiformat.c: In function 'flash_image':
 commands/ubiformat.c:368:3: warning: implicit declaration of function 
 'read_full' [-Wimplicit-function-declaration]
err = read_full(fd, buf, mtd-eb_size);
^
 because ubiformat.c needs libfile.h for the read_full() function.
 This commit adds the missing header.
 
 Signed-off-by: Ezequiel Garcia ezequiel.gar...@free-electrons.com

Should be fixed in master already.

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 0/3] misc .gitignore-related fixes

2014-09-01 Thread Sascha Hauer
On Wed, Aug 06, 2014 at 09:44:03AM +0400, Antony Pavlov wrote:
 Antony Pavlov (3):
   openrisc: add barebox.lds to .gitignore
   scripts: add bareboximd{,-target} to .gitignore
   fixup! dtc: compile fdtget

Applied, thanks

Sascha

 
  arch/openrisc/cpu/.gitignore | 1 +
  scripts/.gitignore   | 2 ++
  scripts/dtc/.gitignore   | 1 +
  3 files changed, 4 insertions(+)
  create mode 100644 arch/openrisc/cpu/.gitignore
 
 -- 
 2.0.1
 
 
 ___
 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/2] nand: Add Marvell Orion NAND driver

2014-09-01 Thread Sascha Hauer
On Tue, Aug 26, 2014 at 04:28:13PM +0200, Alexander Aring wrote:
 Hi,
 
 On Sat, Aug 23, 2014 at 05:19:22PM -0300, Ezequiel Garcia wrote:
  This commit adds NAND support for the controller present in Kirkwood SoCs.
  
 
 cool! I will test it on my DNS-325 platform, if I find some free time.
 
 Thanks for doing this.
 
  Signed-off-by: Ezequiel Garcia ezequiel.gar...@free-electrons.com
  ---
   drivers/mtd/nand/Kconfig  |   7 ++
   drivers/mtd/nand/Makefile |   1 +
   drivers/mtd/nand/nand_orion.c | 162 
  ++
   3 files changed, 170 insertions(+)
   create mode 100644 drivers/mtd/nand/nand_orion.c
  
  diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
  index 04fe3c8..ccf1f9c 100644
  --- a/drivers/mtd/nand/Kconfig
  +++ b/drivers/mtd/nand/Kconfig
  @@ -90,6 +90,13 @@ config NAND_OMAP_GPMC
Support for NAND flash using GPMC. GPMC is a common memory
interface found on Texas Instrument's OMAP platforms
   
  +config NAND_ORION
  +   bool
  +   prompt Orion NAND driver
  +   depends on ARCH_MVEBU
  +   help
  + Support for the Orion NAND controller, present in Kirkwood SoCs.
  +
   config NAND_ATMEL
  bool
  prompt Atmel (AT91SAM9xxx) NAND driver
 ...
  +
  +static int orion_nand_probe(struct device_d *dev)
  +{
  +   struct device_node *dev_node = dev-device_node;
  +   struct orion_nand *priv;
  +   struct mtd_info *mtd;
  +   struct nand_chip *chip;
  +   struct clk *clk;
  +   void __iomem *io_base;
  +   int width, ret;
  +   u32 val = 0;
  +
  +   priv = xzalloc(sizeof(struct orion_nand));
  +   if (!priv) {
  +   ret = -ENOMEM;
  +   goto no_res;
  +   }
 
 checking on null with xzalloc isn't needed, if fails we run into panic.

removed the check while applying.

 
  +   mtd = priv-mtd;
  +   chip = priv-chip;
  +
  +   io_base = dev_request_mem_region(dev, 0);
  +
 
 here we should check the return value. I don't know what's now the
 behaviour on dev_request_mem_region if fail returns NULL or ERR_PTR.
 There was some discussion on the list.

It still returns NULL. I have a series converting it to return ERR_PTR,
but this isn't mainlined yet. I'll have to rebase it on current master.

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] scripts: gitignore: update based on Makefile

2014-09-01 Thread Sascha Hauer
On Fri, Aug 15, 2014 at 02:11:32AM +0200, Andreas Pretzsch wrote:
 Create up-to-date list of hostprogs and targetprogs based on Makefile.
 Have this list sorted like the targets in the Makefile to ease maintenance.
 Also move some leftovers from root .gitignore over here.
 
 Signed-off-by: Andreas Pretzsch a...@cn-eng.de

Applied, thanks.

Sascha

 ---
 patch relative to master as of 07.08.2014 (45615e3)
 
  .gitignore |  3 ---
  scripts/.gitignore | 20 
  2 files changed, 12 insertions(+), 11 deletions(-)
 
 diff --git a/.gitignore b/.gitignore
 index a62e08c..5d9157d 100644
 --- a/.gitignore
 +++ b/.gitignore
 @@ -83,6 +83,3 @@ cscope.*
  
  # patches
  *.patch
 -scripts/gen_netx_image
 -scripts/s5p_cksum
 -scripts/bareboxenv-target
 diff --git a/scripts/.gitignore b/scripts/.gitignore
 index fddc04b..1df04ba 100644
 --- a/scripts/.gitignore
 +++ b/scripts/.gitignore
 @@ -1,17 +1,21 @@
 -bareboxenv
  bin2c
 +mkimage
  fix_size
 -gen_netx_image
 -kallsyms
 +bareboxenv
 +bareboxcrc32
  kernel-install
 -kernel-install-target
 +bareboximd
 +kallsyms
  kwbimage
  kwboot
 -mk-am35xx-spi-image
 -mkimage
 -mkublheader
 +gen_netx_image
  omap_signGP
 +mk-am3xxx-spi-image
 +s5p_cksum
 +mkublheader
  zynq_mkimage
  socfpga_mkimage
 -bareboxcrc32
 +bareboxenv-target
 +kernel-install-target
  bareboxcrc32-target
 +bareboximd-target
 -- 
 2.0.1
 
 
 ___
 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


[RFC] MTD m25p80 3-byte addressing and boot problem

2014-09-01 Thread Matteo Fortini
If a Linux/Barebox system is using an SPI flash of size = 16 MB, the 
driver is switching to 3-byte addressing to be able to use linear access 
to the whole memory.


This leads to the impossibility to boot a board after a warm reset, 
because all bootloaders use the standard 2-byte addressing (if the board 
doesn't physically reset the flash or do something similar).


Some documentation in the following links:
http://www.at91.com/discussions/viewtopic.php/f,30/t,22849.html
https://community.freescale.com/docs/DOC-93632

The solution proposed on freescale forums is not final: it involves 
switching back to 2-byte addressing after every access, which still 
leaves a small window in which a warm reset would be fatal.


One solution would be to use the bank command in the flash, using each 
16MB bank linearly, and changing bank depending on the address. This 
would be messy for accesses which are crossing the boundary, but it is 
doable.


I'm asking here for comments before I start patching the code. Right now 
I resorted to stick to 2-byte addressing and leave half of my NOR (32MB) 
unused.


TIA,
M

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


Re: [PATCH 1/5] mtd: nand: remove NAND_ATMEL_PMECC

2014-09-01 Thread Sascha Hauer
On Wed, Aug 06, 2014 at 09:21:52AM +0200, Raphaël Poggi wrote:
 Ok, I did it because we need a structure member to retrieve
 atmel,has-pmecc from device tree.
 
 Is this ok if I add the has_pmecc member (feed by atmel_nand_of_init),
 let the NAND_ATMEL_PMECC, and the if will be like :
 
 if (IS_ENABLED(CONFIG_NAND_ATMEL_PMECC) || pdata-has_pmecc)

Shouldn't this be  instead of ||?

Otherwise this approach should be fine.

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 4/5] board: atmel: initialise ecc_mode

2014-09-01 Thread Sascha Hauer
On Tue, Aug 05, 2014 at 11:14:48AM +0200, Raphaël Poggi wrote:
 This commit initialise the ecc_mode (NAND_ECC_SOFT) on atmel board init which 
 missing it.
 
 Signed-off-by: Raphaël Poggi poggi.r...@gmail.com
 ---
  arch/arm/boards/at91sam9260ek/init.c|1 +
  arch/arm/boards/at91sam9261ek/init.c|1 +
  arch/arm/boards/at91sam9263ek/init.c|1 +
  arch/arm/boards/at91sam9m10g45ek/init.c |1 +
  arch/arm/boards/at91sam9m10ihd/init.c   |1 +
  5 files changed, 5 insertions(+)
 
 diff --git a/arch/arm/boards/at91sam9260ek/init.c 
 b/arch/arm/boards/at91sam9260ek/init.c
 index 1298dde..76e0195 100644
 --- a/arch/arm/boards/at91sam9260ek/init.c
 +++ b/arch/arm/boards/at91sam9260ek/init.c
 @@ -51,6 +51,7 @@ static struct atmel_nand_data nand_pdata = {
   .det_pin= -EINVAL,
   .rdy_pin= AT91_PIN_PC13,
   .enable_pin = AT91_PIN_PC14,
 + .ecc_mode   = NAND_ECC_SOFT,

You have to combine 3/5 and 4/5 in a single patch. Otherwise the ecc
mode is not initialized correctly between both patches.

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 2/2] EFI: handle more boot devices

2014-09-01 Thread Michael Olbrich
On Mon, Sep 01, 2014 at 11:06:19AM +0200, Sascha Hauer wrote:
 On Tue, Aug 12, 2014 at 11:37:21AM +0200, Michael Olbrich wrote:
  efi_get_boot() fails for partitions that are not supported, so errors must
  be ignored to find all supported devices.
  
  Signed-off-by: Michael Olbrich m.olbr...@pengutronix.de
  ---
  
  I'm not sure about this one. We're not doing anythings with the return
  value of efi_get_boot(), so this is just some debug output + memory leak.
 
 So maybe we should rather comment out the code until we do something
 meaningful with it?

I don't care either way. What's this stuff for anyways?

Michael

-- 
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 v2 1/2] pinctrl: at91: add pinctrl driver

2014-09-01 Thread Sascha Hauer
On Tue, Aug 05, 2014 at 01:09:16PM -0700, Raphaël Poggi wrote:
 diff --git a/drivers/pinctrl/pinctrl-at91.h b/drivers/pinctrl/pinctrl-at91.h
 new file mode 100644
 index 000..e719fb8
 --- /dev/null
 +++ b/drivers/pinctrl/pinctrl-at91.h
 @@ -0,0 +1,148 @@
 +/*
 + * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD 
 plagn...@jcrosoft.com
 + *
 + * Under GPLv2 only
 + */
 +
 +#ifndef __AT91_GPIO_H__
 +#define __AT91_GPIO_H__
 +
 +#ifndef __gpio_init
 +#define __gpio_init
 +#endif
 +
 +#define MAX_NB_GPIO_PER_BANK 32
 +
 +static inline unsigned pin_to_bank(unsigned pin)
 +{
 + return pin / MAX_NB_GPIO_PER_BANK;
 +}
 +
 +static inline unsigned pin_to_bank_offset(unsigned pin)
 +{
 + return pin % MAX_NB_GPIO_PER_BANK;
 +}
 +
 +static inline unsigned pin_to_mask(unsigned pin)
 +{
 + return 1  pin_to_bank_offset(pin);
 +}
 +
 +static inline void at91_mux_disable_interrupt(void __iomem *pio, unsigned 
 mask)
 +{
 + __raw_writel(mask, pio + PIO_IDR);
 +}
 +
 +static inline void at91_mux_set_pullup(void __iomem *pio, unsigned mask, 
 bool on)
 +{
 + __raw_writel(mask, pio + (on ? PIO_PUER : PIO_PUDR));
 +}
 +
 +static inline void at91_mux_set_multidrive(void __iomem *pio, unsigned mask, 
 bool on)
 +{
 + __raw_writel(mask, pio + (on ? PIO_MDER : PIO_MDDR));
 +}
 +
 +static inline void at91_mux_set_A_periph(void __iomem *pio, unsigned mask)
 +{
 + __raw_writel(mask, pio + PIO_ASR);
 +}
 +
 +static inline void at91_mux_set_B_periph(void __iomem *pio, unsigned mask)
 +{
 + __raw_writel(mask, pio + PIO_BSR);
 +}
 +
 +static inline void at91_mux_pio3_set_A_periph(void __iomem *pio, unsigned 
 mask)
 +{
 +
 + __raw_writel(__raw_readl(pio + PIO_ABCDSR1)  ~mask,
 + pio + PIO_ABCDSR1);
 + __raw_writel(__raw_readl(pio + PIO_ABCDSR2)  ~mask,
 + pio + PIO_ABCDSR2);
 +}
 +
 +static inline void at91_mux_pio3_set_B_periph(void __iomem *pio, unsigned 
 mask)
 +{
 + __raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask,
 + pio + PIO_ABCDSR1);
 + __raw_writel(__raw_readl(pio + PIO_ABCDSR2)  ~mask,
 + pio + PIO_ABCDSR2);
 +}
 +
 +static inline void at91_mux_pio3_set_C_periph(void __iomem *pio, unsigned 
 mask)
 +{
 + __raw_writel(__raw_readl(pio + PIO_ABCDSR1)  ~mask, pio + PIO_ABCDSR1);
 + __raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2);
 +}
 +
 +static inline void at91_mux_pio3_set_D_periph(void __iomem *pio, unsigned 
 mask)
 +{
 + __raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask, pio + PIO_ABCDSR1);
 + __raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2);
 +}
 +
 +static inline void at91_mux_set_deglitch(void __iomem *pio, unsigned mask, 
 bool is_on)
 +{
 + __raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR));
 +}
 +
 +static inline void at91_mux_pio3_set_deglitch(void __iomem *pio, unsigned 
 mask, bool is_on)
 +{
 + if (is_on)
 + __raw_writel(mask, pio + PIO_IFSCDR);
 + at91_mux_set_deglitch(pio, mask, is_on);
 +}
 +
 +static inline void at91_mux_pio3_set_debounce(void __iomem *pio, unsigned 
 mask,
 + bool is_on, u32 div)
 +{
 + if (is_on) {
 + __raw_writel(mask, pio + PIO_IFSCER);
 + __raw_writel(div  PIO_SCDR_DIV, pio + PIO_SCDR);
 + __raw_writel(mask, pio + PIO_IFER);
 + } else {
 + __raw_writel(mask, pio + PIO_IFDR);
 + }
 +}
 +
 +static inline void at91_mux_pio3_set_pulldown(void __iomem *pio, unsigned 
 mask, bool is_on)
 +{
 + __raw_writel(mask, pio + (is_on ? PIO_PPDER : PIO_PPDDR));
 +}
 +
 +static inline void at91_mux_pio3_disable_schmitt_trig(void __iomem *pio, 
 unsigned mask)
 +{
 + __raw_writel(__raw_readl(pio + PIO_SCHMITT) | mask, pio + PIO_SCHMITT);
 +}
 +
 +static inline void at91_mux_gpio_disable(void __iomem *pio, unsigned mask)
 +{
 + __raw_writel(mask, pio + PIO_PDR);
 +}
 +
 +static inline void at91_mux_gpio_enable(void __iomem *pio, unsigned mask)
 +{
 + __raw_writel(mask, pio + PIO_PER);
 +}
 +
 +static inline void at91_mux_gpio_input(void __iomem *pio, unsigned mask, 
 bool input)
 +{
 + __raw_writel(mask, pio + (input ? PIO_ODR : PIO_OER));
 +}
 +
 +static inline void at91_mux_gpio_set(void __iomem *pio, unsigned mask,
 +int value)
 +{
 + __raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR));
 +}
 +
 +static inline int at91_mux_gpio_get(void __iomem *pio, unsigned mask)
 +{
 +   u32 pdsr;
 +
 +   pdsr = __raw_readl(pio + PIO_PDSR);
 +   return (pdsr  mask) != 0;
 +}

We already have all these functions in arch/arm/mach-at91/gpio.h. Do we
really need them twice? Can't we use a single header file?

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner 

Re: [PATCH 2/2] EFI: handle more boot devices

2014-09-01 Thread Sascha Hauer
On Mon, Sep 01, 2014 at 12:02:00PM +0200, Michael Olbrich wrote:
 On Mon, Sep 01, 2014 at 11:06:19AM +0200, Sascha Hauer wrote:
  On Tue, Aug 12, 2014 at 11:37:21AM +0200, Michael Olbrich wrote:
   efi_get_boot() fails for partitions that are not supported, so errors must
   be ignored to find all supported devices.
   
   Signed-off-by: Michael Olbrich m.olbr...@pengutronix.de
   ---
   
   I'm not sure about this one. We're not doing anythings with the return
   value of efi_get_boot(), so this is just some debug output + memory leak.
  
  So maybe we should rather comment out the code until we do something
  meaningful with it?
 
 I don't care either way. What's this stuff for anyways?

These variables contain the boot order. I added this stuff to verify
that I can read EFI variables.

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 v3 2/3] at91sam9g45: clock: add i2c clocks

2014-09-01 Thread Sascha Hauer
On Wed, Aug 06, 2014 at 12:17:48PM +0200, Raphaël Poggi wrote:
 Add the device tree and non device tree at91 i2c clocks.
 
 Signed-off-by: Raphaël Poggi poggi.r...@gmail.com
 ---
  arch/arm/mach-at91/at91sam9g45.c |4 
  1 file changed, 4 insertions(+)
 
 diff --git a/arch/arm/mach-at91/at91sam9g45.c 
 b/arch/arm/mach-at91/at91sam9g45.c
 index 9a50deb..d19d26a 100644
 --- a/arch/arm/mach-at91/at91sam9g45.c
 +++ b/arch/arm/mach-at91/at91sam9g45.c
 @@ -192,6 +192,10 @@ static struct clk_lookup periph_clocks_lookups[] = {
   CLKDEV_CON_DEV_ID(mci_clk, atmel_mci1, mmc1_clk),
   CLKDEV_CON_DEV_ID(spi_clk, atmel_spi0, spi0_clk),
   CLKDEV_CON_DEV_ID(spi_clk, atmel_spi1, spi1_clk),
 + CLKDEV_DEV_ID(at91sam9g10-i2c0, twi0_clk),
 + CLKDEV_DEV_ID(at91sam9g10-i2c1, twi1_clk),
 + CLKDEV_DEV_ID(fff84000.i2c, twi0_clk),
 + CLKDEV_DEV_ID(fff88000.i2c, twi1_clk),

Can you use clkdev_add_physbase()? This way you wouldn't have to
register separate clocks for the device tree and non device tree case.

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 v3] commands: of_dump switch to get fixed devictree

2014-09-01 Thread Sascha Hauer
On Thu, Aug 21, 2014 at 04:15:07PM +0400, Antony Pavlov wrote:
 On Thu, 21 Aug 2014 13:26:19 +0200
 Jan Weitzel j.weit...@phytec.de wrote:
 
  Add a switch to get the devicetree processed by the registered fixups.
  This is also whats the kernel gets.
  
   BAREBOX_CMD_START(of_dump)
  .cmd= do_of_dump,
  BAREBOX_CMD_DESC(dump devicetree nodes)
  -   BAREBOX_CMD_OPTS([-f] [NODE])
  +   BAREBOX_CMD_OPTS([-fF] [NODE])
 
 This is a bit confusing. The '-f' option has one argument,
 but '-F' option has noone.
 
 IMHO this solution is more accurate:
 
 + BAREBOX_CMD_OPTS([-F] [-f NODE])

Indeed it's more accurate, but the way Jan did it is in line with the
other commands.

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 v3] commands: of_dump switch to get fixed devictree

2014-09-01 Thread Sascha Hauer
On Thu, Aug 21, 2014 at 01:26:19PM +0200, Jan Weitzel wrote:
 Add a switch to get the devicetree processed by the registered fixups.
 This is also whats the kernel gets.
 
 Signed-off-by: Jan Weitzel j.weit...@phytec.de
 ---
 v3: create a copy of the internal devicetree before use of_fix_tree
 
  commands/of_dump.c |   31 +--
  1 files changed, 29 insertions(+), 2 deletions(-)
 
 diff --git a/commands/of_dump.c b/commands/of_dump.c
 index cafde07..f82f0fd 100644
 --- a/commands/of_dump.c
 +++ b/commands/of_dump.c
 @@ -34,16 +34,20 @@ static int do_of_dump(int argc, char *argv[])
  {
   int opt;
   int ret;
 + int fix = 0;
   struct device_node *root = NULL, *node, *of_free = NULL;
   char *dtbfile = NULL;
   size_t size;
   const char *nodename;
  
 - while ((opt = getopt(argc, argv, f:))  0) {
 + while ((opt = getopt(argc, argv, Ff:))  0) {
   switch (opt) {
   case 'f':
   dtbfile = optarg;
   break;
 + case 'F':
 + fix = 1;
 + break;
   default:
   return COMMAND_ERROR_USAGE;
   }
 @@ -75,6 +79,28 @@ static int do_of_dump(int argc, char *argv[])
   of_free = root;
   } else {
   root = of_get_root_node();
 +
 + if (fix) {
 + /* create a copy of internal devicetree */
 + void *fdt;
 + fdt = of_flatten_dtb(root);
 + root = of_unflatten_dtb(fdt);

That's really a creative way to make a copy of the device tree ;)

Ok, I'll close both eyes while applying it.

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] commands: saveenv: Fix comment about directories in help text

2014-09-01 Thread Sascha Hauer
On Fri, Aug 01, 2014 at 08:45:04AM +0200, Alexander Aring wrote:
 Hi Sascha,
 
 On Fri, Aug 01, 2014 at 08:17:10AM +0200, Sascha Hauer wrote:
  envfs indeed handles directories, at least since 2007:
  
  | commit 913691eccd13c1509470eb8b059aa0beecc6d8d8
  | Author: Sascha Hauer s.ha...@pengutronix.de
  | Date:   Tue Sep 25 12:58:52 2007 +0200
  |
  | add directory handling for environment
  
  Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
  ---
   commands/saveenv.c | 3 +--
   1 file changed, 1 insertion(+), 2 deletions(-)
  
  diff --git a/commands/saveenv.c b/commands/saveenv.c
  index 31d6951..9da733e 100644
  --- a/commands/saveenv.c
  +++ b/commands/saveenv.c
  @@ -60,8 +60,7 @@ BAREBOX_CMD_HELP_TEXT(Save the files in DIRECTORY to the 
  persistent storage dev
   BAREBOX_CMD_HELP_TEXT()
   BAREBOX_CMD_HELP_TEXT(ENVFS is usually a block in flash but can be any 
  other file. If)
   BAREBOX_CMD_HELP_TEXT(omitted, DIRECTORY defaults to /env and ENVFS 
  defaults to)
  -BAREBOX_CMD_HELP_TEXT(/dev/env0. Note that envfs can only handle files, 
  directories are being)
  -BAREBOX_CMD_HELP_TEXT(skipped silently.)
  +BAREBOX_CMD_HELP_TEXT(/dev/env0.)
 
 but envfs can't handle directories which are empty while saving? :-)
 Maybe we should add this as note or support empty directories.

I think we should add some more general docs how the environment works.
That would be a more appropriate place to add this note. Otherwise we
would have to add it to loadenv aswell.

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 0/2] Rockchip: adapt pinctrl driver to new dts

2014-09-01 Thread Sascha Hauer
On Thu, Jul 24, 2014 at 06:54:56PM +0200, Beniamino Galvani wrote:
 Hi,
 
 the dts for Rockchip rk3188 imported in commit 9313920df6d dts:
 update to v3.16-rc1 contains a change in the bindings for the pinctrl
 node, which now uses syscons to obtain the address of memory mapped
 registers.
 
 On barebox master branch the pinctrl driver fails during the probe
 with the new dts and thus some pin functions are not set properly; for
 this reason the ethernet port doesn't work at the moment on the Radxa
 Rock.
 
 The patches below fix the problem, adapting the driver to the new dts.
 
 Beniamino

Applied, thanks.

I missed this series in my inbox, otherwise the patches would have been
in the last release. Sorry for that.

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: [RFC] MTD m25p80 3-byte addressing and boot problem

2014-09-01 Thread Mark Marshall
Hi.

We had the same problem here, but luckily our Flash also supported a
different read command that took the larger address.  I made a (small)
modification to the m25p80 driver to use this command when the flash
supported it.

I've attached the two patches that come from my tree that are
relevant.  The first one (42)  just changes to the page size used to
access the flash, and is only needed so that you don;t get conflicts
wit the second.  The second patch (45) is the one of interest.  These
patches are against v3.2.52-rt73 from the real-time tree, and there
are (obviously) other patches either side of them, but they should
show what I have done.  At some point (!) I'll try to push these
up-stream, but as ou can see, we are well behind the curve at the
moment, which makes this harder.

Regards,

Mark Marshall.

PS.
On our original prototype hardware we had no reset line connected to
the flash, so even a hard reset wouldn't get things back to how they
should be when Linux was changing the bank register!  I think that the
longer commands should be used if the flash chip supports them in
preference to either bank switching or converting the small commands
to longer ones.


On 1 September 2014 11:43, Matteo Fortini matteo.fort...@gmail.com wrote:
 If a Linux/Barebox system is using an SPI flash of size = 16 MB, the driver
 is switching to 3-byte addressing to be able to use linear access to the
 whole memory.

 This leads to the impossibility to boot a board after a warm reset, because
 all bootloaders use the standard 2-byte addressing (if the board doesn't
 physically reset the flash or do something similar).

 Some documentation in the following links:
 http://www.at91.com/discussions/viewtopic.php/f,30/t,22849.html
 https://community.freescale.com/docs/DOC-93632

 The solution proposed on freescale forums is not final: it involves
 switching back to 2-byte addressing after every access, which still leaves a
 small window in which a warm reset would be fatal.

 One solution would be to use the bank command in the flash, using each 16MB
 bank linearly, and changing bank depending on the address. This would be
 messy for accesses which are crossing the boundary, but it is doable.

 I'm asking here for comments before I start patching the code. Right now I
 resorted to stick to 2-byte addressing and leave half of my NOR (32MB)
 unused.

 TIA,
 M

 __
 Linux MTD discussion mailing list
 http://lists.infradead.org/mailman/listinfo/linux-mtd/
From 9fe96f9fe893e4f8a42c37df5db1e29d5bab739e Mon Sep 17 00:00:00 2001
From: Mark Marshall mark.marsh...@omicron.at
Date: Thu, 25 Apr 2013 13:50:30 +0200
Subject: [PATCH 42/96] m25p80: Use a 512 byte page size for Spansion flash
 s25fl512s

The s25fl512s flash from Spnasion has a 512 byte write page size,
which means that we can write 512 bytes at a time (instead of 256).

This single change makes writing to the flash about 2x's faster.

Signed-off-by: Mark Marshall mark.marsh...@omicron.at
---
 drivers/mtd/devices/m25p80.c |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index b777697..3258179 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -637,6 +637,16 @@ struct flash_info {
 		.flags = (_flags),	\
 	})
 
+#define INFOP(_jedec_id, _ext_id, _sector_size, _n_sectors, _pg_sz, _flags) \
+	((kernel_ulong_t)(struct flash_info) {\
+		.jedec_id = (_jedec_id),\
+		.ext_id = (_ext_id),	\
+		.sector_size = (_sector_size),\
+		.n_sectors = (_n_sectors),\
+		.page_size = (_pg_sz),	\
+		.flags = (_flags),	\
+	})
+
 #define CAT25_INFO(_sector_size, _n_sectors, _page_size, _addr_width)	\
 	((kernel_ulong_t)(struct flash_info) {\
 		.sector_size = (_sector_size),\
@@ -698,7 +708,7 @@ static const struct spi_device_id m25p_ids[] = {
 	{ s25sl064a,  INFO(0x010216,  0,  64 * 1024, 128, 0) },
 	{ s25fl256s0, INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) },
 	{ s25fl256s1, INFO(0x010219, 0x4d01,  64 * 1024, 512, 0) },
-	{ s25fl512s,  INFO(0x010220, 0x4d00, 256 * 1024, 256, 0) },
+	{ s25fl512s, INFOP(0x010220, 0x4d00, 256 * 1024, 256, 512, 0) },
 	{ s70fl01gs,  INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) },
 	{ s25sl12800, INFO(0x012018, 0x0300, 256 * 1024,  64, 0) },
 	{ s25sl12801, INFO(0x012018, 0x0301,  64 * 1024, 256, 0) },
-- 
1.7.9.5

From 7c14b894f1884bf7915417ce8b747b11b6f603c6 Mon Sep 17 00:00:00 2001
From: Mark Marshall mark.marsh...@omicron.at
Date: Wed, 31 Jul 2013 15:26:12 +0200
Subject: [PATCH 45/96] m25p80: Use the 4-byte address read command

It is better for some hardware platforms if we use the dedicated
4-byte address SPI read command when reading from SPI Flash chips
 16 MB (rather than converting the 3-byte address command to take
4 address bytes).

The problem that we had is that on reset the boot loader tries to
use the 3-byte address command which, 

Re: [BUG] readline history

2014-09-01 Thread Sascha Hauer
On Mon, Sep 01, 2014 at 10:44:57AM +0200, Alexander Aring wrote:
 Hi Sascha,
 
 On Mon, Sep 01, 2014 at 10:30:33AM +0200, Sascha Hauer wrote:
  Hi Teresa,
  
  On Thu, Aug 28, 2014 at 09:50:05AM +0200, Teresa Gamez wrote:
   Hello Sascha,
   
   I noticed a bug on the latest master.
   When no history is present and I hit the arrow up key, I get:
   
   unable to handle NULL pointer dereference at address 0x0001
   pc : [9fe243ba]lr : [9fe268cf]
   sp : 99d0  ip : 0016  fp : 0002
   r10: 0001  r9 : 9fe549dc  r8 : 9fe65d08
   r7 : 0400  r6 : 0001  r5 :   r4 : 9fe66258
   r3 :   r2 :   r1 : 0001  r0 : 9fe66258
   Flags: nZCv  IRQs off  FIQs on  Mode SVC_32
   [9fe243ba] (strcpy+0xa/0xe) from [9fe268cf] (readline+0x363/0x4e0)
   [9fe268cf] (readline+0x363/0x4e0) from [9fe05469] (file_get
   +0x49/0x110)
   
   I could bisect it to this commit:
   
   
   ada160a34a1ec8421d5bb7b9dd746294668a5130 is the first bad commit
   commit ada160a34a1ec8421d5bb7b9dd746294668a5130
   Author: Sascha Hauer s.ha...@pengutronix.de
   Date:   Tue Jul 29 11:54:26 2014 +0200
  
  Damned. While working on that patch I had exactly this problem and
  thought I tested this case. Apparantly I didn't :(
  
  The following should fix this:
  
  Sascha
  
  From 7fd0d972f71610c25276ca387164b1fd71fb74be Mon Sep 17 00:00:00 2001
  From: Sascha Hauer s.ha...@pengutronix.de
  Date: Mon, 1 Sep 2014 10:21:44 +0200
  Subject: [PATCH] readline: Fix history prev when history is empty
  
  We cannot use list_entry() on an empty list. Without history
  we have to return an empty line. This fixes a crash when the
  cursor up button is pressed and no command has been entered
  previously. Broken since:
  
  commit ada160a34a1ec8421d5bb7b9dd746294668a5130
  Author: Sascha Hauer s.ha...@pengutronix.de
  Date:   Tue Jul 29 11:54:26 2014 +0200
  
  readline: reimplement history functions
  
  Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
  Reported-by: Teresa Gamez t.ga...@phytec.de
  ---
   lib/readline.c | 3 +++
   1 file changed, 3 insertions(+)
  
  diff --git a/lib/readline.c b/lib/readline.c
  index b70bca8..e855abd 100644
  --- a/lib/readline.c
  +++ b/lib/readline.c
  @@ -68,6 +68,9 @@ static const char *hist_prev(void)
  struct history *history;
   
  if (history_current-prev == history_list) {
  +   if (list_empty(history_list))
  +   return ;
  +
 
 what's about to ring the terminal bell when this happen?

I added a getcmd_cbeep() to add the beep.

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


[PATCH v3 3/3] mtd: atmel_nand: add support for device tree

2014-09-01 Thread Raphaël Poggi
Signed-off-by: Raphaël Poggi poggi.r...@gmail.com
---
 drivers/mtd/nand/atmel_nand.c |  111 -
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 2246602..910ecc3 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -28,6 +28,10 @@
 #include init.h
 #include gpio.h
 
+#include of.h
+#include of_gpio.h
+#include of_mtd.h
+
 #include linux/mtd/mtd.h
 #include linux/mtd/nand.h
 
@@ -1038,6 +1042,92 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int 
mode)
 #endif
 }
 
+static int atmel_nand_of_init(struct atmel_nand_host *host, struct device_node 
*np)
+{
+   u32 val;
+   u32 offset[2];
+   int ecc_mode;
+   struct atmel_nand_data *board = host-board;
+   enum of_gpio_flags flags = 0;
+
+   if (!IS_ENABLED(CONFIG_OFDEVICE))
+   return -ENOSYS;
+
+   if (of_property_read_u32(np, atmel,nand-addr-offset, val) == 0) {
+   if (val = 32) {
+   dev_err(host-dev, invalid addr-offset %u\n, val);
+   return -EINVAL;
+   }
+   board-ale = val;
+   }
+
+   if (of_property_read_u32(np, atmel,nand-cmd-offset, val) == 0) {
+   if (val = 32) {
+   dev_err(host-dev, invalid cmd-offset %u\n, val);
+   return -EINVAL;
+   }
+   board-cle = val;
+   }
+
+   ecc_mode = of_get_nand_ecc_mode(np);
+
+   board-ecc_mode = ecc_mode  0 ? NAND_ECC_SOFT : ecc_mode;
+
+   board-on_flash_bbt = of_get_nand_on_flash_bbt(np);
+
+   if (of_get_nand_bus_width(np) == 16)
+   board-bus_width_16 = 1;
+
+   board-rdy_pin = of_get_gpio_flags(np, 0, flags);
+   board-enable_pin = of_get_gpio(np, 1);
+   board-det_pin = of_get_gpio(np, 2);
+
+   board-has_pmecc = of_property_read_bool(np, atmel,has-pmecc);
+
+   if (!(board-ecc_mode == NAND_ECC_HW) || !board-has_pmecc)
+   return 0;   /* Not using PMECC */
+
+   /* use PMECC, get correction capability, sector size and lookup
+   * table offset.
+   * If correction bits and sector size are not specified, then
+   *   find
+   * them from NAND ONFI parameters.
+   */
+   if (of_property_read_u32(np, atmel,pmecc-cap, val) == 0) {
+   if ((val != 2)  (val != 4)  (val != 8)  (val != 12)  
(val != 24)) {
+   dev_err(host-dev, Unsupported PMECC correction 
capability: %d
+should be 2, 4, 8, 12 or 24\n, val);
+   return -EINVAL;
+   }
+
+   board-pmecc_corr_cap = (u8)val;
+   }
+
+   if (of_property_read_u32(np, atmel,pmecc-sector-size, val) == 0) {
+   if ((val != 512)  (val != 1024)) {
+   dev_err(host-dev, Unsupported PMECC sector 
size: %d
+should be 512 or 1024 bytes\n, val);
+   return -EINVAL;
+   }
+
+   board-pmecc_sector_size = (u16)val;
+   }
+
+   if (of_property_read_u32_array(np, atmel,pmecc-lookup-table-offset, 
offset, 2) != 0) {
+   dev_err(host-dev, Cannot get PMECC lookup table offset\n);
+   return -EINVAL;
+   }
+
+   if (!offset[0]  !offset[1]) {
+   dev_err(host-dev, Invalid PMECC lookup table offset\n);
+   return -EINVAL;
+   }
+
+   board-pmecc_lookup_table_offset = (board-pmecc_sector_size == 512) ? 
offset[0] : offset[1];
+
+   return 0;
+}
+
 static int atmel_hw_nand_init_params(struct device_d *dev,
 struct atmel_nand_host *host)
 {
@@ -1093,7 +1183,7 @@ static int atmel_hw_nand_init_params(struct device_d *dev,
  */
 static int __init atmel_nand_probe(struct device_d *dev)
 {
-   struct atmel_nand_data *pdata = dev-platform_data;
+   struct atmel_nand_data *pdata = NULL;
struct atmel_nand_host *host;
struct mtd_info *mtd;
struct nand_chip *nand_chip;
@@ -,6 +1201,18 @@ static int __init atmel_nand_probe(struct device_d *dev)
host-board = pdata;
host-dev = dev;
 
+   if (dev-device_node) {
+   res = atmel_nand_of_init(host, dev-device_node);
+   if (res)
+   goto err_no_card;
+   } else {
+   pdata = kzalloc(sizeof(struct atmel_nand_data), GFP_KERNEL);
+   if (!pdata)
+   return -ENOMEM;
+
+   memcpy(host-board, dev-platform_data, sizeof(struct 
atmel_nand_data));
+   }
+
nand_chip-priv = host; /* link the private data structures */
mtd-priv = nand_chip;
mtd-parent = dev;
@@ -1245,13 +1347,20 @@ err_hw_ecc:
 err_scan_ident:
 err_no_card:
atmel_nand_disable(host);
+   

[PATCH v3 0/3] Add device tree support of Atmel NAND driver

2014-09-01 Thread Raphaël Poggi
Change since v2:
* Combine in one patch the creation and initialisation of has_pmecc 
structure member
* Combine patch [PATCH 3/5] mtd: atmel_nand: retrieve ecc_mode from 
pdata 
and [PATCH 4/5] board: atmel: initialise ecc_mode
* Let NAND_ATMEL_PMECC config, but change the test in atmel_nand

Change since v1:
* Reorder patchs
* Fix some clean style issue.

This patchset adds the device tree support for the Atmel NAND driver.

The first patch add the has_pmecc structure member to be able to retrieve pmecc 
from device tree
and adds the has_pmecc on boards which need it.

The second patch retrieves the ecc_mode from the plateform data, and remove 
this code:

nand_chip-ecc.mode = NAND_ECC_SOFT;

which arbitrary sets the ecc.mode to NAND_ECC_SOFT and changes the value 
depending of the config and plateform data.
With this, we can use the same logics for device tree and non device tree 
probing of the driver. 
It also adds the ecc_mode on boards which are missing it (boards which use 
NAND_ECC_SOFT).

The third patch adds the device tree in the atmel_nand driver.

Raphaël Poggi (4):
(1) mtd: nand: add has_pmecc member
(2) mtd: atmel_nand: retrieve ecc_mode from pdata
(3) mtd: atmel_nand: add support for device tree

 arch/arm/boards/at91sam9260ek/init.c|1 +
 arch/arm/boards/at91sam9261ek/init.c|1 +
 arch/arm/boards/at91sam9263ek/init.c|1 +
 arch/arm/boards/at91sam9m10g45ek/init.c |1 +
 arch/arm/boards/at91sam9m10ihd/init.c   |1 +
 arch/arm/boards/at91sam9n12ek/init.c|1 +
 arch/arm/boards/at91sam9x5ek/init.c |1 +
 arch/arm/boards/sama5d3_xplained/init.c |1 +
 arch/arm/boards/sama5d3xek/init.c   |1 +
 arch/arm/mach-at91/include/mach/board.h |1 +
 drivers/mtd/nand/atmel_nand.c   |  115 ++-
 11 files changed, 122 insertions(+), 3 deletions(-)


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


[PATCH v3 2/3] mtd: atmel_nand: retrieve ecc_mode from pdata

2014-09-01 Thread Raphaël Poggi
By retrieving the ecc_mode from pdata we can use the same code for device tree 
and
non device tree probing. Which was not possible before, because ecc_mode was 
arbitrarily set to
NAND_ECC_SOFT.

Signed-off-by: Raphaël Poggi poggi.r...@gmail.com
---
 arch/arm/boards/at91sam9260ek/init.c|1 +
 arch/arm/boards/at91sam9261ek/init.c|1 +
 arch/arm/boards/at91sam9263ek/init.c|1 +
 arch/arm/boards/at91sam9m10g45ek/init.c |1 +
 arch/arm/boards/at91sam9m10ihd/init.c   |1 +
 drivers/mtd/nand/atmel_nand.c   |2 +-
 6 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/at91sam9260ek/init.c 
b/arch/arm/boards/at91sam9260ek/init.c
index 1298dde..76e0195 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -51,6 +51,7 @@ static struct atmel_nand_data nand_pdata = {
.det_pin= -EINVAL,
.rdy_pin= AT91_PIN_PC13,
.enable_pin = AT91_PIN_PC14,
+   .ecc_mode   = NAND_ECC_SOFT,
.on_flash_bbt   = 1,
 };
 
diff --git a/arch/arm/boards/at91sam9261ek/init.c 
b/arch/arm/boards/at91sam9261ek/init.c
index 9ebc16a..7b8ce98 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/init.c
@@ -46,6 +46,7 @@ static struct atmel_nand_data nand_pdata = {
.det_pin= -EINVAL,
.rdy_pin= AT91_PIN_PC15,
.enable_pin = AT91_PIN_PC14,
+   .ecc_mode   = NAND_ECC_SOFT,
 #if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
.bus_width_16   = 1,
 #else
diff --git a/arch/arm/boards/at91sam9263ek/init.c 
b/arch/arm/boards/at91sam9263ek/init.c
index 889b4c2..c8a9d5c 100644
--- a/arch/arm/boards/at91sam9263ek/init.c
+++ b/arch/arm/boards/at91sam9263ek/init.c
@@ -43,6 +43,7 @@ static struct atmel_nand_data nand_pdata = {
.det_pin= -EINVAL,
.rdy_pin= AT91_PIN_PA22,
.enable_pin = AT91_PIN_PD15,
+   .ecc_mode   = NAND_ECC_SOFT,
 #if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
.bus_width_16   = 1,
 #else
diff --git a/arch/arm/boards/at91sam9m10g45ek/init.c 
b/arch/arm/boards/at91sam9m10g45ek/init.c
index 6503ebb..cdd7806 100644
--- a/arch/arm/boards/at91sam9m10g45ek/init.c
+++ b/arch/arm/boards/at91sam9m10g45ek/init.c
@@ -67,6 +67,7 @@ static struct atmel_nand_data nand_pdata = {
.det_pin= -EINVAL,
.rdy_pin= AT91_PIN_PC8,
.enable_pin = AT91_PIN_PC14,
+   .ecc_mode   = NAND_ECC_SOFT,
 #if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
.bus_width_16   = 1,
 #else
diff --git a/arch/arm/boards/at91sam9m10ihd/init.c 
b/arch/arm/boards/at91sam9m10ihd/init.c
index fc37af4..a432e5c 100644
--- a/arch/arm/boards/at91sam9m10ihd/init.c
+++ b/arch/arm/boards/at91sam9m10ihd/init.c
@@ -44,6 +44,7 @@ static struct atmel_nand_data nand_pdata = {
.det_pin= -EINVAL,
.rdy_pin= AT91_PIN_PC15,
.enable_pin = AT91_PIN_PC14,
+   .ecc_mode   = NAND_ECC_SOFT,
.bus_width_16   = 0,
.on_flash_bbt   = 1,
 };
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 220ec5c..2246602 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1157,7 +1157,7 @@ static int __init atmel_nand_probe(struct device_d *dev)
}
}
 
-   nand_chip-ecc.mode = NAND_ECC_SOFT;
+   nand_chip-ecc.mode = pdata-ecc_mode;
 
if (IS_ENABLED(CONFIG_NAND_ECC_HW) 
pdata-ecc_mode == NAND_ECC_HW) {
-- 
1.7.9.5


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


Re: [PATCH v3] commands: of_dump switch to get fixed devictree

2014-09-01 Thread Jan Weitzel

Am 01.09.2014 um 12:38 schrieb Sascha Hauer:

On Thu, Aug 21, 2014 at 01:26:19PM +0200, Jan Weitzel wrote:

Add a switch to get the devicetree processed by the registered fixups.
This is also whats the kernel gets.

Signed-off-by: Jan Weitzel j.weit...@phytec.de
---
v3: create a copy of the internal devicetree before use of_fix_tree

  commands/of_dump.c |   31 +--
  1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/commands/of_dump.c b/commands/of_dump.c
index cafde07..f82f0fd 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -34,16 +34,20 @@ static int do_of_dump(int argc, char *argv[])
  {
int opt;
int ret;
+   int fix = 0;
struct device_node *root = NULL, *node, *of_free = NULL;
char *dtbfile = NULL;
size_t size;
const char *nodename;
  
-	while ((opt = getopt(argc, argv, f:))  0) {

+   while ((opt = getopt(argc, argv, Ff:))  0) {
switch (opt) {
case 'f':
dtbfile = optarg;
break;
+   case 'F':
+   fix = 1;
+   break;
default:
return COMMAND_ERROR_USAGE;
}
@@ -75,6 +79,28 @@ static int do_of_dump(int argc, char *argv[])
of_free = root;
} else {
root = of_get_root_node();
+
+   if (fix) {
+   /* create a copy of internal devicetree */
+   void *fdt;
+   fdt = of_flatten_dtb(root);
+   root = of_unflatten_dtb(fdt);

That's really a creative way to make a copy of the device tree ;)


And it use known good functions ;)

Jan



Ok, I'll close both eyes while applying it.

Sascha




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