Re: [PATCH 01/11] imx: implement get_effective_memsize

2022-11-08 Thread Pali Rohár
On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:
> > Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize
> > 
> > On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:
> > > On 11/7/2022 3:55 PM, Pali Rohár wrote:
> > > > On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:
> > > > > From: Peng Fan 
> > > > >
> > > > > To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause
> > > > > the top 1MB not mapped as normal memory, because ARMV7-A use
> > > > > section mapping. So implement i.MX6/7 specific
> > > > > get_effective_memsize to fix the issue.
> > > > >
> > > > > Fixes: 777706bc("common/memsize.c: Fix get_effective_memsize()
> > > > > to check for overflow")
> > > > > Signed-off-by: Peng Fan 
> > > >
> > > > Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid
> > that issue?
> > >
> > > No, unless I decrease PHYS_SDRAM_SIZE.
> > 
> > So, what is the issue? I just do not see what happens after 777706bc
> > that RAM size is calculated incorrectly in your case. I did not catch the
> > description from commit message. What are your gd->ram_size and
> > CONFIG_MAX_MEM_MAPPED values that current code does not work?
> 
> The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED,
> the ram_size already decreased by 4KB.

If base is 2GB and size is 2GB then ram_top is 4GB which cannot be
represented in 32-bit phys_size_t type and hence some of other u-boot
functions use 0 as ram_top. Mentioned commit tries to fix this issue.
I guess that you have some other hidden problem and my change just
showed implication of that. Could you check how is gd->ram_top
configured with and without this change?

> Regards,
> Peng.
> 
> > 
> > > Regards,
> > > Peng.
> > >
> > > >
> > > > > ---
> > > > >   arch/arm/mach-imx/cache.c | 14 ++
> > > > >   1 file changed, 14 insertions(+)
> > > > >
> > > > > diff --git a/arch/arm/mach-imx/cache.c b/arch/arm/mach-imx/cache.c
> > > > > index ab9b621a2a6..69a085abee7 100644
> > > > > --- a/arch/arm/mach-imx/cache.c
> > > > > +++ b/arch/arm/mach-imx/cache.c
> > > > > @@ -7,10 +7,24 @@
> > > > >   #include 
> > > > >   #include 
> > > > >   #include 
> > > > > +#include 
> > > > >   #include 
> > > > >   #include 
> > > > >   #include 
> > > > > +DECLARE_GLOBAL_DATA_PTR;
> > > > > +
> > > > > +phys_size_t get_effective_memsize(void) { #ifndef
> > > > > +CONFIG_MAX_MEM_MAPPED
> > > > > + return gd->ram_size;
> > > > > +#else
> > > > > + /* limit stack to what we can reasonable map */
> > > > > + return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
> > > > > + CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
> > > > > +
> > > > >   void enable_ca7_smp(void)
> > > > >   {
> > > > >   u32 val;
> > > > > --
> > > > > 2.36.0
> > > > >


[PATCH v4 0/1] Makefile: rework u-boot-initial-env target

2022-11-08 Thread Max Krummenacher
From: Max Krummenacher 


With CONFIG_LTO enabled the current way of extracting the
configured environment no longer works, i.e. the object file
content changes due to LTO.

Build a host tool which prints the configured environment instead
of using objcopy and friends to achive the same.

The code and Makefile changes were mostly stolen from tools/env/
i.e. the target userspace tools to access the environment.


Changes in v4:
- add '(objtree)/' when calling the tool. Suggested by Pali Rohár.
- renamed patch, as more than just the Makefile has changes

Changes in v3:
- moved the tool from scripts/ to tools/. Suggested by Tom Rini
- changed the dependencies to '$(env_h)' and 'tools'.
  Suggested by Tom Rini and Pali Rohár.
- removed the sed rule which replaces \x00 with \x0A as this is already
  done by the tool. Suggested by Pali Rohár.

Changes in v2:
- reworked to build a host tool which prints the configured
  environment as proposed by Pali Rohár
  https://lore.kernel.org/u-boot/20221018174827.1393211-1-max.oss...@gmail.com/
- renamed patch, v1 used "Makefile: fix u-boot-initial-env target if lto is 
enabled"

Max Krummenacher (1):
  u-boot-initial-env: rework make target

 Makefile|  9 +
 tools/.gitignore|  1 +
 tools/Makefile  |  3 +++
 tools/printinitialenv.c | 44 +
 4 files changed, 53 insertions(+), 4 deletions(-)
 create mode 100644 tools/printinitialenv.c

-- 
2.35.3



[PATCH v4 1/1] u-boot-initial-env: rework make target

2022-11-08 Thread Max Krummenacher
From: Max Krummenacher 

With LTO enabled the U-Boot initial environment is no longer stored
in an easy accessible section in env/common.o. I.e. the section name
changes from build to build, its content maybe compressed and it is
annotated with additional data.

Drop trying to read the initial env with elf tools from the compiler
specific object file in favour of adding and using a host tool with
the only functionality of printing the initial env to stdout.

See also:
https://lore.kernel.org/all/927b122e-1f62-e790-f5ca-30bae4332...@foss.st.com/

Signed-off-by: Max Krummenacher 

---

Changes in v4:
- add '(objtree)/' when calling the tool. Suggested by Pali Rohár.
- renamed patch, as more than just the Makefile has changes

Changes in v3:
- moved the tool from scripts/ to tools/. Suggested by Tom Rini
- changed the dependencies to '$(env_h)' and 'tools'.
  Suggested by Tom Rini and Pali Rohár.
- removed the sed rule which replaces \x00 with \x0A as this is already
  done by the tool. Suggested by Pali Rohár.

Changes in v2:
- reworked to build a host tool which prints the configured
  environment as proposed by Pali Rohár
  https://lore.kernel.org/u-boot/20221018174827.1393211-1-max.oss...@gmail.com/
- renamed patch, v1 used "Makefile: fix u-boot-initial-env target if lto is 
enabled"

 Makefile|  9 +
 tools/.gitignore|  1 +
 tools/Makefile  |  3 +++
 tools/printinitialenv.c | 44 +
 4 files changed, 53 insertions(+), 4 deletions(-)
 create mode 100644 tools/printinitialenv.c

diff --git a/Makefile b/Makefile
index 0f1174718f7..c0669840dc7 100644
--- a/Makefile
+++ b/Makefile
@@ -2442,11 +2442,12 @@ endif
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 
 quiet_cmd_genenv = GENENV  $@
-cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ 
env/common.o; \
-   sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' $@; 
\
-   sort --field-separator== -k1,1 --stable $@ -o $@
+cmd_genenv = \
+   $(objtree)/tools/printinitialenv | \
+   sed -e '/^\s*$$/d' | \
+   sort --field-separator== -k1,1 --stable -o $@
 
-u-boot-initial-env: u-boot.bin
+u-boot-initial-env: $(env_h) tools FORCE
$(call if_changed,genenv)
 
 # Consistency checks
diff --git a/tools/.gitignore b/tools/.gitignore
index d3a93ff294a..28e8ce2a07a 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -28,6 +28,7 @@
 /mxsboot
 /ncb
 /prelink-riscv
+/printinitialenv
 /proftool
 /relocate-rela
 /spl_size_limit
diff --git a/tools/Makefile b/tools/Makefile
index 34a1aa7a8b7..a3afdee7813 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -245,6 +245,9 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
 hostprogs-$(CONFIG_ASN1_COMPILER)  += asn1_compiler
 HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
 
+# host tool to dump the currently configured default environment
+hostprogs-y+= printinitialenv
+
 HOSTCFLAGS_mkeficapsule.o += \
$(shell pkg-config --cflags gnutls 2> /dev/null || echo "")
 HOSTCFLAGS_mkeficapsule.o += \
diff --git a/tools/printinitialenv.c b/tools/printinitialenv.c
new file mode 100644
index 000..c58b234d679
--- /dev/null
+++ b/tools/printinitialenv.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2022
+ * Max Krummenacher, Toradex
+ *
+ * Snippets taken from tools/env/fw_env.c
+ *
+ * This prints the list of default environment variables as currently
+ * configured.
+ *
+ */
+
+#include 
+
+/* Pull in the current config to define the default environment */
+#include 
+
+#ifndef __ASSEMBLY__
+#define __ASSEMBLY__ /* get only #defines from config.h */
+#include 
+#undef __ASSEMBLY__
+#else
+#include 
+#endif
+
+#define DEFAULT_ENV_INSTANCE_STATIC
+#include 
+#include 
+
+int main(void)
+{
+   char *env, *nxt;
+
+   for (env = default_environment; *env; env = nxt + 1) {
+   for (nxt = env; *nxt; ++nxt) {
+   if (nxt >= 
&default_environment[sizeof(default_environment)]) {
+   fprintf(stderr, "## Error: environment not 
terminated\n");
+   return -1;
+   }
+   }
+   printf("%s\n", env);
+   }
+   return 0;
+}
-- 
2.35.3



[PATCH] mtd: nand: drop EXPORT_SYMBOL_GPL for nanddev_erase()

2022-11-08 Thread Dario Binacchi
This function is only used within this module, so it is no longer
necessary to use EXPORT_SYMBOL_GPL().

This patch parallels the work done in the following patch:
https://lore.kernel.org/linux-mtd/20221018170205.1733958-1-dario.binac...@amarulasolutions.com

Signed-off-by: Dario Binacchi 

---

 drivers/mtd/nand/core.c  | 3 +--
 include/linux/mtd/nand.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
index 99c29670c75e..4b9dd6a92694 100644
--- a/drivers/mtd/nand/core.c
+++ b/drivers/mtd/nand/core.c
@@ -129,7 +129,7 @@ EXPORT_SYMBOL_GPL(nanddev_isreserved);
  *
  * Return: 0 in case of success, a negative error code otherwise.
  */
-int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos)
+static int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos)
 {
unsigned int entry;
 
@@ -147,7 +147,6 @@ int nanddev_erase(struct nand_device *nand, const struct 
nand_pos *pos)
 
return nand->ops->erase(nand, pos);
 }
-EXPORT_SYMBOL_GPL(nanddev_erase);
 
 /**
  * nanddev_mtd_erase() - Generic mtd->_erase() implementation for NAND devices
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 7774c17ad5d5..aeb38dec2e03 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -691,7 +691,6 @@ static inline bool nanddev_io_iter_end(struct nand_device 
*nand,
 
 bool nanddev_isbad(struct nand_device *nand, const struct nand_pos *pos);
 bool nanddev_isreserved(struct nand_device *nand, const struct nand_pos *pos);
-int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos);
 int nanddev_markbad(struct nand_device *nand, const struct nand_pos *pos);
 
 /* BBT related functions */
-- 
2.32.0



Re: [PATCH] mtd: nand: drop EXPORT_SYMBOL_GPL for nanddev_erase()

2022-11-08 Thread Michael Nazzareno Trimarchi
On Tue, Nov 8, 2022 at 10:07 AM Dario Binacchi
 wrote:
>
> This function is only used within this module, so it is no longer
> necessary to use EXPORT_SYMBOL_GPL().
>
> This patch parallels the work done in the following patch:
> https://lore.kernel.org/linux-mtd/20221018170205.1733958-1-dario.binac...@amarulasolutions.com
>
> Signed-off-by: Dario Binacchi 

Reviewed-By: Michael Trimarchi 

>
> ---
>
>  drivers/mtd/nand/core.c  | 3 +--
>  include/linux/mtd/nand.h | 1 -
>  2 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
> index 99c29670c75e..4b9dd6a92694 100644
> --- a/drivers/mtd/nand/core.c
> +++ b/drivers/mtd/nand/core.c
> @@ -129,7 +129,7 @@ EXPORT_SYMBOL_GPL(nanddev_isreserved);
>   *
>   * Return: 0 in case of success, a negative error code otherwise.
>   */
> -int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos)
> +static int nanddev_erase(struct nand_device *nand, const struct nand_pos 
> *pos)
>  {
> unsigned int entry;
>
> @@ -147,7 +147,6 @@ int nanddev_erase(struct nand_device *nand, const struct 
> nand_pos *pos)
>
> return nand->ops->erase(nand, pos);
>  }
> -EXPORT_SYMBOL_GPL(nanddev_erase);
>
>  /**
>   * nanddev_mtd_erase() - Generic mtd->_erase() implementation for NAND 
> devices
> diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
> index 7774c17ad5d5..aeb38dec2e03 100644
> --- a/include/linux/mtd/nand.h
> +++ b/include/linux/mtd/nand.h
> @@ -691,7 +691,6 @@ static inline bool nanddev_io_iter_end(struct nand_device 
> *nand,
>
>  bool nanddev_isbad(struct nand_device *nand, const struct nand_pos *pos);
>  bool nanddev_isreserved(struct nand_device *nand, const struct nand_pos 
> *pos);
> -int nanddev_erase(struct nand_device *nand, const struct nand_pos *pos);
>  int nanddev_markbad(struct nand_device *nand, const struct nand_pos *pos);
>
>  /* BBT related functions */
> --
> 2.32.0
>


-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
mich...@amarulasolutions.com
__

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
i...@amarulasolutions.com
www.amarulasolutions.com


Re: [u-boot][PATCH 00/14] rawnand: omap_gpmc: driver model support

2022-11-08 Thread Michael Nazzareno Trimarchi
Hi Roger

On Fri, Nov 4, 2022 at 2:27 PM Roger Quadros  wrote:
>
> Hi,
>
> On 11/10/2022 14:49, Roger Quadros wrote:
> > Hi,
> >
> > This series adds driver model support for rawnand: omap_gpmc
> > and omap_elm drivers.
> >
> > This will enable the driver to be used on K2/K3 platforms as well.
>
> Any comments on patches 5 and later? Thanks
>

We will try to close this week.

Michael

>
> cheers,
> -roger
>
> >
> > cheers,
> > -roger
> >
> > Roger Quadros (14):
> >   mtd: rawnand: omap_gpmc: Deprecate asm/arch/mem.h
> >   mtd: rawnand: omap_gpmc: Enable build for K2/K3 platforms
> >   mtd: rawnand: omap_gpmc: Fix build warning on 64-bit platforms
> >   mtd: rawnand: omap_gpmc: Optimize NAND reads
> >   mtd: rawnand: omap_gpmc: Fix BCH6/16 HW based correction
> >   mtd: rawnand: nand_base: Allow base driver to be used in SPL without
> > nand_bbt
> >   mtd: rawnand: nand_spl_loaders: Fix cast type build warning
> >   mtd: rawnand: omap_gpmc: Reduce .bss usage
> >   dt-bindings: mtd: Add ti,gpmc-nand DT binding documentation
> >   mtd: rawnand: omap_gpmc: support u-boot driver model
> >   mtd: rawnand: omap_gpmc: Add SPL NAND support
> >   mtd: rawnand: omap_gpmc: Enable SYS_NAND_PAGE_COUNT for OMAP_GPMC
> >   dt-bindings: mtd: Add ti,elm DT binding documentation
> >   mtd: rawnand: omap_elm: u-boot driver model support
> >
> >  doc/device-tree-bindings/mtd/ti,elm.yaml  |  72 +++
> >  .../mtd/ti,gpmc-nand.yaml | 129 +
> >  drivers/mtd/nand/raw/Kconfig  |  11 +-
> >  drivers/mtd/nand/raw/Makefile |   2 +-
> >  drivers/mtd/nand/raw/nand_base.c  |  18 +-
> >  drivers/mtd/nand/raw/nand_spl_loaders.c   |   2 +-
> >  drivers/mtd/nand/raw/omap_elm.c   |  33 +-
> >  .../mtd => drivers/mtd/nand/raw}/omap_elm.h   |   6 +
> >  drivers/mtd/nand/raw/omap_gpmc.c  | 500 +-
> >  9 files changed, 637 insertions(+), 136 deletions(-)
> >  create mode 100644 doc/device-tree-bindings/mtd/ti,elm.yaml
> >  create mode 100644 doc/device-tree-bindings/mtd/ti,gpmc-nand.yaml
> >  rename {include/linux/mtd => drivers/mtd/nand/raw}/omap_elm.h (97%)
> >



-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
mich...@amarulasolutions.com
__

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
i...@amarulasolutions.com
www.amarulasolutions.com


Re: [PATCH v5 2/2] serial: mxc: have putc use the TXFIFO

2022-11-08 Thread SCHNEIDER Johannes
Hi Fabio,


gave it another round, and discussed it with Grygorii - he pointed out that it 
would be better to do the "fifo empty" or even better "byte sent" checks in 
"our" code instead of adding more complexity to the serial_mxc for handling a 
buffer/TXFIFO to be properly flushed prior to each of the multiple calls to 
set_baudrate during startup between spl and uboot;
i tried a couple of approaches which would add checks to "pending" to either a 
new "puts"-method, or "set_bgr" with partial success - the problem remains that 
long printfs during board_init - which happens before the serial device is 
actually fully initialized - get cut of near the end... anyway: added 
complexity -> !KISS

so i'd say go for the revert; which reduces use of the fifo back to just the 
first byte


sorry for the trouble
Johannes



From: Fabio Estevam 
Sent: Monday, November 7, 2022 22:17
To: SCHNEIDER Johannes; TERTYCHNYI Grygorii
Cc: Pali Rohár; Fabio Estevam; Tim Harvey; u-boot@lists.denx.de; 
peng@oss.nxp.com; sba...@denx.de; trini; GEO-CHHER-bsp-development; Peng Fan
Subject: Re: [PATCH v5 2/2] serial: mxc: have putc use the TXFIFO

This email is not from Hexagon’s Office 365 instance. Please be careful while 
clicking links, opening attachments, or replying to this email.


Hi Johannes and Grygorii,

On Thu, Nov 3, 2022 at 8:14 AM Fabio Estevam  wrote:

> There is a typo here: it should be mxc_serial_putc() instead.
>
> No, it does not fix the issue.
>
> Not sure why you mentioned imx6. The issue can be reproduced on imx8mm as 
> well.

Do you plan to submit a patch fixing the regression?

Thanks


LX2106A U-Boot: board_eth_init() not called any more

2022-11-08 Thread Stefan Roese

Dear NXP LX2160 developers!

With commit 94633c36f9eb ("net: Make DM_ETH be selected by NETDEVICE")
DM_ETH is now mandatory. And net/eth_legacy.c is not compiled anymore.
Resulting in board_eth_init() not being called anymore. On NXP LX2160
platforms (and some other NXP platforms as well), this functions and
the legacy net/eth infrastructure seems still to be used AFAICT.

So could you please let me know, if and how ethernet support on these
boards is supposed to work with recent U-Boot versions on LX2160? My
understanding is, that the current versions will result in an output
like this:

...
In:serial_pl01x
Out:   serial_pl01x
Err:   serial_pl01x
SEC0:  RNG instantiated
Net:   No ethernet found.
...

Or did I miss something?

Thanks,
Stefan


Re: [PATCH v6 02/10] lib: uuid: introduce be_uuid_str_to_le_bin function

2022-11-08 Thread Abdellatif El Khlifi
On Mon, Oct 24, 2022 at 03:07:35PM +0300, Ilias Apalodimas wrote:
> Hi Abdellatif, 
> 
> On Thu, Oct 13, 2022 at 11:38:49AM +0100, Abdellatif El Khlifi wrote:
> > convert big endian UUID string to little endian buffer
> 
> You don't really need the be_ suffix on the declaration, endianness doesn't
> apply to strings.  Can't we do something similar to uuid_str_to_bin() and
> just convert to LE?

Thanks, done in v7 [1]. Please have a look.

[1]: 
https://lore.kernel.org/all/20221107192055.21669-3-abdellatif.elkhl...@arm.com/

