Re: Invitation: Regular U-Boot video call (Tuesday 19th)

2021-01-13 Thread Heinrich Schuchardt

On 1/14/21 6:42 AM, Bin Meng wrote:

Hi Simon,

On Thu, Jan 14, 2021 at 5:57 AM Simon Glass  wrote:


Hi Bin,

I added you, Heinrich, Tom and Andy.

For others, as mentioned in the doc I can add you to the invitation.
Just reply on this thread.



I am not sure how Google meet works as I never used that. I guess Zoom
is much easier as it has clients on different platforms.


Just open the link in Chromium and allow access to microphone and
camera. No client needed.

Best regards

Heinrich



Regards,
Bin





[PATCH] mmc: sdhci: skip cache invalidation if DMA is not used

2021-01-13 Thread Yuezhang.Mo
If DMA(SDMA or ADMA) is not used, the cache invalidation
after reading is no need, should be skipped. Otherwise
U-Boot may hang at the cache invalidation.

Found this issue and tested this fix on DragonBoard 410c.

Fixes: commit 4155ad9aac94 ("mmc: sdhci: fix missing cache invalidation after 
reading by DMA")

Signed-off-by: Yuezhang.Mo 
---
 drivers/mmc/sdhci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 0628934312..29099199a7 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -174,8 +174,10 @@ static int sdhci_transfer_data(struct sdhci_host *host, 
struct mmc_data *data)
}
} while (!(stat & SDHCI_INT_DATA_END));
 
+#if (defined(CONFIG_MMC_SDHCI_SDMA) || CONFIG_IS_ENABLED(MMC_SDHCI_ADMA))
dma_unmap_single(host->start_addr, data->blocks * data->blocksize,
 mmc_get_dma_dir(data));
+#endif
 
return 0;
 }
-- 
2.25.1

Re: Invitation: Regular U-Boot video call (Tuesday 19th)

2021-01-13 Thread Bin Meng
Hi Simon,

On Thu, Jan 14, 2021 at 5:57 AM Simon Glass  wrote:
>
> Hi Bin,
>
> I added you, Heinrich, Tom and Andy.
>
> For others, as mentioned in the doc I can add you to the invitation.
> Just reply on this thread.
>

I am not sure how Google meet works as I never used that. I guess Zoom
is much easier as it has clients on different platforms.

Regards,
Bin


Re: [RFC PATCH 3/3] efidebug: add multiple device path instances on Boot####

2021-01-13 Thread AKASHI Takahiro
Ilias,

On Wed, Jan 13, 2021 at 01:11:49PM +0200, Ilias Apalodimas wrote:
> The UEFI spec allow a packed array of UEFI device paths in the
> FilePathList[] of an EFI_LOAD_OPTION. The first file path must
> describe the laoded image but the rest are OS specific.
> Previous patches parse the device path and try to use the second
> member of the array as an initrd. So let's modify efidebug slightly
> and install the second file described in the command line as the
> initrd device path.

I have a concern about your proposed command line syntax.
It takes a lot of parameters as a whole which makes it
hard to understand it at a glance, easily overflowing
the width of terminal window.

It will even get worse if we want to take dtb as a third
device path, and what if we want to specify dtb, but not initrd?

Moreover, if we want to add support for non-linux executabes which
utilize extra device paths (neither initrd nor dtb) in a boot
load option, the syntax will be problematic.

> Signed-off-by: Ilias Apalodimas 
> ---
>  cmd/efidebug.c | 89 +-
>  1 file changed, 81 insertions(+), 8 deletions(-)
> 
> diff --git a/cmd/efidebug.c b/cmd/efidebug.c
> index 5fb7b1e3c6a9..8d62981aca92 100644
> --- a/cmd/efidebug.c
> +++ b/cmd/efidebug.c
> @@ -8,6 +8,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -17,6 +18,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #define BS systab.boottime
>  #define RT systab.runtime
> @@ -782,6 +784,42 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int 
> flag,
>   return CMD_RET_SUCCESS;
>  }
>  
> +/**
> + * add_initrd_instance() - Append a device path to load_options pointing to 
> an
> + *  inirtd
> + *
> + * @argc:Number of arguments
> + * @argv:Argument array
> + * @file_pathExisting device path, the new instance will be appended
> + * Return:   Pointer to the device path or ERR_PTR
> + *
> + */
> +static struct efi_device_path *add_initrd_instance(int argc, char *const 
> argv[],
> +struct efi_device_path 
> *file_path)
> +{
> + struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL;
> + struct efi_device_path *final_fp = NULL;
> + efi_status_t ret;
> +
> + if (argc < 8)
> + return ERR_PTR(-EINVAL);
> +
> + ret = efi_dp_from_name(argv[6], argv[7], argv[8], &tmp_dp,
> +&tmp_fp);
> + if (ret != EFI_SUCCESS) {
> + printf("Cannot create device path for \"%s %s\"\n",
> +argv[6], argv[7]);
> + goto out;
> + }
> +
> + final_fp = efi_dp_append_instance(file_path, tmp_fp);
> +
> +out:
> + efi_free_pool(tmp_dp);
> + efi_free_pool(tmp_fp);
> + return final_fp ? final_fp : ERR_PTR(-EINVAL);
> +}
> +
>  /**
>   * do_efi_boot_add() - set UEFI load option
>   *
> @@ -794,7 +832,11 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int 
> flag,
>   *
>   * Implement efidebug "boot add" sub-command. Create or change UEFI load 
> option.
>   *
> - * efidebug boot add[:]  
> 
> + * Without initrd:
> + * efidebug boot add[:]  
> 
> + *
> + * With initrd:
> + * efidebug boot add[:]  
>  [:]  
>   */
>  static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
>  int argc, char *const argv[])
> @@ -807,13 +849,14 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int 
> flag,
>   size_t label_len, label_len16;
>   u16 *label;
>   struct efi_device_path *device_path = NULL, *file_path = NULL;
> + struct efi_device_path *final_fp = NULL;
>   struct efi_load_option lo;
>   void *data = NULL;
>   efi_uintn_t size;
>   efi_status_t ret;
>   int r = CMD_RET_SUCCESS;
>  
> - if (argc < 6 || argc > 7)
> + if (argc < 6 || argc > 9)
>   return CMD_RET_USAGE;
>  
>   id = (int)simple_strtoul(argv[1], &endp, 16);
> @@ -829,6 +872,12 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int 
> flag,
>   /* attributes */
>   lo.attributes = LOAD_OPTION_ACTIVE; /* always ACTIVE */
>  
> + /* optional data */
> + if (argc == 6)
> + lo.optional_data = NULL;
> + else
> + lo.optional_data = (const u8 *)argv[6];
> +
>   /* label */
>   label_len = strlen(argv[2]);
>   label_len16 = utf8_utf16_strnlen(argv[2], label_len);
> @@ -847,15 +896,30 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int 
> flag,
>   r = CMD_RET_FAILURE;
>   goto out;
>   }
> +
> + /* add initrd instance in device path */
> + if (argc >= 9) {
> + final_fp = add_initrd_instance(argc, argv, file_path);

We'd better pass argv[6], argv[7] and argv[8] explicitly here,
which will make the code readable and easily extended to support
dtb in the future.
then,
argc -= 3;
argv += 3;

> + if (IS_ERR(fi

Re: [RFC PATCH 1/3] efi_loader: Introduce helper functions for EFI

2021-01-13 Thread Heinrich Schuchardt
Am 14. Januar 2021 05:48:28 MEZ schrieb AKASHI Takahiro 
:
>On Wed, Jan 13, 2021 at 01:11:47PM +0200, Ilias Apalodimas wrote:
>> A following patch introduces a different logic for loading initrd's
>> based on the EFI_LOAD_FILE2_PROTOCOL.
>> Since similar logic can be applied in the future for other system
>files
>> (i.e DTBs),
>
>In this respect,
>
>> let's add some helper functions which will retrieve and
>> parse file paths stored in EFI load options.
>> Signed-off-by: Ilias Apalodimas 
>> ---
>>  include/efi_helper.h|  23 ++
>>  lib/efi_loader/efi_helper.c | 146
>
>>  2 files changed, 169 insertions(+)
>>  create mode 100644 include/efi_helper.h
>>  create mode 100644 lib/efi_loader/efi_helper.c
>> 
>> diff --git a/include/efi_helper.h b/include/efi_helper.h
>> new file mode 100644
>> index ..4e6bd2f036df
>> --- /dev/null
>> +++ b/include/efi_helper.h
>> @@ -0,0 +1,23 @@
>> +/* SPDX-License-Identifier: GPL-2.0+ */
>> +/*
>> + * Copyright (c) 2020, Linaro Limited
>> + */
>> +
>> +#if !defined _EFI_HELPER_H_
>> +#define _EFI_HELPER_H
>> +
>> +#include 
>> +#include 
>> +
>> +enum load_option_dp_type {
>> +BOOT_IMAGE_DP,
>> +INITRD_DP,
>> +DTB_DP,
>> +};
>> +
>> +void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t
>*size);
>> +struct efi_device_path *efi_get_fp_from_boot(int idx);
>> +struct efi_device_path *efi_dp_instance_by_idx(struct
>efi_device_path *dp,
>> +   efi_uintn_t *size, int idx);
>> +
>> +#endif
>> diff --git a/lib/efi_loader/efi_helper.c
>b/lib/efi_loader/efi_helper.c
>> new file mode 100644
>> index ..e2437a4f698b
>> --- /dev/null
>> +++ b/lib/efi_loader/efi_helper.c
>> @@ -0,0 +1,146 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * Copyright (c) 2020, Linaro Limited
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/**
>> + * efi_get_var() - read value of an EFI variable
>> + *
>> + * @name:   variable name
>> + * @start:  vendor GUID
>> + * @size:   size of allocated buffer
>> + *
>> + * Return:  buffer with variable data or NULL
>> + */
>> +void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t
>*size)
>> +{
>> +efi_status_t ret;
>> +void *buf = NULL;
>> +
>> +*size = 0;
>> +ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL);
>> +if (ret == EFI_BUFFER_TOO_SMALL) {
>> +buf = malloc(*size);
>> +ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL);
>> +}
>> +
>> +if (ret != EFI_SUCCESS) {
>> +free(buf);
>> +*size = 0;
>> +return NULL;
>> +}
>> +
>> +return buf;
>> +}
>> +
>> +/**
>> + * efi_dp_instance_by_idx() - Get a file path with a specific index
>> + *
>> + * @name:   device path array
>> + * @size:   size of the discovered device path
>> + * @idx:index of the device path
>> + *
>> + * Return:  device path or NULL. Caller must free the returned value
>> + */
>> +
>> +struct
>> +efi_device_path *efi_dp_instance_by_idx(struct efi_device_path *dp,
>> +efi_uintn_t *size, int idx)
>
>The type of "idx" should be 'enum load_option_dp_type'.

There is nothing boot manager specific in this function. You can use it to 
access any multiple device path.

An enum or #define can be used on the caller side.

Should this function be moved to efi_devicepath.c?

Best regards

Heinrich

>
>Currently, "idx" is used as an index into the array of device paths,
>but given each device path is set to have its own guid, "idx" should be
>unlinked from the 'order' within the array.
>
>Even if you don't want so, this function should at least take care of
>some special cases like
> + (no initrd) + 
>Alternatively, "END device path" can be put at the second place.
>
>I expect that handling those corner cases should be described
>explicitly.
>
>> +{
>> +struct efi_device_path *instance = NULL;
>> +efi_uintn_t instance_size = 0;
>> +
>> +if (!efi_dp_is_multi_instance(dp))
>> +return NULL;
>> +
>> +while (idx >= 0 && dp) {
>> +instance = efi_dp_get_next_instance(&dp, &instance_size);
>> +if (idx && instance) {
>> +efi_free_pool(instance);
>> +instance_size = 0;
>> +instance = NULL;
>> +}
>> +idx--;
>> +}
>> +*size = instance_size;
>> +
>> +return instance;
>> +}
>> +
>> +/**
>> + * create_boot_var_indexed() - Return Boot name were  is
>replaced by
>> + * the value of BootCurrent
>> + *
>> + * @var_name:   variable name
>> + * @var_name_size:  size of var_name
>> + *
>> + * Return:  Status code
>> + */
>> +static efi_status_t create_boot_var_indexed(u16 var_name[], size_t
>var_name_size)
>> +{
>> +efi_uintn_t boot_order_size;
>> +

Re: [RFC PATCH 1/3] efi_loader: Introduce helper functions for EFI

2021-01-13 Thread AKASHI Takahiro
On Wed, Jan 13, 2021 at 01:11:47PM +0200, Ilias Apalodimas wrote:
> A following patch introduces a different logic for loading initrd's
> based on the EFI_LOAD_FILE2_PROTOCOL.
> Since similar logic can be applied in the future for other system files
> (i.e DTBs),

In this respect,

> let's add some helper functions which will retrieve and
> parse file paths stored in EFI load options.
> Signed-off-by: Ilias Apalodimas 
> ---
>  include/efi_helper.h|  23 ++
>  lib/efi_loader/efi_helper.c | 146 
>  2 files changed, 169 insertions(+)
>  create mode 100644 include/efi_helper.h
>  create mode 100644 lib/efi_loader/efi_helper.c
> 
> diff --git a/include/efi_helper.h b/include/efi_helper.h
> new file mode 100644
> index ..4e6bd2f036df
> --- /dev/null
> +++ b/include/efi_helper.h
> @@ -0,0 +1,23 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (c) 2020, Linaro Limited
> + */
> +
> +#if !defined _EFI_HELPER_H_
> +#define _EFI_HELPER_H
> +
> +#include 
> +#include 
> +
> +enum load_option_dp_type {
> + BOOT_IMAGE_DP,
> + INITRD_DP,
> + DTB_DP,
> +};
> +
> +void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t *size);
> +struct efi_device_path *efi_get_fp_from_boot(int idx);
> +struct efi_device_path *efi_dp_instance_by_idx(struct efi_device_path *dp,
> +efi_uintn_t *size, int idx);
> +
> +#endif
> diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
> new file mode 100644
> index ..e2437a4f698b
> --- /dev/null
> +++ b/lib/efi_loader/efi_helper.c
> @@ -0,0 +1,146 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2020, Linaro Limited
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * efi_get_var() - read value of an EFI variable
> + *
> + * @name:variable name
> + * @start:   vendor GUID
> + * @size:size of allocated buffer
> + *
> + * Return:   buffer with variable data or NULL
> + */
> +void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t *size)
> +{
> + efi_status_t ret;
> + void *buf = NULL;
> +
> + *size = 0;
> + ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL);
> + if (ret == EFI_BUFFER_TOO_SMALL) {
> + buf = malloc(*size);
> + ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL);
> + }
> +
> + if (ret != EFI_SUCCESS) {
> + free(buf);
> + *size = 0;
> + return NULL;
> + }
> +
> + return buf;
> +}
> +
> +/**
> + * efi_dp_instance_by_idx() - Get a file path with a specific index
> + *
> + * @name:device path array
> + * @size:size of the discovered device path
> + * @idx: index of the device path
> + *
> + * Return:   device path or NULL. Caller must free the returned value
> + */
> +
> +struct
> +efi_device_path *efi_dp_instance_by_idx(struct efi_device_path *dp,
> + efi_uintn_t *size, int idx)

The type of "idx" should be 'enum load_option_dp_type'.

Currently, "idx" is used as an index into the array of device paths,
but given each device path is set to have its own guid, "idx" should be
unlinked from the 'order' within the array.

Even if you don't want so, this function should at least take care of
some special cases like
 + (no initrd) + 
Alternatively, "END device path" can be put at the second place.

I expect that handling those corner cases should be described explicitly.

> +{
> + struct efi_device_path *instance = NULL;
> + efi_uintn_t instance_size = 0;
> +
> + if (!efi_dp_is_multi_instance(dp))
> + return NULL;
> +
> + while (idx >= 0 && dp) {
> + instance = efi_dp_get_next_instance(&dp, &instance_size);
> + if (idx && instance) {
> + efi_free_pool(instance);
> + instance_size = 0;
> + instance = NULL;
> + }
> + idx--;
> + }
> + *size = instance_size;
> +
> + return instance;
> +}
> +
> +/**
> + * create_boot_var_indexed() - Return Boot name were  is replaced by
> + *  the value of BootCurrent
> + *
> + * @var_name:variable name
> + * @var_name_size:   size of var_name
> + *
> + * Return:   Status code
> + */
> +static efi_status_t create_boot_var_indexed(u16 var_name[], size_t 
> var_name_size)
> +{
> + efi_uintn_t boot_order_size;
> + efi_status_t ret;
> + u16 boot_order;
> + u16 *pos;
> +
> + boot_order_size = sizeof(boot_order);
> + ret = efi_get_variable_int(L"BootCurrent",
> +&efi_global_variable_guid, NULL,
> +&boot_order_size, &boot_order, NULL);
> + if (ret != EFI_SUCCESS)
> + goto out;
> +
> + pos = efi_create_indexed_name(var_name

Re: [PATCH] Add fixdefconfig script to update lists of defconfig files from savedefconfig

2021-01-13 Thread Joel Peshkin
No worries.  As long as there is a mechanism that will work OK.

On Wed, Jan 13, 2021 at 12:16 PM Tom Rini  wrote:

> On Wed, Jan 13, 2021 at 09:10:41AM -0700, Simon Glass wrote:
>
> > Hi Joel,
> >
> > On Mon, 11 Jan 2021 at 20:01, Joel Peshkin 
> wrote:
> > >
> > > Cc: Simon Glass 
> > > Cc: Heinrich Schuchardt 
> > > ---
> > >  scripts/fixdefconfig | 25 +
> > >  1 file changed, 25 insertions(+)
> > >  create mode 100755 scripts/fixdefconfig
> >
> > +Tom Rini
> >
> > I normally use moveconfig for this...Tom how do you do it?
>
> Yes, this is a single-threaded version of "moveconfig.py -sC".  This is
> useful I suppose in the case where you have to sync maybe a dozen files
> rather than one or two, or all of them.  But I'm not sure it's worth
> applying, sorry.
>
> --
> Tom
>


smime.p7s
Description: S/MIME Cryptographic Signature


Re: [RFC PATCH 2/3] efi_loader: efi_loader: Replace config option for initrd loading

2021-01-13 Thread AKASHI Takahiro
Ilias,

On Wed, Jan 13, 2021 at 01:11:48PM +0200, Ilias Apalodimas wrote:
> Up to now we install EFI_LOAD_FILE2_PROTOCOL to load an initrd
> unconditionally. Although we correctly return various EFI exit codes
> depending on the file status (i.e EFI_NO_MEDIA, EFI_NOT_FOUND etc), the
> kernel loader, only falls back to the cmdline interpreted initrd if the
> protocol is not installed.
> 
> This creates a problem for EFI installers, since they won't be able to
> load their own initrd and continue the installation. It also makes the
> feature hard to use, since we can either have a single initrd or we have
> to recompile u-boot if the filename changes.
> 
> So let's introduce a different logic that will decouple the initrd
> path from the config option we currently have.
> When defining a UEFI Boot we can use the filepathlist and store
> a file path pointing to our initrd. Specifically the EFI spec describes:
> 
> "The first element of the array is a device path that describes the device
> and location of the Image for this load option. Other device paths may
> optionally exist in the FilePathList, but their usage is OSV specific"

I wonder what "OSV specific" does and should mean.
Apparently, using a "array of device paths" is U-Boot specific for now
and any distro who wants to use U-Boot as an EFI boot loader needs to
(at least, preferably) take care of this. It would be sad
that the installation process cannot be EFI-implementation agnostic
in terms of EFI's purpose.

So do you intend to propose your idea as a common practice to linux community?

> When the EFI application is launched through the bootmgr, we'll try to
> interpret the extra device path. If that points to a file that exists on
> our disk, we'll now install the load_file2 and the efi-stub will be able
> to use it.
> 
> This opens up another path using U-Boot and defines a new boot flow.
> A user will be able to control the kernel/initrd pairs without explicit
> cmdline args or GRUB.
> 
> Signed-off-by: Ilias Apalodimas 
> ---
>  cmd/bootefi.c|   3 +
>  include/efi_loader.h |   1 +
>  lib/efi_loader/Kconfig   |  13 +--
>  lib/efi_loader/efi_bootmgr.c |   3 +
>  lib/efi_loader/efi_load_initrd.c | 154 ---
>  5 files changed, 91 insertions(+), 83 deletions(-)
> 
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index fdf909f8da2c..053927d5d986 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -357,6 +357,9 @@ static efi_status_t do_bootefi_exec(efi_handle_t handle, 
> void *load_options)
>  
>   free(load_options);
>  
> + if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD))
> + efi_initrd_deregister();
> +

I understand why you want do "deregister" the initrd handle,
but the handle for the loaded image is still valid at this point.
So it looks inconsistent from the viewpoint of API's.

>   return ret;
>  }
>  
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 4719fa93f06d..5d2e161963c3 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -432,6 +432,7 @@ efi_status_t efi_net_register(void);
>  /* Called by bootefi to make the watchdog available */
>  efi_status_t efi_watchdog_register(void);
>  efi_status_t efi_initrd_register(void);
> +void efi_initrd_deregister(void);
>  /* Called by bootefi to make SMBIOS tables available */
>  /**
>   * efi_acpi_register() - write out ACPI tables
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index fdf245dea30b..597a3ee86c88 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -307,14 +307,11 @@ config EFI_LOAD_FILE2_INITRD
>   help
> Expose a EFI_FILE_LOAD2_PROTOCOL that the Linux UEFI stub can
> use to load the initial ramdisk. Once this is enabled using
> -   initrd= will stop working.
> -
> -config EFI_INITRD_FILESPEC
> - string "initramfs path"
> - default "host 0:1 initrd"
> - depends on EFI_LOAD_FILE2_INITRD
> - help
> -   Full path of the initramfs file, e.g. mmc 0:2 initramfs.cpio.gz.
> +   initrd= will stop working. The protocol will only be
> +   installed if bootmgr is used and the file is found on the defined
> +   path. A boot entry of Boot0001 will try to match Initrd0001 and use
> +   it. Initrd EFI variable format should be '  '
> +   i.e 'mmc 0:1 boot/initrd'
>  
>  config EFI_SECURE_BOOT
>   bool "Enable EFI secure boot support"
> diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
> index 0fe503a7f376..aa5d521535ee 100644
> --- a/lib/efi_loader/efi_bootmgr.c
> +++ b/lib/efi_loader/efi_bootmgr.c
> @@ -222,6 +222,9 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t 
> *handle,
>   ret = efi_set_variable_int(L"BootCurrent",
>  &efi_global_variable_guid,
>  attributes, sizeof(n), &n, false);
> + /* try to register load file2 for i

[PATCH 00/17] Various minor clean-ups and improvements

2021-01-13 Thread Simon Glass
This series includes a collection of things noticed while bringing up
verified boot on Coral.

It includes support for relocating the bloblist.


Simon Glass (17):
  doc: Correct documentation for uclass_root
  spl: Add functions for next and previous phase
  bloblist: Support relocating to a larger space
  bloblist: Add missing tag names
  x86: tsc_timer: Correct overflow in __udelay()
  video: Allow syncing the entire framebuffer to the copy
  net: Use CONFIG_IS_ENABLED() in eth_dev_get_mac_address()
  fdtdec: Update the missing-devicetree message
  fdtdec: Use CONFIG_IS_ENABLED in board_fdt_blob_setup()
  display_options: Use USE_TINY_PRINTF for SPL check
  uuid: Add a comment for UUID_STR_LEN
  mmc: pci_mmc: Only generate ACPI code for the SD card
  x86: coral: Add a devicetree node for eMMC
  mmc: pci_mmc: Set the removable flag
  crc32: Exclude crc32 from TPL
  binman: Move selection of the binman node into a function
  binman: Allow reading entries from a subnode

 arch/x86/dts/chromebook_coral.dts |  6 +++
 common/Kconfig| 10 +
 common/bloblist.c | 17 +
 common/board_f.c  | 10 +++--
 common/spl/spl.c  |  2 +-
 drivers/mmc/pci_mmc.c | 19 +-
 drivers/timer/tsc_timer.c |  2 +-
 drivers/video/video-uclass.c  | 10 +
 include/asm-generic/global_data.h |  4 +-
 include/binman.h  | 14 +++
 include/bloblist.h| 10 +
 include/spl.h | 53 +++
 include/uuid.h|  1 +
 include/video.h   | 14 +++
 lib/Makefile  |  2 +
 lib/binman.c  | 61 ++-
 lib/display_options.c |  9 ++---
 lib/fdtdec.c  |  5 ++-
 net/eth-uclass.c  |  2 +-
 test/bloblist.c   | 36 ++
 20 files changed, 260 insertions(+), 27 deletions(-)

-- 
2.30.0.284.gd98b1dd5eaa7-goog



Re: [PATCH 4/4] log: Convert log values to printf() if not enabled

2021-01-13 Thread Heinrich Schuchardt
Am 14. Januar 2021 04:30:51 MEZ schrieb Simon Glass :
>At present if logging not enabled, log_info() becomes a nop. But we
>want
>log output at the 'info' level to be akin to printf(). Update the macro
>to
>pass the output straight to printf() in this case.

Looking at 

https://github.com/trini/u-boot/blob/master/include/log.h#L172

the commit message seems not to precisely describe in which cases printf() was 
not called.

We have a nolog unit test. Should that test be extended?

https://github.com/trini/u-boot/blob/master/test/log/nolog_test.c

For the naked log() is see the difference.

Is this patch fixing a recent change?

Best regards

Heinrich


>
>Signed-off-by: Simon Glass 
>---
>
> doc/develop/logging.rst |  5 +++--
> include/log.h   | 12 
> 2 files changed, 11 insertions(+), 6 deletions(-)
>
>diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst
>index b6c6b45049f..fdc869204df 100644
>--- a/doc/develop/logging.rst
>+++ b/doc/develop/logging.rst
>@@ -54,6 +54,9 @@ If CONFIG_LOG is not set, then no logging will be
>available.
>The above have SPL and TPL versions also, e.g. CONFIG_SPL_LOG_MAX_LEVEL
>and
> CONFIG_TPL_LOG_MAX_LEVEL.
> 
>+If logging is disabled, the default behaviour is to output any message
>at
>+level LOGL_INFO and below.
>+
> Temporary logging within a single file
> --
> 
>@@ -293,8 +296,6 @@ More logging destinations:
> 
> Convert debug() statements in the code to log() statements
> 
>-Support making printf() emit log statements at L_INFO level
>-
> Convert error() statements in the code to log() statements
> 
> Figure out what to do with BUG(), BUG_ON() and warn_non_spl()
>diff --git a/include/log.h b/include/log.h
>index c5c1cf92356..3d19f0448da 100644
>--- a/include/log.h
>+++ b/include/log.h
>@@ -175,25 +175,29 @@ static inline int _log_nop(enum log_category_t
>cat, enum log_level_t level,
> #define log_io(_fmt...)   log_nop(LOG_CATEGORY, LOGL_DEBUG_IO, 
> ##_fmt)
> #endif
> 
>-#if CONFIG_IS_ENABLED(LOG)
> #ifdef LOG_DEBUG
> #define _LOG_DEBUGLOGL_FORCE_DEBUG
> #else
> #define _LOG_DEBUG0
> #endif
> 
>+#if CONFIG_IS_ENABLED(LOG)
>+
> /* Emit a log record if the level is less that the maximum */
> #define log(_cat, _level, _fmt, _args...) ({ \
>   int _l = _level; \
>-  if (CONFIG_IS_ENABLED(LOG) && \
>-  (_LOG_DEBUG != 0 || _l <= _LOG_MAX_LEVEL)) \
>+  if ((_LOG_DEBUG != 0 || _l <= _LOG_MAX_LEVEL)) \
>   _log((enum log_category_t)(_cat), \
>(enum log_level_t)(_l | _LOG_DEBUG), __FILE__, \
>__LINE__, __func__, \
> pr_fmt(_fmt), ##_args); \
>   })
> #else
>-#define log(_cat, _level, _fmt, _args...)
>+#define log(_cat, _level, _fmt, _args...) ({ \
>+  int _l = _level; \
>+  if ((_LOG_DEBUG != 0 || _l <= LOGL_INFO)) \
>+  printf(_fmt, ##_args); \
>+  })
> #endif
> 
> #define log_nop(_cat, _level, _fmt, _args...) ({ \



