Re: [U-Boot] [PATCH] lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.

2017-11-23 Thread Wilson Lee
Hi Simon,

On Mon, 2017-11-20 at 08:38 -0700, Simon Glass wrote:
> Hi Wilson,
> 
> On 7 November 2017 at 19:30, Wilson Lee <wilson@ni.com> wrote:
> > 
> > uint8_t used in sha1_der_prefix array was not able to recognize by
> > compiler when try to build the tools using 'HOSTCC'. That is
> > because,
> > uint8_t is undefined when 'HOSTCC' is defined because asm/type.h is
> > not
> > included in that case. Use unsigned char for sha1_der_prefix[]
> > array
> > instead.
> > 
> > This commit is to remove and change the uint8_t to unsigned char
> > for
> > sha1_der_perfix[] array.
> nit: prefix
> 
> This change is OK I suppose. But I'm not sure what compiler you are
> using. This type should be provided in stdint.h - can you take a look
> at why it is not?
> 
> Regards,
> Simon

Kindly correct me if I am wrong. I think the uint8_t was provided in
the "inttypes.h" header file. However, when we using HOSTCC to compile
the code, the "common.h" (which include "inttypes.h") does not included
and cause compilation to fail. The summary version of the code shown
below:

#ifndef USE_HOSTCC
#include 
#include 
#else
#include 
#endif /* USE_HOSTCC */


I think there have 2 solution for this:
    1. Include the "inttypes.h" header file.
    2. Change the uint8_t to unsigned char.

However, I would like to proceed with 2nd option. Because, in existing
sha1 library, variable data type was declare as unsigned char, unsigned
long... and I am thinking convert uint8_t to unsigned char will make
the variable data type more consistent in sha1 library code.


Thanks, Simon.

Best Regards,
Wilson Lee
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] ni: Add NIZYNQ platform

2017-11-22 Thread Wilson Lee
Hi Michal,

On Wed, 2017-11-22 at 08:11 +0100, Michal Simek wrote:
> Hi,
> 
> On 22.11.2017 04:06, Wilson Lee wrote:
> > 
> > Hi Michal,
> > 
> > On Wed, 2017-11-08 at 07:27 +0100, Michal Simek wrote:
> > > 
> > > On 8.11.2017 03:54, Wilson Lee wrote:
> > > > 
> > > > 
> > > > Initial platform creation for NIZYNQ.
> > > > 
> > > > Signed-off-by: Joe Hershberger <joe.hershber...@ni.com>
> > > > Signed-off-by: Keng Soon Cheah <keng.soon.ch...@ni.com>
> > > > Signed-off-by: Wilson Lee <wilson@ni.com>
> > > > Cc: Chen Yee Chew <chen.yee.c...@ni.com>
> > > > Cc: Albert Aribaud <albert.u.b...@aribaud.net>
> > > > ---
> > > >  arch/arm/Kconfig  | 15 +++
> > > >  arch/arm/Makefile |  4 +++-
> > > >  board/ni/Kconfig  | 13 +
> > > >  3 files changed, 31 insertions(+), 1 deletion(-)
> > > >  create mode 100644 board/ni/Kconfig
> > > > 
> > > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > > > index 83b7aa5..ae34821 100644
> > > > --- a/arch/arm/Kconfig
> > > > +++ b/arch/arm/Kconfig
> > > > @@ -767,6 +767,20 @@ config ARCH_ZYNQMP
> > > >     select DM_USB if USB
> > > >     imply FAT_WRITE
> > > >  
> > > > +config NIZYNQ
> > > > +   bool "National Instruments zynq Platform"
> > > > +   select CPU_V7
> > > > +   select SUPPORT_SPL
> > > > +   select OF_CONTROL
> > > > +   select SPL_OF_CONTROL if SPL
> > > > +   select DM
> > > > +   select DM_ETH
> > > > +   select DM_GPIO
> > > > +   select SPL_DM if SPL
> > > > +   select DM_MMC
> > > > +   select DM_SERIAL
> > > > +   select SPL_SEPARATE_BSS if SPL
> > > > +
> > > What's the reason for this? You should reuse current ZYNQ
> > > fragment
> > > and
> > > if this selects something what you don't want then we should
> > > changethat. Look at syzygy or topic boards which are using
> > > existing
> > > zynq
> > > infrastructure.
> > > 
> > > Thanks,
> > > Michal
> > > 
> > > 
> > The reason for adding NIZYNQ instead of reuse ARCH_ZYNQ. That is
> > because we need NIZYNQ at the same level with ARCH_ZYNQ in
> > menuconfig.
> > We are thinking that it would be missleading, if our customer need
> > to
> > select Xilinx Zynq Platform before they can select NI product. 
> > 
> > Hence, what we wish to get the menuconfig that look like below,
> > 
> > + Target select +
> > > 
> > >   Use the arrow keys to navigate this window or press
> > > the  |  
> > >  hotkey of the item you wish to select followed by the  > >   BAR>. Press  for additional information about
> > > this|  
> > > +^(-)---+ |  
> > > > 
> > > > ( ) Support pcm-052|
> > > > |  
> > > > ( ) Support BK4r1  |
> > > > |  
> > >  |( ) Xilinx Zynq Platform   |
> > > |  
> > > > 
> > > > ( ) Support Xilinx ZynqMP Platform |
> > > > |  
> > > > (X) National Instruments zynq Platform |
> > > > |  
> > > > ( ) NVIDIA Tegra   |
> > > > |  
> > > ++(+)---+ |  
> > +---+  
> > > 
> > >   < Help
> > > > |  
> > +---+
> > 
> I understand that you want to put there a little bit of marketing but
> moving to DM should avoid doing this and really I want to make xilinx
> ports generic as much as possible.
> 
> What we can do is to change description to be more understandable
> like
> "Xilinx Zynq based platform".

After some discussion, we think that changing the description to be
more understandable as you suggested above is make sense to us and it
is a good approache also. May I know, do you will sub

Re: [U-Boot] [PATCH] ni: Add NIZYNQ platform

2017-11-21 Thread Wilson Lee
Hi Michal,

On Wed, 2017-11-08 at 07:27 +0100, Michal Simek wrote:
> On 8.11.2017 03:54, Wilson Lee wrote:
> > 
> > Initial platform creation for NIZYNQ.
> > 
> > Signed-off-by: Joe Hershberger <joe.hershber...@ni.com>
> > Signed-off-by: Keng Soon Cheah <keng.soon.ch...@ni.com>
> > Signed-off-by: Wilson Lee <wilson@ni.com>
> > Cc: Chen Yee Chew <chen.yee.c...@ni.com>
> > Cc: Albert Aribaud <albert.u.b...@aribaud.net>
> > ---
> >  arch/arm/Kconfig  | 15 +++
> >  arch/arm/Makefile |  4 +++-
> >  board/ni/Kconfig  | 13 +
> >  3 files changed, 31 insertions(+), 1 deletion(-)
> >  create mode 100644 board/ni/Kconfig
> > 
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index 83b7aa5..ae34821 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -767,6 +767,20 @@ config ARCH_ZYNQMP
> >     select DM_USB if USB
> >     imply FAT_WRITE
> >  
> > +config NIZYNQ
> > +   bool "National Instruments zynq Platform"
> > +   select CPU_V7
> > +   select SUPPORT_SPL
> > +   select OF_CONTROL
> > +   select SPL_OF_CONTROL if SPL
> > +   select DM
> > +   select DM_ETH
> > +   select DM_GPIO
> > +   select SPL_DM if SPL
> > +   select DM_MMC
> > +   select DM_SERIAL
> > +   select SPL_SEPARATE_BSS if SPL
> > +
> What's the reason for this? You should reuse current ZYNQ fragment
> and
> if this selects something what you don't want then we should change
> that. Look at syzygy or topic boards which are using existing zynq
> infrastructure.
> 
> Thanks,
> Michal
> 
> 

