Re: [u-boot][PATCH 10/14] mtd: rawnand: omap_gpmc: support u-boot driver model

2022-10-12 Thread Ladislav Michl
Hi Adam,

On Wed, Oct 12, 2022 at 06:42:22AM -0500, Adam Ford wrote:
[snip]
> On my board the GPMC runs more than just NAND.  I am hoping to get the
> GPMC driver working in U-Boot first then in SPL (assuming it fits).  I
> have LTO enabled on my DM3730, so I am hoping it might help make some
> room.  I am hoping that once the NAND is working that the GPMC driver
> can be used in U-Boot to handle the configuration of the bus for
> handling Ethernet, so some of the quirks and manual board file
> configuration can be removed.

Any estimate on that? I moved IGEP to use DM for ethernet, but for reasons
you mentioned quirk in DT is still there. Reposting that patch would
currently add one more quirk into codebase, so I'd better avoid that.

Thank you,
L.


Re: [PATCH 15/21] igep00x0: Disable networking

2022-09-28 Thread Ladislav Michl
On Tue, Aug 02, 2022 at 07:33:41AM -0400, Tom Rini wrote:
> This platform needs to be converted to use DM_ETH as the deadline is 2
> years passed due.  Disable networking support for now.

Oh well, my bad. There are too many patches accumulated.
Please see bellow for original version for reference (applied
after this one is reverted) Alternatively I can rebase on current
master, just let me know whichever way you prefer.

ladis

> Cc: Enric Balletbo i Serra 
> Signed-off-by: Tom Rini 
> ---
>  board/isee/igep00x0/igep00x0.c | 58 --
>  configs/igep00x0_defconfig |  5 +--
>  2 files changed, 1 insertion(+), 62 deletions(-)
> 
> diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
> index 0932f62b9beb..6c5e6fbbcb0d 100644
> --- a/board/isee/igep00x0/igep00x0.c
> +++ b/board/isee/igep00x0/igep00x0.c
> @@ -88,62 +88,6 @@ int onenand_board_init(struct mtd_info *mtd)
>   return 1;
>  }
>  
> -#if defined(CONFIG_CMD_NET)
> -static void reset_net_chip(int gpio)
> -{
> - if (!gpio_request(gpio, "eth nrst")) {
> - gpio_direction_output(gpio, 1);
> - udelay(1);
> - gpio_set_value(gpio, 0);
> - udelay(40);
> - gpio_set_value(gpio, 1);
> - mdelay(10);
> - }
> -}
> -
> -/*
> - * Routine: setup_net_chip
> - * Description: Setting up the configuration GPMC registers specific to the
> - *   Ethernet hardware.
> - */
> -static void setup_net_chip(void)
> -{
> - struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
> - static const u32 gpmc_lan_config[] = {
> - NET_LAN9221_GPMC_CONFIG1,
> - NET_LAN9221_GPMC_CONFIG2,
> - NET_LAN9221_GPMC_CONFIG3,
> - NET_LAN9221_GPMC_CONFIG4,
> - NET_LAN9221_GPMC_CONFIG5,
> - NET_LAN9221_GPMC_CONFIG6,
> - };
> -
> - enable_gpmc_cs_config(gpmc_lan_config, _cfg->cs[5],
> - CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
> -
> - /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
> - writew(readw(_base->gpmc_nwe) | 0x0E00, _base->gpmc_nwe);
> - /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
> - writew(readw(_base->gpmc_noe) | 0x0E00, _base->gpmc_noe);
> - /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
> - writew(readw(_base->gpmc_nadv_ale) | 0x0E00,
> - _base->gpmc_nadv_ale);
> -
> - reset_net_chip(64);
> -}
> -
> -int board_eth_init(struct bd_info *bis)
> -{
> -#ifdef CONFIG_SMC911X
> - return smc911x_initialize(0, CONFIG_SMC911X_BASE);
> -#else
> - return 0;
> -#endif
> -}
> -#else
> -static inline void setup_net_chip(void) {}
> -#endif
> -
>  #ifdef CONFIG_OF_BOARD_SETUP
>  static int ft_enable_by_compatible(void *blob, char *compat, int enable)
>  {
> @@ -234,8 +178,6 @@ int misc_init_r(void)
>OMAP34XX_CTRL_WKUP_CTRL_GPIO_IO_PWRDNZ,
>OMAP34XX_CTRL_WKUP_CTRL);
>  
> - setup_net_chip();
> -
>   omap_die_id_display();
>  
>   set_led();
> diff --git a/configs/igep00x0_defconfig b/configs/igep00x0_defconfig
> index 17c97ac27f79..25eda11dd45e 100644
> --- a/configs/igep00x0_defconfig
> +++ b/configs/igep00x0_defconfig
> @@ -67,7 +67,7 @@ CONFIG_ENV_UBI_VOLUME="config"
>  CONFIG_ENV_UBI_VOLUME_REDUND="config_r"
>  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>  CONFIG_VERSION_VARIABLE=y
> -CONFIG_NET_RANDOM_ETHADDR=y
> +# CONFIG_NET is not set
>  CONFIG_SYS_I2C_LEGACY=y
>  CONFIG_SPL_SYS_I2C_LEGACY=y
>  CONFIG_MMC_OMAP_HS=y
> @@ -81,9 +81,6 @@ CONFIG_SYS_NAND_PAGE_SIZE=0x800
>  CONFIG_SYS_NAND_OOBSIZE=0x40
>  CONFIG_SYS_NAND_BUSWIDTH_16BIT=y
>  CONFIG_MTD_UBI_FASTMAP=y
> -CONFIG_SMC911X=y
> -CONFIG_SMC911X_BASE=0x2C000000
> -CONFIG_SMC911X_32_BIT=y
>  CONFIG_CONS_INDEX=3
>  CONFIG_SPI=y
>  CONFIG_DM_SPI=y
> -- 
> 2.25.1

From: Ladislav Michl 
Date: Tue, 5 Apr 2022 15:47:45 +0200
Subject: [PATCH] ARM: igep00x0: convert to DM_ETH

The GPMC bus hasn't been converted, so omap3-igep0020-u-boot.dtsi needs
to provide the address of the ethernet controller.

Signed-off-by: Ladislav Michl 
---
 arch/arm/dts/omap3-igep0020-u-boot.dtsi | 12 
 board/isee/igep00x0/igep00x0.c  | 12 +---
 configs/igep00x0_defconfig  |  2 +-
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/arch/arm/dts/omap3-igep0020-u-boot.dtsi 
b/arch/arm/dts/omap3-igep0020-u-boot.dtsi
index 41beaf0900..d418b6a79f 100644
--- a/arch/arm/dts/omap3-igep0020-u-boot.dtsi
+++ b/arch

Re: [U-Boot] [PATCH 2/2] mtd: Get rid of board_mtdparts_default()

2018-12-12 Thread Ladislav Michl
Hello Boris,

On Wed, Dec 12, 2018 at 10:32:51AM +0100, Boris Brezillon wrote:
> Hi Ladislav,
> 
> On Tue, 11 Dec 2018 23:55:26 +0100
> Ladislav Michl  wrote:
> 
> > Hi Boris,
> > 
> > On Mon, Dec 10, 2018 at 04:38:50PM +0100, Boris Brezillon wrote:
> > > The only implementer of this function has been patched to use
> > > CONFIG_MTD{IDS,PARTS}_DEFAULT instead. Let's get rid of this function
> > > and the associated CONFIG_SYS_MTDPARTS_RUNTIME option.  
> > 
> > the only implementer of this fuction did so for a good reason. What is
> > a motivation to remove it?
> 
> Simplifying the code (see this discussion [1] which led me to send
> this patchset).

Thank you, makes sense.

> > The requirement is to be able to use single u-boot binary on all igep2
> > boards ever produced. These comes with various NAND and OneNAND chips
> > and  I was not able to come with single static partition configuration
> > to support them all.
> 
> That's actually the question I asked Enric in [1]. Can you list all
> the memory organization you have (for NAND and OneNAND chips)? I mean,
> the SPL part size depends on the NAND/OneNAND erase block size, and
> board vendors try to use similar flashes when they source different
> parts (same page size, same block size, ...). Assuming this is the
> case, you should always have the same layout for OneNAND/NAND devices,
> hence my proposal to define those parts statically.

First, thanks to Enric for pinging me, otherwise I would probably miss this
completely.

Now problem is that IGEPv2 comes with quite many configurations, some of
them are even customized, so static configuration is a show stopper
mainly as I do not know what devices are in field.
Another issue is how ubispl code works: It expects struct ubispl_info
filled with (among others) peb_offset of ubi partition. ubispl code counts
in terms of eraseblocks regardless of their size. So we would need to touch
this number when using static mtdparts.

> > Hence runtime detection. That code could be used
> > on all OMAP3 boards as BootROM reads up to first four sectors searching
> > for SPL (MLO).
> 
> Note that, for the nand side of things, you can also automate that using
> a u-boot script:
> 
> nand info; setexpr splsize ${nand_erasesize} * 4; setenv mtdparts 
> mtdparts=omap2-nand:0x${splsize}(SPL),-(UBI)

That seems as a way to go!

> Shouldn't be hard to patch the onenand cmd to also expose writesize,
> erasesize and oobsize.

Side note: I never fully understand why is OneNAND using separate set of
commands.

Could you hold merging your paches until I implement above idea and test
it on a few boards? I know u-boot is now using two months merge window,
which is unfortunate, so I'll try to do it as soon as possible, but I do
not think I'll finish it till end of week.

> Regards,
> 
> Boris
> 
> [1]https://www.mail-archive.com/u-boot@lists.denx.de/msg304933.html
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] mtd: Get rid of board_mtdparts_default()

2018-12-11 Thread Ladislav Michl
Hi Boris,

On Mon, Dec 10, 2018 at 04:38:50PM +0100, Boris Brezillon wrote:
> The only implementer of this function has been patched to use
> CONFIG_MTD{IDS,PARTS}_DEFAULT instead. Let's get rid of this function
> and the associated CONFIG_SYS_MTDPARTS_RUNTIME option.

the only implementer of this fuction did so for a good reason. What is
a motivation to remove it?

The requirement is to be able to use single u-boot binary on all igep2
boards ever produced. These comes with various NAND and OneNAND chips
and  I was not able to come with single static partition configuration
to support them all. Hence runtime detection. That code could be used
on all OMAP3 boards as BootROM reads up to first four sectors searching
for SPL (MLO).

Thank you,
ladis

> Signed-off-by: Boris Brezillon 
> ---
>  board/isee/igep00x0/igep00x0.c   | 17 -
>  cmd/mtdparts.c   |  6 --
>  drivers/mtd/mtd_uboot.c  | 10 ++
>  include/configs/omap3_igep00x0.h |  2 --
>  scripts/config_whitelist.txt |  1 -
>  5 files changed, 2 insertions(+), 34 deletions(-)
> 
> diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
> index 367af82d4a16..3552be6f3902 100644
> --- a/board/isee/igep00x0/igep00x0.c
> +++ b/board/isee/igep00x0/igep00x0.c
> @@ -239,20 +239,3 @@ int misc_init_r(void)
>  
>   return 0;
>  }
> -
> -void board_mtdparts_default(const char **mtdids, const char **mtdparts)
> -{
> - struct mtd_info *mtd = get_mtd_device(NULL, 0);
> - if (mtd) {
> - static char ids[24];
> - static char parts[48];
> - const char *linux_name = "omap2-nand";
> - if (strncmp(mtd->name, "onenand0", 8) == 0)
> - linux_name = "omap2-onenand";
> - snprintf(ids, sizeof(ids), "%s=%s", mtd->name, linux_name);
> - snprintf(parts, sizeof(parts), "mtdparts=%s:%dk(SPL),-(UBI)",
> -  linux_name, 4 * mtd->erasesize >> 10);
> - *mtdids = ids;
> - *mtdparts = parts;
> - }
> -}
> diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
> index f7ed1a077974..6b5644523898 100644
> --- a/cmd/mtdparts.c
> +++ b/cmd/mtdparts.c
> @@ -122,9 +122,6 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define MTDPARTS_DEFAULT NULL
>  #endif
>  #endif
> -#if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
> -extern void board_mtdparts_default(const char **mtdids, const char 
> **mtdparts);
> -#endif
>  static const char *mtdids_default = MTDIDS_DEFAULT;
>  static const char *mtdparts_default = MTDPARTS_DEFAULT;
>  
> @@ -1733,9 +1730,6 @@ int mtdparts_init(void)
>   memset(last_ids, 0, sizeof(last_ids));
>   memset(last_parts, 0, sizeof(last_parts));
>   memset(last_partition, 0, sizeof(last_partition));
> -#if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
> - board_mtdparts_default(_default, _default);
> -#endif
>   use_defaults = 1;
>   initialized = 1;
>   }
> diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c
> index d638f700d041..ed619abac390 100644
> --- a/drivers/mtd/mtd_uboot.c
> +++ b/drivers/mtd/mtd_uboot.c
> @@ -13,8 +13,6 @@
>  
>  #define MTD_NAME_MAX_LEN 20
>  
> -void board_mtdparts_default(const char **mtdids, const char **mtdparts);
> -
>  static const char *get_mtdids(void)
>  {
>   __maybe_unused const char *mtdparts = NULL;
> @@ -23,9 +21,7 @@ static const char *get_mtdids(void)
>   if (mtdids)
>   return mtdids;
>  
> -#if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
> - board_mtdparts_default(, );
> -#elif defined(MTDIDS_DEFAULT)
> +#if defined(MTDIDS_DEFAULT)
>   mtdids = MTDIDS_DEFAULT;
>  #elif defined(CONFIG_MTDIDS_DEFAULT)
>   mtdids = CONFIG_MTDIDS_DEFAULT;
> @@ -133,9 +129,7 @@ static const char *get_mtdparts(void)
>   if (mtdparts || !use_defaults)
>   return mtdparts;
>  
> -#if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
> - board_mtdparts_default(, );
> -#elif defined(MTDPARTS_DEFAULT)
> +#if defined(MTDPARTS_DEFAULT)
>   mtdparts = MTDPARTS_DEFAULT;
>  #elif defined(CONFIG_MTDPARTS_DEFAULT)
>   mtdparts = CONFIG_MTDPARTS_DEFAULT;
> diff --git a/include/configs/omap3_igep00x0.h 
> b/include/configs/omap3_igep00x0.h
> index b9d65697521b..280a094cdbae 100644
> --- a/include/configs/omap3_igep00x0.h
> +++ b/include/configs/omap3_igep00x0.h
> @@ -87,8 +87,6 @@
>  
>  #endif
>  
> -#define CONFIG_SYS_MTDPARTS_RUNTIME
> -
>  /* OneNAND config */
>  #define CONFIG_USE_ONENAND_BOARD_INIT
>  #define CONFIG_SYS_ONENAND_BASE  ONENAND_MAP
> diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
> index b8addeaf693a..72608071c486 100644
> --- a/scripts/config_whitelist.txt
> +++ b/scripts/config_whitelist.txt
> @@ -3511,7 +3511,6 @@ CONFIG_SYS_MRAM_SIZE
>  CONFIG_SYS_MSC0_VAL
>  CONFIG_SYS_MSC1_VAL
>  CONFIG_SYS_MSC2_VAL
> -CONFIG_SYS_MTDPARTS_RUNTIME
>  CONFIG_SYS_MX5_CLK32
>  CONFIG_SYS_MX5_HCLK
>  CONFIG_SYS_MX6_CLK32

Re: [U-Boot] [PATCH v2] gpio: dwapb_gpio: Change to use devm_kcalloc()

2018-09-07 Thread Ladislav Michl
On Fri, Sep 07, 2018 at 10:51:00AM +0200, Marek Vasut wrote:
> On 09/07/2018 08:24 AM, Ley Foon Tan wrote:
> > Change to use managed resource function devm_kcalloc(),
> > so it will auto free memory when driver is removed.
> > 
> > Signed-off-by: Ley Foon Tan 
> > 
> > ---
> > v2:
> > - Remove free() function.
> > ---
> >  drivers/gpio/dwapb_gpio.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> > index 0f6574d..6f9d17d 100644
> > --- a/drivers/gpio/dwapb_gpio.c
> > +++ b/drivers/gpio/dwapb_gpio.c
> > @@ -171,8 +171,7 @@ static int gpio_dwapb_bind(struct udevice *dev)
> > if (!fdtdec_get_bool(blob, node, "gpio-controller"))
> > continue;
> >  
> > -   plat = NULL;
> > -   plat = calloc(1, sizeof(*plat));
> > +   plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL);
> > if (!plat)
> > return -ENOMEM;
> >  
> > @@ -196,7 +195,6 @@ static int gpio_dwapb_bind(struct udevice *dev)
> > return 0;
> >  
> >  err:
> > -   free(plat);
> > return ret;
> 
> Well, this becomes return ret, right ? ;-)

Well, this vanishes completely ;-) But there're more strange snipets,
better to show patch:

diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index a118f58b22..7b3c5af6a7 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -123,8 +123,7 @@ static int gpio_dwapb_bind(struct udevice *dev)
if (!fdtdec_get_bool(blob, node, "gpio-controller"))
continue;
 
-   plat = NULL;
-   plat = calloc(1, sizeof(*plat));
+   plat = devm_kcalloc(dev, 1, sizeof(*plat), GFP_KERNEL);
if (!plat)
return -ENOMEM;
 
@@ -133,23 +132,17 @@ static int gpio_dwapb_bind(struct udevice *dev)
plat->pins = fdtdec_get_int(blob, node, "snps,nr-gpios", 0);
plat->name = fdt_stringlist_get(blob, node, "bank-name", 0,
NULL);
-   if (ret)
-   goto err;
 
ret = device_bind(dev, dev->driver, plat->name,
  plat, -1, );
if (ret)
-   goto err;
+   return ret;
 
dev_set_of_offset(subdev, node);
bank++;
}
 
return 0;
-
-err:
-   free(plat);
-   return ret;
 }
 
 static const struct udevice_id gpio_dwapb_ids[] = {
> >  }
> >  
> > 
> 
> 
> -- 
> Best regards,
> Marek Vasut
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v1] ubifs: avoid assert failed in ubifs.c

2018-05-22 Thread Ladislav Michl
On Tue, May 22, 2018 at 01:23:13PM +0200, Richard Weinberger wrote:
> Am Dienstag, 22. Mai 2018, 12:56:48 CEST schrieb Marek Vasut:
> > On 05/10/2018 10:57 PM, Marek Vasut wrote:
> > > On 04/27/2018 03:51 PM, Patrice Chotard wrote:
> > >> This patch solves assert failed displayed in the console during a boot.
> > >> The root cause is that the ubifs_inode is not already allocated when
> > >> ubifs_printdir and ubifs_finddir functions are called.
> > >>
> > >> Trace showing the issue:
> > >> feed 'boot.scr.uimg', ino 94, new f_pos 0x17b40ece
> > >> dent->ch.sqnum '7132', creat_sqnum 3886945402880
> > >> UBIFS assert failed in ubifs_finddir at 436
> > >> INODE ALLOCATION: creat_sqnum '7129'
> > >> Found U-Boot script /boot.scr.uimg
> > >>
> > >> Signed-off-by: Christophe Kerello 
> > >> Signed-off-by: Patrice Chotard 
> > > 
> > > I ran into this too, but what I do not quite understand from the commit
> > > message is how hiding the error actually solves the problem that the
> > > assert points to.
> > > 
> > > Why does the assert trigger in the first place ?
> > > 
> > > What is the root cause of the issue that is being hidden by this patch?
> > 
> > Bump?
> 
> I had a look, the bug is deeper, ubifs_finddir() allocates a vfs inode 
> manually
   ^^^

Hi Richard,

above triggered alert, so here's my old attempt to simplify ubifs_finddir(). 
Things
could be further simplified, but I got distracted and never had time to look 
here
again (which I'm affraid of).

Subject: [PATCH] Refactor ubifs_finddir

Just work in progress...

---
 fs/ubifs/ubifs.c | 67 +++-
 1 file changed, 9 insertions(+), 58 deletions(-)

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 47fa41ad1d..a876546a0e 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -389,47 +389,20 @@ out:
 static int ubifs_finddir(struct super_block *sb, char *dirname,
 unsigned long root_inum, unsigned long *inum)
 {
-   int err;
struct qstr nm;
union ubifs_key key;
struct ubifs_dent_node *dent;
-   struct ubifs_info *c;
-   struct file *file;
-   struct dentry *dentry;
-   struct inode *dir;
-   int ret = 0;
-
-   file = kzalloc(sizeof(struct file), 0);
-   dentry = kzalloc(sizeof(struct dentry), 0);
-   dir = kzalloc(sizeof(struct inode), 0);
-   if (!file || !dentry || !dir) {
-   printf("%s: Error, no memory for malloc!\n", __func__);
-   err = -ENOMEM;
-   goto out;
-   }
-
-   dir->i_sb = sb;
-   file->f_path.dentry = dentry;
-   file->f_path.dentry->d_parent = dentry;
-   file->f_path.dentry->d_inode = dir;
-   file->f_path.dentry->d_inode->i_ino = root_inum;
-   c = sb->s_fs_info;
-
-   dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos);
+   struct ubifs_info *c = sb->s_fs_info;
 
/* Find the first entry in TNC and save it */
-   lowest_dent_key(c, , dir->i_ino);
+   lowest_dent_key(c, , root_inum);
nm.name = NULL;
-   dent = ubifs_tnc_next_ent(c, , );
-   if (IS_ERR(dent)) {
-   err = PTR_ERR(dent);
-   goto out;
-   }
-
-   file->f_pos = key_hash_flash(c, >key);
-   file->private_data = dent;
 
while (1) {
+   dent = ubifs_tnc_next_ent(c, , );
+   if (IS_ERR(dent))
+   return PTR_ERR(dent);
+
dbg_gen("feed '%s', ino %llu, new f_pos %#x",
dent->name, (unsigned long long)le64_to_cpu(dent->inum),
key_hash_flash(c, >key));
@@ -441,36 +414,14 @@ static int ubifs_finddir(struct super_block *sb, char 
*dirname,
if ((strncmp(dirname, (char *)dent->name, nm.len) == 0) &&
(strlen(dirname) == nm.len)) {
*inum = le64_to_cpu(dent->inum);
-   ret = 1;
-   goto out_free;
+   kfree(dent);
+   return 0;
}
-
/* Switch to the next entry */
key_read(c, >key, );
nm.name = (char *)dent->name;
-   dent = ubifs_tnc_next_ent(c, , );
-   if (IS_ERR(dent)) {
-   err = PTR_ERR(dent);
-   goto out;
-   }
-
-   kfree(file->private_data);
-   file->f_pos = key_hash_flash(c, >key);
-   file->private_data = dent;
-   cond_resched();
+   kfree(dent);
}
-
-out:
-   if (err != -ENOENT)
-   dbg_gen("cannot find next direntry, error %d", err);
-
-out_free:
-   kfree(file->private_data);
-   free(file);
-   free(dentry);
-   free(dir);
-
-   return ret;
 }
 
 static unsigned long ubifs_findfile(struct super_block *sb, 

Re: [U-Boot] [PATCH 4/4] board: turris_mox: Add gpio command to defconfig

2018-05-16 Thread Ladislav Michl
On Wed, May 16, 2018 at 04:39:42PM +0200, Marek Behún wrote:
> This can be used to detect whether the button is pressed or light the
> LED diode.

Well, I know it is annoying, but as patch is oneliner anyway, let's get
at least commit log right.

LED stands for Light-Emitting Diode, so Light-Emitting Diode diode
does not look very nice.

(Yes, I know "LED dióda" is commonly used idiom, but this does not
make it any more right)

Thanks,
ladis

> Signed-off-by: Marek Behun 
> 
> diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
> index 7dea7157dc..9538903bd3 100644
> --- a/configs/turris_mox_defconfig
> +++ b/configs/turris_mox_defconfig
> @@ -13,6 +13,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
>  CONFIG_ARCH_EARLY_INIT_R=y
>  # CONFIG_CMD_FLASH is not set
>  CONFIG_CMD_CLK=y
> +CONFIG_CMD_GPIO=y
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_MMC=y
>  CONFIG_CMD_SF=y
> -- 
> 2.16.1
> 
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] twister: Let SPL load U-Boot from MMC

2018-05-14 Thread Ladislav Michl
MMC is not initialized in SPL, so it cannot load u-boot.img
preventing boot from MMC.

Also driver specific functions are guarded with generic
configuration options which leads to build failures when device
driver is not enabled in config. Fix that by using driver
specific defines.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 Stefano,

 if want this patch to be splitted, just let me know.
 I didn't want to make it two fewliners...

 board/technexion/twister/twister.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/board/technexion/twister/twister.c 
b/board/technexion/twister/twister.c
index 1166886e1d..0590e5f8af 100644
--- a/board/technexion/twister/twister.c
+++ b/board/technexion/twister/twister.c
@@ -18,10 +18,8 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_USB_EHCI_HCD
 #include 
 #include 
-#endif
 #include "twister.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -45,7 +43,7 @@ static const u32 gpmc_XR16L2751[] = {
XR16L2751_GPMC_CONFIG6,
 };
 
-#ifdef CONFIG_USB_EHCI_HCD
+#ifdef CONFIG_USB_EHCI_OMAP
 static struct omap_usbhs_board_data usbhs_bdata = {
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
@@ -118,19 +116,20 @@ void set_muxconf_regs(void)
 
 int board_eth_init(bd_t *bis)
 {
+#ifdef CONFIG_DRIVER_TI_EMAC
davinci_emac_initialize();
-
+#endif
/* init cs for extern lan */
enable_gpmc_cs_config(gpmc_smc911, _cfg->cs[5],
CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
-   if (smc911x_initialize(0, CONFIG_SMC911X_BASE) <= 0)
-   printf("\nError initializing SMC911x controlleri\n");
-
+#ifdef CONFIG_SMC911X
+   return smc911x_initialize(0, CONFIG_SMC911X_BASE);
+#else
return 0;
+#endif
 }
 
-#if defined(CONFIG_MMC_OMAP_HS) && \
-   !defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_MMC_OMAP_HS)
 int board_mmc_init(bd_t *bis)
 {
return omap_mmc_init(0, 0, 0, -1, -1);
-- 
2.17.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] UBI / UBIFS booting from NAND support

2017-11-27 Thread Ladislav Michl
On Mon, Nov 27, 2017 at 03:53:27PM +0100, jsanabria wrote:
> I could mount ubifs using ubifsmount command but there were a bit of
> warnings and then after trying to boot the spl did not find volume at all.

SPL is not supposed to load kernel from UBIFS (filesystem), but directly from
UBI volume. On IGEPs U-Boot expects these volumes (shrinked):
=> ubi info l
Volume information dump:
vol_id  0
nameloader
Volume information dump:
vol_id  1
nameconfig
Volume information dump:
vol_id  2
nameconfig_r
Volume information dump:
vol_id  3
namekernel
Volume information dump:
vol_id  4
namedtb
Volume information dump:
vol_id  5
namerootfs

In falcon mode SPL tries to load kernel and dtb, both identified by vol_id,
hence those have to be 3 and 4. If that fails, it loads u-boot image from
vol_id 0. Volumes 1 and 2 are used to store u-boot environment [*].
While there's also vol_id 5, u-boot is not concerned here, it just pass
information about rootfs to kernel.

Speaking about this, it would be nice to have it documented somewhere...

[*] There's bug in UBI env code. It just hangs, if you boot from MMC and flash
still contains vendor instalation (1bit hamming ecc and jffs2). I'll fix that
one day, but if you have time, any help welcome.

Best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] UBI / UBIFS booting from NAND support

2017-11-27 Thread Ladislav Michl
Dear Jose Miguel,

On Mon, Nov 27, 2017 at 11:45:11AM +0100, Jose Miguel Sanchez Sanabria wrote:
> Hi everyone.
> 
> I was testing the booting process from NAND using an UBI/UBIFS image in an
> igepv2 board.

I'm happy to see someone from ISEE being interested in mainline support
for their own product.

> However MLO tries to boot first kernel (falcon mode activated) and then
> falls back to u-boot (as expected anyway I just wanted to load u-boot from
> ubi) trying to load volume 0, but fails.

Due to size restrictions, MLO does contain only limited UBI functionality,
just enough to load image from static UBI volume.

> U-Boot SPL 2017.11-dirty (Nov 24 2017 - 14:29:26)
> Trying to boot from NAND
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 3
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 3
> UBI warning: Failed
> Loading Linux failed, falling back to U-Boot.
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 0
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 0
> UBI warning: Failed
> SPL: failed to boot from all boot devices
> ### ERROR ### Please RESET the board ###

As noted above, ubispl loader is rather limited and identifies volumes
by volume id. u-boot.img is expected to be found in vol_id=0, while linux
zImage in vol_id=3. Log above indicates there are no such volumes.
What does u-boot's command 'ubi info l' show?

> I can however mount the ubi image but suspicious log appear:
> 
> u-boot:> ubifsmount ubi0:ubirootfs

Now you are in u-boot, where different UBI implementation is used, so
you can identify volumes also by name.

> UBIFS assert failed in ubifs_change_lp at 540
> UBIFS assert failed in ubifs_release_lprops at 278
> UBIFS assert failed in ubifs_change_lp at 540
> UBIFS assert failed in ubifs_release_lprops at 278
> 
> This has to do with the discussion about ubifs null deference so I suppose
> it should not affect much to write operation.

Well, I do not use UBIFS in U-Boot at all. Just UBI to read and write volumes.

> I would finally like to know if the ubi/ubifs support is functional; which
> would mean I did not use the ubi tools correctly to create the ubi image.

You will find script I'm using to bring board up at the end of this mail.
But note, that 'fdt memory' is hacked a bit and proper implementaion is welcome:
https://lists.denx.de/pipermail/u-boot/2017-January/279823.html

Also note 'setenv fdtfile "${soc_family}-${board_name}.dtb"' line. That's also
not in mainline as it needs also board revision too and the way it is currently
done, we cannot distinguish rev B. and rev F. Unfortunately this article
http://labs.isee.biz/index.php/IGEP_Technology_devices_revisions#IGEP0020_revisions
does not explain, how all those numbers map to board revisions ISEE is using
in vendor code.

That said, I enabled UBIFS for IGEPv2 only localy to verify my ubifs_finddir
reimplementation, but as I was even unable to mount ubifs, original reporter
did not confirm that at least mount works for him and I run out of the time,
ubifs issue is still unresolved.