Re: [PATCH 0/4] log: Allow multiple lines and conversion to printf()

2021-01-13 Thread Heinrich Schuchardt
Am 14. Januar 2021 04:30:47 MEZ schrieb Simon Glass :
>At present when logging is not enabled, all log calls become nops. This
>does not seem right, since if the log level is high enough then there
>should be some sort of message. So in that case, this series updates it
>to
>print the message if the log level is above LOGL_INFO.

This is already current behavior. See

https://github.com/trini/u-boot/blob/master/include/log.h#L172

Best regards

Heinrich





>
>Also the current implementation does not support multiple log calls on
>the
>same line nicely. The tags are repeated so the line is very hard to
>read.
>This series adds that as a new feature.
>
>
>Simon Glass (4):
>  log: Set up a flag byte for log records
>  log: Handle line continuation
>  log: Add return-checking macros for 0 being success
>  log: Convert log values to printf() if not enabled
>
> common/log.c  | 12 ++--
> common/log_console.c  | 26 ++---
> doc/develop/logging.rst   | 36 +--
> include/asm-generic/global_data.h |  6 
> include/log.h | 48 +--
> test/log/cont_test.c  | 19 +---
> 6 files changed, 118 insertions(+), 29 deletions(-)



[PATCH 2/4] log: Handle line continuation

2021-01-13 Thread Simon Glass
When multiple log() calls are used which don't end in newline, the
log prefix is prepended multiple times in the same line. This makes the
output look strange.

Fix this by detecting when the previous log record did not end in newline.
In that case, setting a flag.

Drop the unused BUFFSIZE in the test while we are here.

As an example implementation, update log_console to check the flag and
produce the expected output.

Signed-off-by: Simon Glass 
---

 common/log.c  |  6 +-
 common/log_console.c  | 26 +++---
 doc/develop/logging.rst   | 16 
 include/asm-generic/global_data.h |  6 ++
 include/log.h |  2 ++
 test/log/cont_test.c  | 19 +++
 6 files changed, 59 insertions(+), 16 deletions(-)

diff --git a/common/log.c b/common/log.c
index d0abedaa05e..90c04c10a79 100644
--- a/common/log.c
+++ b/common/log.c
@@ -227,6 +227,7 @@ int _log(enum log_category_t cat, enum log_level_t level, 
const char *file,
char buf[CONFIG_SYS_CBSIZE];
struct log_rec rec;
va_list args;
+   int len;
 
/* Check for message continuation */
if (cat == LOGC_CONT)
@@ -239,12 +240,15 @@ int _log(enum log_category_t cat, enum log_level_t level, 
const char *file,
rec.flags = 0;
if (level & LOGL_FORCE_DEBUG)
rec.flags |= LOGRECF_FORCE_DEBUG;
+   if (gd->log_cont)
+   rec.flags |= LOGRECF_CONT;
rec.file = file;
rec.line = line;
rec.func = func;
va_start(args, fmt);
-   vsnprintf(buf, sizeof(buf), fmt, args);
+   len = vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
+   gd->log_cont = len && buf[len - 1] != '\n';
rec.msg = buf;
if (!gd || !(gd->flags & GD_FLG_LOG_READY)) {
if (gd)
diff --git a/common/log_console.c b/common/log_console.c
index 8776fd47039..76bc9524202 100644
--- a/common/log_console.c
+++ b/common/log_console.c
@@ -14,6 +14,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
 {
int fmt = gd->log_fmt;
+   bool add_space = false;
 
/*
 * The output format is designed to give someone a fighting chance of
@@ -25,18 +26,21 @@ static int log_console_emit(struct log_device *ldev, struct 
log_rec *rec)
 *- function is an identifier and ends with ()
 *- message has a space before it unless it is on its own
 */
-   if (fmt & BIT(LOGF_LEVEL))
-   printf("%s.", log_get_level_name(rec->level));
-   if (fmt & BIT(LOGF_CAT))
-   printf("%s,", log_get_cat_name(rec->cat));
-   if (fmt & BIT(LOGF_FILE))
-   printf("%s:", rec->file);
-   if (fmt & BIT(LOGF_LINE))
-   printf("%d-", rec->line);
-   if (fmt & BIT(LOGF_FUNC))
-   printf("%s()", rec->func);
+   if (!(rec->flags & LOGRECF_CONT) && fmt != BIT(LOGF_MSG)) {
+   add_space = true;
+   if (fmt & BIT(LOGF_LEVEL))
+   printf("%s.", log_get_level_name(rec->level));
+   if (fmt & BIT(LOGF_CAT))
+   printf("%s,", log_get_cat_name(rec->cat));
+   if (fmt & BIT(LOGF_FILE))
+   printf("%s:", rec->file);
+   if (fmt & BIT(LOGF_LINE))
+   printf("%d-", rec->line);
+   if (fmt & BIT(LOGF_FUNC))
+   printf("%s()", rec->func);
+   }
if (fmt & BIT(LOGF_MSG))
-   printf("%s%s", fmt != BIT(LOGF_MSG) ? " " : "", rec->msg);
+   printf("%s%s", add_space ? " " : "", rec->msg);
 
return 0;
 }
diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst
index 7fdd1132efe..482c17f7800 100644
--- a/doc/develop/logging.rst
+++ b/doc/develop/logging.rst
@@ -98,6 +98,22 @@ Also debug() and error() will generate log records  - these 
use LOG_CATEGORY
 as the category, so you should #define this right at the top of the source
 file to ensure the category is correct.
 
+Generally each log format_string ends with a newline. If it does not, then the
+next log statement will have the LOGRECF_CONT flag set. This can be used to
+continue the statement on the same line as the previous one without emitting
+new header information (such as category/level). This behaviour is implemented
+with log_console. Here is an example that prints a list all on one line with
+the tags at the start:
+
+.. code-block:: c
+
+   log_debug("Here is a list:");
+   for (i = 0; i < count; i++)
+  log_debug(" item %d", i);
+   log_debug("\n");
+
+Also see the special category LOGL_CONT and level LOGC_CONT.
+
 You can also define CONFIG_LOG_ERROR_RETURN to enable the log_ret() macro. This
 can be used whenever your function returns an error value:
 
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data

[PATCH 3/4] log: Add return-checking macros for 0 being success

2021-01-13 Thread Simon Glass
The existing log_ret() and log_msg_ret() macros consider an error to be
less than zero. But some function may return a positive number to indicate
a different kind of failure. Add macros to check for that also.

Signed-off-by: Simon Glass 
---

 doc/develop/logging.rst | 15 ++-
 include/log.h   | 20 
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst
index 482c17f7800..b6c6b45049f 100644
--- a/doc/develop/logging.rst
+++ b/doc/develop/logging.rst
@@ -119,11 +119,24 @@ can be used whenever your function returns an error value:
 
 .. code-block:: c
 
-   return log_ret(uclass_first_device(UCLASS_MMC, &dev));
+   return log_ret(uclass_first_device_err(UCLASS_MMC, &dev));
 
 This will write a log record when an error code is detected (a value < 0). This
 can make it easier to trace errors that are generated deep in the call stack.
 
+The log_msg_ret() variant will print a short string if CONFIG_LOG_ERROR_RETURN
+is enabled. So long as the string is unique within the function you can 
normally
+determine exactly which call failed:
+
+.. code-block:: c
+
+   ret = gpio_request_by_name(dev, "cd-gpios", 0, &desc, GPIOD_IS_IN);
+   if (ret)
+  return log_msg_ret("gpio", ret);
+
+Some functions return 0 for success and any other value is an error. For these,
+log_retz() and log_msg_retz() are available.
+
 Convenience functions
 ~
 
diff --git a/include/log.h b/include/log.h
index b6b3c6b887e..c5c1cf92356 100644
--- a/include/log.h
+++ b/include/log.h
@@ -309,10 +309,30 @@ void __assert_fail(const char *assertion, const char 
*file, unsigned int line,
__ret); \
__ret; \
})
+
+/*
+ * Similar to the above, but any non-zero value is consider an error, not just
+ * values less than 0.
+ */
+#define log_retz(_ret) ({ \
+   int __ret = (_ret); \
+   if (__ret) \
+   log(LOG_CATEGORY, LOGL_ERR, "returning err=%d\n", __ret); \
+   __ret; \
+   })
+#define log_msg_retz(_msg, _ret) ({ \
+   int __ret = (_ret); \
+   if (__ret) \
+   log(LOG_CATEGORY, LOGL_ERR, "%s: returning err=%d\n", _msg, \
+   __ret); \
+   __ret; \
+   })
 #else
 /* Non-logging versions of the above which just return the error code */
 #define log_ret(_ret) (_ret)
 #define log_msg_ret(_msg, _ret) ((void)(_msg), _ret)
+#define log_retz(_ret) (_ret)
+#define log_msg_retz(_msg, _ret) ((void)(_msg), _ret)
 #endif
 
 /** * enum log_rec_flags - Flags for a log record */
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 4/4] log: Convert log values to printf() if not enabled

2021-01-13 Thread Simon Glass
At present if logging not enabled, log_info() becomes a nop. But we want
log output at the 'info' level to be akin to printf(). Update the macro to
pass the output straight to printf() in this case.

Signed-off-by: Simon Glass 
---

 doc/develop/logging.rst |  5 +++--
 include/log.h   | 12 
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst
index b6c6b45049f..fdc869204df 100644
--- a/doc/develop/logging.rst
+++ b/doc/develop/logging.rst
@@ -54,6 +54,9 @@ If CONFIG_LOG is not set, then no logging will be available.
 The above have SPL and TPL versions also, e.g. CONFIG_SPL_LOG_MAX_LEVEL and
 CONFIG_TPL_LOG_MAX_LEVEL.
 
+If logging is disabled, the default behaviour is to output any message at
+level LOGL_INFO and below.
+
 Temporary logging within a single file
 --
 
@@ -293,8 +296,6 @@ More logging destinations:
 
 Convert debug() statements in the code to log() statements
 
-Support making printf() emit log statements at L_INFO level
-
 Convert error() statements in the code to log() statements
 
 Figure out what to do with BUG(), BUG_ON() and warn_non_spl()
diff --git a/include/log.h b/include/log.h
index c5c1cf92356..3d19f0448da 100644
--- a/include/log.h
+++ b/include/log.h
@@ -175,25 +175,29 @@ static inline int _log_nop(enum log_category_t cat, enum 
log_level_t level,
 #define log_io(_fmt...)log_nop(LOG_CATEGORY, LOGL_DEBUG_IO, 
##_fmt)
 #endif
 
-#if CONFIG_IS_ENABLED(LOG)
 #ifdef LOG_DEBUG
 #define _LOG_DEBUG LOGL_FORCE_DEBUG
 #else
 #define _LOG_DEBUG 0
 #endif
 
+#if CONFIG_IS_ENABLED(LOG)
+
 /* Emit a log record if the level is less that the maximum */
 #define log(_cat, _level, _fmt, _args...) ({ \
int _l = _level; \
-   if (CONFIG_IS_ENABLED(LOG) && \
-   (_LOG_DEBUG != 0 || _l <= _LOG_MAX_LEVEL)) \
+   if ((_LOG_DEBUG != 0 || _l <= _LOG_MAX_LEVEL)) \
_log((enum log_category_t)(_cat), \
 (enum log_level_t)(_l | _LOG_DEBUG), __FILE__, \
 __LINE__, __func__, \
  pr_fmt(_fmt), ##_args); \
})
 #else
-#define log(_cat, _level, _fmt, _args...)
+#define log(_cat, _level, _fmt, _args...) ({ \
+   int _l = _level; \
+   if ((_LOG_DEBUG != 0 || _l <= LOGL_INFO)) \
+   printf(_fmt, ##_args); \
+   })
 #endif
 
 #define log_nop(_cat, _level, _fmt, _args...) ({ \
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 1/4] log: Set up a flag byte for log records

2021-01-13 Thread Simon Glass
At present only a single flag (force_debug) is used in log records. Before
adding more, convert this into a bitfield, so more can be added without
using more space.

To avoid expanding the log_record struct itself (which some drivers may
wish to store in memory) reduce the line-number field to 16 bits. This
provides for up to 64K lines which should be enough for anyone.

Signed-off-by: Simon Glass 
---

 common/log.c  |  6 --
 include/log.h | 14 ++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/common/log.c b/common/log.c
index ce39918e045..d0abedaa05e 100644
--- a/common/log.c
+++ b/common/log.c
@@ -152,7 +152,7 @@ static bool log_passes_filters(struct log_device *ldev, 
struct log_rec *rec)
 {
struct log_filter *filt;
 
-   if (rec->force_debug)
+   if (rec->flags & LOGRECF_FORCE_DEBUG)
return true;
 
/* If there are no filters, filter on the default log level */
@@ -236,7 +236,9 @@ int _log(enum log_category_t cat, enum log_level_t level, 
const char *file,
 
rec.cat = cat;
rec.level = level & LOGL_LEVEL_MASK;
-   rec.force_debug = level & LOGL_FORCE_DEBUG;
+   rec.flags = 0;
+   if (level & LOGL_FORCE_DEBUG)
+   rec.flags |= LOGRECF_FORCE_DEBUG;
rec.file = file;
rec.line = line;
rec.func = func;
diff --git a/include/log.h b/include/log.h
index 6bce5606489..2416c3c8113 100644
--- a/include/log.h
+++ b/include/log.h
@@ -315,6 +315,12 @@ void __assert_fail(const char *assertion, const char 
*file, unsigned int line,
 #define log_msg_ret(_msg, _ret) ((void)(_msg), _ret)
 #endif
 
+/** * enum log_rec_flags - Flags for a log record */
+enum log_rec_flags {
+   /** @LOGRECF_FORCE_DEBUG: Force output of debug record */
+   LOGRECF_FORCE_DEBUG = BIT(0),
+};
+
 /**
  * struct log_rec - a single log record
  *
@@ -330,18 +336,18 @@ void __assert_fail(const char *assertion, const char 
*file, unsigned int line,
  *
  * @cat: Category, representing a uclass or part of U-Boot
  * @level: Severity level, less severe is higher
- * @force_debug: Force output of debug
- * @file: Name of file where the log record was generated (not allocated)
  * @line: Line number where the log record was generated
+ * @flags: Flags for log record (enum log_rec_flags)
+ * @file: Name of file where the log record was generated (not allocated)
  * @func: Function where the log record was generated (not allocated)
  * @msg: Log message (allocated)
  */
 struct log_rec {
enum log_category_t cat;
enum log_level_t level;
-   bool force_debug;
+   u16 line;
+   u8 flags;
const char *file;
-   int line;
const char *func;
const char *msg;
 };
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 0/4] log: Allow multiple lines and conversion to printf()

2021-01-13 Thread Simon Glass
At present when logging is not enabled, all log calls become nops. This
does not seem right, since if the log level is high enough then there
should be some sort of message. So in that case, this series updates it to
print the message if the log level is above LOGL_INFO.

Also the current implementation does not support multiple log calls on the
same line nicely. The tags are repeated so the line is very hard to read.
This series adds that as a new feature.


Simon Glass (4):
  log: Set up a flag byte for log records
  log: Handle line continuation
  log: Add return-checking macros for 0 being success
  log: Convert log values to printf() if not enabled

 common/log.c  | 12 ++--
 common/log_console.c  | 26 ++---
 doc/develop/logging.rst   | 36 +--
 include/asm-generic/global_data.h |  6 
 include/log.h | 48 +--
 test/log/cont_test.c  | 19 +---
 6 files changed, 118 insertions(+), 29 deletions(-)

-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 15/17] crc32: Exclude crc32 from TPL

2021-01-13 Thread Simon Glass
Unfortunately the toolchain often brings in the crc32 table even if the
function is not actually used. For now, exclude it from the TPL build,
which is very sensitive to size.

Signed-off-by: Simon Glass 
---

 lib/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/Makefile b/lib/Makefile
index 851a80ef3bf..edc1c3dd4f9 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -92,7 +92,9 @@ obj-y += display_options.o
 CFLAGS_display_options.o := $(if $(BUILD_TAG),-DBUILD_TAG='"$(BUILD_TAG)"')
 obj-$(CONFIG_BCH) += bch.o
 obj-$(CONFIG_MMC_SPI) += crc7.o
+#ifndef CONFIG_TPL_BUILD
 obj-y += crc32.o
+#endif
 obj-$(CONFIG_CRC32C) += crc32c.o
 obj-y += ctype.o
 obj-y += div64.o
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 17/17] binman: Allow reading entries from a subnode

2021-01-13 Thread Simon Glass
Some images may have multiple copies of the same thing, e.g. two versions
of the read/write U-Boots. It is necessary to read data from one or other
of these under selection of the verified-boot logic. Add a function to
select the subnode to use.

Signed-off-by: Simon Glass 
---

 include/binman.h | 14 ++
 lib/binman.c | 18 ++
 2 files changed, 32 insertions(+)

diff --git a/include/binman.h b/include/binman.h
index 8b89a9666d5..5958dfb4485 100644
--- a/include/binman.h
+++ b/include/binman.h
@@ -70,6 +70,20 @@ int binman_entry_find(const char *name, struct binman_entry 
*entry);
  */
 ofnode binman_section_find_node(const char *name);
 
+/**
+ * binman_select_subnode() - Select a subnode to use to find entries
+ *
+ * Normally binman selects the top-level node for future entry requests, such 
as
+ * binman_entry_find(). This function allows a subnode to be chosen instead.
+ *
+ * @name: Name of subnode, typically a section. This must be in the top-level
+ * binman node
+ * @return 0 if OK, -EINVAL if there is no /binman node, -ECHILD if multiple
+ * images are being used but the first image is not available, -ENOENT if
+ * the requested subnode cannot be found
+ */
+int binman_select_subnode(const char *name);
+
 /**
  * binman_init() - Set up the binman symbol information
  *
diff --git a/lib/binman.c b/lib/binman.c
index b6d9dff5b7c..f415df30545 100644
--- a/lib/binman.c
+++ b/lib/binman.c
@@ -116,6 +116,24 @@ int binman_get_rom_offset(void)
return binman->rom_offset;
 }
 
+int binman_select_subnode(const char *name)
+{
+   ofnode node;
+   int ret;
+
+   ret = find_image_node(&node);
+   if (ret)
+   return log_msg_ret("main", -ENOENT);
+   node = ofnode_find_subnode(node, name);
+   if (!ofnode_valid(node))
+   return log_msg_ret("node", -ENOENT);
+   binman->image = node;
+   log_debug("binman: Selected image subnode '%s'\n",
+ ofnode_get_name(binman->image));
+
+   return 0;
+}
+
 int binman_init(void)
 {
int ret;
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 16/17] binman: Move selection of the binman node into a function

2021-01-13 Thread Simon Glass
Move this logic out of the main init function so it is available for
other purpose.

Use a different error when multiple-images is in use but no subnode is
available. This makes it easier to determine what is wrong.

Signed-off-by: Simon Glass 
---

 lib/binman.c | 43 +--
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/lib/binman.c b/lib/binman.c
index f027d1b3042..b6d9dff5b7c 100644
--- a/lib/binman.c
+++ b/lib/binman.c
@@ -30,6 +30,34 @@ struct binman_info {
 
 static struct binman_info *binman;
 
+/**
+ * find_image_node() - Find the top-level binman node
+ *
+ * Finds the binman node which can be used to load entries. The correct node
+ * depends on whether multiple-images is in use.
+ *
+ * @nodep: Returns the node found, on success
+ * @return 0 if OK, , -EINVAL if there is no /binman node, -ECHILD if multiple
+ * images are being used but the first image is not available
+ */
+static int find_image_node(ofnode *nodep)
+{
+   ofnode node;
+
+   node = ofnode_path("/binman");
+   if (!ofnode_valid(node))
+   return log_msg_ret("binman node", -EINVAL);
+   if (ofnode_read_bool(node, "multiple-images")) {
+   node = ofnode_first_subnode(node);
+
+   if (!ofnode_valid(node))
+   return log_msg_ret("first image", -ECHILD);
+   }
+   *nodep = node;
+
+   return 0;
+}
+
 static int binman_entry_find_internal(ofnode node, const char *name,
  struct binman_entry *entry)
 {
@@ -90,19 +118,14 @@ int binman_get_rom_offset(void)
 
 int binman_init(void)
 {
+   int ret;
+
binman = malloc(sizeof(struct binman_info));
if (!binman)
return log_msg_ret("space for binman", -ENOMEM);
-   binman->image = ofnode_path("/binman");
-   if (!ofnode_valid(binman->image))
-   return log_msg_ret("binman node", -EINVAL);
-   if (ofnode_read_bool(binman->image, "multiple-images")) {
-   ofnode node = ofnode_first_subnode(binman->image);
-
-   if (!ofnode_valid(node))
-   return log_msg_ret("first image", -ENOENT);
-   binman->image = node;
-   }
+   ret = find_image_node(&binman->image);
+   if (ret)
+   return log_msg_ret("node", -ENOENT);
binman_set_rom_offset(ROM_OFFSET_NONE);
 
return 0;
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 14/17] mmc: pci_mmc: Set the removable flag

2021-01-13 Thread Simon Glass
Set this flag so that it is available to those looking at the device. For
non-removable devices there is no need to check for insertion/removable
since the media can never change.

Signed-off-by: Simon Glass 
---

 drivers/mmc/pci_mmc.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c
index 6517d8268b2..e2389d1644a 100644
--- a/drivers/mmc/pci_mmc.c
+++ b/drivers/mmc/pci_mmc.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,8 +41,15 @@ static int pci_mmc_probe(struct udevice *dev)
struct pci_mmc_plat *plat = dev_get_plat(dev);
struct pci_mmc_priv *priv = dev_get_priv(dev);
struct sdhci_host *host = &priv->host;
+   struct blk_desc *desc;
int ret;
 
+   ret = mmc_of_parse(dev, &plat->cfg);
+   if (ret)
+   return ret;
+   desc = mmc_get_blk_desc(&plat->mmc);
+   desc->removable = !(plat->cfg.host_caps & MMC_CAP_NONREMOVABLE);
+
host->ioaddr = (void *)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0,
  PCI_REGION_MEM);
host->name = dev->name;
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 12/17] mmc: pci_mmc: Only generate ACPI code for the SD card

2021-01-13 Thread Simon Glass
At present if an eMMC part is in the system, the ACPI table generated
will include information about that, as well as the SD card. We only need
to include the SD card, since it has a card-detect GPIO. Use a different
compatible string for each option, and add code only for the SD card.

Signed-off-by: Simon Glass 
---

 drivers/mmc/pci_mmc.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c
index c71c495d581..6517d8268b2 100644
--- a/drivers/mmc/pci_mmc.c
+++ b/drivers/mmc/pci_mmc.c
@@ -17,6 +17,12 @@
 #include 
 #include 
 
+/* Type of MMC device */
+enum {
+   TYPE_SD,
+   TYPE_EMMC,
+};
+
 struct pci_mmc_plat {
struct mmc_config cfg;
struct mmc mmc;
@@ -77,6 +83,8 @@ static int pci_mmc_acpi_fill_ssdt(const struct udevice *dev,
 
if (!dev_has_ofnode(dev))
return 0;
+   if (dev_get_driver_data(dev) == TYPE_EMMC)
+   return 0;
 
ret = gpio_get_acpi(&priv->cd_gpio, &gpio);
if (ret)
@@ -120,7 +128,8 @@ struct acpi_ops pci_mmc_acpi_ops = {
 };
 
 static const struct udevice_id pci_mmc_match[] = {
-   { .compatible = "intel,apl-sd" },
+   { .compatible = "intel,apl-sd", .data = TYPE_SD },
+   { .compatible = "intel,apl-emmc", .data = TYPE_EMMC },
{ }
 };
 
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 13/17] x86: coral: Add a devicetree node for eMMC

2021-01-13 Thread Simon Glass
Add a node for this so we can indicate that it is does not require any
ACPI code.

Signed-off-by: Simon Glass 
---

 arch/x86/dts/chromebook_coral.dts | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/dts/chromebook_coral.dts 
b/arch/x86/dts/chromebook_coral.dts
index 965f59276af..bfbdd517d1f 100644
--- a/arch/x86/dts/chromebook_coral.dts
+++ b/arch/x86/dts/chromebook_coral.dts
@@ -569,6 +569,12 @@
acpi,name = "SDCD";
};
 