The reason for adding NIZYNQ instead of reuse ARCH_ZYNQ. That is
because we need NIZYNQ at the same level with ARCH_ZYNQ in menuconfig.
We are thinking that it would be missleading, if our customer need to
select Xilinx Zynq Platform before they can select NI product. 

Hence, what we wish to get the menuconfig that look like below,

+ Target select +
|  Use the arrow keys to navigate this window or press the  |
|  hotkey of the item you wish to select followed by the . Press  for additional information about this|
| +^(-)---+ |
| |( ) Support pcm-052                                        | |
| |( ) Support BK4r1  | |
| |( ) Xilinx Zynq Platform   | |
| |( ) Support Xilinx ZynqMP Platform | |
| |(X) National Instruments zynq Platform | |
| |( ) NVIDIA Tegra   | |
| ++(+)---+ |
+---+
|  < Help > |
+---+

Thanks, Michal.

Best Regards,
Wilson Lee
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] ni: Add NIZYNQ platform

2017-11-21 Thread Wilson Lee
Hi Michal,

On Wed, 2017-11-08 at 07:27 +0100, Michal Simek wrote:
> On 8.11.2017 03:54, Wilson Lee wrote:
> > 
> > Initial platform creation for NIZYNQ.
> > 
> > Signed-off-by: Joe Hershberger <joe.hershber...@ni.com>
> > Signed-off-by: Keng Soon Cheah <keng.soon.ch...@ni.com>
> > Signed-off-by: Wilson Lee <wilson@ni.com>
> > Cc: Chen Yee Chew <chen.yee.c...@ni.com>
> > Cc: Albert Aribaud <albert.u.b...@aribaud.net>
> > ---
> >  arch/arm/Kconfig  | 15 +++
> >  arch/arm/Makefile |  4 +++-
> >  board/ni/Kconfig  | 13 +
> >  3 files changed, 31 insertions(+), 1 deletion(-)
> >  create mode 100644 board/ni/Kconfig
> > 
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index 83b7aa5..ae34821 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -767,6 +767,20 @@ config ARCH_ZYNQMP
> >     select DM_USB if USB
> >     imply FAT_WRITE
> >  
> > +config NIZYNQ
> > +   bool "National Instruments zynq Platform"
> > +   select CPU_V7
> > +   select SUPPORT_SPL
> > +   select OF_CONTROL
> > +   select SPL_OF_CONTROL if SPL
> > +   select DM
> > +   select DM_ETH
> > +   select DM_GPIO
> > +   select SPL_DM if SPL
> > +   select DM_MMC
> > +   select DM_SERIAL
> > +   select SPL_SEPARATE_BSS if SPL
> > +
> What's the reason for this? You should reuse current ZYNQ fragment
> and
> if this selects something what you don't want then we should
> changethat. Look at syzygy or topic boards which are using existing
> zynq
> infrastructure.
> 
> Thanks,
> Michal
> 
> 

The reason for adding NIZYNQ instead of reuse ARCH_ZYNQ. That is
because we need NIZYNQ at the same level with ARCH_ZYNQ in menuconfig.
We are thinking that it would be missleading, if our customer need to
select Xilinx Zynq Platform before they can select NI product. 

Hence, what we wish to get the menuconfig that look like below,

+ Target select +
|  Use the arrow keys to navigate this window or press the  |  
|  hotkey of the item you wish to select followed by the . Press  for additional information about this|  
| +^(-)---+ |  
| |( ) Support pcm-052| |  
| |( ) Support BK4r1  | |  
| |( ) Xilinx Zynq Platform   | |  
| |( ) Support Xilinx ZynqMP Platform | |  
| |(X) National Instruments zynq Platform | |  
| |( ) NVIDIA Tegra   | |  
| ++(+)---+ |  
+---+  
|  < Help > |  
+---+
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] mtd: zynq: nand: Move board_nand_init() function to board.c

2017-11-15 Thread Wilson Lee
Putting board_nand_init() function inside NAND driver was not appropriate
due to it doesn't allow board vendor to customise their NAND
initialization code such as adding NAND lock/unlock code.

This commit was to move the board_nand_init() function from NAND driver
to board.c file. This allow customization of board_nand_init() function.

Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Albert Aribaud <albert.u.b...@aribaud.net>
Cc: Michal Simek <michal.si...@xilinx.com>
Cc: Siva Durga Prasad Paladugu <siva.durga.palad...@xilinx.com>
Cc: Scott Wood <o...@buserror.net>
---
 arch/arm/mach-zynq/include/mach/nand.h | 9 +
 drivers/mtd/nand/zynq_nand.c   | 6 --
 2 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-zynq/include/mach/nand.h

diff --git a/arch/arm/mach-zynq/include/mach/nand.h 
b/arch/arm/mach-zynq/include/mach/nand.h
new file mode 100644
index 000..61ef45f
--- /dev/null
+++ b/arch/arm/mach-zynq/include/mach/nand.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2017 National Instruments Corp.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+
+void zynq_nand_init(void);
diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c
index dec2c41..076b878 100644
--- a/drivers/mtd/nand/zynq_nand.c
+++ b/drivers/mtd/nand/zynq_nand.c
@@ -1006,7 +1006,7 @@ static int zynq_nand_device_ready(struct mtd_info *mtd)
return 0;
 }
 
-static int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
+int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
 {
struct zynq_nand_info *xnand;
struct mtd_info *mtd;
@@ -1192,12 +1192,14 @@ fail:
return err;
 }
 
+#ifdef CONFIG_SYS_NAND_SELF_INIT
 static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
 
-void board_nand_init(void)
+void __weak board_nand_init(void)
 {
struct nand_chip *nand = _chip[0];
 
if (zynq_nand_init(nand, 0))
puts("ZYNQ NAND init failed\n");
 }
+#endif
-- 
2.7.4

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


Re: [U-Boot] [PATCH] mtd: zynq: nand: Move board_nand_init() function to board.c

2017-11-08 Thread Wilson Lee
Hi Michal,

On Wed, 2017-11-08 at 08:54 +0100, Michal Simek wrote:
> On 8.11.2017 03:44, Wilson Lee wrote:
> > 
> > Putting board_nand_init() function inside NAND driver was not
> > appropriate
> > due to it doesn't allow board vendor to customise their NAND
> > initialization code such as adding NAND lock/unlock code.
> > 
> > This commit was to move the board_nand_init() function from NAND
> > driver
> > to board.c file. This allow customization of board_nand_init()
> > function.
> > 
> > Signed-off-by: Wilson Lee <wilson@ni.com>
> > Cc: Joe Hershberger <joe.hershber...@ni.com>
> > Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
> > Cc: Chen Yee Chew <chen.yee.c...@ni.com>
> > Cc: Albert Aribaud <albert.u.b...@aribaud.net>
> > Cc: Michal Simek <michal.si...@xilinx.com>
> > Cc: Siva Durga Prasad Paladugu <siva.durga.palad...@xilinx.com>
> > Cc: Scott Wood <o...@buserror.net>
> > ---
> >  arch/arm/mach-zynq/include/mach/nand.h |  9 +
> >  board/xilinx/zynq/board.c  | 10 ++
> >  drivers/mtd/nand/zynq_nand.c   | 12 +---
> >  3 files changed, 20 insertions(+), 11 deletions(-)
> >  create mode 100644 arch/arm/mach-zynq/include/mach/nand.h
> > 
> > diff --git a/arch/arm/mach-zynq/include/mach/nand.h
> > b/arch/arm/mach-zynq/include/mach/nand.h
> > new file mode 100644
> > index 000..61ef45f
> > --- /dev/null
> > +++ b/arch/arm/mach-zynq/include/mach/nand.h
> > @@ -0,0 +1,9 @@
> > +/*
> > + * Copyright (C) 2017 National Instruments Corp.
> > + *
> > + * SPDX-License-Identifier:GPL-2.0+
> > + */
> > +
> > +#include 
> > +
> > +void zynq_nand_init(void);
> > diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
> > index 90ef542..8bcb830 100644
> > --- a/board/xilinx/zynq/board.c
> > +++ b/board/xilinx/zynq/board.c
> > @@ -9,6 +9,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  
> > @@ -156,3 +157,12 @@ int dram_init(void)
> >     return 0;
> >  }
> >  #endif
> > +
> > +static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
> > +void board_nand_init(void)
> > +{
> > +   struct nand_chip *nand = _chip[0];
> > +
> > +   if (zynq_nand_init(nand, 0))
> > +   puts("ZYNQ NAND init failed\n");
> > +}
> This is probably not enough for platforms which don't enable NAND.
> 
> > 
> > diff --git a/drivers/mtd/nand/zynq_nand.c
> > b/drivers/mtd/nand/zynq_nand.c
> > index dec2c41..9be6856 100644
> > --- a/drivers/mtd/nand/zynq_nand.c
> > +++ b/drivers/mtd/nand/zynq_nand.c
> > @@ -1006,7 +1006,7 @@ static int zynq_nand_device_ready(struct
> > mtd_info *mtd)
> >     return 0;
> >  }
> >  
> > -static int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
> > +int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
> >  {
> >     struct zynq_nand_info *xnand;
> >     struct mtd_info *mtd;
> > @@ -1191,13 +1191,3 @@ fail:
> >     free(xnand);
> >     return err;
> >  }
> > -
> > -static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
> > -
> > -void board_nand_init(void)
> > -{
> > -   struct nand_chip *nand = _chip[0];
> > -
> > -   if (zynq_nand_init(nand, 0))
> > -   puts("ZYNQ NAND init failed\n");
> > -}
> > 
> What's the sequence which you want to add?