Best regards,
ladis

echo "*** starting u-boot instalation script ***"
nandecc hw hamming
setenv has_onenand $?
# MLO ...
fatload mmc 0:1 $loadaddr MLO
if test $has_onenand -eq 0
then
nand erase.part SPL
nand write $fileaddr 0 $filesize
nand write $fileaddr 2 $filesize
nand write $fileaddr 4 $filesize
nand write $fileaddr 6 $filesize
nandecc sw bch8
nand read $loadaddr UBI 2
if test $? != 0
then
ubi detach
nand erase.part UBI
fi
else
ubi part UBI
ubi check loader
if test $? != 0
then
ubi detach
onenand erase
else
onenand erase 0 8
fi
onenand write $fileaddr 0 2
onenand write $fileaddr 2 2
onenand write $fileaddr 4 2
onenand write $fileaddr 6 2
fi

# UBI volumes
ubi part UBI

echo "Creating UBI volumes..."
ubi check loader
if test $? != 0
then
ubi createvol loader 10 static 0
fi
ubi check config
if test $? != 0
then
ubi createvol config 8000 static 1
fi
ubi check config_r
if test $? != 0
then
ubi createvol config_r 8000 static 2
fi
ubi check kernel
if test $? != 0
then
ubi createvol kernel 40 static 3
fi
ubi check dtb
if test $? != 0
then
ubi createvol dtb 4 static 4
fi
ubi check rootfs
if test $? != 0
then
ubi createvol rootfs
fi

setenv fdtfile "${soc_family}-${board_name}.dtb"

# U-Boot ...
fatload mmc 0:1 $loadaddr u-boot.img
ubi write $fileaddr loader $filesize
# ... and root filesystem first
fatload mmc 0:1 $loadaddr root.ubifs
ubi write $fileaddr rootfs $filesize
# now load FDT blob ...
fatload mmc 0:1 $fdtaddr $fdtfile
# and fix it...
setenv bootargs "console=ttyO2,115200n8 

Re: [U-Boot] [PATCH v2 1/1] ubifs: avoid possible NULL dereference

2017-11-22 Thread Ladislav Michl
On Wed, Nov 22, 2017 at 02:37:49PM +0100, Ladislav Michl wrote:
> On Wed, Nov 22, 2017 at 01:37:54PM +0100, Heinrich Schuchardt wrote:
[snip]
> > I agree that there is a memory leak. But we should put fixing that into a
> > separate patch so that we can test both modifications separately.
> 
> There was no such memory leak before above patch.
> 
> > It is not enough to kfree(dent).
> > ubifs_tnc_next_ent may return ERR_PTR(err) and we do not want to pass this
> > value to kfree.
> 
> Nobody is claiming otherwise.
> 
> > As Wolfgang wrote we should pass error codes to the calling chain of
> > ubifs_finddir(), i.e. ubifs_findfile(), ubifs_size(), ubifs_read,
> > ubifs_exists(), ubifs_ls(), ...
> > 
> > The code also lacks support for the driver model.
> > 
> > So a lot of other patches needed.
> 
> Yes, but fix should not add another bug.
> 
> > If you think this patch fixes what it promises to fix, please, add your
> > review comment.
> 
> What about (untested)?
[snip]

Okay, just tried to test it. Does ubifsmount even work for you?
I cannot mount volume neither using name nor id.

Does not work on NAND:
=> ubi part UBI
=> ubifsmount ubi0:rootfs
UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
=> ubifsmount ubi5 
UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
UBIFS assert failed in ubifs_change_lp at 540
UBIFS assert failed in ubifs_release_lprops at 278
=> ubifsmount ubi0_5
UBIFS error (pid: 1): cannot open "ubi0_5", error -19Error reading superblock 
on volume 'ubi0_5' errno=-19!
ubifsmount - mount UBIFS volume

Usage:
ubifsmount 
- mount 'volume-name' volume
=> ubifsmount ubi0_5


Does not work on OneNAND:
=> ubifsmount ubi0_5
Error reading superblock on volume 'ubi0_5' errno=-22!
ubifsmount - mount UBIFS volume

Usage:
ubifsmount 
- mount 'volume-name' volume
=> ubifsmount ubi0_5
UBIFS error (ubi0:5 pid 0): check_lpt_crc: invalid crc in LPT node: crc d514 
calc 6695
UBIFS error (ubi0:5 pid 0): read_pnode: error -22 reading pnode at 8:16424
(pid 1) dumping pnode:
address 9dfb2dc0 parent 9dfb2d40 cnext 0
flags 0 iip 1 level 0 num 0
0: free 0 dirty 97240 flags 1 lnum 0
1: free 57344 dirty 39752 flags 34 lnum 0
2: free 0 dirty 111296 flags 1 lnum 0
3: free 0 dirty 85952 flags 34 lnum 0
UBIFS error (ubi0:5 pid 0): read_pnode: calc num: 89
UBIFS assert failed in ubifs_release_lprops at 278
Error reading superblock on volume 'ubi0_5' errno=-22!
ubifsmount - mount UBIFS volume

Usage:
ubifsmount 
- mount 'volume-name' volume

See? It even gives different output for the same command.
Tried every possible options to mount volume found in open_ubi...

So given above unfortunate state, I'm considering fixing $subject mentioned
a bit pointless as I'm not able to test it.

I'll look at mount problems later.

ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/1] ubifs: avoid possible NULL dereference

