RE: [PATCH v2] cmd: Add a pwm command

2020-11-30 Thread Pragnesh Patel
Hi Simon,

>-Original Message-
>From: U-Boot  On Behalf Of Pragnesh Patel
>Sent: 01 December 2020 11:17
>To: Simon Glass 
>Cc: U-Boot Mailing List ; Atish Patra
>; Palmer Dabbelt ; Bin
>Meng ; Paul Walmsley ( Sifive)
>; Anup Patel ; Sagar Kadam
>; rick ; Naoki Hayama
>; Marek Vasut ;
>Patrick Delaunay ; Adam Ford
>; Thomas Hebb ; Ramon Fried
>; Heinrich Schuchardt ; Bin Meng
>; Sam Protsenko ; Miquel
>Raynal ; Philippe Reynes
>; Frédéric Danis
>; Patrice Chotard ;
>Vladimir Olovyannikov 
>Subject: RE: [PATCH v2] cmd: Add a pwm command
>
>Hi Simon,
>
>>-Original Message-
>>From: Simon Glass 
>>Sent: 01 December 2020 01:42
>>To: Pragnesh Patel 
>>Cc: U-Boot Mailing List ; Atish Patra
>>; Palmer Dabbelt ; Bin
>>Meng ; Paul Walmsley ( Sifive)
>>; Anup Patel ; Sagar
>>Kadam ; rick ; Naoki
>>Hayama ; Marek Vasut
>>; Patrick Delaunay
>>; Adam Ford ; Thomas Hebb
>>; Ramon Fried ; Heinrich
>>Schuchardt ; Bin Meng ;
>Sam
>>Protsenko ; Miquel Raynal
>>; Philippe Reynes
>>; Frédéric Danis
>>; Patrice Chotard
>>; Vladimir Olovyannikov
>>
>>Subject: Re: [PATCH v2] cmd: Add a pwm command
>>
>>[External Email] Do not click links or attachments unless you recognize
>>the sender and know the content is safe
>>
>>Hi Pragnesh,
>>
>>On Thu, 26 Nov 2020 at 03:48, Pragnesh Patel
>>
>>wrote:
>>>
>>> Add the command "pwm" for controlling the pwm channels. This command
>>> provides pwm invert/config/enable/disable functionalities via PWM
>>> uclass drivers
>>>
>>> Signed-off-by: Pragnesh Patel 
>>> ---
>>>
>>> Changes in v2:
>>> - Add test for pwm command
>>>
>>>
>>>  README|   1 +
>>>  cmd/Kconfig   |   6 ++
>>>  cmd/Makefile  |   1 +
>>>  cmd/pwm.c | 120 ++
>>>  configs/sandbox_defconfig |   1 +
>>>  test/cmd/Makefile |   1 +
>>>  test/cmd/pwm.c|  54 +
>>>  7 files changed, 184 insertions(+)
>>>  create mode 100644 cmd/pwm.c
>>>  create mode 100644 test/cmd/pwm.c
>>
>>Reviewed-by: Simon Glass 
>>
>>Minor nits below
>>
>>>
>>> diff --git a/README b/README
>>> index cb49aa15da..dab291e0d0 100644
>>> --- a/README
>>> +++ b/README
>>> @@ -3160,6 +3160,7 @@ i2c   - I2C sub-system
>>>  sspi   - SPI utility commands
>>>  base   - print or set address offset
>>>  printenv- print environment variables
>>> +pwm- control pwm channels
>>>  setenv - set environment variables
>>>  saveenv - save environment variables to persistent storage  protect
>>> - enable or disable FLASH write protection diff --git a/cmd/Kconfig
>>> b/cmd/Kconfig index 1595de999b..0d085108f4 100644
>>> --- a/cmd/Kconfig
>>> +++ b/cmd/Kconfig
>>> @@ -918,6 +918,12 @@ config CMD_GPIO
>>> help
>>>   GPIO support.
>>>
>>> +config CMD_PWM
>>> +   bool "pwm"
>>> +   depends on DM_PWM
>>> +   help
>>> + Control PWM channels, this allows
>>> +invert/config/enable/disable PWM
>>channels.
>>> +
>>>  config CMD_GPT
>>> bool "GPT (GUID Partition Table) command"
>>> select EFI_PARTITION
>>> diff --git a/cmd/Makefile b/cmd/Makefile index dd86675bf2..75df3c136c
>>> 100644
>>> --- a/cmd/Makefile
>>> +++ b/cmd/Makefile
>>> @@ -120,6 +120,7 @@ endif
>>>  obj-$(CONFIG_CMD_PINMUX) += pinmux.o
>>>  obj-$(CONFIG_CMD_PMC) += pmc.o
>>>  obj-$(CONFIG_CMD_PSTORE) += pstore.o
>>> +obj-$(CONFIG_CMD_PWM) += pwm.o
>>>  obj-$(CONFIG_CMD_PXE) += pxe.o pxe_utils.o
>>>  obj-$(CONFIG_CMD_WOL) += wol.o
>>>  obj-$(CONFIG_CMD_QFW) += qfw.o
>>> diff --git a/cmd/pwm.c b/cmd/pwm.c
>>> new file mode 100644
>>> index 00..f704c7a755
>>> --- /dev/null
>>> +++ b/cmd/pwm.c
>>> @@ -0,0 +1,120 @@
>>> +// SPDX-License-Identifier: GPL-2.0+
>>> +/*
>>> + * Control PWM channels
>>> + *
>>> + * Copyright (c) 2020 SiFive, Inc
>>> + * author: Pragnesh Patel   */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +enum pwm_cmd {
>>> +   PWM_SET_INVERT,
>>> +   PWM_SET_CONFIG,
>>> +   PWM_SET_ENABLE,
>>> +   PWM_SET_DISABLE,
>>> +};
>>> +
>>> +static int do_pwm(struct cmd_tbl *cmdtp, int flag, int argc,
>>> + char *const argv[]) {
>>> +   const char *str_cmd, *str_channel = NULL, *str_enable = NULL;
>>> +   const char *str_pwm = NULL, *str_period = NULL, *str_duty = NULL;
>>> +   enum pwm_cmd sub_cmd;
>>> +   struct udevice *dev;
>>> +   u32 channel, pwm_enable, pwm_dev, period_ns = 0, duty_ns = 0;
>>> +   int ret;
>>> +
>>> +   if (argc < 4)
>>> + show_usage:
>>> +   return CMD_RET_USAGE;
>>> +
>>> +   str_cmd = argv[1];
>>> +   argc -= 2;
>>> +   argv += 2;
>>> +
>>> +   if (argc > 0) {
>>> +   str_pwm = *argv;
>>> +   argc--;
>>> +   argv++;
>>> +   }
>>> +
>>> +   if (!str_pwm)
>>> +   goto show_usage;
>>> +
>>> +   switch (*str_cmd) {
>>> +   case 'i':
>>> +   sub_cmd = PWM_SET_INVERT;
>>> +   break;
>>> +   case 'c':
>>> + 

RE: [PATCH v2] cmd: Add a pwm command

2020-11-30 Thread Pragnesh Patel
Hi Simon,

>-Original Message-
>From: Simon Glass 
>Sent: 01 December 2020 01:42
>To: Pragnesh Patel 
>Cc: U-Boot Mailing List ; Atish Patra
>; Palmer Dabbelt ; Bin
>Meng ; Paul Walmsley ( Sifive)
>; Anup Patel ; Sagar Kadam
>; rick ; Naoki Hayama
>; Marek Vasut ;
>Patrick Delaunay ; Adam Ford
>; Thomas Hebb ; Ramon Fried
>; Heinrich Schuchardt ; Bin Meng
>; Sam Protsenko ; Miquel
>Raynal ; Philippe Reynes
>; Frédéric Danis
>; Patrice Chotard ;
>Vladimir Olovyannikov 
>Subject: Re: [PATCH v2] cmd: Add a pwm command
>
>[External Email] Do not click links or attachments unless you recognize the
>sender and know the content is safe
>
>Hi Pragnesh,
>
>On Thu, 26 Nov 2020 at 03:48, Pragnesh Patel 
>wrote:
>>
>> Add the command "pwm" for controlling the pwm channels. This command
>> provides pwm invert/config/enable/disable functionalities via PWM
>> uclass drivers
>>
>> Signed-off-by: Pragnesh Patel 
>> ---
>>
>> Changes in v2:
>> - Add test for pwm command
>>
>>
>>  README|   1 +
>>  cmd/Kconfig   |   6 ++
>>  cmd/Makefile  |   1 +
>>  cmd/pwm.c | 120 ++
>>  configs/sandbox_defconfig |   1 +
>>  test/cmd/Makefile |   1 +
>>  test/cmd/pwm.c|  54 +
>>  7 files changed, 184 insertions(+)
>>  create mode 100644 cmd/pwm.c
>>  create mode 100644 test/cmd/pwm.c
>
>Reviewed-by: Simon Glass 
>
>Minor nits below
>
>>
>> diff --git a/README b/README
>> index cb49aa15da..dab291e0d0 100644
>> --- a/README
>> +++ b/README
>> @@ -3160,6 +3160,7 @@ i2c   - I2C sub-system
>>  sspi   - SPI utility commands
>>  base   - print or set address offset
>>  printenv- print environment variables
>> +pwm- control pwm channels
>>  setenv - set environment variables
>>  saveenv - save environment variables to persistent storage  protect -
>> enable or disable FLASH write protection diff --git a/cmd/Kconfig
>> b/cmd/Kconfig index 1595de999b..0d085108f4 100644
>> --- a/cmd/Kconfig
>> +++ b/cmd/Kconfig
>> @@ -918,6 +918,12 @@ config CMD_GPIO
>> help
>>   GPIO support.
>>
>> +config CMD_PWM
>> +   bool "pwm"
>> +   depends on DM_PWM
>> +   help
>> + Control PWM channels, this allows invert/config/enable/disable PWM
>channels.
>> +
>>  config CMD_GPT
>> bool "GPT (GUID Partition Table) command"
>> select EFI_PARTITION
>> diff --git a/cmd/Makefile b/cmd/Makefile index dd86675bf2..75df3c136c
>> 100644
>> --- a/cmd/Makefile
>> +++ b/cmd/Makefile
>> @@ -120,6 +120,7 @@ endif
>>  obj-$(CONFIG_CMD_PINMUX) += pinmux.o
>>  obj-$(CONFIG_CMD_PMC) += pmc.o
>>  obj-$(CONFIG_CMD_PSTORE) += pstore.o
>> +obj-$(CONFIG_CMD_PWM) += pwm.o
>>  obj-$(CONFIG_CMD_PXE) += pxe.o pxe_utils.o
>>  obj-$(CONFIG_CMD_WOL) += wol.o
>>  obj-$(CONFIG_CMD_QFW) += qfw.o
>> diff --git a/cmd/pwm.c b/cmd/pwm.c
>> new file mode 100644
>> index 00..f704c7a755
>> --- /dev/null
>> +++ b/cmd/pwm.c
>> @@ -0,0 +1,120 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * Control PWM channels
>> + *
>> + * Copyright (c) 2020 SiFive, Inc
>> + * author: Pragnesh Patel   */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +enum pwm_cmd {
>> +   PWM_SET_INVERT,
>> +   PWM_SET_CONFIG,
>> +   PWM_SET_ENABLE,
>> +   PWM_SET_DISABLE,
>> +};
>> +
>> +static int do_pwm(struct cmd_tbl *cmdtp, int flag, int argc,
>> + char *const argv[])
>> +{
>> +   const char *str_cmd, *str_channel = NULL, *str_enable = NULL;
>> +   const char *str_pwm = NULL, *str_period = NULL, *str_duty = NULL;
>> +   enum pwm_cmd sub_cmd;
>> +   struct udevice *dev;
>> +   u32 channel, pwm_enable, pwm_dev, period_ns = 0, duty_ns = 0;
>> +   int ret;
>> +
>> +   if (argc < 4)
>> + show_usage:
>> +   return CMD_RET_USAGE;
>> +
>> +   str_cmd = argv[1];
>> +   argc -= 2;
>> +   argv += 2;
>> +
>> +   if (argc > 0) {
>> +   str_pwm = *argv;
>> +   argc--;
>> +   argv++;
>> +   }
>> +
>> +   if (!str_pwm)
>> +   goto show_usage;
>> +
>> +   switch (*str_cmd) {
>> +   case 'i':
>> +   sub_cmd = PWM_SET_INVERT;
>> +   break;
>> +   case 'c':
>> +   sub_cmd = PWM_SET_CONFIG;
>> +   break;
>> +   case 'e':
>> +   sub_cmd = PWM_SET_ENABLE;
>> +   break;
>> +   case 'd':
>> +   sub_cmd = PWM_SET_DISABLE;
>> +   break;
>> +   default:
>> +   goto show_usage;
>
>I think it is better to use 'return CMD_RET_USAGE' at each place rather than 
>use
>a goto.

Okay, will replace in v3.

>
>> +   }
>> +
>> +   if (IS_ENABLED(CONFIG_DM_PWM)) {
>
>You don't need this because the command is only enabled if DM_PWM

Will remove.

>
>> +   pwm_dev = simple_strtoul(str_pwm, NULL, 10);
>> +   ret = uclass_get_device(UCLASS_PWM, pwm_dev, &dev)

[PATCH] mtd: spi-nor-ids: add Winbond W25Q32JW-IM flash

2020-11-30 Thread Michael Walle
The Kontron SMARC-sAL28 board uses that flash.

This is the same change as in the linux commit f3418718c0ec ("mtd:
spi-nor: Add support for w25q32jwm").

Signed-off-by: Michael Walle 
Reported-by: Leo Krueger 
---

Hi,

I totally forgot that some revisions of the Kontron sl28 boards have the
newer SPI flash revision of the W25Q32.

It would be nice if this will make it into v2021.01.

 drivers/mtd/spi/spi-nor-ids.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index bc9d4f7e9f..09e8196048 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -278,6 +278,11 @@ const struct flash_info spi_nor_ids[] = {
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
},
+   {
+   INFO("w25q32jwm", 0xef8016, 0, 64 * 1024,  64,
+   SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
+   SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
+   },
{ INFO("w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K) },
{
INFO("w25q64dw", 0xef6017, 0, 64 * 1024, 128,
-- 
2.20.1



Re: [PATCH 01/27] linker_lists: Fix alignment issue

2020-11-30 Thread Heinrich Schuchardt

On 11/30/20 9:11 PM, Simon Glass wrote:

+Marek Vasut who originally wrote it

Hi Heinrich,

On Sun, 29 Nov 2020 at 23:20, Heinrich Schuchardt  wrote:


Am 30. November 2020 02:53:36 MEZ schrieb Simon Glass :

The linker script uses alphabetic sorting to group the different linker
lists together. Each group has its own struct and potentially its own
alignment. But when the linker packs the structs together it cannot
ensure that a linker list starts on the expected alignment boundary.

For example, if the first list has a struct size of 8 and we place 3 of
them in the image, that means that the next struct will start at offset
0x18 from the start of the linker_list section. If the next struct has
a size of 16 then it will start at an 8-byte aligned offset, but not a
16-byte aligned offset.

With sandbox on x86_64, a reference to a linker list item using
ll_entry_get() can force alignment of that particular linker_list item,
if it is in the same file as the linker_list item is declared.

Consider this example, where struct driver is 0x80 bytes:

   ll_entry_declare(struct driver, fred, driver)

...

   void *p = ll_entry_get(struct driver, fred, driver)

If these two lines of code are in the same file, then the entry is
forced
to be aligned at the 'struct driver' alignment, which is 16 bytes. If
the
second line of code is in a different file, then no action is taken,
since
the compiler cannot update the alignment of the linker_list item.

In the first case, an 8-byte 'fill' region is added:

.u_boot_list_2_driver_2_testbus_drv
0x00270018   0x80 test/built-in.o
0x00270018
   _u_boot_list_2_driver_2_testbus_drv
.u_boot_list_2_driver_2_testfdt1_drv
0x00270098   0x80 test/built-in.o
0x00270098
   _u_boot_list_2_driver_2_testfdt1_drv
*fill* 0x002701180x8
.u_boot_list_2_driver_2_testfdt_drv
0x00270120   0x80 test/built-in.o
0x00270120
   _u_boot_list_2_driver_2_testfdt_drv
.u_boot_list_2_driver_2_testprobe_drv
0x002701a0   0x80 test/built-in.o
0x002701a0
   _u_boot_list_2_driver_2_testprobe_drv

With this, the linker_list no-longer works since items after
testfdt1_drv
are not at the expected address.

Ideally we would have a way to tell gcc not to align structs in this
way.
It is not clear how we could do this, and in any case it would require
us
to adjust every struct used by the linker_list feature.

One possible fix is to force each separate linker_list to start on the
largest possible boundary that can be required by the compiler. However
that does not seem to work on x86_64, which uses 16-byte alignment in
this
case but needs 32-byte alignment.

So add a Kconfig option to handle this. Set the default value to 4 so
as to avoid changing platforms that don't need it.

Update the ll_entry_start() accordingly.

Signed-off-by: Simon Glass 
---

arch/Kconfig | 11 +++
doc/api/linker_lists.rst | 62 
include/linker_lists.h   |  3 +-
3 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 3aa99e08fce..aa8664212f1 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -7,6 +7,17 @@ config HAVE_ARCH_IOREMAP
config NEEDS_MANUAL_RELOC
   bool

+config LINKER_LIST_ALIGN
+  int
+  default 32 if SANDBOX


What is so special about the sandbox?


I'm not too sure, actually. Also, 32 seems to be larger than
__BIGGEST_ALIGNMENT__ so it is confusing.


Just evaluate if the host is 64 bit and use 8 or 4 accordingly?


+  default 8 if ARM64 || X86


Shouldn't the default be 8 on all 64 bit platforms? And 4 on all 32 bit 
platforms?


Possibly, but who knows? One way to really get to the bottom of this
is to have a test that checks that the alignment is what it should be.
I spent half a day diagnosing this but not that much time thinking of
the best solution. If you have time to dig into it please let me know.

Regards,
Simon



If you change ll_entry_start() as below, the linker will complain
"lib/efi_driver/efi_uclass.c:309:
undefined reference to `bad_alignment'"

If you change value 4 to 8, it stops complaining for qemu-x86_64_defconfig.

#define ll_alignment(x) \
(__builtin_offsetof(struct {char a; x b;}, b))
void bad_alignment(void);
#define ll_entry_start(_type, _list) \
({ \
static char start[0] __aligned(4) __attribute__((unused, \
section(".u_boot_list_2_"#_list"_1"))); \
if (ll_alignment(_type) > 4) \
bad_alignment(); \
(_type *)&start; \
})

If the alignment is smaller than the limit, the compiler can remove the
bad_alignment() call due to the optimization setting -Os (or -O2).

For RISC-V 64bit you also need 8 byte alignment.

I suggest tha

Re: [PATCH] binman: Remove additional backslash

2020-11-30 Thread Simon Glass
On Mon, 23 Nov 2020 at 01:08, Michal Simek  wrote:
>
> The origin patch didn't have this change and it was caused by manual
> resolution where additional backslash was added.
>
> Fixes: 6723b4c6ca7b ("binman: Call helper function binman_set_rom_offset() to 
> fill offset")
> Signed-off-by: Michal Simek 
> ---
>
>  lib/binman.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks.

Reviewed-by: Simon Glass 

Applied to u-boot-dm, thanks!


Re: [PATCH] binman: Handle tool paths containing '~' correctly

2020-11-30 Thread Simon Glass
Hi Alper,

On Tue, 10 Nov 2020 at 07:45, Alper Nebi Yasak  wrote:
>
> On 09/11/2020 17:45, Simon Glass wrote:
> > At present if CROSS_COMPILE contains a tilde, such as
> > ~/.buildman-toolchains/gcc-7.3.0-nolibc/i386-linux/bin/i386-linux-gcc
> > then binman gives a confusing error:
> >
> >binman: Error 255 running '~/..buildman-toolchains/gcc-7.3.0- ...
> >
> > Fix this by expanding it out before running the tool.
> >
> > Signed-off-by: Simon Glass 
>
> Arguably, whatever is passing CROSS_COMPILE to binman should have
> expanded that; how are you passing it? If that's from shell you could
> use one of CROSS_COMPILE="$HOME/..." or ~/"..." (the "~/..." form isn't
> expanded), if it's read from e.g. ~/.buildman then the config parser
> should be expanding it at read-time.

This is actually happening in my lab because tbot is set to use the
home directory for the toolchains. It is set up in the 'lab.py' Python
file and uses ~ to avoid hard-coding it to a particular machine.

Regards,
Simon

Applied to u-boot-dm, thanks!


Re: [PATCH v2] sandbox: cros_ec: Basic support for EC_CMD_GET_NEXT_EVENT

2020-11-30 Thread Simon Glass
Since commit 690079767803 ("cros_ec: Support keyboard scanning with
EC_CMD_GET_NEXT_EVENT") the cros-ec-keyb driver has started using this
command, but the sandbox EC emulator does not recognize it and
continuously prints:

** Unknown EC command 0x67

This patch makes the sandbox driver send basic responses to the command,
but the response only supports keyboard scans for now.

The EC side of this command stores and returns events from a queue, and
returns -EC_RES_UNAVAILABLE when there are no new events. This should be
possible to implement by hooking into the SDL event queue (perhaps via
sandbox_sdl_poll_events). Implementing that is a bit harder to do since
the existing sandbox code is discarding pending keyboard events, then
reading the current keyboard state.

Since the EC emulator never explicitly fails to work on this command,
the fallback to the older command will not trigger and will not be
tested anymore.

Fixes: 690079767803 ("cros_ec: Support keyboard scanning with
EC_CMD_GET_NEXT_EVENT")
Reported-by: Heinrich Schuchardt 
Signed-off-by: Alper Nebi Yasak 
Tested-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
---

Changes in v2:
- Add tag: "Tested-by: Heinrich Schuchardt "
- Add tag: "Reviewed-by: Simon Glass "
- Expand commit message with information previously in commit notes

 drivers/misc/cros_ec_sandbox.c | 8 
 1 file changed, 8 insertions(+)

Applied to u-boot-dm, thanks!


Re: [PATCH] dm: core: Fix incorrect flag check

2020-11-30 Thread Simon Glass
On Sun, 15 Nov 2020 at 13:23, Marek Vasut  wrote:
>
> The test should be checking whether $flags are non-zero and $drv_flags
> contain specific flags, however these two sets of flags are separate,
> and the two tests should be logically ANDed, not bitwise ANDed.
>
> Signed-off-by: Marek Vasut 
> Cc: Simon Glass 
> ---
>  drivers/core/device-remove.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 

Applied to u-boot-dm, thanks!


Re: [PATCH v2 1/9] test: add LOGL_FORCE_DEBUG flags support in log tests

2020-11-30 Thread Simon Glass
On Fri, 27 Nov 2020 at 03:21, Patrick Delaunay  wrote:
>
> Add a check of the _log function with LOGL_FORCE_DEBUG flags,
> used to force the trace display.
>
> The trace should be displayed for all the level when flags
> have LOGL_FORCE_DEBUG bit is set, for any filter.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - Add test for LOGL_FORCE_DEBUG (NEW)
>
>  test/log/log_test.c | 29 -
>  1 file changed, 20 insertions(+), 9 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 2/9] log: don't build the trace buffer when log is not ready

2020-11-30 Thread Simon Glass
Hi Sean,

On Fri, 27 Nov 2020 at 07:50, Sean Anderson  wrote:
>
> On 11/27/20 5:20 AM, Patrick Delaunay wrote:
> > Update _log function to drop any traces when log is yet initialized:
> > vsnprintf is no more executed in this case.
> >
> > This patch allows to reduce the cost for the dropped early debug trace.
> >
> > Reviewed-by: Simon Glass 
> > Signed-off-by: Patrick Delaunay 
> > ---
> >
> > (no changes since v1)
> >
> >   common/log.c | 13 -
> >   1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/common/log.c b/common/log.c
> > index ce39918e04..212789d6b3 100644
> > --- a/common/log.c
> > +++ b/common/log.c
> > @@ -228,6 +228,9 @@ int _log(enum log_category_t cat, enum log_level_t 
> > level, const char *file,
> >   struct log_rec rec;
> >   va_list args;
> >
> > + if (!gd)
> > + return -ENOSYS;
>
> How early are you expecting this function to get called? AFAIK this will
> only return true before board_init_f_init_reserve. Shouldn't functions
> that early just not call log in the first place?

Heinrich may have some thoughts here.

I think we will end up using log very early, since it is sort-of the
replacement for printf() and debug().

Regards,
Simon


Re: [PATCH v2 8/9] test: log: add test for console output of dropped messages

2020-11-30 Thread Simon Glass
On Fri, 27 Nov 2020 at 03:21, Patrick Delaunay  wrote:
>
> Add a new test to check the content of the dropped messages
> sent to console puts function.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - added test for content of dropped messages (NEW)
>
>  test/log/log_test.c | 8 
>  1 file changed, 8 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH 2/2] console: sandbox: remove unnecessary sandbox code

2020-11-30 Thread Simon Glass
Hi Patrick,

On Fri, 27 Nov 2020 at 03:49, Patrick Delaunay  wrote:
>
> Remove the specific sandbox code in console.c, as the config
> CONFIG_DEBUG_UART is already supported in drivers/serial/sandbox.c
> and activated by default in all sandbox defconfig
> (CONFIG_DEBUG_UART_SANDBOX=y and CONFIG_DEBUG_UART=y).
>
> This patch allows to test the console code under DEBUG_UART in sandbox
> and avoids to include the file  in this u-boot generic code.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
>  common/console.c | 15 ---
>  1 file changed, 15 deletions(-)

Please see this commit as to why I put that code back, after removing it myself.

64e9b4f346f Revert "sandbox: Drop special case console code for sandbox"

Regards,
Simon


Re: [PATCH 1/1] common: always compile fixup_cmdtable()

2020-11-30 Thread Simon Glass
On Thu, 26 Nov 2020 at 12:46, Heinrich Schuchardt  wrote:
>
> With our optimization settings the linker eliminates unused functions.
>
> But for debugging it is better to compile with -Og or -O0. With -O0
> compiling the sandbox fails due to the missing function fixup_cmdtable()
> called by dm_reloc() and others.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  common/command.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 2/2] tools: image-host: add support for several sub-images

2020-11-30 Thread Simon Glass
Hi Philippe,

On Tue, 24 Nov 2020 at 06:40, Philippe Reynes
 wrote:
>
> The propoerty sign-images points to images in the configuration

spelling

> node. But thoses images may references severals "sub-images" (for

reference several

> example for images loadable). This commit adds the support of
> severals sub-images.

several

>
> Signed-off-by: Philippe Reynes 
> ---
>  tools/image-host.c | 36 +---
>  1 file changed, 21 insertions(+), 15 deletions(-)

The code looks OK but is missing docs.

>
> diff --git a/tools/image-host.c b/tools/image-host.c
> index ce829a8ec9..33a224129a 100644
> --- a/tools/image-host.c
> +++ b/tools/image-host.c
> @@ -805,25 +805,31 @@ static int fit_config_get_hash_list(void *fit, int 
> conf_noffset,
> image_count = 0;
> for (iname = prop; iname < end; iname += strlen(iname) + 1) {
> int image_noffset;
> +   int index, max_index;
>
> -   image_noffset = fit_conf_get_prop_node(fit, conf_noffset,
> -  iname);
> -   if (image_noffset < 0) {
> -   printf("Failed to find image '%s' in  configuration 
> '%s/%s'\n",
> -  iname, conf_name, sig_name);
> -   if (allow_missing)
> -   continue;
> +   max_index = fdt_stringlist_count(fit, conf_noffset, iname);
>
> -   return -ENOENT;
> -   }
> +   for (index = 0; index < max_index; index++) {
> +   image_noffset = fit_conf_get_prop_node_index(fit, 
> conf_noffset,
> +iname, 
> index);
>
> -   ret = fit_config_add_hash(fit, conf_name,
> - sig_name, node_inc,
> - iname, image_noffset);
> -   if (ret < 0)
> -   return ret;
> +   if (image_noffset < 0) {
> +   printf("Failed to find image '%s' in  
> configuration '%s/%s'\n",
> +  iname, conf_name, sig_name);
> +   if (allow_missing)
> +   continue;
>
> -   image_count++;
> +   return -ENOENT;
> +   }
> +
> +   ret = fit_config_add_hash(fit, conf_name,
> + sig_name, node_inc,
> + iname, image_noffset);
> +   if (ret < 0)
> +   return ret;
> +
> +   image_count++;
> +   }
> }
>
> if (!image_count) {
> --
> 2.17.1
>

Regards,
Simon


Re: [PATCH 1/2] configs: sandbox: activate DEBUG_UART

2020-11-30 Thread Simon Glass
On Fri, 27 Nov 2020 at 03:49, Patrick Delaunay  wrote:
>
> Add CONFIG_DEBUG_UART=y for all sandbox defconfig
> as it is already done in sandbox_defconfig.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
>  configs/sandbox64_defconfig| 1 +
>  configs/sandbox_flattree_defconfig | 1 +
>  configs/sandbox_spl_defconfig  | 1 +
>  3 files changed, 3 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH v6 17/28] fdt: translate address if #size-cells = <0>

2020-11-30 Thread Simon Glass
On Sun, 22 Nov 2020 at 09:11, Dario Binacchi  wrote:
>
> The __of_translate_address routine translates an address from the
> device tree into a CPU physical address. A note in the description of
> the routine explains that the crossing of any level with
> #size-cells = <0> is to be considered an error not by specification but
> since inherited from IBM. This does not happen for Texas Instruments, or
> at least for the beaglebone device tree. Without this patch, in fact,
> the translation into physical addresses of the registers contained in the
> am33xx-clocks.dtsi nodes would not be possible. They all have a parent
> with #size-cells = <0>.
>
> The CONFIG_OF_TRANSLATE_ZERO_SIZE_CELLS symbol makes translation
> possible even in the case of crossing levels with #size-cells = <0>.
>
> The patch acts conservatively on address translation, except for
> removing a check within the of_translate_one function in the
> drivers/core/of_addr.c file:
>
> +
> ranges = of_get_property(parent, rprop, &rlen);
> -   if (ranges == NULL && !of_empty_ranges_quirk(parent)) {
> -   debug("no ranges; cannot translate\n");
> -   return 1;
> -   }
> if (ranges == NULL || rlen == 0) {
> offset = of_read_number(addr, na);
> memset(addr, 0, pna * 4);
> debug("empty ranges; 1:1 translation\n");
>
> There are two reasons:
> 1 The function of_empty_ranges_quirk always returns false, invalidating
>   the following if statement in case of null ranges. Therefore one of
>   the two checks is useless.
>
> 2 The implementation of the of_translate_one function found in the
>   common/fdt_support.c file has removed this check while keeping the one
>   about the 1:1 translation.
>
> The patch adds a test and modifies a check for the correctness of an
> address in the case of enabling translation also for zero size cells.
> The added test checks translations of addresses generated by nodes of
> a device tree similar to those you can find in the files am33xx.dtsi
> and am33xx-clocks.dtsi for which the patch was created.
>
> The patch was also tested on a beaglebone black board. The addresses
> generated for the registers of the loaded drivers are those specified
> by the AM335x reference manual.
>
> Signed-off-by: Dario Binacchi 
> Tested-by: Dario Binacchi 
> Reviewed-by: Simon Glass 
>
> ---
>
> (no changes since v4)
>
> Changes in v4:
> - Add Sphinx documentation for dm_flags.
> - Convert GD_DM_FLG_* to enum.
> - Include device_compat.h header in test/dm/test-fdt.c for dev_xxx macros.
>
> Changes in v3:
> - Comment dm_flags field in the global_data structure.
>
> Changes in v2:
> - Fix a missing line in the commit message.
> - Add dm_flags to global_data structure and GD_DM_FLG_SIZE_CELLS_0 macro
>   to test without recompiling.
> - Update the OF_CHECK_COUNTS macro in order to have just one
>   #define by bringing the GD_DM_FLG_SIZE_CELLS_0 into the expression.
> - Lower-case the 0xC019 hex number.
>
>  arch/sandbox/dts/test.dts | 21 ++
>  common/fdt_support.c  |  6 ++-
>  drivers/core/Kconfig  | 12 ++
>  drivers/core/fdtaddr.c|  2 +-
>  drivers/core/of_addr.c| 14 ++-
>  drivers/core/ofnode.c |  7 +++-
>  drivers/core/root.c   |  3 ++
>  include/asm-generic/global_data.h | 18 
>  test/dm/test-fdt.c| 69 ++-
>  9 files changed, 136 insertions(+), 16 deletions(-)

Still looks good to me.


Re: [PATCH] common: spl: spl_fit.c: report an error on hash check fail

2020-11-30 Thread Simon Glass
On Tue, 24 Nov 2020 at 08:15, Philippe Reynes
 wrote:
>
> When the hash check fails on a loadable image, the SPL/TPL simply
> jump to the next one. This commit changes this behaviour, when the
> hash check fails on a loadable image, the function spl_load_simple_fit
> stops and report an error.
>
> Signed-off-by: Philippe Reynes 
> ---
>  common/spl/spl_fit.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass 

This should have a test. We have sandbox SPL test support now so it
should not be too hard.


Re: [PATCH v2 6/9] console: remove duplicated test on gd value

2020-11-30 Thread Simon Glass
On Fri, 27 Nov 2020 at 03:21, Patrick Delaunay  wrote:
>
> Reorder test on gd value and remove the duplicated test (!gd)
> in putc and puts function.
>
> This patch is a preliminary step for rework of this function.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - update gd test in console function puts and putc (cosmetic)
>
>  common/console.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v4 07/18] common: board_r: Drop initr_secondary_cpu wrapper

2020-11-30 Thread Simon Glass
On Sat, 28 Nov 2020 at 01:44, Ovidiu Panait  wrote:
>
> Add a return value to cpu_secondary_init_r and use it directly in the
> post-relocation init sequence, rather than using a wrapper stub.
>
> Signed-off-by: Ovidiu Panait 
> ---
> v4 updates:
> - add reviewed-by tag
>
> v3 updates:
> -none
>
> v2 updates:
> - add function comment
>
>  arch/powerpc/cpu/mpc85xx/cpu_init.c |  4 +++-
>  common/board_r.c| 17 ++---
>  include/init.h  | 14 ++
>  3 files changed, 19 insertions(+), 16 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 1/2] tools: image-host: clean function fit_config_get_hash_list

2020-11-30 Thread Simon Glass
Hi Philippe,

On Tue, 24 Nov 2020 at 06:40, Philippe Reynes
 wrote:
>
> This commit creates a function fit_config_add_hash that will be
> used in the next commit to support several 'sub-images'.
>
> Signed-off-by: Philippe Reynes 
> ---
>  tools/image-host.c | 132 ++---
>  1 file changed, 76 insertions(+), 56 deletions(-)
>

Reviewed-by: Simon Glass 

I'm not quite clear what you are doing in this series or why. Can you
add some documentation updates please?


Re: [PATCH v2] doc: edison: Update information about xFSTK

2020-11-30 Thread Simon Glass
On Fri, 27 Nov 2020 at 08:59, Andy Shevchenko
 wrote:
>
> xFSTK sources got a new home under Edison Firmware Group on GitHub [1].
> Update Intel Edison documentation accordingly.
>
> While here, fix couple of typos.
>
> [1]: https://github.com/edison-fw
>
> Signed-off-by: Andy Shevchenko 
> ---
> v2: more fixes to have nice looking PDF
>  doc/board/intel/edison.rst | 49 ++
>  1 file changed, 29 insertions(+), 20 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v1] x86: edison: Drop unneeded DM_PCI_COMPAT

2020-11-30 Thread Simon Glass
On Fri, 27 Nov 2020 at 05:41, Andy Shevchenko
 wrote:
>
> None of the driver for Edison is using DM_PCI_COMPAT, hence drop it.
>
> Signed-off-by: Andy Shevchenko 
> ---
>  configs/edison_defconfig | 1 -
>  1 file changed, 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH v1] x86: tangier: Find proper memory region for relocation

2020-11-30 Thread Simon Glass
On Fri, 27 Nov 2020 at 05:40, Andy Shevchenko
 wrote:
>
> It appears that U-Boot works by luck on Intel Edison board because the amount
> of RAM is less than 1 GB and standard way of calculating the top of it work
> for this configuration. However, this won't work if the amount of RAM is
> different and split differently in address space. We have to fine the suitable
> window correctly.
>
> Find proper memory region for relocation by scanning MMAP SFI table in
> board_get_usable_ram_top() callback.
>
> According to the address map documentation the Main Memory is guaranteed to 
> lie
> in the 0..2 GB range, that's why we limit search by this range.
>
> Fixes: e71de54a4943 ("x86: Add Intel Tangier support")
> Signed-off-by: Andy Shevchenko 
> ---
>  arch/x86/cpu/tangier/sdram.c | 43 
>  1 file changed, 43 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH v2 7/9] console: allow to record console output before ready

2020-11-30 Thread Simon Glass
Hi Patrick,

On Fri, 27 Nov 2020 at 03:21, Patrick Delaunay  wrote:
>
> Allow to record the console output before before U-Boot
> has a console ready.
>
> This patch allows to test the console output in sandbox test
> based on console record.
>
> It is possible because GD_FLG_RECORD and GD_FLG_SERIAL_READY
> are 2 independent flags.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - Record all messages in console, even when dropped (NEW)
>
>  common/console.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/common/console.c b/common/console.c
> index 70579af042..c3d552bb3e 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -519,6 +519,10 @@ void putc(const char c)
>  {
> if (!gd)
> return;
> +#ifdef CONFIG_CONSOLE_RECORD

Can we use CONFIG_IS_ENABLED() here and avoid the #ifdef? We might
need to add some inline functions for the case where console_out is
not available. See global_data.h for some examples.

> +   if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
> +   membuff_putbyte((struct membuff *)&gd->console_out, c);
> +#endif
>  #ifdef CONFIG_SANDBOX
> /* sandbox can send characters to stdout before it has a console */
> if (!(gd->flags & GD_FLG_SERIAL_READY)) {
> @@ -533,10 +537,6 @@ void putc(const char c)
> return;
> }
>  #endif
> -#ifdef CONFIG_CONSOLE_RECORD
> -   if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
> -   membuff_putbyte((struct membuff *)&gd->console_out, c);
> -#endif
>  #ifdef CONFIG_SILENT_CONSOLE
> if (gd->flags & GD_FLG_SILENT) {
> if (!(gd->flags & GD_FLG_DEVINIT))
> @@ -567,6 +567,10 @@ void puts(const char *s)
>  {
> if (!gd)
> return;
> +#ifdef CONFIG_CONSOLE_RECORD
> +   if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
> +   membuff_put((struct membuff *)&gd->console_out, s, strlen(s));
> +#endif
>  #ifdef CONFIG_SANDBOX
> /* sandbox can send characters to stdout before it has a console */
> if (!(gd->flags & GD_FLG_SERIAL_READY)) {
> @@ -584,10 +588,6 @@ void puts(const char *s)
> return;
> }
>  #endif
> -#ifdef CONFIG_CONSOLE_RECORD
> -   if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
> -   membuff_put((struct membuff *)&gd->console_out, s, strlen(s));
> -#endif
>  #ifdef CONFIG_SILENT_CONSOLE
> if (gd->flags & GD_FLG_SILENT) {
> if (!(gd->flags & GD_FLG_DEVINIT))
> --
> 2.17.1
>

Regards,
Simon


Re: [PATCH v2 5/9] test: add test for dropped trace before log_init

2020-11-30 Thread Simon Glass
On Fri, 27 Nov 2020 at 03:21, Patrick Delaunay  wrote:
>
> Add test for dropped trace before log_init, displayed by debug uart.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - Add test of displayed messages requested before log_init (NEW)
>
>  arch/sandbox/cpu/start.c  |  5 +
>  test/py/tests/test_log.py | 11 +++
>  2 files changed, 16 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH v2 3/9] test: log: add test for dropped messages

2020-11-30 Thread Simon Glass
On Fri, 27 Nov 2020 at 03:21, Patrick Delaunay  wrote:
>
> Add a new test to check the dropped messages when LOG is not ready
> with log_drop_count and the result of _log().
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - add test to count the dropped messages (NEW)
>
>  test/log/log_test.c | 43 +++
>  1 file changed, 35 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] log: typos in include/log.h

2020-11-30 Thread Simon Glass
On Mon, 30 Nov 2020 at 01:04, Heinrich Schuchardt  wrote:
>
> Correct several typos.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  include/log.h | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] MAINTAINERS: assign include/log.h

2020-11-30 Thread Simon Glass
On Mon, 30 Nov 2020 at 01:08, Heinrich Schuchardt  wrote:
>
> include/log.h belongs to LOGGING.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Simon Glass 


Re: [PATCH 01/27] linker_lists: Fix alignment issue

2020-11-30 Thread Simon Glass
+Marek Vasut who originally wrote it

Hi Heinrich,

On Sun, 29 Nov 2020 at 23:20, Heinrich Schuchardt  wrote:
>
> Am 30. November 2020 02:53:36 MEZ schrieb Simon Glass :
> >The linker script uses alphabetic sorting to group the different linker
> >lists together. Each group has its own struct and potentially its own
> >alignment. But when the linker packs the structs together it cannot
> >ensure that a linker list starts on the expected alignment boundary.
> >
> >For example, if the first list has a struct size of 8 and we place 3 of
> >them in the image, that means that the next struct will start at offset
> >0x18 from the start of the linker_list section. If the next struct has
> >a size of 16 then it will start at an 8-byte aligned offset, but not a
> >16-byte aligned offset.
> >
> >With sandbox on x86_64, a reference to a linker list item using
> >ll_entry_get() can force alignment of that particular linker_list item,
> >if it is in the same file as the linker_list item is declared.
> >
> >Consider this example, where struct driver is 0x80 bytes:
> >
> >   ll_entry_declare(struct driver, fred, driver)
> >
> >...
> >
> >   void *p = ll_entry_get(struct driver, fred, driver)
> >
> >If these two lines of code are in the same file, then the entry is
> >forced
> >to be aligned at the 'struct driver' alignment, which is 16 bytes. If
> >the
> >second line of code is in a different file, then no action is taken,
> >since
> >the compiler cannot update the alignment of the linker_list item.
> >
> >In the first case, an 8-byte 'fill' region is added:
> >
> > .u_boot_list_2_driver_2_testbus_drv
> >0x00270018   0x80 test/built-in.o
> >0x00270018
> >   _u_boot_list_2_driver_2_testbus_drv
> > .u_boot_list_2_driver_2_testfdt1_drv
> >0x00270098   0x80 test/built-in.o
> >0x00270098
> >   _u_boot_list_2_driver_2_testfdt1_drv
> > *fill* 0x002701180x8
> > .u_boot_list_2_driver_2_testfdt_drv
> >0x00270120   0x80 test/built-in.o
> >0x00270120
> >   _u_boot_list_2_driver_2_testfdt_drv
> > .u_boot_list_2_driver_2_testprobe_drv
> >0x002701a0   0x80 test/built-in.o
> >0x002701a0
> >   _u_boot_list_2_driver_2_testprobe_drv
> >
> >With this, the linker_list no-longer works since items after
> >testfdt1_drv
> >are not at the expected address.
> >
> >Ideally we would have a way to tell gcc not to align structs in this
> >way.
> >It is not clear how we could do this, and in any case it would require
> >us
> >to adjust every struct used by the linker_list feature.
> >
> >One possible fix is to force each separate linker_list to start on the
> >largest possible boundary that can be required by the compiler. However
> >that does not seem to work on x86_64, which uses 16-byte alignment in
> >this
> >case but needs 32-byte alignment.
> >
> >So add a Kconfig option to handle this. Set the default value to 4 so
> >as to avoid changing platforms that don't need it.
> >
> >Update the ll_entry_start() accordingly.
> >
> >Signed-off-by: Simon Glass 
> >---
> >
> > arch/Kconfig | 11 +++
> > doc/api/linker_lists.rst | 62 
> > include/linker_lists.h   |  3 +-
> > 3 files changed, 75 insertions(+), 1 deletion(-)
> >
> >diff --git a/arch/Kconfig b/arch/Kconfig
> >index 3aa99e08fce..aa8664212f1 100644
> >--- a/arch/Kconfig
> >+++ b/arch/Kconfig
> >@@ -7,6 +7,17 @@ config HAVE_ARCH_IOREMAP
> > config NEEDS_MANUAL_RELOC
> >   bool
> >
> >+config LINKER_LIST_ALIGN
> >+  int
> >+  default 32 if SANDBOX
>
> What is so special about the sandbox?

I'm not too sure, actually. Also, 32 seems to be larger than
__BIGGEST_ALIGNMENT__ so it is confusing.

> Just evaluate if the host is 64 bit and use 8 or 4 accordingly?
>
> >+  default 8 if ARM64 || X86
>
> Shouldn't the default be 8 on all 64 bit platforms? And 4 on all 32 bit 
> platforms?

Possibly, but who knows? One way to really get to the bottom of this
is to have a test that checks that the alignment is what it should be.
I spent half a day diagnosing this but not that much time thinking of
the best solution. If you have time to dig into it please let me know.

Regards,
Simon


Re: [RESEND PATCH] fdt: Use phandle to distinguish DT nodes with same name

2020-11-30 Thread Simon Glass
Hi Aswath,

On Fri, 27 Nov 2020 at 07:05, Aswath Govindraju  wrote:
>
> On 22/11/20 4:37 am, Simon Glass wrote:
> > Hi,
> >
> > On Wed, 18 Nov 2020 at 10:55, Vignesh Raghavendra  wrote:
> >>
> >>
> >>
> >> On 11/18/20 8:44 PM, Aswath Govindraju wrote:
> >>> Hi Simon,
> >>>
> >>> On 18/11/20 8:07 pm, Simon Glass wrote:
>  Hi Aswath,
> 
>  On Mon, 16 Nov 2020 at 07:29, Aswath Govindraju  
>  wrote:
> >
> > While assigning the sequence number to subsystem instances by reading 
> > the
> > aliases property, only DT nodes names are compared and not the complete
> > path. This causes a problem when there are two DT nodes with same name 
> > but
> > have different paths.
> >
> > Fix it by comparing the phandles of DT nodes after the node names match.
> >
> > Signed-off-by: Aswath Govindraju 
> > ---
> >
> > Resending this patch as it was held awaiting for moderator approval 
> > because
> > patch was sent by non-member.
> >
> >  lib/fdtdec.c | 5 +
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> > index 2015907dee7d..9e1bfe0b519e 100644
> > --- a/lib/fdtdec.c
> > +++ b/lib/fdtdec.c
> > @@ -478,6 +478,11 @@ int fdtdec_get_alias_seq(const void *blob, const 
> > char *base, int offset,
> > slash = strrchr(prop, '/');
> > if (strcmp(slash + 1, find_name))
> > continue;
> > +
> > +   if (fdt_get_phandle(blob, offset) !=
> > +   fdt_get_phandle(blob, fdt_path_offset(blob, prop)))
> > +   continue;
> 
>  The call to fdt_path_offset() is very slow. Perhaps we can do this
>  check only with livetree? What situation is causing a problem for you?
>  What are the node / alias names?
> >>>
> >>> In the case of live tree for getting the sequence number the node
> >>> pointers are compared. So, I don't think this problem would come up.
> >>>
> >>> As for the use case,
> >>>
> >>> In AM654 Device tree there are two instances of USB controllers and both
> >>> the controller nodes have the same name usb@1
> >>>
> >>> If dfu is performed through the port connected to second controller.
> >>> Then based on the dr_mode of first controller the instance number to be
> >>> used in dfu command will vary. In order to make the instance number for
> >>> dfu command to be independent, aliases can be used(If aliases are
> >>> defined then the sequence number is assigned as the alias number.).
> >>>
> >>> The problem with current method for acquiring sequence number using
> >>> aliases is that only the name of the node is compared with node name
> >>> from the aliases property. So in the above case both the controllers
> >>> will have the same name. This leads to the first alias number being used
> >>> for the both the controllers to assign sequence number.
> >>>
> >>>
> >>> aliases {
> >>> serial2 = &main_uart0;
> >>> ethernet0 = &cpsw_port1;
> >>> usb0 = &usb0;// This property being used to
> >>>   //alias both the controllers
> >>> usb1 = &usb1;
> >>> };
> >>
> >>
> >> To explain a bit more, here is the DT snippet around usb0 and usb1
> >>
> >> dwc3_0: dwc3@400 {
> >> compatible = "ti,am654-dwc3";
> >> reg = <0x0 0x400 0x0 0x4000>;
> >> #address-cells = <1>;
> >> #size-cells = <1>;
> >> ranges = <0x0 0x0 0x400 0x2>;
> >> ...
> >>
> >> usb0: usb@1 {
> >> compatible = "snps,dwc3";
> >> reg = <0x1 0x1>;
> >> ...
> >> };
> >> };
> >>
> >> dwc3_1: dwc3@402 {
> >> compatible = "ti,am654-dwc3";
> >> reg = <0x0 0x402 0x0 0x4000>;
> >> #address-cells = <1>;
> >> #size-cells = <1>;
> >> ranges = <0x0 0x0 0x402 0x2>;
> >> ...
> >>
> >> usb1: usb@1 {
> >> compatible = "snps,dwc3";
> >> reg = <0x1 0x1>;
> >> ...
> >> };
> >> };
> >>
> >> In above case, (with CONFIG_OF_LIVE disabled),
> >> fdtdec_get_alias_seq() fails to pick the correct instance for USB
> >> controller for a given index. This is because fdtdec_get_alias_seq()
> >> only compares the leaf node name (usb@1) with alias path and thus
> >> both usb instances match to usb0.
> >>
> >>>
> >>> So, to distinguish nodes with same name, phandles can be used while
> >>> assigning sequence numbers.
> >
>
> I apologize for the delay in response.

No hurry!

>
>
> > Thank you both for the detai

Re: [PATCH v2] cmd: Add a pwm command

2020-11-30 Thread Simon Glass
Hi Pragnesh,

On Thu, 26 Nov 2020 at 03:48, Pragnesh Patel  wrote:
>
> Add the command "pwm" for controlling the pwm channels. This
> command provides pwm invert/config/enable/disable functionalities
> via PWM uclass drivers
>
> Signed-off-by: Pragnesh Patel 
> ---
>
> Changes in v2:
> - Add test for pwm command
>
>
>  README|   1 +
>  cmd/Kconfig   |   6 ++
>  cmd/Makefile  |   1 +
>  cmd/pwm.c | 120 ++
>  configs/sandbox_defconfig |   1 +
>  test/cmd/Makefile |   1 +
>  test/cmd/pwm.c|  54 +
>  7 files changed, 184 insertions(+)
>  create mode 100644 cmd/pwm.c
>  create mode 100644 test/cmd/pwm.c

Reviewed-by: Simon Glass 

Minor nits below

>
> diff --git a/README b/README
> index cb49aa15da..dab291e0d0 100644
> --- a/README
> +++ b/README
> @@ -3160,6 +3160,7 @@ i2c   - I2C sub-system
>  sspi   - SPI utility commands
>  base   - print or set address offset
>  printenv- print environment variables
> +pwm- control pwm channels
>  setenv - set environment variables
>  saveenv - save environment variables to persistent storage
>  protect - enable or disable FLASH write protection
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 1595de999b..0d085108f4 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -918,6 +918,12 @@ config CMD_GPIO
> help
>   GPIO support.
>
> +config CMD_PWM
> +   bool "pwm"
> +   depends on DM_PWM
> +   help
> + Control PWM channels, this allows invert/config/enable/disable PWM 
> channels.
> +
>  config CMD_GPT
> bool "GPT (GUID Partition Table) command"
> select EFI_PARTITION
> diff --git a/cmd/Makefile b/cmd/Makefile
> index dd86675bf2..75df3c136c 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -120,6 +120,7 @@ endif
>  obj-$(CONFIG_CMD_PINMUX) += pinmux.o
>  obj-$(CONFIG_CMD_PMC) += pmc.o
>  obj-$(CONFIG_CMD_PSTORE) += pstore.o
> +obj-$(CONFIG_CMD_PWM) += pwm.o
>  obj-$(CONFIG_CMD_PXE) += pxe.o pxe_utils.o
>  obj-$(CONFIG_CMD_WOL) += wol.o
>  obj-$(CONFIG_CMD_QFW) += qfw.o
> diff --git a/cmd/pwm.c b/cmd/pwm.c
> new file mode 100644
> index 00..f704c7a755
> --- /dev/null
> +++ b/cmd/pwm.c
> @@ -0,0 +1,120 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Control PWM channels
> + *
> + * Copyright (c) 2020 SiFive, Inc
> + * author: Pragnesh Patel 
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +enum pwm_cmd {
> +   PWM_SET_INVERT,
> +   PWM_SET_CONFIG,
> +   PWM_SET_ENABLE,
> +   PWM_SET_DISABLE,
> +};
> +
> +static int do_pwm(struct cmd_tbl *cmdtp, int flag, int argc,
> + char *const argv[])
> +{
> +   const char *str_cmd, *str_channel = NULL, *str_enable = NULL;
> +   const char *str_pwm = NULL, *str_period = NULL, *str_duty = NULL;
> +   enum pwm_cmd sub_cmd;
> +   struct udevice *dev;
> +   u32 channel, pwm_enable, pwm_dev, period_ns = 0, duty_ns = 0;
> +   int ret;
> +
> +   if (argc < 4)
> + show_usage:
> +   return CMD_RET_USAGE;
> +
> +   str_cmd = argv[1];
> +   argc -= 2;
> +   argv += 2;
> +
> +   if (argc > 0) {
> +   str_pwm = *argv;
> +   argc--;
> +   argv++;
> +   }
> +
> +   if (!str_pwm)
> +   goto show_usage;
> +
> +   switch (*str_cmd) {
> +   case 'i':
> +   sub_cmd = PWM_SET_INVERT;
> +   break;
> +   case 'c':
> +   sub_cmd = PWM_SET_CONFIG;
> +   break;
> +   case 'e':
> +   sub_cmd = PWM_SET_ENABLE;
> +   break;
> +   case 'd':
> +   sub_cmd = PWM_SET_DISABLE;
> +   break;
> +   default:
> +   goto show_usage;

I think it is better to use 'return CMD_RET_USAGE' at each place
rather than use a goto.

> +   }
> +
> +   if (IS_ENABLED(CONFIG_DM_PWM)) {

You don't need this because the command is only enabled if DM_PWM

> +   pwm_dev = simple_strtoul(str_pwm, NULL, 10);
> +   ret = uclass_get_device(UCLASS_PWM, pwm_dev, &dev);
> +   if (ret) {
> +   printf("PWM: '%s' not found\n", str_pwm);

printf("pwm: ...

> +   return cmd_process_error(cmdtp, ret);
> +   }
> +   }
> +
> +   if (argc > 0) {
> +   str_channel = *argv;
> +   channel = simple_strtoul(str_channel, NULL, 10);
> +   argc--;
> +   argv++;
> +   } else {
> +   goto show_usage;
> +   }
> +
> +   if (sub_cmd == PWM_SET_INVERT && argc > 0) {
> +   str_enable = *argv;
> +   pwm_enable = simple_strtoul(str_enable, NULL, 10);
> +   ret = pwm_set_invert(dev, channel, pwm_enable);
> +   } else if (sub_cmd == PWM_SET_CONFIG && argc == 2) {
> +   str_period = *argv;
> +   argc--;
> + 

[PATCH v1 4/4] imx: aristainetos: enable U-Boot Environment variables protection

2020-11-30 Thread Heiko Schocher
enable Environment protection with:

CONFIG_ENV_APPEND=y
CONFIG_ENV_WRITEABLE_LIST=y
CONFIG_ENV_ACCESS_IGNORE_FORCE

and add board specific env_get_location()
function.

Signed-off-by: Heiko Schocher 
---

 board/aristainetos/aristainetos.c| 20 
 configs/aristainetos2c_defconfig |  8 +++-
 configs/aristainetos2ccslb_defconfig | 10 +-
 include/configs/aristainetos2.h  |  3 +++
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/board/aristainetos/aristainetos.c 
b/board/aristainetos/aristainetos.c
index 6bfaaed666..07d2e3ec7b 100644
--- a/board/aristainetos/aristainetos.c
+++ b/board/aristainetos/aristainetos.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -527,3 +528,22 @@ int embedded_dtb_select(void)
return 0;
 }
 #endif
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+   if (op == ENVOP_SAVE || op == ENVOP_ERASE)
+   return ENVL_SPI_FLASH;
+
+   switch (prio) {
+   case 0:
+   return ENVL_NOWHERE;
+
+   case 1:
+   return ENVL_SPI_FLASH;
+
+   default:
+   return ENVL_UNKNOWN;
+   }
+
+   return ENVL_UNKNOWN;
+}
diff --git a/configs/aristainetos2c_defconfig b/configs/aristainetos2c_defconfig
index 773d7f6774..df0b26d6a0 100644
--- a/configs/aristainetos2c_defconfig
+++ b/configs/aristainetos2c_defconfig
@@ -1,7 +1,7 @@
 CONFIG_ARM=y
 CONFIG_ARCH_MX6=y
 CONFIG_SYS_TEXT_BASE=0x1780
-CONFIG_SYS_MALLOC_F_LEN=0xe000
+CONFIG_SYS_MALLOC_F_LEN=0x13000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_OFFSET=0xD
 CONFIG_MX6DL=y
@@ -30,6 +30,8 @@ CONFIG_CMD_BOOTZ=y
 # CONFIG_BOOTM_PLAN9 is not set
 # CONFIG_BOOTM_RTEMS is not set
 # CONFIG_BOOTM_VXWORKS is not set
+CONFIG_CMD_ENV_FLAGS=y
+CONFIG_CMD_NVEDIT_INFO=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
@@ -54,10 +56,14 @@ CONFIG_OF_CONTROL=y
 CONFIG_DTB_RESELECT=y
 CONFIG_MULTI_DTB_FIT=y
 CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_ENV_SPI_EARLY=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_ENV_APPEND=y
+CONFIG_ENV_WRITEABLE_LIST=y
+CONFIG_ENV_ACCESS_IGNORE_FORCE=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_APBH_DMA=y
diff --git a/configs/aristainetos2ccslb_defconfig 
b/configs/aristainetos2ccslb_defconfig
index 16d3c88fe1..0156493934 100644
--- a/configs/aristainetos2ccslb_defconfig
+++ b/configs/aristainetos2ccslb_defconfig
@@ -1,7 +1,7 @@
 CONFIG_ARM=y
 CONFIG_ARCH_MX6=y
 CONFIG_SYS_TEXT_BASE=0x1780
-CONFIG_SYS_MALLOC_F_LEN=0xe000
+CONFIG_SYS_MALLOC_F_LEN=0x13000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_OFFSET=0xD
 CONFIG_MX6DL=y
@@ -30,6 +30,8 @@ CONFIG_CMD_BOOTZ=y
 # CONFIG_BOOTM_PLAN9 is not set
 # CONFIG_BOOTM_RTEMS is not set
 # CONFIG_BOOTM_VXWORKS is not set
+CONFIG_CMD_ENV_FLAGS=y
+CONFIG_CMD_NVEDIT_INFO=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
@@ -54,10 +56,14 @@ CONFIG_OF_CONTROL=y
 CONFIG_DTB_RESELECT=y
 CONFIG_MULTI_DTB_FIT=y
 CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_ENV_SPI_EARLY=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_ENV_APPEND=y
+CONFIG_ENV_WRITEABLE_LIST=y
+CONFIG_ENV_ACCESS_IGNORE_FORCE=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_APBH_DMA=y
@@ -114,5 +120,7 @@ CONFIG_DISPLAY=y
 CONFIG_VIDEO_IPUV3=y
 CONFIG_SPLASH_SCREEN=y
 CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_BMP_16BPP=y
 CONFIG_IMX_WATCHDOG=y
 # CONFIG_EFI_LOADER is not set
diff --git a/include/configs/aristainetos2.h b/include/configs/aristainetos2.h
index c1e8b4a10c..78fa1a969e 100644
--- a/include/configs/aristainetos2.h
+++ b/include/configs/aristainetos2.h
@@ -449,4 +449,7 @@
 
 #define CONFIG_IMX6_PWM_PER_CLK6600
 
+#define CONFIG_ENV_FLAGS_LIST_STATIC "ethaddr:mw,serial#:sw,board_type:sw," \
+   "sysnum:dw,panel:sw,ipaddr:iw,serverip:iw"
+
 #endif /* __ARISTAINETOS2_CONFIG_H */
-- 
2.25.4



[PATCH v1 1/4] imx6: remove not longer supported aristainetos boards

2020-11-30 Thread Heiko Schocher
Removed aristainetos2, 2b, 2b-csl. This boards have been
recalled and destroyed.

Adapt board code to remove stuff not needed anymore.

Fix checkpatch warning, remove fdt_high and initrd_high
from default environment.

Signed-off-by: Heiko Schocher 
zu remove

---

 arch/arm/dts/Makefile |   7 -
 .../dts/imx6dl-aristainetos2_4-u-boot.dtsi|  13 -
 arch/arm/dts/imx6dl-aristainetos2_4.dts   |  51 ---
 arch/arm/dts/imx6dl-aristainetos2_4.dtsi  |  84 -
 .../dts/imx6dl-aristainetos2_7-u-boot.dtsi|  19 -
 arch/arm/dts/imx6dl-aristainetos2_7.dts   |  16 -
 arch/arm/dts/imx6dl-aristainetos2_7.dtsi  |  11 +-
 .../dts/imx6dl-aristainetos2b_4-u-boot.dtsi   |  13 -
 arch/arm/dts/imx6dl-aristainetos2b_4.dts  |  50 ---
 .../dts/imx6dl-aristainetos2b_7-u-boot.dtsi   |  19 -
 arch/arm/dts/imx6dl-aristainetos2b_7.dts  |  16 -
 .../imx6dl-aristainetos2b_csl_4-u-boot.dtsi   |  13 -
 arch/arm/dts/imx6dl-aristainetos2b_csl_4.dts  |  50 ---
 .../imx6dl-aristainetos2b_csl_7-u-boot.dtsi   |  19 -
 arch/arm/dts/imx6dl-aristainetos2b_csl_7.dts  |  16 -
 .../dts/imx6dl-aristainetos2c_4-u-boot.dtsi   |  13 -
 arch/arm/dts/imx6dl-aristainetos2c_4.dts  |  50 ---
 arch/arm/dts/imx6dl-aristainetos2c_7.dts  |   2 +-
 .../arm/dts/imx6qdl-aristainetos2-common.dtsi |  23 +-
 .../arm/dts/imx6qdl-aristainetos2-u-boot.dtsi |  22 --
 arch/arm/dts/imx6qdl-aristainetos2.dtsi   | 244 -
 .../dts/imx6qdl-aristainetos2b-u-boot.dtsi|  77 -
 arch/arm/dts/imx6qdl-aristainetos2b.dtsi  | 266 --
 .../imx6qdl-aristainetos2b_csl-u-boot.dtsi|  77 -
 arch/arm/dts/imx6qdl-aristainetos2b_csl.dtsi  | 248 -
 arch/arm/dts/imx6qdl-aristainetos2c.dtsi  |  12 +-
 arch/arm/mach-imx/mx6/Kconfig |  33 --
 board/aristainetos/Kconfig|  36 --
 board/aristainetos/MAINTAINERS|  29 +-
 board/aristainetos/aristainetos.c | 263 +++---
 board/aristainetos/common/Kconfig |   5 +-
 configs/aristainetos2_defconfig   | 121 ---
 configs/aristainetos2b_defconfig  | 115 --
 configs/aristainetos2bcsl_defconfig   | 115 --
 configs/aristainetos2c_defconfig  |   6 +-
 include/configs/aristainetos2.h   | 326 +-
 36 files changed, 249 insertions(+), 2231 deletions(-)
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2_4-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2_4.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2_4.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2_7-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2_7.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_4-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_4.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_7-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_7.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_csl_4-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_csl_4.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_csl_7-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_csl_7.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2c_4-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2c_4.dts
 delete mode 100644 arch/arm/dts/imx6qdl-aristainetos2.dtsi
 delete mode 100644 arch/arm/dts/imx6qdl-aristainetos2b-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6qdl-aristainetos2b.dtsi
 delete mode 100644 arch/arm/dts/imx6qdl-aristainetos2b_csl-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6qdl-aristainetos2b_csl.dtsi
 delete mode 100644 configs/aristainetos2_defconfig
 delete mode 100644 configs/aristainetos2b_defconfig
 delete mode 100644 configs/aristainetos2bcsl_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index e2e8a5fb7a..457ccfe08f 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -643,13 +643,6 @@ dtb-$(CONFIG_MX53) += imx53-cx9020.dtb \
 
 ifneq ($(CONFIG_MX6DL)$(CONFIG_MX6QDL)$(CONFIG_MX6S),)
 dtb-y += \
-   imx6dl-aristainetos2_4.dtb \
-   imx6dl-aristainetos2_7.dtb \
-   imx6dl-aristainetos2b_4.dtb \
-   imx6dl-aristainetos2b_7.dtb \
-   imx6dl-aristainetos2b_csl_4.dtb \
-   imx6dl-aristainetos2b_csl_7.dtb \
-   imx6dl-aristainetos2c_4.dtb \
imx6dl-aristainetos2c_7.dtb \
imx6dl-brppt2.dtb \
imx6dl-cubox-i.dtb \
diff --git a/arch/arm/dts/imx6dl-aristainetos2_4-u-boot.dtsi 
b/arch/arm/dts/imx6dl-aristainetos2_4-u-boot.dtsi
deleted file mode 100644
index ac7052c7b7..00
--- a/arch/arm/dts/imx6dl-aristainetos2_4-u-boot.dtsi
+++ /dev/null
@@ -1,13 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2019 Heiko Schocher 
- */
-
-#include 
-
-&lcd_panel {
-   pinctrl-names = "default";
-   pinctrl-0 = <&pinctrl_ipu_disp>;
-   enable-gpios =

[PATCH v1 3/4] arm: dts: aristainetos: sync with changes in linux

2020-11-30 Thread Heiko Schocher
sync with comaptible changes in linux from
Krzysztof Kozlowski.

https://patchwork.kernel.org/project/linux-arm-kernel/patch/20200930190143.27032-12-k...@kernel.org/

Signed-off-by: Heiko Schocher 
---

 arch/arm/dts/imx6dl-aristainetos2c_7.dts  | 2 +-
 arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/imx6dl-aristainetos2c_7.dts 
b/arch/arm/dts/imx6dl-aristainetos2c_7.dts
index 00eec82bf4..e1f9e88291 100644
--- a/arch/arm/dts/imx6dl-aristainetos2c_7.dts
+++ b/arch/arm/dts/imx6dl-aristainetos2c_7.dts
@@ -12,5 +12,5 @@
 
 / {
model = "aristainetos2c+2d i.MX6 Dual Lite Boards 7";
-   compatible = "fsl,imx6dl";
+   compatible = "abb,aristainetos2-imx6dl-7", "fsl,imx6dl";
 };
diff --git a/arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts 
b/arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts
index b40ddafeb9..7f839ca5e2 100644
--- a/arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts
+++ b/arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts
@@ -12,5 +12,5 @@
 
 / {
model = "aristainetos2c cslb i.MX6 Dual Lite Board 7";
-   compatible = "fsl,imx6dl";
+   compatible = "abb,aristainetos2-imx6dl-7", "fsl,imx6dl";
 };
-- 
2.25.4



[PATCH v1 2/4] imx6: add support for aristainetos2c_cslb board variant

2020-11-30 Thread Heiko Schocher
add support for aristainetos2c_cslb board variant.

Signed-off-by: Heiko Schocher 
---

 arch/arm/dts/Makefile |   1 +
 .../imx6dl-aristainetos2c_cslb_7-u-boot.dtsi  |  19 ++
 arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts |  16 ++
 .../imx6qdl-aristainetos2c_cslb-u-boot.dtsi   |  77 ++
 arch/arm/dts/imx6qdl-aristainetos2c_cslb.dtsi | 232 ++
 arch/arm/mach-imx/mx6/Kconfig |  11 +
 board/aristainetos/Kconfig|  12 +
 board/aristainetos/MAINTAINERS|   5 +
 board/aristainetos/common/Kconfig |   1 +
 configs/aristainetos2c_defconfig  |   3 +-
 configs/aristainetos2ccslb_defconfig  | 118 +
 include/configs/aristainetos2.h   |   9 +
 12 files changed, 502 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/imx6dl-aristainetos2c_cslb_7-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts
 create mode 100644 arch/arm/dts/imx6qdl-aristainetos2c_cslb-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6qdl-aristainetos2c_cslb.dtsi
 create mode 100644 configs/aristainetos2ccslb_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 457ccfe08f..089dfb73a3 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -644,6 +644,7 @@ dtb-$(CONFIG_MX53) += imx53-cx9020.dtb \
 ifneq ($(CONFIG_MX6DL)$(CONFIG_MX6QDL)$(CONFIG_MX6S),)
 dtb-y += \
imx6dl-aristainetos2c_7.dtb \
+   imx6dl-aristainetos2c_cslb_7.dtb \
imx6dl-brppt2.dtb \
imx6dl-cubox-i.dtb \
imx6dl-cubox-i-emmc-som-v15.dtb \
diff --git a/arch/arm/dts/imx6dl-aristainetos2c_cslb_7-u-boot.dtsi 
b/arch/arm/dts/imx6dl-aristainetos2c_cslb_7-u-boot.dtsi
new file mode 100644
index 00..b069debc1e
--- /dev/null
+++ b/arch/arm/dts/imx6dl-aristainetos2c_cslb_7-u-boot.dtsi
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+ or X11
+/*
+ * Copyright (C) 2019 Heiko Schocher 
+ */
+
+#include 
+/ {
+   vdd_panel_reg: regulator-panel {
+   compatible = "regulator-fixed";
+   regulator-name = "panel_regulator";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+};
+
+&panel0 {
+   power-supply = <&vdd_panel_reg>;
+};
diff --git a/arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts 
b/arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts
new file mode 100644
index 00..b40ddafeb9
--- /dev/null
+++ b/arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: (GPL-2.0)
+/*
+ * support for the imx6 based aristainetos2c cslb board
+ *
+ * Copyright (C) 2019 Heiko Schocher 
+ * Copyright (C) 2015 Heiko Schocher 
+ *
+ */
+/dts-v1/;
+#include "imx6dl-aristainetos2_7.dtsi"
+#include "imx6qdl-aristainetos2c_cslb.dtsi"
+
+/ {
+   model = "aristainetos2c cslb i.MX6 Dual Lite Board 7";
+   compatible = "fsl,imx6dl";
+};
diff --git a/arch/arm/dts/imx6qdl-aristainetos2c_cslb-u-boot.dtsi 
b/arch/arm/dts/imx6qdl-aristainetos2c_cslb-u-boot.dtsi
new file mode 100644
index 00..8c2ed70075
--- /dev/null
+++ b/arch/arm/dts/imx6qdl-aristainetos2c_cslb-u-boot.dtsi
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0+ or X11
+/*
+ * Copyright (C) 2019 Heiko Schocher 
+ */
+
+/ {
+   chosen {
+   u-boot,dm-pre-reloc;
+   stdout-path = &uart1;
+   };
+
+   wdt-reboot {
+   compatible = "wdt-reboot";
+   wdt = <&wdog1>;
+   };
+};
+
+&uart1 {
+   u-boot,dm-pre-reloc;
+};
+
+&pinctrl_gpio {
+   u-boot,dm-pre-reloc;
+};
+
+&pinctrl_uart1 {
+   u-boot,dm-pre-reloc;
+};
+
+&iomuxc {
+   u-boot,dm-pre-reloc;
+};
+
+&aips1 {
+   u-boot,dm-pre-reloc;
+};
+
+&backlight {
+   pwms = <&pwm1 0 30>;
+   default-brightness-level = <2>;
+};
+
+/*
+ * allow switching write protect / reset pin by gpio,
+ * because "pinctrl-assert-gpios" from &ecspi1 isn't handled by u-boot
+ */
+&gpio2 {
+   u-boot,dm-pre-reloc;
+
+   wp_spi_nor {
+   gpio-hog;
+   output-high;
+   gpios = <15 GPIO_ACTIVE_HIGH>;
+   };
+
+   reset_spi_nor {
+   gpio-hog;
+   output-high;
+   gpios = <28 GPIO_ACTIVE_HIGH>;
+   };
+};
+
+&gpio4 {
+   u-boot,dm-pre-reloc;
+};
+
+&ecspi1 {
+   u-boot,dm-pre-reloc;
+};
+
+&flash {
+   u-boot,dm-pre-reloc;
+};
+
+&pinctrl_ecspi1 {
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/imx6qdl-aristainetos2c_cslb.dtsi 
b/arch/arm/dts/imx6qdl-aristainetos2c_cslb.dtsi
new file mode 100644
index 00..c3724ec86f
--- /dev/null
+++ b/arch/arm/dts/imx6qdl-aristainetos2c_cslb.dtsi
@@ -0,0 +1,232 @@
+// SPDX-License-Identifier: (GPL-2.0)
+/*
+ * support for the imx6 based aristainetos2c-cslb board
+ *
+ * Copyright (C) 2019 Heiko Schocher 
+ * Copyright (C) 2015 Heiko Schocher 
+ *
+ */
+#inclu

[PATCH v1 0/4] arm: imx6: aristainetos board updates

2020-11-30 Thread Heiko Schocher
- remove the not longer used boards: aristainetos2, 2b, 2b-csl
- add support for aristainetos2c_cslb board variant
- sync defconfigs with current mainline
- sync dts files with latest changes in linux mainline
  (not all variants in linux yet)

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

Heiko Schocher (4):
  imx6: remove not longer supported aristainetos boards
  imx6: add support for aristainetos2c_cslb board variant
  arm: dts: aristainetos: sync with changes in linux
  imx: aristainetos: enable U-Boot Environment variables protection

 arch/arm/dts/Makefile |   8 +-
 .../dts/imx6dl-aristainetos2_4-u-boot.dtsi|  13 -
 arch/arm/dts/imx6dl-aristainetos2_4.dts   |  51 ---
 arch/arm/dts/imx6dl-aristainetos2_4.dtsi  |  84 -
 .../dts/imx6dl-aristainetos2_7-u-boot.dtsi|  19 -
 arch/arm/dts/imx6dl-aristainetos2_7.dts   |  16 -
 arch/arm/dts/imx6dl-aristainetos2_7.dtsi  |  11 +-
 .../dts/imx6dl-aristainetos2b_4-u-boot.dtsi   |  13 -
 arch/arm/dts/imx6dl-aristainetos2b_4.dts  |  50 ---
 arch/arm/dts/imx6dl-aristainetos2b_7.dts  |  16 -
 .../imx6dl-aristainetos2b_csl_4-u-boot.dtsi   |  13 -
 arch/arm/dts/imx6dl-aristainetos2b_csl_4.dts  |  50 ---
 .../imx6dl-aristainetos2b_csl_7-u-boot.dtsi   |  19 -
 arch/arm/dts/imx6dl-aristainetos2b_csl_7.dts  |  16 -
 .../dts/imx6dl-aristainetos2c_4-u-boot.dtsi   |  13 -
 arch/arm/dts/imx6dl-aristainetos2c_4.dts  |  50 ---
 arch/arm/dts/imx6dl-aristainetos2c_7.dts  |   4 +-
 ... imx6dl-aristainetos2c_cslb_7-u-boot.dtsi} |   2 +-
 arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts |  16 +
 .../arm/dts/imx6qdl-aristainetos2-common.dtsi |  23 +-
 .../arm/dts/imx6qdl-aristainetos2-u-boot.dtsi |  22 --
 arch/arm/dts/imx6qdl-aristainetos2.dtsi   | 244 -
 .../dts/imx6qdl-aristainetos2b-u-boot.dtsi|  77 
 arch/arm/dts/imx6qdl-aristainetos2b.dtsi  | 266 --
 arch/arm/dts/imx6qdl-aristainetos2c.dtsi  |  12 +-
 ...> imx6qdl-aristainetos2c_cslb-u-boot.dtsi} |   0
 dtsi => imx6qdl-aristainetos2c_cslb.dtsi} |  54 +--
 arch/arm/mach-imx/mx6/Kconfig |  30 +-
 board/aristainetos/Kconfig|  32 +-
 board/aristainetos/MAINTAINERS|  34 +-
 board/aristainetos/aristainetos.c | 283 ---
 board/aristainetos/common/Kconfig |   6 +-
 configs/aristainetos2b_defconfig  | 115 --
 configs/aristainetos2bcsl_defconfig   | 115 --
 configs/aristainetos2c_defconfig  |  13 +-
 ...defconfig => aristainetos2ccslb_defconfig} |  27 +-
 include/configs/aristainetos2.h   | 336 +-
 37 files changed, 354 insertions(+), 1799 deletions(-)
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2_4-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2_4.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2_4.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2_7-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2_7.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_4-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_4.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_7.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_csl_4-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_csl_4.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_csl_7-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2b_csl_7.dts
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2c_4-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6dl-aristainetos2c_4.dts
 rename arch/arm/dts/{imx6dl-aristainetos2b_7-u-boot.dtsi => 
imx6dl-aristainetos2c_cslb_7-u-boot.dtsi} (87%)
 create mode 100644 arch/arm/dts/imx6dl-aristainetos2c_cslb_7.dts
 delete mode 100644 arch/arm/dts/imx6qdl-aristainetos2.dtsi
 delete mode 100644 arch/arm/dts/imx6qdl-aristainetos2b-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx6qdl-aristainetos2b.dtsi
 rename arch/arm/dts/{imx6qdl-aristainetos2b_csl-u-boot.dtsi => 
imx6qdl-aristainetos2c_cslb-u-boot.dtsi} (100%)
 rename arch/arm/dts/{imx6qdl-aristainetos2b_csl.dtsi => 
imx6qdl-aristainetos2c_cslb.dtsi} (80%)
 delete mode 100644 configs/aristainetos2b_defconfig
 delete mode 100644 configs/aristainetos2bcsl_defconfig
 rename configs/{aristainetos2_defconfig => aristainetos2ccslb_defconfig} (84%)

-- 
2.25.4



[PATCH v2] Nokia RX-51: Enable usbtty serial console by default

2020-11-30 Thread Pali Rohár
Now when usbtty serial console is fixed in U-Boot enable CONFIG_USB_TTY for
Nokia RX-51 board by default.

Fix also USB product id as U-Boot ignores CONFIG_USBD_PRODUCTID macro and
include U-Boot string into USB product name to indicate usage of U-Boot.

CONFIG_CONSOLE_MUX is already used and U-Boot console is available for
all in/out devices. Therefore there is no need to have separate commands
'run sercon', 'run usbcon' and 'run vgacon', so remove them.

As space for U-Boot is limited to 256kB, disable some other unused options
so CONFIG_USB_TTY can be enabled.

Nokia RX-51 does not have easily accessible UART serial console so the only
option for easy debugging is to use device's keyboard+screen or this usbtty
serial console over USB.

Signed-off-by: Pali Rohár 
---
Changes since v1:
* Fixed USB product id and product name
* Disabled some other options to free more space
* Changes now passed CI tests:
  https://dev.azure.com/u-boot/u-boot/_build/results?buildId=1492&view=results

Note that this patch depends on other Nokia RX-51 patches which are on
mailing list, otherwise CI tests do not pass:

https://patchwork.ozlabs.org/project/uboot/patch/20201121223011.14262-1-p...@kernel.org/
https://patchwork.ozlabs.org/project/uboot/patch/20201121223317.14347-1-p...@kernel.org/
https://patchwork.ozlabs.org/project/uboot/patch/20201129161505.5092-1-p...@kernel.org/
https://patchwork.ozlabs.org/project/uboot/patch/20201130191034.795-1-p...@kernel.org/
---
 configs/nokia_rx51_defconfig |  8 +---
 doc/README.nokia_rx51| 15 +--
 include/configs/nokia_rx51.h | 21 +++--
 3 files changed, 13 insertions(+), 31 deletions(-)

diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig
index 0f05fe6fc3..963dd145ce 100644
--- a/configs/nokia_rx51_defconfig
+++ b/configs/nokia_rx51_defconfig
@@ -44,18 +44,16 @@ 
CONFIG_MTDPARTS_DEFAULT="mtdparts=onenand:128k(bootloader)ro,384k(config),256k(l
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 # CONFIG_NET is not set
-CONFIG_TWL4030_LED=y
 # CONFIG_MMC_HW_PARTITIONING is not set
+# CONFIG_MMC_VERBOSE is not set
 CONFIG_MMC_OMAP_HS=y
 CONFIG_MTD=y
 CONFIG_CONS_INDEX=3
 CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_USB=y
-CONFIG_USB_MUSB_HCD=y
 CONFIG_USB_MUSB_UDC=y
 CONFIG_USB_OMAP3=y
-CONFIG_TWL4030_USB=y
 CONFIG_CFB_CONSOLE=y
 CONFIG_CFB_CONSOLE_ANSI=y
 # CONFIG_VGA_AS_SINGLE_DEVICE is not set
@@ -66,3 +64,7 @@ CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
 # CONFIG_DM_DEVICE_REMOVE is not set
 # CONFIG_SYS_MALLOC_F is not set
+# CONFIG_DM_WARN is not set
+# CONFIG_DM_SEQ_ALIAS is not set
+# CONFIG_BLOCK_CACHE is not set
+# CONFIG_SYS_DEVICE_NULLDEV is not set
diff --git a/doc/README.nokia_rx51 b/doc/README.nokia_rx51
index 320b5efc7d..84d1912ddd 100644
--- a/doc/README.nokia_rx51
+++ b/doc/README.nokia_rx51
@@ -24,8 +24,7 @@ called u-boot-gen-combined. It is available in following 
repository:
 There is support for hardware watchdog. Hardware watchdog is started by
 NOLO so u-boot must kick watchdog to prevent reboot device (but not very
 often, max every 2 seconds). There is also support for framebuffer display
-output with ANSI escape codes and the N900 HW keyboard input. USB tty works
-but is disabled because it prevents the current Maemo kernel from booting.
+output with ANSI escape codes and the N900 HW keyboard input.
 
 When U-Boot is starting it enable IBE bit in Auxiliary Control Register,
 which is needed for Thumb-2 ISA support. It is workaround for errata 430973.
@@ -49,10 +48,6 @@ Boot from SD or eMMC in this order:
 
 Available additional commands/variables:
 
- * run sercon - Use serial port for control
- * run usbcon - Use usbtty for control
- * run vgacon - Use framebuffer and HW keyboard for control (default)
-
  * run sdboot - Boot from external SD card (see boot order)
  * run emmcboot - Boot from internal eMMC memory (see boot order)
  * run attachboot - Boot attached kernel image (attached to U-Boot binary)
@@ -87,14 +82,6 @@ Additional variables for booting kernel:
  and u-boot standard output is set to serial then setup_console_atag is
  automatically set to 1. So output from Maemo kernel would go to serial port.
 
-USB TTY:
-
- Maemo kernel 2.6.28 will crash if u-boot enable usb tty. So USB TTY is 
disabled.
- For enabling USB TTY just add this line to file include/configs/nokia_rx51.h
-
- #define CONFIG_USB_TTY
-
-
 UBIFS support:
 
  UBIFS support is disabled, because U-Boot image is too big and cannot be
diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h
index 3f2700d8e2..23368de624 100644
--- a/include/configs/nokia_rx51.h
+++ b/include/configs/nokia_rx51.h
@@ -70,10 +70,12 @@
 
 /* USB device configuration */
 #define CONFIG_USB_DEVICE
+#define CONFIG_USB_TTY
 #define CONFIG_USBD_VENDORID   0x0421
-#define CONFIG_USBD_PRODUCTID  0x01c8
+#define CONFIG_USBD_PRODUCTID_CDCACM   0x01c8
+#define CONFIG_USBD_PRODUCTID_GSERIAL  0x01c8
 #define CONFIG_USBD_MANUFACTURER 

[PULL] u-boot-mips fixes for v2021.01

2020-11-30 Thread Daniel Schwierzeck
Hi Tom,

please pull some bugfixes and some minor updates for compatibility with
the Marvell Octeon MIPS64 boot header. Although this adds a new tool,
everything is small and isolated to MIPS/Octeon.

Gitlab CI: https://gitlab.denx.de/u-boot/custodians/u-boot-mips/-/pipelines/5455
Azure: 
https://dev.azure.com/danielschwierzeck/u-boot/_build/results?buildId=10&view=results


The following changes since commit a7ab4b71d563b6e0b65f911a8bf7d6950625982e:

  Merge tag 'mmc-2020-11-29' of 
https://gitlab.denx.de/u-boot/custodians/u-boot-mmc (2020-11-29 11:12:59 -0500)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-mips.git 
tags/mips-fixes-for-v2021.01

for you to fetch changes up to 540a2bcec1389a3a31c23b5275e73186be6102b2:

  mips: octeon: tools: Add update_octeon_header tool (2020-11-30 18:32:09 +0100)


- MIPS: octeon: fix allocation bug in DDR driver
- MIPS: octeon: fix init of gd->ram_size
- MIPS: octeon: add support for Octeon boot header


Stefan Roese (5):
  mips: start.S: Add Octeon boot header compatibility
  mips: octeon: Fix Octeon DDR driver to use the correct struct
  mips: octeon: Report full DDR size in dram_init() to gd->ram_size
  mips: octeon: bootoctlinux: Use gd->ram_size instead of ram_get_info()
  mips: octeon: tools: Add update_octeon_header tool

 arch/mips/cpu/start.S  |  10 +-
 arch/mips/mach-octeon/bootoctlinux.c   |  21 +-
 arch/mips/mach-octeon/dram.c   |   7 +-
 arch/mips/mach-octeon/include/mach/cvmx-bootinfo.h | 222 --
 .../mach-octeon/include/mach/cvmx-bootloader.h | 172 
 drivers/ram/octeon/octeon_ddr.c|   2 +-
 tools/.gitignore   |   1 +
 tools/Makefile |   3 +
 tools/update_octeon_header.c   | 456 +
 9 files changed, 650 insertions(+), 244 deletions(-)
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-bootloader.h
 create mode 100644 tools/update_octeon_header.c


[PATCH] Nokia RX-51: Do not try calling both ext2load and ext4load

2020-11-30 Thread Pali Rohár
Those two commands now doing same thing, reading from ext2/3/4 filesystem.
So remove useless duplicated call.

Signed-off-by: Pali Rohár 
---
 include/configs/nokia_rx51.h | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h
index 6879f52a0c..3f2700d8e2 100644
--- a/include/configs/nokia_rx51.h
+++ b/include/configs/nokia_rx51.h
@@ -169,8 +169,6 @@ int rx51_kp_getc(struct stdio_dev *sdev);
"trymmcboot=if run switchmmc; then " \
"setenv mmctype fat;" \
"run trymmcallpartboot;" \
-   "setenv mmctype ext2;" \
-   "run trymmcallpartboot;" \
"setenv mmctype ext4;" \
"run trymmcallpartboot;" \
"fi\0" \
@@ -179,19 +177,10 @@ int rx51_kp_getc(struct stdio_dev *sdev);
"preboot=setenv mmcnum 1; setenv mmcpart 1;" \
"setenv mmcscriptfile bootmenu.scr;" \
"if run switchmmc; then " \
-   "setenv mmcdone true;" \
"setenv mmctype fat;" \
-   "if run scriptload; then true; else " \
-   "setenv mmctype ext2;" \
-   "if run scriptload; then true; else " \
-   "setenv mmctype ext4;" \
-   "if run scriptload; then true; else " \
-   "setenv mmcdone false;" \
-   "fi;" \
-   "fi;" \
-   "fi;" \
-   "if ${mmcdone}; then " \
-   "run scriptboot;" \
+   "if run scriptload; then run scriptboot; else " \
+   "setenv mmctype ext4;" \
+   "if run scriptload; then run scriptboot; fi;" \
"fi;" \
"fi;" \
"if run slide; then true; else " \
-- 
2.20.1



Re: Porting U-Boot to a QCA9531 board?

2020-11-30 Thread Daniel Schwierzeck
Am Mittwoch, den 18.11.2020, 17:54 + schrieb Richard Thanki:
> Hi Heinrich
> 
> > On 18 Nov 2020, at 17:27, Heinrich Schuchardt  wrote:
> > 
> > 
> > The driver will not be compiled because your config does not select
> > CONFIG_AG7XXX.
> 
> So clear when you point it out. I’ll modify this, and retest, thank you.
> 
> > > - With OpenWrt 18.06 (Kernel 4.4 - ar71xx mach target) and 19.07 (kernel 
> > > 4.14 -
> > >  ath79 dts target) the boot process doesn't complete and stalls at 
> > > [link]. With
> > >  OpenWrt Master (5.4) the boot process completes but the system displays 
> > > the
> > >  following issues: -- Within OpenWrt the watchdog timer (usually on GPIO 
> > > 2)
> > >  does not respond to writes on sysfs and therefore the device reboots 
> > > every 4
> > >  minutes -- The second USB hub on the board is not detected by OpenWrt 
> > > during
> > >  boot and therefore some devices do not come up on the operating system 
> > > such as
> > >  the modem.
> > 
> > These seem to be questions about Linux configuration, not U-Boot.
> 
> Sorry, I think we phrased this badly. We only get these issues when using 
> mainline U-Boot 
> and not a) the manufacturer default bootloader or b) the Pepe2K mod - both of 
> which work 
> perfectly with our test images. In each case we’re using the same OpenWrt OS 
> images 
> we’ve built ourselves between the tests with these different botloaders.
> 
> I guess the deeper understanding we’re trying to get to is the proper 
> relationship between 
> bootloader and Linux:
> 
> - Why would the very same OpenWrt image be able to find and use the USB hub 
> or make 
> use of GPIO 2 using these other two U-Boot variants but not mainline? 
> - Does this point to us not performing important set-up steps in U-Boot or 
> does our problem
>   lie in our OpenWrt setup? (If the latter, why do these other U-Boots work 
> properly?)
> - Are we stumbling into a common beginners’ problem?
> 
> 

Usually this means the Linux driver does not properly setup the
hardware and relies to much on register reset values or relies on the
bootloader to do some setup. At least the ladder should be avoided. A
Linux driver must work independently of the bootloader.

You could compare driver code and device-tree between mainline U-Boot
and pepe2k mod to find differences in HW init. If you find any, patch
mainline U-Boot first for testing. If the patch works, check if the
updated HW init code should rather be added to the according Linux
driver. Otherwise send the patch to the mailing list along with your
board support patch for review.

Maybe it's just as simple as some missing GPIO/pinmux settings, so you
should check that at first.

-- 
- Daniel



Re: [PATCH] tools: add a simple script to generate EFI variables

2020-11-30 Thread Paulo Alcantara
Hi Heinrich,

Heinrich Schuchardt  writes:

> On 11/30/20 4:16 PM, Paulo Alcantara wrote:
>> This script generates EFI variables for U-Boot variable store format.
>
> Wouldn't it make sense to allow overwriting and deleting variables too?

Absolutely.  I'll repost it with those features.

Thanks!


Re: [PATCH v4 16/18] common: board_r: Drop arch-specific ifdefs around initr_trap

2020-11-30 Thread Daniel Schwierzeck
Am Samstag, den 28.11.2020, 10:43 +0200 schrieb Ovidiu Panait:
> In order to remove the arch-specific ifdefs around initr_trap, introduce
> arch_initr_trap weak initcall. Implementations for ppc/m68k/mips have
> been moved to arch//lib/traps.c
> 
> Default implementation is a nop stub.
> 
> Signed-off-by: Ovidiu Panait 
> Reviewed-by: Simon Glass 
> ---
> v4 updates:
> - Drop trap_init declaration from init.h and make arch-specific
> implementations static for mips and m68k (on powerpc trap_init is an
> asm routine)
> 
> v3 updates:
> - none
> 
> v2 updates:
> - add reviewed-by tag
> 
>  arch/m68k/lib/traps.c |  9 -
>  arch/mips/lib/traps.c |  9 -
>  arch/powerpc/lib/Makefile |  1 +
>  arch/powerpc/lib/traps.c  | 19 +++
>  common/board_r.c  | 16 ++--
>  include/init.h| 10 +-
>  6 files changed, 47 insertions(+), 17 deletions(-)
>  create mode 100644 arch/powerpc/lib/traps.c
> 
> 

Reviewed-by: Daniel Schwierzeck 

-- 
- Daniel



Re: [PATCH] efi_loader: allow disabling EFI secure boot in User Mode

2020-11-30 Thread Paulo Alcantara
Hi Heinrich,

Heinrich Schuchardt  writes:

> On 11/30/20 3:58 PM, Paulo Alcantara wrote:
>> Introduce a new config option CONFIG_EFI_SECURE_BOOT_VAR_DISABLE to
>> allow disabling EFI secure boot when the platform is operating in User
>> Mode and there is an NV+BS EFI variable called "SecureBootDisable".
>> Otherwise, keep it enabled by default.
>
> could you, please, explain why this is needed.

I was just looking for an easier way to disable it without having to
mess with the secure boot variables and possibly breaking secure boot
altogether.  Of course, we could do the same by creating such
SecureBootDisable variable and forgetting about it.  Since we're gonna
provide u-boot package with the secure boot keys (PK, KEK, db, dbx)
enrolled in (ESP)/ubootefi.var (generated by efivar.py script), and
those certificates are only provided at build time, that would be tricky
to get it enabled or disabled by removing and inserting the PK, finding
the appropriate certificate depending on whether it is openSUSE or SLES.

For instance, OVMF does have something like that [1].

[1]
https://github.com/tianocore/edk2/blob/master/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c#L682

Thanks.


[ANN] U-Boot v2021.01-rc3 released

2020-11-30 Thread Tom Rini
Hey all,

Well, I managed to miss a calendar reminder, and with the US holiday
last week, I just pushed out until today.  So here's -rc3, a bit behind
schedule.  But the good news is I think we're close enough to final
release to open the next window now.

I feel like I've been following through on what I said I would do about
only applying bug fixes, and I'm going to continue on with that.

In terms of a changelog, 
git log --merges v2021.01-rc3..v2021.01-rc3
contains what I've pulled but as always, better PR messages and tags
will provide better results here.

I plan to do -rc4 on the 11th of December, -rc5 on the 28th.  If we need
a -rc6, it will happen on January 4th, and final release is on January
11th, 2021.  Thanks all!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 5/5 v3] mips: octeon: tools: Add update_octeon_header tool

2020-11-30 Thread Daniel Schwierzeck
Am Montag, den 30.11.2020, 13:14 +0100 schrieb Stefan Roese:
> Add a tool to update or insert an Octeon specific header into the U-Boot
> image. This is needed e.g. for booting via SPI NOR, eMMC and NAND.
> 
> While working on this, move enum cvmx_board_types_enum and
> cvmx_board_type_to_string() to cvmx-bootloader.h and remove the
> unreferenced (unsupported) board definition.
> 
> Signed-off-by: Stefan Roese 
> Cc: Aaron Williams 
> Cc: Chandrakala Chavva 
> Cc: Daniel Schwierzeck 
> ---
> v3:
> - Add .gitignore entry
> - Use compiletime_assert() instead of adhoc-coded compile_time_assert()
> - Dropped forward declarations
> - All functions now static
> - Used prinf instead of debug in most places to make the output
>   more verbose and descriptive
> - Used "fprintf(stderr" for error messages
> - Dropped cvmx_cpu_to_be64
> - Removed crashes as suggested by Daniel
> 
> v2:
> - No change
> - Azure build success here:
>   https://dev.azure.com/sr0718/u-boot/_build/results?buildId=59&view=results
> 
>  .../mach-octeon/include/mach/cvmx-bootinfo.h  | 222 -
>  .../include/mach/cvmx-bootloader.h| 172 +++
>  tools/.gitignore  |   1 +
>  tools/Makefile|   3 +
>  tools/update_octeon_header.c  | 456 ++
>  5 files changed, 632 insertions(+), 222 deletions(-)
>  create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-bootloader.h
>  create mode 100644 tools/update_octeon_header.c
> 

Reviewed-by: Daniel Schwierzeck 

-- 
- Daniel



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

2020-11-30 Thread Heinrich Schuchardt

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 


Hello Joe,

could we get this into v2021.01, please?

Acked-by: Heinrich Schuchardt 


Re: [PATCH] tools: add a simple script to generate EFI variables

2020-11-30 Thread Heinrich Schuchardt

On 11/30/20 4:16 PM, Paulo Alcantara wrote:

This script generates EFI variables for U-Boot variable store format.


Hello Paulo,

thanks for you valuable contribution.

Wouldn't it make sense to allow overwriting and deleting variables too?

Best regards

Heinrich



An example of generating secure boot variables

   $ openssl x509 -in foo.crt -outform DER -out foo.der
   $ efisiglist -a -c foo.der -o foo.esl
   $ efivar.py -i ubootefi.var add -n db -d foo.esl -t file
   $ efivar.py -i ubootefi.var add -n kek -d foo.esl -t file
   $ efivar.py -i ubootefi.var add -n pk -d foo.esl -t file

Signed-off-by: Paulo Alcantara (SUSE) 
---
  tools/efivar.py | 141 
  1 file changed, 141 insertions(+)
  create mode 100755 tools/efivar.py

diff --git a/tools/efivar.py b/tools/efivar.py
new file mode 100755
index ..31e5508f08fd
--- /dev/null
+++ b/tools/efivar.py
@@ -0,0 +1,141 @@
+#!/usr/bin/env python3
+## SPDX-License-Identifier: GPL-2.0-only
+#
+# Generate UEFI variables for U-Boot.
+#
+# (c) 2020 Paulo Alcantara 
+#
+
+import os
+import struct
+import uuid
+import time
+import zlib
+import argparse
+import subprocess as sp
+
+# U-Boot variable store format (version 1)
+UBOOT_EFI_VAR_FILE_MAGIC = 0x0161566966456255
+
+# UEFI variable attributes
+EFI_VARIABLE_NON_VOLATILE = 0x1
+EFI_VARIABLE_BOOTSERVICE_ACCESS = 0x2
+EFI_VARIABLE_RUNTIME_ACCESS = 0x4
+EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS = 0x20
+NV_BS = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS
+NV_BS_RT = NV_BS | EFI_VARIABLE_RUNTIME_ACCESS
+NV_BS_RT_AT = NV_BS_RT | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
+
+# UEFI variable GUIDs
+EFI_GLOBAL_VARIABLE_GUID = '{8be4df61-93ca-11d2-aa0d-00e098032b8c}'
+EFI_IMAGE_SECURITY_DATABASE_GUID = '{d719b2cb-3d3a-4596-a3bc-dad00e67656f}'
+
+class EfiStruct:
+# struct efi_var_file
+var_file_fmt = ' 
self.efi.var_file_size:
+with open(self.infile, 'rb') as f:
+# skip header since it will be recreated by save()
+self.buf = f.read()[self.efi.var_file_size:]
+else:
+self.buf = bytearray()
+
+def _set_var(self, guid, name_data, size, attr, tsec):
+ent = struct.pack(self.efi.var_entry_fmt,
+  size,
+  attr,
+  tsec,
+  uuid.UUID(guid).bytes_le)
+ent += name_data
+self.buf += ent
+
+def set_var(self, guid, name, data, size, attr):
+tsec = int(time.time()) if attr & 
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS else 0
+nd = name.encode('utf_16_le') + b"\x00\x00" + data
+# U-Boot variable format requires the name + data blob to be 8-byte 
aligned
+pad = ((len(nd) + 7) & ~7) - len(nd)
+nd += bytes([0] * pad)
+
+return self._set_var(guid, nd, size, attr, tsec)
+
+def save(self):
+hdr = struct.pack(self.efi.var_file_fmt,
+  0,
+  UBOOT_EFI_VAR_FILE_MAGIC,
+  len(self.buf) + self.efi.var_file_size,
+  zlib.crc32(self.buf) & 0x)
+
+with open(self.infile, 'wb') as f:
+f.write(hdr)
+f.write(self.buf)
+
+def parse_attrs(attr):
+attrs = {
+'nv': EFI_VARIABLE_NON_VOLATILE,
+'bs': EFI_VARIABLE_BOOTSERVICE_ACCESS,
+'rt': EFI_VARIABLE_RUNTIME_ACCESS,
+'at': EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,
+}
+v = 0
+for i in attr.split(','):
+   v |= attrs[i.lower()]
+return v
+
+def parse_data(val, vtype):
+fmt = { 'u8': '



Re: [PATCH] efi_loader: allow disabling EFI secure boot in User Mode

2020-11-30 Thread Heinrich Schuchardt

On 11/30/20 3:58 PM, Paulo Alcantara wrote:

Introduce a new config option CONFIG_EFI_SECURE_BOOT_VAR_DISABLE to
allow disabling EFI secure boot when the platform is operating in User
Mode and there is an NV+BS EFI variable called "SecureBootDisable".
Otherwise, keep it enabled by default.


Hello Paulo,

could you, please, explain why this is needed.

You can simply delete PK if you want to disable secure boot.

Best regards

Heinrich



Signed-off-by: Paulo Alcantara (SUSE) 
---
  lib/efi_loader/Kconfig  | 13 +
  lib/efi_loader/efi_var_common.c | 48 -
  2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 29ea14b2ee2a..d453905c7666 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -224,5 +224,18 @@ config EFI_SECURE_BOOT
  Once SecureBoot mode is enforced, any EFI binary can run only if
  it is signed with a trusted key. To do that, you need to install,
  at least, PK, KEK and db.
+ Note that SecureBoot mode may no longer be enforced when
+ EFI_SECURE_BOOT_VAR_DISABLE option is enabled.
+
+config EFI_SECURE_BOOT_VAR_DISABLE
+   bool "Permit to disable EFI secure boot when in User Mode"
+   depends on EFI_SECURE_BOOT
+   default n
+   help
+ Select this option to allow disabling EFI secure boot when
+ the platform is operating in User Mode (e.g. PK is enrolled)
+ and there is an NV+BS EFI variable called
+ "SecureBootDisable". A platform reset is also required to
+ actually disable it.

  endif
diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c
index 1c7459266a38..89aa944180a4 100644
--- a/lib/efi_loader/efi_var_common.c
+++ b/lib/efi_loader/efi_var_common.c
@@ -241,6 +241,48 @@ err:
return ret;
  }

+
+#ifdef CONFIG_EFI_SECURE_BOOT_VAR_DISABLE
+/**
+ * efi_secure_boot_in_user_mode - check if secure boot enabled in User Mode
+ *
+ * @enabled: true if enabled, false if disabled
+ *
+ * Return: status code
+ */
+static efi_status_t efi_secure_boot_in_user_mode(u8 *enabled)
+{
+   efi_status_t ret;
+   efi_uintn_t size = 0;
+   u32 attributes;
+   u32 mask = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS;
+
+   ret = efi_get_variable_int(L"SecureBootDisable",
+  &efi_global_variable_guid,
+  &attributes, &size, NULL, NULL);
+   if (ret == EFI_BUFFER_TOO_SMALL) {
+   if (attributes ^ mask) {
+   log_err("Unable to disable secure boot. Required attributes 
for SecureBootDisable variable: NV+BS\n");
+   *enabled = 1;
+   } else {
+   EFI_PRINT("Disabling secure boot due to existing 
SecureBootDisable variable\n");
+   *enabled = 0;
+   }
+   ret = EFI_SUCCESS;
+   } else if (ret == EFI_NOT_FOUND) {
+   *enabled = 1;
+   ret = EFI_SUCCESS;
+   }
+   return ret;
+}
+#else
+static efi_status_t efi_secure_boot_in_user_mode(u8 *enabled)
+{
+   *enabled = 1;
+   return EFI_SUCCESS;
+}
+#endif
+
  /**
   * efi_transfer_secure_state - handle a secure boot state transition
   * @mode: new state
@@ -274,7 +316,11 @@ static efi_status_t efi_transfer_secure_state(enum 
efi_secure_mode mode)
if (ret != EFI_SUCCESS)
goto err;
} else if (mode == EFI_MODE_USER) {
-   ret = efi_set_secure_state(1, 0, 0, 0);
+   u8 secure_boot;
+   ret = efi_secure_boot_in_user_mode(&secure_boot);
+   if (ret != EFI_SUCCESS)
+   goto err;
+   ret = efi_set_secure_state(secure_boot, 0, 0, 0);
if (ret != EFI_SUCCESS)
goto err;
} else if (mode == EFI_MODE_SETUP) {





Re: Please pull mmc-2020-11-29

2020-11-30 Thread Tom Rini
On Sun, Nov 29, 2020 at 12:30:50PM +, Peng Fan wrote:

> Hi Tom
> 
> Please pull mmc-2020-11-29
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Pull request for UEFI sub-system for efi-2021-01-rc3 (3)

2020-11-30 Thread Tom Rini
On Sun, Nov 29, 2020 at 10:30:29AM +0100, Heinrich Schuchardt wrote:

> Dear Tom,
> 
> The following changes since commit 7889951d0f56eab746a7c8fde350a022ba0361ca:
> 
>   Merge tag 'u-boot-stm32-20201125' of
> https://gitlab.denx.de/u-boot/custodians/u-boot-stm (2020-11-25 11:00:52
> -0500)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-efi.git
> tags/efi-2021-01-rc3-3
> 
> for you to fetch changes up to 6974a4a37348ba272e53dd33effcc0db9e144c59:
> 
>   charset: make u16_strnlen accessible at runtime (2020-11-29 05:18:37
> +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] tools: add a simple script to generate EFI variables

2020-11-30 Thread Paulo Alcantara
This script generates EFI variables for U-Boot variable store format.

An example of generating secure boot variables

  $ openssl x509 -in foo.crt -outform DER -out foo.der
  $ efisiglist -a -c foo.der -o foo.esl
  $ efivar.py -i ubootefi.var add -n db -d foo.esl -t file
  $ efivar.py -i ubootefi.var add -n kek -d foo.esl -t file
  $ efivar.py -i ubootefi.var add -n pk -d foo.esl -t file

Signed-off-by: Paulo Alcantara (SUSE) 
---
 tools/efivar.py | 141 
 1 file changed, 141 insertions(+)
 create mode 100755 tools/efivar.py

diff --git a/tools/efivar.py b/tools/efivar.py
new file mode 100755
index ..31e5508f08fd
--- /dev/null
+++ b/tools/efivar.py
@@ -0,0 +1,141 @@
+#!/usr/bin/env python3
+## SPDX-License-Identifier: GPL-2.0-only
+#
+# Generate UEFI variables for U-Boot.
+#
+# (c) 2020 Paulo Alcantara 
+#
+
+import os
+import struct
+import uuid
+import time
+import zlib
+import argparse
+import subprocess as sp
+
+# U-Boot variable store format (version 1)
+UBOOT_EFI_VAR_FILE_MAGIC = 0x0161566966456255
+
+# UEFI variable attributes
+EFI_VARIABLE_NON_VOLATILE = 0x1
+EFI_VARIABLE_BOOTSERVICE_ACCESS = 0x2
+EFI_VARIABLE_RUNTIME_ACCESS = 0x4
+EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS = 0x20
+NV_BS = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS
+NV_BS_RT = NV_BS | EFI_VARIABLE_RUNTIME_ACCESS
+NV_BS_RT_AT = NV_BS_RT | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
+
+# UEFI variable GUIDs
+EFI_GLOBAL_VARIABLE_GUID = '{8be4df61-93ca-11d2-aa0d-00e098032b8c}'
+EFI_IMAGE_SECURITY_DATABASE_GUID = '{d719b2cb-3d3a-4596-a3bc-dad00e67656f}'
+
+class EfiStruct:
+# struct efi_var_file
+var_file_fmt = ' 
self.efi.var_file_size:
+with open(self.infile, 'rb') as f:
+# skip header since it will be recreated by save()
+self.buf = f.read()[self.efi.var_file_size:]
+else:
+self.buf = bytearray()
+
+def _set_var(self, guid, name_data, size, attr, tsec):
+ent = struct.pack(self.efi.var_entry_fmt,
+  size,
+  attr,
+  tsec,
+  uuid.UUID(guid).bytes_le)
+ent += name_data
+self.buf += ent
+
+def set_var(self, guid, name, data, size, attr):
+tsec = int(time.time()) if attr & 
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS else 0
+nd = name.encode('utf_16_le') + b"\x00\x00" + data
+# U-Boot variable format requires the name + data blob to be 8-byte 
aligned
+pad = ((len(nd) + 7) & ~7) - len(nd)
+nd += bytes([0] * pad)
+
+return self._set_var(guid, nd, size, attr, tsec)
+
+def save(self):
+hdr = struct.pack(self.efi.var_file_fmt,
+  0,
+  UBOOT_EFI_VAR_FILE_MAGIC,
+  len(self.buf) + self.efi.var_file_size,
+  zlib.crc32(self.buf) & 0x)
+
+with open(self.infile, 'wb') as f:
+f.write(hdr)
+f.write(self.buf)
+
+def parse_attrs(attr):
+attrs = {
+'nv': EFI_VARIABLE_NON_VOLATILE,
+'bs': EFI_VARIABLE_BOOTSERVICE_ACCESS,
+'rt': EFI_VARIABLE_RUNTIME_ACCESS,
+'at': EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS,
+}
+v = 0
+for i in attr.split(','):
+   v |= attrs[i.lower()]
+return v
+
+def parse_data(val, vtype):
+fmt = { 'u8': '

[PATCH] efi_loader: allow disabling EFI secure boot in User Mode

2020-11-30 Thread Paulo Alcantara
Introduce a new config option CONFIG_EFI_SECURE_BOOT_VAR_DISABLE to
allow disabling EFI secure boot when the platform is operating in User
Mode and there is an NV+BS EFI variable called "SecureBootDisable".
Otherwise, keep it enabled by default.

Signed-off-by: Paulo Alcantara (SUSE) 
---
 lib/efi_loader/Kconfig  | 13 +
 lib/efi_loader/efi_var_common.c | 48 -
 2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 29ea14b2ee2a..d453905c7666 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -224,5 +224,18 @@ config EFI_SECURE_BOOT
  Once SecureBoot mode is enforced, any EFI binary can run only if
  it is signed with a trusted key. To do that, you need to install,
  at least, PK, KEK and db.
+ Note that SecureBoot mode may no longer be enforced when
+ EFI_SECURE_BOOT_VAR_DISABLE option is enabled.
+
+config EFI_SECURE_BOOT_VAR_DISABLE
+   bool "Permit to disable EFI secure boot when in User Mode"
+   depends on EFI_SECURE_BOOT
+   default n
+   help
+ Select this option to allow disabling EFI secure boot when
+ the platform is operating in User Mode (e.g. PK is enrolled)
+ and there is an NV+BS EFI variable called
+ "SecureBootDisable". A platform reset is also required to
+ actually disable it.
 
 endif
diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c
index 1c7459266a38..89aa944180a4 100644
--- a/lib/efi_loader/efi_var_common.c
+++ b/lib/efi_loader/efi_var_common.c
@@ -241,6 +241,48 @@ err:
return ret;
 }
 
+
+#ifdef CONFIG_EFI_SECURE_BOOT_VAR_DISABLE
+/**
+ * efi_secure_boot_in_user_mode - check if secure boot enabled in User Mode
+ *
+ * @enabled: true if enabled, false if disabled
+ *
+ * Return: status code
+ */
+static efi_status_t efi_secure_boot_in_user_mode(u8 *enabled)
+{
+   efi_status_t ret;
+   efi_uintn_t size = 0;
+   u32 attributes;
+   u32 mask = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS;
+
+   ret = efi_get_variable_int(L"SecureBootDisable",
+  &efi_global_variable_guid,
+  &attributes, &size, NULL, NULL);
+   if (ret == EFI_BUFFER_TOO_SMALL) {
+   if (attributes ^ mask) {
+   log_err("Unable to disable secure boot. Required 
attributes for SecureBootDisable variable: NV+BS\n");
+   *enabled = 1;
+   } else {
+   EFI_PRINT("Disabling secure boot due to existing 
SecureBootDisable variable\n");
+   *enabled = 0;
+   }
+   ret = EFI_SUCCESS;
+   } else if (ret == EFI_NOT_FOUND) {
+   *enabled = 1;
+   ret = EFI_SUCCESS;
+   }
+   return ret;
+}
+#else
+static efi_status_t efi_secure_boot_in_user_mode(u8 *enabled)
+{
+   *enabled = 1;
+   return EFI_SUCCESS;
+}
+#endif
+
 /**
  * efi_transfer_secure_state - handle a secure boot state transition
  * @mode:  new state
@@ -274,7 +316,11 @@ static efi_status_t efi_transfer_secure_state(enum 
efi_secure_mode mode)
if (ret != EFI_SUCCESS)
goto err;
} else if (mode == EFI_MODE_USER) {
-   ret = efi_set_secure_state(1, 0, 0, 0);
+   u8 secure_boot;
+   ret = efi_secure_boot_in_user_mode(&secure_boot);
+   if (ret != EFI_SUCCESS)
+   goto err;
+   ret = efi_set_secure_state(secure_boot, 0, 0, 0);
if (ret != EFI_SUCCESS)
goto err;
} else if (mode == EFI_MODE_SETUP) {
-- 
2.29.2



Re: [RFC] sunxi phy-mode rgmii-id

2020-11-30 Thread André Przywara
On 29/11/2020 23:07, Heinrich Schuchardt wrote:

Hi,

> since Linux patch
> bbc4d71d6354 ("net: phy: realtek: fix rtl8211e rx/tx delay config")
> i.e. since v5.8.15 or v5.9 many if not all Sunxi A64, H6, H5 boards
> require phy-mode = "rgmii-id" to provide network in Linux
> 
> The U-Boot device-tree is the fallback in the UEFI sub-system if no
> other device-tree is provided. So it would make sense to adjust the
> U-Boot device-trees too.
> 
> The Linux patch has specifically changed the values corresponding to our
> U-Boot defines:
> 
> #define MIIM_RTL8211E_CONFREG_TXD   0x0002
> #define MIIM_RTL8211E_CONFREG_RXD   0x0004
> 
> At least my experience with the NanoPi Neo 2 and the Pine64 A64 LTS
> indicates that setting phy-mode = "rgmii-id" in the device-tree does not
> stop the operation of the network even if the driver is not adjusted.

That is not entirely true, it depends on a patch to not reject other
phy-modes in the Linux driver (f1239d8aa84d).
This entered with v5.5, I believe, and was backported to stable kernels
since, but is not universally available in older kernels. Especially
installers comes to mind ...

But first we need at least the equivalent patch for U-Boot, as I posted
here:
https://lists.denx.de/pipermail/u-boot/2020-November/432823.html

> To avoid breaking boards like Linux did we should change the
> device-trees before or in sync with drivers/net/phy/realtek.c.

Eventually: yes, but at the cost of breaking older kernels. This is
really an unfortunate situation, and actually should not have happened:
normally we at least guarantee operation of newer kernels with older DTs.

Cheers,
Andre



Re: [PATCH 2/3] TI QSPI: add support for dual and quad-bit I/O read

2020-11-30 Thread Pratyush Yadav
Hi Jean,

Quick disclaimer: I am not familiar with the IP or the driver so I just 
gave this patch a brief read and did not dig into it a lot. This is in 
no way a comprehensive review.

On 29/11/20 11:39AM, Jean Pihet wrote:
> TI QSPI: the TI QSPI IP has a limitation of 64MB of MMIO so use
> the MMIO mode to read below 64MB and fallback to the SW generated
> sequences to read above 64MB.
> The TI QSPI IP has another limitation of 4096 words per frame,
> so split the accesses into smaller ones.

Please split this change...

> Also fix the TI QSPI operating frequency in order to correctly
> generate the required SPI CLK frequency.

... and this one into a separate patch. If they cause any bugs or 
regressions it would be easier to bisect and revert.

> 
> Signed-off-by: Jean Pihet 
> ---
>  drivers/spi/Kconfig   |  9 ++
>  drivers/spi/ti_qspi.c | 68 ---
>  2 files changed, 66 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
> index f7a9852565..5d24029ff0 100644
> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -395,10 +395,19 @@ config TEGRA210_QSPI
>  config TI_QSPI
>   bool "TI QSPI driver"
>   imply TI_EDMA3
> + imply TI_QSPI_MQX_FRAME_SIZE
Typo?  ^

>   help
> Enable the TI Quad-SPI (QSPI) driver for DRA7xx and AM43xx evms.
> This driver support spi flash single, quad and memory reads.
>  
> +config TI_QSPI_MAX_FRAME_SIZE
> + int "TI QSPI max frame size"
> + default 4096
> + help
> +   TI Quad-SPI (QSPI) IP block has a maximum number of 4096 words in a
> +   frame, in non-memory mapped mode. A frame includes the command,
> +   arguments and dummy bytes.

Can the frame size change between IP versions/implementations? If it can 
not then I don't see a need for defining a config here. Just use 4096 
directly in the driver.

> +
>  config UNIPHIER_SPI
>   bool "Socionext UniPhier SPI driver"
>   depends on ARCH_UNIPHIER
> diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c
> index 5fdbb49442..57192b9c0a 100644
> --- a/drivers/spi/ti_qspi.c
> +++ b/drivers/spi/ti_qspi.c
> @@ -29,7 +29,7 @@ DECLARE_GLOBAL_DATA_PTR;
>  
>  /* ti qpsi register bit masks */
>  #define QSPI_TIMEOUT200
> -#define QSPI_FCLK19200
> +#define QSPI_FCLK   4800

This is fishy. Different platforms can have different FCLK values. 
Looking at ti_qspi_ids[], it looks like am4372 uses 192 MHz and dra7xxx 
uses 76.8 MHz. Changing QSPI_FCLK like this might break am4372.

Do what dra7xx does and add an entry for your platform in the ids table 
and set .data to the FCLK value for your platform.

>  #define QSPI_DRA7XX_FCLK7680
>  #define QSPI_WLEN_MAX_BITS   128
>  #define QSPI_WLEN_MAX_BYTES  (QSPI_WLEN_MAX_BITS >> 3)
> @@ -41,10 +41,11 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define QSPI_EN_CS(n)   (n << 28)
>  #define QSPI_WLEN(n)((n-1) << 19)
>  #define QSPI_3_PIN  BIT(18)
> -#define QSPI_RD_SNGLBIT(16)
> +#define QSPI_RD_SNGL(1 << 16)
> +#define QSPI_RD_DUAL(3 << 16)
> +#define QSPI_RD_QUAD(7 << 16)
>  #define QSPI_WR_SNGL(2 << 16)
>  #define QSPI_INVAL  (4 << 16)
> -#define QSPI_RD_QUAD(7 << 16)
>  /* device control */
>  #define QSPI_CKPHA(n)   (1 << (2 + n*8))
>  #define QSPI_CSPOL(n)   (1 << (1 + n*8))
> @@ -155,6 +156,7 @@ static int ti_qspi_xfer(struct udevice *dev, unsigned int 
> bitlen,
>   const void *dout, void *din, unsigned long flags)
>  {
>   struct dm_spi_slave_platdata *slave = dev_get_parent_platdata(dev);
> + struct spi_slave *spi_slave = dev_get_parent_priv(dev);
>   struct ti_qspi_priv *priv;
>   struct udevice *bus;
>   uint words = bitlen >> 3; /* fixed 8-bit word length */
> @@ -182,7 +184,6 @@ static int ti_qspi_xfer(struct udevice *dev, unsigned int 
> bitlen,
>  
>   /* Setup command reg */
>   priv->cmd = 0;
> - priv->cmd |= QSPI_WLEN(8);
>   priv->cmd |= QSPI_EN_CS(cs);
>   if (priv->mode & SPI_3WIRE)
>   priv->cmd |= QSPI_3_PIN;
> @@ -206,15 +207,16 @@ static int ti_qspi_xfer(struct udevice *dev, unsigned 
> int bitlen,
>   writel(data, &priv->base->data1);
>   data = cpu_to_be32(*txbuf++);
>   writel(data, &priv->base->data);
> - cmd &= ~QSPI_WLEN_MASK;
>   cmd |= QSPI_WLEN(QSPI_WLEN_MAX_BITS);
>   xfer_len = QSPI_WLEN_MAX_BYTES;
>   } else {
>   writeb(*txp, &priv->base->data);
> + cmd |= QSPI_WLEN

Re: [PATCH 1/3] mtd: spi nor: add support for dual and quad bit transfers

2020-11-30 Thread Pratyush Yadav
Hi Jean,

On 29/11/20 11:39AM, Jean Pihet wrote:
> Use the flags field of the SPI slave struct to pass the dual and quad
> read properties, from the SPI NOR layer to the low level driver.
> Tested with TI QSPI in 1, 2 and 4 bits modes.
> 
> Signed-off-by: Jean Pihet 
> ---
>  drivers/mtd/spi/spi-nor-core.c | 34 +++---
>  drivers/spi/spi-mem.c  |  8 +++-
>  include/spi.h  |  2 ++
>  3 files changed, 40 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
> index e16b0e1462..54569b3cba 100644
> --- a/drivers/mtd/spi/spi-nor-core.c
> +++ b/drivers/mtd/spi/spi-nor-core.c
> @@ -94,22 +94,50 @@ static ssize_t spi_nor_read_data(struct spi_nor *nor, 
> loff_t from, size_t len,
>   /* convert the dummy cycles to the number of bytes */
>   op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) / 8;
>  
> + /* Check for dual and quad I/O read */
> + switch (op.cmd.opcode) {
> + case SPINOR_OP_READ_1_1_2:
> + case SPINOR_OP_READ_1_2_2:
> + case SPINOR_OP_READ_1_1_2_4B:
> + case SPINOR_OP_READ_1_2_2_4B:
> + case SPINOR_OP_READ_1_2_2_DTR:
> + case SPINOR_OP_READ_1_2_2_DTR_4B:
> + nor->spi->flags |= SPI_XFER_DUAL_READ;
> + break;
> + case SPINOR_OP_READ_1_1_4:
> + case SPINOR_OP_READ_1_4_4:
> + case SPINOR_OP_READ_1_1_4_4B:
> + case SPINOR_OP_READ_1_4_4_4B:
> + case SPINOR_OP_READ_1_4_4_DTR:
> + case SPINOR_OP_READ_1_4_4_DTR_4B:
> + nor->spi->flags |= SPI_XFER_QUAD_READ;
> + break;
> + default:
> + break;
> + }
> +

NACK. What if a flash uses some other opcode for dual or quad reads?

Why not use op->data.buswidth in ti_qspi_exec_mem_op() to enable dual or 
quad mode? In fact, ti_qspi_setup_mmap_read() already checks this and 
enables dual or quad mode. What problem does this patch solve then?

>   while (remaining) {
>   op.data.nbytes = remaining < UINT_MAX ? remaining : UINT_MAX;
>   ret = spi_mem_adjust_op_size(nor->spi, &op);
>   if (ret)
> - return ret;
> + goto out;
>  
>   ret = spi_mem_exec_op(nor->spi, &op);
>   if (ret)
> - return ret;
> + goto out;
>  
>   op.addr.val += op.data.nbytes;
>   remaining -= op.data.nbytes;
>   op.data.buf.in += op.data.nbytes;
>   }
>  
> - return len;
> + ret = len;
> +
> +out:
> + /* Reset dual and quad I/O read flags for upcoming transactions */
> + nor->spi->flags &= ~(SPI_XFER_DUAL_READ | SPI_XFER_QUAD_READ);
> +
> + return ret;
>  }
>  
>  static ssize_t spi_nor_write_data(struct spi_nor *nor, loff_t to, size_t len,
> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> index c095ae9505..24e38ea95e 100644
> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -387,9 +387,15 @@ int spi_mem_exec_op(struct spi_slave *slave, const 
> struct spi_mem_op *op)
>   return ret;
>  
>   /* 2nd transfer: rx or tx data path */
> + flag = SPI_XFER_END;
> + /* Check for dual and quad I/O reads */
> + if (slave->flags & SPI_XFER_DUAL_READ)
> + flag |= SPI_XFER_DUAL_READ;
> + if (slave->flags & SPI_XFER_QUAD_READ)
> + flag |= SPI_XFER_QUAD_READ;

Ah, so you are targeting the "legacy" path. Seeing that ti_qspi does 
support the SPI MEM path, this would be executed when the read exceeds 
priv->mmap_size, correct?

In any case, I don't see why you need slave->flags. Why can't you set 
these flags by checking op->data.buswidth and op->data.dir? This would 
make your fix transparent to SPI NOR, which IMO is a much better idea.

>   if (tx_buf || rx_buf) {
>   ret = spi_xfer(slave, op->data.nbytes * 8, tx_buf,
> -rx_buf, SPI_XFER_END);
> +rx_buf, flag);
>   if (ret)
>   return ret;
>   }
> diff --git a/include/spi.h b/include/spi.h
> index ef8c1f6692..cf5f05e526 100644
> --- a/include/spi.h
> +++ b/include/spi.h
> @@ -146,6 +146,8 @@ struct spi_slave {
>  #define SPI_XFER_BEGIN   BIT(0)  /* Assert CS before transfer */
>  #define SPI_XFER_END BIT(1)  /* Deassert CS after transfer */
>  #define SPI_XFER_ONCE(SPI_XFER_BEGIN | SPI_XFER_END)
> +#define SPI_XFER_DUAL_READ   BIT(2)  /* Dual I/O read */
> +#define SPI_XFER_QUAD_READ   BIT(3)  /* Quad I/O read */
>  };
>  
>  /**
> -- 
> 2.26.2
> 

-- 
Regards,
Pratyush Yadav
Texas Instruments India


[PATCH 5/5 v3] mips: octeon: tools: Add update_octeon_header tool

2020-11-30 Thread Stefan Roese
Add a tool to update or insert an Octeon specific header into the U-Boot
image. This is needed e.g. for booting via SPI NOR, eMMC and NAND.

While working on this, move enum cvmx_board_types_enum and
cvmx_board_type_to_string() to cvmx-bootloader.h and remove the
unreferenced (unsupported) board definition.

Signed-off-by: Stefan Roese 
Cc: Aaron Williams 
Cc: Chandrakala Chavva 
Cc: Daniel Schwierzeck 
---
v3:
- Add .gitignore entry
- Use compiletime_assert() instead of adhoc-coded compile_time_assert()
- Dropped forward declarations
- All functions now static
- Used prinf instead of debug in most places to make the output
  more verbose and descriptive
- Used "fprintf(stderr" for error messages
- Dropped cvmx_cpu_to_be64
- Removed crashes as suggested by Daniel

v2:
- No change
- Azure build success here:
  https://dev.azure.com/sr0718/u-boot/_build/results?buildId=59&view=results

 .../mach-octeon/include/mach/cvmx-bootinfo.h  | 222 -
 .../include/mach/cvmx-bootloader.h| 172 +++
 tools/.gitignore  |   1 +
 tools/Makefile|   3 +
 tools/update_octeon_header.c  | 456 ++
 5 files changed, 632 insertions(+), 222 deletions(-)
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-bootloader.h
 create mode 100644 tools/update_octeon_header.c

diff --git a/arch/mips/mach-octeon/include/mach/cvmx-bootinfo.h 
b/arch/mips/mach-octeon/include/mach/cvmx-bootinfo.h
index 337987178f..97438ff787 100644
--- a/arch/mips/mach-octeon/include/mach/cvmx-bootinfo.h
+++ b/arch/mips/mach-octeon/include/mach/cvmx-bootinfo.h
@@ -125,226 +125,4 @@ struct cvmx_bootinfo {
 
 #endif /*   (CVMX_BOOTINFO_MAJ_VER == 1) */
 
-/* Type defines for board and chip types */
-enum cvmx_board_types_enum {
-   CVMX_BOARD_TYPE_NULL = 0,
-   CVMX_BOARD_TYPE_SIM = 1,
-   CVMX_BOARD_TYPE_EBT3000 = 2,
-   CVMX_BOARD_TYPE_KODAMA = 3,
-   CVMX_BOARD_TYPE_NIAGARA = 4,
-   CVMX_BOARD_TYPE_NAC38 = 5,  /* formerly NAO38 */
-   CVMX_BOARD_TYPE_THUNDER = 6,
-   CVMX_BOARD_TYPE_TRANTOR = 7,
-   CVMX_BOARD_TYPE_EBH3000 = 8,
-   CVMX_BOARD_TYPE_EBH3100 = 9,
-   CVMX_BOARD_TYPE_HIKARI = 10,
-   CVMX_BOARD_TYPE_CN3010_EVB_HS5 = 11,
-   CVMX_BOARD_TYPE_CN3005_EVB_HS5 = 12,
-   CVMX_BOARD_TYPE_KBP = 13,
-   /* Deprecated, CVMX_BOARD_TYPE_CN3010_EVB_HS5 supports the CN3020 */
-   CVMX_BOARD_TYPE_CN3020_EVB_HS5 = 14,
-   CVMX_BOARD_TYPE_EBT5800 = 15,
-   CVMX_BOARD_TYPE_NICPRO2 = 16,
-   CVMX_BOARD_TYPE_EBH5600 = 17,
-   CVMX_BOARD_TYPE_EBH5601 = 18,
-   CVMX_BOARD_TYPE_EBH5200 = 19,
-   CVMX_BOARD_TYPE_BBGW_REF = 20,
-   CVMX_BOARD_TYPE_NIC_XLE_4G = 21,
-   CVMX_BOARD_TYPE_EBT5600 = 22,
-   CVMX_BOARD_TYPE_EBH5201 = 23,
-   CVMX_BOARD_TYPE_EBT5200 = 24,
-   CVMX_BOARD_TYPE_CB5600  = 25,
-   CVMX_BOARD_TYPE_CB5601  = 26,
-   CVMX_BOARD_TYPE_CB5200  = 27,
-   /* Special 'generic' board type, supports many boards */
-   CVMX_BOARD_TYPE_GENERIC = 28,
-   CVMX_BOARD_TYPE_EBH5610 = 29,
-   CVMX_BOARD_TYPE_LANAI2_A = 30,
-   CVMX_BOARD_TYPE_LANAI2_U = 31,
-   CVMX_BOARD_TYPE_EBB5600 = 32,
-   CVMX_BOARD_TYPE_EBB6300 = 33,
-   CVMX_BOARD_TYPE_NIC_XLE_10G = 34,
-   CVMX_BOARD_TYPE_LANAI2_G = 35,
-   CVMX_BOARD_TYPE_EBT5810 = 36,
-   CVMX_BOARD_TYPE_NIC10E = 37,
-   CVMX_BOARD_TYPE_EP6300C = 38,
-   CVMX_BOARD_TYPE_EBB6800 = 39,
-   CVMX_BOARD_TYPE_NIC4E = 40,
-   CVMX_BOARD_TYPE_NIC2E = 41,
-   CVMX_BOARD_TYPE_EBB6600 = 42,
-   CVMX_BOARD_TYPE_REDWING = 43,
-   CVMX_BOARD_TYPE_NIC68_4 = 44,
-   CVMX_BOARD_TYPE_NIC10E_66 = 45,
-   CVMX_BOARD_TYPE_MAX,
-
-   /*
-* The range from CVMX_BOARD_TYPE_MAX to
-* CVMX_BOARD_TYPE_CUST_DEFINED_MIN is reserved for future
-* SDK use.
-*/
-
-   /*
-* Set aside a range for customer boards.  These numbers are managed
-* by Cavium.
-*/
-   CVMX_BOARD_TYPE_CUST_DEFINED_MIN = 1,
-   CVMX_BOARD_TYPE_CUST_WSX16 = 10001,
-   CVMX_BOARD_TYPE_CUST_NS0216 = 10002,
-   CVMX_BOARD_TYPE_CUST_NB5 = 10003,
-   CVMX_BOARD_TYPE_CUST_WMR500 = 10004,
-   CVMX_BOARD_TYPE_CUST_ITB101 = 10005,
-   CVMX_BOARD_TYPE_CUST_NTE102 = 10006,
-   CVMX_BOARD_TYPE_CUST_AGS103 = 10007,
-   CVMX_BOARD_TYPE_CUST_GST104 = 10008,
-   CVMX_BOARD_TYPE_CUST_GCT105 = 10009,
-   CVMX_BOARD_TYPE_CUST_AGS106 = 10010,
-   CVMX_BOARD_TYPE_CUST_SGM107 = 10011,
-   CVMX_BOARD_TYPE_CUST_GCT108 = 10012,
-   CVMX_BOARD_TYPE_CUST_AGS109 = 10013,
-   CVMX_BOARD_TYPE_CUST_GCT110 = 10014,
-   CVMX_BOARD_TYPE_CUST_L2_AIR_SENDER = 10015,
-   CVMX_BOARD_TYPE_CUST_L2_AIR_RECEIVER = 10016,
-   CVMX_BOARD_TYPE_CUST_L2_ACCTON2_TX = 10017,
-   CVMX_BOARD_TYPE_CUST_L2_ACCTON2_RX = 10018,
-   CVMX_BOARD_TYPE_CUST_L2_WSTRNSNIC_TX = 10019,
-   

[PATCH] tools: env: return error if ubi_update_start() fails

2020-11-30 Thread Martin Hundebøll
The UBI_IOCVOLUP ioctl can fail if exclusive access to the volume isn't
obtained. If this happens, the flush operation doesn't return error,
leaving the caller without knowledge of missing flush.

Fix this by forwarding the error (-1) from ubi_update_start().

Fixes: 34255b92e6e ("tools: env: Add support for direct read/write UBI volumes")
Signed-off-by: Martin Hundebøll 
---
 tools/env/fw_env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 66cb9d2a25..2a61a5d6f0 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1208,7 +1208,7 @@ static int flash_write(int fd_current, int fd_target, int 
dev_target)
 
if (IS_UBI(dev_target)) {
if (ubi_update_start(fd_target, CUR_ENVSIZE) < 0)
-   return 0;
+   return -1;
return ubi_write(fd_target, environment.image, CUR_ENVSIZE);
}
 
-- 
2.28.0



Re: [PATCH 5/5 v2] mips: octeon: tools: Add update_octeon_header tool

2020-11-30 Thread Stefan Roese

Hi Daniel,

On 27.11.20 20:01, Daniel Schwierzeck wrote:

Am Mittwoch, den 28.10.2020, 15:10 +0100 schrieb Stefan Roese:

Add a tool to update or insert an Octeon specific header into the U-Boot
image. This is needed e.g. for booting via SPI NOR, eMMC and NAND.

While working on this, move enum cvmx_board_types_enum and
cvmx_board_type_to_string() to cvmx-bootloader.h and remove the
unreferenced (unsupported) board definition.

Signed-off-by: Stefan Roese 
Cc: Aaron Williams 
Cc: Chandrakala Chavva 
Cc: Daniel Schwierzeck 
---
v2:
- No change
- Azure build success here:
   https://dev.azure.com/sr0718/u-boot/_build/results?buildId=59&view=results

  .../mach-octeon/include/mach/cvmx-bootinfo.h  | 222 -
  .../include/mach/cvmx-bootloader.h| 172 +++
  tools/Makefile|   3 +
  tools/update_octeon_header.c  | 450 ++
  4 files changed, 625 insertions(+), 222 deletions(-)
  create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-bootloader.h
  create mode 100644 tools/update_octeon_header.c


...


diff --git a/tools/Makefile b/tools/Makefile
index 51123fd929..253a6b9706 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -206,6 +206,9 @@ hostprogs-y += proftool
  hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela
  hostprogs-$(CONFIG_RISCV) += prelink-riscv
  
+hostprogs-$(CONFIG_ARCH_OCTEON) += update_octeon_header

+update_octeon_header-objs := update_octeon_header.o lib/crc32.o


entry in tools/.gitignore is missing


+
  hostprogs-y += fdtgrep
  fdtgrep-objs += $(LIBFDT_OBJS) common/fdt_region.o fdtgrep.o
  
diff --git a/tools/update_octeon_header.c b/tools/update_octeon_header.c

new file mode 100644
index 00..964036216d
--- /dev/null
+++ b/tools/update_octeon_header.c
@@ -0,0 +1,450 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Marvell International Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "mkimage.h"
+
+#include "../arch/mips/mach-octeon/include/mach/cvmx-bootloader.h"
+
+void usage(void);


this needs some code cleanup:
- drop the forward declarations and reorder the functions when
necessary
- make all functions static
- drop dead code
- drop debug() macros convert the useful ones to printf
- maybe use fprintf(STDERR, ...) for error messages

there are also some bugs:
- tool crashes with segfault when called without arguments
- tool crashes when called with a long option but no value
- the bugs above will also be detected by clang-tidy, suggestions for
fixing below


Many thanks for the extensive code review. I'll try to address all
comments shortly.

Thanks,
Stefan


+
+/*
+ * Do some funky stuff here to get a compile time error if the size of the
+ * bootloader_header structure has changed.
+ */
+#define compile_time_assert(cond, msg) char msg[(cond) ? 1 : -1]
+compile_time_assert(sizeof(struct bootloader_header) == 192,
+   bootloader_header_size_changed);


there is BUILD_BUG_ON_MSG() in linux/build_bug.h
or compiletime_assert() in linux/compiler.h


+
+#define BUF_SIZE   (16 * 1024)
+#define NAME_LEN   100
+
+#ifndef WOFFSETOF
+/* word offset */
+#define WOFFSETOF(type, elem)  (offsetof(type, elem) / 4)
+#endif
+
+#define cvmx_cpu_to_be64(x)(x)
+
+static int stage2_flag;
+static int stage_1_5_flag;
+static int stage_1_flag;
+
+int lookup_board_type(char *board_name)
+{
+   int i;
+   int board_type = 0;
+   char *substr = NULL;
+
+   /* Detect stage 2 bootloader boards */
+   if (strcasestr(board_name, "_stage2")) {
+   debug("Stage 2 bootloader detected from substring %s in name 
%s\n",
+ "_stage2", board_name);
+   stage2_flag = 1;
+   } else {
+   debug("Stage 2 bootloader NOT detected from name \"%s\"\n",
+ board_name);
+   }
+
+   if (strcasestr(board_name, "_stage1")) {
+   debug("Stage 1 bootloader detected from substring %s in name 
%s\n",
+ "_stage1", board_name);
+   stage_1_flag = 1;
+   }
+
+   /* Generic is a special case since there are numerous sub-types */
+   if (!strncasecmp("generic", board_name, strlen("generic")))
+   return CVMX_BOARD_TYPE_GENERIC;
+
+   /*
+* If we're an eMMC stage 2 bootloader, cut off the _emmc_stage2
+* part of the name.
+*/
+   substr = strcasestr(board_name, "_emmc_stage2");
+   if (substr && (substr[strlen("_emmc_stage2")] == '\0')) {
+   /*return CVMX_BOARD_TYPE_GENERIC;*/
+
+   printf("  Converting board name %s to ", board_name);
+   *substr = '\0';
+   printf("%s\n", board_name);
+   }
+
+   /*
+* If we're a NAND stage 2 bootloader, cut off the _nand_stage2
+* part of the name.
+*/
+   substr = strcas

[PATCH 2/3 v2] efi_loader: Introduce eventlog support for TCG2_PROTOCOL

2020-11-30 Thread Ilias Apalodimas
In the previous patches we only introduced a minimal subset of the
EFI_TCG2_PROTOCOL protocol implementing GetCapability().
So let's continue adding features to it, introducing the
GetEventLog() and HashLogExtendEvent() functions.

In order to do that we first need to construct the eventlog in memory,
specifically in EFI_BOOT_SERVICES_DATA memory and a configuration table
from EFI_ACPI_MEMORY_NVS.
U-Boot won't currently add any events to the log or measure any
components, but will expose the necessary EFI APIs for applications
to do so.

Signed-off-by: Ilias Apalodimas 
---
 include/efi_api.h  |   4 +
 include/efi_tcg2.h |  71 -
 lib/efi_loader/Kconfig |   9 +
 lib/efi_loader/efi_setup.c |  12 +-
 lib/efi_loader/efi_tcg2.c  | 553 +++--
 5 files changed, 625 insertions(+), 24 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index 5744f6aed86d..364c578a3b1b 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -356,6 +356,10 @@ struct efi_runtime_services {
EFI_GUID(0x4006c0c1, 0xfcb3, 0x403e, \
 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d)
 
+#define EFI_TCG2_FINAL_EVENTS_TABLE_GUID \
+   EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, \
+0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25)
+
 struct efi_configuration_table {
efi_guid_t guid;
void *table;
diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h
index 86b8fe4c01af..40e241ce315c 100644
--- a/include/efi_tcg2.h
+++ b/include/efi_tcg2.h
@@ -17,6 +17,8 @@
 
 /* TPMV2 only */
 #define TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
+#define EFI_TCG2_EXTEND_ONLY 0x0001
+#define PE_COFF_IMAGE 0x0010
 
 /* Algorithm Registry */
 #define EFI_TCG2_BOOT_HASH_ALG_SHA10x0001
@@ -25,6 +27,10 @@
 #define EFI_TCG2_BOOT_HASH_ALG_SHA512  0x0008
 #define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x0010
 
+#define EFI_TCG2_FINAL_EVENTS_TABLE_VERSION 1
+
+#define TPM2_EVENT_LOG_SIZE CONFIG_EFI_TCG2_PROTOCOL_EVENTLOG_SIZE
+
 typedef u32 efi_tcg_event_log_bitmap;
 typedef u32 efi_tcg_event_log_format;
 typedef u32 efi_tcg_event_algorithm_bitmap;
@@ -65,6 +71,68 @@ struct efi_tcg2_boot_service_capability {
sizeof(struct efi_tcg2_boot_service_capability) - \
offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks)
 
+#define TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03 "Spec ID Event03"
+#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2 2
+#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2 0
+#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2
+
+/**
+ *  struct TCG_EfiSpecIdEventAlgorithmSize
+ *
+ *  @algorithm_id: algorithm defined in enum tpm2_algorithms
+ *  @digest_size:  size of the algorithm
+ */
+struct tcg_efi_spec_id_event_algorithm_size {
+   u16  algorithm_id;
+   u16  digest_size;
+} __packed;
+
+/**
+ * struct TCG_EfiSpecIDEventStruct
+ *
+ * @signature: signature, set to Spec ID Event03
+ * @platform_class:class defined in TCG ACPI Specification
+ * Client  Common Header.
+ * @spec_version_minor:minor version
+ * @spec_version_major:major version
+ * @spec_version_errata:   major version
+ * @uintn_size:size of the efi_uintn_t fields used in 
various
+ * data structures used in this specification.
+ * 0x01 indicates u32  and 0x02  indicates u64
+ * @number_of_algorithms:  hashing algorithms used in this event log
+ * @digest_sizes:  array of number_of_algorithms pairs
+ * 1st member defines the algorithm id
+ * 2nd member defines the algorithm size
+ * @vendor_info_size:  size in bytes for vendor specific info
+ * @vendor_info:   vendor specific info
+ */
+struct tcg_efi_spec_id_event {
+   u8 signature[16];
+   u32 platform_class;
+   u8 spec_version_minor;
+   u8 spec_version_major;
+   u8 spec_errata;
+   u8 uintn_size;
+   u32 number_of_algorithms;
+   struct tcg_efi_spec_id_event_algorithm_size 
digest_sizes[TPM2_NUM_PCR_BANKS];
+   u8 vendor_info_size;
+   /* U-Boot does not provide any vendor info */
+   u8 vendor_info[];
+} __packed;
+
+/**
+ * struct tdEFI_TCG2_FINAL_EVENTS_TABLE
+ * @version:   version number for this structure
+ * @number_of_events:  number of events recorded after invocation of
+ * GetEventLog()
+ * @event: List of events of type tcg_pcr_event2
+ */
+struct efi_tcg2_final_events_table {
+   u64 version;
+   u64 number_of_events;
+   struct tcg_pcr_event2 event[];
+};
+
 struct efi_tcg2_protocol {
efi_status_t (EFIAPI * get_capability)(struct efi_tcg2_protocol *this,
   struct 
efi_tcg2_boot_service_capability *capability);
@@ 

[PATCH 3/3 v2] cmd: efidebug: Add support for TCG2 final events table

2020-11-30 Thread Ilias Apalodimas
A previous commit is adding EFI_TCG2_PROTOCOL, which in it's eventlog
support registers an EFI configuration table.
Let's add the necessary GUID so 'efidebug table' command can display
table names properly.

Signed-off-by: Ilias Apalodimas 
---
 cmd/efidebug.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 5288b9920b4d..70bb73ba025f 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -278,6 +278,10 @@ static const struct {
"Runtime properties",
EFI_RT_PROPERTIES_TABLE_GUID,
},
+   {
+   "TCG2 Final Events Table",
+   EFI_TCG2_FINAL_EVENTS_TABLE_GUID,
+   },
 };
 
 /**
-- 
2.29.2



[PATCH 1/3 v2] tpm: Add tpm2 headers for TCG2 eventlog support

2020-11-30 Thread Ilias Apalodimas
A following patch introduces support for the EFI_TCG2_PROTOCOL
eventlog management.
Introduce the necessary tpm related headers

Signed-off-by: Ilias Apalodimas 
---
 include/tpm-v2.h | 82 
 1 file changed, 82 insertions(+)

diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index f1826ff38589..fab6b86ca2fa 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -18,6 +18,12 @@
 
 #define TPM2_DIGEST_LEN32
 
+#define TPM2_SHA1_DIGEST_SIZE 20
+#define TPM2_SHA256_DIGEST_SIZE32
+#define TPM2_SHA384_DIGEST_SIZE48
+#define TPM2_SHA512_DIGEST_SIZE64
+#define TPM2_SM3_256_DIGEST_SIZE 32
+
 #define TPM2_MAX_PCRS 32
 #define TPM2_PCR_SELECT_MAX ((TPM2_MAX_PCRS + 7) / 8)
 #define TPM2_MAX_CAP_BUFFER 1024
@@ -45,6 +51,15 @@
 #define TPM2_PT_MAX_COMMAND_SIZE   (u32)(TPM2_PT_FIXED + 30)
 #define TPM2_PT_MAX_RESPONSE_SIZE  (u32)(TPM2_PT_FIXED + 31)
 
+/* event types */
+#define EV_POST_CODE   ((u32)0x0001)
+#define EV_NO_ACTION   ((u32)0x0003)
+#define EV_SEPARATOR   ((u32)0x0004)
+#define EV_S_CRTM_CONTENTS ((u32)0x0007)
+#define EV_S_CRTM_VERSION  ((u32)0x0008)
+#define EV_CPU_MICROCODE   ((u32)0x0009)
+#define EV_TABLE_OF_DEVICES((u32)0x000B)
+
 /* TPMS_TAGGED_PROPERTY Structure */
 struct tpms_tagged_property {
u32 property;
@@ -86,6 +101,73 @@ struct tpms_capability_data {
union tpmu_capabilities data;
 } __packed;
 
+/**
+ * SHA1 Event Log Entry Format
+ *
+ * @pcr_index: PCRIndex event extended to
+ * @event_type:Type of event (see EFI specs)
+ * @digest:Value extended into PCR index
+ * @event_size:Size of event
+ * @event: Event data
+ */
+struct tcg_pcr_event {
+   u32 pcr_index;
+   u32 event_type;
+   u8 digest[TPM2_SHA1_DIGEST_SIZE];
+   u32 event_size;
+   u8 event[];
+} __packed;
+
+/**
+ * Definition of TPMU_HA Union
+ */
+union tmpu_ha {
+   u8 sha1[TPM2_SHA1_DIGEST_SIZE];
+   u8 sha256[TPM2_SHA256_DIGEST_SIZE];
+   u8 sm3_256[TPM2_SM3_256_DIGEST_SIZE];
+   u8 sha384[TPM2_SHA384_DIGEST_SIZE];
+   u8 sha512[TPM2_SHA512_DIGEST_SIZE];
+} __packed;
+
+/**
+ * Definition of TPMT_HA Structure
+ *
+ * @hash_alg:  Hash algorithm defined in enum tpm2_algorithms
+ * @digest:Digest value for a given algorithm
+ */
+struct tpmt_ha {
+   u16 hash_alg;
+   union tmpu_ha digest;
+} __packed;
+
+/**
+ * Definition of TPML_DIGEST_VALUES Structure
+ *
+ * @count: Number of algorithms supported by hardware
+ * @digests:   struct for algorithm id and hash value
+ */
+struct tpml_digest_values {
+   u32 count;
+   struct tpmt_ha digests[TPM2_NUM_PCR_BANKS];
+} __packed;
+
+/**
+ * Crypto Agile Log Entry Format
+ *
+ * @pcr_index: PCRIndex event extended to
+ * @event_type:Type of event
+ * @digests:   List of digestsextended to PCR index
+ * @event_size: Size of the event data
+ * @event: Event data
+ */
+struct tcg_pcr_event2 {
+   u32 pcr_index;
+   u32 event_type;
+   struct tpml_digest_values digests;
+   u32 event_size;
+   u8 event[];
+} __packed;
+
 /**
  * TPM2 Structure Tags for command/response buffers.
  *
-- 
2.29.2



[PATCH 0/3 v2] extend EFI_TCG2_PROTOCOL support

2020-11-30 Thread Ilias Apalodimas
Hi!

This is v2 of [1].
The issues regarding comments have been addressed and all of the 
newly added structures now have Sphinx style comments.

Changes since v1:
- Eventlog size is now a Kconfig instead of a #define. The default
  size has been kept to 4096b
- Replaced struct tpm_digest with u8 digest[TPM2_SHA1_DIGEST_SIZE].
  This is effectively the same thing, but closer to what the spec defines
- Add Sphinx style comments on new structs
- Remove _put_unaligned_le usage from u8 values
- Remove definitions of algorithms that were duplicated by mistake in 
  efi_tcg.h

[1] https://lists.denx.de/pipermail/u-boot/2020-November/433629.html

Ilias Apalodimas (3):
  tpm: Add tpm2 headers for TCG2 eventlog support
  efi_loader: Introduce eventlog support for TCG2_PROTOCOL
  cmd: efidebug: Add support for TCG2 final events table

 cmd/efidebug.c |   4 +
 include/efi_api.h  |   4 +
 include/efi_tcg2.h |  71 -
 include/tpm-v2.h   |  82 ++
 lib/efi_loader/Kconfig |   9 +
 lib/efi_loader/efi_setup.c |  12 +-
 lib/efi_loader/efi_tcg2.c  | 553 +++--
 7 files changed, 711 insertions(+), 24 deletions(-)

-- 
2.29.2



RE: [PATCH] riscv: timer: Add support for an early timer

2020-11-30 Thread Pragnesh Patel
Hi Rick,
[]
>> >After add CONFIG_TIMER_EARLY, U-Boot boots ok.
>> >But When I try to booting kernel with FTRACE=1, following are the test 
>> >stats:
>> >
>> >ae350_rv64_spl_defconfig without FTRACE=1, kernel booting is ok.
>> >ae350_rv64_spl_defconfig with FTRACE=1, kernel booting fail.
>> >ae350_rv64_defconfig with FTRACE=1, kernel booting is ok
>> >
>> >The failure case seems not reasonable.
>> >Any suggestions ?

Can you please enable debug logs by adding below in ae350_rv64_spl_defconfig ?

CONFIG_LOG=y
CONFIG_LOG_MAX_LEVEL=9
CONFIG_LOG_DEFAULT_LEVEL=9
CONFIG_LOG_CONSOLE=y
CONFIG_SPL_LOG=y
CONFIG_SPL_LOG_MAX_LEVEL=9
CONFIG_SPL_LOG_CONSOLE=y

>>
>> Strange, Can you please tell me which steps you follow and also send some
>debug logs  if possible.
>>
>
>Following are the configurations, steps and debug logs:
>
>+++ b/configs/ae350_rv64_defconfig
>q+CONFIG_TRACE=y
>+CONFIG_TRACE_BUFFER_SIZE=0x0100
>+CONFIG_TRACE_CALL_DEPTH_LIMIT=15
>+CONFIG_CMD_TRACE=y
>+CONFIG_TIMER_EARLY=y
>
>+++ b/configs/ae350_rv64_spl_defconfig
>+CONFIG_TRACE=y
>+CONFIG_TRACE_BUFFER_SIZE=0x0100
>+CONFIG_TRACE_CALL_DEPTH_LIMIT=15
>+CONFIG_CMD_TRACE=y
>+CONFIG_TIMER_EARLY=y
>
> case 1
>///
>ae350_rv64_defconfig with FTRACE=1, kernel booting is ok
> case 1
>///
>make FTRACE=1 ae350_rv64_defconfig
>make FTRACE=1
>//
>/
>U-Boot 2021.01-rc2-00139-gb3d3d69-dirty (Nov 25 2020 - 11:14:28 +0800)
>
>DRAM:  1 GiB
>trace: enabled
>Flash: 64 MiB
>MMC:   mmc@f0e0: 0
>Loading Environment from SPIFlash... SF: Detected mx25u1635e with page
>size 256 Bytes, erase size 4 KiB, total 2 MiB
>OK
>In:serial@f030
>Out:   serial@f030
>Err:   serial@f030
>Net:   no alias for ethernet0
>Warning: mac@e010 (eth0) using random MAC address - de:fa:3e:1b:11:42
>eth0: mac@e010
>Hit any key to stop autoboot:  0
>RISC-V # fatload mmc 0:1 0x2000 ae350_rv64_smp_4_no_fd_coherent.dtb
>6455 bytes read in 67 ms (93.8 KiB/s)
>RISC-V # fatload mmc 0:1 0x0060 bootm_ae350_rv64_smp_bbl.bin
>22518836 bytes read in 11915 ms (1.8 MiB/s)
>RISC-V # bootm 0x0060 - 0x2000
>## Booting kernel from Legacy Image at 0060 ...
>   Image Name:
>   Image Type:   RISC-V Linux Kernel Image (uncompressed)
>   Data Size:22518772 Bytes = 21.5 MiB
>   Load Address: 
>   Entry Point:  
>   Verifying Checksum ... OK
>## Flattened Device Tree blob at 2000
>   Booting using the fdt blob at 0x2000
>   Loading Kernel Image
>   Loading Device Tree to 1effb000, end 1efff936 ... OK
>
>Starting kernel ...(fake run for tracing)
>
>Starting kernel ...
>
>OF: fdt: Ignoring memory range 0x0 - 0x20
>Linux version 4.17.0-00253-g49136e10bcb2 (sqa@atcsqa07) (gcc version
>7.3.0 (2019-04-06_nds64le-linux-glibc-v5_experimental)) #1 SMP PREEMPT
>Sat Apr 6 23:41:49 CST 2019
>bootconsole [early0] enabled
>Initial ramdisk at: 0x(ptrval) (13665712 bytes)
>Zone ranges:
>  DMA32[mem 0x0020-0x3fff]
>  Normal   empty
>Movable zone start for each node
>Early memory node ranges
>...
>...
>
> case 2
>///
>ae350_rv64_spl_defconfig with FTRACE=1, kernel booting fail
> case 2
>///
>make FTRACE=1 ae350_rv64_spl_defconfig
>make FTRACE=1
>//
>/
>U-Boot SPL 2020.10-rc2-00175-gfa50824 (Sep 15 2020 - 19:26:29 +0800)
>Trying to boot from MMC1
>U-Boot SPL 2021.01-rc2-00139-gb3d3d69-dirty (Nov 25 2020 - 13:48:05 +0800)
>Trying to boot from RAM
>U-Boot 2021.01-rc2-00139-gb3d3d69-dirty (Nov 25 2020 - 13:48:05 +0800)
>DRAM:  1 GiB
>trace: enabled
>Flash: 64 MiB
>MMC:   mmc@f0e0: 0
>Loading Environment from SPIFlash... SF: Detected mx25u1635e with page
>size 256 Bytes, erase size 4 KiB, total 2 MiB
>OK
>In:serial@f030
>Out:   serial@f030
>Err:   serial@f030
>Net:   no alias for ethernet0
>Warning: mac@e010 (eth0) using random MAC address - 36:86:da:0f:8e:8d
>eth0: mac@e010
>Hit any key to stop autoboot:  0
>27689996 bytes read in 15024 ms (1.8 MiB/s)
>6435 bytes read in 25 ms (251 KiB/s)
>## Booting kernel from Legacy Image at 0060 ...
>   Image Name:
>   Image Type:   RISC-V Linux Kernel Image (uncompressed)
>   Data Size:27689932 Bytes = 26.4 MiB
>   Load Address: 0020
>   Entry Point:  0020
>   Verifying Checksum ... OK
>## Flattened Device Tree blob at 2000
>   Booting using the fdt blob at 0x2000
>   Loading Kernel Image
>   Loading Device Tree to 1effb000

RE: [PATCH v4 0/4] Add Renesas SoC identification driver support

2020-11-30 Thread Biju Das
Hi All,

Gentle Ping. Please let me know, are we happy with this patch series?

The patch series[1] is blocked by this.
[1] 
http://u-boot.10912.n7.nabble.com/PATCH-v7-0-4-Add-CPU-identification-support-for-RZ-G2-SoC-s-tt433694.html#a433807

Cheers,
Biju

> -Original Message-
> From: Biju Das 
> Sent: 16 November 2020 13:04
> To: Simon Glass ; Marek Vasut
> 
> Cc: Biju Das ; Dave Gerlach  gerl...@ti.com>; Prabhakar Mahadev Lad  lad...@bp.renesas.com>; u-boot@lists.denx.de; Nobuhiro Iwamatsu
> ; Chris Paterson 
> Subject: [PATCH v4 0/4] Add Renesas SoC identification driver support
> 
> This patch series aims to support Renesas SoC identification driver.
> 
> Added a helper function of_match_node to find the matching of_match
> structure. This helper function can be used to replace the following code
> in u-boot [1] and [2]
> 
> [1]
> https://jpn01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.b
> ootlin.com%2Fu-
> boot%2Flatest%2Fsource%2Fdrivers%2Fserial%2Fserial_uniphier.c%23L129&d
> ata=04%7C01%7Cbiju.das.jz%40bp.renesas.com%7Ccc01f2630adf48bdb3c408d88a306
> 996%7C53d82571da1947e49cb4625a166a4a2a%7C0%7C0%7C637411287820999264%7CUnkn
> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJX
> VCI6Mn0%3D%7C1000&sdata=YmZ52jZrOQqXhvbflvy5XWnXsfb7FIRgxpY1XhBI6YE%3D
> &reserved=0
> [2]
> https://jpn01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.b
> ootlin.com%2Fu-
> boot%2Flatest%2Fsource%2Fdrivers%2Fusb%2Fphy%2Frockchip_usb2_phy.c%23L77&a
> mp;data=04%7C01%7Cbiju.das.jz%40bp.renesas.com%7Ccc01f2630adf48bdb3c408d88
> a306996%7C53d82571da1947e49cb4625a166a4a2a%7C0%7C0%7C637411287820999264%7C
> Unknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwi
> LCJXVCI6Mn0%3D%7C1000&sdata=N2wF3aZNCkN7TQlA%2FbhV3ggDjZdYVjjS%2F0tOFf
> j%2BkOE%3D&reserved=0
> 
> Also added soc_id attribute support in UCLASS_SOC which is required for
> Renesas SoC identification driver similar to mainline linux.
> 
> v3->v4
>   * Added Simon's Rb tag
>   * Updated patch description for SoC identification using soc_id
>   * Updated probe function of Renesas SoC identification driver.
> 
> Biju Das (4):
>   dm: core: Add of_match_node helper function
>   soc: Fix comments from SOC to SoC
>   dm: soc: Add SoC id for attribute matching
>   dm: soc: SoC identification driver for Renesas SoC's
> 
>  drivers/core/device.c |  21 
>  drivers/soc/Kconfig   |   7 ++
>  drivers/soc/Makefile  |   1 +
>  drivers/soc/soc-uclass.c  |  19 ++-
>  drivers/soc/soc_renesas.c | 244 ++
>  drivers/soc/soc_sandbox.c |   8 ++
>  include/dm/device.h   |  13 ++
>  include/soc.h |  39 +-
>  test/dm/core.c|  31 +
>  test/dm/soc.c |   8 ++
>  10 files changed, 384 insertions(+), 7 deletions(-)  create mode 100644
> drivers/soc/soc_renesas.c
> 
> --
> 2.17.1



[PATCH v10 11/11] sandbox: enable capsule update for testing

2020-11-30 Thread AKASHI Takahiro
Add more configuration options to allow for efi capsule update
on sandbox.

Signed-off-by: AKASHI Takahiro 
---
 configs/sandbox64_defconfig | 6 ++
 configs/sandbox_defconfig   | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index dc993cd13aaa..661830763feb 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -231,3 +231,9 @@ CONFIG_TEST_FDTDEC=y
 CONFIG_UNIT_TEST=y
 CONFIG_UT_TIME=y
 CONFIG_UT_DM=y
+#
+CONFIG_DFU_SF=y
+CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
+CONFIG_EFI_CAPSULE_ON_DISK=y
+CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
+CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index f2a767a4cdea..e385425b7d91 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -274,3 +274,9 @@ CONFIG_TEST_FDTDEC=y
 CONFIG_UNIT_TEST=y
 CONFIG_UT_TIME=y
 CONFIG_UT_DM=y
+#
+CONFIG_DFU_SF=y
+CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
+CONFIG_EFI_CAPSULE_ON_DISK=y
+CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
+CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
-- 
2.28.0



[PATCH v10 09/11] test/py: efi_capsule: test for FIT image capsule

2020-11-30 Thread AKASHI Takahiro
The test can run on sandbox build and it attempts to execute a firmware
update via a capsule-on-disk, using a FIT image capsule,
CONFIG_EFI_CAPSULE_FIT.

To run this test successfully, you need configure U-Boot specifically;
See test_capsule_firmware.py for requirements, and hence it won't run
on Travis CI, at least, for now.

Signed-off-by: AKASHI Takahiro 
---
 .../py/tests/test_efi_capsule/capsule_defs.py |   5 +
 test/py/tests/test_efi_capsule/conftest.py|  71 +++
 .../test_efi_capsule/test_capsule_firmware.py | 178 ++
 .../tests/test_efi_capsule/uboot_bin_env.its  |  36 
 tools/mkeficapsule.c  |   3 +-
 5 files changed, 292 insertions(+), 1 deletion(-)
 create mode 100644 test/py/tests/test_efi_capsule/capsule_defs.py
 create mode 100644 test/py/tests/test_efi_capsule/conftest.py
 create mode 100644 test/py/tests/test_efi_capsule/test_capsule_firmware.py
 create mode 100644 test/py/tests/test_efi_capsule/uboot_bin_env.its

diff --git a/test/py/tests/test_efi_capsule/capsule_defs.py 
b/test/py/tests/test_efi_capsule/capsule_defs.py
new file mode 100644
index ..4fd6353c2040
--- /dev/null
+++ b/test/py/tests/test_efi_capsule/capsule_defs.py
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier:  GPL-2.0+
+
+# Directories
+CAPSULE_DATA_DIR = '/EFI/CapsuleTestData'
+CAPSULE_INSTALL_DIR = '/EFI/UpdateCapsule'
diff --git a/test/py/tests/test_efi_capsule/conftest.py 
b/test/py/tests/test_efi_capsule/conftest.py
new file mode 100644
index ..d10494a7eed5
--- /dev/null
+++ b/test/py/tests/test_efi_capsule/conftest.py
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier:  GPL-2.0+
+# Copyright (c) 2020, Linaro Limited
+# Author: AKASHI Takahiro 
+
+import os
+import os.path
+import re
+from subprocess import call, check_call, check_output, CalledProcessError
+import pytest
+from capsule_defs import *
+
+#
+# Fixture for UEFI secure boot test
+#
+
+
+@pytest.fixture(scope='session')
+def efi_capsule_data(request, u_boot_config):
+"""Set up a file system to be used in UEFI capsule test.
+
+Args:
+request: Pytest request object.
+u_boot_config: U-boot configuration.
+
+Return:
+A path to disk image to be used for testing
+"""
+global CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR
+
+mnt_point = u_boot_config.persistent_data_dir + '/test_efi_capsule'
+data_dir = mnt_point + CAPSULE_DATA_DIR
+install_dir = mnt_point + CAPSULE_INSTALL_DIR
+image_path = u_boot_config.persistent_data_dir + '/test_efi_capsule.img'
+
+try:
+# Create a target device
+check_call('dd if=/dev/zero of=./spi.bin bs=1MiB count=16', shell=True)
+
+check_call('rm -rf %s' % mnt_point, shell=True)
+check_call('mkdir -p %s' % data_dir, shell=True)
+check_call('mkdir -p %s' % install_dir, shell=True)
+
+# Create capsule files
+# two regions: one for u-boot.bin and the other for u-boot.env
+check_call('cd %s; echo -n u-boot:Old > u-boot.bin.old; echo -n 
u-boot:New > u-boot.bin.new; echo -n u-boot-env:Old -> u-boot.env.old; echo -n 
u-boot-env:New > u-boot.env.new' % data_dir,
+   shell=True)
+check_call('sed -e \"s?BINFILE1?u-boot.bin.new?\" -e 
\"s?BINFILE2?u-boot.env.new?\" 
%s/test/py/tests/test_efi_capsule/uboot_bin_env.its > %s/uboot_bin_env.its' %
+   (u_boot_config.source_dir, data_dir),
+   shell=True)
+check_call('cd %s; %s/tools/mkimage -f uboot_bin_env.its 
uboot_bin_env.itb' %
+   (data_dir, u_boot_config.build_dir),
+   shell=True)
+check_call('cd %s; %s/tools/mkeficapsule --fit uboot_bin_env.itb 
--index 1 Test01' %
+   (data_dir, u_boot_config.build_dir),
+   shell=True)
+
+# Create a disk image with EFI system partition
+check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat %s %s' 
%
+   (mnt_point, image_path), shell=True)
+check_call('sgdisk %s -A 1:set:0 -t 
1:C12A7328-F81F-11D2-BA4B-00A0C93EC93B' %
+   image_path, shell=True)
+
+except CalledProcessError as exception:
+pytest.skip('Setup failed: %s' % exception.cmd)
+return
+else:
+yield image_path
+finally:
+call('rm -rf %s' % mnt_point, shell=True)
+call('rm -f %s' % image_path, shell=True)
+call('rm -f ./spi.bin', shell=True)
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware.py 
b/test/py/tests/test_efi_capsule/test_capsule_firmware.py
new file mode 100644
index ..d8e27707fd79
--- /dev/null
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware.py
@@ -0,0 +1,178 @@
+# SPDX-License-Identifier:  GPL-2.0+
+# Copyright (c) 2020, Linaro Limited
+# Author: AKASHI Takahiro 
+#
+# U-Boot UEFI: Firmware Update Test
+
+"""
+This test verifies capsule-on-disk firmware update
+"""
+
+from subprocess import check_call, c

[PATCH v10 10/11] test/py: efi_capsule: test for raw image capsule

2020-11-30 Thread AKASHI Takahiro
The test can run on sandbox build and it attempts to execute a firmware
update via a capsule-on-disk, using a raw image capsule,
CONFIG_EFI_CAPSULE_RAW.

To run this test successfully, you need configure U-Boot specifically;
See test_capsule_firmware.py for requirements, and hence it won't run
on Travis CI, at least, for now.

Signed-off-by: AKASHI Takahiro 
---
 test/py/tests/test_efi_capsule/conftest.py|  3 +
 .../test_efi_capsule/test_capsule_firmware.py | 63 +++
 2 files changed, 66 insertions(+)

diff --git a/test/py/tests/test_efi_capsule/conftest.py 
b/test/py/tests/test_efi_capsule/conftest.py
index d10494a7eed5..6ad5608cd71c 100644
--- a/test/py/tests/test_efi_capsule/conftest.py
+++ b/test/py/tests/test_efi_capsule/conftest.py
@@ -53,6 +53,9 @@ def efi_capsule_data(request, u_boot_config):
 check_call('cd %s; %s/tools/mkeficapsule --fit uboot_bin_env.itb 
--index 1 Test01' %
(data_dir, u_boot_config.build_dir),
shell=True)
+check_call('cd %s; %s/tools/mkeficapsule --raw u-boot.bin.new --index 
1 Test02' %
+   (data_dir, u_boot_config.build_dir),
+   shell=True)
 
 # Create a disk image with EFI system partition
 check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat %s %s' 
%
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware.py 
b/test/py/tests/test_efi_capsule/test_capsule_firmware.py
index d8e27707fd79..f006fa95d650 100644
--- a/test/py/tests/test_efi_capsule/test_capsule_firmware.py
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware.py
@@ -15,6 +15,7 @@ from capsule_defs import *
 
 @pytest.mark.boardspec('sandbox')
 @pytest.mark.buildconfigspec('efi_capsule_firmware_fit')
+@pytest.mark.buildconfigspec('efi_capsule_firmware_raw')
 @pytest.mark.buildconfigspec('efi_capsule_on_disk')
 @pytest.mark.buildconfigspec('dfu')
 @pytest.mark.buildconfigspec('dfu_sf')
@@ -176,3 +177,65 @@ class TestEfiCapsuleFirmwareFit(object):
 'sf read 400 15 10',
 'md.b 400 10'])
 assert 'u-boot-env:New' in ''.join(output)
+
+def test_efi_capsule_fw3(
+self, u_boot_config, u_boot_console, efi_capsule_data):
+"""
+Test Case 3 - Update U-Boot on SPI Flash, raw image format
+  0x10-0x15: U-Boot binary (but dummy)
+"""
+disk_img = efi_capsule_data
+with u_boot_console.log.section('Test Case 3-a, before reboot'):
+output = u_boot_console.run_command_list([
+'host bind 0 %s' % disk_img,
+'efidebug boot add 1 TEST host 0:1 /helloworld.efi ""',
+'efidebug boot order 1',
+'env set -e -nv -bs -rt OsIndications =0x0004',
+'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x10 
0x5;u-boot-env raw 0x15 0x20"',
+'env save'])
+
+# initialize content
+output = u_boot_console.run_command_list([
+'sf probe 0:0',
+'fatload host 0:1 400 %s/u-boot.bin.old' % 
CAPSULE_DATA_DIR,
+'sf write 400 10 10',
+'sf read 500 10 10',
+'md.b 500 10'])
+assert 'Old' in ''.join(output)
+
+# place a capsule file
+output = u_boot_console.run_command_list([
+'fatload host 0:1 400 %s/Test02' % CAPSULE_DATA_DIR,
+'fatwrite host 0:1 400 %s/Test02 $filesize' % 
CAPSULE_INSTALL_DIR,
+'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR])
+assert 'Test02' in ''.join(output)
+
+# reboot
+u_boot_console.restart_uboot()
+
+capsule_early = u_boot_config.buildconfig.get(
+'config_efi_capsule_on_disk_early')
+with u_boot_console.log.section('Test Case 3-b, after reboot'):
+if not capsule_early:
+# make sure that dfu_alt_info exists even persistent variables
+# are not available.
+output = u_boot_console.run_command_list([
+'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x10 
0x5;u-boot-env raw 0x15 0x20"',
+'host bind 0 %s' % disk_img,
+'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR])
+assert 'Test02' in ''.join(output)
+
+# need to run uefi command to initiate capsule handling
+output = u_boot_console.run_command(
+'env print -e -all Capsule')
+
+output = u_boot_console.run_command_list([
+'host bind 0 %s' % disk_img,
+'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR])
+assert 'Test02' not in ''.join(output)
+
+output = u_boot_console.run_command_list([
+'sf probe 0:0',
+'sf read 400 10 10',

[PATCH v10 08/11] tools: add mkeficapsule command for UEFI capsule update

2020-11-30 Thread AKASHI Takahiro
This is a utility mainly for test purpose.
  mkeficapsule -f: create a test capsule file for FIT image firmware

Having said that, you will be able to customize the code to fit
your specific requirements for your platform.

Signed-off-by: AKASHI Takahiro 
---
 tools/Makefile   |   2 +
 tools/mkeficapsule.c | 236 +++
 2 files changed, 238 insertions(+)
 create mode 100644 tools/mkeficapsule.c

diff --git a/tools/Makefile b/tools/Makefile
index 51123fd92983..66d9376803e3 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -218,6 +218,8 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
 hostprogs-$(CONFIG_ASN1_COMPILER)  += asn1_compiler
 HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
 
+hostprogs-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += mkeficapsule
+
 # We build some files with extra pedantic flags to try to minimize things
 # that won't build on some weird host compiler -- though there are lots of
 # exceptions for files that aren't complaint.
diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c
new file mode 100644
index ..426038ea27ba
--- /dev/null
+++ b/tools/mkeficapsule.c
@@ -0,0 +1,236 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2018 Linaro Limited
+ * Author: AKASHI Takahiro
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+typedef __u8 u8;
+typedef __u16 u16;
+typedef __u32 u32;
+typedef __u64 u64;
+typedef __s16 s16;
+typedef __s32 s32;
+
+#define aligned_u64 __aligned_u64
+
+#ifndef __packed
+#define __packed __attribute__((packed))
+#endif
+
+#include 
+#include 
+
+static const char *tool_name = "mkeficapsule";
+
+efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID;
+efi_guid_t efi_guid_image_type_uboot_fit =
+   EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
+efi_guid_t efi_guid_image_type_uboot_raw =
+   EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;
+
+static struct option options[] = {
+   {"fit", required_argument, NULL, 'f'},
+   {"raw", required_argument, NULL, 'r'},
+   {"index", required_argument, NULL, 'i'},
+   {"instance", required_argument, NULL, 'I'},
+   {"help", no_argument, NULL, 'h'},
+   {NULL, 0, NULL, 0},
+};
+
+static void print_usage(void)
+{
+   printf("Usage: %s [options] \n"
+  "Options:\n"
+  "\t--fit   new FIT image file\n"
+  "\t--raw   new raw image file\n"
+  "\t--index update image index\n"
+  "\t--instance   update hardware instance\n"
+  "\t--help print a help message\n",
+  tool_name);
+}
+
+static int create_fwbin(char *path, char *bin, efi_guid_t *guid,
+   unsigned long index, unsigned long instance)
+{
+   struct efi_capsule_header header;
+   struct efi_firmware_management_capsule_header capsule;
+   struct efi_firmware_management_capsule_image_header image;
+   FILE *f, *g;
+   struct stat bin_stat;
+   u8 *data;
+   size_t size;
+   u64 offset;
+
+#ifdef DEBUG
+   printf("For output: %s\n", path);
+   printf("\tbin: %s\n\ttype: %pUl\n" bin, guid);
+   printf("\tindex: %ld\n\tinstance: %ld\n", index, instance);
+#endif
+
+   g = fopen(bin, "r");
+   if (!g) {
+   printf("cannot open %s\n", bin);
+   return -1;
+   }
+   if (stat(bin, &bin_stat) < 0) {
+   printf("cannot determine the size of %s\n", bin);
+   goto err_1;
+   }
+   data = malloc(bin_stat.st_size);
+   if (!data) {
+   printf("cannot allocate memory: %lx\n", bin_stat.st_size);
+   goto err_1;
+   }
+   f = fopen(path, "w");
+   if (!f) {
+   printf("cannot open %s\n", path);
+   goto err_2;
+   }
+   header.capsule_guid = efi_guid_fm_capsule;
+   header.header_size = sizeof(header);
+   header.flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET; /* TODO */
+   header.capsule_image_size = sizeof(header)
+   + sizeof(capsule) + sizeof(u64)
+   + sizeof(image)
+   + bin_stat.st_size;
+
+   size = fwrite(&header, 1, sizeof(header), f);
+   if (size < sizeof(header)) {
+   printf("write failed (%lx)\n", size);
+   goto err_3;
+   }
+
+   capsule.version = 0x0001;
+   capsule.embedded_driver_count = 0;
+   capsule.payload_item_count = 1;
+   size = fwrite(&capsule, 1, sizeof(capsule), f);
+   if (size < (sizeof(capsule))) {
+   printf("write failed (%lx)\n", size);
+   goto err_3;
+   }
+   offset = sizeof(capsule) + sizeof(u64);
+   size = fwrite(&offset, 1, sizeof(offset), f);
+   if (size < sizeof(offset)) {
+   printf("write failed (%lx)\n", size);
+

[PATCH v10 07/11] cmd: add "efidebug capsule" command

2020-11-30 Thread AKASHI Takahiro
"efidebug capsule" is more or less a debugging utility.
  efidebug capsule update: invoke UpdateCapsule against data on memory
  efidebug capsule show: show a capsule header
  efidebug capsule result: dump a capsule result variable

Signed-off-by: AKASHI Takahiro 
---
 cmd/efidebug.c | 235 +
 1 file changed, 235 insertions(+)

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 5288b9920b4d..7d327c82681f 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -19,6 +19,228 @@
 #include 
 
 #define BS systab.boottime
+#define RT systab.runtime
+
+#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT
+/**
+ * do_efi_capsule_update() - process a capsule update
+ *
+ * @cmdtp: Command table
+ * @flag:  Command flag
+ * @argc:  Number of arguments
+ * @argv:  Argument array
+ * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
+ *
+ * Implement efidebug "capsule update" sub-command.
+ * process a capsule update.
+ *
+ * efidebug capsule update [-v] 
+ */
+static int do_efi_capsule_update(struct cmd_tbl *cmdtp, int flag,
+int argc, char * const argv[])
+{
+   struct efi_capsule_header *capsule;
+   int verbose = 0;
+   char *endp;
+   efi_status_t ret;
+
+   if (argc != 2 && argc != 3)
+   return CMD_RET_USAGE;
+
+   if (argc == 3) {
+   if (strcmp(argv[1], "-v"))
+   return CMD_RET_USAGE;
+
+   verbose = 1;
+   argc--;
+   argv++;
+   }
+
+   capsule = (typeof(capsule))simple_strtoul(argv[1], &endp, 16);
+   if (endp == argv[1]) {
+   printf("Invalid address: %s", argv[1]);
+   return CMD_RET_FAILURE;
+   }
+
+   if (verbose) {
+   printf("Capsule guid: %pUl\n", &capsule->capsule_guid);
+   printf("Capsule flags: 0x%x\n", capsule->flags);
+   printf("Capsule header size: 0x%x\n", capsule->header_size);
+   printf("Capsule image size: 0x%x\n",
+  capsule->capsule_image_size);
+   }
+
+   ret = EFI_CALL(RT->update_capsule(&capsule, 1, (u64)NULL));
+   if (ret) {
+   printf("Cannot handle a capsule at %p", capsule);
+   return CMD_RET_FAILURE;
+   }
+
+   return CMD_RET_SUCCESS;
+}
+
+/**
+ * do_efi_capsule_show() - show capsule information
+ *
+ * @cmdtp: Command table
+ * @flag:  Command flag
+ * @argc:  Number of arguments
+ * @argv:  Argument array
+ * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
+ *
+ * Implement efidebug "capsule show" sub-command.
+ * show capsule information.
+ *
+ * efidebug capsule show 
+ */
+static int do_efi_capsule_show(struct cmd_tbl *cmdtp, int flag,
+  int argc, char * const argv[])
+{
+   struct efi_capsule_header *capsule;
+   char *endp;
+
+   if (argc != 2)
+   return CMD_RET_USAGE;
+
+   capsule = (typeof(capsule))simple_strtoul(argv[1], &endp, 16);
+   if (endp == argv[1]) {
+   printf("Invalid address: %s", argv[1]);
+   return CMD_RET_FAILURE;
+   }
+
+   printf("Capsule guid: %pUl\n", &capsule->capsule_guid);
+   printf("Capsule flags: 0x%x\n", capsule->flags);
+   printf("Capsule header size: 0x%x\n", capsule->header_size);
+   printf("Capsule image size: 0x%x\n",
+  capsule->capsule_image_size);
+
+   return CMD_RET_SUCCESS;
+}
+
+/**
+ * do_efi_capsule_res() - show a capsule update result
+ *
+ * @cmdtp: Command table
+ * @flag:  Command flag
+ * @argc:  Number of arguments
+ * @argv:  Argument array
+ * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
+ *
+ * Implement efidebug "capsule result" sub-command.
+ * show a capsule update result.
+ * If result number is not specified, CapsuleLast will be shown.
+ *
+ * efidebug capsule result []
+ */
+static int do_efi_capsule_res(struct cmd_tbl *cmdtp, int flag,
+ int argc, char * const argv[])
+{
+   int capsule_id;
+   char *endp;
+   char var_name[12];
+   u16 var_name16[12], *p;
+   efi_guid_t guid;
+   struct efi_capsule_result_variable_header *result = NULL;
+   efi_uintn_t size;
+   efi_status_t ret;
+
+   if (argc != 1 && argc != 2)
+   return CMD_RET_USAGE;
+
+   guid = efi_guid_capsule_report;
+   if (argc == 1) {
+   size = sizeof(var_name16);
+   ret = EFI_CALL(RT->get_variable(L"CapsuleLast", &guid, NULL,
+   &size, var_name16));
+   if (ret != EFI_SUCCESS) {
+   if (ret == EFI_NOT_FOUND)
+   printf("CapsuleLast doesn't exist\n");
+   else
+   printf("Failed to get CapsuleLast\n");
+
+

[PATCH v10 06/11] efi_loader: add firmware management protocol for raw image

2020-11-30 Thread AKASHI Takahiro
In this commit, a very simple firmware management protocol driver
is implemented. It will take a binary image in a capsule file and
apply the data using dfu backend storage drivers via dfu_write_by_alt()
interface.

So "dfu_alt_info" variable should be properly set to specify a device
and location to be updated. Please read README.dfu.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_api.h |   4 +
 include/efi_loader.h  |   1 +
 lib/efi_loader/Kconfig|  16 +++
 lib/efi_loader/Makefile   |   2 +-
 lib/efi_loader/efi_capsule.c  |   8 ++
 lib/efi_loader/efi_firmware.c | 226 +-
 6 files changed, 199 insertions(+), 58 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index 071d0ba866c7..c7038f863ab2 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -1853,6 +1853,10 @@ struct efi_signature_list {
EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
 0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
 
+#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \
+   EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \
+0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f)
+
 #define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE0x0001
 #define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0002
 #define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED0x0004
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d24d0ff0e78a..1b19faf76941 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -812,6 +812,7 @@ void efi_memcpy_runtime(void *dest, const void *src, size_t 
n);
 u16 *efi_create_indexed_name(u16 *buffer, const char *name, unsigned int 
index);
 
 extern const struct efi_firmware_management_protocol efi_fmp_fit;
+extern const struct efi_firmware_management_protocol efi_fmp_raw;
 
 /* Capsule update */
 efi_status_t EFIAPI efi_update_capsule(
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 159400fec39e..8332a5072d42 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -126,6 +126,10 @@ config EFI_CAPSULE_ON_DISK_EARLY
  executed as part of U-Boot initialisation so that they will
  surely take place whatever is set to distro_bootcmd.
 
+config EFI_CAPSULE_FIRMWARE
+   bool
+   default n
+
 config EFI_CAPSULE_FIRMWARE_MANAGEMENT
bool "Capsule: Firmware Management Protocol"
depends on EFI_HAVE_CAPSULE_SUPPORT
@@ -140,11 +144,23 @@ config EFI_CAPSULE_FIRMWARE_FIT
depends on FIT
select UPDATE_FIT
select DFU
+   select EFI_CAPSULE_FIRMWARE
default n
help
  Select this option if you want to enable firmware management protocol
  driver for FIT image
 
+config EFI_CAPSULE_FIRMWARE_RAW
+   bool "FMP driver for raw image"
+   depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT
+   select DFU
+   select DFU_WRITE_ALT
+   select EFI_CAPSULE_FIRMWARE
+   default n
+   help
+ Select this option if you want to enable firmware management protocol
+ driver for raw image
+
 config EFI_DEVICE_PATH_TO_TEXT
bool "Device path to text protocol"
default y
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index dedb702c5d43..9a3496350ea4 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -24,7 +24,7 @@ obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
 obj-y += efi_bootmgr.o
 obj-y += efi_boottime.o
 obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o
-obj-$(CONFIG_EFI_CAPSULE_FIRMWARE_FIT) += efi_firmware.o
+obj-$(CONFIG_EFI_CAPSULE_FIRMWARE) += efi_firmware.o
 obj-y += efi_console.o
 obj-y += efi_device_path.o
 obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_device_path_to_text.o
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 33425b7c0e7c..ea22ee796843 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -807,6 +807,14 @@ efi_status_t __weak arch_efi_load_capsule_drivers(void)
&efi_fmp_fit, NULL));
}
 
+   if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_RAW)) {
+   handle = NULL;
+   ret = EFI_CALL(efi_install_multiple_protocol_interfaces(
+   &efi_root,
+   &efi_guid_firmware_management_protocol,
+   &efi_fmp_raw, NULL));
+   }
+
return ret;
 }
 
diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index 15d33ba59112..72c560dbc223 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -13,16 +13,66 @@
 #include 
 #include 
 
-/*
- * This FIRMWARE_MANAGEMENT_PROTOCOL driver provides a firmware update
- * method with existing FIT image format, and handles
- *   - multiple regions of firmware via DFU
- * but doesn't support
- *   - versioning of firmware image
- *   - package information
- */
-const efi_guid_t efi_firmware_i

[PATCH v10 05/11] efi_loader: add firmware management protocol for FIT image

2020-11-30 Thread AKASHI Takahiro
In this commit, a very simple firmware management protocol driver
is implemented. It will take a common FIT image firmware in a capsule
file and apply the data using dfu backend storage drivers via
update_fit() interface.

So "dfu_alt_info" variable should be properly set to specify a device
and location to be updated. Please read README.dfu.

Fit image is a common file format for firmware update on U-Boot, and
this protocol works neatly just as a wrapper for one.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_api.h |   4 +
 include/efi_loader.h  |   2 +
 lib/efi_loader/Kconfig|  11 ++
 lib/efi_loader/Makefile   |   1 +
 lib/efi_loader/efi_capsule.c  |  12 +-
 lib/efi_loader/efi_firmware.c | 291 ++
 6 files changed, 320 insertions(+), 1 deletion(-)
 create mode 100644 lib/efi_loader/efi_firmware.c

diff --git a/include/efi_api.h b/include/efi_api.h
index 966bc6e590bf..071d0ba866c7 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -1849,6 +1849,10 @@ struct efi_signature_list {
EFI_GUID(0x86c77a67, 0x0b97, 0x4633, 0xa1, 0x87, \
 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7)
 
+#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
+   EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
+0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
+
 #define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE0x0001
 #define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0002
 #define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED0x0004
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 1a728bf9702d..d24d0ff0e78a 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -811,6 +811,8 @@ void efi_memcpy_runtime(void *dest, const void *src, size_t 
n);
 /* commonly used helper function */
 u16 *efi_create_indexed_name(u16 *buffer, const char *name, unsigned int 
index);
 
+extern const struct efi_firmware_management_protocol efi_fmp_fit;
+
 /* Capsule update */
 efi_status_t EFIAPI efi_update_capsule(
struct efi_capsule_header **capsule_header_array,
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 5cb34687c26a..159400fec39e 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -134,6 +134,17 @@ config EFI_CAPSULE_FIRMWARE_MANAGEMENT
  Select this option if you want to enable capsule-based
  firmware update using Firmware Management Protocol.
 
+config EFI_CAPSULE_FIRMWARE_FIT
+   bool "FMP driver for FIT image"
+   depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT
+   depends on FIT
+   select UPDATE_FIT
+   select DFU
+   default n
+   help
+ Select this option if you want to enable firmware management protocol
+ driver for FIT image
+
 config EFI_DEVICE_PATH_TO_TEXT
bool "Device path to text protocol"
default y
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 8d729abdfa78..dedb702c5d43 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
 obj-y += efi_bootmgr.o
 obj-y += efi_boottime.o
 obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o
+obj-$(CONFIG_EFI_CAPSULE_FIRMWARE_FIT) += efi_firmware.o
 obj-y += efi_console.o
 obj-y += efi_device_path.o
 obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_device_path_to_text.o
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 3e7ad470d484..33425b7c0e7c 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -797,7 +797,17 @@ static void efi_capsule_scan_done(void)
  */
 efi_status_t __weak arch_efi_load_capsule_drivers(void)
 {
-   return EFI_SUCCESS;
+   __maybe_unused efi_handle_t handle;
+   efi_status_t ret = EFI_SUCCESS;
+
+   if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_FIT)) {
+   handle = NULL;
+   ret = EFI_CALL(efi_install_multiple_protocol_interfaces(
+   &handle, &efi_guid_firmware_management_protocol,
+   &efi_fmp_fit, NULL));
+   }
+
+   return ret;
 }
 
 /**
diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
new file mode 100644
index ..15d33ba59112
--- /dev/null
+++ b/lib/efi_loader/efi_firmware.c
@@ -0,0 +1,291 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * EFI Firmware management protocol
+ *
+ *  Copyright (c) 2020 Linaro Limited
+ * Author: AKASHI Takahiro
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * This FIRMWARE_MANAGEMENT_PROTOCOL driver provides a firmware update
+ * method with existing FIT image format, and handles
+ *   - multiple regions of firmware via DFU
+ * but doesn't support
+ *   - versioning of firmware image
+ *   - package information
+ */
+const efi_guid_t efi_firmware_image_type_uboot_fit =
+   EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
+
+/**
+ 

[PATCH v10 04/11] efi_loader: capsule: support firmware update

2020-11-30 Thread AKASHI Takahiro
A capsule tagged with the guid, EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID,
is handled as a firmware update object.
What efi_update_capsule() basically does is to load any firmware management
protocol (or fmp) drivers contained in a capsule, find out an appropriate
fmp driver and then invoke its set_image() interface against each binary
in a capsule.
In this commit, however, loading drivers is not supported.

The result of applying a capsule is set to be stored in "Capsule"
variable, but its implementation is deferred to a fmp driver.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_api.h| 129 ++
 include/efi_loader.h |   2 +
 lib/efi_loader/Kconfig   |   8 ++
 lib/efi_loader/efi_capsule.c | 252 +--
 lib/efi_loader/efi_setup.c   |   4 +
 5 files changed, 383 insertions(+), 12 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index 7a2a087c60ed..966bc6e590bf 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -217,6 +217,9 @@ enum efi_reset_type {
 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE0x0002
 #define CAPSULE_FLAGS_INITIATE_RESET   0x0004
 
+#define CAPSULE_SUPPORT_AUTHENTICATION 0x0001
+#define CAPSULE_SUPPORT_DEPENDENCY 0x0002
+
 #define EFI_CAPSULE_REPORT_GUID \
EFI_GUID(0x39b68c46, 0xf7fb, 0x441b, 0xb6, 0xec, \
 0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3)
@@ -225,6 +228,10 @@ enum efi_reset_type {
EFI_GUID(0xde9f0ec, 0x88b6, 0x428f, 0x97, 0x7a, \
 0x25, 0x8f, 0x1d, 0xe, 0x5e, 0x72)
 
+#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \
+   EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
+0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
+
 struct efi_capsule_header {
efi_guid_t capsule_guid;
u32 header_size;
@@ -253,6 +260,33 @@ struct efi_memory_range_capsule {
struct efi_memory_range memory_ranges[];
 } __packed;
 
+struct efi_firmware_management_capsule_header {
+   u32 version;
+   u16 embedded_driver_count;
+   u16 payload_item_count;
+   u64 item_offset_list[];
+} __packed;
+
+struct efi_firmware_management_capsule_image_header {
+   u32 version;
+   efi_guid_t update_image_type_id;
+   u8 update_image_index;
+   u8 reserved[3];
+   u32 update_image_size;
+   u32 update_vendor_code_size;
+   u64 update_hardware_instance;
+   u64 image_capsule_support;
+} __packed;
+
+struct efi_capsule_result_variable_fmp {
+   u16 version;
+   u8 payload_index;
+   u8 update_image_index;
+   efi_guid_t update_image_type_id;
+   // u16 capsule_file_name[];
+   // u16 capsule_target[];
+} __packed;
+
 #define EFI_RT_SUPPORTED_GET_TIME  0x0001
 #define EFI_RT_SUPPORTED_SET_TIME  0x0002
 #define EFI_RT_SUPPORTED_GET_WAKEUP_TIME   0x0004
@@ -1808,4 +1842,99 @@ struct efi_signature_list {
 /* struct efi_signature_data signatures[...][signature_size]; */
 } __attribute__((__packed__));
 
+/*
+ * Firmware management protocol
+ */
+#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID \
+   EFI_GUID(0x86c77a67, 0x0b97, 0x4633, 0xa1, 0x87, \
+0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7)
+
+#define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE0x0001
+#define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0002
+#define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED0x0004
+#define IMAGE_ATTRIBUTE_IN_USE 0x0008
+#define IMAGE_ATTRIBUTE_UEFI_IMAGE 0x0010
+#define IMAGE_ATTRIBUTE_DEPENDENCY 0x0020
+
+#define IMAGE_COMPATIBILITY_CHECK_SUPPORTED0x0001
+
+#define IMAGE_UPDATABLE_VALID  0x0001
+#define IMAGE_UPDATABLE_INVALID0x0002
+#define IMAGE_UPDATABLE_INVALID_TYPE   0x0004
+#define IMAGE_UPDATABLE_INVALID_OLLD   0x0008
+#define IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE 0x0010
+
+#define PACKAGE_ATTRIBUTE_VERSION_UPDATABLE0x0001
+#define PACKAGE_ATTRIBUTE_RESET_REQUIRED   0x0002
+#define PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED  0x0004
+
+#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION  4
+
+typedef struct efi_firmware_image_dependencies {
+   u8 dependencies[0];
+} efi_firmware_image_dep_t;
+
+struct efi_firmware_image_descriptor {
+   u8 image_index;
+   efi_guid_t image_type_id;
+   u64 image_id;
+   u16 *image_id_name;
+   u32 version;
+   u16 *version_name;
+   efi_uintn_t size;
+   u64 attributes_supported;
+   u64 attributes_setting;
+   u64 compatibilities;
+   u32 lowest_supported_image_version;
+   u32 last_attempt_version;
+   u32 last_attempt_status;
+   u64 hardware_instance;
+   efi_firmware_image_

[PATCH v10 02/11] efi_loader: capsule: add capsule_on_disk support

2020-11-30 Thread AKASHI Takahiro
Capsule data can be loaded into the system either via UpdateCapsule
runtime service or files on a file system (of boot device).
The latter case is called "capsules on disk", and actual updates will
take place at the next boot time.

In this commit, we will support capsule on disk mechanism.

Please note that U-Boot itself has no notion of "boot device" and
all the capsule files to be executed will be detected only if they
are located in a specific directory, \EFI\UpdateCapsule, on a device
that is identified as a boot device by "Boot" variables.

Signed-off-by: AKASHI Takahiro 
---
 common/main.c|   4 +
 include/efi_loader.h |   9 +
 lib/efi_loader/Kconfig   |  22 ++
 lib/efi_loader/efi_capsule.c | 498 +++
 lib/efi_loader/efi_setup.c   |   8 +
 5 files changed, 541 insertions(+)

diff --git a/common/main.c b/common/main.c
index 4b3cd302c3e2..ae5bcdb32f8b 100644
--- a/common/main.c
+++ b/common/main.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static void run_preboot_environment_command(void)
 {
@@ -53,6 +54,9 @@ void main_loop(void)
if (IS_ENABLED(CONFIG_UPDATE_TFTP))
update_tftp(0UL, NULL, NULL);
 
+   if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY))
+   efi_launch_capsules();
+
s = bootdelay_process();
if (cli_process_fdt(&s))
cli_secure_boot_cmd(s);
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d22f7a43ad09..eb57e7455eb1 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -820,6 +820,11 @@ efi_status_t EFIAPI efi_query_capsule_caps(
u64 *maximum_capsule_size,
u32 *reset_type);
 
+#define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\"
+
+/* Hook at initialization */
+efi_status_t efi_launch_capsules(void);
+
 #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
 
 /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */
@@ -836,6 +841,10 @@ static inline void efi_set_bootdev(const char *dev, const 
char *devnr,
   const char *path) { }
 static inline void efi_net_set_dhcp_ack(void *pkt, int len) { }
 static inline void efi_print_image_infos(void *pc) { }
+static inline efi_status_t efi_launch_capsules(void)
+{
+   return EFI_SUCCESS;
+}
 
 #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */
 
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 3ca396df3646..e1ac5ac055de 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -104,6 +104,28 @@ config EFI_RUNTIME_UPDATE_CAPSULE
  Select this option if you want to use UpdateCapsule and
  QueryCapsuleCapabilities API's.
 
+config EFI_CAPSULE_ON_DISK
+   bool "Enable capsule-on-disk support"
+   select EFI_HAVE_CAPSULE_SUPPORT
+   default n
+   help
+ Select this option if you want to use capsule-on-disk feature,
+ that is, capsules can be fetched and executed from files
+ under a specific directory on UEFI system partition instead of
+ via UpdateCapsule API.
+
+config EFI_CAPSULE_ON_DISK_EARLY
+   bool "Initiate capsule-on-disk at U-Boot boottime"
+   depends on EFI_CAPSULE_ON_DISK
+   default n
+   select EFI_SETUP_EARLY
+   help
+ Normally, without this option enabled, capsules will be
+ executed only at the first time of invoking one of efi command.
+ If this option is enabled, capsules will be enforced to be
+ executed as part of U-Boot initialisation so that they will
+ surely take place whatever is set to distro_bootcmd.
+
 config EFI_DEVICE_PATH_TO_TEXT
bool "Device path to text protocol"
default y
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 575fa75b0a2f..b3c7d1b735b6 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -11,10 +11,16 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 const efi_guid_t efi_guid_capsule_report = EFI_CAPSULE_REPORT_GUID;
 
+#ifdef CONFIG_EFI_CAPSULE_ON_DISK
+/* for file system access */
+static struct efi_file_handle *bootdev_root;
+#endif
+
 /**
  * get_last_capsule - get the last capsule index
  *
@@ -163,3 +169,495 @@ efi_status_t EFIAPI efi_query_capsule_caps(
 out:
return EFI_EXIT(ret);
 }
+
+#ifdef CONFIG_EFI_CAPSULE_ON_DISK
+/**
+ * get_dp_device - retrieve a device  path from boot variable
+ * @boot_var:  Boot variable name
+ * @device_dp  Device path
+ *
+ * Retrieve a device patch from boot variable, @boot_var.
+ *
+ * Return: status code
+ */
+static efi_status_t get_dp_device(u16 *boot_var,
+ struct efi_device_path **device_dp)
+{
+   void *buf = NULL;
+   efi_uintn_t size;
+   struct efi_load_option lo;
+   struct efi_device_path *file_dp;
+   efi_status_t ret;
+
+   size = 0;
+   ret = efi_get_variable_int(boot_var, &efi_global_variable_guid,
+ 

[PATCH v10 03/11] efi_loader: capsule: add memory range capsule definitions

2020-11-30 Thread AKASHI Takahiro
Memory range capsule gives us a way to notify that some memory regions
should be left untouched across the next reset.
See UEFI specification, section 8.5.3.

Since how we should handle this kind of capsule is totally up to
the system, no implementation will be added in this commit.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_api.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/include/efi_api.h b/include/efi_api.h
index c128a0a66ce8..7a2a087c60ed 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -221,6 +221,10 @@ enum efi_reset_type {
EFI_GUID(0x39b68c46, 0xf7fb, 0x441b, 0xb6, 0xec, \
 0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3)
 
+#define EFI_MEMORY_RANGE_CAPSULE_GUID \
+   EFI_GUID(0xde9f0ec, 0x88b6, 0x428f, 0x97, 0x7a, \
+0x25, 0x8f, 0x1d, 0xe, 0x5e, 0x72)
+
 struct efi_capsule_header {
efi_guid_t capsule_guid;
u32 header_size;
@@ -236,6 +240,19 @@ struct efi_capsule_result_variable_header {
efi_status_t capsule_status;
 } __packed;
 
+struct efi_memory_range {
+   efi_physical_addr_t address;
+   u64 length;
+};
+
+struct efi_memory_range_capsule {
+   struct efi_capsule_header *header;
+   /* EFI_MEMORY_TYPE: 0x8000-0x */
+   enum efi_mem_type os_requested_memory_type;
+   u64 number_of_memory_ranges;
+   struct efi_memory_range memory_ranges[];
+} __packed;
+
 #define EFI_RT_SUPPORTED_GET_TIME  0x0001
 #define EFI_RT_SUPPORTED_SET_TIME  0x0002
 #define EFI_RT_SUPPORTED_GET_WAKEUP_TIME   0x0004
-- 
2.28.0



[PATCH v10 00/11] efi_loader: add capsule update support

2020-11-30 Thread AKASHI Takahiro
Summary
===
'UpdateCapsule' is one of runtime services defined in UEFI specification
and its aim is to allow a caller (OS) to pass information to the firmware,
i.e. U-Boot. This is mostly used to update firmware binary on devices by
instructions from OS.

While 'UpdateCapsule' is a runtime services function, it is, at least
initially, supported only before exiting boot services alike other runtime
functions, [Get/]SetVariable. This is because modifying storage which may
be shared with OS must be carefully designed and there is no general
assumption that we can do it.

Therefore, we practically support only "capsule on disk"; any capsule can
be handed over to UEFI subsystem as a file on a specific file system.

In this patch series, all the related definitions and structures are given
as UEFI specification describes, and basic framework for capsule support
is provided. Currently supported is
 * firmware update (Firmware Management Protocol or simply FMP)

Most of functionality of firmware update is provided by FMP driver and
it can be, by nature, system/platform-specific. So you can and should
implement your own FMP driver(s) based on your system requirements.
Under the current implementation, we provide two basic but generic
drivers with two formats:
  * FIT image format (as used in TFTP update and dfu)
  * raw image format

It's totally up to users which one, or both, should be used on users'
system depending on user requirements.

Quick usage
===
1. You can create a capsule file with the following host command:

  $ mkeficapsule [--fit  | --raw ] 

2. Put the file under:

  /EFI/UpdateCapsule of UEFI system partition

3. Specify firmware storage to be updated in "dfu_alt_info" variable
   (Please follow README.dfu for details.)

  ==> env set dfu_alt_info '...'

4. After setting up UEFI's OsIndications variable, reboot U-Boot:

  OsIndications <= EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED

Patch structure
===
Patch#1-#6: main part of implementation
Patch#7-#8: utilities
Patch#9-#10: pytests
Patch#11: for sandbox test

[1] https://git.linaro.org/people/takahiro.akashi/u-boot.git efi/capsule

Prerequisite patches

None

Test

* 'build' passed with gcc 10.2 for (qemu-)arm64 locally.
* passed all the pytests which are included in this patch series
  on sandbox build locally.
* In Travis CI, tests skipped (or 'S', but it's not a failure, 'E' nor 'F')
  because "virt-make-fs" cannot be executed.

Issues
==
* Timing of executing capsules-on-disk
  Currently, processing a capsule is triggered only as part of
  UEFI subsystem initialization. This means that, for example,
  firmware update, may not take place at system booting time and
  will potentially be delayed until a first call of any UEFI functions.
=> See patch#5 for my proposal
* A bunch of warnings like
WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef'
where possible
  I don't think that fixing those improves anything.
* Add a document in uefi.rst

TODO's
==
(Won't be addressed in this series.)
* capsule authentication
* capsule dependency (dependency expression instruction set, or depex)
* loading drivers in a capsule
* handling RESET flag in a capsule and QeuryCapsuleCaps
* full semantics of ESRT (EFI System Resource Table)
* enabling capsule API at runtime
* json capsule
* recovery from update failure

Changes
===
v10 (November 30, 2020)
* allow for only the latest version of descriptor/format (Patch#4)
* replace all 'printf'/'EFI_PRINT' with log_xxx() (Patch#4,#5)
* fix a potential bug of overrunning 'struct 
  efi_firmware_management_capsule_header' (Patch#8)
* fix the version of a created capsule image to "3", removing "--version"
  option of mkeficapsule command (Patch#8-#10)

v9 (November 17, 2020)
* rebased on v2021.01-rc2
* removed already-merged patches
* aligned with a function prototype change of efi_create_indexed_name()
  (Patch#1-2)
# See Travis CI status in v8 below

v8 (November 13, 2020)
* fix a "not used" warning against update_load() in some configuration
  (Patch#3)
* fix failures (marked as 'F') in *secure boot* test in Travis CI by
  making "EFI_CAPSULE_ON_DISK_EARLY" 'default n' (Patch#8)
* fix failures (marked as 'E') at pytest setup in Travis CI by changing
  a python file's name along with removing unused definitions (Patch#16)
* add Patch#18 to enable tests to be run with default sandbox config
  (Patch#18)

v7 (October 29, 2020)
* rename CONFIG_DFU_ALT to CONFIG_DFU_WRITE_ALT (Patch#1,#3,#13)

v6 RESEND (October 29, 2020)
* rebased on v2021.01-rc1

v6 (September 7, 2020)
* temporarily drop the prerequisite patch[2]
* add a missing field (dependencies) in efi_api.h (but never used) (Patch#10)
* add a missing field (image_capsule_support) and related definitions
  in efi_api.h (Patch#10, #15)
* cosmetic changes on constant definitions in efi_api.h (Patch#10)
* strict check for INVALID_PARAMETER at GET_IMAGE_INFO api (Patch#11,#13

[PATCH v10 01/11] efi_loader: define UpdateCapsule api

2020-11-30 Thread AKASHI Takahiro
In this commit, skeleton functions for capsule-related API's are
added under CONFIG_EFI_UPDATE_CAPSULE configuration.
Detailed implementation for a specific capsule type will be added
in the succeeding patches.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_api.h|  12 +++
 include/efi_loader.h |  13 +++
 lib/efi_loader/Kconfig   |  11 +++
 lib/efi_loader/Makefile  |   1 +
 lib/efi_loader/efi_capsule.c | 165 +++
 lib/efi_loader/efi_runtime.c | 104 --
 lib/efi_loader/efi_setup.c   |  64 +++---
 7 files changed, 316 insertions(+), 54 deletions(-)
 create mode 100644 lib/efi_loader/efi_capsule.c

diff --git a/include/efi_api.h b/include/efi_api.h
index 5744f6aed86d..c128a0a66ce8 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -217,6 +217,10 @@ enum efi_reset_type {
 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE0x0002
 #define CAPSULE_FLAGS_INITIATE_RESET   0x0004
 
+#define EFI_CAPSULE_REPORT_GUID \
+   EFI_GUID(0x39b68c46, 0xf7fb, 0x441b, 0xb6, 0xec, \
+0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3)
+
 struct efi_capsule_header {
efi_guid_t capsule_guid;
u32 header_size;
@@ -224,6 +228,14 @@ struct efi_capsule_header {
u32 capsule_image_size;
 } __packed;
 
+struct efi_capsule_result_variable_header {
+   u32 variable_total_size;
+   u32 reserved;
+   efi_guid_t capsule_guid;
+   struct efi_time capsule_processed;
+   efi_status_t capsule_status;
+} __packed;
+
 #define EFI_RT_SUPPORTED_GET_TIME  0x0001
 #define EFI_RT_SUPPORTED_SET_TIME  0x0002
 #define EFI_RT_SUPPORTED_GET_WAKEUP_TIME   0x0004
diff --git a/include/efi_loader.h b/include/efi_loader.h
index f550ced56876..d22f7a43ad09 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -207,6 +207,8 @@ extern const efi_guid_t efi_guid_cert_type_pkcs7;
 
 /* GUID of RNG protocol */
 extern const efi_guid_t efi_guid_rng_protocol;
+/* GUID of capsule update result */
+extern const efi_guid_t efi_guid_capsule_report;
 
 extern unsigned int __efi_runtime_start, __efi_runtime_stop;
 extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop;
@@ -807,6 +809,17 @@ void efi_memcpy_runtime(void *dest, const void *src, 
size_t n);
 /* commonly used helper function */
 u16 *efi_create_indexed_name(u16 *buffer, const char *name, unsigned int 
index);
 
+/* Capsule update */
+efi_status_t EFIAPI efi_update_capsule(
+   struct efi_capsule_header **capsule_header_array,
+   efi_uintn_t capsule_count,
+   u64 scatter_gather_list);
+efi_status_t EFIAPI efi_query_capsule_caps(
+   struct efi_capsule_header **capsule_header_array,
+   efi_uintn_t capsule_count,
+   u64 *maximum_capsule_size,
+   u32 *reset_type);
+
 #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
 
 /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 075481428cdf..3ca396df3646 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -93,6 +93,17 @@ config EFI_SET_TIME
  Provide the SetTime() runtime service at boottime. This service
  can be used by an EFI application to adjust the real time clock.
 
+config EFI_HAVE_CAPSULE_SUPPORT
+   bool
+
+config EFI_RUNTIME_UPDATE_CAPSULE
+   bool "UpdateCapsule() runtime service"
+   default n
+   select EFI_HAVE_CAPSULE_SUPPORT
+   help
+ Select this option if you want to use UpdateCapsule and
+ QueryCapsuleCapabilities API's.
+
 config EFI_DEVICE_PATH_TO_TEXT
bool "Device path to text protocol"
default y
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 8892fb01e125..8d729abdfa78 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -23,6 +23,7 @@ endif
 obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
 obj-y += efi_bootmgr.o
 obj-y += efi_boottime.o
+obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o
 obj-y += efi_console.o
 obj-y += efi_device_path.o
 obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_device_path_to_text.o
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
new file mode 100644
index ..575fa75b0a2f
--- /dev/null
+++ b/lib/efi_loader/efi_capsule.c
@@ -0,0 +1,165 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  EFI Capsule
+ *
+ *  Copyright (c) 2018 Linaro Limited
+ * Author: AKASHI Takahiro
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+const efi_guid_t efi_guid_capsule_report = EFI_CAPSULE_REPORT_GUID;
+
+/**
+ * get_last_capsule - get the last capsule index
+ *
+ * Retrieve the index of the capsule invoked last time from "CapsuleLast"
+ * variable.
+ *
+ * Return:
+ * * > 0   - the last capsule index invoked
+ * * 0x- on error, or no ca

Re: [PATCH v2] gpio: Add support for DM GPIO for Kirkwood

2020-11-30 Thread Stefan Roese

On 29.11.20 11:08, Harm Berntsen wrote:

The Armada driver also works on Nedap's custom Kirkwood board with a
Marvell 88F6180 CPU. The original commit of that driver,
commit 704d9a645e17 ("gpio: Add DM GPIO driver for Marvell MVEBU"),
also mentions that this driver would be suitable for Kirkwood. This
does not completely replace the Kirkwood specific driver as there
are still boards depending on that driver.

Signed-off-by: Harm Berntsen 
CC: Stefan Roese ,


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
Canges for v2:
- Made commit message more clear

  drivers/gpio/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 202fcc6f47..1f41bd3d55 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -374,7 +374,7 @@ config SIFIVE_GPIO
  
  config MVEBU_GPIO

bool "Marvell MVEBU GPIO driver"
-   depends on DM_GPIO && ARCH_MVEBU
+   depends on DM_GPIO && (ARCH_MVEBU || ARCH_KIRKWOOD)
default y
help
  Say yes here to support Marvell MVEBU (Armada XP/38x) GPIOs.




Viele Grüße,
Stefan

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


Re: [PATCH] gpio: Add support for DM GPIO for Kirkwood

2020-11-30 Thread Stefan Roese

Hi Harm,

On 29.11.20 11:01, Harm Berntsen wrote:

Hi Stefan,

Thanks for your review.

I've looked into the usage of the kw_gpio driver. The soft_i2c part I
mentioned in the commit appeared to be specific to my board
configuration. I've replaced the usage of that driver with the DM based
i2c-gpio driver there.


Good.


All the usage of the kw_gpio functions is in board-specific code. I
think the kw_gpio driver can be deprecated and board maintainers could
update their code.


Yes, that would be great. We probably need some way to deprecate this
driver, so that current users will be notified top switch to the common
MVEBU DM GPIO driver when compiling for these boards.

Thanks,
Stefan


Kind regards,
Harm

-Original Message-
From: Stefan Roese 
To: Harm Berntsen , u-boot@lists.denx.de

Subject: Re: [PATCH] gpio: Add support for DM GPIO for Kirkwood
Date: Sat, 28 Nov 2020 11:08:43 +0100

Hi Harm,

On 27.11.20 22:56, Harm Berntsen wrote:

The Armada driver also works on Nedap's ax8008 Kirkwood board with a
Marvell 88F6180 CPU. The original commit of that driver,
704d9a645e1790e568abf43c5eff2de0d7b135ed also mentions that this
driver
would be suitable for Kirkwood.


Well, this was really a long time ago. ;)


This driver does not completely replace the Kirkwood specific driver
as
there are still dependencies on that driver(i.e. soft_i2c.c. in our
case).


So what work needs to be doney to completely replace the old legacy
kw_gpio driver and remove it completely? Could you perhaps tackle it
as well?

Other than that:

Reviewed-by: Stefan Roese 

Thanks,
Stefan


Signed-off-by: Harm Berntsen 
CC: Stefan Roese 
---

   drivers/gpio/Kconfig | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 202fcc6f47..1f41bd3d55 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -374,7 +374,7 @@ config SIFIVE_GPIO
   
   config MVEBU_GPIO

 bool "Marvell MVEBU GPIO driver"
-   depends on DM_GPIO && ARCH_MVEBU
+   depends on DM_GPIO && (ARCH_MVEBU || ARCH_KIRKWOOD)
 default y
 help
   Say yes here to support Marvell MVEBU (Armada XP/38x)
GPIOs.




Viele Grüße,
Stefan





Viele Grüße,
Stefan

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


[PATCH 1/1] doc: allow building htmldoc with Sphinx 3+

2020-11-30 Thread Heinrich Schuchardt
Due to removed function c_funcptr_sig_re building with Sphinx 3 fails.

With the patch building succeeds with a lot of warnings if the '-W' flag is
removed from doc/Makefile. Most of the documentation is correct

This follows the approach taken by the Linux kernel.

Signed-off-by: Heinrich Schuchardt 
---
 doc/conf.py | 29 -
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/doc/conf.py b/doc/conf.py
index 93250a6aee..ee7f201724 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -36,7 +36,34 @@ latex_engine = 'xelatex'
 # Add any Sphinx extension module names here, as strings. They can be
 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
 # ones.
-extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'cdomain', 
'kfigure']
+extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'kfigure']
+
+#
+# cdomain is badly broken in Sphinx 3+. Leaving it out generates *most*
+# of the docs correctly, but not all.
+#
+if major >= 3:
+if (major > 3) or (minor > 0 or patch >= 2):
+sys.stderr.write('''The build process with Sphinx 3+ is broken.
+You will have to remove -W in doc/Makefile.
+''')
+# Sphinx c function parser is more pedantic with regards to type
+# checking. Due to that, having macros at c:function cause problems.
+# Those needed to be escaped by using c_id_attributes[] array
+c_id_attributes = [
+
+# include/linux/compiler.h
+"__maybe_unused",
+
+# include/efi.h
+"EFIAPI",
+
+# include/efi_loader.h
+"__efi_runtime",
+]
+
+else:
+extensions.append('cdomain')

 # The name of the math extension changed on Sphinx 1.4
 if (major == 1 and minor > 3) or (major > 1):
--
2.29.2



[PATCH 1/1] MAINTAINERS: assign include/log.h

2020-11-30 Thread Heinrich Schuchardt
include/log.h belongs to LOGGING.

Signed-off-by: Heinrich Schuchardt 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 874cf2c0e5..2625fc629c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -758,6 +758,7 @@ T:  git https://gitlab.denx.de/u-boot/u-boot.git
 F: common/log*
 F: cmd/log.c
 F: doc/develop/logging.rst
+F: include/log.h
 F: lib/getopt.c
 F: test/log/
 F: test/py/tests/test_log.py
--
2.29.2



[PATCH 1/1] log: typos in include/log.h

2020-11-30 Thread Heinrich Schuchardt
Correct several typos.

Signed-off-by: Heinrich Schuchardt 
---
 include/log.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/log.h b/include/log.h
index e53afa490e..6bce560648 100644
--- a/include/log.h
+++ b/include/log.h
@@ -29,7 +29,7 @@ enum log_level_t {
LOGL_CRIT,
/** @LOGL_ERR: Error that prevents something from working */
LOGL_ERR,
-   /** @LOGL_WARNING: Warning may prevent optimial operation */
+   /** @LOGL_WARNING: Warning may prevent optimal operation */
LOGL_WARNING,
/** @LOGL_NOTICE: Normal but significant condition, printf() */
LOGL_NOTICE,
@@ -322,7 +322,7 @@ void __assert_fail(const char *assertion, const char *file, 
unsigned int line,
  *
  * Members marked as 'not allocated' are stored as pointers and the caller is
  * responsible for making sure that the data pointed to is not overwritten.
- * Memebers marked as 'allocated' are allocated (e.g. via strdup()) by the log
+ * Members marked as 'allocated' are allocated (e.g. via strdup()) by the log
  * system.
  *
  * TODO(s...@chromium.org): Compress this struct down a bit to reduce space, 
e.g.
@@ -379,7 +379,7 @@ struct log_driver {
  * the run-time aspects of drivers (currently just a list of filters to apply
  * to records send to this device).
  *
- * @next_filter_num: Seqence number of next filter filter added (0=no filters
+ * @next_filter_num: Sequence number of next filter filter added (0=no filters
  * yet). This increments with each new filter on the device, but never
  * decrements
  * @flags: Flags for this filter (enum log_device_flags)
@@ -412,7 +412,7 @@ enum log_filter_flags {
 };

 /**
- * struct log_filter - criterial to filter out log messages
+ * struct log_filter - criteria to filter out log messages
  *
  * If a message matches all criteria, then it is allowed. If LOGFF_DENY is set,
  * then it is denied instead.
--
2.29.2