Actually we wish to perform a NAND unlock right after the NAND was
begin initialized. So that, we can do some write operation (ubifs table
R/W) when we mount it as ubifs.

> Isn't it better just to include this there or create a hook here?

I was thinking for adding a hook here before. But, it will be more make
sense to me if we correct the NAND driver by moving board_nand to
board.c file.

> 
> Definitely some platforms moved this to board file and not a problem
> with moving it because it shouldn't be in nand driver.
> 
> Thanks,
> Michal
> 

Thanks, Michal.

Best Regards,
Wilson Lee
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] ni: Add NIZYNQ platform

2017-11-07 Thread Wilson Lee
Initial platform creation for NIZYNQ.

Signed-off-by: Joe Hershberger <joe.hershber...@ni.com>
Signed-off-by: Keng Soon Cheah <keng.soon.ch...@ni.com>
Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Albert Aribaud <albert.u.b...@aribaud.net>
---
 arch/arm/Kconfig  | 15 +++
 arch/arm/Makefile |  4 +++-
 board/ni/Kconfig  | 13 +
 3 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 board/ni/Kconfig

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 83b7aa5..ae34821 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -767,6 +767,20 @@ config ARCH_ZYNQMP
select DM_USB if USB
imply FAT_WRITE
 
+config NIZYNQ
+   bool "National Instruments zynq Platform"
+   select CPU_V7
+   select SUPPORT_SPL
+   select OF_CONTROL
+   select SPL_OF_CONTROL if SPL
+   select DM
+   select DM_ETH
+   select DM_GPIO
+   select SPL_DM if SPL
+   select DM_MMC
+   select DM_SERIAL
+   select SPL_SEPARATE_BSS if SPL
+
 config TEGRA
bool "NVIDIA Tegra"
imply FAT_WRITE
@@ -1258,6 +1272,7 @@ source "board/hisilicon/hikey/Kconfig"
 source "board/hisilicon/poplar/Kconfig"
 source "board/imx31_phycore/Kconfig"
 source "board/isee/igep003x/Kconfig"
+source "board/ni/Kconfig"
 source "board/olimex/mx23_olinuxino/Kconfig"
 source "board/phytec/pcm051/Kconfig"
 source "board/ppcag/bg0900/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 0e0ae77..fbc271a 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -74,7 +74,9 @@ machine-$(CONFIG_ARCH_ROCKCHIP)   += rockchip
 machine-$(CONFIG_STM32)+= stm32
 machine-$(CONFIG_TEGRA)+= tegra
 machine-$(CONFIG_ARCH_UNIPHIER)+= uniphier
-machine-$(CONFIG_ARCH_ZYNQ)+= zynq
+ifneq (,$(findstring y,$(CONFIG_ZYNQ)$(CONFIG_NIZYNQ)))
+machine-y  += zynq
+endif
 
 machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
diff --git a/board/ni/Kconfig b/board/ni/Kconfig
new file mode 100644
index 000..382a544
--- /dev/null
+++ b/board/ni/Kconfig
@@ -0,0 +1,13 @@
+if NIZYNQ
+choice
+   prompt "NI Zynq board select"
+
+endchoice
+
+config SYS_VENDOR
+   default "ni"
+
+config SYS_SOC
+   default "zynq"
+
+endif
-- 
2.7.4

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


[U-Boot] [PATCH] mtd: zynq: nand: Move board_nand_init() function to board.c

2017-11-07 Thread Wilson Lee
Putting board_nand_init() function inside NAND driver was not appropriate
due to it doesn't allow board vendor to customise their NAND
initialization code such as adding NAND lock/unlock code.

This commit was to move the board_nand_init() function from NAND driver
to board.c file. This allow customization of board_nand_init() function.

Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Albert Aribaud <albert.u.b...@aribaud.net>
Cc: Michal Simek <michal.si...@xilinx.com>
Cc: Siva Durga Prasad Paladugu <siva.durga.palad...@xilinx.com>
Cc: Scott Wood <o...@buserror.net>
---
 arch/arm/mach-zynq/include/mach/nand.h |  9 +
 board/xilinx/zynq/board.c  | 10 ++
 drivers/mtd/nand/zynq_nand.c   | 12 +---
 3 files changed, 20 insertions(+), 11 deletions(-)
 create mode 100644 arch/arm/mach-zynq/include/mach/nand.h

diff --git a/arch/arm/mach-zynq/include/mach/nand.h 
b/arch/arm/mach-zynq/include/mach/nand.h
new file mode 100644
index 000..61ef45f
--- /dev/null
+++ b/arch/arm/mach-zynq/include/mach/nand.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2017 National Instruments Corp.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+
+void zynq_nand_init(void);
diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
index 90ef542..8bcb830 100644
--- a/board/xilinx/zynq/board.c
+++ b/board/xilinx/zynq/board.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -156,3 +157,12 @@ int dram_init(void)
return 0;
 }
 #endif
+
+static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
+void board_nand_init(void)
+{
+   struct nand_chip *nand = _chip[0];
+
+   if (zynq_nand_init(nand, 0))
+   puts("ZYNQ NAND init failed\n");
+}
diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c
index dec2c41..9be6856 100644
--- a/drivers/mtd/nand/zynq_nand.c
+++ b/drivers/mtd/nand/zynq_nand.c
@@ -1006,7 +1006,7 @@ static int zynq_nand_device_ready(struct mtd_info *mtd)
return 0;
 }
 
-static int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
+int zynq_nand_init(struct nand_chip *nand_chip, int devnum)
 {
struct zynq_nand_info *xnand;
struct mtd_info *mtd;
@@ -1191,13 +1191,3 @@ fail:
free(xnand);
return err;
 }
-
-static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
-
-void board_nand_init(void)
-{
-   struct nand_chip *nand = _chip[0];
-
-   if (zynq_nand_init(nand, 0))
-   puts("ZYNQ NAND init failed\n");
-}
-- 
2.7.4

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


[U-Boot] [PATCH] lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.

2017-11-07 Thread Wilson Lee
uint8_t used in sha1_der_prefix array was not able to recognize by
compiler when try to build the tools using 'HOSTCC'. That is because,
uint8_t is undefined when 'HOSTCC' is defined because asm/type.h is not
included in that case. Use unsigned char for sha1_der_prefix[] array
instead.