2017-11-22 Thread Ladislav Michl
On Wed, Nov 22, 2017 at 01:37:54PM +0100, Heinrich Schuchardt wrote:
> On 11/21/2017 11:40 PM, Ladislav Michl wrote:
> > On Tue, Nov 21, 2017 at 11:06:35PM +0100, Heinrich Schuchardt wrote:
> > > If 'file' cannot be allocated due to an out of memory
> > > situation, NULL is dereferenced.
> > > 
> > > Variables file and dentry are not needed at all.
> > > So let's eliminate them.
> > > 
> > > When debugging this patch also avoids a misleading message
> > > "cannot find next direntry, error %d" in case of an out of
> > > memory situation. It is sufficent to write
> > > "%s: Error, no memory for malloc!\n" in this case.
> > > 
> > > Reported-by: Ladislav Michl <la...@linux-mips.org>
> > > Reported-by: Alex Sadovsky <nable.mainin...@googlemail.com>
> > > Signed-off-by: Heinrich Schuchardt <xypron.g...@gmx.de>
> > > ---
> > >   fs/ubifs/ubifs.c | 25 ++---
> > >   1 file changed, 2 insertions(+), 23 deletions(-)
> > > 
> > > diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> > > index 4465523d5f..f3d190c763 100644
> > > --- a/fs/ubifs/ubifs.c
> > > +++ b/fs/ubifs/ubifs.c
> > > @@ -393,29 +393,18 @@ static int ubifs_finddir(struct super_block *sb, 
> > > char *dirname,
> > >   union ubifs_key key;
> > >   struct ubifs_dent_node *dent;
> > >   struct ubifs_info *c;
> > > - struct file *file;
> > > - struct dentry *dentry;
> > >   struct inode *dir;
> > >   int ret = 0;
> > > - file = kzalloc(sizeof(struct file), 0);
> > > - dentry = kzalloc(sizeof(struct dentry), 0);
> > >   dir = kzalloc(sizeof(struct inode), 0);
> > > - if (!file || !dentry || !dir) {
> > > + if (!dir) {
> > >   printf("%s: Error, no memory for malloc!\n", __func__);
> > > - err = -ENOMEM;
> > > - goto out;
> > > + goto out_free;
> > >   }
> > >   dir->i_sb = sb;
> > > - file->f_path.dentry = dentry;
> > > - file->f_path.dentry->d_parent = dentry;
> > > - file->f_path.dentry->d_inode = dir;
> > > - file->f_path.dentry->d_inode->i_ino = root_inum;
> > >   c = sb->s_fs_info;
> > > - dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos);
> > > -
> > >   /* Find the first entry in TNC and save it */
> > >   lowest_dent_key(c, , dir->i_ino);
> > >   nm.name = NULL;
> > > @@ -425,9 +414,6 @@ static int ubifs_finddir(struct super_block *sb, char 
> > > *dirname,
> > >   goto out;
> > >   }
> > > - file->f_pos = key_hash_flash(c, >key);
> > > - file->private_data = dent;
> > > -
> > >   while (1) {
> > >   dbg_gen("feed '%s', ino %llu, new f_pos %#x",
> > >   dent->name, (unsigned long 
> > > long)le64_to_cpu(dent->inum),
> > > @@ -450,10 +436,6 @@ static int ubifs_finddir(struct super_block *sb, 
> > > char *dirname,
> > >   err = PTR_ERR(dent);
> > >   goto out;
> > >   }
> > > -
> > > - kfree(file->private_data);
> > 
> > We still need to kfree allocated 'dent' as it was previously allocated:
> > dent = kmalloc(zbr->len, GFP_NOFS);
> > in ubifs_tnc_next_ent.
> 
> I agree that there is a memory leak. But we should put fixing that into a
> separate patch so that we can test both modifications separately.

There was no such memory leak before above patch.

> It is not enough to kfree(dent).
> ubifs_tnc_next_ent may return ERR_PTR(err) and we do not want to pass this
> value to kfree.

Nobody is claiming otherwise.

> As Wolfgang wrote we should pass error codes to the calling chain of
> ubifs_finddir(), i.e. ubifs_findfile(), ubifs_size(), ubifs_read,
> ubifs_exists(), ubifs_ls(), ...
> 
> The code also lacks support for the driver model.
> 
> So a lot of other patches needed.

Yes, but fix should not add another bug.

> If you think this patch fixes what it promises to fix, please, add your
> review comment.

What about (untested)?

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 4465523d5f..64188d9f2d 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -388,47 +388,33 @@ out:
 static int ubifs_finddir(struct super_b

Re: [U-Boot] [PATCH 1/1] ubifs: avoid possible NULL dereference

2017-11-22 Thread Ladislav Michl
On Wed, Nov 22, 2017 at 09:09:36AM +0100, Wolfgang Denk wrote:
> Dear Ladislav,
> 
> In message <2017112121.ryicwv6tyh5rye2e@lenoch> you wrote:
> > > > 
> > > > diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> > > > index 4465523d5f..313dee0579 100644
> > > > --- a/fs/ubifs/ubifs.c
> > > > +++ b/fs/ubifs/ubifs.c
> > > > @@ -403,8 +403,7 @@ static int ubifs_finddir(struct super_block *sb, 
> > > > char *dirname,
> > > > dir = kzalloc(sizeof(struct inode), 0);
> > > > if (!file || !dentry || !dir) {
> > > > printf("%s: Error, no memory for malloc!\n", __func__);
> > > > -   err = -ENOMEM;
> > > > -   goto out;
> > > > +   goto out_nomem;
> > > > }
> ...
> > > Should you not keep the "err = -ENOMEM;" setting?  Otherwise there
> > > is no indivcation that an error happened.
> > 
> > It is not obvious from the patch, but value of err is later discarded.
> > It serves sole purpose of printing debug notice.
> 
> So apparently we have a number of places in U-Boot where fatal
> errors (running out of memory) are just ignored and we continue as
> if nothing happened?

While I have to admit this code is not an example of clean coding,
it prints notice when trying to manipulate with file.

fs/ubifs/ubifs.c as whole needs to be revisited, above patch just
caused shit hitting the fan.

> THis is short-sighted at best. One day Pump Six will fail.
> 
> This is giving me the creepes. 

I was just pointing to the fact, that above mentioned patch does not
make it any worse. Btw, initial commit is even more amazing:

+   if (file)
+   free(file);
+   if (dentry)
+   free(dentry);
+   if (dir)
+   free(dir);
+
+   if (file->private_data)
+   kfree(file->private_data);
+   file->private_data = NULL;
+   file->f_pos = 2;
+   return 0;

.oO(I guess it is safe not pointing where above snippet is comming from,
but will review whole file as I'm going to use it for new board I have to
suport)

Best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/1] ubifs: avoid possible NULL dereference

2017-11-21 Thread Ladislav Michl
On Tue, Nov 21, 2017 at 11:06:35PM +0100, Heinrich Schuchardt wrote:
> If 'file' cannot be allocated due to an out of memory
> situation, NULL is dereferenced.
> 
> Variables file and dentry are not needed at all.
> So let's eliminate them.
> 
> When debugging this patch also avoids a misleading message
> "cannot find next direntry, error %d" in case of an out of
> memory situation. It is sufficent to write
> "%s: Error, no memory for malloc!\n" in this case.
> 
> Reported-by: Ladislav Michl <la...@linux-mips.org>
> Reported-by: Alex Sadovsky <nable.mainin...@googlemail.com>
> Signed-off-by: Heinrich Schuchardt <xypron.g...@gmx.de>
> ---
>  fs/ubifs/ubifs.c | 25 ++---
>  1 file changed, 2 insertions(+), 23 deletions(-)
> 
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index 4465523d5f..f3d190c763 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -393,29 +393,18 @@ static int ubifs_finddir(struct super_block *sb, char 
> *dirname,
>   union ubifs_key key;
>   struct ubifs_dent_node *dent;
>   struct ubifs_info *c;
> - struct file *file;
> - struct dentry *dentry;
>   struct inode *dir;
>   int ret = 0;
>  
> - file = kzalloc(sizeof(struct file), 0);
> - dentry = kzalloc(sizeof(struct dentry), 0);
>   dir = kzalloc(sizeof(struct inode), 0);
> - if (!file || !dentry || !dir) {
> + if (!dir) {
>   printf("%s: Error, no memory for malloc!\n", __func__);
> - err = -ENOMEM;
> - goto out;
> + goto out_free;
>   }
>  
>   dir->i_sb = sb;
> - file->f_path.dentry = dentry;
> - file->f_path.dentry->d_parent = dentry;
> - file->f_path.dentry->d_inode = dir;
> - file->f_path.dentry->d_inode->i_ino = root_inum;
>   c = sb->s_fs_info;
>  
> - dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos);
> -
>   /* Find the first entry in TNC and save it */
>   lowest_dent_key(c, , dir->i_ino);
>   nm.name = NULL;
> @@ -425,9 +414,6 @@ static int ubifs_finddir(struct super_block *sb, char 
> *dirname,
>   goto out;
>   }
>  
> - file->f_pos = key_hash_flash(c, >key);
> - file->private_data = dent;
> -
>   while (1) {
>   dbg_gen("feed '%s', ino %llu, new f_pos %#x",
>   dent->name, (unsigned long long)le64_to_cpu(dent->inum),
> @@ -450,10 +436,6 @@ static int ubifs_finddir(struct super_block *sb, char 
> *dirname,
>   err = PTR_ERR(dent);
>   goto out;
>   }
> -
> - kfree(file->private_data);

We still need to kfree allocated 'dent' as it was previously allocated:
dent = kmalloc(zbr->len, GFP_NOFS);
in ubifs_tnc_next_ent.

> - file->f_pos = key_hash_flash(c, >key);
> - file->private_data = dent;
>   cond_resched();
>   }
>  
> @@ -462,9 +444,6 @@ out:
>   dbg_gen("cannot find next direntry, error %d", err);
>  
>  out_free:
> - kfree(file->private_data);

Same as above.

> - free(file);
> - free(dentry);
>   free(dir);
>  
>   return ret;
> -- 
> 2.11.0
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] ubifs: avoid possible NULL dereference

2017-11-21 Thread Ladislav Michl
On Tue, Nov 21, 2017 at 10:29:51PM +0100, Heinrich Schuchardt wrote:
> 
> 
> On 11/21/2017 09:23 PM, Ladislav Michl wrote:
> > On Tue, Nov 21, 2017 at 07:45:03PM +0100, Heinrich Schuchardt wrote:
> > > If 'file' cannot be allocated due to an out of memory
> > > situation, do not dereference it.
> > > 
> > > When debugging this patch also avoids a misleading message
> > > "cannot find next direntry, error %d" in case of an out of
> > > memory situation. It is sufficent to write
> > > "%s: Error, no memory for malloc!\n" in this case.
> > > 
> > > Reported-by: Alex Sadovsky <nable.mainin...@googlemail.com>
> > > Signed-off-by: Heinrich Schuchardt <xypron.g...@gmx.de>
> > > ---
> > >   fs/ubifs/ubifs.c | 5 ++---
> > >   1 file changed, 2 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> > > index 4465523d5f..313dee0579 100644
> > > --- a/fs/ubifs/ubifs.c
> > > +++ b/fs/ubifs/ubifs.c
> > > @@ -403,8 +403,7 @@ static int ubifs_finddir(struct super_block *sb, char 
> > > *dirname,
> > >   dir = kzalloc(sizeof(struct inode), 0);
> > >   if (!file || !dentry || !dir) {
> > >   printf("%s: Error, no memory for malloc!\n", __func__);
> > > - err = -ENOMEM;
> > > - goto out;
> > > + goto out_nomem;
> > >   }
> > >   dir->i_sb = sb;
> > > @@ -424,7 +423,6 @@ static int ubifs_finddir(struct super_block *sb, char 
> > > *dirname,
> > >   err = PTR_ERR(dent);
> > >   goto out;
> > >   }
> > > -
> > >   file->f_pos = key_hash_flash(c, >key);
> > >   file->private_data = dent;
> > > 
> > This hunk should be probably droped.
> > 
> > > @@ -463,6 +461,7 @@ out:
> > >   out_free:
> > >   kfree(file->private_data);
> > 
> > Now question is why is file->private_data ever assigned as it seems nothing
> > works with it.
> 
> Good catch.
> 
> Do we need file and dentry at all in the function?

Does not seem so. Also what f_pos is good for is unclear.

> Unfortunately the file cannot be compiled on x86 cf.
> https://lists.denx.de/pipermail/u-boot/2017-November/312166.html

I could give it a try on ARM board. Care to cook an untested patch?

> Best regards
> 
> Heinrich
> 
> 
> > 
> > > +out_nomem:
> > >   free(file);
> > >   free(dentry);
> > >   free(dir);
> > > -- 
> > > 2.11.0
> > > 
> > > ___
> > > U-Boot mailing list
> > > U-Boot@lists.denx.de
> > > https://lists.denx.de/listinfo/u-boot
> > 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] ubifs: avoid possible NULL dereference

2017-11-21 Thread Ladislav Michl
On Tue, Nov 21, 2017 at 10:16:40PM +0100, Wolfgang Denk wrote:
> Dear Heinrich,
> 
> In message <20171121184503.3193-1-xypron.g...@gmx.de> you wrote:
> > If 'file' cannot be allocated due to an out of memory
> > situation, do not dereference it.
> > 
> > When debugging this patch also avoids a misleading message
> > "cannot find next direntry, error %d" in case of an out of
> > memory situation. It is sufficent to write
> > "%s: Error, no memory for malloc!\n" in this case.
> > 
> > Reported-by: Alex Sadovsky 
> > Signed-off-by: Heinrich Schuchardt 
> > ---
> >  fs/ubifs/ubifs.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> > index 4465523d5f..313dee0579 100644
> > --- a/fs/ubifs/ubifs.c
> > +++ b/fs/ubifs/ubifs.c
> > @@ -403,8 +403,7 @@ static int ubifs_finddir(struct super_block *sb, char 
> > *dirname,
> > dir = kzalloc(sizeof(struct inode), 0);
> > if (!file || !dentry || !dir) {
> > printf("%s: Error, no memory for malloc!\n", __func__);
> > -   err = -ENOMEM;
> > -   goto out;
> > +   goto out_nomem;
> > }
> >  
> > dir->i_sb = sb;
> > @@ -424,7 +423,6 @@ static int ubifs_finddir(struct super_block *sb, char 
> > *dirname,
> > err = PTR_ERR(dent);
> > goto out;
> > }
> > -
> > file->f_pos = key_hash_flash(c, >key);
> > file->private_data = dent;
> >  
> > @@ -463,6 +461,7 @@ out:
> >  
> >  out_free:
> > kfree(file->private_data);
> > +out_nomem:
> > free(file);
> > free(dentry);
> > free(dir);
> 
> Should you not keep the "err = -ENOMEM;" setting?  Otherwise there
> is no indivcation that an error happened.

It is not obvious from the patch, but value of err is later discarded.
It serves sole purpose of printing debug notice.

> 
> Best regards,
> 
> Wolfgang Denk
> 
> -- 
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
> There are no data that cannot be plotted on a straight  line  if  the
> axis are chosen correctly.
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] ubifs: avoid possible NULL dereference

2017-11-21 Thread Ladislav Michl
On Tue, Nov 21, 2017 at 07:45:03PM +0100, Heinrich Schuchardt wrote:
> If 'file' cannot be allocated due to an out of memory
> situation, do not dereference it.
> 
> When debugging this patch also avoids a misleading message
> "cannot find next direntry, error %d" in case of an out of
> memory situation. It is sufficent to write
> "%s: Error, no memory for malloc!\n" in this case.
> 
> Reported-by: Alex Sadovsky 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  fs/ubifs/ubifs.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index 4465523d5f..313dee0579 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -403,8 +403,7 @@ static int ubifs_finddir(struct super_block *sb, char 
> *dirname,
>   dir = kzalloc(sizeof(struct inode), 0);
>   if (!file || !dentry || !dir) {
>   printf("%s: Error, no memory for malloc!\n", __func__);
> - err = -ENOMEM;
> - goto out;
> + goto out_nomem;
>   }
>  
>   dir->i_sb = sb;
> @@ -424,7 +423,6 @@ static int ubifs_finddir(struct super_block *sb, char 
> *dirname,
>   err = PTR_ERR(dent);
>   goto out;
>   }
> -
>   file->f_pos = key_hash_flash(c, >key);
>   file->private_data = dent;
>
  
This hunk should be probably droped.

> @@ -463,6 +461,7 @@ out:
>  
>  out_free:
>   kfree(file->private_data);

Now question is why is file->private_data ever assigned as it seems nothing
works with it.

> +out_nomem:
>   free(file);
>   free(dentry);
>   free(dir);
> -- 
> 2.11.0
> 
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [OE-core] [PATCH] u-boot: Upgrade to 2017.11 release

2017-11-16 Thread Ladislav Michl
On Thu, Nov 16, 2017 at 04:34:51PM -0200, Otavio Salvador wrote:
> On Thu, Nov 16, 2017 at 4:21 PM, Marek Vasut  wrote:
> > On 11/16/2017 01:02 PM, Otavio Salvador wrote:
> >> On Thu, Nov 16, 2017 at 6:12 AM, Marek Vasut  wrote:
> >>> On 11/15/2017 05:47 PM, Stefan Agner wrote:
>  On 2017-11-14 19:32, Otavio Salvador wrote:
> > This upgrades the U-Boot from 2017.09 to 2017.11 release.
> 
>  You might encounter this when building fw_printenv/setenv tools alone:
> 
>  https://lists.denx.de/pipermail/u-boot/2017-November/311505.html
> >>>
> >>> [...]
> >>>
> >  SRC_URI = "git://git.denx.de/u-boot.git \
> >  file://MPC8315ERDB-enable-DHCP.patch \
> >>> I also see that the number of out-of-tree patches didn't change since
> >>> last time, even though I complained about it ... why are these patches
> >>> still here ?
> >>
> >> Because you are the maintainer and didn't do your duty.
> >
> > And what duty is that exactly ? I at least inquired about the status of
> > these patches and reviewed them [1] (the other was not submitted to ML
> > yet and submitter is not responding), so do you have anything else in mind ?
> >
> > [1] https://marc.info/?l=u-boot=150533817907015=2
> 
> Good, so I don't see the reason for the question.
> 
> I did upgrade the recipe and tested. It didn't have patches merged so
> there is nothing I can do. 

Sure there is. Merging patches does not happen automagically, so it is
your (or whoevers, but definitely not maintainers) responsibility to check
upstream status and eventually resubmit.

> You being the maintainer can keep an eye here.

No. Maintainer's job is mostly rejecting poor quality patches and merging
those properly submited, tested and described. What you are asking for
is ussually called babysitting.

> >>> I also see that the number of out-of-tree patches didn't change since
> >>> last time, even though I complained about it ... why are these patches
> >>> still here ?
> 
> Your question was pointless. So instead of "complain" as you said,
> make sure those are merged.

While I see no reason U-Boot list was cc'ed on this patch, your attitude
is almost perfect example how _not_ to do opensource development.

Best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] UBI/UBIFS complete integrity check

2017-11-06 Thread Ladislav Michl
On Mon, Nov 06, 2017 at 12:31:32PM -0500, Liam Beguin wrote:
> Hi,
> 
> Thanks for taking the time to answer.
> 
> On 11/05/2017 03:37 AM, Ladislav Michl wrote:
> > On Tue, Oct 31, 2017 at 11:01:21AM -0400, Liam Beguin wrote:
> > > Hi everyone,
> > > 
> > > I'm currently using a UBIFS root file system (stored on SPI-NOR flash)
> > > and would like to perform a full integrity check before booting it.
> > > The rootfs is read-only and until now, I've been computing an md5sum on
> > > the whole mtd device from an initramfs and comparing it to a stored
> > > md5sum. If both md5sums don't match, I need to stop the boot process
> > > completely.
> > 
> > Above doesn't sound right even in theory as UBI layer is free to correct
> > bit-flips (unlikely on SPI-NOR) and shuffle eraseblocks around even
> > if read only filesystem is sitting on top of it. See this faq:
> > http://www.linux-mtd.infradead.org/doc/ubi.html#L_ubiblock> So, if you
> > are computing md5sum of underlaying mtd device you might get
> > different checksum even for the same UBI content.
> > 
> 
> I forgot to mention that the flash I use has a hardware lock which is enabled
> after the filesystem is first written (the flash is locked during boot).
> I'm quite confident this works as I've been using the md5sum mechanism for
> some time now.

I see. Btw, have you considered using for example squashfs on top of static UBI
volume? Given the fact your fs is read only you get:
- CRC32 checksum of you volume for free
- filesystem compression
- you can easily compute mtd5sum of volume content
- check filesystem consistency using already provided tools (probably overkill).

> As the UBI layer is able to detect/fix bit-flips, what happens if a bit-flip 
> is
> detected and UBI cannot write to flash? does it fail to attach?

No, it just logs it. It fails once there is enough bitflips that ECC is unable
to correct them. But again, it is not case of NOR, I mentioned it just for
completeness.

> > > If possible, I was hoping to drop initramfs and do the integrity check
> > > from U-Boot. I know UBI/UBIFS does a CRC-32 of the data it writes to
> > > flash but the intent here is to prevent booting an image where
> > > even a _single bit_ of flash may have been corrupted.

Above mentioned solution should fail instantly in case of CRC error. Not sure if
that's what you want as kernel already took over, so either watchdog will kick 
in
or machine will reboot, if configured to do so after panics.

> > > My question is, does UBI/UBIFS have this kind of complete integrity
> > > check built-in? If not, can I take advantage of these CRC-32, to do
> > > something equivalent to my md5sum check from U-Boot.
> > > Thanks,
> > 
> > There is md5sum command, question is whenever you UBI volume fits
> > into RAM to do calculation at once.
> > 
> > > Liam Beguin
> > > Xiphos Systems Corp.
> > > http://xiphos.com
> > > ___
> > > U-Boot mailing list
> > > U-Boot@lists.denx.de
> > > https://lists.denx.de/listinfo/u-boot
> 
> Thanks,
> 
> Liam Beguin
> Xiphos Systems Corp.
> http://xiphos.com
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] UBI/UBIFS complete integrity check

2017-11-05 Thread Ladislav Michl
On Tue, Oct 31, 2017 at 11:01:21AM -0400, Liam Beguin wrote:
> Hi everyone,
> 
> I'm currently using a UBIFS root file system (stored on SPI-NOR flash)
> and would like to perform a full integrity check before booting it.
> The rootfs is read-only and until now, I've been computing an md5sum on
> the whole mtd device from an initramfs and comparing it to a stored
> md5sum. If both md5sums don't match, I need to stop the boot process
> completely.

Above doesn't sound right even in theory as UBI layer is free to correct
bit-flips (unlikely on SPI-NOR) and shuffle eraseblocks around even
if read only filesystem is sitting on top of it. See this faq:
http://www.linux-mtd.infradead.org/doc/ubi.html#L_ubiblock

So, if you are computing md5sum of underlaying mtd device you might get
different checksum even for the same UBI content.

> If possible, I was hoping to drop initramfs and do the integrity check
> from U-Boot. I know UBI/UBIFS does a CRC-32 of the data it writes to
> flash but the intent here is to prevent booting an image where
> even a _single bit_ of flash may have been corrupted.
> 
> My question is, does UBI/UBIFS have this kind of complete integrity
> check built-in? If not, can I take advantage of these CRC-32, to do
> something equivalent to my md5sum check from U-Boot.
> Thanks,

There is md5sum command, question is whenever you UBI volume fits
into RAM to do calculation at once.

> Liam Beguin
> Xiphos Systems Corp.
> http://xiphos.com
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCHv2 2/2] igep00x0: merge igep0020 and igep0030 defconfigs to igep00x0_defconfig

2017-08-16 Thread Ladislav Michl
From: Pau Pajuelo <ppaj...@gmail.com>

Update igep00x0 code with the following features:
- Add board and revision detection for the boards:
  - IGEP0020-RF
  - IGEP0020-RC
  - IGEP0030-RG
  - IGEP0030-RE
- Merge IGEP0020 and IGEP0030 mux tables
- Add suport to use GPIO_126, GPIO_127 and GPIO_129
- board_name and board_rev environment variables display board and
  revision informations
- Move dtb name selection from code to boot script

Signed-off-by: Pau Pajuelo <ppaj...@gmail.com>
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 Changes:
 -v2: Move dtb name selection from code to boot script
  Use board_rev to hold board revision

 board/isee/igep00x0/MAINTAINERS|  3 +-
 board/isee/igep00x0/common.c   | 12 ---
 board/isee/igep00x0/igep00x0.c | 90 --
 board/isee/igep00x0/igep00x0.h | 13 ++--
 configs/igep0030_defconfig | 47 ---
 configs/{igep0020_defconfig => igep00x0_defconfig} |  8 --
 include/configs/omap3_igep00x0.h   | 45 ---
 7 files changed, 124 insertions(+), 94 deletions(-)

diff --git a/board/isee/igep00x0/MAINTAINERS b/board/isee/igep00x0/MAINTAINERS
index 720ef2aa69..d75d400eed 100644
--- a/board/isee/igep00x0/MAINTAINERS
+++ b/board/isee/igep00x0/MAINTAINERS
@@ -3,6 +3,5 @@ M:  Enric Balletbo i Serra <eballe...@gmail.com>
 S: Maintained
 F: board/isee/igep00x0/
 F: include/configs/omap3_igep00x0.h
-F: configs/igep0020_defconfig
-F: configs/igep0030_defconfig
+F: configs/igep00x0_defconfig
 F: configs/igep0032_defconfig
diff --git a/board/isee/igep00x0/common.c b/board/isee/igep00x0/common.c
index b8f1c14f6a..e59516f612 100644
--- a/board/isee/igep00x0/common.c
+++ b/board/isee/igep00x0/common.c
@@ -22,14 +22,6 @@ DECLARE_GLOBAL_DATA_PTR;
 void set_muxconf_regs(void)
 {
MUX_DEFAULT();
-
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
-   MUX_IGEP0020();
-#endif
-
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
-   MUX_IGEP0030();
-#endif
 }
 
 /*
@@ -60,10 +52,6 @@ int board_init(void)
/* boot param addr */
gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
 
-#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
-   status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
-#endif
-
return 0;
 }
 
diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 74f9bab093..5c7f256711 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -17,7 +17,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -38,6 +37,43 @@ U_BOOT_DEVICE(igep_uart) = {
_serial
 };
 
+/*
+ * Routine: get_board_revision
+ * Description: GPIO_28 and GPIO_129 are used to read board and revision from
+ * IGEP00x0 boards. First of all, it is necessary to reset USB transceiver from
+ * IGEP0030 in order to read GPIO_IGEP00X0_BOARD_DETECTION correctly, because
+ * this functionality is shared by USB HOST.
+ * Once USB reset is applied, U-boot configures these pins as input pullup to
+ * detect board and revision:
+ * IGEP0020-RF = 0b00
+ * IGEP0020-RC = 0b01
+ * IGEP0030-RG = 0b10
+ * IGEP0030-RE = 0b11
+ */
+static int get_board_revision(void)
+{
+   int revision;
+
+   gpio_request(IGEP0030_USB_TRANSCEIVER_RESET,
+   "igep0030_usb_transceiver_reset");
+   gpio_direction_output(IGEP0030_USB_TRANSCEIVER_RESET, 0);
+
+   gpio_request(GPIO_IGEP00X0_BOARD_DETECTION, "igep00x0_board_detection");
+   gpio_direction_input(GPIO_IGEP00X0_BOARD_DETECTION);
+   revision = 2 * gpio_get_value(GPIO_IGEP00X0_BOARD_DETECTION);
+   gpio_free(GPIO_IGEP00X0_BOARD_DETECTION);
+
+   gpio_request(GPIO_IGEP00X0_REVISION_DETECTION,
+   "igep00x0_revision_detection");
+   gpio_direction_input(GPIO_IGEP00X0_REVISION_DETECTION);
+   revision = revision + gpio_get_value(GPIO_IGEP00X0_REVISION_DETECTION);
+   gpio_free(GPIO_IGEP00X0_REVISION_DETECTION);
+
+   gpio_free(IGEP0030_USB_TRANSCEIVER_RESET);
+
+   return revision;
+}
+
 int onenand_board_init(struct mtd_info *mtd)
 {
if (gpmc_cs0_flash == MTD_DEV_TYPE_ONENAND) {
@@ -138,31 +174,69 @@ int ft_board_setup(void *blob, bd_t *bd)
 }
 #endif
 
-void set_fdt(void)
+void set_led(void)
 {
-   switch (gd->bd->bi_arch_number) {
-   case MACH_TYPE_IGEP0020:
-   env_set("fdtfile", "omap3-igep0020.dtb");
+   switch (get_board_revision()) {
+   case 0:
+   case 1:
+   gpio_request(IGEP0020_GPIO_LED, "igep0020_gpio_led");
+   gpio_direction_output(IGEP0020_GPIO_LED, 1);
break;
-   case MACH_TYPE_IGEP0030:
-   env_set("fdtfile", &quo

[U-Boot] [PATCH 1/2] igep00x0: move SPL routines into separate file

2017-08-16 Thread Ladislav Michl
Avoid cluttering board file with CONFIG_SPL_BUILD ifdefs
by moving SPL related functions into separate file.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 board/isee/igep00x0/Makefile   |   6 +-
 board/isee/igep00x0/common.c   |  80 ++
 board/isee/igep00x0/igep00x0.c | 128 -
 board/isee/igep00x0/spl.c  |  64 +
 4 files changed, 149 insertions(+), 129 deletions(-)

diff --git a/board/isee/igep00x0/Makefile b/board/isee/igep00x0/Makefile
index 68b151c3c5..74594da771 100644
--- a/board/isee/igep00x0/Makefile
+++ b/board/isee/igep00x0/Makefile
@@ -5,4 +5,8 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
-obj-y  := igep00x0.o
+ifdef CONFIG_SPL_BUILD
+obj-y  := spl.o common.o
+else
+obj-y  := igep00x0.o common.o
+endif
diff --git a/board/isee/igep00x0/common.c b/board/isee/igep00x0/common.c
new file mode 100644
index 00..b8f1c14f6a
--- /dev/null
+++ b/board/isee/igep00x0/common.c
@@ -0,0 +1,80 @@
+/*
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "igep00x0.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * Routine: set_muxconf_regs
+ * Description: Setting up the configuration Mux registers specific to the
+ * hardware. Many pins need to be moved from protect to primary
+ * mode.
+ */
+void set_muxconf_regs(void)
+{
+   MUX_DEFAULT();
+
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
+   MUX_IGEP0020();
+#endif
+
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
+   MUX_IGEP0030();
+#endif
+}
+
+/*
+ * Routine: board_init
+ * Description: Early hardware init.
+ */
+int board_init(void)
+{
+   int loops = 100;
+
+   /* find out flash memory type, assume NAND first */
+   gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
+   gpmc_init();
+
+   /* Issue a RESET and then READID */
+   writeb(NAND_CMD_RESET, _cfg->cs[0].nand_cmd);
+   writeb(NAND_CMD_STATUS, _cfg->cs[0].nand_cmd);
+   while ((readl(_cfg->cs[0].nand_dat) & NAND_STATUS_READY)
+   != NAND_STATUS_READY) {
+   udelay(1);
+   if (--loops == 0) {
+   gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
+   gpmc_init();/* reinitialize for OneNAND */
+   break;
+   }
+   }
+
+   /* boot param addr */
+   gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
+
+#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
+   status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
+#endif
+
+   return 0;
+}
+
+#if defined(CONFIG_MMC)
+int board_mmc_init(bd_t *bis)
+{
+   return omap_mmc_init(0, 0, 0, -1, -1);
+}
+
+void board_mmc_power_init(void)
+{
+   twl4030_power_mmc_init(0);
+}
+#endif
diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index a7a75601dd..74f9bab093 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -20,15 +20,12 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include "igep00x0.h"
 
-DECLARE_GLOBAL_DATA_PTR;
-
 static const struct ns16550_platdata igep_serial = {
.base = OMAP34XX_UART3,
.reg_shift = 2,
@@ -41,98 +38,6 @@ U_BOOT_DEVICE(igep_uart) = {
_serial
 };
 
-/*
- * Routine: board_init
- * Description: Early hardware init.
- */
-int board_init(void)
-{
-   int loops = 100;
-
-   /* find out flash memory type, assume NAND first */
-   gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
-   gpmc_init();
-
-   /* Issue a RESET and then READID */
-   writeb(NAND_CMD_RESET, _cfg->cs[0].nand_cmd);
-   writeb(NAND_CMD_STATUS, _cfg->cs[0].nand_cmd);
-   while ((readl(_cfg->cs[0].nand_dat) & NAND_STATUS_READY)
-   != NAND_STATUS_READY) {
-   udelay(1);
-   if (--loops == 0) {
-   gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
-   gpmc_init();/* reinitialize for OneNAND */
-   break;
-   }
-   }
-
-   /* boot param addr */
-   gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
-
-#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
-   status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
-#endif
-
-   return 0;
-}
-
-#ifdef CONFIG_SPL_BUILD
-/*
- * Routine: get_board_mem_timings
- * Description: If we use SPL then there is no x-loader nor config header
- * so we have to setup the DDR timings ourself on both banks.
- */
-void get_board_mem_timings(struct board_sdrc_timings *timings)
-{
-   int mfr, id, err = identify_nand_chip(, );
-
-   timings->mr = MICRON_V_MR_165;
-   if (!err) {
-   switch

[U-Boot] [PATCH 0/2] igep00x0: defconfig merge

2017-08-16 Thread Ladislav Michl
Hi Pau,

code with your patch "igep00x0: merge igep0020 and igep0030 defconfigs to
igep00x0_defconfig" applied no longer fits to sram (and patch even does
not apply anymore), so here's an update:
- move spl related functions to separate file
- update defconfig merge patch to current git
- use board_rev as other boards do
- set fdtfile using script (do not hardcode it)

best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] igep00x0: merge igep0020 and igep0030 defconfigs to igep00x0_defconfig

2017-08-07 Thread Ladislav Michl
Hello Pau,

On Sun, Aug 06, 2017 at 12:51:38PM +0200, Pau Pajuelo wrote:
> Update igep00x0 code with the following features:
> - Add board and revision detection for the boards:
>   - IGEP0020-RF
>   - IGEP0020-RC
>   - IGEP0030-RG
>   - IGEP0030-RE

(it would be great to see this page updated:
http://labs.isee.biz/index.php/IGEP_Technology_devices_revisions)

> - Merge IGEP0020 and IGEP0030 mux tables
> - Add suport to use GPIO_126, GPIO_127 and GPIO_129
> - board_name environment variable displays board and revision information

nice idea!

> Signed-off-by: Pau Pajuelo <ppaj...@gmail.com>

Reviewed-by: Ladislav Michl <la...@linux-mips.org>

Btw, once here, it would be nice to detect also CPU family as OMAP3530
devices cannot boot with omap3-igep0020.dtb and patch bellow is needed
(unless there is a better solution, I'll provide patch):
 
diff --git a/arch/arm/boot/dts/omap3-igep.dtsi 
b/arch/arm/boot/dts/omap3-igep.dtsi
index c16d17efe38e..1cafae7d8468 100644
--- a/arch/arm/boot/dts/omap3-igep.dtsi
+++ b/arch/arm/boot/dts/omap3-igep.dtsi
@@ -10,7 +10,7 @@
  */
 /dts-v1/;
 
-#include "omap36xx.dtsi"
+#include "omap34xx.dtsi"
 
 / {
memory@8000 {
diff --git a/arch/arm/boot/dts/omap3-igep0020.dts 
b/arch/arm/boot/dts/omap3-igep0020.dts
index cc09842ad21b..0fa4ad499bec 100644
--- a/arch/arm/boot/dts/omap3-igep0020.dts
+++ b/arch/arm/boot/dts/omap3-igep0020.dts
@@ -13,7 +13,7 @@
 
 / {
model = "IGEPv2 Rev. C (TI OMAP AM/DM37x)";
-   compatible = "isee,omap3-igep0020", "ti,omap36xx", "ti,omap3";
+   compatible = "isee,omap3-igep0020", "ti,omap3430", "ti,omap3";
 
vmmcsdio_fixed: fixedregulator-mmcsdio {
compatible = "regulator-fixed";
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] igep003x: Falcon mode

2017-06-25 Thread Ladislav Michl
Implement spl_start_uboot to let Falcon mode work.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 board/isee/igep003x/board.c   | 8 
 configs/am335x_igep003x_defconfig | 1 +
 2 files changed, 9 insertions(+)

diff --git a/board/isee/igep003x/board.c b/board/isee/igep003x/board.c
index 2d0ebbf5ef..e33170d65f 100644
--- a/board/isee/igep003x/board.c
+++ b/board/isee/igep003x/board.c
@@ -166,6 +166,14 @@ void sdram_init(void)
config_ddr(400, _igep0034_lite, _igep0034_lite_data,
_igep0034_lite_cmd_ctrl_data, 
_igep0034_lite_emif_reg_data, 0);
 }
+
+#ifdef CONFIG_SPL_OS_BOOT
+int spl_start_uboot(void)
+{
+   /* break into full u-boot on 'c' */
+   return serial_tstc() && serial_getc() == 'c';
+}
+#endif
 #endif
 
 /*
diff --git a/configs/am335x_igep003x_defconfig 
b/configs/am335x_igep003x_defconfig
index df7d1c69af..8fc31461f1 100644
--- a/configs/am335x_igep003x_defconfig
+++ b/configs/am335x_igep003x_defconfig
@@ -22,6 +22,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_MTD_SUPPORT=y
+CONFIG_SPL_OS_BOOT=y
 CONFIG_SPL_POWER_SUPPORT=y
 CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_HUSH_PARSER=y
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] igep00x0: Enable UBI fastmap

2017-06-25 Thread Ladislav Michl
Fastmap significantly reduces flash scan time, enable it by default.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 configs/igep0020_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/igep0020_defconfig b/configs/igep0020_defconfig
index 3856d3faec..a86a00997f 100644
--- a/configs/igep0020_defconfig
+++ b/configs/igep0020_defconfig
@@ -34,6 +34,7 @@ CONFIG_LED_STATUS_STATE=2
 CONFIG_LED_STATUS_BOOT_ENABLE=y
 CONFIG_LED_STATUS_BOOT=0
 CONFIG_MMC_OMAP_HS=y
+CONFIG_MTD_UBI_FASTMAP=y
 CONFIG_SYS_NS16550=y
 CONFIG_FAT_WRITE=y
 CONFIG_OF_LIBFDT=y
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] spl: Make UBI fastmap support Kconfig selectable

2017-06-25 Thread Ladislav Michl
Fastmap was always enabled in ubispl, make it selectable by
CONFIG_MTD_UBI_FASTMAP.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 common/spl/spl_ubi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index 24633f4766..83089335a7 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -38,7 +38,7 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
goto out;
}
info.ubi = (struct ubi_scan_info *)CONFIG_SPL_UBI_INFO_ADDR;
-   info.fastmap = 1;
+   info.fastmap = IS_ENABLED(CONFIG_MTD_UBI_FASTMAP);
 
info.peb_offset = CONFIG_SPL_UBI_PEB_OFFSET;
info.vid_offset = CONFIG_SPL_UBI_VID_OFFSET;
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] mtd: OneNAND: Fix onenand_block_markbad

2017-06-20 Thread Ladislav Michl
commit dfe64e2c89731a3f9950d7acd8681b68df2bae03
Author: Sergey Lapin <sla...@ossfans.org>
Date:   Mon Jan 14 03:46:50 2013 +

mtd: resync with Linux-3.7.1

modified onenand_block_markbad to call mtd_block_markbad,
but as _block_markbad function pointer used by mtd_block_markbad
to do actual job is by default pointing back to
onenand_block_markbad there is no way this function ever
finishes its job.
Fix it by changing function body according current (4.12-rc6)
linux implementation.
Tested on IGEPv2 board with Muxed OneNAND(DDP) 512MB containing
several unerasable blocks this function marked bad.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 drivers/mtd/onenand/onenand_base.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/onenand/onenand_base.c 
b/drivers/mtd/onenand/onenand_base.c
index 2e3d0e5c9a..8282f683a5 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -1919,6 +1919,7 @@ static int onenand_default_block_markbad(struct mtd_info 
*mtd, loff_t ofs)
  */
 int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs)
 {
+   struct onenand_chip *this = mtd->priv;
int ret;
 
ret = onenand_block_isbad(mtd, ofs);
@@ -1929,7 +1930,10 @@ int onenand_block_markbad(struct mtd_info *mtd, loff_t 
ofs)
return ret;
}
 
-   ret = mtd_block_markbad(mtd, ofs);
+   onenand_get_device(mtd, FL_WRITING);
+   ret = this->block_markbad(mtd, ofs);
+   onenand_release_device(mtd);
+
return ret;
 }
 
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/2] onenand_spl_simple: Add DDP OneNAND support

2017-06-20 Thread Ladislav Michl
Current implementation is unable to access second half of
DDP OneNAND flash (reads first half mirrored). Use block
and bufferram address calculations from onenand_base to
fix this.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 drivers/mtd/onenand/onenand_spl.c | 29 +
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/onenand/onenand_spl.c 
b/drivers/mtd/onenand/onenand_spl.c
index 6fad34aa1d..0b78067a23 100644
--- a/drivers/mtd/onenand/onenand_spl.c
+++ b/drivers/mtd/onenand/onenand_spl.c
@@ -23,11 +23,29 @@ enum onenand_spl_pagesize {
PAGE_4K = 4096,
 };
 
+static unsigned int density_mask;
+
 #define ONENAND_PAGES_PER_BLOCK64
-#define onenand_block_address(block)   (block)
 #define onenand_sector_address(page)   (page << 2)
 #define onenand_buffer_address()   ((1 << 3) << 8)
-#define onenand_bufferram_address(block)   (0)
+
+static inline int onenand_block_address(int block)
+{
+   /* Device Flash Core select, NAND Flash Block Address */
+   if (block & density_mask)
+   return ONENAND_DDP_CHIP1 | (block ^ density_mask);
+
+   return block;
+}
+
+static inline int onenand_bufferram_address(int block)
+{
+   /* Device BufferRAM Select */
+   if (block & density_mask)
+   return ONENAND_DDP_CHIP1;
+
+   return ONENAND_DDP_CHIP0;
+}
 
 static inline uint16_t onenand_readw(uint32_t addr)
 {
@@ -41,7 +59,7 @@ static inline void onenand_writew(uint16_t value, uint32_t 
addr)
 
 static enum onenand_spl_pagesize onenand_spl_get_geometry(void)
 {
-   uint32_t dev_id, density;
+   unsigned int dev_id, density, size;
 
if (!onenand_readw(ONENAND_REG_TECHNOLOGY)) {
dev_id = onenand_readw(ONENAND_REG_DEVICE_ID);
@@ -51,8 +69,11 @@ static enum onenand_spl_pagesize 
onenand_spl_get_geometry(void)
if (density < ONENAND_DEVICE_DENSITY_4Gb)
return PAGE_2K;
 
-   if (dev_id & ONENAND_DEVICE_IS_DDP)
+   if (dev_id & ONENAND_DEVICE_IS_DDP) {
+   size = onenand_readw(ONENAND_REG_DATA_BUFFER_SIZE);
+   density_mask = 1 << (18 + density - ffs(size));
return PAGE_2K;
+   }
}
 
return PAGE_4K;
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/2] onenand_spl_simple: Call onenand_spl_get_geometry() only once

2017-06-20 Thread Ladislav Michl
Do not call onenand_spl_get_geometry() for each block read.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 drivers/mtd/onenand/onenand_spl.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/onenand/onenand_spl.c 
b/drivers/mtd/onenand/onenand_spl.c
index 1925f41d8a..6fad34aa1d 100644
--- a/drivers/mtd/onenand/onenand_spl.c
+++ b/drivers/mtd/onenand/onenand_spl.c
@@ -110,9 +110,12 @@ static u8 scratch_buf[PAGE_4K];
  */
 int onenand_spl_read_block(int block, int offset, int len, void *dst)
 {
-   int page, read, psize;
+   int page, read;
+   static int psize;
+
+   if (!psize)
+   psize = onenand_spl_get_geometry();
 
-   psize = onenand_spl_get_geometry();
/* Calculate the page number */
page = offset / psize;
/* Offset to the start of a flash page */
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 3/7] mtd: nand: Consolidate nand spl loaders implementation

2017-04-16 Thread Ladislav Michl
nand_spl_load_image implementation was copied over into three
different drivers and now with nand_spl_read_block used for
ubispl situation gets even worse. For now use least intrusive
solution and #include the same implementation to nand drivers.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
Tested-by: Pau Pajuelo <ppaj...@gmail.com>
---
 Changes:
 v2: drop CONFIG_SPL_NAND_LOAD ifdef around nand_spl_load_image
 as it breaks some boards build (this should be fixed separately
 anyway)

 drivers/mtd/nand/am335x_spl_bch.c   |  49 +
 drivers/mtd/nand/atmel_nand.c   |  30 +--
 drivers/mtd/nand/nand_spl_loaders.c | 104 
 drivers/mtd/nand/nand_spl_simple.c  |  98 +
 4 files changed, 110 insertions(+), 171 deletions(-)

diff --git a/drivers/mtd/nand/am335x_spl_bch.c 
b/drivers/mtd/nand/am335x_spl_bch.c
index 5b189a1d8a..e68b4a5b19 100644
--- a/drivers/mtd/nand/am335x_spl_bch.c
+++ b/drivers/mtd/nand/am335x_spl_bch.c
@@ -198,53 +198,6 @@ static int nand_read_page(int block, int page, void *dst)
return 0;
 }
 
-int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
-{
-   unsigned int block, lastblock;
-   unsigned int page, page_offset;
-
-   /*
-* offs has to be aligned to a page address!
-*/
-   block = offs / CONFIG_SYS_NAND_BLOCK_SIZE;
-   lastblock = (offs + size - 1) / CONFIG_SYS_NAND_BLOCK_SIZE;
-   page = (offs % CONFIG_SYS_NAND_BLOCK_SIZE) / CONFIG_SYS_NAND_PAGE_SIZE;
-   page_offset = offs % CONFIG_SYS_NAND_PAGE_SIZE;
-
-   while (block <= lastblock) {
-   if (!nand_is_bad_block(block)) {
-   /*
-* Skip bad blocks
-*/
-   while (page < CONFIG_SYS_NAND_PAGE_COUNT) {
-   nand_read_page(block, page, dst);
-   /*
-* When offs is not aligned to page address the
-* extra offset is copied to dst as well. Copy
-* the image such that its first byte will be
-* at the dst.
-*/
-   if (unlikely(page_offset)) {
-   memmove(dst, dst + page_offset,
-   CONFIG_SYS_NAND_PAGE_SIZE);
-   dst = (void *)((int)dst - page_offset);
-   page_offset = 0;
-   }
-   dst += CONFIG_SYS_NAND_PAGE_SIZE;
-   page++;
-   }
-
-   page = 0;
-   } else {
-   lastblock++;
-   }
-
-   block++;
-   }
-
-   return 0;
-}
-
 /* nand_init() - initialize data to make nand usable by SPL */
 void nand_init(void)
 {
@@ -269,3 +222,5 @@ void nand_deselect(void)
if (nand_chip.select_chip)
nand_chip.select_chip(mtd, -1);
 }
+
+#include "nand_spl_loaders.c"
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 21d5d0e70d..7c10bfedc6 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1380,34 +1380,6 @@ static int nand_read_page(int block, int page, void *dst)
 }
 #endif /* CONFIG_SPL_NAND_ECC */
 
-int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
-{
-   unsigned int block, lastblock;
-   unsigned int page;
-
-   block = offs / CONFIG_SYS_NAND_BLOCK_SIZE;
-   lastblock = (offs + size - 1) / CONFIG_SYS_NAND_BLOCK_SIZE;
-   page = (offs % CONFIG_SYS_NAND_BLOCK_SIZE) / CONFIG_SYS_NAND_PAGE_SIZE;
-
-   while (block <= lastblock) {
-   if (!nand_is_bad_block(block)) {
-   while (page < CONFIG_SYS_NAND_PAGE_COUNT) {
-   nand_read_page(block, page, dst);
-   dst += CONFIG_SYS_NAND_PAGE_SIZE;
-   page++;
-   }
-
-   page = 0;
-   } else {
-   lastblock++;
-   }
-
-   block++;
-   }
-
-   return 0;
-}
-
 int at91_nand_wait_ready(struct mtd_info *mtd)
 {
struct nand_chip *this = mtd_to_nand(mtd);
@@ -1474,6 +1446,8 @@ void nand_deselect(void)
nand_chip.select_chip(mtd, -1);
 }
 
+#include "nand_spl_loaders.c"
+
 #else
 
 #ifndef CONFIG_SYS_NAND_BASE_LIST
diff --git a/drivers/mtd/nand/nand_spl_loaders.c 
b/drivers/mtd/nand/nand_spl_loaders.c
new file mode 100644
index 00..177c12b581
--- /dev/null
+++ b/drivers/mtd/nand/nand_spl_loaders.c
@@ -0,0 +1,104 @@
+int nand_spl_load_image(uint32_t offs, unsigned int si

[U-Boot] [PATCH 7/7] igep003x: Add netboot support

2017-04-01 Thread Ladislav Michl
From: Pau Pajuelo <ppaju...@iseebcn.com>

netboot allows to boot an external image using TFTP and NFS protocols

Signed-off-by: Pau Pajuelo <ppaju...@iseebcn.com>
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 include/configs/am335x_igep003x.h | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/configs/am335x_igep003x.h 
b/include/configs/am335x_igep003x.h
index 2962f72582..9a62fc9cb7 100644
--- a/include/configs/am335x_igep003x.h
+++ b/include/configs/am335x_igep003x.h
@@ -79,6 +79,16 @@
"run nandargs; " \
"run nandload; " \
"bootz ${loadaddr} - ${fdtaddr} \0" \
+   "netload=tftpboot ${loadaddr} ${bootfile}; " \
+   "tftpboot ${fdtaddr} ${fdtfile} \0" \
+   "netargs=setenv bootargs console=${console} " \
+   "${optargs} " \
+   "root=/dev/nfs " \
+   "ip=${ipaddr} nfsroot=${serverip}:${rootnfs},v3,tcp \0" \
+   "netboot=echo Booting from net ...; " \
+   "run netargs; " \
+   "run netload; " \
+   "bootz ${loadaddr} - ${fdtaddr} \0" \
"findfdt="\
"if test ${board_name} = igep0033; then " \
"setenv fdtfile am335x-igep-base0033.dtb; fi; " \
@@ -93,7 +103,8 @@
 #define CONFIG_BOOTCOMMAND \
"run findfdt;" \
"run mmcboot;" \
-   "run nandboot;"
+   "run nandboot;" \
+   "run netboot;"
 
 /* NS16550 Configuration */
 #define CONFIG_SYS_NS16550_COM10x44e09000  /* UART0 */
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 6/7] igep003x: Add support for IGEP SMARC AM335x

2017-04-01 Thread Ladislav Michl
From: Pau Pajuelo <ppaju...@iseebcn.com>

The IGEP SMARC AM335x is an industrial processor module with
following highlights:

  o AM3352 TI processor (Up to AM3359)
  o Cortex-A8 ARM CPU
  o SMARC form factor module
  o Up to 512 MB DDR3 SDRAM / 512 MB FLASH
  o WiFi a/b/g/n and Bluetooth v4.0 on-board
  o Ethernet 10/100/1000 Mbps and 10/100 Mbps controller on-board
  o JTAG debug connector available
  o Designed for industrial range purposes

Signed-off-by: Pau Pajuelo <ppaju...@iseebcn.com>
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 arch/arm/mach-omap2/am33xx/Kconfig |   1 +
 board/isee/igep003x/board.c| 126 ++---
 board/isee/igep003x/mux.c  |  10 +-
 ...gep0033_defconfig => am335x_igep003x_defconfig} |   0
 include/configs/am335x_igep003x.h  |  15 ++-
 5 files changed, 133 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-omap2/am33xx/Kconfig 
b/arch/arm/mach-omap2/am33xx/Kconfig
index 387d488c47..db3c70fe21 100644
--- a/arch/arm/mach-omap2/am33xx/Kconfig
+++ b/arch/arm/mach-omap2/am33xx/Kconfig
@@ -46,6 +46,7 @@ config TARGET_AM335X_BALTOS
 
 config TARGET_AM335X_IGEP003X
bool "Support am335x_igep003x"
+   select BOARD_LATE_INIT
select DM
select DM_SERIAL
select DM_GPIO
diff --git a/board/isee/igep003x/board.c b/board/isee/igep003x/board.c
index 9abb4824b5..2d0ebbf5ef 100644
--- a/board/isee/igep003x/board.c
+++ b/board/isee/igep003x/board.c
@@ -1,7 +1,7 @@
 /*
- * Board functions for IGEP COM AQUILA based boards
+ * Board functions for IGEP COM AQUILA and SMARC AM335x based boards
  *
- * Copyright (C) 2013, ISEE 2007 SL - http://www.isee.biz/
+ * Copyright (C) 2013-2017, ISEE 2007 SL - http://www.isee.biz/
  *
  * SPDX-License-Identifier:GPL-2.0+
  */
@@ -26,21 +26,72 @@
 #include 
 #include 
 #include 
+#include 
 #include "board.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/* GPIO0_27 and GPIO0_26 are used to read board revision from IGEP003x boards
+ * and control IGEP0034 green and red LEDs.
+ * U-boot configures these pins as input pullup to detect board revision:
+ * IGEP0034-LITE = 0b00
+ * IGEP0034 (FULL) = 0b01
+ * IGEP0033 = 0b1X
+ */
+#define GPIO_GREEN_REVISION27
+#define GPIO_RED_REVISION  26
+
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
+/*
+ * Routine: get_board_revision
+ * Description: Returns the board revision
+ */
+static int get_board_revision(void)
+{
+   int revision;
+
+   gpio_request(GPIO_GREEN_REVISION, "green_revision");
+   gpio_direction_input(GPIO_GREEN_REVISION);
+   revision = 2 * gpio_get_value(GPIO_GREEN_REVISION);
+   gpio_free(GPIO_GREEN_REVISION);
+
+   gpio_request(GPIO_RED_REVISION, "red_revision");
+   gpio_direction_input(GPIO_RED_REVISION);
+   revision = revision + gpio_get_value(GPIO_RED_REVISION);
+   gpio_free(GPIO_RED_REVISION);
+
+   return revision;
+}
+
 #ifdef CONFIG_SPL_BUILD
-static const struct ddr_data ddr3_data = {
+/* PN H5TQ4G63AFR is equivalent to MT41K256M16HA125*/
+static const struct ddr_data ddr3_igep0034_data = {
+   .datardsratio0 = MT41K256M16HA125E_RD_DQS,
+   .datawdsratio0 = MT41K256M16HA125E_WR_DQS,
+   .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE,
+   .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA,
+};
+
+static const struct ddr_data ddr3_igep0034_lite_data = {
.datardsratio0 = K4B2G1646EBIH9_RD_DQS,
.datawdsratio0 = K4B2G1646EBIH9_WR_DQS,
.datafwsratio0 = K4B2G1646EBIH9_PHY_FIFO_WE,
.datawrsratio0 = K4B2G1646EBIH9_PHY_WR_DATA,
 };
 
-static const struct cmd_control ddr3_cmd_ctrl_data = {
+static const struct cmd_control ddr3_igep0034_cmd_ctrl_data = {
+   .cmd0csratio = MT41K256M16HA125E_RATIO,
+   .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
+
+   .cmd1csratio = MT41K256M16HA125E_RATIO,
+   .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
+
+   .cmd2csratio = MT41K256M16HA125E_RATIO,
+   .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
+};
+
+static const struct cmd_control ddr3_igep0034_lite_cmd_ctrl_data = {
.cmd0csratio = K4B2G1646EBIH9_RATIO,
.cmd0iclkout = K4B2G1646EBIH9_INVERT_CLKOUT,
 
@@ -51,7 +102,17 @@ static const struct cmd_control ddr3_cmd_ctrl_data = {
.cmd2iclkout = K4B2G1646EBIH9_INVERT_CLKOUT,
 };
 
-static struct emif_regs ddr3_emif_reg_data = {
+static struct emif_regs ddr3_igep0034_emif_reg_data = {
+   .sdram_config = MT41K256M16HA125E_EMIF_SDCFG,
+   .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF,
+   .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1,
+   .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2,
+   .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3,
+   .zq_config = MT41K256M16HA125E_ZQ_CFG,
+   .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY,
+};
+
+static struct emif_regs ddr3_igep0034_lite_emif_r

[U-Boot] [PATCH 5/7] igep003x: UBIize

2017-04-01 Thread Ladislav Michl
Convert IGEP board to use UBI volumes for U-Boot, its environment and
kernel. With exception of first four sectors read by SoC BootROM whole
NAND is UBI managed.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 board/isee/igep003x/board.c   | 17 +++
 configs/am335x_igep0033_defconfig |  4 
 include/configs/am335x_igep003x.h | 45 +++
 3 files changed, 48 insertions(+), 18 deletions(-)

diff --git a/board/isee/igep003x/board.c b/board/isee/igep003x/board.c
index 5fea7ffaef..9abb4824b5 100644
--- a/board/isee/igep003x/board.c
+++ b/board/isee/igep003x/board.c
@@ -23,6 +23,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include "board.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -104,6 +107,20 @@ int board_init(void)
return 0;
 }
 
+#ifdef CONFIG_OF_BOARD_SETUP
+int ft_board_setup(void *blob, bd_t *bd)
+{
+#ifdef CONFIG_FDT_FIXUP_PARTITIONS
+   static struct node_info nodes[] = {
+   { "ti,omap2-nand", MTD_DEV_TYPE_NAND, },
+   };
+
+   fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
+#endif
+   return 0;
+}
+#endif
+
 #if defined(CONFIG_DRIVER_TI_CPSW)
 static void cpsw_control(int enabled)
 {
diff --git a/configs/am335x_igep0033_defconfig 
b/configs/am335x_igep0033_defconfig
index 12f04c68f9..71e11da17a 100644
--- a/configs/am335x_igep0033_defconfig
+++ b/configs/am335x_igep0033_defconfig
@@ -13,6 +13,7 @@ CONFIG_SPL_WATCHDOG_SUPPORT=y
 CONFIG_SPL_FAT_SUPPORT=y
 CONFIG_SPL_POWER_SUPPORT=y
 CONFIG_SPL_STACK_R_ADDR=0x8200
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0033"
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_VERSION_VARIABLE=y
@@ -41,9 +42,12 @@ CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_UBI=y
 CONFIG_ISO_PARTITION=y
 CONFIG_EFI_PARTITION=y
 CONFIG_MMC_OMAP_HS=y
+CONFIG_MTD_UBI_FASTMAP=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
+CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_GENERATE_SMBIOS_TABLE is not set
diff --git a/include/configs/am335x_igep003x.h 
b/include/configs/am335x_igep003x.h
index 348b16f3e8..f7209930d3 100644
--- a/include/configs/am335x_igep003x.h
+++ b/include/configs/am335x_igep003x.h
@@ -21,7 +21,7 @@
 #define V_OSCK 2400  /* Clock output from T2 */
 #define V_SCLK (V_OSCK)
 
-#define CONFIG_ENV_SIZE(128 << 10) /* 128 KiB */
+#define CONFIG_ENV_SIZE(96 << 10)  /*  96 KiB */
 
 /* Make the verbose messages from UBI stop printing */
 #define CONFIG_UBI_SILENCE_MSG
@@ -67,11 +67,11 @@
"fi;\0" \
"mtdids=" MTDIDS_DEFAULT "\0" \
"mtdparts=" MTDPARTS_DEFAULT "\0" \
-   "nandroot=ubi0:filesystem rw ubi.mtd=3,2048\0" \
+   "nandroot=ubi0:rootfs rw ubi.mtd=1\0" \
"nandrootfstype=ubifs rootwait\0" \
-   "nandload=ubi part filesystem 2048; ubifsmount ubi0; " \
-   "ubifsload ${loadaddr} ${bootdir}/${bootfile}; " \
-   "ubifsload ${fdtaddr} ${bootdir}/${dtbfile} \0" \
+   "nandload=ubi part UBI; " \
+   "ubi read ${loadaddr} kernel; " \
+   "ubi read ${fdtaddr} dtb \0" \
"nandargs=setenv bootargs console=${console} " \
"${optargs} " \
"root=${nandroot} " \
@@ -97,12 +97,6 @@
 /* NAND support */
 #define CONFIG_NAND_OMAP_ELM
 #define CONFIG_SYS_NAND_ONFI_DETECTION 1
-#define CONFIG_SYS_ENV_SECT_SIZE   (128 << 10) /* 128 KiB */
-#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
-#define CONFIG_ENV_IS_IN_NAND
-#define CONFIG_ENV_OFFSET  0x18 /* environment starts here */
-#define CONFIG_ENV_ADDR_REDUND (CONFIG_ENV_OFFSET + 
CONFIG_SYS_ENV_SECT_SIZE)
-#define CONFIG_ENV_SIZE_REDUND (CONFIG_ENV_SIZE)
 
 #define CONFIG_MTD_PARTITIONS
 #define CONFIG_MTD_DEVICE
@@ -110,9 +104,7 @@
 #define CONFIG_LZO
 
 #define MTDIDS_DEFAULT "nand0=omap2-nand.0"
-#define MTDPARTS_DEFAULT   "mtdparts=omap2-nand.0:512k(spl),"\
-   "1m(uboot),256k(environment),"\
-   "-(filesystem)"
+#define MTDPARTS_DEFAULT   "mtdparts=omap2-nand.0:512k(SPL),-(UBI)"
 
 /* Unsupported features */
 #undef CONFIG_USE_IRQ
@@ -120,6 +112,27 @@
 /* SPL */
 #define CONFIG_SPL_LDSCRIPT
"arch/arm/mach-omap2/am33xx/u-boot-spl.lds"
 
+/* UBI configuration */
+#define CONFIG_SPL_UBI 1
+#define CONFIG_SPL_UBI_MAX_VOL_LEBS256
+#define CONFIG_SPL_UBI_MAX_PEB_SIZE(256*1024)
+#define CONFIG_SPL_UBI_MAX_PEBS4096
+#define CONFIG_SPL_UBI

[U-Boot] [PATCH 4/7] igep0033: Rename to igep003x

2017-04-01 Thread Ladislav Michl
Rename igep0033 to igep003x as IGEP SMARC AM335x module (igep0034)
can use the same source files.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 arch/arm/Kconfig | 2 +-
 arch/arm/mach-omap2/am33xx/Kconfig   | 4 ++--
 board/isee/{igep0033 => igep003x}/Kconfig| 6 +++---
 board/isee/{igep0033 => igep003x}/MAINTAINERS| 6 +++---
 board/isee/{igep0033 => igep003x}/Makefile   | 0
 board/isee/{igep0033 => igep003x}/board.c| 0
 board/isee/{igep0033 => igep003x}/board.h| 0
 board/isee/{igep0033 => igep003x}/mux.c  | 0
 configs/am335x_igep0033_defconfig| 5 -
 include/configs/{am335x_igep0033.h => am335x_igep003x.h} | 9 +++--
 10 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index dacfe9a13f..a9658930c7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1290,7 +1290,7 @@ source "board/gumstix/pepper/Kconfig"
 source "board/h2200/Kconfig"
 source "board/hisilicon/hikey/Kconfig"
 source "board/imx31_phycore/Kconfig"
-source "board/isee/igep0033/Kconfig"
+source "board/isee/igep003x/Kconfig"
 source "board/olimex/mx23_olinuxino/Kconfig"
 source "board/phytec/pcm051/Kconfig"
 source "board/ppcag/bg0900/Kconfig"
diff --git a/arch/arm/mach-omap2/am33xx/Kconfig 
b/arch/arm/mach-omap2/am33xx/Kconfig
index cf5d95a26d..387d488c47 100644
--- a/arch/arm/mach-omap2/am33xx/Kconfig
+++ b/arch/arm/mach-omap2/am33xx/Kconfig
@@ -44,8 +44,8 @@ config TARGET_AM335X_BALTOS
select DM_SERIAL
select DM_GPIO
 
-config TARGET_AM335X_IGEP0033
-   bool "Support am335x_igep0033"
+config TARGET_AM335X_IGEP003X
+   bool "Support am335x_igep003x"
select DM
select DM_SERIAL
select DM_GPIO
diff --git a/board/isee/igep0033/Kconfig b/board/isee/igep003x/Kconfig
similarity index 61%
rename from board/isee/igep0033/Kconfig
rename to board/isee/igep003x/Kconfig
index e989e4b15c..68a68fc52f 100644
--- a/board/isee/igep0033/Kconfig
+++ b/board/isee/igep003x/Kconfig
@@ -1,7 +1,7 @@
-if TARGET_AM335X_IGEP0033
+if TARGET_AM335X_IGEP003X
 
 config SYS_BOARD
-   default "igep0033"
+   default "igep003x"
 
 config SYS_VENDOR
default "isee"
@@ -10,6 +10,6 @@ config SYS_SOC
default "am33xx"
 
 config SYS_CONFIG_NAME
-   default "am335x_igep0033"
+   default "am335x_igep003x"
 
 endif
diff --git a/board/isee/igep0033/MAINTAINERS b/board/isee/igep003x/MAINTAINERS
similarity index 56%
rename from board/isee/igep0033/MAINTAINERS
rename to board/isee/igep003x/MAINTAINERS
index bd8a1f2eb4..748b189c4e 100644
--- a/board/isee/igep0033/MAINTAINERS
+++ b/board/isee/igep003x/MAINTAINERS
@@ -1,6 +1,6 @@
-IGEP0033 BOARD
+IGEP003X BOARD
 M: Enric Balletbo i Serra <eballe...@gmail.com>
 S: Maintained
-F: board/isee/igep0033/
-F: include/configs/am335x_igep0033.h
+F: board/isee/igep003x/
+F: include/configs/am335x_igep003x.h
 F: configs/am335x_igep0033_defconfig
diff --git a/board/isee/igep0033/Makefile b/board/isee/igep003x/Makefile
similarity index 100%
rename from board/isee/igep0033/Makefile
rename to board/isee/igep003x/Makefile
diff --git a/board/isee/igep0033/board.c b/board/isee/igep003x/board.c
similarity index 100%
rename from board/isee/igep0033/board.c
rename to board/isee/igep003x/board.c
diff --git a/board/isee/igep0033/board.h b/board/isee/igep003x/board.h
similarity index 100%
rename from board/isee/igep0033/board.h
rename to board/isee/igep003x/board.h
diff --git a/board/isee/igep0033/mux.c b/board/isee/igep003x/mux.c
similarity index 100%
rename from board/isee/igep0033/mux.c
rename to board/isee/igep003x/mux.c
diff --git a/configs/am335x_igep0033_defconfig 
b/configs/am335x_igep0033_defconfig
index a1991de4ff..12f04c68f9 100644
--- a/configs/am335x_igep0033_defconfig
+++ b/configs/am335x_igep0033_defconfig
@@ -3,7 +3,8 @@ CONFIG_AM33XX=y
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_TARGET_AM335X_IGEP0033=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_TARGET_AM335X_IGEP003X=y
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
@@ -12,6 +13,7 @@ CONFIG_SPL_WATCHDOG_SUPPORT=y
 CONFIG_SPL_FAT_SUPPORT=y
 CONFIG_SPL_POWER_SUPPORT=y
 CONFIG_SPL_STACK_R_ADDR=0x8200
+CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0033"
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_SPL=y
@@ -44,3 +46,4 @@ CONFIG_EFI_PARTITION=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
+# CONFIG_GENERATE_SMBIOS_TABLE is not set
diff --git a/include/configs/am335x_igep0033.h 
b/include/configs/am335x_igep00

[U-Boot] [PATCH 3/7] mtd: nand: Consolidate nand spl loaders implementation

2017-04-01 Thread Ladislav Michl
nand_spl_load_image implementation was copied over into three
different drivers and now with nand_spl_read_block used for
ubispl situation gets even worse. For now use least intrusive
solution and #include the same implementation to nand drivers.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 drivers/mtd/nand/am335x_spl_bch.c   |  49 +
 drivers/mtd/nand/atmel_nand.c   |  30 +-
 drivers/mtd/nand/nand_spl_loaders.c | 106 
 drivers/mtd/nand/nand_spl_simple.c  |  98 +
 4 files changed, 112 insertions(+), 171 deletions(-)

diff --git a/drivers/mtd/nand/am335x_spl_bch.c 
b/drivers/mtd/nand/am335x_spl_bch.c
index a8a7a66a18..c433caa365 100644
--- a/drivers/mtd/nand/am335x_spl_bch.c
+++ b/drivers/mtd/nand/am335x_spl_bch.c
@@ -170,53 +170,6 @@ static int nand_read_page(int block, int page, void *dst)
return 0;
 }
 
-int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
-{
-   unsigned int block, lastblock;
-   unsigned int page, page_offset;
-
-   /*
-* offs has to be aligned to a page address!
-*/
-   block = offs / CONFIG_SYS_NAND_BLOCK_SIZE;
-   lastblock = (offs + size - 1) / CONFIG_SYS_NAND_BLOCK_SIZE;
-   page = (offs % CONFIG_SYS_NAND_BLOCK_SIZE) / CONFIG_SYS_NAND_PAGE_SIZE;
-   page_offset = offs % CONFIG_SYS_NAND_PAGE_SIZE;
-
-   while (block <= lastblock) {
-   if (!nand_is_bad_block(block)) {
-   /*
-* Skip bad blocks
-*/
-   while (page < CONFIG_SYS_NAND_PAGE_COUNT) {
-   nand_read_page(block, page, dst);
-   /*
-* When offs is not aligned to page address the
-* extra offset is copied to dst as well. Copy
-* the image such that its first byte will be
-* at the dst.
-*/
-   if (unlikely(page_offset)) {
-   memmove(dst, dst + page_offset,
-   CONFIG_SYS_NAND_PAGE_SIZE);
-   dst = (void *)((int)dst - page_offset);
-   page_offset = 0;
-   }
-   dst += CONFIG_SYS_NAND_PAGE_SIZE;
-   page++;
-   }
-
-   page = 0;
-   } else {
-   lastblock++;
-   }
-
-   block++;
-   }
-
-   return 0;
-}
-
 /* nand_init() - initialize data to make nand usable by SPL */
 void nand_init(void)
 {
@@ -241,3 +194,5 @@ void nand_deselect(void)
if (nand_chip.select_chip)
nand_chip.select_chip(mtd, -1);
 }
+
+#include "nand_spl_loaders.c"
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 8669432deb..00c8bc5f12 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1379,34 +1379,6 @@ static int nand_read_page(int block, int page, void *dst)
 }
 #endif /* CONFIG_SPL_NAND_ECC */
 
-int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
-{
-   unsigned int block, lastblock;
-   unsigned int page;
-
-   block = offs / CONFIG_SYS_NAND_BLOCK_SIZE;
-   lastblock = (offs + size - 1) / CONFIG_SYS_NAND_BLOCK_SIZE;
-   page = (offs % CONFIG_SYS_NAND_BLOCK_SIZE) / CONFIG_SYS_NAND_PAGE_SIZE;
-
-   while (block <= lastblock) {
-   if (!nand_is_bad_block(block)) {
-   while (page < CONFIG_SYS_NAND_PAGE_COUNT) {
-   nand_read_page(block, page, dst);
-   dst += CONFIG_SYS_NAND_PAGE_SIZE;
-   page++;
-   }
-
-   page = 0;
-   } else {
-   lastblock++;
-   }
-
-   block++;
-   }
-
-   return 0;
-}
-
 int at91_nand_wait_ready(struct mtd_info *mtd)
 {
struct nand_chip *this = mtd_to_nand(mtd);
@@ -1473,6 +1445,8 @@ void nand_deselect(void)
nand_chip.select_chip(mtd, -1);
 }
 
+#include "nand_spl_loaders.c"
+
 #else
 
 #ifndef CONFIG_SYS_NAND_BASE_LIST
diff --git a/drivers/mtd/nand/nand_spl_loaders.c 
b/drivers/mtd/nand/nand_spl_loaders.c
new file mode 100644
index 00..2a4b104954
--- /dev/null
+++ b/drivers/mtd/nand/nand_spl_loaders.c
@@ -0,0 +1,106 @@
+#ifdef CONFIG_SPL_NAND_LOAD
+int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
+{
+   unsigned int block, lastblock;
+   unsigned int page, page_offset;
+
+   /* offs has to be aligned to a page address! */
+   blo

[U-Boot] [PATCH 2/7] ARM: am33xx: define BOOT_DEVICE_ONENAND

2017-04-01 Thread Ladislav Michl
am33xx does not support OneNAND, but we need this define anyway
to let UBI SPL code compile.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 arch/arm/include/asm/arch-am33xx/spl.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/arch-am33xx/spl.h 
b/arch/arm/include/asm/arch-am33xx/spl.h
index 9df7b4ac45..4b5a48edd8 100644
--- a/arch/arm/include/asm/arch-am33xx/spl.h
+++ b/arch/arm/include/asm/arch-am33xx/spl.h
@@ -47,6 +47,7 @@
 #define BOOT_DEVICE_UART   0x41
 #define BOOT_DEVICE_USBETH 0x44
 #define BOOT_DEVICE_CPGMAC 0x46
+#define BOOT_DEVICE_ONENAND0xFF /* ROM does not support OneNAND. */
 
 #define MMC_BOOT_DEVICES_START BOOT_DEVICE_MMC1
 #define MMC_BOOT_DEVICES_END   BOOT_DEVICE_MMC2
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/7] ARM: am33xx: fix typo in spl.h

2017-04-01 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 arch/arm/include/asm/arch-am33xx/spl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-am33xx/spl.h 
b/arch/arm/include/asm/arch-am33xx/spl.h
index f744ab0782..9df7b4ac45 100644
--- a/arch/arm/include/asm/arch-am33xx/spl.h
+++ b/arch/arm/include/asm/arch-am33xx/spl.h
@@ -28,7 +28,7 @@
 #define BOOT_DEVICE_XIP0x01
 #define BOOT_DEVICE_XIPWAIT0x02
 #define BOOT_DEVICE_NAND   0x03
-#define BOOT_DEVICE_ONENAD 0x04
+#define BOOT_DEVICE_ONENAND0x04
 #define BOOT_DEVICE_MMC2   0x05 /* ROM only supports 2nd instance. */
 #define BOOT_DEVICE_MMC1   0x06
 #define BOOT_DEVICE_UART   0x43
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 0/7] Add IGEP SMARC AM335x module support

2017-04-01 Thread Ladislav Michl
Hi there!

this series adds support for ISEE's IGEP SMARC AM335x module.
Patches 1, 2 and 4 are safe to apply, patch 3 is where a bit
of controversy lays. I'm fine with redoing it, whenever better
proposal appears, but note I'm not able to test all platforms
(that's why I did it this way). Patch 5 brings UBI to AM335x
ISEE's boards the same way it is done for OMAP3 based ones.
And finally Pau's patch 6 adds support for SMARTC module.

Best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] arm: OMAP2+: nandecc: propagate error to command return status

2017-03-06 Thread Ladislav Michl
Currently nandecc returns zero even if underlaying
omap_nand_switch_ecc function fails. Fix that by
propagating error returned to command return value.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
Changes:
 - v2: Add changelog text.

 arch/arm/include/asm/arch-am33xx/sys_proto.h |  2 +-
 arch/arm/include/asm/arch-omap3/sys_proto.h  |  2 +-
 arch/arm/mach-omap2/omap3/board.c| 32 
 3 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/arch/arm/include/asm/arch-am33xx/sys_proto.h 
b/arch/arm/include/asm/arch-am33xx/sys_proto.h
index 0c5792baa8..903398fe8f 100644
--- a/arch/arm/include/asm/arch-am33xx/sys_proto.h
+++ b/arch/arm/include/asm/arch-am33xx/sys_proto.h
@@ -29,7 +29,7 @@ void sdelay(unsigned long);
 void gpmc_init(void);
 void enable_gpmc_cs_config(const u32 *gpmc_config, const struct gpmc_cs *cs, 
u32 base,
u32 size);
-void omap_nand_switch_ecc(uint32_t, uint32_t);
+int omap_nand_switch_ecc(uint32_t, uint32_t);
 
 void set_uart_mux_conf(void);
 void set_mux_conf_regs(void);
diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h 
b/arch/arm/include/asm/arch-omap3/sys_proto.h
index 5979340ac8..ddcb559928 100644
--- a/arch/arm/include/asm/arch-omap3/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
@@ -68,7 +68,7 @@ u32 wait_on_value(u32, u32, void *, u32);
 void cancel_out(u32 *num, u32 *den, u32 den_limit);
 void sdelay(unsigned long);
 void make_cs1_contiguous(void);
-void omap_nand_switch_ecc(uint32_t, uint32_t);
+int omap_nand_switch_ecc(uint32_t, uint32_t);
 void power_init_r(void);
 void do_omap3_emu_romcode_call(u32 service_id, u32 parameters);
 void omap3_set_aux_cr_secure(u32 acr);
diff --git a/arch/arm/mach-omap2/omap3/board.c 
b/arch/arm/mach-omap2/omap3/board.c
index 5f5597772b..a727226563 100644
--- a/arch/arm/mach-omap2/omap3/board.c
+++ b/arch/arm/mach-omap2/omap3/board.c
@@ -269,38 +269,34 @@ void abort(void)
  */
 static int do_switch_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const 
argv[])
 {
+   int hw, strength = 1;
+
if (argc < 2 || argc > 3)
goto usage;
 
if (strncmp(argv[1], "hw", 2) == 0) {
-   if (argc == 2) {
-   omap_nand_switch_ecc(1, 1);
-   } else {
-   if (strncmp(argv[2], "hamming", 7) == 0)
-   omap_nand_switch_ecc(1, 1);
-   else if (strncmp(argv[2], "bch8", 4) == 0)
-   omap_nand_switch_ecc(1, 8);
+   hw = 1;
+   if (argc == 3) {
+   if (strncmp(argv[2], "bch8", 4) == 0)
+   strength = 8;
else if (strncmp(argv[2], "bch16", 5) == 0)
-   omap_nand_switch_ecc(1, 16);
-   else
+   strength = 16;
+   else if (strncmp(argv[2], "hamming", 7) != 0)
goto usage;
}
} else if (strncmp(argv[1], "sw", 2) == 0) {
-   if (argc == 2) {
-   omap_nand_switch_ecc(0, 1);
-   } else {
-   if (strncmp(argv[2], "hamming", 7) == 0)
-   omap_nand_switch_ecc(0, 1);
-   else if (strncmp(argv[2], "bch8", 4) == 0)
-   omap_nand_switch_ecc(0, 8);
-   else
+   hw = 0;
+   if (argc == 3) {
+   if (strncmp(argv[2], "bch8", 4) == 0)
+   strength = 8;
+   else if (strncmp(argv[2], "hamming", 7) != 0)
goto usage;
}
} else {
goto usage;
}
 
-   return 0;
+   return -omap_nand_switch_ecc(hw, strength);
 
 usage:
printf ("Usage: nandecc %s\n", cmdtp->usage);
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] arm: OMAP2+: nandecc: propagate error to command return status

2017-02-20 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 arch/arm/include/asm/arch-am33xx/sys_proto.h |  2 +-
 arch/arm/include/asm/arch-omap3/sys_proto.h  |  2 +-
 arch/arm/mach-omap2/omap3/board.c| 32 
 3 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/arch/arm/include/asm/arch-am33xx/sys_proto.h 
b/arch/arm/include/asm/arch-am33xx/sys_proto.h
index 0c5792baa8..903398fe8f 100644
--- a/arch/arm/include/asm/arch-am33xx/sys_proto.h
+++ b/arch/arm/include/asm/arch-am33xx/sys_proto.h
@@ -29,7 +29,7 @@ void sdelay(unsigned long);
 void gpmc_init(void);
 void enable_gpmc_cs_config(const u32 *gpmc_config, const struct gpmc_cs *cs, 
u32 base,
u32 size);
-void omap_nand_switch_ecc(uint32_t, uint32_t);
+int omap_nand_switch_ecc(uint32_t, uint32_t);
 
 void set_uart_mux_conf(void);
 void set_mux_conf_regs(void);
diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h 
b/arch/arm/include/asm/arch-omap3/sys_proto.h
index 5979340ac8..ddcb559928 100644
--- a/arch/arm/include/asm/arch-omap3/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
@@ -68,7 +68,7 @@ u32 wait_on_value(u32, u32, void *, u32);
 void cancel_out(u32 *num, u32 *den, u32 den_limit);
 void sdelay(unsigned long);
 void make_cs1_contiguous(void);
-void omap_nand_switch_ecc(uint32_t, uint32_t);
+int omap_nand_switch_ecc(uint32_t, uint32_t);
 void power_init_r(void);
 void do_omap3_emu_romcode_call(u32 service_id, u32 parameters);
 void omap3_set_aux_cr_secure(u32 acr);
diff --git a/arch/arm/mach-omap2/omap3/board.c 
b/arch/arm/mach-omap2/omap3/board.c
index 5f5597772b..a727226563 100644
--- a/arch/arm/mach-omap2/omap3/board.c
+++ b/arch/arm/mach-omap2/omap3/board.c
@@ -269,38 +269,34 @@ void abort(void)
  */
 static int do_switch_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const 
argv[])
 {
+   int hw, strength = 1;
+
if (argc < 2 || argc > 3)
goto usage;
 
if (strncmp(argv[1], "hw", 2) == 0) {
-   if (argc == 2) {
-   omap_nand_switch_ecc(1, 1);
-   } else {
-   if (strncmp(argv[2], "hamming", 7) == 0)
-   omap_nand_switch_ecc(1, 1);
-   else if (strncmp(argv[2], "bch8", 4) == 0)
-   omap_nand_switch_ecc(1, 8);
+   hw = 1;
+   if (argc == 3) {
+   if (strncmp(argv[2], "bch8", 4) == 0)
+   strength = 8;
else if (strncmp(argv[2], "bch16", 5) == 0)
-   omap_nand_switch_ecc(1, 16);
-   else
+   strength = 16;
+   else if (strncmp(argv[2], "hamming", 7) != 0)
goto usage;
}
} else if (strncmp(argv[1], "sw", 2) == 0) {
-   if (argc == 2) {
-   omap_nand_switch_ecc(0, 1);
-   } else {
-   if (strncmp(argv[2], "hamming", 7) == 0)
-   omap_nand_switch_ecc(0, 1);
-   else if (strncmp(argv[2], "bch8", 4) == 0)
-   omap_nand_switch_ecc(0, 8);
-   else
+   hw = 0;
+   if (argc == 3) {
+   if (strncmp(argv[2], "bch8", 4) == 0)
+   strength = 8;
+   else if (strncmp(argv[2], "hamming", 7) != 0)
goto usage;
}
} else {
goto usage;
}
 
-   return 0;
+   return -omap_nand_switch_ecc(hw, strength);
 
 usage:
printf ("Usage: nandecc %s\n", cmdtp->usage);
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/2] igep00x0: fixup FDT according to detected flash type

2017-02-20 Thread Ladislav Michl
Leave only detected flash type enabled in FTD as otherwise GPMC CS is
claimed (and never freed) by Linux, causing 'concurent' flash type
not to be probed.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 board/isee/igep00x0/igep00x0.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 65cc7dfdec..e032f313a6 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -214,6 +214,20 @@ void board_mmc_power_init(void)
 #endif
 
 #ifdef CONFIG_OF_BOARD_SETUP
+static int ft_enable_by_compatible(void *blob, char *compat, int enable)
+{
+   int off = fdt_node_offset_by_compatible(blob, -1, compat);
+   if (off < 0)
+   return off;
+
+   if (enable)
+   fdt_status_okay(blob, off);
+   else
+   fdt_status_disabled(blob, off);
+
+   return 0;
+}
+
 int ft_board_setup(void *blob, bd_t *bd)
 {
 #ifdef CONFIG_FDT_FIXUP_PARTITIONS
@@ -224,6 +238,11 @@ int ft_board_setup(void *blob, bd_t *bd)
 
fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
 #endif
+   ft_enable_by_compatible(blob, "ti,omap2-nand",
+   gpmc_cs0_flash == MTD_DEV_TYPE_NAND);
+   ft_enable_by_compatible(blob, "ti,omap2-onenand",
+   gpmc_cs0_flash == MTD_DEV_TYPE_ONENAND);
+
return 0;
 }
 #endif
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/2] igep00x0: disable environment

2017-02-20 Thread Ladislav Michl
ISEE's U-Boot and Linux are using 1bit ECC scheme, while we
switched to 8bit ECC to fullfill flash specification requirements.
However when trying to run U-Boot on board with 1bit ECC'd data
on flash, UBI code takes several minutes to pass scan as reading
of every block ends with ecc error (which is also printed on
console).
So, until proper solution is developed, disable environment
alltogether.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 include/configs/omap3_igep00x0.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/omap3_igep00x0.h b/include/configs/omap3_igep00x0.h
index ac0df3e08b..70d337e6f1 100644
--- a/include/configs/omap3_igep00x0.h
+++ b/include/configs/omap3_igep00x0.h
@@ -140,7 +140,7 @@
 #define CONFIG_SPL_UBI_INFO_ADDR   0x8808
 
 /* environment organization */
-#define CONFIG_ENV_IS_IN_UBI   1
+#define CONFIG_ENV_IS_NOWHERE  1
 #define CONFIG_ENV_UBI_PART"UBI"
 #define CONFIG_ENV_UBI_VOLUME  "config"
 #define CONFIG_ENV_UBI_VOLUME_REDUND   "config_r"
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/6] ARM: OMAP2+: define _image_binary_end to fix SPL_OF_CONTROL

2017-02-08 Thread Ladislav Michl
On Wed, Feb 08, 2017 at 06:03:33PM +0530, Lokesh Vutla wrote:
> To make SPL_OF_CONTROL work on OAP2+ SoCs, _image_binary_end must be
OMAP2+  ---> ^

Just a nitpick, but helps grepping for changes in git log.

Thank you,
ladis

> defined in the linker script along with CONFIG_SPL_SEPARATE_BSS.
> 
> Signed-off-by: Lokesh Vutla 
> ---
>  arch/arm/mach-omap2/u-boot-spl.lds | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm/mach-omap2/u-boot-spl.lds 
> b/arch/arm/mach-omap2/u-boot-spl.lds
> index 8fec715ca5..e9da2a9dd1 100644
> --- a/arch/arm/mach-omap2/u-boot-spl.lds
> +++ b/arch/arm/mach-omap2/u-boot-spl.lds
> @@ -46,6 +46,8 @@ SECTIONS
>   *(.__end)
>   }
>  
> + _image_binary_end = .;
> +
>   .bss :
>   {
>   . = ALIGN(4);
> -- 
> 2.11.0
> 
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] cmd: fdt: memory fixup

2017-01-31 Thread Ladislav Michl
On Tue, Jan 31, 2017 at 03:35:51AM +0100, Ladislav Michl wrote:
> To get Falcon mode working with zImage is currently non trivial as zImages
> do not fit into U-Boot's image concept too well. Fortunately at least for
> ARM boards it seems getting memory node right is quite sufficient.
> What about changing 'fdt memory' command to update memory node according to
> detected memory layout when called without parameters?

Looked at other (!arm) platforms implementation... Does not seem like good
idea anymore. What about adding posibility to call ft_arch_fixup? Other
ideas?

Thank you,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC] cmd: fdt: memory fixup

2017-01-30 Thread Ladislav Michl
To get Falcon mode working with zImage is currently non trivial as zImages
do not fit into U-Boot's image concept too well. Fortunately at least for
ARM boards it seems getting memory node right is quite sufficient.
What about changing 'fdt memory' command to update memory node according to
detected memory layout when called without parameters?

ladis

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 95dd673b95..e08296d51c 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -517,11 +517,23 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 * memory command
 */
} else if (strncmp(argv[1], "me", 2) == 0) {
-   uint64_t addr, size;
int err;
-   addr = simple_strtoull(argv[2], NULL, 16);
-   size = simple_strtoull(argv[3], NULL, 16);
-   err = fdt_fixup_memory(working_fdt, addr, size);
+   if (argc < 4) {
+   int i;
+   uint64_t start[CONFIG_NR_DRAM_BANKS];
+   uint64_t size[CONFIG_NR_DRAM_BANKS];
+   bd_t *bd = gd->bd;
+   for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+   start[i] = bd->bi_dram[i].start;
+   size[i] = bd->bi_dram[i].size;
+   }
+   err = fdt_fixup_memory_banks(working_fdt, start, size,
+   CONFIG_NR_DRAM_BANKS);
+   } else {
+   uint64_t addr = simple_strtoull(argv[2], NULL, 16);
+   uint64_t size = simple_strtoull(argv[3], NULL, 16);
+   err = fdt_fixup_memory(working_fdt, addr, size);
+   }
if (err < 0)
return err;
 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/2] arm: omap3: Update cpuinfo for DM3730, DM3725, AM3715, and AM3703

2017-01-20 Thread Ladislav Michl
From: Adam Ford <aford...@gmail.com>

The check for OMAP3630/3730 only checks for 800MHz 3630/3730, but
anything else is lumped into 36XX/37XX with an assumed 1GHz speed.

Based on the DM3730 TRM bit 9 shows the MPU Frequency (800MHz/1GHZ).
This also adds the ability to distinguish between the DM3730, DM3725,
AM3715, and AM3703 and correctly display their maximum speed.

Signed-off-by: Adam Ford <aford...@gmail.com>
Tested-by: Ladislav Michl <la...@linux-mips.org>
---
 Changes:
 - v2: rebase on top of spelling fix
   add Tested-by line
   indent header file

 arch/arm/include/asm/arch-omap3/omap.h |  8 +++
 arch/arm/mach-omap2/omap3/sys_info.c   | 42 --
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/arch-omap3/omap.h 
b/arch/arm/include/asm/arch-omap3/omap.h
index 417ff895f1..91d73c2f1d 100644
--- a/arch/arm/include/asm/arch-omap3/omap.h
+++ b/arch/arm/include/asm/arch-omap3/omap.h
@@ -230,6 +230,14 @@ struct gpio {
 #define AM3517 0x1c00
 
 #define OMAP3730   0x0c00
+#define OMAP3725   0x4c00
+#define AM3715 0x1c00
+#define AM3703 0x5c00
+
+#define OMAP3730_1GHZ  0x0e00
+#define OMAP3725_1GHZ  0x4e00
+#define AM3715_1GHZ0x1e00
+#define AM3703_1GHZ0x5e00
 
 /*
  * ROM code API related flags
diff --git a/arch/arm/mach-omap2/omap3/sys_info.c 
b/arch/arm/mach-omap2/omap3/sys_info.c
index 1f8b5ad77c..7e6c2633f9 100644
--- a/arch/arm/mach-omap2/omap3/sys_info.c
+++ b/arch/arm/mach-omap2/omap3/sys_info.c
@@ -295,16 +295,54 @@ int print_cpuinfo (void)
max_clk = "600 MHz";
break;
case CPU_OMAP36XX:
-   cpu_family_s = "OMAP";
switch (get_cpu_type()) {
+   case AM3703:
+   cpu_family_s = "AM";
+   cpu_s = "3703";
+   max_clk = "800 MHz";
+   break;
+   case AM3703_1GHZ:
+   cpu_family_s = "AM";
+   cpu_s = "3703";
+   max_clk = "1 GHz";
+   break;
+   case AM3715:
+   cpu_family_s = "AM";
+   cpu_s = "3715";
+   max_clk = "800 MHz";
+   break;
+   case AM3715_1GHZ:
+   cpu_family_s = "AM";
+   cpu_s = "3715";
+   max_clk = "1 GHz";
+   break;
+   case OMAP3725:
+   cpu_family_s = "OMAP";
+   cpu_s = "3625/3725";
+   max_clk = "800 MHz";
+   break;
+   case OMAP3725_1GHZ:
+   cpu_family_s = "OMAP";
+   cpu_s = "3625/3725";
+   max_clk = "1 GHz";
+   break;
case OMAP3730:
+   cpu_family_s = "OMAP";
cpu_s = "3630/3730";
+   max_clk = "800 MHz";
+   break;
+   case OMAP3730_1GHZ:
+   cpu_family_s = "OMAP";
+   cpu_s = "3630/3730";
+   max_clk = "1 GHz";
break;
default:
+   cpu_family_s = "OMAP/AM";
cpu_s = "36XX/37XX";
+   max_clk = "1 GHz";
break;
}
-   max_clk = "1 GHz";
+
break;
default:
cpu_family_s = "OMAP";
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/2] arm: omap3: Fix cpuinfo frequency spelling

2017-01-20 Thread Ladislav Michl
Frequency is measured in Hz.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 arch/arm/mach-omap2/omap3/sys_info.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/omap3/sys_info.c 
b/arch/arm/mach-omap2/omap3/sys_info.c
index 6818fab253..1f8b5ad77c 100644
--- a/arch/arm/mach-omap2/omap3/sys_info.c
+++ b/arch/arm/mach-omap2/omap3/sys_info.c
@@ -292,7 +292,7 @@ int print_cpuinfo (void)
cpu_s = "35XX";
break;
}
-   max_clk = "600 Mhz";
+   max_clk = "600 MHz";
break;
case CPU_OMAP36XX:
cpu_family_s = "OMAP";
@@ -304,12 +304,12 @@ int print_cpuinfo (void)
cpu_s = "36XX/37XX";
break;
}
-   max_clk = "1 Ghz";
+   max_clk = "1 GHz";
break;
default:
cpu_family_s = "OMAP";
cpu_s = "35XX";
-   max_clk = "600 Mhz";
+   max_clk = "600 MHz";
}
 
switch (get_device_type()) {
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] cmd: ubi: allow '-' to specify maximum volume size

2017-01-19 Thread Ladislav Michl
Currently maximum volume size can be specified only if no other
arguments are used. Use '-' placeholder as volume size to allow
maximum volume size to be specified together with volume id and
type.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 cmd/ubi.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index 7d0d7e7a80..efc43ffde9 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -600,7 +600,8 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
}
/* E.g., create volume size */
if (argc == 4) {
-   size = simple_strtoull(argv[3], NULL, 16);
+   if (argv[3][0] != '-')
+   size = simple_strtoull(argv[3], NULL, 16);
argc--;
}
/* Use maximum available size */
@@ -691,8 +692,9 @@ U_BOOT_CMD(
" - Display volume and ubi layout information\n"
"ubi check volumename"
" - check if volumename exists\n"
-   "ubi create[vol] volume [size] [type] [id]"
-   " - create volume name with size\n"
+   "ubi create[vol] volume [size] [type] [id]\n"
+   " - create volume name with size ('-' for maximum"
+   " available size)\n"
"ubi write[vol] address volume size"
" - Write volume from address with size\n"
"ubi write.part address volume size [fullsize]\n"
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2] igep00x0: enable CONFIG_FDT_FIXUP_PARTITIONS

2017-01-15 Thread Ladislav Michl
SPL partition size depends on sector size and we want kernel to use
the same layout, so let U-Boot modify FDT accordingly.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
Changes:
 -v2 rebased against current git as it no longer applies

 board/isee/igep00x0/igep00x0.c | 17 +
 configs/igep0020_defconfig |  2 ++
 configs/igep0030_defconfig |  2 ++
 configs/igep0032_defconfig |  2 ++
 4 files changed, 23 insertions(+)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 669f3dde7f..ae7959b1eb 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "igep00x0.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -210,6 +212,21 @@ void board_mmc_power_init(void)
 }
 #endif
 
+#ifdef CONFIG_OF_BOARD_SETUP
+int ft_board_setup(void *blob, bd_t *bd)
+{
+#ifdef CONFIG_FDT_FIXUP_PARTITIONS
+   static struct node_info nodes[] = {
+   { "ti,omap2-nand", MTD_DEV_TYPE_NAND, },
+   { "ti,omap2-onenand", MTD_DEV_TYPE_ONENAND, },
+   };
+
+   fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
+#endif
+   return 0;
+}
+#endif
+
 void set_fdt(void)
 {
switch (gd->bd->bi_arch_number) {
diff --git a/configs/igep0020_defconfig b/configs/igep0020_defconfig
index 0dd244efc9..50bb4acf57 100644
--- a/configs/igep0020_defconfig
+++ b/configs/igep0020_defconfig
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020"
 CONFIG_BOOTDELAY=3
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
@@ -36,3 +37,4 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
+CONFIG_FDT_FIXUP_PARTITIONS=y
diff --git a/configs/igep0030_defconfig b/configs/igep0030_defconfig
index 72fb874b87..42bd6fc3dc 100644
--- a/configs/igep0030_defconfig
+++ b/configs/igep0030_defconfig
@@ -3,6 +3,7 @@ CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
 CONFIG_DISTRO_DEFAULTS=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030"
 CONFIG_BOOTDELAY=3
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
@@ -28,3 +29,4 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
+CONFIG_FDT_FIXUP_PARTITIONS=y
diff --git a/configs/igep0032_defconfig b/configs/igep0032_defconfig
index 1318e5b2d0..01adb2032b 100644
--- a/configs/igep0032_defconfig
+++ b/configs/igep0032_defconfig
@@ -3,6 +3,7 @@ CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
 CONFIG_DISTRO_DEFAULTS=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTDELAY=3
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
@@ -27,3 +28,4 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
+CONFIG_FDT_FIXUP_PARTITIONS=y
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] serial, ns16550: bugfix: ns16550 fifo not enabled

2017-01-10 Thread Ladislav Michl
Hi Heiko,

On Tue, Jan 10, 2017 at 08:08:51AM +0100, Heiko Schocher wrote:
> commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
> breaks u-boot commandline working with long commands
> sending to the board.
> 
> Since the above patch, you have to setup the fcr register.
> 
> For board/archs which enable OF_PLATDATA, the new field
> fcr in struct ns16550_platdata is not filled with a
> default value ...
> 
> This leads in not setting up the uarts fifo, which ends
> in problems, when you send long commands to u-boots
> commandline.
> 
> Detected this issue with automated tbot tests on am335x
> based shc board.
> 
> The error does not popup, if you type commands. You need
> to copy a long command to u-boots commandshell
> (or send a long command with tbot)
> 
> Possible boards/plattforms with problems:
> ./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
> ./arch/arm/mach-tegra/board.c
> ./board/isee/igep00x0/igep00x0.c
> ./board/overo/overo.c
> ./board/quipos/cairo/cairo.c
> ./board/logicpd/omap3som/omap3logic.c
> ./board/logicpd/zoom1/zoom1.c
> ./board/timll/devkit8000/devkit8000.c
> ./board/lg/sniper/sniper.c
> ./board/ti/beagle/beagle.c
> ./drivers/serial/serial_rockchip.c

Quick test shows igep00x0 also suffers from this issue.
Are you going to collect fixes and apply them as one patch or
shall I sent a separate patch?

Anyway, here's fix for igep00x0:

Signed-off-by: Ladislav Michl <la...@linux-mips.org>

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index ae7959b1eb..8bea199a44 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -32,7 +32,8 @@ DECLARE_GLOBAL_DATA_PTR;
 static const struct ns16550_platdata igep_serial = {
.base = OMAP34XX_UART3,
.reg_shift = 2,
-   .clock = V_NS16550_CLK
+   .clock = V_NS16550_CLK,
+   .fcr = UART_FCR_FIFO_EN | UART_FCR_RXSR | UART_FCR_TXSR,
 };
 
 U_BOOT_DEVICE(igep_uart) = {

> This patch fixes only:
> ./arch/arm/mach-omap2/am33xx/board.c
> 
> Signed-off-by: Heiko Schocher <h...@denx.de>
> ---
> 
>  arch/arm/mach-omap2/am33xx/board.c | 23 +--
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/am33xx/board.c 
> b/arch/arm/mach-omap2/am33xx/board.c
> index 581c0ab..a0ce62c 100644
> --- a/arch/arm/mach-omap2/am33xx/board.c
> +++ b/arch/arm/mach-omap2/am33xx/board.c
> @@ -39,15 +39,26 @@
>  DECLARE_GLOBAL_DATA_PTR;
>  
>  #if !CONFIG_IS_ENABLED(OF_CONTROL)
> +/* Clear & enable FIFOs */
> +#define UART_FCRVAL (UART_FCR_FIFO_EN |  \
> +  UART_FCR_RXSR |\
> +  UART_FCR_TXSR)
> +
>  static const struct ns16550_platdata am33xx_serial[] = {
> - { .base = CONFIG_SYS_NS16550_COM1, .reg_shift = 2, .clock = 
> CONFIG_SYS_NS16550_CLK },
> + { .base = CONFIG_SYS_NS16550_COM1, .reg_shift = 2,
> +   .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCRVAL },
>  # ifdef CONFIG_SYS_NS16550_COM2
> - { .base = CONFIG_SYS_NS16550_COM2, .reg_shift = 2, .clock = 
> CONFIG_SYS_NS16550_CLK },
> + { .base = CONFIG_SYS_NS16550_COM2, .reg_shift = 2,
> +   .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCRVAL },
>  #  ifdef CONFIG_SYS_NS16550_COM3
> - { .base = CONFIG_SYS_NS16550_COM3, .reg_shift = 2, .clock = 
> CONFIG_SYS_NS16550_CLK },
> - { .base = CONFIG_SYS_NS16550_COM4, .reg_shift = 2, .clock = 
> CONFIG_SYS_NS16550_CLK },
> - { .base = CONFIG_SYS_NS16550_COM5, .reg_shift = 2, .clock = 
> CONFIG_SYS_NS16550_CLK },
> - { .base = CONFIG_SYS_NS16550_COM6, .reg_shift = 2, .clock = 
> CONFIG_SYS_NS16550_CLK },
> + { .base = CONFIG_SYS_NS16550_COM3, .reg_shift = 2,
> +   .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCRVAL },
> + { .base = CONFIG_SYS_NS16550_COM4, .reg_shift = 2,
> +   .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCRVAL },
> + { .base = CONFIG_SYS_NS16550_COM5, .reg_shift = 2,
> +   .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCRVAL },
> + { .base = CONFIG_SYS_NS16550_COM6, .reg_shift = 2,
> +   .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCRVAL },
>  #  endif
>  # endif
>  };
> -- 
> 2.7.4
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] lib: gitignore *.elf and *.so generated by efi_loader

2017-01-09 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 lib/efi_loader/.gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/efi_loader/.gitignore b/lib/efi_loader/.gitignore
new file mode 100644
index 00..634a600f84
--- /dev/null
+++ b/lib/efi_loader/.gitignore
@@ -0,0 +1,2 @@
+*.efi
+*.so
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] igep00x0: Remove IGEP0020_NAND BOARD entry from MAINTAINERS

2017-01-09 Thread Ladislav Michl
Boards with NAND and OneNAND are supported by single configuration,
thus remove now obsolete IGEP0020_NAND BOARD entry.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 board/isee/igep00x0/MAINTAINERS | 6 --
 1 file changed, 6 deletions(-)

diff --git a/board/isee/igep00x0/MAINTAINERS b/board/isee/igep00x0/MAINTAINERS
index d355c46882..720ef2aa69 100644
--- a/board/isee/igep00x0/MAINTAINERS
+++ b/board/isee/igep00x0/MAINTAINERS
@@ -6,9 +6,3 @@ F:  include/configs/omap3_igep00x0.h
 F: configs/igep0020_defconfig
 F: configs/igep0030_defconfig
 F: configs/igep0032_defconfig
-
-IGEP0020_NAND BOARD
-#M:-
-S: Maintained
-F: configs/igep0020_nand_defconfig
-F: configs/igep0030_nand_defconfig
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] igep00x0: enable CONFIG_FDT_FIXUP_PARTITIONS

2017-01-09 Thread Ladislav Michl
SPL partition size depends on sector size and we want kernel to use
the same layout, so let U-Boot modify FDT accordingly.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 board/isee/igep00x0/igep00x0.c | 17 +
 configs/igep0020_defconfig |  2 ++
 configs/igep0030_defconfig |  2 ++
 configs/igep0032_defconfig |  2 ++
 4 files changed, 23 insertions(+)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 669f3dde7f..ae7959b1eb 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "igep00x0.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -210,6 +212,21 @@ void board_mmc_power_init(void)
 }
 #endif
 