> 
> Thanks
> /Ilias
> > 
> > Signed-off-by: Abdellatif El Khlifi 
> > Cc: Tom Rini 
> > Cc: Simon Glass 
> > Cc: Ilias Apalodimas 
> > Cc: Jens Wiklander 
> > 
> > ---
> > 
> > Changelog:
> > ===
> > 
> > v4:
> > 
> > * rename ffa_uuid_str_to_bin to be_uuid_str_to_le_bin and put in
> >   a standalone commit (the current)
> > 
> > v3:
> > 
> > * introduce ffa_uuid_str_to_bin (provided by
> >   arm_ffa: introduce Arm FF-A low-level driver)
> > 
> > include/uuid.h |  8 +++
> >  lib/uuid.c | 64 ++
> >  2 files changed, 72 insertions(+)
> > 
> > diff --git a/include/uuid.h b/include/uuid.h
> > index 4a4883d3b5..ad3af350f9 100644
> > --- a/include/uuid.h
> > +++ b/include/uuid.h
> > @@ -2,6 +2,8 @@
> >  /*
> >   * Copyright (C) 2014 Samsung Electronics
> >   * Przemyslaw Marczak 
> > + * (C) Copyright 2022 ARM Limited
> > + * Abdellatif El Khlifi 
> >   */
> >  #ifndef __UUID_H__
> >  #define __UUID_H__
> > @@ -44,4 +46,10 @@ int uuid_guid_get_bin(const char *guid_str, unsigned 
> > char *guid_bin);
> >  const char *uuid_guid_get_str(const unsigned char *guid_bin);
> >  void gen_rand_uuid(unsigned char *uuid_bin);
> >  void gen_rand_uuid_str(char *uuid_str, int str_format);
> > +
> > +/**
> > + * be_uuid_str_to_le_bin - Converts a big endian UUID string to a little 
> > endian buffer
> > + */
> > +int be_uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin);
> > +
> >  #endif
> > diff --git a/lib/uuid.c b/lib/uuid.c
> > index 465e1ac38f..15a9ab49d5 100644
> > --- a/lib/uuid.c
> > +++ b/lib/uuid.c
> > @@ -1,6 +1,8 @@
> >  // SPDX-License-Identifier: GPL-2.0+
> >  /*
> >   * Copyright 2011 Calxeda, Inc.
> > + * (C) Copyright 2022 ARM Limited
> > + * Abdellatif El Khlifi 
> >   */
> >  
> >  #include 
> > @@ -346,6 +348,68 @@ int uuid_str_to_bin(const char *uuid_str, unsigned 
> > char *uuid_bin,
> > return 0;
> >  }
> >  
> > +/**
> > + * be_uuid_str_to_le_bin - Converts a big endian UUID string to a little 
> > endian buffer
> > + * @uuid_str:  UUID string in big endian format (36 bytes wide + '/0')
> > + * @uuid_bin:  preallocated 16 bytes UUID buffer in little endian 
> > format
> > + *
> > + * UUID string is 36 characters (36 bytes):
> > + *
> > + * ----
> > + * be   be  be   be  be
> > + *
> > + * where x is a hexadecimal character. Fields are separated by '-'s.
> > + * When converting to a binary UUID, these endianness rules apply:
> > + * be: means the field in the string is considered a big endian hex 
> > number
> > + *and should be converted to little endian binary format
> > + *
> > + * Return:
> > + *
> > + *uuid_bin filled with little endian UUID data
> > + *On success 0 is returned. Otherwise, failure code.
> > + */
> > +int be_uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
> > +{
> > +   u16 tmp16 = 0;
> > +   u32 tmp32 = 0;
> > +   u64 tmp64 = 0;
> > +
> > +   if (!uuid_str_valid(uuid_str) || !uuid_bin)
> > +   return -EINVAL;
> > +
> > +   /*
> > +* reverse bytes from big to little endian
> > +*/
> > +   tmp32 = simple_strtoul(uuid_str, NULL, 16);
> > +   memcpy(uuid_bin, &tmp32, 4);
> > +
> > +   /*
> > +* reverse bytes from big to little endian
> > +*/
> > +   tmp16 = simple_strtoul(uuid_str + 9, NULL, 16);
> > +   memcpy(uuid_bin + 4, &tmp16, 2);
> > +
> > +   /*
> > +* reverse bytes from big to little endian
> > +*/
> > +   tmp16 = simple_strtoul(uuid_str + 14, NULL, 16);
> > +   memcpy(uuid_bin + 6, &tmp16, 2);
> > +
> > +   /*
> > +* reverse bytes from big to little endian
> > +*/
> > +   tmp16 = simple_strtoul(uuid_str + 19, NULL, 16);
> > +   memcpy(uuid_bin + 8, &tmp16, 2);
> > +
> > +   /*
> > +* reverse bytes from big to little endian
> > +*/
> > +   tmp64 = simple_strtoull(uuid_str + 24, NULL, 16);
> > +   memcpy(uuid_bin + 10, (char *)&tmp64, 6);
> > +
> > +   return 0;
> > +}
> > +
> >  /*
> >   * uuid_bin_to_str() - convert big endian binary data to string UUID or 
> > GUID.
> >   *
> > -- 
> > 2.17.1
> > 


Re: [PATCH v6 04/10] arm_ffa: efi: unmap RX/TX buffers

2022-11-08 Thread Abdellatif El Khlifi
On Mon, Oct 24, 2022 at 03:08:53PM +0300, Ilias Apalodimas wrote:
> On Thu, Oct 13, 2022 at 11:38:51AM +0100, Abdellatif El Khlifi wrote:
> > unmap RX/TX buffers at ExitBootServices()
> > 
> > Unmapping the RX/TX buffers created by u-boot is needed before EFI
> > runtime.
> > 
> > At EFI runtime the linux kernel takes care of allocating its own RX/TX
> > buffers and registering them with the secure world.
> > 
> > Secure world should be using the RX/TX buffers created by the kernel.
> > So, RX/TX buffers created by u-boot must be unmapped.
> > 
> > Signed-off-by: Abdellatif El Khlifi 
> > Cc: Tom Rini 
> > Cc: Simon Glass 
> > Cc: Ilias Apalodimas 
> > Cc: Jens Wiklander 
> > ---
> >  lib/efi_loader/efi_boottime.c | 15 +++
> >  1 file changed, 15 insertions(+)
> > 
> > diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> > index a56021559b..2054b33568 100644
> > --- a/lib/efi_loader/efi_boottime.c
> > +++ b/lib/efi_loader/efi_boottime.c
> > @@ -3,6 +3,9 @@
> >   * EFI application boot time services
> >   *
> >   * Copyright (c) 2016 Alexander Graf
> > + *
> > + * (C) Copyright 2022 ARM Limited
> > + * Abdellatif El Khlifi 
> >   */
> >  
> >  #include 
> > @@ -23,6 +26,10 @@
> >  #include 
> >  #include 
> >  
> > +#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
> > +#include 
> > +#endif
> > +
> >  DECLARE_GLOBAL_DATA_PTR;
> >  
> >  /* Task priority level */
> > @@ -2178,6 +2185,14 @@ static efi_status_t EFIAPI 
> > efi_exit_boot_services(efi_handle_t image_handle,
> > dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);
> > }
> >  
> > +#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
> > +   /* unmap FF-A RX/TX buffers */
> > +   if (ffa_bus_ops_get()->rxtx_unmap())
> > +   debug("[efi_boottime][ERROR]: can not unmap FF-A RX/TX 
> > buffers\n");
> 
> Just do log_err() here and get rid of the else

Thanks. Done in v7.

> 
> > +   else
> > +   debug("[efi_boottime][INFO]: FF-A RX/TX buffers 
> > unmapped\n");
> > +#endif
> > +
> > /* Patch out unsupported runtime function */
> > efi_runtime_detach();
> >  
> > -- 
> > 2.17.1
> > 
> 
> Thanks
> /Ilias


Re: [PATCH v6 07/10] arm_ffa: introduce Sandbox test cases for UCLASS_FFA

2022-11-08 Thread Abdellatif El Khlifi
On Mon, Oct 24, 2022 at 03:10:09PM +0300, Ilias Apalodimas wrote:
> Hi Abdellatif
> On Thu, Oct 13, 2022 at 11:38:54AM +0100, Abdellatif El Khlifi wrote:
> > Add functional test cases for the FF-A core driver
> > 
> > These tests rely on the FF-A Sandbox driver which helps in
> >  inspecting the FF-A core driver.
> 
> This looks ok from me, but I'd prefer Simon having a quick look, since I am
> not an expert when it comes to sandbox and testing 

Thanks for the feedback Ilias.

Simon, could you please provide a feedback about the Sandbox part ?
> 
> Thanks
> /Ilias
> > 
> > Signed-off-by: Abdellatif El Khlifi 
> > Cc: Tom Rini 
> > Cc: Simon Glass 
> > Cc: Ilias Apalodimas 
> > Cc: Jens Wiklander 
> > 
> > ---
> > 
> > Changelog:
> > ===
> > 
> > v4: align sandbox tests with the new FF-A driver interfaces
> >  and new way of error handling
> > 
> > v1: introduce sandbox tests
> > 
> >  MAINTAINERS  |   1 +
> >  test/dm/Makefile |   2 +
> >  test/dm/ffa.c| 394 +++
> >  3 files changed, 397 insertions(+)
> >  create mode 100644 test/dm/ffa.c
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 598ae76e16..bf198f4ce1 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -256,6 +256,7 @@ F:  doc/arch/arm64.ffa.rst
> >  F: drivers/firmware/arm-ffa/
> >  F: include/arm_ffa.h
> >  F: include/sandbox_arm_ffa.h
> > +F: test/dm/ffa.c
> >  
> >  ARM FREESCALE IMX
> >  M: Stefano Babic 
> > diff --git a/test/dm/Makefile b/test/dm/Makefile
> > index 5178daa7cf..e5bc4b4bd6 100644
> > --- a/test/dm/Makefile
> > +++ b/test/dm/Makefile
> > @@ -1,6 +1,7 @@
> >  # SPDX-License-Identifier: GPL-2.0+
> >  #
> >  # Copyright (c) 2013 Google, Inc
> > +# (C) Copyright 2022 ARM Limited
> >  
> >  obj-$(CONFIG_UT_DM) += test-dm.o
> >  
> > @@ -81,6 +82,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
> >  obj-$(CONFIG_ACPI_PMC) += pmc.o
> >  obj-$(CONFIG_DM_PMIC) += pmic.o
> >  obj-$(CONFIG_DM_PWM) += pwm.o
> > +obj-$(CONFIG_SANDBOX_FFA) += ffa.o
> >  obj-$(CONFIG_QFW) += qfw.o
> >  obj-$(CONFIG_RAM) += ram.o
> >  obj-y += regmap.o
> > diff --git a/test/dm/ffa.c b/test/dm/ffa.c
> > new file mode 100644
> > index 00..052d5fc3f4
> > --- /dev/null
> > +++ b/test/dm/ffa.c
> > @@ -0,0 +1,394 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Functional tests for UCLASS_FFA  class
> > + *
> > + * (C) Copyright 2022 ARM Limited
> > + * Abdellatif El Khlifi 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include "../../drivers/firmware/arm-ffa/sandbox_arm_ffa_prv.h"
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/* Macros */
> > +
> > +#define LOG_MSG_SZ (100)
> > +#define LOG_CMD_SZ (LOG_MSG_SZ * 2)
> > +
> > +/* Functional tests for the UCLASS_FFA */
> > +
> > +static int dm_test_ffa_log(struct unit_test_state *uts, char *msg)
> > +{
> > +   char cmd[LOG_CMD_SZ] = {0};
> > +
> > +   console_record_reset();
> > +
> > +   snprintf(cmd, LOG_CMD_SZ, "echo \"%s\"", msg);
> > +   run_command(cmd, 0);
> > +
> > +   ut_assert_console_end();
> > +
> > +   return CMD_RET_SUCCESS;
> > +}
> > +
> > +static int check_fwk_version(struct ffa_prvdata *prvdata, struct 
> > sandbox_ffa_prvdata *sdx_prvdata,
> > +struct unit_test_state *uts)
> > +{
> > +   if (prvdata->fwk_version != sdx_prvdata->fwk_version) {
> > +   char msg[LOG_MSG_SZ] = {0};
> > +
> > +   snprintf(msg, LOG_MSG_SZ,
> > +"[%s]: Error: framework version: core = 0x%x , sandbox 
> >  = 0x%x", __func__,
> > +prvdata->fwk_version,
> > +   sdx_prvdata->fwk_version);
> > +
> > +   dm_test_ffa_log(uts, msg);
> > +   return CMD_RET_FAILURE;
> > +   }
> > +   return CMD_RET_SUCCESS;
> > +}
> > +
> > +static int check_endpoint_id(struct ffa_prvdata *prvdata, struct 
> > unit_test_state *uts)
> > +{
> > +   if (prvdata->id) {
> > +   char msg[LOG_MSG_SZ] = {0};
> > +
> > +   snprintf(msg, LOG_MSG_SZ,
> > +"[%s]: Error: endpoint id: core = 0x%x", __func__, 
> > prvdata->id);
> > +   dm_test_ffa_log(uts, msg);
> > +   return CMD_RET_FAILURE;
> > +   }
> > +   return CMD_RET_SUCCESS;
> > +}
> > +
> > +static int check_core_dev(struct ffa_prvdata *prvdata, struct 
> > unit_test_state *uts)
> > +{
> > +   if (!prvdata->dev) {
> > +   char msg[LOG_MSG_SZ] = {0};
> > +
> > +   snprintf(msg, LOG_MSG_SZ, "[%s]: Error: core device NULL", 
> > __func__);
> > +   dm_test_ffa_log(uts, msg);
> > +   return CMD_RET_FAILURE;
> > +   }
> > +   return CMD_RET_SUCCESS;
> > +}
> > +
> > +static int check_sandbox_dev(struct sandbox_ffa_prvdata *sdx_prvdata, 
> > struct unit_test_state *uts)
> > +{
> > +   if (!sdx_prvdata->dev) {
> > +   char msg[LOG_MSG_SZ] = {0};
> > +
> > +   snprintf(msg, LOG_MSG_SZ, "[%s]: Error: sandbox device NULL", 
> > __func__);
> > +   dm_t

Re: [PATCH v6 09/10] arm_ffa: efi: introduce FF-A MM communication

2022-11-08 Thread Abdellatif El Khlifi
On Mon, Oct 24, 2022 at 03:30:11PM +0300, Ilias Apalodimas wrote:
> Hi Abdellatif,
> 
> [...]
> 
> >  
> >  #include 
> > @@ -15,6 +17,36 @@
> >  #include 
> >  #include 
> >  
> > +#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#ifndef FFA_SHARED_MM_BUFFER_SIZE
> > +#warning "FFA_SHARED_MM_BUFFER_SIZE must be defined in 
> > include/configs/.h"
> > +#define FFA_SHARED_MM_BUFFER_SIZE 0
> > +#endif
> > +
> > +#ifndef FFA_SHARED_MM_BUFFER_OFFSET
> > +#warning "FFA_SHARED_MM_BUFFER_OFFSET must be defined in 
> > include/configs/.h"
> > +#define FFA_SHARED_MM_BUFFER_OFFSET 0
> > +#endif
> > +
> > +#ifndef FFA_SHARED_MM_BUFFER_ADDR
> > +#warning "FFA_SHARED_MM_BUFFER_ADDR must be defined in 
> > include/configs/.h"
> > +#define FFA_SHARED_MM_BUFFER_ADDR 0
> > +#endif
> 
> Is the device going to work with these defaults? I am assuming not, so
> isn't better to treat this as compile time errors?

Thanks. Done in v7.

> 
> > +
> > +/* MM return codes */
> > +#define MM_SUCCESS (0)
> > +
> > +const char *mm_sp_svc_uuid = MM_SP_UUID;
> 
> static ?
> 
> > +
> > +static u16 mm_sp_id;
> > +
> > +#endif
> > +
> >  extern struct efi_var_file __efi_runtime_data *efi_var_buf;
> >  static efi_uintn_t max_buffer_size;/* comm + var + func + data */
> >  static efi_uintn_t max_payload_size;   /* func + data */
> > @@ -24,6 +56,7 @@ struct mm_connection {
> > u32 session;
> >  };
> >  
> > +#if (IS_ENABLED(CONFIG_OPTEE))
> >  /**
> >   * get_connection() - Retrieve OP-TEE session for a specific UUID.
> >   *
> > @@ -143,13 +176,224 @@ static efi_status_t optee_mm_communicate(void 
> > *comm_buf, ulong dsize)
> >  
> > return ret;
> >  }
> > +#endif
> > +
> > +#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
> > +
> > +/**
> > + * ffa_notify_mm_sp() - Announce there is data in the shared buffer
> > + *
> > + * Notifies the MM partition in the trusted world that
> > + * data is available in the shared buffer.
> > + * This is a blocking call during which trusted world has exclusive access
> > + * to the MM shared buffer.
> > + *
> > + * Return:
> > + *
> > + * 0 on success
> > + */
> > +static int ffa_notify_mm_sp(void)
> > +{
> > +   struct ffa_send_direct_data msg = {0};
> > +   int ret;
> > +   int sp_event_ret = -1;
> > +
> > +   if (!ffa_bus_ops_get())
> > +   return -EINVAL;
> > +
> > +   msg.data0 = FFA_SHARED_MM_BUFFER_OFFSET; /* x3 */
> > +
> > +   ret = ffa_bus_ops_get()->sync_send_receive(mm_sp_id, &msg);
> > +   if (ret != 0)
> > +   return ret;
> > +
> > +   sp_event_ret = msg.data0; /* x3 */
> > +
> > +   if (sp_event_ret == MM_SUCCESS)
> > +   return 0;
> > +
> > +   /*
> > +* Failure to notify the MM SP
> > +*/
> > +
> > +   return -EACCES;
> > +}
> >  
> >  /**
> > - * mm_communicate() - Adjust the cmonnucation buffer to StandAlonneMM and 
> > send
> > + * ffa_discover_mm_sp_id() - Query the MM partition ID
> > + *
> > + * Use the FF-A driver to get the MM partition ID.
> > + * If multiple partitions are found, use the first one.
> > + * This is a boot time function.
> > + *
> > + * Return:
> > + *
> > + * 0 on success
> > + */
> > +static int ffa_discover_mm_sp_id(void)
> > +{
> > +   u32 count = 0, size = 0;
> > +   int ret;
> > +   struct ffa_partition_info *parts_info;
> > +
> > +   if (!ffa_bus_ops_get())
> > +   return -EINVAL;
> > +
> > +   /*
> > +* get from the driver the count of the SPs matching the UUID
> > +*/
> > +   ret = ffa_bus_ops_get()->partition_info_get(mm_sp_svc_uuid, &count, 
> > NULL);
> > +   if (ret != 0) {
> > +   log_err("EFI: Failure in querying partitions count (error code: 
> > %d)\n", ret);
> > +   return ret;
> > +   }
> > +
> > +   if (!count) {
> > +   log_info("EFI: No MM partition found\n");
> > +   return ret;
> > +   }
> > +
> > +   /*
> > +* pre-allocate a buffer to be filled by the driver
> > +* with  ffa_partition_info structs
> > +*/
> > +
> > +   log_info("EFI: Pre-allocating %d partition(s) info structures\n", 
> > count);
> > +
> > +   parts_info = calloc(count, sizeof(struct ffa_partition_info));
> > +   if (!parts_info)
> > +   return -EINVAL;
> 
> -ENOMEM here is more accurate
> 
> > +
> > +   size = count * sizeof(struct ffa_partition_info);
> > +
> > +   /*
> > +* ask the driver to fill the
> > +* buffer with the SPs info
> > +*/
> > +   ret = ffa_bus_ops_get()->partition_info_get(mm_sp_svc_uuid, &size, 
> > parts_info);
> > +   if (ret != 0) {
> > +   log_err("EFI: Failure in querying partition(s) info (error 
> > code: %d)\n", ret);
> > +   free(parts_info);
> > +   return ret;
> > +   }
> > +
> > +   /*
> > +* MM SPs found , use the first one
> > +*/
> > +
> > +   mm_sp_id = parts_info[0].id;
> > +
> > +   log_info("EFI: MM partition ID 0x%x\n", mm_sp_id);
> > +
> > +   free(parts_info);
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * ffa_mm_c

Re: [PATCH v6 10/10] arm_ffa: efi: corstone1000: enable MM communication

2022-11-08 Thread Abdellatif El Khlifi
On Mon, Oct 24, 2022 at 03:13:08PM +0300, Ilias Apalodimas wrote:
> On Thu, Oct 13, 2022 at 11:38:57AM +0100, Abdellatif El Khlifi wrote:
> > turn on EFI MM communication
> > 
> > On corstone1000 platform MM communication between u-boot
> > and the secure world (Optee) is done using the FF-A bus.
> > 
> > Signed-off-by: Abdellatif El Khlifi 
> > Cc: Tom Rini 
> > Cc: Simon Glass 
> > Cc: Ilias Apalodimas 
> > Cc: Jens Wiklander 
> > 
> > ---
> > 
> > Changelog:
> > ===
> > 
> > v6:
> > 
> > * corstone-1000: enable optee driver
> > * corstone-1000: remove CONFIG_ARM_FFA_EFI_RUNTIME_MODE from the defconfig
> > 
> > v4:
> > 
> > * corstone-1000: turn on EFI MM communication
> > 
> >  configs/corstone1000_defconfig | 4 
> >  include/configs/corstone1000.h | 9 +
> >  2 files changed, 13 insertions(+)
> > 
> > diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
> > index ed2e0fe70a..4c9ed9fb71 100644
> > --- a/configs/corstone1000_defconfig
> > +++ b/configs/corstone1000_defconfig
> > @@ -52,3 +52,7 @@ CONFIG_DM_SERIAL=y
> >  CONFIG_USB=y
> >  CONFIG_USB_ISP1760=y
> >  CONFIG_ERRNO_STR=y
> > +CONFIG_EFI_MM_COMM_TEE=y
> > +CONFIG_TEE=y
> > +CONFIG_OPTEE=y
> > +CONFIG_ARM_FFA_TRANSPORT=y
> > diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
> > index 8e0230c135..997d0bebaf 100644
> > --- a/include/configs/corstone1000.h
> > +++ b/include/configs/corstone1000.h
> > @@ -14,6 +14,15 @@
> >  
> >  #include 
> >  
> > +#define FFA_SHARED_MM_BUFFER_SIZE  SZ_4K /* 4 KB */
> > +
> > +/*
> > + * shared buffer physical address used for communication between
> > + * u-boot and the MM SP
> > + */
> > +#define FFA_SHARED_MM_BUFFER_ADDR  (0x023F8000)
> > +#define FFA_SHARED_MM_BUFFER_OFFSET(0)
> 
> The rest of the declarations on this file don't have () so please remove
> them.  Also is FFA_SHARED_MM_BUFFER_ADDR used anywhere that would justify UL
> in the suffix?

Done in v7.

> 
> Thanks
> /Ilias
> > +
> >  #define V2M_BASE   0x8000
> >  
> >  #define CONFIG_PL011_CLOCK 5000
> > -- 
> > 2.17.1
> > 


Re: [PATCH v6 01/10] arm64: smccc: add support for SMCCCv1.2 x0-x17 registers

2022-11-08 Thread Abdellatif El Khlifi
On Mon, Oct 24, 2022 at 04:19:18PM +0200, Jens Wiklander wrote:
> On Thu, Oct 13, 2022 at 11:38:48AM +0100, Abdellatif El Khlifi wrote:
> > add support for x0-x17 registers used by the SMC calls
> > 
> > In SMCCC v1.2 [1] arguments are passed in registers x1-x17.
> > Results are returned in x0-x17.
> > 
> > This work is inspired from the following kernel commit:
> > 
> > arm64: smccc: Add support for SMCCCv1.2 extended input/output registers
> > 
> > [1]: 
> > https://documentation-service.arm.com/static/5f8edaeff86e16515cdbe4c6?token=
> > 
> > Signed-off-by: Abdellatif El Khlifi 
> > Cc: Tom Rini 
> > Cc: Simon Glass 
> > Cc: Ilias Apalodimas 
> > Cc: Jens Wiklander 
> > 
> > ---
> > 
> > Changelog:
> > ===
> > 
> > v4:
> > 
> > * rename the commit title and improve description
> >   new commit title: the current
> > 
> > v3:
> > 
> > * port x0-x17 registers support from linux kernel as defined by SMCCCv1.2
> >   commit title:
> >   arm64: smccc: add Xn registers support used by SMC calls
> > 
> > arch/arm/cpu/armv8/smccc-call.S | 53 +
> >  arch/arm/lib/asm-offsets.c  | 14 +
> >  include/linux/arm-smccc.h   | 43 ++
> >  3 files changed, 110 insertions(+)
> > 
> > diff --git a/arch/arm/cpu/armv8/smccc-call.S 
> > b/arch/arm/cpu/armv8/smccc-call.S
> > index dc92b28777..ec6f299bc9 100644
> > --- a/arch/arm/cpu/armv8/smccc-call.S
> > +++ b/arch/arm/cpu/armv8/smccc-call.S
> > @@ -1,6 +1,8 @@
> >  /* SPDX-License-Identifier: GPL-2.0 */
> >  /*
> >   * Copyright (c) 2015, Linaro Limited
> > + * (C) Copyright 2022 ARM Limited
> > + * Abdellatif El Khlifi 
> >   */
> >  #include 
> >  #include 
> > @@ -45,3 +47,54 @@ ENDPROC(__arm_smccc_smc)
> >  ENTRY(__arm_smccc_hvc)
> > SMCCC   hvc
> >  ENDPROC(__arm_smccc_hvc)
> > +
> > +#ifdef CONFIG_ARM64
> > +
> > +   .macro SMCCC_1_2 instr
> > +   /* Save `res` and free a GPR that won't be clobbered */
> > +   stp x1, x19, [sp, #-16]!
> > +
> > +   /* Ensure `args` won't be clobbered while loading regs in next step */
> > +   mov x19, x0
> > +
> > +   /* Load the registers x0 - x17 from the struct arm_smccc_1_2_regs */
> > +   ldp x0, x1, [x19, #ARM_SMCCC_1_2_REGS_X0_OFFS]
> > +   ldp x2, x3, [x19, #ARM_SMCCC_1_2_REGS_X2_OFFS]
> > +   ldp x4, x5, [x19, #ARM_SMCCC_1_2_REGS_X4_OFFS]
> > +   ldp x6, x7, [x19, #ARM_SMCCC_1_2_REGS_X6_OFFS]
> > +   ldp x8, x9, [x19, #ARM_SMCCC_1_2_REGS_X8_OFFS]
> > +   ldp x10, x11, [x19, #ARM_SMCCC_1_2_REGS_X10_OFFS]
> > +   ldp x12, x13, [x19, #ARM_SMCCC_1_2_REGS_X12_OFFS]
> > +   ldp x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS]
> > +   ldp x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS]
> > +
> > +   \instr #0
> > +
> > +   /* Load the `res` from the stack */
> > +   ldr x19, [sp]
> > +
> > +   /* Store the registers x0 - x17 into the result structure */
> > +   stp x0, x1, [x19, #ARM_SMCCC_1_2_REGS_X0_OFFS]
> > +   stp x2, x3, [x19, #ARM_SMCCC_1_2_REGS_X2_OFFS]
> > +   stp x4, x5, [x19, #ARM_SMCCC_1_2_REGS_X4_OFFS]
> > +   stp x6, x7, [x19, #ARM_SMCCC_1_2_REGS_X6_OFFS]
> > +   stp x8, x9, [x19, #ARM_SMCCC_1_2_REGS_X8_OFFS]
> > +   stp x10, x11, [x19, #ARM_SMCCC_1_2_REGS_X10_OFFS]
> > +   stp x12, x13, [x19, #ARM_SMCCC_1_2_REGS_X12_OFFS]
> > +   stp x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS]
> > +   stp x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS]
> > +
> > +   /* Restore original x19 */
> > +   ldp xzr, x19, [sp], #16
> > +   ret
> > +   .endm
> > +
> > +/*
> > + * void arm_smccc_1_2_smc(const struct arm_smccc_1_2_regs *args,
> > + *   struct arm_smccc_1_2_regs *res);
> > + */
> > +ENTRY(arm_smccc_1_2_smc)
> > +   SMCCC_1_2 smc
> > +ENDPROC(arm_smccc_1_2_smc)
> > +
> > +#endif
> > diff --git a/arch/arm/lib/asm-offsets.c b/arch/arm/lib/asm-offsets.c
> > index 22fd541f9a..1bc2d90faa 100644
> > --- a/arch/arm/lib/asm-offsets.c
> > +++ b/arch/arm/lib/asm-offsets.c
> > @@ -9,6 +9,9 @@
> >   * generate asm statements containing #defines,
> >   * compile this file to assembler, and then extract the
> >   * #defines from the assembly-language output.
> > + *
> > + * (C) Copyright 2022 ARM Limited
> > + * Abdellatif El Khlifi 
> >   */
> >  
> >  #include 
> > @@ -117,6 +120,17 @@ int main(void)
> > DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2));
> > DEFINE(ARM_SMCCC_QUIRK_ID_OFFS, offsetof(struct arm_smccc_quirk, id));
> > DEFINE(ARM_SMCCC_QUIRK_STATE_OFFS, offsetof(struct arm_smccc_quirk, 
> > state));
> > +   #ifdef CONFIG_ARM64
> > +   DEFINE(ARM_SMCCC_1_2_REGS_X0_OFFS,  offsetof(struct 
> > arm_smccc_1_2_regs, a0));
> > +   DEFINE(ARM_SMCCC_1_2_REGS_X2_OFFS,  offsetof(struct 
> > arm_smccc_1_2_regs, a2));
> > +   DEFINE(ARM_SMCCC_1_2_REGS_X4_OFFS,  offsetof(struct 
> > arm_smccc_1_2_regs, a4));
> > +   DEFINE(ARM_SMCCC_1_2_REGS_X6_OFFS,  offsetof(struct 
> > arm_smccc_1_2_

Re: [PATCH v6 03/10] arm_ffa: introduce Arm FF-A low-level driver

2022-11-08 Thread Abdellatif El Khlifi
On Tue, Oct 25, 2022 at 11:31:11AM +0200, Jens Wiklander wrote:
> On Thu, Oct 13, 2022 at 11:38:50AM +0100, Abdellatif El Khlifi wrote:
> > Add the core driver implementing Arm Firmware Framework for Armv8-A v1.0
> > 
> > The Firmware Framework for Arm A-profile processors (FF-A v1.0) [1]
> > describes interfaces (ABIs) that standardize communication
> > between the Secure World and Normal World leveraging TrustZone
> > technology.
> > 
> > This driver uses 64-bit registers as per SMCCCv1.2 spec and comes
> > on top of the SMCCC layer. The driver provides the FF-A ABIs needed for
> > querying the FF-A framework from the secure world.
> > 
> > 32-bit version of the ABIs is supported and 64-bit version of FFA_RXTX_MAP
> > and FFA_MSG_SEND_DIRECT_{REQ, RESP}.
> > 
> > In u-boot FF-A design, FF-A is considered as a discoverable bus.
> 
> U-Boot

All comments in this patch are addressed in v7, thanks.

> 
> > The Secure World is considered as one entity to communicate with
> > using the FF-A bus. FF-A communication is handled by one device and
> > one instance (the bus). This FF-A driver takes care of all the
> > interactions between Normal world and Secure World.
> > 
> > The driver exports its operations to be used by upper layers.
> > 
> > Exported operations:
> > 
> > - partition_info_get
> > - sync_send_receive
> > - rxtx_unmap
> > 
> > [1]: https://developer.arm.com/documentation/den0077/latest/
> > 
> > Signed-off-by: Abdellatif El Khlifi 
> > Cc: Tom Rini 
> > Cc: Simon Glass 
> > Cc: Ilias Apalodimas 
> > Cc: Jens Wiklander 
> > 
> > ---
> > 
> > Changelog:
> > ===
> > 
> > v6:
> > 
> > * drop use of EFI runtime support (We decided with Linaro to add this later)
> > * drop discovery from initcalls (discovery will be on demand by FF-A users)
> > * set the alignment of the RX/TX buffers to the larger translation granule 
> > size
> > * move FF-A RX/TX buffers unmapping at ExitBootServices() to a separate 
> > commit
> > * update the documentation and move it to doc/arch/arm64.ffa.rst
> > 
> > v4:
> > 
> > * add doc/README.ffa.drv
> > * moving the FF-A driver work to drivers/firmware/arm-ffa
> > * use less #ifdefs in lib/efi_loader/efi_boottime.c and replace
> >   #if defined by #if CONFIG_IS_ENABLED
> > * improving error handling by mapping the FF-A errors to standard errors
> >   and logs
> > * replacing panics with an error log and returning an error code
> > * improving features discovery in FFA_FEATURES by introducing
> >   rxtx_min_pages private data field
> > * add ffa_remove and ffa_unbind functions
> > * improve how the driver behaves when bus discovery is done more than
> >   once
> > 
> > v3:
> > 
> > * align the interfaces of the u-boot FF-A driver with those in the linux
> >   FF-A driver
> > * remove the FF-A helper layer
> > * make the u-boot FF-A driver independent from EFI
> > * provide an optional config that enables copying the driver data to EFI
> >   runtime section at ExitBootServices service
> > * use 64-bit version of FFA_RXTX_MAP, FFA_MSG_SEND_DIRECT_{REQ, RESP}
> > 
> > v2:
> > 
> > * make FF-A bus discoverable using device_{bind, probe} APIs
> > * remove device tree support
> > 
> > v1:
> > 
> > * introduce FF-A bus driver with device tree support
> > 
> >  MAINTAINERS   |7 +
> >  doc/arch/arm64.ffa.rst|  207 
> >  doc/arch/index.rst|1 +
> >  drivers/Kconfig   |2 +
> >  drivers/Makefile  |1 +
> >  drivers/firmware/arm-ffa/Kconfig  |   30 +
> >  drivers/firmware/arm-ffa/Makefile |6 +
> >  drivers/firmware/arm-ffa/arm-ffa-uclass.c |   16 +
> >  drivers/firmware/arm-ffa/arm_ffa_prv.h|  196 +++
> >  drivers/firmware/arm-ffa/core.c   | 1337 +
> >  include/arm_ffa.h |   93 ++
> >  include/dm/uclass-id.h|4 +
> >  12 files changed, 1900 insertions(+)
> >  create mode 100644 doc/arch/arm64.ffa.rst
> >  create mode 100644 drivers/firmware/arm-ffa/Kconfig
> >  create mode 100644 drivers/firmware/arm-ffa/Makefile
> >  create mode 100644 drivers/firmware/arm-ffa/arm-ffa-uclass.c
> >  create mode 100644 drivers/firmware/arm-ffa/arm_ffa_prv.h
> >  create mode 100644 drivers/firmware/arm-ffa/core.c
> >  create mode 100644 include/arm_ffa.h
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index a26b36c7c2..496f47a516 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -248,6 +248,13 @@ F: drivers/net/cortina_ni.h
> >  F: drivers/net/phy/ca_phy.c
> >  F: configs/cortina_presidio-asic-pnand_defconfig
> >  
> > +ARM FF-A
> > +M: Abdellatif El Khlifi 
> > +S: Maintained
> > +F: doc/arch/arm64.ffa.rst
> > +F: drivers/firmware/arm-ffa/
> > +F: include/arm_ffa.h
> > +
> >  ARM FREESCALE IMX
> >  M: Stefano Babic 
> >  M: Fabio Estevam 
> > diff --git a/doc/arch/arm64.ffa.rst b/doc/arch/arm64.ffa.rst
> > new file mode 100644
> > index 

[PATCH] Revert "serial: mxc: have putc use the TXFIFO"

2022-11-08 Thread Fabio Estevam
From: Fabio Estevam 

This reverts commit c7878a0483c59c48a730123bc0f4659fd40921bf.

Since commit c7878a0483c5 ("serial: mxc: have putc use the TXFIFO"),
serial console corruption can be seen when priting inside board_init(). 

Revert it to avoid the regression.

Reported-by: Tim Harvey 
Signed-off-by: Fabio Estevam 
---
 drivers/serial/serial_mxc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index 4cf79c1ca24f..82c0d84628d5 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -311,7 +311,7 @@ static int mxc_serial_putc(struct udevice *dev, const char 
ch)
struct mxc_serial_plat *plat = dev_get_plat(dev);
struct mxc_uart *const uart = plat->reg;
 
-   if (readl(&uart->ts) & UTS_TXFULL)
+   if (!(readl(&uart->ts) & UTS_TXEMPTY))
return -EAGAIN;
 
writel(ch, &uart->txd);
-- 
2.25.1



Re: [PATCH] ARM: mx7: psci: fix suspend/resume e10133 workaround

2022-11-08 Thread Matthias Schiffer
On Mon, 2022-09-26 at 10:31 +0200, Matthias Schiffer wrote:
> The e10133 workaround was broken in two places:
> 
> - The code intended to temporarily mask all interrupts in GPC_IMRx_CORE0.
>   While the old register values were saved, the actual masking was
>   missing.
> - imx_udelay() expects the system counter to run at its base frequency,
>   but the system counter is switched to a lower frequency earlier in
>   psci_system_suspend(), leading to a much longer delay than intended.
>   Replace the call with an equivalent loop (linux-imx 5.15 does the same)
> 
> This fixes the SoC hanging forever when there was already a wakeup IRQ
> pending while suspending.
> 
> Fixes: 57b620255e ("imx: mx7: add system suspend/resume support")
> Signed-off-by: Matthias Schiffer 

Ping, any feedback on this?

I'm not entirely sure anymore if this solution is adequate, as the
duration of the loop depends on the CPU clock frequency and cache
enable/disable state. Maybe a modified imx_udelay() that accounts for
the changed system counter configuration would be necessary after all?


> ---
>  arch/arm/mach-imx/mx7/psci-mx7.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/mx7/psci-mx7.c 
> b/arch/arm/mach-imx/mx7/psci-mx7.c
> index f32945ea37..699a2569cb 100644
> --- a/arch/arm/mach-imx/mx7/psci-mx7.c
> +++ b/arch/arm/mach-imx/mx7/psci-mx7.c
> @@ -643,8 +643,10 @@ __secure void psci_system_suspend(u32 __always_unused 
> function_id,
>   /* disable GIC distributor */
>   writel(0, GIC400_ARB_BASE_ADDR + GIC_DIST_OFFSET);
>  
> - for (i = 0; i < 4; i++)
> + for (i = 0; i < 4; i++) {
>   gpc_mask[i] = readl(GPC_IPS_BASE_ADDR + GPC_IMR1_CORE0 + i * 4);
> + writel(~0, GPC_IPS_BASE_ADDR + GPC_IMR1_CORE0 + i * 4);
> + }
>  
>   /*
>* enable the RBC bypass counter here
> @@ -668,7 +670,7 @@ __secure void psci_system_suspend(u32 __always_unused 
> function_id,
>   writel(gpc_mask[i], GPC_IPS_BASE_ADDR + GPC_IMR1_CORE0 + i * 4);
>  
>   /*
> -  * now delay for a short while (3usec)
> +  * now delay for a short while (~3usec)
>* ARM is at 1GHz at this point
>* so a short loop should be enough.
>* this delay is required to ensure that
> @@ -677,7 +679,8 @@ __secure void psci_system_suspend(u32 __always_unused 
> function_id,
>* or in case an interrupt arrives just
>* as ARM is about to assert DSM_request.
>*/
> - imx_udelay(3);
> + for (i = 0; i < 2000; i++)
> + asm volatile("");
>  
>   /* save resume entry and sp in CPU0 GPR registers */
>   asm volatile("mov %0, sp" : "=r" (val));



Re: [PATCH v5 2/2] serial: mxc: have putc use the TXFIFO

2022-11-08 Thread Fabio Estevam
Hi Johannes,

On Tue, Nov 8, 2022 at 6:37 AM SCHNEIDER Johannes
 wrote:

> gave it another round, and discussed it with Grygorii - he pointed out that 
> it would be better to do the "fifo empty" or even better "byte sent" checks 
> in "our" code instead of adding more complexity to the serial_mxc for 
> handling a buffer/TXFIFO to be properly flushed prior to each of the multiple 
> calls to set_baudrate during startup between spl and uboot;
> i tried a couple of approaches which would add checks to "pending" to either 
> a new "puts"-method, or "set_bgr" with partial success - the problem remains 
> that long printfs during board_init - which happens before the serial device 
> is actually fully initialized - get cut of near the end... anyway: added 
> complexity -> !KISS
>
> so i'd say go for the revert; which reduces use of the fifo back to just the 
> first byte

Thanks for investigating it. I have sent the revert.

Regards,

Fabio Estevam


u-boot-imx master-next CI failure

2022-11-08 Thread Fabio Estevam
Hi Tom,

We are getting a build failure in the u-boot-imx master-next branch
and we are not sure where it is coming from:

https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/525317

The i.MX boards are built, but at the end, the following error is seen:

ERROR: Job failed: exit code 100

Would you have any suggestions?

Thanks,

Fabio Estevam


Re: u-boot-imx master-next CI failure

2022-11-08 Thread Tom Rini
On Tue, Nov 08, 2022 at 09:00:21AM -0300, Fabio Estevam wrote:
> Hi Tom,
> 
> We are getting a build failure in the u-boot-imx master-next branch
> and we are not sure where it is coming from:
> 
> https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/525317
> 
> The i.MX boards are built, but at the end, the following error is seen:
> 
> ERROR: Job failed: exit code 100
> 
> Would you have any suggestions?

The problem is with msc_sm2s_imx8mp. I figured this out by running a
./tools/moveconfig.py -s and waiting to see what got stuck and reading
the resulting /tmp/tmp.../.config file.

Simon, what can we do so that this kind of error is more easily visible
from buildman? Is there some flag the CI jobs are missing?

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v4 04/11] buildman: Convert documentation to rST

2022-11-08 Thread Simon Glass
Convert the buildman documentation to rST format and include it in the
'build' section.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add new patch to convert documentation to rST

 doc/build/buildman.rst  |1 +
 doc/build/index.rst |1 +
 tools/buildman/README   | 1349 -
 tools/buildman/README.rst   |1 +
 tools/buildman/buildman.rst | 1413 +++
 tools/buildman/control.py   |4 +-
 tools/buildman/func_test.py |4 +-
 7 files changed, 1420 insertions(+), 1353 deletions(-)
 create mode 12 doc/build/buildman.rst
 delete mode 100644 tools/buildman/README
 create mode 12 tools/buildman/README.rst
 create mode 100644 tools/buildman/buildman.rst

diff --git a/doc/build/buildman.rst b/doc/build/buildman.rst
new file mode 12
index 000..beeaa425720
--- /dev/null
+++ b/doc/build/buildman.rst
@@ -0,0 +1 @@
+../../tools/buildman/buildman.rst
\ No newline at end of file
diff --git a/doc/build/index.rst b/doc/build/index.rst
index 69952f90d89..9a8105db21d 100644
--- a/doc/build/index.rst
+++ b/doc/build/index.rst
@@ -11,3 +11,4 @@ Build U-Boot
clang
docker
tools
+   buildman
diff --git a/tools/buildman/README b/tools/buildman/README
deleted file mode 100644
index a8357a804b3..000
--- a/tools/buildman/README
+++ /dev/null
@@ -1,1349 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (c) 2013 The Chromium OS Authors.
-
-(Please read 'How to change from MAKEALL' if you are used to that tool)
-
-Quick-start
-===
-
-If you just want to quickly set up buildman so you can build something (for
-example Raspberry Pi 2):
-
-   cd /path/to/u-boot
-   PATH=$PATH:`pwd`/tools/buildman
-   buildman --fetch-arch arm
-   buildman -k rpi_2
-   ls ../current/rpi_2
-   # u-boot.bin is the output image
-
-
-What is this?
-=
-
-This tool handles building U-Boot to check that you have not broken it
-with your patch series. It can build each individual commit and report
-which boards fail on which commits, and which errors come up. It aims
-to make full use of multi-processor machines.
-
-A key feature of buildman is its output summary, which allows warnings,
-errors or image size increases in a particular commit or board to be
-quickly identified and the offending commit pinpointed. This can be a big
-help for anyone working with >10 patches at a time.
-
-
-Caveats
-===
-
-Buildman can be stopped and restarted, in which case it will continue
-where it left off. This should happen cleanly and without side-effects.
-If not, it is a bug, for which a patch would be welcome.
-
-Buildman gets so tied up in its work that it can ignore the outside world.
-You may need to press Ctrl-C several times to quit it. Also it will print
-out various exceptions when stopped. You may have to kill it since the
-Ctrl-C handling is somewhat broken.
-
-
-Theory of Operation
-===
-
-(please read this section in full twice or you will be perpetually confused)
-
-Buildman is a builder. It is not make, although it runs make. It does not
-produce any useful output on the terminal while building, except for
-progress information (but see -v below). All the output (errors, warnings and
-binaries if you ask for them) is stored in output directories, which you can
-look at from a separate 'buildman -s' instance while the build is progressing,
-or when it is finished.
-
-Buildman is designed to build entire git branches, i.e. muliple commits. It
-can be run repeatedly on the same branch after making changes to commits on
-that branch. In this case it will automatically rebuild commits which have
-changed (and remove its old results for that commit). It is possible to build
-a branch for one board, then later build it for another board. This adds to
-the output, so now you have results for two boards. If you want buildman to
-re-build a commit it has already built (e.g. because of a toolchain update),
-use the -f flag.
-
-Buildman produces a concise summary of which boards succeeded and failed.
-It shows which commit introduced which board failure using a simple
-red/green colour coding (with yellow/cyan for warnings). Full error
-information can be requested, in which case it is de-duped and displayed
-against the commit that introduced the error. An example workflow is below.
-
-Buildman stores image size information and can report changes in image size
-from commit to commit. An example of this is below.
-
-Buildman starts multiple threads, and each thread builds for one board at
-a time. A thread starts at the first commit, configures the source for your
-board and builds it. Then it checks out the next commit and does an
-incremental build (i.e. not using 'make xxx_defconfig' unless you use -C).
-Eventually the thread reaches the last commit and stops. If a commit causes
-an error or warning, buildman will try it again after reconfiguring (but see
--Q). Thus some co

[PATCH 2/2] board: mediatek: add mt8195 demo board

2022-11-08 Thread Macpaul Lin
From: Fabien Parent 

Add mt8195-demo board support.
This demo purpose board uses MediaTek's MT8195 SoC.

Signed-off-by: Fabien Parent 
Signed-off-by: Amjad Ouled-Ameur 
Signed-off-by: Macpaul Lin 
---
 MAINTAINERS |   1 +
 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/mt8195-demo.dts| 109 
 board/mediatek/mt8195/MAINTAINERS   |   6 ++
 board/mediatek/mt8195/Makefile  |   3 +
 board/mediatek/mt8195/mt8195_demo.c |  38 ++
 configs/mt8195_demo_defconfig   |  89 +++
 include/configs/mt8195.h|  34 +
 8 files changed, 281 insertions(+)
 create mode 100644 arch/arm/dts/mt8195-demo.dts
 create mode 100644 board/mediatek/mt8195/MAINTAINERS
 create mode 100644 board/mediatek/mt8195/Makefile
 create mode 100644 board/mediatek/mt8195/mt8195_demo.c
 create mode 100644 configs/mt8195_demo_defconfig
 create mode 100644 include/configs/mt8195.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5528dd28c3..5aaeeb02cb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -389,6 +389,7 @@ F:  drivers/watchdog/mtk_wdt.c
 F: drivers/net/mtk_eth.c
 F: drivers/net/mtk_eth.h
 F: drivers/reset/reset-mediatek.c
+F: include/configs/mt8195.h
 F: tools/mtk_image.c
 F: tools/mtk_image.h
 F: tools/mtk_nand_headers.c
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 791838733c..994f7ebcc0 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1271,6 +1271,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
mt7986a-emmc-rfb.dtb \
mt7986b-emmc-rfb.dtb \
mt8183-pumpkin.dtb \
+   mt8195-demo.dtb \
mt8512-bm1-emmc.dtb \
mt8516-pumpkin.dtb \
mt8518-ap1-emmc.dtb
diff --git a/arch/arm/dts/mt8195-demo.dts b/arch/arm/dts/mt8195-demo.dts
new file mode 100644
index 00..bd0952b248
--- /dev/null
+++ b/arch/arm/dts/mt8195-demo.dts
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+/*
+ * Copyright (C) 2022 MediaTek Inc.
+ * Copyright (C) 2022 BayLibre SAS.
+ * Author: Macpaul Lin 
+ * Author: Fabien Parent 
+ */
+
+/dts-v1/;
+
+#include 
+#include "mt8195.dtsi"
+
+/ {
+   model = "MediaTek MT8195 demo board";
+   compatible = "mediatek,mt8195-demo", "mediatek,mt8195";
+
+   memory@4000 {
+   device_type = "memory";
+   reg = <0 0x4000 0 0x8000>;
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   /* 2 MiB reserved for ARM Trusted Firmware (BL31) */
+   bl31_secmon_reserved: secmon@5460 {
+   no-map;
+   reg = <0 0x5460 0x0 0x20>;
+   };
+
+   /* 12 MiB reserved for OP-TEE (BL32)
+* +---+ 0x43e0_
+* |  SHMEM 2MiB   |
+* +---+ 0x43c0_
+* || TA_RAM  8MiB |
+* + TZDRAM +--+ 0x4340_
+* || TEE_RAM 2MiB |
+* +---+ 0x4320_
+*/
+   optee_reserved: optee@4320 {
+   no-map;
+   reg = <0 0x4320 0 0x00c0>;
+   };
+   };
+
+   chosen {
+   stdout-path = &uart0;
+   };
+
+   reg_1p8v: regulator-1p8v {
+   compatible = "regulator-fixed";
+   regulator-name = "fixed-1.8V";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   reg_3p3v: regulator-3p3v {
+   compatible = "regulator-fixed";
+   regulator-name = "fixed-3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+};
+
+&watchdog {
+   status = "okay";
+};
+
+&uart0 {
+   status = "okay";
+};
+
+&mmc0 {
+   bus-width = <4>;
+   max-frequency = <2>;
+   cap-mmc-highspeed;
+   mmc-hs200-1_8v;
+   cap-mmc-hw-reset;
+   vmmc-supply = <®_3p3v>;
+   vqmmc-supply = <®_1p8v>;
+   non-removable;
+   status = "okay";
+};
+
+&usb {
+   status = "okay";
+};
+
+&ssusb {
+   mediatek,force-vbus;
+   maximum-speed = "high-speed";
+   dr_mode = "peripheral";
+   status = "okay";
+};
+
+&xhci0 {
+   status = "okay";
+};
+
+&xhci3 {
+   status = "okay";
+};
diff --git a/board/mediatek/mt8195/MAINTAINERS 
b/board/mediatek/mt8195/MAINTAINERS
new file mode 100644
index 00..01fa25115d
--- /dev/null
+++ b/board/mediatek/mt8195/MAINTAINERS
@@ -0,0 +1,6 @@
+MT8195 Demo
+M: Macpaul Lin 
+S: Maintained
+F: board/media

[PATCH 1/2] arm: mediatek: add mt8195 SOC support

2022-11-08 Thread Macpaul Lin
From: Fabien Parent 

The MediaTek MT8195 is a ARM64-based SoC with a quad-core Cortex-A73 and
a quad-core Cortex-A53. It is including UART, SPI, USB3.0 device and hosts,
SD and MMC cards, UFS, PWM, I2C, I2S, S/PDIF, and several LPDDR3
and LPDDR4 options.

Signed-off-by: Fabien Parent 
Signed-off-by: Macpaul Lin 
---
 MAINTAINERS|   2 +
 arch/arm/dts/mt8195.dtsi   | 317 +
 arch/arm/mach-mediatek/Kconfig |  13 +-
 arch/arm/mach-mediatek/Makefile|   1 +
 arch/arm/mach-mediatek/mt8195/Makefile |   3 +
 arch/arm/mach-mediatek/mt8195/init.c   |  81 +++
 6 files changed, 416 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/mt8195.dtsi
 create mode 100644 arch/arm/mach-mediatek/mt8195/Makefile
 create mode 100644 arch/arm/mach-mediatek/mt8195/init.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 1cf99c1393..5528dd28c3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -362,8 +362,10 @@ ARM MEDIATEK
 M: Ryder Lee 
 M: Weijie Gao 
 M: Chunfeng Yun 
+M: Macpaul Lin 
 R: GSS_MTK_Uboot_upstream 
 S: Maintained
+F: arch/arm/dts/mt8195.dtsi
 F: arch/arm/mach-mediatek/
 F: arch/arm/include/asm/arch-mediatek/
 F: board/mediatek/
diff --git a/arch/arm/dts/mt8195.dtsi b/arch/arm/dts/mt8195.dtsi
new file mode 100644
index 00..d28b038d57
--- /dev/null
+++ b/arch/arm/dts/mt8195.dtsi
@@ -0,0 +1,317 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2022 MediaTek Inc.
+ * Copyright (C) 2022 BayLibre, SAS
+ * Author: Ben Ho 
+ * Erin Lo 
+ * Fabien Parent 
+ * Macpaul Lin 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "mediatek,mt8195";
+   interrupt-parent = <&sysirq>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu-map {
+   cluster0 {
+   core0 {
+   cpu = <&cpu0>;
+   };
+   core1 {
+   cpu = <&cpu1>;
+   };
+   core2 {
+   cpu = <&cpu2>;
+   };
+   core3 {
+   cpu = <&cpu3>;
+   };
+   };
+
+   cluster1 {
+   core0 {
+   cpu = <&cpu4>;
+   };
+   core1 {
+   cpu = <&cpu5>;
+   };
+   core2 {
+   cpu = <&cpu6>;
+   };
+   core3 {
+   cpu = <&cpu7>;
+   };
+   };
+   };
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x000>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <741>;
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x001>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <741>;
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x002>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <741>;
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x003>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <741>;
+   };
+
+   cpu4: cpu@100 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a73";
+   reg = <0x100>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <1024>;
+   };
+
+   cpu5: cpu@101 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a73";
+   reg = <0x101>;
+   enable-method = "psci";
+   capacity-dmips-mhz = <1024>;
+   };
+
+   cpu6: cpu@102 {
+   device_type = "cpu";
+

Re: [PATCH v2 3/5] cmd: mtd: Add total length of read operation

2022-11-08 Thread Liang-Yan Yu
Hi Miquel,

>
> Hi Leo,
>
> liangyany...@gmail.com wrote on Wed,  2 Nov 2022 14:14:30 +0800:
>
> > This patch bypasses the limitation of length for read operations
> > in MTD test module. Thus, the total length of a read operation
> > can be passed down to the continuous read operation in SPI NAND
> > layer.
> >
> > Signed-off-by: Leo Yu 
> > ---
> >  cmd/mtd.c   | 2 ++
> >  include/linux/mtd/mtd.h | 2 ++
> >  2 files changed, 4 insertions(+)
> >
> > diff --git a/cmd/mtd.c b/cmd/mtd.c
> > index ad5cc9827d..0b601e08a3 100644
> > --- a/cmd/mtd.c
> > +++ b/cmd/mtd.c
> > @@ -335,6 +335,8 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, 
> > int argc,
> >   io_op.ooblen = woob ? mtd->oobsize : 0;
> >   io_op.datbuf = buf;
> >   io_op.oobbuf = woob ? &buf[len] : NULL;
> > + /* Total length of this read operation passed by user */
> > + io_op.totallen = len;
>
> Where is this used?

It is used in spinand_mtd_read function (drivers/mtd/nand/spi/core.c)
as a condition to trigger
continuous read mode (please refer to patch[4/5]). This member stores
the total length of a
read operation. The reason why this member is added is because the mtd
command sets
the length of an operation to one page if has_pages flag is set. This
limits spinand_mtd_read
to receive length greater than one page. Which means there is no way
to trigger continuous
mode. Thus, I added this member to bypass the limitation.

> >
> >   /* Search for the first good block after the given offset */
> >   off = start_off;
> > diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> > index ff635bd716..df8a231c82 100644
> > --- a/include/linux/mtd/mtd.h
> > +++ b/include/linux/mtd/mtd.h
> > @@ -79,6 +79,7 @@ struct mtd_erase_region_info {
> >   *   mode = MTD_OPS_PLACE_OOB or MTD_OPS_RAW)
> >   * @datbuf:  data buffer - if NULL only oob data are read/written
> >   * @oobbuf:  oob data buffer
> > + * @totallen:   total number of data bytes to read in one read operation 
> > (for continuous read mode)
> >   */
> >  struct mtd_oob_ops {
> >   unsigned intmode;
> > @@ -89,6 +90,7 @@ struct mtd_oob_ops {
> >   uint32_tooboffs;
> >   uint8_t *datbuf;
> >   uint8_t *oobbuf;
> > + size_t  totallen;
> >  };
> >
> >  #ifdef CONFIG_SYS_NAND_MAX_OOBFREE
> > --
> > 2.17.1
> >
>
>
> Thanks,
> Miquèl

Best,
Leo Yu


Re: [PATCH v7 02/10] lib: uuid: introduce uuid_str_to_le_bin function

2022-11-08 Thread Ilias Apalodimas
Hi Abdellatif,

On Mon, Nov 07, 2022 at 07:20:47PM +, Abdellatif El Khlifi wrote:
> convert UUID string to little endian binary data
> 
> Signed-off-by: Abdellatif El Khlifi 
> Cc: Tom Rini 
> Cc: Simon Glass 
> Cc: Ilias Apalodimas 
> Cc: Jens Wiklander 
> 
> ---
> 
> Changelog:
> ===
> 
> v7:
> 
> * rename be_uuid_str_to_le_bin() to uuid_str_to_le_bin()
> * make uuid_str_to_le_bin() implementation similar to uuid_str_to_bin()
>   by using same APIs
> 
> v4:
> 
> * rename ffa_uuid_str_to_bin to be_uuid_str_to_le_bin and put in
>   a standalone commit (the current)
> 
> v3:
> 
> * introduce ffa_uuid_str_to_bin (provided by
>   arm_ffa: introduce Arm FF-A low-level driver)
> 
> include/uuid.h |  8 
>  lib/uuid.c | 46 ++
>  2 files changed, 54 insertions(+)
> 
> diff --git a/include/uuid.h b/include/uuid.h
> index 4a4883d3b5..293a8eb0a5 100644
> --- a/include/uuid.h
> +++ b/include/uuid.h
> @@ -2,6 +2,8 @@
>  /*
>   * Copyright (C) 2014 Samsung Electronics
>   * Przemyslaw Marczak 
> + * (C) Copyright 2022 ARM Limited
> + * Abdellatif El Khlifi 
>   */
>  #ifndef __UUID_H__
>  #define __UUID_H__
> @@ -44,4 +46,10 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char 
> *guid_bin);
>  const char *uuid_guid_get_str(const unsigned char *guid_bin);
>  void gen_rand_uuid(unsigned char *uuid_bin);
>  void gen_rand_uuid_str(char *uuid_str, int str_format);
> +
> +/**
> + * uuid_str_to_le_bin - Converts a UUID string to little endian binary data
> + */
> +int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin);
> +
>  #endif
> diff --git a/lib/uuid.c b/lib/uuid.c
> index 465e1ac38f..cde5ae2bb7 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -1,6 +1,8 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
>   * Copyright 2011 Calxeda, Inc.
> + * (C) Copyright 2022 ARM Limited
> + * Abdellatif El Khlifi 
>   */
>  
>  #include 
> @@ -346,6 +348,50 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char 
> *uuid_bin,
>   return 0;
>  }
>  
> +/**
> + * uuid_str_to_le_bin() - Convert string UUID to little endian binary data.
> + * @uuid_str:pointer to UUID string
> + * @uuid_bin:pointer to allocated array for little endian output 
> [16B]
> + *
> + * UUID string is 36 characters (36 bytes):
> + *
> + * ----
> + *
> + * where x is a hexadecimal character. Fields are separated by '-'s.
> + * When converting to a little endian binary UUID, the string fields are 
> reversed.
> + *
> + * Return:
> + *
> + *uuid_bin filled with little endian UUID data
> + *On success 0 is returned. Otherwise, failure code.
> + */
> +int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
> +{
> + u16 tmp16;
> + u32 tmp32;
> + u64 tmp64;
> +
> + if (!uuid_str_valid(uuid_str) || !uuid_bin)
> + return -EINVAL;
> +
> + tmp32 = cpu_to_le32(hextoul(uuid_str, NULL));
> + memcpy(uuid_bin, &tmp32, 4);
> +
> + tmp16 = cpu_to_le16(hextoul(uuid_str + 9, NULL));
> + memcpy(uuid_bin + 4, &tmp16, 2);
> +
> + tmp16 = cpu_to_le16(hextoul(uuid_str + 14, NULL));
> + memcpy(uuid_bin + 6, &tmp16, 2);
> +
> + tmp16 = cpu_to_le16(hextoul(uuid_str + 19, NULL));
> + memcpy(uuid_bin + 8, &tmp16, 2);
> +
> + tmp64 = cpu_to_le64(hextoul(uuid_str + 24, NULL));
> + memcpy(uuid_bin + 10, (char *)&tmp64, 6);

The cast isn't needed here 

> +
> + return 0;
> +}
> +
>  /*
>   * uuid_bin_to_str() - convert big endian binary data to string UUID or GUID.
>   *
> -- 
> 2.17.1
> 


Re: [PATCH 1/1] riscv: enable reset via SBI on PolarFire Icicle Kit

2022-11-08 Thread Conor Dooley
On Mon, Nov 07, 2022 at 10:55:46AM +0100, Heinrich Schuchardt wrote:
> HSS 2022.10 provides support for resetting the board.

It's actually v2022.09 that added support for reset. I don't think that
that is important to correct though, since v2022.10 is the version we
are updating the dt in U-Boot to match.
Reviewed-by: Conor Dooley 

One minor & mostly unrelated question below.

> Signed-off-by: Heinrich Schuchardt 
> ---
>  configs/microchip_mpfs_icicle_defconfig | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/configs/microchip_mpfs_icicle_defconfig 
> b/configs/microchip_mpfs_icicle_defconfig
> index c295b9bad3..65bd50db80 100644
> --- a/configs/microchip_mpfs_icicle_defconfig
> +++ b/configs/microchip_mpfs_icicle_defconfig
> @@ -21,3 +21,5 @@ CONFIG_SYS_MEM_TOP_HIDE=0x40
>  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>  CONFIG_BOOTP_SEND_HOSTNAME=y
>  CONFIG_DM_MTD=y
> +CONFIG_SYSRESET=y
> +CONFIG_SYSRESET_SBI=y

I took a look at the config option, but something seemed odd to me. It
says "depends on SBI_V02" but the help text says "version 0.3". I see
there's no define for SBI_V03 so I assume that's why there's a mismatch.

I didn't see a comment about it in the commit hence asking. AFAIR, v0.3
is the correct version.

> config SYSRESET_SBI
>   bool "Enable support for SBI System Reset"
>   depends on RISCV_SMODE && SBI_V02
>   default y
>   select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
>   help
> Enable system reset and poweroff via the SBI system reset extension.
> The extension was introduced in version 0.3 of the SBI specification.


Re: [PATCH 1/1] riscv: enable reset via SBI on PolarFire Icicle Kit

2022-11-08 Thread Sean Anderson

On 11/8/22 09:16, Conor Dooley wrote:

On Mon, Nov 07, 2022 at 10:55:46AM +0100, Heinrich Schuchardt wrote:

HSS 2022.10 provides support for resetting the board.


It's actually v2022.09 that added support for reset. I don't think that
that is important to correct though, since v2022.10 is the version we
are updating the dt in U-Boot to match.
Reviewed-by: Conor Dooley 

One minor & mostly unrelated question below.


Signed-off-by: Heinrich Schuchardt 
---
  configs/microchip_mpfs_icicle_defconfig | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/configs/microchip_mpfs_icicle_defconfig 
b/configs/microchip_mpfs_icicle_defconfig
index c295b9bad3..65bd50db80 100644
--- a/configs/microchip_mpfs_icicle_defconfig
+++ b/configs/microchip_mpfs_icicle_defconfig
@@ -21,3 +21,5 @@ CONFIG_SYS_MEM_TOP_HIDE=0x40
  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
  CONFIG_BOOTP_SEND_HOSTNAME=y
  CONFIG_DM_MTD=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_SBI=y


I took a look at the config option, but something seemed odd to me. It
says "depends on SBI_V02" but the help text says "version 0.3". I see
there's no define for SBI_V03 so I assume that's why there's a mismatch.

I didn't see a comment about it in the commit hence asking. AFAIR, v0.3
is the correct version.


IIRC 0.3 is the same as 0.2 except it was ratified.


config SYSRESET_SBI
bool "Enable support for SBI System Reset"
depends on RISCV_SMODE && SBI_V02
default y
select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
help
  Enable system reset and poweroff via the SBI system reset extension.
  The extension was introduced in version 0.3 of the SBI specification.




Re: u-boot-imx master-next CI failure

2022-11-08 Thread Fabio Estevam
Hi Tom,

On Tue, Nov 8, 2022 at 9:56 AM Tom Rini  wrote:

> The problem is with msc_sm2s_imx8mp. I figured this out by running a
> ./tools/moveconfig.py -s and waiting to see what got stuck and reading
> the resulting /tmp/tmp.../.config file.

That's good information. Thanks for narrowing it down to msc_sm2s_imx8mp.

What is the msc_sm2s_imx8mp config option that causes the problem?

Looking at 
https://source.denx.de/u-boot/custodians/u-boot-imx/-/commit/b6b94d8530f6c29f9b0ed9f25aeb8aa6569573e8
I am not sure what can cause the failure.

Any ideas?

Thanks


Re: u-boot-imx master-next CI failure

2022-11-08 Thread Tom Rini
On Tue, Nov 08, 2022 at 11:31:51AM -0300, Fabio Estevam wrote:
> Hi Tom,
> 
> On Tue, Nov 8, 2022 at 9:56 AM Tom Rini  wrote:
> 
> > The problem is with msc_sm2s_imx8mp. I figured this out by running a
> > ./tools/moveconfig.py -s and waiting to see what got stuck and reading
> > the resulting /tmp/tmp.../.config file.
> 
> That's good information. Thanks for narrowing it down to msc_sm2s_imx8mp.
> 
> What is the msc_sm2s_imx8mp config option that causes the problem?
> 
> Looking at 
> https://source.denx.de/u-boot/custodians/u-boot-imx/-/commit/b6b94d8530f6c29f9b0ed9f25aeb8aa6569573e8
> I am not sure what can cause the failure.
> 
> Any ideas?

Yes, it's CONFIG_SYS_TEXT_BASE -> CONFIG_TEXT BASE and I found that just
by doing 'make msc_sm2s_imx8mp_config oldconfig' :)

-- 
Tom


signature.asc
Description: PGP signature


Re: u-boot-imx master-next CI failure

2022-11-08 Thread Fabio Estevam
Hi Tom,

On Tue, Nov 8, 2022 at 11:34 AM Tom Rini  wrote:

> Yes, it's CONFIG_SYS_TEXT_BASE -> CONFIG_TEXT BASE and I found that just
> by doing 'make msc_sm2s_imx8mp_config oldconfig' :)

Excellent, thanks for the help!


Re: [PATCH 1/1] riscv: enable reset via SBI on PolarFire Icicle Kit

2022-11-08 Thread Heinrich Schuchardt

On 11/8/22 15:16, Conor Dooley wrote:

On Mon, Nov 07, 2022 at 10:55:46AM +0100, Heinrich Schuchardt wrote:

HSS 2022.10 provides support for resetting the board.


It's actually v2022.09 that added support for reset. I don't think that
that is important to correct though, since v2022.10 is the version we
are updating the dt in U-Boot to match.
Reviewed-by: Conor Dooley 

One minor & mostly unrelated question below.


Signed-off-by: Heinrich Schuchardt 
---
  configs/microchip_mpfs_icicle_defconfig | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/configs/microchip_mpfs_icicle_defconfig 
b/configs/microchip_mpfs_icicle_defconfig
index c295b9bad3..65bd50db80 100644
--- a/configs/microchip_mpfs_icicle_defconfig
+++ b/configs/microchip_mpfs_icicle_defconfig
@@ -21,3 +21,5 @@ CONFIG_SYS_MEM_TOP_HIDE=0x40
  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
  CONFIG_BOOTP_SEND_HOSTNAME=y
  CONFIG_DM_MTD=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_SBI=y


I took a look at the config option, but something seemed odd to me. It
says "depends on SBI_V02" but the help text says "version 0.3". I see
there's no define for SBI_V03 so I assume that's why there's a mismatch.

I didn't see a comment about it in the commit hence asking. AFAIR, v0.3
is the correct version.


The only ratified version of the SBI specification is 1.0.

v0.2 introduced the concept of extensions.
v0.3 introduced the SRST extension.

CONFIG_SBI_V02=y means SBI specification v0.2 or later. We should update 
the description of CONFIG_SBI_V02 accordingly.


HSS 2022.10 provides an OpenSBI 1.0 which is good enough.

If you use a 0.1 or 0.2 SBI, the worst thing that can happen is that 
sbi_probe_extension(SBI_EXT_SRST) will return an error and the reset 
driver is not loaded.


Best regards

Heinrich




config SYSRESET_SBI
bool "Enable support for SBI System Reset"
depends on RISCV_SMODE && SBI_V02
default y
select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
help
  Enable system reset and poweroff via the SBI system reset extension.
  The extension was introduced in version 0.3 of the SBI specification.




[PATCH] msc_sm2s_imx8mp: Convert to CONFIG_TEXT_BASE

2022-11-08 Thread Fabio Estevam
From: Fabio Estevam 

The conversion to CONFIG_TEXT_BASE was missed here.

Convert it to fix a build error in CI.

Signed-off-by: Fabio Estevam 
---
Stefano,

This is against u-boot-imx, master-next branch.

If you prefer to squash with the original commit, feel free to do it.

 configs/msc_sm2s_imx8mp_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/msc_sm2s_imx8mp_defconfig 
b/configs/msc_sm2s_imx8mp_defconfig
index a4f39061ae62..6691eb312fe5 100644
--- a/configs/msc_sm2s_imx8mp_defconfig
+++ b/configs/msc_sm2s_imx8mp_defconfig
@@ -1,6 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_IMX8M=y
-CONFIG_SYS_TEXT_BASE=0x4020
+CONFIG_TEXT_BASE=0x4020
 CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SPL_GPIO=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
-- 
2.25.1



Re: [PATCH 1/1] riscv: enable reset via SBI on PolarFire Icicle Kit

2022-11-08 Thread Conor Dooley
On Tue, Nov 08, 2022 at 09:23:19AM -0500, Sean Anderson wrote:
> On 11/8/22 09:16, Conor Dooley wrote:
> > > +CONFIG_SYSRESET_SBI=y
> > 
> > I took a look at the config option, but something seemed odd to me. It
> > says "depends on SBI_V02" but the help text says "version 0.3". I see
> > there's no define for SBI_V03 so I assume that's why there's a mismatch.
> > 
> > I didn't see a comment about it in the commit hence asking. AFAIR, v0.3
> > is the correct version.
> 
> IIRC 0.3 is the same as 0.2 except it was ratified.

Ah I see. Apologies for the noise on that one so, had a quick look on
the riscv-non-isa github but obviously not enough!

Thanks Sean.

> > > config SYSRESET_SBI
> > >   bool "Enable support for SBI System Reset"
> > >   depends on RISCV_SMODE && SBI_V02
> > >   default y
> > >   select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
> > >   help
> > > Enable system reset and poweroff via the SBI system reset extension.
> > > The extension was introduced in version 0.3 of the SBI specification.
> 


Re: u-boot-imx master-next CI failure

2022-11-08 Thread Stefano Babic

Hi Tom,

On 08.11.22 15:36, Fabio Estevam wrote:

Hi Tom,

On Tue, Nov 8, 2022 at 11:34 AM Tom Rini  wrote:


Yes, it's CONFIG_SYS_TEXT_BASE -> CONFIG_TEXT BASE and I found that just
by doing 'make msc_sm2s_imx8mp_config oldconfig' :)


Excellent, thanks for the help!


Many thanks, we were puzzled !


Stefano


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



Please pull u-boot-dm

2022-11-08 Thread Simon Glass
Hi Tom,

https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/14049


The following changes since commit 88bd8ee106591eb900561715c44ad04441afc0e3:

  Prepare v2023.01-rc1 (2022-11-07 15:27:03 -0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-dm.git tags/dm-pull-7nov22

for you to fetch changes up to 168a0e45fcf49194fca55795f84a844f16b480f6:

  dm: blk: Add probe in blk_first_device/blk_next_device (2022-11-07
16:24:30 -0700)


sandbox UCLASS_HOST


Michal Suchanek (1):
  dm: blk: Add probe in blk_first_device/blk_next_device

Simon Glass (17):
  dm: sandbox: Drop non-BLK code from host implementation
  sandbox: Add missing comments for os_alarm()
  test: Split out mk_fs function into a helper
  test: Correct pylint warnings in fs_helper
  dm: test: Drop the special function for running DM tests
  dm: test: Clear the block cache after running a test
  test: Drop an unused parameter to ut_run_test_live_flat()
  test: Tidy up help for ut command
  test: doc: Add documentation for ut command
  test: Allow showing basic information about tests
  test: Add a way to detect a test that breaks another
  dm: blk: Tidy up obtaining a block device from its parent
  dm: sandbox: Create a new HOST uclass
  dm: sandbox: Create a block driver
  dm: sandbox: Switch over to using the new host uclass
  dm: Add documentation for host command and implementation
  dm: Add tests for the sandbox host driver

 arch/sandbox/cpu/spl.c |   2 +-
 arch/sandbox/dts/sandbox.dts   |   4 -
 cmd/host.c | 210 --
 disk/part.c|   4 +-
 doc/arch/index.rst |   2 +-
 doc/arch/sandbox/block_impl.rst|  39 +
 doc/arch/sandbox/index.rst |  12 ++
 doc/arch/{ => sandbox}/sandbox.rst |   9 +-
 doc/develop/tests_sandbox.rst  |  69 +
 doc/usage/cmd/host.rst | 116 +++
 doc/usage/cmd/ut.rst   | 117 +++
 doc/usage/index.rst|   2 +
 drivers/block/Makefile |   2 +-
 drivers/block/blk-uclass.c |  74 +-
 drivers/block/blkcache.c   |  23 ++-
 drivers/block/host-uclass.c| 176 ++
 drivers/block/host_dev.c   | 142 ++
 drivers/block/sandbox.c| 236
+++---
 include/blk.h  |  37 -
 include/dm/uclass-id.h |   1 +
 include/os.h   |   4 +
 include/sandbox_host.h | 125 
 include/sandboxblockdev.h  |  31 
 include/test/ut.h  |   7 +-
 lib/efi_loader/efi_device_path.c   |   5 +-
 lib/efi_loader/efi_disk.c  |   2 +-
 test/cmd_ut.c  |  82 +++
 test/dm/Makefile   |   1 +
 test/dm/blk.c  |  49 ---
 test/dm/host.c | 195 
 test/dm/test-dm.c  |  49 +--
 test/py/tests/fs_helper.py |  68 +
 test/py/tests/test_eficonfig/test_eficonfig.py |   3 +
 test/py/tests/test_fs/conftest.py  |  58 +---
 test/py/tests/test_ut.py   |   6 +
 test/test-main.c   |  47 +-
 36 files changed, 1458 insertions(+), 551 deletions(-)
 create mode 100644 doc/arch/sandbox/block_impl.rst
 create mode 100644 doc/arch/sandbox/index.rst
 rename doc/arch/{ => sandbox}/sandbox.rst (98%)
 create mode 100644 doc/usage/cmd/host.rst
 create mode 100644 doc/usage/cmd/ut.rst
 create mode 100644 drivers/block/host-uclass.c
 create mode 100644 drivers/block/host_dev.c
 create mode 100644 include/sandbox_host.h
 delete mode 100644 include/sandboxblockdev.h
 create mode 100644 test/dm/host.c
 create mode 100644 test/py/tests/fs_helper.py

Regards,
SImon


Re: [PATCH] msc_sm2s_imx8mp: Convert to CONFIG_TEXT_BASE

2022-11-08 Thread Stefano Babic

Hi Fabio,

On 08.11.22 15:42, Fabio Estevam wrote:

From: Fabio Estevam 

The conversion to CONFIG_TEXT_BASE was missed here.

Convert it to fix a build error in CI.

Signed-off-by: Fabio Estevam 
---
Stefano,

This is against u-boot-imx, master-next branch.

If you prefer to squash with the original commit, feel free to do it.

  configs/msc_sm2s_imx8mp_defconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/msc_sm2s_imx8mp_defconfig 
b/configs/msc_sm2s_imx8mp_defconfig
index a4f39061ae62..6691eb312fe5 100644
--- a/configs/msc_sm2s_imx8mp_defconfig
+++ b/configs/msc_sm2s_imx8mp_defconfig
@@ -1,6 +1,6 @@
  CONFIG_ARM=y
  CONFIG_ARCH_IMX8M=y
-CONFIG_SYS_TEXT_BASE=0x4020
+CONFIG_TEXT_BASE=0x4020
  CONFIG_SYS_MALLOC_LEN=0x200
  CONFIG_SPL_GPIO=y
  CONFIG_SPL_LIBCOMMON_SUPPORT=y



Thanks. I will first run a pipeline, but it makes sense that I squash 
this with Martyn's v5-5-5-arm-imx8mp-Initial-MSC-SM2S-iMX8MP-support, by 
adding Fabio's Signed-off. @Martyn, is it okay for you ?


Regards,
Stefano

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



[PATCH 1/1] riscv: clarify meaning of CONFIG_SBI_V02

2022-11-08 Thread Heinrich Schuchardt
Describe that CONFIG_SBI_V02=y does not mean SBI specification v0.2
but v0.2 or later.

Signed-off-by: Heinrich Schuchardt 
---
 arch/riscv/Kconfig | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 4d64e9be3f..ebc4bef220 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -257,16 +257,16 @@ config SBI_V01
  deprecated in future once legacy M-mode software are no longer in use.
 
 config SBI_V02
-   bool "SBI v0.2 support"
+   bool "SBI v0.2 or later support"
depends on SBI
help
- This config allows kernel to use SBI v0.2 APIs. SBI v0.2 is more
- scalable and extendable to handle future needs for RISC-V supervisor
- interfaces. For example, with SBI v0.2 HSM extension, only a single
- hart need to boot and enter operating system. The booting hart can
- bring up secondary harts one by one afterwards.
+ The SBI specification introduced the concept of extensions in version
+ v0.2. With this configuration option U-Boot can detect and use SBI
+ extensions. With the HSM extension introduced in SBI 0.2, only a
+ single hart needs to boot and enter the operating system. The booting
+ hart can bring up secondary harts one by one afterwards.
 
- Choose this option if OpenSBI v0.7 or above release is used together
+ Choose this option if OpenSBI release v0.7 or above is used together
  with U-Boot.
 
 endchoice
-- 
2.37.2



Re: [PATCH 1/1] riscv: clarify meaning of CONFIG_SBI_V02

2022-11-08 Thread Bin Meng
Hi Heinrich,

On Tue, Nov 8, 2022 at 10:53 PM Heinrich Schuchardt
 wrote:
>
> Describe that CONFIG_SBI_V02=y does not mean SBI specification v0.2
> but v0.2 or later.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  arch/riscv/Kconfig | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 4d64e9be3f..ebc4bef220 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -257,16 +257,16 @@ config SBI_V01
>   deprecated in future once legacy M-mode software are no longer in 
> use.
>
>  config SBI_V02
> -   bool "SBI v0.2 support"
> +   bool "SBI v0.2 or later support"
> depends on SBI
> help
> - This config allows kernel to use SBI v0.2 APIs. SBI v0.2 is more
> - scalable and extendable to handle future needs for RISC-V supervisor
> - interfaces. For example, with SBI v0.2 HSM extension, only a single
> - hart need to boot and enter operating system. The booting hart can
> - bring up secondary harts one by one afterwards.
> + The SBI specification introduced the concept of extensions in 
> version
> + v0.2. With this configuration option U-Boot can detect and use SBI
> + extensions. With the HSM extension introduced in SBI 0.2, only a
> + single hart needs to boot and enter the operating system. The 
> booting
> + hart can bring up secondary harts one by one afterwards.
>
> - Choose this option if OpenSBI v0.7 or above release is used together
> + Choose this option if OpenSBI release v0.7 or above is used together
>   with U-Boot.
>
>  endchoice

I remember this option was borrowed from the Linux kernel. Do you plan
to send patch to Linux kernel too?

Regards,
Bin


Re: [PATCH 1/1] riscv: clarify meaning of CONFIG_SBI_V02

2022-11-08 Thread Heinrich Schuchardt

On 11/8/22 16:05, Bin Meng wrote:

Hi Heinrich,

On Tue, Nov 8, 2022 at 10:53 PM Heinrich Schuchardt
 wrote:


Describe that CONFIG_SBI_V02=y does not mean SBI specification v0.2
but v0.2 or later.

Signed-off-by: Heinrich Schuchardt 
---
  arch/riscv/Kconfig | 14 +++---
  1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 4d64e9be3f..ebc4bef220 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -257,16 +257,16 @@ config SBI_V01
   deprecated in future once legacy M-mode software are no longer in 
use.

  config SBI_V02
-   bool "SBI v0.2 support"
+   bool "SBI v0.2 or later support"
 depends on SBI
 help
- This config allows kernel to use SBI v0.2 APIs. SBI v0.2 is more
- scalable and extendable to handle future needs for RISC-V supervisor
- interfaces. For example, with SBI v0.2 HSM extension, only a single
- hart need to boot and enter operating system. The booting hart can
- bring up secondary harts one by one afterwards.
+ The SBI specification introduced the concept of extensions in version
+ v0.2. With this configuration option U-Boot can detect and use SBI
+ extensions. With the HSM extension introduced in SBI 0.2, only a
+ single hart needs to boot and enter the operating system. The booting
+ hart can bring up secondary harts one by one afterwards.

- Choose this option if OpenSBI v0.7 or above release is used together
+ Choose this option if OpenSBI release v0.7 or above is used together
   with U-Boot.

  endchoice


I remember this option was borrowed from the Linux kernel. Do you plan
to send patch to Linux kernel too?


Linux uses a single configuration symbol
CONFIG_RISCV_SBI_V01 "SBI v0.1 support"

So there is no need for a change there.

SBI v0.1 is really obsolete. Can we drop support for it in U-Boot?

Best regards

Heinrich


Re: [PATCH 1/1] riscv: clarify meaning of CONFIG_SBI_V02

2022-11-08 Thread Bin Meng
On Tue, Nov 8, 2022 at 11:13 PM Heinrich Schuchardt
 wrote:
>
> On 11/8/22 16:05, Bin Meng wrote:
> > Hi Heinrich,
> >
> > On Tue, Nov 8, 2022 at 10:53 PM Heinrich Schuchardt
> >  wrote:
> >>
> >> Describe that CONFIG_SBI_V02=y does not mean SBI specification v0.2
> >> but v0.2 or later.
> >>
> >> Signed-off-by: Heinrich Schuchardt 
> >> ---
> >>   arch/riscv/Kconfig | 14 +++---
> >>   1 file changed, 7 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> >> index 4d64e9be3f..ebc4bef220 100644
> >> --- a/arch/riscv/Kconfig
> >> +++ b/arch/riscv/Kconfig
> >> @@ -257,16 +257,16 @@ config SBI_V01
> >>deprecated in future once legacy M-mode software are no longer 
> >> in use.
> >>
> >>   config SBI_V02
> >> -   bool "SBI v0.2 support"
> >> +   bool "SBI v0.2 or later support"
> >>  depends on SBI
> >>  help
> >> - This config allows kernel to use SBI v0.2 APIs. SBI v0.2 is more
> >> - scalable and extendable to handle future needs for RISC-V 
> >> supervisor
> >> - interfaces. For example, with SBI v0.2 HSM extension, only a 
> >> single
> >> - hart need to boot and enter operating system. The booting hart 
> >> can
> >> - bring up secondary harts one by one afterwards.
> >> + The SBI specification introduced the concept of extensions in 
> >> version
> >> + v0.2. With this configuration option U-Boot can detect and use 
> >> SBI
> >> + extensions. With the HSM extension introduced in SBI 0.2, only a
> >> + single hart needs to boot and enter the operating system. The 
> >> booting
> >> + hart can bring up secondary harts one by one afterwards.
> >>
> >> - Choose this option if OpenSBI v0.7 or above release is used 
> >> together
> >> + Choose this option if OpenSBI release v0.7 or above is used 
> >> together
> >>with U-Boot.
> >>
> >>   endchoice
> >
> > I remember this option was borrowed from the Linux kernel. Do you plan
> > to send patch to Linux kernel too?
>
> Linux uses a single configuration symbol
> CONFIG_RISCV_SBI_V01 "SBI v0.1 support"
>
> So there is no need for a change there.
>
> SBI v0.1 is really obsolete. Can we drop support for it in U-Boot?
>

I am fine with dropping v0.1 support in U-Boot.

Regards,
Bin


Re: [PATCH 1/2] mach-snapdragon/mach-ipq40xx: fix, merge and refactoring

2022-11-08 Thread Tom Rini
On Sun, Nov 06, 2022 at 02:52:56AM +0100, Andrey VOLKOV wrote:
> Hi Robert, Tom,
> 
> Updated patches are following, could you review/accept them?
> 
> Le 04/11/2022 à 12:05, Robert Marko a écrit :
> > On Tue, Oct 25, 2022 at 3:31 AM Andrey Volkov  wrote:
> >> SoC: qcom: Add missing Qualcomm's SOCs definitions to the arch KConfig
> >>
> >> From: Andrey VOLKOV
> >>
> >> Add APQ8016/APQ8096/QCS40X decls to the KConfig, convert SDM845 
> >> declaration to the hidden one (selected by target),
> >> and update mach-snapdragon/Makefile accordingly.
> >>
> >> Also move 'CONFIG_ARM64' choice to the new declarations, since 
> >> 'Snapdragon' contains Cortex A7A members too.
> >>
> >> Signed-off-by: Andrey VOLKOV
> > I like this cleanup effort, however, can you rebase this to apply on the 
> > master?
> > I would like to use this as a base of moving IPQ40xx to use Linux DTS
> > and keep it in sync.
> 
> It's nice idea, except that full blown DTS is huge enough (+some KiB at 
> least),
> and i'm afraid it's an old, old story about failing to make it :(.
> Probably will be better if we will have some option that allowed to import and
> reuse DTS files directly from the kernel.
> Something like CONFIG_DTS_FILE_PATH/CONFIG_DTS_INCLUDES/...
> 
> @Tom, any additional comments/objections?
> 
> Btw As far as I remember, this topic (reuse kernel's DTS) has been discussed
> repeatedly since the mid-2000s, but I don't remember why it was not 
> implemented yet.

Is the problem that the full DTS would make the resulting binary too
large to fit in some restricted and can't be changed easily space?
Generally we do want to keep the DTS files in-sync with the kernel.

-- 
Tom


signature.asc
Description: PGP signature


Re: [RFC PATCH v5 09/24] cli: Add menu for hush parser

2022-11-08 Thread Tom Rini
On Mon, Nov 07, 2022 at 08:28:42AM -0700, Simon Glass wrote:
> Hi Patrick,
> 
> On Mon, 7 Nov 2022 at 05:32, Patrick DELAUNAY
>  wrote:
> >
> > Hi,
> >
> > On 11/1/22 20:20, Francis Laniel wrote:
> > > For the moment, the menu contains only entry: HUSH_OLD_PARSER which is the
> > > default.
> > > The goal is to prepare the field to add a new hush parser which guarantees
> > > actual behavior is still correct.
> > >
> > > Signed-off-by: Francis Laniel 
> > > ---
> > >   cmd/Kconfig | 21 +
> > >   common/Makefile |  3 ++-
> > >   2 files changed, 23 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > > index 3f6bc70d43..c15d7c51f7 100644
> > > --- a/cmd/Kconfig
> > > +++ b/cmd/Kconfig
> > > @@ -23,6 +23,27 @@ config HUSH_PARSER
> > > If disabled, you get the old, much simpler behaviour with a 
> > > somewhat
> > > smaller memory footprint.
> > >
> > > +menu "Hush flavor to use"
> > > + depends on HUSH_PARSER
> > > +
> > > + config HUSH_OLD_PARSER
> > > + bool "Use hush old parser"
> > > + default y
> > > + help
> > > +   This option enables the old flavor of hush based on hush 
> > > Busybox from
> > > +   2005.
> > > +
> > > +   It is actually the default U-Boot shell when decided to 
> > > use hush as shell.
> > > +
> > > + config HUSH_2021_PARSER
> > > + bool "Use hush 2021 parser"
> > > + help
> > > +   This option enables the new flavor of hush based on hush 
> > > Busybox from
> > > +   2021.
> > > +
> > > +   For the moment, it is highly experimental and should be 
> > > used at own risks.
> > > +endmenu
> > > +
> >
> >
> > I think "choice" can be made sense here
> >
> > => only one version is used
> >
> >
> > choice
> >  prompt "Hush flavor to use"
> >  default HUSH_OLD_PARSER
> >
> >  depends on HUSH_PARSER
> >
> >
> > config HUSH_OLD_PARSER
> >
> >  bool  "Use hush old parser"
> >
> > config HUSH_2021_PARSER
> >
> >bool "Use hush 2021 parser"
> >
> > endchoice
> 
> We need to be able to build both and then select the correct one at
> runtime, at least for sandbox. Otherwise we would need yet another
> sandbox build. So I think what we have here makes sense.

I think choice is fine, as that's for testing. Once we're ready to merge
this we'll not keep both around for long.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] mach-snapdragon/mach-ipq40xx: fix, merge and refactoring

2022-11-08 Thread Robert Marko
On Tue, Nov 8, 2022 at 4:20 PM Tom Rini  wrote:
>
> On Sun, Nov 06, 2022 at 02:52:56AM +0100, Andrey VOLKOV wrote:
> > Hi Robert, Tom,
> >
> > Updated patches are following, could you review/accept them?
> >
> > Le 04/11/2022 à 12:05, Robert Marko a écrit :
> > > On Tue, Oct 25, 2022 at 3:31 AM Andrey Volkov  wrote:
> > >> SoC: qcom: Add missing Qualcomm's SOCs definitions to the arch KConfig
> > >>
> > >> From: Andrey VOLKOV
> > >>
> > >> Add APQ8016/APQ8096/QCS40X decls to the KConfig, convert SDM845 
> > >> declaration to the hidden one (selected by target),
> > >> and update mach-snapdragon/Makefile accordingly.
> > >>
> > >> Also move 'CONFIG_ARM64' choice to the new declarations, since 
> > >> 'Snapdragon' contains Cortex A7A members too.
> > >>
> > >> Signed-off-by: Andrey VOLKOV
> > > I like this cleanup effort, however, can you rebase this to apply on the 
> > > master?
> > > I would like to use this as a base of moving IPQ40xx to use Linux DTS
> > > and keep it in sync.
> >
> > It's nice idea, except that full blown DTS is huge enough (+some KiB at 
> > least),
> > and i'm afraid it's an old, old story about failing to make it :(.
> > Probably will be better if we will have some option that allowed to import 
> > and
> > reuse DTS files directly from the kernel.
> > Something like CONFIG_DTS_FILE_PATH/CONFIG_DTS_INCLUDES/...
> >
> > @Tom, any additional comments/objections?
> >
> > Btw As far as I remember, this topic (reuse kernel's DTS) has been discussed
> > repeatedly since the mid-2000s, but I don't remember why it was not 
> > implemented yet.
>
> Is the problem that the full DTS would make the resulting binary too
> large to fit in some restricted and can't be changed easily space?
> Generally we do want to keep the DTS files in-sync with the kernel.

Most IPQ40xx devices have a slot of 512kB left for the bootloader
which cannot be easily
expanded, however, that should still be enough for synced DTS anyway.

I am now more familiar with U-boot and really dont like the IPQ40xx
target as it is and
would like to rework it, including using upstream DTS.

Regards,
Robert
>
> --
> Tom



-- 
Robert Marko
Staff Embedded Linux Engineer
Sartura Ltd.
Lendavska ulica 16a
1 Zagreb, Croatia
Email: robert.ma...@sartura.hr
Web: www.sartura.hr


Re: [PATCH v2 2/2] ipq40xx/snapdragon: Merge the two, more than 90% overlapping Qualcomm's Snapdrgon based arches, into one: "mach-snapdragon".

2022-11-08 Thread Robert Marko
On Sun, Nov 6, 2022 at 2:53 AM Andrey VOLKOV  wrote:
>
> Signed-off-by: Andrey VOLKOV 
> ---
>  arch/arm/Kconfig  |  19 +-
>  arch/arm/Makefile |   1 -
>  arch/arm/mach-ipq40xx/Kconfig |  15 --
>  arch/arm/mach-ipq40xx/Makefile|   9 -
>  arch/arm/mach-ipq40xx/include/mach/gpio.h |  10 --
>  arch/arm/mach-ipq40xx/pinctrl-snapdragon.c| 166 --
>  arch/arm/mach-ipq40xx/pinctrl-snapdragon.h|  30 
>  arch/arm/mach-snapdragon/Kconfig  |  47 -
>  arch/arm/mach-snapdragon/Makefile |   5 +-
>  .../clock-ipq4019.c   |   0
>  .../pinctrl-ipq4019.c |   0
>  arch/arm/mach-snapdragon/pinctrl-snapdragon.c |  38 ++--
>  arch/arm/mach-snapdragon/pinctrl-snapdragon.h |   1 +
>  drivers/phy/qcom/Kconfig  |   2 +-
>  drivers/reset/Kconfig |   2 +-
>  drivers/reset/reset-qcom.c|   2 +-
>  drivers/smem/Kconfig  |   2 +-
>  drivers/spi/Kconfig   |   2 +-
>  18 files changed, 80 insertions(+), 271 deletions(-)
>  delete mode 100644 arch/arm/mach-ipq40xx/Kconfig
>  delete mode 100644 arch/arm/mach-ipq40xx/Makefile
>  delete mode 100644 arch/arm/mach-ipq40xx/include/mach/gpio.h
>  delete mode 100644 arch/arm/mach-ipq40xx/pinctrl-snapdragon.c
>  delete mode 100644 arch/arm/mach-ipq40xx/pinctrl-snapdragon.h
>  rename arch/arm/{mach-ipq40xx => mach-snapdragon}/clock-ipq4019.c (100%)
>  rename arch/arm/{mach-ipq40xx => mach-snapdragon}/pinctrl-ipq4019.c (100%)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index cdc8d4aeb4..d94ca7dcf9 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -781,21 +781,6 @@ config ARCH_INTEGRATOR
> select PL01X_SERIAL
> imply CMD_DM
>
> -config ARCH_IPQ40XX
> -   bool "Qualcomm IPQ40xx SoCs"
> -   select CPU_V7A
> -   select DM
> -   select DM_GPIO
> -   select DM_SERIAL
> -   select DM_RESET
> -   select GPIO_EXTRA_HEADER
> -   select MSM_SMEM
> -   select PINCTRL
> -   select CLK
> -   select SMEM
> -   select OF_CONTROL
> -   imply CMD_DM
> -
>  config ARCH_KEYSTONE
> bool "TI Keystone"
> select CMD_POWEROFF
> @@ -1076,6 +1061,7 @@ config ARCH_RMOBILE
>
>  config ARCH_SNAPDRAGON
> bool "Qualcomm Snapdragon SoCs"
> +   select CLK
> select DM
> select DM_GPIO
> select DM_SERIAL
> @@ -1083,6 +1069,7 @@ config ARCH_SNAPDRAGON
> select MSM_SMEM
> select OF_CONTROL
> select OF_SEPARATE
> +   select PINCTRL
> select SMEM
> select SPMI
> imply CMD_DM
> @@ -2203,8 +2190,6 @@ source "arch/arm/mach-highbank/Kconfig"
>
>  source "arch/arm/mach-integrator/Kconfig"
>
> -source "arch/arm/mach-ipq40xx/Kconfig"
> -
>  source "arch/arm/mach-k3/Kconfig"
>
>  source "arch/arm/mach-keystone/Kconfig"
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index ac602aed9c..ceee6a02d0 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -61,7 +61,6 @@ machine-$(CONFIG_ARCH_DAVINCI)+= davinci
>  machine-$(CONFIG_ARCH_EXYNOS)  += exynos
>  machine-$(CONFIG_ARCH_GXP) += hpe
>  machine-$(CONFIG_ARCH_HIGHBANK)+= highbank
> -machine-$(CONFIG_ARCH_IPQ40XX) += ipq40xx
>  machine-$(CONFIG_ARCH_K3)  += k3
>  machine-$(CONFIG_ARCH_KEYSTONE)+= keystone
>  machine-$(CONFIG_ARCH_KIRKWOOD)+= kirkwood
> diff --git a/arch/arm/mach-ipq40xx/Kconfig b/arch/arm/mach-ipq40xx/Kconfig
> deleted file mode 100644
> index f9db55c42a..00
> --- a/arch/arm/mach-ipq40xx/Kconfig
> +++ /dev/null
> @@ -1,15 +0,0 @@
> -if ARCH_IPQ40XX
> -
> -config SYS_SOC
> -   default "ipq40xx"
> -
> -config SYS_MALLOC_F_LEN
> -   default 0x2000
> -
> -config TEXT_BASE
> -   default 0x8730
> -
> -config NR_DRAM_BANKS
> -   default 1
> -
> -endif
> diff --git a/arch/arm/mach-ipq40xx/Makefile b/arch/arm/mach-ipq40xx/Makefile
> deleted file mode 100644
> index 08a65b8854..00
> --- a/arch/arm/mach-ipq40xx/Makefile
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0+
> -#
> -# Copyright (c) 2019 Sartura Ltd.
> -#
> -# Author: Robert Marko 
> -
> -obj-y += clock-ipq4019.o
> -obj-y += pinctrl-snapdragon.o
> -obj-y += pinctrl-ipq4019.o
> diff --git a/arch/arm/mach-ipq40xx/include/mach/gpio.h 
> b/arch/arm/mach-ipq40xx/include/mach/gpio.h
> deleted file mode 100644
> index a45747c0fe..00
> --- a/arch/arm/mach-ipq40xx/include/mach/gpio.h
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0+ */
> -/*
> - * Empty gpio.h
> - *
> - * This file must stay as arch/arm/include/asm/gpio.h requires it.
> - *
> - * Copyright (c) 2019 Sartura Ltd.
> - *
> - * Author: Robert Marko 
> - */
> diff --git a/arch/arm/ma

Re: [PATCH 1/2] mach-snapdragon/mach-ipq40xx: fix, merge and refactoring

2022-11-08 Thread Tom Rini
On Tue, Nov 08, 2022 at 04:23:16PM +0100, Robert Marko wrote:
> On Tue, Nov 8, 2022 at 4:20 PM Tom Rini  wrote:
> >
> > On Sun, Nov 06, 2022 at 02:52:56AM +0100, Andrey VOLKOV wrote:
> > > Hi Robert, Tom,
> > >
> > > Updated patches are following, could you review/accept them?
> > >
> > > Le 04/11/2022 à 12:05, Robert Marko a écrit :
> > > > On Tue, Oct 25, 2022 at 3:31 AM Andrey Volkov  wrote:
> > > >> SoC: qcom: Add missing Qualcomm's SOCs definitions to the arch KConfig
> > > >>
> > > >> From: Andrey VOLKOV
> > > >>
> > > >> Add APQ8016/APQ8096/QCS40X decls to the KConfig, convert SDM845 
> > > >> declaration to the hidden one (selected by target),
> > > >> and update mach-snapdragon/Makefile accordingly.
> > > >>
> > > >> Also move 'CONFIG_ARM64' choice to the new declarations, since 
> > > >> 'Snapdragon' contains Cortex A7A members too.
> > > >>
> > > >> Signed-off-by: Andrey VOLKOV
> > > > I like this cleanup effort, however, can you rebase this to apply on 
> > > > the master?
> > > > I would like to use this as a base of moving IPQ40xx to use Linux DTS
> > > > and keep it in sync.
> > >
> > > It's nice idea, except that full blown DTS is huge enough (+some KiB at 
> > > least),
> > > and i'm afraid it's an old, old story about failing to make it :(.
> > > Probably will be better if we will have some option that allowed to 
> > > import and
> > > reuse DTS files directly from the kernel.
> > > Something like CONFIG_DTS_FILE_PATH/CONFIG_DTS_INCLUDES/...
> > >
> > > @Tom, any additional comments/objections?
> > >
> > > Btw As far as I remember, this topic (reuse kernel's DTS) has been 
> > > discussed
> > > repeatedly since the mid-2000s, but I don't remember why it was not 
> > > implemented yet.
> >
> > Is the problem that the full DTS would make the resulting binary too
> > large to fit in some restricted and can't be changed easily space?
> > Generally we do want to keep the DTS files in-sync with the kernel.
> 
> Most IPQ40xx devices have a slot of 512kB left for the bootloader
> which cannot be easily
> expanded, however, that should still be enough for synced DTS anyway.

This is about what I was expecting. And if we need to develop more
tooling to better support this, that's a problem we should solve. We do
have for example MULTI_DTB_FIT_GZIP (or LZO) but it might need a bit
more tweaking to be available / usable in all cases?

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] msc_sm2s_imx8mp: Convert to CONFIG_TEXT_BASE

2022-11-08 Thread Martyn Welch
On Tue, 2022-11-08 at 15:50 +0100, Stefano Babic wrote:
> Hi Fabio,
> 
> On 08.11.22 15:42, Fabio Estevam wrote:
> > From: Fabio Estevam 
> > 
> > The conversion to CONFIG_TEXT_BASE was missed here.
> > 
> > Convert it to fix a build error in CI.
> > 
> > Signed-off-by: Fabio Estevam 
> > ---
> > Stefano,
> > 
> > This is against u-boot-imx, master-next branch.
> > 
> > If you prefer to squash with the original commit, feel free to do
> > it.
> > 
> >   configs/msc_sm2s_imx8mp_defconfig | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/configs/msc_sm2s_imx8mp_defconfig
> > b/configs/msc_sm2s_imx8mp_defconfig
> > index a4f39061ae62..6691eb312fe5 100644
> > --- a/configs/msc_sm2s_imx8mp_defconfig
> > +++ b/configs/msc_sm2s_imx8mp_defconfig
> > @@ -1,6 +1,6 @@
> >   CONFIG_ARM=y
> >   CONFIG_ARCH_IMX8M=y
> > -CONFIG_SYS_TEXT_BASE=0x4020
> > +CONFIG_TEXT_BASE=0x4020
> >   CONFIG_SYS_MALLOC_LEN=0x200
> >   CONFIG_SPL_GPIO=y
> >   CONFIG_SPL_LIBCOMMON_SUPPORT=y
> 
> 
> Thanks. I will first run a pipeline, but it makes sense that I squash
> this with Martyn's v5-5-5-arm-imx8mp-Initial-MSC-SM2S-iMX8MP-support,
> by 
> adding Fabio's Signed-off. @Martyn, is it okay for you ?
> 

That's fine with me!

> Regards,
> Stefano
> 



[PATCH v5 7/8] imx8mn: synchronise device tree with linux

2022-11-08 Thread sbabic
> From: Marcel Ziswiler 
> Synchronise device tree with linux v6.1-rc3.
> Signed-off-by: Marcel Ziswiler 
> Tested-By: Tim Harvey  #imx8m{m,n,p}-venice-*
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] configs: imx8m{m, n}_venice: remove unneeded CONFIG_FEC_MXC_PHYADDR

2022-11-08 Thread sbabic
> The IMX8M based Venice boards all have device-tree fec nodes that
> use proper dt with a phy-handle pointing to a phy with reg assigned
> to the proper phy address.
> There is no need to keep using the CONFIG_FEC_MXC_PHYADDR hack when
> a proper dt is used - remove it.
> This was previously done in commit 400eebf10d9b
> ("configs: imx8m{m, n}_venice: remove unneeded CONFIG_FEC_MXC_PHYADDR")
> but got clobbered by commit 6889412ad5e7
> ("Convert CONFIG_SYS_BARGSIZE to Kconfig")
> Signed-off-by: Tim Harvey 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] configs: imx8mn_venice.h: remove unused ifdef

2022-11-08 Thread sbabic
> remove unused ifdef left behind after commit ca3369df71d8
> ("configs: drop CONFIG_SPL_ABORT_ON_RAW_IMAGE")
> Signed-off-by: Tim Harvey 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 1/3] imx: imx8mm_beacon: Eliminate a few extras to free up SPL space

2022-11-08 Thread sbabic
> There are a few functions which are not essential for use in
> SPL, but they take up enough space to make other preferred
> features not fit.  Remove the extras.
> Signed-off-by: Adam Ford 
> Reviewed-by: Fabio Estevam 
> diff --git a/board/beacon/imx8mm/spl.c b/board/beacon/imx8mm/spl.c
> index a93cc93878..b0e9d918da 100644
> --- a/board/beacon/imx8mm/spl.c
> +++ b/board/beacon/imx8mm/spl.c
> @@ -44,11 +44,6 @@ static void spl_dram_init(void)
>   ddr_init(&dram_timing);
>  }
>  
> -void spl_board_init(void)
> -{
> - debug("Normal Boot\n");
> -}
> -
>  #ifdef CONFIG_SPL_LOAD_FIT
>  int board_fit_config_name_match(const char *name)
>  {
> diff --git a/configs/imx8mm_beacon_defconfig b/configs/imx8mm_beacon_defconfig
> index e37ce01c19..f6a1012d8a 100644
> --- a/configs/imx8mm_beacon_defconfig
> +++ b/configs/imx8mm_beacon_defconfig
> @@ -29,7 +29,6 @@ CONFIG_DEFAULT_FDT_FILE="imx8mm-beacon-kit.dtb"
>  CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
>  CONFIG_SPL_BSS_START_ADDR=0x91
>  CONFIG_SPL_BSS_MAX_SIZE=0x2000
> -CONFIG_SPL_BOARD_INIT=y
>  # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
>  CONFIG_SPL_STACK=0x92
>  CONFIG_SYS_SPL_MALLOC=y
> @@ -88,12 +87,9 @@ CONFIG_DM_PCA953X=y
>  CONFIG_DM_I2C=y
>  CONFIG_SUPPORT_EMMC_BOOT=y
>  CONFIG_MMC_IO_VOLTAGE=y
> -CONFIG_SPL_MMC_IO_VOLTAGE=y
>  CONFIG_MMC_UHS_SUPPORT=y
> -CONFIG_SPL_MMC_UHS_SUPPORT=y
>  CONFIG_MMC_HS400_ES_SUPPORT=y
>  CONFIG_MMC_HS400_SUPPORT=y
> -CONFIG_SPL_MMC_HS400_SUPPORT=y
>  CONFIG_FSL_USDHC=y
>  CONFIG_MTD=y
>  CONFIG_DM_MTD=y
> @@ -113,14 +109,12 @@ CONFIG_PINCTRL_IMX8M=y
>  CONFIG_POWER_DOMAIN=y
>  CONFIG_IMX8M_POWER_DOMAIN=y
>  CONFIG_DM_PMIC=y
> +# CONFIG_SPL_PMIC_CHILDREN is not set
>  CONFIG_DM_PMIC_BD71837=y
>  CONFIG_SPL_DM_PMIC_BD71837=y
>  CONFIG_DM_REGULATOR=y
> -CONFIG_SPL_DM_REGULATOR=y
>  CONFIG_DM_REGULATOR_BD71837=y
> -CONFIG_SPL_DM_REGULATOR_BD71837=y
>  CONFIG_DM_REGULATOR_FIXED=y
> -CONFIG_SPL_DM_REGULATOR_FIXED=y
>  CONFIG_DM_REGULATOR_GPIO=y
>  CONFIG_DM_SERIAL=y
>  CONFIG_MXC_UART=y
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 1/5] imx8m: USDHC3 base address definition for i.MX8MP

2022-11-08 Thread sbabic
> The i.MX8MP also has USDHC3, allow access to the relvant base address
> definition.
> Signed-off-by: Martyn Welch 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 5/8] imx8mq: synchronise device tree with linux

2022-11-08 Thread sbabic
> From: Marcel Ziswiler 
> Synchronise device tree with linux v6.1-rc3.
> Signed-off-by: Marcel Ziswiler 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 3/3] imx: imx8mm-beacon: Move Environment to eMMC partition 2

2022-11-08 Thread sbabic
> The downstream U-Boot distributed by Beacon stores the environment
> in the eMMC and the end of partition 2.  This allow the environment
> to stay on the SOM regardless of the boot source.
> Signed-off-by: Adam Ford 
> Reviewed-by: Fabio Estevam 
> diff --git a/configs/imx8mm_beacon_defconfig b/configs/imx8mm_beacon_defconfig
> index 90a623515e..4dd87914b8 100644
> --- a/configs/imx8mm_beacon_defconfig
> +++ b/configs/imx8mm_beacon_defconfig
> @@ -5,8 +5,8 @@ CONFIG_SYS_MALLOC_LEN=0x200
>  CONFIG_SPL_GPIO=y
>  CONFIG_SPL_LIBCOMMON_SUPPORT=y
>  CONFIG_SPL_LIBGENERIC_SUPPORT=y
> -CONFIG_ENV_SIZE=0x1000
> -CONFIG_ENV_OFFSET=0x40
> +CONFIG_ENV_SIZE=0x2000
> +CONFIG_ENV_OFFSET=0xDE00
>  CONFIG_DM_GPIO=y
>  CONFIG_DEFAULT_DEVICE_TREE="imx8mm-beacon-kit"
>  CONFIG_SPL_TEXT_BASE=0x7E1000
> @@ -76,7 +76,8 @@ CONFIG_SPL_OF_CONTROL=y
>  CONFIG_ENV_OVERWRITE=y
>  CONFIG_ENV_IS_IN_MMC=y
>  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> -CONFIG_SYS_MMC_ENV_DEV=1
> +CONFIG_SYS_MMC_ENV_DEV=2
> +CONFIG_SYS_MMC_ENV_PART=2
>  CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
>  CONFIG_USE_ETHPRIME=y
>  CONFIG_ETHPRIME="FEC"
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] ARM: imx: Add version variable to DHSOM

2022-11-08 Thread sbabic
> Enable insertion of version variable into U-Boot environment on DHSOM,
> to make it possible to check U-Boot version e.g. in U-Boot scripts.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] imx: imx8m{m,n,p}_venice: migrate to CONFIG_EXTRA_ENV_TEXT

2022-11-08 Thread sbabic
> Move the majority of the environment from the board headers to
> a separate text file.
> Signed-off-by: Tim Harvey 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH V2 2/4] regulator: bd718x7: Only bind children when PMIC_CHILDREN is enabled

2022-11-08 Thread sbabic
> If the bd718x7 is required, but PMIC_CHILDREN is disabled, this
> driver throws a compile error.  Fix this by putting the function
> to bind children into an if-statement checking for PMIC_CHILDREN.
> Allowing PMIC_CHILDREN to be disabled in SPL saves some space and
> still permits some read/write functions to access the PMIC in
> early startup.
> Signed-off-by: Adam Ford 
> Reviewed-by: Simon Glass 
> Reviewed-by: Fabio Estevam 
> diff --git a/drivers/power/pmic/bd71837.c b/drivers/power/pmic/bd71837.c
> index cb9238972f..fdbbd6f559 100644
> --- a/drivers/power/pmic/bd71837.c
> +++ b/drivers/power/pmic/bd71837.c
> @@ -63,10 +63,11 @@ static int bd71837_bind(struct udevice *dev)
>  
>   debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
>  
> - children = pmic_bind_children(dev, regulators_node, pmic_children_info);
> - if (!children)
> - debug("%s: %s - no child found\n", __func__, dev->name);
> -
> + if (CONFIG_IS_ENABLED(PMIC_CHILDREN)) {
> + children = pmic_bind_children(dev, regulators_node, 
> pmic_children_info);
> + if (!children)
> + debug("%s: %s - no child found\n", __func__, dev->name);
> + }
>   /* Always return success for this device */
>   return 0;
>  }
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH V2 1/4] configs: imx8mn_beacon: Re-align memory to standard imx8mn settings

2022-11-08 Thread sbabic
> The imx8mn_beacon board does not use the same memory map as the reference
> design from NXP or other imx8mn boards.  As such, memory is more limited
> in SPL.
> Moving SPL_BSS_START_ADDR and SPL_STACK to default locations increases
> the amount of available meory for the SPL stack.  Doing this allows
> the board to no longer define CONFIG_MALLOC_F_ADDR.
> Since SYS_LOAD_ADDR also does not align with other boards, move it too.
> Signed-off-by: Adam Ford 
> Reviewed-by: Fabio Estevam 
> Reviewed-by: Peng Fan 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] configs: imx8mn_venice: fix include header protection

2022-11-08 Thread sbabic
> Fix typo in the include header protection.
> Signed-off-by: Tim Harvey 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 6/8] imx8mp: synchronise device tree with linux

2022-11-08 Thread sbabic
> From: Marcel Ziswiler 
> Synchronise device tree with linux v6.1-rc3.
> Signed-off-by: Marcel Ziswiler 
> Tested-By: Tim Harvey  #imx8m{m,n,p}-venice-*
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 2/8] imxrt1020: migrate to build system included -u-boot.dtsi

2022-11-08 Thread sbabic
> From: Marcel Ziswiler 
> Migrate to using automatic build system included -u-boot.dtsi device
> tree include files.
> Signed-off-by: Marcel Ziswiler 
> Reviewed-by: Giulio Benetti 
> Tested-by: Giulio Benetti 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 3/8] imxrt1050: synchronise device tree with linux