This commit is to remove and change the uint8_t to unsigned char for
sha1_der_perfix[] array.

Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Andrew Duda <ad...@meraki.com>
Cc: Simon Glass <s...@chromium.org>
---
 include/u-boot/sha1.h | 2 +-
 lib/sha1.c| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/u-boot/sha1.h b/include/u-boot/sha1.h
index 2634a29..b5e55fe 100644
--- a/include/u-boot/sha1.h
+++ b/include/u-boot/sha1.h
@@ -23,7 +23,7 @@ extern "C" {
 #define SHA1_SUM_LEN   20
 #define SHA1_DER_LEN   15
 
-extern const uint8_t sha1_der_prefix[];
+extern const unsigned char sha1_der_prefix[];
 
 /**
  * \brief SHA-1 context structure
diff --git a/lib/sha1.c b/lib/sha1.c
index f54bb5b..d5d58c4 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -26,7 +26,7 @@
 #include 
 #include 
 
-const uint8_t sha1_der_prefix[SHA1_DER_LEN] = {
+const unsigned char sha1_der_prefix[SHA1_DER_LEN] = {
0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14
 };
-- 
2.7.4

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


[U-Boot] [PATCH] net: dhcp: Allow "MAY_FAIL" to still try each adapter

2017-11-07 Thread Wilson Lee
From: Joe Hershberger 

This change allows the "MAY_FAIL" DHCP option to still attempt to
contact a DHCP server on each adapter and only give up once each
adapter has failed once.  To get the existing behavior, set the
already-existing ethrotate=no variable.

Signed-off-by: Joe Hershberger 
Cc: Keng Soon Cheah 
Cc: Chen Yee Chew 
---
 net/bootp.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/net/bootp.c b/net/bootp.c
index 73370a1..cb724e9 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -387,12 +387,19 @@ static void bootp_timeout_handler(void)
 
if (time_taken >= time_taken_max) {
 #ifdef CONFIG_BOOTP_MAY_FAIL
-   puts("\nRetry time exceeded\n");
-   net_set_state(NETLOOP_FAIL);
-#else
-   puts("\nRetry time exceeded; starting again\n");
-   net_start_again();
+   char *ethrotate;
+
+   ethrotate = getenv("ethrotate");
+   if ((ethrotate != NULL && strcmp(ethrotate, "no") == 0) ||
+   net_restart_wrap) {
+   puts("\nRetry time exceeded\n");
+   net_set_state(NETLOOP_FAIL);
+   } else
 #endif
+   {
+   puts("\nRetry time exceeded; starting again\n");
+   net_start_again();
+   }
} else {
bootp_timeout *= 2;
if (bootp_timeout > 2000)
-- 
2.7.4

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


[U-Boot] [RESEND PATCH] mtd: nand: zynq: Add support for the NAND lock/unlock operation

2017-11-06 Thread Wilson Lee
From: Joe Hershberger 

Zynq NAND driver is not support for NAND lock or unlock operation.
Hence, accidentally write into the critical NAND region might cause
data corruption to occur.

This commit is to add NAND lock/unlock command into NAND SMC register
set for NAND lock/unlock operaion.

Signed-off-by: Joe Hershberger 
Signed-off-by: Keng Soon Cheah 
Cc: Chen Yee Chew 
Cc: Siva Durga Prasad Paladugu 
Cc: Michal Simek 
Cc: Scott Wood 
---
 drivers/mtd/nand/zynq_nand.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c
index 948f059..484f1bb 100644
--- a/drivers/mtd/nand/zynq_nand.c
+++ b/drivers/mtd/nand/zynq_nand.c
@@ -81,6 +81,13 @@
 #define ZYNQ_NAND_ECC_BUSY (1 << 6)/* ECC block is busy */
 #define ZYNQ_NAND_ECC_MASK 0x00FF  /* ECC value mask */
 
+#ifndef NAND_CMD_LOCK_TIGHT
+#define NAND_CMD_LOCK_TIGHT 0x2c
+#endif
+
+#ifndef NAND_CMD_LOCK_STATUS
+#define NAND_CMD_LOCK_STATUS 0x7a
+#endif
 
 /* SMC register set */
 struct zynq_nand_smc_regs {
@@ -141,6 +148,11 @@ static const struct zynq_nand_command_format 
zynq_nand_commands[] = {
{NAND_CMD_PARAM, NAND_CMD_NONE, 1, 0},
{NAND_CMD_GET_FEATURES, NAND_CMD_NONE, 1, 0},
{NAND_CMD_SET_FEATURES, NAND_CMD_NONE, 1, 0},
+   {NAND_CMD_LOCK, NAND_CMD_NONE, 0, 0},
+   {NAND_CMD_LOCK_TIGHT, NAND_CMD_NONE, 0, 0},
+   {NAND_CMD_UNLOCK1, NAND_CMD_NONE, 3, 0},
+   {NAND_CMD_UNLOCK2, NAND_CMD_NONE, 3, 0},
+   {NAND_CMD_LOCK_STATUS, NAND_CMD_NONE, 3, 0},
{NAND_CMD_NONE, NAND_CMD_NONE, 0, 0},
/* Add all the flash commands supported by the flash device */
 };
-- 
2.7.4

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


[U-Boot] [RESEND PATCH] net: macb: Add support for Xilinx Zynq SoC

2017-11-06 Thread Wilson Lee
Although Xilinx Zynq SoC was using MACB similar hardware. However,
U-boot MACB driver was not supporting Xilinx Zynq SoC. This patch is
to add support for the Xilinx Zynq SoC to the existing MACB network
driver.

This patch is to add Zynq GEM DMA Config, provide callback
function for different linkspeed for case of using Xilinx Zynq
Programmable Logic as GMII to RGMII convertor.

This patch convert the return value to use error codes.

Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Wenyou Yang <wenyou.y...@atmel.com>
---
 drivers/net/Kconfig |  7 +
 drivers/net/macb.c  | 91 ++---
 drivers/net/macb.h  |  1 +
 3 files changed, 87 insertions(+), 12 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index c1ce54e..e310238 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -185,6 +185,13 @@ config MACB
  GEM (Gigabit Ethernet MAC) found in some ARM SoC devices.
  Say Y to include support for the MACB/GEM chip.
 
+config MACB_ZYNQ
+   bool "Cadence MACB/GEM Ethernet Interface for Xilinx Zynq"
+   depends on MACB
+   help
+ The Cadence MACB ethernet interface was used on Zynq platform.
+ Say Y to enable support for the MACB/GEM in Zynq chip.
+
 config PCH_GBE
bool "Intel Platform Controller Hub EG20T GMAC driver"
depends on DM_ETH && DM_PCI
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index f9373db..e62aefc 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -52,6 +52,22 @@ DECLARE_GLOBAL_DATA_PTR;
 #define MACB_TX_TIMEOUT1000
 #define MACB_AUTONEG_TIMEOUT   500
 
+#ifdef CONFIG_MACB_ZYNQ
+/* INCR4 AHB bursts */
+#define MACB_ZYNQ_GEM_DMACR_BLENGTH0x0004
+/* Use full configured addressable space (8 Kb) */
+#define MACB_ZYNQ_GEM_DMACR_RXSIZE 0x0300
+/* Use full configured addressable space (4 Kb) */
+#define MACB_ZYNQ_GEM_DMACR_TXSIZE 0x0400
+/* Set RXBUF with use of 128 byte */
+#define MACB_ZYNQ_GEM_DMACR_RXBUF  0x0002
+#define MACB_ZYNQ_GEM_DMACR_INIT \
+   (MACB_ZYNQ_GEM_DMACR_BLENGTH | \
+   MACB_ZYNQ_GEM_DMACR_RXSIZE | \
+   MACB_ZYNQ_GEM_DMACR_TXSIZE | \
+   MACB_ZYNQ_GEM_DMACR_RXBUF)
+#endif
+
 struct macb_dma_desc {
u32 addr;
u32 ctrl;
@@ -461,13 +477,25 @@ static int macb_phy_find(struct macb_device *macb, const 
char *name)
phy_id = macb_mdio_read(macb, MII_PHYSID1);
if (phy_id != 0x) {
printf("%s: PHY present at %d\n", name, i);
-   return 1;
+   return 0;
}
}
 
/* PHY isn't up to snuff */
printf("%s: PHY not found\n", name);
 
+   return -ENODEV;
+}
+
+/**
+ * macb_linkspd_cb - Linkspeed change callback function
+ * @regs:  Base Register of MACB devices
+ * @speed: Linkspeed
+ * Returns 0 when operation success and negative errno number
+ * when operation failed.
+ */
+int __weak macb_linkspd_cb(void *regs, unsigned int speed)
+{
return 0;
 }
 
@@ -483,18 +511,20 @@ static int macb_phy_init(struct macb_device *macb, const 
char *name)
u32 ncfgr;
u16 phy_id, status, adv, lpa;
int media, speed, duplex;
+   int ret;
int i;
 
arch_get_mdio_control(name);
/* Auto-detect phy_addr */
-   if (!macb_phy_find(macb, name))
-   return 0;
+   ret = macb_phy_find(macb, name);
+   if (ret)
+   return ret;
 
/* Check if the PHY is up to snuff... */
phy_id = macb_mdio_read(macb, MII_PHYSID1);
if (phy_id == 0x) {
printf("%s: No PHY present\n", name);
-   return 0;
+   return -ENODEV;
}
 
 #ifdef CONFIG_PHYLIB
@@ -530,7 +560,7 @@ static int macb_phy_init(struct macb_device *macb, const 
char *name)
if (!(status & BMSR_LSTATUS)) {
printf("%s: link down (status: 0x%04x)\n",
   name, status);
-   return 0;
+   return -ENETDOWN;
}
 
/* First check for GMAC and that it is GiB capable */
@@ -554,7 +584,11 @@ static int macb_phy_init(struct macb_device *macb, const 
char *name)
 
macb_writel(macb, NCFGR, ncfgr);
 
-   return 1;
+   ret = macb_linkspd_cb(macb->regs, _1000BASET);
+   if (ret)
+   return ret;
+
+   return 0;
}
}
 