+#ifdef CONFIG_OF_BOARD_SETUP
+int ft_board_setup(void *blob, bd_t *bd)
+{
+#ifdef CONFIG_FDT_FIXUP_PARTITIONS
+   static struct node_info nodes[] = {
+   { "ti,omap2-nand", MTD_DEV_TYPE_NAND, },
+   { "ti,omap2-onenand", MTD_DEV_TYPE_ONENAND, },
+   };
+
+   fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
+#endif
+   return 0;
+}
+#endif
+
 void set_fdt(void)
 {
switch (gd->bd->bi_arch_number) {
diff --git a/configs/igep0020_defconfig b/configs/igep0020_defconfig
index c25b6b85a3..9e99c0c10a 100644
--- a/configs/igep0020_defconfig
+++ b/configs/igep0020_defconfig
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020"
 CONFIG_BOOTDELAY=3
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
@@ -35,3 +36,4 @@ CONFIG_CMD_UBI=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
+CONFIG_FDT_FIXUP_PARTITIONS=y
diff --git a/configs/igep0030_defconfig b/configs/igep0030_defconfig
index 925c42fd44..3478d4dd74 100644
--- a/configs/igep0030_defconfig
+++ b/configs/igep0030_defconfig
@@ -3,6 +3,7 @@ CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
 CONFIG_DISTRO_DEFAULTS=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030"
 CONFIG_BOOTDELAY=3
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
@@ -27,3 +28,4 @@ CONFIG_CMD_UBI=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
+CONFIG_FDT_FIXUP_PARTITIONS=y
diff --git a/configs/igep0032_defconfig b/configs/igep0032_defconfig
index dad8dfaf0c..c72fb58e3b 100644
--- a/configs/igep0032_defconfig
+++ b/configs/igep0032_defconfig
@@ -3,6 +3,7 @@ CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
 CONFIG_DISTRO_DEFAULTS=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0032"
 CONFIG_BOOTDELAY=3
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
@@ -27,3 +28,4 @@ CONFIG_CMD_UBI=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
+CONFIG_FDT_FIXUP_PARTITIONS=y
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] common: fdt_support: Remove check for mtdparts in fdt_fixup_mtdparts

2017-01-09 Thread Ladislav Michl
fdt_fixup_mtdparts currently does nothing when partitin info is
runtime generated or compiled-in defaults are used.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 common/fdt_support.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index c9f7019e38..a57a5759e4 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -903,14 +903,9 @@ void fdt_fixup_mtdparts(void *blob, void *node_info, int 
node_info_size)
 {
struct node_info *ni = node_info;
struct mtd_device *dev;
-   char *parts;
int i, idx;
int noff;
 
-   parts = getenv("mtdparts");
-   if (!parts)
-   return;
-
if (mtdparts_init() != 0)
return;
 
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] omap-gpmc: use SECTOR_BYTES instead of hardcoded value

2017-01-09 Thread Ladislav Michl
Replace hardcoded value with defined constant SECTOR_BYTES.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 drivers/mtd/nand/omap_gpmc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c
index d1e1bdda28..f4f0de395b 100644
--- a/drivers/mtd/nand/omap_gpmc.c
+++ b/drivers/mtd/nand/omap_gpmc.c
@@ -656,14 +656,14 @@ static int omap_correct_data_bch_sw(struct mtd_info *mtd, 
u_char *data,
struct nand_chip *chip = mtd_to_nand(mtd);
struct omap_nand_info *info = nand_get_controller_data(chip);
 
-   count = decode_bch(info->control, NULL, 512, read_ecc, calc_ecc,
-   NULL, errloc);
+   count = decode_bch(info->control, NULL, SECTOR_BYTES,
+   read_ecc, calc_ecc, NULL, errloc);
if (count > 0) {
/* correct errors */
for (i = 0; i < count; i++) {
/* correct data only, not ecc bytes */
-   if (errloc[i] < 8*512)
-   data[errloc[i]/8] ^= 1 << (errloc[i] & 7);
+   if (errloc[i] < SECTOR_BYTES << 3)
+   data[errloc[i] >> 3] ^= 1 << (errloc[i] & 7);
debug("corrected bitflip %u\n", errloc[i]);
 #ifdef DEBUG
puts("read_ecc: ");
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: omap3_logic: Add scripts to program NAND

2017-01-04 Thread Ladislav Michl
On Wed, Jan 04, 2017 at 12:06:48PM -0600, Adam Ford wrote:
> This patch adds scripts to burn the kernel, U-Boot, and MLO to NAND.
> The RootFS needs to be added and programmed from the kernel for now.

Do you really need this all in environment? What about making this u-boot
script and store it on mmc together with MLO, u-boot.img, etc...

ladis

> Signed-off-by: Adam Ford 
> 
> diff --git a/include/configs/omap3_logic.h b/include/configs/omap3_logic.h
> index 90faaf4..632885a 100644
> --- a/include/configs/omap3_logic.h
> +++ b/include/configs/omap3_logic.h
> @@ -227,7 +227,33 @@
>   "nandbootz=run nandbootcommon; "\
>   "bootz ${loadaddr} - ${fdtaddr}\0"\
>   "nandboot=run nandbootcommon; "\
> - "bootm ${loadaddr} - ${fdtaddr}\0"\
> + "bootm ${loadaddr} - ${fdtaddr}\0" \
> + "nandburnkernel=echo 'Burn Image to NAND...'; "\
> + "nand unlock;" \
> + "echo 'Erasing Kernel partition...';" \
> + "nand erase.part kernel; "\
> + "run loadimage; " \
> + "echo 'Flashing Kernel partition...';" \
> + "nand write ${loadaddr} kernel ${filesize}; \0" \
> + "nandburnzimage=setenv bootfile zImage; run nandburnkernel\0"\
> + "nandburnuimage=setenv bootfile uImage; run nandburnkernel\0"\
> + "nandburnuboot=echo 'Burn U-Boot to NAND...'; " \
> + "nand unlock;" \
> + "echo 'Erasing U-Boot partition...';" \
> + "nand erase.part u-boot; "\
> + "mmc rescan; " \
> + "load mmc ${mmcdev} ${loadaddr} u-boot.img; " \
> + "echo 'Flashing U-Boot partition...';" \
> + "nand write ${loadaddr} u-boot ${filesize};\0" \
> + "nandburnmlo=echo 'Burn MLO to NAND...'; " \
> + "nand unlock;" \
> + "echo 'Erasing MLO partition...';" \
> + "nand erase.part MLO; "\
> + "mmc rescan; " \
> + "load mmc ${mmcdev} ${loadaddr} MLO; " \
> + "nandecc hw;" \
> + "echo 'Flashing MLO partition...';" \
> + "nand write ${loadaddr} MLO ${filesize};\0"
>  
>  #define CONFIG_BOOTCOMMAND \
>   "run autoboot"
> -- 
> 2.7.4
> 
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] tools: mkimage: Call fclose in error path

2016-12-20 Thread Ladislav Michl
Hi Michal,

On Tue, Dec 20, 2016 at 09:58:31AM +0100, Michal Simek wrote:
> This patch is fixing missing fclose() calls
> in error patch introduced by:
> "tools: mkimage: Use fstat instead of stat to avoid malicious hacks"
> (sha1: ebe0f53f48e8f9ecc823e533a85b05c13638c350)
> 
> Reported-by: Coverity (CID: 155064, 155065)
> Signed-off-by: Michal Simek <michal.si...@xilinx.com>
> ---
> 
>  tools/zynqimage.c   | 8 ++--
>  tools/zynqmpimage.c | 8 ++--
>  2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/zynqimage.c b/tools/zynqimage.c
> index b47132b02a60..021d2d3fc91f 100644
> --- a/tools/zynqimage.c
> +++ b/tools/zynqimage.c
> @@ -239,11 +239,15 @@ static void zynqimage_parse_initparams(struct 
> zynq_header *zynqhdr,
>   }
>  
>   err = fstat(fileno(fp), _stat);
> - if (err)
> + if (err) {
> + fclose(fp);
>   return;
> + }
>  
> - if (!S_ISREG(path_stat.st_mode))
> + if (!S_ISREG(path_stat.st_mode)) {
> + fclose(fp);
>   return;
> + }
>  
>   do {
>   r = fscanf(fp, "%x %x", , );
> diff --git a/tools/zynqmpimage.c b/tools/zynqmpimage.c
> index 60d8ed23b4a1..0c9a3daddd6a 100644
> --- a/tools/zynqmpimage.c
> +++ b/tools/zynqmpimage.c
> @@ -251,11 +251,15 @@ static void zynqmpimage_parse_initparams(struct 
> zynqmp_header *zynqhdr,
>   }
>  
>   err = fstat(fileno(fp), _stat);
> - if (err)
> + if (err) {
> + fclose(fp);
>   return;
> + }
>  
> - if (!S_ISREG(path_stat.st_mode))
> + if (!S_ISREG(path_stat.st_mode)) {
> + fclose(fp);
>   return;
> + }
>  
>   do {
>   r = fscanf(fp, "%x %x", , );

what about something like this?

Best regards,
ladis (bored waiting for the lunch ;-))

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
diff --git a/tools/zynqimage.c b/tools/zynqimage.c
index b47132b02a..026e99c00b 100644
--- a/tools/zynqimage.c
+++ b/tools/zynqimage.c
@@ -228,7 +228,7 @@ static void zynqimage_parse_initparams(struct zynq_header 
*zynqhdr,
FILE *fp;
struct zynq_reginit reginit;
unsigned int reg_count = 0;
-   int r, err;
+   int r;
struct stat path_stat;
 
/* Expect a table of register-value pairs, e.g. "0x12345678 0x4321" */
@@ -238,12 +238,10 @@ static void zynqimage_parse_initparams(struct zynq_header 
*zynqhdr,
exit(1);
}
 
-   err = fstat(fileno(fp), _stat);
-   if (err)
-   return;
-
-   if (!S_ISREG(path_stat.st_mode))
+   if (fstat(fileno(fp), _stat) || !S_ISREG(path_stat.st_mode)) {
+   fclose(fp);
return;
+   }
 
do {
r = fscanf(fp, "%x %x", , );
diff --git a/tools/zynqmpimage.c b/tools/zynqmpimage.c
index 60d8ed23b4..767e93a2ab 100644
--- a/tools/zynqmpimage.c
+++ b/tools/zynqmpimage.c
@@ -240,7 +240,7 @@ static void zynqmpimage_parse_initparams(struct 
zynqmp_header *zynqhdr,
FILE *fp;
struct zynqmp_reginit reginit;
unsigned int reg_count = 0;
-   int r, err;
+   int r;
struct stat path_stat;
 
/* Expect a table of register-value pairs, e.g. "0x12345678 0x4321" */
@@ -250,12 +250,10 @@ static void zynqmpimage_parse_initparams(struct 
zynqmp_header *zynqhdr,
exit(1);
}
 
-   err = fstat(fileno(fp), _stat);
-   if (err)
-   return;
-
-   if (!S_ISREG(path_stat.st_mode))
+   if (fstat(fileno(fp), _stat) || !S_ISREG(path_stat.st_mode)) {
+   fclose(fp);
return;
+   }
 
do {
r = fscanf(fp, "%x %x", , );
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [Resend RFC PATCH v1 0/3] GPT over MTD

2016-11-25 Thread Ladislav Michl
Hi Patrick,

On Thu, Nov 24, 2016 at 02:14:22PM +, Patrick DELAUNAY wrote:
> Hi Ladislav,
> 
> > 
> > Hi,
> > 
> > On Tue, Nov 22, 2016 at 02:24:39PM +0100, Patrick Delaunay wrote:
> > >
> > > I have a request to support GPT over MTD to be able to have dynamic
> > > MTD informations without u-Boot
> > environment(CONFIG_ENV_IS_NOWHERE is a
> > > other requirement of my project).
> > 
> > I'm just curious, could you provide some reasoning, why this is a
> > requirement?
> 
> One platform requirement is to boot from any supported device (NOR, NAND, 
> eMMC, ...) with the same boot chain (including SPL and U-Boot) WITHOUT 
> recompilation and only by changing the hardware boot configuration (OTP).

Ok, the very same requirement here...

> So I can't use environment (CONFIG_ENV_IS_NOWHERE), because I don't know 
> which device is expected for tests (boot from NAND,  eMMC, NOR).
> PS: I agree that in final client board, the u-boot will be optimized and 
> u-boot env could be used.
> 
> For  block device(eMMC), it is not an issue
>   -  first boot stage uses the GPT header in block device,  to found, 
> load and execute SPL and U-Boot.
> -  U-Boot Generic Distro feature is used in U-Boot to load 
> kernel (found extlinux.conf in bootable partition)
> 
> For Flash Device, the offset for SPL and U-Boot can't be determined easily by 
> first boot stage.

Offset of SPL? Isn't that determined by boot ROM code? So you actually
cannot do much with that. What hardware are you planning to use your
solution with?

> It is why GPT is re-used to save MTD partition offset without hardcoded part 
> in first boot stage or in SPL (and without U-Boot env).
> => partition offsets are determined dynamically

As SPL offset is given and only U-Boot offset can be changed (is that
assumption right?), you can store U-Boot in UBI volume.

> So it should be easier to have the same behavior, based on GPT, for every 
> boot device, block or flash.
> And the same tools (programmer) or command in U-Boot will use to update/read 
> every device, based on GPT header. 

I have to admit, that UBI solution would not let you use the same
scenario for eMMC and NAND in terms of U-Boot commands used, but otherwise
it is more robust.

> > > The idea is to use the GPT header to save partitioning information
> > > directly in flash device (NOR or NAND), then the MTD variables are
> > > rebuild from these GPT partitions and can be used by DISTRO to search
> > bootable binary.
> > 
> > Ok, so you stored partitioning information on flash... That seems to be some
> > kind of limited environment saved :-)
> 
> Yes I use standard GPT to save partitioning information, to save offset of 
> MTD partition in flash device.
> So it is limited environment :-) but limited to partition offset and it can 
> be discovered dynamically by first boot stage.

First boot stage is SPL here?

> > > I make a first prototyping for this request but I want ask you if this
> > > feature is acceptable for u-boot and if this patches, after some
> > > update and cleanups, would be merged in u-boot mainline.
> > > Do you see already some blocking points ?
> > 
> > Is there any reason why you cannot use UBI?
> 
> UBIFS will be used in U-Boot not in previous boot stage

Just to make it completely clear: UBIFS is a filesystem used
on the top of UBI volume...

> Kernel and device tree will be found in a UBIFS volume

...so kernel and DTB are stored as a files inside UBIFS
(filesystem)?

Both SPL and U-Boot can load images from UBI volumes. Also you'll get
Falcon mode for free :-)

Best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [Resend RFC PATCH v1 0/3] GPT over MTD

2016-11-22 Thread Ladislav Michl
Hi,

On Tue, Nov 22, 2016 at 02:24:39PM +0100, Patrick Delaunay wrote:
> 
> I have a request to support GPT over MTD to be able to have dynamic
> MTD informations without u-Boot environment(CONFIG_ENV_IS_NOWHERE
> is a other requirement of my project).

I'm just curious, could you provide some reasoning, why this is a requirement?

> The idea is to use the GPT header to save partitioning information directly
> in flash device (NOR or NAND), then the MTD variables are rebuild from
> these GPT partitions and can be used by DISTRO to search bootable binary.

Ok, so you stored partitioning information on flash... That seems to be some
kind of limited environment saved :-)

> I make a first prototyping for this request but I want ask you if this
> feature is acceptable for u-boot and if this patches, after some update
> and cleanups, would be merged in u-boot mainline.
> Do you see already some blocking points ?

Is there any reason why you cannot use UBI?

> - added code is under a new CONFIG : CONFIG_EFI_PARTITION_MTD
> - for implementation details, see doc/README.gpt.mtd
> 
> TODO:
> - split patch between core impact (disk/part_efi.c)
>   and command update
> - full support for modified command
>   (today I limit the support for the command used by DISTRO macro)
> - DISTRO macro update for automatic boot on GPT bootable partition
>   found in MTD devices

Best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCHv2 1/3] igep00x0: disable CONFIG_DISPLAY_BOARDINFO

2016-11-04 Thread Ladislav Michl
On Fri, Nov 04, 2016 at 12:42:57PM -0300, Javier Martinez Canillas wrote:
> Hello Ladis,
> 
> On 11/04/2016 08:55 AM, Ladislav Michl wrote:
> > As a single U-Boot binary can now run on various board modifications,
> > drop CONFIG_DISPLAY_BOARDINFO as it prints flash memory information
> > too early to give us chance to easily detect it. Also saves few bytes
> > as a bonus.
> > 
> > Signed-off-by: Ladislav Michl <la...@linux-mips.org>
> > ---
> 
> I tried to test your patches on latest u-boot master (sha-1 dd93a8e9e688)
> but my IGEPv2 board fails to boot and prints in an infinite loop following:
> 
> "ecc unrecoverable error"

This comes from SPL, right? That would imply you boot from NAND...

> This is not related to your patches though, since I've the same issue
> without your patches applied.
> 
> Did you see this issue? u-boot works with previous v2016.09 release so
> this is a newly introduced regression.

No, otherwise I would fix that. Care to send complete boot log if there is
any?

> Unfortunately I don't have time to dig deeper on this but I may give a
> try next week.

Thank you,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCHv2 3/3] igep00x0: add Hynix timings

2016-11-04 Thread Ladislav Michl
Tested on IGEPv2 with Micron MT29F4G16ABBDA3W and
Hynix H27S4G6F2DKA-BM

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
Changes in v2:
 - None

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 71688cc..669f3dd 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -84,10 +84,22 @@ void get_board_mem_timings(struct board_sdrc_timings 
*timings)
int mfr, id, err = identify_nand_chip(, );
 
timings->mr = MICRON_V_MR_165;
-   if (!err && mfr == NAND_MFR_MICRON) {
-   timings->mcfg = MICRON_V_MCFG_200(256 << 20);
-   timings->ctrla = MICRON_V_ACTIMA_200;
-   timings->ctrlb = MICRON_V_ACTIMB_200;
+   if (!err) {
+   switch (mfr) {
+   case NAND_MFR_HYNIX:
+   timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
+   timings->ctrla = HYNIX_V_ACTIMA_200;
+   timings->ctrlb = HYNIX_V_ACTIMB_200;
+   break;
+   case NAND_MFR_MICRON:
+   timings->mcfg = MICRON_V_MCFG_200(256 << 20);
+   timings->ctrla = MICRON_V_ACTIMA_200;
+   timings->ctrlb = MICRON_V_ACTIMB_200;
+   break;
+   default:
+   /* Should not happen... */
+   break;
+   }
timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
} else {
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCHv2 2/3] igep00x0: consolidate defconfigs

2016-11-04 Thread Ladislav Michl
Defconfigs should remain the same except CONFIG_SYS_EXTRA_OPTIONS.
Drop NAND specific defconfig as flash type is runtime detected.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
Changes in v2:
 - fix screwup caused by mismerge
 - update to current git

diff --git a/configs/igep0030_defconfig b/configs/igep0030_defconfig
index 75f731d..edc7520 100644
--- a/configs/igep0030_defconfig
+++ b/configs/igep0030_defconfig
@@ -2,7 +2,8 @@ CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030,BOOT_ONENAND"
+CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030"
+CONFIG_BOOTDELAY=3
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_VERSION_VARIABLE=y
@@ -31,5 +32,6 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
+CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/igep0030_nand_defconfig b/configs/igep0030_nand_defconfig
deleted file mode 100644
index dda1a7b..000
--- a/configs/igep0030_nand_defconfig
+++ /dev/null
@@ -1,34 +0,0 @@
-CONFIG_ARM=y
-CONFIG_OMAP34XX=y
-# CONFIG_SPL_EXT_SUPPORT is not set
-CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030,BOOT_NAND"
-CONFIG_SYS_CONSOLE_IS_IN_ENV=y
-CONFIG_SYS_CONSOLE_INFO_QUIET=y
-CONFIG_VERSION_VARIABLE=y
-CONFIG_SPL=y
-CONFIG_SPL_MTD_SUPPORT=y
-CONFIG_SPL_ONENAND_SUPPORT=y
-CONFIG_SPL_OS_BOOT=y
-CONFIG_HUSH_PARSER=y
-CONFIG_CMD_BOOTZ=y
-# CONFIG_CMD_IMLS is not set
-CONFIG_CMD_ASKENV=y
-# CONFIG_CMD_FLASH is not set
-CONFIG_CMD_MMC=y
-CONFIG_CMD_SPI=y
-CONFIG_CMD_I2C=y
-CONFIG_CMD_GPIO=y
-# CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_MII=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
-CONFIG_CMD_UBI=y
-CONFIG_SYS_NS16550=y
-CONFIG_OF_LIBFDT=y
diff --git a/configs/igep0032_defconfig b/configs/igep0032_defconfig
index 1819995..81d05d4 100644
--- a/configs/igep0032_defconfig
+++ b/configs/igep0032_defconfig
@@ -2,7 +2,8 @@ CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0032,BOOT_ONENAND"
+CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0032"
+CONFIG_BOOTDELAY=3
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_VERSION_VARIABLE=y
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCHv2 1/3] igep00x0: disable CONFIG_DISPLAY_BOARDINFO

2016-11-04 Thread Ladislav Michl
As a single U-Boot binary can now run on various board modifications,
drop CONFIG_DISPLAY_BOARDINFO as it prints flash memory information
too early to give us chance to easily detect it. Also saves few bytes
as a bonus.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
Changes in v2:
  - update to current git (uses Kconfig)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 808955e..71688cc 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -27,24 +27,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-const omap3_sysinfo sysinfo = {
-   DDR_STACKED,
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
-   "IGEPv2",
-#endif
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
-   "IGEP COM MODULE/ELECTRON",
-#endif
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0032)
-   "IGEP COM PROTON",
-#endif
-#if defined(CONFIG_ENV_IS_IN_ONENAND)
-   "ONENAND",
-#else
-   "NAND",
-#endif
-};
-
 static const struct ns16550_platdata igep_serial = {
.base = OMAP34XX_UART3,
.reg_shift = 2,
diff --git a/configs/igep0020_defconfig b/configs/igep0020_defconfig
index 9c247d7..c25b6b8 100644
--- a/configs/igep0020_defconfig
+++ b/configs/igep0020_defconfig
@@ -7,6 +7,7 @@ CONFIG_BOOTDELAY=3
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_VERSION_VARIABLE=y
+# CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_ONENAND_SUPPORT=y
diff --git a/configs/igep0030_defconfig b/configs/igep0030_defconfig
index 1312ddb..75f731d 100644
--- a/configs/igep0030_defconfig
+++ b/configs/igep0030_defconfig
@@ -6,6 +6,7 @@ 
CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030,BOOT_ONENAND"
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_VERSION_VARIABLE=y
+# CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_ONENAND_SUPPORT=y
diff --git a/configs/igep0032_defconfig b/configs/igep0032_defconfig
index 37e46b0..1819995 100644
--- a/configs/igep0032_defconfig
+++ b/configs/igep0032_defconfig
@@ -6,6 +6,7 @@ 
CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0032,BOOT_ONENAND"
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_VERSION_VARIABLE=y
+# CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SPL=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_ONENAND_SUPPORT=y
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] igep00x0: disable CONFIG_DISPLAY_BOARDINFO

2016-11-04 Thread Ladislav Michl
Hi Enric,

On Tue, Sep 20, 2016 at 05:41:02PM +0200, Enric Balletbo Serra wrote:
[snip]
> I must NACK for now these series, meanwhile I don't find time to look
> at this deeply. I think this will break lots of things. For example,
> will this u-boot boot a non-device tree based kernel without breaking
> things? I don't think so, It's right that non-device tree kernels are
> old but these are still used in lots of IGEP boards and I don't want
> to break this, for now.
> 
> Please give me some time to look at this and think in all the use cases.

Any chance you'll find time to look at this? I'm sending updated patch serie
as a reply to this email. I do not think it breaks anything and I'll provide
fix if you prove me wrong. Please note, that without "igep00x0: add Hynix
timings" patch some boards are unable to boot. My bad, of course, as I hadn't
all board variants on my table at the time writing runtime flash detection
support.

Thank you,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Help with spl: zImage support in Falcon mode

2016-10-19 Thread Ladislav Michl
On Wed, Oct 19, 2016 at 04:52:50PM +, Diego Dorta wrote: 
[snip]
> Yes, all these commands works fine with uImage. I understood now.
> But, how do I do to use zImage instead of uImage?

I've never used spl export as I have fdt prepared during build time.
Looking at source, zImage support is not implemented.

> Is there any document that I can learn the steps?

See common/bootm.c:boot_get_kernel. You'll need a bit of hacking
to support zImage.

ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Help with spl: zImage support in Falcon mode

2016-10-19 Thread Ladislav Michl
Hi,

On Tue, Oct 18, 2016 at 04:36:54PM +, Diego Dorta wrote:
> Hi all,
> 
> According to commit log: 
> 
> commit 431889d6ad9a39846636716478d504aa7ff976fc
> Author: Ladislav Michl <la...@linux-mips.org>
> Date:   Tue Jul 12 20:28:14 2016 +0200
> 
> spl: zImage support in Falcon mode
> 
> Other payload than uImage is currently considered to be raw U-Boot
> image. Check also for zImage in Falcon mode.
> 
> Signed-off-by: Ladislav Michl <la...@linux-mips.org>
> Reviewed-by: Heiko Schocher <h...@denx.de>
> 
> Already include at U-Boot 2016.09.01.
> 
> I was trying to apply Falcon mode on i.MX6 Sabre SD using zImage instead of 
> uImage.
> After the steps below I got an error trying to "spl export":
> 
> # dhcp ${fdt_addr} imx6q-sabresd.dtb
> 
> # dhcp ${loadaddr} zImage
> 
> # mmc write ${loadaddr} 0x1000 0x4000

Where did you get those numbers above?

> # setenv bootargs 'console=ttymxc0,115200 root=/dev/mmcblk1p1 rootfstype=ext4 
> rootwait quiet rw'
> 
> # spl export fdt ${loadaddr} - ${fdt_addr}
[garbage deleted]
> ERROR: can't get kernel image!
>XIP Invalid Image ... OK
> ERROR: booting os 'Invalid OS' (0) is not supported
> ERROR: booting os 'Invalid OS' (0) is not supported
> ERROR: booting os 'Invalid OS' (0) is not supported
> ERROR prep subcommand failed!
> Subcommand failed
> 
> I can't understand this error. Does anybody know how to fix it?

Does it work with uImage? Also patch you pointed at above has nothing to
do with u-boot itself, but SPL which does not seem to get involved.

> Regards,
> Diego

Best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] igep00x0: consolidate defconfigs