2022-11-08 Thread sbabic
> From: Marcel Ziswiler 
> Synchronise device tree with linux v6.1-rc3.
> Note: Nowadays, the intent is for them regular device trees to just be
> synchronised from them Linux kernel device trees and any and all U-Boot
> specific changes need to go into the -u-boot.dtsi device tree include
> files which BTW get included automatically by the U-Boot build system.
> Signed-off-by: Marcel Ziswiler 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH V2 4/4] imx: imx8mn-beacon: Fix out of spec voltage

2022-11-08 Thread sbabic
> The DDR is configured for LPDDR4 running at 1.6GHz which requires
> the voltage on the PMIC to rise a bit before initializing LPDDR4
> or it will be running out of spec.
> Signed-off-by: Adam Ford 
> Reviewed-by: Fabio Estevam 
> Reviewed-by: Peng Fan 
> diff --git a/board/beacon/imx8mn/spl.c b/board/beacon/imx8mn/spl.c
> index 029f71bc99..9acd916180 100644
> --- a/board/beacon/imx8mn/spl.c
> +++ b/board/beacon/imx8mn/spl.c
> @@ -74,6 +74,38 @@ static iomux_v3_cfg_t const pwm_pads[] = {
>   IMX8MN_PAD_GPIO1_IO01__PWM1_OUT | MUX_PAD_CTRL(PWM1_PAD_CTRL),
>  };
>  
> +static int power_init_board(void)
> +{
> + struct udevice *dev;
> + int ret;
> +
> + ret = pmic_get("pmic@4b", &dev);
> + if (ret == -ENODEV) {
> + puts("No pmic\n");
> + return 0;
> + }
> +
> + if (ret != 0)
> + return ret;
> +
> + /* decrease RESET key long push time from the default 10s to 10ms */
> + pmic_reg_write(dev, BD718XX_PWRONCONFIG1, 0x0);
> +
> + /* unlock the PMIC regs */
> + pmic_reg_write(dev, BD718XX_REGLOCK, 0x1);
> +
> + /* increase VDD_SOC to typical value 0.85v before first DRAM access */
> + pmic_reg_write(dev, BD718XX_BUCK1_VOLT_RUN, 0x0f);
> +
> + /* increase VDD_DRAM to 0.975v for 3Ghz DDR */
> + pmic_reg_write(dev, BD718XX_1ST_NODVS_BUCK_VOLT, 0x83);
> +
> + /* lock the PMIC regs */
> + pmic_reg_write(dev, BD718XX_REGLOCK, 0x11);
> +
> + return 0;
> +}
> +
>  int board_early_init_f(void)
>  {
>   /* Claiming pwm pins prevents LCD flicker during startup*/
> @@ -107,6 +139,9 @@ void board_init_f(ulong dummy)
>  
>   enable_tzc380();
>  
> + /* LPDDR4 at 1.6GHz requires a voltage adjustment on the PMIC */
> + power_init_board();
> +
>   /* DDR initialization */
>   spl_dram_init();
>  
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 3/5] drivers: power: pmic: Add support for rn5t568 PMIC