@@ -573,13 +607,21 @@ stati

[U-Boot] [PATCH] cmd: console: Add serial devices probe command

2017-11-06 Thread Wilson Lee
U-boot will only probe and register single serial device that selected
to be used as stdio device. This will cause changing of stdio devices
from one serial devices to another serial devices is not possible due
to others serial devices are not registered on the stdio list. This
command will allow user to probe others possible serial console and
register them to stdio list for stdio switching.

Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
---
 cmd/console.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/cmd/console.c b/cmd/console.c
index 9a356ec..5bf897f 100644
--- a/cmd/console.c
+++ b/cmd/console.c
@@ -8,6 +8,7 @@
 /*
  * Boot support
  */
+#include 
 #include 
 #include 
 #include 
@@ -43,6 +44,22 @@ static int do_coninfo(cmd_tbl_t *cmd, int flag, int argc, 
char * const argv[])
return 0;
 }
 
+static int do_conprobe(cmd_tbl_t *cmd, int flag, int argc, char * const argv[])
+{
+   struct udevice *dev;
+   struct uclass *uc;
+
+   uclass_get(UCLASS_SERIAL, );
+   uclass_foreach_dev(dev, uc) {
+   /*
+* Loop through all serial devices, probe and register
+* them with stdio services.
+*/
+   if (device_probe(dev))
+   debug("%s: %s: PROBE FAIL\n", __func__, dev->name);
+   }
+   return 0;
+}
 
 /***/
 
@@ -51,3 +68,9 @@ U_BOOT_CMD(
"print console devices and information",
""
 );
+
+U_BOOT_CMD(
+   conprobe,   3,  1,  do_conprobe,
+   "probe serial devices and register with stdio list",
+   ""
+);
-- 
2.7.4

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


[U-Boot] [PATCH v2] mtd: nand: zynq: Add a config option to use 1st stage bootloader timing

2017-11-06 Thread Wilson Lee
From: Jeff Westfahl <jeff.westf...@ni.com>

In legacy method, 1st stage bootloader was used to configure the HW
setting such as NAND timing. Hence, adding a config option in Zynq
NAND driver for the compatibility of device that using 1st stage
bootloder instead of U-boot SPL.

This commit is to add config option
CONFIG_NAND_ZYNQ_USE_BOOTLOADER1_TIMINGS that allow NAND driver use
timing values set by the 1st stage bootloader, instead of the hard-coded
values in the Zynq NAND driver.

Signed-off-by: Jeff Westfahl <jeff.westf...@ni.com>
Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Siva Durga Prasad Paladugu <siva.durga.palad...@xilinx.com>
Cc: Michal Simek <michal.si...@xilinx.com>
Cc: Scott Wood <o...@buserror.net>
---
 drivers/mtd/nand/Kconfig | 7 +++
 drivers/mtd/nand/zynq_nand.c | 5 +
 2 files changed, 12 insertions(+)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 794410a..3f7edbb 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -164,6 +164,13 @@ config NAND_ZYNQ
  This enables Nand driver support for Nand flash controller
  found on Zynq SoC.
 
+config NAND_ZYNQ_USE_BOOTLOADER1_TIMINGS
+   bool "Enable use of 1st stage bootloader timing for NAND"
+   depends on NAND_ZYNQ
+   help
+ This flag prevent U-boot reconfigure NAND flash controller and reuse
+ the NAND timing from 1st stage bootloader.
+
 comment "Generic NAND options"
 
 # Enhance depends when converting drivers to Kconfig which use this config
diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c
index 484f1bb..dec2c41 100644
--- a/drivers/mtd/nand/zynq_nand.c
+++ b/drivers/mtd/nand/zynq_nand.c
@@ -35,6 +35,8 @@
(0x1 << 4)   |  /* Clear interrupt */ \
(0x1 << 6)) /* Disable ECC interrupt */
 
+#ifndef CONFIG_NAND_ZYNQ_USE_BOOTLOADER1_TIMINGS
+
 /* Assuming 50MHz clock (20ns cycle time) and 3V operation */
 #define ZYNQ_NAND_SET_CYCLES   ((0x2 << 20) |  /* t_rr from nand_cycles */ \
(0x2 << 17)  |  /* t_ar from nand_cycles */ \
@@ -43,6 +45,7 @@
(0x2 << 8)   |  /* t_rea from nand_cycles */ \
(0x5 << 4)   |  /* t_wc from nand_cycles */ \
(0x5 << 0)) /* t_rc from nand_cycles */
+#endif
 
 
 #define ZYNQ_NAND_DIRECT_CMD   ((0x4 << 23) |  /* Chip 0 from interface 1 */ \
@@ -257,8 +260,10 @@ static int zynq_nand_init_nand_flash(int option)
 
/* disable interrupts */
writel(ZYNQ_NAND_CLR_CONFIG, _nand_smc_base->cfr);
+#ifndef CONFIG_NAND_ZYNQ_USE_BOOTLOADER1_TIMINGS
/* Initialize the NAND interface by setting cycles and operation mode */
writel(ZYNQ_NAND_SET_CYCLES, _nand_smc_base->scr);
+#endif
if (option & NAND_BUSWIDTH_16)
writel(ZYNQ_NAND_SET_OPMODE_16BIT, _nand_smc_base->sor);
else
-- 
2.7.4

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


[U-Boot] [PATCH] serial: nulldev: Implement "pending" function to fix tstc return "true"

2017-11-03 Thread Wilson Lee
In U-boot, serial_tstc was use to determine is there have a character in
serial console that pending for read. If there is no "pending" function
implemented in serial driver, the serial-uclass will return "true(1)"
to indicate there have a character pending to read.

Thus, read a character from nulldev serial will result in continuous
getting -EAGAIN return which might lead system to hang.

This commit is to fix a bug in nulldev serial which implement "pending"
function in nulldev serial to always indicate there is no character in
console that pending for read.

Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Bin Meng <bmeng...@gmail.com>
---

 drivers/serial/serial_nulldev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/serial/serial_nulldev.c b/drivers/serial/serial_nulldev.c