2016-09-21 Thread Ladislav Michl
On Wed, Sep 21, 2016 at 10:02:47AM -0400, Tom Rini wrote:
> On Wed, Sep 21, 2016 at 03:46:08PM +0200, Enric Balletbo Serra wrote:
> > 2016-09-21 14:51 GMT+02:00 Tom Rini <tr...@konsulko.com>:
> > > On Wed, Sep 21, 2016 at 01:46:51PM +0200, Enric Balletbo Serra wrote:
> > >> Hi,
> > >>
> > >> 2016-09-21 11:39 GMT+02:00 Ladislav Michl <la...@linux-mips.org>:
> > >> > On Tue, Sep 20, 2016 at 08:26:36PM -0400, Tom Rini wrote:
> > >> >> On Wed, Sep 21, 2016 at 01:52:21AM +0200, Ladislav Michl wrote:
> > >> >> > On Tue, Sep 20, 2016 at 07:45:14PM -0400, Tom Rini wrote:
> > >> > [snip]
> > >> >> > > But why do we even need to set MACH_TYPE these days?
> > >> >> >
> > >> >> > That's only needed for non-device tree kernel boot. These boards 
> > >> >> > run mostly
> > >> >> > vendor provided kernels based on TI 2.6.32 or 2.6.37 kernel tree 
> > >> >> > with
> > >> >> > daughter boards specific patches on top of it. Enric is concerned 
> > >> >> > not
> > >> >> > to break that support, so I'm trying to keep it.
> > >> >>
> > >> >> OK, if you're still supporting stuff that old then yes, it makes 
> > >> >> sense.
> > >> >> And we can't get this right at run time?
> > >> >
> > >> > I asked several times, if there's a way to differentiate those boards
> > >> > (0020, 0030 and 0032) at runtime, but never get an answer. Of course
> > >> > I'd like to see one U-Boot binary to rule them all, but I'm out of clue
> > >> > there. Few people added to Cc...
> > >>
> > >> There is no way to differentiate those boards at runtime, those boards
> > >> are completely different platforms that share same processor, like
> > >> BeagleBoard or OMAP3 Overos . For me what you're trying to do is join
> > >> different platforms with the same processor, so why not join
> > >> BeagleBone, Overos, and IGEPs and all other OMAP3 based platforms?
> > >
> > > Note that the different beagleboard used GPIOs to tell which platform is
> > > which :)
> > 
> > Yes, but if I'm not mistaken you have different GPIOs for different
> > hardware revisions of Beagleboard. For IGEPv2 this is also true, you
> > have different GPIOs for different hardware revisions of IGEPv2. But
> > we're talking about join two completely different boards, i.e join
> > IGEPv2 (IGEP0020) with IGEP COM PROTON (IGEP0032) would be similar to
> > join Beagleboard with OMAP3 OVERO COM.