2022-11-08 Thread sbabic
> Add support for the rn5t568 PMIC to the rn5t567 driver.
> Signed-off-by: Martyn Welch 
> Reviewed-by: Jaehoon Chung 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 2/3] imx: imx8mm-beacon: Enable USB booting via SDP

2022-11-08 Thread sbabic
> In order to boot over USB, the device tree needs to enable
> a few extra nodes in SPL.  Since the USB driver has the
> ability to detect host/device, the dr_mode can be removed
> from the device tree since it needs to act as a device when
> booting and OTG is the default mode.  Add USB boot support
> to spl_board_boot_device and enable the corresponding config
> options.
> Signed-off-by: Adam Ford 
> Reviewed-by: Fabio Estevam 
> diff --git a/arch/arm/dts/imx8mm-beacon-kit-u-boot.dtsi 
> b/arch/arm/dts/imx8mm-beacon-kit-u-boot.dtsi
> index c94b4ffa4c..00ac413f36 100644
> --- a/arch/arm/dts/imx8mm-beacon-kit-u-boot.dtsi
> +++ b/arch/arm/dts/imx8mm-beacon-kit-u-boot.dtsi
> @@ -13,6 +13,10 @@
>   };
>  };
>  
> +&aips4 {
> + u-boot,dm-spl;
> +};
> +
>  ®_usdhc2_vmmc {
>   u-boot,off-on-delay-us = <2>;
>  };
> @@ -77,12 +81,24 @@
>   u-boot,dm-spl;
>  };
>  
> +®_usbotg1 {
> +
> +};
> +
>  &uart2 {
>   u-boot,dm-spl;
>  };
>  
> +&usbmisc1 {
> + u-boot,dm-spl;
> +};
> +
>  &usbotg1 {
> - dr_mode="host";
> + u-boot,dm-spl;
> +};
> +
> +&usbphynop1 {
> + u-boot,dm-spl;
>  };
>  
>  &usdhc2 {
> diff --git a/board/beacon/imx8mm/spl.c b/board/beacon/imx8mm/spl.c
> index b0e9d918da..a5f337aa17 100644
> --- a/board/beacon/imx8mm/spl.c
> +++ b/board/beacon/imx8mm/spl.c
> @@ -34,6 +34,8 @@ int spl_board_boot_device(enum boot_device boot_dev_spl)
>   case SD3_BOOT:
>   case MMC3_BOOT:
>   return BOOT_DEVICE_MMC2;
> + case USB_BOOT:
> + return BOOT_DEVICE_BOARD;
>   default:
>   return BOOT_DEVICE_NONE;
>   }
> diff --git a/configs/imx8mm_beacon_defconfig b/configs/imx8mm_beacon_defconfig
> index f6a1012d8a..90a623515e 100644
> --- a/configs/imx8mm_beacon_defconfig
> +++ b/configs/imx8mm_beacon_defconfig
> @@ -39,6 +39,9 @@ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
>  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x300
>  CONFIG_SPL_I2C=y
>  CONFIG_SPL_POWER=y
> +CONFIG_SPL_USB_HOST=y
> +CONFIG_SPL_USB_GADGET=y
> +CONFIG_SPL_USB_SDP_SUPPORT=y
>  CONFIG_SPL_WATCHDOG=y
>  CONFIG_HUSH_PARSER=y
>  CONFIG_SYS_MAXARGS=64
> @@ -56,6 +59,7 @@ CONFIG_CMD_MMC=y
>  CONFIG_CMD_PART=y
>  CONFIG_CMD_SPI=y
>  CONFIG_CMD_USB=y
> +CONFIG_CMD_USB_SDP=y
>  CONFIG_CMD_USB_MASS_STORAGE=y
>  CONFIG_CMD_DHCP=y
>  CONFIG_CMD_MII=y
> @@ -103,6 +107,8 @@ CONFIG_PHY_ATHEROS=y
>  CONFIG_PHY_GIGE=y
>  CONFIG_FEC_MXC=y
>  CONFIG_MII=y
> +CONFIG_SPL_PHY=y
> +CONFIG_SPL_NOP_PHY=y
>  CONFIG_PINCTRL=y
>  CONFIG_SPL_PINCTRL=y
>  CONFIG_PINCTRL_IMX8M=y
> @@ -127,12 +133,13 @@ CONFIG_SYSRESET_PSCI=y
>  CONFIG_SYSRESET_WATCHDOG=y
>  CONFIG_DM_THERMAL=y
>  CONFIG_USB=y
> -# CONFIG_SPL_DM_USB is not set
>  CONFIG_USB_EHCI_HCD=y
> +CONFIG_MXC_USB_OTG_HACTIVE=y
>  CONFIG_USB_STORAGE=y
>  CONFIG_USB_GADGET=y
>  CONFIG_USB_GADGET_VENDOR_NUM=0x0525
>  CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
>  CONFIG_CI_UDC=y
> +CONFIG_SDP_LOADADDR=0x4040
>  CONFIG_USB_GADGET_DOWNLOAD=y
>  CONFIG_IMX_WATCHDOG=y
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] board: gateworks: venice: remove redundance adjustment of thermal trip points

