Re: [PATCH] mmc: omap_hsmmc: Add guards around omap_hsmmc_get_cfg()

2020-06-04 Thread Lokesh Vutla



On 05/06/20 1:33 am, Tom Rini wrote:
> We only call the function omap_hsmmc_get_cfg in the case of OMAP34XX or
> when we have to iodelay recalibration.  Add guards for these checks as
> clang will otherwise warn.
> 
> Cc: Peng Fan 
> Cc: Lokesh Vutla 
> Signed-off-by: Tom Rini 

Reviewed-by: Lokesh Vutla 

> ---
> Aside, Lokesh, can you please add drivers/mmc/omap_hsmmc.c to the
> general TI entry MAINTAINERS entry?  Thanks!

We have a subsystem maintainer for MMC. IIUC, all the patches should go through
subsystem if one is available, so I intentionally did not add omap_hsmmc under
TI. Is my understanding wrong?

Thanks and regards,
Lokesh



Re: [PATCH] gpio: omap_gpio: Fix unused function warning in non-DM case

2020-06-04 Thread Lokesh Vutla



On 05/06/20 1:31 am, Tom Rini wrote:
> In the case of non-DM_GPIO the function get_gpio_index() will never be
> called, and clang will warn about this.  Move this to be with the other
> non-DM code for easier removal later.
> 
> Cc: Lokesh Vutla 
> Signed-off-by: Tom Rini 

Reviewed-by: Lokesh Vutla 

Thanks and regards,
Lokesh

> ---
>  drivers/gpio/omap_gpio.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
> index 4249850f4bf9..c986ef03805c 100644
> --- a/drivers/gpio/omap_gpio.c
> +++ b/drivers/gpio/omap_gpio.c
> @@ -41,11 +41,6 @@ struct gpio_bank {
>  
>  #endif
>  
> -static inline int get_gpio_index(int gpio)
> -{
> - return gpio & 0x1f;
> -}
> -
>  int gpio_is_valid(int gpio)
>  {
>   return (gpio >= 0) && (gpio < OMAP_MAX_GPIO);
> @@ -122,6 +117,10 @@ static int _get_gpio_value(const struct gpio_bank *bank, 
> int gpio)
>  }
>  
>  #if !CONFIG_IS_ENABLED(DM_GPIO)
> +static inline int get_gpio_index(int gpio)
> +{
> + return gpio & 0x1f;
> +}
>  
>  static inline const struct gpio_bank *get_gpio_bank(int gpio)
>  {
> 


Re: [PATCH] board: ti: common: Fix pointer-bool-conversion warnings

2020-06-04 Thread Lokesh Vutla



On 05/06/20 1:15 am, Tom Rini wrote:
> When building this code with clang-10 a number of warnings will be
> generated along the lines of:
> warning: address of array 'ep->version' will always evaluate to 'true'
> 
> Convert these checks to checking the strlen of the part of the array we
> care about.  As this array will be null terminated previously by us,
> this is safe.
> 
> Cc: Lokesh Vutla > Signed-off-by: Tom Rini 
> 

Reviewed-by: Lokesh Vutla 

Thanks and regards,
Lokesh



Re: [PATCH v2 17/23] ti: Drop omap5 uevm

2020-06-04 Thread Lokesh Vutla
Hi Jagan,

On 27/05/20 6:26 pm, Jagan Teki wrote:
> DM, DM_SPI and other driver model migration deadlines
> are expired for this board.
> 
> Drop it.
> 
> Cc: Lokesh Vutla 
> Signed-off-by: Jagan Teki 

Please hold this patch. I see patches in ML for converting to DM
https://patchwork.ozlabs.org/project/uboot/list/?series=180914

Thanks and regards,
Lokesh

> ---
> Changes for v2:
> - none
> 
>  arch/arm/mach-omap2/omap5/Kconfig |   4 -
>  board/ti/omap5_uevm/Kconfig   |  12 --
>  board/ti/omap5_uevm/MAINTAINERS   |   6 -
>  board/ti/omap5_uevm/Makefile  |   6 -
>  board/ti/omap5_uevm/README|  25 ---
>  board/ti/omap5_uevm/evm.c | 283 --
>  board/ti/omap5_uevm/mux_data.h|  57 --
>  configs/omap5_uevm_defconfig  |  55 --
>  include/configs/omap5_uevm.h  |  62 ---
>  9 files changed, 510 deletions(-)
>  delete mode 100644 board/ti/omap5_uevm/Kconfig
>  delete mode 100644 board/ti/omap5_uevm/MAINTAINERS
>  delete mode 100644 board/ti/omap5_uevm/Makefile
>  delete mode 100644 board/ti/omap5_uevm/README
>  delete mode 100644 board/ti/omap5_uevm/evm.c
>  delete mode 100644 board/ti/omap5_uevm/mux_data.h
>  delete mode 100644 configs/omap5_uevm_defconfig
>  delete mode 100644 include/configs/omap5_uevm.h
> 
> diff --git a/arch/arm/mach-omap2/omap5/Kconfig 
> b/arch/arm/mach-omap2/omap5/Kconfig
> index a0c0b93a00..e73106e321 100644
> --- a/arch/arm/mach-omap2/omap5/Kconfig
> +++ b/arch/arm/mach-omap2/omap5/Kconfig
> @@ -9,9 +9,6 @@ choice
>   prompt "OMAP5 board select"
>   optional
>  
> -config TARGET_OMAP5_UEVM
> - bool "TI OMAP5 uEVM board"
> -
>  config TARGET_DRA7XX_EVM
>   bool "TI DRA7XX"
>   select BOARD_LATE_INIT
> @@ -153,7 +150,6 @@ endchoice
>  endmenu
>  endif
>  
> -source "board/ti/omap5_uevm/Kconfig"
>  source "board/ti/dra7xx/Kconfig"
>  source "board/ti/am57xx/Kconfig"
>  
> diff --git a/board/ti/omap5_uevm/Kconfig b/board/ti/omap5_uevm/Kconfig
> deleted file mode 100644
> index aa13844544..00
> --- a/board/ti/omap5_uevm/Kconfig
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -if TARGET_OMAP5_UEVM
> -
> -config SYS_BOARD
> - default "omap5_uevm"
> -
> -config SYS_VENDOR
> - default "ti"
> -
> -config SYS_CONFIG_NAME
> - default "omap5_uevm"
> -
> -endif
> diff --git a/board/ti/omap5_uevm/MAINTAINERS b/board/ti/omap5_uevm/MAINTAINERS
> deleted file mode 100644
> index 280ea2f91f..00
> --- a/board/ti/omap5_uevm/MAINTAINERS
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -OMAP5_UEVM BOARD
> -M:   Lokesh Vutla 
> -S:   Maintained
> -F:   board/ti/omap5_uevm/
> -F:   include/configs/omap5_uevm.h
> -F:   configs/omap5_uevm_defconfig
> diff --git a/board/ti/omap5_uevm/Makefile b/board/ti/omap5_uevm/Makefile
> deleted file mode 100644
> index 17ee516d26..00
> --- a/board/ti/omap5_uevm/Makefile
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0+
> -#
> -# (C) Copyright 2000, 2001, 2002
> -# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
> -
> -obj-y:= evm.o
> diff --git a/board/ti/omap5_uevm/README b/board/ti/omap5_uevm/README
> deleted file mode 100644
> index 970e2eceb7..00
> --- a/board/ti/omap5_uevm/README
> +++ /dev/null
> @@ -1,25 +0,0 @@
> -Summary
> -===
> -
> -This document covers various features of the 'omap5_uevm' build and some
> -related uses.
> -
> -eMMC boot partition use
> -===
> -
> -It is possible, depending on SYSBOOT configuration to boot from the eMMC
> -boot partitions using (name depending on documentation referenced)
> -Alternative Boot operation mode or Boot Sequence Option 1/2.  In this
> -example we load MLO and u-boot.img from the build into DDR and then use
> -'mmc bootbus' to set the required rate (see TRM) and 'mmc partconfig' to
> -set boot0 as the boot device.
> -U-Boot # setenv autoload no
> -U-Boot # usb start
> -U-Boot # dhcp
> -U-Boot # mmc dev 1 1
> -U-Boot # tftp ${loadaddr} omap5uevm/MLO
> -U-Boot # mmc write ${loadaddr} 0 100
> -U-Boot # tftp ${loadaddr} omap5uevm/u-boot.img
> -U-Boot # mmc write ${loadaddr} 300 400
> -U-Boot # mmc bootbus 1 2 0 2
> -U-Boot # mmc partconf 1 1 1 0
> diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
> deleted file mode 100644
> index e35f319b46..00
> --- a/board/ti/omap5_uevm/evm.c
> +++ /dev/null
> @@ -1,283 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -/*
> - * (C) Copyright 2010
> - * Texas Instruments Incorporated, 
> - * Aneesh V   
> - * Steve Sakoman  
> - */
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -#include "mux_data.h"
> -
> -#if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_XHCI_OMAP)
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -#define DIE_ID_REG_BASE (OMAP54XX_L4_CORE_BASE + 0x2000)
> 

Re: [PATCH v2 15/23] ti: Drop panda board

2020-06-04 Thread Lokesh Vutla
Hi Jagan,

On 27/05/20 6:26 pm, Jagan Teki wrote:
> DM, DM_SPI and other driver model migration deadlines
> are expired for this board.
> 
> Drop it.
> 
> Cc: Lokesh Vutla 
> Signed-off-by: Jagan Teki 

Please hold this patch. I see patches in ML for converting to DM
https://patchwork.ozlabs.org/project/uboot/list/?series=180809

Thanks and regards,
Lokesh

> ---
> Changes for v2:
> - none
> 
>  arch/arm/mach-omap2/omap4/Kconfig |   4 -
>  board/ti/panda/Kconfig|  12 --
>  board/ti/panda/MAINTAINERS|   6 -
>  board/ti/panda/Makefile   |   6 -
>  board/ti/panda/panda.c| 346 --
>  board/ti/panda/panda_mux_data.h   |  86 
>  configs/omap4_panda_defconfig |  42 
>  include/configs/omap4_panda.h |  34 ---
>  8 files changed, 536 deletions(-)
>  delete mode 100644 board/ti/panda/Kconfig
>  delete mode 100644 board/ti/panda/MAINTAINERS
>  delete mode 100644 board/ti/panda/Makefile
>  delete mode 100644 board/ti/panda/panda.c
>  delete mode 100644 board/ti/panda/panda_mux_data.h
>  delete mode 100644 configs/omap4_panda_defconfig
>  delete mode 100644 include/configs/omap4_panda.h
> 
> diff --git a/arch/arm/mach-omap2/omap4/Kconfig 
> b/arch/arm/mach-omap2/omap4/Kconfig
> index 899289b645..4cc360f38a 100644
> --- a/arch/arm/mach-omap2/omap4/Kconfig
> +++ b/arch/arm/mach-omap2/omap4/Kconfig
> @@ -4,9 +4,6 @@ choice
>   prompt "OMAP4 board select"
>   optional
>  
> -config TARGET_OMAP4_PANDA
> - bool "TI OMAP4 PandaBoard"
> -
>  config TARGET_OMAP4_SDP4430
>   bool "TI OMAP4 SDP4430"
>  
> @@ -18,7 +15,6 @@ endchoice
>  config SYS_SOC
>   default "omap4"
>  
> -source "board/ti/panda/Kconfig"
>  source "board/ti/sdp4430/Kconfig"
>  source "board/amazon/kc1/Kconfig"
>  
> diff --git a/board/ti/panda/Kconfig b/board/ti/panda/Kconfig
> deleted file mode 100644
> index 8f277b612a..00
> --- a/board/ti/panda/Kconfig
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -if TARGET_OMAP4_PANDA
> -
> -config SYS_BOARD
> - default "panda"
> -
> -config SYS_VENDOR
> - default "ti"
> -
> -config SYS_CONFIG_NAME
> - default "omap4_panda"
> -
> -endif
> diff --git a/board/ti/panda/MAINTAINERS b/board/ti/panda/MAINTAINERS
> deleted file mode 100644
> index 2142368271..00
> --- a/board/ti/panda/MAINTAINERS
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -PANDA BOARD
> -M:   Lokesh Vutla 
> -S:   Maintained
> -F:   board/ti/panda/
> -F:   include/configs/omap4_panda.h
> -F:   configs/omap4_panda_defconfig
> diff --git a/board/ti/panda/Makefile b/board/ti/panda/Makefile
> deleted file mode 100644
> index dd2ff33afa..00
> --- a/board/ti/panda/Makefile
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0+
> -#
> -# (C) Copyright 2000, 2001, 2002
> -# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
> -
> -obj-y:= panda.o
> diff --git a/board/ti/panda/panda.c b/board/ti/panda/panda.c
> deleted file mode 100644
> index 9ebecfdbf5..00
> --- a/board/ti/panda/panda.c
> +++ /dev/null
> @@ -1,346 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -/*
> - * (C) Copyright 2010
> - * Texas Instruments Incorporated, 
> - * Steve Sakoman  
> - */
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -#include "panda_mux_data.h"
> -
> -#ifdef CONFIG_USB_EHCI_HCD
> -#include 
> -#include 
> -#include 
> -#endif
> -
> -#define PANDA_ULPI_PHY_TYPE_GPIO   182
> -#define PANDA_BOARD_ID_1_GPIO  101
> -#define PANDA_ES_BOARD_ID_1_GPIO48
> -#define PANDA_BOARD_ID_2_GPIO  171
> -#define PANDA_ES_BOARD_ID_3_GPIO 3
> -#define PANDA_ES_BOARD_ID_4_GPIO 2
> -
> -DECLARE_GLOBAL_DATA_PTR;
> -
> -const struct omap_sysinfo sysinfo = {
> - "Board: OMAP4 Panda\n"
> -};
> -
> -struct omap4_scrm_regs *const scrm = (struct omap4_scrm_regs *)0x4a30a000;
> -
> -/**
> - * @brief board_init
> - *
> - * @return 0
> - */
> -int board_init(void)
> -{
> - gpmc_init();
> -
> - gd->bd->bi_arch_number = MACH_TYPE_OMAP4_PANDA;
> - gd->bd->bi_boot_params = (0x8000 + 0x100); /* boot param addr */
> -
> - return 0;
> -}
> -
> -int board_eth_init(bd_t *bis)
> -{
> - return 0;
> -}
> -
> -/*
> -* Routine: get_board_revision
> -* Description: Detect if we are running on a panda revision A1-A6,
> -*  or an ES panda board. This can be done by reading
> -*  the level of GPIOs and checking the processor revisions.
> -*  This should result in:
> -*Panda 4430:
> -*  GPIO171, GPIO101, GPIO182: 0 1 1 => A1-A5
> -*  GPIO171, GPIO101, GPIO182: 1 0 1 => A6
> -*Panda ES:
> -*  GPIO2, GPIO3, GPIO171, GPIO48, GPIO182: 0 0 0 1 1 => B1/B2
> -*  GPIO2, GPIO3, GPIO171, GPIO48, GPIO182: 0 0 1 1 1 => B3
> -*/
> -int get_board_revision(void)
> -{
> - 

Re: [PATCH v7 2/3] dm: core: fix dev_read_alias_highest_id() without libfdt

2020-06-04 Thread Simon Glass
On Mon, 1 Jun 2020 at 17:47, Michael Walle  wrote:
>
> If CONFIG_DM_DEV_READ_INLINE is set, dev_read_alias_highest_id() calls
> libfdt_get_highest_id(). But this function is only available if we have
> libfdt compiled in. If its not available return -1, which matches the
> return code for no alias found.
>
> This fixes the following error on omapl138_lcdk:
> arm-linux-gnueabi-ld.bfd: drivers/built-in.o: in function 
> `dev_read_alias_highest_id':
> /home/mw/repo/u-boot/include/dm/read.h:986: undefined reference to 
> `fdtdec_get_alias_highest_id'
>
> Signed-off-by: Michael Walle 
> ---
>  include/dm/read.h | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] smbios: empty strings in smbios_add_string()

2020-06-04 Thread Simon Glass
On Mon, 1 Jun 2020 at 07:44, Heinrich Schuchardt  wrote:
>
> smbios_add_string() cannot deal with empty strings. This leads to incorrect
> property values and invalid tables. E.g. for the pine64-lts_defconfig
> CONFIG_SMBIOS_MANUFACTURER="". Linux command dmidecode shows:
>
> Table 1:
> Manufacturer: sunxi
> Product Name: sunxi
>
> Table 3:
> Invalid entry length (2). DMI table is broken! Stop.
>
> Replace empty strings by "Unknown".
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  lib/smbios.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH] RFC: tiny-dm: Proposal for using driver model in SPL

2020-06-04 Thread Simon Glass
Hi,

On Thu, 4 Jun 2020 at 21:11, Simon Glass  wrote:
>
> Hi Walter,
>
> On Mon, 1 Jun 2020 at 14:55, Walter Lozano  
> wrote:
> >
> > Hi Simon,
> >
> > On 26/5/20 15:39, Walter Lozano wrote:
> > > Hi Simon,
> > >
> > > On 25/5/20 18:40, Simon Glass wrote:
> > >> Hi Tom,
> > >>
> > >> On Mon, 25 May 2020 at 14:57, Tom Rini  wrote:
> > >>> On Mon, May 25, 2020 at 02:34:20PM -0600, Simon Glass wrote:
> >  Hi Tom,
> > 
> >  On Mon, 25 May 2020 at 13:47, Tom Rini  wrote:
> > > On Mon, May 25, 2020 at 09:35:44AM -0600, Simon Glass wrote:
> > >
> > >> This patch provides the documentation for a proposed enhancement
> > >> to driver
> > >> model to reduce overhead in SPL.
> > >>
> > >> The actual patches are not included here because they are based
> > >> on some
> > >> pending work by Walter Lozano which is not in final form.
> > >>
> > >> For now, the source tree is available at:
> > >>
> > >> https://gitlab.denx.de/u-boot/custodians/u-boot-dm/-/tree/dtoc-working
> > >>
> > >>
> > >> Comments welcome!
> > > So here's my worry.  It's not clear, aside from the device tree, how
> > > much re-use of existing code we get with this.  It feels like it
> > > might
> > > be fairly minimal.  And at that point, are we not perhaps making too
> > > much work for ourselves compared with just excepting that there will
> > > need to be a place for non-abstracted-framework drivers? What do
> > > we do
> > > about TPL, when we get to the point of everything being converted
> > > to DM
> > > and as-needed tiny-DM but there's still TPL drivers?  The reason
> > > we have
> > > SPL_FRAMEWORK as a symbol today is that we already had some
> > > SoCs/architectures (primarily PowerPC) that had "SPL" but it was very
> > > centric to the SoCs in question.
> > >
> > > The interface for example for mmc is:
> > > int spl_mmc_load_image(struct spl_image_info *spl_image, struct
> > > spl_boot_device *bootdev) and neither part of that is inherently
> > > DM.  So
> > > let it be MMC_TINY for the non-DM case and regular DM_MMC for the DM
> > > case.  I wonder if we could clean that up code a little if we let
> > > it be
> > > separate.
> > >
> > > The interface for example for spi is:
> > > int spl_spi_load_image(struct spl_image_info *spl_image,
> > > struct spl_boot_device *bootdev) and well, the same thing.  Or
> > > maybe we
> > > can even push that up to the spi_flash_load() call.
> > >
> > > But my worry is that a different set of abstractions here are still
> > > going to bring us in more overhead than writing drivers for the
> > > functionality we need directly, and if we define what's allowed in
> > > this
> > > limited case well, that might be good enough.
> >  Some boards (e.g. x86) Need to read multiple things from the SPI flash
> >  (such as FSP binaries), so I still think we will want a generic
> >  reading interface.
> > 
> >  You could be right, but my hunch is that there is value in having
> >  things more generic and the cost should be minimal. The value is that
> >  hopefully writing a few C functions in the SPI driver will be enough
> >  to enable tiny SPI on an SoC, reusing much of the code in the driver
> >  (only the reading bits!). We won't need as much special-case code and
> >  an entirely different way of configuring these devices for TPL/SPL.
> > 
> >  It has been interesting digging into the Zephyr model. It's drivers
> >  are very basic and thus small. But there is still value in using the
> >  device tree to assemble things.
> > 
> >  Anyway I'm not really sure at this point. It is just a hunch. I don't
> >  think we can know all this until we have a bit more information.
> >  Perhaps with a board with SPI, MMC and serial converted we would get a
> >  better picture?
> > >>> I think it's absolutely the case that we'll have to convert something
> > >>> and see how it looks, then convert something else and see if it still
> > >>> looks good enough.  At a high enough level there's not really too much
> > >>> of a difference between what it sounds like you're proposing and what
> > >>> I'm proposing.  Possibly even in a progmatic way too.  We have (I think
> > >>> anyhow) fairly static board configurations in this case so we don't so
> > >>> much need to "probe" for possible drivers be told what our device
> > >>> hierarchy is and to initialize what we're going to use.
> > >> Yes, we may end up with special, separate code anyway, since if you
> > >> end up refactoring the driver so much (and putting tiny-dm tentacles
> > >> into it) that it becomes harder to maintain, it isn't a win.
> > >>
> > >> Basically I started out similar to what you are saying, with the idea
> > >> of just direct calls into the driver (e.g. the driver 

[PATCH 1/1] doc: Coccinelle: move to HTML doc

2020-06-04 Thread Heinrich Schuchardt
Move doc/README.coccinelle to doc/develop/coccinelle.rst using the current
linux-next version of the text.

Signed-off-by: Heinrich Schuchardt 
---
 doc/README.coccinelle  | 491 
 doc/develop/coccinelle.rst | 505 +
 doc/develop/index.rst  |   1 +
 3 files changed, 506 insertions(+), 491 deletions(-)
 delete mode 100644 doc/README.coccinelle
 create mode 100644 doc/develop/coccinelle.rst

diff --git a/doc/README.coccinelle b/doc/README.coccinelle
deleted file mode 100644
index 4a64b4c69d..00
--- a/doc/README.coccinelle
+++ /dev/null
@@ -1,491 +0,0 @@
-.. Copyright 2010 Nicolas Palix 
-.. Copyright 2010 Julia Lawall 
-.. Copyright 2010 Gilles Muller 
-
-.. highlight:: none
-
-Coccinelle
-==
-
-Coccinelle is a tool for pattern matching and text transformation that has
-many uses in kernel development, including the application of complex,
-tree-wide patches and detection of problematic programming patterns.
-
-Getting Coccinelle

-
-The semantic patches included in the kernel use features and options
-which are provided by Coccinelle version 1.0.0-rc11 and above.
-Using earlier versions will fail as the option names used by
-the Coccinelle files and coccicheck have been updated.
-
-Coccinelle is available through the package manager
-of many distributions, e.g. :
-
- - Debian
- - Fedora
- - Ubuntu
- - OpenSUSE
- - Arch Linux
- - NetBSD
- - FreeBSD
-
-You can get the latest version released from the Coccinelle homepage at
-http://coccinelle.lip6.fr/
-
-Information and tips about Coccinelle are also provided on the wiki
-pages at http://cocci.ekstranet.diku.dk/wiki/doku.php
-
-Once you have it, run the following command::
-
-   ./configure
-make
-
-as a regular user, and install it with::
-
-sudo make install
-
-Supplemental documentation

-
-For supplemental documentation refer to the wiki:
-
-https://bottest.wiki.kernel.org/coccicheck
-
-The wiki documentation always refers to the linux-next version of the script.
-
-Using Coccinelle on the Linux kernel
-
-
-A Coccinelle-specific target is defined in the top level
-Makefile. This target is named ``coccicheck`` and calls the ``coccicheck``
-front-end in the ``scripts`` directory.
-
-Four basic modes are defined: ``patch``, ``report``, ``context``, and
-``org``. The mode to use is specified by setting the MODE variable with
-``MODE=``.
-
-- ``patch`` proposes a fix, when possible.
-
-- ``report`` generates a list in the following format:
-  file:line:column-column: message
-
-- ``context`` highlights lines of interest and their context in a
-  diff-like style.Lines of interest are indicated with ``-``.
-
-- ``org`` generates a report in the Org mode format of Emacs.
-
-Note that not all semantic patches implement all modes. For easy use
-of Coccinelle, the default mode is "report".
-
-Two other modes provide some common combinations of these modes.
-
-- ``chain`` tries the previous modes in the order above until one succeeds.
-
-- ``rep+ctxt`` runs successively the report mode and the context mode.
-  It should be used with the C option (described later)
-  which checks the code on a file basis.
-
-Examples
-
-
-To make a report for every semantic patch, run the following command::
-
-   make coccicheck MODE=report
-
-To produce patches, run::
-
-   make coccicheck MODE=patch
-
-
-The coccicheck target applies every semantic patch available in the
-sub-directories of ``scripts/coccinelle`` to the entire Linux kernel.
-
-For each semantic patch, a commit message is proposed.  It gives a
-description of the problem being checked by the semantic patch, and
-includes a reference to Coccinelle.
-
-As any static code analyzer, Coccinelle produces false
-positives. Thus, reports must be carefully checked, and patches
-reviewed.
-
-To enable verbose messages set the V= variable, for example::
-
-   make coccicheck MODE=report V=1
-
-Coccinelle parallelization

-
-By default, coccicheck tries to run as parallel as possible. To change
-the parallelism, set the J= variable. For example, to run across 4 CPUs::
-
-   make coccicheck MODE=report J=4
-
-As of Coccinelle 1.0.2 Coccinelle uses Ocaml parmap for parallelization,
-if support for this is detected you will benefit from parmap parallelization.
-
-When parmap is enabled coccicheck will enable dynamic load balancing by using
-``--chunksize 1`` argument, this ensures we keep feeding threads with work
-one by one, so that we avoid the situation where most work gets done by only
-a few threads. With dynamic load balancing, if a thread finishes early we keep
-feeding it more work.
-
-When parmap is enabled, if an error occurs in Coccinelle, this error
-value is propagated back, the return value of the ``make coccicheck``
-captures this return value.
-
-Using 

Re: [PATCH] RFC: tiny-dm: Proposal for using driver model in SPL

2020-06-04 Thread Simon Glass
Hi Tom,

On Tue, 2 Jun 2020 at 07:53, Tom Rini  wrote:
>
> On Mon, Jun 01, 2020 at 05:55:31PM -0300, Walter Lozano wrote:
> > Hi Simon,
> >
> > On 26/5/20 15:39, Walter Lozano wrote:
> > > Hi Simon,
> > >
> > > On 25/5/20 18:40, Simon Glass wrote:
> > > > Hi Tom,
> > > >
> > > > On Mon, 25 May 2020 at 14:57, Tom Rini  wrote:
> > > > > On Mon, May 25, 2020 at 02:34:20PM -0600, Simon Glass wrote:
> > > > > > Hi Tom,
> > > > > >
> > > > > > On Mon, 25 May 2020 at 13:47, Tom Rini  wrote:
> > > > > > > On Mon, May 25, 2020 at 09:35:44AM -0600, Simon Glass wrote:
> > > > > > >
> > > > > > > > This patch provides the documentation for a proposed
> > > > > > > > enhancement to driver
> > > > > > > > model to reduce overhead in SPL.
> > > > > > > >
> > > > > > > > The actual patches are not included here because
> > > > > > > > they are based on some
> > > > > > > > pending work by Walter Lozano which is not in final form.
> > > > > > > >
> > > > > > > > For now, the source tree is available at:
> > > > > > > >
> > > > > > > > https://gitlab.denx.de/u-boot/custodians/u-boot-dm/-/tree/dtoc-working
> > > > > > > >
> > > > > > > >
> > > > > > > > Comments welcome!
> > > > > > > So here's my worry.  It's not clear, aside from the device tree, 
> > > > > > > how
> > > > > > > much re-use of existing code we get with this.  It feels
> > > > > > > like it might
> > > > > > > be fairly minimal.  And at that point, are we not perhaps making 
> > > > > > > too
> > > > > > > much work for ourselves compared with just excepting that there 
> > > > > > > will
> > > > > > > need to be a place for non-abstracted-framework drivers?
> > > > > > > What do we do
> > > > > > > about TPL, when we get to the point of everything being
> > > > > > > converted to DM
> > > > > > > and as-needed tiny-DM but there's still TPL drivers?
> > > > > > > The reason we have
> > > > > > > SPL_FRAMEWORK as a symbol today is that we already had some
> > > > > > > SoCs/architectures (primarily PowerPC) that had "SPL" but it was 
> > > > > > > very
> > > > > > > centric to the SoCs in question.
> > > > > > >
> > > > > > > The interface for example for mmc is:
> > > > > > > int spl_mmc_load_image(struct spl_image_info *spl_image, struct
> > > > > > > spl_boot_device *bootdev) and neither part of that is
> > > > > > > inherently DM.  So
> > > > > > > let it be MMC_TINY for the non-DM case and regular DM_MMC for the 
> > > > > > > DM
> > > > > > > case.  I wonder if we could clean that up code a little
> > > > > > > if we let it be
> > > > > > > separate.
> > > > > > >
> > > > > > > The interface for example for spi is:
> > > > > > > int spl_spi_load_image(struct spl_image_info *spl_image,
> > > > > > > struct spl_boot_device *bootdev) and well, the same
> > > > > > > thing.  Or maybe we
> > > > > > > can even push that up to the spi_flash_load() call.
> > > > > > >
> > > > > > > But my worry is that a different set of abstractions here are 
> > > > > > > still
> > > > > > > going to bring us in more overhead than writing drivers for the
> > > > > > > functionality we need directly, and if we define what's
> > > > > > > allowed in this
> > > > > > > limited case well, that might be good enough.
> > > > > > Some boards (e.g. x86) Need to read multiple things from the SPI 
> > > > > > flash
> > > > > > (such as FSP binaries), so I still think we will want a generic
> > > > > > reading interface.
> > > > > >
> > > > > > You could be right, but my hunch is that there is value in having
> > > > > > things more generic and the cost should be minimal. The value is 
> > > > > > that
> > > > > > hopefully writing a few C functions in the SPI driver will be enough
> > > > > > to enable tiny SPI on an SoC, reusing much of the code in the driver
> > > > > > (only the reading bits!). We won't need as much special-case code 
> > > > > > and
> > > > > > an entirely different way of configuring these devices for TPL/SPL.
> > > > > >
> > > > > > It has been interesting digging into the Zephyr model. It's drivers
> > > > > > are very basic and thus small. But there is still value in using the
> > > > > > device tree to assemble things.
> > > > > >
> > > > > > Anyway I'm not really sure at this point. It is just a hunch. I 
> > > > > > don't
> > > > > > think we can know all this until we have a bit more information.
> > > > > > Perhaps with a board with SPI, MMC and serial converted we would 
> > > > > > get a
> > > > > > better picture?
> > > > > I think it's absolutely the case that we'll have to convert something
> > > > > and see how it looks, then convert something else and see if it still
> > > > > looks good enough.  At a high enough level there's not really too much
> > > > > of a difference between what it sounds like you're proposing and what
> > > > > I'm proposing.  Possibly even in a progmatic way too.  We have (I 
> > > > > think
> > > > > anyhow) fairly static board configurations in this case so we don't so
> > > > > much need to "probe" for possible drivers 