Well, on igep platform MACH_TYPE is currently used for:
- mux configuration (with IGEP COM PROTON strangely left out)
- status LED configuration
I wouldn't say these are completely different boards, at lest from
software perspective.

> > OTOH I think the Ladis work trying to join the IGEP boards is really
> > interesting, just want to look deeper :)
> 
> Right.  To play the thought exercise out a bit farther, if all of the
> detection methods for Beagleboard would _not_ cause an OVERO COM to be
> identified as a Beagle, we could move on to trying to see what rev overo
> we're on, or just assume it's that if all else fails.  Is anything like
> that possible with these IGEP boards?

I certainly didn't mean any board detection method hardware designer had in
mind while drawing schemantics, but more likely something like this:
IGEPv2 is using GPIO_94 to drive WIFI_PD_n and there's 100K pullup, so
setting this pin as input and reading its value could give some clue.
Now question is if there's such a combination of gpios used over this board
family, which provides reliable detection method. Unfortunately, I have only
IGEPv2 and public schemantics is available only for this board.

> > >> > Another approach might be to configure U-Boot using FDT and translate
> > >> > that information into MACH_TYPE and kernel command line to support
> > >> > non-device tree enabled kernels.
> 
> And to be clear over on this part, if we can tell at run time (or normal
> build time even, without directly passing MACH_TYPE=..) we should set
> that then instead of SYS_EXTRA_OPTIONS.

ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] igep00x0: consolidate defconfigs

2016-09-21 Thread Ladislav Michl
On Tue, Sep 20, 2016 at 08:26:36PM -0400, Tom Rini wrote:
> On Wed, Sep 21, 2016 at 01:52:21AM +0200, Ladislav Michl wrote:
> > On Tue, Sep 20, 2016 at 07:45:14PM -0400, Tom Rini wrote:
[snip]
> > > But why do we even need to set MACH_TYPE these days?
> > 
> > That's only needed for non-device tree kernel boot. These boards run mostly
> > vendor provided kernels based on TI 2.6.32 or 2.6.37 kernel tree with
> > daughter boards specific patches on top of it. Enric is concerned not
> > to break that support, so I'm trying to keep it.
> 
> OK, if you're still supporting stuff that old then yes, it makes sense.
> And we can't get this right at run time?

I asked several times, if there's a way to differentiate those boards
(0020, 0030 and 0032) at runtime, but never get an answer. Of course
I'd like to see one U-Boot binary to rule them all, but I'm out of clue
there. Few people added to Cc...

Another approach might be to configure U-Boot using FDT and translate
that information into MACH_TYPE and kernel command line to support
non-device tree enabled kernels.

ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] igep00x0: consolidate defconfigs

2016-09-20 Thread Ladislav Michl
On Tue, Sep 20, 2016 at 07:45:14PM -0400, Tom Rini wrote:
> On Wed, Sep 21, 2016 at 12:44:17AM +0200, Ladislav Michl wrote:
[snip]
> > Gah... I have to screw it up while resolving conflicts with upstream 
> > changes.
> > Obviously MACH_TYPE has to remain the same. Will do v2. I'm sorry for that.
> 
> But why do we even need to set MACH_TYPE these days?

That's only needed for non-device tree kernel boot. These boards run mostly
vendor provided kernels based on TI 2.6.32 or 2.6.37 kernel tree with
daughter boards specific patches on top of it. Enric is concerned not
to break that support, so I'm trying to keep it.

ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] igep00x0: disable CONFIG_DISPLAY_BOARDINFO

2016-09-20 Thread Ladislav Michl
Hi Enric,

On Tue, Sep 20, 2016 at 05:41:02PM +0200, Enric Balletbo Serra wrote:
> Hi Ladis,
> 
> I must NACK for now these series, meanwhile I don't find time to look
> at this deeply. I think this will break lots of things. For example,
> will this u-boot boot a non-device tree based kernel without breaking
> things? I don't think so, It's right that non-device tree kernels are
> old but these are still used in lots of IGEP boards and I don't want
> to break this, for now.
> 
> Please give me some time to look at this and think in all the use cases.

I'm sorry for screwing up MACH_TYPE, here's an updated version. I haven't
tested with non-device tree kernels, but I can't see how these patches
could break it. Please let me know, if you find any other objections.

Best regards,
ladis

8< ---
>From 2f7c58982e7e58dae092e2db60385cb2448b9d31 Mon Sep 17 00:00:00 2001
From: Ladislav Michl <la...@linux-mips.org>
Date: Tue, 9 Aug 2016 12:46:07 +0200
Subject: [PATCH v2] igep00x0: consolidate defconfigs

Update defconfigs and drop NAND specific defconfig as flash type
is runtime detected.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
Changelog:
v2: Restore patch to its original state before merge conflict screwup

 configs/igep0030_defconfig  |  5 -
 configs/igep0030_nand_defconfig | 30 --
 configs/igep0032_defconfig  |  4 +++-
 3 files changed, 7 insertions(+), 32 deletions(-)
 delete mode 100644 configs/igep0030_nand_defconfig

diff --git a/configs/igep0030_defconfig b/configs/igep0030_defconfig
index 66371d6..66a45cb 100644
--- a/configs/igep0030_defconfig
+++ b/configs/igep0030_defconfig
@@ -2,7 +2,9 @@ CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030,BOOT_ONENAND"
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030"
+CONFIG_BOOTDELAY=3
 CONFIG_VERSION_VARIABLE=y
 CONFIG_SPL=y
 CONFIG_SPL_MTD_SUPPORT=y
@@ -26,5 +28,6 @@ CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
+CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/igep0030_nand_defconfig b/configs/igep0030_nand_defconfig
deleted file mode 100644
index f63bcac..000
--- a/configs/igep0030_nand_defconfig
+++ /dev/null
@@ -1,30 +0,0 @@
-CONFIG_ARM=y
-CONFIG_OMAP34XX=y
-# CONFIG_SPL_EXT_SUPPORT is not set
-CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030,BOOT_NAND"
-CONFIG_VERSION_VARIABLE=y
-CONFIG_SPL=y
-CONFIG_SPL_MTD_SUPPORT=y
-CONFIG_SPL_ONENAND_SUPPORT=y
-CONFIG_HUSH_PARSER=y
-CONFIG_CMD_BOOTZ=y
-# CONFIG_CMD_IMLS is not set
-CONFIG_CMD_ASKENV=y
-# CONFIG_CMD_FLASH is not set
-CONFIG_CMD_MMC=y
-CONFIG_CMD_SPI=y
-CONFIG_CMD_I2C=y
-CONFIG_CMD_GPIO=y
-# CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_MII=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
-CONFIG_SYS_NS16550=y
-CONFIG_OF_LIBFDT=y
diff --git a/configs/igep0032_defconfig b/configs/igep0032_defconfig
index 991d9d7..9e397bb 100644
--- a/configs/igep0032_defconfig
+++ b/configs/igep0032_defconfig
@@ -2,7 +2,9 @@ CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0032,BOOT_ONENAND"
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0032"
+CONFIG_BOOTDELAY=3
 CONFIG_VERSION_VARIABLE=y
 CONFIG_SPL=y
 CONFIG_SPL_MTD_SUPPORT=y
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] igep00x0: consolidate defconfigs

2016-09-20 Thread Ladislav Michl
On Tue, Sep 20, 2016 at 08:52:21AM -0400, Tom Rini wrote:
> On Tue, Sep 20, 2016 at 11:07:57AM +0200, Ladislav Michl wrote:
> > Update defconfigs and drop NAND specific defconfig as flash type
> > is runtime detected.
> > 
> > Signed-off-by: Ladislav Michl <la...@linux-mips.org>
> > ---
> >  configs/igep0030_defconfig  |  5 -
> >  configs/igep0030_nand_defconfig | 30 --
> >  configs/igep0032_defconfig  |  4 +++-
> >  3 files changed, 7 insertions(+), 32 deletions(-)
> >  delete mode 100644 configs/igep0030_nand_defconfig
> > 
> > diff --git a/configs/igep0030_defconfig b/configs/igep0030_defconfig
> > index 66371d6..eb7a28f 100644
> > --- a/configs/igep0030_defconfig
> > +++ b/configs/igep0030_defconfig
> > @@ -2,7 +2,9 @@ CONFIG_ARM=y
> >  CONFIG_OMAP34XX=y
> >  # CONFIG_SPL_EXT_SUPPORT is not set
> >  CONFIG_TARGET_OMAP3_IGEP00X0=y
> > -CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030,BOOT_ONENAND"
> > +CONFIG_SPL=y
> > +CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020"
> 
> Since you're even changing MACH_TYPE here, do we really need to be
> setting this?  For both defconfigs, even.  Thanks!

Gah... I have to screw it up while resolving conflicts with upstream changes.
Obviously MACH_TYPE has to remain the same. Will do v2. I'm sorry for that.

ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/3] igep00x0: add Hynix timings

2016-09-20 Thread Ladislav Michl
Tested on IGEPv2 with Micron MT29F4G16ABBDA3W and
Hynix H27S4G6F2DKA-BM

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 board/isee/igep00x0/igep00x0.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 71688cc..669f3dd 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -84,10 +84,22 @@ void get_board_mem_timings(struct board_sdrc_timings 
*timings)
int mfr, id, err = identify_nand_chip(, );
 
timings->mr = MICRON_V_MR_165;
-   if (!err && mfr == NAND_MFR_MICRON) {
-   timings->mcfg = MICRON_V_MCFG_200(256 << 20);
-   timings->ctrla = MICRON_V_ACTIMA_200;
-   timings->ctrlb = MICRON_V_ACTIMB_200;
+   if (!err) {
+   switch (mfr) {
+   case NAND_MFR_HYNIX:
+   timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
+   timings->ctrla = HYNIX_V_ACTIMA_200;
+   timings->ctrlb = HYNIX_V_ACTIMB_200;
+   break;
+   case NAND_MFR_MICRON:
+   timings->mcfg = MICRON_V_MCFG_200(256 << 20);
+   timings->ctrla = MICRON_V_ACTIMA_200;
+   timings->ctrlb = MICRON_V_ACTIMB_200;
+   break;
+   default:
+   /* Should not happen... */
+   break;
+   }
timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
} else {
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/3] igep00x0: consolidate defconfigs

2016-09-20 Thread Ladislav Michl
Update defconfigs and drop NAND specific defconfig as flash type
is runtime detected.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 configs/igep0030_defconfig  |  5 -
 configs/igep0030_nand_defconfig | 30 --
 configs/igep0032_defconfig  |  4 +++-
 3 files changed, 7 insertions(+), 32 deletions(-)
 delete mode 100644 configs/igep0030_nand_defconfig

diff --git a/configs/igep0030_defconfig b/configs/igep0030_defconfig
index 66371d6..eb7a28f 100644
--- a/configs/igep0030_defconfig
+++ b/configs/igep0030_defconfig
@@ -2,7 +2,9 @@ CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030,BOOT_ONENAND"
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020"
+CONFIG_BOOTDELAY=3
 CONFIG_VERSION_VARIABLE=y
 CONFIG_SPL=y
 CONFIG_SPL_MTD_SUPPORT=y
@@ -26,5 +28,6 @@ CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
+CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/igep0030_nand_defconfig b/configs/igep0030_nand_defconfig
deleted file mode 100644
index f63bcac..000
--- a/configs/igep0030_nand_defconfig
+++ /dev/null
@@ -1,30 +0,0 @@
-CONFIG_ARM=y
-CONFIG_OMAP34XX=y
-# CONFIG_SPL_EXT_SUPPORT is not set
-CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0030,BOOT_NAND"
-CONFIG_VERSION_VARIABLE=y
-CONFIG_SPL=y
-CONFIG_SPL_MTD_SUPPORT=y
-CONFIG_SPL_ONENAND_SUPPORT=y
-CONFIG_HUSH_PARSER=y
-CONFIG_CMD_BOOTZ=y
-# CONFIG_CMD_IMLS is not set
-CONFIG_CMD_ASKENV=y
-# CONFIG_CMD_FLASH is not set
-CONFIG_CMD_MMC=y
-CONFIG_CMD_SPI=y
-CONFIG_CMD_I2C=y
-CONFIG_CMD_GPIO=y
-# CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_MII=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
-CONFIG_SYS_NS16550=y
-CONFIG_OF_LIBFDT=y
diff --git a/configs/igep0032_defconfig b/configs/igep0032_defconfig
index 991d9d7..eb7a28f 100644
--- a/configs/igep0032_defconfig
+++ b/configs/igep0032_defconfig
@@ -2,7 +2,9 @@ CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0032,BOOT_ONENAND"
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020"
+CONFIG_BOOTDELAY=3
 CONFIG_VERSION_VARIABLE=y
 CONFIG_SPL=y
 CONFIG_SPL_MTD_SUPPORT=y
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/3] igep00x0: disable CONFIG_DISPLAY_BOARDINFO