2022-11-08 Thread sbabic
> commit 0543a1ed2787 ("imx8m: fixup thermal trips") moved updating the
> thermal trip points to all IMX8M so we can remove it from our board
> specific dt config.
> Signed-off-by: Tim Harvey 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 4/8] imx8ulp: synchronise device tree with linux

2022-11-08 Thread sbabic
> From: Marcel Ziswiler 
> Synchronise device tree with linux v6.1-rc3.
> Signed-off-by: Marcel Ziswiler 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v2] configs: imx8m: Enable CONFIG_ARMV8_CRYPTO support

2022-11-08 Thread sbabic
> This enables armv8 crypto extension usage for SHA1/SHA256.
> Which speed up sha1/sha256 operations, about 10x faster with
> a imx8mm evk for a 20MiB kernel hash verification (12ms vs 165ms).
> Signed-off-by: Loic Poulain 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 8/8] imx8mm: synchronise device tree with linux

2022-11-08 Thread sbabic
> From: Marcel Ziswiler 
> Synchronise device tree with linux v6.1-rc3.
> Signed-off-by: Marcel Ziswiler 
> Tested-By: Tim Harvey  #imx8m{m,n,p}-venice-*
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] configs: imx8m{m,n,p}_venice: disable autoload

2022-11-08 Thread sbabic
> disable network autoload
> Signed-off-by: Tim Harvey 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 1/8] vf610: synchronise device tree with linux