Re: [PATCH] RFC: tiny-dm: Proposal for using driver model in SPL

2020-06-04 Thread Simon Glass
Hi Walter,

On Mon, 1 Jun 2020 at 14:55, Walter Lozano  wrote:
>
> Hi Simon,
>
> On 26/5/20 15:39, Walter Lozano wrote:
> > Hi Simon,
> >
> > On 25/5/20 18:40, Simon Glass wrote:
> >> Hi Tom,
> >>
> >> On Mon, 25 May 2020 at 14:57, Tom Rini  wrote:
> >>> On Mon, May 25, 2020 at 02:34:20PM -0600, Simon Glass wrote:
>  Hi Tom,
> 
>  On Mon, 25 May 2020 at 13:47, Tom Rini  wrote:
> > On Mon, May 25, 2020 at 09:35:44AM -0600, Simon Glass wrote:
> >
> >> This patch provides the documentation for a proposed enhancement
> >> to driver
> >> model to reduce overhead in SPL.
> >>
> >> The actual patches are not included here because they are based
> >> on some
> >> pending work by Walter Lozano which is not in final form.
> >>
> >> For now, the source tree is available at:
> >>
> >> https://gitlab.denx.de/u-boot/custodians/u-boot-dm/-/tree/dtoc-working
> >>
> >>
> >> Comments welcome!
> > So here's my worry.  It's not clear, aside from the device tree, how
> > much re-use of existing code we get with this.  It feels like it
> > might
> > be fairly minimal.  And at that point, are we not perhaps making too
> > much work for ourselves compared with just excepting that there will
> > need to be a place for non-abstracted-framework drivers? What do
> > we do
> > about TPL, when we get to the point of everything being converted
> > to DM
> > and as-needed tiny-DM but there's still TPL drivers?  The reason
> > we have
> > SPL_FRAMEWORK as a symbol today is that we already had some
> > SoCs/architectures (primarily PowerPC) that had "SPL" but it was very
> > centric to the SoCs in question.
> >
> > The interface for example for mmc is:
> > int spl_mmc_load_image(struct spl_image_info *spl_image, struct
> > spl_boot_device *bootdev) and neither part of that is inherently
> > DM.  So
> > let it be MMC_TINY for the non-DM case and regular DM_MMC for the DM
> > case.  I wonder if we could clean that up code a little if we let
> > it be
> > separate.
> >
> > The interface for example for spi is:
> > int spl_spi_load_image(struct spl_image_info *spl_image,
> > struct spl_boot_device *bootdev) and well, the same thing.  Or
> > maybe we
> > can even push that up to the spi_flash_load() call.
> >
> > But my worry is that a different set of abstractions here are still
> > going to bring us in more overhead than writing drivers for the
> > functionality we need directly, and if we define what's allowed in
> > this
> > limited case well, that might be good enough.
>  Some boards (e.g. x86) Need to read multiple things from the SPI flash
>  (such as FSP binaries), so I still think we will want a generic
>  reading interface.
> 
>  You could be right, but my hunch is that there is value in having
>  things more generic and the cost should be minimal. The value is that
>  hopefully writing a few C functions in the SPI driver will be enough
>  to enable tiny SPI on an SoC, reusing much of the code in the driver
>  (only the reading bits!). We won't need as much special-case code and
>  an entirely different way of configuring these devices for TPL/SPL.
> 
>  It has been interesting digging into the Zephyr model. It's drivers
>  are very basic and thus small. But there is still value in using the
>  device tree to assemble things.
> 
>  Anyway I'm not really sure at this point. It is just a hunch. I don't
>  think we can know all this until we have a bit more information.
>  Perhaps with a board with SPI, MMC and serial converted we would get a
>  better picture?
> >>> I think it's absolutely the case that we'll have to convert something
> >>> and see how it looks, then convert something else and see if it still
> >>> looks good enough.  At a high enough level there's not really too much
> >>> of a difference between what it sounds like you're proposing and what
> >>> I'm proposing.  Possibly even in a progmatic way too.  We have (I think
> >>> anyhow) fairly static board configurations in this case so we don't so
> >>> much need to "probe" for possible drivers be told what our device
> >>> hierarchy is and to initialize what we're going to use.
> >> Yes, we may end up with special, separate code anyway, since if you
> >> end up refactoring the driver so much (and putting tiny-dm tentacles
> >> into it) that it becomes harder to maintain, it isn't a win.
> >>
> >> Basically I started out similar to what you are saying, with the idea
> >> of just direct calls into the driver (e.g. the driver implements
> >> serial_putc() and spi_read_flash()). But then I figured it is a very
> >> small overhead to retain some sort of driver model, so I thought I'd
> >> try that.
> >>
> >> I'll fiddle with this again in a week or so...
> >
> > Thanks for this proposal.
> 

[PATCH 1/1] doc: move Clang documentation to HTML

2020-06-04 Thread Heinrich Schuchardt
* Move README.clang to doc/build/clang.rst and reformat as
  reStructeredText.
* Indicate that -ffixed-r9 and -ffixed-x18 are used to reserve registers
  for gd.
* Minor editing.

Signed-off-by: Heinrich Schuchardt 
---
 doc/README.clang| 55 
 doc/build/clang.rst | 76 +
 doc/build/index.rst |  1 +
 3 files changed, 77 insertions(+), 55 deletions(-)
 delete mode 100644 doc/README.clang
 create mode 100644 doc/build/clang.rst

diff --git a/doc/README.clang b/doc/README.clang
deleted file mode 100644
index 475bb1e2ed..00
--- a/doc/README.clang
+++ /dev/null
@@ -1,55 +0,0 @@
-The biggest problem when trying to compile U-Boot with clang is that
-almost all archs rely on storing gd in a global register and clang user
-manual states: "clang does not support global register variables; this
-is unlikely to be implemented soon because it requires additional LLVM
-backend support."
-
-Since version 3.4 the ARM backend can be instructed to leave r9 alone.
-Global registers themselves are not supported so some inline assembly is
-used to get its value. This does lead to larger code then strictly
-necessary, but at least works.
-
-NOTE: target compilation only work for _some_ ARM boards at the moment.
-Also AArch64 is not supported currently due to a lack of private libgcc
-support.  Boards which reassign gd in c will also fail to compile, but there is
-in no strict reason to do so in the ARM world, since crt0.S takes care of this.
-These assignments can be avoided by changing the init calls but this is not in
-mainline yet.
-
-Debian (based)
---
-Binary packages can be installed as usual, e.g.:
-sudo apt-get install clang
-
-Note that we still use binutils for some tools so we must continue to set
-CROSS_COMPILE. To compile U-Boot with clang on linux without IAS use e.g.:
-make HOSTCC=clang rpi_2_defconfig
-make HOSTCC=clang CROSS_COMPILE=arm-linux-gnueabi- \
-CC="clang -target arm-linux-gnueabi" -j8
-
-It can also be used to compile sandbox:
-make HOSTCC=clang sandbox_defconfig
-make HOSTCC=clang CC=clang -j8
-
-FreeBSD 11 (Current):
-
-Since llvm 3.4 is currently in the base system, the integrated as is
-incapable of building U-Boot. Therefore gas from devel/arm-gnueabi-binutils
-is used instead. It needs a symlinks to be picked up correctly though:
-
-ln -s /usr/local/bin/arm-gnueabi-freebsd-as /usr/bin/arm-freebsd-eabi-as
-
-# The following commands compile U-Boot using the clang xdev toolchain.
-# NOTE: CROSS_COMPILE and target differ on purpose!
-export CROSS_COMPILE=arm-gnueabi-freebsd-
-gmake rpi_2_defconfig
-gmake CC="clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd" -j8
-
-Given that U-Boot will default to gcc, above commands can be
-simplified with a simple wrapper script, listed below.
-
-/usr/local/bin/arm-gnueabi-freebsd-gcc

-#!/bin/sh
-
-exec clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd "$@"
diff --git a/doc/build/clang.rst b/doc/build/clang.rst
new file mode 100644
index 00..1d35616eb5
--- /dev/null
+++ b/doc/build/clang.rst
@@ -0,0 +1,76 @@
+Building with Clang
+===
+
+The biggest problem when trying to compile U-Boot with Clang is that almost all
+archs rely on storing gd in a global register and the Clang 3.5 user manual
+states: "Clang does not support global register variables; this is unlikely to
+be implemented soon because it requires additional LLVM backend support."
+
+The ARM backend can be instructed not to use the r9 and x18 registers using
+-ffixed-r9 or -ffixed-x18 respectively. As global registers themselves are not
+supported inline assembly is needed to get and set the r9 or x18 value. This
+leads to larger code then strictly necessary, but at least works.
+
+**NOTE:** target compilation only work for _some_ ARM boards at the moment.
+Also AArch64 is not supported currently due to a lack of private libgcc
+support. Boards which reassign gd in c will also fail to compile, but there is
+in no strict reason to do so in the ARM world, since crt0.S takes care of this.
+These assignments can be avoided by changing the init calls but this is not in
+mainline yet.
+
+
+Debian based
+
+
+Required packages can be installed via apt, e.g.
+
+.. code-block:: bash
+
+sudo apt-get install clang
+
+Note that we still use binutils for some tools so we must continue to set
+CROSS_COMPILE. To compile U-Boot with Clang on Linux without IAS use e.g.
+
+.. code-block:: bash
+
+make HOSTCC=clang rpi_2_defconfig
+make HOSTCC=clang CROSS_COMPILE=arm-linux-gnueabi- \
+ CC="clang -target arm-linux-gnueabi" -j8
+
+It can also be used to compile sandbox:
+
+.. code-block:: bash
+
+make HOSTCC=clang sandbox_defconfig
+make HOSTCC=clang CC=clang -j8
+
+
+FreeBSD 11
+--
+
+Since llvm 3.4 is currently in the base system, the integrated assembler as
+is incapable of building U-Boot. Therefore gas 

Re: [PATCH v2 8/8] rockchip: puma: enable new usb config options

2020-06-04 Thread Kever Yang



On 2020/6/4 下午6:09, Heiko Stuebner wrote:

From: Heiko Stuebner 

With recently added changes we get support for usb3 including handling
of the phys (type-c and inno-usb2), so enable the necessary config
options on puma.

Signed-off-by: Heiko Stuebner 


Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  configs/puma-rk3399_defconfig | 5 +
  1 file changed, 5 insertions(+)

diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig
index 31d4eb3471..6b7d2ee6b8 100644
--- a/configs/puma-rk3399_defconfig
+++ b/configs/puma-rk3399_defconfig
@@ -59,6 +59,8 @@ CONFIG_PHY_MICREL_KSZ90X1=y
  CONFIG_DM_ETH=y
  CONFIG_ETH_DESIGNWARE=y
  CONFIG_GMAC_ROCKCHIP=y
+CONFIG_PHY_ROCKCHIP_INNO_USB2=y
+CONFIG_PHY_ROCKCHIP_TYPEC=y
  CONFIG_DM_PMIC_FAN53555=y
  CONFIG_PMIC_RK8XX=y
  CONFIG_SPL_DM_REGULATOR=y
@@ -67,6 +69,7 @@ CONFIG_SPL_DM_REGULATOR_FIXED=y
  CONFIG_DM_REGULATOR_GPIO=y
  CONFIG_REGULATOR_RK8XX=y
  CONFIG_PWM_ROCKCHIP=y
+CONFIG_DM_RESET=y
  CONFIG_DM_RTC=y
  CONFIG_RTC_ISL1208=y
  CONFIG_DEBUG_UART_SHIFT=2
@@ -77,6 +80,8 @@ CONFIG_USB_XHCI_HCD=y
  CONFIG_USB_XHCI_DWC3=y
  CONFIG_USB_EHCI_HCD=y
  CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
  CONFIG_USB_HOST_ETHER=y
  CONFIG_USB_ETHER_ASIX=y
  CONFIG_USB_ETHER_ASIX88179=y





Re: [PATCH v2 7/8] rockchip: puma: drop special handling of usb host regulator

2020-06-04 Thread Kever Yang



On 2020/6/4 下午6:09, Heiko Stuebner wrote:

From: Heiko Stuebner 

With the current usb stack in u-boot, all host ports on puma work
flawlessly without any additional special handling, so drop that
usb hub hacking from the puma board.

Tested with mass-storage and usb-ethernet on both usb3 and usb2 ports.

Signed-off-by: Heiko Stuebner 


Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  .../puma_rk3399/puma-rk3399.c | 67 ---
  1 file changed, 67 deletions(-)

diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c 
b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
index 65bb2ad6f2..deeba3084a 100644
--- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c
+++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
@@ -152,70 +152,3 @@ void get_board_serial(struct tag_serialnr *serialnr)
serialnr->low = (u32)(serial & 0x);
  }
  #endif
-
-/**
- * Switch power at an external regulator (for our root hub).
- *
- * @param ctrl pointer to the xHCI controller
- * @param port port number as in the control message (one-based)
- * @param enable boolean indicating whether to enable or disable power
- * @return returns 0 on success, an error-code on failure
- */
-static int board_usb_port_power_set(struct udevice *dev, int port,
-   bool enable)
-{
-#if CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_REGULATOR)
-   /* We start counting ports at 0, while USB counts from 1. */
-   int index = port - 1;
-   const char *regname = NULL;
-   struct udevice *regulator;
-   const char *prop = "tsd,usb-port-power";
-   int ret;
-
-   debug("%s: ctrl '%s' port %d enable %s\n", __func__,
- dev_read_name(dev), port, enable ? "true" : "false");
-
-   ret = dev_read_string_index(dev, prop, index, );
-   if (ret < 0) {
-   debug("%s: ctrl '%s' port %d: no entry in '%s'\n",
- __func__, dev_read_name(dev), port, prop);
-   return ret;
-   }
-
-   ret = regulator_get_by_platname(regname, );
-   if (ret) {
-   debug("%s: ctrl '%s' port %d: could not get regulator '%s'\n",
- __func__, dev_read_name(dev), port, regname);
-   return ret;
-   }
-
-   regulator_set_enable(regulator, enable);
-   return 0;
-#else
-   return -ENOTSUPP;
-#endif
-}
-
-void usb_hub_reset_devices(struct usb_hub_device *hub, int port)
-{
-   struct udevice *dev = hub->pusb_dev->dev;
-   struct udevice *ctrl;
-
-   /* We are only interested in our root-hubs */
-   if (usb_hub_is_root_hub(dev) == false)
-   return;
-
-   ctrl = usb_get_bus(dev);
-   if (!ctrl) {
-   debug("%s: could not retrieve ctrl for hub\n", __func__);
-   return;
-   }
-
-   /*
-* To work around an incompatibility between the single-threaded
-* USB stack in U-Boot and (a strange low-power mode of) the USB
-* hub we have on-module, we need to delay powering on the hub
-* until the first time the port is probed.
-*/
-   board_usb_port_power_set(ctrl, port, true);
-}





Re: [PATCH v2 6/8] rockchip: puma: remove separate fit generator

2020-06-04 Thread Kever Yang



On 2020/6/4 下午6:09, Heiko Stuebner wrote:

From: Heiko Stuebner 

The introduction of the puma-specific generator was mainly a way
to split the pmu firmware from the ATF binary and not having to
distribute that 4GB (sparse) image that was created before moving
to the bl31.elf as base.

Looking at the publically available repository for that separate
pmu firmware
 https://git.theobroma-systems.com/rk3399-cortex-m0.git/
there is also no activity for 3 years and apart from some build
customizations no other changes were done.

And even then, if changes need to be made, this can very well also
happen in the atf context itself, so there is no real need to
diverge from the established build procedure and we can just go
back to using the main make_fit_atf.py script.

Signed-off-by: Heiko Stuebner 
Reviewed-by: Philipp Tomsich 


Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  .../puma_rk3399/fit_spl_atf.sh| 94 ---
  configs/puma-rk3399_defconfig |  1 -
  2 files changed, 95 deletions(-)
  delete mode 100755 board/theobroma-systems/puma_rk3399/fit_spl_atf.sh

diff --git a/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh 
b/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh
deleted file mode 100755
index c9396577a9..00
--- a/board/theobroma-systems/puma_rk3399/fit_spl_atf.sh
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/sh
-#
-# SPDX-License-Identifier:  GPL-2.0+
-#
-# Copyright (C) 2019 Jagan Teki 
-#
-# Based on the board/sunxi/mksunxi_fit_atf.sh
-#
-# Script to generate FIT image source for 64-bit puma boards with
-# U-Boot proper, ATF, PMU firmware and devicetree.
-#
-# usage: $0  [ [&2
-   echo "Please read Building section in doc/README.rockchip" >&2
-   BL31=/dev/null
-fi
-
-[ -z "$PMUM0" ] && PMUM0="rk3399m0.bin"
-
-if [ ! -f $PMUM0 ]; then
-   echo "WARNING: PMUM0 file $PMUM0 NOT found, resulting binary is 
non-functional" >&2
-   echo "Please read Building section in doc/README.rockchip" >&2
-   PMUM0=/dev/null
-fi
-
-cat << __HEADER_EOF
-/* SPDX-License-Identifier: GPL-2.0+ OR X11 */
-/*
- * Copyright (C) 2017 Theobroma Systems Design und Consulting GmbH
- *
- * Minimal dts for a SPL FIT image payload.
- */
-
-/dts-v1/;
-
-/ {
-   description = "FIT image with U-Boot proper, ATF bl31, M0 Firmware, 
DTB";
-   #address-cells = <1>;
-
-   images {
-   uboot {
-   description = "U-Boot (64-bit)";
-   data = /incbin/("u-boot-nodtb.bin");
-   type = "standalone";
-   arch = "arm64";
-   compression = "none";
-   load = <0x4a00>;
-   };
-   atf {
-   description = "ARM Trusted Firmware";
-   data = /incbin/("$BL31");
-   type = "firmware";
-   arch = "arm64";
-   os = "arm-trusted-firmware";
-   compression = "none";
-   load = <0x1000>;
-   entry = <0x1000>;
-   };
-   pmu {
-   description = "Cortex-M0 firmware";
-   data = /incbin/("$PMUM0");
-   type = "pmu-firmware";
-   compression = "none";
-   load = <0x18>;
-};
-   fdt {
-   description = "RK3399-Q7 (Puma) flat device-tree";
-   data = /incbin/("$1");
-   type = "flat_dt";
-   compression = "none";
-   };
-__HEADER_EOF
-
-cat << __CONF_HEADER_EOF
-   };
-
-   configurations {
-   default = "conf";
-   conf {
-   description = "Theobroma Systems RK3399-Q7 (Puma) SoM";
-   firmware = "atf";
-   loadables = "uboot", "pmu";
-   fdt = "fdt";
-   };
-__CONF_HEADER_EOF
-
-cat << __ITS_EOF
-   };
-};
-__ITS_EOF
diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig
index 47a60930b6..31d4eb3471 100644
--- a/configs/puma-rk3399_defconfig
+++ b/configs/puma-rk3399_defconfig
@@ -14,7 +14,6 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y
  CONFIG_SPL_SPI_SUPPORT=y
  CONFIG_SPL_TEXT_BASE=0xff8c2000
  CONFIG_DEBUG_UART=y