2016-09-20 Thread Ladislav Michl
As a single U-Boot binary can now run on various board modifications,
drop CONFIG_DISPLAY_BOARDINFO as there's no known way to distinguish
between them. Also saves few bytes as a bonus.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 board/isee/igep00x0/igep00x0.c   | 18 --
 include/configs/omap3_igep00x0.h |  5 +
 2 files changed, 1 insertion(+), 22 deletions(-)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 808955e..71688cc 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -27,24 +27,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-const omap3_sysinfo sysinfo = {
-   DDR_STACKED,
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
-   "IGEPv2",
-#endif
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
-   "IGEP COM MODULE/ELECTRON",
-#endif
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0032)
-   "IGEP COM PROTON",
-#endif
-#if defined(CONFIG_ENV_IS_IN_ONENAND)
-   "ONENAND",
-#else
-   "NAND",
-#endif
-};
-
 static const struct ns16550_platdata igep_serial = {
.base = OMAP34XX_UART3,
.reg_shift = 2,
diff --git a/include/configs/omap3_igep00x0.h b/include/configs/omap3_igep00x0.h
index 1f30710..2ae9737 100644
--- a/include/configs/omap3_igep00x0.h
+++ b/include/configs/omap3_igep00x0.h
@@ -23,11 +23,8 @@
 #undef CONFIG_SPL_TEXT_BASE
 #define CONFIG_SPL_TEXT_BASE   0x4020
 
-/*
- * Display CPU and Board information
- */
+/* Display CPU information */
 #define CONFIG_DISPLAY_CPUINFO 1
-#define CONFIG_DISPLAY_BOARDINFO   1
 
 #define CONFIG_MISC_INIT_R
 
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] cmd: ubi: add option to specify volume id

2016-09-20 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
diff --git a/cmd/ubi.c b/cmd/ubi.c
index 4a92d84..b66bc62 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -162,7 +162,7 @@ bad:
return err;
 }
 