+   emmc: emmc@1c,0 {
+   reg = <0xe000 0 0 0 0>;
+   compatible = "intel,apl-emmc";
+   non-removable;
+   };
+
pch: pch@1f,0 {
reg = <0xf800 0 0 0 0>;
compatible = "intel,apl-pch";
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 09/17] fdtdec: Use CONFIG_IS_ENABLED in board_fdt_blob_setup()

2021-01-13 Thread Simon Glass
This setting may be different in SPL and TPL. Update the code to check
the correct setting.

Signed-off-by: Simon Glass 
---

 lib/fdtdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 54f7a1fe477..a2d2fb4e1fe 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1253,7 +1253,7 @@ __weak void *board_fdt_blob_setup(void)
void *fdt_blob = NULL;
 #ifdef CONFIG_SPL_BUILD
/* FDT is at end of BSS unless it is in a different memory region */
-   if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
+   if (CONFIG_IS_ENABLED(SEPARATE_BSS))
fdt_blob = (ulong *)&_image_binary_end;
else
fdt_blob = (ulong *)&__bss_end;
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 11/17] uuid: Add a comment for UUID_STR_LEN

2021-01-13 Thread Simon Glass
This macro is the length of the string but excludes the terminator. Users
must add 1 when declaring a large-enough string. Add a comment to make
this clear.

Signed-off-by: Simon Glass 
---

 include/uuid.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uuid.h b/include/uuid.h
index 73c5a89ec7c..f82f6dc5eff 100644
--- a/include/uuid.h
+++ b/include/uuid.h
@@ -23,6 +23,7 @@ struct uuid {
 #define UUID_STR_FORMAT_GUID   BIT(0)
 #define UUID_STR_UPPER_CASEBIT(1)
 
+/* Use UUID_STR_LEN + 1 for string space */
 #define UUID_STR_LEN   36
 #define UUID_BIN_LEN   sizeof(struct uuid)
 
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 10/17] display_options: Use USE_TINY_PRINTF for SPL check

2021-01-13 Thread Simon Glass
At present this code uses a simple printf() format if running in SPL. But
SPL can use the full printf. Use USE_TINY_PRINTF instead.

Signed-off-by: Simon Glass 
---

 lib/display_options.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/display_options.c b/lib/display_options.c
index b2025eeb5cf..cd48998b6d4 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -169,11 +169,10 @@ int print_buffer(ulong addr, const void *data, uint 
width, uint count,
x = lb.us[i] = *(volatile uint16_t *)data;
else
x = lb.uc[i] = *(volatile uint8_t *)data;
-#if defined(CONFIG_SPL_BUILD)
-   printf(" %x", (uint)x);
-#else
-   printf(" %0*lx", width * 2, x);
-#endif
+   if (CONFIG_IS_ENABLED(USE_TINY_PRINTF))
+   printf(" %x", (uint)x);
+   else
+   printf(" %0*lx", width * 2, x);
data += width;
}
 
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 08/17] fdtdec: Update the missing-devicetree message

2021-01-13 Thread Simon Glass
This includes information about sandbox which is not relevant for most
boards. Drop it.

Also add the address to help figure out the problem.

Signed-off-by: Simon Glass 
---

 lib/fdtdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 0ab7105fef0..54f7a1fe477 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -600,7 +600,8 @@ int fdtdec_prepare_fdt(void)
 #ifdef CONFIG_SPL_BUILD
puts("Missing DTB\n");
 #else
-   puts("No valid device tree binary found - please append one to 
U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use 
-d \n");
+   printf("No valid device tree binary found at %p\n",
+  gd->fdt_blob);
 # ifdef DEBUG
if (gd->fdt_blob) {
printf("fdt_blob=%p\n", gd->fdt_blob);
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 05/17] x86: tsc_timer: Correct overflow in __udelay()

2021-01-13 Thread Simon Glass
At present long delays such as msleep(2000) can cause an overflow in this
function. There is no need for this, since it already uses a 64-bit int.

Add a cast to correct this.

Signed-off-by: Simon Glass 
---

 drivers/timer/tsc_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c
index 706d52b830a..7d0fc66cc75 100644
--- a/drivers/timer/tsc_timer.c
+++ b/drivers/timer/tsc_timer.c
@@ -372,7 +372,7 @@ void __udelay(unsigned long usec)
u64 now = get_ticks();
u64 stop;
 
-   stop = now + usec * get_tbclk_mhz();
+   stop = now + (u64)usec * get_tbclk_mhz();
 
while ((int64_t)(stop - get_ticks()) > 0)
 #if defined(CONFIG_QEMU) && defined(CONFIG_SMP)
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 04/17] bloblist: Add missing tag names

2021-01-13 Thread Simon Glass
Add tag names for recently added types.

Fixes: d2cb7a22da0 (x86: Allow putting some tables in the bloblist)
Signed-off-by: Simon Glass 
---

 common/bloblist.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/common/bloblist.c b/common/bloblist.c
index e32f551e27e..0e6448becbc 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -33,6 +33,12 @@ static const char *const tag_name[] = {
[BLOBLISTT_SPL_HANDOFF] = "SPL hand-off",
[BLOBLISTT_VBOOT_CTX]   = "Chrome OS vboot context",
[BLOBLISTT_VBOOT_HANDOFF]   = "Chrome OS vboot hand-off",
+   [BLOBLISTT_ACPI_GNVS]   = "ACPI GNVS",
+   [BLOBLISTT_INTEL_VBT]   = "Intel Video-BIOS table",
+   [BLOBLISTT_TPM2_TCG_LOG]= "TPM v2 log space",
+   [BLOBLISTT_TCPA_LOG]= "TPM log space",
+   [BLOBLISTT_ACPI_TABLES] = "ACPI tables for x86",
+   [BLOBLISTT_SMBIOS_TABLES]   = "SMBIOS tables for x86",
 };
 
 const char *bloblist_tag_name(enum bloblist_tag_t tag)
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 06/17] video: Allow syncing the entire framebuffer to the copy

2021-01-13 Thread Simon Glass
In some cases so much of the framebuffer is updated that it is not worth
copying the changes piece by piece to the copy framebuffer. Add a function
to copy the whole thing.

Signed-off-by: Simon Glass 
---

 drivers/video/video-uclass.c | 10 ++
 include/video.h  | 14 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 8883e290357..8a832aef01a 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -275,6 +275,16 @@ int video_sync_copy(struct udevice *dev, void *from, void 
*to)
 
return 0;
 }
+
+int video_sync_copy_all(struct udevice *dev)
+{
+   struct video_priv *priv = dev_get_uclass_priv(dev);
+
+   video_sync_copy(dev, priv->fb, priv->fb + priv->fb_size);
+
+   return 0;
+}
+
 #endif
 
 /* Set up the colour map */
diff --git a/include/video.h b/include/video.h
index 7b7f62a8277..a63dbbd7df9 100644
--- a/include/video.h
+++ b/include/video.h
@@ -236,11 +236,25 @@ void video_set_default_colors(struct udevice *dev, bool 
invert);
  * frame buffer start
  */
 int video_sync_copy(struct udevice *dev, void *from, void *to);
+
+/**
+ * video_sync_copy_all() - Sync the entire framebuffer to the copy
+ *
+ * @dev: Vidconsole device being updated
+ * @return 0 (always)
+ */
+int video_sync_copy_all(struct udevice *dev);
 #else
 static inline int video_sync_copy(struct udevice *dev, void *from, void *to)
 {
return 0;
 }
+
+static inline int video_sync_copy_all(struct udevice *dev)
+{
+   return 0;
+}
+
 #endif
 
 #ifndef CONFIG_DM_VIDEO
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 07/17] net: Use CONFIG_IS_ENABLED() in eth_dev_get_mac_address()

2021-01-13 Thread Simon Glass
This function may be used in SPL where devicetree is not available.
Use the correct macro so that the function does not try to read it.

Signed-off-by: Simon Glass 
---

 net/eth-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 0156324032b..cb3f8a9095f 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -482,7 +482,7 @@ static int eth_pre_unbind(struct udevice *dev)
 
 static bool eth_dev_get_mac_address(struct udevice *dev, u8 mac[ARP_HLEN])
 {
-#if IS_ENABLED(CONFIG_OF_CONTROL)
+#if CONFIG_IS_ENABLED(OF_CONTROL)
const uint8_t *p;
 
p = dev_read_u8_array_ptr(dev, "mac-address", ARP_HLEN);
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 03/17] bloblist: Support relocating to a larger space

2021-01-13 Thread Simon Glass
Typically in TPL/SPL the bloblist is quite small. But U-Boot proper may
want to add a lot more to it, such as ACPI tables.

Add a way to expand the bloblist by relocating it in U-Boot proper, along
with the other relocation activities.

Signed-off-by: Simon Glass 
---

 common/Kconfig | 10 ++
 common/bloblist.c  | 11 +++
 common/board_f.c   | 10 ++
 include/bloblist.h | 10 ++
 test/bloblist.c| 36 
 5 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 2bce8c9ba1b..f5fe3701626 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -689,6 +689,16 @@ config BLOBLIST_ADDR
  Sets the address of the bloblist, set up by the first part of U-Boot
  which runs. Subsequent U-Boot stages typically use the same address.
 
+config BLOBLIST_SIZE_RELOC
+   hex "Size of bloblist after relocation"
+   depends on BLOBLIST
+   default BLOBLIST_SIZE
+   help
+ Sets the size of the bloblist in bytes after relocation. Since U-Boot
+ has a lot more memory available then, it is possible to use a larger
+ size than the one set up by SPL. This bloblist is set up during the
+ relocation process.
+
 endmenu
 
 source "common/spl/Kconfig"
diff --git a/common/bloblist.c b/common/bloblist.c
index 33b58623807..e32f551e27e 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -317,6 +317,15 @@ void bloblist_show_list(void)
}
 }
 
+void bloblist_reloc(void *to, uint to_size, void *from, uint from_size)
+{
+   struct bloblist_hdr *hdr;
+
+   memcpy(to, from, from_size);
+   hdr = to;
+   hdr->size = to_size;
+}
+
 int bloblist_init(void)
 {
bool expected;
@@ -327,6 +336,8 @@ int bloblist_init(void)
 * that runs
 */
expected = !u_boot_first_phase();
+   if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
+   expected = false;
if (expected)
ret = bloblist_check(CONFIG_BLOBLIST_ADDR,
 CONFIG_BLOBLIST_SIZE);
diff --git a/common/board_f.c b/common/board_f.c
index 9f441c44f17..2aa5e728dbb 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -576,9 +576,10 @@ static int reserve_bloblist(void)
 {
 #ifdef CONFIG_BLOBLIST
/* Align to a 4KB boundary for easier reading of addresses */
-   gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp - CONFIG_BLOBLIST_SIZE,
-  0x1000);
-   gd->new_bloblist = map_sysmem(gd->start_addr_sp, CONFIG_BLOBLIST_SIZE);
+   gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp -
+  CONFIG_BLOBLIST_SIZE_RELOC, 0x1000);
+   gd->new_bloblist = map_sysmem(gd->start_addr_sp,
+ CONFIG_BLOBLIST_SIZE_RELOC);
 #endif
 
return 0;
@@ -661,7 +662,8 @@ static int reloc_bloblist(void)
 
debug("Copying bloblist from %p to %p, size %x\n",
  gd->bloblist, gd->new_bloblist, size);
-   memcpy(gd->new_bloblist, gd->bloblist, size);
+   bloblist_reloc(gd->new_bloblist, CONFIG_BLOBLIST_SIZE_RELOC,
+  gd->bloblist, size);
gd->bloblist = gd->new_bloblist;
}
 #endif
diff --git a/include/bloblist.h b/include/bloblist.h
index 8cdce61187a..964b974fdaf 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -242,6 +242,16 @@ void bloblist_show_list(void);
  */
 const char *bloblist_tag_name(enum bloblist_tag_t tag);
 
+/**
+ * bloblist_reloc() - Relocate the bloblist and optionally resize it
+ *
+ * @to: Pointer to new bloblist location (must not overlap old location)
+ * @to:size: New size for bloblist (must be larger than from_size)
+ * @from: Pointer to bloblist to relocate
+ * @from_size: Size of bloblist to relocate
+ */
+void bloblist_reloc(void *to, uint to_size, void *from, uint from_size);
+
 /**
  * bloblist_init() - Init the bloblist system with a single bloblist
  *
diff --git a/test/bloblist.c b/test/bloblist.c
index 0bb9e2d81e7..adf437ff0b1 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -352,6 +352,42 @@ static int bloblist_test_align(struct unit_test_state *uts)
 }
 BLOBLIST_TEST(bloblist_test_align, 0);
 
+/* Test relocation of a bloblist */
+static int bloblist_test_reloc(struct unit_test_state *uts)
+{
+   const uint large_size = TEST_BLOBLIST_SIZE;
+   const uint small_size = 0x20;
+   void *old_ptr, *new_ptr;
+   void *blob1, *blob2;
+   ulong new_addr;
+   ulong new_size;
+
+   ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+   old_ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE);
+
+   /* Add one blob and then one that won't fit */
+   blob1 = bloblist_add(TEST_TAG, small_size, 0);
+   ut_assertnonnull(blob1);
+   blob2 = bloblist_add(TEST_TAG2, large_size, 0);
+   ut_assertnull(b

[PATCH 02/17] spl: Add functions for next and previous phase

2021-01-13 Thread Simon Glass
It is useful to be able to figure out which phase we are loading next and
which phase we came from. Add some functions to handle this as well as
returning the name of a phase. This allows messages like "Booting to x"
where x is the next phase.

At present, TPL says 'Jumping to U-Boot' at the end, when in fact it is
jumping to SPL. This is confusing, so use the new functions to correct
this.

Tests for this will come with an upcoming minor SPL test refactor.

Signed-off-by: Simon Glass 
---

 common/spl/spl.c |  2 +-
 include/spl.h| 53 
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 835c53deaa8..d375dcbb2ed 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -734,7 +734,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
debug("Failed to stash bootstage: err=%d\n", ret);
 #endif
 
-   debug("loaded - jumping to U-Boot...\n");
+   debug("loaded - jumping to %s...\n", spl_phase_name(spl_next_phase()));
spl_board_prepare_for_boot();
jump_to_image_no_args(&spl_image);
 }
diff --git a/include/spl.h b/include/spl.h
index a7648787b74..faffeb519ac 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -58,6 +58,7 @@ static inline bool u_boot_first_phase(void)
 }
 
 enum u_boot_phase {
+   PHASE_NONE, /* Invalid phase, signifying before U-Boot */
PHASE_TPL,  /* Running in TPL */
PHASE_SPL,  /* Running in SPL */
PHASE_BOARD_F,  /* Running in U-Boot before relocation */
@@ -123,6 +124,58 @@ static inline enum u_boot_phase spl_phase(void)
 #endif
 }
 
+/**
+ * spl_prev_phase() - Figure out the previous U-Boot phase
+ *
+ * @return the previous phase from this one, e.g. if called in SPL this returns
+ * PHASE_TPL, if TPL is enabled
+ */
+static inline enum u_boot_phase spl_prev_phase(void)
+{
+#ifdef CONFIG_TPL_BUILD
+   return PHASE_NONE;
+#elif defined(CONFIG_SPL_BUILD)
+   return IS_ENABLED(CONFIG_TPL) ? PHASE_TPL : PHASE_NONE;
+#else
+   return IS_ENABLED(CONFIG_SPL) ? PHASE_SPL : PHASE_NONE;
+#endif
+}
+
+/**
+ * spl_next_phase() - Figure out the next U-Boot phase
+ *
+ * @return the next phase from this one, e.g. if called in TPL this returns
+ * PHASE_SPL
+ */
+static inline enum u_boot_phase spl_next_phase(void)
+{
+#ifdef CONFIG_TPL_BUILD
+   return PHASE_SPL;
+#else
+   return PHASE_BOARD_F;
+#endif
+}
+
+/**
+ * spl_phase_name() - Get the name of the current phase
+ *
+ * @return phase name
+ */
+static inline const char *spl_phase_name(enum u_boot_phase phase)
+{
+   switch (phase) {
+   case PHASE_TPL:
+   return "TPL";
+   case PHASE_SPL:
+   return "SPL";
+   case PHASE_BOARD_F:
+   case PHASE_BOARD_R:
+   return "U-Boot";
+   default:
+   return "phase?";
+   }
+}
+
 /* A string name for SPL or TPL */
 #ifdef CONFIG_SPL_BUILD
 # ifdef CONFIG_TPL_BUILD
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH 01/17] doc: Correct documentation for uclass_root

2021-01-13 Thread Simon Glass
The comments are swapped at present so this produces an error with
'make htmldocs'. Fix it.