-CONFIG_SPL_FIT_GENERATOR="board/theobroma-systems/puma_rk3399/fit_spl_atf.sh"
  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-puma-haikou.dtb"
  CONFIG_MISC_INIT_R=y
  CONFIG_DISPLAY_BOARDINFO_LATE=y





Re: [PATCH v2 5/8] rockchip: puma: reorganize devicetrees to actually work and match upstream

2020-06-04 Thread Kever Yang

Hi Heiko,

On 2020/6/4 下午6:09, Heiko Stuebner wrote:

index 00..f23ec02783
--- /dev/null
+++ b/arch/arm/dts/rk3399-puma-haikou.dts
@@ -0,0 +1,272 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
+ */
+
+/dts-v1/;
+#include "rk3399-puma.dtsi"
+#include "rk3399-puma-u-boot.dtsi"


There will be a "rk3399-puma-haikou-u-boot.dtsi " auto detect and 
include in the dts,


so "rk3399-puma-u-boot.dtsi " should be rename or included to  
"rk3399-puma-haikou-u-boot.dtsi ".


After this update, the "rk3399-puma-haikou.dts" can sync from kernel 
without any modify.



Thanks,

- Kever





Re: [PATCH v2 4/8] rockchip: puma: fix indentation of misc_init_r

2020-06-04 Thread Kever Yang



On 2020/6/4 下午6:09, Heiko Stuebner wrote:

From: Heiko Stuebner 

The commit moving puma to the generic cpuid/macaddr helpers used 7 spaces
as indentation, so correct that by moving to the required tabs.

Fixes: fa177ff0208b ("board: puma: Use rockchip_* helpers to setup cpuid and 
macaddr")
Signed-off-by: Heiko Stuebner 
Reviewed-by: Philipp Tomsich 


Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  .../puma_rk3399/puma-rk3399.c | 32 +--
  1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c 
b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
index f7f08ae617..65bb2ad6f2 100644
--- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c
+++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
@@ -114,22 +114,22 @@ static int setup_boottargets(void)
  
  int misc_init_r(void)

  {
-   const u32 cpuid_offset = 0x7;
-   const u32 cpuid_length = 0x10;
-   u8 cpuid[cpuid_length];
-   int ret;
-
-   ret = rockchip_cpuid_from_efuse(cpuid_offset, cpuid_length, cpuid);
-   if (ret)
-   return ret;
-
-   ret = rockchip_cpuid_set(cpuid, cpuid_length);
-   if (ret)
-   return ret;
-
-   ret = rockchip_setup_macaddr();
-   if (ret)
-   return ret;
+   const u32 cpuid_offset = 0x7;
+   const u32 cpuid_length = 0x10;
+   u8 cpuid[cpuid_length];
+   int ret;
+
+   ret = rockchip_cpuid_from_efuse(cpuid_offset, cpuid_length, cpuid);
+   if (ret)
+   return ret;
+
+   ret = rockchip_cpuid_set(cpuid, cpuid_length);
+   if (ret)
+   return ret;
+
+   ret = rockchip_setup_macaddr();
+   if (ret)
+   return ret;
  
  	setup_iodomain();

setup_boottargets();





Re: [PATCH v2 3/8] rockchip: puma: fix indentation for -u-boot.dtsi

2020-06-04 Thread Kever Yang



On 2020/6/4 下午6:09, Heiko Stuebner wrote:

From: Heiko Stuebner 

Tabs not spaces, so transform it to the common styling.

Signed-off-by: Heiko Stuebner 
Reviewed-by: Philipp Tomsich 


Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  arch/arm/dts/rk3399-puma-u-boot.dtsi | 30 ++--
  1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/arm/dts/rk3399-puma-u-boot.dtsi 
b/arch/arm/dts/rk3399-puma-u-boot.dtsi
index 3ad1139833..ddb5fa6e76 100644
--- a/arch/arm/dts/rk3399-puma-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-puma-u-boot.dtsi
@@ -2,24 +2,24 @@
  
  #include "rk3399-u-boot.dtsi"

  / {
-   config {
-   u-boot,spl-payload-offset = <0x4>; /* @ 256KB */
-   u-boot,mmc-env-offset = <0x4000>;  /* @  16KB */
-   u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */
-   u-boot,boot-led = "module_led";
-   sysreset-gpio = < RK_PA6 GPIO_ACTIVE_HIGH>;
-   };
+   config {
+   u-boot,spl-payload-offset = <0x4>; /* @ 256KB */
+   u-boot,mmc-env-offset = <0x4000>;  /* @  16KB */
+   u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */
+   u-boot,boot-led = "module_led";
+   sysreset-gpio = < RK_PA6 GPIO_ACTIVE_HIGH>;
+   };
  
-   chosen {

-   stdout-path = "serial0:115200n8";
-   u-boot,spl-boot-order = \
+   chosen {
+   stdout-path = "serial0:115200n8";
+   u-boot,spl-boot-order = \
"same-as-spl", , , 
-   };
+   };
  
-   aliases {

-   spi0 = 
-   spi1 = 
-   };
+   aliases {
+   spi0 = 
+   spi1 = 
+   };
  
  	/*

 * The Qseven BIOS_DISABLE signal on the RK3399-Q7 keeps the on-module





Re: [PATCH v2 2/8] arm64: dts: rk3399-puma: fix gpio levels for vcc5v0-host regulator

2020-06-04 Thread Kever Yang



On 2020/6/4 下午6:09, Heiko Stuebner wrote:

From: Heiko Stuebner 

The regulator enable-gpio uses opposite values for the declaration
vs. the enable_active_low property, breaking the regulator enablement.

Make the usbhost-supply work again by bringing them in sync again.

This mimics the upstream Linux change found on:
http://lore.kernel.org/r/20200604091239.424318-1-he...@sntech.de

Signed-off-by: Heiko Stuebner 


Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  arch/arm/dts/rk3399-puma.dtsi | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/rk3399-puma.dtsi b/arch/arm/dts/rk3399-puma.dtsi
index 531520e771..72c06abd27 100644
--- a/arch/arm/dts/rk3399-puma.dtsi
+++ b/arch/arm/dts/rk3399-puma.dtsi
@@ -101,7 +101,7 @@
  
  	vcc5v0_host: vcc5v0-host-regulator {

compatible = "regulator-fixed";
-   gpio = < RK_PA3 GPIO_ACTIVE_HIGH>;
+   gpio = < RK_PA3 GPIO_ACTIVE_LOW>;
enable-active-low;
pinctrl-names = "default";
pinctrl-0 = <_host_en>;





Re: [PATCH v2 1/8] arm64: dts: rk3399-puma: fix gpio levels for gmac reset pin

2020-06-04 Thread Kever Yang



On 2020/6/4 下午6:09, Heiko Stuebner wrote:

From: Heiko Stuebner 

The gmac reset has opposite values for the gpio declaration
and the separate reset-active, bring this in line to make
u-boot also find the ethernet-phy.

This mimics the upstream Linux commit found on
https://lore.kernel.org/r/20200603132836.362519-1-he...@sntech.de

Signed-off-by: Heiko Stuebner 
Reviewed-by: Philipp Tomsich 


Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  arch/arm/dts/rk3399-puma.dtsi | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/rk3399-puma.dtsi b/arch/arm/dts/rk3399-puma.dtsi
index 07694b196f..531520e771 100644
--- a/arch/arm/dts/rk3399-puma.dtsi
+++ b/arch/arm/dts/rk3399-puma.dtsi
@@ -157,7 +157,7 @@
phy-mode = "rgmii";
pinctrl-names = "default";
pinctrl-0 = <_pins>;
-   snps,reset-gpio = < RK_PC0 GPIO_ACTIVE_HIGH>;
+   snps,reset-gpio = < RK_PC0 GPIO_ACTIVE_LOW>;
snps,reset-active-low;
snps,reset-delays-us = <0 1 5>;
tx_delay = <0x10>;





RE: [PATCH] mmc: omap_hsmmc: Add guards around omap_hsmmc_get_cfg()

2020-06-04 Thread Peng Fan
> Subject: [PATCH] mmc: omap_hsmmc: Add guards around
> omap_hsmmc_get_cfg()
> 
> We only call the function omap_hsmmc_get_cfg in the case of OMAP34XX or
> when we have to iodelay recalibration.  Add guards for these checks as clang
> will otherwise warn.
> 
> Cc: Peng Fan 
> Cc: Lokesh Vutla 
> Signed-off-by: Tom Rini 
> ---
> Aside, Lokesh, can you please add drivers/mmc/omap_hsmmc.c to the
> general TI entry MAINTAINERS entry?  Thanks!
> ---
>  drivers/mmc/omap_hsmmc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
> index 8636cd713a36..0e05fe4cfcbb 100644
> --- a/drivers/mmc/omap_hsmmc.c
> +++ b/drivers/mmc/omap_hsmmc.c
> @@ -175,6 +175,8 @@ static inline struct omap_hsmmc_data
> *omap_hsmmc_get_data(struct mmc *mmc)
>   return (struct omap_hsmmc_data *)mmc->priv;  #endif  }
> +
> +#if defined(CONFIG_OMAP34XX) ||
> defined(CONFIG_IODELAY_RECALIBRATION)
>  static inline struct mmc_config *omap_hsmmc_get_cfg(struct mmc *mmc)
> {  #if CONFIG_IS_ENABLED(DM_MMC) @@ -184,6 +186,7 @@ static inline
> struct mmc_config *omap_hsmmc_get_cfg(struct mmc *mmc)
>   return &((struct omap_hsmmc_data *)mmc->priv)->cfg;  #endif  }
> +#endif
> 
>  #if defined(OMAP_HSMMC_USE_GPIO)
> && !CONFIG_IS_ENABLED(DM_MMC)  static int
> omap_mmc_setup_gpio_in(int gpio, const char *label)
> --
> 2.17.1

Reviewed-by: Peng Fan 



[PATCH] tpm: add TPM2_GetRandom command support

2020-06-04 Thread Dhananjay Phadke
Add support for TPM2 GetRandom command

Signed-off-by: Dhananjay Phadke 
---
 include/tpm-v2.h | 13 +
 lib/tpm-v2.c | 44 
 2 files changed, 57 insertions(+)

diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index ae00803f6d..513697e9a1 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -70,6 +70,7 @@ enum tpm2_handles {
  * @TPM2_CC_DAM_RESET: TPM2_DictionaryAttackLockReset().
  * @TPM2_CC_DAM_PARAMETERS: TPM2_DictionaryAttackParameters().
  * @TPM2_CC_GET_CAPABILITY: TPM2_GetCapibility().
+ * @TPM2_CC_GET_RANDOM: TPM2_GetRandom().
  * @TPM2_CC_PCR_READ: TPM2_PCR_Read().
  * @TPM2_CC_PCR_EXTEND: TPM2_PCR_Extend().
  * @TPM2_CC_PCR_SETAUTHVAL: TPM2_PCR_SetAuthValue().
@@ -85,6 +86,7 @@ enum tpm2_command_codes {
TPM2_CC_DAM_PARAMETERS  = 0x013A,
TPM2_CC_NV_READ = 0x014E,
TPM2_CC_GET_CAPABILITY  = 0x017A,
+   TPM2_CC_GET_RANDOM  = 0x017B,
TPM2_CC_PCR_READ= 0x017E,
TPM2_CC_PCR_EXTEND  = 0x0182,
TPM2_CC_PCR_SETAUTHVAL  = 0x0183,
@@ -308,4 +310,15 @@ u32 tpm2_pcr_setauthvalue(struct udevice *dev, const char 
*pw,
  const ssize_t pw_sz, u32 index, const char *key,
  const ssize_t key_sz);
 
+/**
+ * Issue a TPM2_GetRandom command.
+ *
+ * @devTPM device
+ * @param data output buffer for the random bytes
+ * @param countsize of output buffer
+ *
+ * @return return code of the operation
+ */
+u32 tpm2_get_random(struct udevice *dev, void *data, u32 count);
+
 #endif /* __TPM_V2_H */
diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
index f89592d6e2..9d078877bc 100644
--- a/lib/tpm-v2.c
+++ b/lib/tpm-v2.c
@@ -421,3 +421,47 @@ u32 tpm2_pcr_setauthvalue(struct udevice *dev, const char 
*pw,
 
return tpm_sendrecv_command(dev, command_v2, NULL, NULL);
 }
+
+u32 tpm2_get_random(struct udevice *dev, void *data, u32 count)
+{
+   const u8 command_v2[10] = {
+   tpm_u16(TPM2_ST_NO_SESSIONS),
+   tpm_u32(12),
+   tpm_u32(TPM2_CC_GET_RANDOM),
+   };
+   u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+
+   const size_t data_size_offset = 10;
+   const size_t data_offset = 12;
+   size_t response_length = sizeof(response);
+   u32 data_size;
+   u8 *out = data;
+
+   while (count > 0) {
+   u32 this_bytes = min((size_t)count,
+sizeof(response) - data_offset);
+   u32 err;
+
+   if (pack_byte_string(buf, sizeof(buf), "sw",
+0, command_v2, sizeof(command_v2),
+sizeof(command_v2), this_bytes))
+   return TPM_LIB_ERROR;
+   err = tpm_sendrecv_command(dev, buf, response,
+  _length);
+   if (err)
+   return err;
+   if (unpack_byte_string(response, response_length, "w",
+  data_size_offset, _size))
+   return TPM_LIB_ERROR;
+   if (data_size > this_bytes)
+   return TPM_LIB_ERROR;
+   if (unpack_byte_string(response, response_length, "s",
+  data_offset, out, data_size))
+   return TPM_LIB_ERROR;
+
+   count -= data_size;
+   out += data_size;
+   }
+
+   return 0;
+}
-- 
2.17.1



Re: [PATCH] serial: Convert ARM_DCC to Kconfig

2020-06-04 Thread Tom Rini
On Tue, Jun 02, 2020 at 05:26:33PM -0400, Tom Rini wrote:

> The symbol "CONFIG_ARM_DCC" is used to control building
> drivers/serial/arm_dcc.c.  Provide a simple Kconfig entry for this.
> 
> Cc: Luca Ceresoli 
> Cc: Michal Simek 
> Cc: Tom McLeod 
> Cc: Mike Looijmans 
> Signed-off-by: Tom Rini 
> Reviewed-by: Luca Ceresoli 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] serial: Add missing Kconfig dependencies for debug consoles

2020-06-04 Thread Tom Rini
On Thu, May 28, 2020 at 12:05:12PM +0200, Michal Simek wrote:

> Debug console is the part of serial driver in the same file. It means to be
> able to enable debug console you also need to enable driver itself.
> That's why add all dependecies and list only debug consoles which are
> enabled based on driver selection to avoid compilation error when user
> asks for certain debug console but driver is not enable for it.
> 
> Error:
> aarch64-linux-gnu-ld.bfd: common/built-in.o: in function `putc':
> /home/monstr/data/disk/u-boot/common/console.c:513: undefined reference to 
> `printch'
> aarch64-linux-gnu-ld.bfd: common/built-in.o: in function `puts':
> /home/monstr/data/disk/u-boot/common/console.c:563: undefined reference to 
> `printch'
> 
> Signed-off-by: Michal Simek 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 6/8] Convert CONFIG_BZIP2 et al to Kconfig

2020-06-04 Thread Tom Rini
On Tue, May 26, 2020 at 03:06:17PM -0400, Tom Rini wrote:

> This converts the following to Kconfig:
>CONFIG_BZIP2
>CONFIG_GZIP
>CONFIG_LZO
>CONFIG_ZLIB
>CONFIG_LZMA
>CONFIG_LZO
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 5/8] topic_miami: Disable GPIO

2020-06-04 Thread Tom Rini
On Tue, May 26, 2020 at 03:06:16PM -0400, Tom Rini wrote:

> Per the boards config header file, there is no useful GPIO on these
> boards.  Remove CONFIG_CMD_GPIO from the defconfigs.
> 
> Cc: Mike Looijmans 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 8/8] Convert CONFIG_BOARD_LATE_INIT to Kconfig

2020-06-04 Thread Tom Rini
On Tue, May 26, 2020 at 03:06:19PM -0400, Tom Rini wrote:

> This converts the following to Kconfig:
>CONFIG_BOARD_LATE_INIT
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 7/8] Convert CONFIG_CMD_ASKENV et al to Kconfig

2020-06-04 Thread Tom Rini
On Tue, May 26, 2020 at 03:06:18PM -0400, Tom Rini wrote:

> This converts the following to Kconfig:
>CONFIG_CMD_ASKENV
>CONFIG_CMD_BMP
>CONFIG_CMD_BOOTD
>CONFIG_CMD_CACHE
>CONFIG_CMD_CRC32
>CONFIG_CMD_DHCP
>CONFIG_CMD_ENV
>CONFIG_CMD_EXPORTENV
>CONFIG_CMD_EXT2
>CONFIG_CMD_EXT4
>CONFIG_CMD_FLASH
>CONFIG_CMD_FS_GENERIC
>CONFIG_CMD_FUSE
>CONFIG_CMD_GPIO
>CONFIG_CMD_GPT
>CONFIG_CMD_GREPENV
>CONFIG_CMD_I2C
>CONFIG_CMD_IMLS
>CONFIG_CMD_IMPORTENV
>CONFIG_CMD_LOADB
>CONFIG_CMD_LOADS
>CONFIG_CMD_MEMINFO
>CONFIG_CMD_MII
>CONFIG_CMD_MTDPARTS
>CONFIG_CMD_NAND
>CONFIG_CMD_NAND_TRIMFFS
>CONFIG_CMD_NFS
>CONFIG_CMD_PCA953X
>CONFIG_CMD_PCA953X_INFO
>CONFIG_CMD_PCI
>CONFIG_CMD_PING
>CONFIG_CMD_READ
>CONFIG_CMD_SF
>CONFIG_CMD_SPI
>CONFIG_CMD_SPL
>CONFIG_CMD_SPL_WRITE_SIZE
>CONFIG_CMD_TIME
>CONFIG_CMD_TRACE
>CONFIG_CMD_UBI
>CONFIG_CMD_UBIFS
>CONFIG_CMD_UNZIP
>CONFIG_FS_EXT4
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 3/8] bcmstb: Migrate CONFIG_CMD_EXT[24]

2020-06-04 Thread Tom Rini
On Tue, May 26, 2020 at 03:06:14PM -0400, Tom Rini wrote:

> The common config header for bcm7260 and bcm7445 enable
> CONFIG_CMD_EXT2/EXT4 but the defconfigs do not.  This results in the
> commands being disabled.  Enable them via the defconfig.
> 
> Cc: Thomas Fitzsimmons 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 6/6] checkpatch.pl: Request if() instead #ifdef

2020-06-04 Thread Tom Rini
On Fri, May 22, 2020 at 04:32:40PM -0600, Simon Glass wrote:

> There is a lot of use of #ifdefs in U-Boot. In an effort reduce this,
> suggest using the compile-time construct.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 4/8] ARM: rmobile: blanche: Disable CONFIG_CMD_SF / CONFIG_CMD_SPI

2020-06-04 Thread Tom Rini
On Tue, May 26, 2020 at 03:06:15PM -0400, Tom Rini wrote:

> The config header for this platform disables both CMD_SF and CMD_SPI and
> the defconfig leaves them enabled.  Disable them from the defconfig and
> enable them in the header.
> 
> Cc: Marek Vasut 
> Cc: Masakazu Mochizuki 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/8] mx6memcal: Finish migration to defconfig options

2020-06-04 Thread Tom Rini
On Tue, May 26, 2020 at 03:06:13PM -0400, Tom Rini wrote:

> The config header for this platform uses '#undef' in a number of cases.
> All of the MMC related ones were already handled correctly in the
> defconfig file.  In the case of CONFIG_CMD_FUSE, the command was being
> built and enabled via defconfig.  Disable it in the defconfig, cleanup
> the header.
> 
> Reviewed-by: Eric Nelson 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/8] pfla02: Rework excluding NAND from SPL

2020-06-04 Thread Tom Rini
On Tue, May 26, 2020 at 03:06:12PM -0400, Tom Rini wrote:

> Rather than only enable CONFIG_CMD_NAND for non-SPL builds, move the CMD
> options to defconfig and rework the guards to not try and call the
> function in SPL builds.
> 
> Cc: Stefano Babic 
> Signed-off-by: Tom Rini 
> Acked-by: Stefano Babic 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCHv2] checkpatch.pl: Add check for defining CONFIG_CMD_xxx via config files

2020-06-04 Thread Tom Rini
On Tue, May 26, 2020 at 02:29:02PM -0400, Tom Rini wrote:

> All of our cmds have a Kconfig entry.  Making enabling a CMD via the
> config file an error to checkpatch.pl.
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/6] checkpatch.pl: Update to v5.7-rc6

2020-06-04 Thread Tom Rini
On Fri, May 22, 2020 at 04:32:35PM -0600, Simon Glass wrote:

> Bring in the newest script. This is close enough to v5.8 that it will
> likely be final. Keep the U-Boot changes to $logFunctions
> 
> Signed-off-by: Simon Glass 

I've moved this to v5.7 itself and reworded to match.

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 5/6] checkpatch.pl: Request a test when a new command is added

2020-06-04 Thread Tom Rini
On Fri, May 22, 2020 at 04:32:39PM -0600, Simon Glass wrote:

> This request is made with nearly every new command. Point to some docs
> on how to do it.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 3/6] checkpatch.pl: Add a check for tests needed for uclasses

2020-06-04 Thread Tom Rini
On Fri, May 22, 2020 at 04:32:37PM -0600, Simon Glass wrote:

> A common problem when submitting a new uclass is to forget to add sandbox
> tests. Add a warning for this.
> 
> Of course tests should always be added for new code, but this one seems to
> be missed by nearly every new contributor.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/6] checkpatch.pl: Add a U-Boot option

2020-06-04 Thread Tom Rini
On Fri, May 22, 2020 at 04:32:36PM -0600, Simon Glass wrote:

> Add an option to indicate that U-Boot-specific checks should be enabled.
> Add a function to house the code that will be added.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 4/6] checkpatch.pl: Warn if the flattree API is used

2020-06-04 Thread Tom Rini
On Fri, May 22, 2020 at 04:32:38PM -0600, Simon Glass wrote:

> We want people to use the livetree API, so request it.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] usb: eth: lan78xx: Fix logic in lan78xx_read_otp() to avoid a warning

2020-06-04 Thread Marek Vasut
On 6/4/20 10:35 PM, Tom Rini wrote:
> In lan78xx_read_otp() we want to know if sig is LAN78XX_OTP_INDICATOR_1
> or LAN78XX_OTP_INDICATOR_2.  In the case of matching the first one we
> set offset to itself, and clang warns about this.  Rework the logic so
> that if sig is the second indicator we adjust the offset as today and if
> it does not match the first indicator we return -EINVAL
> 
> Cc: Marek Vasut 
> Signed-off-by: Tom Rini 

Reviewed-by: Marek Vasut 


Re: [PATCH v5 05/21] arm: mvebu: x530: Disable smart hwcaps selection

2020-06-04 Thread Chris Packham

On 5/06/20 12:44 am, Pratyush Yadav wrote:
> The option SPI_FLASH_SMART_HWCAPS will be introduced in a future commit.
> It is enabled by default. It updates the hwcaps selection of SPI NOR to
> use the SPI MEM's supports_op() hook. But this leads to a code size
> increase and so the SPL binary exceeds the size limit.
>
> So, use the old hwcaps selection logic here to make sure the SPL size
> does not exceed the limit.
>
> Signed-off-by: Pratyush Yadav 
> ---
>   configs/x530_defconfig | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/configs/x530_defconfig b/configs/x530_defconfig
> index 67c8fbf663..35e2d53285 100644
> --- a/configs/x530_defconfig
> +++ b/configs/x530_defconfig
> @@ -58,6 +58,7 @@ CONFIG_SYS_NAND_USE_FLASH_BBT=y
>   CONFIG_NAND_PXA3XX=y
>   CONFIG_SF_DEFAULT_BUS=1
>   CONFIG_SF_DEFAULT_SPEED=5000
> +CONFIG_SPI_FLASH_SMART_HWCAPS=n

Last time I checked =n wasn't valid Kconfig for this to have the desired 
effect wouldn't it need to be

# CONFIG_SPI_FLASH_SMART_HWCAPS is not set