2022-11-08 Thread sbabic
> From: Marcel Ziswiler 
> Synchronise device tree with linux v6.1-rc3.
> Signed-off-by: Marcel Ziswiler 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 4/5] drivers: power: pmic: Enable use of rn5t567 PMIC in SPL

2022-11-08 Thread sbabic
> From: Martyn Welch 
> The support added later in this series tweaks the PMIC voltages in the
> SPL. Enable support for the rn5t567 in SPL builds to allow this to be done
> cleanly.
> Signed-off-by: Martyn Welch 
> Reviewed-by: Simon Glass 
> Reviewed-by: Jaehoon Chung 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


Re: [PATCH v2 0/8] imx8: switch missing boards to binman

2022-11-08 Thread Stefano Babic

Hi Fabio, Oliver,

On 04.11.22 17:31, Fabio Estevam wrote:

Hi Oliver,

On Fri, Nov 4, 2022 at 12:19 PM Oliver Graute
 wrote:


This patchsets switches the remaining imx8 boards to binman.

Oliver Graute (8):
   imx: imx8qm-rom7720: switch to binman
   imx: imx8qm: cgtqmx8: switch to binman
   imx: imx8qxp: imx8qxp_mek switch to binman
   imx: imx8qm: imx8qm_mek switch to binman
   imx: imx8qxp: giedi switch to binman
   imx: imx8qxp: deneb switch to binman
   imx: imx8x: colibri: switch to binman
   imx: imx8: apalis: switch to binman


Great work, thanks. This series looks good to me:

Reviewed-by: Fabio Estevam 

It would be nice to get some Tested-by from the board maintainers.


I have tried to merge the series, but I get build errors, see:

https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/519510

Could you take a look ?

Thanks,
Stefano

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



[PATCH v5 2/5] ARM: imx: imx8mp: Enable support for i2c5 and i2c6 on i.MX8MP

2022-11-08 Thread sbabic
> The i.MX8MP SoC contains 2 more i2c buses. Add support for the
> configuration of these buses.
> Signed-off-by: Martyn Welch 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] ARM: mx7: psci: fix suspend/resume e10133 workaround

2022-11-08 Thread sbabic
> The e10133 workaround was broken in two places:
> - The code intended to temporarily mask all interrupts in GPC_IMRx_CORE0.
>   While the old register values were saved, the actual masking was
>   missing.
> - imx_udelay() expects the system counter to run at its base frequency,
>   but the system counter is switched to a lower frequency earlier in
>   psci_system_suspend(), leading to a much longer delay than intended.
>   Replace the call with an equivalent loop (linux-imx 5.15 does the same)
> This fixes the SoC hanging forever when there was already a wakeup IRQ
> pending while suspending.
> Fixes: 57b620255e ("imx: mx7: add system suspend/resume support")
> Signed-off-by: Matthias Schiffer 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v5 5/5] arm: imx8mp: Initial MSC SM2S iMX8MP support

2022-11-08 Thread sbabic
> Add support for the MSC SM2S-IMX8PLUS SMARC Module. Tested in conjunction
> with the MSC SM2-MB-EP1 Mini-ITX Carrier Board.
> Signed-off-by: Martyn Welch 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] mx6cuboxi: migrate to DM_SERIAL

2022-11-08 Thread sbabic
> Add the needed DT overrides to enable UART in SPL.
> Cc: Fabio Estevam 
> Signed-off-by: Baruch Siach 
> Tested-by: Tom Rini 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH V2 3/4] configs: imx8mn_beacon: Enable SPL_DM_PMIC_BD71837

2022-11-08 Thread sbabic
> To properly operate the Nano with LPDDR4 at 1.6GHz, the
> voltage needs to be adjusted before DDR is initialized.
> Enable the PMIC in SPL to do this.
> Signed-off-by: Adam Ford 
> Reviewed-by: Fabio Estevam 
> Reviewed-by: Peng Fan 
> diff --git a/configs/imx8mn_beacon_2g_defconfig 
> b/configs/imx8mn_beacon_2g_defconfig
> index 5708ba5c69..4931f836f0 100644
> --- a/configs/imx8mn_beacon_2g_defconfig
> +++ b/configs/imx8mn_beacon_2g_defconfig
> @@ -120,6 +120,7 @@ CONFIG_PINCTRL_IMX8M=y
>  CONFIG_DM_PMIC=y
>  # CONFIG_SPL_PMIC_CHILDREN is not set
>  CONFIG_DM_PMIC_BD71837=y
> +CONFIG_SPL_DM_PMIC_BD71837=y
>  CONFIG_DM_REGULATOR=y
>  CONFIG_DM_REGULATOR_BD71837=y
>  CONFIG_DM_REGULATOR_FIXED=y
> diff --git a/configs/imx8mn_beacon_defconfig b/configs/imx8mn_beacon_defconfig
> index 0793db0bd6..ae29da 100644
> --- a/configs/imx8mn_beacon_defconfig
> +++ b/configs/imx8mn_beacon_defconfig
> @@ -124,6 +124,7 @@ CONFIG_PINCTRL_IMX8M=y
>  CONFIG_DM_PMIC=y
>  # CONFIG_SPL_PMIC_CHILDREN is not set
>  CONFIG_DM_PMIC_BD71837=y
> +CONFIG_SPL_DM_PMIC_BD71837=y
>  CONFIG_DM_REGULATOR=y
>  CONFIG_DM_REGULATOR_BD71837=y
>  CONFIG_DM_REGULATOR_FIXED=y
> diff --git a/configs/imx8mn_beacon_fspi_defconfig 
> b/configs/imx8mn_beacon_fspi_defconfig
> index 6da2182eb3..94d069cbfa 100644
> --- a/configs/imx8mn_beacon_fspi_defconfig
> +++ b/configs/imx8mn_beacon_fspi_defconfig
> @@ -125,6 +125,7 @@ CONFIG_PINCTRL_IMX8M=y
>  CONFIG_DM_PMIC=y
>  # CONFIG_SPL_PMIC_CHILDREN is not set
>  CONFIG_DM_PMIC_BD71837=y
> +CONFIG_SPL_DM_PMIC_BD71837=y
>  CONFIG_DM_REGULATOR=y
>  CONFIG_DM_REGULATOR_BD71837=y
>  CONFIG_DM_REGULATOR_FIXED=y
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


Re: Please pull u-boot-dm

2022-11-08 Thread Tom Rini
On Tue, Nov 08, 2022 at 07:44:29AM -0700, Simon Glass wrote:

> Hi Tom,
> 
> https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/14049
> 
> 
> The following changes since commit 88bd8ee106591eb900561715c44ad04441afc0e3:
> 
>   Prepare v2023.01-rc1 (2022-11-07 15:27:03 -0500)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-dm.git tags/dm-pull-7nov22
> 
> for you to fetch changes up to 168a0e45fcf49194fca55795f84a844f16b480f6:
> 
>   dm: blk: Add probe in blk_first_device/blk_next_device (2022-11-07
> 16:24:30 -0700)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v4 1/1] u-boot-initial-env: rework make target

2022-11-08 Thread Pali Rohár
On Tuesday 08 November 2022 09:52:22 Max Krummenacher wrote:
> From: Max Krummenacher 
> 
> With LTO enabled the U-Boot initial environment is no longer stored
> in an easy accessible section in env/common.o. I.e. the section name
> changes from build to build, its content maybe compressed and it is
> annotated with additional data.
> 
> Drop trying to read the initial env with elf tools from the compiler
> specific object file in favour of adding and using a host tool with
> the only functionality of printing the initial env to stdout.
> 
> See also:
> https://lore.kernel.org/all/927b122e-1f62-e790-f5ca-30bae4332...@foss.st.com/
> 
> Signed-off-by: Max Krummenacher 

Looks good,

Acked-by: Pali Rohár 