index 0768308..17b2310 100644
--- a/drivers/serial/serial_nulldev.c
+++ b/drivers/serial/serial_nulldev.c
@@ -18,6 +18,11 @@ static int nulldev_serial_getc(struct udevice *dev)
return -EAGAIN;
 }
 
+static int nulldev_serial_pending(struct udevice *dev, bool input)
+{
+   return 0;
+}
+
 static int nulldev_serial_input(struct udevice *dev)
 {
return 0;
@@ -36,6 +41,7 @@ static const struct udevice_id nulldev_serial_ids[] = {
 
 const struct dm_serial_ops nulldev_serial_ops = {
.putc = nulldev_serial_putc,
+   .pending = nulldev_serial_pending,
.getc = nulldev_serial_getc,
.setbrg = nulldev_serial_setbrg,
 };
-- 
2.7.4

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


Re: [U-Boot] [PATCH v2] serial: nulldev: Add nulldev serial driver

2017-08-29 Thread Wilson Lee
Hi Bin Meng,

On Tue, 2017-08-29 at 09:41 +0800, Bin Meng wrote:
> Hi Wilson,
> 
> On Fri, Aug 25, 2017 at 11:29 AM, Wilson Lee <wilson@ni.com>
> wrote:
> > 
> > From: Keng Soon Cheah <keng.soon.ch...@ni.com>
> > 
> > Some device the serial console's initialization cannot run early
> > during
> > the boot process. Hence, nulldev serial device is helpful on that
> > situation.
> > 
> > For example, if the serial module was implemented in FPGA. Serial
> > initialization is prohibited to run until the FPGA was programmed.
> > 
> I still don't fully understand this. Shouldn't the FPGA serial driver
> has some sort of register bits that determine if it's ready? And if
> not ready, the FPGA serial driver can do nothing like your null
> serial
> driver does?
> 

In most case we will not implement new FPGA serial driver. For example,
we will try to implement the ns16550 serial module in FPGA and reuse
the ns16550 driver that already exist in u-boot. The ns16550 driver
will not know when is the right time to initialize the console hence
causing system halt.

This nulldev console will eventually help to prevent such situation.
Before the FPGA is ready, all the console initialization and output
will be redirect to this nulldev console. After the FPGA is ready,
"user" have the "flexibility" redirect the console to ns16550 serial
module in FPGA.

> > 
> > This commit is to adding nulldev serial driver. This will allows
> > the
> > default console to be specified as a nulldev.
> > 
> > Signed-off-by: Joe Hershberger <joe.hershber...@ni.com>
> > Signed-off-by: Keng Soon Cheah <keng.soon.ch...@ni.com>
> > Cc: Chen Yee Chew <chen.yee.c...@ni.com>
> > ---
> >  drivers/serial/Kconfig  |  7 ++
> >  drivers/serial/Makefile |  1 +
> >  drivers/serial/serial_nulldev.c | 48
> > +
> >  3 files changed, 56 insertions(+)
> >  create mode 100644 drivers/serial/serial_nulldev.c
> > 
> [snip]
> 
> Regards,
> Bin

Thanks.

Best Regards,
Wilson Lee
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] mtd: nand: zynq: Add a config option to use timing values set by FSBL

2017-08-25 Thread Wilson Lee
From: Jeff Westfahl <jeff.westf...@ni.com>

In legacy method, FSBL was used to configure the HW setting such as
NAND timing. Hence, adding a config option in Zynq NAND driver for the
compability of device that using FSBL instead of U-boot SPL.

This commit is to add config option CONFIG_NAND_ZYNQ_USE_FSBL_TIMINGS
that allow NAND driver use timing values set by the FSBL, instead of
the hard-coded values in the Zynq NAND driver.

Signed-off-by: Jeff Westfahl <jeff.westf...@ni.com>
Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Siva Durga Prasad Paladugu <siva.durga.palad...@xilinx.com>
Cc: Michal Simek <michal.si...@xilinx.com>
Cc: Scott Wood <o...@buserror.net>
---

 drivers/mtd/nand/Kconfig | 6 ++
 drivers/mtd/nand/zynq_nand.c | 5 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 71d678f..44d6aa0 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -121,6 +121,12 @@ config NAND_ZYNQ
  This enables Nand driver support for Nand flash controller
  found on Zynq SoC.
 
+config NAND_ZYNQ_USE_FSBL_TIMINGS
+   bool "Enable use of FSBL timing for NAND"
+   depends on NAND_ZYNQ
+   help
+ This enabled the use of FSBL timing for NAND flash controller.
+
 comment "Generic NAND options"
 
 # Enhance depends when converting drivers to Kconfig which use this config
diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c
index 484f1bb..f292531 100644
--- a/drivers/mtd/nand/zynq_nand.c
+++ b/drivers/mtd/nand/zynq_nand.c
@@ -35,6 +35,8 @@
(0x1 << 4)   |  /* Clear interrupt */ \
(0x1 << 6)) /* Disable ECC interrupt */
 
+#ifndef CONFIG_NAND_ZYNQ_USE_FSBL_TIMINGS
+
 /* Assuming 50MHz clock (20ns cycle time) and 3V operation */
 #define ZYNQ_NAND_SET_CYCLES   ((0x2 << 20) |  /* t_rr from nand_cycles */ \
(0x2 << 17)  |  /* t_ar from nand_cycles */ \
@@ -43,6 +45,7 @@
(0x2 << 8)   |  /* t_rea from nand_cycles */ \
(0x5 << 4)   |  /* t_wc from nand_cycles */ \
(0x5 << 0)) /* t_rc from nand_cycles */
+#endif
 
 
 #define ZYNQ_NAND_DIRECT_CMD   ((0x4 << 23) |  /* Chip 0 from interface 1 */ \
@@ -257,8 +260,10 @@ static int zynq_nand_init_nand_flash(int option)
 
/* disable interrupts */
writel(ZYNQ_NAND_CLR_CONFIG, _nand_smc_base->cfr);
+#ifndef CONFIG_NAND_ZYNQ_USE_FSBL_TIMINGS
/* Initialize the NAND interface by setting cycles and operation mode */
writel(ZYNQ_NAND_SET_CYCLES, _nand_smc_base->scr);
+#endif
if (option & NAND_BUSWIDTH_16)
writel(ZYNQ_NAND_SET_OPMODE_16BIT, _nand_smc_base->sor);
else
-- 
2.7.4

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


[U-Boot] [PATCH] mtd: nand: zynq: Add support for the NAND lock/unlock operation

2017-08-25 Thread Wilson Lee
From: Joe Hershberger <joe.hershber...@ni.com>

Zynq NAND driver is not support for NAND lock or unlock operation.
Hence, accidentally write into the critical NAND region might cause
data corruption to occur.

This commit is to add NAND lock/unlock command into NAND SMC register
set for NAND lock/unlock operaion.

Signed-off-by: Joe Hershberger <joe.hershber...@ni.com>
Signed-off-by: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Siva Durga Prasad Paladugu <siva.durga.palad...@xilinx.com>
Cc: Michal Simek <michal.si...@xilinx.com>
Cc: Scott Wood <o...@buserror.net>
Signed-off-by: Wilson Lee <wilson@ni.com>
---

 drivers/mtd/nand/zynq_nand.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c
index 948f059..484f1bb 100644
--- a/drivers/mtd/nand/zynq_nand.c
+++ b/drivers/mtd/nand/zynq_nand.c
@@ -81,6 +81,13 @@
 #define ZYNQ_NAND_ECC_BUSY (1 << 6)/* ECC block is busy */
 #define ZYNQ_NAND_ECC_MASK 0x00FF  /* ECC value mask */
 