>   CONFIG_SPI_FLASH_BAR=y
>   CONFIG_SPI_FLASH_MACRONIX=y
>   CONFIG_SPI_FLASH_STMICRO=y

[PATCH v3 2/6] sifive: fu540: Add Booting from SPI

2020-06-04 Thread Jagan Teki
Add booting from SPI for SiFive Unleashed board.

Signed-off-by: Jagan Teki 
---
Changes for v3:
- updated based on master

 arch/riscv/cpu/fu540/Kconfig  |  2 +
 .../dts/hifive-unleashed-a00-u-boot.dtsi  | 12 ++
 configs/sifive_fu540_defconfig|  4 ++
 doc/board/sifive/fu540.rst| 41 +++
 4 files changed, 59 insertions(+)

diff --git a/arch/riscv/cpu/fu540/Kconfig b/arch/riscv/cpu/fu540/Kconfig
index e9302e87c0..7a813a9ac8 100644
--- a/arch/riscv/cpu/fu540/Kconfig
+++ b/arch/riscv/cpu/fu540/Kconfig
@@ -5,6 +5,8 @@
 config SIFIVE_FU540
bool
select ARCH_EARLY_INIT_R
+   imply BOARD
+   imply BOARD_FU540
imply CPU
imply CPU_RISCV
imply RISCV_TIMER
diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi 
b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
index 303806454b..4b2b242deb 100644
--- a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
+++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
@@ -12,6 +12,10 @@
spi2 = 
};
 
+   config {
+   u-boot,spl-payload-offset = <0x105000>; /* loader2 @1044KB */
+   };
+
hfclk {
u-boot,dm-spl;
};
@@ -22,6 +26,14 @@
 
 };
 
+ {
+   u-boot,dm-spl;
+
+   flash@0 {
+   u-boot,dm-spl;
+   };
+};
+
  {
mmc@0 {
u-boot,dm-spl;
diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig
index 8d412f8d6a..551d4b04a5 100644
--- a/configs/sifive_fu540_defconfig
+++ b/configs/sifive_fu540_defconfig
@@ -2,9 +2,11 @@ CONFIG_RISCV=y
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SYS_MALLOC_F_LEN=0x3000
 CONFIG_ENV_SIZE=0x2
+CONFIG_SPL_DM_SPI=y
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SPL=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_TARGET_SIFIVE_FU540=y
 CONFIG_ARCH_RV64I=y
@@ -15,9 +17,11 @@ CONFIG_MISC_INIT_R=y
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
 CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SPL_SPI_LOAD=y
 CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_OF_BOARD_FIXUP=y
 CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_CLK=y
 CONFIG_DM_MTD=y
diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
index f7c2c9f5bd..7a4b208288 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -533,3 +533,44 @@ Sample boot log from HiFive Unleashed board
type:   0fc63daf-8483-4772-8e79-3d69d8477de4
type:   linux
guid:   9faa81b6-39b1-4418-af5e-89c48f29c20d
+
+Booting from SPI
+
+
+Use Building steps from "Booting from MMC using U-Boot SPL" section.
+
+Partition the SPI in Linux via mtdblock. (Require to boot the board in
+SD boot mode by enabling MTD block in Linux)
+
+Use prebuilt image from here [1], which support to partition the SPI flash.
+
+.. code-block:: none
+
+  # sgdisk --clear \
+  > --set-alignment=2 \
+  > --new=1:40:2087 --change-name=1:loader1 
--typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \
+  > --new=2:2088:10279 --change-name=2:loader2 
--typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \
+  > --new=3:10536:65494 --change-name=3:rootfs 
--typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \
+  > /dev/mtdblock0
+
+Program the SPI (Require to boot the board in SD boot mode)
+
+Execute below steps on U-Boot proper,
+
+.. code-block:: none
+
+  tftpboot $kernel_addr_r u-boot-spl.bin
+  sf erase 0x5000 $filesize
+  sf write $kernel_addr_r 0x5000 $filesize
+
+  tftpboot $kernel_addr_r u-boot.itb
+  sf erase 0x105000 $filesize
+  sf write $kernel_addr_r 0x105000 $filesize
+
+Power off the board
+
+Change DIP switches MSEL[3:0] are set to 0110
+
+Power up the board.
+
+[1] https://github.com/amarula/bsp-sifive
-- 
2.25.1



[PATCH v3 6/6] sifive: fu540: Enable SF distro bootcmd

2020-06-04 Thread Jagan Teki
Enable SPI flash(SF) distro boot command in Sifive FU540.

This distro boot will read the boot script at specific
location at the flash and start sourcing the same.

Included the SF device at the last of the target devices
list since all the rest of the devices on the list have
more possibility to boot the distribution due to the
size of the SPI flash is concern.

Signed-off-by: Jagan Teki 
---
Changes for v3:
- none

 include/configs/sifive-fu540.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/configs/sifive-fu540.h b/include/configs/sifive-fu540.h
index 68fda14d76..f21411a701 100644
--- a/include/configs/sifive-fu540.h
+++ b/include/configs/sifive-fu540.h
@@ -43,9 +43,11 @@
 #ifndef CONFIG_SPL_BUILD
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 0) \
+   func(SF, sf, 0) \
func(DHCP, dhcp, na)
 
 #include 
+#include 
 
 #define TYPE_GUID_LOADER1  "5B193300-FC78-40CD-8002-E86C45580B47"
 #define TYPE_GUID_LOADER2  "2E54B353-1271-4842-806F-E436D6AF6985"
@@ -70,7 +72,8 @@
"type_guid_gpt_loader2=" TYPE_GUID_LOADER2 "\0" \
"type_guid_gpt_system=" TYPE_GUID_SYSTEM "\0" \
"partitions=" PARTS_DEFAULT "\0" \
-   BOOTENV
+   BOOTENV \
+   BOOTENV_SF
 
 #define CONFIG_PREBOOT \
"setenv fdt_addr ${fdtcontroladdr};" \
-- 
2.25.1



[PATCH v3 4/6] sifive: fu540: Mark the default env as SPI flash

2020-06-04 Thread Jagan Teki
Mark the default U-Boot environment as SPI flash since
this is an on board flash device.

Reviewed-by: Bin Meng 
Signed-off-by: Jagan Teki 
---
Changes for v3:
- none

 board/sifive/fu540/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig
index 86193d7668..e1ba629e37 100644
--- a/board/sifive/fu540/Kconfig
+++ b/board/sifive/fu540/Kconfig
@@ -27,6 +27,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
select SIFIVE_FU540
select SUPPORT_SPL
+   select ENV_IS_IN_SPI_FLASH
select RAM
select SPL_RAM if SPL
imply CMD_DHCP
-- 
2.25.1



[PATCH v3 5/6] sifive: fu540: Add boot flash script offset, size

2020-06-04 Thread Jagan Teki
HiFive-Unleashed-A00 has SPI flash with 32MiB size.
So, let's use the script offset at the end of 4K.
This way it cannot overlap any offsets being used
by software components in flash layout.

So, SF distrocmd will pick the script at desired
script address and run.

Signed-off-by: Jagan Teki 
---
Changes for v3:
- none

 include/configs/sifive-fu540.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/sifive-fu540.h b/include/configs/sifive-fu540.h
index 72c841eb9b..68fda14d76 100644
--- a/include/configs/sifive-fu540.h
+++ b/include/configs/sifive-fu540.h
@@ -62,6 +62,8 @@
"kernel_addr_r=0x8400\0" \
"fdt_addr_r=0x8800\0" \
"scriptaddr=0x8810\0" \
+   "script_offset_f=0x1fff000\0" \
+   "script_size_f=0x1000\0" \
"pxefile_addr_r=0x8820\0" \
"ramdisk_addr_r=0x8830\0" \
"type_guid_gpt_loader1=" TYPE_GUID_LOADER1 "\0" \
-- 
2.25.1



[PATCH v3 3/6] env: Enable SPI flash env for SiFive FU540

2020-06-04 Thread Jagan Teki
SPI flash device on HiFive Unleashed has 32MiB Size.

This patch add SPI flash environment after U-Boot proper
partition with a size of 128KiB.

SPI flash partition layout(32MiB):
0 - 34  : reserved for GPT header
   35 - 39  : unused
   40 - 2087: loader1 (SPL, FSBL)
 2088 - 10279   : loader2 (U-Boot proper, U-Boot)
10280 - 10535   : environment
10536 - 65494   : rootfs
65528 - 65536   : distro script

Note: the loader1 must start from 40th sector even though
there are 6 free sectors prior since 40th sector is nearest
flash sector boundary. 

Signed-off-by: Jagan Teki 
---
Changes for v3:
- fixed build issues

 arch/riscv/cpu/fu540/Kconfig | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/riscv/cpu/fu540/Kconfig b/arch/riscv/cpu/fu540/Kconfig
index 7a813a9ac8..15698eaf65 100644
--- a/arch/riscv/cpu/fu540/Kconfig
+++ b/arch/riscv/cpu/fu540/Kconfig
@@ -15,3 +15,16 @@ config SIFIVE_FU540
imply SPL_CPU_SUPPORT
imply SPL_OPENSBI
imply SPL_LOAD_FIT
+
+if ENV_IS_IN_SPI_FLASH
+
+config ENV_OFFSET
+   default 0x505000
+
+config ENV_SIZE
+   default 0x2
+
+config ENV_SECT_SIZE
+   default 0x1
+
+endif # ENV_IS_IN_SPI_FLASH
-- 
2.25.1



[PATCH v3 1/6] sifive: fu540: Add runtime boot mode detection

2020-06-04 Thread Jagan Teki
Add support to detect boot mode at runtime for
SiFive FU540 boards.

Signed-off-by: Jagan Teki 
---
Changes for v3:
- new patch

 board/sifive/fu540/fu540.c | 25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c
index fa705dea71..a35b79ace3 100644
--- a/board/sifive/fu540/fu540.c
+++ b/board/sifive/fu540/fu540.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -120,14 +121,26 @@ int board_init(void)
 }
 
 #ifdef CONFIG_SPL
+#define MODE_SELECT_REG0x1000
+#define MODE_SELECT_QSPI   0x6
+#define MODE_SELECT_SD 0xb
+#define MODE_SELECT_MASK   GENMASK(3, 0)
+
 u32 spl_boot_device(void)
 {
-#ifdef CONFIG_SPL_MMC_SUPPORT
-   return BOOT_DEVICE_MMC1;
-#else
-   puts("Unknown boot device\n");
-   hang();
-#endif
+   u32 mode_select = readl((void *)MODE_SELECT_REG);
+   u32 boot_device = mode_select & MODE_SELECT_MASK;
+
+   switch (boot_device) {
+   case MODE_SELECT_QSPI:
+   return BOOT_DEVICE_SPI;
+   case MODE_SELECT_SD:
+   return BOOT_DEVICE_MMC1;
+   default:
+   debug("Unsupported boot device 0x%x but trying MMC1\n",
+ boot_device);
+   return BOOT_DEVICE_MMC1;
+   }
 }
 #endif
 
-- 
2.25.1



[PATCH v3 0/6] riscv: sifive/fu540: SPI boot

2020-06-04 Thread Jagan Teki
Updated series with boot device detection directly
on spl_boot_device function instead of having separate
board driver.

Previous version changes are at [1].

Changes for v3:
- fixed env definitions build
- added boot device detection in board
Changes for v2:
- fu540 board driver
- runtime bootmode detection
- rebase on Pragnesh v11 series

[1] 
https://patchwork.ozlabs.org/project/uboot/cover/20200519192340.16624-1-ja...@amarulasolutions.com/

Any inputs?
Jagan.

Jagan Teki (6):
  sifive: fu540: Add runtime boot mode detection
  sifive: fu540: Add Booting from SPI
  env: Enable SPI flash env for SiFive FU540
  sifive: fu540: Mark the default env as SPI flash
  sifive: fu540: Add boot flash script offset, size
  sifive: fu540: Enable SF distro bootcmd

 arch/riscv/cpu/fu540/Kconfig  | 15 +++
 .../dts/hifive-unleashed-a00-u-boot.dtsi  | 12 ++
 board/sifive/fu540/Kconfig|  1 +
 board/sifive/fu540/fu540.c| 25 ---
 configs/sifive_fu540_defconfig|  4 ++
 doc/board/sifive/fu540.rst| 41 +++
 include/configs/sifive-fu540.h|  7 +++-
 7 files changed, 98 insertions(+), 7 deletions(-)

-- 
2.25.1



[PATCH] usb: eth: lan78xx: Fix logic in lan78xx_read_otp() to avoid a warning

2020-06-04 Thread Tom Rini
In lan78xx_read_otp() we want to know if sig is LAN78XX_OTP_INDICATOR_1
or LAN78XX_OTP_INDICATOR_2.  In the case of matching the first one we
set offset to itself, and clang warns about this.  Rework the logic so
that if sig is the second indicator we adjust the offset as today and if
it does not match the first indicator we return -EINVAL

Cc: Marek Vasut 
Signed-off-by: Tom Rini 
---
 drivers/usb/eth/lan78xx.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/eth/lan78xx.c b/drivers/usb/eth/lan78xx.c