-static int ubi_create_vol(char *volume, int64_t size, int dynamic)
+static int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id)
 {
struct ubi_mkvol_req req;
int err;
@@ -172,7 +172,7 @@ static int ubi_create_vol(char *volume, int64_t size, int 
dynamic)
else
req.vol_type = UBI_STATIC_VOLUME;
 
-   req.vol_id = UBI_VOL_NUM_AUTO;
+   req.vol_id = vol_id;
req.alignment = 1;
req.bytes = size;
 
@@ -577,10 +577,17 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
if (strncmp(argv[1], "create", 6) == 0) {
int dynamic = 1;/* default: dynamic volume */
+   int id = UBI_VOL_NUM_AUTO;
 
/* Use maximum available size */
size = 0;
 
+   /* E.g., create volume size type vol_id */
+   if (argc == 6) {
+   id = simple_strtoull(argv[5], NULL, 16);
+   argc--;
+   }
+
/* E.g., create volume size type */
if (argc == 5) {
if (strncmp(argv[4], "s", 1) == 0)
@@ -603,7 +610,7 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
}
/* E.g., create volume */
if (argc == 3)
-   return ubi_create_vol(argv[2], size, dynamic);
+   return ubi_create_vol(argv[2], size, dynamic, id);
}
 
if (strncmp(argv[1], "remove", 6) == 0) {
@@ -684,7 +691,7 @@ U_BOOT_CMD(
" - Display volume and ubi layout information\n"
"ubi check volumename"
" - check if volumename exists\n"
-   "ubi create[vol] volume [size] [type]"
+   "ubi create[vol] volume [size] [type] [id]"
" - create volume name with size\n"
"ubi write[vol] address volume size"
" - Write volume from address with size\n"
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] cmd/onenand.c: block align warning

2016-09-20 Thread Ladislav Michl
An attempt to write non block aligned data fails silently, add warning and
set result.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
 cmd/onenand.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/cmd/onenand.c b/cmd/onenand.c
index feab01a..090f835 100644
--- a/cmd/onenand.c
+++ b/cmd/onenand.c
@@ -139,6 +139,12 @@ static int onenand_block_write(loff_t to, size_t len,
size_t _retlen = 0;
int ret;
 
+   if ((to & (mtd->writesize - 1)) != 0) {
+   printf("Attempt to write non block-aligned data\n");
+   *retlen = 0;
+   return 1;
+   }
+
if (to == next_ofs) {
next_ofs = to + len;
to += skip_ofs;
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] TI: Rework SRAM definitions and maximums

2016-09-06 Thread Ladislav Michl
On Sat, Aug 27, 2016 at 05:29:44PM +0530, Lokesh Vutla wrote:
> On Friday 26 August 2016 11:00 PM, Tom Rini wrote:
> > On all TI platforms the ROM defines a "downloaded image" area at or near
> > the start of SRAM which is followed by a reserved area.  As it is at
> > best bad form and at worst possibly harmful in corner cases to write in
> > this reserved area, we stop doing that by adding in the define
> > NON_SECURE_SRAM_IMG_END to say where the end of the downloaded image
> > area is and make SRAM_SCRATCH_SPACE_ADDR be one kilobyte before this.
> > At current we define the end of scratch space at 0x228 bytes past the
> > start of scratch space this this gives us a lot of room to grow.  As
> > these scratch uses are non-optional today, all targets are modified to
> > respect this boundary.
> > 
> > Tested on OMAP4 Pandaboard, OMAP3 Beagle xM
> 
> Verified on AM437x-GP EVM.
> 
> Tested-by: Lokesh Vutla <lokeshvu...@ti.com>
> Acked-by: Lokesh Vutla <lokeshvu...@ti.com>

Verified on IGEPv2.

Tested-by: Ladislav Michl <la...@linux-mips.org>

Also note, that this patch and CONFIG_SPL_SYS_MALLOC_SIMPLE is needed
for sucessfull build (with gcc-5.4.0), otherwise compilation fails with:
arm-v7a-linux-gnueabi-ld.bfd: u-boot-spl section `.data' will not fit in region 
`.sram'
arm-v7a-linux-gnueabi-ld.bfd: region `.sram' overflowed by 264 bytes
Just enabling CONFIG_SPL_SYS_MALLOC_SIMPLE without this patch makes
malloc in fat loading code fail and thus causes boot failure.

Best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/2] ARM: Move SYS_CACHELINE_SIZE over to Kconfig

2016-08-22 Thread Ladislav Michl
On Mon, Aug 22, 2016 at 08:22:17AM -0400, Tom Rini wrote:
[snip]
> diff --git a/include/configs/cm_t3517.h b/include/configs/cm_t3517.h
> index ea9983bc7d43..a89ccb73b178 100644
> --- a/include/configs/cm_t3517.h
> +++ b/include/configs/cm_t3517.h
> @@ -10,8 +10,6 @@
>  #ifndef __CONFIG_H
>  #define __CONFIG_H
>  
> -#define CONFIG_SYS_CACHELINE_SIZE64
> -
>  /*
>   * High Level Configuration Options
>   */
> @@ -30,7 +28,6 @@
>   * Although the default iss 64, we still define it
>   * to be on the safe side once the default is changed.
>   */

That comment above probably looses sense with define removed...

> -#define CONFIG_SYS_CACHELINE_SIZE64
>  
>  #define CONFIG_EMIF4 /* The chip has EMIF4 controller */
>  

regards,
ladis

PS. Tested on OMAP3 IGEPv2 and TAM-3517 boards
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Disable command at runtime

2016-08-01 Thread Ladislav Michl
On Fri, Jul 29, 2016 at 05:57:58PM +0200, Petr Kubiz??ák wrote:
> Ok, I get it, then I'll have to deal with two defconfigs and reflashing for
> now.
> 
> Anyway, at least a user feedback / feature request... I believe it would be
> useful for many users to have a manufacturing mode, which they would escape
> permanently by e.g. executing some command. In normal mode, some commands
> would be disabled. Logic would be similar to CONFIG_OVERWRITE_ETHADDR_ONCE.

You can still download U-Boot standalone application implementing whatever
you need to do in production, so in "normal mode" your manufacturing secrets
are not even part of your product.

Best regards,
ladis
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 25/26] igep00x0: generate default mtdparts according NAND chip used

2016-07-12 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c   | 18 ++
 include/configs/omap3_igep00x0.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index b36709c..4c52b36 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -232,6 +233,23 @@ int misc_init_r(void)
return 0;
 }
 
+void board_mtdparts_default(const char **mtdids, const char **mtdparts)
+{
+   struct mtd_info *mtd = get_mtd_device(NULL, 0);
+   if (mtd) {
+   static char ids[24];
+   static char parts[48];
+   const char *linux_name = "omap2-nand";
+   if (strncmp(mtd->name, "onenand0", 8) == 0)
+   linux_name = "omap2-onenand";
+   snprintf(ids, sizeof(ids), "%s=%s", mtd->name, linux_name);
+   snprintf(parts, sizeof(parts), "mtdparts=%s:%dk(SPL),-(UBI)",
+linux_name, 4 * mtd->erasesize >> 10);
+   *mtdids = ids;
+   *mtdparts = parts;
+   }
+}
+
 /*
  * Routine: set_muxconf_regs
  * Description: Setting up the configuration Mux registers specific to the
diff --git a/include/configs/omap3_igep00x0.h b/include/configs/omap3_igep00x0.h
index 03ffda9..e0d2593 100644
--- a/include/configs/omap3_igep00x0.h
+++ b/include/configs/omap3_igep00x0.h
@@ -113,6 +113,7 @@
 
 #define CONFIG_RBTREE
 #define CONFIG_MTD_PARTITIONS
+#define CONFIG_SYS_MTDPARTS_RUNTIME
 
 /* OneNAND config */
 #define CONFIG_SPL_ONENAND_SUPPORT
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 26/26] igep00x0: Falcon mode

2016-07-12 Thread Ladislav Michl
Implement spl_start_uboot to let Falcon mode work.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
Reviewed-by: Heiko Schocher <h...@denx.de>
Acked-by: Enric Balletbo i Serra <enric.balle...@collabora.com>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 4c52b36..808955e 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -122,6 +123,17 @@ void get_board_mem_timings(struct board_sdrc_timings 
*timings)
gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
}
 }
+
+#ifdef CONFIG_SPL_OS_BOOT
+int spl_start_uboot(void)
+{
+   /* break into full u-boot on 'c' */
+   if (serial_tstc() && serial_getc() == 'c')
+   return 1;
+
+   return 0;
+}
+#endif
 #endif
 
 int onenand_board_init(struct mtd_info *mtd)
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 24/26] igep00x0: UBIize

2016-07-12 Thread Ladislav Michl
Convert IGEP board to use UBI volumes for U-Boot, its environment and
kernel. With exception of first four sectors read by SoC boot
ROM whole (One)NAND is UBI managed.
Also merge NAND and OneNAND defconfigs as now one binary can serve
both flashes.
As code is too big now, drop CONFIG_SPL_EXT_SUPPORT to make it fit.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
Reviewed-by: Heiko Schocher <h...@denx.de>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 configs/igep0020_defconfig   |  4 +-
 configs/igep0020_nand_defconfig  | 27 -
 include/configs/omap3_igep00x0.h | 85 ++--
 3 files changed, 41 insertions(+), 75 deletions(-)
 delete mode 100644 configs/igep0020_nand_defconfig

diff --git a/configs/igep0020_defconfig b/configs/igep0020_defconfig
index 66dd93f..649dd47 100644
--- a/configs/igep0020_defconfig
+++ b/configs/igep0020_defconfig
@@ -2,7 +2,8 @@ CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_OMAP3_IGEP00X0=y
 CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020,BOOT_ONENAND"
+CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020"
+CONFIG_BOOTDELAY=3
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_IMLS is not set
@@ -24,4 +25,5 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SYS_NS16550=y
+CONFIG_USE_TINY_PRINTF=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/igep0020_nand_defconfig b/configs/igep0020_nand_defconfig
deleted file mode 100644
index 7535d10..000
--- a/configs/igep0020_nand_defconfig
+++ /dev/null
@@ -1,27 +0,0 @@
-CONFIG_ARM=y
-CONFIG_OMAP34XX=y
-CONFIG_TARGET_OMAP3_IGEP00X0=y
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="MACH_TYPE=MACH_TYPE_IGEP0020,BOOT_NAND"
-CONFIG_HUSH_PARSER=y
-CONFIG_CMD_BOOTZ=y
-# CONFIG_CMD_IMLS is not set
-CONFIG_CMD_ASKENV=y
-# CONFIG_CMD_FLASH is not set
-CONFIG_CMD_MMC=y
-CONFIG_CMD_SPI=y
-CONFIG_CMD_I2C=y
-CONFIG_CMD_GPIO=y
-# CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_MII=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
-CONFIG_NET_RANDOM_ETHADDR=y
-CONFIG_SYS_NS16550=y
-CONFIG_OF_LIBFDT=y
diff --git a/include/configs/omap3_igep00x0.h b/include/configs/omap3_igep00x0.h
index 9bd8915..03ffda9 100644
--- a/include/configs/omap3_igep00x0.h
+++ b/include/configs/omap3_igep00x0.h
@@ -10,11 +10,8 @@
 #ifndef __IGEP00X0_H
 #define __IGEP00X0_H
 
-#ifdef CONFIG_BOOT_NAND
-#define CONFIG_NAND
-#endif
-
 #define CONFIG_NR_DRAM_BANKS2
+#define CONFIG_NAND
 
 #include 
 #include 
@@ -76,9 +73,9 @@
 #define CONFIG_USBD_MANUFACTURER   "Texas Instruments"
 #define CONFIG_USBD_PRODUCT_NAME   "IGEP"
 
-#ifdef CONFIG_BOOT_ONENAND
-#define CONFIG_CMD_ONENAND /* ONENAND support  */
-#endif
+#define CONFIG_CMD_MTDPARTS
+#define CONFIG_CMD_ONENAND
+#define CONFIG_CMD_UBI
 
 #ifndef CONFIG_SPL_BUILD
 
@@ -106,27 +103,6 @@
 #endif
 
 /*
- * FLASH and environment organization
- */
-
-#ifdef CONFIG_BOOT_ONENAND
-#define CONFIG_SYS_ONENAND_BASEONENAND_MAP
-
-#define ONENAND_ENV_OFFSET 0x26 /* environment starts here */
-
-#define CONFIG_ENV_IS_IN_ONENAND   1
-#define CONFIG_ENV_SIZE(512 << 10) /* Total Size 
Environment */
-#define CONFIG_ENV_ADDRONENAND_ENV_OFFSET
-#endif
-
-#ifdef CONFIG_NAND
-#define CONFIG_ENV_OFFSET  0x26 /* environment starts here */
-#define CONFIG_ENV_IS_IN_NAND  1
-#define CONFIG_ENV_SIZE(512 << 10) /* Total Size 
Environment */
-#define CONFIG_ENV_ADDRNAND_ENV_OFFSET
-#endif
-
-/*
  * SMSC911x Ethernet
  */
 #if defined(CONFIG_CMD_NET)
@@ -135,19 +111,18 @@
 #define CONFIG_SMC911X_BASE0x2C00
 #endif /* (CONFIG_CMD_NET) */
 
-/* OneNAND boot config */
-#ifdef CONFIG_BOOT_ONENAND
-#define CONFIG_SPL_ONENAND_SUPPORT
-#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x8
-#define CONFIG_SYS_ONENAND_PAGE_SIZE   2048
-#define CONFIG_SPL_ONENAND_LOAD_ADDR0x8
-#define CONFIG_SPL_ONENAND_LOAD_SIZE\
-   (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
+#define CONFIG_RBTREE
+#define CONFIG_MTD_PARTITIONS
 
-#endif
+/* OneNAND config */
+#define CONFIG_SPL_ONENAND_SUPPORT
+#define CONFIG_USE_ONENAND_BOARD_INIT
+#define CONFIG_SYS_ONENAND_BASEONENAND_MAP
+#define CONFIG_SYS_ONENAND_BLOCK_SIZE  (128*1024)
 
-/* NAND boot config */
-#ifdef CONFIG_NAND
+/* NAND config */
+#define CONFIG_SPL_NAND_SUPPORT
+#define CONFIG_SPL_OMAP3_ID_NAND
 #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
 #define CONFIG_SYS_NAND_PAGE_COUNT 64
@@ -168,13 +143,29 @@
 #define CONFIG_NAND_OMAP_GPMC
 #define CONFIG_BCH
 
-#define CONFIG_SYS_NAND_U_BOOT_OFFS0x8
-/* NAND: SPL falcon m

[U-Boot] [PATCH v5 23/26] igep00x0: runtime flash detection

2016-07-12 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c | 71 +++---
 1 file changed, 53 insertions(+), 18 deletions(-)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 5dfb7d2..b36709c 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -17,6 +17,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include "igep00x0.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -56,7 +60,25 @@ U_BOOT_DEVICE(igep_uart) = {
  */
 int board_init(void)
 {
-   gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
+   int loops = 100;
+
+   /* find out flash memory type, assume NAND first */
+   gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
+   gpmc_init();
+
+   /* Issue a RESET and then READID */
+   writeb(NAND_CMD_RESET, _cfg->cs[0].nand_cmd);
+   writeb(NAND_CMD_STATUS, _cfg->cs[0].nand_cmd);
+   while ((readl(_cfg->cs[0].nand_dat) & NAND_STATUS_READY)
+   != NAND_STATUS_READY) {
+   udelay(1);
+   if (--loops == 0) {
+   gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
+   gpmc_init();/* reinitialize for OneNAND */
+   break;
+   }
+   }
+
/* boot param addr */
gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
 
@@ -75,29 +97,42 @@ int board_init(void)
  */
 void get_board_mem_timings(struct board_sdrc_timings *timings)
 {
-   timings->mr = MICRON_V_MR_165;
-#ifdef CONFIG_BOOT_NAND
-   timings->mcfg = MICRON_V_MCFG_200(256 << 20);
-   timings->ctrla = MICRON_V_ACTIMA_200;
-   timings->ctrlb = MICRON_V_ACTIMB_200;
-   timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
-#else
-   if (get_cpu_family() == CPU_OMAP34XX) {
-   timings->mcfg = NUMONYX_V_MCFG_165(256 << 20);
-   timings->ctrla = NUMONYX_V_ACTIMA_165;
-   timings->ctrlb = NUMONYX_V_ACTIMB_165;
-   timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
+   int mfr, id, err = identify_nand_chip(, );
 
-   } else {
-   timings->mcfg = NUMONYX_V_MCFG_200(256 << 20);
-   timings->ctrla = NUMONYX_V_ACTIMA_200;
-   timings->ctrlb = NUMONYX_V_ACTIMB_200;
+   timings->mr = MICRON_V_MR_165;
+   if (!err && mfr == NAND_MFR_MICRON) {
+   timings->mcfg = MICRON_V_MCFG_200(256 << 20);
+   timings->ctrla = MICRON_V_ACTIMA_200;
+   timings->ctrlb = MICRON_V_ACTIMB_200;
timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
+   gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
+   } else {
+   if (get_cpu_family() == CPU_OMAP34XX) {
+   timings->mcfg = NUMONYX_V_MCFG_165(256 << 20);
+   timings->ctrla = NUMONYX_V_ACTIMA_165;
+   timings->ctrlb = NUMONYX_V_ACTIMB_165;
+   timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
+   } else {
+   timings->mcfg = NUMONYX_V_MCFG_200(256 << 20);
+   timings->ctrla = NUMONYX_V_ACTIMA_200;
+   timings->ctrlb = NUMONYX_V_ACTIMB_200;
+   timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
+   }
+   gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
}
-#endif
 }
 #endif
 
+int onenand_board_init(struct mtd_info *mtd)
+{
+   if (gpmc_cs0_flash == MTD_DEV_TYPE_ONENAND) {
+   struct onenand_chip *this = mtd->priv;
+   this->base = (void *)CONFIG_SYS_ONENAND_BASE;
+   return 0;
+   }
+   return 1;
+}
+
 #if defined(CONFIG_CMD_NET)
 static void reset_net_chip(int gpio)
 {
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 21/26] igep00x0: remove useless setup_net_chip declaration

2016-07-12 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/board/isee/igep00x0/igep00x0.h b/board/isee/igep00x0/igep00x0.h
index e47ee66..5698efa 100644
--- a/board/isee/igep00x0/igep00x0.h
+++ b/board/isee/igep00x0/igep00x0.h
@@ -7,8 +7,6 @@
 #ifndef _IGEP00X0_H_
 #define _IGEP00X0_H_
 
-static void setup_net_chip(void);
-
 /*
  * IEN  - Input Enable
  * IDIS - Input Disable
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 20/26] igep00x0: reorder lan9221 code to remove ifdefs

2016-07-12 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c | 41 +
 1 file changed, 17 insertions(+), 24 deletions(-)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 0ad5123..4baaee5 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -39,18 +39,6 @@ const omap3_sysinfo sysinfo = {
 #endif
 };
 
-#if defined(CONFIG_CMD_NET)
-/* GPMC definitions for LAN9221 chips */
-static const u32 gpmc_lan_config[] = {
-   NET_LAN9221_GPMC_CONFIG1,
-   NET_LAN9221_GPMC_CONFIG2,
-   NET_LAN9221_GPMC_CONFIG3,
-   NET_LAN9221_GPMC_CONFIG4,
-   NET_LAN9221_GPMC_CONFIG5,
-   NET_LAN9221_GPMC_CONFIG6,
-};
-#endif
-
 static const struct ns16550_platdata igep_serial = {
.base = OMAP34XX_UART3,
.reg_shift = 2,
@@ -119,7 +107,6 @@ void get_board_mem_timings(struct board_sdrc_timings 
*timings)
 #endif
 
 #if defined(CONFIG_CMD_NET)
-
 static void reset_net_chip(int gpio)
 {
if (!gpio_request(gpio, "eth nrst")) {
@@ -140,6 +127,14 @@ static void reset_net_chip(int gpio)
 static void setup_net_chip(void)
 {
struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
+   static const u32 gpmc_lan_config[] = {
+   NET_LAN9221_GPMC_CONFIG1,
+   NET_LAN9221_GPMC_CONFIG2,
+   NET_LAN9221_GPMC_CONFIG3,
+   NET_LAN9221_GPMC_CONFIG4,
+   NET_LAN9221_GPMC_CONFIG5,
+   NET_LAN9221_GPMC_CONFIG6,
+   };
 
enable_gpmc_cs_config(gpmc_lan_config, _cfg->cs[5],
CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
@@ -154,6 +149,15 @@ static void setup_net_chip(void)
 
reset_net_chip(64);
 }
+
+int board_eth_init(bd_t *bis)
+{
+#ifdef CONFIG_SMC911X
+   return smc911x_initialize(0, CONFIG_SMC911X_BASE);
+#else
+   return 0;
+#endif
+}
 #else
 static inline void setup_net_chip(void) {}
 #endif
@@ -219,14 +223,3 @@ void set_muxconf_regs(void)
MUX_IGEP0030();
 #endif
 }
-
-#if defined(CONFIG_CMD_NET)
-int board_eth_init(bd_t *bis)
-{
-#ifdef CONFIG_SMC911X
-   return smc911x_initialize(0, CONFIG_SMC911X_BASE);
-#else
-   return 0;
-#endif
-}
-#endif
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 22/26] igep00x0: remove unused empty function omap_rev_string()

2016-07-12 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 4baaee5..5dfb7d2 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -69,14 +69,6 @@ int board_init(void)
 
 #ifdef CONFIG_SPL_BUILD
 /*
- * Routine: omap_rev_string
- * Description: For SPL builds output board rev
- */
-void omap_rev_string(void)
-{
-}
-
-/*
  * Routine: get_board_mem_timings
  * Description: If we use SPL then there is no x-loader nor config header
  * so we have to setup the DDR timings ourself on both banks.
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 17/26] cmd: mtdparts: use defaults by default

2016-07-12 Thread Ladislav Michl
Boards which are defining default mtdparts often need them early
in boot process (to load environment from UBI volume, for example).
This is currently solved by adding mtdparts and mtdids variable
definitions also to default environment. With this change, default
partitions are used by default unless explicitely deleted or
redefined.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/mtdparts.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 7860ed9..53074a1 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -142,6 +142,8 @@ static struct list_head devices;
 struct mtd_device *current_mtd_dev = NULL;
 u8 current_mtd_partnum = 0;
 
+u8 use_defaults;
+
 static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int 
part_num);
 
 /* command line only routines */
@@ -1723,6 +1725,7 @@ int mtdparts_init(void)
memset(last_ids, 0, MTDIDS_MAXLEN);
memset(last_parts, 0, MTDPARTS_MAXLEN);
memset(last_partition, 0, PARTITION_MAXLEN);
+   use_defaults = 1;
initialized = 1;
}
 
@@ -1761,10 +1764,16 @@ int mtdparts_init(void)
return 1;
}
 
-   /* do no try to use defaults when mtdparts variable is not defined,
-* just check the length */
-   if (!parts)
-   printf("mtdparts variable not set, see 'help mtdparts'\n");
+   /* use defaults when mtdparts variable is not defined
+* once mtdparts is saved environment, drop use_defaults flag */
+   if (!parts) {
+   if (mtdparts_default && use_defaults) {
+   parts = mtdparts_default;
+   if (setenv("mtdparts", (char *)parts) == 0)
+   use_defaults = 0;
+   } else
+   printf("mtdparts variable not set, see 'help 
mtdparts'\n");
+   }
 
if (parts && (strlen(parts) > MTDPARTS_MAXLEN - 1)) {
printf("mtdparts too long (> %d)\n", MTDPARTS_MAXLEN);
@@ -1936,9 +1945,10 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int 
argc,
 {
if (argc == 2) {
if (strcmp(argv[1], "default") == 0) {
-   setenv("mtdids", (char *)mtdids_default);
-   setenv("mtdparts", (char *)mtdparts_default);
+   setenv("mtdids", NULL);
+   setenv("mtdparts", NULL);
setenv("partition", NULL);
+   use_defaults = 1;
 
mtdparts_init();
return 0;
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 18/26] cmd: mtdparts: support runtime generated mtdparts

2016-07-12 Thread Ladislav Michl
Some CPUs contains boot ROM code capable reading first few blocks
(where SPL resides) of NAND flash and executing it. It is wise to
create separate partition here for SPL. As block size depends on
NAND chip used, we could either use worst case (biggest) partition
size or base its size on actual block size. This patch adds support
for the latter option.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/mtdparts.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 53074a1..3f4f334 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -109,17 +109,17 @@ DECLARE_GLOBAL_DATA_PTR;
 #define MTD_WRITEABLE_CMD  1
 
 /* default values for mtdids and mtdparts variables */
-#if defined(MTDIDS_DEFAULT)
-static const char *const mtdids_default = MTDIDS_DEFAULT;
-#else
-static const char *const mtdids_default = NULL;
+#if !defined(MTDIDS_DEFAULT)
+#define MTDIDS_DEFAULT NULL
 #endif
-
-#if defined(MTDPARTS_DEFAULT)
-static const char *const mtdparts_default = MTDPARTS_DEFAULT;
-#else
-static const char *const mtdparts_default = NULL;
+#if !defined(MTDPARTS_DEFAULT)
+#define MTDPARTS_DEFAULT NULL
 #endif
+#if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
+extern void board_mtdparts_default(const char **mtdids, const char **mtdparts);
+#endif
+static const char *mtdids_default = MTDIDS_DEFAULT;
+static const char *mtdparts_default = MTDPARTS_DEFAULT;
 
 /* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */
 #define MTDIDS_MAXLEN  128
@@ -1725,6 +1725,9 @@ int mtdparts_init(void)
memset(last_ids, 0, MTDIDS_MAXLEN);
memset(last_parts, 0, MTDPARTS_MAXLEN);
memset(last_partition, 0, PARTITION_MAXLEN);
+#if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
+   board_mtdparts_default(_default, _default);
+#endif
use_defaults = 1;
initialized = 1;
}
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 19/26] igep00x0: move sysinfo into C file

2016-07-12 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/isee/igep00x0/igep00x0.c | 18 ++
 board/isee/igep00x0/igep00x0.h | 18 --
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index d1a6a6f..0ad5123 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -21,6 +21,24 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+const omap3_sysinfo sysinfo = {
+   DDR_STACKED,
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
+   "IGEPv2",
+#endif
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
+   "IGEP COM MODULE/ELECTRON",
+#endif
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0032)
+   "IGEP COM PROTON",
+#endif
+#if defined(CONFIG_ENV_IS_IN_ONENAND)
+   "ONENAND",
+#else
+   "NAND",
+#endif
+};
+
 #if defined(CONFIG_CMD_NET)
 /* GPMC definitions for LAN9221 chips */
 static const u32 gpmc_lan_config[] = {
diff --git a/board/isee/igep00x0/igep00x0.h b/board/isee/igep00x0/igep00x0.h
index 3c7ff9b..e47ee66 100644
--- a/board/isee/igep00x0/igep00x0.h
+++ b/board/isee/igep00x0/igep00x0.h
@@ -7,24 +7,6 @@
 #ifndef _IGEP00X0_H_
 #define _IGEP00X0_H_
 
-const omap3_sysinfo sysinfo = {
-   DDR_STACKED,
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
-   "IGEPv2",
-#endif
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
-   "IGEP COM MODULE/ELECTRON",
-#endif
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0032)
-   "IGEP COM PROTON",
-#endif
-#if defined(CONFIG_ENV_IS_IN_ONENAND)
-   "ONENAND",
-#else
-   "NAND",
-#endif
-};
-
 static void setup_net_chip(void);
 
 /*
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 14/26] cmd: mtdparts: fix mtdparts variable presence confusion in mtdparts_init

2016-07-12 Thread Ladislav Michl
A private buffer is used to read mtdparts variable from non-relocated
environment. A pointer to that buffer is returned unconditionally,
confusing later test for variable presence in the environment.
Fix it by returning NULL when getenv_f fails.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/mtdparts.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 44b2c3a..3a88a10 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -1720,11 +1720,13 @@ int mtdparts_init(void)
 * before the env is relocated, then we need to use our own stack
 * buffer.  gd->env_buf will be too small.
 */
-   if (gd->flags & GD_FLG_ENV_READY) {
+   if (gd->flags & GD_FLG_ENV_READY)
parts = getenv("mtdparts");
-   } else {
-   parts = tmp_parts;
-   getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
+   else {
+   if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1)
+   parts = tmp_parts;
+   else
+   parts = NULL;
}
current_partition = getenv("partition");
 
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 16/26] cmd: mtdparts: consolidate mtdparts reading from env

2016-07-12 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/mtdparts.c | 42 --
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 995cb87..7860ed9 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -1516,6 +1516,23 @@ static int spread_partitions(void)
 #endif /* CONFIG_CMD_MTDPARTS_SPREAD */
 
 /**
+ * The mtdparts variable tends to be long. If we need to access it
+ * before the env is relocated, then we need to use our own stack
+ * buffer.  gd->env_buf will be too small.
+ *
+ * @param buf temporary buffer pointer MTDPARTS_MAXLEN long
+ * @return mtdparts variable string, NULL if not found
+ */
+static const char *getenv_mtdparts(char *buf)
+{
+   if (gd->flags & GD_FLG_ENV_READY)
+   return getenv("mtdparts");
+   if (getenv_f("mtdparts", buf, MTDPARTS_MAXLEN) != -1)
+   return buf;
+   return NULL;
+}
+
+/**
  * Accept character string describing mtd partitions and call device_parse()
  * for each entry. Add created devices to the global devices list.
  *
@@ -1538,15 +1555,7 @@ static int parse_mtdparts(const char *const mtdparts)
}
 
/* re-read 'mtdparts' variable, mtd_devices_init may be updating env */
-   if (gd->flags & GD_FLG_ENV_READY)
-   p = getenv("mtdparts");
-   else {
-   if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1)
-   p = tmp_parts;
-   else
-   p = NULL;
-   }
-
+   p = getenv_mtdparts(tmp_parts);
if (!p)
p = mtdparts;
 
@@ -1691,6 +1700,7 @@ static int parse_mtdids(const char *const ids)
return 0;
 }
 
+
 /**
  * Parse and initialize global mtdids mapping and create global
  * device/partition list.
@@ -1718,19 +1728,7 @@ int mtdparts_init(void)
 
/* get variables */
ids = getenv("mtdids");
-   /*
-* The mtdparts variable tends to be long. If we need to access it
-* before the env is relocated, then we need to use our own stack
-* buffer.  gd->env_buf will be too small.
-*/
-   if (gd->flags & GD_FLG_ENV_READY)
-   parts = getenv("mtdparts");
-   else {
-   if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1)
-   parts = tmp_parts;
-   else
-   parts = NULL;
-   }
+   parts = getenv_mtdparts(tmp_parts);
current_partition = getenv("partition");
 
/* save it for later parsing, cannot rely on current partition pointer
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 15/26] cmd: mtdparts: fix null pointer dereference in parse_mtdparts

2016-07-12 Thread Ladislav Michl
In case there is no mtdparts variable in relocated environment,
NULL is assigned to p, which is later fed to strncpy.
Also function parameter mtdparts is completely ignored, so use it
in case mtdparts variable is not found in environment. This
parameter is checked not to be NULL in caller.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/mtdparts.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 3a88a10..995cb87 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -1524,7 +1524,7 @@ static int spread_partitions(void)
  */
 static int parse_mtdparts(const char *const mtdparts)
 {
-   const char *p = mtdparts;
+   const char *p;
struct mtd_device *dev;
int err = 1;
char tmp_parts[MTDPARTS_MAXLEN];
@@ -1538,20 +1538,25 @@ static int parse_mtdparts(const char *const mtdparts)
}
 
/* re-read 'mtdparts' variable, mtd_devices_init may be updating env */
-   if (gd->flags & GD_FLG_ENV_READY) {
+   if (gd->flags & GD_FLG_ENV_READY)
p = getenv("mtdparts");
-   } else {
-   p = tmp_parts;
-   getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
+   else {
+   if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1)
+   p = tmp_parts;
+   else
+   p = NULL;
}
 
+   if (!p)
+   p = mtdparts;
+
if (strncmp(p, "mtdparts=", 9) != 0) {
printf("mtdparts variable doesn't start with 'mtdparts='\n");
return err;
}
p += 9;
 
-   while (p && (*p != '\0')) {
+   while (*p != '\0') {
err = 1;
if ((device_parse(p, , ) != 0) || (!dev))
break;
@@ -1569,12 +1574,10 @@ static int parse_mtdparts(const char *const mtdparts)
list_add_tail(>link, );
err = 0;
}
-   if (err == 1) {
+   if (err == 1)
device_delall();
-   return 1;
-   }
 
-   return 0;
+   return err;
 }
 
 /**
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 12/26] mtd: OneNAND: allow board init function fail

2016-07-12 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/micronas/vct/ebi_onenand.c   |  4 +++-
 board/samsung/goni/onenand.c   |  4 +++-
 board/samsung/smdkc100/onenand.c   |  4 +++-
 board/samsung/universal_c210/onenand.c |  4 +++-
 drivers/mtd/onenand/onenand_uboot.c| 30 +++---
 include/onenand_uboot.h|  2 +-
 6 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/board/micronas/vct/ebi_onenand.c b/board/micronas/vct/ebi_onenand.c
index 62eb648..ef892ca 100644
--- a/board/micronas/vct/ebi_onenand.c
+++ b/board/micronas/vct/ebi_onenand.c
@@ -169,7 +169,7 @@ static int ebi_write_bufferram(struct mtd_info *mtd, loff_t 
addr, int area,
return 0;
 }
 
-void onenand_board_init(struct mtd_info *mtd)
+int onenand_board_init(struct mtd_info *mtd)
 {
struct onenand_chip *chip = mtd->priv;
 
@@ -181,4 +181,6 @@ void onenand_board_init(struct mtd_info *mtd)
 
chip->read_bufferram = ebi_read_bufferram;
chip->write_bufferram = ebi_write_bufferram;
+
+   return 0;
 }
diff --git a/board/samsung/goni/onenand.c b/board/samsung/goni/onenand.c
index b74d8e8..cbe1d12f 100644
--- a/board/samsung/goni/onenand.c
+++ b/board/samsung/goni/onenand.c
@@ -11,11 +11,13 @@
 #include 
 #include 
 
-void onenand_board_init(struct mtd_info *mtd)
+int onenand_board_init(struct mtd_info *mtd)
 {
struct onenand_chip *this = mtd->priv;
 
this->base = (void *)CONFIG_SYS_ONENAND_BASE;
this->options |= ONENAND_RUNTIME_BADBLOCK_CHECK;
this->chip_probe = s5pc110_chip_probe;
+
+   return 0;
 }
diff --git a/board/samsung/smdkc100/onenand.c b/board/samsung/smdkc100/onenand.c
index 577c1a5..994d91d 100644
--- a/board/samsung/smdkc100/onenand.c
+++ b/board/samsung/smdkc100/onenand.c
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-void onenand_board_init(struct mtd_info *mtd)
+int onenand_board_init(struct mtd_info *mtd)
 {
struct onenand_chip *this = mtd->priv;
struct s5pc100_clock *clk =
@@ -65,4 +65,6 @@ void onenand_board_init(struct mtd_info *mtd)
writel(value, >int_err_mask);
 
s3c_onenand_init(mtd);
+
+   return 0;
 }
diff --git a/board/samsung/universal_c210/onenand.c 
b/board/samsung/universal_c210/onenand.c
index 28bc811..147a95e 100644
--- a/board/samsung/universal_c210/onenand.c
+++ b/board/samsung/universal_c210/onenand.c
@@ -10,11 +10,13 @@
 #include 
 #include 
 
-void onenand_board_init(struct mtd_info *mtd)
+int onenand_board_init(struct mtd_info *mtd)
 {
struct onenand_chip *this = mtd->priv;
 
this->base = (void *)CONFIG_SYS_ONENAND_BASE;
this->options |= ONENAND_RUNTIME_BADBLOCK_CHECK;
this->chip_probe = s5pc210_chip_probe;
+
+   return 0;
 }
diff --git a/drivers/mtd/onenand/onenand_uboot.c 
b/drivers/mtd/onenand/onenand_uboot.c
index ae60c3b..c15ec9d 100644
--- a/drivers/mtd/onenand/onenand_uboot.c
+++ b/drivers/mtd/onenand/onenand_uboot.c
@@ -24,33 +24,33 @@ static __attribute__((unused)) char dev_name[] = "onenand0";
 
 void onenand_init(void)
 {
+   int err = 0;
memset(_mtd, 0, sizeof(struct mtd_info));
memset(_chip, 0, sizeof(struct onenand_chip));
 
onenand_mtd.priv = _chip;
 
 #ifdef CONFIG_USE_ONENAND_BOARD_INIT
-   /*
-* It's used for some board init required
-*/
-   onenand_board_init(_mtd);
+   /* It's used for some board init required */
+   err = onenand_board_init(_mtd);
 #else
onenand_chip.base = (void *) CONFIG_SYS_ONENAND_BASE;
 #endif
 
-   onenand_scan(_mtd, 1);
+   if (!err && !(onenand_scan(_mtd, 1))) {
 
-   if (onenand_chip.device_id & DEVICE_IS_FLEXONENAND)
-   puts("Flex-");
-   puts("OneNAND: ");
-   print_size(onenand_chip.chipsize, "\n");
+   if (onenand_chip.device_id & DEVICE_IS_FLEXONENAND)
+   puts("Flex-");
+   puts("OneNAND: ");
 
 #ifdef CONFIG_MTD_DEVICE
-   /*
-* Add MTD device so that we can reference it later
-* via the mtdcore infrastructure (e.g. ubi).
-*/
-   onenand_mtd.name = dev_name;
-   add_mtd_device(_mtd);
+   /*
+* Add MTD device so that we can reference it later
+* via the mtdcore infrastructure (e.g. ubi).
+*/
+   onenand_mtd.name = dev_name;
+   add_mtd_device(_mtd);
 #endif
+   }
+   print_size(onenand_chip.chipsize, "\n");
 }
diff --git a/include/onenand_uboot.h b/include/onenand_uboot.h
index d69e0d2..995f0aa 100644
--- a/include/onenand_uboot.h
+++ b/include/onenand_uboot.h
@@ -26,7 +26,7 @@ extern struct mtd_info onenand_mtd;
 extern struct onenand_chip onenand_chip;
 
 /* board */
-ex

[U-Boot] [PATCH v5 13/26] mtd: OneNAND: initialize mtd->writebufsize to let UBI work

2016-07-12 Thread Ladislav Michl
io_init checks this value and fails with "bad write buffer size 0 for
2048 min. I/O unit"

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/mtd/onenand/onenand_base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/onenand/onenand_base.c 
b/drivers/mtd/onenand/onenand_base.c
index d194d97..0e35dc5 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -2657,6 +2657,7 @@ int onenand_probe(struct mtd_info *mtd)
mtd->_sync = onenand_sync;
mtd->_block_isbad = onenand_block_isbad;
mtd->_block_markbad = onenand_block_markbad;
+   mtd->writebufsize = mtd->writesize;
 
return 0;
 }
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 11/26] mtd: OneNAND: add timeout to wait ready loops

2016-07-12 Thread Ladislav Michl
Add timeout to onenand_wait ready loop as it hangs here indefinitely
when chip not present. Once there, do the same for onenand_bbt_wait
as well (note: recent Linux driver code does the same)

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/mtd/onenand/onenand_base.c | 30 +++---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/onenand/onenand_base.c 
b/drivers/mtd/onenand/onenand_base.c
index 03deabc..d194d97 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -20,6 +20,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include "linux/mtd/flashchip.h"
@@ -467,15 +468,18 @@ static int onenand_read_ecc(struct onenand_chip *this)
 static int onenand_wait(struct mtd_info *mtd, int state)
 {
struct onenand_chip *this = mtd->priv;
-   unsigned int flags = ONENAND_INT_MASTER;
unsigned int interrupt = 0;
unsigned int ctrl;
 
-   while (1) {
+   /* Wait at most 20ms ... */
+   u32 timeo = (CONFIG_SYS_HZ * 20) / 1000;
+   u32 time_start = get_timer(0);
+   do {
+   WATCHDOG_RESET();
+   if (get_timer(time_start) > timeo)
+   return -EIO;
interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
-   if (interrupt & flags)
-   break;
-   }
+   } while ((interrupt & ONENAND_INT_MASTER) == 0);
 
ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
 
@@ -1154,15 +1158,18 @@ int onenand_read_oob(struct mtd_info *mtd, loff_t from,
 static int onenand_bbt_wait(struct mtd_info *mtd, int state)
 {
struct onenand_chip *this = mtd->priv;
-   unsigned int flags = ONENAND_INT_MASTER;
unsigned int interrupt;
unsigned int ctrl;
 
-   while (1) {
+   /* Wait at most 20ms ... */
+   u32 timeo = (CONFIG_SYS_HZ * 20) / 1000;
+   u32 time_start = get_timer(0);
+   do {
+   WATCHDOG_RESET();
+   if (get_timer(time_start) > timeo)
+   return ONENAND_BBT_READ_FATAL_ERROR;
interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
-   if (interrupt & flags)
-   break;
-   }
+   } while ((interrupt & ONENAND_INT_MASTER) == 0);
 
/* To get correct interrupt status in timeout case */
interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
@@ -2536,7 +2543,8 @@ static int onenand_chip_probe(struct mtd_info *mtd)
this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_BOOTRAM);
 
/* Wait reset */
-   this->wait(mtd, FL_RESETING);
+   if (this->wait(mtd, FL_RESETING))
+   return -ENXIO;
 
/* Restore system configuration 1 */
this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 09/26] armv7: armv7: introduce set_gpmc_cs0

2016-07-12 Thread Ladislav Michl
Allow boards to runtime detect flash type.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/omap-common/mem-common.c | 148 +---
 arch/arm/include/asm/arch-omap3/sys_proto.h |   1 +
 include/linux/mtd/omap_gpmc.h   |   1 +
 3 files changed, 92 insertions(+), 58 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/mem-common.c 
b/arch/arm/cpu/armv7/omap-common/mem-common.c
index 136a032..d72e82e 100644
--- a/arch/arm/cpu/armv7/omap-common/mem-common.c
+++ b/arch/arm/cpu/armv7/omap-common/mem-common.c
@@ -20,9 +20,20 @@
 #include 
 #include 
 #include 
+#include 
 
 const struct gpmc *gpmc_cfg = (struct gpmc *)GPMC_BASE;
 
+#if defined(CONFIG_NOR)
+char gpmc_cs0_flash = MTD_DEV_TYPE_NOR;
+#elif defined(CONFIG_NAND) || defined(CONFIG_CMD_NAND)
+char gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
+#elif defined(CONFIG_CMD_ONENAND)
+char gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
+#else
+char gpmc_cs0_flash = -1;
+#endif
+
 #if defined(CONFIG_OMAP34XX)
 /
  *  mem_ok() - test used to see if timings are correct
@@ -68,6 +79,81 @@ void enable_gpmc_cs_config(const u32 *gpmc_config, const 
struct gpmc_cs *cs,
sdelay(2000);
 }
 
+void set_gpmc_cs0(int flash_type)
+{
+   const u32 *gpmc_regs;
+   u32 base, size;
+#if defined(CONFIG_NOR)
+   const u32 gpmc_regs_nor[GPMC_MAX_REG] = {
+   STNOR_GPMC_CONFIG1,
+   STNOR_GPMC_CONFIG2,
+   STNOR_GPMC_CONFIG3,
+   STNOR_GPMC_CONFIG4,
+   STNOR_GPMC_CONFIG5,
+   STNOR_GPMC_CONFIG6,
+   STNOR_GPMC_CONFIG7
+   };
+#endif
+#if defined(CONFIG_NAND) || defined(CONFIG_CMD_NAND)
+   const u32 gpmc_regs_nand[GPMC_MAX_REG] = {
+   M_NAND_GPMC_CONFIG1,
+   M_NAND_GPMC_CONFIG2,
+   M_NAND_GPMC_CONFIG3,
+   M_NAND_GPMC_CONFIG4,
+   M_NAND_GPMC_CONFIG5,
+   M_NAND_GPMC_CONFIG6,
+   0
+   };
+#endif
+#if defined(CONFIG_CMD_ONENAND)
+   const u32 gpmc_regs_onenand[GPMC_MAX_REG] = {
+   ONENAND_GPMC_CONFIG1,
+   ONENAND_GPMC_CONFIG2,
+   ONENAND_GPMC_CONFIG3,
+   ONENAND_GPMC_CONFIG4,
+   ONENAND_GPMC_CONFIG5,
+   ONENAND_GPMC_CONFIG6,
+   0
+   };
+#endif
+
+   switch (flash_type) {
+#if defined(CONFIG_NOR)
+   case MTD_DEV_TYPE_NOR:
+   gpmc_regs = gpmc_regs_nor;
+   base = CONFIG_SYS_FLASH_BASE;
+   size = (CONFIG_SYS_FLASH_SIZE > 0x0800) ? GPMC_SIZE_256M :
+ ((CONFIG_SYS_FLASH_SIZE > 0x0400) ? GPMC_SIZE_128M :
+ ((CONFIG_SYS_FLASH_SIZE > 0x0200) ? GPMC_SIZE_64M  :
+ ((CONFIG_SYS_FLASH_SIZE > 0x0100) ? GPMC_SIZE_32M  :
+ GPMC_SIZE_16M)));
+   break;
+#endif
+#if defined(CONFIG_NAND) || defined(CONFIG_CMD_NAND)
+   case MTD_DEV_TYPE_NAND:
+   gpmc_regs = gpmc_regs_nand;
+   base = CONFIG_SYS_NAND_BASE;
+   size = GPMC_SIZE_16M;
+   break;
+#endif
+#if defined(CONFIG_CMD_ONENAND)
+   case MTD_DEV_TYPE_ONENAND:
+   gpmc_regs = gpmc_regs_onenand;
+   base = CONFIG_SYS_ONENAND_BASE;
+   size = GPMC_SIZE_128M;
+   break;
+#endif
+   default:
+   /* disable the GPMC0 config set by ROM code */
+   writel(0, _cfg->cs[0].config7);
+   sdelay(1000);
+   return;
+   }
+
+   /* enable chip-select specific configurations */
+   enable_gpmc_cs_config(gpmc_regs, _cfg->cs[0], base, size);
+}
+
 /*
  * gpmc_init(): init gpmc bus
  * Init GPMC for x16, MuxMode (SDRAM in x32).
@@ -75,68 +161,14 @@ void enable_gpmc_cs_config(const u32 *gpmc_config, const 
struct gpmc_cs *cs,
  */
 void gpmc_init(void)
 {
-#if defined(CONFIG_NOR)
-/* configure GPMC for NOR */
-   const u32 gpmc_regs[GPMC_MAX_REG] = {   STNOR_GPMC_CONFIG1,
-   STNOR_GPMC_CONFIG2,
-   STNOR_GPMC_CONFIG3,
-   STNOR_GPMC_CONFIG4,
-   STNOR_GPMC_CONFIG5,
-   STNOR_GPMC_CONFIG6,
-   STNOR_GPMC_CONFIG7
-   };
-   u32 base = CONFIG_SYS_FLASH_BASE;
-   u32 size =  (CONFIG_SYS_FLASH_SIZE  > 0x0800) ? GPMC_SIZE_256M :
-   /* > 64MB */((CONFIG_SYS_FLASH_SIZE 

[U-Boot] [PATCH v5 10/26] armv7: simplify identify_nand_chip

2016-07-12 Thread Ladislav Michl
Use newly introduced function

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/omap3/spl_id_nand.c | 35 +++---
 1 file changed, 11 insertions(+), 24 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap3/spl_id_nand.c 
b/arch/arm/cpu/armv7/omap3/spl_id_nand.c
index 26d3aa4..0e2f0a2 100644
--- a/arch/arm/cpu/armv7/omap3/spl_id_nand.c
+++ b/arch/arm/cpu/armv7/omap3/spl_id_nand.c
@@ -13,13 +13,13 @@
  */
 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
-static struct gpmc *gpmc_config = (struct gpmc *)GPMC_BASE;
-
 /*
  * Many boards will want to know the results of the NAND_CMD_READID command
  * in order to decide what to do about DDR initialization.  This function
@@ -31,40 +31,27 @@ int identify_nand_chip(int *mfr, int *id)
int loops = 1000;
 
/* Make sure that we have setup GPMC for NAND correctly. */
-   writel(M_NAND_GPMC_CONFIG1, _config->cs[0].config1);
-   writel(M_NAND_GPMC_CONFIG2, _config->cs[0].config2);
-   writel(M_NAND_GPMC_CONFIG3, _config->cs[0].config3);
-   writel(M_NAND_GPMC_CONFIG4, _config->cs[0].config4);
-   writel(M_NAND_GPMC_CONFIG5, _config->cs[0].config5);
-   writel(M_NAND_GPMC_CONFIG6, _config->cs[0].config6);
-
-   /*
-* Enable the config.  The CS size goes in bits 11:8.  We set
-* bit 6 to enable the CS and the base address goes into bits 5:0.
-*/
-   writel((GPMC_SIZE_128M << 8) | (GPMC_CS_ENABLE << 6) |
-   ((NAND_BASE >> 24) & GPMC_BASEADDR_MASK),
-   _config->cs[0].config7);
+   set_gpmc_cs0(MTD_DEV_TYPE_NAND);
 
sdelay(2000);
 
/* Issue a RESET and then READID */
-   writeb(NAND_CMD_RESET, _config->cs[0].nand_cmd);
-   writeb(NAND_CMD_STATUS, _config->cs[0].nand_cmd);
-   while ((readl(_config->cs[0].nand_dat) & NAND_STATUS_READY)
-  != NAND_STATUS_READY) {
+   writeb(NAND_CMD_RESET, _cfg->cs[0].nand_cmd);
+   writeb(NAND_CMD_STATUS, _cfg->cs[0].nand_cmd);
+   while ((readl(_cfg->cs[0].nand_dat) & NAND_STATUS_READY)
+   != NAND_STATUS_READY) {
sdelay(100);
if (--loops == 0)
return 1;
}
-   writeb(NAND_CMD_READID, _config->cs[0].nand_cmd);
+   writeb(NAND_CMD_READID, _cfg->cs[0].nand_cmd);
 
/* Set the address to read to 0x0 */
-   writeb(0x0, _config->cs[0].nand_adr);
+   writeb(0x0, _cfg->cs[0].nand_adr);
 
/* Read off the manufacturer and device id. */
-   *mfr = readb(_config->cs[0].nand_dat);
-   *id = readb(_config->cs[0].nand_dat);
+   *mfr = readb(_cfg->cs[0].nand_dat);
+   *id = readb(_cfg->cs[0].nand_dat);
 
return 0;
 }
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 08/26] armv7: make gpmc_cfg const

2016-07-12 Thread Ladislav Michl
Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/omap-common/mem-common.c | 8 +++-
 arch/arm/include/asm/arch-omap3/sys_proto.h | 4 ++--
 drivers/mtd/nand/omap_gpmc.c| 3 ++-
 include/linux/mtd/omap_gpmc.h   | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/mem-common.c 
b/arch/arm/cpu/armv7/omap-common/mem-common.c
index fc4290c..136a032 100644
--- a/arch/arm/cpu/armv7/omap-common/mem-common.c
+++ b/arch/arm/cpu/armv7/omap-common/mem-common.c
@@ -21,7 +21,7 @@
 #include 
 #include 
 
-struct gpmc *gpmc_cfg;
+const struct gpmc *gpmc_cfg = (struct gpmc *)GPMC_BASE;
 
 #if defined(CONFIG_OMAP34XX)
 /
@@ -50,8 +50,8 @@ u32 mem_ok(u32 cs)
 }
 #endif
 
-void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 
base,
-   u32 size)
+void enable_gpmc_cs_config(const u32 *gpmc_config, const struct gpmc_cs *cs,
+   u32 base, u32 size)
 {
writel(0, >config7);
sdelay(1000);
@@ -75,8 +75,6 @@ void enable_gpmc_cs_config(const u32 *gpmc_config, struct 
gpmc_cs *cs, u32 base,
  */
 void gpmc_init(void)
 {
-   /* putting a blanket check on GPMC based on ZeBu for now */
-   gpmc_cfg = (struct gpmc *)GPMC_BASE;
 #if defined(CONFIG_NOR)
 /* configure GPMC for NOR */
const u32 gpmc_regs[GPMC_MAX_REG] = {   STNOR_GPMC_CONFIG1,
diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h 
b/arch/arm/include/asm/arch-omap3/sys_proto.h
index 1be2b15..4c5aa99 100644
--- a/arch/arm/include/asm/arch-omap3/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
@@ -43,8 +43,8 @@ void get_board_mem_timings(struct board_sdrc_timings 
*timings);
 int identify_nand_chip(int *mfr, int *id);
 void emif4_init(void);
 void gpmc_init(void);
-void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 
base,
-   u32 size);
+void enable_gpmc_cs_config(const u32 *gpmc_config, const struct gpmc_cs *cs,
+   u32 base, u32 size);
 
 void watchdog_init(void);
 void set_muxconf_regs(void);
diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c
index 67f293d..6e201d6 100644
--- a/drivers/mtd/nand/omap_gpmc.c
+++ b/drivers/mtd/nand/omap_gpmc.c
@@ -264,7 +264,8 @@ static int omap_calculate_ecc(struct mtd_info *mtd, const 
uint8_t *dat,
 {
struct nand_chip *chip = mtd_to_nand(mtd);
struct omap_nand_info *info = nand_get_controller_data(chip);
-   uint32_t *ptr, val = 0;
+   const uint32_t *ptr;
+   uint32_t val = 0;
int8_t i = 0, j;
 
switch (info->ecc_scheme) {
diff --git a/include/linux/mtd/omap_gpmc.h b/include/linux/mtd/omap_gpmc.h
index 3a75674..f49ea3d 100644
--- a/include/linux/mtd/omap_gpmc.h
+++ b/include/linux/mtd/omap_gpmc.h
@@ -92,6 +92,6 @@ struct gpmc {
 };
 
 /* Used for board specific gpmc initialization */
-extern struct gpmc *gpmc_cfg;
+extern const struct gpmc *gpmc_cfg;
 
 #endif /* __ASM_OMAP_GPMC_H */
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 07/26] armv7: add reset timeout to identify_nand_chip

2016-07-12 Thread Ladislav Michl
identify_nand_chip hangs forever in loop when NAND is not present.
As IGEPv2 comes either with NAND or OneNAND flash, add reset timeout
to let function fail gracefully allowing caller to know NAND is
not present. On NAND equipped board, reset succeeds on first read,
so 1000 loops seems to be safe timeout.

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/omap3/spl_id_nand.c  | 32 +
 arch/arm/include/asm/arch-omap3/sys_proto.h |  2 +-
 2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap3/spl_id_nand.c 
b/arch/arm/cpu/armv7/omap3/spl_id_nand.c
index db6de09..26d3aa4 100644
--- a/arch/arm/cpu/armv7/omap3/spl_id_nand.c
+++ b/arch/arm/cpu/armv7/omap3/spl_id_nand.c
@@ -20,29 +20,16 @@
 
 static struct gpmc *gpmc_config = (struct gpmc *)GPMC_BASE;
 
-/* nand_command: Send a flash command to the flash chip */
-static void nand_command(u8 command)
-{
-   writeb(command, _config->cs[0].nand_cmd);
-
-   if (command == NAND_CMD_RESET) {
-   unsigned char ret_val;
-   writeb(NAND_CMD_STATUS, _config->cs[0].nand_cmd);
-   do {
-   /* Wait until ready */
-   ret_val = readl(_config->cs[0].nand_dat);
-   } while ((ret_val & NAND_STATUS_READY) != NAND_STATUS_READY);
-   }
-}
-
 /*
  * Many boards will want to know the results of the NAND_CMD_READID command
  * in order to decide what to do about DDR initialization.  This function
  * allows us to do that very early and to pass those results back to the
  * board so it can make whatever decisions need to be made.
  */
-void identify_nand_chip(int *mfr, int *id)
+int identify_nand_chip(int *mfr, int *id)
 {
+   int loops = 1000;
+
/* Make sure that we have setup GPMC for NAND correctly. */
writel(M_NAND_GPMC_CONFIG1, _config->cs[0].config1);
writel(M_NAND_GPMC_CONFIG2, _config->cs[0].config2);
@@ -62,8 +49,15 @@ void identify_nand_chip(int *mfr, int *id)
sdelay(2000);
 
/* Issue a RESET and then READID */
-   nand_command(NAND_CMD_RESET);
-   nand_command(NAND_CMD_READID);
+   writeb(NAND_CMD_RESET, _config->cs[0].nand_cmd);
+   writeb(NAND_CMD_STATUS, _config->cs[0].nand_cmd);
+   while ((readl(_config->cs[0].nand_dat) & NAND_STATUS_READY)
+  != NAND_STATUS_READY) {
+   sdelay(100);
+   if (--loops == 0)
+   return 1;
+   }
+   writeb(NAND_CMD_READID, _config->cs[0].nand_cmd);
 
/* Set the address to read to 0x0 */
writeb(0x0, _config->cs[0].nand_adr);
@@ -71,4 +65,6 @@ void identify_nand_chip(int *mfr, int *id)
/* Read off the manufacturer and device id. */
*mfr = readb(_config->cs[0].nand_dat);
*id = readb(_config->cs[0].nand_dat);
+
+   return 0;
 }
diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h 
b/arch/arm/include/asm/arch-omap3/sys_proto.h
index 24563c0..1be2b15 100644
--- a/arch/arm/include/asm/arch-omap3/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
@@ -40,7 +40,7 @@ void sdrc_init(void);
 void do_sdrc_init(u32, u32);
 
 void get_board_mem_timings(struct board_sdrc_timings *timings);
-void identify_nand_chip(int *mfr, int *id);
+int identify_nand_chip(int *mfr, int *id);
 void emif4_init(void);
 void gpmc_init(void);
 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 
base,
-- 
2.1.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


  1   2   3   >