+#ifndef NAND_CMD_LOCK_TIGHT
+#define NAND_CMD_LOCK_TIGHT 0x2c
+#endif
+
+#ifndef NAND_CMD_LOCK_STATUS
+#define NAND_CMD_LOCK_STATUS 0x7a
+#endif
 
 /* SMC register set */
 struct zynq_nand_smc_regs {
@@ -141,6 +148,11 @@ static const struct zynq_nand_command_format 
zynq_nand_commands[] = {
{NAND_CMD_PARAM, NAND_CMD_NONE, 1, 0},
{NAND_CMD_GET_FEATURES, NAND_CMD_NONE, 1, 0},
{NAND_CMD_SET_FEATURES, NAND_CMD_NONE, 1, 0},
+   {NAND_CMD_LOCK, NAND_CMD_NONE, 0, 0},
+   {NAND_CMD_LOCK_TIGHT, NAND_CMD_NONE, 0, 0},
+   {NAND_CMD_UNLOCK1, NAND_CMD_NONE, 3, 0},
+   {NAND_CMD_UNLOCK2, NAND_CMD_NONE, 3, 0},
+   {NAND_CMD_LOCK_STATUS, NAND_CMD_NONE, 3, 0},
{NAND_CMD_NONE, NAND_CMD_NONE, 0, 0},
/* Add all the flash commands supported by the flash device */
 };
-- 
2.7.4

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


[U-Boot] [PATCH] common: console: Fix duplicated CONFIG in silent env callback

2017-08-25 Thread Wilson Lee
The silent environment callback function does not update the silent
flag during silent env set or unset. That is because of duplicated
CONFIG keyword at preprocessor condition in silent environment
callback function and cause silent env callback unable to work.

This patch is to remove the duplicated CONFIG keywork in silent
environment callback function.

Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
---

 common/console.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/console.c b/common/console.c
index 3167921..f83528c 100644
--- a/common/console.c
+++ b/common/console.c
@@ -68,11 +68,11 @@ U_BOOT_ENV_CALLBACK(console, on_console);
 static int on_silent(const char *name, const char *value, enum env_op op,
int flags)
 {
-#if !CONFIG_IS_ENABLED(CONFIG_SILENT_CONSOLE_UPDATE_ON_SET)
+#if !CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_SET)
if (flags & H_INTERACTIVE)
return 0;
 #endif
-#if !CONFIG_IS_ENABLED(CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC)
+#if !CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_RELOC)
if ((flags & H_INTERACTIVE) == 0)
return 0;
 #endif
-- 
2.7.4

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


[U-Boot] [PATCH v2] serial: nulldev: Add nulldev serial driver

2017-08-25 Thread Wilson Lee
From: Keng Soon Cheah 

Some device the serial console's initialization cannot run early during
the boot process. Hence, nulldev serial device is helpful on that
situation.

For example, if the serial module was implemented in FPGA. Serial
initialization is prohibited to run until the FPGA was programmed.

This commit is to adding nulldev serial driver. This will allows the
default console to be specified as a nulldev.

Signed-off-by: Joe Hershberger 
Signed-off-by: Keng Soon Cheah 
Cc: Chen Yee Chew 
---
 drivers/serial/Kconfig  |  7 ++
 drivers/serial/Makefile |  1 +
 drivers/serial/serial_nulldev.c | 48 +
 3 files changed, 56 insertions(+)
 create mode 100644 drivers/serial/serial_nulldev.c

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index a8e9978..5064edf 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -409,6 +409,13 @@ config MXC_UART
  If you have a machine based on a Motorola IMX CPU you
  can enable its onboard serial port by enabling this option.
 
+config NULLDEV_SERIAL
+   bool "Null serial device"
+   help
+ Select this to enable null serial device support. A null serial
+ device merely acts as a placeholder for a serial device and does
+ nothing for all it's operation.
+
 config PIC32_SERIAL
bool "Support for Microchip PIC32 on-chip UART"
depends on DM_SERIAL && MACH_PIC32
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 72a6996..7adcee3 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -49,6 +49,7 @@ obj-$(CONFIG_BCM283X_MU_SERIAL) += serial_bcm283x_mu.o
 obj-$(CONFIG_MSM_SERIAL) += serial_msm.o
 obj-$(CONFIG_MVEBU_A3700_UART) += serial_mvebu_a3700.o
 obj-$(CONFIG_MPC8XX_CONS) += serial_mpc8xx.o
+obj-$(CONFIG_NULLDEV_SERIAL) += serial_nulldev.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_USB_TTY) += usbtty.o
diff --git a/drivers/serial/serial_nulldev.c b/drivers/serial/serial_nulldev.c
new file mode 100644
index 000..0768308
--- /dev/null
+++ b/drivers/serial/serial_nulldev.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015 National Instruments
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+static int nulldev_serial_setbrg(struct udevice *dev, int baudrate)
+{
+   return 0;
+}
+
+static int nulldev_serial_getc(struct udevice *dev)
+{
+   return -EAGAIN;
+}
+
+static int nulldev_serial_input(struct udevice *dev)
+{
+   return 0;
+}
+
+static int nulldev_serial_putc(struct udevice *dev, const char ch)
+{
+   return 0;
+}
+
+static const struct udevice_id nulldev_serial_ids[] = {
+   { .compatible = "nulldev-serial" },
+   { }
+};
+
+
+const struct dm_serial_ops nulldev_serial_ops = {
+   .putc = nulldev_serial_putc,
+   .getc = nulldev_serial_getc,
+   .setbrg = nulldev_serial_setbrg,
+};
+
+U_BOOT_DRIVER(serial_nulldev) = {
+   .name   = "serial_nulldev",
+   .id = UCLASS_SERIAL,
+   .of_match = nulldev_serial_ids,
+   .ops= _serial_ops,
+};
-- 
2.7.4

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


[U-Boot] [PATCH] serial: nulldev: Add nulldev serial driver

2017-08-23 Thread Wilson Lee
From: Keng Soon Cheah <keng.soon.ch...@ni.com>

Some device the serial console's initialization cannot run early during
the boot process. Hence, nulldev serial device is helpful on that
situation.

This commit is to adding nulldev serial driver. This will allows the
default console to be specified as a nulldev.

Signed-off-by: Joe Hershberger <joe.hershber...@ni.com>
Signed-off-by: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Signed-off-by: Wilson Lee <wilson@ni.com>
---

 drivers/serial/Kconfig  |   7 +++
 drivers/serial/Makefile |   1 +
 drivers/serial/serial.c |   2 +
 drivers/serial/serial_nulldev.c | 103 
 include/serial.h|   2 +
 5 files changed, 115 insertions(+)
 create mode 100644 drivers/serial/serial_nulldev.c

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index a8e9978..5064edf 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -409,6 +409,13 @@ config MXC_UART
  If you have a machine based on a Motorola IMX CPU you
  can enable its onboard serial port by enabling this option.
 
+config NULLDEV_SERIAL
+   bool "Null serial device"
+   help
+ Select this to enable null serial device support. A null serial
+ device merely acts as a placeholder for a serial device and does
+ nothing for all it's operation.
+
 config PIC32_SERIAL
bool "Support for Microchip PIC32 on-chip UART"
depends on DM_SERIAL && MACH_PIC32
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 72a6996..7adcee3 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -49,6 +49,7 @@ obj-$(CONFIG_BCM283X_MU_SERIAL) += serial_bcm283x_mu.o
 obj-$(CONFIG_MSM_SERIAL) += serial_msm.o
 obj-$(CONFIG_MVEBU_A3700_UART) += serial_mvebu_a3700.o
 obj-$(CONFIG_MPC8XX_CONS) += serial_mpc8xx.o
+obj-$(CONFIG_NULLDEV_SERIAL) += serial_nulldev.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_USB_TTY) += usbtty.o
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index cc4bdcb..b902162 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -138,6 +138,7 @@ serial_initfunc(mpc8xx_serial_initialize);
 serial_initfunc(mxc_serial_initialize);
 serial_initfunc(mxs_auart_initialize);
 serial_initfunc(ns16550_serial_initialize);