index e34ad2603fbb..d147412990de 100644
--- a/drivers/usb/eth/lan78xx.c
+++ b/drivers/usb/eth/lan78xx.c
@@ -146,11 +146,9 @@ static int lan78xx_read_otp(struct usb_device *udev, u32 
offset,
ret = lan78xx_read_raw_otp(udev, 0, 1, );
 
if (!ret) {
-   if (sig == LAN78XX_OTP_INDICATOR_1)
-   offset = offset;
-   else if (sig == LAN78XX_OTP_INDICATOR_2)
+   if (sig == LAN78XX_OTP_INDICATOR_2)
offset += 0x100;
-   else
+   else if (sig != LAN78XX_OTP_INDICATOR_1)
return -EINVAL;
ret = lan78xx_read_raw_otp(udev, offset, length, data);
if (ret)
-- 
2.17.1



Re: [PATCH u-boot] eth/r8152: update the firmware

2020-06-04 Thread Marek Vasut
On 6/4/20 5:45 AM, Hayes Wang wrote:
> Marek Vasut [mailto:ma...@denx.de]
>> Sent: Tuesday, June 02, 2020 7:59 PM
> [...]
>> Can you be more specific about the problem you are fixing here ?
>> What is the problem ?
>
> There is low probability that the device may be lost when rebooting.
> Should I submit v2 to reword the commit message?

 Lost how ?
>>>
>>> USB enumeration may fail. The device would be at wrong state.
>>> I don't know detail about the hardware behavior.
>>
>> Is there any chance you can ask someone ? It would be real helpful to
>> know the details of the problem, in case someone runs into it, they
>> would know what is going on.
> 
> I get the following information.
> 
> 1.
> Our device has auto-installed driver feature - via switch CD-ROM/NIC
> mode. But in some corner cases, it would switch to CD-ROM unexpected.
> This issue results in Lan Function Disabled.
> 
> 2.
> While USB PHY transits to P3 from P0 due to the absent of transmitter
> control, it would issues undefined signal to its’ link partner.
> Some Down Stream Port misidentify the undefined signal as wakeup
> signal. So the link state will not keep in suspend even the system
> is idle.

OK, then please add this into the commit message and send a V2, I'll
pick it then. Thanks!


Re: [PATCH] usb: musb-new: Fix unused function warnings from clang

2020-06-04 Thread Marek Vasut
On 6/4/20 10:09 PM, Tom Rini wrote:
> The functions dsps_readb and dsps_writeb are only used by code that is
> under a !__UBOOT__ guard today.  Add that guard around these functions
> as well to avoid the warning.
> 
> Cc: Marek Vasut 
> Signed-off-by: Tom Rini 

Reviewed-by: Marek Vasut 


[PATCH] usb: musb-new: Fix unused function warnings from clang

2020-06-04 Thread Tom Rini
The functions dsps_readb and dsps_writeb are only used by code that is
under a !__UBOOT__ guard today.  Add that guard around these functions
as well to avoid the warning.

Cc: Marek Vasut 
Signed-off-by: Tom Rini 
---
 drivers/usb/musb-new/musb_dsps.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c
index eb590885bc53..1d94249c092e 100644
--- a/drivers/usb/musb-new/musb_dsps.c
+++ b/drivers/usb/musb-new/musb_dsps.c
@@ -42,14 +42,18 @@
  * avoid using musb_readx()/musb_writex() as glue layer should not be
  * dependent on musb core layer symbols.
  */
+#ifndef __UBOOT__
 static inline u8 dsps_readb(const void __iomem *addr, unsigned offset)
{ return __raw_readb(addr + offset); }
+#endif
 
 static inline u32 dsps_readl(const void __iomem *addr, unsigned offset)
{ return __raw_readl(addr + offset); }
 
+#ifndef __UBOOT__
 static inline void dsps_writeb(void __iomem *addr, unsigned offset, u8 data)
{ __raw_writeb(data, addr + offset); }
+#endif
 
 static inline void dsps_writel(void __iomem *addr, unsigned offset, u32 data)
{ __raw_writel(data, addr + offset); }
-- 
2.17.1



[PATCH] usb: gadget: ether: Fix warnings about unused code

2020-06-04 Thread Tom Rini
When building this with clang we see a few new warnings.  There are a
handful of structs that we declare and use only in the case of
!defined(CONFIG_USB_ETH_CDC) && defined(CONFIG_USB_ETH_SUBSET) so update
the guards used to match this as well as cover all members rather than
just a few.  Finally, eth_is_promisc() is only called by
eth_start_xmit() which is under and #if 0 and immediately follows the
function.  Move the #if 0 up.

Cc: Lukasz Majewski 
Cc: Marek Vasut 
Signed-off-by: Tom Rini 
---
 drivers/usb/gadget/ether.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 6f04523f15e9..0daaf36f68f7 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -476,14 +476,12 @@ static const struct usb_cdc_acm_descriptor acm_descriptor 
= {
 
 #endif
 
-#ifndef CONFIG_USB_ETH_CDC
-
+#if !defined(CONFIG_USB_ETH_CDC) && defined(CONFIG_USB_ETH_SUBSET)
 /*
  * "SAFE" loosely follows CDC WMC MDLM, violating the spec in various
  * ways:  data endpoints live in the control interface, there's no data
  * interface, and it's not used to talk to a cell phone radio.
  */
-
 static const struct usb_cdc_mdlm_desc mdlm_desc = {
.bLength =  sizeof mdlm_desc,
.bDescriptorType =  USB_DT_CS_INTERFACE,
@@ -501,7 +499,6 @@ static const struct usb_cdc_mdlm_desc mdlm_desc = {
  * can't really use its struct.  All we do here is say that we're using
  * the submode of "SAFE" which directly matches the CDC Subset.
  */
-#ifdef CONFIG_USB_ETH_SUBSET
 static const u8 mdlm_detail_desc[] = {
6,
USB_DT_CS_INTERFACE,
@@ -511,9 +508,6 @@ static const u8 mdlm_detail_desc[] = {
0,  /* network control capabilities (none) */
0,  /* network data capabilities ("raw" encapsulation) */
 };
-#endif
-
-#endif
 
 static const struct usb_cdc_ether_desc ether_desc = {
.bLength =  sizeof(ether_desc),
@@ -527,6 +521,7 @@ static const struct usb_cdc_ether_desc ether_desc = {
.wNumberMCFilters = __constant_cpu_to_le16(0),
.bNumberPowerFilters =  0,
 };
+#endif
 
 #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS)
 
@@ -1643,6 +1638,7 @@ static void tx_complete(struct usb_ep *ep, struct 
usb_request *req)
packet_sent = 1;
 }
 
+#if 0
 static inline int eth_is_promisc(struct eth_dev *dev)
 {
/* no filters for the CDC subset; always promisc */
@@ -1651,7 +1647,6 @@ static inline int eth_is_promisc(struct eth_dev *dev)
return dev->cdc_filter & USB_CDC_PACKET_TYPE_PROMISCUOUS;
 }
 
-#if 0
 static int eth_start_xmit (struct sk_buff *skb, struct net_device *net)
 {
struct eth_dev  *dev = netdev_priv(net);
-- 
2.17.1



[PATCH] net: cpsw: Add __maybe_unused to generated inlines

2020-06-04 Thread Tom Rini
We generate a number of helper inline functions to make accesses easier.
However not all permutations of each function will be used and clang
will warn about unused ones.  Decorate all of them with __maybe_unused
because of this.

Cc: Lokesh Vutla 
Signed-off-by: Tom Rini 
---
 drivers/net/ti/cpsw.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c
index 95761fffc0f0..9d4332f45048 100644
--- a/drivers/net/ti/cpsw.c
+++ b/drivers/net/ti/cpsw.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -247,11 +248,11 @@ static inline void cpsw_ale_set_field(u32 *ale_entry, u32 
start, u32 bits,
 }
 
 #define DEFINE_ALE_FIELD(name, start, bits)\
-static inline int cpsw_ale_get_##name(u32 *ale_entry)  \
+static inline int __maybe_unused cpsw_ale_get_##name(u32 *ale_entry)   \
 {  \
return cpsw_ale_get_field(ale_entry, start, bits);  \
 }  \
-static inline void cpsw_ale_set_##name(u32 *ale_entry, u32 value)  \
+static inline void __maybe_unused cpsw_ale_set_##name(u32 *ale_entry, u32 
value)   \
 {  \
cpsw_ale_set_field(ale_entry, start, bits, value);  \
 }
-- 
2.17.1



[PATCH] mmc: omap_hsmmc: Add guards around omap_hsmmc_get_cfg()

2020-06-04 Thread Tom Rini
We only call the function omap_hsmmc_get_cfg in the case of OMAP34XX or
when we have to iodelay recalibration.  Add guards for these checks as
clang will otherwise warn.

Cc: Peng Fan 
Cc: Lokesh Vutla 
Signed-off-by: Tom Rini 
---
Aside, Lokesh, can you please add drivers/mmc/omap_hsmmc.c to the
general TI entry MAINTAINERS entry?  Thanks!
---
 drivers/mmc/omap_hsmmc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 8636cd713a36..0e05fe4cfcbb 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -175,6 +175,8 @@ static inline struct omap_hsmmc_data 
*omap_hsmmc_get_data(struct mmc *mmc)
return (struct omap_hsmmc_data *)mmc->priv;
 #endif
 }
+
+#if defined(CONFIG_OMAP34XX) || defined(CONFIG_IODELAY_RECALIBRATION)
 static inline struct mmc_config *omap_hsmmc_get_cfg(struct mmc *mmc)
 {
 #if CONFIG_IS_ENABLED(DM_MMC)
@@ -184,6 +186,7 @@ static inline struct mmc_config *omap_hsmmc_get_cfg(struct 
mmc *mmc)
return &((struct omap_hsmmc_data *)mmc->priv)->cfg;
 #endif
 }
+#endif
 
 #if defined(OMAP_HSMMC_USE_GPIO) && !CONFIG_IS_ENABLED(DM_MMC)
 static int omap_mmc_setup_gpio_in(int gpio, const char *label)
-- 
2.17.1



[PATCH] gpio: omap_gpio: Fix unused function warning in non-DM case

2020-06-04 Thread Tom Rini
In the case of non-DM_GPIO the function get_gpio_index() will never be
called, and clang will warn about this.  Move this to be with the other
non-DM code for easier removal later.

Cc: Lokesh Vutla 
Signed-off-by: Tom Rini 
---
 drivers/gpio/omap_gpio.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index 4249850f4bf9..c986ef03805c 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -41,11 +41,6 @@ struct gpio_bank {
 
 #endif
 
-static inline int get_gpio_index(int gpio)
-{
-   return gpio & 0x1f;
-}
-
 int gpio_is_valid(int gpio)
 {
return (gpio >= 0) && (gpio < OMAP_MAX_GPIO);
@@ -122,6 +117,10 @@ static int _get_gpio_value(const struct gpio_bank *bank, 
int gpio)
 }
 
 #if !CONFIG_IS_ENABLED(DM_GPIO)
+static inline int get_gpio_index(int gpio)
+{
+   return gpio & 0x1f;
+}
 
 static inline const struct gpio_bank *get_gpio_bank(int gpio)
 {
-- 
2.17.1



[PATCH] board: ti: am335x_evm: Remove duplicate setting of bd_ram_ofs member

2020-06-04 Thread Tom Rini
With clang we get a report that we are setting this member twice.
Fortunately it is to the same value, so drop the hard-coded value line.

Signed-off-by: Tom Rini 
---
 board/ti/am335x/board.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 4199bee2e64a..123ccaac44e5 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -912,7 +912,6 @@ struct cpsw_platform_data am335_eth_data = {
.slaves = 2,
.slave_data = slave_data,
.ale_entries= 1024,
-   .bd_ram_ofs = 0x2000,
.mac_control= 0x20,
.active_slave   = 0,
.mdio_base  = 0x4a101000,
-- 
2.17.1



[PATCH] board: ti: common: Fix pointer-bool-conversion warnings

2020-06-04 Thread Tom Rini
When building this code with clang-10 a number of warnings will be
generated along the lines of:
warning: address of array 'ep->version' will always evaluate to 'true'

Convert these checks to checking the strlen of the part of the array we
care about.  As this array will be null terminated previously by us,
this is safe.

Cc: Lokesh Vutla 
Signed-off-by: Tom Rini 
---
 board/ti/common/board_detect.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index 429668404a3b..e09ecda4d7e6 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -669,17 +669,17 @@ void __maybe_unused set_board_info_env(char *name)
 
if (name)
env_set("board_name", name);
-   else if (ep->name)
+   else if (strlen(ep->name) != 0)
env_set("board_name", ep->name);
else
env_set("board_name", unknown);
 
-   if (ep->version)
+   if (strlen(ep->version) != 0)
env_set("board_rev", ep->version);
else
env_set("board_rev", unknown);
 
-   if (ep->serial)
+   if (strlen(ep->serial) != 0)
env_set("board_serial", ep->serial);
else
env_set("board_serial", unknown);
@@ -692,22 +692,22 @@ void __maybe_unused set_board_info_env_am6(char *name)
 
if (name)
env_set("board_name", name);
-   else if (ep->name)
+   else if (strlen(ep->name) != 0)
env_set("board_name", ep->name);
else
env_set("board_name", unknown);
 
-   if (ep->version)
+   if (strlen(ep->version) != 0)
env_set("board_rev", ep->version);
else
env_set("board_rev", unknown);
 
-   if (ep->software_revision)
+   if (strlen(ep->software_revision) != 0)
env_set("board_software_revision", ep->software_revision);
else
env_set("board_software_revision", unknown);
 
-   if (ep->serial)
+   if (strlen(ep->serial) != 0)
env_set("board_serial", ep->serial);
else
env_set("board_serial", unknown);
-- 
2.17.1



[PATCH] crypto/fsl: fix unaligned access

2020-06-04 Thread Michael Walle
On aarch64 running with dcache off, will result in an unaligned access
exception:

   => dcache off
   => hash sha1 $kernel_addr_r 100
   "Synchronous Abort" handler, esr 0x9661
   elr: 960317d8 lr : 960316a4 (reloc)
   elr: fbd787d8 lr : fbd786a4
   [..]

The compiler emits a "stur x1, [x0, #12]". x1 is might just be 32 bit
aligned pointer. Remove the unused u64 element from the union to drop
the minimal alignment to 32 bit. Also remove the union, because it is
no more needed.

Signed-off-by: Michael Walle 
---
 drivers/crypto/fsl/desc_constr.h | 27 +--
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/crypto/fsl/desc_constr.h b/drivers/crypto/fsl/desc_constr.h
index cb112283ac..b82ba83e73 100644
--- a/drivers/crypto/fsl/desc_constr.h
+++ b/drivers/crypto/fsl/desc_constr.h
@@ -36,19 +36,16 @@
   (LDOFF_ENABLE_AUTO_NFIFO << LDST_OFFSET_SHIFT))
 
 #ifdef CONFIG_PHYS_64BIT
-union ptr_addr_t {
-   u64 m_whole;
-   struct {
+struct ptr_addr_t {
 #ifdef CONFIG_SYS_FSL_SEC_LE
-   u32 low;
-   u32 high;
+   u32 low;
+   u32 high;
 #elif defined(CONFIG_SYS_FSL_SEC_BE)
-   u32 high;
-   u32 low;
+   u32 high;
+   u32 low;
 #else
 #error Neither CONFIG_SYS_FSL_SEC_LE nor CONFIG_SYS_FSL_SEC_BE is defined
 #endif
-   } m_halfs;
 };
 #endif
 
@@ -57,9 +54,10 @@ static inline void pdb_add_ptr(dma_addr_t *offset, 
dma_addr_t ptr)
 #ifdef CONFIG_PHYS_64BIT
/* The Position of low and high part of 64 bit address
 * will depend on the endianness of CAAM Block */
-   union ptr_addr_t *ptr_addr = (union ptr_addr_t *)offset;
-   ptr_addr->m_halfs.high = (u32)(ptr >> 32);
-   ptr_addr->m_halfs.low = (u32)ptr;
+   struct ptr_addr_t *ptr_addr = (struct ptr_addr_t *)offset;
+
+   ptr_addr->high = (u32)(ptr >> 32);
+   ptr_addr->low = (u32)ptr;
 #else
*offset = ptr;
 #endif
@@ -111,9 +109,10 @@ static inline void append_ptr(u32 *desc, dma_addr_t ptr)
 #ifdef CONFIG_PHYS_64BIT
/* The Position of low and high part of 64 bit address
 * will depend on the endianness of CAAM Block */
-   union ptr_addr_t *ptr_addr = (union ptr_addr_t *)offset;
-   ptr_addr->m_halfs.high = (u32)(ptr >> 32);
-   ptr_addr->m_halfs.low = (u32)ptr;
+   struct ptr_addr_t *ptr_addr = (struct ptr_addr_t *)offset;
+
+   ptr_addr->high = (u32)(ptr >> 32);
+   ptr_addr->low = (u32)ptr;
 #else
*offset = ptr;
 #endif
-- 
2.20.1



Re: [U-Boot] Pull request: u-boot-riscv/master

2020-06-04 Thread Tom Rini
On Thu, Jun 04, 2020 at 10:18:07AM +0800, ub...@andestech.com wrote:

> Hi Tom,
> 
> Please pull some riscv updates:
> 
> - Fixes 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01")
>Move sbi_probe_extension() out of CONFIG_SBI_V01.
> - SiFive FU540 support SPL.
> 
> Thanks
> Rick
> 
> 
> https://travis-ci.org/github/rickchen36/u-boot-riscv/builds/694099665
> 
> 
> The following changes since commit 0d8f35b58cc8458a5263b424896a386429ee49e5:
> 
>   Merge https://gitlab.denx.de/u-boot/custodians/u-boot-spi (2020-06-03 
> 12:27:51 -0400)
> 
>   are available in the Git repository at:
> 
> g...@gitlab.denx.de:u-boot/custodians/u-boot-riscv.git
> 
> for you to fetch changes up to 0a94007e829876c7ebd49daebfaa90eea25801b8:
> 
>   riscv: sbi: Move sbi_probe_extension() out of CONFIG_SBI_V01 (2020-06-04 
> 09:44:21 +0800)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v4] net: tftp: Add client support for RFC 7440

2020-06-04 Thread Ravik Hasija


On Wed, Jun 3, 2020 at 5:55 AM Ravik Hasija rahasij@.microsoft
wrote:
>
> Ramon Fried-4 wrote
> > + if (strcmp((char *)pkt + i,  "windowsize") == 0) {
> > For servers that doesnt support windowsize option the above check could
> > result in accessing memory outside of valid range. Please check if
> (i+11)
> > < len before comparing the strings.
> This is the same handling as all other possible configurations,
> following the same code.
> I agree that this needs reworking, but I'll do it in a different patch
> all together.

Yes, the other options need to be fixed as well. However, we should fix
(i+11)




--
Sent from: http://u-boot.10912.n7.nabble.com/


[PATCH 1/2] cmd: booti: Fix spelling of "environment".

2020-06-04 Thread Vagrant Cascadian
Signed-off-by: Vagrant Cascadian 
---

 cmd/booti.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/booti.c b/cmd/booti.c
index ae37975494..af0603b96e 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -141,7 +141,7 @@ static char booti_help_text[] =
"\tspecifying the size of a RAW initrd.\n"
"\tCurrently only booting from gz, bz2, lzma and lz4 compression\n"
"\ttypes are supported. In order to boot from any of these compressed\n"
-   "\timages, user have to set kernel_comp_addr_r and kernel_comp_size 
enviornment\n"
+   "\timages, user have to set kernel_comp_addr_r and kernel_comp_size 
environment\n"
"\tvariables beforehand.\n"
 #if defined(CONFIG_OF_LIBFDT)
"\tSince booting a Linux kernel requires a flat device-tree, a\n"
-- 
2.20.1



[PATCH 2/2] doc: sifive: Fix spelling of "environment".

2020-06-04 Thread Vagrant Cascadian
Signed-off-by: Vagrant Cascadian 
---

 doc/board/sifive/fu540.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
index 43402cb2e5..39fb8d8990 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -35,7 +35,7 @@ Building
 
 
 1. Add the RISC-V toolchain to your PATH.
-2. Setup ARCH & cross compilation enviornment variable:
+2. Setup ARCH & cross compilation environment variable:
 
 .. code-block:: none
 
@@ -225,7 +225,7 @@ Or if you want to use a compressed kernel image file such 
as Image.gz
=>setenv kernel_comp_addr_r 0x9000
=>setenv kernel_comp_size 0x50
 
-By this time, correct kernel image is loaded and required enviornment variables
+By this time, correct kernel image is loaded and required environment variables
 are set. You can proceed to load the ramdisk and device tree from the tftp 
server
 as well.
 
-- 
2.20.1



[PATCH 1/1] sandbox: handling out of memory

2020-06-04 Thread Heinrich Schuchardt
assert() only works in debug mode. So checking a successful memory
allocation should not use assert().

Signed-off-by: Heinrich Schuchardt 
---
 arch/sandbox/cpu/state.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index 1f794123b3..34b6fff7e7 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -378,7 +378,10 @@ int state_init(void)

state->ram_size = CONFIG_SYS_SDRAM_SIZE;
state->ram_buf = os_malloc(state->ram_size);
-   assert(state->ram_buf);
+   if (!state->ram_buf) {
+   printf("Out of memory\n");
+   os_exit(1);
+   }

state_reset_for_test(state);
/*
--
2.26.2



Re: [PULL] u-boot-atmel-fixes-2020.07-a

2020-06-04 Thread Tom Rini
On Thu, Jun 04, 2020 at 03:26:24PM +, eugen.hris...@microchip.com wrote:
> On 04.06.2020 18:05, Tom Rini wrote:
> 
> 
>  > Applied to u-boot/master, thanks!
> 
>  > But please note that building for all of "sama5" gives a ton of device
>  > tree warnings, can you please look in to them?  Thanks!
> 
> 
> Hi Tom,
> 
> Any changes in the DTC version or something? there are no changes in the 
> device tree from 2020.04, so, if the warnings appeared now, it can be 
> due to a more restrictive DTC setting.

Sorry, to be clear they are quite old warnings.  I assume they've been
fixed in the kernel sama5d3/d4.dtsi files for some time even.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 1/1] efi_loader: comments EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL

2020-06-04 Thread Heinrich Schuchardt
Provide missing comments for the functions implementing the
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_console.c | 124 ---
 1 file changed, 115 insertions(+), 9 deletions(-)

diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index ac0dec1146..426de77951 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -80,13 +80,13 @@ static int term_get_char(s32 *c)
return 0;
 }

-/*
+/**
  * Receive and parse a reply from the terminal.
  *
  * @n: array of return values
  * @num:   number of return values expected
  * @end_char:  character indicating end of terminal message
- * @return:non-zero indicates error
+ * Return: non-zero indicates error
  */
 static int term_read_reply(int *n, int num, char end_char)
 {
@@ -127,6 +127,17 @@ static int term_read_reply(int *n, int num, char end_char)
return 0;
 }

+/**
+ * efi_cout_output_string() - write Unicode string to console
+ *
+ * This function implements the OutputString service of the simple text output
+ * protocol. See the Unified Extensible Firmware Interface (UEFI) specification
+ * for details.
+ *
+ * @this:  simple text output protocol
+ * @string:u16 string
+ * Return: status code
+ */
 static efi_status_t EFIAPI efi_cout_output_string(
struct efi_simple_text_output_protocol *this,
const efi_string_t string)
@@ -202,6 +213,20 @@ out:
return EFI_EXIT(ret);
 }

+/**
+ * efi_cout_test_string() - test writing Unicode string to console
+ *
+ * This function implements the TestString service of the simple text output
+ * protocol. See the Unified Extensible Firmware Interface (UEFI) specification
+ * for details.
+ *
+ * As in OutputString we simply convert UTF-16 to UTF-8 there are no 
unsupported
+ * code points and we can always return EFI_SUCCESS.
+ *
+ * @this:  simple text output protocol
+ * @string:u16 string
+ * Return: status code
+ */
 static efi_status_t EFIAPI efi_cout_test_string(
struct efi_simple_text_output_protocol *this,
const efi_string_t string)
@@ -210,6 +235,15 @@ static efi_status_t EFIAPI efi_cout_test_string(
return EFI_EXIT(EFI_SUCCESS);
 }

+/**
+ * cout_mode_matches() - check if mode has given terminal size
+ *
+ * @mode:  text mode
+ * @rows:  number of rows
+ * @cols:  number of columns
+ * Return: true if number of rows and columns matches the mode and
+ * the mode is present
+ */
 static bool cout_mode_matches(struct cout_mode *mode, int rows, int cols)
 {
if (!mode->present)
@@ -221,6 +255,9 @@ static bool cout_mode_matches(struct cout_mode *mode, int 
rows, int cols)
 /**
  * query_console_serial() - query console size
  *
+ * When using a serial console or the net console we can only devise the
+ * terminal size by querying the terminal using ECMA-48 control sequences.
+ *
  * @rows:  pointer to return number of rows
  * @cols:  pointer to return number of columns
  * Returns:0 on success
@@ -261,8 +298,8 @@ out:
return ret;
 }

-/*
- * Update the mode table.
+/**
+ * query_console_size() - update the mode table.
  *
  * By default the only mode available is 80x25. If the console has at least 50
  * lines, enable mode 80x50. If we can query the console size and it is neither
@@ -306,6 +343,20 @@ static void query_console_size(void)
}
 }

+
+/**
+ * efi_cout_query_mode() - get terminal size for a text mode
+ *
+ * This function implements the QueryMode service of the simple text output
+ * protocol. See the Unified Extensible Firmware Interface (UEFI) specification
+ * for details.
+ *
+ * @this:  simple text output protocol
+ * @mode_number:   mode number to retrieve information on
+ * @columns:   number of columns
+ * @rows:  number of rows
+ * Return: status code
+ */
 static efi_status_t EFIAPI efi_cout_query_mode(
struct efi_simple_text_output_protocol *this,
unsigned long mode_number, unsigned long *columns,
@@ -341,7 +392,17 @@ static const struct {
{ 37, 47 }, /* 7: light gray, map to white */
 };

-/* See EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute(). */
+/**
+ * efi_cout_set_attribute() - set fore- and background color
+ *
+ * This function implements the SetAttribute service of the simple text output
+ * protocol. See the Unified Extensible Firmware Interface (UEFI) specification
+ * for details.
+ *
+ * @this:  simple text output protocol
+ * @attribute: foreground color - bits 0-3, background color - bits 4-6
+ * Return: status code
+ */
 static efi_status_t EFIAPI efi_cout_set_attribute(
struct efi_simple_text_output_protocol *this,
unsigned long attribute)
@@ -364,9 +425,9 @@ static 

Re: [PATCH v4 1/2] net: cortina_ni: Add eth support for Cortina Access CAxxxx SoCs

2020-06-04 Thread Ramon Fried
On Wed, Jun 3, 2020 at 11:05 AM Alex Nemirovsky
 wrote:
>
> From: Aaron Tseng 
>
> Add Cortina Access Ethernet device driver for CA SoCs.
> This driver supports only the DM_ETH network model.
>
> Signed-off-by: Aaron Tseng 
> Signed-off-by: Alex Nemirovsky 
>
> CC: Joe Hershberger 
> CC: Abbie Chang 
> CC: Tom Rini 
>
> ---
>
> Changes in v4: None
> Changes in v3:
> - Changed commit comment to state that only DM model is supported
> - Removed blank line at end of C file
>
> Changes in v2:
> - Remove legacy mode support
> - Add support for additional SoC variants
> - Remove unused variables
>
>  MAINTAINERS  |4 +
>  drivers/net/Kconfig  |7 +
>  drivers/net/Makefile |1 +
>  drivers/net/cortina_ni.c | 1909 
> ++
>  drivers/net/cortina_ni.h |  592 ++
>  5 files changed, 2513 insertions(+)
>  create mode 100644 drivers/net/cortina_ni.c
>  create mode 100644 drivers/net/cortina_ni.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 8add9d4..1b166d2 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -181,6 +181,8 @@ F:  drivers/gpio/cortina_gpio.c
>  F: drivers/watchdog/cortina_wdt.c
>  F: drivers/serial/serial_cortina.c
>  F: drivers/mmc/ca_dw_mmc.c
> +F: drivers/net/cortina_ni.c
> +F: drivers/net/cortina_ni.h
>
>  ARM/CZ.NIC TURRIS MOX SUPPORT
>  M: Marek Behun 
> @@ -732,6 +734,8 @@ F:  drivers/gpio/cortina_gpio.c
>  F: drivers/watchdog/cortina_wdt.c
>  F: drivers/serial/serial_cortina.c
>  F: drivers/mmc/ca_dw_mmc.c
> +F: drivers/net/cortina_ni.c
> +F: drivers/net/cortina_ni.h
>
>  MIPS MSCC
>  M: Gregory CLEMENT 
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index f7855c9..45e0480 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -149,6 +149,13 @@ config BCMGENET
> help
>   This driver supports the BCMGENET Ethernet MAC.
>
> +config CORTINA_NI_ENET
> +   bool "Cortina-Access Ethernet driver"
> +   depends on DM_ETH && CORTINA_PLATFORM
> +   help
> + The driver supports the Cortina-Access Ethernet MAC for
> + all supported CA SoCs
> +
>  config DWC_ETH_QOS
> bool "Synopsys DWC Ethernet QOS device support"
> depends on DM_ETH
> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
> index 383ed1c..1d6ec4f 100644
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -14,6 +14,7 @@ obj-$(CONFIG_DRIVER_AX88180) += ax88180.o
>  obj-$(CONFIG_BCM_SF2_ETH) += bcm-sf2-eth.o
>  obj-$(CONFIG_BCM_SF2_ETH_GMAC) += bcm-sf2-eth-gmac.o
>  obj-$(CONFIG_CALXEDA_XGMAC) += calxedaxgmac.o
> +obj-$(CONFIG_CORTINA_NI_ENET) += cortina_ni.o
>  obj-$(CONFIG_CS8900) += cs8900.o
>  obj-$(CONFIG_TULIP) += dc2114x.o
>  obj-$(CONFIG_ETH_DESIGNWARE) += designware.o
> diff --git a/drivers/net/cortina_ni.c b/drivers/net/cortina_ni.c
> new file mode 100644
> index 000..d5bbf3e
> --- /dev/null
> +++ b/drivers/net/cortina_ni.c
> @@ -0,0 +1,1909 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +/*
> + * Copyright (C) 2020 Cortina Access Inc.
> + * Author: Aaron Tseng 
> + *
> + * Ethernet MAC Driver for all supported CA SoCs
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "cortina_ni.h"
> +
> +static u32 reg_value;
> +
> +/* port 0-3 are individual port connect to PHY directly */
> +/* port 4-7 are LAN ports connected to QSGMII PHY */
> +int active_port = NI_PORT_5;  /* Physical port 5 */
> +u32 ge_port_phy_addr;  /* PHY address connected to active port */
> +int auto_scan_active_port;
> +
> +#define HEADER_A_SIZE  8
> +
> +/*define CORTINA_NI_DBG if individual rx,tx,init needs to be called */
> +#if CORTINA_NI_DBG
> +static struct udevice  *dbg_dev;
> +#endif
> +static struct udevice   *curr_dev;
> +
> +#if defined(CONFIG_TARGET_SATURN_ASIC)
> +#define CA_REG_READ(off)readl((u64)KSEG1_ATU_XLAT(off))
> +#define CA_REG_WRITE(data, off) writel(data, (u64)KSEG1_ATU_XLAT(off))
> +#else
> +#define CA_REG_READ(off)readl((u64)off)
> +#define CA_REG_WRITE(data, off) writel(data, (u64)off)
> +#endif
> +
> +int cortina_ni_recv(struct udevice *netdev);
> +static int ca_ni_ofdata_to_platdata(struct udevice *dev);
> +
> +static u32 *RDWRPTR_ADVANCE_ONE(u32 *x, unsigned long base, unsigned long 
> max)
Please don't use upper case function names.
> +{
> +   if (x + 1 >= (u32 *)max)
> +   return (u32 *)base;
> +   else
> +   return (x + 1);
> +}
> +
> +static void ni_setup_mac_addr(void)
> +{
> +   unsigned char mac[6];
> +
> +   union NI_HV_GLB_MAC_ADDR_CFG0_t mac_addr_cfg0;
> +   union NI_HV_GLB_MAC_ADDR_CFG1_t mac_addr_cfg1;
> +   union NI_HV_PT_PORT_STATIC_CFG_tport_static_cfg;
> +   union NI_HV_XRAM_CPUXRAM_CFG_t  cpuxram_cfg;
> +   struct cortina_ni_priv *priv = dev_get_priv(curr_dev);
> +
> +   /* parsing ethaddr and set to NI 

Re: [PATCH v4] net: tftp: Add client support for RFC 7440

2020-06-04 Thread Ramon Fried
On Wed, Jun 3, 2020 at 5:55 AM Ravik Hasija  wrote:
>
> Ramon Fried-4 wrote
> > + if (strcmp((char *)pkt + i,  "windowsize") == 0) {
> > For servers that doesnt support windowsize option the above check could
> > result in accessing memory outside of valid range. Please check if (i+11)
> > < len before comparing the strings.
This is the same handling as all other possible configurations,
following the same code.
I agree that this needs reworking, but I'll do it in a different patch
all together.

> >
> >
> > +
> > + if (ntohs(*(__be16 *)pkt) != (ushort)(tftp_cur_block + 1)) {
> > + debug("Received unexpected block: %d, expected: %d\n",
> > +   ntohs(*(__be16 *)pkt),
> > +   (ushort)(tftp_cur_block + 1));
> > + /*
> > +  * If one packet is dropped most likely
> > +  * all other buffers in the window
> > +  * that will arrive will cause a sending NACK.
> > +  * This just overwellms the server, let's just send 
> > one.
> > +  */
> > + if (tftp_last_nack != tftp_cur_block) {
> > + tftp_send();
> > + tftp_last_nack = tftp_cur_block;
> > + tftp_next_ack = (ushort)(tftp_cur_block +
> > +  tftp_windowsize);
> > + }
> > + break;
> > + }
> > +
> > + tftp_cur_block++;
> >
> > Monotonically increasing the tftp_cur_block will cause error for cases
> > where sequence number wraps around as tftp_cur_block is ulong, thus during
> > wraparound the check ntohs(*(__be16 *)pkt) != (ushort)(tftp_cur_block + 1)
> > will fail and incorrectly generate ACK, and the connection will eventually
> > be terminated once the retry is exhausted. Please modulo the increment
> > with TFTP_SEQUENCE_SIZE.
True, will fix.
Thanks.
> > --
> > 2.26.2
>
> Quoted from:
> http://u-boot.10912.n7.nabble.com/PATCH-v4-net-tftp-Add-client-support-for-RFC-7440-tp412754.html
>
>
>
>
> --
> Sent from: http://u-boot.10912.n7.nabble.com/


Re: [PATCH v2 5/6] crypto/fsl: instantiate the RNG with prediciton resistance

2020-06-04 Thread Michael Walle

Am 2020-06-04 17:46, schrieb Michael Walle:

If it is already instantiated tear it down first and then reinstanciate
it again with prediction resistance.

Signed-off-by: Michael Walle 
---
 drivers/crypto/fsl/desc.h|  2 ++
 drivers/crypto/fsl/jobdesc.c | 12 ++-
 drivers/crypto/fsl/jobdesc.h |  2 ++
 drivers/crypto/fsl/jr.c  | 66 
 include/fsl_sec.h|  7 ++--
 5 files changed, 78 insertions(+), 11 deletions(-)

diff --git a/drivers/crypto/fsl/desc.h b/drivers/crypto/fsl/desc.h
index 11ad506829..3589e6ea02 100644
--- a/drivers/crypto/fsl/desc.h
+++ b/drivers/crypto/fsl/desc.h
@@ -520,6 +520,8 @@
 #define OP_ALG_ICV_OFF (0 << OP_ALG_ICV_SHIFT)
 #define OP_ALG_ICV_ON  (1 << OP_ALG_ICV_SHIFT)

+#define OP_ALG_PR_ON   0x02
+
 #define OP_ALG_DIR_SHIFT   0
 #define OP_ALG_DIR_MASK1
 #define OP_ALG_DECRYPT 0
diff --git a/drivers/crypto/fsl/jobdesc.c 
b/drivers/crypto/fsl/jobdesc.c

index 6102e9c06b..d9554c550b 100644
--- a/drivers/crypto/fsl/jobdesc.c
+++ b/drivers/crypto/fsl/jobdesc.c
@@ -266,7 +266,8 @@ void inline_cnstr_jobdesc_rng_instantiation(u32
*desc, int handle, int do_sk)

/* INIT RNG in non-test mode */
append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
-   (handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INIT);
+(handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INIT |
+OP_ALG_PR_ON);

/* For SH0, Secure Keys must be generated as well */
if (!handle && do_sk) {
@@ -286,6 +287,15 @@ void inline_cnstr_jobdesc_rng_instantiation(u32
*desc, int handle, int do_sk)
}
 }

+/* Descriptor for deinstantiation of the RNG block. */
+void inline_cnstr_jobdesc_rng_deinstantiation(u32 *desc, int handle)
+{
+   init_job_desc(desc, 0);
+
+   append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
+(handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INITFINAL);
+}
+
 /* Change key size to bytes form bits in calling function*/
 void inline_cnstr_jobdesc_pkha_rsaexp(uint32_t *desc,
  struct pk_in_params *pkin, uint8_t *out,
diff --git a/drivers/crypto/fsl/jobdesc.h 
b/drivers/crypto/fsl/jobdesc.h

index 14b2a119d7..5185ddd535 100644
--- a/drivers/crypto/fsl/jobdesc.h
+++ b/drivers/crypto/fsl/jobdesc.h
@@ -41,6 +41,8 @@ void inline_cnstr_jobdesc_blob_decap(uint32_t *desc,
uint8_t *key_idnfr,

 void inline_cnstr_jobdesc_rng_instantiation(u32 *desc, int handle, int 
do_sk);


+void inline_cnstr_jobdesc_rng_deinstantiation(u32 *desc, int handle);
+
 void inline_cnstr_jobdesc_pkha_rsaexp(uint32_t *desc,
  struct pk_in_params *pkin, uint8_t *out,
  uint32_t out_siz);
diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index 42865a6cd7..14f9227b37 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -446,6 +446,51 @@ int sec_reset(void)
return sec_reset_idx(0);
 }
 #ifndef CONFIG_SPL_BUILD
+static int deinstantiate_rng(u8 sec_idx, int state_handle_mask)
+{
+   u32 *desc;
+   int sh_idx, ret = 0;
+   int desc_size = sizeof(u32) * 3;


This should be 2.


+
+   desc = memalign(ARCH_DMA_MINALIGN, desc_size);
+   if (!desc) {
+   debug("cannot allocate RNG init descriptor memory\n");
+   return -ENOMEM;
+   }
+
+   for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) {
+   /*
+* If the corresponding bit is set, then it means the state
+* handle was initialized by us, and thus it needs to be
+* deinitialized as well
+*/
+
+   if (state_handle_mask & RDSTA_IF(sh_idx)) {
+   /*
+* Create the descriptor for deinstantating this state
+* handle.
+*/
+   inline_cnstr_jobdesc_rng_deinstantiation(desc, sh_idx);
+   flush_dcache_range((unsigned long)desc,
+  (unsigned long)desc + desc_size);
+
+   ret = run_descriptor_jr_idx(desc, sec_idx);
+   if (ret) {
+printf("SEC%u:  RNG4 SH%d deinstantiation failed with error 
0x%x\n",

+  sec_idx, sh_idx, ret);
+   ret = -EIO;
+   break;
+   }
+
+   printf("SEC%u:  Deinstantiated RNG4 SH%d\n",
+  sec_idx, sh_idx);
+   }
+   }
+
+   free(desc);
+   return ret;
+}
+
 static int instantiate_rng(u8 sec_idx, int gen_sk)
 {
u32 *desc;
@@ -466,9 +511,18 @@ static int instantiate_rng(u8 sec_idx, int gen_sk)
 * If the corresponding bit is set, this state handle
 

Re: [PATCH 06/10] dtoc: extend dtoc to use struct driver_info when linking nodes

2020-06-04 Thread Simon Glass
On Fri, 29 May 2020 at 12:15, Walter Lozano  wrote:
>
> In the current implementation, when dtoc parses a dtb to generate a struct
> platdata it converts the information related to linked nodes as pointers
> to struct platdata of destination nodes. By doing this, it makes
> difficult to get pointer to udevices created based on these
> information.
>
> This patch extends dtoc to use struct driver_info when populating
> information about linked nodes, which makes it easier to later get
> the devices created. In this context, reimplement functions like
> clk_get_by_index_platdata() which made use of the previous approach.
>
> Signed-off-by: Walter Lozano 
> ---
>  drivers/clk/clk-uclass.c| 11 +--
>  drivers/misc/irq-uclass.c   | 10 --
>  drivers/mmc/ftsdc010_mci.c  |  2 +-
>  drivers/mmc/rockchip_dw_mmc.c   |  2 +-
>  drivers/mmc/rockchip_sdhci.c|  2 +-
>  drivers/ram/rockchip/sdram_rk3399.c |  2 +-
>  drivers/spi/rk_spi.c|  2 +-
>  include/clk.h   |  4 ++--
>  tools/dtoc/dtb_platdata.py  | 24 +---
>  9 files changed, 37 insertions(+), 22 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 02/10] dtoc: add option to disable warnings

2020-06-04 Thread Simon Glass
Hi Walter,

On Fri, 29 May 2020 at 12:15, Walter Lozano  wrote:
>
> As dtoc now performs checks for valid driver names, when running dtoc
> tests several warnings arise as these tests don't use valid driver
> names.
>
> This patch adds an option to disable those warning, which is only
> intended for running tests.
>
> Signed-off-by: Walter Lozano 
> ---
>  tools/dtoc/dtb_platdata.py | 11 +---
>  tools/dtoc/test_dtoc.py| 54 +++---
>  2 files changed, 34 insertions(+), 31 deletions(-)
>
> diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
> index 23cfda2f88..0a54188348 100644
> --- a/tools/dtoc/dtb_platdata.py
> +++ b/tools/dtoc/dtb_platdata.py
> @@ -141,17 +141,19 @@ class DtbPlatdata(object):
>  _valid_nodes: A list of Node object with compatible strings
>  _include_disabled: true to include nodes marked status = "disabled"
>  _outfile: The current output file (sys.stdout or a real file)
> +_warning_disabled: true to disable warnings about driver names not 
> found
>  _lines: Stashed list of output lines for outputting in the future
>  _aliases: Dict that hold aliases for compatible strings
>  _drivers: List of valid driver names found in drivers/
>  _driver_aliases: Dict that holds aliases for driver names
>  """
> -def __init__(self, dtb_fname, include_disabled):
> +def __init__(self, dtb_fname, include_disabled, warning_disable):
>  self._fdt = None
>  self._dtb_fname = dtb_fname
>  self._valid_nodes = None
>  self._include_disabled = include_disabled
>  self._outfile = None
> +self._warning_disable = warning_disable
>  self._lines = []
>  self._aliases = {}
>  self._drivers = []
> @@ -177,7 +179,8 @@ class DtbPlatdata(object):
>  compat_c_old = compat_c
>  compat_c = self._driver_aliases.get(compat_c)
>  if not compat_c:
> -print('WARNING: the driver %s was not found in the driver 
> list' % (compat_c_old))
> +if not self._warning_disable: # pragma: no cover

Need coverage for this.

> +print('WARNING: the driver %s was not found in the 
> driver list' % (compat_c_old))
>  compat_c = compat_c_old
>  else: # pragma: no cover
>  aliases_c = [compat_c_old] + aliases_c
> @@ -623,7 +626,7 @@ class DtbPlatdata(object):
>  nodes_to_output.remove(node)
>
>
> -def run_steps(args, dtb_file, include_disabled, output):
> +def run_steps(args, dtb_file, include_disabled, output, warning_disable = 
> False):

no spaces around =

>  """Run all the steps of the dtoc tool
>
>  Args:
> @@ -635,7 +638,7 @@ def run_steps(args, dtb_file, include_disabled, output):
>  if not args:
>  raise ValueError('Please specify a command: struct, platdata')
>
> -plat = DtbPlatdata(dtb_file, include_disabled)
> +plat = DtbPlatdata(dtb_file, include_disabled, warning_disable)
>  plat.scan_drivers()
>  plat.scan_dtb()
>  plat.scan_tree()
> diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
> index 8498e8303c..a9b605cac8 100755
> --- a/tools/dtoc/test_dtoc.py
> +++ b/tools/dtoc/test_dtoc.py
> @@ -154,12 +154,12 @@ class TestDtoc(unittest.TestCase):
>  """Test output from a device tree file with no nodes"""
>  dtb_file = get_dtb_file('dtoc_test_empty.dts')
>  output = tools.GetOutputFilename('output')
> -dtb_platdata.run_steps(['struct'], dtb_file, False, output)
> +dtb_platdata.run_steps(['struct'], dtb_file, False, output, True)
>  with open(output) as infile:
>  lines = infile.read().splitlines()
>  self.assertEqual(HEADER.splitlines(), lines)
>
> -dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
> +dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True)

Can you create run_test which calls run_steps with that set that to
True, to avoid adding the param everywhere in this file?

Regards,
Simon


Re: [PATCH 09/10] dtoc: update dtb_platdata to support cd-gpios

2020-06-04 Thread Simon Glass
On Fri, 29 May 2020 at 12:15, Walter Lozano  wrote:
>
> Currently dtoc does not support the property cd-gpios used to declare
> the gpios for card detect in mmc.
>
> This patch adds support to cd-gpios property.
>
> Signed-off-by: Walter Lozano 
> ---
>  tools/dtoc/dtb_platdata.py | 13 -
>  tools/dtoc/test_dtoc.py|  2 +-
>  2 files changed, 9 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass 

But I think you should mention GPIOs, rather than just cd-gpios, as it
seems this will add support for any GPIO.


Re: [PATCH 08/10] dtoc: update tests to match new platdata

2020-06-04 Thread Simon Glass
On Fri, 29 May 2020 at 12:15, Walter Lozano  wrote:
>
> After using a new approach to link nodes when OF_PLATDATA is enabled
> the test cases need to be update.
>
> This patch updates the tests based on this new implementation.
>
> Signed-off-by: Walter Lozano 
> ---
>  tools/dtoc/test_dtoc.py | 95 +++--
>  1 file changed, 54 insertions(+), 41 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 04/10] core: drop const for struct driver_info

2020-06-04 Thread Simon Glass
On Fri, 29 May 2020 at 12:15, Walter Lozano  wrote:
>
> In order to prepare for a new support of phandle when OF_PLATDATA is used
> drop the const for struct driver_info as this struct will need to be
> updated on runtime.
>
> Signed-off-by: Walter Lozano 
> ---
>  drivers/core/device.c| 2 +-
>  drivers/core/root.c  | 2 +-
>  include/dm/device-internal.h | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 05/10] core: extend struct driver_info to point to device

2020-06-04 Thread Simon Glass
Hi Walter,

On Fri, 29 May 2020 at 12:15, Walter Lozano  wrote:
>
> Currently when creating an U_BOOT_DEVICE entry a struct driver_info
> is declared, which contains the data needed to instantiate the device.
> However, the actual device is created at runtime and there is no proper
> way to get the device based on its struct driver_info.
>
> This patch extends struct driver_info adding a pointer to udevice which
> is populated during the bind process, allowing to generate a set of
> functions to get the device based on its struct driver_info.
>
> Signed-off-by: Walter Lozano 
> ---
>  drivers/core/device.c | 26 +++---
>  drivers/core/root.c   |  4 
>  include/dm/device.h   | 14 ++
>  include/dm/platdata.h | 14 ++
>  4 files changed, 55 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass 

Nits below

>
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index a0ad080aaf..5adbc30849 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -250,6 +250,7 @@ int device_bind_by_name(struct udevice *parent, bool 
> pre_reloc_only,
>  {
> struct driver *drv;
> uint platdata_size = 0;
> +   int ret = 0;

Can you drop = 0 ?

>
> drv = lists_driver_lookup_name(info->name);
> if (!drv)
> @@ -260,9 +261,16 @@ int device_bind_by_name(struct udevice *parent, bool 
> pre_reloc_only,
>  #if CONFIG_IS_ENABLED(OF_PLATDATA)
> platdata_size = info->platdata_size;
>  #endif
> -   return device_bind_common(parent, drv, info->name,
> -   (void *)info->platdata, 0, ofnode_null(), 
> platdata_size,
> -   devp);
> +   ret = device_bind_common(parent, drv, info->name,
> +(void *)info->platdata, 0, ofnode_null(),
> +platdata_size, devp);
> +   if (ret)
> +   return ret;
> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
> +   info->dev = *devp;
> +#endif
> +
> +   return ret;
>  }
>
>  static void *alloc_priv(int size, uint flags)
> @@ -727,6 +735,18 @@ int device_get_global_by_ofnode(ofnode ofnode, struct 
> udevice **devp)
> return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp);
>  }
>
> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
> +int device_get_by_driver_info(const struct driver_info *info,
> + struct udevice **devp)
> +{
> +   struct udevice *dev;
> +
> +   dev = info->dev;
> +
> +   return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp);
> +}
> +#endif
> +
>  int device_find_first_child(const struct udevice *parent, struct udevice 
> **devp)
>  {
> if (list_empty(>child_head)) {
> diff --git a/drivers/core/root.c b/drivers/core/root.c
> index c9ee56478a..8f47a6b356 100644
> --- a/drivers/core/root.c
> +++ b/drivers/core/root.c
> @@ -346,6 +346,10 @@ int dm_init_and_scan(bool pre_reloc_only)
>  {
> int ret;
>
> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
> +   populate_phandle_data();
> +#endif
> +
> ret = dm_init(IS_ENABLED(CONFIG_OF_LIVE));
> if (ret) {
> debug("dm_init() failed: %d\n", ret);
> diff --git a/include/dm/device.h b/include/dm/device.h
> index 2cfe10766f..a3b3e5bc46 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -538,6 +538,20 @@ int device_find_global_by_ofnode(ofnode node, struct 
> udevice **devp);
>   */
>  int device_get_global_by_ofnode(ofnode node, struct udevice **devp);
>
> +/**
> + * device_get_by_driver_info() - Get a device based on driver_info
> + *
> + * Locates a device by its struct driver_info.
> + *
> + * The device is probed to activate it ready for use.
> + *
> + * @info: Struct driver_info

Here you should mention using DM_GET_DRIVER() to find it.

> + * @devp: Returns pointer to device if found, otherwise this is set to NULL
> + * @return 0 if OK, -ve on error
> + */
> +int device_get_by_driver_info(const struct driver_info *info,
> + struct udevice **devp);
> +
>  /**
>   * device_find_first_child() - Find the first child of a device
>   *
> diff --git a/include/dm/platdata.h b/include/dm/platdata.h
> index c972fa6936..238379b0e4 100644
> --- a/include/dm/platdata.h
> +++ b/include/dm/platdata.h
> @@ -22,12 +22,14 @@
>   * @name:  Driver name
>   * @platdata:  Driver-specific platform data
>   * @platdata_size: Size of platform data structure
> + * @dev:   Device created from this structure data
>   */
>  struct driver_info {
> const char *name;
> const void *platdata;
>  #if CONFIG_IS_ENABLED(OF_PLATDATA)
> uint platdata_size;
> +   struct udevice *dev;
>  #endif
>  };
>
> @@ -43,4 +45,16 @@ struct driver_info {
>  #define U_BOOT_DEVICES(__name) \
> ll_entry_declare_list(struct driver_info, __name, driver_info)
>
> +/* Get a pointer to a given driver */
> +#define DM_GET_DEVICE(__name)

Re: [PATCH 10/10] dtoc add test for cd-gpios

2020-06-04 Thread Simon Glass
On Fri, 29 May 2020 at 12:15, Walter Lozano  wrote:
>
> Add a test for dtoc taking into account the cd-gpios property.
>
> Signed-off-by: Walter Lozano 
> ---
>  tools/dtoc/dtoc_test_phandle_cd_gpios.dts | 42 ++
>  tools/dtoc/test_dtoc.py   | 67 +++
>  2 files changed, 109 insertions(+)
>  create mode 100644 tools/dtoc/dtoc_test_phandle_cd_gpios.dts

Reviewed-by: Simon Glass 


Re: [PATCH 07/10] dm: doc: update of-plat with new phandle support

2020-06-04 Thread Simon Glass
On Fri, 29 May 2020 at 12:15, Walter Lozano  wrote:
>
> Update documentation to reflect the new phandle support when OF_PLATDATA
> is used. Now phandles are implemented as pointers to U_BOOT_DEVICE,
> which makes it possible to get a pointer to the actual device.
>
> Signed-off-by: Walter Lozano 
> ---
>  doc/driver-model/of-plat.rst | 24 
>  1 file changed, 16 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass 

But note dm_populate_...

I would like it to be easy to see what module/subsystem a function belongs to.


Re: [PATCH 01/10] dtoc: add support to scan drivers

2020-06-04 Thread Simon Glass
Hi Walter,

On Fri, 29 May 2020 at 12:15, Walter Lozano  wrote:
>
> Currently dtoc scans dtbs to convert them to struct platdata and
> to generate U_BOOT_DEVICE entries. These entries need to be filled
> with the driver name, but at this moment the information used is the
> compatible name present in the dtb. This causes that only nodes with
> a compatible name that matches a driver name generate a working
> entry.
>
> In order to improve this behaviour, this patch adds to dtoc the
> capability of scan drivers source code to generate a list of valid driver
> names. This allows to rise a warning in the case that an U_BOOT_DEVICE
> entry will try to use a name not valid.
>
> Additionally, in order to add more flexibility to the solution, adds the
> U_BOOT_DRIVER_ALIAS macro, which generates no code at all, but allows an
> easy way to declare driver name aliases. Thanks to this, dtoc can look
> for the driver name based on its alias when it populates the U_BOOT_DEVICE
> entry.
>
> Signed-off-by: Walter Lozano 
> ---
>  include/dm/device.h|  7 
>  tools/dtoc/dtb_platdata.py | 83 --
>  2 files changed, 86 insertions(+), 4 deletions(-)
>
> diff --git a/include/dm/device.h b/include/dm/device.h
> index 975eec5d0e..2cfe10766f 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -282,6 +282,13 @@ struct driver {
>  #define DM_GET_DRIVER(__name)  \
> ll_entry_get(struct driver, __name, driver)
>
> +/**
> + * Declare a macro to state a alias for a driver name. This macro will
> + * produce no code but its information will be parsed by tools like
> + * dtoc
> + */
> +#define U_BOOT_DRIVER_ALIAS(__name, __alias)
> +
>  /**
>   * dev_get_platdata() - Get the platform data for a device
>   *
> diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
> index ecfe0624d1..23cfda2f88 100644
> --- a/tools/dtoc/dtb_platdata.py
> +++ b/tools/dtoc/dtb_platdata.py
> @@ -13,6 +13,8 @@ static data.
>
>  import collections
>  import copy
> +import os
> +import re
>  import sys
>
>  from dtoc import fdt
> @@ -140,6 +142,9 @@ class DtbPlatdata(object):
>  _include_disabled: true to include nodes marked status = "disabled"
>  _outfile: The current output file (sys.stdout or a real file)
>  _lines: Stashed list of output lines for outputting in the future
> +_aliases: Dict that hold aliases for compatible strings
key: The driver name, i.e. the part between brackets in U_BOOT_DRIVER(xx)  ??
value: ...
> +_drivers: List of valid driver names found in drivers/
> +_driver_aliases: Dict that holds aliases for driver names
key:
vaue:

>  """
>  def __init__(self, dtb_fname, include_disabled):
>  self._fdt = None
> @@ -149,6 +154,35 @@ class DtbPlatdata(object):
>  self._outfile = None
>  self._lines = []
>  self._aliases = {}
> +self._drivers = []
> +self._driver_aliases = {}
> +
> +def get_normalized_compat_name(self, node):
> +"""Get a node's normalized compat name
> +
> +Returns a valid driver name by retrieving node's first compatible
> +string as a C identifier and perfomrming a check against _drivers

performing

> +and a lookup in driver_aliases rising a warning in case of failure.

s/ rising/, printing/

> +
> +Args:
> +node: Node object to check
> +Return:
> +Tuple:
> +Driver name associated with the first compatible string
> +List of C identifiers for all the other compatible strings
> +(possibly empty)

Can you update this comment to explain what is returned when it is not found?

> +"""
> +compat_c, aliases_c = get_compat_name(node)
> +if compat_c not in self._drivers:
> +compat_c_old = compat_c
> +compat_c = self._driver_aliases.get(compat_c)
> +if not compat_c:
> +print('WARNING: the driver %s was not found in the driver 
> list' % (compat_c_old))

This creates lots of warnings at present. Either we need a patch to
clean up the differences in the source code, or we need to disable the
warning.

Also the warning is not really actionable. It needs to add mention of
U_BOOT_DEVICE and ...ALIAS.

In future we can scan the compatible strings and tell the user what
changes to make, I suppose.

> +compat_c = compat_c_old
> +else: # pragma: no cover

Need to fix the coverage here

> +aliases_c = [compat_c_old] + aliases_c
> +
> +return compat_c, aliases_c
>
>  def setup_output(self, fname):
>  """Set up the output destination
> @@ -243,6 +277,46 @@ class DtbPlatdata(object):
>  return PhandleInfo(max_args, args)
>  return None
>
> +def scan_driver(self, fn):
> +"""Scan a driver file to build a list of driver names and 

Re: [PATCH 03/10] dm: doc: update of-plat with the suppor for driver aliases

2020-06-04 Thread Simon Glass
On Fri, 29 May 2020 at 12:15, Walter Lozano  wrote:
>
> Update the documentation with the support for driver aliases using
> U_BOOT_DRIVER_ALIAS.
>
> Signed-off-by: Walter Lozano 
> ---
>  doc/driver-model/of-plat.rst | 14 +-
>  1 file changed, 13 insertions(+), 1 deletion(-)
>

Reviewed-by: Simon Glass 


Re: Re: [PATCH v2 00/35] dm: Add programmatic generation of ACPI tables (part B)

2020-06-04 Thread Simon Glass
Hi Wolfgang,

On Thu, 4 Jun 2020 at 07:27, Wolfgang Wallner
 wrote:
>
> Hi Simon,
>
> -"U-Boot"  schrieb: -
> > Betreff: Antwort: Re: [PATCH v2 00/35] dm: Add programmatic generation of 
> > ACPI tables (part B)
> >
> > Hi Bin,
> >
> > -"Bin Meng"  schrieb: -
> > > Betreff: Re: [PATCH v2 00/35] dm: Add programmatic generation of ACPI 
> > > tables (part B)
> > >
> > > Hi Wolfgang, Andy,
> > >
> > > On Mon, May 11, 2020 at 4:34 AM Simon Glass  wrote:
> > > >
> > > > NOTE: I have resent this as v1 to avoid confusion
> > > >
> > > > This is split from the original series in an attempt to get things 
> > > > applied
> > > > in chunks.
> > > >
>
> [snip]
>
> > > >
> > >
> > > Since you were involved a lot in the discussion in the part A series,
> > > would you please let me know if you get some time to review this?
> >
> > Unfortunately, I don't have as much time now for review of part B as I had 
> > for
> > part A. I already started reviewing part B and I will try to continue when 
> > time
> > allows.
>
> I'm done with my review of v2 of part B.
> I haven't commented on the patches 06/35 and 12/35, as the comments would be
> similar as in other patches of the series and I thought it would not make 
> sense
> to review them without waiting for the feedback to the other reviews.
>

OK great, thank you! I'll go through these soon.

Regards,
Simon


[PATCH v2 4/6] crypto/fsl: don't regenerate secure keys

2020-06-04 Thread Michael Walle
The secure keys (TDKEK, JDKEK, TDSK) can only be generated once after a
POR. Otherwise the RNG4 will throw an error.

Signed-off-by: Michael Walle 
---
 drivers/crypto/fsl/jobdesc.c | 4 ++--
 drivers/crypto/fsl/jobdesc.h | 2 +-
 drivers/crypto/fsl/jr.c  | 9 +
 include/fsl_sec.h| 1 +
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/fsl/jobdesc.c b/drivers/crypto/fsl/jobdesc.c
index 2f35e0c90b..6102e9c06b 100644
--- a/drivers/crypto/fsl/jobdesc.c
+++ b/drivers/crypto/fsl/jobdesc.c
@@ -258,7 +258,7 @@ void inline_cnstr_jobdesc_blob_decap(uint32_t *desc, 
uint8_t *key_idnfr,
  * Descriptor to instantiate RNG State Handle 0 in normal mode and
  * load the JDKEK, TDKEK and TDSK registers
  */
-void inline_cnstr_jobdesc_rng_instantiation(uint32_t *desc, int handle)
+void inline_cnstr_jobdesc_rng_instantiation(u32 *desc, int handle, int do_sk)
 {
u32 *jump_cmd;
 
@@ -269,7 +269,7 @@ void inline_cnstr_jobdesc_rng_instantiation(uint32_t *desc, 
int handle)
(handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INIT);
 
/* For SH0, Secure Keys must be generated as well */
-   if (handle == 0) {
+   if (!handle && do_sk) {
/* wait for done */
jump_cmd = append_jump(desc, JUMP_CLASS_CLASS1);
set_jump_tgt_here(desc, jump_cmd);
diff --git a/drivers/crypto/fsl/jobdesc.h b/drivers/crypto/fsl/jobdesc.h
index d782c46b9d..14b2a119d7 100644
--- a/drivers/crypto/fsl/jobdesc.h
+++ b/drivers/crypto/fsl/jobdesc.h
@@ -39,7 +39,7 @@ void inline_cnstr_jobdesc_blob_decap(uint32_t *desc, uint8_t 
*key_idnfr,
 uint8_t *enc_blob, uint8_t *plain_txt,
 uint32_t out_sz);
 
-void inline_cnstr_jobdesc_rng_instantiation(uint32_t *desc, int handle);
+void inline_cnstr_jobdesc_rng_instantiation(u32 *desc, int handle, int do_sk);
 
 void inline_cnstr_jobdesc_pkha_rsaexp(uint32_t *desc,
  struct pk_in_params *pkin, uint8_t *out,
diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index 5275c50e8b..42865a6cd7 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -446,7 +446,7 @@ int sec_reset(void)
return sec_reset_idx(0);
 }
 #ifndef CONFIG_SPL_BUILD
-static int instantiate_rng(uint8_t sec_idx)
+static int instantiate_rng(u8 sec_idx, int gen_sk)
 {
u32 *desc;
u32 rdsta_val;
@@ -470,7 +470,7 @@ static int instantiate_rng(uint8_t sec_idx)
if (rdsta_val & (1 << sh_idx))
continue;
 
-   inline_cnstr_jobdesc_rng_instantiation(desc, sh_idx);
+   inline_cnstr_jobdesc_rng_instantiation(desc, sh_idx, gen_sk);
size = roundup(sizeof(uint32_t) * 6, ARCH_DMA_MINALIGN);
flush_dcache_range((unsigned long)desc,
   (unsigned long)desc + size);
@@ -546,12 +546,13 @@ static void kick_trng(int ent_delay, uint8_t sec_idx)
 
 static int rng_init(uint8_t sec_idx)
 {
-   int ret, ent_delay = RTSDCTL_ENT_DLY_MIN;
+   int ret, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN;
ccsr_sec_t __iomem *sec = (ccsr_sec_t __iomem *)SEC_ADDR(sec_idx);
struct rng4tst __iomem *rng =
(struct rng4tst __iomem *)>rng;
u32 inst_handles;
 
+   gen_sk = !(sec_in32(>rdsta) & RDSTA_SKVN);
do {
inst_handles = sec_in32(>rdsta) & RNG_STATE_HANDLE_MASK;
 
@@ -574,7 +575,7 @@ static int rng_init(uint8_t sec_idx)
 * interval, leading to a sucessful initialization of
 * the RNG.
 */
-   ret = instantiate_rng(sec_idx);
+   ret = instantiate_rng(sec_idx, gen_sk);
} while ((ret == -1) && (ent_delay < RTSDCTL_ENT_DLY_MAX));
if (ret) {
printf("SEC%u:  Failed to instantiate RNG\n", sec_idx);
diff --git a/include/fsl_sec.h b/include/fsl_sec.h
index 8dce0bbb1b..64b8751f2d 100644
--- a/include/fsl_sec.h
+++ b/include/fsl_sec.h
@@ -69,6 +69,7 @@ struct rng4tst {
 #define RNG_STATE1_HANDLE_INSTANTIATED 0x0002
 #define RNG_STATE_HANDLE_MASK  \
(RNG_STATE0_HANDLE_INSTANTIATED | RNG_STATE1_HANDLE_INSTANTIATED)
+#define RDSTA_SKVN 0x4000
u32 rdsta;  /*RNG DRNG Status Register*/
u32 rsvd2[15];
 };
-- 
2.20.1



[PATCH v2 2/6] crypto/fsl: export caam_get_era()

2020-06-04 Thread Michael Walle
We need the era in other modules, too. For example, to get the RNG
version.

Signed-off-by: Michael Walle 
Reviewed-by: Horia Geantă 
---
 drivers/crypto/fsl/sec.c | 10 +-
 include/fsl_sec.h|  2 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/fsl/sec.c b/drivers/crypto/fsl/sec.c
index a2c0bfaf44..18fc0c66e2 100644
--- a/drivers/crypto/fsl/sec.c
+++ b/drivers/crypto/fsl/sec.c
@@ -98,7 +98,15 @@ void fdt_fixup_crypto_node(void *blob, int sec_rev)
   fdt_strerror(err));
 }
 #elif CONFIG_SYS_FSL_SEC_COMPAT >= 4  /* SEC4 */
-static u8 caam_get_era(void)
+/**
+ * caam_get_era() - fetch the CAAM's era
+ *
+ * The SEC module povides an "Era" which can be used to differentiate
+ * between different revisions.
+ *
+ * Return: era of the SEC.
+ */
+u8 caam_get_era(void)
 {
static const struct {
u16 ip_id;
diff --git a/include/fsl_sec.h b/include/fsl_sec.h
index c0d2c7e866..2ebb75c9b2 100644
--- a/include/fsl_sec.h
+++ b/include/fsl_sec.h
@@ -316,6 +316,8 @@ int blob_dek(const u8 *src, u8 *dst, u8 len);
 int sec_init_idx(uint8_t);
 #endif
 int sec_init(void);
+
+u8 caam_get_era(void);
 #endif
 
 #endif /* __FSL_SEC_H */
-- 
2.20.1



[PATCH v2 6/6] crypto/fsl: add RNG support

2020-06-04 Thread Michael Walle
Register the random number generator with the rng subsystem in u-boot.
This way it can be used by EFI as well as for the 'rng' command.

Signed-off-by: Michael Walle 
---
 drivers/crypto/fsl/Kconfig   | 14 ++
 drivers/crypto/fsl/Makefile  |  1 +
 drivers/crypto/fsl/jobdesc.c | 10 +
 drivers/crypto/fsl/jobdesc.h |  3 ++
 drivers/crypto/fsl/jr.c  |  9 
 drivers/crypto/fsl/rng.c | 84 
 6 files changed, 121 insertions(+)
 create mode 100644 drivers/crypto/fsl/rng.c

diff --git a/drivers/crypto/fsl/Kconfig b/drivers/crypto/fsl/Kconfig
index 181a1e5e99..5ed6140da3 100644
--- a/drivers/crypto/fsl/Kconfig
+++ b/drivers/crypto/fsl/Kconfig
@@ -45,3 +45,17 @@ config SYS_FSL_SEC_COMPAT
 
 config SYS_FSL_SEC_LE
bool "Little-endian access to Freescale Secure Boot"
+
+if FSL_CAAM
+
+config FSL_CAAM_RNG
+   bool "Enable Random Number Generator support"
+   depends on DM_RNG
+   default y
+   help
+ Enable support for the hardware based random number generator
+ module of the CAAM. The random data is fetched from the DRGB
+ using the prediction resistance flag which means the DRGB is
+ reseeded from the TRNG every time random data is generated.
+
+endif
diff --git a/drivers/crypto/fsl/Makefile b/drivers/crypto/fsl/Makefile
index cfb36f3bb9..a5e8d38e38 100644
--- a/drivers/crypto/fsl/Makefile
+++ b/drivers/crypto/fsl/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_FSL_CAAM) += jr.o fsl_hash.o jobdesc.o error.o
 obj-$(CONFIG_CMD_BLOB) += fsl_blob.o
 obj-$(CONFIG_CMD_DEKBLOB) += fsl_blob.o
 obj-$(CONFIG_RSA_FREESCALE_EXP) += fsl_rsa.o
+obj-$(CONFIG_FSL_CAAM_RNG) += rng.o
diff --git a/drivers/crypto/fsl/jobdesc.c b/drivers/crypto/fsl/jobdesc.c
index d9554c550b..decde64078 100644
--- a/drivers/crypto/fsl/jobdesc.c
+++ b/drivers/crypto/fsl/jobdesc.c
@@ -296,6 +296,16 @@ void inline_cnstr_jobdesc_rng_deinstantiation(u32 *desc, 
int handle)
 (handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INITFINAL);
 }
 
+void inline_cnstr_jobdesc_rng(u32 *desc, void *data_out, u32 size)
+{
+   dma_addr_t dma_data_out = virt_to_phys(data_out);
+
+   init_job_desc(desc, 0);
+   append_operation(desc, OP_ALG_ALGSEL_RNG | OP_TYPE_CLASS1_ALG |
+OP_ALG_PR_ON);
+   append_fifo_store(desc, dma_data_out, size, FIFOST_TYPE_RNGSTORE);
+}
+
 /* Change key size to bytes form bits in calling function*/
 void inline_cnstr_jobdesc_pkha_rsaexp(uint32_t *desc,
  struct pk_in_params *pkin, uint8_t *out,
diff --git a/drivers/crypto/fsl/jobdesc.h b/drivers/crypto/fsl/jobdesc.h
index 5185ddd535..c4501abd26 100644
--- a/drivers/crypto/fsl/jobdesc.h
+++ b/drivers/crypto/fsl/jobdesc.h
@@ -43,7 +43,10 @@ void inline_cnstr_jobdesc_rng_instantiation(u32 *desc, int 
handle, int do_sk);
 
 void inline_cnstr_jobdesc_rng_deinstantiation(u32 *desc, int handle);
 
+void inline_cnstr_jobdesc_rng(u32 *desc, void *data_out, u32 size);
+
 void inline_cnstr_jobdesc_pkha_rsaexp(uint32_t *desc,
  struct pk_in_params *pkin, uint8_t *out,
  uint32_t out_siz);
+
 #endif
diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index 14f9227b37..629a0f30db 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #endif
+#include 
 
 #define CIRC_CNT(head, tail, size) (((head) - (tail)) & (size - 1))
 #define CIRC_SPACE(head, tail, size)   CIRC_CNT((tail), (head) + 1, (size))
@@ -720,6 +721,14 @@ int sec_init_idx(uint8_t sec_idx)
printf("SEC%u:  RNG instantiation failed\n", sec_idx);
return -1;
}
+
+   if (IS_ENABLED(CONFIG_DM_RNG)) {
+   ret = device_bind_driver(NULL, "caam-rng", "caam-rng",
+NULL);
+   if (ret)
+   printf("Couldn't bind rng driver (%d)\n", ret);
+   }
+
printf("SEC%u:  RNG instantiated\n", sec_idx);
}
 #endif
diff --git a/drivers/crypto/fsl/rng.c b/drivers/crypto/fsl/rng.c
new file mode 100644
index 00..3da318d767
--- /dev/null
+++ b/drivers/crypto/fsl/rng.c
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Michael Walle 
+ *
+ * Driver for Freescale Cryptographic Accelerator and Assurance
+ * Module (CAAM) hardware random number generator.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "desc_constr.h"
+#include "jobdesc.h"
+#include "jr.h"
+
+#define CAAM_RNG_MAX_FIFO_STORE_SIZE 16
+#define CAAM_RNG_DESC_LEN (3 * CAAM_CMD_SZ + CAAM_PTR_SZ)
+
+struct caam_rng_platdata {
+   u32 desc[CAAM_RNG_DESC_LEN / 4];
+   u8 data[CAAM_RNG_MAX_FIFO_STORE_SIZE] __aligned(ARCH_DMA_MINALIGN);
+};
+
+static int caam_rng_read_one(struct caam_rng_platdata *pdata)
+{

[PATCH v2 5/6] crypto/fsl: instantiate the RNG with prediciton resistance

2020-06-04 Thread Michael Walle
If it is already instantiated tear it down first and then reinstanciate
it again with prediction resistance.

Signed-off-by: Michael Walle 
---
 drivers/crypto/fsl/desc.h|  2 ++
 drivers/crypto/fsl/jobdesc.c | 12 ++-
 drivers/crypto/fsl/jobdesc.h |  2 ++
 drivers/crypto/fsl/jr.c  | 66 
 include/fsl_sec.h|  7 ++--
 5 files changed, 78 insertions(+), 11 deletions(-)

diff --git a/drivers/crypto/fsl/desc.h b/drivers/crypto/fsl/desc.h
index 11ad506829..3589e6ea02 100644
--- a/drivers/crypto/fsl/desc.h
+++ b/drivers/crypto/fsl/desc.h
@@ -520,6 +520,8 @@
 #define OP_ALG_ICV_OFF (0 << OP_ALG_ICV_SHIFT)
 #define OP_ALG_ICV_ON  (1 << OP_ALG_ICV_SHIFT)
 
+#define OP_ALG_PR_ON   0x02
+
 #define OP_ALG_DIR_SHIFT   0
 #define OP_ALG_DIR_MASK1
 #define OP_ALG_DECRYPT 0
diff --git a/drivers/crypto/fsl/jobdesc.c b/drivers/crypto/fsl/jobdesc.c
index 6102e9c06b..d9554c550b 100644
--- a/drivers/crypto/fsl/jobdesc.c
+++ b/drivers/crypto/fsl/jobdesc.c
@@ -266,7 +266,8 @@ void inline_cnstr_jobdesc_rng_instantiation(u32 *desc, int 
handle, int do_sk)
 
/* INIT RNG in non-test mode */
append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
-   (handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INIT);
+(handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INIT |
+OP_ALG_PR_ON);
 
/* For SH0, Secure Keys must be generated as well */
if (!handle && do_sk) {
@@ -286,6 +287,15 @@ void inline_cnstr_jobdesc_rng_instantiation(u32 *desc, int 
handle, int do_sk)
}
 }
 
+/* Descriptor for deinstantiation of the RNG block. */
+void inline_cnstr_jobdesc_rng_deinstantiation(u32 *desc, int handle)
+{
+   init_job_desc(desc, 0);
+
+   append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
+(handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INITFINAL);
+}
+
 /* Change key size to bytes form bits in calling function*/
 void inline_cnstr_jobdesc_pkha_rsaexp(uint32_t *desc,
  struct pk_in_params *pkin, uint8_t *out,
diff --git a/drivers/crypto/fsl/jobdesc.h b/drivers/crypto/fsl/jobdesc.h
index 14b2a119d7..5185ddd535 100644
--- a/drivers/crypto/fsl/jobdesc.h
+++ b/drivers/crypto/fsl/jobdesc.h
@@ -41,6 +41,8 @@ void inline_cnstr_jobdesc_blob_decap(uint32_t *desc, uint8_t 
*key_idnfr,
 
 void inline_cnstr_jobdesc_rng_instantiation(u32 *desc, int handle, int do_sk);
 
+void inline_cnstr_jobdesc_rng_deinstantiation(u32 *desc, int handle);
+
 void inline_cnstr_jobdesc_pkha_rsaexp(uint32_t *desc,
  struct pk_in_params *pkin, uint8_t *out,
  uint32_t out_siz);
diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index 42865a6cd7..14f9227b37 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -446,6 +446,51 @@ int sec_reset(void)
return sec_reset_idx(0);
 }
 #ifndef CONFIG_SPL_BUILD
+static int deinstantiate_rng(u8 sec_idx, int state_handle_mask)
+{
+   u32 *desc;
+   int sh_idx, ret = 0;
+   int desc_size = sizeof(u32) * 3;
+
+   desc = memalign(ARCH_DMA_MINALIGN, desc_size);
+   if (!desc) {
+   debug("cannot allocate RNG init descriptor memory\n");
+   return -ENOMEM;
+   }
+
+   for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) {
+   /*
+* If the corresponding bit is set, then it means the state
+* handle was initialized by us, and thus it needs to be
+* deinitialized as well
+*/
+
+   if (state_handle_mask & RDSTA_IF(sh_idx)) {
+   /*
+* Create the descriptor for deinstantating this state
+* handle.
+*/
+   inline_cnstr_jobdesc_rng_deinstantiation(desc, sh_idx);
+   flush_dcache_range((unsigned long)desc,
+  (unsigned long)desc + desc_size);
+
+   ret = run_descriptor_jr_idx(desc, sec_idx);
+   if (ret) {
+   printf("SEC%u:  RNG4 SH%d deinstantiation 
failed with error 0x%x\n",
+  sec_idx, sh_idx, ret);
+   ret = -EIO;
+   break;
+   }
+
+   printf("SEC%u:  Deinstantiated RNG4 SH%d\n",
+  sec_idx, sh_idx);
+   }
+   }
+
+   free(desc);
+   return ret;
+}
+
 static int instantiate_rng(u8 sec_idx, int gen_sk)
 {
u32 *desc;
@@ -466,9 +511,18 @@ static int instantiate_rng(u8 sec_idx, int gen_sk)
 * If the corresponding bit is set, this state handle
 * was initialized by somebody else, so 

[PATCH v2 3/6] crypto/fsl: support newer SEC modules

2020-06-04 Thread Michael Walle
Since Era 10, the version registers changed. Add the version registers
and use them on newer modules.

Signed-off-by: Michael Walle 
Reviewed-by: Horia Geantă 
---
 drivers/crypto/fsl/jr.c | 12 --
 include/fsl_sec.h   | 51 +++--
 2 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index bbdbcb8e58..5275c50e8b 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -498,9 +498,17 @@ static int instantiate_rng(uint8_t sec_idx)
 static u8 get_rng_vid(uint8_t sec_idx)
 {
ccsr_sec_t *sec = (void *)SEC_ADDR(sec_idx);
-   u32 cha_vid = sec_in32(>chavid_ls);
+   u8 vid;
 
-   return (cha_vid & SEC_CHAVID_RNG_LS_MASK) >> SEC_CHAVID_LS_RNG_SHIFT;
+   if (caam_get_era() < 10) {
+   vid = (sec_in32(>chavid_ls) & SEC_CHAVID_RNG_LS_MASK)
+  >> SEC_CHAVID_LS_RNG_SHIFT;
+   } else {
+   vid = (sec_in32(>vreg.rng) & CHA_VER_VID_MASK)
+  >> CHA_VER_VID_SHIFT;
+   }
+
+   return vid;
 }
 
 /*
diff --git a/include/fsl_sec.h b/include/fsl_sec.h
index 2ebb75c9b2..8dce0bbb1b 100644
--- a/include/fsl_sec.h
+++ b/include/fsl_sec.h
@@ -73,6 +73,41 @@ struct rng4tst {
u32 rsvd2[15];
 };
 
+/* Version registers (Era 10+) */
+struct version_regs {
+   u32 crca;   /* CRCA_VERSION */
+   u32 afha;   /* AFHA_VERSION */
+   u32 kfha;   /* KFHA_VERSION */
+   u32 pkha;   /* PKHA_VERSION */
+   u32 aesa;   /* AESA_VERSION */
+   u32 mdha;   /* MDHA_VERSION */
+   u32 desa;   /* DESA_VERSION */
+   u32 snw8a;  /* SNW8A_VERSION */
+   u32 snw9a;  /* SNW9A_VERSION */
+   u32 zuce;   /* ZUCE_VERSION */
+   u32 zuca;   /* ZUCA_VERSION */
+   u32 ccha;   /* CCHA_VERSION */
+   u32 ptha;   /* PTHA_VERSION */
+   u32 rng;/* RNG_VERSION */
+   u32 trng;   /* TRNG_VERSION */
+   u32 aaha;   /* AAHA_VERSION */
+   u32 rsvd[10];
+   u32 sr; /* SR_VERSION */
+   u32 dma;/* DMA_VERSION */
+   u32 ai; /* AI_VERSION */
+   u32 qi; /* QI_VERSION */
+   u32 jr; /* JR_VERSION */
+   u32 deco;   /* DECO_VERSION */
+};
+
+#define CHA_VER_NUM_MASK   0x00ff
+#define CHA_VER_MISC_SHIFT 8
+#define CHA_VER_MISC_MASK  0xff00
+#define CHA_VER_REV_SHIFT  16
+#define CHA_VER_REV_MASK   0x00ff
+#define CHA_VER_VID_SHIFT  24
+#define CHA_VER_VID_MASK   0xff00
+
 typedef struct ccsr_sec {
u32 res0;
u32 mcfgr;  /* Master CFG Register */
@@ -98,17 +133,19 @@ typedef struct ccsr_sec {
u32 drr;/* DECO Reset Register */
u8  res5[0x4d8];
struct rng4tst rng; /* RNG Registers */
-   u8  res6[0x8a0];
+   u8  res6[0x780];
+   struct version_regs vreg; /* version registers since era 10 */
+   u8  res7[0xa0];
u32 crnr_ms;/* CHA Revision Number Register, MS */
u32 crnr_ls;/* CHA Revision Number Register, LS */
u32 ctpr_ms;/* Compile Time Parameters Register, MS */
u32 ctpr_ls;/* Compile Time Parameters Register, LS */
-   u8  res7[0x10];
+   u8  res8[0x10];
u32 far_ms; /* Fault Address Register, MS */
u32 far_ls; /* Fault Address Register, LS */
u32 falr;   /* Fault Address LIODN Register */
u32 fadr;   /* Fault Address Detail Register */
-   u8  res8[0x4];
+   u8  res9[0x4];
u32 csta;   /* CAAM Status Register */
u32 smpart; /* Secure Memory Partition Parameters */
u32 smvid;  /* Secure Memory Version ID */
@@ -121,16 +158,16 @@ typedef struct ccsr_sec {
u32 secvid_ms;  /* SEC Version ID Register, MS */
u32 secvid_ls;  /* SEC Version ID Register, LS */
 #if defined(CONFIG_FSL_LSCH2) || defined(CONFIG_FSL_LSCH3)
-   u8  res9[0x6f020];
+   u8  res10[0x6f020];
 #else
-   u8  res9[0x6020];
+   u8  res10[0x6020];
 #endif
u32 qilcr_ms;   /* Queue Interface LIODN CFG Register, MS */
u32 qilcr_ls;   /* Queue Interface LIODN CFG Register, LS */
 #if defined(CONFIG_FSL_LSCH2) || defined(CONFIG_FSL_LSCH3)
-   u8  res10[0x8ffd8];
+   u8  res11[0x8ffd8];
 #else
-   u8  res10[0x8fd8];
+   u8  res11[0x8fd8];
 #endif
 } ccsr_sec_t;
 
-- 
2.20.1



[PATCH v2 0/6] crypto/fsl: add RNG support

2020-06-04 Thread Michael Walle
First, improve the compatibility on newer Era CAAMs. These introduced new
version registers. Secondly, add RNG support for the CAAM. This way we get
random number generator support for EFI for free and KASLR will work with
ARM64 kernels booted with bootefi.

Changes since v1:
 - instantiate RNG with prediction resistance
 - add annotation for caam_get_era()
 - fix all prints to match u-boots status lines
 - remove superfluous #ifdef CONFIG_DM_RNG
 - changed kconfig help text

Michael Walle (6):
  crypto/fsl: make SEC%u status line consistent
  crypto/fsl: export caam_get_era()
  crypto/fsl: support newer SEC modules
  crypto/fsl: don't regenerate secure keys
  crypto/fsl: instantiate the RNG with prediciton resistance
  crypto/fsl: add RNG support

 drivers/crypto/fsl/Kconfig   |  14 +
 drivers/crypto/fsl/Makefile  |   1 +
 drivers/crypto/fsl/desc.h|   2 +
 drivers/crypto/fsl/jobdesc.c |  27 -
 drivers/crypto/fsl/jobdesc.h |   8 ++-
 drivers/crypto/fsl/jr.c  | 110 +--
 drivers/crypto/fsl/rng.c |  84 ++
 drivers/crypto/fsl/sec.c |  10 +++-
 include/fsl_sec.h|  61 +++
 9 files changed, 282 insertions(+), 35 deletions(-)
 create mode 100644 drivers/crypto/fsl/rng.c

-- 
2.20.1



[PATCH v2 1/6] crypto/fsl: make SEC%u status line consistent

2020-06-04 Thread Michael Walle
Align the status line with all the other output in U-Boot.

Before the change:
DDR3.9 GiB (DDR3, 32-bit, CL=11, ECC on)
SEC0: RNG instantiated
WDT:   Started with servicing (60s timeout)

After the change:
DDR3.9 GiB (DDR3, 32-bit, CL=11, ECC on)
SEC0:  RNG instantiated
WDT:   Started with servicing (60s timeout)

Signed-off-by: Michael Walle 
---
 drivers/crypto/fsl/jr.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index e2d9216cfc..bbdbcb8e58 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -478,8 +478,8 @@ static int instantiate_rng(uint8_t sec_idx)
ret = run_descriptor_jr_idx(desc, sec_idx);
 
if (ret)
-   printf("RNG: Instantiation failed with error 0x%x\n",
-  ret);
+   printf("SEC%u:  RNG4 SH%d instantiation failed with 
error 0x%x\n",
+  sec_idx, sh_idx, ret);
 
rdsta_val = sec_in32(>rdsta) & RNG_STATE_HANDLE_MASK;
if (!(rdsta_val & (1 << sh_idx))) {
@@ -569,7 +569,7 @@ static int rng_init(uint8_t sec_idx)
ret = instantiate_rng(sec_idx);
} while ((ret == -1) && (ent_delay < RTSDCTL_ENT_DLY_MAX));
if (ret) {
-   printf("RNG: Failed to instantiate RNG\n");
+   printf("SEC%u:  Failed to instantiate RNG\n", sec_idx);
return ret;
}
 
@@ -592,7 +592,7 @@ int sec_init_idx(uint8_t sec_idx)
 #endif
 
if (!(sec_idx < CONFIG_SYS_FSL_MAX_NUM_OF_SEC)) {
-   printf("SEC initialization failed\n");
+   printf("SEC%u:  initialization failed\n", sec_idx);
return -1;
}
 
@@ -640,7 +640,7 @@ int sec_init_idx(uint8_t sec_idx)
 
ret = jr_init(sec_idx);
if (ret < 0) {
-   printf("SEC initialization failed\n");
+   printf("SEC%u:  initialization failed\n", sec_idx);
return -1;
}
 
@@ -654,10 +654,10 @@ int sec_init_idx(uint8_t sec_idx)
 #ifndef CONFIG_SPL_BUILD
if (get_rng_vid(sec_idx) >= 4) {
if (rng_init(sec_idx) < 0) {
-   printf("SEC%u: RNG instantiation failed\n", sec_idx);
+   printf("SEC%u:  RNG instantiation failed\n", sec_idx);
return -1;
}
-   printf("SEC%u: RNG instantiated\n", sec_idx);
+   printf("SEC%u:  RNG instantiated\n", sec_idx);
}
 #endif
return ret;
-- 
2.20.1



Re: [PATCH 4/4] crypto/fsl: add RNG support

2020-06-04 Thread Heinrich Schuchardt
On 04.06.20 15:20, Michael Walle wrote:
> Am 2020-06-04 14:58, schrieb Heinrich Schuchardt:
>> On 04.06.20 14:52, Michael Walle wrote:
>>> Am 2020-06-04 14:26, schrieb Heinrich Schuchardt:
 On 04.06.20 10:05, Horia Geantă wrote:
> On 6/4/2020 5:31 AM, Heinrich Schuchardt wrote:
>>>
> From what I see, driver added by Michael is using the PRNG / DRBG
> and not the TRNG. Is this acceptable?
>

 If it is only PRNG, this is not what we look for. If a PRNG/DRBG is
 used
 to ameliorate the raw entropy stream like Linux does for the
 /dev/random
 device this is fine. We need something non-deterministic.
>>>
>>> What do you mean by "only PRNG"?
>>>
> -a PRNG / DRBG (SP800-90A compliant DRBG_Hash) - which is seeded
> from the TRNG
>>>
>>> So while it is a PRNG, it is non-deterministic because its seeded
>>> from the TRNG.
>>
>> If for every byte that your DM_RNG driver outputs at least one byte from
>> the TRNG is consumed, it is fine. Otherwise it is not what we are
>> looking for.
>
> And why is that? This should really be documented somewhere.

We want to provide raw entropy in the EFI_RNG_PROTOCOL. So this cannot
be a deterministic sequence of bytes where you only have to know the
current state of a PRNG to find the next byte.

As mentioned above you have a TRNG available. What is problematic about
providing its output?

Best regards

Heinrich


[PATCH] sata_sil: make it buildable with DM_PCI

2020-06-04 Thread Marcin Juszkiewicz
Linker complained about lack of `pci_virt_to_mem` function.
Looks like driver was not ready for device model - I took solution from
e1000.c driver.

Signed-off-by: Marcin Juszkiewicz 
---
 drivers/ata/sata_sil.c | 4 
 1 file changed, 4 insertions(+)

diff --git drivers/ata/sata_sil.c drivers/ata/sata_sil.c
index 6896fa8771..5f9d4378e2 100644
--- drivers/ata/sata_sil.c
+++ drivers/ata/sata_sil.c
@@ -27,7 +27,11 @@
 
 #include "sata_sil.h"
 
+#ifdef CONFIG_DM_PCI
+#define virt_to_bus(devno, v)  dm_pci_virt_to_mem(devno, (void *) (v))
+#else
 #define virt_to_bus(devno, v)  pci_virt_to_mem(devno, (void *) (v))
+#endif
 
 /* just compatible ahci_ops */
 struct sil_ops {
-- 
2.26.2



Re: [PULL] u-boot-atmel-fixes-2020.07-a

2020-06-04 Thread Eugen.Hristev
On 04.06.2020 18:05, Tom Rini wrote:


 > Applied to u-boot/master, thanks!

 > But please note that building for all of "sama5" gives a ton of device
 > tree warnings, can you please look in to them?  Thanks!


Hi Tom,

Any changes in the DTC version or something? there are no changes in the 
device tree from 2020.04, so, if the warnings appeared now, it can be 
due to a more restrictive DTC setting.

Eugen


[PATCH] test_sleep.py: make sleep time and margin configurable

2020-06-04 Thread Heiko Schocher
make the sleep time and the margin configurable.

Signed-off-by: Heiko Schocher 
---

travis build:
https://travis-ci.org/github/hsdenx/u-boot-test/builds/694545225

This patch is needed as I start test/py now within tbot [1]. On
some configurations U-Boot is compiled on a build machine for
example in munich, while the board under test is in my lab in
hungary.

So the 0.25 seconds default margin is often to low because
of latencies on the net.

See as an example configuration (within tbot):

https://github.com/EmbLux-Kft/tbot-tbot2go/blob/devel/boards/aristainetos.py#L29

[1] http://tbot.tools/modules/tc.html#u-boot-test-py

 test/py/tests/test_sleep.py | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/py/tests/test_sleep.py b/test/py/tests/test_sleep.py
index b69edf26ef..392af29db2 100644
--- a/test/py/tests/test_sleep.py
+++ b/test/py/tests/test_sleep.py
@@ -11,6 +11,12 @@ change test behavior.
 # Setup env__sleep_accurate to False if time is not accurate on your platform
 env__sleep_accurate = False
 
+# Setup env__sleep_time time in seconds board is set to sleep
+env__sleep_time = 3
+
+# Setup env__sleep_margin set a margin for any system overhead
+env__sleep_margin = 0.25
+
 """
 
 def test_sleep(u_boot_console):
@@ -23,13 +29,15 @@ def test_sleep(u_boot_console):
 
 if u_boot_console.config.buildconfig.get('config_cmd_misc', 'n') != 'y':
 pytest.skip('sleep command not supported')
+
 # 3s isn't too long, but is enough to cross a few second boundaries.
-sleep_time = 3
+sleep_time = u_boot_console.config.env.get('env__sleep_time', 3)
+sleep_margin = u_boot_console.config.env.get('env__sleep_margin', 0.25)
 tstart = time.time()
 u_boot_console.run_command('sleep %d' % sleep_time)
 tend = time.time()
 elapsed = tend - tstart
 assert elapsed >= (sleep_time - 0.01)
 if not u_boot_console.config.gdbserver:
-# 0.25s margin is hopefully enough to account for any system overhead.
-assert elapsed < (sleep_time + 0.25)
+# margin is hopefully enough to account for any system overhead.
+assert elapsed < (sleep_time + sleep_margin)
-- 
2.24.1



[PATCHv3 33/36] configs: T4240RDB: Enable ESPI driver

2020-06-04 Thread Zhiqiang Hou
From: Xiaowei Bao 

Enable the DM ESPI driver in T4240RDB defconfig.

Signed-off-by: Xiaowei Bao 
Signed-off-by: Hou Zhiqiang 
---
V3:
 - No change.

 configs/T4240RDB_SDCARD_defconfig | 2 ++
 configs/T4240RDB_defconfig| 2 ++
 2 files changed, 4 insertions(+)

diff --git a/configs/T4240RDB_SDCARD_defconfig 
b/configs/T4240RDB_SDCARD_defconfig
index 14e366358b..a0238599f3 100644
--- a/configs/T4240RDB_SDCARD_defconfig
+++ b/configs/T4240RDB_SDCARD_defconfig
@@ -41,6 +41,8 @@ CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="t4240rdb"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
diff --git a/configs/T4240RDB_defconfig b/configs/T4240RDB_defconfig
index dfe8953af7..95388a8cbf 100644
--- a/configs/T4240RDB_defconfig
+++ b/configs/T4240RDB_defconfig
@@ -29,6 +29,8 @@ CONFIG_DEFAULT_DEVICE_TREE="t4240rdb"
 CONFIG_ENV_IS_IN_FLASH=y
 CONFIG_ENV_ADDR=0xEFF2
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
-- 
2.25.1



[PATCHv3 35/36] dts: P1010RDB: Add eSPI slave DT nodes

2020-06-04 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Add DT nodes for eSPI slave device SPI flash.

Signed-off-by: Hou Zhiqiang 
---
V3:
 - No change.

 arch/powerpc/dts/p1010rdb-pa.dts |  1 +
 arch/powerpc/dts/p1010rdb-pa_36b.dts |  1 +
 arch/powerpc/dts/p1010rdb.dtsi   | 17 +
 3 files changed, 19 insertions(+)

diff --git a/arch/powerpc/dts/p1010rdb-pa.dts b/arch/powerpc/dts/p1010rdb-pa.dts
index c66c4923ac..360d254d91 100644
--- a/arch/powerpc/dts/p1010rdb-pa.dts
+++ b/arch/powerpc/dts/p1010rdb-pa.dts
@@ -15,3 +15,4 @@
 };
 
 /include/ "p1010si-post.dtsi"
+/include/ "p1010rdb.dtsi"
diff --git a/arch/powerpc/dts/p1010rdb-pa_36b.dts 
b/arch/powerpc/dts/p1010rdb-pa_36b.dts
index b943de7cbb..062086a8c0 100644
--- a/arch/powerpc/dts/p1010rdb-pa_36b.dts
+++ b/arch/powerpc/dts/p1010rdb-pa_36b.dts
@@ -15,3 +15,4 @@
 };
 
 /include/ "p1010si-post.dtsi"
+/include/ "p1010rdb.dtsi"
diff --git a/arch/powerpc/dts/p1010rdb.dtsi b/arch/powerpc/dts/p1010rdb.dtsi
index 4f58ee2446..20bd570299 100644
--- a/arch/powerpc/dts/p1010rdb.dtsi
+++ b/arch/powerpc/dts/p1010rdb.dtsi
@@ -4,6 +4,12 @@
  *
  * Copyright 2020 NXP
  */
+/ {
+   aliases {
+   spi0 = 
+   };
+};
+
  {
i2c@3000 {
rtc@68 {
@@ -11,4 +17,15 @@
reg = <0x68>;
};
};
+
+   spi@7000 {
+   status = "okay";
+   flash@0 {
+   compatible = "jedec,spi-nor";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   reg = <0>;
+   spi-max-frequency = <1000>; /* input clock */
+   };
+   };
 };
-- 
2.25.1



[PATCHv3 36/36] configs: P1010RDB: Enable eSPI controller and SPI flash DM driver

2020-06-04 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Enable the DM_SPI and DM_SPI_FLASH in P1010RDB defconfigs except
SECBOOT defconfigs.

Signed-off-by: Hou Zhiqiang 
---
V3:
 - No change.

 configs/P1010RDB-PA_36BIT_NAND_defconfig | 2 ++
 configs/P1010RDB-PA_36BIT_NOR_defconfig  | 2 ++
 configs/P1010RDB-PA_36BIT_SDCARD_defconfig   | 2 ++
 configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig | 2 ++
 configs/P1010RDB-PA_NAND_defconfig   | 2 ++
 configs/P1010RDB-PA_NOR_defconfig| 2 ++
 configs/P1010RDB-PA_SDCARD_defconfig | 2 ++
 configs/P1010RDB-PA_SPIFLASH_defconfig   | 2 ++
 configs/P1010RDB-PB_36BIT_NAND_defconfig | 2 ++
 configs/P1010RDB-PB_36BIT_NOR_defconfig  | 2 ++
 configs/P1010RDB-PB_36BIT_SDCARD_defconfig   | 2 ++
 configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig | 2 ++
 configs/P1010RDB-PB_NAND_defconfig   | 2 ++
 configs/P1010RDB-PB_NOR_defconfig| 2 ++
 configs/P1010RDB-PB_SDCARD_defconfig | 2 ++
 configs/P1010RDB-PB_SPIFLASH_defconfig   | 2 ++
 16 files changed, 32 insertions(+)

diff --git a/configs/P1010RDB-PA_36BIT_NAND_defconfig 
b/configs/P1010RDB-PA_36BIT_NAND_defconfig
index da04cab014..c10f3f3a4f 100644
--- a/configs/P1010RDB-PA_36BIT_NAND_defconfig
+++ b/configs/P1010RDB-PA_36BIT_NAND_defconfig
@@ -48,6 +48,8 @@ CONFIG_DEFAULT_DEVICE_TREE="p1010rdb-pa_36b"
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_FSL_ESDHC=y
diff --git a/configs/P1010RDB-PA_36BIT_NOR_defconfig 
b/configs/P1010RDB-PA_36BIT_NOR_defconfig
index e6edd395e7..dc69fec2f2 100644
--- a/configs/P1010RDB-PA_36BIT_NOR_defconfig
+++ b/configs/P1010RDB-PA_36BIT_NOR_defconfig
@@ -31,6 +31,8 @@ CONFIG_DEFAULT_DEVICE_TREE="p1010rdb-pa_36b"
 CONFIG_ENV_IS_IN_FLASH=y
 CONFIG_ENV_ADDR=0xEFF2
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_FSL_ESDHC=y
diff --git a/configs/P1010RDB-PA_36BIT_SDCARD_defconfig 
b/configs/P1010RDB-PA_36BIT_SDCARD_defconfig
index dcd606b0c2..4674caf4a3 100644
--- a/configs/P1010RDB-PA_36BIT_SDCARD_defconfig
+++ b/configs/P1010RDB-PA_36BIT_SDCARD_defconfig
@@ -43,6 +43,8 @@ CONFIG_DEFAULT_DEVICE_TREE="p1010rdb-pa_36b"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_FSL_ESDHC=y
diff --git a/configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig 
b/configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig
index c0800c8d7d..ded4db2555 100644
--- a/configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig
+++ b/configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig
@@ -45,6 +45,8 @@ CONFIG_DEFAULT_DEVICE_TREE="p1010rdb-pa_36b"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_FSL_ESDHC=y
diff --git a/configs/P1010RDB-PA_NAND_defconfig 
b/configs/P1010RDB-PA_NAND_defconfig
index 29ba692ca1..6c2b1e8f1b 100644
--- a/configs/P1010RDB-PA_NAND_defconfig
+++ b/configs/P1010RDB-PA_NAND_defconfig
@@ -47,6 +47,8 @@ CONFIG_DEFAULT_DEVICE_TREE="p1010rdb-pa"
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_FSL_ESDHC=y
diff --git a/configs/P1010RDB-PA_NOR_defconfig 
b/configs/P1010RDB-PA_NOR_defconfig
index d8f87b5dac..d49c27f9c6 100644
--- a/configs/P1010RDB-PA_NOR_defconfig
+++ b/configs/P1010RDB-PA_NOR_defconfig
@@ -30,6 +30,8 @@ CONFIG_DEFAULT_DEVICE_TREE="p1010rdb-pa"
 CONFIG_ENV_IS_IN_FLASH=y
 CONFIG_ENV_ADDR=0xEFF2
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_FSL_ESDHC=y
diff --git a/configs/P1010RDB-PA_SDCARD_defconfig 
b/configs/P1010RDB-PA_SDCARD_defconfig
index 9711082529..68f31a0cb3 100644
--- a/configs/P1010RDB-PA_SDCARD_defconfig
+++ b/configs/P1010RDB-PA_SDCARD_defconfig
@@ -42,6 +42,8 @@ CONFIG_DEFAULT_DEVICE_TREE="p1010rdb-pa"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_FSL_ESDHC=y
diff --git a/configs/P1010RDB-PA_SPIFLASH_defconfig 
b/configs/P1010RDB-PA_SPIFLASH_defconfig
index de2ac2235f..d9298a058d 100644
--- a/configs/P1010RDB-PA_SPIFLASH_defconfig
+++ b/configs/P1010RDB-PA_SPIFLASH_defconfig
@@ -44,6 +44,8 @@ CONFIG_DEFAULT_DEVICE_TREE="p1010rdb-pa"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_FSL_ESDHC=y
diff --git a/configs/P1010RDB-PB_36BIT_NAND_defconfig 
b/configs/P1010RDB-PB_36BIT_NAND_defconfig
index 9f4876dd13..436e3b833f 100644
--- a/configs/P1010RDB-PB_36BIT_NAND_defconfig
+++ b/configs/P1010RDB-PB_36BIT_NAND_defconfig
@@ -48,6 +48,8 @@ CONFIG_DEFAULT_DEVICE_TREE="p1010rdb-pb_36b"
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y

[PATCHv3 34/36] dts: P1010: Add eSPI controller DT node

2020-06-04 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Add eSPI controller DT node for P1010.

Signed-off-by: Hou Zhiqiang 
---
V3:
 - No change.

 arch/powerpc/dts/p1010si-post.dtsi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/powerpc/dts/p1010si-post.dtsi 
b/arch/powerpc/dts/p1010si-post.dtsi
index 0289441381..aa04f5f033 100644
--- a/arch/powerpc/dts/p1010si-post.dtsi
+++ b/arch/powerpc/dts/p1010si-post.dtsi
@@ -23,6 +23,16 @@
single-cpu-affinity;
last-interrupt-source = <255>;
};
+
+   espi0: spi@7000 {
+   compatible = "fsl,mpc8536-espi";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x7000 0x1000>;
+   fsl,espi-num-chipselects = <1>;
+   status = "disabled";
+   };
+
 /include/ "pq3-i2c-0.dtsi"
 /include/ "pq3-i2c-1.dtsi"
 };
-- 
2.25.1



[PATCHv3 31/36] dts: T4240: Add ESPI DT nodes

2020-06-04 Thread Zhiqiang Hou
From: Xiaowei Bao 

Add ESPI controller DT node for T4240.

Signed-off-by: Xiaowei Bao 
Signed-off-by: Hou Zhiqiang 
---
V3:
 - Move the eSPI DT node back to path /soc, in v2 the patch command put
   the eSPI node to the path /cpus by mistake.

 arch/powerpc/dts/t4240.dtsi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/powerpc/dts/t4240.dtsi b/arch/powerpc/dts/t4240.dtsi
index 9b5902fe9e..498da4f795 100644
--- a/arch/powerpc/dts/t4240.dtsi
+++ b/arch/powerpc/dts/t4240.dtsi
@@ -99,6 +99,15 @@
clock-frequency = <0x0>;
};
 
+   espi0: spi@11 {
+   compatible = "fsl,mpc8536-espi";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x11 0x1000>;
+   fsl,espi-num-chipselects = <4>;
+   status = "disabled";
+   };
+
usb@21 {
compatible = "fsl-usb2-mph";
reg = <0x21 0x1000>;
-- 
2.25.1



[PATCHv3 32/36] dts: T4240RDB: Add ESPI slave device node

2020-06-04 Thread Zhiqiang Hou
From: Xiaowei Bao 

Add ESPI slave node for T4240RDB.

Signed-off-by: Xiaowei Bao 
Signed-off-by: Hou Zhiqiang 
---
V3:
 - No change.

 arch/powerpc/dts/t4240rdb.dts | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/powerpc/dts/t4240rdb.dts b/arch/powerpc/dts/t4240rdb.dts
index f67d7ce2ae..635065a036 100644
--- a/arch/powerpc/dts/t4240rdb.dts
+++ b/arch/powerpc/dts/t4240rdb.dts
@@ -14,4 +14,19 @@
#address-cells = <2>;
#size-cells = <2>;
interrupt-parent = <>;
+
+   aliases {
+   spi0 = 
+   };
+};
+
+ {
+   status = "okay";
+   flash@0 {
+   compatible = "jedec,spi-nor";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   reg = <0>;
+   spi-max-frequency = <1000>; /* input clock */
+   };
 };
-- 
2.25.1



[PATCHv3 30/36] configs: T2080RDB: Enable ESPI driver

2020-06-04 Thread Zhiqiang Hou
From: Xiaowei Bao 

Enable the DM ESPI driver in T2080RDB defconfig.

Signed-off-by: Xiaowei Bao 
Signed-off-by: Hou Zhiqiang 
---
V3:
 - No change.

 configs/T2080RDB_NAND_defconfig | 2 ++
 configs/T2080RDB_SDCARD_defconfig   | 2 ++
 configs/T2080RDB_SPIFLASH_defconfig | 2 ++
 configs/T2080RDB_defconfig  | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/configs/T2080RDB_NAND_defconfig b/configs/T2080RDB_NAND_defconfig
index 81baa5dbdd..e349396785 100644
--- a/configs/T2080RDB_NAND_defconfig
+++ b/configs/T2080RDB_NAND_defconfig
@@ -50,6 +50,8 @@ CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="t2080rdb"
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
diff --git a/configs/T2080RDB_SDCARD_defconfig 
b/configs/T2080RDB_SDCARD_defconfig
index a1d7d87b60..397ac2873c 100644
--- a/configs/T2080RDB_SDCARD_defconfig
+++ b/configs/T2080RDB_SDCARD_defconfig
@@ -48,6 +48,8 @@ CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="t2080rdb"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
diff --git a/configs/T2080RDB_SPIFLASH_defconfig 
b/configs/T2080RDB_SPIFLASH_defconfig
index c433a922e6..3bea0da750 100644
--- a/configs/T2080RDB_SPIFLASH_defconfig
+++ b/configs/T2080RDB_SPIFLASH_defconfig
@@ -51,6 +51,8 @@ CONFIG_DEFAULT_DEVICE_TREE="t2080rdb"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_ENV_ADDR=0xFFFC9000
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
diff --git a/configs/T2080RDB_defconfig b/configs/T2080RDB_defconfig
index 85e3b64ad3..f9021e5e05 100644
--- a/configs/T2080RDB_defconfig
+++ b/configs/T2080RDB_defconfig
@@ -36,6 +36,8 @@ CONFIG_DEFAULT_DEVICE_TREE="t2080rdb"
 CONFIG_ENV_IS_IN_FLASH=y
 CONFIG_ENV_ADDR=0xEFF2
 CONFIG_DM=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_FSL_CAAM=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
-- 
2.25.1



[PATCHv3 29/36] dts: T2080RDB: Add ESPI slave device node

2020-06-04 Thread Zhiqiang Hou
From: Xiaowei Bao 

Add ESPI slave node for T2080RDB.

Signed-off-by: Xiaowei Bao 
Signed-off-by: Hou Zhiqiang 
---
V3:
 - No change.

 arch/powerpc/dts/t2080rdb.dts | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/powerpc/dts/t2080rdb.dts b/arch/powerpc/dts/t2080rdb.dts
index 49c1765b29..34ec6a74cb 100644
--- a/arch/powerpc/dts/t2080rdb.dts
+++ b/arch/powerpc/dts/t2080rdb.dts
@@ -14,4 +14,19 @@
#address-cells = <2>;
#size-cells = <2>;
interrupt-parent = <>;
+
+   aliases {
+   spi0 = 
+   };
+};
+
+ {
+   status = "okay";
+   flash@0 {
+   compatible = "jedec,spi-nor"; /* 16MB */
+   #address-cells = <1>;
+   #size-cells = <1>;
+   reg = <0>;
+   spi-max-frequency = <1000>; /* input clock */
+   };
 };
-- 
2.25.1



[PATCHv3 26/36] dts: T104x: Add ESPI DT nodes

2020-06-04 Thread Zhiqiang Hou
From: Xiaowei Bao 

Add ESPI controller DT node for T104x.

Signed-off-by: Xiaowei Bao 
Signed-off-by: Hou Zhiqiang 
---
V3:
 - Move the eSPI DT node back to path /soc, in v2 the patch command put
   the eSPI node to the path /cpus by mistake.

 arch/powerpc/dts/t104x.dtsi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/powerpc/dts/t104x.dtsi b/arch/powerpc/dts/t104x.dtsi
index 0a08a69f31..2c7e5b4718 100644
--- a/arch/powerpc/dts/t104x.dtsi
+++ b/arch/powerpc/dts/t104x.dtsi
@@ -59,6 +59,15 @@
clock-frequency = <0x0>;
};
 
+   espi0: spi@11 {
+   compatible = "fsl,mpc8536-espi";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x11 0x1000>;
+   fsl,espi-num-chipselects = <4>;
+   status = "disabled";
+   };
+
usb0@21 {
compatible = "fsl-usb2-mph";
reg = <0x21 0x1000>;
-- 
2.25.1



  1   2   3   >