Re: [PATCH v4 2/3] fastboot: Add support for 'reboot fastboot' command

2020-07-03 Thread Roman Stratiienko
Looks good. Tested on my side.
This patch fixes some of VtsFastbootVerification.

вт, 23 июн. 2020 г. в 03:28, Roman Kovalivskyi
:
>
> Android 10 adds support for dynamic partitions and in order to support
> this userspace fastboot must be used[1]. New tool fastbootd is
> included into recovery.
>
> Userspace fastboot works from recovery and is launched if:
> 1) - Dynamic partitioning is enabled
> 2) - Boot control block has 'boot-fastboot' value into command field
> The bootloader is expected to load and boot into the recovery image
> upon seeing boot-fastboot in the BCB command. Recovery then parses the
> BCB message and switches to fastbootd mode[2].
>
> Please note that boot script is expected to handle 'boot-fastboot'
> command in BCB and load into recovery mode.
>
> Bootloader must support 'reboot fastboot' command which should reboot
> device into userspace fastboot to accomodate those changes[3].
>
> Another command that bootloader must support[3] is 'reboot recovery'. This
> command should simply reboot device into recovery mode.
>
> [1] - https://source.android.com/devices/bootloader/fastbootd
> [2] - 
> https://source.android.com/devices/bootloader/fastbootd#unified_fastboot_and_recovery
> [3] - 
> https://source.android.com/devices/bootloader/fastbootd#modifications_to_the_bootloader
>
> Signed-off-by: Roman Kovalivskyi 
> Signed-off-by: Roman Stratiienko 
> Change-Id: I9d2bdc9a6f6f31ea98572fe155e1cc8341e9af76
> ---
>  drivers/fastboot/fb_command.c   | 38 +
>  drivers/usb/gadget/f_fastboot.c |  2 ++
>  include/fastboot.h  |  4 
>  net/fastboot.c  |  2 ++
>  4 files changed, 46 insertions(+)
>
> diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
> index 8ce5d32fb2ba..d3c578672dc6 100644
> --- a/drivers/fastboot/fb_command.c
> +++ b/drivers/fastboot/fb_command.c
> @@ -37,6 +37,8 @@ static void flash(char *, char *);
>  static void erase(char *, char *);
>  #endif
>  static void reboot_bootloader(char *, char *);
> +static void reboot_fastbootd(char *, char *);
> +static void reboot_recovery(char *, char *);
>  #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
>  static void oem_format(char *, char *);
>  #endif
> @@ -79,6 +81,14 @@ static const struct {
> .command = "reboot-bootloader",
> .dispatch = reboot_bootloader
> },
> +   [FASTBOOT_COMMAND_REBOOT_FASTBOOTD] =  {
> +   .command = "reboot-fastboot",
> +   .dispatch = reboot_fastbootd
> +   },
> +   [FASTBOOT_COMMAND_REBOOT_RECOVERY] =  {
> +   .command = "reboot-recovery",
> +   .dispatch = reboot_recovery
> +   },
> [FASTBOOT_COMMAND_SET_ACTIVE] =  {
> .command = "set_active",
> .dispatch = okay
> @@ -313,6 +323,34 @@ static void reboot_bootloader(char *cmd_parameter, char 
> *response)
> fastboot_okay(NULL, response);
>  }
>
> +/**
> + * reboot_fastbootd() - Sets reboot fastboot flag.
> + *
> + * @cmd_parameter: Pointer to command parameter
> + * @response: Pointer to fastboot response buffer
> + */
> +static void reboot_fastbootd(char *cmd_parameter, char *response)
> +{
> +   if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_REASON_FASTBOOTD))
> +   fastboot_fail("Cannot set fastboot flag", response);
> +   else
> +   fastboot_okay(NULL, response);
> +}
> +
> +/**
> + * reboot_recovery() - Sets reboot recovery flag.
> + *
> + * @cmd_parameter: Pointer to command parameter
> + * @response: Pointer to fastboot response buffer
> + */
> +static void reboot_recovery(char *cmd_parameter, char *response)
> +{
> +   if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_REASON_RECOVERY))
> +   fastboot_fail("Cannot set recovery flag", response);
> +   else
> +   fastboot_okay(NULL, response);
> +}
> +
>  #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
>  /**
>   * oem_format() - Execute the OEM format command
> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
> index 384c0f6f6e27..30f7a52087fc 100644
> --- a/drivers/usb/gadget/f_fastboot.c
> +++ b/drivers/usb/gadget/f_fastboot.c
> @@ -455,6 +455,8 @@ static void rx_handler_command(struct usb_ep *ep, struct 
> usb_request *req)
>
> case FASTBOOT_COMMAND_REBOOT:
> case FASTBOOT_COMMAND_REBOOT_BOOTLOADER:
> +   case FASTBOOT_COMMAND_REBOOT_FASTBOOTD:
> +   case FASTBOOT_COMMAND_REBOOT_RECOVERY:
> fastboot_func->in_req->complete = compl_do_reset;
> break;
> }
> diff --git a/include/fastboot.h b/include/fastboot.h
> index 14f4c68868d8..b86b508e69fd 100644
> --- a/include/fastboot.h
> +++ b/include/fastboot.h
> @@ -32,6 +32,8 @@ enum {
> FASTBOOT_COMMAND_CONTINUE,
> FASTBOOT_COMMAND_REBOOT,
> FASTBOOT_COMMAND_REBOOT_BOOTLOADER,
> +   

Re: [PATCH v4 3/3] fastboot: Add default fastboot_set_reboot_flag implementation

2020-07-03 Thread Roman Stratiienko
Reviewed-by: Roman Stratiienko 

вт, 23 июн. 2020 г. в 03:28, Roman Kovalivskyi
:
>
> Default implementation of fastboot_set_reboot_flag function that depends
> on "bcb" commands could be used in general case if there are no need to
> make any platform-specific implementation, otherwise it could be
> disabled via Kconfig option FASTBOOT_USE_BCB_SET_REBOOT_FLAG.
>
> Please note that FASTBOOT_USE_BCB_SET_REBOOT_FLAG is mutually exclusive
> with some platforms which already have their own implementation of this
> function.
>
> Signed-off-by: Roman Kovalivskyi 
> ---
>  drivers/fastboot/Kconfig   | 12 +
>  drivers/fastboot/Makefile  |  1 +
>  drivers/fastboot/fb_bcb_impl.c | 48 ++
>  3 files changed, 61 insertions(+)
>  create mode 100644 drivers/fastboot/fb_bcb_impl.c
>
> diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
> index d4436dfc9173..4352ba67a713 100644
> --- a/drivers/fastboot/Kconfig
> +++ b/drivers/fastboot/Kconfig
> @@ -165,6 +165,18 @@ config FASTBOOT_CMD_OEM_FORMAT
>   relies on the env variable partitions to contain the list of
>   partitions as required by the gpt command.
>
> +config FASTBOOT_USE_BCB_SET_REBOOT_FLAG
> +   bool "Use BCB by fastboot to set boot reason"
> +   depends on CMD_BCB && !ARCH_MESON && !ARCH_ROCKCHIP && !TARGET_KC1 && 
> \
> + !TARGET_SNIPER && !TARGET_AM57XX_EVM && !TARGET_DRA7XX_EVM
> +   default y
> +   help
> + Fastboot could implement setting of reboot reason in a generic 
> fashion
> + via BCB commands. BCB commands are able to write reboot reason into
> + command field of boot control block. In general case it is 
> sufficient
> + implementation if your platform supports BCB commands and doesn't
> + require any specific reboot reason handling.
> +
>  endif # FASTBOOT
>
>  endmenu
> diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile
> index 048af5aa8234..2b2c390fe4de 100644
> --- a/drivers/fastboot/Makefile
> +++ b/drivers/fastboot/Makefile
> @@ -5,3 +5,4 @@ obj-y += fb_getvar.o
>  obj-y += fb_command.o
>  obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
>  obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o
> +obj-$(CONFIG_FASTBOOT_USE_BCB_SET_REBOOT_FLAG) += fb_bcb_impl.o
> diff --git a/drivers/fastboot/fb_bcb_impl.c b/drivers/fastboot/fb_bcb_impl.c
> new file mode 100644
> index ..a5ae94e2e357
> --- /dev/null
> +++ b/drivers/fastboot/fb_bcb_impl.c
> @@ -0,0 +1,48 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2020 GlobalLogic.
> + * Roman Kovalivskyi 
> + */
> +
> +#include 
> +#include 
> +
> +/**
> + * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader
> + *
> + * Set flag which indicates that we should reboot into the bootloader
> + * following the reboot that fastboot executes after this function.
> + *
> + * This function should be overridden in your board file with one
> + * which sets whatever flag your board specific Android bootloader flow
> + * requires in order to re-enter the bootloader.
> + */
> +int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
> +{
> +   static const char * const boot_cmds[] = {
> +   "bootonce-bootloader",
> +   "boot-fastboot",
> +   "boot-recovery"
> +   };
> +
> +   char cmd[32];
> +
> +   if (reason >= FASTBOOT_REBOOT_REASONS_COUNT)
> +   return -EINVAL;
> +
> +   snprintf(cmd, sizeof(cmd), "bcb load %d misc",
> +CONFIG_FASTBOOT_FLASH_MMC_DEV);
> +
> +   if (run_command(cmd, 0))
> +   return -ENODEV;
> +
> +   snprintf(cmd, sizeof(cmd), "bcb set command %s", boot_cmds[reason]);
> +
> +   if (run_command(cmd, 0))
> +   return -ENOEXEC;
> +
> +   if (run_command("bcb store", 0))
> +   return -EIO;
> +
> +   return 0;
> +}
> --
> 2.17.1
>


Re: [PATCH v4 1/3] fastboot: Extend fastboot_set_reboot_flag with reboot reason

2020-07-03 Thread Roman Stratiienko
Reviewed-by: Roman Stratiienko 

вт, 23 июн. 2020 г. в 03:28, Roman Kovalivskyi
:
>
> Extend fastboot_set_reboot_flag arguments with reboot reason so that
> it could handle different reboot cases in future.
>
> Signed-off-by: Roman Kovalivskyi 
> ---
>  arch/arm/mach-meson/board-common.c |  6 +-
>  arch/arm/mach-rockchip/board.c |  6 +-
>  board/amazon/kc1/kc1.c |  6 +-
>  board/lg/sniper/sniper.c   |  6 +-
>  board/ti/am57xx/board.c|  6 +-
>  board/ti/dra7xx/evm.c  |  6 +-
>  drivers/fastboot/fb_command.c  |  2 +-
>  drivers/fastboot/fb_common.c   |  2 +-
>  include/fastboot.h | 10 +-
>  9 files changed, 41 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/mach-meson/board-common.c 
> b/arch/arm/mach-meson/board-common.c
> index 19e5bfd3660c..a1f08bb98c6f 100644
> --- a/arch/arm/mach-meson/board-common.c
> +++ b/arch/arm/mach-meson/board-common.c
> @@ -5,6 +5,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -153,8 +154,11 @@ int board_late_init(void)
>  #if CONFIG_IS_ENABLED(FASTBOOT)
>  static unsigned int reboot_reason = REBOOT_REASON_NORMAL;
>
> -int fastboot_set_reboot_flag()
> +int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
>  {
> +   if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
> +   return -ENOTSUPP;
> +
> reboot_reason = REBOOT_REASON_BOOTLOADER;
>
> printf("Using reboot reason: 0x%x\n", reboot_reason);
> diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
> index 430c0cbf41e4..ba4da72b3910 100644
> --- a/arch/arm/mach-rockchip/board.c
> +++ b/arch/arm/mach-rockchip/board.c
> @@ -6,6 +6,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -152,8 +153,11 @@ int board_usb_init(int index, enum usb_init_type init)
>  #endif /* CONFIG_USB_GADGET */
>
>  #if CONFIG_IS_ENABLED(FASTBOOT)
> -int fastboot_set_reboot_flag(void)
> +int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
>  {
> +   if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
> +   return -ENOTSUPP;
> +
> printf("Setting reboot to fastboot flag ...\n");
> /* Set boot mode to fastboot */
> writel(BOOT_FASTBOOT, CONFIG_ROCKCHIP_BOOT_MODE_REG);
> diff --git a/board/amazon/kc1/kc1.c b/board/amazon/kc1/kc1.c
> index fb1828ff44da..445980f16e62 100644
> --- a/board/amazon/kc1/kc1.c
> +++ b/board/amazon/kc1/kc1.c
> @@ -8,6 +8,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -163,8 +164,11 @@ void get_board_serial(struct tag_serialnr *serialnr)
> omap_die_id_get_board_serial(serialnr);
>  }
>
> -int fastboot_set_reboot_flag(void)
> +int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
>  {
> +   if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
> +   return -ENOTSUPP;
> +
> return omap_reboot_mode_store("b");
>  }
>
> diff --git a/board/lg/sniper/sniper.c b/board/lg/sniper/sniper.c
> index 2825eccc035a..99b832fe601b 100644
> --- a/board/lg/sniper/sniper.c
> +++ b/board/lg/sniper/sniper.c
> @@ -9,6 +9,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -175,8 +176,11 @@ void reset_misc(void)
> omap_reboot_mode_store(reboot_mode);
>  }
>
> -int fastboot_set_reboot_flag(void)
> +int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
>  {
> +   if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
> +   return -ENOTSUPP;
> +
> return omap_reboot_mode_store("b");
>  }
>
> diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
> index 8720eb87a55d..49afd3bc927b 100644
> --- a/board/ti/am57xx/board.c
> +++ b/board/ti/am57xx/board.c
> @@ -9,6 +9,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1169,8 +1170,11 @@ int board_fit_config_name_match(const char *name)
>  #endif
>
>  #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
> -int fastboot_set_reboot_flag(void)
> +int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
>  {
> +   if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
> +   return -ENOTSUPP;
> +
> printf("Setting reboot to fastboot flag ...\n");
> env_set("dofastboot", "1");
> env_save();
> diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
> index acf7ff169170..3bc40c721146 100644
> --- a/board/ti/dra7xx/evm.c
> +++ b/board/ti/dra7xx/evm.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1050,8 +1051,11 @@ int board_fit_config_name_match(const char *name)
>  #endif
>
>  #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
> -int fastboot_set_reboot_flag(void)
> +int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
>  {
> +

Re: [PATCH v5 04/14] dtoc: add support to scan drivers

2020-07-03 Thread Simon Glass
Hi Walter,

On Fri, 3 Jul 2020 at 11:45, Walter Lozano  wrote:
>
> Hi Simon,
>
> On 3/7/20 13:08, Simon Glass wrote:
> > Hi Walter,
> >
> > On Fri, 3 Jul 2020 at 05:07, 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 and aliases. This allows to generate U_BOOT_DEVICE entries using
> >> valid driver names and rise a warning in the case a name is not valid.
> >>
> >> Signed-off-by: Walter Lozano 
> >> ---
> >>
> >> (no changes since v1)
> >>
> >>   tools/dtoc/dtb_platdata.py| 91 +--
> >>   tools/dtoc/dtoc_test_driver_alias.dts | 20 ++
> >>   tools/dtoc/test_dtoc.py   | 33 ++
> >>   3 files changed, 140 insertions(+), 4 deletions(-)
> >>   create mode 100644 tools/dtoc/dtoc_test_driver_alias.dts
> >>
> > This seems to do the trick, thanks!
> >
> > But there is one problem remaining - lots of warning output from the
> > various tests:
> >
> > https://pastebin.com/K7GBPiqC
>
> The warnings are removed by the next patch in the series, "[PATCH v4
> 05/14] dtoc: add option to disable warnings", by adding additional
> arguments.
>
> I thought having these two things in different patches made sense, but
> If you prefer I can re send the series with those two patches squashed.
>
> Please confirm.

OK I see. Then that is fine, thanks.

Regards,
SImon


[PATCH] mmc: omap_hsmmc: Set 3.3V for IO voltage on all places

2020-07-03 Thread Pali Rohár
In commit commit d2c05f50e12f ("mmc: omap_hsmmc: Set 3.3V for IO voltage")
was changed 3.0V IO voltage to 3.3V but it was not done on all places in
omap_hsmmc driver. That commit broke eMMC support on Nokia N900.

This patch fixes that problematic commit and changes 3.0V to 3.3V on all
remaining places in omap_hsmmc driver.

Fixes: d2c05f50e12f ("mmc: omap_hsmmc: Set 3.3V for IO voltage")
Signed-off-by: Pali Rohár 
---
 drivers/mmc/omap_hsmmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 8636cd713a..dc26e54795 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -840,7 +840,7 @@ static int omap_hsmmc_init_setup(struct mmc *mmc)
omap_hsmmc_conf_bus_power(mmc, (reg_val & VS33_3V3SUP) ?
  MMC_SIGNAL_VOLTAGE_330 : MMC_SIGNAL_VOLTAGE_180);
 #else
-   writel(DTW_1_BITMODE | SDBP_PWROFF | SDVS_3V0, _base->hctl);
+   writel(DTW_1_BITMODE | SDBP_PWROFF | SDVS_3V3, _base->hctl);
writel(readl(_base->capa) | VS33_3V3SUP | VS18_1V8SUP,
_base->capa);
 #endif
-- 
2.20.1



[PATCH] rockchip: rock64-rk3328: Add SPI Flash support

2020-07-03 Thread Johannes Krottmayer
Add SPI Flash support for the PINE64 Rock64 board

Signed-off-by: Johannes Krottmayer 
Cc: Kever Yang 
Cc: Jagan Teki 
---

Initial SPI Flash support.

Okay?

 arch/arm/dts/rk3328-rock64-u-boot.dtsi | 6 ++
 configs/rock64-rk3328_defconfig| 2 ++
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/dts/rk3328-rock64-u-boot.dtsi 
b/arch/arm/dts/rk3328-rock64-u-boot.dtsi
index f076075076..7340ef95f1 100644
--- a/arch/arm/dts/rk3328-rock64-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-rock64-u-boot.dtsi
@@ -46,3 +46,9 @@
 _sd {
u-boot,dm-spl;
 };
+
+ {
+   spi_flash: spiflash@0 {
+   u-boot,dm-pre-reloc;
+   };
+};
diff --git a/configs/rock64-rk3328_defconfig b/configs/rock64-rk3328_defconfig
index f123826358..0a51e51a0c 100644
--- a/configs/rock64-rk3328_defconfig
+++ b/configs/rock64-rk3328_defconfig
@@ -97,3 +97,5 @@ CONFIG_SPL_TINY_MEMSET=y
 CONFIG_TPL_TINY_MEMSET=y
 CONFIG_ERRNO_STR=y
 CONFIG_SMBIOS_MANUFACTURER="pine64"
+CONFIG_ROCKCHIP_SPI=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
-- 
2.26.2



Re: [RFC PATCH 4/4] linux/kconfig.h: create two- and three-argument versions of CONFIG_IS_ENABLED

2020-07-03 Thread Tom Rini
On Fri, Jul 03, 2020 at 10:22:17AM -0600, Simon Glass wrote:
> Hi,
> 
> On Tue, 16 Jun 2020 at 17:31, Simon Glass  wrote:
> >
> > Hi Rasmus,
> >
> > On Fri, 12 Jun 2020 at 05:02, Rasmus Villemoes
> >  wrote:
> > >
> > > This adds a bunch of preprocessor magic to extend the capabilities of
> > > CONFIG_IS_ENABLED. The existing semantics of
> > >
> > >   CONFIG_IS_ENABLED(FOO)
> > >
> > > expanding to a 1 or 0 (depending on build context and the defined-ness
> > > or not of the appropriate CONFIG_FOO/CONFIG_SPL_FOO/CONFIG_TPL_FOO)
> > > are of course preserved. With this, one is also allowed a two-argument
> > > form
> > >
> > >   CONFIG_IS_ENABLED(FOO, (something))
> > >
> > > which expands to something precisely when CONFIG_IS_ENABLED(FOO) would
> > > expand to 1, and expands to nothing otherwise. It is, in other words,
> > > completely equivalent to the three lines
> > >
> > >   #if CONFIG_IS_ENABLED(FOO)
> > >   something
> > >   #endif
> > >
> > > The second argument must be parenthesized in order to allow any
> > > tokens, including a trailing comma, to appear - one use case for this
> > > is precisely to make it a bit more ergonomic to build an array and
> > > only include certain items depending on .config. That should increase
> > > both readability and not least "git grep"ability.
> > >
> > > A third variant is also introduced,
> > >
> > >   CONFIG_IS_ENABLED(FOO, (xxx), (yyy))
> > >
> > > which corresponds to
> > >
> > >   #if CONFIG_IS_ENABLED(FOO)
> > >   xxx
> > >   #else
> > >   yyy
> > >   #endif
> > >
> > > Signed-off-by: Rasmus Villemoes 
> > > ---
> > >  include/linux/kconfig.h | 48 ++---
> > >  1 file changed, 45 insertions(+), 3 deletions(-)
> >
> > Reviewed-by: Simon Glass 
> >
> > See also this:
> >
> > http://patchwork.ozlabs.org/project/uboot/patch/20200522020223.230834-2-...@chromium.org/
> >
> > but I think your idea is a lot nicer.
> 
> I'd like to pick up these three Kconfig patches for dm/next. Any objection?

I'll take them through master soon.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] rockchip: rk3328: Add SPI support

2020-07-03 Thread Johannes Krottmayer
Add U-Boot SPI support for the RK3328

Signed-off-by: Johannes Krottmayer 
Cc: Kever Yang 
Cc: Jagan Teki 
---

It's a initial SPI support. Not sure if "rk3399_spi_params" is also
needed. Probing of the SPI flash devices works. Tested with the
PINE64 Rock64 board.

Okay?

 arch/arm/dts/rk3328-u-boot.dtsi   |  5 +
 drivers/clk/rockchip/clk_rk3328.c | 31 +++
 drivers/spi/rk_spi.c  |  2 ++
 3 files changed, 38 insertions(+)

diff --git a/arch/arm/dts/rk3328-u-boot.dtsi b/arch/arm/dts/rk3328-u-boot.dtsi
index c69e13e11e..c980daae99 100644
--- a/arch/arm/dts/rk3328-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-u-boot.dtsi
@@ -7,6 +7,7 @@
aliases {
mmc0 = 
mmc1 = 
+   spi0 = 
};
 
chosen {
@@ -66,3 +67,7 @@
 _otg {
hnp-srp-disable;
 };
+
+ {
+   u-boot,dm-pre-reloc;
+};
diff --git a/drivers/clk/rockchip/clk_rk3328.c 
b/drivers/clk/rockchip/clk_rk3328.c
index 02d3b08efa..bd95ab832b 100644
--- a/drivers/clk/rockchip/clk_rk3328.c
+++ b/drivers/clk/rockchip/clk_rk3328.c
@@ -555,6 +555,31 @@ static ulong rk3328_saradc_set_clk(struct rk3328_cru *cru, 
uint hz)
return rk3328_saradc_get_clk(cru);
 }
 
+static ulong rk3328_spi_get_clk(struct rk3328_cru *cru)
+{
+   u32 div, val;
+
+   val = readl(>clksel_con[24]);
+   div = (val & CLK_SPI_DIV_CON_MASK) >> CLK_SPI_DIV_CON_SHIFT;
+
+   return DIV_TO_RATE(OSC_HZ, div);
+}
+
+static ulong rk3328_spi_set_clk(struct rk3328_cru *cru, uint hz)
+{
+   u32 src_clk_div;
+
+   src_clk_div = GPLL_HZ / hz;
+   assert(src_clk_div < 128);
+
+   rk_clrsetreg(>clksel_con[24],
+CLK_PWM_PLL_SEL_MASK | CLK_PWM_DIV_CON_MASK,
+CLK_PWM_PLL_SEL_GPLL << CLK_PWM_PLL_SEL_SHIFT |
+(src_clk_div - 1) << CLK_PWM_DIV_CON_SHIFT);
+
+   return rk3328_spi_get_clk(cru);
+}
+
 static ulong rk3328_clk_get_rate(struct clk *clk)
 {
struct rk3328_clk_priv *priv = dev_get_priv(clk->dev);
@@ -581,6 +606,9 @@ static ulong rk3328_clk_get_rate(struct clk *clk)
case SCLK_SARADC:
rate = rk3328_saradc_get_clk(priv->cru);
break;
+   case SCLK_SPI:
+   rate = rk3328_spi_get_clk(priv->cru);
+   break;
default:
return -ENOENT;
}
@@ -617,6 +645,9 @@ static ulong rk3328_clk_set_rate(struct clk *clk, ulong 
rate)
case SCLK_SARADC:
ret = rk3328_saradc_set_clk(priv->cru, rate);
break;
+case SCLK_SPI:
+   ret = rk3328_spi_set_clk(priv->cru, rate);
+break;
case DCLK_LCDC:
case SCLK_PDM:
case SCLK_RTC32K:
diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c
index 833cb04922..0495e04945 100644
--- a/drivers/spi/rk_spi.c
+++ b/drivers/spi/rk_spi.c
@@ -545,7 +545,9 @@ const  struct rockchip_spi_params rk3399_spi_params = {
 };
 
 static const struct udevice_id rockchip_spi_ids[] = {
+   { .compatible = "rockchip,rk3066-spi" },
{ .compatible = "rockchip,rk3288-spi" },
+   { .compatible = "rockchip,rk3328-spi" },
{ .compatible = "rockchip,rk3368-spi",
  .data = (ulong)_spi_params },
{ .compatible = "rockchip,rk3399-spi",
-- 
2.26.2



Re: [PATCH v5 04/14] dtoc: add support to scan drivers

2020-07-03 Thread Walter Lozano

Hi Simon,

On 3/7/20 13:08, Simon Glass wrote:

Hi Walter,

On Fri, 3 Jul 2020 at 05:07, 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 and aliases. This allows to generate U_BOOT_DEVICE entries using
valid driver names and rise a warning in the case a name is not valid.

Signed-off-by: Walter Lozano 
---

(no changes since v1)

  tools/dtoc/dtb_platdata.py| 91 +--
  tools/dtoc/dtoc_test_driver_alias.dts | 20 ++
  tools/dtoc/test_dtoc.py   | 33 ++
  3 files changed, 140 insertions(+), 4 deletions(-)
  create mode 100644 tools/dtoc/dtoc_test_driver_alias.dts


This seems to do the trick, thanks!

But there is one problem remaining - lots of warning output from the
various tests:

https://pastebin.com/K7GBPiqC


The warnings are removed by the next patch in the series, "[PATCH v4 
05/14] dtoc: add option to disable warnings", by adding additional 
arguments.


I thought having these two things in different patches made sense, but 
If you prefer I can re send the series with those two patches squashed.


Please confirm.

Regards,

Walter



[PATCH] phy: usbphyc: use regulator_set_enable_if_allowed for disabling vdd supply

2020-07-03 Thread Patrick Delaunay
Use regulator_set_enable_if_allowed() api instead of regulator_set_enable()
while disabling vdd supply. This way the driver doesn't see an error
when disabling an always-on regulator.

This patch is needed since the commit f93fab312615 ("Revert 'power:
regulator: Return success on attempt to disable an always-on regulator'")
and use the API introduced by commit cc4a224af226 ("power: regulator:
Introduce regulator_set_enable_if_allowed api").

Signed-off-by: Patrick Delaunay 
---

 drivers/phy/phy-stm32-usbphyc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c
index 464b0735e8..c6d3048602 100644
--- a/drivers/phy/phy-stm32-usbphyc.c
+++ b/drivers/phy/phy-stm32-usbphyc.c
@@ -263,7 +263,7 @@ static int stm32_usbphyc_phy_power_off(struct phy *phy)
return 0;
 
if (usbphyc_phy->vdd) {
-   ret = regulator_set_enable(usbphyc_phy->vdd, false);
+   ret = regulator_set_enable_if_allowed(usbphyc_phy->vdd, false);
if (ret)
return ret;
}
-- 
2.17.1



Re: PINE64 Rock64 - How to get SPI driver working

2020-07-03 Thread Johannes Krottmayer
I finally resolved the issue:

=> sf probe
SF: Detected gd25q128 with page size 256 Bytes, erase size 4 KiB, total
16 MiB
=>

The flash device will be correctly detected.
The problem was missing support in the clock driver of the SoC.

Should I release a patch for it?

On 24.06.20 at 17:52,  Johannes Krottmayer wrote:
> Sorry for my late response.
> 
> Thanks for the suggestions.
> 
> On 22.05.20 at 16:28,  Peter Robinson wrote:
>> Make sure you enable the driver for the actual flash chip too, some of
>> the popular ones are:
>> CONFIG_SPI_FLASH_WINBOND=y
>> CONFIG_SPI_FLASH_MACRONIX=y
>> CONFIG_SPI_FLASH_SPANSION=y
>> CONFIG_SPI_FLASH_GIGADEVICE=y
> 
> I have enabled 'CONFIG_SPI_FLASH_GIGADEVICE'. But still getting
> the same error code (-2). On board is the GD25Q127C from Gigadevice.
> 
> The device ID for the operation code 0x9F according to the datasheet
> should be 0xC84018. I also found this device ID in the SPI-NOR IDS
> file.
> 


RE: [PATCH 3/3] cmd: adtimg: Refactor usage style

2020-07-03 Thread Patrick DELAUNAY
Hi Eugeniu,

> From: U-Boot  On Behalf Of Eugeniu Rosca
> Sent: samedi 11 janvier 2020 00:30
> 
> Hi Tom,
> 
> On Fri, Jan 10, 2020 at 04:50:52PM -0500, Tom Rini wrote:
> > On Tue, Dec 24, 2019 at 05:51:08PM +0100, Eugeniu Rosca wrote:
> > > Signed-off-by: Eugeniu Rosca 
> > > Reviewed-by: Sam Protsenko 
> >
> > Applied to u-boot/master, thanks!
> 
> Thanks for merging!

For the planned update of the command adtimg:

> [6] Soon-to-be-provided "by id|rev" add-on functionality adtimg get dt 
> --id= --rev= [avar [svar [ivar]]]
>  - Get DT address/size/index by id|rev fields

Do you have plan to upstream this code or it is available  in downstream ?

Because stm32mp1 platform needs this feature

We code in downstream [1] based on v2020.01 almost the same command
but based on the old usage = [2]

dtimg getindex[varname] 
- get index of FDT in the image, by board identifier and revision
  : image address in RAM, in hex
  : board identifier
  : board revision (0 if not used)
  [varname]: name of variable where to store index of FDT

So if you have nothing ready, I can update my code with your proposed 
parameters.

[1] 
https://github.com/STMicroelectronics/u-boot/blob/v2020.01-stm32mp/cmd/dtimg.c
[2] 
https://github.com/STMicroelectronics/u-boot/commit/21b57a166e73a8457d4caea6a1d37f1f3fda3d45


> --
> Best Regards,
> Eugeniu

Best Regards

Patrick


[PATCH v2 8/8] x86: fsp: Support a warning message when DRAM init is slow

2020-07-03 Thread Simon Glass
With DDR4, Intel SOCs take quite a long time to init their memory. During
this time, if the user is watching, it looks like SPL has hung. Add a
message in this case.

This works by adding a return code to fspm_update_config() that indicates
whether MRC data was found and a new property to the device tree.

Also add one more debug message while starting.

Signed-off-by: Simon Glass 
Reviewed-by: Wolfgang Wallner 
Tested-by: Wolfgang Wallner 
---

Changes in v2:
- Use the three-argument CONFIG_IS_ENABLED() instead of IF_ENABLED_INT()
- Update binding to mention timing for coral and a 1GB APL board
- Drop patch 'kconfig: Add support for conditional values'

 arch/x86/cpu/apollolake/fsp_m.c   | 12 --
 arch/x86/dts/chromebook_coral.dts |  1 +
 arch/x86/include/asm/fsp2/fsp_internal.h  |  3 ++-
 arch/x86/lib/fsp2/fsp_meminit.c   | 24 +++
 .../fsp/fsp2/apollolake/fsp-m.txt |  4 
 5 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/arch/x86/cpu/apollolake/fsp_m.c b/arch/x86/cpu/apollolake/fsp_m.c
index 1301100cd5..65461d85b8 100644
--- a/arch/x86/cpu/apollolake/fsp_m.c
+++ b/arch/x86/cpu/apollolake/fsp_m.c
@@ -16,10 +16,14 @@ int fspm_update_config(struct udevice *dev, struct fspm_upd 
*upd)
 {
struct fsp_m_config *cfg = >config;
struct fspm_arch_upd *arch = >arch;
+   int cache_ret = 0;
ofnode node;
+   int ret;
 
arch->nvs_buffer_ptr = NULL;
-   prepare_mrc_cache(upd);
+   cache_ret = prepare_mrc_cache(upd);
+   if (cache_ret && cache_ret != -ENOENT)
+   return log_msg_ret("mrc", cache_ret);
arch->stack_base = (void *)0xfef96000;
arch->boot_loader_tolum_size = 0;
arch->boot_mode = FSP_BOOT_WITH_FULL_CONFIGURATION;
@@ -28,7 +32,11 @@ int fspm_update_config(struct udevice *dev, struct fspm_upd 
*upd)
if (!ofnode_valid(node))
return log_msg_ret("fsp-m settings", -ENOENT);
 
-   return fsp_m_update_config_from_dtb(node, cfg);
+   ret = fsp_m_update_config_from_dtb(node, cfg);
+   if (ret)
+   return log_msg_ret("dtb", cache_ret);
+
+   return cache_ret;
 }
 
 /*
diff --git a/arch/x86/dts/chromebook_coral.dts 
b/arch/x86/dts/chromebook_coral.dts
index 965d9f387d..a17a9c2800 100644
--- a/arch/x86/dts/chromebook_coral.dts
+++ b/arch/x86/dts/chromebook_coral.dts
@@ -117,6 +117,7 @@
reg = <0x 0 0 0 0>;
compatible = "intel,apl-hostbridge";
pciex-region-size = <0x1000>;
+   fspm,training-delay = <21>;
/*
 * Parameters used by the FSP-S binary blob. This is
 * really unfortunate since these parameters mostly
diff --git a/arch/x86/include/asm/fsp2/fsp_internal.h 
b/arch/x86/include/asm/fsp2/fsp_internal.h
index f751fbf961..b4a4fbbd84 100644
--- a/arch/x86/include/asm/fsp2/fsp_internal.h
+++ b/arch/x86/include/asm/fsp2/fsp_internal.h
@@ -57,7 +57,8 @@ int arch_fsps_preinit(void);
  *
  * @dev: Hostbridge device containing config
  * @upd: Config data to fill in
- * @return 0 if OK, -ve on error
+ * @return 0 if OK, -ENOENT if OK but no MRC-cache data was found, other -ve on
+ * error
  */
 int fspm_update_config(struct udevice *dev, struct fspm_upd *upd);
 
diff --git a/arch/x86/lib/fsp2/fsp_meminit.c b/arch/x86/lib/fsp2/fsp_meminit.c
index faf9c29aef..ce0b0aff76 100644
--- a/arch/x86/lib/fsp2/fsp_meminit.c
+++ b/arch/x86/lib/fsp2/fsp_meminit.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -63,8 +64,10 @@ int fsp_memory_init(bool s3wake, bool use_spi_flash)
struct fsp_header *hdr;
struct hob_header *hob;
struct udevice *dev;
+   int delay;
int ret;
 
+   log_debug("Locating FSP\n");
ret = fsp_locate_fsp(FSP_M, , use_spi_flash, , , NULL);
if (ret)
return log_msg_ret("locate FSP", ret);
@@ -76,21 +79,32 @@ int fsp_memory_init(bool s3wake, bool use_spi_flash)
return log_msg_ret("Bad UPD signature", -EPERM);
memcpy(, fsp_upd, sizeof(upd));
 
+   delay = dev_read_u32_default(dev, "fspm,training-delay", 0);
ret = fspm_update_config(dev, );
-   if (ret)
-   return log_msg_ret("Could not setup config", ret);
-
-   debug("SDRAM init...");
+   if (ret) {
+   if (ret != -ENOENT)
+   return log_msg_ret("Could not setup config", ret);
+   } else {
+   delay = 0;
+   }
+
+   if (delay)
+   printf("SDRAM training (%d seconds)...", delay);
+   else
+   log_debug("SDRAM init...");
bootstage_start(BOOTSTAGE_ID_ACCUM_FSP_M, "fsp-m");
func = (fsp_memory_init_func)(hdr->img_base + hdr->fsp_mem_init);
ret = func(, );

[PATCH v2 7/8] x86: Avoid #ifdef with CONFIG_HAVE_ACPI_RESUME

2020-07-03 Thread Simon Glass
At present this enables a few arch-specific members of the global_data
struct which are otherwise not part of the struct. As a result we have to
use #ifdef in various places.

The cost of always having these in the struct is small. Adjust things so
that we can use compile-time code instead of #ifdefs.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Use new three-argument CONFIG_IS_ENABLED() instead

 arch/x86/cpu/apollolake/cpu_spl.c| 13 +-
 arch/x86/cpu/apollolake/fsp_s.c  | 10 
 arch/x86/cpu/baytrail/acpi.c |  2 --
 arch/x86/cpu/broadwell/power_state.c |  5 ++--
 arch/x86/cpu/cpu.c   | 38 ++--
 arch/x86/include/asm/global_data.h   |  2 --
 arch/x86/lib/coreboot_table.c|  6 ++---
 arch/x86/lib/fsp/fsp_common.c|  2 --
 arch/x86/lib/fsp/fsp_dram.c  | 26 +++
 arch/x86/lib/fsp1/fsp_common.c   | 16 +++-
 arch/x86/lib/fsp2/fsp_dram.c |  7 +++--
 11 files changed, 63 insertions(+), 64 deletions(-)

diff --git a/arch/x86/cpu/apollolake/cpu_spl.c 
b/arch/x86/cpu/apollolake/cpu_spl.c
index 707ceb3e64..9f32f2e27e 100644
--- a/arch/x86/cpu/apollolake/cpu_spl.c
+++ b/arch/x86/cpu/apollolake/cpu_spl.c
@@ -247,12 +247,13 @@ static int arch_cpu_init_spl(void)
ret = pmc_init(pmc);
if (ret < 0)
return log_msg_ret("Could not init PMC", ret);
-#ifdef CONFIG_HAVE_ACPI_RESUME
-   ret = pmc_prev_sleep_state(pmc);
-   if (ret < 0)
-   return log_msg_ret("Could not get PMC sleep state", ret);
-   gd->arch.prev_sleep_state = ret;
-#endif
+   if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)) {
+   ret = pmc_prev_sleep_state(pmc);
+   if (ret < 0)
+   return log_msg_ret("Could not get PMC sleep state",
+  ret);
+   gd->arch.prev_sleep_state = ret;
+   }
 
return 0;
 }
diff --git a/arch/x86/cpu/apollolake/fsp_s.c b/arch/x86/cpu/apollolake/fsp_s.c
index 767ddfe680..13e6b20f08 100644
--- a/arch/x86/cpu/apollolake/fsp_s.c
+++ b/arch/x86/cpu/apollolake/fsp_s.c
@@ -192,16 +192,16 @@ int arch_fsps_preinit(void)
 
 int arch_fsp_init_r(void)
 {
-#ifdef CONFIG_HAVE_ACPI_RESUME
-   bool s3wake = gd->arch.prev_sleep_state == ACPI_S3;
-#else
-   bool s3wake = false;
-#endif
+   bool s3wake;
struct udevice *dev, *itss;
int ret;
 
if (!ll_boot_init())
return 0;
+
+   s3wake = IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) &&
+   gd->arch.prev_sleep_state == ACPI_S3;
+
/*
 * This must be called before any devices are probed. Put any probing
 * into arch_fsps_preinit() above.
diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c
index 65f2006a0a..b17bc62a2d 100644
--- a/arch/x86/cpu/baytrail/acpi.c
+++ b/arch/x86/cpu/baytrail/acpi.c
@@ -161,7 +161,6 @@ void acpi_create_gnvs(struct acpi_global_nvs *gnvs)
gnvs->iuart_en = 0;
 }
 
-#ifdef CONFIG_HAVE_ACPI_RESUME
 /*
  * The following two routines are called at a very early stage, even before
  * FSP 2nd phase API fsp_init() is called. Registers off ACPI_BASE_ADDRESS
@@ -204,4 +203,3 @@ void chipset_clear_sleep_state(void)
pm1_cnt = inl(ACPI_BASE_ADDRESS + PM1_CNT);
outl(pm1_cnt & ~(SLP_TYP), ACPI_BASE_ADDRESS + PM1_CNT);
 }
-#endif
diff --git a/arch/x86/cpu/broadwell/power_state.c 
b/arch/x86/cpu/broadwell/power_state.c
index 99d6f72cf6..62fd2e8d2c 100644
--- a/arch/x86/cpu/broadwell/power_state.c
+++ b/arch/x86/cpu/broadwell/power_state.c
@@ -23,11 +23,10 @@ static int prev_sleep_state(struct chipset_power_state *ps)
 
if (ps->pm1_sts & WAK_STS) {
switch ((ps->pm1_cnt & SLP_TYP) >> SLP_TYP_SHIFT) {
-#if CONFIG_HAVE_ACPI_RESUME
case SLP_TYP_S3:
-   prev_sleep_state = SLEEP_STATE_S3;
+   if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME))
+   prev_sleep_state = SLEEP_STATE_S3;
break;
-#endif
case SLP_TYP_S5:
prev_sleep_state = SLEEP_STATE_S5;
break;
diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
index a814e7d7a6..23a4d633d2 100644
--- a/arch/x86/cpu/cpu.c
+++ b/arch/x86/cpu/cpu.c
@@ -163,10 +163,10 @@ int default_print_cpuinfo(void)
   cpu_has_64bit() ? "x86_64" : "x86",
   cpu_vendor_name(gd->arch.x86_vendor), gd->arch.x86_device);
 
-#ifdef CONFIG_HAVE_ACPI_RESUME
-   debug("ACPI previous sleep state: %s\n",
- acpi_ss_string(gd->arch.prev_sleep_state));
-#endif
+   if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)) {
+   debug("ACPI previous sleep state: %s\n",
+ acpi_ss_string(gd->arch.prev_sleep_state));
+   }
 
return 0;
 }
@@ -191,12 +191,12 @@ int last_stage_init(void)
 
board_final_cleanup();
 
-#ifdef 

[PATCH v2 6/8] coral: Enable the copy framebuffer

2020-07-03 Thread Simon Glass
Enable this feature on chromebook_coral to speed up the display.

With this change, the time taken to print the environment to the display
without CONFIG_CONSOLE_SCROLL_LINES is reduced from 1830ms to 62ms.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 configs/chromebook_coral_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/chromebook_coral_defconfig 
b/configs/chromebook_coral_defconfig
index d7cab2334b..a2a29cf842 100644
--- a/configs/chromebook_coral_defconfig
+++ b/configs/chromebook_coral_defconfig
@@ -93,6 +93,7 @@ CONFIG_TPM2_CR50_I2C=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_VIDEO_COPY=y
 CONFIG_SPL_FS_CBFS=y
 # CONFIG_SPL_USE_TINY_PRINTF is not set
 CONFIG_TPL_USE_TINY_PRINTF=y
-- 
2.27.0.212.ge8ba1cc988-goog



[PATCH v2 5/8] timer: Allow delays with a 32-bit microsecond timer

2020-07-03 Thread Simon Glass
The current get_timer_us() uses 64-bit arithmetic. When implementing
microsecond-level timeouts, 32-bits is plenty. Add a new function to
support this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/time.h | 11 +++
 lib/time.c |  5 +
 2 files changed, 16 insertions(+)

diff --git a/include/time.h b/include/time.h
index e99f9c8012..434e63b075 100644
--- a/include/time.h
+++ b/include/time.h
@@ -17,6 +17,17 @@ unsigned long get_timer(unsigned long base);
 unsigned long timer_get_us(void);
 uint64_t get_timer_us(uint64_t base);
 
+/**
+ * get_timer_us_long() - Get the number of elapsed microseconds
+ *
+ * This uses 32-bit arithmetic on 32-bit machines, which is enough to handle
+ * delays of over an hour.
+ *
+ *@base: Base time to consider
+ *@return elapsed time since @base
+ */
+unsigned long get_timer_us_long(unsigned long base);
+
 /*
  * timer_test_add_offset()
  *
diff --git a/lib/time.c b/lib/time.c
index 65db0f6cda..47f8c84327 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -152,6 +152,11 @@ uint64_t __weak get_timer_us(uint64_t base)
return tick_to_time_us(get_ticks()) - base;
 }
 
+unsigned long __weak get_timer_us_long(unsigned long base)
+{
+   return timer_get_us() - base;
+}
+
 unsigned long __weak notrace timer_get_us(void)
 {
return tick_to_time(get_ticks() * 1000);
-- 
2.27.0.212.ge8ba1cc988-goog



[PATCH v2 3/8] linux/kconfig.h: create two- and three-argument versions of CONFIG_IS_ENABLED

2020-07-03 Thread Simon Glass
From: Rasmus Villemoes 

This adds a bunch of preprocessor magic to extend the capabilities of
CONFIG_IS_ENABLED. The existing semantics of

  CONFIG_IS_ENABLED(FOO)

expanding to a 1 or 0 (depending on build context and the defined-ness
or not of the appropriate CONFIG_FOO/CONFIG_SPL_FOO/CONFIG_TPL_FOO)
are of course preserved. With this, one is also allowed a two-argument
form

  CONFIG_IS_ENABLED(FOO, (something))

which expands to something precisely when CONFIG_IS_ENABLED(FOO) would
expand to 1, and expands to nothing otherwise. It is, in other words,
completely equivalent to the three lines

  #if CONFIG_IS_ENABLED(FOO)
  something
  #endif

The second argument must be parenthesized in order to allow any
tokens, including a trailing comma, to appear - one use case for this
is precisely to make it a bit more ergonomic to build an array and
only include certain items depending on .config. That should increase
both readability and not least "git grep"ability.

A third variant is also introduced,

  CONFIG_IS_ENABLED(FOO, (xxx), (yyy))

which corresponds to

  #if CONFIG_IS_ENABLED(FOO)
  xxx
  #else
  yyy
  #endif

Signed-off-by: Rasmus Villemoes 
Reviewed-by: Simon Glass 
Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/linux/kconfig.h | 48 ++---
 1 file changed, 45 insertions(+), 3 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index caea505a0e..d109ed3119 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -56,13 +56,55 @@
 #define CONFIG_VAL(option)  config_val(option)
 
 /*
- * CONFIG_IS_ENABLED(FOO) evaluates to
+ * Count number of arguments to a variadic macro. Currently only need
+ * it for 1, 2 or 3 arguments.
+ */
+#define __arg6(a1, a2, a3, a4, a5, a6, ...) a6
+#define __count_args(...) __arg6(dummy, ##__VA_ARGS__, 4, 3, 2, 1, 0)
+
+#define __concat(a, b)   ___concat(a, b)
+#define ___concat(a, b)  a ## b
+
+#define __unwrap(...) __VA_ARGS__
+#define __unwrap1(case1, case0) __unwrap case1
+#define __unwrap0(case1, case0) __unwrap case0
+
+#define __CONFIG_IS_ENABLED_1(option)__CONFIG_IS_ENABLED_3(option, 
(1), (0))
+#define __CONFIG_IS_ENABLED_2(option, case1) __CONFIG_IS_ENABLED_3(option, 
case1, ())
+#define __CONFIG_IS_ENABLED_3(option, case1, case0) \
+   __concat(__unwrap, config_enabled(CONFIG_VAL(option))) (case1, case0)
+
+/*
+ * CONFIG_IS_ENABLED(FOO) expands to
  *  1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
  *  1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
  *  1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
  *  0 otherwise.
+ *
+ * CONFIG_IS_ENABLED(FOO, (abc)) expands to
+ *  abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
+ *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
+ *  nothing otherwise.
+ *
+ * CONFIG_IS_ENABLED(FOO, (abc), (def)) expands to
+ *  abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
+ *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
+ *  def otherwise.
+ *
+ * The optional second and third arguments must be parenthesized; that
+ * allows one to include a trailing comma, e.g. for use in
+ *
+ * CONFIG_IS_ENABLED(ACME, ({.compatible = "acme,frobnozzle"},))
+ *
+ * which adds an entry to the array being defined if CONFIG_ACME (or
+ * CONFIG_SPL_ACME/CONFIG_TPL_ACME, depending on build context) is
+ * set, and nothing otherwise.
  */