+serial_initfunc(nulldev_serial_initialize);
 serial_initfunc(oc_serial_initialize);
 serial_initfunc(p3mx_serial_initialize);
 serial_initfunc(pl01x_serial_initialize);
@@ -225,6 +226,7 @@ void serial_initialize(void)
mxc_serial_initialize();
mxs_auart_initialize();
ns16550_serial_initialize();
+   nulldev_serial_initialize();
oc_serial_initialize();
p3mx_serial_initialize();
pl01x_serial_initialize();
diff --git a/drivers/serial/serial_nulldev.c b/drivers/serial/serial_nulldev.c
new file mode 100644
index 000..0545a74
--- /dev/null
+++ b/drivers/serial/serial_nulldev.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2015 National Instruments
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+
+#ifndef CONFIG_DM_SERIAL
+
+static int nulldev_init(void)
+{
+   /* nulldev is empty! */
+   return 0;
+}
+
+static void nulldev_setbrg(void)
+{
+   /* nulldev is empty! */
+}
+
+static void nulldev_putc(const char c)
+{
+   /* nulldev is empty! */
+}
+
+static void nulldev_puts(const char *s)
+{
+   /* nulldev is empty! */
+}
+
+static int nulldev_input(void)
+{
+   /* nulldev is empty! */
+   return 0;
+}
+
+struct serial_device nulldev_serial_device = {
+   "nulldev",
+   nulldev_init,
+   NULL,
+   nulldev_setbrg,
+   nulldev_input,
+   nulldev_input,
+   nulldev_putc,
+   nulldev_puts,
+};
+
+void nulldev_serial_initialize(void)
+{
+   serial_register(_serial_device);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+   return _serial_device;
+}
+
+#else /* CONFIG_DM_SERIAL */
+
+static int nulldev_serial_setbrg(struct udevice *dev, int baudrate)
+{
+   return 0;
+}
+
+static int nulldev_serial_getc(struct udevice *dev)
+{
+   return -EAGAIN;
+}
+
+static int nulldev_serial_input(struct udevice *dev)
+{
+   return 0;
+}
+
+static int nulldev_serial_putc(struct udevice *dev, const char ch)
+{
+   return 0;
+}
+
+static const struct udevice_id nulldev_serial_ids[] = {
+   { .compatible = "nulldev-serial" },
+   { }
+};
+
+
+const struct dm_serial_ops nulldev_serial_ops = {
+   .putc = nulldev_serial_putc,
+   .getc = nulldev_serial_getc,
+   .setbrg = nulldev_serial_setbrg,
+};
+
+U_BOOT_DRIVER(serial_nulldev) = {
+   .name   = "serial_nulldev",
+   .id = UCLASS_SERIAL,
+   .of_match = nulldev_serial_ids,
+   .ops= _serial_ops,
+};
+
+#endif /* CONFIG_DM_

[U-Boot] [PATCH] net: macb: Add support for Xilinx Zynq SoC

2017-08-23 Thread Wilson Lee
Although Xilinx Zynq SoC was using MACB similar hardware. However,
U-boot MACB driver was not supporting Xilinx Zynq SoC. This patch is
to add support for the Xilinx Zynq SoC to the existing MACB network
driver.

This patch is to add Zynq GEM DMA Config, provide callback
function for different linkspeed for case of using Xilinx Zynq
Programmable Logic as GMII to RGMII convertor.

This patch convert the return value to use error codes.

Signed-off-by: Wilson Lee <wilson@ni.com>
Cc: Chen Yee Chew <chen.yee.c...@ni.com>
Cc: Keng Soon Cheah <keng.soon.ch...@ni.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Wenyou Yang <wenyou.y...@atmel.com>
---

 drivers/net/Kconfig |  7 +
 drivers/net/macb.c  | 91 ++---
 drivers/net/macb.h  |  1 +
 3 files changed, 87 insertions(+), 12 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 5ceea44..6c54f93 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -177,6 +177,13 @@ config MACB
  GEM (Gigabit Ethernet MAC) found in some ARM SoC devices.
  Say Y to include support for the MACB/GEM chip.
 
+config MACB_ZYNQ
+   bool "Cadence MACB/GEM Ethernet Interface for Xilinx Zynq"
+   depends on MACB
+   help
+ The Cadence MACB ethernet interface was used on Zynq platform.
+ Say Y to enable support for the MACB/GEM in Zynq chip.
+
 config PCH_GBE
bool "Intel Platform Controller Hub EG20T GMAC driver"
depends on DM_ETH && DM_PCI
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index f9373db..e62aefc 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -52,6 +52,22 @@ DECLARE_GLOBAL_DATA_PTR;
 #define MACB_TX_TIMEOUT1000
 #define MACB_AUTONEG_TIMEOUT   500
 
+#ifdef CONFIG_MACB_ZYNQ
+/* INCR4 AHB bursts */
+#define MACB_ZYNQ_GEM_DMACR_BLENGTH0x0004
+/* Use full configured addressable space (8 Kb) */
+#define MACB_ZYNQ_GEM_DMACR_RXSIZE 0x0300
+/* Use full configured addressable space (4 Kb) */
+#define MACB_ZYNQ_GEM_DMACR_TXSIZE 0x0400
+/* Set RXBUF with use of 128 byte */
+#define MACB_ZYNQ_GEM_DMACR_RXBUF  0x0002
+#define MACB_ZYNQ_GEM_DMACR_INIT \
+   (MACB_ZYNQ_GEM_DMACR_BLENGTH | \
+   MACB_ZYNQ_GEM_DMACR_RXSIZE | \
+   MACB_ZYNQ_GEM_DMACR_TXSIZE | \
+   MACB_ZYNQ_GEM_DMACR_RXBUF)
+#endif
+
 struct macb_dma_desc {
u32 addr;
u32 ctrl;
@@ -461,13 +477,25 @@ static int macb_phy_find(struct macb_device *macb, const 
char *name)
phy_id = macb_mdio_read(macb, MII_PHYSID1);
if (phy_id != 0x) {
printf("%s: PHY present at %d\n", name, i);
-   return 1;
+   return 0;
}
}
 
/* PHY isn't up to snuff */
printf("%s: PHY not found\n", name);
 
+   return -ENODEV;
+}
+
+/**
+ * macb_linkspd_cb - Linkspeed change callback function
+ * @regs:  Base Register of MACB devices
+ * @speed: Linkspeed
+ * Returns 0 when operation success and negative errno number
+ * when operation failed.
+ */
+int __weak macb_linkspd_cb(void *regs, unsigned int speed)
+{
return 0;
 }
 
@@ -483,18 +511,20 @@ static int macb_phy_init(struct macb_device *macb, const 
char *name)
u32 ncfgr;
u16 phy_id, status, adv, lpa;
int media, speed, duplex;
+   int ret;
int i;
 
arch_get_mdio_control(name);
/* Auto-detect phy_addr */
-   if (!macb_phy_find(macb, name))
-   return 0;
+   ret = macb_phy_find(macb, name);
+   if (ret)
+   return ret;
 
/* Check if the PHY is up to snuff... */
phy_id = macb_mdio_read(macb, MII_PHYSID1);
if (phy_id == 0x) {
printf("%s: No PHY present\n", name);
-   return 0;
+   return -ENODEV;
}
 
 #ifdef CONFIG_PHYLIB
@@ -530,7 +560,7 @@ static int macb_phy_init(struct macb_device *macb, const 
char *name)
if (!(status & BMSR_LSTATUS)) {
printf("%s: link down (status: 0x%04x)\n",
   name, status);
-   return 0;
+   return -ENETDOWN;
}
 
/* First check for GMAC and that it is GiB capable */
@@ -554,7 +584,11 @@ static int macb_phy_init(struct macb_device *macb, const 
char *name)
 
macb_writel(macb, NCFGR, ncfgr);
 
-   return 1;
+   ret = macb_linkspd_cb(macb->regs, _1000BASET);
+   if (ret)
+   return ret;
+
+   return 0;
}
}
 
@@ -573,13 +607,21 @@ stati