> ---
> 
> Changes in v4:
> - add '(objtree)/' when calling the tool. Suggested by Pali Rohár.
> - renamed patch, as more than just the Makefile has changes
> 
> Changes in v3:
> - moved the tool from scripts/ to tools/. Suggested by Tom Rini
> - changed the dependencies to '$(env_h)' and 'tools'.
>   Suggested by Tom Rini and Pali Rohár.
> - removed the sed rule which replaces \x00 with \x0A as this is already
>   done by the tool. Suggested by Pali Rohár.
> 
> Changes in v2:
> - reworked to build a host tool which prints the configured
>   environment as proposed by Pali Rohár
>   
> https://lore.kernel.org/u-boot/20221018174827.1393211-1-max.oss...@gmail.com/
> - renamed patch, v1 used "Makefile: fix u-boot-initial-env target if lto is 
> enabled"
> 
>  Makefile|  9 +
>  tools/.gitignore|  1 +
>  tools/Makefile  |  3 +++
>  tools/printinitialenv.c | 44 +
>  4 files changed, 53 insertions(+), 4 deletions(-)
>  create mode 100644 tools/printinitialenv.c
> 
> diff --git a/Makefile b/Makefile
> index 0f1174718f7..c0669840dc7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2442,11 +2442,12 @@ endif
>   $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
>  
>  quiet_cmd_genenv = GENENV  $@
> -cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ 
> env/common.o; \
> - sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' $@; 
> \
> - sort --field-separator== -k1,1 --stable $@ -o $@
> +cmd_genenv = \
> + $(objtree)/tools/printinitialenv | \
> + sed -e '/^\s*$$/d' | \
> + sort --field-separator== -k1,1 --stable -o $@
>  
> -u-boot-initial-env: u-boot.bin
> +u-boot-initial-env: $(env_h) tools FORCE
>   $(call if_changed,genenv)
>  
>  # Consistency checks
> diff --git a/tools/.gitignore b/tools/.gitignore
> index d3a93ff294a..28e8ce2a07a 100644
> --- a/tools/.gitignore
> +++ b/tools/.gitignore
> @@ -28,6 +28,7 @@
>  /mxsboot
>  /ncb
>  /prelink-riscv
> +/printinitialenv
>  /proftool
>  /relocate-rela
>  /spl_size_limit
> diff --git a/tools/Makefile b/tools/Makefile
> index 34a1aa7a8b7..a3afdee7813 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -245,6 +245,9 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
>  hostprogs-$(CONFIG_ASN1_COMPILER)+= asn1_compiler
>  HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
>  
> +# host tool to dump the currently configured default environment
> +hostprogs-y  += printinitialenv
> +
>  HOSTCFLAGS_mkeficapsule.o += \
>   $(shell pkg-config --cflags gnutls 2> /dev/null || echo "")
>  HOSTCFLAGS_mkeficapsule.o += \
> diff --git a/tools/printinitialenv.c b/tools/printinitialenv.c
> new file mode 100644
> index 000..c58b234d679
> --- /dev/null
> +++ b/tools/printinitialenv.c
> @@ -0,0 +1,44 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * (C) Copyright 2022
> + * Max Krummenacher, Toradex
> + *
> + * Snippets taken from tools/env/fw_env.c
> + *
> + * This prints the list of default environment variables as currently
> + * configured.
> + *
> + */
> +
> +#include 
> +
> +/* Pull in the current config to define the default environment */
> +#include 
> +
> +#ifndef __ASSEMBLY__
> +#define __ASSEMBLY__ /* get only #defines from config.h */
> +#include 
> +#undef   __ASSEMBLY__
> +#else
> +#include 
> +#endif
> +
> +#define DEFAULT_ENV_INSTANCE_STATIC
> +#include 
> +#include 
> +
> +int main(void)
> +{
> + char *env, *nxt;
> +
> + for (env = default_environment; *env; env = nxt + 1) {
> + for (nxt = env; *nxt; ++nxt) {
> + if (nxt >= 
> &default_environment[sizeof(default_environment)]) {
> + fprintf(stderr, "## Error: environment not 
> terminated\n");
> + return -1;
> + }
> + }
> + printf("%s\n", env);
> + }
> + return 0;
> +}
> -- 
> 2.35.3
> 


Re: [PATCH v4] schemas: Add schema for U-Boot driver model 'phase tags'

2022-11-08 Thread Rob Herring
On Tue, Nov 1, 2022 at 10:13 PM Simon Glass  wrote:
>
> U-Boot has some particular challenges with device tree and devices:
>
> - U-Boot has multiple build phases, such as a Secondary Program Loader
>   (SPL) phase which typically runs in a pre-SDRAM environment where code
>   and data space are limited. In particular, there may not be enough
>   space for the full device tree blob. U-Boot uses various automated
>   techniques to reduce the size from perhaps 40KB to 3KB. It is not
>   always possible to handle these tags entirely at build time, since
>   U-Boot proper must have the full device tree, even though we do not
>   want it to process all nodes until after relocation.
> - Some U-Boot phases needs to run before the clocks are properly set up,
>   where the CPU may be running very slowly. Therefore it is important to
>   bind only those devices which are actually needed in that phase
> - U-Boot uses lazy initialisation for its devices, with 'bind' and
>   'probe' being separate steps. Even if a device is bound, it is not
>   actually probed until it is used. This is necessary to keep the boot
>   time reasonable, e.g. to under a second
>
> The phases of U-Boot in order are: TPL, VPL, SPL, U-Boot (first
> pre-relocation, then post-relocation). ALl but the last two are optional.
>
> For the above reasons, U-Boot only includes the full device tree in the
> final 'U-Boot proper' build. Even then, before relocation U-Boot only
> processes nodes which are marked as being needed.
>
> For this to work, U-Boot's driver model[1] provides a way to mark device
> tree nodes as applicable for a particular phase. This works by adding a
> tag to the node, e.g.:
>
>cru: clock-controller@ff76 {
>   phase,all;
>   compatible = "rockchip,rk3399-cru";
>   reg = <0x0 0xff76 0x0 0x1000>;
>   rockchip,grf = <&grf>;
>   #clock-cells = <1>;
>   #reset-cells = <1>;
>   ...
>};
>
> Here the "phase,all" tag indicates that the node must be present in all
> phases, since the clock driver is required.
>
> There has been discussion over the years about whether this could be done
> in a property instead, e.g.
>
>options {
>   phase,all = <&cru> <&gpio_a> ...;
>   ...
>};
>
> Some problems with this:
>
> - we need to be able to merge several such tags from different .dtsi files
>   since many boards have their own specific requirements
> - it is hard to find and cross-reference the affected nodes
> - it is more error-prone
> - it requires significant tool rework in U-Boot, including fdtgrep and
>   the build system
> - is harder (slower, more code) to process since it involves scanning
>   another node/property to find out what to do with a particular node
> - we don't want to add phandle arguments to the above since we are
>   referring, e.g., to the clock device as a whole, not a paricular clock
> - the of-platdata feature[2], which converts device tree to C for even
>   more constrained environments, would need to become aware of the
>   /options node
>
> There is also the question about whether this needs to be U-Boot-specific,
> or whether the tags could be generic. From what I can tell, U-Boot is the
> only bootloader which seriously attempts to use a runtime device tree in
> all cases. For this version, an attempt is made to name the phases in a
> generic manner.
>
> It should also be noted that the approach provided here has stood the test
> of time, used in U-Boot for 8 years so far.
>
> So add the schema for this. This will allow a major class of schema
> exceptions to be dropped from the U-Boot source tree.
>
> This being sent to the mailing list since it might attract more review.
> A PR will be sent when this has had some review. That is why the file
> path is set up for https://github.com/devicetree-org/dt-schema rather
> than the Linux kernel.
>
> [1] https://u-boot.readthedocs.io/en/latest/develop/driver-model/index.html
> [2] https://u-boot.readthedocs.io/en/latest/develop/driver-model/of-plat.html
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v4:
> - Drop some unnecessary context from the commit message
> - Explain why parent nodes do not automatically inherit their children's
>   tags
> - Rename the tags to use a phase,xxx format, explaining each one
>
> Changes in v3:
> - Fix an incorrect schema path in $id
>
> Changes in v2:
> - Expand docs to include a description of each tag
> - Fix some typos and unclear wording
>
>  dtschema/lib.py |  5 +++
>  dtschema/schemas/phase.yaml | 73 +
>  test/phases.dts | 26 +
>  3 files changed, 104 insertions(+)
>  create mode 100644 dtschema/schemas/phase.yaml
>  create mode 100644 test/phases.dts
>
> diff --git a/dtschema/lib.py b/dtschema/lib.py
> index 3b6c937..9a2fafa 100644
> --- a/dtschema/lib.py
> +++ b/dtschema/lib.py
> @@ -514,6 +514,11 @@ def fixup_node_props(schema):
>  schema['properties'].setdefault('status', True)
>  sche

Changing eMMC boot partition size

2022-11-08 Thread Philip Oberfichtner
Hi everybody,

I have a question regarding changing the eMMC boot partition size.
According the the JEDEC eMMC spec it is read-only (BOOT_SIZE_MULT
register).

But we still have mmc_boot_partition_size_change() in
drivers/mmc/mmc_boot.c. It contains the comment

/* Only use this command for raw EMMC moviNAND. Enter backdoor mode */

What is moviNAND? My research pointed me to Samsung products only. So
is changing the boot partition size vendor specific or can it be used
more generally?

To be specific, I use the Kioxia THGBMJG6C1LBAB7 eMMC chip.


Thanks and best regards,
Philip Oberfichtner


Re: Changing eMMC boot partition size

2022-11-08 Thread Tom Rini
On Tue, Nov 08, 2022 at 06:34:18PM +0100, Philip Oberfichtner wrote:
> Hi everybody,
> 
> I have a question regarding changing the eMMC boot partition size.
> According the the JEDEC eMMC spec it is read-only (BOOT_SIZE_MULT
> register).
> 
> But we still have mmc_boot_partition_size_change() in
> drivers/mmc/mmc_boot.c. It contains the comment
> 
> /* Only use this command for raw EMMC moviNAND. Enter backdoor mode */
> 
> What is moviNAND? My research pointed me to Samsung products only. So
> is changing the boot partition size vendor specific or can it be used
> more generally?
> 
> To be specific, I use the Kioxia THGBMJG6C1LBAB7 eMMC chip.

Yes, moviNAND was some Samsung technology that may or may not still be
used on some platforms. And yes, some eMMC parts do allow for boot
partitions to be resized but such information is often under NDA, so
contacting the hardware vendor or looking for eMMC chip documentation
may be helpful here.

-- 
Tom


signature.asc
Description: PGP signature


Re: [RFC PATCH v5 09/24] cli: Add menu for hush parser

2022-11-08 Thread Simon Glass
Hi,

On Tue, 8 Nov 2022 at 08:21, Tom Rini  wrote:
>
> On Mon, Nov 07, 2022 at 08:28:42AM -0700, Simon Glass wrote:
> > Hi Patrick,
> >
> > On Mon, 7 Nov 2022 at 05:32, Patrick DELAUNAY
> >  wrote:
> > >
> > > Hi,
> > >
> > > On 11/1/22 20:20, Francis Laniel wrote:
> > > > For the moment, the menu contains only entry: HUSH_OLD_PARSER which is 
> > > > the
> > > > default.
> > > > The goal is to prepare the field to add a new hush parser which 
> > > > guarantees
> > > > actual behavior is still correct.
> > > >
> > > > Signed-off-by: Francis Laniel 
> > > > ---
> > > >   cmd/Kconfig | 21 +
> > > >   common/Makefile |  3 ++-
> > > >   2 files changed, 23 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > > > index 3f6bc70d43..c15d7c51f7 100644
> > > > --- a/cmd/Kconfig
> > > > +++ b/cmd/Kconfig
> > > > @@ -23,6 +23,27 @@ config HUSH_PARSER
> > > > If disabled, you get the old, much simpler behaviour with a 
> > > > somewhat
> > > > smaller memory footprint.
> > > >
> > > > +menu "Hush flavor to use"
> > > > + depends on HUSH_PARSER
> > > > +
> > > > + config HUSH_OLD_PARSER
> > > > + bool "Use hush old parser"
> > > > + default y
> > > > + help
> > > > +   This option enables the old flavor of hush based on 
> > > > hush Busybox from
> > > > +   2005.
> > > > +
> > > > +   It is actually the default U-Boot shell when decided to 
> > > > use hush as shell.
> > > > +
> > > > + config HUSH_2021_PARSER
> > > > + bool "Use hush 2021 parser"
> > > > + help
> > > > +   This option enables the new flavor of hush based on 
> > > > hush Busybox from
> > > > +   2021.
> > > > +
> > > > +   For the moment, it is highly experimental and should be 
> > > > used at own risks.
> > > > +endmenu
> > > > +
> > >
> > >
> > > I think "choice" can be made sense here
> > >
> > > => only one version is used
> > >
> > >
> > > choice
> > >  prompt "Hush flavor to use"
> > >  default HUSH_OLD_PARSER
> > >
> > >  depends on HUSH_PARSER
> > >
> > >
> > > config HUSH_OLD_PARSER
> > >
> > >  bool  "Use hush old parser"
> > >
> > > config HUSH_2021_PARSER
> > >
> > >bool "Use hush 2021 parser"
> > >
> > > endchoice
> >
> > We need to be able to build both and then select the correct one at
> > runtime, at least for sandbox. Otherwise we would need yet another
> > sandbox build. So I think what we have here makes sense.
>
> I think choice is fine, as that's for testing. Once we're ready to merge
> this we'll not keep both around for long.

Oh that's good. I heard people worrying about compatibility and size
of the new shell, so thought we might need both.

Regards,
Simon


Re: [PATCH v20 4/4] test: cmd: add test for wget command.

2022-11-08 Thread Simon Glass
On Mon, 7 Nov 2022 at 23:17, Ying-Chun Liu (PaulLiu)
 wrote:
>
> From: "Ying-Chun Liu (PaulLiu)" 
>
> Simulate a TCP HTTP server's response for testing wget command.
>
> Signed-off-by: Ying-Chun Liu (PaulLiu) 
> Cc: Christian Gmeiner 
> Cc: Joe Hershberger 
> Cc: Michal Simek 
> Cc: Ramon Fried 
> Cc: Simon Glass 
> ---
>  test/cmd/Makefile |   1 +
>  test/cmd/wget.c   | 206 ++
>  2 files changed, 207 insertions(+)
>  create mode 100644 test/cmd/wget.c
>

Reviewed-by: Simon Glass 


Re: [PATCH v20 3/4] doc: cmd: wget: add documentation

2022-11-08 Thread Simon Glass
On Mon, 7 Nov 2022 at 23:17, Ying-Chun Liu (PaulLiu)
 wrote:
>
> From: "Ying-Chun Liu (PaulLiu)" 
>
> Add documentation for the wget command.
>
> Signed-off-by: Ying-Chun Liu (PaulLiu) 
> Cc: Christian Gmeiner 
> Cc: Joe Hershberger 
> Cc: Michal Simek 
> Cc: Ramon Fried 
> Cc: Simon Glass 
> ---
>  doc/usage/cmd/wget.rst | 61 ++
>  doc/usage/index.rst|  1 +
>  2 files changed, 62 insertions(+)
>  create mode 100644 doc/usage/cmd/wget.rst
>

Reviewed-by: Simon Glass 


Re: [PATCH v20 2/4] net: Add wget application

2022-11-08 Thread Sean Anderson
On 11/8/22 01:17, Ying-Chun Liu (PaulLiu) wrote:
> From: "Ying-Chun Liu (PaulLiu)" 
> 
> This commit adds a simple wget command that can download files
> from http server.
> 
> The command syntax is
> wget ${loadaddr} 
> 
> Signed-off-by: Duncan Hare 
> Signed-off-by: Ying-Chun Liu (PaulLiu) 
> Reviewed-by: Simon Glass 
> Cc: Christian Gmeiner 
> Cc: Joe Hershberger 
> Cc: Michal Simek 
> Cc: Ramon Fried 
> ---
> v1-v12: Made by Duncan, didn't tracked.
> v13: Fix some issues which is reviewed by Christian
> v14: Add options to enable/disable SACK.
> v15: Fix various syntax errors reviewed by Michal.
>  Remove magic numbers. Use kernel-doc format.
> v16: Add more kernel-doc. Fix more double spaces.
> v17: Fix wget with address timeout issue reported by Ramon.
> v20: Rebase to latest master and resolve conflict.
> ---
>  cmd/Kconfig|   7 +
>  cmd/net.c  |  13 ++
>  include/net.h  |   2 +-
>  include/net/wget.h |  22 +++
>  net/Makefile   |   1 +
>  net/net.c  |   6 +
>  net/wget.c | 438 +
>  7 files changed, 488 insertions(+), 1 deletion(-)
>  create mode 100644 include/net/wget.h
>  create mode 100644 net/wget.c
> 
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 105406496e..d093581b24 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -1798,6 +1798,13 @@ config SYS_DISABLE_AUTOLOAD
> is complete.  Enable this option to disable this behavior and instead
> require files to be loaded over the network by subsequent commands.
>  
> +config CMD_WGET
> + bool "wget"
> + select TCP
> + help
> +   wget is a simple command to download kernel, or other files,
> +   from a http server over TCP.
> +
>  config CMD_MII
>   bool "mii"
>   imply CMD_MDIO
> diff --git a/cmd/net.c b/cmd/net.c
> index addcad3ac1..f6d9f5ea3a 100644
> --- a/cmd/net.c
> +++ b/cmd/net.c
> @@ -125,6 +125,19 @@ U_BOOT_CMD(
>  );
>  #endif
>  
> +#if defined(CONFIG_CMD_WGET)
> +static int do_wget(struct cmd_tbl *cmdtp, int flag, int argc, char * const 
> argv[])
> +{
> + return netboot_common(WGET, cmdtp, argc, argv);
> +}
> +
> +U_BOOT_CMD(
> + wget,   3,  1,  do_wget,
> + "boot image via network using HTTP protocol",
> + "[loadAddress] [[hostIPaddr:]path and image name]"
> +);
> +#endif
> +
>  static void netboot_update_env(void)
>  {
>   char tmp[22];
> diff --git a/include/net.h b/include/net.h
> index f4140523c2..e0c7804827 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -561,7 +561,7 @@ extern intnet_restart_wrap;   /* 
> Tried all network devices */
>  
>  enum proto_t {
>   BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
> - TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI
> + TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI, WGET
>  };
>  
>  extern char  net_boot_file_name[1024];/* Boot File name */
> diff --git a/include/net/wget.h b/include/net/wget.h
> new file mode 100644
> index 00..da0920de11
> --- /dev/null
> +++ b/include/net/wget.h
> @@ -0,0 +1,22 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Duncan Hare Copyright 2017
> + */
> +
> +/**
> + * wget_start() - begin wget
> + */
> +void wget_start(void);
> +
> +enum wget_state {
> + WGET_CLOSED,
> + WGET_CONNECTING,
> + WGET_CONNECTED,
> + WGET_TRANSFERRING,
> + WGET_TRANSFERRED
> +};
> +
> +#define DEBUG_WGET   0   /* Set to 1 for debug messages */
> +#define SERVER_PORT  80
> +#define WGET_RETRY_COUNT 30
> +#define WGET_TIMEOUT 2000UL
> diff --git a/net/Makefile b/net/Makefile
> index d131d1cb1a..4f757a224c 100644
> --- a/net/Makefile
> +++ b/net/Makefile
> @@ -31,6 +31,7 @@ obj-$(CONFIG_UDP_FUNCTION_FASTBOOT)  += fastboot.o
>  obj-$(CONFIG_CMD_WOL)  += wol.o
>  obj-$(CONFIG_PROT_UDP) += udp.o
>  obj-$(CONFIG_PROT_TCP) += tcp.o
> +obj-$(CONFIG_CMD_WGET) += wget.o
>  
>  # Disable this warning as it is triggered by:
>  # sprintf(buf, index ? "foo%d" : "foo", index)
> diff --git a/net/net.c b/net/net.c
> index 7878a9970b..8c630f9467 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -118,6 +118,7 @@
>  #include "wol.h"
>  #endif
>  #include 
> +#include 
>  
>  /** BOOTP EXTENTIONS **/
>  
> @@ -517,6 +518,11 @@ restart:
>   nfs_start();
>   break;
>  #endif
> +#if defined(CONFIG_CMD_WGET)
> + case WGET:
> + wget_start();
> + break;
> +#endif
>  #if defined(CONFIG_CMD_CDP)
>   case CDP:
>   cdp_start();
> diff --git a/net/wget.c b/net/wget.c
> new file mode 100644
> index 00..3826c4b364
> --- /dev/null
> +++ b/net/wget.c
> @@ -0,0 +1,438 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * WGET/HTTP support driver based on U-BOOT's nfs.c
> + * Copyright Duncan Hare  2017
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
>

Re: [PATCH 1/8] arm: dts: introduce am62a7 dtbs from linux kernel

2022-11-08 Thread Bryan Brattlof
On November  4, 2022 thus sayeth Tom Rini:
> On Thu, Nov 03, 2022 at 07:13:51PM -0500, Bryan Brattlof wrote:
> 
> > Introduce the basic am62a7 SoC dtbs from the linux kernel along with the
> > new am62a specific pinmux definition that we will use to generate the
> > dtbs for the u-boot-spl and u-boot binaries
> 
> Please note what tag this is synced from.
>

Ah! I'll update the commit msg in v2. I pulled these from v6.1-rc3

Thanks for reviewing
~Bryan


Re: [PATCH 0/8] Introduce initial TI's am62a support

2022-11-08 Thread Bryan Brattlof
On November  4, 2022 thus sayeth Andrew Davis:
> On 11/4/22 8:08 AM, Tom Rini wrote:
> > On Fri, Nov 04, 2022 at 11:49:39AM +, Peter Robinson wrote:
> > > Hi Bryan,
> > > 
> > > > This series will introduce basic support (SD and UART) support for Texas
> > > > Instruments AM62Ax SK EVM.
> > > > 
> > > > The am62ax shares many of the same features as the am62x however it uses
> > > > a new 32bit controller and therefore depends on the patch I sent last
> > > > week updating the macros used by the k3-ddrss ram driver[0].
> > > > 
> > > > Here is some proof of life & more documentation if you're interested :)
> > > > 
> > > > Bootlog:https://paste.sr.ht/~bryanb/e0a418ba7dd452749d2dd1efb5e91b2875a01708
> > > > Technical Reference Manual:https://www.ti.com/lit/zip/spruj16
> > > > Schematics:https://www.ti.com/lit/zip/sprr459
> > > 
> > > Does this board need a readme for how to build the firmware, these
> > > days there generally needs to be ATF and probably a slew of other
> > > firmwares linked into a FIT image or similar to build the entire
> > > firmware bundle, a readme would likely be a useful addition for people
> > > getting started if there's not a generic TI 64 bit build doc, and if
> > > there is that likely needs an update to include this SoC/board. I
> > > didn't see anything that looked like that in the file list below.
> > 
> > Agreed, something under doc/board/ti/ is needed as well for the series,
> > thanks!
> > 
> 
> I see we do have some files at board/ti/{j721e,j721s2}/README with some
> good info on all this firmware source/building. Much of that info is
> common and could be factored out into a "generic TI 64 bit build doc".
> 

Cool! I can add this to the series :)

Thanks for reviewing everyone
~Bryan


Re: [PATCH v2 0/8] imx8: switch missing boards to binman

2022-11-08 Thread Fabio Estevam
Hi Oliver and Stefano,

On Tue, Nov 8, 2022 at 1:43 PM Stefano Babic  wrote:

> I have tried to merge the series, but I get build errors, see:
>
> https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/519510
>
> Could you take a look ?

One problem I noticed is the missing CONFIG_TEXT_BASE conversion:

diff --git a/arch/arm/dts/imx8qm-u-boot.dtsi b/arch/arm/dts/imx8qm-u-boot.dtsi
index 3507489a813c..442e64badc39 100644
--- a/arch/arm/dts/imx8qm-u-boot.dtsi
+++ b/arch/arm/dts/imx8qm-u-boot.dtsi
@@ -50,7 +50,7 @@
arch = "arm64";
compression = "none";
description = "U-Boot (64-bit)";
-   load = ;
+   load = ;
type = "standalone";

uboot-blob {
diff --git a/arch/arm/dts/imx8qxp-u-boot.dtsi b/arch/arm/dts/imx8qxp-u-boot.dtsi
index 01183f8ade63..e8df5bb8bfea 100644
--- a/arch/arm/dts/imx8qxp-u-boot.dtsi
+++ b/arch/arm/dts/imx8qxp-u-boot.dtsi
@@ -50,7 +50,7 @@
arch = "arm64";
compression = "none";
description = "U-Boot (64-bit)";
-   load = ;
+   load = ;
type = "standalone";

uboot-blob {

With this fix applied, I got:

WARNING './ahab-container.img' not found, resulting binary is not-functional
make[1]: Nothing to be done for 'SPL'.
  BINMAN  all
binman: Error 1 running 'mkimage -d ./mkimage.spl.mkimage -n
spl/u-boot-spl.cfgout -T imx8image -e 0x10
./mkimage-out.spl.mkimage': Fail open first container file
ahab-container.img

make: *** [Makefile:1116: all] Error 1


but if I manually copy the firmware, then the build succeeds.

binman should not thrown an error in case of missing firmware. Oliver,
any ideas?

Also, some boards use ahab-container.img and others use
mx8qxc0-ahab-container.img.

Is it OK to use mx8qxc0-ahab-container.img for all of them?


[PATCH] dfu: bounds check USB upload and download sizes

2022-11-08 Thread Sultan Qasim Khan
Also verify transfer directions match what is expected for the operation
type. Addresses memory corruption and disclosure vulnerability
CVE-2022-2347.

Signed-off-by: Sultan Qasim Khan 
---
 drivers/usb/gadget/f_dfu.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index e9340ff5cb..4a7057c529 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -323,7 +323,7 @@ static int state_dfu_idle(struct f_dfu *f_dfu,
 
switch (ctrl->bRequest) {
case USB_REQ_DFU_DNLOAD:
-   if (len == 0) {
+   if (len == 0 || len > DFU_USB_BUFSIZ || (ctrl->bRequestType & 
USB_DIR_IN)) {
f_dfu->dfu_state = DFU_STATE_dfuERROR;
value = RET_STALL;
break;
@@ -333,6 +333,11 @@ static int state_dfu_idle(struct f_dfu *f_dfu,
value = handle_dnload(gadget, len);
break;
case USB_REQ_DFU_UPLOAD:
+   if (len > DFU_USB_BUFSIZ || (ctrl->bRequestType & USB_DIR_IN) 
!= USB_DIR_IN) {
+   f_dfu->dfu_state = DFU_STATE_dfuERROR;
+   value = RET_STALL;
+   break;
+   }
f_dfu->dfu_state = DFU_STATE_dfuUPLOAD_IDLE;
f_dfu->blk_seq_num = 0;
value = handle_upload(req, len);
@@ -428,6 +433,11 @@ static int state_dfu_dnload_idle(struct f_dfu *f_dfu,
 
switch (ctrl->bRequest) {
case USB_REQ_DFU_DNLOAD:
+   if (len > DFU_USB_BUFSIZ || (ctrl->bRequestType & USB_DIR_IN)) {
+   f_dfu->dfu_state = DFU_STATE_dfuERROR;
+   value = RET_STALL;
+   break;
+   }
f_dfu->dfu_state = DFU_STATE_dfuDNLOAD_SYNC;
f_dfu->blk_seq_num = w_value;
value = handle_dnload(gadget, len);
@@ -515,6 +525,11 @@ static int state_dfu_upload_idle(struct f_dfu *f_dfu,
 
switch (ctrl->bRequest) {
case USB_REQ_DFU_UPLOAD:
+   if (len > DFU_USB_BUFSIZ || (ctrl->bRequestType & USB_DIR_IN) 
!= USB_DIR_IN) {
+   f_dfu->dfu_state = DFU_STATE_dfuERROR;
+   value = RET_STALL;
+   break;
+   }
/* state transition if less data then requested */
f_dfu->blk_seq_num = w_value;
value = handle_upload(req, len);
-- 
2.31.1



Re: [PATCH] dfu: bounds check USB upload and download sizes

2022-11-08 Thread Fabio Estevam
Hi Sultan,

On Tue, Nov 8, 2022 at 9:22 PM Sultan Qasim Khan  wrote:
>
> Also verify transfer directions match what is expected for the operation
> type. Addresses memory corruption and disclosure vulnerability
> CVE-2022-2347.
>
> Signed-off-by: Sultan Qasim Khan 

There was a submission already to fix this problem:
https://lists.denx.de/pipermail/u-boot/2022-November/498977.html


Re: [PATCH] dfu: bounds check USB upload and download sizes

2022-11-08 Thread Sultan Khan
Hi Fabio,

Ah, sorry I missed that. This was on my todo list to patch as when I looked 
last week I didn’t see any patch for it. That patch you linked should also work 
to solve the issue.

Best regards,
Sultan Qasim Khan

> On Nov 8, 2022, at 7:56 PM, Fabio Estevam  wrote:
> 
> Hi Sultan,
> 
> On Tue, Nov 8, 2022 at 9:22 PM Sultan Qasim Khan  
> wrote:
>> 
>> Also verify transfer directions match what is expected for the operation
>> type. Addresses memory corruption and disclosure vulnerability
>> CVE-2022-2347.
>> 
>> Signed-off-by: Sultan Qasim Khan 
> 
> There was a submission already to fix this problem:
> https://lists.denx.de/pipermail/u-boot/2022-November/498977.html



Re: [PATCH 01/11] imx: implement get_effective_memsize

2022-11-08 Thread Peng Fan




On 11/8/2022 4:03 PM, Pali Rohár wrote:

On Tuesday 08 November 2022 07:56:59 Peng Fan wrote:

Subject: Re: [PATCH 01/11] imx: implement get_effective_memsize

On Tuesday 08 November 2022 09:38:01 Peng Fan wrote:

On 11/7/2022 3:55 PM, Pali Rohár wrote:

On Monday 07 November 2022 16:00:06 Peng Fan (OSS) wrote:

From: Peng Fan 

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause
the top 1MB not mapped as normal memory, because ARMV7-A use
section mapping. So implement i.MX6/7 specific
get_effective_memsize to fix the issue.

Fixes: 777706bc("common/memsize.c: Fix get_effective_memsize()
to check for overflow")
Signed-off-by: Peng Fan 


Should not just configuring CONFIG_MAX_MEM_MAPPED properly avoid

that issue?


No, unless I decrease PHYS_SDRAM_SIZE.


So, what is the issue? I just do not see what happens after 777706bc
that RAM size is calculated incorrectly in your case. I did not catch the
description from commit message. What are your gd->ram_size and
CONFIG_MAX_MEM_MAPPED values that current code does not work?


The base is 2GB, the size is 2GB. With CONFIG_MAX_MEM_MAPPED,
the ram_size already decreased by 4KB.


If base is 2GB and size is 2GB then ram_top is 4GB which cannot be
represented in 32-bit phys_size_t type and hence some of other u-boot
functions use 0 as ram_top. Mentioned commit tries to fix this issue.
I guess that you have some other hidden problem and my change just
showed implication of that. 


The issue is with higher 4KB cut off, the MMU mapping will cut off
1MB or 2MB(section mapping), so after MMU enabled, the PC instruction 
will not able to fetch instruction in the higher 1MB area because of 
U-Boot relocated to

top of DRAM.

Regards,
Peng.

Could you check how is gd->ram_top

configured with and without this change?


Regards,
Peng.




Regards,
Peng.




---
   arch/arm/mach-imx/cache.c | 14 ++
   1 file changed, 14 insertions(+)

diff --git a/arch/arm/mach-imx/cache.c b/arch/arm/mach-imx/cache.c
index ab9b621a2a6..69a085abee7 100644
--- a/arch/arm/mach-imx/cache.c
+++ b/arch/arm/mach-imx/cache.c
@@ -7,10 +7,24 @@
   #include 
   #include 
   #include 
+#include 
   #include 
   #include 
   #include 
+DECLARE_GLOBAL_DATA_PTR;
+
+phys_size_t get_effective_memsize(void) { #ifndef
+CONFIG_MAX_MEM_MAPPED
+   return gd->ram_size;
+#else
+   /* limit stack to what we can reasonable map */
+   return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+   CONFIG_MAX_MEM_MAPPED : gd->ram_size); #endif }
+
   void enable_ca7_smp(void)
   {
u32 val;
--
2.36.0



Re: [PATCH 1/2] arm: mediatek: add mt8195 SOC support

2022-11-08 Thread 云春峰
On Tue, 2022-11-08 at 11:21 +0800, Macpaul Lin wrote:
> From: Fabien Parent 
> 
> The MediaTek MT8195 is a ARM64-based SoC with a quad-core Cortex-A73
> and
> a quad-core Cortex-A53. It is including UART, SPI, USB3.0 device and
> hosts,
> SD and MMC cards, UFS, PWM, I2C, I2S, S/PDIF, and several LPDDR3
> and LPDDR4 options.
> 
> Signed-off-by: Fabien Parent 
> Signed-off-by: Macpaul Lin 
> ---
>  MAINTAINERS|   2 +
>  arch/arm/dts/mt8195.dtsi   | 317
> +
>  arch/arm/mach-mediatek/Kconfig |  13 +-
>  arch/arm/mach-mediatek/Makefile|   1 +
>  arch/arm/mach-mediatek/mt8195/Makefile |   3 +
>  arch/arm/mach-mediatek/mt8195/init.c   |  81 +++
>  6 files changed, 416 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/dts/mt8195.dtsi
>  create mode 100644 arch/arm/mach-mediatek/mt8195/Makefile
>  create mode 100644 arch/arm/mach-mediatek/mt8195/init.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1cf99c1393..5528dd28c3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -362,8 +362,10 @@ ARM MEDIATEK
>  M:   Ryder Lee 
>  M:   Weijie Gao 
>  M:   Chunfeng Yun 
> +M:   Macpaul Lin 
>  R:   GSS_MTK_Uboot_upstream 
>  S:   Maintained
> +F:   arch/arm/dts/mt8195.dtsi
>  F:   arch/arm/mach-mediatek/
>  F:   arch/arm/include/asm/arch-mediatek/
>  F:   board/mediatek/
> diff --git a/arch/arm/dts/mt8195.dtsi b/arch/arm/dts/mt8195.dtsi
> new file mode 100644
> index 00..d28b038d57
> --- /dev/null
> +++ b/arch/arm/dts/mt8195.dtsi
> @@ -0,0 +1,317 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +/*
> + * Copyright (C) 2022 MediaTek Inc.
> + * Copyright (C) 2022 BayLibre, SAS
> + * Author: Ben Ho 
> + * Erin Lo 
> + * Fabien Parent 
> + * Macpaul Lin 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/ {
> + compatible = "mediatek,mt8195";
> + interrupt-parent = <&sysirq>;
> + #address-cells = <2>;
> + #size-cells = <2>;
> +
> + cpus {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + cpu-map {
> + cluster0 {
> + core0 {
> + cpu = <&cpu0>;
> + };
> + core1 {
> + cpu = <&cpu1>;
> + };
> + core2 {
> + cpu = <&cpu2>;
> + };
> + core3 {
> + cpu = <&cpu3>;
> + };
> + };
> +
> + cluster1 {
> + core0 {
> + cpu = <&cpu4>;
> + };
> + core1 {
> + cpu = <&cpu5>;
> + };
> + core2 {
> + cpu = <&cpu6>;
> + };
> + core3 {
> + cpu = <&cpu7>;
> + };
> + };
> + };
> +
> + cpu0: cpu@0 {
> + device_type = "cpu";
> + compatible = "arm,cortex-a53";
> + reg = <0x000>;
> + enable-method = "psci";
> + capacity-dmips-mhz = <741>;
> + };
> +
> + cpu1: cpu@1 {
> + device_type = "cpu";
> + compatible = "arm,cortex-a53";
> + reg = <0x001>;
> + enable-method = "psci";
> + capacity-dmips-mhz = <741>;
> + };
> +
> + cpu2: cpu@2 {
> + device_type = "cpu";
> + compatible = "arm,cortex-a53";
> + reg = <0x002>;
> + enable-method = "psci";
> + capacity-dmips-mhz = <741>;
> + };
> +
> + cpu3: cpu@3 {
> + device_type = "cpu";
> + compatible = "arm,cortex-a53";
> + reg = <0x003>;
> + enable-method = "psci";
> + capacity-dmips-mhz = <741>;
> + };
> +
> + cpu4: cpu@100 {
> + device_type = "cpu";
> + compatible = "arm,cortex-a73";
> + reg = <0x100>;
> + enable-method = "psci";
> + capacity-dmips-mhz = <1024>;
> + };
> +
> + cpu5: cpu@101 {
> + device_type = "cpu";
> + compatible = "arm,cortex-a73";
> + reg = <0x101>;
> + enable-method = "psci"

Re: [PATCH v20 2/4] net: Add wget application

2022-11-08 Thread Ying-Chun Liu (PaulLiu)




On 2022/11/9 05:03, Sean Anderson wrote:

On 11/8/22 01:17, Ying-Chun Liu (PaulLiu) wrote:

From: "Ying-Chun Liu (PaulLiu)" 

This commit adds a simple wget command that can download files
from http server.

The command syntax is
wget ${loadaddr} 

Signed-off-by: Duncan Hare 
Signed-off-by: Ying-Chun Liu (PaulLiu) 
Reviewed-by: Simon Glass 
Cc: Christian Gmeiner 
Cc: Joe Hershberger 
Cc: Michal Simek 
Cc: Ramon Fried 
---
v1-v12: Made by Duncan, didn't tracked.
v13: Fix some issues which is reviewed by Christian
v14: Add options to enable/disable SACK.
v15: Fix various syntax errors reviewed by Michal.
  Remove magic numbers. Use kernel-doc format.
v16: Add more kernel-doc. Fix more double spaces.
v17: Fix wget with address timeout issue reported by Ramon.
v20: Rebase to latest master and resolve conflict.
---
  cmd/Kconfig|   7 +
  cmd/net.c  |  13 ++
  include/net.h  |   2 +-
  include/net/wget.h |  22 +++
  net/Makefile   |   1 +
  net/net.c  |   6 +
  net/wget.c | 438 +
  7 files changed, 488 insertions(+), 1 deletion(-)
  create mode 100644 include/net/wget.h
  create mode 100644 net/wget.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 105406496e..d093581b24 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1798,6 +1798,13 @@ config SYS_DISABLE_AUTOLOAD
  is complete.  Enable this option to disable this behavior and instead
  require files to be loaded over the network by subsequent commands.
  
+config CMD_WGET

+   bool "wget"
+   select TCP
+   help
+ wget is a simple command to download kernel, or other files,
+ from a http server over TCP.
+
  config CMD_MII
bool "mii"
imply CMD_MDIO
diff --git a/cmd/net.c b/cmd/net.c
index addcad3ac1..f6d9f5ea3a 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -125,6 +125,19 @@ U_BOOT_CMD(
  );
  #endif
  
+#if defined(CONFIG_CMD_WGET)

+static int do_wget(struct cmd_tbl *cmdtp, int flag, int argc, char * const 
argv[])
+{
+   return netboot_common(WGET, cmdtp, argc, argv);
+}
+
+U_BOOT_CMD(
+   wget,   3,  1,  do_wget,
+   "boot image via network using HTTP protocol",
+   "[loadAddress] [[hostIPaddr:]path and image name]"
+);
+#endif
+
  static void netboot_update_env(void)
  {
char tmp[22];
diff --git a/include/net.h b/include/net.h
index f4140523c2..e0c7804827 100644
--- a/include/net.h
+++ b/include/net.h
@@ -561,7 +561,7 @@ extern int  net_restart_wrap;   /* Tried all 
network devices */
  
  enum proto_t {

BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
-   TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI
+   TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI, WGET
  };
  
  extern char	net_boot_file_name[1024];/* Boot File name */

diff --git a/include/net/wget.h b/include/net/wget.h
new file mode 100644
index 00..da0920de11
--- /dev/null
+++ b/include/net/wget.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Duncan Hare Copyright 2017
+ */
+
+/**
+ * wget_start() - begin wget
+ */
+void wget_start(void);
+
+enum wget_state {
+   WGET_CLOSED,
+   WGET_CONNECTING,
+   WGET_CONNECTED,
+   WGET_TRANSFERRING,
+   WGET_TRANSFERRED
+};
+
+#define DEBUG_WGET 0   /* Set to 1 for debug messages */
+#define SERVER_PORT80
+#define WGET_RETRY_COUNT   30
+#define WGET_TIMEOUT   2000UL
diff --git a/net/Makefile b/net/Makefile
index d131d1cb1a..4f757a224c 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_UDP_FUNCTION_FASTBOOT)  += fastboot.o
  obj-$(CONFIG_CMD_WOL)  += wol.o
  obj-$(CONFIG_PROT_UDP) += udp.o
  obj-$(CONFIG_PROT_TCP) += tcp.o
+obj-$(CONFIG_CMD_WGET) += wget.o
  
  # Disable this warning as it is triggered by:

  # sprintf(buf, index ? "foo%d" : "foo", index)
diff --git a/net/net.c b/net/net.c
index 7878a9970b..8c630f9467 100644
--- a/net/net.c
+++ b/net/net.c
@@ -118,6 +118,7 @@
  #include "wol.h"
  #endif
  #include 
+#include 
  
  /** BOOTP EXTENTIONS **/
  
@@ -517,6 +518,11 @@ restart:

nfs_start();
break;
  #endif
+#if defined(CONFIG_CMD_WGET)
+   case WGET:
+   wget_start();
+   break;
+#endif
  #if defined(CONFIG_CMD_CDP)
case CDP:
cdp_start();
diff --git a/net/wget.c b/net/wget.c
new file mode 100644
index 00..3826c4b364
--- /dev/null
+++ b/net/wget.c
@@ -0,0 +1,438 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * WGET/HTTP support driver based on U-BOOT's nfs.c
+ * Copyright Duncan Hare  2017
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const char bootfile1[] = "GET ";
+static const char bootfile3[] = " HTTP/1.0\r\n\r\n";
+static const char http_eom[] = "\r\n\r\n";
+static const char http_ok[] = "200";
+

[PATCH v6 1/5] eficonfig: refactor eficonfig_select_file_handler()

2022-11-08 Thread Masahisa Kojima
eficonfig_select_file_handler() is commonly used to select the
file. eficonfig_display_select_file_option() intends to add the
additional menu mainly to clear the selected file information.
eficonfig_display_select_file_option() is not necessary for the
file selection process, so it should be outside of
eficonfig_select_file_handler().

Signed-off-by: Masahisa Kojima 
---
No change since v2

newly created in v2

 cmd/eficonfig.c| 13 +
 test/py/tests/test_eficonfig/test_eficonfig.py |  1 +
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index 2595dd9563..f6a99bd01a 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -968,7 +968,7 @@ efi_status_t eficonfig_process_clear_file_selection(void 
*data)
 }
 
 static struct eficonfig_item select_file_menu_items[] = {
-   {"Select File", eficonfig_process_select_file},
+   {"Select File", eficonfig_select_file_handler},
{"Clear", eficonfig_process_clear_file_selection},
{"Quit", eficonfig_process_quit},
 };
@@ -980,12 +980,13 @@ static struct eficonfig_item select_file_menu_items[] = {
  * @file_info: pointer to the file information structure
  * Return: status code
  */
-efi_status_t eficonfig_display_select_file_option(struct 
eficonfig_select_file_info *file_info)
+efi_status_t eficonfig_display_select_file_option(void *data)
 {
efi_status_t ret;
struct efimenu *efi_menu;
 
-   select_file_menu_items[1].data = file_info;
+   select_file_menu_items[0].data = data;
+   select_file_menu_items[1].data = data;
efi_menu = eficonfig_create_fixed_menu(select_file_menu_items,
   
ARRAY_SIZE(select_file_menu_items));
if (!efi_menu)
@@ -1016,10 +1017,6 @@ efi_status_t eficonfig_select_file_handler(void *data)
struct eficonfig_select_file_info *tmp = NULL;
struct eficonfig_select_file_info *file_info = data;
 
-   ret = eficonfig_display_select_file_option(file_info);
-   if (ret != EFI_SUCCESS)
-   return ret;
-
tmp = calloc(1, sizeof(struct eficonfig_select_file_info));
if (!tmp)
return EFI_OUT_OF_RESOURCES;
@@ -1284,7 +1281,7 @@ static efi_status_t prepare_file_selection_entry(struct 
efimenu *efi_menu, char
utf8_utf16_strcpy(&p, devname);
u16_strlcat(file_name, file_info->current_path, len);
ret = create_boot_option_entry(efi_menu, title, file_name,
-  eficonfig_select_file_handler, 
file_info);
+  eficonfig_display_select_file_option, 
file_info);
 out:
free(devname);
free(file_name);
diff --git a/test/py/tests/test_eficonfig/test_eficonfig.py 
b/test/py/tests/test_eficonfig/test_eficonfig.py
index 99606d9c4b..102bfd7541 100644
--- a/test/py/tests/test_eficonfig/test_eficonfig.py
+++ b/test/py/tests/test_eficonfig/test_eficonfig.py
@@ -349,6 +349,7 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
 press_up_down_enter_and_wait(0, 1, True, 'Quit')
 press_up_down_enter_and_wait(0, 0, True, 'No block device found!')
 press_escape_key(False)
+press_escape_key(False)
 check_current_is_maintenance_menu()
 # Return to U-Boot console
 press_escape_key(True)
-- 
2.17.1



[PATCH v6 0/5] eficonfig: add UEFI Secure Boot key maintenance interface

2022-11-08 Thread Masahisa Kojima
This series adds the UEFI Secure Boot key maintenance interface
to the eficonfig command.
User can enroll and delete the PK, KEK, db and dbx.

Source code can be cloned with:
$ git clone https://git.linaro.org/people/masahisa.kojima/u-boot.git -b 
kojima/eficonfig_sbkey_v6

Masahisa Kojima (5):
  eficonfig: refactor eficonfig_select_file_handler()
  eficonfig: expose append entry function
  eficonfig: refactor change boot order implementation
  eficonfig: add UEFI Secure Boot Key enrollment interface
  eficonfig: add "Show/Delete Signature Database" menu entry

 cmd/Makefile  |   5 +
 cmd/eficonfig.c   | 177 +++--
 cmd/eficonfig_sbkey.c | 727 ++
 include/efi_config.h  |  10 +
 .../py/tests/test_eficonfig/test_eficonfig.py |   1 +
 5 files changed, 835 insertions(+), 85 deletions(-)
 create mode 100644 cmd/eficonfig_sbkey.c

-- 
2.17.1



[PATCH v6 2/5] eficonfig: expose append entry function

2022-11-08 Thread Masahisa Kojima
This commit exposes the eficonfig menu entry append function.

Signed-off-by: Masahisa Kojima 
---
No change since v2

newly created in v2

 cmd/eficonfig.c  | 32 +---
 include/efi_config.h |  5 +
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index f6a99bd01a..0cb0770ac3 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -263,7 +263,7 @@ efi_status_t eficonfig_process_quit(void *data)
 }
 
 /**
- * append_entry() - append menu item
+ * eficonfig_append_menu_entry() - append menu item
  *
  * @efi_menu:  pointer to the efimenu structure
  * @title: pointer to the entry title
@@ -271,8 +271,9 @@ efi_status_t eficonfig_process_quit(void *data)
  * @data:  pointer to the data to be passed to each entry callback
  * Return: status code
  */
-static efi_status_t append_entry(struct efimenu *efi_menu,
-char *title, eficonfig_entry_func func, void 
*data)
+efi_status_t eficonfig_append_menu_entry(struct efimenu *efi_menu,
+char *title, eficonfig_entry_func func,
+void *data)
 {
struct eficonfig_entry *entry;
 
@@ -295,12 +296,12 @@ static efi_status_t append_entry(struct efimenu *efi_menu,
 }
 
 /**
- * append_quit_entry() - append quit entry
+ * eficonfig_append_quit_entry() - append quit entry
  *
  * @efi_menu:  pointer to the efimenu structure
  * Return: status code
  */
-static efi_status_t append_quit_entry(struct efimenu *efi_menu)
+efi_status_t eficonfig_append_quit_entry(struct efimenu *efi_menu)
 {
char *title;
efi_status_t ret;
@@ -309,7 +310,7 @@ static efi_status_t append_quit_entry(struct efimenu 
*efi_menu)
if (!title)
return EFI_OUT_OF_RESOURCES;
 
-   ret = append_entry(efi_menu, title, eficonfig_process_quit, NULL);
+   ret = eficonfig_append_menu_entry(efi_menu, title, 
eficonfig_process_quit, NULL);
if (ret != EFI_SUCCESS)
free(title);
 
@@ -341,7 +342,7 @@ void *eficonfig_create_fixed_menu(const struct 
eficonfig_item *items, int count)
if (!title)
goto out;
 
-   ret = append_entry(efi_menu, title, iter->func, iter->data);
+   ret = eficonfig_append_menu_entry(efi_menu, title, iter->func, 
iter->data);
if (ret != EFI_SUCCESS) {
free(title);
goto out;
@@ -634,14 +635,15 @@ static efi_status_t eficonfig_select_volume(struct 
eficonfig_select_file_info *f
info->v = v;
info->dp = device_path;
info->file_info = file_info;
-   ret = append_entry(efi_menu, devname, 
eficonfig_volume_selected, info);
+   ret = eficonfig_append_menu_entry(efi_menu, devname, 
eficonfig_volume_selected,
+ info);
if (ret != EFI_SUCCESS) {
free(info);
goto out;
}
}
 
-   ret = append_quit_entry(efi_menu);
+   ret = eficonfig_append_quit_entry(efi_menu);
if (ret != EFI_SUCCESS)
goto out;
 
@@ -745,8 +747,8 @@ eficonfig_create_file_entry(struct efimenu *efi_menu, u32 
count,
  (int (*)(const void *, const void *))sort_file);
 
for (i = 0; i < entry_num; i++) {
-   ret = append_entry(efi_menu, tmp_infos[i]->file_name,
-  eficonfig_file_selected, tmp_infos[i]);
+   ret = eficonfig_append_menu_entry(efi_menu, 
tmp_infos[i]->file_name,
+ eficonfig_file_selected, 
tmp_infos[i]);
if (ret != EFI_SUCCESS)
goto out;
}
@@ -815,7 +817,7 @@ static efi_status_t eficonfig_select_file(struct 
eficonfig_select_file_info *fil
if (ret != EFI_SUCCESS)
goto err;
 
-   ret = append_quit_entry(efi_menu);
+   ret = eficonfig_append_quit_entry(efi_menu);
if (ret != EFI_SUCCESS)
goto err;
 
@@ -1218,7 +1220,7 @@ static efi_status_t create_boot_option_entry(struct 
efimenu *efi_menu, char *tit
utf16_utf8_strcpy(&p, val);
}
 
-   return append_entry(efi_menu, buf, func, data);
+   return eficonfig_append_menu_entry(efi_menu, buf, func, data);
 }
 
 /**
@@ -1677,7 +1679,7 @@ static efi_status_t 
eficonfig_add_boot_selection_entry(struct efimenu *efi_menu,
utf16_utf8_strcpy(&p, lo.label);
info->boot_index = boot_index;
info->selected = selected;
-   ret = append_entry(efi_menu, buf, eficonfig_process_boot_selected, 
info);
+   ret = eficonfig_append_menu_entry(efi_menu, buf, 
eficonfig_process_boot_selected, info);
if (ret != EFI_SUCCESS) {
 

[PATCH v6 3/5] eficonfig: refactor change boot order implementation

2022-11-08 Thread Masahisa Kojima
This commit refactors change boot order implementation
to use 'eficonfig_entry' structure.

Signed-off-by: Masahisa Kojima 
---
No update since v5

Changes in v5:
- remove direct access mode

newly created in v4

 cmd/eficonfig.c | 129 +---
 1 file changed, 67 insertions(+), 62 deletions(-)

diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index 0cb0770ac3..c765b795d0 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -93,20 +93,14 @@ struct eficonfig_boot_selection_data {
 };
 
 /**
- * struct eficonfig_boot_order - structure to be used to update BootOrder 
variable
+ * struct eficonfig_boot_order_data - structure to be used to update BootOrder 
variable
  *
- * @num:   index in the menu entry
- * @description:   pointer to the description string
  * @boot_index:boot option index
  * @active:flag to include the boot option into BootOrder variable
- * @list:  list structure
  */
-struct eficonfig_boot_order {
-   u32 num;
-   u16 *description;
+struct eficonfig_boot_order_data {
u32 boot_index;
bool active;
-   struct list_head list;
 };
 
 /**
@@ -1814,7 +1808,7 @@ static void eficonfig_display_change_boot_order(struct 
efimenu *efi_menu)
 {
bool reverse;
struct list_head *pos, *n;
-   struct eficonfig_boot_order *entry;
+   struct eficonfig_entry *entry;
 
printf(ANSI_CLEAR_CONSOLE ANSI_CURSOR_POSITION
   "\n  ** Change Boot Order **\n"
@@ -1830,7 +1824,7 @@ static void eficonfig_display_change_boot_order(struct 
efimenu *efi_menu)
 
/* draw boot option list */
list_for_each_safe(pos, n, &efi_menu->list) {
-   entry = list_entry(pos, struct eficonfig_boot_order, list);
+   entry = list_entry(pos, struct eficonfig_entry, list);
reverse = (entry->num == efi_menu->active);
 
printf(ANSI_CURSOR_POSITION, entry->num + 4, 7);
@@ -1839,13 +1833,13 @@ static void eficonfig_display_change_boot_order(struct 
efimenu *efi_menu)
puts(ANSI_COLOR_REVERSE);
 
if (entry->num < efi_menu->count - 2) {
-   if (entry->active)
+   if (((struct eficonfig_boot_order_data 
*)entry->data)->active)
printf("[*]  ");
else
printf("[ ]  ");
}
 
-   printf("%ls", entry->description);
+   printf("%s", entry->title);
 
if (reverse)
puts(ANSI_COLOR_RESET);
@@ -1862,9 +1856,8 @@ static efi_status_t 
eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
 {
int esc = 0;
struct list_head *pos, *n;
-   struct eficonfig_boot_order *tmp;
enum bootmenu_key key = KEY_NONE;
-   struct eficonfig_boot_order *entry;
+   struct eficonfig_entry *entry, *tmp;
 
while (1) {
bootmenu_loop(NULL, &key, &esc);
@@ -1873,11 +1866,11 @@ static efi_status_t 
eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
case KEY_PLUS:
if (efi_menu->active > 0) {
list_for_each_safe(pos, n, &efi_menu->list) {
-   entry = list_entry(pos, struct 
eficonfig_boot_order, list);
+   entry = list_entry(pos, struct 
eficonfig_entry, list);
if (entry->num == efi_menu->active)
break;
}
-   tmp = list_entry(pos->prev, struct 
eficonfig_boot_order, list);
+   tmp = list_entry(pos->prev, struct 
eficonfig_entry, list);
entry->num--;
tmp->num++;
list_del(&tmp->list);
@@ -1891,11 +1884,11 @@ static efi_status_t 
eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
case KEY_MINUS:
if (efi_menu->active < efi_menu->count - 3) {
list_for_each_safe(pos, n, &efi_menu->list) {
-   entry = list_entry(pos, struct 
eficonfig_boot_order, list);
+   entry = list_entry(pos, struct 
eficonfig_entry, list);
if (entry->num == efi_menu->active)
break;
}
-   tmp = list_entry(pos->next, struct 
eficonfig_boot_order, list);
+   tmp = list_entry(pos->next, struct 
eficonfig_entry, list);
entry->num++;
tmp->num--;
list_del(&entry

[PATCH v6 4/5] eficonfig: add UEFI Secure Boot Key enrollment interface

2022-11-08 Thread Masahisa Kojima
This commit adds the menu-driven UEFI Secure Boot Key
enrollment interface. User can enroll the PK, KEK, db
and dbx by selecting EFI Signature Lists file.
After the PK is enrolled, UEFI Secure Boot is enabled and
EFI Signature Lists file must be signed by KEK or PK.

Signed-off-by: Masahisa Kojima 
---
Changes in v6:
- use efi_secure_boot_enabled()
- replace with WIN_CERT_REVISION_2_0 from pe.h
- call efi_build_signature_store() to check the valid EFI Signature List
- update comment

Changes in v4:
- add CONFIG_EFI_MM_COMM_TEE dependency
- fix error handling

Changes in v3:
- fix error handling

Changes in v2:
- allow to enroll .esl file
- fix typos
- add function comments

 cmd/Makefile  |   5 +
 cmd/eficonfig.c   |   3 +
 cmd/eficonfig_sbkey.c | 333 ++
 include/efi_config.h  |   5 +
 4 files changed, 346 insertions(+)
 create mode 100644 cmd/eficonfig_sbkey.c

diff --git a/cmd/Makefile b/cmd/Makefile
index c95e09d058..e43ef22e98 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -66,6 +66,11 @@ obj-$(CONFIG_CMD_EEPROM) += eeprom.o
 obj-$(CONFIG_EFI) += efi.o
 obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o
 obj-$(CONFIG_CMD_EFICONFIG) += eficonfig.o
+ifdef CONFIG_CMD_EFICONFIG
+ifdef CONFIG_EFI_MM_COMM_TEE
+obj-$(CONFIG_EFI_SECURE_BOOT) += eficonfig_sbkey.o
+endif
+endif
 obj-$(CONFIG_CMD_ELF) += elf.o
 obj-$(CONFIG_CMD_EROFS) += erofs.o
 obj-$(CONFIG_HUSH_PARSER) += exit.o
diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index c765b795d0..0b643a046c 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -2447,6 +2447,9 @@ static const struct eficonfig_item 
maintenance_menu_items[] = {
{"Edit Boot Option", eficonfig_process_edit_boot_option},
{"Change Boot Order", eficonfig_process_change_boot_order},
{"Delete Boot Option", eficonfig_process_delete_boot_option},
+#if (CONFIG_IS_ENABLED(EFI_SECURE_BOOT) && CONFIG_IS_ENABLED(EFI_MM_COMM_TEE))
+   {"Secure Boot Configuration", eficonfig_process_secure_boot_config},
+#endif
{"Quit", eficonfig_process_quit},
 };
 
diff --git a/cmd/eficonfig_sbkey.c b/cmd/eficonfig_sbkey.c
new file mode 100644
index 00..e4a3573f1b
--- /dev/null
+++ b/cmd/eficonfig_sbkey.c
@@ -0,0 +1,333 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  Menu-driven UEFI Secure Boot Key Maintenance
+ *
+ *  Copyright (c) 2022 Masahisa Kojima, Linaro Limited
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+enum efi_sbkey_signature_type {
+   SIG_TYPE_X509 = 0,
+   SIG_TYPE_HASH,
+   SIG_TYPE_CRL,
+   SIG_TYPE_RSA2048,
+};
+
+struct eficonfig_sigtype_to_str {
+   efi_guid_t sig_type;
+   char *str;
+   enum efi_sbkey_signature_type type;
+};
+
+static const struct eficonfig_sigtype_to_str sigtype_to_str[] = {
+   {EFI_CERT_X509_GUID,"X509", SIG_TYPE_X509},
+   {EFI_CERT_SHA256_GUID,  "SHA256",   SIG_TYPE_HASH},
+   {EFI_CERT_X509_SHA256_GUID, "X509_SHA256 CRL",  SIG_TYPE_CRL},
+   {EFI_CERT_X509_SHA384_GUID, "X509_SHA384 CRL",  SIG_TYPE_CRL},
+   {EFI_CERT_X509_SHA512_GUID, "X509_SHA512 CRL",  SIG_TYPE_CRL},
+   /* U-Boot does not support the following signature types */
+/* {EFI_CERT_RSA2048_GUID, "RSA2048",  
SIG_TYPE_RSA2048}, */
+/* {EFI_CERT_RSA2048_SHA256_GUID,  "RSA2048_SHA256",   
SIG_TYPE_RSA2048}, */
+/* {EFI_CERT_SHA1_GUID,"SHA1", SIG_TYPE_HASH}, 
*/
+/* {EFI_CERT_RSA2048_SHA_GUID, "RSA2048_SHA",  
SIG_TYPE_RSA2048 }, */
+/* {EFI_CERT_SHA224_GUID,  "SHA224",   SIG_TYPE_HASH}, 
*/
+/* {EFI_CERT_SHA384_GUID,  "SHA384",   SIG_TYPE_HASH}, 
*/
+/* {EFI_CERT_SHA512_GUID,  "SHA512",   SIG_TYPE_HASH}, 
*/
+};
+
+/**
+ * create_time_based_payload() - create payload for time based authenticate 
variable
+ *
+ * @db:pointer to the original signature database
+ * @new_db:pointer to the authenticated variable payload
+ * @size:  pointer to payload size
+ * Return: status code
+ */
+static efi_status_t create_time_based_payload(void *db, void **new_db, 
efi_uintn_t *size)
+{
+   efi_status_t ret;
+   struct efi_time time;
+   efi_uintn_t total_size;
+   struct efi_variable_authentication_2 *auth;
+
+   *new_db = NULL;
+
+   /*
+* SetVariable() call with 
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
+* attribute requires EFI_VARIABLE_AUTHENTICATED_2 descriptor, prepare 
it
+* without certificate data in it.
+*/
+   total_size = sizeof(struct efi_variable_authentication_2) + *size;
+
+   auth = calloc(1, total_size);
+   if (!auth)
+   return EFI_OUT_OF_RESOURCES;
+
+   ret = EFI_CALL((*efi_runtime_services.get_time)(&time, NULL));
+   if (ret != EF

  1   2   >