-#define CONFIG_IS_ENABLED(option) \
-   (config_enabled(CONFIG_VAL(option)))
+
+#define CONFIG_IS_ENABLED(option, ...) \
+   __concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) 
(option, ##__VA_ARGS__)
+
 
 #endif /* __LINUX_KCONFIG_H */
-- 
2.27.0.212.ge8ba1cc988-goog



[PATCH v2 1/8] linux/kconfig.h: simplify logic for choosing CONFIG_{SPL_, TPL_, }*

2020-07-03 Thread Simon Glass
From: Rasmus Villemoes 

Instead of using the arg1_or_junk trick to pick between two choices,
with a bit of duplication between the branches (and most of the
CONFIG_TPL_BUILD case being redundant, as _IS_TPL is known to be
defined to 1 in that case), simply define a prefix that we inject
between CONFIG_ and the given config symbol.

This only requires one level of indirection (to get the
_CONFIG_PREFIX macro expanded before the token concatenation takes
place), and makes it easy to, say, introduce a CONFIG_HOSTTOOL_
prefix. [I would expect most HOSTTOOL_ symbols to just be def_bool y,
but it would allow us to clean up some of the ifdef HOSTCC mess in the
sources shared between U-Boot and host tools.]

Signed-off-by: Rasmus Villemoes 
Reviewed-by: Simon Glass 
Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/linux/kconfig.h | 27 ---
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 3a2da738c4..56b8e5d787 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -47,30 +47,19 @@
  * U-Boot add-on: Helper macros to reference to different macros
  * (CONFIG_ or CONFIG_SPL_ prefixed), depending on the build context.
  */
-#ifdef CONFIG_SPL_BUILD
-#define _IS_SPL 1
-#endif
-
-#ifdef CONFIG_TPL_BUILD
-#define _IS_TPL 1
-#endif
 
 #if defined(CONFIG_TPL_BUILD)
-#define config_val(cfg) _config_val(_IS_TPL, cfg)
-#define _config_val(x, cfg) __config_val(x, cfg)
-#define __config_val(x, cfg) ___config_val(__ARG_PLACEHOLDER_##x, cfg)
-#define ___config_val(arg1_or_junk, cfg)  \
-   config_val(arg1_or_junk CONFIG_TPL_##cfg, CONFIG_##cfg)
-#define config_val(__ignored, val, ...) val
+#define _CONFIG_PREFIX TPL_
+#elif defined(CONFIG_SPL_BUILD)
+#define _CONFIG_PREFIX SPL_
 #else
-#define config_val(cfg) _config_val(_IS_SPL, cfg)
-#define _config_val(x, cfg) __config_val(x, cfg)
-#define __config_val(x, cfg) ___config_val(__ARG_PLACEHOLDER_##x, cfg)
-#define ___config_val(arg1_or_junk, cfg)  \
-   config_val(arg1_or_junk CONFIG_SPL_##cfg, CONFIG_##cfg)
-#define config_val(__ignored, val, ...) val
+#define _CONFIG_PREFIX
 #endif
 
+#define   config_val(cfg)   _config_val(_CONFIG_PREFIX, cfg)
+#define  _config_val(pfx, cfg) __config_val(pfx, cfg)
+#define __config_val(pfx, cfg) CONFIG_ ## pfx ## cfg
+
 /*
  * CONFIG_VAL(FOO) evaluates to the value of
  *  CONFIG_FOO if CONFIG_SPL_BUILD is undefined,
-- 
2.27.0.212.ge8ba1cc988-goog



[PATCH v2 4/8] bootstage: Fix 'stacked' typo

2020-07-03 Thread Simon Glass
This should be 'stashed'. Fix it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/bootstage.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/bootstage.h b/include/bootstage.h
index f507271375..00c85fb86a 100644
--- a/include/bootstage.h
+++ b/include/bootstage.h
@@ -338,7 +338,7 @@ int bootstage_stash(void *base, int size);
  * @param base Base address of memory buffer
  * @param size Size of memory buffer (-1 if unknown)
  * @return 0 if unstashed ok, -ENOENT if bootstage info not found, -ENOSPC if
- * there is not space for read the stacked data, or other error if
+ * there is not space for read the stashed data, or other error if
  * something else went wrong
  */
 int bootstage_unstash(const void *base, int size);
-- 
2.27.0.212.ge8ba1cc988-goog



[PATCH v2 2/8] linux/kconfig.h: remove unused helper macros

2020-07-03 Thread Simon Glass
From: Rasmus Villemoes 

U-Boot does not have loadable modules, and nothing currently uses any
of the (CONFIG_)?IS_(BUILTIN|MODULE) macros - only
the (CONFIG_)?IS_ENABLED variants are ever used.

While I understand the desire to keep this somewhat synchronized with
linux, we've already departed by the introduction of the
CONFIG_IS_ENABLED extra logic, and deleting these makes the next patch
much simpler, since I won't have to duplicate a lot of logic for no
real gain (as there are no users).

Signed-off-by: Rasmus Villemoes 
Reviewed-by: Simon Glass 
Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/linux/kconfig.h  | 40 +---
 scripts/config_whitelist.txt |  2 --
 2 files changed, 5 insertions(+), 37 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 56b8e5d787..caea505a0e 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -23,25 +23,12 @@
 #define ___config_enabled(__ignored, val, ...) val
 
 /*
- * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
+ * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y',
  * 0 otherwise.
  *
  */
 #define IS_ENABLED(option) \
-   (config_enabled(option) || config_enabled(option##_MODULE))
-
-/*
- * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
- * otherwise. For boolean options, this is equivalent to
- * IS_ENABLED(CONFIG_FOO).
- */
-#define IS_BUILTIN(option) config_enabled(option)
-
-/*
- * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
- * otherwise.
- */
-#define IS_MODULE(option) config_enabled(option##_MODULE)
+   (config_enabled(option))
 
 /*
  * U-Boot add-on: Helper macros to reference to different macros
@@ -70,29 +57,12 @@
 
 /*
  * CONFIG_IS_ENABLED(FOO) evaluates to
- *  1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y' or 'm',
- *  1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y' or 'm',
- *  1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y' or 'm',
- *  0 otherwise.
- */
-#define CONFIG_IS_ENABLED(option) \
-   (config_enabled(CONFIG_VAL(option)) ||  \
-config_enabled(CONFIG_VAL(option##_MODULE)))
-
-/*
- * CONFIG_IS_BUILTIN(FOO) evaluates to
  *  1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
  *  1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ *  1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
  *  0 otherwise.
  */
-#define CONFIG_IS_BUILTIN(option) config_enabled(CONFIG_VAL(option))
-
-/*
- * CONFIG_IS_MODULE(FOO) evaluates to
- *  1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'm',
- *  1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'm',
- *  0 otherwise.
- */
-#define CONFIG_IS_MODULE(option) config_enabled(CONFIG_VAL(option##_MODULE))
+#define CONFIG_IS_ENABLED(option) \
+   (config_enabled(CONFIG_VAL(option)))
 
 #endif /* __LINUX_KCONFIG_H */
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 2210f46e44..352db2b57a 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -875,9 +875,7 @@ CONFIG_IRAM_SIZE
 CONFIG_IRAM_STACK
 CONFIG_IRAM_TOP
 CONFIG_IRDA_BASE
-CONFIG_IS_BUILTIN
 CONFIG_IS_ENABLED
-CONFIG_IS_MODULE
 CONFIG_JFFS2_CMDLINE
 CONFIG_JFFS2_DEV
 CONFIG_JFFS2_LZO
-- 
2.27.0.212.ge8ba1cc988-goog



Re: [RFC PATCH 4/4] linux/kconfig.h: create two- and three-argument versions of CONFIG_IS_ENABLED

2020-07-03 Thread Simon Glass
Hi,

On Tue, 16 Jun 2020 at 17:31, Simon Glass  wrote:
>
> Hi Rasmus,
>
> On Fri, 12 Jun 2020 at 05:02, Rasmus Villemoes
>  wrote:
> >
> > This adds a bunch of preprocessor magic to extend the capabilities of
> > CONFIG_IS_ENABLED. The existing semantics of
> >
> >   CONFIG_IS_ENABLED(FOO)
> >
> > expanding to a 1 or 0 (depending on build context and the defined-ness
> > or not of the appropriate CONFIG_FOO/CONFIG_SPL_FOO/CONFIG_TPL_FOO)
> > are of course preserved. With this, one is also allowed a two-argument
> > form
> >
> >   CONFIG_IS_ENABLED(FOO, (something))
> >
> > which expands to something precisely when CONFIG_IS_ENABLED(FOO) would
> > expand to 1, and expands to nothing otherwise. It is, in other words,
> > completely equivalent to the three lines
> >
> >   #if CONFIG_IS_ENABLED(FOO)
> >   something
> >   #endif
> >
> > The second argument must be parenthesized in order to allow any
> > tokens, including a trailing comma, to appear - one use case for this
> > is precisely to make it a bit more ergonomic to build an array and
> > only include certain items depending on .config. That should increase
> > both readability and not least "git grep"ability.
> >
> > A third variant is also introduced,
> >
> >   CONFIG_IS_ENABLED(FOO, (xxx), (yyy))
> >
> > which corresponds to
> >
> >   #if CONFIG_IS_ENABLED(FOO)
> >   xxx
> >   #else
> >   yyy
> >   #endif
> >
> > Signed-off-by: Rasmus Villemoes 
> > ---
> >  include/linux/kconfig.h | 48 ++---
> >  1 file changed, 45 insertions(+), 3 deletions(-)
>
> Reviewed-by: Simon Glass 
>
> See also this:
>
> http://patchwork.ozlabs.org/project/uboot/patch/20200522020223.230834-2-...@chromium.org/
>
> but I think your idea is a lot nicer.

I'd like to pick up these three Kconfig patches for dm/next. Any objection?

Regards,
SImon


Re: [PATCH v2 14/17] test/py: efi_secboot: split "signed image" test case-1 into two cases

2020-07-03 Thread Heinrich Schuchardt
On 09.06.20 07:09, AKASHI Takahiro wrote:
> Split the existing test case-1 into case1 and a new case-2:
> case-1 for non-SecureBoot mode; case-2 for SecureBoot mode.
>
> In addition, one corner case is added to case-2; a image is signed
> but a corresponding certificate is not yet installed in "db."
>
> Signed-off-by: AKASHI Takahiro 

Reviewed-by: Heinrich Schuchardt 


Re: [PATCH v5 04/14] dtoc: add support to scan drivers

2020-07-03 Thread Simon Glass
Hi Walter,

On Fri, 3 Jul 2020 at 05:07, 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 and aliases. This allows to generate U_BOOT_DEVICE entries using
> valid driver names and rise a warning in the case a name is not valid.
>
> Signed-off-by: Walter Lozano 
> ---
>
> (no changes since v1)
>
>  tools/dtoc/dtb_platdata.py| 91 +--
>  tools/dtoc/dtoc_test_driver_alias.dts | 20 ++
>  tools/dtoc/test_dtoc.py   | 33 ++
>  3 files changed, 140 insertions(+), 4 deletions(-)
>  create mode 100644 tools/dtoc/dtoc_test_driver_alias.dts
>

This seems to do the trick, thanks!

But there is one problem remaining - lots of warning output from the
various tests:

https://pastebin.com/K7GBPiqC

Regards,
Simon


Re: [PATCH v2 13/17] test/py: efi_secboot: fix test case 1g of test_authvar

2020-07-03 Thread Heinrich Schuchardt
On 09.06.20 07:09, AKASHI Takahiro wrote:
> In the test case (1g) of test_authvar, "db" is mistakenly used,
> and it ends up being the exact same as (1f).
> So correct it as "dbx" test case.
>
> Signed-off-by: AKASHI Takahiro 

Reviewed-by: Heinrich Schuchardt 


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

2020-07-03 Thread Tom Rini
On Thu, Jul 02, 2020 at 09:50:53AM +0800, ub...@andestech.com wrote:

> Hi Tom,
> 
> This PR is for -next
> 
> Please pull some riscv updates:
> 
> - Add Sipeed Maix support
> - Update clock handler and proper cpu features
> 
> Thanks
> Rick
> 
> https://travis-ci.org/github/rickchen36/u-boot-riscv/builds/703836681
> 
> The following changes since commit e2a4d24e6b1f3d30136e2dde7b6fbf35bd427b8a:
> 
>   Merge branch '2020-06-30-minor-TI-board-updates' into next (2020-06-30 
> 15:03:25 -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 add0dc1f7de91112d9e738f9482b09b75fa86acb:
> 
>   riscv: cpu: check and append L1 cache to cpu features (2020-07-01 15:01:27 
> +0800)
> 

Applied to u-boot/next, thanks!


-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 12/17] test/py: efi_secboot: remove all "re.search"

2020-07-03 Thread Heinrich Schuchardt
On 09.06.20 07:09, AKASHI Takahiro wrote:
> Currently, we don't use any regular expression in matching outputs from
> U-Boot. Since its use is just redundant, we can remove all.
>
> Signed-off-by: AKASHI Takahiro 

Reviewed-by: Heinrich Schuchardt 


[PATCH] board: update test on misc_read result in board_late_init

2020-07-03 Thread Patrick Delaunay
Update management of misc_read, which now return length of data
after the commit 8729b1ae2cbd ("misc: Update read() and write()
methods to return bytes xfered")

Fixes: 8b8b3d6b55b9 ("stm32mp1: board: add environment variable for board id 
and board rev")

Signed-off-by: Patrick Delaunay 
---

 board/st/stm32mp1/stm32mp1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 4553329b25..b51165a636 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -732,7 +732,7 @@ int board_late_init(void)
if (!ret)
ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
, sizeof(otp));
-   if (!ret && otp) {
+   if (ret > 0 && otp) {
snprintf(buf, sizeof(buf), "0x%04x", otp >> 16);
env_set("board_id", buf);
 
-- 
2.17.1



[PATCH v3 7/7] arm: meson: change trace level for phy errors managed by uclass

2020-07-03 Thread Patrick Delaunay
As the error message is now displayed by generic phy functions,
the pr_err can be change to pr_debug.

Signed-off-by: Patrick Delaunay 
---

Changes in v3:
- add update for mach-meson board-gx: new generic_phy API usage

 arch/arm/mach-meson/board-gx.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-meson/board-gx.c b/arch/arm/mach-meson/board-gx.c
index c4cc11f1de..b4fde46fcb 100644
--- a/arch/arm/mach-meson/board-gx.c
+++ b/arch/arm/mach-meson/board-gx.c
@@ -196,8 +196,8 @@ int board_usb_init(int index, enum usb_init_type init)
for (i = 0; i < 2; i++) {
ret = generic_phy_init(_phys[i]);
if (ret) {
-   pr_err("Can't init USB PHY%d for %s\n",
-  i, ofnode_get_name(dwc2_node));
+   pr_debug("Can't init USB PHY%d for %s\n",
+i, ofnode_get_name(dwc2_node));
return ret;
}
}
@@ -205,8 +205,8 @@ int board_usb_init(int index, enum usb_init_type init)
for (i = 0; i < 2; i++) {
ret = generic_phy_power_on(_phys[i]);
if (ret) {
-   pr_err("Can't power USB PHY%d for %s\n",
-  i, ofnode_get_name(dwc2_node));
+   pr_debug("Can't power USB PHY%d for %s\n",
+i, ofnode_get_name(dwc2_node));
return ret;
}
}
-- 
2.17.1



[PATCH v3 0/7] phy: generic: add error trace to detect PHY issue in uclass

2020-07-03 Thread Patrick Delaunay


Hi,

it is a V3 serie for [1].

After rebase 2 patches are no more needed:
[v2,2/8] usb: gadget: dwc2: change trace level for phy errors managed by uclass
[v2,6/8] usb: dwc3: change trace level for phy errors managed by uclass

And I add a patch in this V3 serie:
[PATCH v3 7/7] arm: meson: change trace level for phy errors managed

Regards,

Patrick

[1] [v2,1/8] phy: generic: add error trace to detect PHY issue in uclass
http://patchwork.ozlabs.org/project/uboot/list/?series=159187=*

Changes in v3:
- rebase on next branch
- removed added dm/device_compat.h include after rebase
- simplify test on ops presence after Marek review
- add update for mach-meson board-gx: new generic_phy API usage

Changes in v2:
- Rebase and add include dm/device_compat.h
- Added patch after rebase: new generic_phy API usage

Patrick Delaunay (7):
  phy: generic: add error trace to detect PHY issue in uclass
  board: sunxi: change trace level for phy errors managed by uclass
  usb: host: ohci: change trace level for phy errors managed by uclass
  usb: host: ehci-hcd: change trace level for phy errors managed by
uclass
  ata: dwc-ahci: change trace level for phy errors managed by uclass
  usb: musb-new: sunxi: change trace level for phy errors managed by
uclass
  arm: meson: change trace level for phy errors managed by uclass

 arch/arm/mach-meson/board-gx.c  |  8 +++---
 board/sunxi/board.c |  2 +-
 drivers/ata/dwc_ahci.c  |  4 +--
 drivers/phy/phy-uclass.c| 45 +
 drivers/usb/host/ehci-hcd.c |  8 +++---
 drivers/usb/host/ohci-generic.c |  8 +++---
 drivers/usb/musb-new/sunxi.c|  8 +++---
 7 files changed, 59 insertions(+), 24 deletions(-)

-- 
2.17.1



[PATCH v3 6/7] usb: musb-new: sunxi: change trace level for phy errors managed by uclass

2020-07-03 Thread Patrick Delaunay
As the error message is now displayed by generic phy functions,
the dev_err/pr_err can be change to dev_dbg/pr_debug.

Signed-off-by: Patrick Delaunay 
---

(no changes since v2)

Changes in v2:
- Added patch after rebase: new generic_phy API usage

 drivers/usb/musb-new/sunxi.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 53c336fc3f..06a55bf6ee 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -257,7 +257,7 @@ static int sunxi_musb_enable(struct musb *musb)
 
ret = generic_phy_power_on(>phy);
if (ret) {
-   pr_err("failed to power on USB PHY\n");
+   pr_debug("failed to power on USB PHY\n");
return ret;
}
}
@@ -281,7 +281,7 @@ static void sunxi_musb_disable(struct musb *musb)
if (is_host_enabled(musb)) {
ret = generic_phy_power_off(>phy);
if (ret) {
-   pr_err("failed to power off USB PHY\n");
+   pr_debug("failed to power off USB PHY\n");
return;
}
}
@@ -315,7 +315,7 @@ static int sunxi_musb_init(struct musb *musb)
 
ret = generic_phy_init(>phy);
if (ret) {
-   dev_err(dev, "failed to init USB PHY\n");
+   dev_dbg(dev, "failed to init USB PHY\n");
goto err_rst;
}
 
@@ -352,7 +352,7 @@ static int sunxi_musb_exit(struct musb *musb)
if (generic_phy_valid(>phy)) {
ret = generic_phy_exit(>phy);
if (ret) {
-   dev_err(dev, "failed to power off usb phy\n");
+   dev_dbg(dev, "failed to power off usb phy\n");
return ret;
}
}
-- 
2.17.1



[PATCH v3 1/7] phy: generic: add error trace to detect PHY issue in uclass

2020-07-03 Thread Patrick Delaunay
Add an error trace for PHY errors directly in generic phy
functions provided by PHY uclass.

Signed-off-by: Patrick Delaunay 
---

This patch is requested by Marek Vasut to avoid code duplication
in usb host serie for dwc2:

See http://patchwork.ozlabs.org/patch/1176048/#2297595
[U-Boot,RESEND,1/5] usb: host: dwc2: add phy support


Changes in v3:
- rebase on next branch
- removed added dm/device_compat.h include after rebase
- simplify test on ops presence after Marek review

Changes in v2:
- Rebase and add include dm/device_compat.h

 drivers/phy/phy-uclass.c | 45 +++-
 1 file changed, 40 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index db7f39cd0b..8f456f33d2 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -117,56 +117,91 @@ int generic_phy_get_by_name(struct udevice *dev, const 
char *phy_name,
 int generic_phy_init(struct phy *phy)
 {
struct phy_ops const *ops;
+   int ret;
 
if (!generic_phy_valid(phy))
return 0;
ops = phy_dev_ops(phy->dev);
+   if (!ops->init)
+   return 0;
+   ret = ops->init(phy);
+   if (ret)
+   dev_err(phy->dev, "PHY: Failed to init %s: %d.\n",
+   phy->dev->name, ret);
 
-   return ops->init ? ops->init(phy) : 0;
+   return ret;
 }
 
 int generic_phy_reset(struct phy *phy)
 {
struct phy_ops const *ops;
+   int ret;
 
if (!generic_phy_valid(phy))
return 0;
ops = phy_dev_ops(phy->dev);
+   if (!ops->reset)
+   return 0;
+   ret = ops->reset(phy);
+   if (ret)
+   dev_err(phy->dev, "PHY: Failed to reset %s: %d.\n",
+   phy->dev->name, ret);
 
-   return ops->reset ? ops->reset(phy) : 0;
+   return ret;
 }
 
 int generic_phy_exit(struct phy *phy)
 {
struct phy_ops const *ops;
+   int ret;
 
if (!generic_phy_valid(phy))
return 0;
ops = phy_dev_ops(phy->dev);
+   if (!ops->exit)
+   return 0;
+   ret = ops->exit(phy);
+   if (ret)
+   dev_err(phy->dev, "PHY: Failed to exit %s: %d.\n",
+   phy->dev->name, ret);
 
-   return ops->exit ? ops->exit(phy) : 0;
+   return ret;
 }
 
 int generic_phy_power_on(struct phy *phy)
 {
struct phy_ops const *ops;
+   int ret;
 
if (!generic_phy_valid(phy))
return 0;
ops = phy_dev_ops(phy->dev);
+   if (!ops->power_on)
+   return 0;
+   ret = ops->power_on(phy);
+   if (ret)
+   dev_err(phy->dev, "PHY: Failed to power on %s: %d.\n",
+   phy->dev->name, ret);
 
-   return ops->power_on ? ops->power_on(phy) : 0;
+   return ret;
 }
 
 int generic_phy_power_off(struct phy *phy)
 {
struct phy_ops const *ops;
+   int ret;
 
if (!generic_phy_valid(phy))
return 0;
ops = phy_dev_ops(phy->dev);
+   if (!ops->power_off)
+   return 0;
+   ret = ops->power_off(phy);
+   if (ret)
+   dev_err(phy->dev, "PHY: Failed to power off %s: %d.\n",
+   phy->dev->name, ret);
 
-   return ops->power_off ? ops->power_off(phy) : 0;
+   return ret;
 }
 
 int generic_phy_get_bulk(struct udevice *dev, struct phy_bulk *bulk)
-- 
2.17.1



[PATCH v3 4/7] usb: host: ehci-hcd: change trace level for phy errors managed by uclass

2020-07-03 Thread Patrick Delaunay
As the error message is now displayed by generic phy functions,
the pr_err can be change to pr_debug.

Signed-off-by: Patrick Delaunay 
---

(no changes since v1)

 drivers/usb/host/ehci-hcd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index f79f06320b..8933f60843 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1762,13 +1762,13 @@ int ehci_setup_phy(struct udevice *dev, struct phy 
*phy, int index)
} else {
ret = generic_phy_init(phy);
if (ret) {
-   dev_err(dev, "failed to init usb phy\n");
+   dev_dbg(dev, "failed to init usb phy\n");
return ret;
}
 
ret = generic_phy_power_on(phy);
if (ret) {
-   dev_err(dev, "failed to power on usb phy\n");
+   dev_dbg(dev, "failed to power on usb phy\n");
return generic_phy_exit(phy);
}
}
@@ -1786,13 +1786,13 @@ int ehci_shutdown_phy(struct udevice *dev, struct phy 
*phy)
if (generic_phy_valid(phy)) {
ret = generic_phy_power_off(phy);
if (ret) {
-   dev_err(dev, "failed to power off usb phy\n");
+   dev_dbg(dev, "failed to power off usb phy\n");
return ret;
}
 
ret = generic_phy_exit(phy);
if (ret) {
-   dev_err(dev, "failed to power off usb phy\n");
+   dev_dbg(dev, "failed to power off usb phy\n");
return ret;
}
}
-- 
2.17.1



[PATCH v3 5/7] ata: dwc-ahci: change trace level for phy errors managed by uclass

2020-07-03 Thread Patrick Delaunay
As the error message is now displayed by generic phy functions,
the pr_err can be change to pr_debug.

Signed-off-by: Patrick Delaunay 
---

(no changes since v1)

 drivers/ata/dwc_ahci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/dwc_ahci.c b/drivers/ata/dwc_ahci.c
index 017650ae46..3c2a3ac201 100644
--- a/drivers/ata/dwc_ahci.c
+++ b/drivers/ata/dwc_ahci.c
@@ -62,13 +62,13 @@ static int dwc_ahci_probe(struct udevice *dev)
 
ret = generic_phy_init();
if (ret) {
-   pr_err("unable to initialize the sata phy\n");
+   pr_debug("unable to initialize the sata phy\n");
return ret;
}
 
ret = generic_phy_power_on();
if (ret) {
-   pr_err("unable to power on the sata phy\n");
+   pr_debug("unable to power on the sata phy\n");
return ret;
}
 
-- 
2.17.1



[PATCH v3 2/7] board: sunxi: change trace level for phy errors managed by uclass

2020-07-03 Thread Patrick Delaunay
As the error message is now displayed by generic phy functions,
the pr_err can be change to pr_idebug.

Signed-off-by: Patrick Delaunay 
---

(no changes since v1)

 board/sunxi/board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index f32e8f582f..f1925f032d 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -711,7 +711,7 @@ int g_dnl_board_usb_cable_connected(void)
 
ret = generic_phy_init();
if (ret) {
-   pr_err("failed to init %s USB PHY\n", dev->name);
+   pr_debug("failed to init %s USB PHY\n", dev->name);
return ret;
}
 
-- 
2.17.1



[PATCH v3 3/7] usb: host: ohci: change trace level for phy errors managed by uclass

2020-07-03 Thread Patrick Delaunay
As the error message is now displayed by generic phy functions,
the dev_err can be change to dev_dbg.

Signed-off-by: Patrick Delaunay 
---

(no changes since v1)

 drivers/usb/host/ohci-generic.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index 631711a9e8..f1e5b4e769 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -41,13 +41,13 @@ static int ohci_setup_phy(struct udevice *dev, int index)
} else {
ret = generic_phy_init(>phy);
if (ret) {
-   dev_err(dev, "failed to init usb phy\n");
+   dev_dbg(dev, "failed to init usb phy\n");
return ret;
}
 
ret = generic_phy_power_on(>phy);
if (ret) {
-   dev_err(dev, "failed to power on usb phy\n");
+   dev_dbg(dev, "failed to power on usb phy\n");
return generic_phy_exit(>phy);
}
}
@@ -63,13 +63,13 @@ static int ohci_shutdown_phy(struct udevice *dev)
if (generic_phy_valid(>phy)) {
ret = generic_phy_power_off(>phy);
if (ret) {
-   dev_err(dev, "failed to power off usb phy\n");
+   dev_dbg(dev, "failed to power off usb phy\n");
return ret;
}
 
ret = generic_phy_exit(>phy);
if (ret) {
-   dev_err(dev, "failed to power off usb phy\n");
+   dev_dbg(dev, "failed to power off usb phy\n");
return ret;
}
}
-- 
2.17.1



[PATCH] Convert CONFIG_SYS_MMCSD_FS_BOOT_PARTITION to Kconfig

2020-07-03 Thread Adam Ford
This converts the following to Kconfig:
   CONFIG_SYS_MMCSD_FS_BOOT_PARTITION

Signed-off-by: Adam Ford 

diff --git a/README b/README
index 6bac583666..b45c7b27d7 100644
--- a/README
+++ b/README
@@ -2275,10 +2275,6 @@ The following options need to be configured:
parameters from when MMC is being used in raw mode
(for falcon mode)
 
-   CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
-   Partition on the MMC to load U-Boot from when the MMC is being
-   used in fs mode
-
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
Filename to read to load U-Boot when reading from filesystem
 
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index b7d01c28fb..580bdfddc8 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -664,6 +664,13 @@ config SPL_MMC_SUPPORT
  this option to build the drivers in drivers/mmc as part of an SPL
  build.
 
+config SYS_MMCSD_FS_BOOT_PARTITION
+   int "MMC Boot Partition"
+   default 1
+   help
+ Partition on the MMC to load U-Boot from when the MMC is being
+  used in fs mode
+
 config SPL_MMC_TINY
bool "Tiny MMC framework in SPL"
depends on SPL_MMC_SUPPORT
diff --git a/include/configs/am3517_crane.h b/include/configs/am3517_crane.h
index 93b767be9d..943371d526 100644
--- a/include/configs/am3517_crane.h
+++ b/include/configs/am3517_crane.h
@@ -208,7 +208,6 @@
 #define CONFIG_SPL_BSS_START_ADDR  0x8000
 #define CONFIG_SPL_BSS_MAX_SIZE0x8 /* 512 KB */
 
-#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME"u-boot.img"
 
 /* NAND boot config */
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index 5d36a1429f..0375438a59 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -171,7 +171,6 @@
 
 /* Defines for SPL */
 
-#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME"u-boot.img"
 
 #endif /* __CONFIG_H */
diff --git a/include/configs/at91sam9m10g45ek.h 
b/include/configs/at91sam9m10g45ek.h
index e20cb5e332..b4aaf5995f 100644
--- a/include/configs/at91sam9m10g45ek.h
+++ b/include/configs/at91sam9m10g45ek.h
@@ -101,7 +101,6 @@
 #define CONFIG_SYS_SPL_MALLOC_START0x7008
 #define CONFIG_SYS_SPL_MALLOC_SIZE 0x0008
 
-#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME"u-boot.img"
 
 #elif CONFIG_NAND_BOOT
diff --git a/include/configs/at91sam9n12ek.h b/include/configs/at91sam9n12ek.h
index c6b734ffcf..ec4f8217d4 100644
--- a/include/configs/at91sam9n12ek.h
+++ b/include/configs/at91sam9n12ek.h
@@ -134,7 +134,6 @@
 #define CONFIG_SYS_MCKR_CSS0x1302
 
 #ifdef CONFIG_SD_BOOT
-#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME"u-boot.img"
 #endif
 #define CONFIG_SYS_NAND_U_BOOT_OFFS0x4
diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
index 1889450f3f..6a95b39cdb 100644
--- a/include/configs/at91sam9x5ek.h
+++ b/include/configs/at91sam9x5ek.h
@@ -107,7 +107,6 @@
 #define CONFIG_SYS_MCKR_CSS0x1302
 
 #ifdef CONFIG_SD_BOOT
-#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME"u-boot.img"
 #endif
 #define CONFIG_SYS_NAND_U_BOOT_OFFS0x4
diff --git a/include/configs/ax25-ae350.h b/include/configs/ax25-ae350.h
index 6d53f922b7..a08fd6352f 100644
--- a/include/configs/ax25-ae350.h
+++ b/include/configs/ax25-ae350.h
@@ -19,7 +19,6 @@
 #endif
 
 #ifdef CONFIG_SPL_MMC_SUPPORT
-#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME"u-boot.itb"
 #endif
 #endif
diff --git a/include/configs/capricorn-common.h 
b/include/configs/capricorn-common.h
index b57e4878ff..ed6b9a5be3 100644
--- a/include/configs/capricorn-common.h
+++ b/include/configs/capricorn-common.h
@@ -20,7 +20,6 @@
 #define CONFIG_SYS_MONITOR_LEN (1024 * 1024)
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR0x800
-#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 0
 
 #define CONFIG_SPL_LDSCRIPT"arch/arm/cpu/armv8/u-boot-spl.lds"
 #define CONFIG_SPL_STACK   0x013E000
diff --git a/include/configs/cm_t35.h b/include/configs/cm_t35.h
index b7fb6e3e70..689226886a 100644
--- a/include/configs/cm_t35.h
+++ b/include/configs/cm_t35.h
@@ -197,7 +197,6 @@
 
 /* Defines for SPL */
 
-#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME"u-boot.img"
 
 /* NAND boot config */
diff --git a/include/configs/imx6_spl.h b/include/configs/imx6_spl.h
index a223930240..ede81cca1f 100644
--- a/include/configs/imx6_spl.h
+++ b/include/configs/imx6_spl.h
@@ -55,7 +55,6 @@
 
 /* MMC support */
 #if 

Re: [PATCH 12/17] xen: pvblock: Add initial support for para-virtualized block driver

2020-07-03 Thread Anastasiia Lukianenko
Hi Heinrich,

On Thu, 2020-07-02 at 06:29 +0200, Heinrich Schuchardt wrote:
> On 7/1/20 6:29 PM, Anastasiia Lukianenko wrote:
> > From: Anastasiia Lukianenko 
> > 
> > Add initial infrastructure for Xen para-virtualized block device.
> > This includes compile-time configuration and the skeleton for
> > the future driver implementation.
> > Add new class UCLASS_PVBLOCK which is going to be a parent for
> > virtual block devices.
> 
> We already have virtual block devices: virtio_blk, efi_blk.
> 
> They work fine using the exising UCLASS_BLK. Why do we need a new
> uclass?
> 

During the implementation we had a discussion with Simon Glass on that
[1]. PVBLOCK could be just a UCLASS_BLK driver with the parent being
gd->dm_root, but in this case most of the file system/block device
commands fail to work as those expect that pvblock driver must be a
parent device and pvblock blk device must be its child to comply
to U-boot driver architecture.

When we bind a new driver [2], we need to specify it's parent. There is
no UCLASS_BLK device available at that moment, therefore it is possible
to use only a UCLASS_ROOT device, but parent and child interface types
must be the same [3].

So, then we need interface to be defined as [IF_TYPE_PVBLOCK] =
UCLASS_ROOT which doesn't seem to be right. Thereby, we created a new
UCLASS_PVBLOCK class for para-virtual block devices [4].

The driver class provides methods for accessing the "bus" and actually
implements the ops for reading and writing. But, we don't have a "bus"
or a common transport as virtio has, so we are a bit different with
that respect from the drivers you mentioned.

[1] - https://www.mail-archive.com/u-boot@lists.denx.de/msg371956.html
[2] - 
https://github.com/xen-troops/u-boot/blob/master/drivers/xen/pvblock.c#L697
[3] - 
https://github.com/xen-troops/u-boot/blob/master/drivers/block/blk-uclass.c#L124
[4] - 
https://github.com/xen-troops/u-boot/blob/master/drivers/block/blk-uclass.c#L47

> > Add new interface type IF_TYPE_PVBLOCK.
> > 
> > Implement basic driver setup by reading XenStore configuration.
> > 
> > Signed-off-by: Andrii Anisov 
> > Signed-off-by: Anastasiia Lukianenko <
> > anastasiia_lukiane...@epam.com>
> > Signed-off-by: Oleksandr Andrushchenko <
> > oleksandr_andrushche...@epam.com>
> > ---
> >  cmd/Kconfig  |   7 ++
> >  cmd/Makefile |   1 +
> >  cmd/pvblock.c|  31 
> >  common/board_r.c |  14 
> >  configs/xenguest_arm64_defconfig |   4 +
> >  disk/part.c  |   4 +
> >  drivers/Kconfig  |   2 +
> >  drivers/block/blk-uclass.c   |   2 +
> >  drivers/xen/Kconfig  |  10 +++
> >  drivers/xen/Makefile |   2 +
> >  drivers/xen/pvblock.c| 121
> > +++
> >  include/blk.h|   1 +
> >  include/configs/xenguest_arm64.h |   8 ++
> >  include/dm/uclass-id.h   |   1 +
> >  include/pvblock.h|  12 +++
> >  15 files changed, 220 insertions(+)
> >  create mode 100644 cmd/pvblock.c
> >  create mode 100644 drivers/xen/Kconfig
> >  create mode 100644 drivers/xen/pvblock.c
> >  create mode 100644 include/pvblock.h
> > 
> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > index 192b3b262f..f28576947b 100644
> > --- a/cmd/Kconfig
> > +++ b/cmd/Kconfig
> > @@ -1335,6 +1335,13 @@ config CMD_USB_MASS_STORAGE
> > help
> >   USB mass storage support
> > 
> > +config CMD_PVBLOCK
> > +   bool "Xen para-virtualized block device"
> > +   depends on XEN
> > +   select PVBLOCK
> > +   help
> > + Xen para-virtualized block device support
> > +
> >  config CMD_VIRTIO
> > bool "virtio"
> > depends on VIRTIO
> > diff --git a/cmd/Makefile b/cmd/Makefile
> > index 974ad48b0a..117284a28c 100644
> > --- a/cmd/Makefile
> > +++ b/cmd/Makefile
> > @@ -169,6 +169,7 @@ obj-$(CONFIG_CMD_DFU) += dfu.o
> >  obj-$(CONFIG_CMD_GPT) += gpt.o
> >  obj-$(CONFIG_CMD_ETHSW) += ethsw.o
> >  obj-$(CONFIG_CMD_AXI) += axi.o
> > +obj-$(CONFIG_CMD_PVBLOCK) += pvblock.o
> > 
> >  # Power
> >  obj-$(CONFIG_CMD_PMIC) += pmic.o
> > diff --git a/cmd/pvblock.c b/cmd/pvblock.c
> > new file mode 100644
> > index 00..7dbb243a74
> > --- /dev/null
> > +++ b/cmd/pvblock.c
> > @@ -0,0 +1,31 @@
> > +/*
> > + * SPDX-License-Identifier:GPL-2.0+
> 
> Please, correct the formatting.
> 
> 
https://urldefense.com/v3/__https://www.kernel.org/doc/html/latest/process/license-rules.html*license-identifier-syntax__;Iw!!GF_29dbcQIUBPA!jxsFCyOKmFzfwm6JpWhcYhyr_qGk_okiGw-S0zzuQwWAleeoT0qjgG6bmf0_OfcJMo3d-dM$
>  
> 

Ok.

> > + *
> > + * (C) Copyright 2020 EPAM Systems Inc.
> > + *
> > + * XEN para-virtualized block device support
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/* Current I/O Device  */
> > +static int pvblock_curr_device;
> > +
> > +int do_pvblock(struct cmd_tbl *cmdtp, int flag, int argc, char
> > *const argv[])
> > +{
> > +   

[PATCH] configs: Remove dead CONFIG options

2020-07-03 Thread Adam Ford
BOOTP_DEFAULT is defined in several boards, but this config
option is never checked or used.

This patch removes this config option from config files and
the whitelist.txt

Signed-off-by: Adam Ford 

diff --git a/include/configs/am335x_shc.h b/include/configs/am335x_shc.h
index c88067c012..7240ff6901 100644
--- a/include/configs/am335x_shc.h
+++ b/include/configs/am335x_shc.h
@@ -239,7 +239,6 @@
 #undef CONFIG_TIMER
 #endif
 
-#define CONFIG_BOOTP_DEFAULT
 #define CONFIG_NET_RETRY_COUNT 10
 
 /* I2C configuration */
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index a0d815db32..5d36a1429f 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -34,7 +34,6 @@
 /* I2C */
 
 /* Ethernet */
-#define CONFIG_BOOTP_DEFAULT
 #define CONFIG_NET_RETRY_COUNT 10
 
 /* Board NAND Info. */
diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h
index 6788cb01f6..8355b4abc0 100644
--- a/include/configs/am43xx_evm.h
+++ b/include/configs/am43xx_evm.h
@@ -192,7 +192,6 @@
 
 #ifndef CONFIG_SPL_BUILD
 /* CPSW Ethernet */
-#define CONFIG_BOOTP_DEFAULT
 #define CONFIG_NET_RETRY_COUNT 10
 #endif
 
diff --git a/include/configs/cm_t43.h b/include/configs/cm_t43.h
index 857a5d86dd..73205d0de6 100644
--- a/include/configs/cm_t43.h
+++ b/include/configs/cm_t43.h
@@ -43,7 +43,6 @@
 50, 51, 52, 53, 54, 55, 56, 57, }
 
 /* CPSW Ethernet support */
-#define CONFIG_BOOTP_DEFAULT
 #define CONFIG_SYS_RX_ETH_BUFFER   64
 
 /* USB support */
diff --git a/include/configs/omapl138_lcdk.h b/include/configs/omapl138_lcdk.h
index 6d552b09d4..a37359e6c3 100644
--- a/include/configs/omapl138_lcdk.h
+++ b/include/configs/omapl138_lcdk.h
@@ -152,7 +152,6 @@
  * Network & Ethernet Configuration
  */
 #ifdef CONFIG_DRIVER_TI_EMAC
-#define CONFIG_BOOTP_DEFAULT
 #define CONFIG_NET_RETRY_COUNT 10
 #endif
 
diff --git a/include/configs/siemens-am33x-common.h 
b/include/configs/siemens-am33x-common.h
index fc5a8c672b..e48283f685 100644
--- a/include/configs/siemens-am33x-common.h
+++ b/include/configs/siemens-am33x-common.h
@@ -165,7 +165,6 @@
  * 0x442000 - 0x80 : Userland
  */
 
-#define CONFIG_BOOTP_DEFAULT
 #define CONFIG_NET_RETRY_COUNT 10
 
 /* NAND support */
diff --git a/include/configs/ti_armv7_keystone2.h 
b/include/configs/ti_armv7_keystone2.h
index cb20dc01b7..cfc2be7b9f 100644
--- a/include/configs/ti_armv7_keystone2.h
+++ b/include/configs/ti_armv7_keystone2.h
@@ -66,7 +66,6 @@
 #define CONFIG_SYS_SPI_CLK ks_clk_get_rate(KS2_CLK1_6)
 
 /* Network Configuration */
-#define CONFIG_BOOTP_DEFAULT
 #define CONFIG_NET_RETRY_COUNT 32
 #define CONFIG_SYS_SGMII_REFCLK_MHZ312
 #define CONFIG_SYS_SGMII_LINERATE_MHZ  1250
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 131678ffb7..b6165c1361 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -126,7 +126,6 @@ CONFIG_BOOTMODE
 CONFIG_BOOTP_
 CONFIG_BOOTP_BOOTFILE
 CONFIG_BOOTP_BOOTFILESIZE
-CONFIG_BOOTP_DEFAULT
 CONFIG_BOOTP_DHCP_REQUEST_DELAY
 CONFIG_BOOTP_ID_CACHE_SIZE
 CONFIG_BOOTP_MAY_FAIL
-- 
2.25.1



Re: [PATCH] rockchip: rk3288: Add OF board setup

2020-07-03 Thread Jagan Teki
On Fri, Jul 3, 2020 at 6:09 PM Robin Murphy  wrote:
>
> On 2020-07-03 11:10, Jagan Teki wrote:
> > On Thu, Jul 2, 2020 at 7:26 PM Robin Murphy  wrote:
> >>
> >> On 2020-07-02 09:48, Jagan Teki wrote:
> >>> The new rk3288 revision rk3288w has some changes with respect
> >>> to legacy rk3288 like hclk_vio and usb host0 ohci.
> >>>
> >>> In order to work these on the same in Linux kernel update the
> >>> compatible the root compatible with rockchip,rk3288w before
> >>> booting.
> >>>
> >>> So, this support during of board setup code of rk3288.
> >>>
> >>> Signed-off-by: Jagan Teki 
> >>> ---
> >>>arch/arm/mach-rockchip/Kconfig |  1 +
> >>>arch/arm/mach-rockchip/rk3288/rk3288.c | 26 ++
> >>>2 files changed, 27 insertions(+)
> >>>
> >>> diff --git a/arch/arm/mach-rockchip/Kconfig 
> >>> b/arch/arm/mach-rockchip/Kconfig
> >>> index b1008a5058..822d8d4e9c 100644
> >>> --- a/arch/arm/mach-rockchip/Kconfig
> >>> +++ b/arch/arm/mach-rockchip/Kconfig
> >>> @@ -98,6 +98,7 @@ config ROCKCHIP_RK322X
> >>>config ROCKCHIP_RK3288
> >>>bool "Support Rockchip RK3288"
> >>>select CPU_V7A
> >>> + select OF_BOARD_SETUP
> >>>select SUPPORT_SPL
> >>>select SPL
> >>>select SUPPORT_TPL
> >>> diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c 
> >>> b/arch/arm/mach-rockchip/rk3288/rk3288.c
> >>> index 804abe8a1b..8a682675e6 100644
> >>> --- a/arch/arm/mach-rockchip/rk3288/rk3288.c
> >>> +++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
> >>> @@ -115,6 +115,32 @@ int rk_board_late_init(void)
> >>>return rk3288_board_late_init();
> >>>}
> >>>
> >>> +#ifdef CONFIG_OF_BOARD_SETUP
> >>> +
> >>> +#define RK3288_HDMI_PHYS 0xff98
> >>> +#define RK3288W_HDMI_REV 0x1A
> >>> +#define HDMI_CONFIG0_ID  0x04
> >>> +
> >>> +int ft_board_setup(void *blob, bd_t *bd)
> >>> +{
> >>> + u8 config0;
> >>> + int ret;
> >>> +
> >>> + config0 = readb(RK3288_HDMI_PHYS + HDMI_CONFIG0_ID);
> >>> + if (config0 == RK3288W_HDMI_REV) {
> >>> + ret = fdt_setprop_string(blob, 0,
> >>> +  "compatible", "rockchip,rk3288w");
> >>
> >> Does this end up replacing the entire top-level compatible property?
> >> i.e. from:
> >>
> >>  compatible = "vendor,board\0rockchip,rk3288";
> >>
> >> to just:
> >>
> >>  compatible = "rockchip,rk3288w";
> >>
> >> If so, that's a bit of a problem for various drivers that care about the
> >> actual board compatible rather than the SoC.
> >
> > Yes, It looks replacing the entire compatible. I think the root
> > compatible is mostly untouchable because of this reason.
> >
> > But, if we skip the root compatible and trying to replace individual
> > nodes for W revision then it requires extra registration code on in
> > the Linux drivers like Linux clock driver is registering the clock
> > with rockchip,rk3288-cru but updating this compatible with
> > rockchip,rk3288w-cru will require another registration code. Having
> > common rockchip,rk3288w can be possible to check any code in the tree.
>
> Right, it's definitely reasonable to update the top-level SoC
> compatible, we just need to be prepared to deal with a whole string list
> here. It looks like libfdt doesn't offer any nice helpers for
> inserting/removing/updating in string lists, but given that the SoC
> should be the last entry here we might be able to cheat a bit - just get
> the whole raw property, check that the final characters are exactly
> "rockchip,rk3288", and if so append a "w" to the end and write it back.

Look like exiting fdt helper does print the compatible up to \0
instead of whole root compatible, at least I have checked with
fdt_getpro and fdt_get_property.


[PATCH] Convert CONFIG_BOOTP_SEND_HOSTNAME to Kconfig

2020-07-03 Thread Adam Ford
This converts the following to Kconfig:
   CONFIG_BOOTP_SEND_HOSTNAME

Signed-off-by: Adam Ford 

diff --git a/README b/README
index 60d8e77256..6bac583666 100644
--- a/README
+++ b/README
@@ -1427,7 +1427,6 @@ The following options need to be configured:
 
CONFIG_BOOTP_NISDOMAIN
CONFIG_BOOTP_BOOTFILESIZE
-   CONFIG_BOOTP_SEND_HOSTNAME
CONFIG_BOOTP_NTPSERVER
CONFIG_BOOTP_TIMEOFFSET
CONFIG_BOOTP_VENDOREX
@@ -1442,13 +1441,6 @@ The following options need to be configured:
to Link-local IP address configuration if the DHCP server
is not available.
 
-   CONFIG_BOOTP_SEND_HOSTNAME - Some DHCP servers are capable
-   to do a dynamic update of a DNS server. To do this, they
-   need the hostname of the DHCP requester.
-   If CONFIG_BOOTP_SEND_HOSTNAME is defined, the content
-   of the "hostname" environment variable is passed as
-   option 12 to the DHCP server.
-
CONFIG_BOOTP_DHCP_REQUEST_DELAY
 
A 32bit value in microseconds for a delay between
diff --git a/configs/am335x_baltos_defconfig b/configs/am335x_baltos_defconfig
index 4e6a3ca446..57133a7059 100644
--- a/configs/am335x_baltos_defconfig
+++ b/configs/am335x_baltos_defconfig
@@ -48,6 +48,7 @@ CONFIG_DEFAULT_DEVICE_TREE="am335x-baltos"
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_SYS_OMAP24_I2C_SPEED=1000
 CONFIG_DM_MMC=y
diff --git a/configs/am335x_boneblack_vboot_defconfig 
b/configs/am335x_boneblack_vboot_defconfig
index 984c33c42f..104e7b5b51 100644
--- a/configs/am335x_boneblack_vboot_defconfig
+++ b/configs/am335x_boneblack_vboot_defconfig
@@ -37,6 +37,7 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_BOOTP_SEND_HOSTNAME=y
 # CONFIG_SPL_BLK is not set
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_DFU_MMC=y
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 2030cd3610..d530b9fe45 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -42,6 +42,7 @@ CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_SPL_ENV_IS_NOWHERE=y
+CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_CLK=y
 CONFIG_CLK_CDCE9XX=y
diff --git a/configs/am335x_guardian_defconfig 
b/configs/am335x_guardian_defconfig
index 535a6b4d13..6a5e93b627 100644
--- a/configs/am335x_guardian_defconfig
+++ b/configs/am335x_guardian_defconfig
@@ -66,6 +66,7 @@ CONFIG_ENV_IS_IN_NAND=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SPL_ENV_IS_NOWHERE=y
+CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_SPL_DM=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_LED=y
diff --git a/configs/am335x_hs_evm_defconfig b/configs/am335x_hs_evm_defconfig
index 31ffbf063a..5d26e675d9 100644
--- a/configs/am335x_hs_evm_defconfig
+++ b/configs/am335x_hs_evm_defconfig
@@ -39,6 +39,7 @@ CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack 
am335x-evmsk am335x-bone
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_CLK=y
 CONFIG_CLK_CDCE9XX=y
diff --git a/configs/am335x_hs_evm_uart_defconfig 
b/configs/am335x_hs_evm_uart_defconfig
index dfe506f9ed..1007afdba5 100644
--- a/configs/am335x_hs_evm_uart_defconfig
+++ b/configs/am335x_hs_evm_uart_defconfig
@@ -41,6 +41,7 @@ CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack 
am335x-evmsk am335x-bone
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_CLK=y
 CONFIG_CLK_CDCE9XX=y
diff --git a/configs/am335x_igep003x_defconfig 
b/configs/am335x_igep003x_defconfig
index 80d56eb1dd..eeec15ec28 100644
--- a/configs/am335x_igep003x_defconfig
+++ b/configs/am335x_igep003x_defconfig
@@ -67,6 +67,7 @@ CONFIG_ENV_UBI_VOLUME="config"
 CONFIG_ENV_UBI_VOLUME_REDUND="config_r"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_MTD=y
diff --git a/configs/am335x_shc_defconfig b/configs/am335x_shc_defconfig
index e45bbe0862..7039a892e6 100644
--- a/configs/am335x_shc_defconfig
+++ b/configs/am335x_shc_defconfig
@@ -49,6 +49,7 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_PHY_ADDR_ENABLE=y
diff --git a/configs/am335x_shc_ict_defconfig b/configs/am335x_shc_ict_defconfig
index 9df1f11848..960af25493 100644
--- a/configs/am335x_shc_ict_defconfig
+++ 

[PATCH] Convert CONFIG_BOOTP_DNS2 to Kconfig

2020-07-03 Thread Adam Ford
The Kconfig already has BOOTP_DNS2, but not all boards have been
converted. This finishes converting the following to Kconfig:
   CONFIG_BOOTP_DNS2

Signed-off-by: Adam Ford 

diff --git a/configs/am335x_baltos_defconfig b/configs/am335x_baltos_defconfig
index 326882908b..4e6a3ca446 100644
--- a/configs/am335x_baltos_defconfig
+++ b/configs/am335x_baltos_defconfig
@@ -37,6 +37,7 @@ CONFIG_CMD_NAND=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0"
diff --git a/configs/am335x_boneblack_vboot_defconfig 
b/configs/am335x_boneblack_vboot_defconfig
index 9220fc7d15..984c33c42f 100644
--- a/configs/am335x_boneblack_vboot_defconfig
+++ b/configs/am335x_boneblack_vboot_defconfig
@@ -29,6 +29,7 @@ CONFIG_AUTOBOOT_STOP_STR=" "
 CONFIG_CMD_SPL=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_DNS2=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="am335x-boneblack"
 CONFIG_ENV_OVERWRITE=y
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 2c1135dd2b..2030cd3610 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -30,6 +30,7 @@ CONFIG_CMD_SPL_NAND_OFS=0x0008
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_NAND=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=nand.0"
 
CONFIG_MTDPARTS_DEFAULT="mtdparts=nand.0:128k(NAND.SPL),128k(NAND.SPL.backup1),128k(NAND.SPL.backup2),128k(NAND.SPL.backup3),256k(NAND.u-boot-spl-os),1m(NAND.u-boot),128k(NAND.u-boot-env),128k(NAND.u-boot-env.backup1),8m(NAND.kernel),-(NAND.file-system)"
diff --git a/configs/am335x_guardian_defconfig 
b/configs/am335x_guardian_defconfig
index 5b212d31a5..535a6b4d13 100644
--- a/configs/am335x_guardian_defconfig
+++ b/configs/am335x_guardian_defconfig
@@ -50,6 +50,7 @@ CONFIG_CMD_MTD=y
 CONFIG_CMD_NAND=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_DNS2=y
 # CONFIG_CMD_LED is not set
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_MTDPARTS=y
diff --git a/configs/am335x_hs_evm_defconfig b/configs/am335x_hs_evm_defconfig
index f90bcc5f59..31ffbf063a 100644
--- a/configs/am335x_hs_evm_defconfig
+++ b/configs/am335x_hs_evm_defconfig
@@ -28,6 +28,7 @@ CONFIG_SPL_NAND_BASE=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_NAND=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=nand.0"
 
CONFIG_MTDPARTS_DEFAULT="mtdparts=nand.0:128k(NAND.SPL),128k(NAND.SPL.backup1),128k(NAND.SPL.backup2),128k(NAND.SPL.backup3),256k(NAND.u-boot-spl-os),1m(NAND.u-boot),128k(NAND.u-boot-env),128k(NAND.u-boot-env.backup1),8m(NAND.kernel),-(NAND.file-system)"
diff --git a/configs/am335x_hs_evm_uart_defconfig 
b/configs/am335x_hs_evm_uart_defconfig
index 5cbb8091a2..dfe506f9ed 100644
--- a/configs/am335x_hs_evm_uart_defconfig
+++ b/configs/am335x_hs_evm_uart_defconfig
@@ -30,6 +30,7 @@ CONFIG_SPL_NAND_BASE=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_NAND=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=nand.0"
 
CONFIG_MTDPARTS_DEFAULT="mtdparts=nand.0:128k(NAND.SPL),128k(NAND.SPL.backup1),128k(NAND.SPL.backup2),128k(NAND.SPL.backup3),256k(NAND.u-boot-spl-os),1m(NAND.u-boot),128k(NAND.u-boot-env),128k(NAND.u-boot-env.backup1),8m(NAND.kernel),-(NAND.file-system)"
diff --git a/configs/am335x_igep003x_defconfig 
b/configs/am335x_igep003x_defconfig
index 9787f2a2b5..80d56eb1dd 100644
--- a/configs/am335x_igep003x_defconfig
+++ b/configs/am335x_igep003x_defconfig
@@ -50,6 +50,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_NAND=y
 CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0"
diff --git a/configs/am335x_shc_defconfig b/configs/am335x_shc_defconfig
index 7774b61635..e45bbe0862 100644
--- a/configs/am335x_shc_defconfig
+++ b/configs/am335x_shc_defconfig
@@ -40,6 +40,7 @@ CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 # CONFIG_CMD_PINMUX is not set
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_CACHE=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="am335x-shc"
diff --git a/configs/am335x_shc_ict_defconfig b/configs/am335x_shc_ict_defconfig
index 35ffd81e6c..9df1f11848 100644
--- a/configs/am335x_shc_ict_defconfig
+++ b/configs/am335x_shc_ict_defconfig
@@ -41,6 +41,7 @@ CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 # CONFIG_CMD_PINMUX is not set
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_CACHE=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="am335x-shc"
diff --git a/configs/am335x_shc_netboot_defconfig 
b/configs/am335x_shc_netboot_defconfig
index 10bbb1520a..96c40485e1 100644
--- a/configs/am335x_shc_netboot_defconfig
+++ b/configs/am335x_shc_netboot_defconfig
@@ -42,6 +42,7 @@ CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 # CONFIG_CMD_PINMUX is not set
 # CONFIG_CMD_SETEXPR is 

Re: [PATCH 05/17] xen: Port Xen hypervizor related code from mini-os

2020-07-03 Thread Julien Grall

Hi,

On 03/07/2020 13:21, Anastasiia Lukianenko wrote:

Hi Julien,

On Wed, 2020-07-01 at 18:46 +0100, Julien Grall wrote:

Title: s/hypervizor/hypervisor/


Thank you for pointing :) I will fix it in the next version.



On 01/07/2020 17:29, Anastasiia Lukianenko wrote:

From: Oleksandr Andrushchenko 

Port hypervizor related code from mini-os. Update essential


Ditto.

But I would be quite cautious to import code from mini-OS in order
to
support Arm. The port has always been broken and from a look below
needs
to be refined for Arm.


We were referencing the code of Mini-OS from [1] by Huang Shijie and
Volodymyr Babchuk which is for ARM64, so we hope this part should be
ok.

[1] https://github.com/zyzii/mini-os.git


Well, that's not part of the official port. It would have been nice to 
at least mention that in somewhere in the series.



+   return result;
+}


I can understand why we implement sync_* helpers as AFAICT the
generic
helpers are not SMP safe. However...


+
+#define xchg(ptr, v)   __atomic_exchange_n(ptr, v,
__ATOMIC_SEQ_CST)
+#define xchg(ptr, v)   __atomic_exchange_n(ptr, v,
__ATOMIC_SEQ_CST)
+
+#define mb()   dsb()
+#define rmb()  dsb()
+#define wmb()  dsb()
+#define __iormb()  dmb()
+#define __iowmb()  dmb()


Why do you need to re-implement the barriers?


Indeed, we do not need to do this.
I will fix it in the next version.




+#define xen_mb()   mb()
+#define xen_rmb()  rmb()
+#define xen_wmb()  wmb()
+
+#define smp_processor_id() 0


Shouldn't this be common?


Currently it is only used by Xen and we are not sure if
any other entity will use it, but we can put that into
arch/arm/include/asm/io.h
I looked at the usage in Xen and don't really think it would help in any 
way to get the code SMP ready. Does U-boot will enable Xen features on 
secondary CPUs? If not, then I would recomment to just drop it.


[...]




+
+#endif
diff --git a/common/board_r.c b/common/board_r.c
index fa57fa9b69..fd36edb4e5 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -56,6 +56,7 @@
   #include 
   #include 
   #include 
+#include 


Do we want to include it for other boards?


For now, we do not have a plan and resources to support
anything other than what we need. Therefore only ARM64.


I think you misunderstood my comment here. The file seems to be common 
but you include xen.h unconditionnally. Is it really what you want to do?



+/*
+ * Shared page for communicating with the hypervisor.
+ * Events flags go here, for example.
+ */
+struct shared_info *HYPERVISOR_shared_info;
+
+#ifndef CONFIG_PARAVIRT


Is there any plan to support this on x86?


For now, we do not have a plan and resources to support
anything other
than what we need. Therefore only ARM64.


Ok. I doubt that one will want to use U-boot on PV x86. So I would 
recommend to drop anything related to CONFIG_PARAVIRT.



+{
+   struct xen_hvm_param xhv;
+   int ret;


I don't think there is a guarantee that your cache is going to be
clean
when writing xhv. So you likely want to add a
invalidate_dcache_range()
before writing it.


Thank you for advice.
Ah, so we need something like:

...
invalidate_dcache_range((unsigned long),
(unsigned long) + sizeof(xhv));
xhv.domid = DOMID_SELF;
xhv.index = idx;
invalidate_dcache_range((unsigned long),
(unsigned long) + sizeof(xhv));
...


Right, this would indeed be safer.

[...]


+void do_hypervisor_callback(struct pt_regs *regs)
+{
+   unsigned long l1, l2, l1i, l2i;
+   unsigned int port;
+   int cpu = 0;
+   struct shared_info *s = HYPERVISOR_shared_info;
+   struct vcpu_info *vcpu_info = >vcpu_info[cpu];
+
+   in_callback = 1;
+
+   vcpu_info->evtchn_upcall_pending = 0;
+   /* NB x86. No need for a barrier here -- XCHG is a barrier on
x86. */
+#if !defined(__i386__) && !defined(__x86_64__)
+   /* Clear master flag /before/ clearing selector flag. */
+   wmb();
+#endif
+   l1 = xchg(_info->evtchn_pending_sel, 0);
+
+   while (l1 != 0) {
+   l1i = __ffs(l1);
+   l1 &= ~(1UL << l1i);
+
+   while ((l2 = active_evtchns(cpu, s, l1i)) != 0) {
+   l2i = __ffs(l2);
+   l2 &= ~(1UL << l2i);
+
+   port = (l1i * (sizeof(unsigned long) * 8)) +
l2i;
+   /* TODO: handle new event: do_event(port,
regs); */
+   /* Suppress -Wunused-but-set-variable */
+   (void)(port);
+   }
+   }


You likely want a memory barrier here as otherwise in_callback could
be
written/seen before the loop end.



We are not running in a multi-threaded environment, so probably
in_callback should be fine as is?


It really depends on how you plan to use in_callback. If you want to use 
it in interrupt context to know whether you are dealing with a callback, 
then you will want a compiler barrier.  

[PATCH] Convert CONFIG_DRIVER_TI_EMAC_USE_RMII to Kconfig

2020-07-03 Thread Adam Ford
This converts the following to Kconfig:
   CONFIG_DRIVER_TI_EMAC_USE_RMII

Signed-off-by: Adam Ford 

diff --git a/configs/am3517_evm_defconfig b/configs/am3517_evm_defconfig
index 58fb91c1c5..a78a596d4d 100644
--- a/configs/am3517_evm_defconfig
+++ b/configs/am3517_evm_defconfig
@@ -62,6 +62,7 @@ CONFIG_SYS_NAND_U_BOOT_OFFS=0x8
 CONFIG_DM_ETH=y
 CONFIG_MII=y
 CONFIG_DRIVER_TI_EMAC=y
+CONFIG_DRIVER_TI_EMAC_USE_RMII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_SINGLE=y
 CONFIG_DM_PMIC=y
diff --git a/drivers/net/ti/Kconfig b/drivers/net/ti/Kconfig
index ecf642de10..f2dbbd0128 100644
--- a/drivers/net/ti/Kconfig
+++ b/drivers/net/ti/Kconfig
@@ -14,6 +14,12 @@ config DRIVER_TI_EMAC
help
   Support for davinci emac
 
+config DRIVER_TI_EMAC_USE_RMII
+   depends on DRIVER_TI_EMAC
+   bool "Use RMII"
+   help
+ Configure the TI EMAC driver to use RMII
+
 config DRIVER_TI_KEYSTONE_NET
bool "TI Keystone 2 Ethernet"
help
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index 18d0568287..f61bb1d44d 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -34,7 +34,6 @@
 /* I2C */
 
 /* Ethernet */
-#define CONFIG_DRIVER_TI_EMAC_USE_RMII
 #define CONFIG_BOOTP_DEFAULT
 #define CONFIG_BOOTP_DNS2
 #define CONFIG_BOOTP_SEND_HOSTNAME
diff --git a/include/configs/omapl138_lcdk.h b/include/configs/omapl138_lcdk.h
index 114c773fd9..2d588d9003 100644
--- a/include/configs/omapl138_lcdk.h
+++ b/include/configs/omapl138_lcdk.h
@@ -152,7 +152,6 @@
  * Network & Ethernet Configuration
  */
 #ifdef CONFIG_DRIVER_TI_EMAC
-#undef CONFIG_DRIVER_TI_EMAC_USE_RMII
 #define CONFIG_BOOTP_DEFAULT
 #define CONFIG_BOOTP_DNS2
 #define CONFIG_BOOTP_SEND_HOSTNAME
diff --git a/include/configs/tam3517-common.h b/include/configs/tam3517-common.h
index b127a774ac..31c582bde6 100644
--- a/include/configs/tam3517-common.h
+++ b/include/configs/tam3517-common.h
@@ -118,7 +118,6 @@
  * ethernet support, EMAC
  *
  */
-#define CONFIG_DRIVER_TI_EMAC_USE_RMII
 #define CONFIG_BOOTP_DNS2
 #define CONFIG_BOOTP_SEND_HOSTNAME
 #define CONFIG_NET_RETRY_COUNT 10
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 61d0d8cc6f..9a7f0fba0c 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -341,7 +341,6 @@ CONFIG_DRIVER_DM9000
 CONFIG_DRIVER_EP93XX_MAC
 CONFIG_DRIVER_NE2000
 CONFIG_DRIVER_NE2000_BASE
-CONFIG_DRIVER_TI_EMAC_USE_RMII
 CONFIG_DSP_CLUSTER_START
 CONFIG_DUOVERO
 CONFIG_DWC2_DFLT_SPEED_FULL
-- 
2.25.1



Re: [PATCH 12/17] xen: pvblock: Add initial support for para-virtualized block driver

2020-07-03 Thread Anastasiia Lukianenko
Hi Heinrich,

On Thu, 2020-07-02 at 06:17 +0200, Heinrich Schuchardt wrote:
> On 7/1/20 6:29 PM, Anastasiia Lukianenko wrote:
> > From: Anastasiia Lukianenko 
> > 
> > Add initial infrastructure for Xen para-virtualized block device.
> > This includes compile-time configuration and the skeleton for
> > the future driver implementation.
> > Add new class UCLASS_PVBLOCK which is going to be a parent for
> > virtual block devices.
> > Add new interface type IF_TYPE_PVBLOCK.
> > 
> > Implement basic driver setup by reading XenStore configuration.
> 
> Please, add documenation for the board in doc/board/.

Ok, will add.

> 
> > 
> > Signed-off-by: Andrii Anisov 
> > Signed-off-by: Anastasiia Lukianenko <
> > anastasiia_lukiane...@epam.com>
> > Signed-off-by: Oleksandr Andrushchenko <
> > oleksandr_andrushche...@epam.com>
> > ---
> >  cmd/Kconfig  |   7 ++
> >  cmd/Makefile |   1 +
> >  cmd/pvblock.c|  31 
> >  common/board_r.c |  14 
> >  configs/xenguest_arm64_defconfig |   4 +
> >  disk/part.c  |   4 +
> >  drivers/Kconfig  |   2 +
> >  drivers/block/blk-uclass.c   |   2 +
> >  drivers/xen/Kconfig  |  10 +++
> >  drivers/xen/Makefile |   2 +
> >  drivers/xen/pvblock.c| 121
> > +++
> >  include/blk.h|   1 +
> >  include/configs/xenguest_arm64.h |   8 ++
> >  include/dm/uclass-id.h   |   1 +
> >  include/pvblock.h|  12 +++
> >  15 files changed, 220 insertions(+)
> >  create mode 100644 cmd/pvblock.c
> >  create mode 100644 drivers/xen/Kconfig
> >  create mode 100644 drivers/xen/pvblock.c
> >  create mode 100644 include/pvblock.h
> > 
> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > index 192b3b262f..f28576947b 100644
> > --- a/cmd/Kconfig
> > +++ b/cmd/Kconfig
> > @@ -1335,6 +1335,13 @@ config CMD_USB_MASS_STORAGE
> > help
> >   USB mass storage support
> > 
> > +config CMD_PVBLOCK
> > +   bool "Xen para-virtualized block device"
> > +   depends on XEN
> > +   select PVBLOCK
> > +   help
> > + Xen para-virtualized block device support
> > +
> >  config CMD_VIRTIO
> > bool "virtio"
> > depends on VIRTIO
> > diff --git a/cmd/Makefile b/cmd/Makefile
> > index 974ad48b0a..117284a28c 100644
> > --- a/cmd/Makefile
> > +++ b/cmd/Makefile
> > @@ -169,6 +169,7 @@ obj-$(CONFIG_CMD_DFU) += dfu.o
> >  obj-$(CONFIG_CMD_GPT) += gpt.o
> >  obj-$(CONFIG_CMD_ETHSW) += ethsw.o
> >  obj-$(CONFIG_CMD_AXI) += axi.o
> > +obj-$(CONFIG_CMD_PVBLOCK) += pvblock.o
> > 
> >  # Power
> >  obj-$(CONFIG_CMD_PMIC) += pmic.o
> > diff --git a/cmd/pvblock.c b/cmd/pvblock.c
> > new file mode 100644
> > index 00..7dbb243a74
> > --- /dev/null
> > +++ b/cmd/pvblock.c
> > @@ -0,0 +1,31 @@
> > +/*
> > + * SPDX-License-Identifier:GPL-2.0+
> 
> SPDX should be in first line and formatted as described in
> 
> 
https://urldefense.com/v3/__https://www.kernel.org/doc/html/latest/process/license-rules.html*license-identifier-syntax__;Iw!!GF_29dbcQIUBPA!l97PRX7YWb0RSRfrhKECVdFblqlOu73YTMPut6YwlXMfrLzvQrqF56fQO2MjT5c6kJT1Mqk$
> 

Ok, will fix.

>  
> 
> > + *
> > + * (C) Copyright 2020 EPAM Systems Inc.
> > + *
> > + * XEN para-virtualized block device support
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/* Current I/O Device  */
> > +static int pvblock_curr_device;
> > +
> > +int do_pvblock(struct cmd_tbl *cmdtp, int flag, int argc, char
> > *const argv[])
> > +{
> > +   return blk_common_cmd(argc, argv, IF_TYPE_PVBLOCK,
> > + _curr_device);
> > +}
> > +
> > +U_BOOT_CMD(pvblock, 5, 1, do_pvblock,
> > +  "Xen para-virtualized block device",
> > +  "info  - show available block devices\n"
> > +  "pvblock device [dev] - show or set current device\n"
> > +  "pvblock part [dev] - print partition table of one or all
> > devices\n"
> > +  "pvblock read  addr blk# cnt\n"
> > +  "pvblock write addr blk# cnt - read/write `cnt'"
> > +  " blocks starting at block `blk#'\n"
> > +  "to/from memory address `addr'");
> > +
> > diff --git a/common/board_r.c b/common/board_r.c
> > index fd36edb4e5..40cd0e5d3c 100644
> > --- a/common/board_r.c
> > +++ b/common/board_r.c
> > @@ -49,6 +49,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -470,6 +471,16 @@ static int initr_xen(void)
> > return 0;
> >  }
> >  #endif
> > +
> > +#ifdef CONFIG_PVBLOCK
> > +static int initr_pvblock(void)
> > +{
> > +   puts("PVBLOCK: ");
> > +   pvblock_init();
> > +   return 0;
> > +}
> > +#endif
> > +
> >  /*
> >   * Tell if it's OK to load the environment early in boot.
> >   *
> > @@ -780,6 +791,9 @@ static init_fnc_t init_sequence_r[] = {
> >  #endif
> >  #ifdef CONFIG_XEN
> > initr_xen,
> > +#endif
> > +#ifdef CONFIG_PVBLOCK
> > +   initr_pvblock,
> >  #endif
> > 

[PATCH 2/2] Convert CONFIG_SPL_NAND_BASE et al to Kconfig

2020-07-03 Thread Adam Ford
This converts the following to Kconfig:
   CONFIG_SPL_NAND_BASE
   CONFIG_SPL_NAND_IDENT

Signed-off-by: Adam Ford 

diff --git a/README b/README
index b6d368041c..60d8e77256 100644
--- a/README
+++ b/README
@@ -2307,8 +2307,6 @@ The following options need to be configured:
CONFIG_SPL_SKIP_RELOCATE
Avoid SPL relocation
 
-   CONFIG_SPL_NAND_BASE
-   Include nand_base.c in the SPL.  Requires
CONFIG_SPL_NAND_IDENT
SPL uses the chip ID list to identify the NAND flash.
Requires CONFIG_SPL_NAND_BASE.
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index af68d00e0b..b7d01c28fb 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -736,6 +736,18 @@ config SPL_NAND_SIMPLE
  Support for NAND boot using simple NAND drivers that
  expose the cmd_ctrl() interface.
 
+config SPL_NAND_BASE
+   depends on SPL_NAND_DRIVERS
+   bool "Use Base NAND Driver"
+help
+  Include nand_base.c in the SPL.
+
+config SPL_NAND_IDENT
+   depends on SPL_NAND_BASE
+   bool "Use chip ID to identify NAND flash"
+   help
+ SPL uses the chip ID list to identify the NAND flash.
+
 config SPL_UBI
bool "Support UBI"
help
diff --git a/configs/am335x_baltos_defconfig b/configs/am335x_baltos_defconfig
index 4656f5ef47..326882908b 100644
--- a/configs/am335x_baltos_defconfig
+++ b/configs/am335x_baltos_defconfig
@@ -22,6 +22,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_NAND_DRIVERS=y
 CONFIG_SPL_NAND_ECC=y
+CONFIG_SPL_NAND_BASE=y
 CONFIG_SPL_POWER_SUPPORT=y
 CONFIG_SPL_WATCHDOG_SUPPORT=y
 CONFIG_SPL_YMODEM_SUPPORT=y
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 2b572c8881..2c1135dd2b 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -19,6 +19,7 @@ CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_MUSB_NEW_SUPPORT=y
 CONFIG_SPL_NAND_DRIVERS=y
 CONFIG_SPL_NAND_ECC=y
+CONFIG_SPL_NAND_BASE=y
 CONFIG_SPL_NET_SUPPORT=y
 CONFIG_SPL_NET_VCI_STRING="AM335x U-Boot SPL"
 CONFIG_SPL_OS_BOOT=y
diff --git a/configs/am335x_guardian_defconfig 
b/configs/am335x_guardian_defconfig
index 9979bd4533..5b212d31a5 100644
--- a/configs/am335x_guardian_defconfig
+++ b/configs/am335x_guardian_defconfig
@@ -29,6 +29,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_MUSB_NEW_SUPPORT=y
 CONFIG_SPL_NAND_DRIVERS=y
 CONFIG_SPL_NAND_ECC=y
+CONFIG_SPL_NAND_BASE=y
 CONFIG_SPL_NET_SUPPORT=y
 CONFIG_SPL_NET_VCI_STRING="Guardian U-Boot SPL"
 CONFIG_SPL_POWER_SUPPORT=y
diff --git a/configs/am335x_hs_evm_defconfig b/configs/am335x_hs_evm_defconfig
index 223edb18e6..f90bcc5f59 100644
--- a/configs/am335x_hs_evm_defconfig
+++ b/configs/am335x_hs_evm_defconfig
@@ -23,6 +23,7 @@ CONFIG_SPL_MTD_SUPPORT=y
 # CONFIG_SPL_NAND_SUPPORT is not set
 CONFIG_SPL_NAND_DRIVERS=y
 CONFIG_SPL_NAND_ECC=y
+CONFIG_SPL_NAND_BASE=y
 # CONFIG_SPL_YMODEM_SUPPORT is not set
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_NAND=y
diff --git a/configs/am335x_hs_evm_uart_defconfig 
b/configs/am335x_hs_evm_uart_defconfig
index dd91036ec7..5cbb8091a2 100644
--- a/configs/am335x_hs_evm_uart_defconfig
+++ b/configs/am335x_hs_evm_uart_defconfig
@@ -26,6 +26,7 @@ CONFIG_SPL_MTD_SUPPORT=y
 # CONFIG_SPL_NAND_SUPPORT is not set
 CONFIG_SPL_NAND_DRIVERS=y
 CONFIG_SPL_NAND_ECC=y
+CONFIG_SPL_NAND_BASE=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_NAND=y
 # CONFIG_CMD_SETEXPR is not set
diff --git a/configs/am335x_igep003x_defconfig 
b/configs/am335x_igep003x_defconfig
index f5fd9677b6..9787f2a2b5 100644
--- a/configs/am335x_igep003x_defconfig
+++ b/configs/am335x_igep003x_defconfig
@@ -24,6 +24,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_NAND_DRIVERS=y
 CONFIG_SPL_NAND_ECC=y
+CONFIG_SPL_NAND_BASE=y
 CONFIG_SPL_UBI=y
 CONFIG_SPL_UBI_MAX_VOL_LEBS=256
 CONFIG_SPL_UBI_MAX_PEB_SIZE=262144
diff --git a/configs/am3517_crane_defconfig b/configs/am3517_crane_defconfig
index 4155df51bd..44f6c064dd 100644
--- a/configs/am3517_crane_defconfig
+++ b/configs/am3517_crane_defconfig
@@ -13,6 +13,7 @@ CONFIG_BOOTDELAY=10
 CONFIG_SPL_NAND_DRIVERS=y
 CONFIG_SPL_NAND_ECC=y
 CONFIG_SPL_NAND_SIMPLE=y
+CONFIG_SPL_NAND_BASE=y
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMDLINE_EDITING is not set
 CONFIG_SYS_PROMPT="AM3517_CRANE # "
diff --git a/configs/am3517_evm_defconfig b/configs/am3517_evm_defconfig
index 52912502fa..58fb91c1c5 100644
--- a/configs/am3517_evm_defconfig
+++ b/configs/am3517_evm_defconfig
@@ -24,6 +24,7 @@ CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_NAND_DRIVERS=y
 CONFIG_SPL_NAND_ECC=y
 CONFIG_SPL_NAND_SIMPLE=y
+CONFIG_SPL_NAND_BASE=y
 CONFIG_SPL_OS_BOOT=y
 # CONFIG_SPL_POWER_SUPPORT is not set
 CONFIG_SYS_PROMPT="AM3517_EVM # "
diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig
index dd31d523b7..aa4364355c 100644
--- a/configs/am43xx_evm_defconfig
+++ b/configs/am43xx_evm_defconfig
@@ -19,6 +19,7 @@ CONFIG_SPL_ETH_SUPPORT=y
 CONFIG_SPL_MTD_SUPPORT=y
 

Re: [PATCH 11/17] xen: Port Xen grant table driver from mini-os

2020-07-03 Thread Anastasiia Lukianenko
Hi Julien,

On Wed, 2020-07-01 at 17:59 +0100, Julien Grall wrote:
> 
> On 01/07/2020 17:29, Anastasiia Lukianenko wrote:
> > From: Oleksandr Andrushchenko 
> > 
> > Make required updates to run on u-boot.
> > 
> > Signed-off-by: Oleksandr Andrushchenko <
> > oleksandr_andrushche...@epam.com>
> > Signed-off-by: Anastasiia Lukianenko <
> > anastasiia_lukiane...@epam.com>
> > ---
> >   board/xen/xenguest_arm64/xenguest_arm64.c |  13 ++
> >   drivers/xen/Makefile  |   1 +
> >   drivers/xen/gnttab.c  | 258
> > ++
> >   drivers/xen/hypervisor.c  |   2 +
> >   include/xen/gnttab.h  |  25 +++
> >   5 files changed, 299 insertions(+)
> >   create mode 100644 drivers/xen/gnttab.c
> >   create mode 100644 include/xen/gnttab.h
> > 
> > diff --git a/board/xen/xenguest_arm64/xenguest_arm64.c
> > b/board/xen/xenguest_arm64/xenguest_arm64.c
> > index e8621f7174..b4e1650f99 100644
> > --- a/board/xen/xenguest_arm64/xenguest_arm64.c
> > +++ b/board/xen/xenguest_arm64/xenguest_arm64.c
> > @@ -22,6 +22,7 @@
> >   
> >   #include 
> >   
> > +#include 
> >   #include 
> >   
> >   DECLARE_GLOBAL_DATA_PTR;
> > @@ -64,6 +65,8 @@ static int setup_mem_map(void)
> > struct fdt_resource res;
> > const void *blob = gd->fdt_blob;
> > u64 gfn;
> > +   phys_addr_t gnttab_base;
> > +   phys_size_t gnttab_sz;
> >   
> > /*
> >  * Add "magic" region which is used by Xen to provide some
> > essentials
> > @@ -97,6 +100,16 @@ static int setup_mem_map(void)
> > PTE_BLOCK_INNER_SHARE);
> > i++;
> >   
> > +   /* Get Xen's suggested physical page assignments for the grant
> > table. */
> > +   get_gnttab_base(_base, _sz);
> > +
> > +   xen_mem_map[i].virt = gnttab_base;
> > +   xen_mem_map[i].phys = gnttab_base;
> > +   xen_mem_map[i].size = gnttab_sz;
> > +   xen_mem_map[i].attrs = (PTE_BLOCK_MEMTYPE(MT_NORMAL) |
> > +   PTE_BLOCK_INNER_SHARE);
> > +   i++;
> > +
> > mem = get_next_memory_node(blob, -1);
> > if (mem < 0) {
> > printf("%s: Missing /memory node\n", __func__);
> > diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
> > index 9d0f604aaa..243b13277a 100644
> > --- a/drivers/xen/Makefile
> > +++ b/drivers/xen/Makefile
> > @@ -5,3 +5,4 @@
> >   obj-y += hypervisor.o
> >   obj-y += events.o
> >   obj-y += xenbus.o
> > +obj-y += gnttab.o
> > diff --git a/drivers/xen/gnttab.c b/drivers/xen/gnttab.c
> > new file mode 100644
> > index 00..b18102e329
> > --- /dev/null
> > +++ b/drivers/xen/gnttab.c
> > @@ -0,0 +1,258 @@
> > +/*
> > +
> > ***
> > *
> > + * (C) 2006 - Cambridge University
> > + * (C) 2020 - EPAM Systems Inc.
> > +
> > ***
> > *
> > + *
> > + * File: gnttab.c
> > + *   Author: Steven Smith (so...@cam.ac.uk)
> > + *  Changes: Grzegorz Milos (gm...@cam.ac.uk)
> > + *
> > + * Date: July 2006
> > + *
> > + * Environment: Xen Minimal OS
> > + * Description: Simple grant tables implementation. About as
> > stupid as it's
> > + *  possible to be and still work.
> > + *
> > +
> > ***
> > *
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +DECLARE_GLOBAL_DATA_PTR;
> > +
> > +#define NR_RESERVED_ENTRIES 8
> > +
> > +/* NR_GRANT_FRAMES must be less than or equal to that configured
> > in Xen */
> > +#define NR_GRANT_FRAMES 1
> > +#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE /
> > sizeof(struct grant_entry_v1))
> > +
> > +static struct grant_entry_v1 *gnttab_table;
> > +static grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
> > +
> > +static void put_free_entry(grant_ref_t ref)
> > +{
> > +   unsigned long flags;
> > +
> > +   local_irq_save(flags);
> > +   gnttab_list[ref] = gnttab_list[0];
> > +   gnttab_list[0]  = ref;
> > +   local_irq_restore(flags);
> > +}
> > +
> > +static grant_ref_t get_free_entry(void)
> > +{
> > +   unsigned int ref;
> > +   unsigned long flags;
> > +
> > +   local_irq_save(flags);
> > +   ref = gnttab_list[0];
> > +   BUG_ON(ref < NR_RESERVED_ENTRIES || ref >= NR_GRANT_ENTRIES);
> > +   gnttab_list[0] = gnttab_list[ref];
> > +   local_irq_restore(flags);
> > +   return ref;
> > +}
> > +
> > +grant_ref_t gnttab_grant_access(domid_t domid, unsigned long
> > frame, int readonly)
> > +{
> > +   grant_ref_t ref;
> > +
> > +   ref = get_free_entry();
> > +   gnttab_table[ref].frame = frame;
> > +   gnttab_table[ref].domid = domid;
> > +   wmb();
> > +   readonly *= GTF_readonly;
> > +   gnttab_table[ref].flags = GTF_permit_access | readonly;
> > +
> > +   return ref;
> > +}
> > +
> > +grant_ref_t 

[PATCH 1/2] Convert CONFIG_SPL_NAND_DRIVERS et al to Kconfig

2020-07-03 Thread Adam Ford
This converts the following to Kconfig:
   CONFIG_SPL_NAND_DRIVERS
   CONFIG_SPL_NAND_ECC
   CONFIG_SPL_NAND_SIMPLE

Signed-off-by: Adam Ford 
---
The following appear as 'suspicious' but I think it's because
they don't have SPL enabled:

at91sam9x5ek_nandflash_defconfig
k2e_hs_evm_defconfig
k2l_hs_evm_defconfig
sama5d36ek_cmp_nandflash_defconfig
omap3_zoom1_defconfig
k2hk_hs_evm_defconfig
at91sam9n12ek_nandflash_defconfig
k2g_hs_evm_defconfig
pm9g45_defconfig
at91sam9m10g45ek_nandflash_defconfig

diff --git a/README b/README
index bcf1983631..b6d368041c 100644
--- a/README
+++ b/README
@@ -2309,22 +2309,10 @@ The following options need to be configured:
 
CONFIG_SPL_NAND_BASE
Include nand_base.c in the SPL.  Requires
-   CONFIG_SPL_NAND_DRIVERS.
-
-   CONFIG_SPL_NAND_DRIVERS
-   SPL uses normal NAND drivers, not minimal drivers.
-
CONFIG_SPL_NAND_IDENT
SPL uses the chip ID list to identify the NAND flash.
Requires CONFIG_SPL_NAND_BASE.
 
-   CONFIG_SPL_NAND_ECC
-   Include standard software ECC in the SPL
-
-   CONFIG_SPL_NAND_SIMPLE
-   Support for NAND boot using simple NAND drivers that
-   expose the cmd_ctrl() interface.
-
CONFIG_SPL_UBI
Support for a lightweight UBI (fastmap) scanner and
loader
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 8ece9057b1..af68d00e0b 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -722,6 +722,20 @@ config SPL_NAND_SUPPORT
  This enables the drivers in drivers/mtd/nand/raw as part of an SPL
  build.
 
+config SPL_NAND_DRIVERS
+   bool "Use standard NAND driver"
+   help
+ SPL uses normal NAND drivers, not minimal drivers.
+
+config SPL_NAND_ECC
+   bool "Include standard software ECC in the SPL"
+
+config SPL_NAND_SIMPLE
+   bool "Support simple NAND drivers in SPL"
+   help
+ Support for NAND boot using simple NAND drivers that
+ expose the cmd_ctrl() interface.
+
 config SPL_UBI
bool "Support UBI"
help
diff --git a/configs/am335x_baltos_defconfig b/configs/am335x_baltos_defconfig
index e7700a1fbf..4656f5ef47 100644
--- a/configs/am335x_baltos_defconfig
+++ b/configs/am335x_baltos_defconfig
@@ -20,6 +20,8 @@ CONFIG_ARCH_MISC_INIT=y
 CONFIG_SPL_FS_EXT4=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_MTD_SUPPORT=y
+CONFIG_SPL_NAND_DRIVERS=y
+CONFIG_SPL_NAND_ECC=y
 CONFIG_SPL_POWER_SUPPORT=y
 CONFIG_SPL_WATCHDOG_SUPPORT=y
 CONFIG_SPL_YMODEM_SUPPORT=y
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index e515aaa84b..2b572c8881 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -17,6 +17,8 @@ CONFIG_SPL_ETH_SUPPORT=y
 # CONFIG_SPL_FS_EXT4 is not set
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_MUSB_NEW_SUPPORT=y
+CONFIG_SPL_NAND_DRIVERS=y
+CONFIG_SPL_NAND_ECC=y
 CONFIG_SPL_NET_SUPPORT=y
 CONFIG_SPL_NET_VCI_STRING="AM335x U-Boot SPL"
 CONFIG_SPL_OS_BOOT=y
diff --git a/configs/am335x_guardian_defconfig 
b/configs/am335x_guardian_defconfig
index ab86e6aacc..9979bd4533 100644
--- a/configs/am335x_guardian_defconfig
+++ b/configs/am335x_guardian_defconfig
@@ -27,6 +27,8 @@ CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_ETH_SUPPORT=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_MUSB_NEW_SUPPORT=y
+CONFIG_SPL_NAND_DRIVERS=y
+CONFIG_SPL_NAND_ECC=y
 CONFIG_SPL_NET_SUPPORT=y
 CONFIG_SPL_NET_VCI_STRING="Guardian U-Boot SPL"
 CONFIG_SPL_POWER_SUPPORT=y
diff --git a/configs/am335x_hs_evm_defconfig b/configs/am335x_hs_evm_defconfig
index 6e7b0a0d9a..223edb18e6 100644
--- a/configs/am335x_hs_evm_defconfig
+++ b/configs/am335x_hs_evm_defconfig
@@ -21,6 +21,8 @@ CONFIG_SPL_FIT_IMAGE_TINY=y
 # CONFIG_SPL_FS_EXT4 is not set
 CONFIG_SPL_MTD_SUPPORT=y
 # CONFIG_SPL_NAND_SUPPORT is not set
+CONFIG_SPL_NAND_DRIVERS=y
+CONFIG_SPL_NAND_ECC=y
 # CONFIG_SPL_YMODEM_SUPPORT is not set
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_NAND=y
diff --git a/configs/am335x_hs_evm_uart_defconfig 
b/configs/am335x_hs_evm_uart_defconfig
index 9e7fd1a7b2..dd91036ec7 100644
--- a/configs/am335x_hs_evm_uart_defconfig
+++ b/configs/am335x_hs_evm_uart_defconfig
@@ -24,6 +24,8 @@ CONFIG_SPL_FIT_IMAGE_TINY=y
 # CONFIG_SPL_FS_EXT4 is not set
 CONFIG_SPL_MTD_SUPPORT=y
 # CONFIG_SPL_NAND_SUPPORT is not set
+CONFIG_SPL_NAND_DRIVERS=y
+CONFIG_SPL_NAND_ECC=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_NAND=y
 # CONFIG_CMD_SETEXPR is not set
diff --git a/configs/am335x_igep003x_defconfig 
b/configs/am335x_igep003x_defconfig
index 27f3b01643..f5fd9677b6 100644
--- a/configs/am335x_igep003x_defconfig
+++ b/configs/am335x_igep003x_defconfig
@@ -22,6 +22,8 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_SPL_FS_EXT4=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_MTD_SUPPORT=y
+CONFIG_SPL_NAND_DRIVERS=y
+CONFIG_SPL_NAND_ECC=y
 CONFIG_SPL_UBI=y
 CONFIG_SPL_UBI_MAX_VOL_LEBS=256
 CONFIG_SPL_UBI_MAX_PEB_SIZE=262144
diff 

Re: [PATCH 08/17] linux/compat.h: Add wait_event_timeout macro

2020-07-03 Thread Anastasiia Lukianenko
Hi Heinrich,

On Thu, 2020-07-02 at 06:08 +0200, Heinrich Schuchardt wrote:
> On 7/1/20 6:29 PM, Anastasiia Lukianenko wrote:
> > From: Oleksandr Andrushchenko 
> > 
> > Add  wait_event_timeout - sleep until a condition gets true or a
> > timeout elapses.
> > 
> > This is a stripped version of the same from Linux kernel with the
> > following u-boot specific modifications:
> > - no wait queues supported
> > - use u-boot timer to detect timeouts
> > - check for Ctrl-C pressed during wait
> > 
> > Signed-off-by: Oleksandr Andrushchenko <
> > oleksandr_andrushche...@epam.com>
> > Signed-off-by: Anastasiia Lukianenko <
> > anastasiia_lukiane...@epam.com>
> > ---
> >  include/linux/compat.h | 45
> > ++
> >  1 file changed, 45 insertions(+)
> > 
> > diff --git a/include/linux/compat.h b/include/linux/compat.h
> > index 712eeaef4e..5375b7d3b8 100644
> > --- a/include/linux/compat.h
> > +++ b/include/linux/compat.h
> > @@ -1,12 +1,20 @@
> >  #ifndef _LINUX_COMPAT_H_
> >  #define _LINUX_COMPAT_H_
> > 
> > +#include 
> >  #include 
> >  #include 
> > +
> > +#include 
> > +
> >  #include 
> >  #include 
> >  #include 
> > 
> > +#ifdef CONFIG_XEN
> > +#include 
> > +#endif
> > +
> >  struct unused {};
> >  typedef struct unused unused_t;
> > 
> > @@ -122,6 +130,43 @@ static inline void kmem_cache_destroy(struct
> > kmem_cache *cachep)
> >  #define add_wait_queue(...)do { } while (0)
> >  #define remove_wait_queue(...) do { } while (0)
> > 
> > +#ifndef CONFIG_XEN
> > +#define eventchn_poll()
> > +#endif
> > +
> > +#define __wait_event_timeout(condition, timeout, ret)  
> > \
> > +({ \
> > +   ulong __ret = ret; /* explicit shadow */\
> > +   ulong start = get_timer(0); \
> > +   for (;;) {  \
> > +   eventchn_poll();\
> > +   if (condition) {\
> > +   __ret = 1;  \
> > +   break;  \
> > +   }   \
> > +   if ((get_timer(start) > timeout) || ctrlc()) {  \
> > +   __ret = 0;  \
> > +   break;  \
> > +   }   \
> > +   cpu_relax();\
> > +   }   \
> > +   __ret;  \
> > +})
> > +
> > +/*
> > + * 0 if the @condition evaluated to %false after the @timeout
> > elapsed,
> > + * 1 if the @condition evaluated to %true
> > + */
> 
> Please, document all arguments. Use Sphinx style as in
> 
> 
https://urldefense.com/v3/__https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html*function-documentation__;Iw!!GF_29dbcQIUBPA!jxP9Fy4gB94pb9T2mEndgiT2VqEyLEBMrYaWyDyW68eZlNMGungcRuQt_ImPQPyw3zQYqiU$
>  .
> 

Ok, I will fix it in the next version.

> Best regards
> 
> Heinrich.

Best regards,
Anastasiia

> 
> > +#define wait_event_timeout(wq_head, condition, timeout)
> > \
> > +({ 
> > \
> > +   ulong __ret;
> > \
> > +   if (condition)  
> > \
> > +   __ret = 1;  \
> > +   else
> > \
> > +   __ret = __wait_event_timeout(condition, timeout,
> > __ret);\
> > +   __ret;  
> > \
> > +})
> > +
> >  #define KERNEL_VERSION(a,b,c)  (((a) << 16) + ((b) << 8) +
> > (c))
> > 
> >  /* This is also defined in ARMv8's mmu.h */
> > 
> 
> 


Re: [PATCH 07/17] serial: serial_xen: Add Xen PV serial driver

2020-07-03 Thread Anastasiia Lukianenko
Hello Simon,

On Thu, 2020-07-02 at 21:50 -0600, Simon Glass wrote:
> Hi Anastasiia,
> 
> On Wed, 1 Jul 2020 at 10:30, Anastasiia Lukianenko <
> vicooo...@gmail.com> wrote:
> > 
> > From: Peng Fan 
> > 
> > Add support for Xen para-virtualized serial driver. This
> > driver fully supports serial console for the virtual machine.
> > 
> > Please note that as the driver is initialized late, so no banner
> > nor memory size is visible.
> > 
> > Signed-off-by: Peng Fan 
> > Signed-off-by: Oleksandr Andrushchenko <
> > oleksandr_andrushche...@epam.com>
> > Signed-off-by: Anastasiia Lukianenko <
> > anastasiia_lukiane...@epam.com>
> > ---
> >  arch/arm/Kconfig  |   1 +
> >  board/xen/xenguest_arm64/xenguest_arm64.c |  31 +++-
> >  configs/xenguest_arm64_defconfig  |   4 +-
> >  drivers/serial/Kconfig|   7 +
> >  drivers/serial/Makefile   |   1 +
> >  drivers/serial/serial_xen.c   | 175
> > ++
> >  drivers/xen/events.c  |   4 +
> >  7 files changed, 214 insertions(+), 9 deletions(-)
> >  create mode 100644 drivers/serial/serial_xen.c
> 
> Reviewed-by: Simon Glass 
> 
> nits below
> 
> > 
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index c469863967..d4de1139aa 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -1723,6 +1723,7 @@ config TARGET_XENGUEST_ARM64
> > select XEN
> > select OF_CONTROL
> > select LINUX_KERNEL_IMAGE_HEADER
> > +   select XEN_SERIAL
> >  endchoice
> > 
> >  config ARCH_SUPPORT_TFABOOT
> > diff --git a/board/xen/xenguest_arm64/xenguest_arm64.c
> > b/board/xen/xenguest_arm64/xenguest_arm64.c
> > index 9e099f388f..fd10a002e9 100644
> > --- a/board/xen/xenguest_arm64/xenguest_arm64.c
> > +++ b/board/xen/xenguest_arm64/xenguest_arm64.c
> > @@ -18,9 +18,12 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> > 
> >  #include 
> > 
> > +#include 
> > +
> >  DECLARE_GLOBAL_DATA_PTR;
> > 
> >  int board_init(void)
> > @@ -57,9 +60,28 @@ static int get_next_memory_node(const void
> > *blob, int mem)
> > 
> >  static int setup_mem_map(void)
> >  {
> > -   int i, ret, mem, reg = 0;
> > +   int i = 0, ret, mem, reg = 0;
> > struct fdt_resource res;
> > const void *blob = gd->fdt_blob;
> > +   u64 gfn;
> > +
> > +   /*
> > +* Add "magic" region which is used by Xen to provide some
> > essentials
> > +* for the guest: we need console.
> > +*/
> > +   ret =
> > hvm_get_parameter_maintain_dcache(HVM_PARAM_CONSOLE_PFN, );
> > +   if (ret < 0) {
> > +   printf("%s: Can't get HVM_PARAM_CONSOLE_PFN, ret
> > %d\n",
> > +  __func__, ret);
> > +   return -EINVAL;
> > +   }
> > +
> > +   xen_mem_map[i].virt = PFN_PHYS(gfn);
> > +   xen_mem_map[i].phys = PFN_PHYS(gfn);
> > +   xen_mem_map[i].size = PAGE_SIZE;
> > +   xen_mem_map[i].attrs = (PTE_BLOCK_MEMTYPE(MT_NORMAL) |
> > +   PTE_BLOCK_INNER_SHARE);
> > +   i++;
> > 
> > mem = get_next_memory_node(blob, -1);
> > if (mem < 0) {
> > @@ -67,7 +89,7 @@ static int setup_mem_map(void)
> > return -EINVAL;
> > }
> > 
> > -   for (i = 0; i < MAX_MEM_MAP_REGIONS; i++) {
> > +   for (; i < MAX_MEM_MAP_REGIONS; i++) {
> > ret = fdt_get_resource(blob, mem, "reg", reg++,
> > );
> > if (ret == -FDT_ERR_NOTFOUND) {
> > reg = 0;
> > @@ -146,8 +168,3 @@ int print_cpuinfo(void)
> > return 0;
> >  }
> > 
> > -__weak struct serial_device *default_serial_console(void)
> > -{
> > -   return NULL;
> > -}
> > -
> > diff --git a/configs/xenguest_arm64_defconfig
> > b/configs/xenguest_arm64_defconfig
> > index 2a8caf8647..45559a161b 100644
> > --- a/configs/xenguest_arm64_defconfig
> > +++ b/configs/xenguest_arm64_defconfig
> > @@ -47,9 +47,9 @@ CONFIG_CMD_UMS=n
> >  #CONFIG_EFI_PARTITION=y
> >  # CONFIG_EFI_LOADER is not set
> > 
> > -# CONFIG_DM is not set
> > +CONFIG_DM=y
> >  # CONFIG_MMC is not set
> > -# CONFIG_DM_SERIAL is not set
> > +CONFIG_DM_SERIAL=y
> >  # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
> > 
> >  CONFIG_OF_BOARD=y
> > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> > index 17d0e73623..33c989a66d 100644
> > --- a/drivers/serial/Kconfig
> > +++ b/drivers/serial/Kconfig
> > @@ -821,6 +821,13 @@ config MPC8XX_CONS
> > depends on MPC8xx
> > default y
> > 
> > +config XEN_SERIAL
> > +   bool "XEN serial support"
> > +   depends on XEN
> > +   help
> > + If built without DM support, then requires Xen
> > + to be built with CONFIG_VERBOSE_DEBUG.
> 
> Yes but what does it do? Also should probably not support non-DM at
> this point.
> 

This will be removed at all as only DM based drivers are added.

> > +
> >  choice
> > prompt "Console port"
> > 

Re: [PATCH 1/3] video: add support for drawing 8bpp bitmap on 32bpp framebuffer

2020-07-03 Thread Anatolij Gustschin
Hi Igor,

On Fri, 3 Jul 2020 15:42:08 +0300
Igor Opaniuk igor.opan...@gmail.com wrote:
... 
> Thanks, I also successfully tested it on Toradex modules.

OK, thanks for testing!

--
Anatolij


Re: [PATCH 02/17] Kconfig: Introduce CONFIG_XEN

2020-07-03 Thread Anastasiia Lukianenko
Hi Simon,

On Thu, 2020-07-02 at 21:50 -0600, Simon Glass wrote:
> Hi Anastasiia,
> 
> On Wed, 1 Jul 2020 at 10:30, Anastasiia Lukianenko <
> vicooo...@gmail.com> wrote:
> > 
> > From: Peng Fan 
> > 
> > Introduce CONFIG_XEN to make U-Boot could be used as bootloader
> > for a virtual machine.
> > 
> > Without bootloader, we could successfully boot up android on XEN,
> > but
> > we need need bootloader to support A/B, dm verify and etc.
> > 
> > Signed-off-by: Peng Fan 
> > Signed-off-by: Oleksandr Andrushchenko <
> > oleksandr_andrushche...@epam.com>
> > Signed-off-by: Anastasiia Lukianenko <
> > anastasiia_lukiane...@epam.com>
> > ---
> >  Kconfig | 7 +++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/Kconfig b/Kconfig
> > index 8f3fba085a..67f773d3a6 100644
> > --- a/Kconfig
> > +++ b/Kconfig
> > @@ -69,6 +69,13 @@ config CC_COVERAGE
> >   Enabling this option will pass "--coverage" to gcc to
> > compile
> >   and link code instrumented for coverage analysis.
> > 
> > +config XEN
> > +   bool "Select U-Boot be run as a bootloader for XEN Virtual
> > Machine"
> > +   default n
> 
> Not needed

Ok, will remove.

> 
> > +   help
> > + Enabling this option will make U-Boot be run as a
> > bootloader
> > + for XEN Virtual Machine.
> 
> Can you please add a few more details. What is XEN? URL? Also what
> does this actually do? Add some features to talk to XEN? It really
> needs more info and perhaps a pointer to some docs.

I have number of links and explanation in the cover-letter,
so I’ll paste some of that here in the next version.

> 
> > +
> >  config DISTRO_DEFAULTS
> > bool "Select defaults suitable for booting general purpose
> > Linux distributions"
> > select AUTO_COMPLETE
> > --
> > 2.17.1
> > 
> 
> Regards,
> Simon

Regards,
Anastasiia


Re: [PATCH 1/3] video: add support for drawing 8bpp bitmap on 32bpp framebuffer

2020-07-03 Thread Igor Opaniuk
Hi Anatolij,

On Mon, Jun 29, 2020, 10:52 Anatolij Gustschin  wrote:

> Hi Igor,
>
> On Tue, 23 Jun 2020 14:40:45 +0300
> Igor Opaniuk igor.opan...@gmail.com wrote:
> ...
> > Any chance to get this merged?
>
> I've merged another reworked patch to fix the logo drawing problem.
>
Thanks, I also successfully tested it on Toradex modules.


> --
> Anatolij
>


Re: [PATCH] rockchip: rk3288: Add OF board setup

2020-07-03 Thread Robin Murphy

On 2020-07-03 11:10, Jagan Teki wrote:

On Thu, Jul 2, 2020 at 7:26 PM Robin Murphy  wrote:


On 2020-07-02 09:48, Jagan Teki wrote:

The new rk3288 revision rk3288w has some changes with respect
to legacy rk3288 like hclk_vio and usb host0 ohci.

In order to work these on the same in Linux kernel update the
compatible the root compatible with rockchip,rk3288w before
booting.

So, this support during of board setup code of rk3288.

Signed-off-by: Jagan Teki 
---
   arch/arm/mach-rockchip/Kconfig |  1 +
   arch/arm/mach-rockchip/rk3288/rk3288.c | 26 ++
   2 files changed, 27 insertions(+)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index b1008a5058..822d8d4e9c 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -98,6 +98,7 @@ config ROCKCHIP_RK322X
   config ROCKCHIP_RK3288
   bool "Support Rockchip RK3288"
   select CPU_V7A
+ select OF_BOARD_SETUP
   select SUPPORT_SPL
   select SPL
   select SUPPORT_TPL
diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c 
b/arch/arm/mach-rockchip/rk3288/rk3288.c
index 804abe8a1b..8a682675e6 100644
--- a/arch/arm/mach-rockchip/rk3288/rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
@@ -115,6 +115,32 @@ int rk_board_late_init(void)
   return rk3288_board_late_init();
   }

+#ifdef CONFIG_OF_BOARD_SETUP
+
+#define RK3288_HDMI_PHYS 0xff98
+#define RK3288W_HDMI_REV 0x1A
+#define HDMI_CONFIG0_ID  0x04
+
+int ft_board_setup(void *blob, bd_t *bd)
+{
+ u8 config0;
+ int ret;
+
+ config0 = readb(RK3288_HDMI_PHYS + HDMI_CONFIG0_ID);
+ if (config0 == RK3288W_HDMI_REV) {
+ ret = fdt_setprop_string(blob, 0,
+  "compatible", "rockchip,rk3288w");


Does this end up replacing the entire top-level compatible property?
i.e. from:

 compatible = "vendor,board\0rockchip,rk3288";

to just:

 compatible = "rockchip,rk3288w";

If so, that's a bit of a problem for various drivers that care about the
actual board compatible rather than the SoC.


Yes, It looks replacing the entire compatible. I think the root
compatible is mostly untouchable because of this reason.

But, if we skip the root compatible and trying to replace individual
nodes for W revision then it requires extra registration code on in
the Linux drivers like Linux clock driver is registering the clock
with rockchip,rk3288-cru but updating this compatible with
rockchip,rk3288w-cru will require another registration code. Having
common rockchip,rk3288w can be possible to check any code in the tree.


Right, it's definitely reasonable to update the top-level SoC 
compatible, we just need to be prepared to deal with a whole string list 
here. It looks like libfdt doesn't offer any nice helpers for 
inserting/removing/updating in string lists, but given that the SoC 
should be the last entry here we might be able to cheat a bit - just get 
the whole raw property, check that the final characters are exactly 
"rockchip,rk3288", and if so append a "w" to the end and write it back.


Robin.


Re: [PATCH 06/17] xen: Port Xen event channel driver from mini-os

2020-07-03 Thread Anastasiia Lukianenko
Hello Simon,

On Thu, 2020-07-02 at 21:50 -0600, Simon Glass wrote:
> Hi,
> 
> On Wed, 1 Jul 2020 at 10:30, Anastasiia Lukianenko <
> vicooo...@gmail.com> wrote:
> > 
> > From: Oleksandr Andrushchenko 
> > 
> > Make required updates to run on u-boot. Strip functionality
> > not needed by U-boot.
> > 
> > Signed-off-by: Oleksandr Andrushchenko <
> > oleksandr_andrushche...@epam.com>
> > Signed-off-by: Anastasiia Lukianenko <
> > anastasiia_lukiane...@epam.com>
> > ---
> >  drivers/xen/Makefile |   1 +
> >  drivers/xen/events.c | 177
> > +++
> >  drivers/xen/hypervisor.c |   6 +-
> >  include/xen/events.h |  47 +++
> >  4 files changed, 228 insertions(+), 3 deletions(-)
> >  create mode 100644 drivers/xen/events.c
> >  create mode 100644 include/xen/events.h
> > 
> > diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
> > index 1211bf2386..0ad35edefb 100644
> > --- a/drivers/xen/Makefile
> > +++ b/drivers/xen/Makefile
> > @@ -3,3 +3,4 @@
> >  # (C) Copyright 2020 EPAM Systems Inc.
> > 
> >  obj-y += hypervisor.o
> > +obj-y += events.o
> > diff --git a/drivers/xen/events.c b/drivers/xen/events.c
> > new file mode 100644
> > index 00..eddc6b6e29
> > --- /dev/null
> > +++ b/drivers/xen/events.c
> > @@ -0,0 +1,177 @@
> > +/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
> 
> SPDX is needed on files

Ok, will add.

> 
> > +
> > ***
> > *
> > + * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
> > + * (C) 2005 - Grzegorz Milos - Intel Research Cambridge
> > + * (C) 2020 - EPAM Systems Inc.
> > +
> > ***
> > *
> > + *
> > + * File: events.c
> > + *   Author: Rolf Neugebauer (neuge...@dcs.gla.ac.uk)
> > + *  Changes: Grzegorz Milos (gm...@cam.ac.uk)
> > + *
> > + * Date: Jul 2003, changes Jun 2005
> > + *
> > + * Environment: Xen Minimal OS
> > + * Description: Deals with events received on event channels
> > + *
> > +
> > ***
> > *
> 
> Can you drop these stars and use the normal U-Boot format?

Ok, will update all the files.

> 
> > + */
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +
> > +#define NR_EVS 1024
> > +
> > +/* this represents a event handler. Chaining or sharing is not
> > allowed */
> > +typedef struct _ev_action_t {
> 
> Please don't use typedefs.

Ok.

> 
> Also there should be comments on functions, particularly those in the
> header file.

Ok, will add comments in next version.

> 
> Are you trying to keep the source similar to an upstream version?

It seems that after this review we are stepping away from Mini-OS
anyway (like removing x86 code etc), so it is ok not to keep the source
close to the original code.

> 
> Regards,
> SImon

Regards,
Anastasiia


Chainloading U-Boot from Fastboot on Tegra30

2020-07-03 Thread Peter Geis
Good Morning,

I am attempting to expand on the work for chainloading U-Boot on the
nyan-big in order to chainload U-Boot on the Ouya Tegra30 device from fastboot.
I have so far been unsuccessful at getting any output from U-Boot
through this method.

I'm building the cardhu board with tweaks for Ouya's specifications
similar to my work for the linux kernel.
I build the image using mkbootimg --kernel u-boot.bin --ramdisk
/dev/null --output u-boot-android.bin.
I then fastboot boot u-boot-android.bin.

I've tried tweaking the text base and tried both standard debug and
low level debug.

Do you think you could give me some insight into where I'm going wrong?

Thank you,
Peter Geis


Re: [PATCH 05/17] xen: Port Xen hypervizor related code from mini-os

2020-07-03 Thread Anastasiia Lukianenko
Hi Julien,

On Wed, 2020-07-01 at 18:46 +0100, Julien Grall wrote:
> Title: s/hypervizor/hypervisor/

Thank you for pointing :) I will fix it in the next version.

> 
> On 01/07/2020 17:29, Anastasiia Lukianenko wrote:
> > From: Oleksandr Andrushchenko 
> > 
> > Port hypervizor related code from mini-os. Update essential
> 
> Ditto.
> 
> But I would be quite cautious to import code from mini-OS in order
> to 
> support Arm. The port has always been broken and from a look below
> needs 
> to be refined for Arm.

We were referencing the code of Mini-OS from [1] by Huang Shijie and
Volodymyr Babchuk which is for ARM64, so we hope this part should be
ok.

[1] https://github.com/zyzii/mini-os.git

> 
> > arch code to support required bit operations, memory barriers etc.
> > 
> > Copyright for the bits ported belong to at least the following
> > authors,
> > please see related files for details:
> > 
> > Copyright (c) 2002-2003, K A Fraser
> > Copyright (c) 2005, Grzegorz Milos, gm...@cam.ac.uk,Intel Research
> > Cambridge
> > Copyright (c) 2014, Karim Allah Ahmed 
> > 
> > Signed-off-by: Oleksandr Andrushchenko <
> > oleksandr_andrushche...@epam.com>
> > Signed-off-by: Anastasiia Lukianenko <
> > anastasiia_lukiane...@epam.com>
> > ---
> >   arch/arm/include/asm/xen/system.h |  96 +++
> >   common/board_r.c  |  11 ++
> >   drivers/Makefile  |   1 +
> >   drivers/xen/Makefile  |   5 +
> >   drivers/xen/hypervisor.c  | 277
> > ++
> >   include/xen.h |  11 ++
> >   include/xen/hvm.h |  30 
> >   7 files changed, 431 insertions(+)
> >   create mode 100644 arch/arm/include/asm/xen/system.h
> >   create mode 100644 drivers/xen/Makefile
> >   create mode 100644 drivers/xen/hypervisor.c
> >   create mode 100644 include/xen.h
> >   create mode 100644 include/xen/hvm.h
> > 
> > diff --git a/arch/arm/include/asm/xen/system.h
> > b/arch/arm/include/asm/xen/system.h
> > new file mode 100644
> > index 00..81ab90160e
> > --- /dev/null
> > +++ b/arch/arm/include/asm/xen/system.h
> > @@ -0,0 +1,96 @@
> > +/*
> > + * SPDX-License-Identifier: GPL-2.0
> > + *
> > + * (C) 2014 Karim Allah Ahmed 
> > + * (C) 2020, EPAM Systems Inc.
> > + */
> > +#ifndef _ASM_ARM_XEN_SYSTEM_H
> > +#define _ASM_ARM_XEN_SYSTEM_H
> > +
> > +#include 
> > +#include 
> > +
> > +/* If *ptr == old, then store new there (and return new).
> > + * Otherwise, return the old value.
> > + * Atomic.
> > + */
> > +#define synch_cmpxchg(ptr, old, new) \
> > +({ __typeof__(*ptr) stored = old; \
> > +   __atomic_compare_exchange_n(ptr, , new, 0,
> > __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? new : old; \
> > +})
> > +
> > +/* As test_and_clear_bit, but using __ATOMIC_SEQ_CST */
> > +static inline int synch_test_and_clear_bit(int nr, volatile void
> > *addr)
> > +{
> > +   u8 *byte = ((u8 *)addr) + (nr >> 3);
> > +   u8 bit = 1 << (nr & 7);
> > +   u8 orig;
> > +
> > +   orig = __atomic_fetch_and(byte, ~bit, __ATOMIC_SEQ_CST);
> > +
> > +   return (orig & bit) != 0;
> > +}
> > +
> > +/* As test_and_set_bit, but using __ATOMIC_SEQ_CST */
> > +static inline int synch_test_and_set_bit(int nr, volatile void
> > *base)
> > +{
> > +   u8 *byte = ((u8 *)base) + (nr >> 3);
> > +   u8 bit = 1 << (nr & 7);
> > +   u8 orig;
> > +
> > +   orig = __atomic_fetch_or(byte, bit, __ATOMIC_SEQ_CST);
> > +
> > +   return (orig & bit) != 0;
> > +}
> > +
> > +/* As set_bit, but using __ATOMIC_SEQ_CST */
> > +static inline void synch_set_bit(int nr, volatile void *addr)
> > +{
> > +   synch_test_and_set_bit(nr, addr);
> > +}
> > +
> > +/* As clear_bit, but using __ATOMIC_SEQ_CST */
> > +static inline void synch_clear_bit(int nr, volatile void *addr)
> > +{
> > +   synch_test_and_clear_bit(nr, addr);
> > +}
> > +
> > +/* As test_bit, but with a following memory barrier. */
> > +//static inline int synch_test_bit(int nr, volatile void *addr)
> > +static inline int synch_test_bit(int nr, const void *addr)
> > +{
> > +   int result;
> > +
> > +   result = test_bit(nr, addr);
> > +   barrier();
> > +   return result;
> > +}
> 
> I can understand why we implement sync_* helpers as AFAICT the
> generic 
> helpers are not SMP safe. However...
> 
> > +
> > +#define xchg(ptr, v)   __atomic_exchange_n(ptr, v,
> > __ATOMIC_SEQ_CST)
> > +#define xchg(ptr, v)   __atomic_exchange_n(ptr, v,
> > __ATOMIC_SEQ_CST)
> > +
> > +#define mb()   dsb()
> > +#define rmb()  dsb()
> > +#define wmb()  dsb()
> > +#define __iormb()  dmb()
> > +#define __iowmb()  dmb()
> 
> Why do you need to re-implement the barriers?

Indeed, we do not need to do this.
I will fix it in the next version.

> 
> > +#define xen_mb()   mb()
> > +#define xen_rmb()  rmb()
> > +#define xen_wmb()  wmb()
> > +
> > +#define smp_processor_id() 0
> 
> Shouldn't this be common?

Currently it is only used by Xen and we are not sure if
any other entity will use it, but we can put 

[PATCH v3 2/2] test: gpio: Add tests for the managed API

2020-07-03 Thread Pratyush Yadav
From: Jean-Jacques Hiblot 

Add a test to verify that GPIOs can be acquired/released using the managed
API. Also check that the GPIOs are released when the consumer device is
removed.

Signed-off-by: Jean-Jacques Hiblot 
Reviewed-by: Simon Glass 
Signed-off-by: Pratyush Yadav 
---
 arch/sandbox/dts/test.dts |  10 
 test/dm/gpio.c| 102 ++
 2 files changed, 112 insertions(+)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 5ce5e28476..a8618ccade 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -107,6 +107,9 @@
<_c 5 GPIO_IN>,
<_c 6 (GPIO_ACTIVE_LOW|GPIO_OUT|GPIO_OPEN_DRAIN)>,
<_c 7 (GPIO_ACTIVE_LOW|GPIO_OUT|GPIO_OPEN_SOURCE)>;
+   test4-gpios = <_a 14>, <_b 4 1 3 2 1>;
+   test5-gpios = <_a 19>;
+
int-value = <1234>;
uint-value = <(-1234)>;
int64-value = /bits/ 64 <0x>;
@@ -114,6 +117,13 @@
interrupts-extended = < 3 0>;
};

+   another-test {
+   reg = <0 2>;
+   compatible = "denx,u-boot-fdt-test";
+   test4-gpios = <_a 14>, <_b 4 1 3 2 1>;
+   test5-gpios = <_a 19>;
+   };
+
junk {
reg = <1 1>;
compatible = "not,compatible";
diff --git a/test/dm/gpio.c b/test/dm/gpio.c
index b5ee4e4f87..40bea32b13 100644
--- a/test/dm/gpio.c
+++ b/test/dm/gpio.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -385,3 +386,104 @@ static int dm_test_gpio_get_dir_flags(struct 
unit_test_state *uts)
return 0;
 }
 DM_TEST(dm_test_gpio_get_dir_flags, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that we can get/release GPIOs using managed API */
+static int dm_test_gpio_devm(struct unit_test_state *uts)
+{
+   static const u32 flags = GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE;
+   struct gpio_desc *desc1, *desc2, *desc3, *desc_err;
+   struct udevice *dev;
+   struct udevice *dev2;
+
+   ut_assertok(uclass_get_device_by_name(UCLASS_TEST_FDT, "a-test",
+ ));
+   ut_assertok(uclass_get_device_by_name(UCLASS_TEST_FDT, "another-test",
+ ));
+
+   /* Get 3 GPIOs from 'a-test' dev */
+   desc1 = devm_gpiod_get_index(dev, "test4", 0, flags);
+   ut_assert(!IS_ERR(desc1));
+   desc2 = devm_gpiod_get_index(dev, "test4", 1, flags);
+   ut_assert(!IS_ERR(desc2));
+   desc3 = devm_gpiod_get_index_optional(dev, "test5", 0, flags);
+   ut_assert(!IS_ERR(desc3));
+   ut_assert(desc3);
+
+   /*
+* Try get the same 3 GPIOs from 'a-test' and 'another-test' devices.
+* check that it fails
+*/
+   desc_err = devm_gpiod_get_index(dev, "test4", 0, flags);
+   ut_asserteq(-EBUSY, PTR_ERR(desc_err));
+   desc_err = devm_gpiod_get_index(dev2, "test4", 0, flags);
+   ut_asserteq(-EBUSY, PTR_ERR(desc_err));
+   desc_err = devm_gpiod_get_index(dev, "test4", 1, flags);
+   ut_asserteq(-EBUSY, PTR_ERR(desc_err));
+   desc_err = devm_gpiod_get_index(dev2, "test4", 1, flags);
+   ut_asserteq(-EBUSY, PTR_ERR(desc_err));
+   desc_err = devm_gpiod_get_index_optional(dev, "test5", 0, flags);
+   ut_asserteq_ptr(NULL, desc_err);
+   desc_err = devm_gpiod_get_index_optional(dev2, "test5", 0, flags);
+   ut_asserteq_ptr(NULL, desc_err);
+
+   /* Try get GPIOs outside of the list */
+   desc_err = devm_gpiod_get_index(dev, "test4", 2, flags);
+   ut_assert(IS_ERR(desc_err));
+   desc_err = devm_gpiod_get_index_optional(dev, "test5", 1, flags);
+   ut_asserteq_ptr(NULL, desc_err);
+
+   /* Manipulate the GPIOs */
+   ut_assertok(dm_gpio_set_value(desc1, 1));
+   ut_asserteq(1, dm_gpio_get_value(desc1));
+   ut_assertok(dm_gpio_set_value(desc1, 0));
+   ut_asserteq(0, dm_gpio_get_value(desc1));
+
+   ut_assertok(dm_gpio_set_value(desc2, 1));
+   ut_asserteq(1, dm_gpio_get_value(desc2));
+   ut_assertok(dm_gpio_set_value(desc2, 0));
+   ut_asserteq(0, dm_gpio_get_value(desc2));
+
+   ut_assertok(dm_gpio_set_value(desc3, 1));
+   ut_asserteq(1, dm_gpio_get_value(desc3));
+   ut_assertok(dm_gpio_set_value(desc3, 0));
+   ut_asserteq(0, dm_gpio_get_value(desc3));
+
+   /* Check that the GPIO cannot be owned by more than one device */
+   desc_err = devm_gpiod_get_index(dev2, "test4", 0, flags);
+   ut_asserteq(-EBUSY, PTR_ERR(desc_err));
+   desc_err = devm_gpiod_get_index(dev2, "test4", 1, flags);
+   ut_asserteq(-EBUSY, PTR_ERR(desc_err));
+   desc_err = devm_gpiod_get_index_optional(dev2, "test5", 0, flags);
+   ut_asserteq_ptr(NULL, desc_err);
+
+   /*
+* Release one GPIO and check that we can get it back using
+   

[PATCH v3 0/2] gpio: Add a managed API

2020-07-03 Thread Pratyush Yadav
Hi,

This is a re-submission of Jean-Jacques' earlier work in October last
year. It can be fount at [0]. The goal is to facilitate porting drivers
from the linux kernel. Most of the series will be about adding managed
API to existing infrastructure (GPIO, reset, regmap (already
submitted)).

This particular series is about GPIOs. It adds a managed API using the
API as Linux. To make it 100% compatible with linux, there is a small
deviation from u-boot's way of naming the gpio lists: the managed
equivalent of gpio_request_by_name(..,"blabla-gpios", ...) is
devm_gpiod_get_index(..., "blabla", ...)

Changes in v3:
- Add a blank line before return in devm_gpiod_get_index().
- Add Simon's Reviwed-by in both patches.

Changes in v2:
- The original series had a patch that checked for NULL pointers in the
  core GPIO functions. The checks were needed because of the addition of
  devm_gpiod_get_index_optional() which would return NULL when when no
  GPIO was assigned to the requested function. This is convenient for
  drivers that need to handle optional GPIOs.

  Simon argued that those should be behind a Kconfig option because of
  code size concerns. He also argued against implicit return in the
  macro that checked for the optional GPIOs.

  This submission removes the controversial patch so that base
  functionality can get merged.

  We still need to take a stance on who is responsible for the NULL
  check: the driver or the GPIO core? Do we want to trust drivers to
  take care of the NULL checks, or do we want to distrust them and make
  sure they don't send us anything bogus in the GPIO core. I will send a
  separate RFC of the NULL check patch and we can probably discuss the
  issue there.

[0] 
https://patchwork.ozlabs.org/project/uboot/cover/20191001115130.18886-1-jjhib...@ti.com/

Jean-Jacques Hiblot (2):
  drivers: gpio: Add a managed API to get a GPIO from the device-tree
  test: gpio: Add tests for the managed API

 arch/sandbox/dts/test.dts  |  10 
 drivers/gpio/gpio-uclass.c |  71 ++
 include/asm-generic/gpio.h |  47 +
 test/dm/gpio.c | 102 +
 4 files changed, 230 insertions(+)

--
2.27.0



[PATCH v3 1/2] drivers: gpio: Add a managed API to get a GPIO from the device-tree

2020-07-03 Thread Pratyush Yadav
From: Jean-Jacques Hiblot 

Add managed functions to get a gpio from the devce-tree, based on a
property name (minus the '-gpios' suffix) and optionally an index.

When the device is unbound, the GPIO is automatically released and the
data structure is freed.

Signed-off-by: Jean-Jacques Hiblot 
Reviewed-by: Simon Glass 
Signed-off-by: Pratyush Yadav 
---
 drivers/gpio/gpio-uclass.c | 71 ++
 include/asm-generic/gpio.h | 47 +
 2 files changed, 118 insertions(+)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 9eeab22eef..c460ebc63b 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -6,6 +6,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -1141,6 +1143,75 @@ int gpio_dev_request_index(struct udevice *dev, const 
char *nodename,
 flags, 0, dev);
 }

+static void devm_gpiod_release(struct udevice *dev, void *res)
+{
+   dm_gpio_free(dev, res);
+}
+
+static int devm_gpiod_match(struct udevice *dev, void *res, void *data)
+{
+   return res == data;
+}
+
+struct gpio_desc *devm_gpiod_get_index(struct udevice *dev, const char *id,
+  unsigned int index, int flags)
+{
+   int rc;
+   struct gpio_desc *desc;
+   char *propname;
+   static const char suffix[] = "-gpios";
+
+   propname = malloc(strlen(id) + sizeof(suffix));
+   if (!propname) {
+   rc = -ENOMEM;
+   goto end;
+   }
+
+   strcpy(propname, id);
+   strcat(propname, suffix);
+
+   desc = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc),
+   __GFP_ZERO);
+   if (unlikely(!desc)) {
+   rc = -ENOMEM;
+   goto end;
+   }
+
+   rc = gpio_request_by_name(dev, propname, index, desc, flags);
+
+end:
+   if (propname)
+   free(propname);
+
+   if (rc)
+   return ERR_PTR(rc);
+
+   devres_add(dev, desc);
+
+   return desc;
+}
+
+struct gpio_desc *devm_gpiod_get_index_optional(struct udevice *dev,
+   const char *id,
+   unsigned int index,
+   int flags)
+{
+   struct gpio_desc *desc = devm_gpiod_get_index(dev, id, index, flags);
+
+   if (IS_ERR(desc))
+   return NULL;
+
+   return desc;
+}
+
+void devm_gpiod_put(struct udevice *dev, struct gpio_desc *desc)
+{
+   int rc;
+
+   rc = devres_release(dev, devm_gpiod_release, devm_gpiod_match, desc);
+   WARN_ON(rc);
+}
+
 static int gpio_post_bind(struct udevice *dev)
 {
struct udevice *child;
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index e16c2f31d9..76e0e902c4 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -674,4 +674,51 @@ int dm_gpio_get_dir_flags(struct gpio_desc *desc, ulong 
*flags);
  */
 int gpio_get_number(const struct gpio_desc *desc);

+/**
+ * devm_gpiod_get_index - Resource-managed gpiod_get()
+ * @dev:   GPIO consumer
+ * @con_id:function within the GPIO consumer
+ * @index: index of the GPIO to obtain in the consumer
+ * @flags: optional GPIO initialization flags
+ *
+ * Managed gpiod_get(). GPIO descriptors returned from this function are
+ * automatically disposed on driver detach.
+ * Return the GPIO descriptor corresponding to the function con_id of device
+ * dev, -ENOENT if no GPIO has been assigned to the requested function, or
+ * another IS_ERR() code if an error occurred while trying to acquire the GPIO.
+ */
+struct gpio_desc *devm_gpiod_get_index(struct udevice *dev, const char *id,
+  unsigned int index, int flags);
+
+#define devm_gpiod_get(dev, id, flags) devm_gpiod_get_index(dev, id, 0, flags)
+/**
+ * gpiod_get_optional - obtain an optional GPIO for a given GPIO function
+ * @dev: GPIO consumer, can be NULL for system-global GPIOs
+ * @con_id: function within the GPIO consumer
+ * @index: index of the GPIO to obtain in the consumer
+ * @flags: optional GPIO initialization flags
+ *
+ * This is equivalent to devm_gpiod_get(), except that when no GPIO was
+ * assigned to the requested function it will return NULL. This is convenient
+ * for drivers that need to handle optional GPIOs.
+ */
+struct gpio_desc *devm_gpiod_get_index_optional(struct udevice *dev,
+   const char *id,
+   unsigned int index,
+   int flags);
+
+#define devm_gpiod_get_optional(dev, id, flags) \
+   devm_gpiod_get_index_optional(dev, id, 0, flags)
+
+/**
+ * devm_gpiod_put - Resource-managed gpiod_put()
+ * @dev:   GPIO consumer
+ * @desc:  GPIO descriptor to dispose of
+ *
+ * Dispose 

Re: [PATCH 01/17] armv8: Fix SMCC and ARM_PSCI_FW dependencies

2020-07-03 Thread Nastya Vicodin
On Thu, Jul 2, 2020 at 4:14 AM Peng Fan  wrote:
>
> > Subject: [PATCH 01/17] armv8: Fix SMCC and ARM_PSCI_FW dependencies
> >
> > From: Oleksandr Andrushchenko 
> >
> > Currently SMCC selects ARM_PSCI_FW if enabled which is not correct as
> > there are cases that PSCI can function without firmware at all.
> > ARM_PSCI_FW itself is built with driver model approach, so it cannot be
> > enabled if DM is off.
> > Fix this by making PSCI reset functionality depend on ARM_PSCI_FW and
only
> > in case if DM is enabled.
>
> I think this might break others, see drivers/firmware/psci.c
>
> Regards,
> Peng.

Well, the only reason we have this patch *was* the problem with the board
support
if CONFIG_DM is off when we tried to add an early console support w/o
driver model.

But it seems this is not needed at all now, so this patch can be easily
dropped without
causing any harm. I’ll also enable CONFIG_DM from the very start as all the
drivers
we are adding will use it anyway.

But, IMO, CONFIG_ARM_PSCI_FW support is still broken wrt the fact that SMCC
can function without PSCI_FW, but made a strong requirement. Even more, it
requires
DM because of the PSCI driver which detects if we are about to use SMCCC or
HVC.

Regards,
Anastasiia

>
>
> >
> > Signed-off-by: Oleksandr Andrushchenko
> > 
> > Signed-off-by: Anastasiia Lukianenko 
> > Suggested-by: Volodymyr Babchuk 
> > ---
> >  arch/arm/Kconfig   | 1 -
> >  arch/arm/cpu/armv8/Kconfig | 2 ++
> >  2 files changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index
> > 54d65f8488..e9ad716aaa 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -387,7 +387,6 @@ config SYS_ARCH_TIMER  config ARM_SMCCC
> >   bool "Support for ARM SMC Calling Convention (SMCCC)"
> >   depends on CPU_V7A || ARM64
> > - select ARM_PSCI_FW
> >   help
> > Say Y here if you want to enable ARM SMC Calling Convention.
> > This should be enabled if U-Boot needs to communicate with
system
> > diff --git a/arch/arm/cpu/armv8/Kconfig b/arch/arm/cpu/armv8/Kconfig
> > index 3655990772..c8727f4175 100644
> > --- a/arch/arm/cpu/armv8/Kconfig
> > +++ b/arch/arm/cpu/armv8/Kconfig
> > @@ -103,6 +103,8 @@ config PSCI_RESET
> >   bool "Use PSCI for reset and shutdown"
> >   default y
> >   select ARM_SMCCC if OF_CONTROL
> > + select ARM_PSCI_FW if DM
> > +
> >   depends on !ARCH_EXYNOS7 && !ARCH_BCM283X && \
> >  !TARGET_LS2080A_SIMU && !TARGET_LS2080AQDS && \
> >  !TARGET_LS2080ARDB && !TARGET_LS2080A_EMU && \
> > --
> > 2.17.1


Re: [PATCH v2 09/17] efi_loader: signature: make efi_hash_regions more generic

2020-07-03 Thread Heinrich Schuchardt
On 09.06.20 07:09, AKASHI Takahiro wrote:
> There are a couple of occurrences of hash calculations in which a new
> efi_hash_regions will be commonly used.

Please, describe the difference.

Do you want to calculate the hash over an interval of regions?

>
> Signed-off-by: AKASHI Takahiro 

Please, provide a test for efi_hash_regions() in test/lib/.

> ---
>  lib/efi_loader/efi_signature.c | 44 +-
>  1 file changed, 16 insertions(+), 28 deletions(-)
>
> diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c
> index f22dc151971f..03080bc0b11c 100644
> --- a/lib/efi_loader/efi_signature.c
> +++ b/lib/efi_loader/efi_signature.c
> @@ -30,6 +30,7 @@ const efi_guid_t efi_guid_cert_type_pkcs7 = 
> EFI_CERT_TYPE_PKCS7_GUID;
>  /**
>   * efi_hash_regions - calculate a hash value
>   * @regs:List of regions

The argument should be renamed and the description corrected:

@reg:   first region

Best regards

Heinrich

> + * @count:   Number of regions
>   * @hash:Pointer to a pointer to buffer holding a hash value
>   * @size:Size of buffer to be returned
>   *
> @@ -37,18 +38,20 @@ const efi_guid_t efi_guid_cert_type_pkcs7 = 
> EFI_CERT_TYPE_PKCS7_GUID;
>   *
>   * Return:   true on success, false on error
>   */
> -static bool efi_hash_regions(struct efi_image_regions *regs, void **hash,
> -  size_t *size)
> +static bool efi_hash_regions(struct image_region *regs, int count,
> +  void **hash, size_t *size)
>  {
> - *size = 0;
> - *hash = calloc(1, SHA256_SUM_LEN);
>   if (!*hash) {
> - EFI_PRINT("Out of memory\n");
> - return false;
> + *hash = calloc(1, SHA256_SUM_LEN);
> + if (!*hash) {
> + EFI_PRINT("Out of memory\n");
> + return false;
> + }
>   }
> - *size = SHA256_SUM_LEN;
> + if (size)
> + *size = SHA256_SUM_LEN;
>
> - hash_calculate("sha256", regs->reg, regs->num, *hash);
> + hash_calculate("sha256", regs, count, *hash);
>  #ifdef DEBUG
>   EFI_PRINT("hash calculated:\n");
>   print_hex_dump("", DUMP_PREFIX_OFFSET, 16, 1,
> @@ -73,26 +76,10 @@ static bool efi_hash_msg_content(struct pkcs7_message 
> *msg, void **hash,
>  {
>   struct image_region regtmp;
>
> - *size = 0;
> - *hash = calloc(1, SHA256_SUM_LEN);
> - if (!*hash) {
> - EFI_PRINT("Out of memory\n");
> - free(msg);
> - return false;
> - }
> - *size = SHA256_SUM_LEN;
> -
>   regtmp.data = msg->data;
>   regtmp.size = msg->data_len;
>
> - hash_calculate("sha256", , 1, *hash);
> -#ifdef DEBUG
> - EFI_PRINT("hash calculated based on contentInfo:\n");
> - print_hex_dump("", DUMP_PREFIX_OFFSET, 16, 1,
> -*hash, SHA256_SUM_LEN, false);
> -#endif
> -
> - return true;
> + return efi_hash_regions(, 1, hash, size);
>  }
>
>  /**
> @@ -170,9 +157,10 @@ static bool efi_signature_verify(struct 
> efi_image_regions *regs,
>  false);
>  #endif
>   /* against contentInfo first */
> + hash = NULL;
>   if ((msg->data && efi_hash_msg_content(msg, , )) ||
>   /* for signed image */
> - efi_hash_regions(regs, , )) {
> + efi_hash_regions(regs->reg, regs->num, , )) {
>   /* for authenticated variable */
>   if (ps_info->msgdigest_len != size ||
>   memcmp(hash, ps_info->msgdigest, size)) {
> @@ -240,7 +228,7 @@ bool efi_signature_verify_with_list(struct 
> efi_image_regions *regs,
> regs, signed_info, siglist, valid_cert);
>
>   if (!signed_info) {
> - void *hash;
> + void *hash = NULL;
>   size_t size;
>
>   EFI_PRINT("%s: unsigned image\n", __func__);
> @@ -254,7 +242,7 @@ bool efi_signature_verify_with_list(struct 
> efi_image_regions *regs,
>   goto out;
>   }
>
> - if (!efi_hash_regions(regs, , )) {
> + if (!efi_hash_regions(regs->reg, regs->num, , )) {
>   EFI_PRINT("Digesting unsigned image failed\n");
>   goto out;
>   }
>



Re: [PATCH v4 04/14] dtoc: add support to scan drivers

2020-07-03 Thread Walter Lozano



On 2/7/20 16:47, Simon Glass wrote:

Hi Walter,

On Thu, 25 Jun 2020 at 19:43, Simon Glass  wrote:

On Wed, 24 Jun 2020 at 22:10, 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 and aliases. This allows to generate U_BOOT_DEVICE entries using
valid driver names and rise a warning in the case a name is not valid.

Signed-off-by: Walter Lozano 
---

  tools/dtoc/dtb_platdata.py | 91 --
  tools/dtoc/test_dtoc.py| 33 ++
  2 files changed, 120 insertions(+), 4 deletions(-)


Reviewed-by: Simon Glass 

Unfortunately this patch seems to be missing a file
dtoc_test_driver_alias.dts without which the tests fail. Can you
please resend just this patch?



Sorry for the mistake. I've just sent the patch.

Thanks for your time and deep review.

Regards,

Walter



[PATCH v5 04/14] dtoc: add support to scan drivers

2020-07-03 Thread Walter Lozano
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 and aliases. This allows to generate U_BOOT_DEVICE entries using
valid driver names and rise a warning in the case a name is not valid.

Signed-off-by: Walter Lozano 
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py| 91 +--
 tools/dtoc/dtoc_test_driver_alias.dts | 20 ++
 tools/dtoc/test_dtoc.py   | 33 ++
 3 files changed, 140 insertions(+), 4 deletions(-)
 create mode 100644 tools/dtoc/dtoc_test_driver_alias.dts

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index bc0de426a9..ae8674d85c 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
@@ -143,6 +145,11 @@ class DtbPlatdata(object):
 _aliases: Dict that hold aliases for compatible strings
 key: First compatible string declared in a node
 value: List of additional compatible strings declared in a node
+_drivers: List of valid driver names found in drivers/
+_driver_aliases: Dict that holds aliases for driver names
+key: Driver alias declared with
+U_BOOT_DRIVER_ALIAS(driver_alias, driver_name)
+value: Driver name declared with U_BOOT_DRIVER(driver_name)
 """
 def __init__(self, dtb_fname, include_disabled):
 self._fdt = None
@@ -152,6 +159,38 @@ 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 performing a check against _drivers
+and a lookup in driver_aliases printing a warning in case of failure.
+
+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)
+In case of no match found, the return will be the same as
+get_compat_name()
+"""
+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))
+compat_c = compat_c_old
+else:
+aliases_c = [compat_c_old] + aliases_c
+
+return compat_c, aliases_c
 
 def setup_output(self, fname):
 """Set up the output destination
@@ -246,6 +285,49 @@ 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 aliases
+
+This procedure will populate self._drivers and self._driver_aliases
+
+Args
+fn: Driver filename to scan
+"""
+with open(fn) as fd:
+buff = fd.read()
+
+# The following re will search for driver names declared as
+# U_BOOT_DRIVER(driver_name)
+drivers = re.findall('U_BOOT_DRIVER\((.*)\)', buff)
+
+for driver in drivers:
+self._drivers.append(driver)
+
+# The following re will search for driver aliases declared as
+# U_BOOT_DRIVER_ALIAS(alias, driver_name)
+driver_aliases = 
re.findall('U_BOOT_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)',
+buff)
+
+for alias in driver_aliases: # pragma: no cover
+if len(alias) != 2:
+continue
+self._driver_aliases[alias[1]] = alias[0]
+
+def scan_drivers(self):
+"""Scan the driver folders to build a list of driver names and aliases
+
+This procedure will populate self._drivers and self._driver_aliases
+
+"""
+basedir = sys.argv[0].replace('tools/dtoc/dtoc', '')
+if basedir == '':
+basedir = './'
+for (dirpath, dirnames, filenames) in os.walk(basedir):
+for fn in 

Re: [PATCH v2 08/17] efi_loader: signature: fix a size check against revocation list

2020-07-03 Thread Heinrich Schuchardt
On 09.06.20 07:09, AKASHI Takahiro wrote:
> Since the size check against an entry in efi_search_siglist() is
> incorrect, this function will never find out a to-be-matched certificate
> and its associated revocation time in the signature list.
>
> Signed-off-by: AKASHI Takahiro 
> ---
>  lib/efi_loader/efi_signature.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c
> index a05c75472721..f22dc151971f 100644
> --- a/lib/efi_loader/efi_signature.c
> +++ b/lib/efi_loader/efi_signature.c
> @@ -434,10 +434,11 @@ static bool efi_search_siglist(struct x509_certificate 
> *cert,
>*  time64_t revocation_time;
>* };
>*/
> - if ((sig_data->size == SHA256_SUM_LEN) &&
> - !memcmp(sig_data->data, hash, SHA256_SUM_LEN)) {
> + if ((sig_data->size >= SHA256_SUM_LEN + sizeof(time64_t)) &&
> + !memcmp(sig_data->data, msg, SHA256_SUM_LEN)) {
>   memcpy(revoc_time, sig_data->data + SHA256_SUM_LEN,
>  sizeof(*revoc_time));
> + EFI_PRINT("revocation time: %llu\n", *revoc_time);

*revoc_time is of type __s64. So this must be %lld. Cf.

include/linux/time.h:156

Best regards

Heinrich

>   found = true;
>   goto out;
>   }
>



Re: [PATCH v2 06/17] efi_loader: image_loader: add a check against certificate type of authenticode

2020-07-03 Thread Heinrich Schuchardt
On 09.06.20 07:09, AKASHI Takahiro wrote:
> UEFI specification requires that we shall support three type of
> certificates of authenticode in PE image:
>   WIN_CERT_TYPE_EFI_GUID with the guid, EFI_CERT_TYPE_PCKS7_GUID
>   WIN_CERT_TYPE_PKCS_SIGNED_DATA
>   WIN_CERT_TYPE_EFI_PKCS1_15
>
> As EDK2 does, we will support the first two that are pkcs7 SignedData.
>
> Signed-off-by: AKASHI Takahiro 
> ---
>  lib/efi_loader/efi_image_loader.c | 56 ---
>  1 file changed, 44 insertions(+), 12 deletions(-)
>
> diff --git a/lib/efi_loader/efi_image_loader.c 
> b/lib/efi_loader/efi_image_loader.c
> index 5b00fea2f113..38b2c24ab1d6 100644
> --- a/lib/efi_loader/efi_image_loader.c
> +++ b/lib/efi_loader/efi_image_loader.c
> @@ -484,7 +484,8 @@ static bool efi_image_authenticate(void *efi, size_t 
> efi_size)
>   struct efi_signature_store *db = NULL, *dbx = NULL;
>   struct x509_certificate *cert = NULL;
>   void *new_efi = NULL;
> - size_t new_efi_size;
> + u8 *auth, *wincerts_end;
> + size_t new_efi_size, auth_size;
>   bool ret = false;
>
>   if (!efi_secure_boot_enabled())
> @@ -533,21 +534,52 @@ static bool efi_image_authenticate(void *efi, size_t 
> efi_size)
>   }
>
>   /* go through WIN_CERTIFICATE list */
> - for (wincert = wincerts;
> -  (void *)wincert < (void *)wincerts + wincerts_len;
> -  wincert = (void *)wincert + ALIGN(wincert->dwLength, 8)) {
> - if (wincert->dwLength < sizeof(*wincert)) {
> - EFI_PRINT("%s: dwLength too small: %u < %zu\n",
> -   __func__, wincert->dwLength,
> -   sizeof(*wincert));
> - goto err;
> + for (wincert = wincerts, wincerts_end = (u8 *)wincerts + wincerts_len;
> +  (u8 *)wincert < wincerts_end;

Shouldn't you compare the end of the current certificate to wincerts_end?

((u8 *)wincert + ALIGN(wincert->dwLength, 8))) <= wincerts_end

But you doing such a comparison anyway two lines below. So there is no
need to duplicate the test here.

> +  wincert = (WIN_CERTIFICATE *)
> + ((u8 *)wincert + ALIGN(wincert->dwLength, 8))) {
> + if ((u8 *)wincert + sizeof(*wincert) >= wincerts_end)
> + break;

Why is this >= and not >?

Best regards

Heinrich

> +
> + if (wincert->dwLength <= sizeof(*wincert)) {
> + EFI_PRINT("dwLength too small: %u < %zu\n",
> +   wincert->dwLength, sizeof(*wincert));
> + continue;
> + }
> +
> + EFI_PRINT("WIN_CERTIFICATE_TYPE: 0x%x\n",
> +   wincert->wCertificateType);
> +
> + auth = (u8 *)wincert + sizeof(*wincert);
> + auth_size = wincert->dwLength - sizeof(*wincert);
> + if (wincert->wCertificateType == WIN_CERT_TYPE_EFI_GUID) {
> + if (auth + sizeof(efi_guid_t) >= wincerts_end)
> + break;
> +
> + if (auth_size <= sizeof(efi_guid_t)) {
> + EFI_PRINT("dwLength too small: %u < %zu\n",
> +   wincert->dwLength, sizeof(*wincert));
> + continue;
> + }
> + if (guidcmp(auth, _guid_cert_type_pkcs7)) {
> + EFI_PRINT("Certificate type not supported: 
> %pUl\n",
> +   auth);
> + continue;
> + }
> +
> + auth += sizeof(efi_guid_t);
> + auth_size -= sizeof(efi_guid_t);
> + } else if (wincert->wCertificateType
> + != WIN_CERT_TYPE_PKCS_SIGNED_DATA) {
> + EFI_PRINT("Certificate type not supported\n");
> + continue;
>   }
> - msg = pkcs7_parse_message((void *)wincert + sizeof(*wincert),
> -   wincert->dwLength - sizeof(*wincert));
> +
> + msg = pkcs7_parse_message(auth, auth_size);
>   if (IS_ERR(msg)) {
>   EFI_PRINT("Parsing image's signature failed\n");
>   msg = NULL;
> - goto err;
> + continue;
>   }
>
>   /* try black-list first */
>



Re: [PATCH v2 05/17] efi_loader: image_loader: replace debug to EFI_PRINT

2020-07-03 Thread Heinrich Schuchardt
On 09.06.20 07:09, AKASHI Takahiro wrote:
> Just for style consistency, replace all the uses of debug() to
> EFI_PRINT() in efi_image_loader.c.
>
> Signed-off-by: AKASHI Takahiro 

Reviewed-by: Heinrich Schuchardt 


Re: [PATCH v2 03/17] efi_loader: signature: replace debug to EFI_PRINT

2020-07-03 Thread Heinrich Schuchardt
On 09.06.20 07:09, AKASHI Takahiro wrote:
> Just for style consistency, replace all the uses of debug to
> EFI_PRINT in efi_signature.c
>
> Signed-off-by: AKASHI Takahiro 

Reviewed-by: Heinrich Schuchardt 


Re: [PATCH v2 02/17] Revert "test: stabilize test_efi_secboot"

2020-07-03 Thread Heinrich Schuchardt
On 09.06.20 07:09, AKASHI Takahiro wrote:
> This reverts commit 5827c2545849441dd60467565aac11964259972f.
>
> Signed-off-by: AKASHI Takahiro 

Reviewed-by: Heinrich Schuchardt 


Re: [PATCH v2 01/17] efi_loader: change efi objects initialization order

2020-07-03 Thread Heinrich Schuchardt
On 09.06.20 07:09, AKASHI Takahiro wrote:
> The simplest solution to revert the commit b32ac16f9a32 ("test/py: fix
> test_efi_secboot/conftest.py") is to move efi_console_register()
> forward before efi_disk_register().
>
> Signed-off-by: AKASHI Takahiro 

Reviewed-by: Heinrich Schuchardt 


Re: [PATCH] rockchip: rk3288: Add OF board setup

2020-07-03 Thread Jagan Teki
On Thu, Jul 2, 2020 at 7:26 PM Robin Murphy  wrote:
>
> On 2020-07-02 09:48, Jagan Teki wrote:
> > The new rk3288 revision rk3288w has some changes with respect
> > to legacy rk3288 like hclk_vio and usb host0 ohci.
> >
> > In order to work these on the same in Linux kernel update the
> > compatible the root compatible with rockchip,rk3288w before
> > booting.
> >
> > So, this support during of board setup code of rk3288.
> >
> > Signed-off-by: Jagan Teki 
> > ---
> >   arch/arm/mach-rockchip/Kconfig |  1 +
> >   arch/arm/mach-rockchip/rk3288/rk3288.c | 26 ++
> >   2 files changed, 27 insertions(+)
> >
> > diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> > index b1008a5058..822d8d4e9c 100644
> > --- a/arch/arm/mach-rockchip/Kconfig
> > +++ b/arch/arm/mach-rockchip/Kconfig
> > @@ -98,6 +98,7 @@ config ROCKCHIP_RK322X
> >   config ROCKCHIP_RK3288
> >   bool "Support Rockchip RK3288"
> >   select CPU_V7A
> > + select OF_BOARD_SETUP
> >   select SUPPORT_SPL
> >   select SPL
> >   select SUPPORT_TPL
> > diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c 
> > b/arch/arm/mach-rockchip/rk3288/rk3288.c
> > index 804abe8a1b..8a682675e6 100644
> > --- a/arch/arm/mach-rockchip/rk3288/rk3288.c
> > +++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
> > @@ -115,6 +115,32 @@ int rk_board_late_init(void)
> >   return rk3288_board_late_init();
> >   }
> >
> > +#ifdef CONFIG_OF_BOARD_SETUP
> > +
> > +#define RK3288_HDMI_PHYS 0xff98
> > +#define RK3288W_HDMI_REV 0x1A
> > +#define HDMI_CONFIG0_ID  0x04
> > +
> > +int ft_board_setup(void *blob, bd_t *bd)
> > +{
> > + u8 config0;
> > + int ret;
> > +
> > + config0 = readb(RK3288_HDMI_PHYS + HDMI_CONFIG0_ID);
> > + if (config0 == RK3288W_HDMI_REV) {
> > + ret = fdt_setprop_string(blob, 0,
> > +  "compatible", "rockchip,rk3288w");
>
> Does this end up replacing the entire top-level compatible property?
> i.e. from:
>
> compatible = "vendor,board\0rockchip,rk3288";
>
> to just:
>
> compatible = "rockchip,rk3288w";
>
> If so, that's a bit of a problem for various drivers that care about the
> actual board compatible rather than the SoC.

Yes, It looks replacing the entire compatible. I think the root
compatible is mostly untouchable because of this reason.

But, if we skip the root compatible and trying to replace individual
nodes for W revision then it requires extra registration code on in
the Linux drivers like Linux clock driver is registering the clock
with rockchip,rk3288-cru but updating this compatible with
rockchip,rk3288w-cru will require another registration code. Having
common rockchip,rk3288w can be possible to check any code in the tree.

Jagan.


[PATCH] sunxi: Add support for using UART4 as console on A64

2020-07-03 Thread Nazım Gediz Aydındoğmuş
Add some additional tests and definitions to be able to use UART4 of A64 and do 
not let it get in conflict with R_UART of some other SoCs (e.g. A23).

Signed-off-by: Nazım Gediz Aydındoğmuş 
---

 arch/arm/include/asm/arch-sunxi/gpio.h | 1 +
 arch/arm/mach-sunxi/board.c| 4 
 arch/arm/mach-sunxi/clock_sun6i.c  | 3 ++-
 include/configs/sunxi-common.h | 4 
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h 
b/arch/arm/include/asm/arch-sunxi/gpio.h
index a646ea6a3c..1407aff25f 100644
--- a/arch/arm/include/asm/arch-sunxi/gpio.h
+++ b/arch/arm/include/asm/arch-sunxi/gpio.h
@@ -176,6 +176,7 @@ enum sunxi_gpio_number {
 #define SUNXI_GPD_LCD0 2
 #define SUNXI_GPD_LVDS03
 #define SUNXI_GPD_PWM  2
+#define SUN50I_GPD_UART4   3
 
 #define SUN5I_GPE_SDC2 3
 #define SUN8I_GPE_TWI2 3
diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index f40fccd8f8..7d95b7dd29 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -140,6 +140,10 @@ static int gpio_init(void)
sunxi_gpio_set_cfgpin(SUNXI_GPL(2), SUN8I_GPL_R_UART);
sunxi_gpio_set_cfgpin(SUNXI_GPL(3), SUN8I_GPL_R_UART);
sunxi_gpio_set_pull(SUNXI_GPL(3), SUNXI_GPIO_PULL_UP);
+#elif CONFIG_CONS_INDEX == 5 && defined(CONFIG_MACH_SUN50I)
+   sunxi_gpio_set_cfgpin(SUNXI_GPD(2), SUN50I_GPD_UART4);
+   sunxi_gpio_set_cfgpin(SUNXI_GPD(3), SUN50I_GPD_UART4);
+   sunxi_gpio_set_pull(SUNXI_GPD(3), SUNXI_GPIO_PULL_UP);
 #else
 #error Unsupported console port number. Please fix pin mux settings in board.c
 #endif
diff --git a/arch/arm/mach-sunxi/clock_sun6i.c 
b/arch/arm/mach-sunxi/clock_sun6i.c
index 8e84062bd7..1f13b96be3 100644
--- a/arch/arm/mach-sunxi/clock_sun6i.c
+++ b/arch/arm/mach-sunxi/clock_sun6i.c
@@ -83,7 +83,8 @@ void clock_init_sec(void)
 
 void clock_init_uart(void)
 {
-#if CONFIG_CONS_INDEX < 5
+#if CONFIG_CONS_INDEX < 5 || \
+defined(CONFIG_MACH_SUN50I) && CONFIG_CONS_INDEX < 6
struct sunxi_ccm_reg *const ccm =
(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
 
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 5b0bec0561..1324d60f60 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -45,8 +45,12 @@
 # define CONFIG_SYS_NS16550_COM2   SUNXI_UART1_BASE
 # define CONFIG_SYS_NS16550_COM3   SUNXI_UART2_BASE
 # define CONFIG_SYS_NS16550_COM4   SUNXI_UART3_BASE
+#if defined(CONFIG_MACH_SUN50I)
+# define CONFIG_SYS_NS16550_COM5   SUNXI_UART4_BASE
+#else
 # define CONFIG_SYS_NS16550_COM5   SUNXI_R_UART_BASE
 #endif
+#endif
 
 /* CPU */
 #define COUNTER_FREQUENCY  2400
-- 
2.17.1



[U-Boot] Pull request: u-boot-riscv/master 2020-07-02(2)

2020-07-03 Thread uboot
Hi Tom,

This is version two of PR send by 7/2

Drop patchs about sysreset
[PATCH 1/5] sysreset: syscon: Don't assume default value for offset and mask 
property
[PATCH 2/5] sysreset: syscon: Support value property
[PATCH 4/5] riscv: qemu: Add syscon reboot and poweroff support

Please pull some riscv updates:

- sbi: Add newline to error message
- fu540: dts: Correct reg size of otp and dmc nodes
- Enhance reserved memory fixup about PMP information passed from OpenSbi
- sifive: fu540: Add gpio-restart support
- qemu-riscv: Update QEMU run command
- Assorted fixes related to reserved memory
- fu540: enable all cache ways from U-Boot proper
- use log functions in fdt_fixup

Thanks
Rick

https://travis-ci.org/github/rickchen36/u-boot-riscv/builds/703843003

The following changes since commit bcfe764ee925d0820e82c69ccf75b71d142644c7:

  Merge tag 'efi-2020-07-rc6-2' of 
https://gitlab.denx.de/u-boot/custodians/u-boot-efi (2020-06-30 17:15:39 -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 c5a444270f4f4d1f5418c97db9ff18631bf69846:

  riscv: use log functions in fdt_fixup (2020-07-03 15:09:12 +0800)


Atish Patra (2):
  riscv: Do not return error if reserved node already exists
  riscv: Use optimized version of fdtdec_get_addr_size_no_parent

Bin Meng (8):
  riscv: fu540: dts: Remove the unnecessary space in the cpu2_intc node
  riscv: fu540: dts: Correct reg size of otp and dmc nodes
  riscv: Avoid the reserved memory fixup if src and dst point to the same 
place
  riscv: Expand the DT size before copy reserved memory node
  riscv: Enable CONFIG_OF_BOARD_FIXUP by default for OF_SEPARATE
  riscv: Do not build reset.c if SYSRESET is on
  riscv: sifive: fu540: Add gpio-restart support
  doc: qemu-riscv: Update QEMU run command

Heinrich Schuchardt (1):
  riscv: use log functions in fdt_fixup

Pragnesh Patel (1):
  riscv: sifive: fu540: enable all cache ways from U-Boot proper

Sean Anderson (1):
  riscv: sbi: Add newline to error message

 arch/riscv/Kconfig|  3 +++
 arch/riscv/cpu/fu540/Makefile |  1 +
 arch/riscv/cpu/fu540/cache.c  | 53 
+
 arch/riscv/dts/fu540-c000-u-boot.dtsi | 10 +++---
 arch/riscv/include/asm/arch-fu540/cache.h | 14 ++
 arch/riscv/lib/Makefile   |  2 ++
 arch/riscv/lib/fdt_fixup.c| 46 
--
 board/sifive/fu540/Kconfig|  2 ++
 board/sifive/fu540/fu540.c| 10 +-
 common/spl/spl_opensbi.c  |  2 +-
 configs/sifive_fu540_defconfig|  1 -
 doc/board/emulation/qemu-riscv.rst| 10 +-
 12 files changed, 129 insertions(+), 25 deletions(-)
 create mode 100644 arch/riscv/cpu/fu540/cache.c
 create mode 100644 arch/riscv/include/asm/arch-fu540/cache.h


Re: [PATCH 06/13] arm: mach-k3: am6_init: Do USB fixups to facilitate host and device boot modes

2020-07-03 Thread Vignesh Raghavendra
Hi,

On 02/07/20 1:32 pm, Faiz Abbas wrote:

[...]
> int am6_spl_early_init(void)

Can this be static or do you intend to use this outside of this func file?

> +{
> + int ret;
> +#if CONFIG_VAL(SYS_MALLOC_F_LEN)
> +#ifdef CONFIG_MALLOC_F_ADDR
> + gd->malloc_base = CONFIG_MALLOC_F_ADDR;
> +#endif
> + gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN);
> + gd->malloc_ptr = 0;
> +#endif
> + ret = fdtdec_setup();
> + if (ret) {
> + printf("fdtdec_setup() returned error %d\n", ret);
> + return ret;
> + }
> +
> +#if CONFIG_IS_ENABLED(DFU) || CONFIG_IS_ENABLED(USB_STORAGE)
> + fixup_usb_boot();
> +#endif
> + /* With CONFIG_SPL_OF_PLATDATA, bring in all devices */
> + ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA));
> + if (ret) {
> + printf("dm_init_and_scan() returned error %d\n", ret);
> + return ret;
> + }
> +
> + gd->flags |= GD_FLG_SPL_EARLY_INIT;
> +
> + return 0;
> +}
>  void board_init_f(ulong dummy)
>  {
>  #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS)
> @@ -141,9 +206,8 @@ void board_init_f(ulong dummy)
>   disable_linefill_optimization();
>   setup_k3_mpu_regions();
>  #endif
> -
>   /* Init DM early in-order to invoke system controller */
> - spl_early_init();

I don't like this part as patch now open codes part of spl_early_init()
here and any fixes/enhancements to that core code would not be available
for am6 unless explicitly ported

How about having a arch specific post fdtdec_setup() hook instead, that
gets called from spl_common_init()?

> + am6_spl_early_init();
>  
>  #ifdef CONFIG_K3_EARLY_CONS
>   /*
> -- 2.17.1


Regards
Vignesh


Re: [Uboot-stm32] [PATCH v2 9/9] board: stm32mp1: move the function board_debug_uart_init in spl.c

2020-07-03 Thread Patrice CHOTARD
Hi Patrick

On 5/25/20 12:19 PM, Patrick Delaunay wrote:
> Move the debug function board_debug_uart_init in spl.c
> as the debug_uart_init() function is called in arch_cpu_init()
> only for SPL and remove the board.c file.
>
> For TFABOOT, the UART TX pin configuration is done in TF-A.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - NEW: merge spl.c and board.c to avoid a file with only one function
>
>  board/st/stm32mp1/Makefile |  2 --
>  board/st/stm32mp1/board.c  | 34 --
>  board/st/stm32mp1/spl.c| 26 ++
>  3 files changed, 26 insertions(+), 36 deletions(-)
>  delete mode 100644 board/st/stm32mp1/board.c
>
> diff --git a/board/st/stm32mp1/Makefile b/board/st/stm32mp1/Makefile
> index 8188075b1a..65560df290 100644
> --- a/board/st/stm32mp1/Makefile
> +++ b/board/st/stm32mp1/Makefile
> @@ -8,5 +8,3 @@ obj-y += spl.o
>  else
>  obj-y += stm32mp1.o
>  endif
> -
> -obj-y += board.o
> diff --git a/board/st/stm32mp1/board.c b/board/st/stm32mp1/board.c
> deleted file mode 100644
> index 1887941e57..00
> --- a/board/st/stm32mp1/board.c
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
> -/*
> - * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
> - */
> -
> -#include 
> -#include 
> -
> -#ifdef CONFIG_DEBUG_UART_BOARD_INIT
> -void board_debug_uart_init(void)
> -{
> -#if (CONFIG_DEBUG_UART_BASE == STM32_UART4_BASE)
> -
> -#define RCC_MP_APB1ENSETR (STM32_RCC_BASE + 0x0A00)
> -#define RCC_MP_AHB4ENSETR (STM32_RCC_BASE + 0x0A28)
> -
> - /* UART4 clock enable */
> - setbits_le32(RCC_MP_APB1ENSETR, BIT(16));
> -
> -#define GPIOG_BASE 0x50008000
> - /* GPIOG clock enable */
> - writel(BIT(6), RCC_MP_AHB4ENSETR);
> - /* GPIO configuration for EVAL board
> -  * => Uart4 TX = G11
> -  */
> - writel(0xffbf, GPIOG_BASE + 0x00);
> - writel(0x6000, GPIOG_BASE + 0x24);
> -#else
> -
> -#error("CONFIG_DEBUG_UART_BASE: not supported value")
> -
> -#endif
> -}
> -#endif
> diff --git a/board/st/stm32mp1/spl.c b/board/st/stm32mp1/spl.c
> index 96ab671169..977703f58a 100644
> --- a/board/st/stm32mp1/spl.c
> +++ b/board/st/stm32mp1/spl.c
> @@ -5,6 +5,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include "../common/stpmic1.h"
>  
>  /* board early initialisation in board_f: need to use global variable */
> @@ -23,3 +24,28 @@ int board_early_init_f(void)
>  
>   return 0;
>  }
> +
> +#ifdef CONFIG_DEBUG_UART_BOARD_INIT
> +void board_debug_uart_init(void)
> +{
> +#if (CONFIG_DEBUG_UART_BASE == STM32_UART4_BASE)
> +
> +#define RCC_MP_APB1ENSETR (STM32_RCC_BASE + 0x0A00)
> +#define RCC_MP_AHB4ENSETR (STM32_RCC_BASE + 0x0A28)
> +
> + /* UART4 clock enable */
> + setbits_le32(RCC_MP_APB1ENSETR, BIT(16));
> +
> +#define GPIOG_BASE 0x50008000
> + /* GPIOG clock enable */
> + writel(BIT(6), RCC_MP_AHB4ENSETR);
> + /* GPIO configuration for ST boards: Uart4 TX = G11 */
> + writel(0xffbf, GPIOG_BASE + 0x00);
> + writel(0x6000, GPIOG_BASE + 0x24);
> +#else
> +
> +#error("CONFIG_DEBUG_UART_BASE: not supported value")
> +
> +#endif
> +}
> +#endif

Reviewed-by: Patrice Chotard 

Thanks


Re: [Uboot-stm32] [PATCH v2 8/9] ARM: dts: stm32mp1: use OPP information for PLL1 settings in SPL

2020-07-03 Thread Patrice CHOTARD
HI Patrick

On 5/25/20 12:19 PM, Patrick Delaunay wrote:
> This patch allows to switch the CPU frequency to 800MHz on the
> ST Microelectronics board (DK1/DK2 and EV1) or dh electronics SOM
> using the STM32MP15x SOC and when it is supported by the HW
> (for STM32MP15xD and STM32MP15xF).
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - update stm32mp15xx-dhcor and dhcom device tree
>
>  arch/arm/dts/stm32mp15-u-boot.dtsi | 10 ++
>  arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi   |  9 -
>  arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi   |  9 -
>  arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi |  9 -
>  arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi |  9 -
>  5 files changed, 10 insertions(+), 36 deletions(-)
>
> diff --git a/arch/arm/dts/stm32mp15-u-boot.dtsi 
> b/arch/arm/dts/stm32mp15-u-boot.dtsi
> index a0d971ad88..66be7df9ae 100644
> --- a/arch/arm/dts/stm32mp15-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp15-u-boot.dtsi
> @@ -88,6 +88,16 @@
>   u-boot,dm-pre-reloc;
>  };
>  
> +_opp_table {
> + u-boot,dm-spl;
> + opp-65000 {
> + u-boot,dm-spl;
> + };
> + opp-8 {
> + u-boot,dm-spl;
> + };
> +};
> +
>   {
>   u-boot,dm-pre-reloc;
>  };
> diff --git a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi 
> b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
> index c52abeb1e7..69cdae6685 100644
> --- a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
> @@ -118,15 +118,6 @@
>   CLK_LPTIM45_LSE
>   >;
>  
> - /* VCO = 1300.0 MHz => P = 650 (CPU) */
> - pll1: st,pll@0 {
> - compatible = "st,stm32mp1-pll";
> - reg = <0>;
> - cfg = < 2 80 0 0 0 PQR(1,0,0) >;
> - frac = < 0x800 >;
> - u-boot,dm-pre-reloc;
> - };
> -
>   /* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
>   pll2: st,pll@1 {
>   compatible = "st,stm32mp1-pll";
> diff --git a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi 
> b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
> index 84af7fa47b..3f716306be 100644
> --- a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
> @@ -115,15 +115,6 @@
>   CLK_LPTIM45_LSE
>   >;
>  
> - /* VCO = 1300.0 MHz => P = 650 (CPU) */
> - pll1: st,pll@0 {
> - compatible = "st,stm32mp1-pll";
> - reg = <0>;
> - cfg = < 2 80 0 0 0 PQR(1,0,0) >;
> - frac = < 0x800 >;
> - u-boot,dm-pre-reloc;
> - };
> -
>   /* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
>   pll2: st,pll@1 {
>   compatible = "st,stm32mp1-pll";
> diff --git a/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi 
> b/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi
> index 75d75266e8..f96de9e7a3 100644
> --- a/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi
> @@ -235,15 +235,6 @@
>   CLK_LPTIM45_LSE
>   >;
>  
> - /* VCO = 1300.0 MHz => P = 650 (CPU) */
> - pll1: st,pll@0 {
> - compatible = "st,stm32mp1-pll";
> - reg = <0>;
> - cfg = < 2 80 0 0 0 PQR(1,0,0) >;
> - frac = < 0x800 >;
> - u-boot,dm-pre-reloc;
> - };
> -
>   /* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
>   pll2: st,pll@1 {
>   compatible = "st,stm32mp1-pll";
> diff --git a/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi 
> b/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi
> index ef730a8322..4059dabf1d 100644
> --- a/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi
> @@ -105,15 +105,6 @@
>   CLK_LPTIM45_LSE
>   >;
>  
> - /* VCO = 1300.0 MHz => P = 650 (CPU) */
> - pll1: st,pll@0 {
> - compatible = "st,stm32mp1-pll";
> - reg = <0>;
> - cfg = < 2 80 0 0 0 PQR(1,0,0) >;
> - frac = < 0x800 >;
> - u-boot,dm-pre-reloc;
> - };
> -
>   /* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU), R = 533 (DDR) */
>   pll2: st,pll@1 {
>   compatible = "st,stm32mp1-pll";

Reviewed-by: Patrice Chotard 

Thanks


Re: [Uboot-stm32] [PATCH v2 7/9] board: stm32mp1: update vddcore in SPL

2020-07-03 Thread Patrice CHOTARD
Hi Patrick

On 5/25/20 12:19 PM, Patrick Delaunay wrote:
> For board using STPMIC1, the vddcore is provided by BUCK1 of STPMIC1
> and need to be updated for 800MHz support and only after the clock
> tree initialization.
>
> The VDDCORE voltage value is provided by clock driver, saved in global
> variable opp_voltage_mv and udpated in SPL board_early_init_f(),
> just after clock tree initialization.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - stmpic_buck1_set is a static function called in stpmic1_init
>   (with new parameter for vddcore value)
> - update also dh_stm32mp1 board
>
>  board/dhelectronics/dh_stm32mp1/board.c |  9 -
>  board/st/common/stpmic1.c   | 23 ++-
>  board/st/common/stpmic1.h   |  2 +-
>  board/st/stm32mp1/spl.c | 11 ++-
>  4 files changed, 41 insertions(+), 4 deletions(-)
>
> diff --git a/board/dhelectronics/dh_stm32mp1/board.c 
> b/board/dhelectronics/dh_stm32mp1/board.c
> index df0810dbda..2ae97f677b 100644
> --- a/board/dhelectronics/dh_stm32mp1/board.c
> +++ b/board/dhelectronics/dh_stm32mp1/board.c
> @@ -136,6 +136,7 @@ int checkboard(void)
>  static u8 brdcode __section("data");
>  static u8 ddr3code __section("data");
>  static u8 somcode __section("data");
> +static u32 opp_voltage_mv __section(".data");
>  
>  static void board_get_coding_straps(void)
>  {
> @@ -193,10 +194,16 @@ int board_stm32mp1_ddr_config_name_match(struct udevice 
> *dev,
>   return -EINVAL;
>  }
>  
> +void board_vddcore_init(u32 voltage_mv)
> +{
> + if (IS_ENABLED(CONFIG_SPL_BUILD))
> + opp_voltage_mv = voltage_mv;
> +}
> +
>  int board_early_init_f(void)
>  {
>   if (IS_ENABLED(CONFIG_SPL_BUILD))
> - stpmic1_init();
> + stpmic1_init(opp_voltage_mv);
>   board_get_coding_straps();
>  
>   return 0;
> diff --git a/board/st/common/stpmic1.c b/board/st/common/stpmic1.c
> index 64f24f1f6f..47f9d95c29 100644
> --- a/board/st/common/stpmic1.c
> +++ b/board/st/common/stpmic1.c
> @@ -162,8 +162,25 @@ int board_ddr_power_init(enum ddr_type ddr_type)
>   return 0;
>  }
>  
> +static int stmpic_buck1_set(struct udevice *dev, u32 voltage_mv)
> +{
> + u32 value;
> +
> + /* VDDCORE= STMPCI1 BUCK1 ramp=+25mV, 5 => 725mV, 36 => 1500mV */
> + value = ((voltage_mv - 725) / 25) + 5;
> + if (value < 5)
> + value = 5;
> + if (value > 36)
> + value = 36;
> +
> + return pmic_clrsetbits(dev,
> +STPMIC1_BUCKX_MAIN_CR(STPMIC1_BUCK1),
> +STPMIC1_BUCK_VOUT_MASK,
> +STPMIC1_BUCK_VOUT(value));
> +}
> +
>  /* early init of PMIC */
> -void stpmic1_init(void)
> +void stpmic1_init(u32 voltage_mv)
>  {
>   struct udevice *dev;
>  
> @@ -171,6 +188,10 @@ void stpmic1_init(void)
>   DM_GET_DRIVER(pmic_stpmic1), ))
>   return;
>  
> + /* update VDDCORE = BUCK1 */
> + if (voltage_mv)
> + stmpic_buck1_set(dev, voltage_mv);
> +
>   /* Keep vdd on during the reset cycle */
>   pmic_clrsetbits(dev,
>   STPMIC1_BUCKS_MRST_CR,
> diff --git a/board/st/common/stpmic1.h b/board/st/common/stpmic1.h
> index ecc3276697..b17d6f1633 100644
> --- a/board/st/common/stpmic1.h
> +++ b/board/st/common/stpmic1.h
> @@ -3,4 +3,4 @@
>   * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
>   */
>  
> -void stpmic1_init(void);
> +void stpmic1_init(u32 voltage_mv);
> diff --git a/board/st/stm32mp1/spl.c b/board/st/stm32mp1/spl.c
> index 28efc5c0ae..96ab671169 100644
> --- a/board/st/stm32mp1/spl.c
> +++ b/board/st/stm32mp1/spl.c
> @@ -7,10 +7,19 @@
>  #include 
>  #include "../common/stpmic1.h"
>  
> +/* board early initialisation in board_f: need to use global variable */
> +static u32 opp_voltage_mv __section(".data");
> +
> +void board_vddcore_init(u32 voltage_mv)
> +{
> + if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER_SUPPORT))
> + opp_voltage_mv = voltage_mv;
> +}
> +
>  int board_early_init_f(void)
>  {
>   if (IS_ENABLED(CONFIG_PMIC_STPMIC1) && CONFIG_IS_ENABLED(POWER_SUPPORT))
> - stpmic1_init();
> + stpmic1_init(opp_voltage_mv);
>  
>   return 0;
>  }

Reviewed-by: Patrice Chotard 

Thanks


Re: [PATCH v2 6/9] board: st: stpmic1: add function stpmic1_init

2020-07-03 Thread Patrice CHOTARD
Hi Patrick

On 5/25/20 12:19 PM, Patrick Delaunay wrote:
> Add a function stmpic_init to early initialize the PMIC STPMIC1
> - keep vdd on during the reset cycle (to avoid issue when backup battery
>   is absent)
> - Check if debug is enabled to program PMIC according to the bit
>
> This patch allows to remove the compilation of spl.c file from stm32mp1
> board in dh_stm32mp1.
>
> CONFIG_SPL_BOARD_INIT is removed as the new function is called earlier
> in SPL, in the function board_early_init_f.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - add stpmic1_init function, called in board_early_init_f for
>   dh_stm32mp1 board support (and no more use spl.c from stm32mp1)
> - remove CONFIG_SPL_BOARD_INIT
>
>  arch/arm/mach-stm32mp/Kconfig|  1 -
>  board/dhelectronics/dh_stm32mp1/Makefile |  4 ---
>  board/dhelectronics/dh_stm32mp1/board.c  |  3 ++
>  board/st/common/stpmic1.c| 31 +++
>  board/st/common/stpmic1.h|  6 
>  board/st/stm32mp1/spl.c  | 39 +++-
>  board/st/stm32mp1/stm32mp1.c |  6 
>  configs/stm32mp15_basic_defconfig|  1 +
>  8 files changed, 52 insertions(+), 39 deletions(-)
>  create mode 100644 board/st/common/stpmic1.h
>
> diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
> index 6c995ed8d8..ea7d57477b 100644
> --- a/arch/arm/mach-stm32mp/Kconfig
> +++ b/arch/arm/mach-stm32mp/Kconfig
> @@ -1,7 +1,6 @@
>  if ARCH_STM32MP
>  
>  config SPL
> - select SPL_BOARD_INIT
>   select SPL_CLK
>   select SPL_DM
>   select SPL_DM_SEQ_ALIAS
> diff --git a/board/dhelectronics/dh_stm32mp1/Makefile 
> b/board/dhelectronics/dh_stm32mp1/Makefile
> index 5758d9816b..b368b396a4 100644
> --- a/board/dhelectronics/dh_stm32mp1/Makefile
> +++ b/board/dhelectronics/dh_stm32mp1/Makefile
> @@ -3,10 +3,6 @@
>  # Copyright (C) 2018, STMicroelectronics - All Rights Reserved
>  #
>  
> -ifdef CONFIG_SPL_BUILD
> -obj-y += ../../st/stm32mp1/spl.o
> -endif
> -
>  obj-y += ../../st/common/stpmic1.o board.o
>  
>  obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o
> diff --git a/board/dhelectronics/dh_stm32mp1/board.c 
> b/board/dhelectronics/dh_stm32mp1/board.c
> index 85d56f6082..df0810dbda 100644
> --- a/board/dhelectronics/dh_stm32mp1/board.c
> +++ b/board/dhelectronics/dh_stm32mp1/board.c
> @@ -37,6 +37,7 @@
>  #include 
>  #include 
>  #include 
> +#include "../../st/common/stpmic1.h"
>  
>  /* SYSCFG registers */
>  #define SYSCFG_BOOTR 0x00
> @@ -194,6 +195,8 @@ int board_stm32mp1_ddr_config_name_match(struct udevice 
> *dev,
>  
>  int board_early_init_f(void)
>  {
> + if (IS_ENABLED(CONFIG_SPL_BUILD))
> + stpmic1_init();
>   board_get_coding_straps();
>  
>   return 0;
> diff --git a/board/st/common/stpmic1.c b/board/st/common/stpmic1.c
> index ca10a2246b..64f24f1f6f 100644
> --- a/board/st/common/stpmic1.c
> +++ b/board/st/common/stpmic1.c
> @@ -5,6 +5,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -160,3 +161,33 @@ int board_ddr_power_init(enum ddr_type ddr_type)
>  
>   return 0;
>  }
> +
> +/* early init of PMIC */
> +void stpmic1_init(void)
> +{
> + struct udevice *dev;
> +
> + if (uclass_get_device_by_driver(UCLASS_PMIC,
> + DM_GET_DRIVER(pmic_stpmic1), ))
> + return;
> +
> + /* Keep vdd on during the reset cycle */
> + pmic_clrsetbits(dev,
> + STPMIC1_BUCKS_MRST_CR,
> + STPMIC1_MRST_BUCK(STPMIC1_BUCK3),
> + STPMIC1_MRST_BUCK(STPMIC1_BUCK3));
> +
> + /* Check if debug is enabled to program PMIC according to the bit */
> + if (readl(TAMP_BOOT_CONTEXT) & TAMP_BOOT_DEBUG_ON) {
> + printf("Keep debug unit ON\n");
> +
> + pmic_clrsetbits(dev, STPMIC1_BUCKS_MRST_CR,
> + STPMIC1_MRST_BUCK_DEBUG,
> + STPMIC1_MRST_BUCK_DEBUG);
> +
> + if (STPMIC1_MRST_LDO_DEBUG)
> + pmic_clrsetbits(dev, STPMIC1_LDOS_MRST_CR,
> + STPMIC1_MRST_LDO_DEBUG,
> + STPMIC1_MRST_LDO_DEBUG);
> + }
> +}
> diff --git a/board/st/common/stpmic1.h b/board/st/common/stpmic1.h
> new file mode 100644
> index 00..ecc3276697
> --- /dev/null
> +++ b/board/st/common/stpmic1.h
> @@ -0,0 +1,6 @@
> +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
> +/*
> + * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
> + */
> +
> +void stpmic1_init(void);
> diff --git a/board/st/stm32mp1/spl.c b/board/st/stm32mp1/spl.c
> index e65ff288ea..28efc5c0ae 100644
> --- a/board/st/stm32mp1/spl.c
> +++ b/board/st/stm32mp1/spl.c
> @@ -5,41 +5,12 @@
>  
>  #include 
>  #include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> 

RE: [PATCH v2 1/5] dt-bindings: prci: add indexes for reset signals available in prci

2020-07-03 Thread Sagar Kadam
Hi Jagan,

> -Original Message-
> From: Jagan Teki 
> Sent: Friday, July 3, 2020 12:04 PM
> To: Sagar Kadam 
> Cc: U-Boot-Denx ; Rick Chen ;
> Paul Walmsley ( Sifive) ; Palmer Dabbelt
> ; Anup Patel ; Atish Patra
> ; Lukasz Majewski ; Pragnesh
> Patel ; bin.m...@windriver.com; Simon Glass
> ; Trevor Woerner ; Eugeniy
> Paltsev ; Patrick Wildt
> ; Weijie Gao ; Fabio
> Estevam 
> Subject: Re: [PATCH v2 1/5] dt-bindings: prci: add indexes for reset signals
> available in prci
> 
> [External Email] Do not click links or attachments unless you recognize the
> sender and know the content is safe
> 
> On Fri, Jul 3, 2020 at 11:52 AM Sagar Kadam 
> wrote:
> >
> >
> > > -Original Message-
> > > From: U-Boot  On Behalf Of Sagar
> Kadam
> > > Sent: Monday, June 29, 2020 9:37 PM
> > > To: Jagan Teki 
> > > Cc: U-Boot-Denx ; Rick Chen
> > > ; Paul Walmsley ( Sifive)
> > > ; Palmer Dabbelt ;
> > > Anup Patel ; Atish Patra
> ;
> > > Lukasz Majewski ; Pragnesh Patel
> > > ; bin.m...@windriver.com; Simon Glass
> > > ; Trevor Woerner ; Eugeniy
> > > Paltsev ; Patrick Wildt
> > > ; Weijie Gao ; Fabio
> > > Estevam 
> > > Subject: RE: [PATCH v2 1/5] dt-bindings: prci: add indexes for reset
> > > signals available in prci
> > >
> > > Hello Jagan,
> > > > -Original Message-
> > > > From: Jagan Teki 
> > > > Sent: Monday, June 29, 2020 9:00 PM
> > > > To: Sagar Kadam 
> > > > Cc: U-Boot-Denx ; Rick Chen
> > > > ; Paul Walmsley ( Sifive)
> > > > ; Palmer Dabbelt ;
> > > Anup
> > > > Patel ; Atish Patra ;
> > > > Lukasz Majewski ; Pragnesh Patel
> > > ;
> > > > bin.m...@windriver.com; Simon Glass ; Trevor
> > > Woerner
> > > > ; Eugeniy Paltsev
> > > ;
> > > > Patrick Wildt ; Weijie Gao
> > > > ; Fabio Estevam 
> > > > Subject: Re: [PATCH v2 1/5] dt-bindings: prci: add indexes for
> > > > reset signals available in prci
> > > >
> > > > [External Email] Do not click links or attachments unless you
> > > > recognize the sender and know the content is safe
> > > >
> > > > On Fri, Jun 26, 2020 at 8:51 AM Sagar Kadam
> > > > 
> > > > wrote:
> > > > >
> > > > > Hi Jagan,
> > > > >
> > > > > > -Original Message-
> > > > > > From: Jagan Teki 
> > > > > > Sent: Thursday, June 25, 2020 11:13 PM
> > > > > > To: Sagar Kadam 
> > > > > > Cc: U-Boot-Denx ; Rick Chen
> > > > ;
> > > > > > Paul Walmsley ( Sifive) ; Palmer
> > > > > > Dabbelt ; Anup Patel
> ;
> > > > > > Atish
> > > > Patra
> > > > > > ; Lukasz Majewski ;
> > > Pragnesh
> > > > > > Patel ; bin.m...@windriver.com;
> > > > > > Simon
> > > > Glass
> > > > > > ; Trevor Woerner ;
> > > Eugeniy
> > > > > > Paltsev ; Patrick Wildt
> > > > > > ; Weijie Gao ;
> > > > > > Fabio Estevam 
> > > > > > Subject: Re: [PATCH v2 1/5] dt-bindings: prci: add indexes for
> > > > > > reset
> > > > signals
> > > > > > available in prci
> > > > > >
> > > > > > [External Email] Do not click links or attachments unless you
> > > > > > recognize
> > > > the
> > > > > > sender and know the content is safe
> > > > > >
> > > > > > On Thu, Jun 25, 2020 at 5:56 PM Sagar Shrikant Kadam
> > > > > >  wrote:
> > > > > > >
> > > > > > > Add bit indexes for reset signals within the PRCI module on
> > > > > > > FU540-C000 SoC.
> > > > > > > The DDR and ethernet sub-system's have reset signals
> > > > > > > indicated by these reset indexes.
> > > > > > >
> > > > > > > Signed-off-by: Sagar Shrikant Kadam 
> > > > > > > Reviewed-by: Pragnesh Patel 
> > > > > > > Reviewed-by: Bin Meng 
> > > > > > > ---
> > > > > > >  include/dt-bindings/clock/sifive-fu540-prci.h | 8 
> > > > > > >  1 file changed, 8 insertions(+)
> > > > > > >
> > > > > > > diff --git a/include/dt-bindings/clock/sifive-fu540-prci.h
> > > > > > > b/include/dt-
> > > > > > bindings/clock/sifive-fu540-prci.h
> > > > > > > index 6a0b70a..1c03b09 100644
> > > > > > > --- a/include/dt-bindings/clock/sifive-fu540-prci.h
> > > > > > > +++ b/include/dt-bindings/clock/sifive-fu540-prci.h
> > > > > > > @@ -15,4 +15,12 @@
> > > > > > >  #define PRCI_CLK_GEMGXLPLL2
> > > > > > >  #define PRCI_CLK_TLCLK3
> > > > > > >
> > > > > > > +/* Reset bit indexes to be used by driver */
> > > > > > > +#define PRCI_RST_DDR_CTRL_N0
> > > > > > > +#define PRCI_RST_DDR_AXI_N 1
> > > > > > > +#define PRCI_RST_DDR_AHB_N 2
> > > > > > > +#define PRCI_RST_DDR_PHY_N 3
> > > > > > > +/* bit 4 is reserved bit */
> > > > > > > +#define PRCI_RST_RSVD_N4
> > > > > > > +#define PRCI_RST_GEMGXL_N  5
> > > > > > >  #endif
> > > > > >
> > > > > > Do these bindings are synced from Linux? If Yes better to sync
> > > > > > with a particular commit or tag rather than patch.
> > > > > >
> > > > >
> > > > > No, these reset bindings are not synced from Linux.
> > > >
> > > > This is synced file from Linux, better to inline with Linux files
> > > > always, if these bindings are not related to Linux then maintain
> > > > it in a separate file or support it in Linux first if they do
> > > > require for 

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

2020-07-03 Thread Bin Meng
Hi Rick,

On Fri, Jul 3, 2020 at 2:01 PM Rick Chen  wrote:
>
> > From: Tom Rini [mailto:tr...@konsulko.com]
> > Sent: Thursday, July 02, 2020 9:53 PM
> > To: Open Source Project uboot
> > Cc: u-boot@lists.denx.de; Rick Jian-Zhi Chen(陳建志)
> > Subject: Re: [U-Boot] Pull request: u-boot-riscv/master
> >
> > On Thu, Jul 02, 2020 at 10:51:48AM +0800, ub...@andestech.com wrote:
> >
> > > Hi Tom,
> > >
> > > Please pull some riscv updates:
> > >
> > > - sbi: Add newline to error message
> > > - fu540: dts: Correct reg size of otp and dmc nodes
> > > - Enhance reserved memory fixup about PMP information passed from
> > > OpenSbi
> > > - sifive: fu540: Add gpio-restart support
> > > - qemu: Add syscon reboot and poweroff support
> > > - qemu-riscv: Update QEMU run command
> > > - Assorted fixes related to reserved memory
> > > - fu540: enable all cache ways from U-Boot proper
> > > - use log functions in fdt_fixup
> >
> > This changes a few MIPS and ARM platforms.  We're a few days away from 
> > release, so I don't feel comfortable taking this right now as I assume it 
> > hasn't been tested on the other platforms as well.  Sorry.
>
> Hi Tom,
>
> Thanks for your suggestions.
>
>
> Hi Bin,
>
> Can you separate this series about sysreset into two series ?
> [PATCH 1/5] sysreset: syscon: Don't assume default value for offset
> and mask property
> [PATCH 2/5] sysreset: syscon: Support value property
> [PATCH 3/5] riscv: Do not build reset.c if SYSRESET is on
> [PATCH 4/5] riscv: qemu: Add syscon reboot and poweroff support
> [PATCH 5/5] riscv: sifive: fu540: Add gpio-restart support
>
> It looks like that patch 3/5, 4/5, 5/5 doesn't depend on patch 1/5 and 2/5.

Patch 3 and 5 can be targeted for this release, and let's do patch
1,2,4 for the next release.

So you can drop patch 1,2,4 in your queue and resend the PR. Thanks!

Regards,
Bin


Re: [PATCH v2 1/5] dt-bindings: prci: add indexes for reset signals available in prci

2020-07-03 Thread Jagan Teki
On Fri, Jul 3, 2020 at 11:52 AM Sagar Kadam  wrote:
>
>
> > -Original Message-
> > From: U-Boot  On Behalf Of Sagar Kadam
> > Sent: Monday, June 29, 2020 9:37 PM
> > To: Jagan Teki 
> > Cc: U-Boot-Denx ; Rick Chen ;
> > Paul Walmsley ( Sifive) ; Palmer Dabbelt
> > ; Anup Patel ; Atish Patra
> > ; Lukasz Majewski ; Pragnesh
> > Patel ; bin.m...@windriver.com; Simon Glass
> > ; Trevor Woerner ; Eugeniy
> > Paltsev ; Patrick Wildt
> > ; Weijie Gao ; Fabio
> > Estevam 
> > Subject: RE: [PATCH v2 1/5] dt-bindings: prci: add indexes for reset signals
> > available in prci
> >
> > Hello Jagan,
> > > -Original Message-
> > > From: Jagan Teki 
> > > Sent: Monday, June 29, 2020 9:00 PM
> > > To: Sagar Kadam 
> > > Cc: U-Boot-Denx ; Rick Chen
> > > ; Paul Walmsley ( Sifive)
> > > ; Palmer Dabbelt ;
> > Anup
> > > Patel ; Atish Patra ; Lukasz
> > > Majewski ; Pragnesh Patel
> > ;
> > > bin.m...@windriver.com; Simon Glass ; Trevor
> > Woerner
> > > ; Eugeniy Paltsev
> > ;
> > > Patrick Wildt ; Weijie Gao
> > > ; Fabio Estevam 
> > > Subject: Re: [PATCH v2 1/5] dt-bindings: prci: add indexes for reset
> > > signals available in prci
> > >
> > > [External Email] Do not click links or attachments unless you
> > > recognize the sender and know the content is safe
> > >
> > > On Fri, Jun 26, 2020 at 8:51 AM Sagar Kadam 
> > > wrote:
> > > >
> > > > Hi Jagan,
> > > >
> > > > > -Original Message-
> > > > > From: Jagan Teki 
> > > > > Sent: Thursday, June 25, 2020 11:13 PM
> > > > > To: Sagar Kadam 
> > > > > Cc: U-Boot-Denx ; Rick Chen
> > > ;
> > > > > Paul Walmsley ( Sifive) ; Palmer Dabbelt
> > > > > ; Anup Patel ; Atish
> > > Patra
> > > > > ; Lukasz Majewski ;
> > Pragnesh
> > > > > Patel ; bin.m...@windriver.com; Simon
> > > Glass
> > > > > ; Trevor Woerner ;
> > Eugeniy
> > > > > Paltsev ; Patrick Wildt
> > > > > ; Weijie Gao ; Fabio
> > > > > Estevam 
> > > > > Subject: Re: [PATCH v2 1/5] dt-bindings: prci: add indexes for
> > > > > reset
> > > signals
> > > > > available in prci
> > > > >
> > > > > [External Email] Do not click links or attachments unless you
> > > > > recognize
> > > the
> > > > > sender and know the content is safe
> > > > >
> > > > > On Thu, Jun 25, 2020 at 5:56 PM Sagar Shrikant Kadam
> > > > >  wrote:
> > > > > >
> > > > > > Add bit indexes for reset signals within the PRCI module on
> > > > > > FU540-C000 SoC.
> > > > > > The DDR and ethernet sub-system's have reset signals indicated
> > > > > > by these reset indexes.
> > > > > >
> > > > > > Signed-off-by: Sagar Shrikant Kadam 
> > > > > > Reviewed-by: Pragnesh Patel 
> > > > > > Reviewed-by: Bin Meng 
> > > > > > ---
> > > > > >  include/dt-bindings/clock/sifive-fu540-prci.h | 8 
> > > > > >  1 file changed, 8 insertions(+)
> > > > > >
> > > > > > diff --git a/include/dt-bindings/clock/sifive-fu540-prci.h
> > > > > > b/include/dt-
> > > > > bindings/clock/sifive-fu540-prci.h
> > > > > > index 6a0b70a..1c03b09 100644
> > > > > > --- a/include/dt-bindings/clock/sifive-fu540-prci.h
> > > > > > +++ b/include/dt-bindings/clock/sifive-fu540-prci.h
> > > > > > @@ -15,4 +15,12 @@
> > > > > >  #define PRCI_CLK_GEMGXLPLL2
> > > > > >  #define PRCI_CLK_TLCLK3
> > > > > >
> > > > > > +/* Reset bit indexes to be used by driver */
> > > > > > +#define PRCI_RST_DDR_CTRL_N0
> > > > > > +#define PRCI_RST_DDR_AXI_N 1
> > > > > > +#define PRCI_RST_DDR_AHB_N 2
> > > > > > +#define PRCI_RST_DDR_PHY_N 3
> > > > > > +/* bit 4 is reserved bit */
> > > > > > +#define PRCI_RST_RSVD_N4
> > > > > > +#define PRCI_RST_GEMGXL_N  5
> > > > > >  #endif
> > > > >
> > > > > Do these bindings are synced from Linux? If Yes better to sync
> > > > > with a particular commit or tag rather than patch.
> > > > >
> > > >
> > > > No, these reset bindings are not synced from Linux.
> > >
> > > This is synced file from Linux, better to inline with Linux files
> > > always, if these bindings are not related to Linux then maintain it in
> > > a separate file or support it in Linux first if they do require for
> > > Linux.
> > >
> > Ohh. Sorry I thought you were asking if reset-bindings are from Linux.
> > Yes this file is synced from Linux but these reset-bindings are not related 
> > to
> > Linux. So I can split it and place reset bindings into another file:
> > "include/dt-bindings/reset/sifive-fu540-reset.h"
>
> It will be "include/dt-bindings/reset/sifive-fu540-prci.h"

What if it would be the same directory structure and file name with
-u-boot.h extension. This way we can identify these are u-boot related
defines.

Jagan.


RE: [PATCH v2 1/5] dt-bindings: prci: add indexes for reset signals available in prci

2020-07-03 Thread Sagar Kadam

> -Original Message-
> From: U-Boot  On Behalf Of Sagar Kadam
> Sent: Monday, June 29, 2020 9:37 PM
> To: Jagan Teki 
> Cc: U-Boot-Denx ; Rick Chen ;
> Paul Walmsley ( Sifive) ; Palmer Dabbelt
> ; Anup Patel ; Atish Patra
> ; Lukasz Majewski ; Pragnesh
> Patel ; bin.m...@windriver.com; Simon Glass
> ; Trevor Woerner ; Eugeniy
> Paltsev ; Patrick Wildt
> ; Weijie Gao ; Fabio
> Estevam 
> Subject: RE: [PATCH v2 1/5] dt-bindings: prci: add indexes for reset signals
> available in prci
> 
> Hello Jagan,
> > -Original Message-
> > From: Jagan Teki 
> > Sent: Monday, June 29, 2020 9:00 PM
> > To: Sagar Kadam 
> > Cc: U-Boot-Denx ; Rick Chen
> > ; Paul Walmsley ( Sifive)
> > ; Palmer Dabbelt ;
> Anup
> > Patel ; Atish Patra ; Lukasz
> > Majewski ; Pragnesh Patel
> ;
> > bin.m...@windriver.com; Simon Glass ; Trevor
> Woerner
> > ; Eugeniy Paltsev
> ;
> > Patrick Wildt ; Weijie Gao
> > ; Fabio Estevam 
> > Subject: Re: [PATCH v2 1/5] dt-bindings: prci: add indexes for reset
> > signals available in prci
> >
> > [External Email] Do not click links or attachments unless you
> > recognize the sender and know the content is safe
> >
> > On Fri, Jun 26, 2020 at 8:51 AM Sagar Kadam 
> > wrote:
> > >
> > > Hi Jagan,
> > >
> > > > -Original Message-
> > > > From: Jagan Teki 
> > > > Sent: Thursday, June 25, 2020 11:13 PM
> > > > To: Sagar Kadam 
> > > > Cc: U-Boot-Denx ; Rick Chen
> > ;
> > > > Paul Walmsley ( Sifive) ; Palmer Dabbelt
> > > > ; Anup Patel ; Atish
> > Patra
> > > > ; Lukasz Majewski ;
> Pragnesh
> > > > Patel ; bin.m...@windriver.com; Simon
> > Glass
> > > > ; Trevor Woerner ;
> Eugeniy
> > > > Paltsev ; Patrick Wildt
> > > > ; Weijie Gao ; Fabio
> > > > Estevam 
> > > > Subject: Re: [PATCH v2 1/5] dt-bindings: prci: add indexes for
> > > > reset
> > signals
> > > > available in prci
> > > >
> > > > [External Email] Do not click links or attachments unless you
> > > > recognize
> > the
> > > > sender and know the content is safe
> > > >
> > > > On Thu, Jun 25, 2020 at 5:56 PM Sagar Shrikant Kadam
> > > >  wrote:
> > > > >
> > > > > Add bit indexes for reset signals within the PRCI module on
> > > > > FU540-C000 SoC.
> > > > > The DDR and ethernet sub-system's have reset signals indicated
> > > > > by these reset indexes.
> > > > >
> > > > > Signed-off-by: Sagar Shrikant Kadam 
> > > > > Reviewed-by: Pragnesh Patel 
> > > > > Reviewed-by: Bin Meng 
> > > > > ---
> > > > >  include/dt-bindings/clock/sifive-fu540-prci.h | 8 
> > > > >  1 file changed, 8 insertions(+)
> > > > >
> > > > > diff --git a/include/dt-bindings/clock/sifive-fu540-prci.h
> > > > > b/include/dt-
> > > > bindings/clock/sifive-fu540-prci.h
> > > > > index 6a0b70a..1c03b09 100644
> > > > > --- a/include/dt-bindings/clock/sifive-fu540-prci.h
> > > > > +++ b/include/dt-bindings/clock/sifive-fu540-prci.h
> > > > > @@ -15,4 +15,12 @@
> > > > >  #define PRCI_CLK_GEMGXLPLL2
> > > > >  #define PRCI_CLK_TLCLK3
> > > > >
> > > > > +/* Reset bit indexes to be used by driver */
> > > > > +#define PRCI_RST_DDR_CTRL_N0
> > > > > +#define PRCI_RST_DDR_AXI_N 1
> > > > > +#define PRCI_RST_DDR_AHB_N 2
> > > > > +#define PRCI_RST_DDR_PHY_N 3
> > > > > +/* bit 4 is reserved bit */
> > > > > +#define PRCI_RST_RSVD_N4
> > > > > +#define PRCI_RST_GEMGXL_N  5
> > > > >  #endif
> > > >
> > > > Do these bindings are synced from Linux? If Yes better to sync
> > > > with a particular commit or tag rather than patch.
> > > >
> > >
> > > No, these reset bindings are not synced from Linux.
> >
> > This is synced file from Linux, better to inline with Linux files
> > always, if these bindings are not related to Linux then maintain it in
> > a separate file or support it in Linux first if they do require for
> > Linux.
> >
> Ohh. Sorry I thought you were asking if reset-bindings are from Linux.
> Yes this file is synced from Linux but these reset-bindings are not related to
> Linux. So I can split it and place reset bindings into another file:
> "include/dt-bindings/reset/sifive-fu540-reset.h"

It will be "include/dt-bindings/reset/sifive-fu540-prci.h"

BR,
Sagar

> and include it wherever required.  Please let me know if this sounds okay.
> 
> Thanks & BR,
> Sagar Kadam
> 
> > Jagan.


Re: [PATCH v1 27/43] i2c: Add log_ret() on error

2020-07-03 Thread Heiko Schocher

Hello Simon,

Am 15.06.2020 um 05:57 schrieb Simon Glass:

Add a few of these calls to make it easier to see where an error occurs,
if CONFIG_LOG_ERROR_RETURN is enabled.

Signed-off-by: Simon Glass 
---

  drivers/i2c/i2c-uclass.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)


Reviewed-by: Heiko Schocher 

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH v1 28/43] i2c: designware_i2c: Support ACPI table generation

2020-07-03 Thread Heiko Schocher

Hello Simon,

Am 15.06.2020 um 05:57 schrieb Simon Glass:

Update the PCI driver to generate ACPI information so that Linux has the
full information about each I2C bus.

Signed-off-by: Simon Glass 

---

Changes in v1:
- Capitalise ACPI_OPS_PTR

  drivers/i2c/designware_i2c.c |  25 
  drivers/i2c/designware_i2c.h |  15 +
  drivers/i2c/designware_i2c_pci.c | 104 ++-
  3 files changed, 143 insertions(+), 1 deletion(-)


Reviewed-by: Heiko Schocher 

Some nitpicks...


diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index 44a1f33398..630938743f 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -333,6 +333,31 @@ static int _dw_i2c_set_bus_speed(struct dw_i2c *priv, 
struct i2c_regs *i2c_base,
/* Restore back i2c now speed set */
if (ena == IC_ENABLE_0B)
dw_i2c_enable(i2c_base, true);
+   if (priv)
+   priv->config = config;


Please add an empty line here.


+   return 0;
+}
+
+int dw_i2c_gen_speed_config(const struct udevice *dev, int speed_hz,
+   struct dw_i2c_speed_config *config)
+{
+   struct dw_i2c *priv = dev_get_priv(dev);
+   ulong rate;
+   int ret;
+
+#if CONFIG_IS_ENABLED(CLK)
+   rate = clk_get_rate(>clk);
+   if (IS_ERR_VALUE(rate))
+   return log_msg_ret("clk", -EINVAL);
+#else
+   rate = IC_CLK;
+#endif
+
+   ret = calc_bus_speed(priv, priv->regs, speed_hz, rate, config);
+   if (ret)
+   printf("%s: ret=%d\n", __func__, ret);
+   if (ret)
+   return log_msg_ret("calc_bus_speed", ret);
  
  	return 0;

  }


[...]

diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c
index bd34ec0b47..d5108e9064 100644
--- a/drivers/i2c/designware_i2c_pci.c
+++ b/drivers/i2c/designware_i2c_pci.c
@@ -9,7 +9,12 @@
  #include 
  #include 
  #include 
+#include 
+#include 
  #include 
+#include 
+#include 
+#include 
  #include "designware_i2c.h"
  
  enum {

@@ -87,6 +92,8 @@ static int designware_i2c_pci_bind(struct udevice *dev)
  {
char name[20];
  
+	if (dev_of_valid(dev))

+   return 0;


here too.


/*
 * Create a unique device name for PCI type devices
 * ToDo:
@@ -100,13 +107,107 @@ static int designware_i2c_pci_bind(struct udevice *dev)
 * be possible. We cannot use static data in drivers since they may be
 * used in SPL or before relocation.
 */
-   dev->req_seq = gd->arch.dw_i2c_num_cards++;
+   dev->req_seq = uclass_find_next_free_req_seq(UCLASS_I2C);
sprintf(name, "i2c_designware#%u", dev->req_seq);
device_set_name(dev, name);
  
  	return 0;

  }
  
+/*

+ * Write ACPI object to describe speed configuration.
+ *
+ * ACPI Object: Name ("", Package () { scl_lcnt, scl_hcnt, sda_hold }
+ *
+ * SSCN: I2C_SPEED_STANDARD
+ * FMCN: I2C_SPEED_FAST
+ * FPCN: I2C_SPEED_FAST_PLUS
+ * HSCN: I2C_SPEED_HIGH
+ */
+static void dw_i2c_acpi_write_speed_config(struct acpi_ctx *ctx,
+  struct dw_i2c_speed_config *config)
+{
+   switch (config->speed_mode) {
+   case IC_SPEED_MODE_HIGH:
+   acpigen_write_name(ctx, "HSCN");
+   break;
+   case IC_SPEED_MODE_FAST_PLUS:
+   acpigen_write_name(ctx, "FPCN");
+   break;
+   case IC_SPEED_MODE_FAST:
+   acpigen_write_name(ctx, "FMCN");
+   break;
+   case IC_SPEED_MODE_STANDARD:
+   default:
+   acpigen_write_name(ctx, "SSCN");
+   }
+
+   /* Package () { scl_lcnt, scl_hcnt, sda_hold } */
+   acpigen_write_package(ctx, 3);
+   acpigen_write_word(ctx, config->scl_hcnt);
+   acpigen_write_word(ctx, config->scl_lcnt);
+   acpigen_write_dword(ctx, config->sda_hold);
+   acpigen_pop_len(ctx);
+}
+
+/*
+ * Generate I2C timing information into the SSDT for the OS driver to consume,
+ * optionally applying override values provided by the caller.
+ */
+static int dw_i2c_acpi_fill_ssdt(const struct udevice *dev,
+struct acpi_ctx *ctx)
+{
+   struct dw_i2c_speed_config config;
+   char path[ACPI_PATH_MAX];
+   u32 speeds[4];
+   int size, i;
+   int ret;
+
+   /* If no device-tree node, ignore this since we assume it isn't used */
+   if (!dev_of_valid(dev))
+   return 0;


and here.


+   ret = acpi_device_path(dev, path, sizeof(path));
+   if (ret)
+   return log_msg_ret("path", ret);
+
+   size = dev_read_size(dev, "i2c,speeds");
+   if (size < 0)
+   return log_msg_ret("i2c,speeds", -EINVAL);


and here.


+   size /= sizeof(u32);
+   if (size > ARRAY_SIZE(speeds))
+   return log_msg_ret("array", -E2BIG);
+
+   ret = dev_read_u32_array(dev, "i2c,speeds", speeds, size);
+   if (ret)
+   return 

Re: [PATCH] checkpatch: fix a false check against wchar/utf-16 string

2020-07-03 Thread Heinrich Schuchardt
Am 3. Juli 2020 07:45:03 MESZ schrieb AKASHI Takahiro 
:
>On Thu, Jul 02, 2020 at 04:26:34PM -0400, Tom Rini wrote:
>> On Thu, Jul 02, 2020 at 07:00:04PM +0200, Heinrich Schuchardt wrote:
>> > On 16.06.20 16:17, Tom Rini wrote:
>> > > On Tue, Jun 16, 2020 at 02:43:07PM +0900, AKASHI Takahiro wrote:
>> > >
>> > >> UEFI subsystem uses utf-16 string, but checkpatch.pl complains
>> > >> about any occurrences of L"xxx" which is definitely legal.
>> > >> So just suppress this kind of warning.
>> > >> Precautiously, we will check u"xxx" as well.
>> > >>
>> > >> Signed-off-by: AKASHI Takahiro 
>> > >> ---
>> > >>  scripts/checkpatch.pl | 2 +-
>> > >>  1 file changed, 1 insertion(+), 1 deletion(-)
>> > >>
>> > >> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> > >> index edba36565167..b3697720787c 100755
>> > >> --- a/scripts/checkpatch.pl
>> > >> +++ b/scripts/checkpatch.pl
>> > >> @@ -5462,7 +5462,7 @@ sub process {
>> > >> }
>> > >>
>> > >>  # concatenated string without spaces between elements
>> > >> -   if ($line =~ /$String[A-Za-z0-9_]/ || $line =~
>/[A-Za-z0-9_]$String/) {
>> > >> +   if ($line =~ /$String[A-Za-z0-9_]/ || $line =~
>/([A-Za-z0-9_]+[Lu]|[A-Za-z0-9_]*[A-KM-Za-tv-z0-9_])$String/) {
>> > >> if (CHK("CONCATENATED_STRING",
>> > >> "Concatenated strings should use spaces 
>> > >> between elements\n"
>. $herecurr) &&
>> > >> $fix) {
>> > >
>> > > This looks like a generic checkpatch issue.  I think we're a
>little out
>> > > of sync with the kernel's v5.7 but this doesn't look to be fixed
>there
>> > > either.  Can you please submit it upstream?  Thanks!
>> > >
>> > 
>> > Hello Tom,
>> > 
>> > I already raised that issue to the Kernel people and they were not
>> > interested in fixing it:
>> > 
>> > https://lkml.org/lkml/2017/10/17/1086
>> > 
>> > Recently a lot of changes have been done to the U-Boot version of
>> > checkpatch.pl.
>> > 
>> > Do we want to diverge from the upstream and have a lot of work each
>time
>> > we try to sync? Or should we use checkpatch.pl as is and live
>without
>> > U-Boot specific stuff?
>> 
>> I would raise the issue with Joe again to see if he still doesn't
>want
>> to support wide strings.  If he doesn't I worry that since this
>change
>> is outside of the new u-boot function it will get removed by accident
>> with a future resync.
>
>To be strict, Joe's comment, "Kernel doesn't support wide strings."
>is no longer true. We can see several examples of L"..." in
>security/integrity/platform_certs/load_uefi.c

That makes things easier. Please, check if the upstream checkpatch.pl still has 
the issue. If yes, please, send your pstch upstream.

Best regards

Heinrich

>
>-Takahiro Akashi
>
>> -- 
>> Tom



Re: [PATCH v1 26/43] i2c: designware_i2c: Add a little more debugging

2020-07-03 Thread Heiko Schocher

Hello Simon,

Am 15.06.2020 um 05:57 schrieb Simon Glass:

Add debugging for a few more values and also use log to show return values
when something goes wrong. This makes it easier to see the root cause.

Signed-off-by: Simon Glass 
---

Changes in v1:
- Add new patch to improve designware_i2c debugging

  drivers/i2c/designware_i2c.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)


Reviewed-by: Heiko Schocher 

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH v3 04/14] i2c: add nexell driver

2020-07-03 Thread Heiko Schocher

Hello Stefan,

Am 29.06.2020 um 19:46 schrieb Stefan Bosch:

Changes in relation to FriendlyARM's U-Boot nanopi2-v2016.01:
- i2c/nx_i2c.c: Some adaptions mainly because of changes in
   "struct udevice".
- several Bugfixes in nx_i2c.c.
- the driver has been for s5p6818 only. Code extended appropriately
   in order s5p4418 is also working.
- "probe_chip" added.
- pinctrl-driver/dt is used instead of configuring the i2c I/O-pins
   in the i2c-driver.
- '#ifdef CONFIG...' changed to 'if (IS_ENABLED(CONFIG...))' where
   possible (and similar).
- livetree API (dev_read_...) is used instead of fdt one (fdt...).

Signed-off-by: Stefan Bosch 


Reviewed-by: Heiko Schocher 

Nitpick only ...

[...]

diff --git a/drivers/i2c/nx_i2c.c b/drivers/i2c/nx_i2c.c
new file mode 100644
index 000..cefc774
--- /dev/null
+++ b/drivers/i2c/nx_i2c.c
@@ -0,0 +1,624 @@

[...]

+static uint i2c_set_clk(struct nx_i2c_bus *bus, uint enb)
+{
+   struct clk *clk;
+   char name[50];
+
+   sprintf(name, "%s.%d", DEV_NAME_I2C, bus->bus_num);
+   clk = clk_get((const char *)name);
+   if (!clk) {
+   debug("%s(): clk_get(%s) error!\n",
+ __func__, (const char *)name);
+   return -EINVAL;
+   }
+
+   if (enb) {
+   clk_disable(clk);
+   clk_enable(clk);
+   } else {
+   clk_disable(clk);
+   }


You can do here:

clk_disable(clk);
if (enb)
clk_enable(clk);


+
+   return 0;
+}
+
+#ifdef CONFIG_ARCH_S5P6818
+/* Set SDA line delay, not available at S5P4418 */
+static int nx_i2c_set_sda_delay(struct nx_i2c_bus *bus)
+{
+   struct nx_i2c_regs *i2c = bus->regs;
+   uint pclk = 0;
+   uint t_pclk = 0;
+   uint delay = 0;
+
+   /* get input clock of the I2C-controller */
+   pclk = i2c_get_clkrate(bus);
+
+   if (bus->sda_delay) {
+   /* t_pclk = period time of one pclk [ns] */
+   t_pclk = DIV_ROUND_UP(1000, pclk / 100);
+   /* delay = number of pclks required for sda_delay [ns] */
+   delay = DIV_ROUND_UP(bus->sda_delay, t_pclk);
+   /* delay = register value (step of 5 clocks) */
+   delay = DIV_ROUND_UP(delay, 5);
+   /* max. possible register value = 3 */
+   if (delay > 3) {


May you use defines here?


+   delay = 3;
+   debug("%s(): sda-delay des.: %dns, sat. to max.: %dns 
(granularity: %dns)\n",
+ __func__, bus->sda_delay, t_pclk * delay * 5,
+ t_pclk * 5);
+   } else {
+   debug("%s(): sda-delay des.: %dns, act.: %dns (granularity: 
%dns)\n",
+ __func__, bus->sda_delay, t_pclk * delay * 5,
+ t_pclk * 5);
+   }
+
+   delay |= I2CLC_FILTER;
+   } else {
+   delay = 0;
+   debug("%s(): sda-delay = 0\n", __func__);
+   }
+
+   delay &= 0x7;
+   writel(delay, >iiclc);
+
+   return 0;
+}
+#endif
+
+static int nx_i2c_set_bus_speed(struct udevice *dev, uint speed)
+{
+   struct nx_i2c_bus *bus = dev_get_priv(dev);
+   struct nx_i2c_regs *i2c = bus->regs;
+   unsigned long pclk, pres = 16, div;
+
+   if (i2c_set_clk(bus, 1))
+   return -EINVAL;
+
+   /* get input clock of the I2C-controller */
+   pclk = i2c_get_clkrate(bus);
+
+   /* calculate prescaler and divisor values */
+   if ((pclk / pres / (16 + 1)) > speed)
+   /* set prescaler to 256 */
+   pres = 256;
+
+   div = 0;
+   /* actual divider = div + 1 */
+   while ((pclk / pres / (div + 1)) > speed)
+   div++;
+
+   if (div > 0xF) {
+   debug("%s(): pres==%ld, div==0x%lx is saturated to 0xF !)\n",
+ __func__, pres, div);
+   div = 0xF;
+   } else {
+   debug("%s(): pres==%ld, div==0x%lx)\n", __func__, pres, div);
+   }
+
+   /* set prescaler, divisor according to pclk, also set ACKGEN, IRQ */
+   writel((div & 0x0F) | ((pres == 256) ? 0x40 : 0), >iiccon);


Ok, I am really nitpicking now ... can you use defines here instead
this magic values?

[...]

Thanks!

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


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

2020-07-03 Thread Rick Chen
> From: Tom Rini [mailto:tr...@konsulko.com]
> Sent: Thursday, July 02, 2020 9:53 PM
> To: Open Source Project uboot
> Cc: u-boot@lists.denx.de; Rick Jian-Zhi Chen(陳建志)
> Subject: Re: [U-Boot] Pull request: u-boot-riscv/master
>
> On Thu, Jul 02, 2020 at 10:51:48AM +0800, ub...@andestech.com wrote:
>
> > Hi Tom,
> >
> > Please pull some riscv updates:
> >
> > - sbi: Add newline to error message
> > - fu540: dts: Correct reg size of otp and dmc nodes
> > - Enhance reserved memory fixup about PMP information passed from
> > OpenSbi
> > - sifive: fu540: Add gpio-restart support
> > - qemu: Add syscon reboot and poweroff support
> > - qemu-riscv: Update QEMU run command
> > - Assorted fixes related to reserved memory
> > - fu540: enable all cache ways from U-Boot proper
> > - use log functions in fdt_fixup
>
> This changes a few MIPS and ARM platforms.  We're a few days away from 
> release, so I don't feel comfortable taking this right now as I assume it 
> hasn't been tested on the other platforms as well.  Sorry.

Hi Tom,

Thanks for your suggestions.


Hi Bin,

Can you separate this series about sysreset into two series ?
[PATCH 1/5] sysreset: syscon: Don't assume default value for offset
and mask property
[PATCH 2/5] sysreset: syscon: Support value property
[PATCH 3/5] riscv: Do not build reset.c if SYSRESET is on
[PATCH 4/5] riscv: qemu: Add syscon reboot and poweroff support
[PATCH 5/5] riscv: sifive: fu540: Add gpio-restart support

It looks like that patch 3/5, 4/5, 5/5 doesn't depend on patch 1/5 and 2/5.

Thanks,
Rick

>
> --