Signed-off-by: Simon Glass 
---

 include/asm-generic/global_data.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index aa6bba8645d..63bcf109d40 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -192,12 +192,12 @@ struct global_data {
 */
struct udevice *dm_root_f;
/**
-* @uclass_root: head of core tree
+* @uclass_root_s: head of core tree
 */
struct list_head uclass_root_s;
/**
 * @uclass_root: pointer to head of core tree, if uclasses are in
-* read-only memory and cannot be adjusted to use @uclass_root as a
+* read-only memory and cannot be adjusted to use @uclass_root_s as a
 * list head.
 */
struct list_head *uclass_root;
-- 
2.30.0.284.gd98b1dd5eaa7-goog



[PATCH] ARM: imx6: dh-imx6: Move bootcounter to SNVS_LPGDR

2021-01-13 Thread Marek Vasut
Move the bootcounter to SVNS_LPGDR to free up OCRAM for usage by the VPU.

Signed-off-by: Marek Vasut 
Cc: Stefano Babic 
---
 configs/dh_imx6_defconfig | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/configs/dh_imx6_defconfig b/configs/dh_imx6_defconfig
index 0d1f0cfeac1..0a667fbae97 100644
--- a/configs/dh_imx6_defconfig
+++ b/configs/dh_imx6_defconfig
@@ -18,8 +18,10 @@ CONFIG_DM_GPIO=y
 CONFIG_SPL_TEXT_BASE=0x00908000
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
-CONFIG_SYS_BOOTCOUNT_ADDR=0x0090
+CONFIG_BOOTCOUNT_BOOTLIMIT=3
+CONFIG_SYS_BOOTCOUNT_ADDR=0x020CC068
 CONFIG_SPL=y
+CONFIG_SYS_BOOTCOUNT_SINGLEWORD=y
 CONFIG_ENV_OFFSET_REDUND=0x11
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_SUPPORT=y
@@ -47,6 +49,7 @@ CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_WDT=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_EXT4_WRITE=y
-- 
2.29.2



Re: Invitation: Regular U-Boot video call (Tuesday 19th)

2021-01-13 Thread Andy Shevchenko
On Thu, Jan 14, 2021 at 12:00 AM Simon Glass  wrote:
> On Wed, 13 Jan 2021 at 06:00, Andy Shevchenko  
> wrote:
> > On Wed, Jan 13, 2021 at 5:39 AM Simon Glass  wrote:

...

> > I added myself with a topic, but two issues so far:
> > - i have no camera setup
>
> That should be easy to fix!

Unfortunately no, since I'll be at work premises (against policy).

> > - the timing is quite bad since it overlaps with a the series of some
> > work important meeting, shifting later by half an hour will solve it
>
> Oh dear, that's unfortunate. I have a conflict at that time every week
> :-( We also have people in Asia who won't be able to come in the
> middle of the night. We can discuss possible other time slots (30mins
> earlier?) in the meeting and I'm certainly open to having two
> different times each month.

30 min earlier is even worse to me :-(
Then not in the near future, unfortunately... I'll remove myself from
the topic list then.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] net: sun8i-emac: Allow all RGMII PHY modes

2021-01-13 Thread André Przywara
On 30/11/2020 17:23, Heinrich Schuchardt wrote:

Hi Joe,

> On 11/16/20 10:46 AM, Andre Przywara wrote:
>> So far all GBit users of the sun8i-emac driver were using the "rgmii"
>> PHY mode, even though this turns out to be mostly wrong. It just worked
>> because the PHY driver doesn't do the proper setup (yet).
>> In fact for most boards the "rgmii-id" or "rgmii-txid" PHY modes are the
>> correct ones.
>>
>> To allow the DTs to describe the phy-mode correctly, and to stay
>> compatible with Linux, at least allow those other RGMII modes in the
>> driver.
>>
>> This avoids breakage if mainline DTs will be synced with U-Boot.
>>
>> An almost identical patch (f1239d8aa84d) was merged into the Linux driver
>> and has been backported to stable kernels.
>>
>> Signed-off-by: Andre Przywara 

Are you going to take this through your tree?
Or are you OK with me merging this through u-boot-sunxi?
We depend on this for a DT update, which relies on those new PHY modes.

Cheers,
Andre

> 
> Hello Joe,
> 
> could we get this into v2021.01, please?
> 
> Acked-by: Heinrich Schuchardt 


Re: Invitation: Regular U-Boot video call (Tuesday 19th)

2021-01-13 Thread Simon Glass
Hi Andy,

On Wed, 13 Jan 2021 at 06:00, Andy Shevchenko  wrote:
>
> On Wed, Jan 13, 2021 at 5:39 AM Simon Glass  wrote:
> >
> > Hi,
> >
> > (This has been discussed for a while now so I thought I would just try it)
> >
> > As an experiment I'd like to set up a regular 30-minute U-Boot call
> > for people to discuss features, bugs, patches, etc.
> >
> > The meeting notes and details are here[1].
> >
> > Please feel free to send this to others. I cc'd a small number of
> > people on the list.
>
> I added myself with a topic, but two issues so far:
> - i have no camera setup

That should be easy to fix!

> - the timing is quite bad since it overlaps with a the series of some
> work important meeting, shifting later by half an hour will solve it

Oh dear, that's unfortunate. I have a conflict at that time every week
:-( We also have people in Asia who won't be able to come in the
middle of the night. We can discuss possible other time slots (30mins
earlier?) in the meeting and I'm certainly open to having two
different times each month.

Regards,
Simon


Re: Invitation: Regular U-Boot video call (Tuesday 19th)

2021-01-13 Thread Simon Glass
Hi Bin,

I added you, Heinrich, Tom and Andy.

For others, as mentioned in the doc I can add you to the invitation.
Just reply on this thread.

Regards,
Simon

On Tue, 12 Jan 2021 at 20:44, Bin Meng  wrote:
>
> Hi Simon,,
>
> On Wed, Jan 13, 2021 at 11:39 AM Simon Glass  wrote:
> >
> > Hi,
> >
> > (This has been discussed for a while now so I thought I would just try it)
> >
> > As an experiment I'd like to set up a regular 30-minute U-Boot call
> > for people to discuss features, bugs, patches, etc.
> >
> > The meeting notes and details are here[1].
> >
> > Please feel free to send this to others. I cc'd a small number of
> > people on the list.
> >
>
> Is there a meeting invitation so that people get notified in advance?
>
> Regards,
> Bin


Re: [PATCH] Add fixdefconfig script to update lists of defconfig files from savedefconfig

2021-01-13 Thread Tom Rini
On Wed, Jan 13, 2021 at 09:10:41AM -0700, Simon Glass wrote:

> Hi Joel,
> 
> On Mon, 11 Jan 2021 at 20:01, Joel Peshkin  wrote:
> >
> > Cc: Simon Glass 
> > Cc: Heinrich Schuchardt 
> > ---
> >  scripts/fixdefconfig | 25 +
> >  1 file changed, 25 insertions(+)
> >  create mode 100755 scripts/fixdefconfig
> 
> +Tom Rini
> 
> I normally use moveconfig for this...Tom how do you do it?

Yes, this is a single-threaded version of "moveconfig.py -sC".  This is
useful I suppose in the case where you have to sync maybe a dozen files
rather than one or two, or all of them.  But I'm not sure it's worth
applying, sorry.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 4/5] arm: dts: ls1028a: Add Ethernet switch node and dependencies

2021-01-13 Thread Michael Walle

Am 2021-01-13 19:05, schrieb Claudiu Manoil:

From: Alex Marginean 

The definition follows the DSA binding in kernel and describes the 
switch,

its ports and PHYs.
ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028A, it 
is

not used in U-Boot and was disabled.  Ethernet port aliases were also
added to better manage the multitude of ports available now, and to
enforce the order in which master and slave ports are probed.

Signed-off-by: Alex Marginean 
Signed-off-by: Claudiu Manoil 
---
 arch/arm/dts/fsl-ls1028a-rdb.dts | 36 +
 arch/arm/dts/fsl-ls1028a.dtsi| 55 +++-
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/fsl-ls1028a-rdb.dts 
b/arch/arm/dts/fsl-ls1028a-rdb.dts

index 85b4815b2e..92d83a5c0c 100644
--- a/arch/arm/dts/fsl-ls1028a-rdb.dts
+++ b/arch/arm/dts/fsl-ls1028a-rdb.dts
@@ -131,9 +131,45 @@
phy-handle = <&rdb_phy0>;
 };

+ðsw_ports {
+   port@0 {
+   status = "okay";
+   phy-mode = "qsgmii";
+   phy-handle = <&sw_phy0>;
+   };
+   port@1 {
+   status = "okay";
+   phy-mode = "qsgmii";
+   phy-handle = <&sw_phy1>;
+   };
+   port@2 {
+   status = "okay";
+   phy-mode = "qsgmii";
+   phy-handle = <&sw_phy2>;
+   };
+   port@3 {
+   status = "okay";
+   phy-mode = "qsgmii";
+   phy-handle = <&sw_phy3>;
+   };
+};
+
 &mdio0 {
status = "okay";
rdb_phy0: phy@2 {
reg = <2>;
};
+
+   sw_phy0: phy@10 {
+   reg = <0x10>;
+   };
+   sw_phy1: phy@11 {
+   reg = <0x11>;
+   };
+   sw_phy2: phy@12 {
+   reg = <0x12>;
+   };
+   sw_phy3: phy@13 {
+   reg = <0x13>;
+   };
 };
diff --git a/arch/arm/dts/fsl-ls1028a.dtsi 
b/arch/arm/dts/fsl-ls1028a.dtsi

index d0850237c7..e73769392f 100644
--- a/arch/arm/dts/fsl-ls1028a.dtsi
+++ b/arch/arm/dts/fsl-ls1028a.dtsi
@@ -14,6 +14,17 @@
#address-cells = <2>;
#size-cells = <2>;

+   aliases {
+   eth0 = &enetc0;
+   eth1 = &enetc1;
+   eth2 = &enetc2;
+   eth3 = &enetc6;
+   eth4 = &felix0;
+   eth5 = &felix1;
+   eth6 = &felix2;
+   eth7 = &felix3;
+   };


Don't include the aliases in the common dtsi. There are serveral
reasons for that:
 (1) it is really board dependent. not every board has all these
 ports.
 (2) it will mess up the device numbering for boards which use
 this dtsi. And with this it will also mess up the ethNaddr
 environment variable logic.

Please move them into the corresponding boards.


+
sysclk: sysclk {
compatible = "fixed-clock";
#clock-cells = <0>;
@@ -151,9 +162,51 @@
reg = <0x000300 0 0 0 0>;
status = "disabled";
};
+   ethsw: pci@0,5 {
+   #address-cells=<0>;
+   #size-cells=<1>;
+   reg = <0x000500 0 0 0 0>;
+
+   ethsw_ports: ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   felix0: port@0 {
+   reg = <0>;
+   status = "disabled";
+   label = "swp0";
+   };
+   felix1: port@1 {
+   reg = <1>;
+   status = "disabled";
+   label = "swp1";
+   };
+   felix2: port@2 {
+   reg = <2>;
+   status = "disabled";
+   label = "swp2";
+   };
+   felix3: port@3 {
+   reg = <3>;
+   status = "disabled";
+   label = "swp3";
+   };
+   port@4 {
+   reg = <4>;
+   phy-mode = "internal";
+   status = "okay";
+   ethernet = <&enetc2>;
+   };


status = "disabled".

Why would you enable just this port if all the switch ports
are disabled.


+   port@5 {
+   reg = <5>;
+   phy-mode = "internal";
+   sta

[PATCH 4/4] board: gateworks: imx8mm: Add Gateworks Venice board support

2021-01-13 Thread Tim Harvey
Add initial support for Gateworks Venice product family based on the
i.MX 8M Mini SoC

Signed-off-by: Tim Harvey 
---
 arch/arm/dts/imx8mm-venice-gw700x-u-boot.dtsi|  105 +
 arch/arm/dts/imx8mm-venice-gw71xx-0x-u-boot.dtsi |5 +
 arch/arm/dts/imx8mm-venice-gw72xx-0x-u-boot.dtsi |5 +
 arch/arm/dts/imx8mm-venice-gw73xx-0x-u-boot.dtsi |5 +
 arch/arm/dts/imx8mm-venice-u-boot.dtsi   |  103 +
 arch/arm/dts/imx8mm-venice.dts   |  152 ++
 arch/arm/mach-imx/imx8m/Kconfig  |7 +
 board/gateworks/venice/Kconfig   |   13 +
 board/gateworks/venice/MAINTAINERS   |7 +
 board/gateworks/venice/Makefile  |   12 +
 board/gateworks/venice/README|   34 +
 board/gateworks/venice/gsc.c |  687 ++
 board/gateworks/venice/gsc.h |   54 +
 board/gateworks/venice/imx8mm_venice.c   |  133 ++
 board/gateworks/venice/lpddr4_timing.c   | 2505 ++
 board/gateworks/venice/lpddr4_timing.h   |   12 +
 board/gateworks/venice/spl.c |  187 ++
 configs/imx8mm_venice_defconfig  |  113 +
 include/configs/imx8mm_venice.h  |  125 ++
 19 files changed, 4264 insertions(+)
 create mode 100644 arch/arm/dts/imx8mm-venice-gw700x-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw71xx-0x-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw72xx-0x-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw73xx-0x-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice.dts
 create mode 100644 board/gateworks/venice/Kconfig
 create mode 100644 board/gateworks/venice/MAINTAINERS
 create mode 100644 board/gateworks/venice/Makefile
 create mode 100644 board/gateworks/venice/README
 create mode 100644 board/gateworks/venice/gsc.c
 create mode 100644 board/gateworks/venice/gsc.h
 create mode 100644 board/gateworks/venice/imx8mm_venice.c
 create mode 100644 board/gateworks/venice/lpddr4_timing.c
 create mode 100644 board/gateworks/venice/lpddr4_timing.h
 create mode 100644 board/gateworks/venice/spl.c
 create mode 100644 configs/imx8mm_venice_defconfig
 create mode 100644 include/configs/imx8mm_venice.h

diff --git a/arch/arm/dts/imx8mm-venice-gw700x-u-boot.dtsi 
b/arch/arm/dts/imx8mm-venice-gw700x-u-boot.dtsi
new file mode 100644
index 000..a4487e2
--- /dev/null
+++ b/arch/arm/dts/imx8mm-venice-gw700x-u-boot.dtsi
@@ -0,0 +1,105 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021 Gateworks Corporation
+ */
+
+&{/soc@0} {
+   u-boot,dm-pre-reloc;
+   u-boot,dm-spl;
+};
+
+&clk {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+   /delete-property/ assigned-clocks;
+   /delete-property/ assigned-clock-parents;
+   /delete-property/ assigned-clock-rates;
+};
+
+&osc_24m {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+&aips1 {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+&aips2 {
+   u-boot,dm-spl;
+};
+
+&aips3 {
+   u-boot,dm-spl;
+};
+
+&iomuxc {
+   u-boot,dm-spl;
+};
+
+&gpio1 {
+   u-boot,dm-spl;
+};
+
+&gpio2 {
+   u-boot,dm-spl;
+};
+
+&gpio3 {
+   u-boot,dm-spl;
+};
+
+&gpio4 {
+   u-boot,dm-spl;
+};
+
+&gpio5 {
+   u-boot,dm-spl;
+};
+
+&uart2 {
+   u-boot,dm-spl;
+};
+
+&pinctrl_uart2 {
+   u-boot,dm-spl;
+};
+
+&usdhc3 {
+   u-boot,dm-spl;
+};
+
+&pinctrl_usdhc3 {
+   u-boot,dm-spl;
+};
+
+&i2c1 {
+   u-boot,dm-spl;
+};
+
+&pinctrl_i2c1 {
+   u-boot,dm-spl;
+};
+
+&i2c2 {
+   u-boot,dm-spl;
+};
+
+&pinctrl_i2c2 {
+   u-boot,dm-spl;
+};
+
+&fec1 {
+   phy-reset-gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
+   phy-reset-duration = <1>;
+   phy-reset-post-delay = <1>;
+};
+
+&{/soc@0/bus@3080/i2c@30a2/pmic@69} {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3080/i2c@30a2/pmic@69/regulators} {
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/dts/imx8mm-venice-gw71xx-0x-u-boot.dtsi 
b/arch/arm/dts/imx8mm-venice-gw71xx-0x-u-boot.dtsi
new file mode 100644
index 000..f5d52c2
--- /dev/null
+++ b/arch/arm/dts/imx8mm-venice-gw71xx-0x-u-boot.dtsi
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021 Gateworks Corporation
+ */
+#include "imx8mm-venice-gw700x-u-boot.dtsi"
diff --git a/arch/arm/dts/imx8mm-venice-gw72xx-0x-u-boot.dtsi 
b/arch/arm/dts/imx8mm-venice-gw72xx-0x-u-boot.dtsi
new file mode 100644
index 000..f5d52c2
--- /dev/null
+++ b/arch/arm/dts/imx8mm-venice-gw72xx-0x-u-boot.dtsi
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021 Gateworks Corporation
+ */
+#include "imx8mm-venice-gw700x-u-boot.dtsi"
diff --git a/arch/arm/dts/imx8mm-venice-gw73xx-0x-u-boot.dtsi 
b/arch/arm/dts/imx8mm-venice-gw73xx-0x-u-boot.dtsi
new file mode 100644
index 000..f5d52c2
--- /dev/null
+++ b/arch/arm/dts/imx8mm-venice-gw73xx-0x-u-boot.d

Re: Pull request: u-boot-riscv/master

2021-01-13 Thread Tom Rini
On Wed, Jan 13, 2021 at 01:34:55PM +0800, ub...@andestech.com wrote:

> Hi Tom,
> 
> Please pull some riscv updates:
> 
> - Update qemu-riscv.rst build instructions.
> - Add support for SPI on Kendryte K210.
> - Add Microchip PolarFire SoC Icicle Kit support.
> 
> Thanks
> Rick
> 
> CI: passed
> https://gitlab.denx.de/u-boot/custodians/u-boot-riscv/-/pipelines/5853
> 
> The following changes since commit ee6726be4f0dccb612f0193c62ca149164c8a5af:
> 
>   Merge tag 'ti-v2021.04-rc1' of 
> https://gitlab.denx.de/u-boot/custodians/u-boot-ti (2021-01-12 09:32:48 -0500)
> 
> 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 477b035bd200fbef3045902f3ea2fe26cd831a5c:
> 
>   doc: board: Add Microchip MPFS Icicle Kit doc (2021-01-13 08:51:55 +0800)

NAK:
ERROR: fdt or initrd relocation disabled at boot time
#272: FILE: include/configs/microchip_mpfs_icicle.h:32:
+   "fdt_high=0x\0" \

It also disables initrd relocation, which I don't like, but isn't fatal.
But you cannot disable fdt relocation as that leads to run time problems
all too often.

-- 
Tom


signature.asc
Description: PGP signature


Re: spi-nor dummy bytes for fast read command

2021-01-13 Thread Tudor.Ambarus
On 1/13/21 4:06 AM, Bin Meng wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the 
> content is safe
> 
> Hi,

Hi,

> 
> It seems both U-Boot and Linux kernel spi-nor drivers have the same
> assumption on dummy cycles required in a fast read command.
> 
> In U-Boot spi_nor_read_data(), there is a logic to calculate the dummy
> bytes needed for fast read command:
> 
> /* convert the dummy cycles to the number of bytes */
> op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) / 8;
> 
> This logic assumes the (nor->read_dummy * op.dummy.buswidth) is a
> multiple of 8, otherwise this won't work.
> 
> In Linux, the same logic exists in spi_nor_spimem_read_data().
> 
> Note on most flashes this is not a problem, however on some flashes
> the dummy cycles for the fast read command is configurable. If the
> dummy cycle is configured to some odd value which makes this
> assumption false, then we get a non-working driver.
> 

Right. We should use dummy cycles directly and get rid of the
dummy bytes logic. I have this in my todo queue for linux.

Cheers,
ta


Pull request for UEFI sub-system for efi-2021-04-rc1

2021-01-13 Thread Heinrich Schuchardt

Dear Tom,

The following changes since commit ee6726be4f0dccb612f0193c62ca149164c8a5af:

  Merge tag 'ti-v2021.04-rc1' of
https://gitlab.denx.de/u-boot/custodians/u-boot-ti (2021-01-12 09:32:48
-0500)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-efi.git
tags/efi-2021-04-rc1

for you to fetch changes up to 8e70f1cb3f2c18d574b087d4fc1d79e68ce98fa9:

  efi_selftest: dtbdump support EFI_DT_FIXUP_PROTOCOL (2021-01-13
02:38:01 +0100)

Gitlab showed no problems:
https://gitlab.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/5854


Pull request for UEFI sub-system for efi-2021-04-rc1

In the UEFI sub-system:

* implement non-blocking file services
* print boot device and file path in helloworld.efi
* improve detection of boot device
* correct argument handling in efivar.py
* implement EFI_DT_FIXUP_PROTOCOL

Bug fixes:

* adjust conitrace command for low baud rates
* check that FIT images are valid FDTs


Heinrich Schuchardt (16):
  efi_loader: implement non-blocking file services
  tools: efivar.py without arguments
  tools: efivar.py: incorrect indentation
  tools: efivar.py should check GUID when deleting
  tools: efivar.py unused variable
  efi_loader: simplify running helloworld.efi
  efi_loader: print boot device and file path in helloworld
  efi_loader: carve out efi_check_pe()
  image-fit: fit_check_format check for valid FDT
  efi_loader: setting boot device
  efi_loader: move efi_(u)intn_t to efi.h
  efi_loader: typedef efi_string_t text output protocol
  efi_loader: remove outdated TODO in efi_memory.c
  cmd: conitrace: increase wait for next key
  efi_loader: implement EFI_DT_FIXUP_PROTOCOL
  efi_selftest: dtbdump support EFI_DT_FIXUP_PROTOCOL

 cmd/bootefi.c | 234 +++-
 cmd/conitrace.c   |   4 +-
 cmd/efidebug.c|   5 +
 common/image-fit.c|   6 +
 doc/uefi/uefi.rst |  11 +-
 fs/fs.c   |   3 +-
 include/efi.h |   5 +
 include/efi_api.h |  34 ++--
 include/efi_dt_fixup.h|  39 +
 include/efi_loader.h  |  10 +-
 lib/efi_loader/Makefile   |   3 +
 lib/efi_loader/efi_console.c  |   6 +-
 lib/efi_loader/efi_dt_fixup.c | 160 +++
 lib/efi_loader/efi_file.c | 317
--
 lib/efi_loader/efi_image_loader.c |  80 ++
 lib/efi_loader/efi_memory.c   |   2 -
 lib/efi_loader/efi_root_node.c|   6 +
 lib/efi_loader/helloworld.c   | 167 
 lib/efi_selftest/dtbdump.c| 310
-
 net/tftp.c|   9 +-
 tools/efivar.py   |  39 ++---
 21 files changed, 1096 insertions(+), 354 deletions(-)
 create mode 100644 include/efi_dt_fixup.h
 create mode 100644 lib/efi_loader/efi_dt_fixup.c


Re: [PATCH 03/16] dh_imx6: Switch to full DM-aware

2021-01-13 Thread Marek Vasut

On 6/29/20 4:01 PM, Tom Rini wrote:

On Mon, Jun 29, 2020 at 12:27:08PM +, Ludwig Zenz wrote:

On 25/06/20 2:52 PM, Tom Rini wrote:

On Thu, Jun 25, 2020 at 02:52:58PM +, Ludwig Zenz wrote:

On 22/06/20 9:38 AM, Tom Rini wrote:

On Mon, Jun 22, 2020 at 09:38:36AM +, Ludwig Zenz wrote:


On 6/13/20 3:55 PM, Jagan Teki wrote:

Enable DM_SPI/DM_SPI_FLASH with a related config option.

Build fine, but not tested.


Hello,

due to memory limitations in the SRAM of the i.MX6S in SPL we have not used the 
device tree. Have the restrictions been removed in the meantime? We need a 
single binary for the i.MX6 q/d/dl/s variants of our system on module.

I think this patch breaks the board support for our module.


I _think_ i.MX is making use of the generic hooks to cause build time failures 
when we grow too large.  And we have addressed some, but not all of the 
concerns about DM size.  Can you please test this patch?  If it doesn't work 
doing:


diff --git a/include/configs/dh_imx6.h
b/include/configs/dh_imx6.h index 5bfdf4044b..5fb84f72a2 100644
--- a/include/configs/dh_imx6.h
+++ b/include/configs/dh_imx6.h
@@ -53,12 +53,6 @@
  /* SATA Configs */
  #define CONFIG_LBA48
  
-/* SPI Flash Configs */

-#if defined(CONFIG_SPL_BUILD)
-#undef CONFIG_DM_SPI
-#undef CONFIG_DM_SPI_FLASH
-#endif


is still needed as we have a symbol to control DM SPI in SPL directly so the 
above isn't doing what you imply you want.  Thanks!



I can remove the above defines from include/configs/dh_imx6.h when I add the 
following patch:

include/config_uncmd_spl.h
@@ -14,6 +14,7 @@
  #undef CONFIG_DM_SERIAL
  #undef CONFIG_DM_I2C
  #undef CONFIG_DM_SPI
+#undef CONFIG_DM_SPI_FLASH
  #endif




With the above patch the board hangs after printing "U-Boot SPL 
2020.07-rc5-38776-g922c6d5d009-dirty (Jun 25 2020 - 16:34:23 +0200)".

Through some debugging i found the board hangs on calling gpio_request() in 
dhcom_get_ddr3_code().
  
Just for testing I skipped dhcom_get_ddr3_code and hardcoded the DDR3 size. Then I get:


Missing DTB
fdtdec_setup() returned error -1
### ERROR ### Please RESET the board ###

Unfortunately I have not found out how the SPL should load the devicetree. Can 
you give me a hint for this?


Ah, so you've not done any SPL DM migration.

So there's two paths here.  Path 1, the config header snippet that got things rolling here does 
need to be removed as "no DM SPI in SPL" means CONFIG_SPL_DM_SPI=n and not 
"CONFIG_DM_SPI=n if CONFIG_SPL_BUILD".  We are not now, and are not at the point where we 
can say we will be at some future point, saying everyone must use DM in SPL.  You may want to 
examine the .config you get today from running dh_imx6_defconfig and seeing what can/should be 
disabled, if anything, that's an unexpected enabled option.  Path 2, look at something like 
mx6cuboxi and convert to CONFIG_SPL_DM=y



The CONFIG_SPL_DM_SPI is not in the .config of my build. The little patch for 
include/config_uncmd_spl.h from above allows me to clean up dh_imx6.h.

Remark on path 2: mx6cuboxi avoids gpio usage in spl for some reason. We need 
gpio support to detect the DDR3 size. I would like to go with path 1.

How can I check if adding CONFIG_DM_SPI_FLASH to include/config_uncmd_spl.h 
causes problems for other boards?


So this is another example then where we do need
http://patchwork.ozlabs.org/project/uboot/patch/20200604151153.3980-4-zhiqiang@nxp.com/
and I'll be pushing that to -next shortly, as it needed
http://patchwork.ozlabs.org/project/uboot/patch/20200627120041.11223-1-tr...@konsulko.com/
as well.  Thanks for digging in to this more.


Note that this patch broke the DH iMX6 board, it now hangs in SPL.


[PATCH 4/5] arm: dts: ls1028a: Add Ethernet switch node and dependencies

2021-01-13 Thread Claudiu Manoil
From: Alex Marginean 

The definition follows the DSA binding in kernel and describes the switch,
its ports and PHYs.
ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028A, it is
not used in U-Boot and was disabled.  Ethernet port aliases were also
added to better manage the multitude of ports available now, and to
enforce the order in which master and slave ports are probed.

Signed-off-by: Alex Marginean 
Signed-off-by: Claudiu Manoil 
---
 arch/arm/dts/fsl-ls1028a-rdb.dts | 36 +
 arch/arm/dts/fsl-ls1028a.dtsi| 55 +++-
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/fsl-ls1028a-rdb.dts b/arch/arm/dts/fsl-ls1028a-rdb.dts
index 85b4815b2e..92d83a5c0c 100644
--- a/arch/arm/dts/fsl-ls1028a-rdb.dts
+++ b/arch/arm/dts/fsl-ls1028a-rdb.dts
@@ -131,9 +131,45 @@
phy-handle = <&rdb_phy0>;
 };
 
+ðsw_ports {
+   port@0 {
+   status = "okay";
+   phy-mode = "qsgmii";
+   phy-handle = <&sw_phy0>;
+   };
+   port@1 {
+   status = "okay";
+   phy-mode = "qsgmii";
+   phy-handle = <&sw_phy1>;
+   };
+   port@2 {
+   status = "okay";
+   phy-mode = "qsgmii";
+   phy-handle = <&sw_phy2>;
+   };
+   port@3 {
+   status = "okay";
+   phy-mode = "qsgmii";
+   phy-handle = <&sw_phy3>;
+   };
+};
+
 &mdio0 {
status = "okay";
rdb_phy0: phy@2 {
reg = <2>;
};
+
+   sw_phy0: phy@10 {
+   reg = <0x10>;
+   };
+   sw_phy1: phy@11 {
+   reg = <0x11>;
+   };
+   sw_phy2: phy@12 {
+   reg = <0x12>;
+   };
+   sw_phy3: phy@13 {
+   reg = <0x13>;
+   };
 };
diff --git a/arch/arm/dts/fsl-ls1028a.dtsi b/arch/arm/dts/fsl-ls1028a.dtsi
index d0850237c7..e73769392f 100644
--- a/arch/arm/dts/fsl-ls1028a.dtsi
+++ b/arch/arm/dts/fsl-ls1028a.dtsi
@@ -14,6 +14,17 @@
#address-cells = <2>;
#size-cells = <2>;
 
+   aliases {
+   eth0 = &enetc0;
+   eth1 = &enetc1;
+   eth2 = &enetc2;
+   eth3 = &enetc6;
+   eth4 = &felix0;
+   eth5 = &felix1;
+   eth6 = &felix2;
+   eth7 = &felix3;
+   };
+
sysclk: sysclk {
compatible = "fixed-clock";
#clock-cells = <0>;
@@ -151,9 +162,51 @@
reg = <0x000300 0 0 0 0>;
status = "disabled";
};
+   ethsw: pci@0,5 {
+   #address-cells=<0>;
+   #size-cells=<1>;
+   reg = <0x000500 0 0 0 0>;
+
+   ethsw_ports: ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   felix0: port@0 {
+   reg = <0>;
+   status = "disabled";
+   label = "swp0";
+   };
+   felix1: port@1 {
+   reg = <1>;
+   status = "disabled";
+   label = "swp1";
+   };
+   felix2: port@2 {
+   reg = <2>;
+   status = "disabled";
+   label = "swp2";
+   };
+   felix3: port@3 {
+   reg = <3>;
+   status = "disabled";
+   label = "swp3";
+   };
+   port@4 {
+   reg = <4>;
+   phy-mode = "internal";
+   status = "okay";
+   ethernet = <&enetc2>;
+   };
+   port@5 {
+   reg = <5>;
+   phy-mode = "internal";
+   status = "disabled";
+   };
+   };
+   };
enetc6: pci@0,6 {
reg = <0x000600 0 0 0 0>;
-   status = "okay";
+   status = "disabled";
phy-mode = "internal";
};
};
-- 
2.17.1



[PATCH 2/5] sandbox: Add a DSA sandbox driver and unit test

2021-01-13 Thread Claudiu Manoil
The DSA sandbox driver is used for unit testing the DSA class code.
It implements a simple 2 port switch plus 1 CPU port, and uses a very
simple tag to identify the ports.
The DSA sandbox device is connected via CPU port to a regular Ethernet
sandbox device, called 'dsa-test-eth, managed by the existing eth sandbox
driver.  The 'dsa-test-eth' is not intended for testing the eth class
code however, but it is used to emulate traffic through the 'lan0' and
'lan1' front pannel switch ports.  To achieve this the dsa sandbox driver
registers a tx handler for the 'dsa-test-eth' device.  The switch ports,
labeled as 'lan0' and 'lan1', are also registered as eth devices by the
dsa class code this time.  So pinging through these switch ports is as
easy as:
=> setenv ethact lan0
=> ping 1.2.3.5

Unit tests for the dsa class code were also added.  The 'dsa_probe'
test exercises most API functions from dsa.h.  The 'dsa' unit test
simply exercises ARP/ICMP traffic through the two switch ports,
including tag injection and extraction, with the help of the dsa
sandbox driver.
I took care to minimize the impact on the existing eth unit tests,
though some adjustments needed to be made with the addition of
extra eth interfaces used by the dsa unit tests. The additional eth
interfaces also require MAC addresses, these have been added to the
sandbox default environment.

Signed-off-by: Alex Marginean 
Signed-off-by: Claudiu Manoil 
---
 arch/Kconfig  |   1 +
 arch/sandbox/dts/test.dts |  40 +
 drivers/net/Kconfig   |   9 ++
 drivers/net/Makefile  |   1 +
 drivers/net/dsa_sandbox.c | 181 ++
 include/configs/sandbox.h |   2 +
 test/dm/Makefile  |   1 +
 test/dm/dsa.c |  91 +++
 test/dm/eth.c |  10 +--
 9 files changed, 331 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/dsa_sandbox.c
 create mode 100644 test/dm/dsa.c

diff --git a/arch/Kconfig b/arch/Kconfig
index 27843cd79c..8a8130f0c8 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -160,6 +160,7 @@ config SANDBOX
imply CMD_CLONE
imply SILENT_CONSOLE
imply BOOTARGS_SUBST
+   imply DM_DSA
 
 config SH
bool "SuperH architecture"
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index c9b9b7b75e..8e85b343db 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -14,7 +14,9 @@
aliases {
console = &uart0;
eth0 = "/eth@10002000";
+   eth2 = &swp_0;
eth3 = ð_3;
+   eth4 = &dsa_eth0;
eth5 = ð_5;
gpio1 = &gpio_a;
gpio2 = &gpio_b;
@@ -375,6 +377,44 @@
fake-host-hwaddr = [00 00 66 44 22 22];
};
 
+   dsa_eth0: dsa-test-eth {
+   compatible = "sandbox,eth";
+   reg = <0x10006000 0x1000>;
+   fake-host-hwaddr = [00 00 66 44 22 66];
+   };
+
+   dsa-test {
+   compatible = "sandbox,dsa";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   swp_0: port@0 {
+   reg = <0>;
+   label = "lan0";
+   };
+
+   swp_1: port@1 {
+   reg = <1>;
+   label = "lan1";
+   phy-mode = "rgmii-txid";
+   fixed-link {
+   speed = <100>;
+   full-duplex;
+   };
+   };
+
+   port@2 {
+   reg = <2>;
+   ethernet = <&dsa_eth0>;
+   fixed-link {
+   speed = <1000>;
+   full-duplex;
+   };
+   };
+   };
+   };
+
firmware {
sandbox_firmware: sandbox-firmware {
compatible = "sandbox,firmware";
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 382224d04c..214aebf14a 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -77,6 +77,15 @@ config DM_ETH_PHY
help
  Enable driver model for Ethernet Generic PHY .
 
+config DSA_SANDBOX
+   depends on DM_DSA && SANDBOX
+   default y
+   bool "Sandbox: Mocked DSA driver"
+   help
+ This driver implements a dummy DSA switch connected to a dummy sandbox
+ Ethernet device used as DSA master, to test DSA class code, including
+ exported DSA API and datapath processing of Ethernet traffic.
+
 menuconfig NETDEVICES
bool "Network device support"
depends on NET
diff --git a/drivers/net/Makefile b/drivers/net/Ma

[PATCH 3/5] drivers: net: Add Felix DSA switch driver

2021-01-13 Thread Claudiu Manoil
From: Alex Marginean 

This driver is used for the Ethernet switch integrated into LS1028A NXP.
Felix on LS1028A has 4 front panel ports and two internal ports, I/O
to/from the switch is done through an ENETC Ethernet interface.
The 4 front panel ports are available as Ethernet interfaces and can be
used with the typical network commands like tftp.

Signed-off-by: Alex Marginean 
Signed-off-by: Vladimir Oltean 
Signed-off-by: Claudiu Manoil 
---
 drivers/net/fsl_enetc.h |   5 +
 drivers/net/mscc_eswitch/Kconfig|   8 +
 drivers/net/mscc_eswitch/Makefile   |   1 +
 drivers/net/mscc_eswitch/felix_switch.c | 432 
 4 files changed, 446 insertions(+)
 create mode 100644 drivers/net/mscc_eswitch/felix_switch.c

diff --git a/drivers/net/fsl_enetc.h b/drivers/net/fsl_enetc.h
index 37e7e85843..110c1d78fb 100644
--- a/drivers/net/fsl_enetc.h
+++ b/drivers/net/fsl_enetc.h
@@ -201,6 +201,11 @@ struct enetc_priv {
 /* PCS replicator block for USXGMII */
 #define ENETC_PCS_DEVAD_REPL   0x1f
 
+#define ENETC_PCS_REPL_LINK_TIMER_10x12
+#define  ENETC_PCS_REPL_LINK_TIMER_1_DEF   0x0003
+#define ENETC_PCS_REPL_LINK_TIMER_20x13
+#define  ENETC_PCS_REPL_LINK_TIMER_2_DEF   0x06a0
+
 /* ENETC external MDIO registers */
 #define ENETC_MDIO_BASE0x1c00
 #define ENETC_MDIO_CFG 0x00
diff --git a/drivers/net/mscc_eswitch/Kconfig b/drivers/net/mscc_eswitch/Kconfig
index 80dd22f98b..11fb08edaa 100644
--- a/drivers/net/mscc_eswitch/Kconfig
+++ b/drivers/net/mscc_eswitch/Kconfig
@@ -36,3 +36,11 @@ config MSCC_SERVAL_SWITCH
select PHYLIB
help
  This driver supports the Serval network switch device.
+
+config MSCC_FELIX_SWITCH
+   bool "Felix switch driver"
+   depends on DM_DSA && DM_PCI
+   select FSL_ENETC
+   help
+ This driver supports the Ethernet switch integrated in LS1028A NXP
+ SoC.
diff --git a/drivers/net/mscc_eswitch/Makefile 
b/drivers/net/mscc_eswitch/Makefile
index d583fe9fc4..22342ed114 100644
--- a/drivers/net/mscc_eswitch/Makefile
+++ b/drivers/net/mscc_eswitch/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_MSCC_LUTON_SWITCH) += luton_switch.o mscc_xfer.o 
mscc_mac_table.o m
 obj-$(CONFIG_MSCC_JR2_SWITCH) += jr2_switch.o mscc_xfer.o mscc_miim.o
 obj-$(CONFIG_MSCC_SERVALT_SWITCH) += servalt_switch.o mscc_xfer.o mscc_miim.o
 obj-$(CONFIG_MSCC_SERVAL_SWITCH) += serval_switch.o mscc_xfer.o 
mscc_mac_table.o mscc_miim.o
+obj-$(CONFIG_MSCC_FELIX_SWITCH) += felix_switch.o
diff --git a/drivers/net/mscc_eswitch/felix_switch.c 
b/drivers/net/mscc_eswitch/felix_switch.c
new file mode 100644
index 00..ae8b690e76
--- /dev/null
+++ b/drivers/net/mscc_eswitch/felix_switch.c
@@ -0,0 +1,432 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Felix Ethernet switch driver
+ * Copyright 2018-2021 NXP
+ */
+
+/*
+ * This driver is used for the Ethernet switch integrated into LS1028A NXP.
+ * Felix switch is derived from Microsemi Ocelot but there are several NXP
+ * adaptations that makes the two U-Boot drivers largely incompatible.
+ *
+ * Felix on LS1028A has 4 front panel ports and two internal ports, connected
+ * to ENETC interfaces.  We're using one of the ENETC interfaces to push 
traffic
+ * into the switch.  Injection/extraction headers are used to identify
+ * egress/ingress ports in the switch for Tx/Rx.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* defines especially around PCS are reused from enetc */
+#include "../fsl_enetc.h"
+
+#define PCI_DEVICE_ID_FELIX_ETHSW  0xEEF0
+
+/* Felix has in fact 6 ports, but we don't use the last internal one */
+#define FELIX_PORT_COUNT   5
+/* Front panel port mask */
+#define FELIX_FP_PORT_MASK 0xf
+
+/* Register map for BAR4 */
+#define FELIX_SYS  0x01
+#define FELIX_ES0  0x04
+#define FELIX_IS1  0x05
+#define FELIX_IS2  0x06
+#define FELIX_GMII(port)   (0x10 + (port) * 0x1)
+#define FELIX_QSYS 0x20
+
+#define FELIX_SYS_SYSTEM   (FELIX_SYS + 0x0E00)
+#define  FELIX_SYS_SYSTEM_EN   BIT(0)
+#define FELIX_SYS_RAM_CTRL (FELIX_SYS + 0x0F24)
+#define  FELIX_SYS_RAM_CTRL_INIT   BIT(1)
+#define FELIX_SYS_SYSTEM_PORT_MODE(a)  (FELIX_SYS_SYSTEM + 0xC + (a) * 4)
+#define  FELIX_SYS_SYSTEM_PORT_MODE_CPU0x001e
+
+#define FELIX_ES0_TCAM_CTRL(FELIX_ES0 + 0x03C0)
+#define  FELIX_ES0_TCAM_CTRL_ENBIT(0)
+#define FELIX_IS1_TCAM_CTRL(FELIX_IS1 + 0x03C0)
+#define  FELIX_IS1_TCAM_CTRL_ENBIT(0)
+#define FELIX_IS2_TCAM_CTRL(FELIX_IS2 + 0x03C0)
+#define  FELIX_IS2_TCAM_CTRL_ENBIT(0)
+
+#define FELIX_GMII_CLOCK_CFG(port) (FELIX_GMII(port) + 0x)
+#define  FELIX_GMII_CLOCK_CFG_LINK_1G  1
+#define 

[PATCH 5/5] configs: ls1028a: Enable the Ethernet switch driver in defconfig

2021-01-13 Thread Claudiu Manoil
From: Alex Marginean 

The switch driver for LS1028A Ethernet switch is now compiled in for
both LS1028A boards.

Signed-off-by: Alex Marginean 
Signed-off-by: Claudiu Manoil 
---
 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig | 2 ++
 configs/ls1028aqds_tfa_defconfig | 2 ++
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig | 2 ++
 configs/ls1028ardb_tfa_defconfig | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig 
b/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
index 14c49cd0d6..43ddcf9166 100644
--- a/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
@@ -61,6 +61,8 @@ CONFIG_DM_MDIO_MUX=y
 CONFIG_E1000=y
 CONFIG_FSL_ENETC=y
 CONFIG_MDIO_MUX_I2CREG=y
+CONFIG_DM_DSA=y
+CONFIG_MSCC_FELIX_SWITCH=y
 CONFIG_NVME=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
diff --git a/configs/ls1028aqds_tfa_defconfig b/configs/ls1028aqds_tfa_defconfig
index 09a6923708..c790e99485 100644
--- a/configs/ls1028aqds_tfa_defconfig
+++ b/configs/ls1028aqds_tfa_defconfig
@@ -67,6 +67,8 @@ CONFIG_DM_MDIO_MUX=y
 CONFIG_E1000=y
 CONFIG_FSL_ENETC=y
 CONFIG_MDIO_MUX_I2CREG=y
+CONFIG_DM_DSA=y
+CONFIG_MSCC_FELIX_SWITCH=y
 CONFIG_NVME=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
diff --git a/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig 
b/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
index b034580aef..8b9e217c61 100644
--- a/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
@@ -58,6 +58,8 @@ CONFIG_DM_MDIO=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_FSL_ENETC=y
+CONFIG_DM_DSA=y
+CONFIG_MSCC_FELIX_SWITCH=y
 CONFIG_NVME=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
diff --git a/configs/ls1028ardb_tfa_defconfig b/configs/ls1028ardb_tfa_defconfig
index 4bed352420..aa82719e5e 100644
--- a/configs/ls1028ardb_tfa_defconfig
+++ b/configs/ls1028ardb_tfa_defconfig
@@ -64,6 +64,8 @@ CONFIG_DM_MDIO=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_FSL_ENETC=y
+CONFIG_DM_DSA=y
+CONFIG_MSCC_FELIX_SWITCH=y
 CONFIG_NVME=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
-- 
2.17.1



[PATCH 1/5] net: Introduce DSA class for Ethernet switches

2021-01-13 Thread Claudiu Manoil
DSA stands for Distributed Switch Architecture and it covers switches that
are connected to the CPU through an Ethernet link and generally use frame
tags to pass information about the source/destination ports to/from CPU.
Front panel ports are presented as regular ethernet devices in U-Boot and
they are expected to support the typical networking commands.
DSA switches may be cascaded, DSA class code does not currently support
this.

Signed-off-by: Alex Marginean 
Signed-off-by: Claudiu Manoil 
---
 drivers/net/Kconfig|  14 ++
 include/dm/uclass-id.h |   1 +
 include/net.h  |   6 +
 include/net/dsa.h  | 206 
 net/Makefile   |   1 +
 net/dsa-uclass.c   | 517 +
 6 files changed, 745 insertions(+)
 create mode 100644 include/net/dsa.h
 create mode 100644 net/dsa-uclass.c

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 3a5e036880..382224d04c 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -37,6 +37,20 @@ config DM_MDIO_MUX
  This is currently implemented in net/mdio-mux-uclass.c
  Look in include/miiphy.h for details.
 
+config DM_DSA
+   bool "Enable Driver Model for DSA switches"
+   depends on DM_ETH && DM_MDIO
+   help
+ Enable driver model for DSA switches
+
+ Adds UCLASS_DSA class supporting switches that follow the Distributed
+ Switch Architecture (DSA).  These switches rely on the presence of a
+ management switch port connected to an Ethernet controller capable of
+ receiving frames from the switch.  This host Ethernet controller is
+ called the "master" Ethernet interface in DSA terminology.
+ This is currently implemented in net/dsa-uclass.c, refer to
+ include/net/dsa.h for API details.
+
 config MDIO_SANDBOX
depends on DM_MDIO && SANDBOX
default y
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index ae4425d7a5..d75de368c5 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -46,6 +46,7 @@ enum uclass_id {
UCLASS_DISPLAY, /* Display (e.g. DisplayPort, HDMI) */
UCLASS_DSI_HOST,/* Display Serial Interface host */
UCLASS_DMA, /* Direct Memory Access */
+   UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */
UCLASS_EFI, /* EFI managed devices */
UCLASS_ETH, /* Ethernet device */
UCLASS_ETH_PHY, /* Ethernet PHY device */
diff --git a/include/net.h b/include/net.h
index 13da69b7c1..b95d6a6f60 100644
--- a/include/net.h
+++ b/include/net.h
@@ -499,7 +499,13 @@ struct icmp_hdr {
  * maximum packet size and multiple of 32 bytes =  1536
  */
 #define PKTSIZE1522
+#ifndef CONFIG_DM_DSA
 #define PKTSIZE_ALIGN  1536
+#else
+/* Maximum DSA tagging overhead (headroom and/or tailroom) */
+#define DSA_MAX_OVR256
+#define PKTSIZE_ALIGN  (1536 + DSA_MAX_OVR)
+#endif
 
 /*
  * Maximum receive ring size; that is, the number of packets
diff --git a/include/net/dsa.h b/include/net/dsa.h
new file mode 100644
index 00..a2bf4851df
--- /dev/null
+++ b/include/net/dsa.h
@@ -0,0 +1,206 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2019-2021 NXP
+ */
+
+#ifndef __DSA_H__
+#define __DSA_H__
+
+#include 
+#include 
+
+/**
+ * DSA stands for Distributed Switch Architecture and it is infrastructure
+ * intended to support drivers for Switches that rely on an intermediary
+ * Ethernet device for I/O.  These switches may support cascading allowing
+ * them to be arranged as a tree.
+ * DSA is documented in detail in the Linux kernel documentation under
+ * Documentation/networking/dsa/dsa.txt
+ * The network layout of such a switch is shown below:
+ *
+ * |--|
+ * | eth0 | <--- master eth device (regular eth driver)
+ * |--|
+ *   ^  |
+ * tag added by switch -->|  |
+ *   |  |
+ *   |  |<-- tag added by DSA driver
+ *   |  v
+ * |--|
+ * | | CPU port | | <-- DSA (switch) device
+ * |  | (DSA driver)
+ * | _  _   _ |
+ * | | port0 |  | port1 |  ...  | portn | | <-- ports as eth devices
+ * |-+---+--+---+---+---+-| ('dsa-port' eth driver)
+ *
+ * In U-Boot the intent is to allow access to front panel ports (shown at the
+ * bottom of the picture) through the master Ethernet dev (eth0 in the 
picture).
+ * Front panel ports are presented as regular Ethernet devices in U-Boot and
+ * they are expected to support the typical networking commands.
+ * In general DSA switches require the use of tags, extra headers added both by
+ * software on Tx and by the switch on Rx.  These

[PATCH 0/5] Introduce DSA Ethernet switch class and Felix driver

2021-01-13 Thread Claudiu Manoil
DSA stands for Distributed Switch Architecture and it is a subsystem
introduced in the Linux kernel to support switches that:
- have an Ethernet link up to the CPU
- use some form of tagging to identify the source/destination port for
  Rx/Tx
- may be cascaded in tree-like structures.

DSA is described in depth here:
https://www.kernel.org/doc/Documentation/networking/dsa/dsa.txt

This patch set introduces a DSA class in U-Boot to support drivers of DSA
switches.  DSA drivers have to implement the following ops:
- enable/disable of switch ports,
- insert a tag in frames being transmitted, used by the switch to select
  the egress port,
- parse a tag in frames being received, used for Rx traffic.

DSA class code deals with presentation of switch ports as Ethernet
interfaces, deals with the master Ethernet device for I/O and helps with
parsing of the DT assuming the structure follows the DSA kernel binding.

Support for switch cascading is not included yet.

In the sandbox environment, the DSA sandbox driver, the switch ports and
master eth interface look like this:
=> dm tree
 Class Index  Probed  DriverName
---
[...]
 eth   4  [ + ]   eth_sandbox   |-- dsa-test-eth
 dsa   0  [ + ]   dsa_sandbox   |-- dsa-test
 eth   5  [ + ]   dsa-port  |   |-- lan0
 eth   6  [ + ]   dsa-port  |   `-- lan1

=> setenv ethact lan1
=> ping 1.2.3.5
Using lan1 device
host 1.2.3.5 is alive
=>

This patch set also introduces a driver for the Ethernet switch integrated
into NXP LS1028A, called Felix.  The switch has 4 front panel ports, I/O
to/from it is done though an ENETC Ethernet interface and meta-data is
carried between the switch and the driver though an additional header
pre-pended to the original frame.
Network commands like tftp can be used on these front panel ports.  The
ports are disabled unless used so they do not cause issues on network
topologies that include loops.

Felix as seen on LS1028A RDB:
=> dm tree
 Class Index  Probed  DriverName
---
[...]
 dsa   0  [ + ]   felix-switch  |   |-- felix-switch
 eth   4  [ + ]   dsa-port  |   |   |-- swp0
 eth   5  [ + ]   dsa-port  |   |   |-- swp1
 eth   6  [ + ]   dsa-port  |   |   |-- swp2
 eth   7  [ + ]   dsa-port  |   |   `-- swp3

=> mdio list
[...]
10 - Vitesse VSC8514 <--> swp0
11 - Vitesse VSC8514 <--> swp1
12 - Vitesse VSC8514 <--> swp2
13 - Vitesse VSC8514 <--> swp3

NOTE:
This patchset is a major rework of the dsa-class code since the last
submission from May 5th:
https://patchwork.ozlabs.org/project/uboot/cover/1588700588-8587-1-git-send-email-claudiu.man...@nxp.com/
The basic concepts and data path operation (tagging) in the DSA class
code remain the same as in the initial patchset from Alex, however the
external API has been changed significantly (simplified), the driver
model integration has been improved to the point that the DSA class
code no longer needs to allocate extra memory internally (via malloc),
reduced memory footprint, internal state data moved from the external
API and internalized, cleaner external API, internal code reworked,
completly reworked DSA sandbox driver and unit tests for better coverage
and to integrate better with the eth sandbox driver and tests, etc.
The DSA class code is now ported on top of the latest u-boot master
branch (obviously), and I tested it thoroughly with the sandbox driver
and unit tests.  The felix driver has been tested with an older uboot,
since there are some issues booting the latest upstream uboot on a
LS1028A RDB board.  Note that the felix driver itself didn't change
since the last submission, except for the DSA API function calls.

Alex Marginean (3):
  drivers: net: Add Felix DSA switch driver
  arm: dts: ls1028a: Add Ethernet switch node and dependencies
  configs: ls1028a: Enable the Ethernet switch driver in defconfig

Claudiu Manoil (2):
  net: Introduce DSA class for Ethernet switches
  sandbox: Add a DSA sandbox driver and unit test

 arch/Kconfig |   1 +
 arch/arm/dts/fsl-ls1028a-rdb.dts |  36 ++
 arch/arm/dts/fsl-ls1028a.dtsi|  55 +-
 arch/sandbox/dts/test.dts|  40 ++
 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig |   2 +
 configs/ls1028aqds_tfa_defconfig |   2 +
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig |   2 +
 configs/ls1028ardb_tfa_defconfig |   2 +
 drivers/net/Kconfig  |  23 +
 drivers/net/Makefile |   1 +
 drivers/net/dsa_sandbox.c| 181 +++
 drivers/net/fsl_enetc.h  |   5 +
 drivers/net/mscc_eswitch/Kconfig |   8 +
 drivers/net/mscc_eswitch/Makefile|   1 +

[PATCH u-boot-marvell] arm: mvebu: turris_mox: enable wdt command in defconfig

2021-01-13 Thread Marek Behún
Enable wdt command in defconfig for Turris MOX. This is useful when
doing debugging.

Signed-off-by: Marek Behún 
---
 configs/turris_mox_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
index 66dc2473d6..4543acf073 100644
--- a/configs/turris_mox_defconfig
+++ b/configs/turris_mox_defconfig
@@ -31,6 +31,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
+CONFIG_CMD_WDT=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_TFTPPUT=y
 CONFIG_CMD_CACHE=y
-- 
2.26.2



[PATCH 3/4] arm: dts: imx8mm: add Gateworks i.MX8 Mini Dev kits

2021-01-13 Thread Tim Harvey
Add Gateworks i.MX 8M Mini Development kits from Mainline Linux

Signed-off-by: Tim Harvey 
---
 arch/arm/dts/Makefile|   4 +
 arch/arm/dts/imx8mm-venice-gw700x.dtsi   | 495 +++
 arch/arm/dts/imx8mm-venice-gw71xx-0x.dts |  19 ++
 arch/arm/dts/imx8mm-venice-gw71xx.dtsi   | 186 
 arch/arm/dts/imx8mm-venice-gw72xx-0x.dts |  20 ++
 arch/arm/dts/imx8mm-venice-gw72xx.dtsi   | 311 +++
 arch/arm/dts/imx8mm-venice-gw73xx-0x.dts |  19 ++
 arch/arm/dts/imx8mm-venice-gw73xx.dtsi   | 362 ++
 8 files changed, 1416 insertions(+)
 create mode 100644 arch/arm/dts/imx8mm-venice-gw700x.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw71xx-0x.dts
 create mode 100644 arch/arm/dts/imx8mm-venice-gw71xx.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw72xx-0x.dts
 create mode 100644 arch/arm/dts/imx8mm-venice-gw72xx.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw73xx-0x.dts
 create mode 100644 arch/arm/dts/imx8mm-venice-gw73xx.dtsi

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index fd47e40..a0acf24 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -772,6 +772,10 @@ dtb-$(CONFIG_ARCH_IMX8) += \
 
 dtb-$(CONFIG_ARCH_IMX8M) += \
imx8mm-evk.dtb \
+   imx8mm-venice.dtb \
+   imx8mm-venice-gw71xx-0x.dtb \
+   imx8mm-venice-gw72xx-0x.dtb \
+   imx8mm-venice-gw73xx-0x.dtb \
imx8mm-verdin.dtb \
phycore-imx8mm.dtb \
imx8mn-ddr4-evk.dtb \
diff --git a/arch/arm/dts/imx8mm-venice-gw700x.dtsi 
b/arch/arm/dts/imx8mm-venice-gw700x.dtsi
new file mode 100644
index 000..c769fad
--- /dev/null
+++ b/arch/arm/dts/imx8mm-venice-gw700x.dtsi
@@ -0,0 +1,495 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2020 Gateworks Corporation
+ */
+
+#include 
+#include 
+#include 
+
+/ {
+   memory@4000 {
+   device_type = "memory";
+   reg = <0x0 0x4000 0 0x8000>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   user-pb {
+   label = "user_pb";
+   gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   user-pb1x {
+   label = "user_pb1x";
+   linux,code = ;
+   interrupt-parent = <&gsc>;
+   interrupts = <0>;
+   };
+
+   key-erased {
+   label = "key_erased";
+   linux,code = ;
+   interrupt-parent = <&gsc>;
+   interrupts = <1>;
+   };
+
+   eeprom-wp {
+   label = "eeprom_wp";
+   linux,code = ;
+   interrupt-parent = <&gsc>;
+   interrupts = <2>;
+   };
+
+   tamper {
+   label = "tamper";
+   linux,code = ;
+   interrupt-parent = <&gsc>;
+   interrupts = <5>;
+   };
+
+   switch-hold {
+   label = "switch_hold";
+   linux,code = ;
+   interrupt-parent = <&gsc>;
+   interrupts = <7>;
+   };
+   };
+};
+
+&A53_0 {
+   cpu-supply = <&buck3_reg>;
+};
+
+&A53_1 {
+   cpu-supply = <&buck3_reg>;
+};
+
+&A53_2 {
+   cpu-supply = <&buck3_reg>;
+};
+
+&A53_3 {
+   cpu-supply = <&buck3_reg>;
+};
+
+&ddrc {
+   operating-points-v2 = <&ddrc_opp_table>;
+
+   ddrc_opp_table: opp-table {
+   compatible = "operating-points-v2";
+
+   opp-25M {
+   opp-hz = /bits/ 64 <2500>;
+   };
+
+   opp-100M {
+   opp-hz = /bits/ 64 <1>;
+   };
+
+   opp-750M {
+   opp-hz = /bits/ 64 <75000>;
+   };
+   };
+};
+
+&fec1 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_fec1>;
+   phy-mode = "rgmii-id";
+   phy-handle = <ðphy0>;
+   status = "okay";
+
+   mdio {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ethphy0: ethernet-phy@0 {
+   compatible = "ethernet-phy-ieee802.3-c22";
+   reg = <0>;
+   ti,rx-internal-delay = ;
+   ti,tx-internal-delay = ;
+   tx-fifo-depth = ;
+   rx-fifo-depth = ;
+   };
+   };
+};
+
+&i2c1 {
+   clock-frequency = <10>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_i2c1>;
+   status = "okay";
+
+   gsc: gsc@20 {
+   compatible = "gw,gsc";
+   reg = <0x20>;
+   pinctrl-0 = <&pinctrl_gsc>;
+   int

[PATCH 2/4] power: pmic: add driver for Monolithic Power mp5416

2021-01-13 Thread Tim Harvey
This adds basic register access and child regulator binding
for the Monolithic MP5416 Power Management IC which integrates
four DC/DC switching converters and five LDO regulators.

Signed-off-by: Tim Harvey 
---
 drivers/power/pmic/Kconfig  | 15 +++
 drivers/power/pmic/Makefile |  1 +
 drivers/power/pmic/mp5416.c | 98 +
 include/power/mp5416.h  | 41 +++
 4 files changed, 155 insertions(+)
 create mode 100644 drivers/power/pmic/mp5416.c
 create mode 100644 include/power/mp5416.h

diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
index 7d51510..583fd3d 100644
--- a/drivers/power/pmic/Kconfig
+++ b/drivers/power/pmic/Kconfig
@@ -91,6 +91,21 @@ config DM_PMIC_FAN53555
  The driver implements read/write operations for use with the FAN53555
  regulator driver and binds the regulator driver to its node.
 
+config DM_PMIC_MP5416
+   bool "Enable Driver Model for PMIC MP5416"
+   depends on DM_PMIC
+   help
+ This config enables implementation of driver-model pmic uclass 
features
+ for PMIC MP5416. The driver implements read/write operations.
+
+config SPL_DM_PMIC_MP5416
+   bool "Enable Driver Model for PMIC MP5416 in SPL stage"
+   depends on DM_PMIC
+   help
+ This config enables implementation of driver-model pmic uclass
+ features for PMIC MP5416. The driver implements read/write
+ operations.
+
 config DM_PMIC_PCA9450
bool "Enable Driver Model for PMIC PCA9450"
depends on DM_PMIC
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index 9cd6c37..2b2a6dd 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o
 obj-$(CONFIG_DM_PMIC_MAX8998) += max8998.o
 obj-$(CONFIG_DM_PMIC_MC34708) += mc34708.o
 obj-$(CONFIG_$(SPL_)DM_PMIC_BD71837) += bd71837.o
+obj-$(CONFIG_$(SPL_)DM_PMIC_MP5416) += mp5416.o
 obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o
 obj-$(CONFIG_$(SPL_)DM_PMIC_PCA9450) += pca9450.o
 obj-$(CONFIG_PMIC_S2MPS11) += s2mps11.o
diff --git a/drivers/power/pmic/mp5416.c b/drivers/power/pmic/mp5416.c
new file mode 100644
index 000..458c4df
--- /dev/null
+++ b/drivers/power/pmic/mp5416.c
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier:  GPL-2.0+
+/*
+ * Copyright 2020 Gateworks Corporation
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct pmic_child_info pmic_children_info[] = {
+   /* buck */
+   { .prefix = "b", .driver = MP6416_REGULATOR_DRIVER },
+   /* ldo */
+   { .prefix = "l", .driver = MP6416_REGULATOR_DRIVER },
+   { },
+};
+
+static int mp5416_reg_count(struct udevice *dev)
+{
+   return MP5416_NUM_OF_REGS - 1;
+}
+
+static int mp5416_write(struct udevice *dev, uint reg, const uint8_t *buff,
+   int len)
+{
+   if (dm_i2c_write(dev, reg, buff, len)) {
+   pr_err("write error to device: %p register: %#x!", dev, reg);
+   return -EIO;
+   }
+
+   return 0;
+}
+
+static int mp5416_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+   if (dm_i2c_read(dev, reg, buff, len)) {
+   pr_err("read error from device: %p register: %#x!", dev, reg);
+   return -EIO;
+   }
+
+   return 0;
+}
+
+static int mp5416_bind(struct udevice *dev)
+{
+   int children;
+   ofnode regulators_node;
+
+   debug("%s %s\n", __func__, dev->name);
+   regulators_node = dev_read_subnode(dev, "regulators");
+   if (!ofnode_valid(regulators_node)) {
+   debug("%s: %s regulators subnode not found!\n", __func__,
+ dev->name);
+   return -ENXIO;
+   }
+
+   debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
+
+   children = pmic_bind_children(dev, regulators_node, pmic_children_info);
+   if (!children)
+   debug("%s: %s - no child found\n", __func__, dev->name);
+
+   /* Always return success for this device */
+   return 0;
+}
+
+static int mp5416_probe(struct udevice *dev)
+{
+   debug("%s %s\n", __func__, dev->name);
+
+   return 0;
+}
+
+static struct dm_pmic_ops mp5416_ops = {
+   .reg_count = mp5416_reg_count,
+   .read = mp5416_read,
+   .write = mp5416_write,
+};
+
+static const struct udevice_id mp5416_ids[] = {
+   { .compatible = "mps,mp5416", },
+   { }
+};
+
+U_BOOT_DRIVER(pmic_mp5416) = {
+   .name = "mp5416 pmic",
+   .id = UCLASS_PMIC,
+   .of_match = mp5416_ids,
+   .bind = mp5416_bind,
+   .probe = mp5416_probe,
+   .ops = &mp5416_ops,
+};
diff --git a/include/power/mp5416.h b/include/power/mp5416.h
new file mode 100644
index 000..dc096fe
--- /dev/null
+++ b/include/power/mp5416.h
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0-or-late

[PATCH 0/4] Add Gateworks Venice board support

2021-01-13 Thread Tim Harvey
The Gateworks Venice product family consists of several boards based on
the i.MX 8M Mini SoC.

A challenge I've had with this is that the board model information is
stored in an I2C based EEPROM that must be read to know what PMIC is
on the board in order to adjust certain power rails before DRAM init
is called. I found this to be a challenge in the SPL as the SPL does
not free memory thus the conceprt of calling dm_uninit() followed by
dm_init_and_scan() to change dt's live in the SPL runs out of memory.
Therefore I can't rely on DT/DM within the SPL for things that may
differ board to board.

Best Regards,

Tim

Frieder Schrempf (1):
  Respect that some compression algos can be enabled separately for SPL

Tim Harvey (3):
  power: pmic: add driver for Monolithic Power mp5416
  arm: dts: imx8mm: add Gateworks i.MX8 Mini Dev kits
  board: gateworks: imx8mm: Add Gateworks Venice board support

 arch/arm/dts/Makefile|4 +
 arch/arm/dts/imx8mm-venice-gw700x-u-boot.dtsi|  105 +
 arch/arm/dts/imx8mm-venice-gw700x.dtsi   |  495 +
 arch/arm/dts/imx8mm-venice-gw71xx-0x-u-boot.dtsi |5 +
 arch/arm/dts/imx8mm-venice-gw71xx-0x.dts |   19 +
 arch/arm/dts/imx8mm-venice-gw71xx.dtsi   |  186 ++
 arch/arm/dts/imx8mm-venice-gw72xx-0x-u-boot.dtsi |5 +
 arch/arm/dts/imx8mm-venice-gw72xx-0x.dts |   20 +
 arch/arm/dts/imx8mm-venice-gw72xx.dtsi   |  311 +++
 arch/arm/dts/imx8mm-venice-gw73xx-0x-u-boot.dtsi |5 +
 arch/arm/dts/imx8mm-venice-gw73xx-0x.dts |   19 +
 arch/arm/dts/imx8mm-venice-gw73xx.dtsi   |  362 
 arch/arm/dts/imx8mm-venice-u-boot.dtsi   |  103 +
 arch/arm/dts/imx8mm-venice.dts   |  152 ++
 arch/arm/mach-imx/imx8m/Kconfig  |7 +
 board/gateworks/venice/Kconfig   |   13 +
 board/gateworks/venice/MAINTAINERS   |7 +
 board/gateworks/venice/Makefile  |   12 +
 board/gateworks/venice/README|   34 +
 board/gateworks/venice/gsc.c |  687 ++
 board/gateworks/venice/gsc.h |   54 +
 board/gateworks/venice/imx8mm_venice.c   |  133 ++
 board/gateworks/venice/lpddr4_timing.c   | 2505 ++
 board/gateworks/venice/lpddr4_timing.h   |   12 +
 board/gateworks/venice/spl.c |  187 ++
 common/image.c   |   13 +-
 configs/imx8mm_venice_defconfig  |  113 +
 drivers/power/pmic/Kconfig   |   15 +
 drivers/power/pmic/Makefile  |1 +
 drivers/power/pmic/mp5416.c  |   98 +
 include/configs/imx8mm_venice.h  |  125 ++
 include/power/mp5416.h   |   41 +
 32 files changed, 5842 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/dts/imx8mm-venice-gw700x-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw700x.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw71xx-0x-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw71xx-0x.dts
 create mode 100644 arch/arm/dts/imx8mm-venice-gw71xx.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw72xx-0x-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw72xx-0x.dts
 create mode 100644 arch/arm/dts/imx8mm-venice-gw72xx.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw73xx-0x-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-gw73xx-0x.dts
 create mode 100644 arch/arm/dts/imx8mm-venice-gw73xx.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-venice.dts
 create mode 100644 board/gateworks/venice/Kconfig
 create mode 100644 board/gateworks/venice/MAINTAINERS
 create mode 100644 board/gateworks/venice/Makefile
 create mode 100644 board/gateworks/venice/README
 create mode 100644 board/gateworks/venice/gsc.c
 create mode 100644 board/gateworks/venice/gsc.h
 create mode 100644 board/gateworks/venice/imx8mm_venice.c
 create mode 100644 board/gateworks/venice/lpddr4_timing.c
 create mode 100644 board/gateworks/venice/lpddr4_timing.h
 create mode 100644 board/gateworks/venice/spl.c
 create mode 100644 configs/imx8mm_venice_defconfig
 create mode 100644 drivers/power/pmic/mp5416.c
 create mode 100644 include/configs/imx8mm_venice.h
 create mode 100644 include/power/mp5416.h

-- 
2.7.4



[PATCH 1/4] Respect that some compression algos can be enabled separately for SPL

2021-01-13 Thread Tim Harvey
From: Frieder Schrempf 

Some compression algorithms currently can be enabled for SPL and
U-Boot proper separately. Therefore we need to use
CONFIG_IS_ENABLED() in these cases and also prevent compiling these
functions in case of a host tool build.

Signed-off-by: Frieder Schrempf 
Signed-off-by: Tim Harvey 
---
 common/image.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/common/image.c b/common/image.c
index 451fc68..bda19c0 100644
--- a/common/image.c
+++ b/common/image.c
@@ -72,6 +72,7 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, 
uint8_t arch,
 
 #include 
 #include 
+#include 
 
 #ifndef CONFIG_SYS_BARGSIZE
 #define CONFIG_SYS_BARGSIZE 512
@@ -460,13 +461,13 @@ int image_decomp(int comp, ulong load, ulong image_start, 
int type,
else
ret = -ENOSPC;
break;
-#ifdef CONFIG_GZIP
+#if CONFIG_IS_ENABLED(GZIP) && !defined(USE_HOSTCC)
case IH_COMP_GZIP: {
ret = gunzip(load_buf, unc_len, image_buf, &image_len);
break;
}
 #endif /* CONFIG_GZIP */
-#ifdef CONFIG_BZIP2
+#if CONFIG_IS_ENABLED(BZIP2) && !defined(USE_HOSTCC)
case IH_COMP_BZIP2: {
uint size = unc_len;
 
@@ -482,7 +483,7 @@ int image_decomp(int comp, ulong load, ulong image_start, 
int type,
break;
}
 #endif /* CONFIG_BZIP2 */
-#ifdef CONFIG_LZMA
+#if CONFIG_IS_ENABLED(LZMA) && !defined(USE_HOSTCC)
case IH_COMP_LZMA: {
SizeT lzma_len = unc_len;
 
@@ -492,7 +493,7 @@ int image_decomp(int comp, ulong load, ulong image_start, 
int type,
break;
}
 #endif /* CONFIG_LZMA */
-#ifdef CONFIG_LZO
+#if CONFIG_IS_ENABLED(LZO) && !defined(USE_HOSTCC)
case IH_COMP_LZO: {
size_t size = unc_len;
 
@@ -501,7 +502,7 @@ int image_decomp(int comp, ulong load, ulong image_start, 
int type,
break;
}
 #endif /* CONFIG_LZO */
-#ifdef CONFIG_LZ4
+#if CONFIG_IS_ENABLED(LZ4) && !defined(USE_HOSTCC)
case IH_COMP_LZ4: {
size_t size = unc_len;
 
@@ -510,7 +511,7 @@ int image_decomp(int comp, ulong load, ulong image_start, 
int type,
break;
}
 #endif /* CONFIG_LZ4 */
-#ifdef CONFIG_ZSTD
+#if CONFIG_IS_ENABLED(ZSTD) && !defined(USE_HOSTCC)
case IH_COMP_ZSTD: {
size_t size = unc_len;
ZSTD_DStream *dstream;
-- 
2.7.4



[PATCH 4/4] board: keymile: add support for seli8 design based on nxp ls102x soc

2021-01-13 Thread Aleksandar Gerasimovski
The SELI8 design is a new tdm service unit card for Hitachi-Powergrids
XMC and FOX product lines.

It is based on NXP LS1021 SoC and it provides following interfaces:
 - IFC interface for NOR, NAND and external FPGA's
 - 1 x RGMII ETH for debug purposes
 - 2 x SGMII ETH for management communication via back-plane
 - 1 x uQE HDLC for management communication via back-plane
 - 1 x I2C for peripheral devices
 - 1 x SPI for peripheral devices
 - 1 x UART for debug logging

It is foreseen that the design will be later re-used for another XMC and
FOX service cards with similar SoC requirements.

Signed-off-by: Rainer Boschung 
Signed-off-by: Matteo Ghidoni 
Signed-off-by: Aleksandar Gerasimovski 

---
 arch/arm/Kconfig|  19 ++
 arch/arm/dts/Makefile   |   2 +
 arch/arm/dts/ls1021a-pg-wcom-seli8.dts  | 111 +
 board/keymile/Kconfig   |  23 +-
 board/keymile/common/ivm.c  |  19 +-
 board/keymile/pg-wcom-ls102xa/Kconfig   |  19 ++
 board/keymile/pg-wcom-ls102xa/MAINTAINERS   |  10 +
 board/keymile/pg-wcom-ls102xa/Makefile  |  11 +
 board/keymile/pg-wcom-ls102xa/ddr.c |  90 +++
 board/keymile/pg-wcom-ls102xa/pg-wcom-ls102xa.c | 160 
 configs/pg_wcom_seli8_defconfig |  63 +
 include/configs/km/pg-wcom-ls102xa.h| 309 
 include/configs/pg-wcom-seli8.h |  45 
 13 files changed, 870 insertions(+), 11 deletions(-)
 create mode 100644 arch/arm/dts/ls1021a-pg-wcom-seli8.dts
 create mode 100644 board/keymile/pg-wcom-ls102xa/Kconfig
 create mode 100644 board/keymile/pg-wcom-ls102xa/MAINTAINERS
 create mode 100644 board/keymile/pg-wcom-ls102xa/Makefile
 create mode 100644 board/keymile/pg-wcom-ls102xa/ddr.c
 create mode 100644 board/keymile/pg-wcom-ls102xa/pg-wcom-ls102xa.c
 create mode 100644 configs/pg_wcom_seli8_defconfig
 create mode 100644 include/configs/km/pg-wcom-ls102xa.h
 create mode 100644 include/configs/pg-wcom-seli8.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fbe9087..13fdf3c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1515,6 +1515,24 @@ config TARGET_LS1021ATWR
select DM_SPI_FLASH if FSL_DSPI || FSL_QSPI
imply SCSI
 
+config TARGET_PG_WCOM_SELI8
+   bool "Support Hitachi-Powergrids SELI8 service unit card"
+   select ARCH_LS1021A
+   select ARCH_SUPPORT_PSCI
+   select BOARD_EARLY_INIT_F
+   select BOARD_LATE_INIT
+   select CPU_V7A
+   select CPU_V7_HAS_NONSEC
+   select CPU_V7_HAS_VIRT
+   select SYS_FSL_DDR
+   select FSL_DDR_INTERACTIVE
+   select VENDOR_KM
+   imply SCSI
+   help
+Support for Hitachi-Powergrids SELI8 service unit card.
+SELI8 is a QorIQ LS1021a based service unit card used
+in XMC20 and FOX615 product families.
+
 config TARGET_LS1021ATSN
bool "Support ls1021atsn"
select ARCH_LS1021A
@@ -2034,6 +2052,7 @@ source "board/variscite/dart_6ul/Kconfig"
 source "board/vscom/baltos/Kconfig"
 source "board/phytium/durian/Kconfig"
 source "board/xen/xenguest_arm64/Kconfig"
+source "board/keymile/Kconfig"
 
 source "arch/arm/Kconfig.debug"
 
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index fd47e40..ec93f93 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -393,6 +393,8 @@ dtb-$(CONFIG_ARCH_LS1021A) += ls1021a-qds-duart.dtb \
ls1021a-qds-lpuart.dtb \
ls1021a-twr-duart.dtb ls1021a-twr-lpuart.dtb \
ls1021a-iot-duart.dtb ls1021a-tsn.dtb
+dtb-$(CONFIG_TARGET_PG_WCOM_SELI8) += ls1021a-pg-wcom-seli8.dtb
+
 dtb-$(CONFIG_FSL_LSCH3) += fsl-ls2080a-qds.dtb \
fsl-ls2080a-qds-42-x.dtb \
fsl-ls2080a-rdb.dtb \
diff --git a/arch/arm/dts/ls1021a-pg-wcom-seli8.dts 
b/arch/arm/dts/ls1021a-pg-wcom-seli8.dts
new file mode 100644
index 000..e335188
--- /dev/null
+++ b/arch/arm/dts/ls1021a-pg-wcom-seli8.dts
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2013-2015 Freescale Semiconductor, Inc.
+ * Copyright 2020 Hitachi Power Grids. All rights reserved.
+ */
+
+/dts-v1/;
+#include "ls1021a.dtsi"
+
+/ {
+   model = "Hitachi-Powergrids SELI8 Service Unit for XMC and FOX";
+
+   chosen {
+   stdout-path = &uart0;
+   };
+};
+
+&enet0 {
+   status = "okay";
+   tbi-handle = <&tbi0>;
+   phy-connection-type = "sgmii";
+   fixed-link {
+   speed = <1000>;
+   full-duplex;
+   };
+};
+
+&enet1 {
+   status = "okay";
+   tbi-handle = <&tbi1>;
+   phy-connection-type = "sgmii";
+   fixed-link {
+   speed = <1000>;
+   full-duplex;
+   };
+};
+
+&enet2 {
+   phy-handle = <&debug_phy>;
+   phy-connection-type = "rgmii-id";
+   status = "okay";
+};
+
+&i2c0 {
+   status = "okay";
+};
+
+&ifc {
+   #address-cells = <2>;
+   #size-cells 

[PATCH 3/4] board: keymile: common: fix pnvramaddr and varaddr address calculation

2021-01-13 Thread Aleksandar Gerasimovski
Take into account SDRAM_BASE address when calculating pnvramaddr and
varaddr offsets.
Up to now Keymile designs had SDRAM_BASE equal to zero and the offsets
where calculated correctly, this fix is for the upcoming designs that
have SDRAM_BASE different then zero.

Signed-off-by: Aleksandar Gerasimovski 

---
 board/keymile/common/common.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index df507e2..e3e9c4a 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -49,8 +49,8 @@ int set_km_env(void)
char *p;
unsigned long rootfssize = 0;
 
-   pnvramaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM
-   - CONFIG_KM_PNVRAM;
+   pnvramaddr = CONFIG_SYS_SDRAM_BASE + gd->ram_size -
+   CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM - CONFIG_KM_PNVRAM;
sprintf((char *)buf, "0x%x", pnvramaddr);
env_set("pnvramaddr", (char *)buf);
 
@@ -63,7 +63,8 @@ int set_km_env(void)
sprintf((char *)buf, "0x%x", pram);
env_set("pram", (char *)buf);
 
-   varaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM;
+   varaddr = CONFIG_SYS_SDRAM_BASE + gd->ram_size -
+   CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM;
sprintf((char *)buf, "0x%x", varaddr);
env_set("varaddr", (char *)buf);
 
-- 
1.8.3.1


[PATCH 2/4] keymile: common: qrio: print QRIO id and revision number

2021-01-13 Thread Aleksandar Gerasimovski
Add show_qrio function to print chip id and revision information.
There are already multiple QRIO chip versions available and the upcoming
designs may want to show used version.

Signed-off-by: Rainer Boschung 
Signed-off-by: Aleksandar Gerasimovski 

---
 board/keymile/common/qrio.c | 12 
 board/keymile/common/qrio.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/board/keymile/common/qrio.c b/board/keymile/common/qrio.c
index d4e75f2..25937ee 100644
--- a/board/keymile/common/qrio.c
+++ b/board/keymile/common/qrio.c
@@ -11,10 +11,22 @@
 #include "common.h"
 #include "qrio.h"
 
+/* QRIO ID register offset */
+#define ID_REV_OFF 0x00
+
 /* QRIO GPIO register offsets */
 #define DIRECT_OFF 0x18
 #define GPRT_OFF   0x1c
 
+void show_qrio(void)
+{
+   void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE;
+   u16 id_rev = in_be16(qrio_base + ID_REV_OFF);
+
+   printf("QRIO: id = %u, revision = %u\n",
+  (id_rev >> 8) & 0xff, id_rev & 0xff);
+}
+
 int qrio_get_gpio(u8 port_off, u8 gpio_nr)
 {
u32 gprt;
diff --git a/board/keymile/common/qrio.h b/board/keymile/common/qrio.h
index a04a732..757bcbf 100644
--- a/board/keymile/common/qrio.h
+++ b/board/keymile/common/qrio.h
@@ -11,6 +11,7 @@
 #define QRIO_GPIO_A0x40
 #define QRIO_GPIO_B0x60
 
+void show_qrio(void);
 int qrio_get_gpio(u8 port_off, u8 gpio_nr);
 void qrio_set_opendrain_gpio(u8 port_off, u8 gpio_nr, u8 val);
 void qrio_set_gpio(u8 port_off, u8 gpio_nr, bool value);
-- 
1.8.3.1


[PATCH 1/4] board: keymile: common: fix qrio compilation for arm

2021-01-13 Thread Aleksandar Gerasimovski
This patch is fixing qrio driver compilation for ARM architecture:
- It includes asm/io.h for in_/out_ access
- It use correct names for set/clear_bits as defined in linux/bitops.h

Signed-off-by: Aleksandar Gerasimovski 

---
 board/keymile/common/qrio.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/board/keymile/common/qrio.c b/board/keymile/common/qrio.c
index 06a4e67..d4e75f2 100644
--- a/board/keymile/common/qrio.c
+++ b/board/keymile/common/qrio.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include "common.h"
@@ -129,7 +130,7 @@ void qrio_prst(u8 bit, bool en, bool wden)
 
 void qrio_prstcfg(u8 bit, u8 mode)
 {
-   u32 prstcfg;
+   unsigned long prstcfg;
u8 i;
void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE;
 
@@ -137,9 +138,9 @@ void qrio_prstcfg(u8 bit, u8 mode)
 
for (i = 0; i < 2; i++) {
if (mode & (1 << i))
-   set_bit(2 * bit + i, &prstcfg);
+   __set_bit(2 * bit + i, &prstcfg);
else
-   clear_bit(2 * bit + i, &prstcfg);
+   __clear_bit(2 * bit + i, &prstcfg);
}
 
out_be32(qrio_base + PRSTCFG_OFF, prstcfg);
-- 
1.8.3.1


Re: [PATCH] fastboot: add UUU command UCmd and ACmd support

2021-01-13 Thread Simon Glass
Hi Heiko,

On Mon, 11 Jan 2021 at 03:19, Heiko Schocher  wrote:
>
> add support for the UUU commands ACmd and UCmd.
>
> Enable them through the Kconfig option
> CONFIG_FASTBOOT_UUU_SUPPORT
>
> base was commit in NXP kernel
> 9b149c2a2882: ("MLK-18591-3 android: Add FSL android fastboot support")
>
> and ported it to current mainline. Tested this patch
> on imx6ul based board.
>
> Signed-off-by: Heiko Schocher 
> ---
> azure build:
> https://dev.azure.com/hs0298/hs/_build/results?buildId=57&view=results
>
> version uuu tool used for tests:
> commit 3870fb781b35: ("fastboot: default to logical-block-size 4096")
>
>  doc/android/fastboot-protocol.rst |  5 +++
>  doc/android/fastboot.rst  |  2 +
>  drivers/fastboot/Kconfig  |  7 
>  drivers/fastboot/fb_command.c | 62 +++
>  drivers/usb/gadget/f_fastboot.c   | 17 +
>  include/fastboot.h|  7 
>  6 files changed, 100 insertions(+)

Reviewed-by: Simon Glass 

You can try to use if() for the CONFIG options here. See for example
vid_console_color().

It is sometimes possible to do this, too, but it is a bit riskier:

switch (xxx) {
case SOMETHING:
if (CONFIG_IS_ENABLED...) {
   do stuff if this feature is enabled
break;
}
/* no break */
default:
/* not supported */
}

Regards,
Simon


Re: [PATCH] common: fit-sig: Fix error message in fit_config_verify_sig()

2021-01-13 Thread Simon Glass
On Mon, 11 Jan 2021 at 07:47, Alexandru Gagniuc  wrote:
>
> In fit_config_verify_sig(), when no 'signature*' subnode exists in
> the configuration node, the fdt_for_each_subnode() loop is a no-op.
> Therefore, no error flags are set, and 'err_,sg' is not populated
> with an error string. This is incorrect behavior.
>
> Populate err_msg to indicate that no 'signature' is found, before
> entering the loop. The first call to fit_image_verify_sig() will
> override clear err_msg, or set it to a more specific message.
>
> Signed-off-by: Alexandru Gagniuc 
> ---
>  common/image-fit-sig.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH 1/4] misc: make CONFIG_IRQ selectable for all platforms

2021-01-13 Thread Simon Glass
On Tue, 12 Jan 2021 at 02:05, Wasim Khan  wrote:
>
> From: Wasim Khan 
>
> UCLASS_IRQ driver is not Intel specific. Make CONFIG_IRQ
> selectable for all platfroms.
>
> Signed-off-by: Wasim Khan 
> ---
>  drivers/misc/Kconfig | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH] Add fixdefconfig script to update lists of defconfig files from savedefconfig

2021-01-13 Thread Simon Glass
Hi Joel,

On Mon, 11 Jan 2021 at 20:01, Joel Peshkin  wrote:
>
> Cc: Simon Glass 
> Cc: Heinrich Schuchardt 
> ---
>  scripts/fixdefconfig | 25 +
>  1 file changed, 25 insertions(+)
>  create mode 100755 scripts/fixdefconfig

+Tom Rini

I normally use moveconfig for this...Tom how do you do it?

>
> diff --git a/scripts/fixdefconfig b/scripts/fixdefconfig
> new file mode 100755
> index 000..7f36762
> --- /dev/null
> +++ b/scripts/fixdefconfig
> @@ -0,0 +1,25 @@
> +#!/bin/bash
> +
> +if [ -z "$*" -o  "${1%_defconfig}" = "$1" ]
> +then
> +  echo "Usage:  $0 [defconfig_file...]"
> +  echo " Normalizes each listed defconfig and replaces it with the 
> normalized"
> +  echo "version. The original is renamed with an extension of .old appended"
> +  exit 1
> +fi
> +
> +tmp=tmp_build_$$
> +mkdir $tmp
> +for config in $*
> +do
> +  base=`basename $config`
> +  make O=$tmp/$base $base \
> +&& make O=$tmp/$base $base \
> +&& make O=$tmp/$base savedefconfig \
> +&& diff -q $tmp/$base/defconfig configs/$base \
> +|| mv configs/$base configs/$base.old \
> +&& mv $tmp/$base/defconfig configs/$base
> +  rm -rf $tmp/$base
> +done
> +rmdir $tmp
> +
> --
> 1.8.3.1
>

Regards,
Simon


Re: [PATCH] cmd: disk: Remove fit_print_contents API

2021-01-13 Thread Simon Glass
On Fri, 8 Jan 2021 at 10:56, Ravik Hasija  wrote:
>
> fit_print_contents prints similar fit information as printed in bootm stages.
> Removing this API reduces redundancy & provides improvement in boottime.
>
> Signed-off-by: Ravik Hasija 
> ---
>
>  cmd/disk.c | 1 -
>  1 file changed, 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCHv3 1/4] drivers: tee: i2c trampoline driver

2021-01-13 Thread Simon Glass
On Tue, 12 Jan 2021 at 01:43, Jorge Ramirez-Ortiz  wrote:
>
> This commit gives the secure world access to the I2C bus so it can
> communicate with I2C slaves (typically those would be secure elements
> like the NXP SE050).
>
> A similar service implementation has been merged in linux:
> c05210ab ("drivers: optee: allow op-tee to access devices on the i2c
> bus")
>
> Signed-off-by: Jorge Ramirez-Ortiz 
> ---
>  drivers/tee/optee/Makefile   |  1 +
>  drivers/tee/optee/i2c.c  | 90 
>  drivers/tee/optee/optee_msg.h| 21 ++
>  drivers/tee/optee/optee_msg_supplicant.h |  5 ++
>  drivers/tee/optee/optee_private.h| 17 +
>  drivers/tee/optee/supplicant.c   |  3 +
>  6 files changed, 137 insertions(+)
>  create mode 100644 drivers/tee/optee/i2c.c
>

Reviewed-by: Simon Glass 


Re: [PATCH v3 3/6] lib: Add support for ECDSA image signing

2021-01-13 Thread Simon Glass
On Thu, 7 Jan 2021 at 15:34, Alexandru Gagniuc  wrote:
>
> mkimage supports rsa2048, and rsa4096 signatures. With newer silicon
> now supporting hardware-accelerated ECDSA, it makes sense to expand
> signing support to elliptic curves.
>
> Implement host-side ECDSA signing and verification with libcrypto.
> Device-side implementation of signature verification is beyond the
> scope of this patch.
>
> Signed-off-by: Alexandru Gagniuc 
> ---
>  common/image-sig.c  |  11 +-
>  include/image.h |   3 +
>  include/u-boot/ecdsa.h  |  94 +++
>  lib/ecdsa/ecdsa-libcrypto.c | 306 
>  tools/Makefile  |   3 +
>  5 files changed, 415 insertions(+), 2 deletions(-)
>  create mode 100644 include/u-boot/ecdsa.h
>  create mode 100644 lib/ecdsa/ecdsa-libcrypto.c

Reviewed-by: Simon Glass 

But you should check the return value of do_sign(). Why do you call
ecdsa_check_signature() afterwards? Can you not trust the library?

Regards,
Simon


Re: [PATCH 3/5] lib: ecdsa: Implement signature verification for crypto_algo API

2021-01-13 Thread Simon Glass
On Mon, 11 Jan 2021 at 08:41, Alexandru Gagniuc  wrote:
>
> Implement the crypto_algo .verify() function for ecdsa256. Because
> it backends on UCLASS_ECDSA, this change is focused on parsing the
> keys from devicetree and passing this information to the specific
> UCLASS driver.
>
> Signed-off-by: Alexandru Gagniuc 
> ---
>  lib/ecdsa/ecdsa-verify.c | 117 ++-
>  1 file changed, 116 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH 4/4] sandbox: enable IRQ using select for sandbox architecture

2021-01-13 Thread Simon Glass
On Tue, 12 Jan 2021 at 02:05, Wasim Khan  wrote:
>
> From: Wasim Khan 
>
> Enable IRQ using select for sandbox architecture.
>
> Signed-off-by: Wasim Khan 
> ---
>  arch/Kconfig   | 1 +
>  configs/sandbox64_defconfig| 1 -
>  configs/sandbox_defconfig  | 1 -
>  configs/sandbox_flattree_defconfig | 1 -
>  configs/sandbox_spl_defconfig  | 1 -
>  5 files changed, 1 insertion(+), 4 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH] pci: Remove CONFIG_PCI_ENUM_ONLY as it's not used (any more)

2021-01-13 Thread Simon Glass
On Tue, 12 Jan 2021 at 04:03, Stefan Roese  wrote:
>
> This patch completely removes CONFIG_PCI_ENUM_ONLY from the PCI code as
> it is not configured for any board (any more). With this removal, some
> PCI related files get cleaned up a bit.
>
> Additional, dm_pciauto_setup_device() is now static, as it's not
> referenced from any code outside of this C file.
>
> Signed-off-by: Stefan Roese 
> Cc: Simon Glass 
> Cc: Bin Meng 
> ---
>  README   |   7 ---
>  drivers/pci/pci_auto.c   | 104 ++-
>  drivers/pci/pci_auto_old.c   |  18 --
>  scripts/config_whitelist.txt |   1 -
>  4 files changed, 41 insertions(+), 89 deletions(-)
>

Reviewed-by: Simon Glass 

Yes we handle this at run-time now.


Re: [PATCH 2/4] arch: arm: update Kconfig to select IRQ when GIC_V3_ITS is enabled

2021-01-13 Thread Simon Glass
On Tue, 12 Jan 2021 at 02:05, Wasim Khan  wrote:
>
> From: Wasim Khan 
>
> GIC_V3_ITS uses UCLASS_IRQ driver. Update Kconfig to select
> IRQ when GIC_V3_ITS is enabled.
>
> Signed-off-by: Wasim Khan 
> ---
>  arch/arm/Kconfig | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Simon Glass 


Re: [PATCH 3/4] arch: Kconfig: enable IRQ using select for x86 architecture

2021-01-13 Thread Simon Glass
On Tue, 12 Jan 2021 at 02:05, Wasim Khan  wrote:
>
> From: Wasim Khan 
>
> use 'select' to enable IRQ as it does not have architecture
> specific dependency.
>
> Signed-off-by: Wasim Khan 
> ---
>  arch/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCHv3 4/4] test: dm: tee: extend with RPC test

2021-01-13 Thread Simon Glass
On Tue, 12 Jan 2021 at 01:44, Jorge Ramirez-Ortiz  wrote:
>
> From: Igor Opaniuk 
>
> Extend existing DM tee tests adding test coverage for reverse RPC calls.
> Currently this commit only adds tests for I2C requests from TEE driver
> to TEE supplicant, for instance reading/writing data to emulated i2c
> eeprom defines in standard sandbox test device tree
> (arch/sandbox/dts/test.dtb):
>
> => i2c bus
> Bus 0:  i2c@0  (active 0)
>2c: eeprom@2c, offset len 1, flags 0
>...
>
> Running TEE tests:
> => ut dm tee
> Test: dm_test_tee: tee.c
> Test: dm_test_tee: tee.c (flat tree)
> Failures: 0
>
> Signed-off-by: Igor Opaniuk 
> ---
>  test/dm/tee.c | 109 +++---
>  1 file changed, 104 insertions(+), 5 deletions(-)

Reviewed-by: Simon Glass 

I wonder if the #ifdefs could go away, or at least be reduced. Perhaps
just assuming that the option is enabled on sandbox?


Re: [PATCHv3 3/4] drivers: tee: sandbox: add rpc test ta emulation

2021-01-13 Thread Simon Glass
On Tue, 12 Jan 2021 at 01:44, Jorge Ramirez-Ortiz  wrote:
>
> From: Igor Opaniuk 
>
> This adds support for RPC test trusted application emulation, which
> permits to test reverse RPC calls to TEE supplicant. Currently it covers
> requests to the I2C bus from TEE.
>
> Signed-off-by: Igor Opaniuk 
> ---
>  drivers/tee/Makefile|   2 +
>  drivers/tee/optee/Kconfig   |   9 +++
>  drivers/tee/sandbox.c   | 137 +++-
>  include/tee/optee_ta_rpc_test.h |  28 +++
>  4 files changed, 172 insertions(+), 4 deletions(-)
>  create mode 100644 include/tee/optee_ta_rpc_test.h

Reviewed-by: Simon Glass 


Re: [PATCHv3 2/4] test: py: add pygit2 and pyelftools to requirements.txt

2021-01-13 Thread Simon Glass
On Tue, 12 Jan 2021 at 01:43, Jorge Ramirez-Ortiz  wrote:
>
> From: Igor Opaniuk 
>
> Add pygit2 and pyelftools to the list of packages for virtualenv
> needed to run all sets of pytests.This fixes warnings like:
>
> binman.elf_test.TestElf.testDecodeElf (subunit.RemotedTestCase):
> Python elftools not available
>
> Signed-off-by: Igor Opaniuk 
> ---
>  test/py/requirements.txt | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH 5/5] Kconfig: FIT_SIGNATURE should not select RSA_VERIFY

2021-01-13 Thread Simon Glass
On Mon, 11 Jan 2021 at 08:41, Alexandru Gagniuc  wrote:
>
> FIT signatures can now be implemented with ECDSA. The assumption that
> all FIT images are signed with RSA is no longer valid. Thus, instead
> of 'select'ing RSA, only 'imply' it. This doesn't change the defaults,
> but allows one to explicitly disable RSA support.
>
> Signed-off-by: Alexandru Gagniuc 
> ---
>  common/Kconfig.boot | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 1/5] dm: crypto: Define UCLASS API for ECDSA signature verification

2021-01-13 Thread Simon Glass
Hi Alexandru,

On Mon, 11 Jan 2021 at 08:41, Alexandru Gagniuc  wrote:
>
> Define a UCLASS API for verifying ECDSA signatures. Unlike
> UCLASS_MOD_EXP, which focuses strictly on modular exponentiation,
> the ECDSA class focuses on verification. This is done so that it
> better aligns with mach-specific implementations, such as stm32mp.
>
> Signed-off-by: Alexandru Gagniuc 
> ---
>  include/crypto/ecdsa-uclass.h | 39 +++
>  include/dm/uclass-id.h|  1 +
>  2 files changed, 40 insertions(+)
>  create mode 100644 include/crypto/ecdsa-uclass.h

This needs a test, as do all uclasses in U-Boot. If it isn't easy to
implement the algorithm then I suppose you could fake it by using an
easy algorithm like md5, but it does need a test.

Regards,
Simon


Re: [PATCH v3 5/6] test/py: Add pycryptodomex to list of required pakages

2021-01-13 Thread Simon Glass
On Thu, 7 Jan 2021 at 15:34, Alexandru Gagniuc  wrote:
>
> We wish to use pycryptodomex to verify code paths involving ECDSA
> signatures. Add it to requirements.txt so that they get picked up
> automatically .gitlab and .azure tasks
>
> Signed-off-by: Alexandru Gagniuc 
> ---
>  test/py/requirements.txt | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Simon Glass 


Re: [PATCH v3 6/6] test/py: ecdsa: Add test for mkimage ECDSA signing

2021-01-13 Thread Simon Glass
Hi Alexandru,

On Thu, 7 Jan 2021 at 15:34, Alexandru Gagniuc  wrote:
>
> Add a test to make sure that the ECDSA signatures generated by
> mkimage can be verified successfully. pyCryptodomex was chosen as the
> crypto library because it integrates much better with python code.
> Using openssl would have been unnecessarily painful.
>
> Signed-off-by: Alexandru Gagniuc 
> ---
>  test/py/tests/test_fit_ecdsa.py | 111 
>  1 file changed, 111 insertions(+)
>  create mode 100644 test/py/tests/test_fit_ecdsa.py
>

This is fine for now, but I think it will need to be integrated with
the existing test somehow once you have the runtime side working.

Reviewed-by: Simon Glass 

Regards,
Simon


Re: [PATCH v3 4/6] doc: signature.txt: Document devicetree format for ECDSA keys

2021-01-13 Thread Simon Glass
On Thu, 7 Jan 2021 at 15:34, Alexandru Gagniuc  wrote:
>
> Signed-off-by: Alexandru Gagniuc 
> ---
>  doc/uImage.FIT/signature.txt | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>

I think you left off my review tag so I am adding it again here. You
can try 'patman status' to collect review tags from patchwork.

Reviewed-by: Simon Glass 


Re: [PATCH v3 2/6] lib/rsa: Make fdt_add_bignum() available outside of RSA code

2021-01-13 Thread Simon Glass
On Thu, 7 Jan 2021 at 15:33, Alexandru Gagniuc  wrote:
>
> fdt_add_bignum() is useful for algorithms other than just RSA. To
> allow its use for ECDSA, move it to a common file under lib/.
>
> The new file is suffixed with '-libcrypto' because it has a direct
> dependency on openssl. This is due to the use of the "BIGNUM *" type.
>
> Signed-off-by: Alexandru Gagniuc 
> ---
>  include/u-boot/fdt-libcrypto.h | 27 +
>  lib/fdt-libcrypto.c| 72 ++
>  lib/rsa/rsa-sign.c | 65 +-
>  tools/Makefile |  1 +
>  4 files changed, 101 insertions(+), 64 deletions(-)
>  create mode 100644 include/u-boot/fdt-libcrypto.h
>  create mode 100644 lib/fdt-libcrypto.c

Reviewed-by: Simon Glass 


Re: [PATCH v3 1/6] lib: Rename rsa-checksum.c to hash-checksum.c

2021-01-13 Thread Simon Glass
On Thu, 7 Jan 2021 at 15:33, Alexandru Gagniuc  wrote:
>
> rsa-checksum.c sontains the hash_calculate() implementations. Despite
> the "rsa-" file prefix, this function is useful for other algorithms.
>
> To prevent confusion, move this file to lib/crypto, and rename it to
> hash-checksum.c, to give it a more "generic" feel.
>
> Signed-off-by: Alexandru Gagniuc 
> ---
>  common/image-fit-sig.c | 2 +-
>  common/image-sig.c | 2 +-
>  include/image.h| 2 +-
>  include/u-boot/{rsa-checksum.h => hash-checksum.h} | 0
>  lib/Makefile   | 1 +
>  lib/crypto/pkcs7_verify.c  | 2 +-
>  lib/crypto/x509_public_key.c   | 2 +-
>  lib/{rsa/rsa-checksum.c => hash-checksum.c}| 3 ++-
>  lib/rsa/Makefile   | 2 +-
>  tools/Makefile | 3 ++-
>  10 files changed, 11 insertions(+), 8 deletions(-)
>  rename include/u-boot/{rsa-checksum.h => hash-checksum.h} (100%)
>  rename lib/{rsa/rsa-checksum.c => hash-checksum.c} (96%)
>

Reviewed-by: Simon Glass 


[PATCH v3] board: phytec: imx8mp: Add PHYTEC phyCORE-i.MX8MP support

2021-01-13 Thread Teresa Remmet
Add initial support PHYTEC phyCORE-i.MX8MP SOM.

Supported features:
 - 2GB LPDDR4 RAM
 - eMMC
 - external SD
 - debug UART2
 - watchdog

Signed-off-by: Teresa Remmet 
Reviewed-by: Heiko Schocher 
---
Changes in v3:
- switched to accepted upstream kernel device tree
  
(http://lists.infradead.org/pipermail/linux-arm-kernel/2021-January/629277.html)
- added Reviewed-by

Changes in v2:
- remove not needed spl board init
- remove ifdef from board_fit_config_name_match
- disabled not needed i2c busses from defconfig
- not use size macro for PHYS_SDRAM
- remove makros from phycore_imx8mp.h that are defined
  elsewhere

 arch/arm/dts/Makefile  |1 +
 .../arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi |  114 ++
 arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts|  161 ++
 arch/arm/dts/imx8mp-phycore-som.dtsi   |  293 
 arch/arm/mach-imx/imx8m/Kconfig|7 +
 board/phytec/phycore_imx8mp/Kconfig|   12 +
 board/phytec/phycore_imx8mp/MAINTAINERS|9 +
 board/phytec/phycore_imx8mp/Makefile   |   11 +
 board/phytec/phycore_imx8mp/lpddr4_timing.c| 1849 
 board/phytec/phycore_imx8mp/phycore-imx8mp.c   |   39 +
 board/phytec/phycore_imx8mp/spl.c  |  129 ++
 configs/phycore-imx8mp_defconfig   |   95 +
 include/configs/phycore_imx8mp.h   |  107 ++
 13 files changed, 2827 insertions(+)
 create mode 100644 arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts
 create mode 100644 arch/arm/dts/imx8mp-phycore-som.dtsi
 create mode 100644 board/phytec/phycore_imx8mp/Kconfig
 create mode 100644 board/phytec/phycore_imx8mp/MAINTAINERS
 create mode 100644 board/phytec/phycore_imx8mp/Makefile
 create mode 100644 board/phytec/phycore_imx8mp/lpddr4_timing.c
 create mode 100644 board/phytec/phycore_imx8mp/phycore-imx8mp.c
 create mode 100644 board/phytec/phycore_imx8mp/spl.c
 create mode 100644 configs/phycore-imx8mp_defconfig
 create mode 100644 include/configs/phycore_imx8mp.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0f738c224f2e..991b41a7d7da 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -780,6 +780,7 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
imx8mm-beacon-kit.dtb \
imx8mq-phanbell.dtb \
imx8mp-evk.dtb \
+   imx8mp-phyboard-pollux-rdk.dtb \
imx8mq-pico-pi.dtb
 
 dtb-$(CONFIG_ARCH_IMXRT) += imxrt1050-evk.dtb \
diff --git a/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi 
b/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi
new file mode 100644
index ..20e7f63ff91f
--- /dev/null
+++ b/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi
@@ -0,0 +1,114 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2020 PHYTEC Messtechnik GmbH
+ * Author: Teresa Remmet 
+ */
+
+/ {
+   wdt-reboot {
+   compatible = "wdt-reboot";
+   wdt = <&wdog1>;
+   u-boot,dm-spl;
+   };
+};
+
+&{/soc@0} {
+   u-boot,dm-pre-reloc;
+   u-boot,dm-spl;
+};
+
+&clk {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+&osc_32k {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+&osc_24m {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+&aips1 {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+&aips2 {
+   u-boot,dm-spl;
+};
+
+&aips3 {
+   u-boot,dm-spl;
+};
+
+&iomuxc {
+   u-boot,dm-spl;
+};
+
+®_usdhc2_vmmc {
+   u-boot,dm-spl;
+};
+
+&pinctrl_uart2 {
+   u-boot,dm-spl;
+};
+
+&pinctrl_usdhc2_pins {
+   u-boot,dm-spl;
+};
+
+&pinctrl_usdhc2 {
+   u-boot,dm-spl;
+};
+
+&pinctrl_usdhc3 {
+   u-boot,dm-spl;
+};
+
+&gpio1 {
+   u-boot,dm-spl;
+};
+
+&gpio2 {
+   u-boot,dm-spl;
+};
+
+&gpio3 {
+   u-boot,dm-spl;
+};
+
+&gpio4 {
+   u-boot,dm-spl;
+};
+
+&gpio5 {
+   u-boot,dm-spl;
+};
+
+&uart2 {
+   u-boot,dm-spl;
+};
+
+&i2c1 {
+   u-boot,dm-spl;
+};
+
+&pmic {
+   u-boot,dm-spl;
+};
+
+&usdhc2 {
+   u-boot,dm-spl;
+};
+
+&usdhc3 {
+   u-boot,dm-spl;
+};
+
+&wdog1 {
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts 
b/arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts
new file mode 100644
index ..0e1a6d953389
--- /dev/null
+++ b/arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts
@@ -0,0 +1,161 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 PHYTEC Messtechnik GmbH
+ * Author: Teresa Remmet 
+ */
+
+/dts-v1/;
+
+#include 
+#include 
+#include "imx8mp-phycore-som.dtsi"
+
+/ {
+   model = "PHYTEC phyBOARD-Pollux i.MX8MP";
+   compatible = "phytec,imx8mp-phyboard-pollux-rdk",
+"phytec,imx8mp-phycore-som", "fsl,imx8mp";
+
+   chosen {
+   stdout-path = &uart2;
+   };
+
+   reg_usdhc2_vmmc: regulator-usdhc2 {
+   compatible 

Re: [PATCH] env: Remove all dependencies for SYS_REDUNDAND_ENVIRONMENT

2021-01-13 Thread Michal Simek



On 13. 01. 21 15:43, Tom Rini wrote:
> On Wed, Jan 13, 2021 at 03:24:24PM +0100, Michal Simek wrote:
>> On 13. 01. 21 15:02, Tom Rini wrote:
>>> On Wed, Jan 13, 2021 at 01:26:27PM +0100, Michal Simek wrote:
>>>
 CONFIG_SYS_REDUNDAND_ENVIRONMENT is changing in env_internal.h how u-boot
 works with variables. struct environment_s has one byte flags property
 which also affects ENV_SIZE macro.

 I have reached the case where CONFIG_ENV_IS_NOWHERE is default setup
 but custom scripts can be designed in a way that u-boot is asked to
 import/export variables from/to file which can be in certain format.
 That's why also for this configuration make sense to enable
 CONFIG_SYS_REDUNDAND_ENVIRONMENT because it depends on environment file
 format.

 The patch is removing dependency on this configuration to support selecting
 environment file format without any specific dependency where variables are
 stored.
>>>
>>> Are you importing a binary of the environment in, which was generated
>>> with redundant env set, is what the problem is?
>>
>> Yes exactly.
> 
> OK, so env import/export -b require compatible env structs, that makes
> sense.  I assume you've ruled out env import/export -t instead already.

Yes that's not an option.

> I would rather see the struct be identical (so, always have flags)
> rather than say that we can enable redundant environment in all cases
> (since functionally, we can't for "nowhere" and don't for some others)
> as it also means that for your case you would still need to know to
> enable the redundant feature to get what you're aiming for to work.
> Does that make sense?  Thanks!

I have not a problem to enable this feature for all but when this is
simply enabled for everybody boards which don't have this enabled will
fail. Maybe variables without that flags can be fall back option that
you can read them but when you save you will add there flag field.

As of I now I know that I want to enable this feature for certain board
because boot variables are generated by OS.

Thanks,
Michal





[PATCH v2] armv8: lx2: SVR_SOC_VER: Mask CAN_FD and security bit

2021-01-13 Thread Wasim Khan
From: Wasim Khan 

Multiple LX2(LX2160A/LX2162A SoC) personality variants
exists based on CAN-FD and security bit in SVR.

Currenly SVR_SOC_VER mask only security bit.
Update SVR_SOC_VER to mask CAN_FD and security bit
for LX2 products.

Signed-off-by: Wasim Khan 
---
Changes in v2:
- Updated commit subject and description

 arch/arm/include/asm/arch-fsl-layerscape/soc.h | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/arch-fsl-layerscape/soc.h 
b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
index b24f38cac9..887954eaa5 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/soc.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright 2017-2020 NXP
+ * Copyright 2017-2021 NXP
  * Copyright 2015 Freescale Semiconductor
  */
 
@@ -113,10 +113,13 @@ enum boot_src get_boot_src(void);
 #define SVR_MAJ(svr)   (((svr) >> 4) & 0xf)
 #define SVR_MIN(svr)   (((svr) >> 0) & 0xf)
 #define SVR_REV(svr)   (((svr) >> 0) & 0xff)
-#define SVR_SOC_VER(svr)   (((svr) >> 8) & SVR_WO_E)
 #define IS_E_PROCESSOR(svr)(!((svr >> 8) & 0x1))
 #if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
 #define IS_C_PROCESSOR(svr)(!((svr >> 12) & 0x1))
+#define SVR_WO_CE  0xEE
+#define SVR_SOC_VER(svr)   (((svr) >> 8) & SVR_WO_CE)
+#else
+#define SVR_SOC_VER(svr)   (((svr) >> 8) & SVR_WO_E)
 #endif
 #ifdef CONFIG_ARCH_LS1028A
 #define IS_MULTIMEDIA_EN(svr)  (!((svr >> 10) & 0x1))
-- 
2.25.1



activate Logging SPL log.c:48: undefined reference to `uclass_get_name'

2021-01-13 Thread Arendt, Steffen
By activating Logging of SPL (uboot 20.04) I got the error:

aarch64-poky-linux-ld.bfd: common/built-in.o: in function `log_get_cat_name':
/home/user/y/src/uboot/uboot-imx/common/log.c:48: undefined reference to 
`uclass_get_name'

I found something about DM in mailing list, but DM is activated while building 
this.

How to solve/workaround that?
uclass.h , where uclass_get_name() is defined seems to be include in log.c. und 
uclass.o is compiled.

_

SensoPart Industriesensorik GmbH
Am Wiedenbach 1
79695 Wieden
Deutschland

Telefon: +49 7673 821 0

Amtsgericht Freiburg HRB 660163
USt-IdNr.: DE 811614252

Gesch?ftsf?hrer: Dr. Theodor Wanner, Thorsten Wanner

Informationen gem. Art. 13 DSGVO f?r unsere Kunden, Partner, Lieferanten finden 
Sie in unserer Erkl?rung zum Datenschutz unter 
https://www.sensopart.com/de/datenschutz




build the u-boot for BCM53016

2021-01-13 Thread scd rjcom
How do I build the u-boot for BCM53016 SoC (
https://www.broadcom.com/products/embedded-and-networking-processors/communications/bcm5301x
)?

Is there any compatible board/config for the BCM53016 SoC?

It is supported by the linux kernel under CONFIG_ARCH_BCM_5301X config flag.


[PATCH V2] imx: imx8mn/p: drop CONFIG_SYS_[I,D]CACHE_OFF

2021-01-13 Thread Peng Fan (OSS)
From: Peng Fan 

Drop CONFIG_SYS_[I,D]CACHE_OFF, it is safe to run with caches enabled on
these platforms.

Signed-off-by: Peng Fan 
---

V2:
 Update subject/commit Per Fabio's comments

 include/configs/imx8mn_evk.h | 2 --
 include/configs/imx8mp_evk.h | 2 --
 2 files changed, 4 deletions(-)

diff --git a/include/configs/imx8mn_evk.h b/include/configs/imx8mn_evk.h
index 92f435f578..369aa538bf 100644
--- a/include/configs/imx8mn_evk.h
+++ b/include/configs/imx8mn_evk.h
@@ -25,8 +25,6 @@
 #define CONFIG_SPL_BSS_MAX_SIZESZ_8K   /* 8 KB */
 #define CONFIG_SYS_SPL_MALLOC_START0x4220
 #define CONFIG_SYS_SPL_MALLOC_SIZE SZ_512K /* 512 KB */
-#define CONFIG_SYS_ICACHE_OFF
-#define CONFIG_SYS_DCACHE_OFF
 
 /* For RAW image gives a error info not panic */
 #define CONFIG_SPL_ABORT_ON_RAW_IMAGE
diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h
index 7abaf5ff84..f89950f74e 100644
--- a/include/configs/imx8mp_evk.h
+++ b/include/configs/imx8mp_evk.h
@@ -26,8 +26,6 @@
 #define CONFIG_SPL_BSS_MAX_SIZE0x400   /* 1 KB */
 #define CONFIG_SYS_SPL_MALLOC_START0x4220
 #define CONFIG_SYS_SPL_MALLOC_SIZE SZ_512K /* 512 KB */
-#define CONFIG_SYS_ICACHE_OFF
-#define CONFIG_SYS_DCACHE_OFF
 
 #define CONFIG_SPL_ABORT_ON_RAW_IMAGE
 
-- 
2.28.0



[PATCH] imx: imx8mn/p: drop CONFIG_SYS_[I,D]CACHE_OFF in SPL stage

2021-01-13 Thread Peng Fan (OSS)
From: Peng Fan 

Drop CONFIG_SYS_[I,D]CACHE_OFF in SPL stage

Signed-off-by: Peng Fan 
---

This is to replace
https://patchwork.ozlabs.org/project/uboot/patch/20210103101144.4375-12-peng@oss.nxp.com/

 include/configs/imx8mn_evk.h | 2 --
 include/configs/imx8mp_evk.h | 2 --
 2 files changed, 4 deletions(-)

diff --git a/include/configs/imx8mn_evk.h b/include/configs/imx8mn_evk.h
index 92f435f578..369aa538bf 100644
--- a/include/configs/imx8mn_evk.h
+++ b/include/configs/imx8mn_evk.h
@@ -25,8 +25,6 @@
 #define CONFIG_SPL_BSS_MAX_SIZESZ_8K   /* 8 KB */
 #define CONFIG_SYS_SPL_MALLOC_START0x4220
 #define CONFIG_SYS_SPL_MALLOC_SIZE SZ_512K /* 512 KB */
-#define CONFIG_SYS_ICACHE_OFF
-#define CONFIG_SYS_DCACHE_OFF
 
 /* For RAW image gives a error info not panic */
 #define CONFIG_SPL_ABORT_ON_RAW_IMAGE
diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h
index 7abaf5ff84..f89950f74e 100644
--- a/include/configs/imx8mp_evk.h
+++ b/include/configs/imx8mp_evk.h
@@ -26,8 +26,6 @@
 #define CONFIG_SPL_BSS_MAX_SIZE0x400   /* 1 KB */
 #define CONFIG_SYS_SPL_MALLOC_START0x4220
 #define CONFIG_SYS_SPL_MALLOC_SIZE SZ_512K /* 512 KB */
-#define CONFIG_SYS_ICACHE_OFF
-#define CONFIG_SYS_DCACHE_OFF
 
 #define CONFIG_SPL_ABORT_ON_RAW_IMAGE
 
-- 
2.28.0



Re: [PULL u-boot] Please pull u-boot-amlogic-20210112

2021-01-13 Thread Tom Rini
On Tue, Jan 12, 2021 at 05:39:54PM +0100, Neil Armstrong wrote:

> Hi Tom,
> 
> These are the changes for the next release, in brief is adds some features to 
> the VIM3 boards
> (drivers fro function button detect using ADC, mac from efuses), new boards 
> (V2 of libretech-cc,
> GT-King/Pro and Wetek Core2), all this with DT sync'ed over Linux 5.10 with 
> new Power Domain
> driver support. A new DSI panel driver has been added, the rest of support 
> will come next (PHYs, ...).
> 
> The CI job is at 
> https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic/pipelines/5836
> 
> Thanks,
> Neil
> 
> The following changes since commit c8f2a060a15b8a21cef90c82cc49f70517356a50:
> 
>   xea: config: Disable CONFIG_SPL_OF_PLATDATA_PARENT on XEA (imx28) 
> (2021-01-08 08:42:08 -0500)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic.git 
> tags/u-boot-amlogic-20210112
> 
> for you to fetch changes up to 6bfa331a6e22507ae839fb8474ce1b3fd58808df:
> 
>   board: amlogic: vim3: fix setup ethernet mac from efuse (2021-01-12 
> 14:25:55 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] env: Remove all dependencies for SYS_REDUNDAND_ENVIRONMENT

2021-01-13 Thread Tom Rini
On Wed, Jan 13, 2021 at 03:24:24PM +0100, Michal Simek wrote:
> On 13. 01. 21 15:02, Tom Rini wrote:
> > On Wed, Jan 13, 2021 at 01:26:27PM +0100, Michal Simek wrote:
> > 
> >> CONFIG_SYS_REDUNDAND_ENVIRONMENT is changing in env_internal.h how u-boot
> >> works with variables. struct environment_s has one byte flags property
> >> which also affects ENV_SIZE macro.
> >>
> >> I have reached the case where CONFIG_ENV_IS_NOWHERE is default setup
> >> but custom scripts can be designed in a way that u-boot is asked to
> >> import/export variables from/to file which can be in certain format.
> >> That's why also for this configuration make sense to enable
> >> CONFIG_SYS_REDUNDAND_ENVIRONMENT because it depends on environment file
> >> format.
> >>
> >> The patch is removing dependency on this configuration to support selecting
> >> environment file format without any specific dependency where variables are
> >> stored.
> > 
> > Are you importing a binary of the environment in, which was generated
> > with redundant env set, is what the problem is?
> 
> Yes exactly.

OK, so env import/export -b require compatible env structs, that makes
sense.  I assume you've ruled out env import/export -t instead already.
I would rather see the struct be identical (so, always have flags)
rather than say that we can enable redundant environment in all cases
(since functionally, we can't for "nowhere" and don't for some others)
as it also means that for your case you would still need to know to
enable the redundant feature to get what you're aiming for to work.
Does that make sense?  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] env: Remove all dependencies for SYS_REDUNDAND_ENVIRONMENT

2021-01-13 Thread Michal Simek



On 13. 01. 21 15:02, Tom Rini wrote:
> On Wed, Jan 13, 2021 at 01:26:27PM +0100, Michal Simek wrote:
> 
>> CONFIG_SYS_REDUNDAND_ENVIRONMENT is changing in env_internal.h how u-boot
>> works with variables. struct environment_s has one byte flags property
>> which also affects ENV_SIZE macro.
>>
>> I have reached the case where CONFIG_ENV_IS_NOWHERE is default setup
>> but custom scripts can be designed in a way that u-boot is asked to
>> import/export variables from/to file which can be in certain format.
>> That's why also for this configuration make sense to enable
>> CONFIG_SYS_REDUNDAND_ENVIRONMENT because it depends on environment file
>> format.
>>
>> The patch is removing dependency on this configuration to support selecting
>> environment file format without any specific dependency where variables are
>> stored.
> 
> Are you importing a binary of the environment in, which was generated
> with redundant env set, is what the problem is?
> 

Yes exactly.

Thanks,
Michal


Re: [PATCH] env: Remove all dependencies for SYS_REDUNDAND_ENVIRONMENT

2021-01-13 Thread Tom Rini
On Wed, Jan 13, 2021 at 01:26:27PM +0100, Michal Simek wrote:

> CONFIG_SYS_REDUNDAND_ENVIRONMENT is changing in env_internal.h how u-boot
> works with variables. struct environment_s has one byte flags property
> which also affects ENV_SIZE macro.
> 
> I have reached the case where CONFIG_ENV_IS_NOWHERE is default setup
> but custom scripts can be designed in a way that u-boot is asked to
> import/export variables from/to file which can be in certain format.
> That's why also for this configuration make sense to enable
> CONFIG_SYS_REDUNDAND_ENVIRONMENT because it depends on environment file
> format.
> 
> The patch is removing dependency on this configuration to support selecting
> environment file format without any specific dependency where variables are
> stored.

Are you importing a binary of the environment in, which was generated
with redundant env set, is what the problem is?

-- 
Tom


signature.asc
Description: PGP signature


Re: [RFC PATCH 1/3] efi_loader: Introduce helper functions for EFI

2021-01-13 Thread Ilias Apalodimas
Hi Heinrich,
> > +   efi_status_t ret;
> > +   void *buf = NULL;
> > +
> > +   *size = 0;
> > +   ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL);
> > +   if (ret == EFI_BUFFER_TOO_SMALL) {
> > +   buf = malloc(*size);
> 
> Please, always check the output of malloc(), e.g.
> 
>   if (!buf)
>   ret = EFI_OUT_OF_RESOURCES;
>   else
> 

I just moved the function from lib/efi_loader/efi_bootmgr.c (check for
get_var()) and completely missed that. I'll fix it on the next revision.

> > +   ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL);
> > +   }
> > +
> > +   if (ret != EFI_SUCCESS) {
> > +   free(buf);
> > +   *size = 0;
> > +   return NULL;
> > +   }
> > +
> > +   return buf;
> > +}
> > +
> > +/**
> > + * efi_dp_instance_by_idx() - Get a file path with a specific index
> > + *
> > + * @name:  device path array
> > + * @size:  size of the discovered device path
> > + * @idx:   index of the device path
> > + *
> > + * Return: device path or NULL. Caller must free the returned value
> > + */
> > +
> > +struct
> > +efi_device_path *efi_dp_instance_by_idx(struct efi_device_path *dp,
> > +   efi_uintn_t *size, int idx)
> > +{
> 
> idx should be of an unsigned type as we cannot have negative indices.
> 
> > +   struct efi_device_path *instance = NULL;
> > +   efi_uintn_t instance_size = 0;
> > +
> > +   if (!efi_dp_is_multi_instance(dp))
> 
> Given a device path with one instance, why don't you allow me to read
> index 0? I assume this check can be removed.
> 

Yea, but why would you ever use that? you can just retrieve the deserialized
device path directly if there are no other instances.

> > +   return NULL;
> > +
> > +   while (idx >= 0 && dp) {
> > +   instance = efi_dp_get_next_instance(&dp, &instance_size);
> > +   if (idx && instance) {
> > +   efi_free_pool(instance);
> > +   instance_size = 0;
> > +   instance = NULL;
> > +   }
> > +   idx--;
> > +   }
> > +   *size = instance_size;
> > +
> > +   return instance;
> 
> This can be simplified with unsigned idx:
> 
> for (; dp; --idx) {
>   instance = efi_dp_get_next_instance(&dp, size);
>   if (!idx)  {
>   return instance;
>   efi_free_pool(instance);
> }
> return NULL;

Ok I'll have a look

> 
> > +}
> > +
> > +/**
> > + * create_boot_var_indexed() - Return Boot name were  is replaced 
> > by
> > + *the value of BootCurrent
> > + *
> > + * @var_name:  variable name
> > + * @var_name_size: size of var_name
> > + *
> > + * Return: Status code
> > + */
> > +static efi_status_t create_boot_var_indexed(u16 var_name[], size_t 
> > var_name_size)
> > +{
> > +   efi_uintn_t boot_order_size;
> 
> You are reading BootCurrent, not BootOrder.
> 
> > +   efi_status_t ret;
> > +   u16 boot_order;
> 
> Same here.
> 

Ok

> > +   if (!file_path) {
> > +   printf("Instance not found\n");
> 
> This message is not enough for a user to take action. I suggest
> 
> ("Missing file path with index %d in %ls", idx, var_name)
> 
> We want to use logging. I assume this is not an error. Can we use
> log_debug() here?
> 


That's a leftover from my opwn debugging that I neglected to remove prior to
the RFC. I'll just add a log_debug()

> > +   return NULL;
> > +   }
> > +
> > +   return file_path;
> > +}
> >
> 
> Some other functions would fit into the same C module. Candidates are:
> 
> * efi_create_indexed_name()
> * efi_deserialize_load_option()
> * efi_serialize_load_option()
> 
> But that can be done in a separate patch.

Yea, that's the idea, we can also use the efi_get_var() in multiple places,
but I'll send different patches for that, once we merge this.

I assume we agree on the architecture. If so I'll fix the selftests and post a
proper patch

Regards
/Ilias
> 
> Best regards
> 
> Heinrich


Re: Devicetree state of U-Boot vs kernel

2021-01-13 Thread Neil Armstrong
Hi,

On 08/01/2021 01:39, Bill Mills wrote:
> All,
> 
> On the Devicetree evolution call Wednesday I promised to finish my comparison 
> of u-boot DT vs kernel DT.
> The script is not perfect but the results are still interesting.
> 
> For each dts and dtsi file in the tip of the u-boot tree, it tries to 
> correlate it to the kernel tip.
> It compares git SHA1 signatures or falls back to filenames.
> The results were surprising to me but perhaps they should not have been.
> 
> I have checked in the script[1] and the full results here [2]
> 
> The full file lists (with some diff stats) are in the root dir.
> Example [3]
> 
> I also looked at the line count of the u-boot override files.
> Even though we don't expect these to correlate, we do expect reasonable usage 
> to result in small files.  Big files are an indication of possible abuse of 
> the system.  (I don't think the idea was to have wholesale new versions of 
> the DTS as an override.)
> 
> I plan to redo the script in python.  It will be much easier to be more 
> precise and to look deeper.  (For example figure out how old the u-boot 
> version is in number of change sets and number of days.  Or if no content 
> sync now were they ever synced?)
> 
> Here is the scripts output: (from summary.txt)
> 
> Devicetree sync status for u-boot v2021.01-rc5-7-gb8c725e736
> Compared to kernel v5.11-rc2-156-g71c061d24438

Do not compare with a such kernel, usually DT is sync'ed from stable kernels, 
or -rc1, so 5.11 stuff will eventually go for next u-boot release, not the 
actual one.

We (amlogic/meson) will sync part of DT with 5.10 for next release, the 
previous is sync'ed to 5.9/5.8.

It's almost impossible to sync to each release.

Neil

> 14% (255) are completely synced
>  253 arm
>    2 riscv
>    0 mips
>    0 powerpc
>    0 x86
>    0 68k
>    0 microblaze
>    0 sh
>    0 arc
> 23% (416) content has appeared in the kernel but is not up to date
>  411 arm
>    0 riscv
>    1 mips
>    0 powerpc
>    1 x86
>    0 68k
>    0 microblaze
>    0 sh
>    1 arc
> 33% (584) filename appears in kernel but content never has
>  467 arm
>    1 riscv
>   12 mips
>   91 powerpc
>    0 x86
>    0 68k
>    0 microblaze
>    0 sh
>    8 arc
> 28% (510) neither filename nor content appears in kernel
>  305 arm
>    4 riscv
>   48 mips
>   35 powerpc
>   44 x86
>    0 68k
>    1 microblaze
>    1 sh
>    6 arc
> n/a (510) U-Boot specific, no correlation expected
>    7 sandbox
>  358 override
>  211 test
> histogram of override size (in raw lines)
>    10  61
>    20  53
>    30  38
>    40  33
>    50  23
>    60  14
>    70  12
>    80   7
>    90   5
>   100   4
>   110   4
>   120   5
>   130   6
>   140   4
>   150   0
>   160   2
>   170   0
>   180   0
>   190   4
>   200   0
>   210   2
>   220   2
>   230   1
>   240   2
>   250   1
>   260   1
>   270   1
>   280   0
>   290   0
>   300   0
>   310   0
>   320   1
> 
> 
> [1] 
> https://github.com/wmamills/devicetree-source/blob/master/scripts/correlate-dts
> [2] https://github.com/wmamills/devicetree-source
> [3] 
> https://github.com/wmamills/devicetree-source/blob/master/dts-somewhere.txt
> 



Re: Invitation: Regular U-Boot video call (Tuesday 19th)

2021-01-13 Thread Heinrich Schuchardt
On 13.01.21 14:12, Marek Vasut wrote:
> On 1/13/21 1:59 PM, Andy Shevchenko wrote:
>> On Wed, Jan 13, 2021 at 5:39 AM Simon Glass  wrote:
>>>
>>> Hi,
>>>
>>> (This has been discussed for a while now so I thought I would just
>>> try it)
>>>
>>> As an experiment I'd like to set up a regular 30-minute U-Boot call
>>> for people to discuss features, bugs, patches, etc.
>>>
>>> The meeting notes and details are here[1].
>>>
>>> Please feel free to send this to others. I cc'd a small number of
>>> people on the list.
>>
>> I added myself with a topic, but two issues so far:
>> - i have no camera setup
>> - the timing is quite bad since it overlaps with a the series of some
>> work important meeting, shifting later by half an hour will solve it
>
> Can't we simply have an IRC meeting ? I am still concerned about the
> language barrier.

Dear Marek,

as I have seen you as speaker at Fosdem I don't expect that you
personally will have a problem in the discussion.

I would very much prefer a video call.

Best regards

Heinrich


Re: [RFC PATCH 2/3] efi_loader: efi_loader: Replace config option for initrd loading

2021-01-13 Thread Ilias Apalodimas
> > + initrd= will stop working. The protocol will only be
[...]
> 
> How about
> 
> "Linux v5.7 and later can make use of this option. If the boot option
> selected by the UEFI boot manager specifies an existing file to be used
> as initial RAM disk, a Linux specific Load File2 protocol will be
> installed and Linux 5.7+ will ignore any initrd= command line
> argument."
> 
> > + installed if bootmgr is used and the file is found on the defined
> > + path. A boot entry of Boot0001 will try to match Initrd0001 and use
> 
> This does not match the implementation.
> 
> > + it. Initrd EFI variable format should be '  '
> > + i.e 'mmc 0:1 boot/initrd'
> 
> "The efidebug command can be used to specify the file with the initial
> RAM disk."

Seems like I missed some text while amending the description. 
Your proposal sounds good I'll update it.

[...]
> 
> In all our other coding this variable is called ret.
> I would prefer to do the same here too.

No problem

Cheers
/Ilias
> 
> Best regards
> 


Re: [RFC PATCH 3/3] efidebug: add multiple device path instances on Boot####

2021-01-13 Thread Ilias Apalodimas
On Wed, Jan 13, 2021 at 02:13:44PM +0100, Heinrich Schuchardt wrote:
> On 13.01.21 12:11, Ilias Apalodimas wrote:
> > The UEFI spec allow a packed array of UEFI device paths in the
> > FilePathList[] of an EFI_LOAD_OPTION. The first file path must
> > describe the laoded image but the rest are OS specific.
> > Previous patches parse the device path and try to use the second
> > member of the array as an initrd. So let's modify efidebug slightly
> > and install the second file described in the command line as the
> > initrd device path.
> 
> Please, describe the syntax of the efidebug command in the commit message.

sure 

[...]

> > +   }
> >
> > printf("  data:\n");
> > print_hex_dump("", DUMP_PREFIX_OFFSET, 16, 1,
> > @@ -1583,7 +1656,7 @@ static char efidebug_help_text[] =
> 
> Where is the change to efidebug_help_text[]?

Thanks, I'll add that on the next version

Cheers
/Ilias
> 
> Best regards
> 
> Heinrich
> 
> >  #endif
> >
> >  U_BOOT_CMD(
> > -   efidebug, 10, 0, do_efidebug,
> > +   efidebug, CONFIG_SYS_MAXARGS, 0, do_efidebug,
> > "Configure UEFI environment",
> > efidebug_help_text
> >  );
> >
> 


Re: [RFC PATCH 3/3] efidebug: add multiple device path instances on Boot####

2021-01-13 Thread Heinrich Schuchardt
On 13.01.21 12:11, Ilias Apalodimas wrote:
> The UEFI spec allow a packed array of UEFI device paths in the
> FilePathList[] of an EFI_LOAD_OPTION. The first file path must
> describe the laoded image but the rest are OS specific.
> Previous patches parse the device path and try to use the second
> member of the array as an initrd. So let's modify efidebug slightly
> and install the second file described in the command line as the
> initrd device path.

Please, describe the syntax of the efidebug command in the commit message.

>
> Signed-off-by: Ilias Apalodimas 
> ---
>  cmd/efidebug.c | 89 +-
>  1 file changed, 81 insertions(+), 8 deletions(-)
>
> diff --git a/cmd/efidebug.c b/cmd/efidebug.c
> index 5fb7b1e3c6a9..8d62981aca92 100644
> --- a/cmd/efidebug.c
> +++ b/cmd/efidebug.c
> @@ -8,6 +8,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -17,6 +18,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define BS systab.boottime
>  #define RT systab.runtime
> @@ -782,6 +784,42 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int 
> flag,
>   return CMD_RET_SUCCESS;
>  }
>
> +/**
> + * add_initrd_instance() - Append a device path to load_options pointing to 
> an
> + *  inirtd
> + *
> + * @argc:Number of arguments
> + * @argv:Argument array
> + * @file_pathExisting device path, the new instance will be appended
> + * Return:   Pointer to the device path or ERR_PTR
> + *
> + */
> +static struct efi_device_path *add_initrd_instance(int argc, char *const 
> argv[],
> +struct efi_device_path 
> *file_path)
> +{
> + struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL;
> + struct efi_device_path *final_fp = NULL;
> + efi_status_t ret;
> +
> + if (argc < 8)
> + return ERR_PTR(-EINVAL);
> +
> + ret = efi_dp_from_name(argv[6], argv[7], argv[8], &tmp_dp,
> +&tmp_fp);
> + if (ret != EFI_SUCCESS) {
> + printf("Cannot create device path for \"%s %s\"\n",
> +argv[6], argv[7]);
> + goto out;
> + }
> +
> + final_fp = efi_dp_append_instance(file_path, tmp_fp);
> +
> +out:
> + efi_free_pool(tmp_dp);
> + efi_free_pool(tmp_fp);
> + return final_fp ? final_fp : ERR_PTR(-EINVAL);
> +}
> +
>  /**
>   * do_efi_boot_add() - set UEFI load option
>   *
> @@ -794,7 +832,11 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int 
> flag,
>   *
>   * Implement efidebug "boot add" sub-command. Create or change UEFI load 
> option.
>   *
> - * efidebug boot add[:]  
> 
> + * Without initrd:
> + * efidebug boot add[:]  
> 
> + *
> + * With initrd:
> + * efidebug boot add[:]  
>  [:]  
>   */
>  static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
>  int argc, char *const argv[])
> @@ -807,13 +849,14 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int 
> flag,
>   size_t label_len, label_len16;
>   u16 *label;
>   struct efi_device_path *device_path = NULL, *file_path = NULL;
> + struct efi_device_path *final_fp = NULL;
>   struct efi_load_option lo;
>   void *data = NULL;
>   efi_uintn_t size;
>   efi_status_t ret;
>   int r = CMD_RET_SUCCESS;
>
> - if (argc < 6 || argc > 7)
> + if (argc < 6 || argc > 9)
>   return CMD_RET_USAGE;
>
>   id = (int)simple_strtoul(argv[1], &endp, 16);
> @@ -829,6 +872,12 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int 
> flag,
>   /* attributes */
>   lo.attributes = LOAD_OPTION_ACTIVE; /* always ACTIVE */
>
> + /* optional data */
> + if (argc == 6)
> + lo.optional_data = NULL;
> + else
> + lo.optional_data = (const u8 *)argv[6];
> +
>   /* label */
>   label_len = strlen(argv[2]);
>   label_len16 = utf8_utf16_strnlen(argv[2], label_len);
> @@ -847,15 +896,30 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int 
> flag,
>   r = CMD_RET_FAILURE;
>   goto out;
>   }
> +
> + /* add initrd instance in device path */
> + if (argc >= 9) {
> + final_fp = add_initrd_instance(argc, argv, file_path);
> + if (IS_ERR(final_fp)) {
> + r = CMD_RET_FAILURE;
> + goto out;
> + }
> +
> + /* add_initrd_instance allocates a new device path */
> + efi_free_pool(file_path);
> + file_path = final_fp;
> +
> + /* update optional data */
> + if (argc == 9)
> + lo.optional_data = NULL;
> + else
> + lo.optional_data = (const u8 *)argv[9];
> + }
> +
>   lo.file_path = file_path;
>   lo.file_path_length = efi_dp_size(file_path)
>   + sizeof(struct efi_device_path); /* f

Re: Invitation: Regular U-Boot video call (Tuesday 19th)

2021-01-13 Thread Marek Vasut

On 1/13/21 1:59 PM, Andy Shevchenko wrote:

On Wed, Jan 13, 2021 at 5:39 AM Simon Glass  wrote:


Hi,

(This has been discussed for a while now so I thought I would just try it)

As an experiment I'd like to set up a regular 30-minute U-Boot call
for people to discuss features, bugs, patches, etc.

The meeting notes and details are here[1].

Please feel free to send this to others. I cc'd a small number of
people on the list.


I added myself with a topic, but two issues so far:
- i have no camera setup
- the timing is quite bad since it overlaps with a the series of some
work important meeting, shifting later by half an hour will solve it


Can't we simply have an IRC meeting ? I am still concerned about the 
language barrier.


  1   2   >