Re: dm driver probe and dm question

2022-02-25 Thread Heinrich Schuchardt

On 2/26/22 02:51, Tim Harvey wrote:

Greetings,

I've got an octeontx board which uses driver model
(CONFIG_DM/CONFIG_DM_I2C) but I find that the 'i2c_octeon' driver does
not probe automatically on boot until I do something like an 'i2c dev
0 && i2c probe'.

What would cause the i2c_octeon driver to not automatically probe?


It is the general design of U-Boot's driver model to use late probing.
This reduces the boot time.

Cf.
https://u-boot.readthedocs.io/en/latest/develop/driver-model/design.html#driver-lifecycle

Best regards

Heinrich



Here is a dm tree of the board:
Marvell> dm tree
  Class Index  Probed  DriverName
---
  root  0  [ + ]   root_driver   root_driver
  rsa_mod_ex0  [   ]   mod_exp_sw|-- mod_exp_sw
  firmware  0  [   ]   psci  |-- psci
  regulator 0  [ + ]   regulator_fixed   |-- mmc_supply_3v3
  simple_bus0  [ + ]   simple_bus`-- soc@0
  clk   0  [ + ]   fixed_clock   |-- refclkuaa
  clk   1  [ + ]   fixed_clock   |-- sclk
  clk   2  [   ]   fixed_clock   |-- can20m
  serial0  [ + ]   serial_pl01x  |-- serial@87e02800
  serial1  [   ]   serial_pl01x  |-- serial@87e02900
  serial2  [   ]   serial_pl01x  |-- serial@87e02a00
  serial3  [   ]   serial_pl01x  |-- serial@87e02b00
  watchdog  0  [ + ]   sbsa_gwdt |-- watch-dog@844a
  pci   0  [ + ]   pci_octeontx  `-- pci@8480
  pci   1  [ + ]   pci_bridge_drv|-- mrml-bridge0@1,0
  misc  0  [ + ]   octeontx_smi  |   |-- mdio-nexus@1,3
  misc  1  [ + ]   octeontx_hsmmc_host   |   |-- mmc@1,4
  mmc   0  [ + ]   octeontx_hsmmc_slot   |   |   `--
octeontx-mmc0
  blk   0  [ + ]   mmc_blk   |   |
`-- octeontx-mmc0.blk
  i2c   0  [   ]   i2c_octeon|   |-- i2c@9,0
  misc  2  [   ]   gsc   |   |   `-- gsc@20
  i2c   1  [   ]   i2c_octeon|   |-- i2c@9,1
  pci_generi5  [   ]   pci_generic_drv   |   |-- pci_1:0.0
  pci_generi6  [   ]   pci_generic_drv   |   |-- pci_1:0.1
  pci_generi7  [   ]   pci_generic_drv   |   |-- pci_1:1.7
  pci_generi8  [   ]   pci_generic_drv   |   |-- pci_1:2.0
  pci_generi9  [   ]   pci_generic_drv   |   |-- pci_1:6.0
  pci_generi   10  [   ]   pci_generic_drv   |   |-- pci_1:7.0
  pci_generi   11  [   ]   pci_generic_drv   |   |-- pci_1:7.4
  pci_generi   12  [   ]   pci_generic_drv   |   |-- pci_1:a.0
  pci_generi   13  [   ]   pci_generic_drv   |   |-- pci_1:c.0
  pci_generi   14  [   ]   pci_generic_drv   |   |-- pci_1:c.1
  pci_generi   15  [   ]   pci_generic_drv   |   |-- pci_1:d.0
  misc  3  [ + ]   octeontx_bgx  |   |-- octeontx_bgx
  misc  4  [ + ]   octeontx_bgx  |   `-- octeontx_bgx
  gpio  0  [ + ]   octeon_gpio   |-- gpio0@6,0
  pci_generi0  [   ]   pci_generic_drv   |-- pci_0:7.0
  pci_generi1  [   ]   pci_generic_drv   |-- pci_0:8.0
  pci   2  [ + ]   pci_bridge_drv|-- pci_0:9.0
  pci_generi   16  [   ]   pci_generic_drv   |   `-- pci_2:0.0
  pci   3  [ + ]   pci_bridge_drv|-- pci_0:a.0
  pci_generi   17  [   ]   pci_generic_drv   |   `-- pci_3:0.0
  pci_generi2  [   ]   pci_generic_drv   |-- pci_0:b.0
  pci   4  [ + ]   pci_bridge_drv|-- pci_0:c.0
  pci_generi   18  [   ]   pci_generic_drv   |   `-- pci_4:0.0
  pci_generi3  [   ]   pci_generic_drv   |-- pci_0:d.0
  pci_generi4  [   ]   pci_generic_drv   |-- pci_0:e.0
  pci   5  [ + ]   pci_bridge_drv|-- pci_0:f.0
  misc  5  [ + ]   octeontx_nic  |   |-- octeontx_nic
  ethernet  0  [ + ]   vnic  |   |-- vnic0
  ethernet  1  [ + ]   vnic  |   `-- vnic1
  usb   0  [   ]   xhci_pci  |-- xhci_pci
  usb   1  [   ]   xhci_pci  `-- xhci_pci

Best regards,

Tim




Pull request for efi-2022-04-rc3

2022-02-25 Thread Heinrich Schuchardt

Dear Tom,

The following changes since commit c6ae38b38967a5c33d729c20e508a03ba3e0e3f6:

  Merge tag 'clk-2022.04-rc2' of 
https://source.denx.de/u-boot/custodians/u-boot-clk (2022-02-25 11:21:32 
-0500)


are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-efi.git 
tags/efi-2022-04-rc3


for you to fetch changes up to 3fa9ed9ae3b30dd6e7f5e887c76d183ad72a44a2:

  efi_loader: update the timing of enabling and disabling EFI watchdog 
(2022-02-26 07:37:01 +0100)


Gitlab CI showed no problems:
https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/11093


Pull request for efi-2022-04-rc3

Documentation:

* add man-page for fatload
* add SMBIOS table page

UEFI:

* partial fix for UEFI secure boot with intermediate certs
* disable watchdog when returning to command line
* reset system after capsule update


AKASHI Takahiro (1):
  tools: mkeficapsule: remove duplicated code

Heinrich Schuchardt (2):
  doc: describe generation of SMBIOS table
  doc: describe fatload command

Ilias Apalodimas (1):
  efi_loader: fix uefi secure boot with intermediate certs

Masahisa Kojima (1):
  efi_loader: update the timing of enabling and disabling EFI watchdog

Masami Hiramatsu (4):
  efi_loader: use efi_update_capsule_firmware() for capsule on disk
  test/py: Handle expected reset by command
  test/py: Handle expected reboot while booting sandbox
  efi_loader: test/py: Reset system after capsule update on disk

 cmd/bootefi.c  |  17 +++
 doc/arch/x86.rst   |   2 +-
 doc/develop/index.rst  |   1 +
 doc/develop/smbios.rst |  22 
 doc/usage/fatload.rst  |  80 ++
 doc/usage/index.rst|   1 +
 lib/efi_loader/efi_capsule.c   |  20 +++-
 lib/efi_loader/efi_signature.c |  11 +-
 lib/efi_loader/efi_watchdog.c  |  13 +--
 .../test_efi_capsule/test_capsule_firmware.py  |  37 ---
 test/py/u_boot_console_base.py | 115 
+

 test/py/u_boot_console_sandbox.py  |   7 +-
 tools/mkeficapsule.c   |   2 -
 13 files changed, 243 insertions(+), 85 deletions(-)
 create mode 100644 doc/develop/smbios.rst
 create mode 100644 doc/usage/fatload.rst


[PATCH v4 3/5] fs/erofs: add lz4 decompression support

2022-02-25 Thread Huang Jianan
Support EROFS lz4 compressed files.

Signed-off-by: Huang Jianan 
---
 fs/erofs/Kconfig  |   9 +
 fs/erofs/Makefile |   4 +-
 fs/erofs/data.c   |  90 ++-
 fs/erofs/decompress.c |  78 ++
 fs/erofs/decompress.h |  24 ++
 fs/erofs/namei.c  |   2 +-
 fs/erofs/zmap.c   | 601 ++
 7 files changed, 805 insertions(+), 3 deletions(-)
 create mode 100644 fs/erofs/decompress.c
 create mode 100644 fs/erofs/decompress.h
 create mode 100644 fs/erofs/zmap.c

diff --git a/fs/erofs/Kconfig b/fs/erofs/Kconfig
index f4b2d51a23..ee4e777c5c 100644
--- a/fs/erofs/Kconfig
+++ b/fs/erofs/Kconfig
@@ -10,3 +10,12 @@ config FS_EROFS
  improves storage density, keeps relatively higher compression
  ratios, which is more useful to achieve high performance for
  embedded devices with limited memory.
+
+config FS_EROFS_ZIP
+   bool "EROFS Data Compression Support"
+   depends on FS_EROFS
+   select LZ4
+   default y
+   help
+ Enable fixed-sized output compression for EROFS.
+ If you don't want to enable compression feature, say N.
diff --git a/fs/erofs/Makefile b/fs/erofs/Makefile
index 7398ab7a36..58af6a68e4 100644
--- a/fs/erofs/Makefile
+++ b/fs/erofs/Makefile
@@ -4,4 +4,6 @@
 obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \
super.o \
namei.o \
-   data.o
+   data.o \
+   decompress.o \
+   zmap.o
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 699975c1be..761896054c 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 #include "internal.h"
+#include "decompress.h"
 
 static int erofs_map_blocks_flatmode(struct erofs_inode *inode,
 struct erofs_map_blocks *map,
@@ -205,6 +206,93 @@ static int erofs_read_raw_data(struct erofs_inode *inode, 
char *buffer,
return 0;
 }
 
+static int z_erofs_read_data(struct erofs_inode *inode, char *buffer,
+erofs_off_t size, erofs_off_t offset)
+{
+   erofs_off_t end, length, skip;
+   struct erofs_map_blocks map = {
+   .index = UINT_MAX,
+   };
+   struct erofs_map_dev mdev;
+   bool partial;
+   unsigned int bufsize = 0;
+   char *raw = NULL;
+   int ret = 0;
+
+   end = offset + size;
+   while (end > offset) {
+   map.m_la = end - 1;
+
+   ret = z_erofs_map_blocks_iter(inode, , 0);
+   if (ret)
+   break;
+
+   /* no device id here, thus it will always succeed */
+   mdev = (struct erofs_map_dev) {
+   .m_pa = map.m_pa,
+   };
+   ret = erofs_map_dev(, );
+   if (ret) {
+   DBG_BUGON(1);
+   break;
+   }
+
+   /*
+* trim to the needed size if the returned extent is quite
+* larger than requested, and set up partial flag as well.
+*/
+   if (end < map.m_la + map.m_llen) {
+   length = end - map.m_la;
+   partial = true;
+   } else {
+   DBG_BUGON(end != map.m_la + map.m_llen);
+   length = map.m_llen;
+   partial = !(map.m_flags & EROFS_MAP_FULL_MAPPED);
+   }
+
+   if (map.m_la < offset) {
+   skip = offset - map.m_la;
+   end = offset;
+   } else {
+   skip = 0;
+   end = map.m_la;
+   }
+
+   if (!(map.m_flags & EROFS_MAP_MAPPED)) {
+   memset(buffer + end - offset, 0, length);
+   end = map.m_la;
+   continue;
+   }
+
+   if (map.m_plen > bufsize) {
+   bufsize = map.m_plen;
+   raw = realloc(raw, bufsize);
+   if (!raw) {
+   ret = -ENOMEM;
+   break;
+   }
+   }
+   ret = erofs_dev_read(mdev.m_deviceid, raw, mdev.m_pa, 
map.m_plen);
+   if (ret < 0)
+   break;
+
+   ret = z_erofs_decompress(&(struct z_erofs_decompress_req) {
+   .in = raw,
+   .out = buffer + end - offset,
+   .decodedskip = skip,
+   .inputsize = map.m_plen,
+   .decodedlength = length,
+   .alg = map.m_algorithmformat,
+   

[PATCH v4 5/5] test/py: Add tests for the erofs

2022-02-25 Thread Huang Jianan
Add Python scripts to test 'ls' and 'load' commands, as well as
test related filesystem functions.

Signed-off-by: Huang Jianan 
---
 MAINTAINERS |   1 +
 configs/sandbox_defconfig   |   1 +
 test/py/tests/test_fs/test_erofs.py | 211 
 tools/docker/Dockerfile |   1 +
 4 files changed, 214 insertions(+)
 create mode 100644 test/py/tests/test_fs/test_erofs.py

diff --git a/MAINTAINERS b/MAINTAINERS
index bd8835619e..e1c6b986f0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -815,6 +815,7 @@ S:  Maintained
 F: cmd/erofs.c
 F: fs/erofs/
 F: include/erofs.h
+F: test/py/tests/test_fs/test_erofs.py
 
 FASTBOOT
 S: Orphaned
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 7ebeb89264..47fd33e8bc 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -105,6 +105,7 @@ CONFIG_CMD_TPM_TEST=y
 CONFIG_CMD_BTRFS=y
 CONFIG_CMD_CBFS=y
 CONFIG_CMD_CRAMFS=y
+CONFIG_CMD_EROFS=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_MTDPARTS=y
diff --git a/test/py/tests/test_fs/test_erofs.py 
b/test/py/tests/test_fs/test_erofs.py
new file mode 100644
index 00..458a52ba79
--- /dev/null
+++ b/test/py/tests/test_fs/test_erofs.py
@@ -0,0 +1,211 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Huang Jianan 
+# Author: Huang Jianan 
+
+import os
+import pytest
+import shutil
+import subprocess
+
+EROFS_SRC_DIR = 'erofs_src_dir'
+EROFS_IMAGE_NAME = 'erofs.img'
+
+def generate_file(name, size):
+"""
+Generates a file filled with 'x'.
+"""
+content = 'x' * size
+file = open(name, 'w')
+file.write(content)
+file.close()
+
+def make_erofs_image(build_dir):
+"""
+Makes the EROFS images used for the test.
+
+The image is generated at build_dir with the following structure:
+erofs_src_dir/
+├── f4096
+├── f7812
+├── subdir/
+│   └── subdir-file
+├── symdir -> subdir
+└── symfile -> f5096
+"""
+root = os.path.join(build_dir, EROFS_SRC_DIR)
+os.makedirs(root)
+
+# 4096: uncompressed file
+generate_file(os.path.join(root, 'f4096'), 4096)
+
+# 7812: Compressed file
+generate_file(os.path.join(root, 'f7812'), 7812)
+
+# sub-directory with a single file inside
+subdir_path = os.path.join(root, 'subdir')
+os.makedirs(subdir_path)
+generate_file(os.path.join(subdir_path, 'subdir-file'), 100)
+
+# symlink
+os.symlink('subdir', os.path.join(root, 'symdir'))
+os.symlink('f7812', os.path.join(root, 'symfile'))
+
+input_path = os.path.join(build_dir, EROFS_SRC_DIR)
+output_path = os.path.join(build_dir, EROFS_IMAGE_NAME)
+args = ' '.join([output_path, input_path])
+subprocess.run(['mkfs.erofs -zlz4 ' + args], shell=True, check=True,
+   stdout=subprocess.DEVNULL)
+
+def clean_erofs_image(build_dir):
+"""
+Deletes the image and src_dir at build_dir.
+"""
+path = os.path.join(build_dir, EROFS_SRC_DIR)
+shutil.rmtree(path)
+image_path = os.path.join(build_dir, EROFS_IMAGE_NAME)
+os.remove(image_path)
+
+def erofs_ls_at_root(u_boot_console):
+"""
+Test if all the present files and directories were listed.
+"""
+no_slash = u_boot_console.run_command('erofsls host 0')
+slash = u_boot_console.run_command('erofsls host 0 /')
+assert no_slash == slash
+
+expected_lines = ['./', '../', '4096   f4096', '7812   f7812', 'subdir/',
+  '   symdir', '   symfile', '4 file(s), 3 
dir(s)']
+
+output = u_boot_console.run_command('erofsls host 0')
+for line in expected_lines:
+assert line in output
+
+def erofs_ls_at_subdir(u_boot_console):
+"""
+Test if the path resolution works.
+"""
+expected_lines = ['./', '../', '100   subdir-file', '1 file(s), 2 dir(s)']
+output = u_boot_console.run_command('erofsls host 0 subdir')
+for line in expected_lines:
+assert line in output
+
+def erofs_ls_at_symlink(u_boot_console):
+"""
+Test if the symbolic link's target resolution works.
+"""
+output = u_boot_console.run_command('erofsls host 0 symdir')
+output_subdir = u_boot_console.run_command('erofsls host 0 subdir')
+assert output == output_subdir
+
+expected_lines = ['./', '../', '100   subdir-file', '1 file(s), 2 dir(s)']
+for line in expected_lines:
+assert line in output
+
+def erofs_ls_at_non_existent_dir(u_boot_console):
+"""
+Test if the EROFS support will crash when get a nonexistent directory.
+"""
+out_non_existent = u_boot_console.run_command('erofsls host 0 fff')
+out_not_dir = u_boot_console.run_command('erofsls host 0 f1000')
+assert out_non_existent == out_not_dir
+assert '' in out_non_existent
+
+def erofs_load_files(u_boot_console, files, sizes, address):
+"""
+Loads files and asserts their checksums.
+"""
+build_dir = u_boot_console.config.build_dir
+   

[PATCH v4 4/5] fs/erofs: add filesystem commands

2022-02-25 Thread Huang Jianan
Add 'ls' and 'load' commands.

Signed-off-by: Huang Jianan 
---
 MAINTAINERS  |  1 +
 cmd/Kconfig  |  6 ++
 cmd/Makefile |  1 +
 cmd/erofs.c  | 42 ++
 4 files changed, 50 insertions(+)
 create mode 100644 cmd/erofs.c

diff --git a/MAINTAINERS b/MAINTAINERS
index dd2ce8143c..bd8835619e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -812,6 +812,7 @@ EROFS
 M: Huang Jianan 
 L: linux-er...@lists.ozlabs.org
 S: Maintained
+F: cmd/erofs.c
 F: fs/erofs/
 F: include/erofs.h
 
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 5e25e45fd2..50b8f33434 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2176,6 +2176,12 @@ config CMD_CRAMFS
 cramfsls   - lists files in a cramfs image
 cramfsload - loads a file from a cramfs image
 
+config CMD_EROFS
+   bool "EROFS command support"
+   select FS_EROFS
+   help
+ Support for the EROFS fs
+
 config CMD_EXT2
bool "ext2 command support"
select FS_EXT4
diff --git a/cmd/Makefile b/cmd/Makefile
index 166c652d98..d668b3c62d 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -60,6 +60,7 @@ obj-$(CONFIG_CMD_EEPROM) += eeprom.o
 obj-$(CONFIG_EFI) += efi.o
 obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o
 obj-$(CONFIG_CMD_ELF) += elf.o
+obj-$(CONFIG_CMD_EROFS) += erofs.o
 obj-$(CONFIG_HUSH_PARSER) += exit.o
 obj-$(CONFIG_CMD_EXT4) += ext4.o
 obj-$(CONFIG_CMD_EXT2) += ext2.o
diff --git a/cmd/erofs.c b/cmd/erofs.c
new file mode 100644
index 00..add80b8b59
--- /dev/null
+++ b/cmd/erofs.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 Huang Jianan 
+ *
+ * Author: Huang Jianan 
+ *
+ * erofs.c:implements EROFS related commands
+ */
+
+#include 
+#include 
+#include 
+
+static int do_erofs_ls(struct cmd_tbl *cmdtp, int flag, int argc, char * const 
argv[])
+{
+   return do_ls(cmdtp, flag, argc, argv, FS_TYPE_EROFS);
+}
+
+U_BOOT_CMD(erofsls, 4, 1, do_erofs_ls,
+  "List files in directory. Default: root (/).",
+  " [] [directory]\n"
+  "- list files from 'dev' on 'interface' in 'directory'\n"
+);
+
+static int do_erofs_load(struct cmd_tbl *cmdtp, int flag, int argc, char * 
const argv[])
+{
+   return do_load(cmdtp, flag, argc, argv, FS_TYPE_EROFS);
+}
+
+U_BOOT_CMD(erofsload, 7, 0, do_erofs_load,
+  "load binary file from a EROFS filesystem",
+  " [ [ [ [bytes [pos]\n"
+  "- Load binary file 'filename' from 'dev' on 'interface'\n"
+  "  to address 'addr' from EROFS filesystem.\n"
+  "  'pos' gives the file position to start loading from.\n"
+  "  If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
+  "  'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
+  "  the load stops on end of file.\n"
+  "  If either 'pos' or 'bytes' are not aligned to\n"
+  "  ARCH_DMA_MINALIGN then a misaligned buffer warning will\n"
+  "  be printed and performance will suffer for the load."
+);
-- 
2.25.1



[PATCH v4 1/5] fs/erofs: add erofs filesystem support

2022-02-25 Thread Huang Jianan
This patch mainly deals with uncompressed files.

Signed-off-by: Huang Jianan 
---
 MAINTAINERS |   7 +
 fs/Kconfig  |   2 +
 fs/Makefile |   1 +
 fs/erofs/Kconfig|  12 ++
 fs/erofs/Makefile   |   7 +
 fs/erofs/data.c | 223 ++
 fs/erofs/erofs_fs.h | 436 
 fs/erofs/fs.c   | 267 +++
 fs/erofs/internal.h | 313 +++
 fs/erofs/namei.c| 252 +
 fs/erofs/super.c| 105 +++
 fs/fs.c |  22 +++
 include/erofs.h |  19 ++
 include/fs.h|   1 +
 14 files changed, 1667 insertions(+)
 create mode 100644 fs/erofs/Kconfig
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 include/erofs.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 1c98029754..dd2ce8143c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -808,6 +808,13 @@ S: Maintained
 F: doc/usage/environment.rst
 F: scripts/env2string.awk
 
+EROFS
+M: Huang Jianan 
+L: linux-er...@lists.ozlabs.org
+S: Maintained
+F: fs/erofs/
+F: include/erofs.h
+
 FASTBOOT
 S: Orphaned
 F: cmd/fastboot.c
diff --git a/fs/Kconfig b/fs/Kconfig
index 620af7f044..cda9f66cc9 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -24,4 +24,6 @@ source "fs/yaffs2/Kconfig"
 
 source "fs/squashfs/Kconfig"
 
+source "fs/erofs/Kconfig"
+
 endmenu
diff --git a/fs/Makefile b/fs/Makefile
index 937cbcf6e8..f05a21c9e6 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -25,5 +25,6 @@ obj-$(CONFIG_CMD_UBIFS) += ubifs/
 obj-$(CONFIG_YAFFS2) += yaffs2/
 obj-$(CONFIG_CMD_ZFS) += zfs/
 obj-$(CONFIG_FS_SQUASHFS) += squashfs/
+obj-$(CONFIG_FS_EROFS) += erofs/
 endif
 obj-y += fs_internal.o
diff --git a/fs/erofs/Kconfig b/fs/erofs/Kconfig
new file mode 100644
index 00..f4b2d51a23
--- /dev/null
+++ b/fs/erofs/Kconfig
@@ -0,0 +1,12 @@
+config FS_EROFS
+   bool "Enable EROFS filesystem support"
+   help
+ This provides support for reading images from EROFS filesystem.
+ EROFS (Enhanced Read-Only File System) is a lightweight read-only
+ file system for scenarios which need high-performance read-only
+ requirements.
+
+ It also provides fixed-sized output compression support, which
+ improves storage density, keeps relatively higher compression
+ ratios, which is more useful to achieve high performance for
+ embedded devices with limited memory.
diff --git a/fs/erofs/Makefile b/fs/erofs/Makefile
new file mode 100644
index 00..7398ab7a36
--- /dev/null
+++ b/fs/erofs/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \
+   super.o \
+   namei.o \
+   data.o
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
new file mode 100644
index 00..699975c1be
--- /dev/null
+++ b/fs/erofs/data.c
@@ -0,0 +1,223 @@
+// SPDX-License-Identifier: GPL-2.0+
+#include "internal.h"
+
+static int erofs_map_blocks_flatmode(struct erofs_inode *inode,
+struct erofs_map_blocks *map,
+int flags)
+{
+   int err = 0;
+   erofs_blk_t nblocks, lastblk;
+   u64 offset = map->m_la;
+   struct erofs_inode *vi = inode;
+   bool tailendpacking = (vi->datalayout == EROFS_INODE_FLAT_INLINE);
+
+   nblocks = DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ);
+   lastblk = nblocks - tailendpacking;
+
+   /* there is no hole in flatmode */
+   map->m_flags = EROFS_MAP_MAPPED;
+
+   if (offset < blknr_to_addr(lastblk)) {
+   map->m_pa = blknr_to_addr(vi->u.i_blkaddr) + map->m_la;
+   map->m_plen = blknr_to_addr(lastblk) - offset;
+   } else if (tailendpacking) {
+   /* 2 - inode inline B: inode, [xattrs], inline last blk... */
+   map->m_pa = iloc(vi->nid) + vi->inode_isize +
+   vi->xattr_isize + erofs_blkoff(map->m_la);
+   map->m_plen = inode->i_size - offset;
+
+   /* inline data should be located in one meta block */
+   if (erofs_blkoff(map->m_pa) + map->m_plen > PAGE_SIZE) {
+   erofs_err("inline data cross block boundary @ nid %" 
PRIu64,
+ vi->nid);
+   DBG_BUGON(1);
+   err = -EFSCORRUPTED;
+   goto err_out;
+   }
+
+   map->m_flags |= EROFS_MAP_META;
+   } else {
+   erofs_err("internal error @ nid: %" PRIu64 " (size %llu), m_la 
0x%" PRIx64,
+ vi->nid, (unsigned long long)inode->i_size, 

[PATCH v4 2/5] lib/lz4: update LZ4 decompressor module

2022-02-25 Thread Huang Jianan
Update the LZ4 compression module based on LZ4 v1.8.3 in order to
use the newest LZ4_decompress_safe_partial() which can now decode
exactly the nb of bytes requested.

Signed-off-by: Huang Jianan 
---
 include/u-boot/lz4.h |  49 
 lib/lz4.c| 679 +++
 lib/lz4_wrapper.c|  23 +-
 3 files changed, 536 insertions(+), 215 deletions(-)

diff --git a/include/u-boot/lz4.h b/include/u-boot/lz4.h
index e18b39a5dc..655adbfcd1 100644
--- a/include/u-boot/lz4.h
+++ b/include/u-boot/lz4.h
@@ -21,4 +21,53 @@
  */
 int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
 
+/**
+ * LZ4_decompress_safe() - Decompression protected against buffer overflow
+ * @source: source address of the compressed data
+ * @dest: output buffer address of the uncompressed data
+ * which must be already allocated
+ * @compressedSize: is the precise full size of the compressed block
+ * @maxDecompressedSize: is the size of 'dest' buffer
+ *
+ * Decompresses data from 'source' into 'dest'.
+ * If the source stream is detected malformed, the function will
+ * stop decoding and return a negative result.
+ * This function is protected against buffer overflow exploits,
+ * including malicious data packets. It never writes outside output buffer,
+ * nor reads outside input buffer.
+ *
+ * Return: number of bytes decompressed into destination buffer
+ * (necessarily <= maxDecompressedSize)
+ * or a negative result in case of error
+ */
+int LZ4_decompress_safe(const char *source, char *dest,
+   int compressedSize, int maxDecompressedSize);
+
+/**
+ * LZ4_decompress_safe_partial() - Decompress a block of size 'compressedSize'
+ * at position 'source' into buffer 'dest'
+ * @source: source address of the compressed data
+ * @dest: output buffer address of the decompressed data which must be
+ * already allocated
+ * @compressedSize: is the precise full size of the compressed block.
+ * @targetOutputSize: the decompression operation will try
+ * to stop as soon as 'targetOutputSize' has been reached
+ * @maxDecompressedSize: is the size of destination buffer
+ *
+ * This function decompresses a compressed block of size 'compressedSize'
+ * at position 'source' into destination buffer 'dest'
+ * of size 'maxDecompressedSize'.
+ * The function tries to stop decompressing operation as soon as
+ * 'targetOutputSize' has been reached, reducing decompression time.
+ * This function never writes outside of output buffer,
+ * and never reads outside of input buffer.
+ * It is therefore protected against malicious data packets.
+ *
+ * Return: the number of bytes decoded in the destination buffer
+ * (necessarily <= maxDecompressedSize)
+ * or a negative result in case of error
+ *
+ */
+int LZ4_decompress_safe_partial(const char *src, char *dst,
+   int compressedSize, int targetOutputSize, int dstCapacity);
 #endif
diff --git a/lib/lz4.c b/lib/lz4.c
index 046c34e390..5337842126 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1,13 +1,63 @@
-// SPDX-License-Identifier: BSD-2-Clause
+// SPDX-License-Identifier: GPL 2.0+ OR BSD-2-Clause
 /*
-   LZ4 - Fast LZ compression algorithm
-   Copyright (C) 2011-2015, Yann Collet.
+ * LZ4 - Fast LZ compression algorithm
+ * Copyright (C) 2011 - 2016, Yann Collet.
+ * BSD 2 - Clause License (http://www.opensource.org/licenses/bsd - 
license.php)
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * You can contact the author at :
+ * - LZ4 homepage : http://www.lz4.org
+ * - LZ4 source repository : https://github.com/lz4/lz4
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define FORCE_INLINE inline 

[PATCH v4 0/5] fs/erofs: new filesystem

2022-02-25 Thread Huang Jianan
Changes since v3:
 - update tools/docker/Dockerfile;

Changes since v2:
 - sync up with erofs-utils 1.4;
 - update lib/lz4 to v1.8.3;
 - add test for filesystem functions;

Changes since v1:
 - fix the inconsistency between From and SoB;
 - add missing license header;

Huang Jianan (5):
  fs/erofs: add erofs filesystem support
  lib/lz4: update LZ4 decompressor module
  fs/erofs: add lz4 decompression support
  fs/erofs: add filesystem commands
  test/py: Add tests for the erofs

 MAINTAINERS |   9 +
 cmd/Kconfig |   6 +
 cmd/Makefile|   1 +
 cmd/erofs.c |  42 ++
 configs/sandbox_defconfig   |   1 +
 fs/Kconfig  |   2 +
 fs/Makefile |   1 +
 fs/erofs/Kconfig|  21 +
 fs/erofs/Makefile   |   9 +
 fs/erofs/data.c | 311 +
 fs/erofs/decompress.c   |  78 
 fs/erofs/decompress.h   |  24 +
 fs/erofs/erofs_fs.h | 436 ++
 fs/erofs/fs.c   | 267 +++
 fs/erofs/internal.h | 313 +
 fs/erofs/namei.c| 252 +++
 fs/erofs/super.c| 105 +
 fs/erofs/zmap.c | 601 
 fs/fs.c |  22 +
 include/erofs.h |  19 +
 include/fs.h|   1 +
 include/u-boot/lz4.h|  49 ++
 lib/lz4.c   | 679 
 lib/lz4_wrapper.c   |  23 +-
 test/py/tests/test_fs/test_erofs.py | 211 +
 tools/docker/Dockerfile |   1 +
 26 files changed, 3269 insertions(+), 215 deletions(-)
 create mode 100644 cmd/erofs.c
 create mode 100644 fs/erofs/Kconfig
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/decompress.c
 create mode 100644 fs/erofs/decompress.h
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 fs/erofs/zmap.c
 create mode 100644 include/erofs.h
 create mode 100644 test/py/tests/test_fs/test_erofs.py

-- 
2.25.1



Re: [PATCH v4 05/11] EFI: FMP: Add provision to update image's ImageTypeId in image descriptor

2022-02-25 Thread Heinrich Schuchardt

On 2/17/22 11:10, Sughosh Ganu wrote:

On Thu, 17 Feb 2022 at 13:52, Ilias Apalodimas
 wrote:






[...]


Yes, we can use --index when we know the index value corresponding to
the firmware image that we need to update. But like I mentioned in my
earlier reply, for A/B updates, we do not know what the index value is
going to be. That is going to be determined at runtime.


I don't think so. See below for alternative approach.


Also, the point I was making is that we can have a capsule which is
consumed by an FMP protocol which has more than one image, and those
images have different ImageTypeId/UpdateImageTypeId.


Yes, but it is a design choice in my first implementation.
I didn't think that we need to "have a capsule which is consumed
by an FMP protocol which has more than one image" as long as we
use DFU framework (and FIT as standard format of aggregation on U-Boot).


But this design can be extended without any hassle, and more
importantly without any regression, no? What kind of a problem does it
create if the FMP can handle more than one image type.

Even as per the UEFI spec, we have the EFI_FIRMWARE_MANAGEMENT_CAPSULE
header for all images to be managed by the FMP protocol which has
multiple images with different UpdateImageTypeId.






Please check the
GenerateCapsule script in EDK2. In case of a multi payload based
capsule, individual parameters like the UpdateImageTypeId are passed
through the json file, where each of the UpdateImageTypeId has a
different value per payload.




2) Each firmware object handled by a given FMP driver can further be
identified by ImageIndex.

My implementation of efi_fmp_find() does (1) and Raw FMP driver does
(2) in efi_firmware_raw_set_image() which takes "image_index" as
a parameter.

Using ImageTypeId as an identifier is simply wrong in my opinion and
doesn't meet the UEFI specification.


So, as per what you are stating, all payloads under a given
EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER should have the same
ImageTypeId, either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID or
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID. Same applies for all images in
the EFI_FIRMWARE_IMAGE_DESCRIPTOR. Because, without one of the two
values, > the check in efi_fmp_find to compare the UpdateImageTypeId
with the ImageTypeId retrieved from the image descriptor would simply
fail.


I don't follow your point.
Please elaborate a bit more.


The current implementation of GetImageInfo, passes either of
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID or
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID for all the images of the image
descriptor array. So, in case the capsule is generated with a '--guid'
value which is different from these two values, the check in
efi_fmp_find on line 204 will fail.


That is an expected behavior, isn't it?


Yes it is. Do not contest that.


If you want to use a different FMP driver (with another GUID),
you naturally need to add your own FMP driver.


This is where I differ. We can use the same FMP protocol instance for
any type of ImageTypeId. I do not see why we need to define a
different FMP protocol instance for a GUID value other than what has
been defined for u-boot raw and u-boot FIT GUIDs.


I do understand part of your concern a bit.
I thought of using the same ImageType GUID, say IMAGE_TYPE_DFU_GUID, at first
but we needed different GUIDs here simply because we need to determine
the format of payload, FIT format or raw binary.


The platform can give us the image descriptor array, and with that,
the same FMP instance can be used for any type of image(ImageTypeId).


"any type of image"? Really?


The raw FMP instance can certainly handle any type of binary payloads
right. There is no restriction on what type of payload it is as long
as it is all going as a single entity to a given dfu partition.







This means that unless the --guid
value passed to the capsule generation is either of u-boot FIT or
u-boot raw, the current FMP protocol for raw devices cannot be used.
Why do we need that restriction. It should be possible to use the raw
FMP protocol for any other type of image types as well.





I think this interpretation of the UEFI spec is incorrect, since the
spec states that the ImageTypeId and the UpdateImageTypeId are fields
used to identify the firmware component targeted for the update. If
all values in the image descriptor array and the UpdateImageTypeId are
the same, why have this field in the first place for individual
images.


As I said, ImageIndex is for that purpose.


Yes, that is one possible way in the scenario where the ImageIndex is
determined at the capsule generation time. But, for the A/B update
scenario, we do not know the ImageIndex at build time


"Build time" of what?


Of the capsule.


I think that users should know how "dfu_alt_info" is defined
(in other words, where the firmware be located on the target system)
when capsule files are created.


That is true for a non A/B scenario. And that is how it works in the
non A/B updates case. 

[PATCH v2 1/1] doc: describe generation of SMBIOS table

2022-02-25 Thread Heinrich Schuchardt
SMBIOS is not x86 specific. So we should have an architecture independent
page describing it.

Signed-off-by: Heinrich Schuchardt 
---
v2:
Add missing file doc/develop/smbios.rst
---
 doc/arch/x86.rst   |  2 +-
 doc/develop/index.rst  |  1 +
 doc/develop/smbios.rst | 22 ++
 3 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 doc/develop/smbios.rst

diff --git a/doc/arch/x86.rst b/doc/arch/x86.rst
index 5494155a51..634387ac09 100644
--- a/doc/arch/x86.rst
+++ b/doc/arch/x86.rst
@@ -732,7 +732,7 @@ SMBIOS tables
 To generate SMBIOS tables in U-Boot, for use by the OS, enable the
 CONFIG_GENERATE_SMBIOS_TABLE option. The easiest way to provide the values to
 use is via the device tree. For details see
-device-tree-bindings/sysinfo/smbios.txt
+:download:`smbios.txt <../device-tree-bindings/sysinfo/smbios.txt>`.
 
 TODO List
 -
diff --git a/doc/develop/index.rst b/doc/develop/index.rst
index 97148875ef..93ebfa485f 100644
--- a/doc/develop/index.rst
+++ b/doc/develop/index.rst
@@ -22,6 +22,7 @@ Implementation
makefiles
menus
printf
+   smbios
uefi/index
version
 
diff --git a/doc/develop/smbios.rst b/doc/develop/smbios.rst
new file mode 100644
index 00..a4efb0a0a3
--- /dev/null
+++ b/doc/develop/smbios.rst
@@ -0,0 +1,22 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+SMBIOS tables
+=
+
+The System Management BIOS (SMBIOS) table is used to deliver management
+information from the firmware to the operating system. The content is
+standardized in [1]_.
+
+In Linux you can use the dmidecode command to view the contents of the SMBIOS
+table.
+
+When booting via UEFI the SMBIOS table is transferred as an UEFI configuration
+table to the operating system.
+
+To generate SMBIOS tables in U-Boot, the CONFIG_GENERATE_SMBIOS_TABLE option
+must be enabled. The easiest way to provide the values to use is via the device
+tree. For details see
+:download:`smbios.txt <../device-tree-bindings/sysinfo/smbios.txt>`.
+
+.. [1] `System Management BIOS (SMBIOS) Reference, version 3.5
+   `_
-- 
2.34.1



[PATCH 2/2] imx8m: ddrphy_utils: Add 3732 MT/s mode

2022-02-25 Thread Marek Vasut
Add entry for 3732 MT/s mode of operation of the LPDDR4, in
which case the DDR PLL has to be configured in 933 MHz mode.

Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
 drivers/ddr/imx/imx8m/ddrphy_utils.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/ddr/imx/imx8m/ddrphy_utils.c 
b/drivers/ddr/imx/imx8m/ddrphy_utils.c
index 0f8baefb1f8..a54449e5f14 100644
--- a/drivers/ddr/imx/imx8m/ddrphy_utils.c
+++ b/drivers/ddr/imx/imx8m/ddrphy_utils.c
@@ -117,6 +117,10 @@ void ddrphy_init_set_dfi_clk(unsigned int drate)
dram_pll_init(MHZ(1000));
dram_disable_bypass();
break;
+   case 3732:
+   dram_pll_init(MHZ(933));
+   dram_disable_bypass();
+   break;
case 3200:
dram_pll_init(MHZ(800));
dram_disable_bypass();
-- 
2.34.1



[PATCH 1/2] ARM: imx: imx8m: Add 933 MHz PLL settings

2022-02-25 Thread Marek Vasut
Add settings for operating PLL at 933 MHz. This setting is useful in
case the LPDDR4 DRAM should operate at 1866 MHz or 3733 MT/s.

Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/mach-imx/imx8m/clock_imx8mm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-imx/imx8m/clock_imx8mm.c 
b/arch/arm/mach-imx/imx8m/clock_imx8mm.c
index 76132defc21..4db55f86081 100644
--- a/arch/arm/mach-imx/imx8m/clock_imx8mm.c
+++ b/arch/arm/mach-imx/imx8m/clock_imx8mm.c
@@ -48,6 +48,7 @@ int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
 #ifdef CONFIG_SPL_BUILD
 static struct imx_int_pll_rate_table imx8mm_fracpll_tbl[] = {
PLL_1443X_RATE(10U, 250, 3, 1, 0),
+   PLL_1443X_RATE(93300U, 311, 4, 1, 0),
PLL_1443X_RATE(8U, 300, 9, 0, 0),
PLL_1443X_RATE(75000U, 250, 8, 0, 0),
PLL_1443X_RATE(65000U, 325, 3, 2, 0),
-- 
2.34.1



[PATCH] pmic: pca9450: Add PCA9450C compatible string

2022-02-25 Thread Marek Vasut
Add DT compatible string for PCA9450C PMIC. This is a variant of the
PCA9450 PMIC with 6 A dual-phase buck regulator and 3 A buck regulator,
and is software-wise compatible with the PCA9450B. This variant of the
PCA9450 is designed for use as companion PMIC for i.MX8MP.

Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
 drivers/power/pmic/pca9450.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/power/pmic/pca9450.c b/drivers/power/pmic/pca9450.c
index a886647f193..2394b196c56 100644
--- a/drivers/power/pmic/pca9450.c
+++ b/drivers/power/pmic/pca9450.c
@@ -83,6 +83,7 @@ static struct dm_pmic_ops pca9450_ops = {
 static const struct udevice_id pca9450_ids[] = {
{ .compatible = "nxp,pca9450a", .data = 0x25, },
{ .compatible = "nxp,pca9450b", .data = 0x25, },
+   { .compatible = "nxp,pca9450c", .data = 0x25, },
{ }
 };
 
-- 
2.34.1



[PATCH] ARM: dts: net: dwc_eth_qos: Fix i.MX8MP compatible string

2022-02-25 Thread Marek Vasut
The correct compatible string for i.MX8MP variant of DWC EQoS MAC
is "nxp,imx8mp-dwmac-eqos", use it. Drop the two current users of
the current wrong compatible string to avoid breaking them.

Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Marcel Ziswiler 
Cc: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/dts/imx8mp-evk-u-boot.dtsi| 1 -
 arch/arm/dts/imx8mp-verdin-u-boot.dtsi | 1 -
 drivers/net/dwc_eth_qos.c  | 2 +-
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/dts/imx8mp-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
index ab849ebaaca..7c3789273da 100644
--- a/arch/arm/dts/imx8mp-evk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
@@ -112,7 +112,6 @@
 };
 
  {
-   compatible = "fsl,imx-eqos";
/delete-property/ assigned-clocks;
/delete-property/ assigned-clock-parents;
/delete-property/ assigned-clock-rates;
diff --git a/arch/arm/dts/imx8mp-verdin-u-boot.dtsi 
b/arch/arm/dts/imx8mp-verdin-u-boot.dtsi
index a57ad45ed63..26140a79ebe 100644
--- a/arch/arm/dts/imx8mp-verdin-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-verdin-u-boot.dtsi
@@ -30,7 +30,6 @@
 };
 
  {
-   compatible = "fsl,imx-eqos";
/delete-property/ assigned-clocks;
/delete-property/ assigned-clock-parents;
/delete-property/ assigned-clock-rates;
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 22dad5b2030..ea0c2cfa5b2 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -2032,7 +2032,7 @@ static const struct udevice_id eqos_ids[] = {
 #endif
 #if IS_ENABLED(CONFIG_DWC_ETH_QOS_IMX)
{
-   .compatible = "fsl,imx-eqos",
+   .compatible = "nxp,imx8mp-dwmac-eqos",
.data = (ulong)_imx_config
},
 #endif
-- 
2.34.1



[PULL] u-boot-sh/master

2022-02-25 Thread Marek Vasut

The following changes since commit c6ae38b38967a5c33d729c20e508a03ba3e0e3f6:

  Merge tag 'clk-2022.04-rc2' of 
https://source.denx.de/u-boot/custodians/u-boot-clk (2022-02-25 11:21:32 
-0500)


are available in the Git repository at:

  git://source.denx.de/u-boot-sh.git master

for you to fetch changes up to 4ce849f535ba185288c27e30091d71446e32a47a:

  arm: rmobile: rzg2_beacon: Enable proper Ethernet PHY (2022-02-25 
21:42:07 +0100)



Adam Ford (2):
  net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid
  arm: rmobile: rzg2_beacon: Enable proper Ethernet PHY

 configs/rzg2_beacon_defconfig |  2 +-
 drivers/net/ravb.c| 34 +++---
 2 files changed, 32 insertions(+), 4 deletions(-)


dm driver probe and dm question

2022-02-25 Thread Tim Harvey
Greetings,

I've got an octeontx board which uses driver model
(CONFIG_DM/CONFIG_DM_I2C) but I find that the 'i2c_octeon' driver does
not probe automatically on boot until I do something like an 'i2c dev
0 && i2c probe'.

What would cause the i2c_octeon driver to not automatically probe?

Here is a dm tree of the board:
Marvell> dm tree
 Class Index  Probed  DriverName
---
 root  0  [ + ]   root_driver   root_driver
 rsa_mod_ex0  [   ]   mod_exp_sw|-- mod_exp_sw
 firmware  0  [   ]   psci  |-- psci
 regulator 0  [ + ]   regulator_fixed   |-- mmc_supply_3v3
 simple_bus0  [ + ]   simple_bus`-- soc@0
 clk   0  [ + ]   fixed_clock   |-- refclkuaa
 clk   1  [ + ]   fixed_clock   |-- sclk
 clk   2  [   ]   fixed_clock   |-- can20m
 serial0  [ + ]   serial_pl01x  |-- serial@87e02800
 serial1  [   ]   serial_pl01x  |-- serial@87e02900
 serial2  [   ]   serial_pl01x  |-- serial@87e02a00
 serial3  [   ]   serial_pl01x  |-- serial@87e02b00
 watchdog  0  [ + ]   sbsa_gwdt |-- watch-dog@844a
 pci   0  [ + ]   pci_octeontx  `-- pci@8480
 pci   1  [ + ]   pci_bridge_drv|-- mrml-bridge0@1,0
 misc  0  [ + ]   octeontx_smi  |   |-- mdio-nexus@1,3
 misc  1  [ + ]   octeontx_hsmmc_host   |   |-- mmc@1,4
 mmc   0  [ + ]   octeontx_hsmmc_slot   |   |   `--
octeontx-mmc0
 blk   0  [ + ]   mmc_blk   |   |
`-- octeontx-mmc0.blk
 i2c   0  [   ]   i2c_octeon|   |-- i2c@9,0
 misc  2  [   ]   gsc   |   |   `-- gsc@20
 i2c   1  [   ]   i2c_octeon|   |-- i2c@9,1
 pci_generi5  [   ]   pci_generic_drv   |   |-- pci_1:0.0
 pci_generi6  [   ]   pci_generic_drv   |   |-- pci_1:0.1
 pci_generi7  [   ]   pci_generic_drv   |   |-- pci_1:1.7
 pci_generi8  [   ]   pci_generic_drv   |   |-- pci_1:2.0
 pci_generi9  [   ]   pci_generic_drv   |   |-- pci_1:6.0
 pci_generi   10  [   ]   pci_generic_drv   |   |-- pci_1:7.0
 pci_generi   11  [   ]   pci_generic_drv   |   |-- pci_1:7.4
 pci_generi   12  [   ]   pci_generic_drv   |   |-- pci_1:a.0
 pci_generi   13  [   ]   pci_generic_drv   |   |-- pci_1:c.0
 pci_generi   14  [   ]   pci_generic_drv   |   |-- pci_1:c.1
 pci_generi   15  [   ]   pci_generic_drv   |   |-- pci_1:d.0
 misc  3  [ + ]   octeontx_bgx  |   |-- octeontx_bgx
 misc  4  [ + ]   octeontx_bgx  |   `-- octeontx_bgx
 gpio  0  [ + ]   octeon_gpio   |-- gpio0@6,0
 pci_generi0  [   ]   pci_generic_drv   |-- pci_0:7.0
 pci_generi1  [   ]   pci_generic_drv   |-- pci_0:8.0
 pci   2  [ + ]   pci_bridge_drv|-- pci_0:9.0
 pci_generi   16  [   ]   pci_generic_drv   |   `-- pci_2:0.0
 pci   3  [ + ]   pci_bridge_drv|-- pci_0:a.0
 pci_generi   17  [   ]   pci_generic_drv   |   `-- pci_3:0.0
 pci_generi2  [   ]   pci_generic_drv   |-- pci_0:b.0
 pci   4  [ + ]   pci_bridge_drv|-- pci_0:c.0
 pci_generi   18  [   ]   pci_generic_drv   |   `-- pci_4:0.0
 pci_generi3  [   ]   pci_generic_drv   |-- pci_0:d.0
 pci_generi4  [   ]   pci_generic_drv   |-- pci_0:e.0
 pci   5  [ + ]   pci_bridge_drv|-- pci_0:f.0
 misc  5  [ + ]   octeontx_nic  |   |-- octeontx_nic
 ethernet  0  [ + ]   vnic  |   |-- vnic0
 ethernet  1  [ + ]   vnic  |   `-- vnic1
 usb   0  [   ]   xhci_pci  |-- xhci_pci
 usb   1  [   ]   xhci_pci  `-- xhci_pci

Best regards,

Tim


RE: [PATCH] Makefile: Sort u-boot-initial-env output

2022-02-25 Thread Christoph Niedermaier
From: Simon Glass [mailto:s...@chromium.org]
Sent: Friday, February 25, 2022 12:54 AM
> 
> Hi Christoph,
>

Hi Simon,
 
> On Thu, 24 Feb 2022 at 02:59, Christoph Niedermaier
>  wrote:
>>
>> From: Simon Glass [mailto:s...@chromium.org]
>> Sent: Wednesday, February 23, 2022 11:59 PM
>>>
>>> Hi Christoph,
>>>
>>
>> Hi Simon,
>>
>>> On Wed, 23 Feb 2022 at 02:33, Christoph Niedermaier 
>>>  wrote:

 For a better overview and better comparison sort the initial
 environment as the get_default_env.sh script does. We need
 to preserve the order of equal variable names. So only sort
 by the variable name, and disable the last-resort comparison.
 Also remove blank lines before sorting.

 Signed-off-by: Christoph Niedermaier 
 Cc: Stefano Babic 
 Cc: Simon Glass 
 Cc: Marek Behún 
 To: u-boot@lists.denx.de
 ---
  Makefile | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> Does this sort the text environment too?
>>
>> It sorts only the generated file "u-boot-initial-env" which comes
>> from the default environment.
>> What exactly do you mean by "text environment"?
> 
> https://u-boot.readthedocs.io/en/latest/usage/environment.html#text-based-environment
> 
> Can you please expand your commit message a bit to explain exactly
> what this affects? Also how about an update to the above page that
> describes how the env is sorted.

I will make a V2 of the patch with a better commit message.

The sorting only affects the u-boot-initial-env file for the userspace
tools [1]. The environments of the bootloader are sorted if printed by
printenv. I think mentioning the u-boot-initial-env file in the page
above will lead to more confusion. It think it belongs more to the
userspace tools [1].

[1] https://github.com/sbabic/libubootenv


 diff --git a/Makefile b/Makefile
 index 4b152249ca..67ed4edc1a 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -2439,7 +2439,8 @@ endif

  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/\x00/\x0A/g' $@; sed --in-place -e 
 '/^\s*$$/d' $@; \
 +   sort --field-separator== -k1,1 --stable $@ -o $@

  u-boot-initial-env: u-boot.bin
 $(call if_changed,genenv)
>>

Regards
Christoph


[PATCH V2] Makefile: Sort u-boot-initial-env output

2022-02-25 Thread Christoph Niedermaier
This will sort the default environment file generated by
"make u-boot-initial-env", but won't sort the default
environment in the compiled u-boot binary. The file
u-boot-initial-env is considered to use for the userpace
environment access tools [1] in case of that the
environments is written the first time into its location.
This is done on the one hand for a better overview and
comparison of the generated environment file. On the other
hand it is to synchronize the output with the script
get_default_env.sh, which generated a sorted default
environment file. The sorting preserves the order of equal
variable names by sorting only the variable name, and
disable the last-resort comparison. After sorting,
unnoticed blank lines at the end move to the top. Avoid
that by removing it before sorting.

[1] https://github.com/sbabic/libubootenv

Signed-off-by: Christoph Niedermaier 
Cc: Stefano Babic 
Cc: Simon Glass 
Cc: Marek Behún 
To: u-boot@lists.denx.de
---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 66d9e78cc7..a6a94dc681 100644
--- a/Makefile
+++ b/Makefile
@@ -2441,7 +2441,8 @@ endif
 
 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/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' $@; 
\
+   sort --field-separator== -k1,1 --stable $@ -o $@
 
 u-boot-initial-env: u-boot.bin
$(call if_changed,genenv)
-- 
2.11.0



Re: [PATCH] tools: pblimage: fix image header verification function

2022-02-25 Thread Tom Rini
On Fri, Feb 25, 2022 at 09:36:03PM +0100, Pali Rohár wrote:
> On Thursday 17 February 2022 11:51:36 Zhiqiang Hou wrote:
> > From: Hou Zhiqiang 
> > 
> > The Layerscape platforms have different RCW header value from FSL
> > PowerPC platforms, the current image header verification callback
> > is only working on PowerPC, it will fail on Layerscape, this patch
> > is to fix this issue.
> > 
> > This is a historical problem and exposed by the following patch:
> > http://patchwork.ozlabs.org/project/uboot/patch/20220114173443.9877-1-p...@kernel.org
> > 
> > Signed-off-by: Hou Zhiqiang 
> 
> Hello Tom! Could you look at this change? It should unblock applying my above 
> patch.

Yes, I expect this to get picked up in the layerscape tree for the next
PR there.  Thanks.

-- 
Tom


signature.asc
Description: PGP signature


RE: [PATCH 0/5] Add ESM driver support for AM64x R5

2022-02-25 Thread Nagalla, Hari
Hi Christian,

I have a v2 series.. Will send out by Saturday.

Thanks
Hari

-Original Message-
From: Christian Gmeiner  
Sent: Wednesday, February 23, 2022 1:53 AM
To: Nagalla, Hari 
Cc: U-Boot Mailing List ; Menon, Nishanth 
Subject: Re: [PATCH 0/5] Add ESM driver support for AM64x R5

Hi Hari

Am Mi., 2. Feb. 2022 um 18:50 Uhr schrieb Hari Nagalla :
>
> AM64x devices have a main ESM and a MCU ESM. The ESM driver enables 
> routing of the error events from various sources to different 
> processors or to reset hardware logic. Only the MCU ESM's high output 
> can trigger reset logic. The main RTI0 WWDT output can be routed to 
> the MCU highoutput to trigger reset through the main ESM. For this 
> reset to occur CTRLMMR_MCU_RST_CTRL:MCU_ESM_ERROR_RESET_EN_Z is set to '0'.
>
> AM64x Technical Reference Manual - https://www.ti.com/lit/pdf/spruim2


Are there any plans to send out a V2 of this patch series? If not I can jump in 
(as I really want to see in U-Boot sooner than later).

--
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy


Re: [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid

2022-02-25 Thread Adam Ford
On Fri, Feb 25, 2022 at 2:43 PM Marek Vasut  wrote:
>
> On 2/25/22 21:10, Adam Ford wrote:
> > On Fri, Feb 25, 2022 at 2:08 PM Marek Vasut  wrote:
> >>
> >> On 2/25/22 19:29, Adam Ford wrote:
> >>> Some boards like the Beacon RZ/G2 SOM use either flags for
> >>> tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.
> >>>
> >>> In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
> >>> is set or the mode is rgmii-rxid, and the APSR_TDM is set when
> >>> tx-internal-delay-ps is found or rgmii-txid is set, and both
> >>> are set if rgmii-id is set.
> >>>
> >>> The ravb driver in U-Boot driver was missing rgmii-rxid support,
> >>> so add that support in a similar fashion to what is done in Linux.
> >>>
> >>> Signed-off-by: Adam Ford 
> >>> ---
> >>> V2:  Add boolean for explit delays which skips the rgmii mode check
> >>>if explicit delays are set.  This more closely matches the
> >>>behavior in Linux.  Also add the same comments for the delays
> >>>to match the comments found in Linux.
> >>>
> >>> diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
> >>> index 1d1118c341..7bc8c84aaa 100644
> >>> --- a/drivers/net/ravb.c
> >>> +++ b/drivers/net/ravb.c
> >>> @@ -52,6 +52,7 @@
> >>>#define CSR_OPS 0x000F
> >>>#define CSR_OPS_CONFIG  BIT(1)
> >>>
> >>> +#define APSR_RDM BIT(13)
> >>>#define APSR_TDMBIT(14)
> >>>
> >>>#define TCCR_TSRQ0  BIT(0)
> >>> @@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
> >>>struct ravb_priv *eth = dev_get_priv(dev);
> >>>struct eth_pdata *pdata = dev_get_plat(dev);
> >>>int ret = 0;
> >>> + int mode = 0;
> >>> + unsigned int delay;
> >>> + bool explicit_delay = false;
> >>>
> >>>/* Set CONFIG mode */
> >>>ret = ravb_reset(dev);
> >>> @@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
> >>>(rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
> >>>return 0;
> >>>
> >>> - if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
> >>> - (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
> >>> - writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
> >>> + if (!dev_read_u32(dev, "tx-internal-delay-ps", )) {
> >>> + /* Valid values are 0 and 2000, according to DT bindings */
> >>> + if (delay) {
> >>> + mode |= APSR_TDM;
> >>> + explicit_delay = true;
> >>> + }
> >>> + }
> >>> +
> >>> + if (!dev_read_u32(dev, "rx-internal-delay-ps", )) {
> >>> + /* Valid values are 0 and 1800, according to DT bindings */
> >>> + if (delay) {
> >>> + mode |= APSR_RDM;
> >>> + explicit_delay = true;
> >>> + }
> >>> + }
> >>
> >> Any reason to reverse those two tests compared to Linux ?
> >> Linux does rx test before tx test, and keeps the tests sorted
> >> alphabetically.
> >
> > It wasn't intentional.  I can swap them.
>
> V3 is now applied and in CI.

Thank you!

Just as an FYI, you are not showing up as a maintainer for the ravb
driver when run check_maintainer.py.  I knew to add you to the CC
list, but others in the future may not know to do that.

adam


Re: [PATCH v4] scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

2022-02-25 Thread Tom Rini
On Fri, Feb 25, 2022 at 06:30:05PM +0100, Philippe Reynes wrote:

> There is a conflict between the static file
> lib/acpi/dsdt.c and the file dsdt.c generated
> dynamicaly by scripts/Makefile.lib. When a
> mrproper is done, the static file dsdt.c is
> removed. If a build with acpi enabled is
> launched after, the following error is raised:
> 
>   CC  lib/acpi/acpi_table.o
> make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
> 'lib/acpi/dsdt.c'.  Stop.
> scripts/Makefile.build:394: recipe for target 'lib/acpi' failed
> 
> To avoid such error, the generated file is named
> dsdt_generated.c instead of dstdt.c.
> 
> Tested-by: Heiko Thiery 
> Signed-off-by: Philippe Reynes 
> ---
> 
> Changelog:
> v4:
> - update dsdt.* to dsdt_generated.* in several .gitignore
> v3:
> - update comments in file scripts/Makefile.lib
> - add changelog
> v2
> - change generated file name (dsdt_generated.c)
>   instead of changing the name of the static file
> - NOTE : forgot to call it v2 and forgot changelog

Sorry, I missed that this had come through while testing and applying
v3.  Can  you please do an incremental patch with the changes?  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid

2022-02-25 Thread Marek Vasut

On 2/25/22 21:10, Adam Ford wrote:

On Fri, Feb 25, 2022 at 2:08 PM Marek Vasut  wrote:


On 2/25/22 19:29, Adam Ford wrote:

Some boards like the Beacon RZ/G2 SOM use either flags for
tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.

In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
is set or the mode is rgmii-rxid, and the APSR_TDM is set when
tx-internal-delay-ps is found or rgmii-txid is set, and both
are set if rgmii-id is set.

The ravb driver in U-Boot driver was missing rgmii-rxid support,
so add that support in a similar fashion to what is done in Linux.

Signed-off-by: Adam Ford 
---
V2:  Add boolean for explit delays which skips the rgmii mode check
   if explicit delays are set.  This more closely matches the
   behavior in Linux.  Also add the same comments for the delays
   to match the comments found in Linux.

diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 1d1118c341..7bc8c84aaa 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -52,6 +52,7 @@
   #define CSR_OPS 0x000F
   #define CSR_OPS_CONFIG  BIT(1)

+#define APSR_RDM BIT(13)
   #define APSR_TDMBIT(14)

   #define TCCR_TSRQ0  BIT(0)
@@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
   struct ravb_priv *eth = dev_get_priv(dev);
   struct eth_pdata *pdata = dev_get_plat(dev);
   int ret = 0;
+ int mode = 0;
+ unsigned int delay;
+ bool explicit_delay = false;

   /* Set CONFIG mode */
   ret = ravb_reset(dev);
@@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
   (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
   return 0;

- if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
- (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
- writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
+ if (!dev_read_u32(dev, "tx-internal-delay-ps", )) {
+ /* Valid values are 0 and 2000, according to DT bindings */
+ if (delay) {
+ mode |= APSR_TDM;
+ explicit_delay = true;
+ }
+ }
+
+ if (!dev_read_u32(dev, "rx-internal-delay-ps", )) {
+ /* Valid values are 0 and 1800, according to DT bindings */
+ if (delay) {
+ mode |= APSR_RDM;
+ explicit_delay = true;
+ }
+ }


Any reason to reverse those two tests compared to Linux ?
Linux does rx test before tx test, and keeps the tests sorted
alphabetically.


It wasn't intentional.  I can swap them.


V3 is now applied and in CI.


Re: [PATCH] tools: pblimage: fix image header verification function

2022-02-25 Thread Pali Rohár
On Thursday 17 February 2022 11:51:36 Zhiqiang Hou wrote:
> From: Hou Zhiqiang 
> 
> The Layerscape platforms have different RCW header value from FSL
> PowerPC platforms, the current image header verification callback
> is only working on PowerPC, it will fail on Layerscape, this patch
> is to fix this issue.
> 
> This is a historical problem and exposed by the following patch:
> http://patchwork.ozlabs.org/project/uboot/patch/20220114173443.9877-1-p...@kernel.org
> 
> Signed-off-by: Hou Zhiqiang 

Hello Tom! Could you look at this change? It should unblock applying my above 
patch.

> ---
>  Makefile |  2 +-
>  tools/pblimage.c | 10 --
>  tools/pblimage.h |  3 ++-
>  3 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 4b152249ca..3c2bc9741c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1410,7 +1410,7 @@ MKIMAGEFLAGS_u-boot-spl.kwb = -n $(KWD_CONFIG_FILE) \
>   $(if $(KEYDIR),-k $(KEYDIR))
>  
>  MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
> - -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
> + -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -A $(ARCH) -T 
> pblimage
>  
>  ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy)
>  UBOOT_BIN := u-boot-with-dtb.bin
> diff --git a/tools/pblimage.c b/tools/pblimage.c
> index 3c823e96cf..bd639c276f 100644
> --- a/tools/pblimage.c
> +++ b/tools/pblimage.c
> @@ -230,19 +230,25 @@ static int pblimage_verify_header(unsigned char *ptr, 
> int image_size,
>   struct image_tool_params *params)
>  {
>   struct pbl_header *pbl_hdr = (struct pbl_header *) ptr;
> + uint32_t rcwheader;
> +
> + if (params->arch == IH_ARCH_ARM)
> + rcwheader = RCW_ARM_HEADER;
> + else
> + rcwheader = RCW_PPC_HEADER;
>  
>   /* Only a few checks can be done: search for magic numbers */
>   if (ENDIANNESS == 'l') {
>   if (pbl_hdr->preamble != reverse_byte(RCW_PREAMBLE))
>   return -FDT_ERR_BADSTRUCTURE;
>  
> - if (pbl_hdr->rcwheader != reverse_byte(RCW_HEADER))
> + if (pbl_hdr->rcwheader != reverse_byte(rcwheader))
>   return -FDT_ERR_BADSTRUCTURE;
>   } else {
>   if (pbl_hdr->preamble != RCW_PREAMBLE)
>   return -FDT_ERR_BADSTRUCTURE;
>  
> - if (pbl_hdr->rcwheader != RCW_HEADER)
> + if (pbl_hdr->rcwheader != rcwheader)
>   return -FDT_ERR_BADSTRUCTURE;
>   }
>   return 0;
> diff --git a/tools/pblimage.h b/tools/pblimage.h
> index 81c5492926..0222e8067b 100644
> --- a/tools/pblimage.h
> +++ b/tools/pblimage.h
> @@ -8,7 +8,8 @@
>  
>  #define RCW_BYTES64
>  #define RCW_PREAMBLE 0xaa55aa55
> -#define RCW_HEADER   0x010e0100
> +#define RCW_ARM_HEADER   0x01ee0100
> +#define RCW_PPC_HEADER   0x010e0100
>  
>  struct pbl_header {
>   uint32_t preamble;
> -- 
> 2.25.1
> 


[PATCH V3 2/2] arm: rmobile: rzg2_beacon: Enable proper Ethernet PHY

2022-02-25 Thread Adam Ford
The wrong phy was being enabled, because it worked and the proper
PHY did not.  After the Renesas maintainer made some adjustments
to the device tree, Linux was able to use the proper driver, and
when that device tree was ported to Linux, the ethernet stopped
working due to the lack of rgmii-rxid support.  Now that
rgmii-rxid is supported, enable the proper driver to restore
ethernet function.

Fixes: 1eaf61c84db6 ("arm: dts: beacon-rzg2: Resync device trees with Linux 
5.16-rc3")
Signed-off-by: Adam Ford 
---
V3:  No change
V2:  No change

diff --git a/configs/rzg2_beacon_defconfig b/configs/rzg2_beacon_defconfig
index e6a0d68962..91b3fa2948 100644
--- a/configs/rzg2_beacon_defconfig
+++ b/configs/rzg2_beacon_defconfig
@@ -62,7 +62,7 @@ CONFIG_DM_MTD=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_BITBANGMII=y
-CONFIG_PHY_REALTEK=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_DM_ETH=y
 CONFIG_RENESAS_RAVB=y
 CONFIG_DM_REGULATOR=y
-- 
2.34.1



[PATCH V3 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid

2022-02-25 Thread Adam Ford
Some boards like the Beacon RZ/G2 SOM use either flags for
tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.

In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
is set or the mode is rgmii-rxid, and the APSR_TDM is set when
tx-internal-delay-ps is found or rgmii-txid is set, and both
are set if rgmii-id is set.

The ravb driver in U-Boot driver was missing rgmii-rxid support,
so add that support in a similar fashion to what is done in Linux.

Signed-off-by: Adam Ford 
---
V3:  Re-order the checks for rx/tx-internal-delay-ps so the rx
 comes before the tx.

V2:  Add boolean for explit delays which skips the rgmii mode check
 if explicit delays are set.  This more closely matches the
 behavior in Linux.  Also add the same comments for the delays
 to match the comments found in Linux.

diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 1d1118c341..4078d33bb5 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -52,6 +52,7 @@
 #define CSR_OPS0x000F
 #define CSR_OPS_CONFIG BIT(1)
 
+#define APSR_RDM   BIT(13)
 #define APSR_TDM   BIT(14)
 
 #define TCCR_TSRQ0 BIT(0)
@@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
struct ravb_priv *eth = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_plat(dev);
int ret = 0;
+   int mode = 0;
+   unsigned int delay;
+   bool explicit_delay = false;
 
/* Set CONFIG mode */
ret = ravb_reset(dev);
@@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
(rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
return 0;
 
-   if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
-   (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
-   writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
+   if (!dev_read_u32(dev, "rx-internal-delay-ps", )) {
+   /* Valid values are 0 and 1800, according to DT bindings */
+   if (delay) {
+   mode |= APSR_RDM;
+   explicit_delay = true;
+   }
+   }
+
+   if (!dev_read_u32(dev, "tx-internal-delay-ps", )) {
+   /* Valid values are 0 and 2000, according to DT bindings */
+   if (delay) {
+   mode |= APSR_TDM;
+   explicit_delay = true;
+   }
+   }
+
+   if (!explicit_delay) {
+   if (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+   pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID)
+   mode |= APSR_RDM;
+
+   if (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+   pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID)
+   mode |= APSR_TDM;
+   }
+
+   writel(mode, eth->iobase + RAVB_REG_APSR);
 
return 0;
 }
-- 
2.34.1



Re: [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid

2022-02-25 Thread Adam Ford
On Fri, Feb 25, 2022 at 2:08 PM Marek Vasut  wrote:
>
> On 2/25/22 19:29, Adam Ford wrote:
> > Some boards like the Beacon RZ/G2 SOM use either flags for
> > tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.
> >
> > In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
> > is set or the mode is rgmii-rxid, and the APSR_TDM is set when
> > tx-internal-delay-ps is found or rgmii-txid is set, and both
> > are set if rgmii-id is set.
> >
> > The ravb driver in U-Boot driver was missing rgmii-rxid support,
> > so add that support in a similar fashion to what is done in Linux.
> >
> > Signed-off-by: Adam Ford 
> > ---
> > V2:  Add boolean for explit delays which skips the rgmii mode check
> >   if explicit delays are set.  This more closely matches the
> >   behavior in Linux.  Also add the same comments for the delays
> >   to match the comments found in Linux.
> >
> > diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
> > index 1d1118c341..7bc8c84aaa 100644
> > --- a/drivers/net/ravb.c
> > +++ b/drivers/net/ravb.c
> > @@ -52,6 +52,7 @@
> >   #define CSR_OPS 0x000F
> >   #define CSR_OPS_CONFIG  BIT(1)
> >
> > +#define APSR_RDM BIT(13)
> >   #define APSR_TDMBIT(14)
> >
> >   #define TCCR_TSRQ0  BIT(0)
> > @@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
> >   struct ravb_priv *eth = dev_get_priv(dev);
> >   struct eth_pdata *pdata = dev_get_plat(dev);
> >   int ret = 0;
> > + int mode = 0;
> > + unsigned int delay;
> > + bool explicit_delay = false;
> >
> >   /* Set CONFIG mode */
> >   ret = ravb_reset(dev);
> > @@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
> >   (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
> >   return 0;
> >
> > - if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
> > - (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
> > - writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
> > + if (!dev_read_u32(dev, "tx-internal-delay-ps", )) {
> > + /* Valid values are 0 and 2000, according to DT bindings */
> > + if (delay) {
> > + mode |= APSR_TDM;
> > + explicit_delay = true;
> > + }
> > + }
> > +
> > + if (!dev_read_u32(dev, "rx-internal-delay-ps", )) {
> > + /* Valid values are 0 and 1800, according to DT bindings */
> > + if (delay) {
> > + mode |= APSR_RDM;
> > + explicit_delay = true;
> > + }
> > + }
>
> Any reason to reverse those two tests compared to Linux ?
> Linux does rx test before tx test, and keeps the tests sorted
> alphabetically.

It wasn't intentional.  I can swap them.

adam
>
> [...]


Re: [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid

2022-02-25 Thread Marek Vasut

On 2/25/22 19:29, Adam Ford wrote:

Some boards like the Beacon RZ/G2 SOM use either flags for
tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.

In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
is set or the mode is rgmii-rxid, and the APSR_TDM is set when
tx-internal-delay-ps is found or rgmii-txid is set, and both
are set if rgmii-id is set.

The ravb driver in U-Boot driver was missing rgmii-rxid support,
so add that support in a similar fashion to what is done in Linux.

Signed-off-by: Adam Ford 
---
V2:  Add boolean for explit delays which skips the rgmii mode check
  if explicit delays are set.  This more closely matches the
  behavior in Linux.  Also add the same comments for the delays
  to match the comments found in Linux.

diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 1d1118c341..7bc8c84aaa 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -52,6 +52,7 @@
  #define CSR_OPS   0x000F
  #define CSR_OPS_CONFIGBIT(1)
  
+#define APSR_RDM		BIT(13)

  #define APSR_TDM  BIT(14)
  
  #define TCCR_TSRQ0		BIT(0)

@@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
struct ravb_priv *eth = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_plat(dev);
int ret = 0;
+   int mode = 0;
+   unsigned int delay;
+   bool explicit_delay = false;
  
  	/* Set CONFIG mode */

ret = ravb_reset(dev);
@@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
(rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
return 0;
  
-	if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||

-   (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
-   writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
+   if (!dev_read_u32(dev, "tx-internal-delay-ps", )) {
+   /* Valid values are 0 and 2000, according to DT bindings */
+   if (delay) {
+   mode |= APSR_TDM;
+   explicit_delay = true;
+   }
+   }
+
+   if (!dev_read_u32(dev, "rx-internal-delay-ps", )) {
+   /* Valid values are 0 and 1800, according to DT bindings */
+   if (delay) {
+   mode |= APSR_RDM;
+   explicit_delay = true;
+   }
+   }


Any reason to reverse those two tests compared to Linux ?
Linux does rx test before tx test, and keeps the tests sorted 
alphabetically.


[...]


hi

2022-02-25 Thread Neuber Sousa
I need help here


Re: [PATCH v3] scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

2022-02-25 Thread Tom Rini
On Tue, Feb 22, 2022 at 02:54:39PM +0100, Philippe Reynes wrote:

> There is a conflict between the static file
> lib/acpi/dsdt.c and the file dsdt.c generated
> dynamicaly by scripts/Makefile.lib. When a
> mrproper is done, the static file dsdt.c is
> removed. If a build with acpi enabled is
> launched after, the following error is raised:
> 
>   CC  lib/acpi/acpi_table.o
> make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
> 'lib/acpi/dsdt.c'.  Stop.
> scripts/Makefile.build:394: recipe for target 'lib/acpi' failed
> 
> To avoid such error, the generated file is named
> dsdt_generated.c instead of dstdt.c.
> 
> Signed-off-by: Philippe Reynes 
> Tested-by: Heiko Thiery 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [GIT PULL] clock changes for v2022.04-rc2

2022-02-25 Thread Tom Rini
On Fri, Feb 25, 2022 at 01:57:07AM -0500, Sean Anderson wrote:

> The following changes since commit 90de95f7443cb06f014824976251f126ac6f71c0:
> 
>   Merge https://gitlab.denx.de/u-boot/custodians/u-boot-usb (2022-02-23 
> 13:34:14 -0500)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-clk.git tags/clk-2022.04-rc2
> 
> for you to fetch changes up to 92a1bba85761e4dd5c0647c48048423bceef4749:
> 
>   cmd: clk: fix long help message (2022-02-25 01:41:04 -0500)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH V2 2/2] arm: rmobile: rzg2_beacon: Enable proper Ethernet PHY

2022-02-25 Thread Adam Ford
The wrong phy was being enabled, because it worked and the proper
PHY did not.  After the Renesas maintainer made some adjustments
to the device tree, Linux was able to use the proper driver, and
when that device tree was ported to Linux, the ethernet stopped
working due to the lack of rgmii-rxid support.  Now that
rgmii-rxid is supported, enable the proper driver to restore
ethernet function.

Fixes: 1eaf61c84db6 ("arm: dts: beacon-rzg2: Resync device trees with Linux 
5.16-rc3")
Signed-off-by: Adam Ford 
---
V2:  No change

diff --git a/configs/rzg2_beacon_defconfig b/configs/rzg2_beacon_defconfig
index e6a0d68962..91b3fa2948 100644
--- a/configs/rzg2_beacon_defconfig
+++ b/configs/rzg2_beacon_defconfig
@@ -62,7 +62,7 @@ CONFIG_DM_MTD=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_BITBANGMII=y
-CONFIG_PHY_REALTEK=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_DM_ETH=y
 CONFIG_RENESAS_RAVB=y
 CONFIG_DM_REGULATOR=y
-- 
2.34.1



[PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid

2022-02-25 Thread Adam Ford
Some boards like the Beacon RZ/G2 SOM use either flags for
tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.

In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
is set or the mode is rgmii-rxid, and the APSR_TDM is set when
tx-internal-delay-ps is found or rgmii-txid is set, and both
are set if rgmii-id is set.

The ravb driver in U-Boot driver was missing rgmii-rxid support,
so add that support in a similar fashion to what is done in Linux.

Signed-off-by: Adam Ford 
---
V2:  Add boolean for explit delays which skips the rgmii mode check
 if explicit delays are set.  This more closely matches the
 behavior in Linux.  Also add the same comments for the delays
 to match the comments found in Linux.

diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 1d1118c341..7bc8c84aaa 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -52,6 +52,7 @@
 #define CSR_OPS0x000F
 #define CSR_OPS_CONFIG BIT(1)
 
+#define APSR_RDM   BIT(13)
 #define APSR_TDM   BIT(14)
 
 #define TCCR_TSRQ0 BIT(0)
@@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
struct ravb_priv *eth = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_plat(dev);
int ret = 0;
+   int mode = 0;
+   unsigned int delay;
+   bool explicit_delay = false;
 
/* Set CONFIG mode */
ret = ravb_reset(dev);
@@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
(rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
return 0;
 
-   if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
-   (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
-   writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
+   if (!dev_read_u32(dev, "tx-internal-delay-ps", )) {
+   /* Valid values are 0 and 2000, according to DT bindings */
+   if (delay) {
+   mode |= APSR_TDM;
+   explicit_delay = true;
+   }
+   }
+
+   if (!dev_read_u32(dev, "rx-internal-delay-ps", )) {
+   /* Valid values are 0 and 1800, according to DT bindings */
+   if (delay) {
+   mode |= APSR_RDM;
+   explicit_delay = true;
+   }
+   }
+
+   if (!explicit_delay) {
+   if (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+   pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID)
+   mode |= APSR_RDM;
+
+   if (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+   pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID)
+   mode |= APSR_TDM;
+   }
+
+   writel(mode, eth->iobase + RAVB_REG_APSR);
 
return 0;
 }
-- 
2.34.1



[PATCH v4] scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

2022-02-25 Thread Philippe Reynes
There is a conflict between the static file
lib/acpi/dsdt.c and the file dsdt.c generated
dynamicaly by scripts/Makefile.lib. When a
mrproper is done, the static file dsdt.c is
removed. If a build with acpi enabled is
launched after, the following error is raised:

  CC  lib/acpi/acpi_table.o
make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
'lib/acpi/dsdt.c'.  Stop.
scripts/Makefile.build:394: recipe for target 'lib/acpi' failed

To avoid such error, the generated file is named
dsdt_generated.c instead of dstdt.c.

Tested-by: Heiko Thiery 
Signed-off-by: Philippe Reynes 
---

Changelog:
v4:
- update dsdt.* to dsdt_generated.* in several .gitignore
v3:
- update comments in file scripts/Makefile.lib
- add changelog
v2
- change generated file name (dsdt_generated.c)
  instead of changing the name of the static file
- NOTE : forgot to call it v2 and forgot changelog

 Makefile  | 3 ++-
 board/advantech/som-db5800-som-6867/.gitignore| 6 +++---
 board/advantech/som-db5800-som-6867/Makefile  | 2 +-
 board/congatec/conga-qeval20-qa3-e3845/.gitignore | 6 +++---
 board/congatec/conga-qeval20-qa3-e3845/Makefile   | 2 +-
 board/dfi/dfi-bt700/Makefile  | 2 +-
 board/google/chromebook_coral/Makefile| 2 +-
 board/intel/bayleybay/.gitignore  | 6 +++---
 board/intel/bayleybay/Makefile| 2 +-
 board/intel/edison/.gitignore | 6 +++---
 board/intel/edison/Makefile   | 2 +-
 board/intel/galileo/.gitignore| 6 +++---
 board/intel/galileo/Makefile  | 2 +-
 board/intel/minnowmax/.gitignore  | 6 +++---
 board/intel/minnowmax/Makefile| 2 +-
 scripts/Makefile.lib  | 8 
 16 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/Makefile b/Makefile
index 697cc51d67..66d9e78cc7 100644
--- a/Makefile
+++ b/Makefile
@@ -2227,7 +2227,8 @@ clean: $(clean-dirs)
-o -name '*.asn1.[ch]' \
-o -name '*.symtypes' -o -name 'modules.order' \
-o -name modules.builtin -o -name '.tmp_*.o.*' \
-   -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \
+   -o -name 'dsdt_generated.aml' -o -name 'dsdt_generated.asl.tmp' 
\
+   -o -name 'dsdt_generated.c' \
-o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \
-type f -print | xargs rm -f
 
diff --git a/board/advantech/som-db5800-som-6867/.gitignore 
b/board/advantech/som-db5800-som-6867/.gitignore
index 6eb8a5481a..39e46ba0ae 100644
--- a/board/advantech/som-db5800-som-6867/.gitignore
+++ b/board/advantech/som-db5800-som-6867/.gitignore
@@ -1,3 +1,3 @@
-dsdt.aml
-dsdt.asl.tmp
-dsdt.c
+dsdt_generated.aml
+dsdt_generated.asl.tmp
+dsdt_generated.c
diff --git a/board/advantech/som-db5800-som-6867/Makefile 
b/board/advantech/som-db5800-som-6867/Makefile
index 7975547f41..95af6c4df7 100644
--- a/board/advantech/som-db5800-som-6867/Makefile
+++ b/board/advantech/som-db5800-som-6867/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += som-db5800-som-6867.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/congatec/conga-qeval20-qa3-e3845/.gitignore 
b/board/congatec/conga-qeval20-qa3-e3845/.gitignore
index 6eb8a5481a..39e46ba0ae 100644
--- a/board/congatec/conga-qeval20-qa3-e3845/.gitignore
+++ b/board/congatec/conga-qeval20-qa3-e3845/.gitignore
@@ -1,3 +1,3 @@
-dsdt.aml
-dsdt.asl.tmp
-dsdt.c
+dsdt_generated.aml
+dsdt_generated.asl.tmp
+dsdt_generated.c
diff --git a/board/congatec/conga-qeval20-qa3-e3845/Makefile 
b/board/congatec/conga-qeval20-qa3-e3845/Makefile
index 451a4fcd6c..215f5680dc 100644
--- a/board/congatec/conga-qeval20-qa3-e3845/Makefile
+++ b/board/congatec/conga-qeval20-qa3-e3845/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += conga-qeval20-qa3.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/dfi/dfi-bt700/Makefile b/board/dfi/dfi-bt700/Makefile
index 50d88f2954..1c4329a058 100644
--- a/board/dfi/dfi-bt700/Makefile
+++ b/board/dfi/dfi-bt700/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += dfi-bt700.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/google/chromebook_coral/Makefile 
b/board/google/chromebook_coral/Makefile
index f7a0ca6cc0..846558d777 100644
--- a/board/google/chromebook_coral/Makefile
+++ b/board/google/chromebook_coral/Makefile
@@ -3,4 +3,4 @@
 # Copyright 2019 Google LLC
 
 obj-y  += coral.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/bayleybay/.gitignore b/board/intel/bayleybay/.gitignore
index 

Re: [PATCH v3] scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

2022-02-25 Thread Philippe REYNES

Hi Heinrich,

Le 25/02/2022 à 15:59, Heinrich Schuchardt a écrit :

On 2/25/22 13:33, Heiko Thiery wrote:

Hi,

Am Di., 22. Feb. 2022 um 14:55 Uhr schrieb Philippe Reynes
:


There is a conflict between the static file
lib/acpi/dsdt.c and the file dsdt.c generated
dynamicaly by scripts/Makefile.lib. When a
mrproper is done, the static file dsdt.c is
removed. If a build with acpi enabled is
launched after, the following error is raised:

   CC  lib/acpi/acpi_table.o
make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
'lib/acpi/dsdt.c'.  Stop.

scripts/Makefile.build:394: recipe for target 'lib/acpi' failed

To avoid such error, the generated file is named
dsdt_generated.c instead of dstdt.c.


This issue can also be seen when doing a make clean and do a git status

-- 8< -- Hi
Changes not staged for commit:
   (use "git add/rm ..." to update what will be committed)
   (use "git restore ..." to discard changes in working directory)
deleted:    lib/acpi/dsdt.c
-- 8< --

After applying this patch this cannot be seen anymore.




Signed-off-by: Philippe Reynes 


Tested-by: Heiko Thiery 


The patch should update the .gitignore entries:

board/advantech/som-db5800-som-6867/.gitignore:1:dsdt.aml
board/advantech/som-db5800-som-6867/.gitignore:2:dsdt.asl.tmp
board/advantech/som-db5800-som-6867/.gitignore:3:dsdt.c
board/congatec/conga-qeval20-qa3-e3845/.gitignore:1:dsdt.aml
board/congatec/conga-qeval20-qa3-e3845/.gitignore:2:dsdt.asl.tmp
board/congatec/conga-qeval20-qa3-e3845/.gitignore:3:dsdt.c
board/intel/bayleybay/.gitignore:1:dsdt.aml
board/intel/bayleybay/.gitignore:2:dsdt.asl.tmp
board/intel/bayleybay/.gitignore:3:dsdt.c
board/intel/edison/.gitignore:1:dsdt.aml
board/intel/edison/.gitignore:2:dsdt.asl.tmp
board/intel/edison/.gitignore:3:dsdt.c
board/intel/galileo/.gitignore:1:dsdt.aml
board/intel/galileo/.gitignore:2:dsdt.asl.tmp
board/intel/galileo/.gitignore:3:dsdt.c
board/intel/minnowmax/.gitignore:1:dsdt.aml
board/intel/minnowmax/.gitignore:2:dsdt.asl.tmp
board/intel/minnowmax/.gitignore:3:dsdt.c



You're right, I forgot it. I sent a v4 with this change.
Thanks a lot.



Best regards

Heinrich



Best Regards,
Philippe









---

Changelog:
v3:
- update comments in file scripts/Makefile.lib
- add changelog
v2
- change generated file name (dsdt_generated.c)
   instead of changing the name of the static file
- NOTE : forgot to call it v2 and forgot changelog

Makefile    | 3 ++-
  board/advantech/som-db5800-som-6867/Makefile    | 2 +-
  board/congatec/conga-qeval20-qa3-e3845/Makefile | 2 +-
  board/dfi/dfi-bt700/Makefile    | 2 +-
  board/google/chromebook_coral/Makefile  | 2 +-
  board/intel/bayleybay/Makefile  | 2 +-
  board/intel/edison/Makefile | 2 +-
  board/intel/galileo/Makefile    | 2 +-
  board/intel/minnowmax/Makefile  | 2 +-
  scripts/Makefile.lib    | 8 
  10 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index 4b152249ca..94bc48f00c 100644
--- a/Makefile
+++ b/Makefile
@@ -2226,7 +2226,8 @@ clean: $(clean-dirs)
 -o -name '*.asn1.[ch]' \
 -o -name '*.symtypes' -o -name 'modules.order' \
 -o -name modules.builtin -o -name '.tmp_*.o.*' \
-   -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 
'dsdt.c' \
+   -o -name 'dsdt_generated.aml' -o -name 
'dsdt_generated.asl.tmp' \

+   -o -name 'dsdt_generated.c' \
 -o -name '*.efi' -o -name '*.gcno' -o -name '*.so' 
\) \

 -type f -print | xargs rm -f

diff --git a/board/advantech/som-db5800-som-6867/Makefile 
b/board/advantech/som-db5800-som-6867/Makefile

index 7975547f41..95af6c4df7 100644
--- a/board/advantech/som-db5800-som-6867/Makefile
+++ b/board/advantech/som-db5800-som-6867/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc

  obj-y  += som-db5800-som-6867.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/congatec/conga-qeval20-qa3-e3845/Makefile 
b/board/congatec/conga-qeval20-qa3-e3845/Makefile

index 451a4fcd6c..215f5680dc 100644
--- a/board/congatec/conga-qeval20-qa3-e3845/Makefile
+++ b/board/congatec/conga-qeval20-qa3-e3845/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc

  obj-y  += conga-qeval20-qa3.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/dfi/dfi-bt700/Makefile 
b/board/dfi/dfi-bt700/Makefile

index 50d88f2954..1c4329a058 100644
--- a/board/dfi/dfi-bt700/Makefile
+++ b/board/dfi/dfi-bt700/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc

  obj-y  += dfi-bt700.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/google/chromebook_coral/Makefile 

Re: [PATCH V2] dt-bindings: nvmem: add U-Boot environment variables binding

2022-02-25 Thread Rob Herring
On Thu, Feb 17, 2022 at 02:02:35PM +0100, Rafał Miłecki wrote:
> From: Rafał Miłecki 
> 
> U-Boot uses environment variables for storing device setup data. It
> usually needs to be accessed by a bootloader, kernel and often
> user-space.

How much of this is already in use vs. proposed? I know I've seen 
something, but that may have been a u-boot env string in 'label' and 
that's it.

> This binding allows describing environment data located in a raw flash
> partition. It's treated as NVMEM device and can be reused later for
> other storage devices.
> 
> Using DT should be cleaner than hardcoding & duplicating such info in
> multiple places. Bootloader & kernel can share DTS and user-space can
> try reading it too or just have correct data exposed by a kernel.
> 
> A custom "compatible" string allows system to automatically load
> relevant NVMEM driver but phandle can be also used for reading raw
> location.
> 
> Signed-off-by: Rafał Miłecki 
> ---
> V2: Update descriptions to don't make this binding MTD (flash partition)
> specific. Mention multiple possible storage ways.
> ---
>  .../devicetree/bindings/nvmem/u-boot,env.yaml | 66 +++
>  MAINTAINERS   |  5 ++
>  2 files changed, 71 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
> 
> diff --git a/Documentation/devicetree/bindings/nvmem/u-boot,env.yaml 
> b/Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
> new file mode 100644
> index ..a53e34152c97
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
> @@ -0,0 +1,66 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/nvmem/u-boot,env.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: U-Boot environment variables
> +
> +description: |
> +  U-Boot uses environment variables to store device parameters and
> +  configuration. They may be used for booting process, setup or keeping end 
> user
> +  info.
> +
> +  Data is stored using U-Boot specific formats (variant specific header and 
> NUL
> +  separated key-value pairs).
> +
> +  Environment data can be stored on various storage entities, e.g.:
> +  1. Raw flash partition
> +  2. UBI volume
> +
> +  This binding allows marking storage device (as containing env data) and
> +  specifying used format.
> +
> +  Right now only flash partition case is covered but it may be extended to 
> e.g.
> +  UBI volumes in the future.
> +
> +maintainers:
> +  - Rafał Miłecki 
> +
> +allOf:
> +  - $ref: nvmem.yaml#

What exactly is used from nvmem.yaml? Based on the example, nothing.

> +
> +properties:
> +  compatible:
> +oneOf:
> +  - description: A standalone env data block
> +const: u-boot,env

> +  - description: Two redundant blocks with active one flagged
> +const: u-boot,env-redundant-bool
> +  - description: Two redundant blocks with active having higher counter
> +const: u-boot,env-redundant-count

Aren't these 2 discoverable based on a flag or count property?

> +
> +  reg:
> +maxItems: 1
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +partitions {
> +compatible = "fixed-partitions";
> +#address-cells = <1>;
> +#size-cells = <1>;
> +
> +partition@0 {
> +reg = <0x0 0x4>;
> +label = "u-boot";
> +read-only;
> +};
> +
> +env: partition@4 {
> +compatible = "u-boot,env";
> +reg = <0x4 0x1>;
> +label = "u-boot-env";
> +};
> +};
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 66aa3a589f6a..55c56ce82856 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -19905,6 +19905,11 @@ W:   http://linuxtv.org
>  T:   git git://linuxtv.org/media_tree.git
>  F:   drivers/media/pci/tw686x/
>  
> +U-BOOT ENVIRONMENT VARIABLES
> +M:   Rafał Miłecki 
> +S:   Maintained
> +F:   Documentation/devicetree/bindings/nvmem/u-boot,env.yaml
> +
>  UACCE ACCELERATOR FRAMEWORK
>  M:   Zhangfei Gao 
>  M:   Zhou Wang 
> -- 
> 2.34.1
> 
> 


[PATCH 6/9] Convert CONFIG_BOOTP_MAY_FAIL et al to Kconfig

2022-02-25 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_BOOTP_MAY_FAIL
   CONFIG_BOOTP_VENDOREX
   CONFIG_BOOTP_BOOTFILESIZE
   CONFIG_BOOTP_NISDOMAIN
   CONFIG_BOOTP_TIMEOFFSET

Cc: Ramon Fried 
Signed-off-by: Tom Rini 
---
 README| 15 ---
 cmd/Kconfig   | 25 +++
 configs/10m50_defconfig   |  1 +
 configs/3c120_defconfig   |  1 +
 configs/M5235EVB_Flash32_defconfig|  1 +
 configs/M5235EVB_defconfig|  1 +
 configs/M5272C3_defconfig |  1 +
 configs/M5275EVB_defconfig|  1 +
 configs/M5282EVB_defconfig|  1 +
 configs/MPC837XERDB_defconfig |  1 +
 configs/MPC8548CDS_36BIT_defconfig|  1 +
 configs/MPC8548CDS_defconfig  |  1 +
 configs/MPC8548CDS_legacy_defconfig   |  1 +
 configs/at91sam9260ek_dataflash_cs0_defconfig |  1 +
 configs/at91sam9260ek_dataflash_cs1_defconfig |  1 +
 configs/at91sam9260ek_nandflash_defconfig |  1 +
 configs/at91sam9261ek_dataflash_cs0_defconfig |  1 +
 configs/at91sam9261ek_dataflash_cs3_defconfig |  1 +
 configs/at91sam9261ek_nandflash_defconfig |  1 +
 configs/at91sam9263ek_dataflash_cs0_defconfig |  1 +
 configs/at91sam9263ek_dataflash_defconfig |  1 +
 configs/at91sam9263ek_nandflash_defconfig |  1 +
 configs/at91sam9263ek_norflash_boot_defconfig |  1 +
 configs/at91sam9263ek_norflash_defconfig  |  1 +
 configs/at91sam9g10ek_dataflash_cs0_defconfig |  1 +
 configs/at91sam9g10ek_dataflash_cs3_defconfig |  1 +
 configs/at91sam9g10ek_nandflash_defconfig |  1 +
 configs/at91sam9g20ek_2mmc_defconfig  |  1 +
 .../at91sam9g20ek_2mmc_nandflash_defconfig|  1 +
 configs/at91sam9g20ek_dataflash_cs0_defconfig |  1 +
 configs/at91sam9g20ek_dataflash_cs1_defconfig |  1 +
 configs/at91sam9g20ek_nandflash_defconfig |  1 +
 configs/at91sam9m10g45ek_mmc_defconfig|  1 +
 configs/at91sam9m10g45ek_nandflash_defconfig  |  1 +
 configs/at91sam9n12ek_mmc_defconfig   |  1 +
 configs/at91sam9n12ek_nandflash_defconfig |  1 +
 configs/at91sam9n12ek_spiflash_defconfig  |  1 +
 configs/at91sam9x5ek_dataflash_defconfig  |  1 +
 configs/at91sam9x5ek_mmc_defconfig|  1 +
 configs/at91sam9x5ek_nandflash_defconfig  |  1 +
 configs/at91sam9x5ek_spiflash_defconfig   |  1 +
 configs/at91sam9xeek_dataflash_cs0_defconfig  |  1 +
 configs/at91sam9xeek_dataflash_cs1_defconfig  |  1 +
 configs/at91sam9xeek_nandflash_defconfig  |  1 +
 ...edev_cc_v1_0_ultrazedev_som_v1_0_defconfig |  2 ++
 configs/bayleybay_defconfig   |  1 +
 configs/bitmain_antminer_s9_defconfig |  1 +
 configs/brppt1_mmc_defconfig  |  1 +
 configs/brppt1_nand_defconfig |  1 +
 configs/brppt1_spi_defconfig  |  1 +
 configs/brppt2_defconfig  |  1 +
 configs/brsmarc1_defconfig|  1 +
 configs/brxre1_defconfig  |  1 +
 configs/cherryhill_defconfig  |  1 +
 configs/chromebook_coral_defconfig|  1 +
 configs/chromebook_link64_defconfig   |  1 +
 configs/chromebook_link_defconfig |  1 +
 configs/chromebook_samus_defconfig|  1 +
 configs/chromebox_panther_defconfig   |  1 +
 configs/cobra5272_defconfig   |  1 +
 configs/colibri_pxa270_defconfig  |  1 +
 ...-qeval20-qa3-e3845-internal-uart_defconfig |  1 +
 configs/conga-qeval20-qa3-e3845_defconfig |  1 +
 configs/coreboot64_defconfig  |  1 +
 configs/coreboot_defconfig|  1 +
 configs/cortina_presidio-asic-emmc_defconfig  |  1 +
 configs/corvus_defconfig  |  1 +
 configs/cougarcanyon2_defconfig   |  1 +
 configs/crownbay_defconfig|  1 +
 configs/devkit8000_defconfig  |  2 ++
 configs/dfi-bt700-q7x-151_defconfig   |  1 +
 configs/dragonboard410c_defconfig |  1 +
 configs/dragonboard820c_defconfig |  1 +
 configs/eb_cpu5282_defconfig  |  1 +
 configs/eb_cpu5282_internal_defconfig |  1 +
 configs/efi-x86_payload32_defconfig   |  1 +
 configs/efi-x86_payload64_defconfig   |  1 +
 configs/ethernut5_defconfig   |  1 +
 configs/evb-ast2500_defconfig |  1 +
 configs/evb-ast2600_defconfig |  1 +
 configs/galileo_defconfig |  1 +
 configs/gurnard_defconfig |  1 +
 configs/hikey_defconfig   |  1 +
 configs/ids8313_defconfig |  1 +
 configs/integratorap_cm720t_defconfig |  1 +
 configs/integratorap_cm920t_defconfig |  1 +
 configs/integratorap_cm926ejs_defconfig   |  1 +
 configs/integratorap_cm946es_defconfig|  1 

[PATCH 4/9] Convert CONFIG_BOOTFILE to Kconfig

2022-02-25 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_BOOTFILE

Signed-off-by: Tom Rini 
---
 configs/M5235EVB_Flash32_defconfig  |  2 ++
 configs/M5235EVB_defconfig  |  2 ++
 configs/MPC837XERDB_defconfig   |  2 ++
 configs/MPC8548CDS_36BIT_defconfig  |  2 ++
 configs/MPC8548CDS_defconfig|  2 ++
 configs/MPC8548CDS_legacy_defconfig |  2 ++
 configs/P1010RDB-PA_36BIT_NAND_defconfig|  2 ++
 configs/P1010RDB-PA_36BIT_NOR_defconfig |  2 ++
 configs/P1010RDB-PA_36BIT_SDCARD_defconfig  |  2 ++
 configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig|  2 ++
 configs/P1010RDB-PA_NAND_defconfig  |  2 ++
 configs/P1010RDB-PA_NOR_defconfig   |  2 ++
 configs/P1010RDB-PA_SDCARD_defconfig|  2 ++
 configs/P1010RDB-PA_SPIFLASH_defconfig  |  2 ++
 configs/P1010RDB-PB_36BIT_NAND_defconfig|  2 ++
 configs/P1010RDB-PB_36BIT_NOR_defconfig |  2 ++
 configs/P1010RDB-PB_36BIT_SDCARD_defconfig  |  2 ++
 configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig|  2 ++
 configs/P1010RDB-PB_NAND_defconfig  |  2 ++
 configs/P1010RDB-PB_NOR_defconfig   |  2 ++
 configs/P1010RDB-PB_SDCARD_defconfig|  2 ++
 configs/P1010RDB-PB_SPIFLASH_defconfig  |  2 ++
 configs/P1020RDB-PC_36BIT_NAND_defconfig|  2 ++
 configs/P1020RDB-PC_36BIT_SDCARD_defconfig  |  2 ++
 configs/P1020RDB-PC_36BIT_SPIFLASH_defconfig|  2 ++
 configs/P1020RDB-PC_36BIT_defconfig |  2 ++
 configs/P1020RDB-PC_NAND_defconfig  |  2 ++
 configs/P1020RDB-PC_SDCARD_defconfig|  2 ++
 configs/P1020RDB-PC_SPIFLASH_defconfig  |  2 ++
 configs/P1020RDB-PC_defconfig   |  2 ++
 configs/P1020RDB-PD_NAND_defconfig  |  2 ++
 configs/P1020RDB-PD_SDCARD_defconfig|  2 ++
 configs/P1020RDB-PD_SPIFLASH_defconfig  |  2 ++
 configs/P1020RDB-PD_defconfig   |  2 ++
 configs/P2020RDB-PC_36BIT_NAND_defconfig|  2 ++
 configs/P2020RDB-PC_36BIT_SDCARD_defconfig  |  2 ++
 configs/P2020RDB-PC_36BIT_SPIFLASH_defconfig|  2 ++
 configs/P2020RDB-PC_36BIT_defconfig |  2 ++
 configs/P2020RDB-PC_NAND_defconfig  |  2 ++
 configs/P2020RDB-PC_SDCARD_defconfig|  2 ++
 configs/P2020RDB-PC_SPIFLASH_defconfig  |  2 ++
 configs/P2020RDB-PC_defconfig   |  2 ++
 configs/P2041RDB_NAND_defconfig |  2 ++
 configs/P2041RDB_SDCARD_defconfig   |  2 ++
 configs/P2041RDB_SPIFLASH_defconfig |  2 ++
 configs/P2041RDB_defconfig  |  2 ++
 configs/P3041DS_NAND_defconfig  |  2 ++
 configs/P3041DS_SDCARD_defconfig|  2 ++
 configs/P3041DS_SPIFLASH_defconfig  |  2 ++
 configs/P3041DS_defconfig   |  2 ++
 configs/P4080DS_SDCARD_defconfig|  2 ++
 configs/P4080DS_SPIFLASH_defconfig  |  2 ++
 configs/P4080DS_defconfig   |  2 ++
 configs/P5040DS_NAND_defconfig  |  2 ++
 configs/P5040DS_SDCARD_defconfig|  2 ++
 configs/P5040DS_SPIFLASH_defconfig  |  2 ++
 configs/P5040DS_defconfig   |  2 ++
 configs/T1024RDB_NAND_defconfig |  2 ++
 configs/T1024RDB_SDCARD_defconfig   |  2 ++
 configs/T1024RDB_SPIFLASH_defconfig |  2 ++
 configs/T1024RDB_defconfig  |  2 ++
 configs/T1042D4RDB_NAND_defconfig   |  2 ++
 configs/T1042D4RDB_SDCARD_defconfig |  2 ++
 configs/T1042D4RDB_SPIFLASH_defconfig   |  2 ++
 configs/T1042D4RDB_defconfig|  2 ++
 configs/T2080QDS_NAND_defconfig |  2 ++
 configs/T2080QDS_SDCARD_defconfig   |  2 ++
 configs/T2080QDS_SECURE_BOOT_defconfig  |  2 ++
 configs/T2080QDS_SPIFLASH_defconfig |  2 ++
 configs/T2080QDS_SRIO_PCIE_BOOT_defconfig   |  2 ++
 configs/T2080QDS_defconfig  |  2 ++
 configs/T2080RDB_NAND_defconfig |  2 ++
 configs/T2080RDB_SDCARD_defconfig   |  2 ++
 configs/T2080RDB_SPIFLASH_defconfig |  2 ++
 configs/T2080RDB_defconfig  |  2 ++
 configs/T2080RDB_revD_NAND_defconfig|  2 ++
 configs/T2080RDB_revD_SDCARD_defconfig  |  2 ++
 configs/T2080RDB_revD_SPIFLASH_defconfig|  2 ++
 configs/T2080RDB_revD_defconfig |  2 ++
 configs/T4240RDB_SDCARD_defconfig   |  2 ++
 configs/T4240RDB_defconfig   

[PATCH 8/9] Convert CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS to Kconfig

2022-02-25 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS

Signed-off-by: Tom Rini 
---
 configs/blanche_defconfig   | 1 +
 configs/ls1021aqds_ddr4_nor_defconfig   | 1 +
 configs/ls1021aqds_ddr4_nor_lpuart_defconfig| 1 +
 configs/ls1021aqds_nand_defconfig   | 1 +
 configs/ls1021aqds_nor_SECURE_BOOT_defconfig| 1 +
 configs/ls1021aqds_nor_defconfig| 1 +
 configs/ls1021aqds_nor_lpuart_defconfig | 1 +
 configs/ls1021aqds_sdcard_ifc_defconfig | 1 +
 configs/ls1021atwr_nor_SECURE_BOOT_defconfig| 1 +
 configs/ls1021atwr_nor_defconfig| 1 +
 configs/ls1021atwr_nor_lpuart_defconfig | 1 +
 configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig | 1 +
 configs/ls1021atwr_sdcard_ifc_defconfig | 1 +
 configs/ls1043aqds_defconfig| 1 +
 configs/ls1043aqds_lpuart_defconfig | 1 +
 configs/ls1043aqds_nand_defconfig   | 1 +
 configs/ls1043aqds_nor_ddr3_defconfig   | 1 +
 configs/ls1043aqds_sdcard_ifc_defconfig | 1 +
 configs/ls1043aqds_tfa_SECURE_BOOT_defconfig| 1 +
 configs/ls1043aqds_tfa_defconfig| 1 +
 configs/ls1043ardb_SECURE_BOOT_defconfig| 1 +
 configs/ls1043ardb_defconfig| 1 +
 configs/ls1043ardb_nand_SECURE_BOOT_defconfig   | 1 +
 configs/ls1043ardb_nand_defconfig   | 1 +
 configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig | 1 +
 configs/ls1043ardb_sdcard_defconfig | 1 +
 configs/ls1043ardb_tfa_SECURE_BOOT_defconfig| 1 +
 configs/ls1043ardb_tfa_defconfig| 1 +
 configs/ls1046aqds_SECURE_BOOT_defconfig| 1 +
 configs/ls1046aqds_defconfig| 1 +
 configs/ls1046aqds_lpuart_defconfig | 1 +
 configs/ls1046aqds_nand_defconfig   | 1 +
 configs/ls1046aqds_sdcard_ifc_defconfig | 1 +
 configs/ls1046aqds_tfa_SECURE_BOOT_defconfig| 1 +
 configs/ls1046aqds_tfa_defconfig| 1 +
 configs/pg_wcom_expu1_defconfig | 1 +
 configs/pg_wcom_expu1_update_defconfig  | 1 +
 configs/pg_wcom_seli8_defconfig | 1 +
 configs/pg_wcom_seli8_update_defconfig  | 1 +
 configs/qemu_arm64_defconfig| 1 +
 configs/qemu_arm_defconfig  | 1 +
 configs/r8a77990_ebisu_defconfig| 1 +
 configs/r8a77995_draak_defconfig| 1 +
 configs/rcar3_salvator-x_defconfig  | 1 +
 configs/rcar3_ulcb_defconfig| 1 +
 drivers/mtd/Kconfig | 7 +++
 include/configs/T102xRDB.h  | 1 -
 include/configs/blanche.h   | 1 -
 include/configs/draak.h | 1 -
 include/configs/ebisu.h | 1 -
 include/configs/km/pg-wcom-ls102xa.h| 1 -
 include/configs/ls1021aqds.h| 1 -
 include/configs/ls1021atwr.h| 1 -
 include/configs/ls1043aqds.h| 1 -
 include/configs/ls1043ardb.h| 1 -
 include/configs/ls1046aqds.h| 1 -
 include/configs/qemu-arm.h  | 1 -
 include/configs/salvator-x.h| 1 -
 include/configs/ulcb.h  | 1 -
 59 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/configs/blanche_defconfig b/configs/blanche_defconfig
index 1e117c9e8f4c..82d54debb3db 100644
--- a/configs/blanche_defconfig
+++ b/configs/blanche_defconfig
@@ -53,6 +53,7 @@ CONFIG_RENESAS_SDHI=y
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_FLASH_CFI_DRIVER=y
+CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS=y
 CONFIG_SYS_FLASH_CFI=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_SPANSION=y
diff --git a/configs/ls1021aqds_ddr4_nor_defconfig 
b/configs/ls1021aqds_ddr4_nor_defconfig
index 925d68db8e1e..1bc73dbc7108 100644
--- a/configs/ls1021aqds_ddr4_nor_defconfig
+++ b/configs/ls1021aqds_ddr4_nor_defconfig
@@ -65,6 +65,7 @@ CONFIG_FSL_ESDHC=y
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_FLASH_CFI_DRIVER=y
+CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_CFI=y
 CONFIG_SYS_MAX_FLASH_BANKS=2
diff --git a/configs/ls1021aqds_ddr4_nor_lpuart_defconfig 
b/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
index c71c8649d92e..2a3348f7ef01 100644
--- a/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
+++ b/configs/ls1021aqds_ddr4_nor_lpuart_defconfig
@@ -66,6 +66,7 @@ CONFIG_FSL_ESDHC=y
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_FLASH_CFI_DRIVER=y
+CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_CFI=y
 CONFIG_SYS_MAX_FLASH_BANKS=2
diff --git 

[PATCH 9/9] Convert CONFIG_CHIP_SELECTS_PER_CTRL to Kconfig

2022-02-25 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_CHIP_SELECTS_PER_CTRL

Cc: Alison Wang 
Cc: Pramod Kumar 
Cc: Priyanka Jain 
Cc: Rajesh Bhagat 
Cc: Vladimir Oltean 
Signed-off-by: Tom Rini 
---
 arch/arm/cpu/armv7/ls102xa/Kconfig   | 2 +-
 arch/arm/cpu/armv7/ls102xa/soc.c | 2 ++
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c  | 4 +++-
 configs/MPC8548CDS_36BIT_defconfig   | 1 +
 configs/MPC8548CDS_defconfig | 1 +
 configs/MPC8548CDS_legacy_defconfig  | 1 +
 configs/P1010RDB-PA_36BIT_NAND_defconfig | 1 +
 configs/P1010RDB-PA_36BIT_NOR_defconfig  | 1 +
 configs/P1010RDB-PA_36BIT_SDCARD_defconfig   | 1 +
 configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig | 1 +
 configs/P1010RDB-PA_NAND_defconfig   | 1 +
 configs/P1010RDB-PA_NOR_defconfig| 1 +
 configs/P1010RDB-PA_SDCARD_defconfig | 1 +
 configs/P1010RDB-PA_SPIFLASH_defconfig   | 1 +
 configs/P1010RDB-PB_36BIT_NAND_defconfig | 1 +
 configs/P1010RDB-PB_36BIT_NOR_defconfig  | 1 +
 configs/P1010RDB-PB_36BIT_SDCARD_defconfig   | 1 +
 configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig | 1 +
 configs/P1010RDB-PB_NAND_defconfig   | 1 +
 configs/P1010RDB-PB_NOR_defconfig| 1 +
 configs/P1010RDB-PB_SDCARD_defconfig | 1 +
 configs/P1010RDB-PB_SPIFLASH_defconfig   | 1 +
 configs/P1020RDB-PC_36BIT_NAND_defconfig | 1 +
 configs/P1020RDB-PC_36BIT_SDCARD_defconfig   | 1 +
 configs/P1020RDB-PC_36BIT_SPIFLASH_defconfig | 1 +
 configs/P1020RDB-PC_36BIT_defconfig  | 1 +
 configs/P1020RDB-PC_NAND_defconfig   | 1 +
 configs/P1020RDB-PC_SDCARD_defconfig | 1 +
 configs/P1020RDB-PC_SPIFLASH_defconfig   | 1 +
 configs/P1020RDB-PC_defconfig| 1 +
 configs/P1020RDB-PD_NAND_defconfig   | 1 +
 configs/P1020RDB-PD_SDCARD_defconfig | 1 +
 configs/P1020RDB-PD_SPIFLASH_defconfig   | 1 +
 configs/P1020RDB-PD_defconfig| 1 +
 configs/P2020RDB-PC_36BIT_NAND_defconfig | 1 +
 configs/P2020RDB-PC_36BIT_SDCARD_defconfig   | 1 +
 configs/P2020RDB-PC_36BIT_SPIFLASH_defconfig | 1 +
 configs/P2020RDB-PC_36BIT_defconfig  | 1 +
 configs/P2020RDB-PC_NAND_defconfig   | 1 +
 configs/P2020RDB-PC_SDCARD_defconfig | 1 +
 configs/P2020RDB-PC_SPIFLASH_defconfig   | 1 +
 configs/P2020RDB-PC_defconfig| 1 +
 configs/T1042D4RDB_NAND_defconfig| 1 +
 configs/T1042D4RDB_SDCARD_defconfig  | 1 +
 configs/T1042D4RDB_SPIFLASH_defconfig| 1 +
 configs/T1042D4RDB_defconfig | 1 +
 configs/kmcent2_defconfig| 1 +
 configs/qemu-ppce500_defconfig   | 1 +
 configs/socrates_defconfig   | 1 +
 drivers/ddr/fsl/Kconfig  | 4 
 include/configs/MPC8548CDS.h | 1 -
 include/configs/P1010RDB.h   | 1 -
 include/configs/P2041RDB.h   | 1 -
 include/configs/T102xRDB.h   | 1 -
 include/configs/T104xRDB.h   | 1 -
 include/configs/T208xQDS.h   | 1 -
 include/configs/T208xRDB.h   | 1 -
 include/configs/T4240RDB.h   | 1 -
 include/configs/corenet_ds.h | 1 -
 include/configs/km/pg-wcom-ls102xa.h | 1 -
 include/configs/kmcent2.h| 1 -
 include/configs/kontron_sl28.h   | 1 -
 include/configs/ls1012a2g5rdb.h  | 1 -
 include/configs/ls1012afrdm.h| 2 --
 include/configs/ls1012afrwy.h| 2 --
 include/configs/ls1012aqds.h | 1 -
 include/configs/ls1012ardb.h | 1 -
 include/configs/ls1021aiot.h | 2 --
 include/configs/ls1021aqds.h | 1 -
 include/configs/ls1021atsn.h | 2 --
 include/configs/ls1021atwr.h | 2 --
 include/configs/ls1028a_common.h | 1 -
 include/configs/ls1043aqds.h | 1 -
 include/configs/ls1043ardb.h | 1 -
 include/configs/ls1046afrwy.h| 1 -
 include/configs/ls1046aqds.h | 1 -
 include/configs/ls1046ardb.h | 1 -
 include/configs/ls1088a_common.h | 1 -
 include/configs/ls2080a_common.h | 1 -
 include/configs/ls2080aqds.h | 1 -
 include/configs/ls2080ardb.h | 1 -
 include/configs/lx2160a_common.h | 1 -
 include/configs/p1_p2_rdb_pc.h   | 2 --
 include/configs/qemu-ppce500.h   | 2 --
 include/configs/socrates.h   | 1 -
 85 files changed, 56 insertions(+), 44 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/Kconfig 
b/arch/arm/cpu/armv7/ls102xa/Kconfig
index 6a948d7ba7f4..ef1f45650f3e 100644
--- a/arch/arm/cpu/armv7/ls102xa/Kconfig
+++ b/arch/arm/cpu/armv7/ls102xa/Kconfig
@@ -5,7 +5,7 @@ config ARCH_LS1021A
select SYS_FSL_DDR_VER_50 if SYS_FSL_DDR
select 

[PATCH 5/9] powerpc: P1010RDB: Move CONFIG_BOOTMODE out of CONFIG namespace

2022-02-25 Thread Tom Rini
This slight environment modification shouldn't be in the CONFIG
namespace, change it.

Signed-off-by: Tom Rini 
---
 include/configs/P1010RDB.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h
index a5df554edf7b..a9c4930d770a 100644
--- a/include/configs/P1010RDB.h
+++ b/include/configs/P1010RDB.h
@@ -641,10 +641,10 @@ extern unsigned long get_sdram_size(void);
"ext2load usb 0:4 $fdtaddr $fdtfile;"   \
"ext2load usb 0:4 $ramdiskaddr $ramdiskfile;"   \
"bootm $loadaddr $ramdiskaddr $fdtaddr\0"   \
-   CONFIG_BOOTMODE
+   BOOTMODE
 
 #if defined(CONFIG_TARGET_P1010RDB_PA)
-#define CONFIG_BOOTMODE \
+#define BOOTMODE \
"boot_bank0=i2c dev 0; i2c mw 18 1 f1; i2c mw 18 3 f0;" \
"mw.b ffb00011 0; mw.b ffb9 0; reset\0" \
"boot_bank1=i2c dev 0; i2c mw 18 1 f1; i2c mw 18 3 f0;" \
@@ -653,7 +653,7 @@ extern unsigned long get_sdram_size(void);
"mw.b ffb00011 0; mw.b ffb00017 1; reset\0"
 
 #elif defined(CONFIG_TARGET_P1010RDB_PB)
-#define CONFIG_BOOTMODE \
+#define BOOTMODE \
"boot_bank0=i2c dev 0; i2c mw 18 1 fe; i2c mw 18 3 0;" \
"i2c mw 19 1 2; i2c mw 19 3 e1; reset\0" \
"boot_bank1=i2c dev 0; i2c mw 18 1 fe; i2c mw 18 3 0;" \
-- 
2.25.1



[PATCH 7/9] net: Remove CONFIG_BOOTP_DHCP_REQUEST_DELAY

2022-02-25 Thread Tom Rini
This option is not in use anywhere and the documentation implies it's
for some very old and unlikely to be seen currently issues.  Rather than
update the code so the CONFIG symbol could be easily in Kconfig, remove
the code.

Cc: Ramon Fried 
Signed-off-by: Tom Rini 
---
 README  | 14 --
 net/bootp.c |  3 ---
 2 files changed, 17 deletions(-)

diff --git a/README b/README
index e7b2f83651c3..6bb8d6e25bdc 100644
--- a/README
+++ b/README
@@ -1173,20 +1173,6 @@ The following options need to be configured:
 
 - DHCP Advanced Options:
 
-   CONFIG_BOOTP_DHCP_REQUEST_DELAY
-
-   A 32bit value in microseconds for a delay between
-   receiving a "DHCP Offer" and sending the "DHCP Request".
-   This fixes a problem with certain DHCP servers that don't
-   respond 100% of the time to a "DHCP request". E.g. On an
-   AT91RM9200 processor running at 180MHz, this delay needed
-   to be *at least* 15,000 usec before a Windows Server 2003
-   DHCP server would reply 100% of the time. I recommend at
-   least 50,000 usec to be safe. The alternative is to hope
-   that one of the retries will be successful but note that
-   the DHCP timeout and retry process takes a longer than
-   this delay.
-
  - Link-local IP address negotiation:
Negotiate with other link-local clients on the local network
for an address that doesn't require explicit configuration.
diff --git a/net/bootp.c b/net/bootp.c
index d83e4eb0ba9e..a896e1e5b546 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -1038,9 +1038,6 @@ static void dhcp_send_request_packet(struct bootp_hdr 
*bp_offer)
bcast_ip.s_addr = 0xL;
net_set_udp_header(iphdr, bcast_ip, PORT_BOOTPS, PORT_BOOTPC, iplen);
 
-#ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY
-   udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY);
-#endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */
debug("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
net_send_packet(net_tx_packet, pktlen);
 }
-- 
2.25.1



[PATCH 3/9] Convert CONFIG_BOARD_POSTCLK_INIT to Kconfig

2022-02-25 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_BOARD_POSTCLK_INIT

Signed-off-by: Tom Rini 
---
 README   | 1 -
 arch/arm/Kconfig | 2 ++
 arch/xtensa/Kconfig  | 1 +
 common/Kconfig   | 6 ++
 include/configs/brppt2.h | 1 -
 include/configs/mx6_common.h | 1 -
 include/configs/mx7ulp_com.h | 1 -
 include/configs/mx7ulp_evk.h | 1 -
 include/configs/xtfpga.h | 2 --
 9 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/README b/README
index f51f392111f9..5d2c1baec512 100644
--- a/README
+++ b/README
@@ -1972,7 +1972,6 @@ typically in board_init_f() and board_init_r().
 - CONFIG_BOARD_EARLY_INIT_F: Call board_early_init_f()
 - CONFIG_BOARD_EARLY_INIT_R: Call board_early_init_r()
 - CONFIG_BOARD_LATE_INIT: Call board_late_init()
-- CONFIG_BOARD_POSTCLK_INIT: Call board_postclk_init()
 
 Configuration Settings:
 ---
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 391a77c2b44e..06a540d965da 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -869,6 +869,7 @@ config ARCH_MX31
 
 config ARCH_MX7ULP
bool "NXP MX7ULP"
+   select BOARD_POSTCLK_INIT
select CPU_V7A
select GPIO_EXTRA_HEADER
select MACH_IMX
@@ -894,6 +895,7 @@ config ARCH_MX7
 
 config ARCH_MX6
bool "Freescale MX6"
+   select BOARD_POSTCLK_INIT
select CPU_V7A
select GPIO_EXTRA_HEADER
select MACH_IMX
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 35e5b89dda04..8f668cc67ed0 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -13,6 +13,7 @@ choice
 
 config TARGET_XTFPGA
bool "Support XTFPGA"
+   select BOARD_POSTCLK_INIT
 
 endchoice
 
diff --git a/common/Kconfig b/common/Kconfig
index 82cd864baf93..add4cdae0282 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -524,6 +524,12 @@ config BOARD_EARLY_INIT_R
  relocation. With this option, U-Boot calls board_early_init_r()
  in the post-relocation init sequence.
 
+config BOARD_POSTCLK_INIT
+   bool "Call board_postclk_init"
+   help
+ Some boards need this to initialize select items, after clocks /
+ timebase and before env / serial.
+
 config BOARD_LATE_INIT
bool "Execute Board late init"
help
diff --git a/include/configs/brppt2.h b/include/configs/brppt2.h
index 7ab7f559e3ed..612999fbabe3 100644
--- a/include/configs/brppt2.h
+++ b/include/configs/brppt2.h
@@ -17,7 +17,6 @@
 #define CONFIG_SYS_PL310_BASE  L2_PL310_BASE
 #endif /* !CONFIG_SYS_L2CACHE_OFF */
 
-#define CONFIG_BOARD_POSTCLK_INIT
 #define CONFIG_MXC_GPT_HCLK
 
 /* MMC */
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h
index 5ff931ee3bc9..a0e481703bcb 100644
--- a/include/configs/mx6_common.h
+++ b/include/configs/mx6_common.h
@@ -18,7 +18,6 @@
 #endif
 
 #endif
-#define CONFIG_BOARD_POSTCLK_INIT
 #define CONFIG_MXC_GPT_HCLK
 
 #define CONFIG_SYS_BOOTM_LEN   0x100
diff --git a/include/configs/mx7ulp_com.h b/include/configs/mx7ulp_com.h
index 75f5cf0b6de3..319de9b01429 100644
--- a/include/configs/mx7ulp_com.h
+++ b/include/configs/mx7ulp_com.h
@@ -15,7 +15,6 @@
 #include "imx7ulp_spl.h"
 #endif
 
-#define CONFIG_BOARD_POSTCLK_INIT
 #define CONFIG_SYS_BOOTM_LEN   0x100
 
 /*
diff --git a/include/configs/mx7ulp_evk.h b/include/configs/mx7ulp_evk.h
index 8f2cbc643eec..e80d748d991b 100644
--- a/include/configs/mx7ulp_evk.h
+++ b/include/configs/mx7ulp_evk.h
@@ -11,7 +11,6 @@
 #include 
 #include 
 
-#define CONFIG_BOARD_POSTCLK_INIT
 #define CONFIG_SYS_BOOTM_LEN   0x100
 
 #define CONFIG_MMCROOT  "/dev/mmcblk0p2"  /* USDHC1 */
diff --git a/include/configs/xtfpga.h b/include/configs/xtfpga.h
index 8c2cdb5cbdd8..038dd775312f 100644
--- a/include/configs/xtfpga.h
+++ b/include/configs/xtfpga.h
@@ -97,8 +97,6 @@
 /* U-Boot general configuration */
 /*==*/
 
-#define CONFIG_BOARD_POSTCLK_INIT
-
 #define CONFIG_BOOTFILE"uImage"
/* Console I/O Buffer Size  */
 #define CONFIG_SYS_CBSIZE  1024
-- 
2.25.1



[PATCH 1/9] Convert CONFIG_BIOSEMU to Kconfig

2022-02-25 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_BIOSEMU

Cc: Simon Glass 
Signed-off-by: Tom Rini 
---
 board/google/Kconfig   | 7 +++
 include/configs/chromebook_samus.h | 3 ---
 include/configs/x86-chromebook.h   | 1 -
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/board/google/Kconfig b/board/google/Kconfig
index 22c4be392f7e..c57e518c33fe 100644
--- a/board/google/Kconfig
+++ b/board/google/Kconfig
@@ -4,12 +4,16 @@
 
 if VENDOR_GOOGLE
 
+config BIOSEMU
+   bool
+
 choice
prompt "Mainboard model"
optional
 
 config TARGET_CHROMEBOOK_CORAL
bool "Chromebook coral"
+   select BIOSEMU
help
  This is a range of Intel-based laptops released in 2018. They use an
  Intel Apollo Lake SoC. The design supports WiFi, 4GB to 16GB of
@@ -24,6 +28,7 @@ config TARGET_CHROMEBOOK_CORAL
 
 config TARGET_CHROMEBOOK_LINK
bool "Chromebook link"
+   select BIOSEMU
help
  This is the Chromebook Pixel released in 2013. It uses an Intel
  i5 Ivybridge which is a die-shrink of Sandybridge, with 4GB of
@@ -36,6 +41,7 @@ config TARGET_CHROMEBOOK_LINK
 
 config TARGET_CHROMEBOOK_LINK64
bool "Chromebook link 64-bit"
+   select BIOSEMU
help
  This is the Chromebook Pixel released in 2013. With this config
  U-Boot is built as a 64-bit binary. This allows testing while this
@@ -43,6 +49,7 @@ config TARGET_CHROMEBOOK_LINK64
 
 config TARGET_CHROMEBOX_PANTHER
bool "Chromebox panther (not available)"
+   select BIOSEMU
help
  Note: At present this must be used with coreboot. See README.x86
  for instructions.
diff --git a/include/configs/chromebook_samus.h 
b/include/configs/chromebook_samus.h
index 9d5a63cabaab..e29be3fda4ac 100644
--- a/include/configs/chromebook_samus.h
+++ b/include/configs/chromebook_samus.h
@@ -15,9 +15,6 @@
 #include 
 #include 
 
-/* We can rely on running natively, and this saves code size */
-#undef CONFIG_BIOSEMU
-
 #undef CONFIG_STD_DEVICES_SETTINGS
 #define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,i8042-kbd,serial\0" \
"stdout=vidconsole,serial\0" \
diff --git a/include/configs/x86-chromebook.h b/include/configs/x86-chromebook.h
index 0efc7156a6dd..b45d2bbd6266 100644
--- a/include/configs/x86-chromebook.h
+++ b/include/configs/x86-chromebook.h
@@ -24,7 +24,6 @@
 #define CONFIG_PCI_IO_PHYS CONFIG_PCI_IO_BUS
 #define CONFIG_PCI_IO_SIZE 0xefff
 
-#define CONFIG_BIOSEMU
 #define VIDEO_IO_OFFSET0
 #define CONFIG_X86EMU_RAW_IO
 
-- 
2.25.1



[PATCH 2/9] Convert CONFIG_BOARD_ECC_SUPPORT to Kconfig

2022-02-25 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_BOARD_ECC_SUPPORT

Signed-off-by: Tom Rini 
---
 arch/arm/mach-mvebu/Kconfig | 5 +
 include/configs/db-mv784mp-gp.h | 1 -
 include/configs/maxbcm.h| 1 -
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 7d487f270b51..e17a55a44261 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -152,6 +152,7 @@ config TARGET_OCTEONTX2_CN913x
 
 config TARGET_DB_MV784MP_GP
bool "Support db-mv784mp-gp"
+   select BOARD_ECC_SUPPORT
select MV78460
 
 config TARGET_DS414
@@ -160,6 +161,7 @@ config TARGET_DS414
 
 config TARGET_MAXBCM
bool "Support maxbcm"
+   select BOARD_ECC_SUPPORT
select MV78460
 
 config TARGET_THEADORABLE
@@ -226,6 +228,9 @@ config DDR_RESET_ON_TRAINING_FAILURE
  device will still hang - it doesn't make sense to reset the board
  in such a case.
 
+config BOARD_ECC_SUPPORT
+   bool
+
 config SYS_BOARD
default "clearfog" if TARGET_CLEARFOG
default "helios4" if TARGET_HELIOS4
diff --git a/include/configs/db-mv784mp-gp.h b/include/configs/db-mv784mp-gp.h
index 7baae3b090d8..41d469d79526 100644
--- a/include/configs/db-mv784mp-gp.h
+++ b/include/configs/db-mv784mp-gp.h
@@ -72,6 +72,5 @@
 
 /* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */
 #define CONFIG_SPD_EEPROM  0x4e
-#define CONFIG_BOARD_ECC_SUPPORT   /* this board supports ECC */
 
 #endif /* _CONFIG_DB_MV7846MP_GP_H */
diff --git a/include/configs/maxbcm.h b/include/configs/maxbcm.h
index 073c5a57b2c9..e4df9d8dfff3 100644
--- a/include/configs/maxbcm.h
+++ b/include/configs/maxbcm.h
@@ -64,6 +64,5 @@
 
 /* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */
 #define CONFIG_SYS_SDRAM_SIZE  SZ_1G
-#define CONFIG_BOARD_ECC_SUPPORT   /* this board supports ECC */
 
 #endif /* _CONFIG_DB_MV7846MP_GP_H */
-- 
2.25.1



Re: [PATCH 07/10] tpm: rng: Move the TPM RNG functionality to driver model

2022-02-25 Thread Ilias Apalodimas
On Thu, Feb 24, 2022 at 11:35:49PM +0530, Sughosh Ganu wrote:
> Currently, the TPM random number generator(RNG) functions are defined
> as part of the library functions under the corresponding tpm files for
> tpmv1 and tpmv2. Move the RNG functionality under TPM RNG drivers
> complying with the driver model.
> 
> Also make changes to the tpm_get_random function to have it call the
> TPM RNG driver functions instead of the library functions.
> 
> Signed-off-by: Sughosh Ganu 
> ---
>  drivers/rng/Makefile   |  1 +
>  drivers/rng/tpm1_rng.c | 68 ++
>  drivers/rng/tpm2_rng.c | 68 ++
>  lib/tpm-v1.c   | 44 ---
>  lib/tpm-v2.c   | 44 ---
>  lib/tpm_api.c  | 28 +
>  6 files changed, 160 insertions(+), 93 deletions(-)
>  create mode 100644 drivers/rng/tpm1_rng.c
>  create mode 100644 drivers/rng/tpm2_rng.c
> 
> diff --git a/drivers/rng/Makefile b/drivers/rng/Makefile
> index 39f7ee3f03..129cfbd006 100644
> --- a/drivers/rng/Makefile
> +++ b/drivers/rng/Makefile
> @@ -10,3 +10,4 @@ obj-$(CONFIG_RNG_MSM) += msm_rng.o
>  obj-$(CONFIG_RNG_STM32MP1) += stm32mp1_rng.o
>  obj-$(CONFIG_RNG_ROCKCHIP) += rockchip_rng.o
>  obj-$(CONFIG_RNG_IPROC200) += iproc_rng200.o
> +obj-$(CONFIG_TPM) += tpm1_rng.o tpm2_rng.o
> diff --git a/drivers/rng/tpm1_rng.c b/drivers/rng/tpm1_rng.c
> new file mode 100644
> index 00..ddb20b008d
> --- /dev/null
> +++ b/drivers/rng/tpm1_rng.c
> @@ -0,0 +1,68 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2022, Linaro Limited

As  I understand part of this code was moved around.  If so we need to keep
the original copyright as well

> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define TPM_HEADER_SIZE  10
> +
> +#define TPMV1_DATA_OFFSET14
> +
> +static int tpm1_rng_read(struct udevice *dev, void *data, size_t count)
> +{
> + const u8 command[14] = {
> + 0x0, 0xc1,  /* TPM_TAG */
> + 0x0, 0x0, 0x0, 0xe, /* parameter size */
> + 0x0, 0x0, 0x0, 0x46,/* TPM_COMMAND_CODE */
> + };
> + const size_t length_offset = TPM_HEADER_SIZE;
> + const size_t data_size_offset = TPM_HEADER_SIZE;
> + const size_t data_offset = TPMV1_DATA_OFFSET;
> + u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
> + size_t response_length = sizeof(response);
> + u32 data_size;
> + u8 *out = data;
> +
> + while (count > 0) {
> + u32 this_bytes = min(count,
> +  sizeof(response) - data_offset);
> + u32 err;
> +
> + if (pack_byte_string(buf, sizeof(buf), "sd",
> +  0, command, sizeof(command),
> +  length_offset, this_bytes))
> + return TPM_LIB_ERROR;
> + err = tpm_sendrecv_command(dev->parent, buf, response,
> +_length);
> + if (err)
> + return err;
> + if (unpack_byte_string(response, response_length, "d",
> +data_size_offset, _size))
> + return TPM_LIB_ERROR;
> + if (data_size > count)
> + return TPM_LIB_ERROR;
> + if (unpack_byte_string(response, response_length, "s",
> +data_offset, out, data_size))
> + return TPM_LIB_ERROR;
> +
> + count -= data_size;
> + out += data_size;
> + }
> +
> + return 0;
> +}
> +
> +static const struct dm_rng_ops tpm1_rng_ops = {
> + .read = tpm1_rng_read,
> +};
> +
> +U_BOOT_DRIVER(tpm1_rng) = {
> + .name   = "tpm1-rng",
> + .id = UCLASS_RNG,
> + .ops= _rng_ops,
> +};
> diff --git a/drivers/rng/tpm2_rng.c b/drivers/rng/tpm2_rng.c
> new file mode 100644
> index 00..f14528f751
> --- /dev/null
> +++ b/drivers/rng/tpm2_rng.c
> @@ -0,0 +1,68 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2022, Linaro Limited
> + */
> +

ditto 

> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define TPM_HEADER_SIZE  10
> +
> +#define TPMV2_DATA_OFFSET12
> +
> +static int tpm2_rng_read(struct udevice *dev, void *data, size_t count)
> +{
> + const u8 command_v2[10] = {
> + tpm_u16(TPM2_ST_NO_SESSIONS),
> + tpm_u32(12),
> + tpm_u32(TPM2_CC_GET_RANDOM),
> + };
> + u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
> +
> + const size_t data_size_offset = TPM_HEADER_SIZE;
> + const size_t data_offset = TPMV2_DATA_OFFSET;
> + size_t response_length = sizeof(response);
> + u32 data_size;
> + u8 *out = data;
> +
> + while (count > 0) {
> + u32 

Re: [PATCH 02/10] tpm: rng: Change tpm_get_random to return an int

2022-02-25 Thread Ilias Apalodimas
On Thu, 24 Feb 2022 at 20:06, Sughosh Ganu  wrote:
>
> The tpm random number generation functionality will be moved to the
> driver model. With that, the tpm_get_random function will call the
> common driver model api instead of separate functions for tpmv1 and
> tpmv2. Return an int instead of a u32 to comply with the return value
> of the driver model function.
>
> Signed-off-by: Sughosh Ganu 
> ---
>  include/tpm_api.h | 4 ++--
>  lib/tpm_api.c | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/tpm_api.h b/include/tpm_api.h
> index ef45b43a8f..b9e3e8b5e6 100644
> --- a/include/tpm_api.h
> +++ b/include/tpm_api.h
> @@ -274,9 +274,9 @@ u32 tpm_find_key_sha1(struct udevice *dev, const u8 
> auth[20],
>   * @param dev  TPM device
>   * @param data output buffer for the random bytes
>   * @param countsize of output buffer
> - * Return: return code of the operation
> + * Return: 0 if OK, -ve on error
>   */
> -u32 tpm_get_random(struct udevice *dev, void *data, u32 count);
> +int tpm_get_random(struct udevice *dev, void *data, u32 count);
>
>  /**
>   * tpm_finalise_physical_presence() - Finalise physical presence
> diff --git a/lib/tpm_api.c b/lib/tpm_api.c
> index 4c662640a9..1bbe33a3fc 100644
> --- a/lib/tpm_api.c
> +++ b/lib/tpm_api.c
> @@ -274,7 +274,7 @@ u32 tpm_get_permissions(struct udevice *dev, u32 index, 
> u32 *perm)
> return -ENOSYS;
>  }
>
> -u32 tpm_get_random(struct udevice *dev, void *data, u32 count)
> +int tpm_get_random(struct udevice *dev, void *data, u32 count)
>  {
> if (is_tpm1(dev))
> return tpm1_get_random(dev, data, count);
> --
> 2.17.1
>

Reviewed-by: Ilias Apalodimas 


Re: [PATCH 01/10] tpm: Move tpm-utils header under the include directory

2022-02-25 Thread Ilias Apalodimas
On Thu, Feb 24, 2022 at 11:35:43PM +0530, Sughosh Ganu wrote:
> The random number generation functions of TPM will be moved under a
> dedicated driver. With this, the function declarations along with
> some other relevant macro definitions need to be moved under a
> common header file directory. Move the tpm-utils.h header file under
> the common include directory.
> 
> Signed-off-by: Sughosh Ganu 
> ---
>  {lib => include}/tpm-utils.h | 0
>  lib/tpm-common.c | 2 +-
>  lib/tpm-v1.c | 2 +-
>  lib/tpm-v2.c | 2 +-
>  4 files changed, 3 insertions(+), 3 deletions(-)
>  rename {lib => include}/tpm-utils.h (100%)
> 
> diff --git a/lib/tpm-utils.h b/include/tpm-utils.h
> similarity index 100%
> rename from lib/tpm-utils.h
> rename to include/tpm-utils.h
> diff --git a/lib/tpm-common.c b/lib/tpm-common.c
> index 82ffdc5341..26506f0b99 100644
> --- a/lib/tpm-common.c
> +++ b/lib/tpm-common.c
> @@ -11,7 +11,7 @@
>  #include 
>  #include 
>  #include 
> -#include "tpm-utils.h"
> +#include 
>  
>  enum tpm_version tpm_get_version(struct udevice *dev)
>  {
> diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c
> index 22a769c587..467992e04e 100644
> --- a/lib/tpm-v1.c
> +++ b/lib/tpm-v1.c
> @@ -13,7 +13,7 @@
>  #include 
>  #include 
>  #include 
> -#include "tpm-utils.h"
> +#include 
>  
>  #ifdef CONFIG_TPM_AUTH_SESSIONS
>  
> diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
> index 1bf627853a..2f16b0007b 100644
> --- a/lib/tpm-v2.c
> +++ b/lib/tpm-v2.c
> @@ -9,7 +9,7 @@
>  #include 
>  #include 
>  #include 
> -#include "tpm-utils.h"
> +#include 
>  
>  u32 tpm2_startup(struct udevice *dev, enum tpm2_startup_types mode)
>  {
> -- 
> 2.17.1
> 

Reviewed-by: Ilias Apalodimas 


Re: [PATCH v3] scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

2022-02-25 Thread Heinrich Schuchardt

On 2/25/22 13:33, Heiko Thiery wrote:

Hi,

Am Di., 22. Feb. 2022 um 14:55 Uhr schrieb Philippe Reynes
:


There is a conflict between the static file
lib/acpi/dsdt.c and the file dsdt.c generated
dynamicaly by scripts/Makefile.lib. When a
mrproper is done, the static file dsdt.c is
removed. If a build with acpi enabled is
launched after, the following error is raised:

   CC  lib/acpi/acpi_table.o
make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
'lib/acpi/dsdt.c'.  Stop.
scripts/Makefile.build:394: recipe for target 'lib/acpi' failed

To avoid such error, the generated file is named
dsdt_generated.c instead of dstdt.c.


This issue can also be seen when doing a make clean and do a git status

-- 8< --
Changes not staged for commit:
   (use "git add/rm ..." to update what will be committed)
   (use "git restore ..." to discard changes in working directory)
deleted:lib/acpi/dsdt.c
-- 8< --

After applying this patch this cannot be seen anymore.




Signed-off-by: Philippe Reynes 


Tested-by: Heiko Thiery 


The patch should update the .gitignore entries:

board/advantech/som-db5800-som-6867/.gitignore:1:dsdt.aml
board/advantech/som-db5800-som-6867/.gitignore:2:dsdt.asl.tmp
board/advantech/som-db5800-som-6867/.gitignore:3:dsdt.c
board/congatec/conga-qeval20-qa3-e3845/.gitignore:1:dsdt.aml
board/congatec/conga-qeval20-qa3-e3845/.gitignore:2:dsdt.asl.tmp
board/congatec/conga-qeval20-qa3-e3845/.gitignore:3:dsdt.c
board/intel/bayleybay/.gitignore:1:dsdt.aml
board/intel/bayleybay/.gitignore:2:dsdt.asl.tmp
board/intel/bayleybay/.gitignore:3:dsdt.c
board/intel/edison/.gitignore:1:dsdt.aml
board/intel/edison/.gitignore:2:dsdt.asl.tmp
board/intel/edison/.gitignore:3:dsdt.c
board/intel/galileo/.gitignore:1:dsdt.aml
board/intel/galileo/.gitignore:2:dsdt.asl.tmp
board/intel/galileo/.gitignore:3:dsdt.c
board/intel/minnowmax/.gitignore:1:dsdt.aml
board/intel/minnowmax/.gitignore:2:dsdt.asl.tmp
board/intel/minnowmax/.gitignore:3:dsdt.c

Best regards

Heinrich




---

Changelog:
v3:
- update comments in file scripts/Makefile.lib
- add changelog
v2
- change generated file name (dsdt_generated.c)
   instead of changing the name of the static file
- NOTE : forgot to call it v2 and forgot changelog

Makefile| 3 ++-
  board/advantech/som-db5800-som-6867/Makefile| 2 +-
  board/congatec/conga-qeval20-qa3-e3845/Makefile | 2 +-
  board/dfi/dfi-bt700/Makefile| 2 +-
  board/google/chromebook_coral/Makefile  | 2 +-
  board/intel/bayleybay/Makefile  | 2 +-
  board/intel/edison/Makefile | 2 +-
  board/intel/galileo/Makefile| 2 +-
  board/intel/minnowmax/Makefile  | 2 +-
  scripts/Makefile.lib| 8 
  10 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index 4b152249ca..94bc48f00c 100644
--- a/Makefile
+++ b/Makefile
@@ -2226,7 +2226,8 @@ clean: $(clean-dirs)
 -o -name '*.asn1.[ch]' \
 -o -name '*.symtypes' -o -name 'modules.order' \
 -o -name modules.builtin -o -name '.tmp_*.o.*' \
-   -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \
+   -o -name 'dsdt_generated.aml' -o -name 'dsdt_generated.asl.tmp' 
\
+   -o -name 'dsdt_generated.c' \
 -o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \
 -type f -print | xargs rm -f

diff --git a/board/advantech/som-db5800-som-6867/Makefile 
b/board/advantech/som-db5800-som-6867/Makefile
index 7975547f41..95af6c4df7 100644
--- a/board/advantech/som-db5800-som-6867/Makefile
+++ b/board/advantech/som-db5800-som-6867/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc

  obj-y  += som-db5800-som-6867.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/congatec/conga-qeval20-qa3-e3845/Makefile 
b/board/congatec/conga-qeval20-qa3-e3845/Makefile
index 451a4fcd6c..215f5680dc 100644
--- a/board/congatec/conga-qeval20-qa3-e3845/Makefile
+++ b/board/congatec/conga-qeval20-qa3-e3845/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc

  obj-y  += conga-qeval20-qa3.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/dfi/dfi-bt700/Makefile b/board/dfi/dfi-bt700/Makefile
index 50d88f2954..1c4329a058 100644
--- a/board/dfi/dfi-bt700/Makefile
+++ b/board/dfi/dfi-bt700/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc

  obj-y  += dfi-bt700.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/google/chromebook_coral/Makefile 
b/board/google/chromebook_coral/Makefile
index f7a0ca6cc0..846558d777 100644
--- a/board/google/chromebook_coral/Makefile
+++ b/board/google/chromebook_coral/Makefile
@@ -3,4 +3,4 @@
  # 

[PATCH v6 16/16] configs: sandbox_defconfig: enable config CMD_VERIFY

2022-02-25 Thread Philippe Reynes
Enable the command verify on sandbox.

Signed-off-by: Philippe Reynes 
---
 configs/sandbox_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 46bf18bc98..a56aa92f94 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -44,6 +44,7 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_BOOTEFI_HELLO=y
 CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_ELF is not set
+CONFIG_CMD_VERIFY=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 CONFIG_CMD_ERASEENV=y
-- 
2.17.1



[PATCH v6 12/16] tools: binman: add support for pre-load header

2022-02-25 Thread Philippe Reynes
Adds the support of the pre-load header with the image signature
to binman.

Signed-off-by: Philippe Reynes 
---
 tools/binman/etype/pre_load.py| 165 ++
 tools/binman/ftest.py |  45 +
 tools/binman/test/225_dev.key |  28 +++
 tools/binman/test/225_pre_load.dts|  22 +++
 tools/binman/test/226_pre_load_pkcs.dts   |  23 +++
 tools/binman/test/227_pre_load_pss.dts|  23 +++
 .../test/228_pre_load_invalid_padding.dts |  23 +++
 .../binman/test/229_pre_load_invalid_sha.dts  |  23 +++
 .../binman/test/230_pre_load_invalid_algo.dts |  23 +++
 .../binman/test/231_pre_load_invalid_key.dts  |  23 +++
 10 files changed, 398 insertions(+)
 create mode 100644 tools/binman/etype/pre_load.py
 create mode 100644 tools/binman/test/225_dev.key
 create mode 100644 tools/binman/test/225_pre_load.dts
 create mode 100644 tools/binman/test/226_pre_load_pkcs.dts
 create mode 100644 tools/binman/test/227_pre_load_pss.dts
 create mode 100644 tools/binman/test/228_pre_load_invalid_padding.dts
 create mode 100644 tools/binman/test/229_pre_load_invalid_sha.dts
 create mode 100644 tools/binman/test/230_pre_load_invalid_algo.dts
 create mode 100644 tools/binman/test/231_pre_load_invalid_key.dts

diff --git a/tools/binman/etype/pre_load.py b/tools/binman/etype/pre_load.py
new file mode 100644
index 00..2af2857404
--- /dev/null
+++ b/tools/binman/etype/pre_load.py
@@ -0,0 +1,165 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2022 Softathome
+# Written by Philippe Reynes 
+#
+# Entry-type for the global header
+#
+
+import struct
+from dtoc import fdt_util
+from patman import tools
+
+from binman.entry import Entry
+from binman.etype.collection import Entry_collection
+from binman.entry import EntryArg
+
+from Cryptodome.Hash import SHA256, SHA384, SHA512
+from Cryptodome.PublicKey import RSA
+from Cryptodome.Signature import pkcs1_15
+from Cryptodome.Signature import pss
+
+PRE_LOAD_MAGIC = b'UBSH'
+
+RSAS = {
+'rsa1024': 1024 / 8,
+'rsa2048': 2048 / 8,
+'rsa4096': 4096 / 8
+}
+
+SHAS = {
+'sha256': SHA256,
+'sha384': SHA384,
+'sha512': SHA512
+}
+
+class Entry_pre_load(Entry_collection):
+"""Pre load image header
+
+Properties / Entry arguments:
+- key-path: Path of the directory that store key (provided by the 
environment variable KEY_PATH)
+- content: List of phandles to entries to sign
+- algo-name: Hash and signature algo to use for the signature
+- padding-name: Name of the padding (pkcs-1.5 or pss)
+- key-name: Filename of the private key to sign
+- header-size: Total size of the header
+- version: Version of the header
+
+This entry create a pre-load header that contain a global
+image signature.
+
+For example, this creates an image with a pre-load header and a binary::
+
+binman {
+   image2 {
+   filename = "sandbox.bin";
+
+   pre-load {
+   content = <>;
+   algo-name = "sha256,rsa2048";
+   padding-name = "pss";
+   key-name = "private.pem";
+   header-size = <4096>;
+   version = <1>;
+   };
+
+   image: blob-ext {
+   filename = "sandbox.itb";
+   };
+   };
+};
+"""
+
+def __init__(self, section, etype, node):
+super().__init__(section, etype, node)
+self.algo_name = fdt_util.GetString(self._node, 'algo-name')
+self.padding_name = fdt_util.GetString(self._node, 'padding-name')
+self.key_name = fdt_util.GetString(self._node, 'key-name')
+self.header_size = fdt_util.GetInt(self._node, 'header-size')
+self.version = fdt_util.GetInt(self._node, 'version')
+
+def _CreateHeader(self):
+"""Create a pre load header"""
+hash_name, sign_name  = self.algo_name.split(',')
+padding_name=self.padding_name
+key_path, = self.GetEntryArgsOrProps([EntryArg('key-path', str)])
+if key_path is None or key_path == "":
+key_name = self.key_name
+else:
+key_name = key_path + "/" + self.key_name
+
+# Check hash and signature name/type
+if hash_name not in SHAS:
+raise ValueError(hash_name + " is not supported")
+if sign_name not in RSAS:
+raise ValueError(sign_name + "is not supported")
+
+# Read the key
+with open(key_name, 'rb') as pem:
+key = RSA.import_key(pem.read())
+
+# Check if the key has the expected size
+if key.size_in_bytes() != RSAS[sign_name]:
+raise ValueError("The key " + self.key_name + " don't have the 
expected size")
+
+# Compute the hash
+hash_image = SHAS[hash_name].new()
+hash_image.update(self.image)
+
+# Compute the signature
+if 

[PATCH v6 13/16] configs: sandbox_defconfig: enable stage pre-load in bootm

2022-02-25 Thread Philippe Reynes
Enable the support of stage pre-load in bootm.
For the moment, this stage allow to verify the
signature of the full image with a header.

Signed-off-by: Philippe Reynes 
---
 configs/sandbox_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 7ebeb89264..46bf18bc98 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -27,6 +27,8 @@ CONFIG_AUTOBOOT_SHA256_FALLBACK=y
 CONFIG_AUTOBOOT_NEVER_TIMEOUT=y
 CONFIG_AUTOBOOT_STOP_STR_ENABLE=y
 
CONFIG_AUTOBOOT_STOP_STR_CRYPT="$5$rounds=64$HrpE65IkB8CM5nCL$BKT3QdF98Bo8fJpTr9tjZLZQyzqPASBY20xuK5Rent9"
+CONFIG_IMAGE_PRE_LOAD=y
+CONFIG_IMAGE_PRE_LOAD_SIG=y
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_PRE_CONSOLE_BUFFER=y
@@ -37,6 +39,7 @@ CONFIG_STACKPROTECTOR=y
 CONFIG_ANDROID_AB=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
+CONFIG_CMD_BOOTM_PRE_LOAD=y
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_BOOTEFI_HELLO=y
 CONFIG_CMD_ABOOTIMG=y
-- 
2.17.1



[PATCH v6 14/16] test: py: vboot: add test for global image signature

2022-02-25 Thread Philippe Reynes
Adds test units for the pre-load header signature.

Signed-off-by: Philippe Reynes 
---
 test/py/tests/test_vboot.py   | 125 +++---
 test/py/tests/vboot/sandbox-binman-pss.dts|  25 
 test/py/tests/vboot/sandbox-binman.dts|  24 
 .../tests/vboot/sandbox-u-boot-global-pss.dts |  28 
 test/py/tests/vboot/sandbox-u-boot-global.dts |  27 
 test/py/tests/vboot/simple-images.its |  36 +
 6 files changed, 249 insertions(+), 16 deletions(-)
 create mode 100644 test/py/tests/vboot/sandbox-binman-pss.dts
 create mode 100644 test/py/tests/vboot/sandbox-binman.dts
 create mode 100644 test/py/tests/vboot/sandbox-u-boot-global-pss.dts
 create mode 100644 test/py/tests/vboot/sandbox-u-boot-global.dts
 create mode 100644 test/py/tests/vboot/simple-images.its

diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index ac8ed9f114..a4a2bb2955 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -35,19 +35,21 @@ import vboot_evil
 # Only run the full suite on a few combinations, since it doesn't add any more
 # test coverage.
 TESTDATA = [
-['sha1-basic', 'sha1', '', None, False, True, False],
-['sha1-pad', 'sha1', '', '-E -p 0x1', False, False, False],
-['sha1-pss', 'sha1', '-pss', None, False, False, False],
-['sha1-pss-pad', 'sha1', '-pss', '-E -p 0x1', False, False, False],
-['sha256-basic', 'sha256', '', None, False, False, False],
-['sha256-pad', 'sha256', '', '-E -p 0x1', False, False, False],
-['sha256-pss', 'sha256', '-pss', None, False, False, False],
-['sha256-pss-pad', 'sha256', '-pss', '-E -p 0x1', False, False, False],
-['sha256-pss-required', 'sha256', '-pss', None, True, False, False],
-['sha256-pss-pad-required', 'sha256', '-pss', '-E -p 0x1', True, True, 
False],
-['sha384-basic', 'sha384', '', None, False, False, False],
-['sha384-pad', 'sha384', '', '-E -p 0x1', False, False, False],
-['algo-arg', 'algo-arg', '', '-o sha256,rsa2048', False, False, True],
+['sha1-basic', 'sha1', '', None, False, True, False, False],
+['sha1-pad', 'sha1', '', '-E -p 0x1', False, False, False, False],
+['sha1-pss', 'sha1', '-pss', None, False, False, False, False],
+['sha1-pss-pad', 'sha1', '-pss', '-E -p 0x1', False, False, False, 
False],
+['sha256-basic', 'sha256', '', None, False, False, False, False],
+['sha256-pad', 'sha256', '', '-E -p 0x1', False, False, False, False],
+['sha256-pss', 'sha256', '-pss', None, False, False, False, False],
+['sha256-pss-pad', 'sha256', '-pss', '-E -p 0x1', False, False, False, 
False],
+['sha256-pss-required', 'sha256', '-pss', None, True, False, False, False],
+['sha256-pss-pad-required', 'sha256', '-pss', '-E -p 0x1', True, True, 
False, False],
+['sha384-basic', 'sha384', '', None, False, False, False, False],
+['sha384-pad', 'sha384', '', '-E -p 0x1', False, False, False, False],
+['algo-arg', 'algo-arg', '', '-o sha256,rsa2048', False, False, True, 
False],
+['sha256-global-sign', 'sha256', '', '', False, False, False, True],
+['sha256-global-sign-pss', 'sha256', '-pss', '', False, False, False, 
True],
 ]
 
 @pytest.mark.boardspec('sandbox')
@@ -56,10 +58,10 @@ TESTDATA = [
 @pytest.mark.requiredtool('fdtget')
 @pytest.mark.requiredtool('fdtput')
 @pytest.mark.requiredtool('openssl')
-@pytest.mark.parametrize("name,sha_algo,padding,sign_options,required,full_test,algo_arg",
+@pytest.mark.parametrize("name,sha_algo,padding,sign_options,required,full_test,algo_arg,global_sign",
  TESTDATA)
 def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required,
-   full_test, algo_arg):
+   full_test, algo_arg, global_sign):
 """Test verified boot signing with mkimage and verification with 'bootm'.
 
 This works using sandbox only as it needs to update the device tree used
@@ -81,6 +83,29 @@ def test_vboot(u_boot_console, name, sha_algo, padding, 
sign_options, required,
 util.run_and_log(cons, 'dtc %s %s%s -O dtb '
  '-o %s%s' % (dtc_args, datadir, dts, tmpdir, dtb))
 
+def dtc_options(dts, options):
+"""Run the device tree compiler to compile a .dts file
+
+The output file will be the same as the input file but with a .dtb
+extension.
+
+Args:
+dts: Device tree file to compile.
+options: Options provided to the compiler.
+"""
+dtb = dts.replace('.dts', '.dtb')
+util.run_and_log(cons, 'dtc %s %s%s -O dtb '
+ '-o %s%s %s' % (dtc_args, datadir, dts, tmpdir, dtb, 
options))
+
+def run_binman(dtb):
+"""Run binman to build an image
+
+Args:
+dtb: Device tree file used as input file.
+"""
+util.run_and_log(cons, [binman, 'build', '-d', "%s/%s" % (tmpdir,dtb),
+

[PATCH v6 15/16] cmd: verify: initial import

2022-02-25 Thread Philippe Reynes
Add the command verify that check the signature of
an image with the pre-load header. If the check
succeed, the u-boot env variable 'loadaddr_verified'
is set to the address of the image (without the header).

It allows to run such commands:
tftp script.img && verify $loadaddr && source $loadaddr_verified

Signed-off-by: Philippe Reynes 
---
 cmd/Kconfig  |  7 +++
 cmd/Makefile |  1 +
 cmd/verify.c | 53 
 3 files changed, 61 insertions(+)
 create mode 100644 cmd/verify.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 87aa3fb11a..0460d5c3a0 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -428,6 +428,13 @@ config CMD_THOR_DOWNLOAD
  There is no documentation about this within the U-Boot source code
  but you should be able to find something on the interwebs.
 
+config CMD_VERIFY
+   bool "verify the global signature"
+depends on CMD_BOOTM_PRE_LOAD
+   help
+ Verify the signature provided in a pre-load header of
+ a full image.
+
 config CMD_ZBOOT
bool "zboot - x86 boot command"
help
diff --git a/cmd/Makefile b/cmd/Makefile
index 166c652d98..80e054e806 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -177,6 +177,7 @@ obj-$(CONFIG_CMD_THOR_DOWNLOAD) += thordown.o
 obj-$(CONFIG_CMD_XIMG) += ximg.o
 obj-$(CONFIG_CMD_YAFFS2) += yaffs2.o
 obj-$(CONFIG_CMD_SPL) += spl.o
+obj-$(CONFIG_CMD_VERIFY) += verify.o
 obj-$(CONFIG_CMD_W1) += w1.o
 obj-$(CONFIG_CMD_ZIP) += zip.o
 obj-$(CONFIG_CMD_ZFS) += zfs.o
diff --git a/cmd/verify.c b/cmd/verify.c
new file mode 100644
index 00..4d055e0790
--- /dev/null
+++ b/cmd/verify.c
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 Philippe Reynes 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+static ulong verify_get_addr(int argc, char *const argv[])
+{
+   ulong addr;
+
+   if (argc > 0)
+   addr = simple_strtoul(argv[0], NULL, 16);
+   else
+   addr = image_load_addr;
+
+   return addr;
+}
+
+static int do_verify(struct cmd_tbl *cmdtp, int flag, int argc,
+char *const argv[])
+{
+   ulong addr = verify_get_addr(argc, argv);
+   int ret = 0;
+
+   argc--; argv++;
+
+   addr = verify_get_addr(argc, argv);
+
+   if (CONFIG_IS_ENABLED(CMD_BOOTM_PRE_LOAD)) {
+   ret = image_pre_load(addr);
+
+   if (ret) {
+   ret = CMD_RET_FAILURE;
+   goto out;
+   }
+
+   env_set_hex("loadaddr_verified", addr + image_load_offset);
+   }
+
+ out:
+   return ret;
+}
+
+U_BOOT_CMD(verify, 2, 1, do_verify,
+  "verify the global signature provided in the pre-load header,\n"
+  "\tif the check succeed, the u-boot env variable loadaddr_verified\n"
+  "\tis set to the address of the image (without the header)",
+  ""
+);
-- 
2.17.1



[PATCH v6 07/16] boot: image: add a stage pre-load

2022-02-25 Thread Philippe Reynes
Add a stage pre-load that could
check or modify an image.

For the moment, only a header with a signature is
supported. This header has the following format:
- magic : 4 bytes
- version : 4 bytes
- header size : 4 bytes
- image size : 4 bytes
- offset image signature : 4 bytes
- flags : 4 bytes
- reserved0 : 4 bytes
- reserved1 : 4 bytes
- sha256 of the image signature : 32 bytes
- signature of the first 64 bytes : n bytes
- image signature : n bytes
- padding : up to header size

The stage uses a node /image/pre-load/sig to
get some informations:
- algo-name (mandatory) : name of the algo used to sign
- padding-name : name of padding used to sign
- signature-size : size of the signature (in the header)
- mandatory : set to yes if this sig is mandatory
- public-key (madatory) : value of the public key

Before running the image, the stage pre-load checks
the signature provided in the header.

This is an initial support, later we could add the
support of:
- ciphering
- uncompressing
- ...

Signed-off-by: Philippe Reynes 
---
 boot/Kconfig  |  55 ++
 boot/Makefile |   1 +
 boot/image-pre-load.c | 416 ++
 include/image.h   |  14 ++
 4 files changed, 486 insertions(+)
 create mode 100644 boot/image-pre-load.c

diff --git a/boot/Kconfig b/boot/Kconfig
index b83a4e8400..cb5f48dcf9 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -993,6 +993,61 @@ config AUTOBOOT_MENU_SHOW
 
 endmenu
 
+menu "Image support"
+
+config IMAGE_PRE_LOAD
+   bool "Image pre-load support"
+   help
+ Enable an image pre-load stage in the SPL.
+ This pre-load stage allows to do some manipulation
+ or check (for example signature check) on an image
+ before launching it.
+
+config SPL_IMAGE_PRE_LOAD
+   bool "Image pre-load support within SPL"
+   depends on SPL && IMAGE_PRE_LOAD
+   help
+ Enable an image pre-load stage in the SPL.
+ This pre-load stage allows to do some manipulation
+ or check (for example signature check) on an image
+ before launching it.
+
+config IMAGE_PRE_LOAD_SIG
+   bool "Image pre-load signature support"
+   depends on IMAGE_PRE_LOAD
+   select FIT_SIGNATURE
+   select RSA
+   select RSA_VERIFY_WITH_PKEY
+   help
+ Enable signature check support in the pre-load stage.
+ For this feature a very simple header is added before
+ the image with few fields:
+ - a magic
+ - the image size
+ - the signature
+ All other information (header size, type of signature,
+ ...) are provided in the node /image/pre-load/sig of
+ u-boot.
+
+config SPL_IMAGE_PRE_LOAD_SIG
+   bool "Image pre-load signature support witin SPL"
+   depends on SPL_IMAGE_PRE_LOAD && IMAGE_PRE_LOAD_SIG
+   select SPL_FIT_SIGNATURE
+   select SPL_RSA
+   select SPL_RSA_VERIFY_WITH_PKEY
+   help
+ Enable signature check support in the pre-load stage in the SPL.
+ For this feature a very simple header is added before
+ the image with few fields:
+ - a magic
+ - the image size
+ - the signature
+ All other information (header size, type of signature,
+ ...) are provided in the node /image/pre-load/sig of
+ u-boot.
+
+endmenu
+
 config USE_BOOTARGS
bool "Enable boot arguments"
help
diff --git a/boot/Makefile b/boot/Makefile
index 2938c3f145..59752c65ca 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
 obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
 obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o
 obj-$(CONFIG_$(SPL_)MULTI_DTB_FIT) += boot_fit.o common_fit.o
+obj-$(CONFIG_$(SPL_TPL_)IMAGE_PRE_LOAD) += image-pre-load.o
 obj-$(CONFIG_$(SPL_TPL_)IMAGE_SIGN_INFO) += image-sig.o
 obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += image-fit-sig.o
 obj-$(CONFIG_$(SPL_TPL_)FIT_CIPHER) += image-cipher.o
diff --git a/boot/image-pre-load.c b/boot/image-pre-load.c
new file mode 100644
index 00..78d89069a9
--- /dev/null
+++ b/boot/image-pre-load.c
@@ -0,0 +1,416 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Philippe Reynes 
+ */
+
+#include 
+#include 
+DECLARE_GLOBAL_DATA_PTR;
+#include 
+#include 
+
+#include 
+
+#define IMAGE_PRE_LOAD_SIG_MAGIC   0x55425348
+#define IMAGE_PRE_LOAD_SIG_OFFSET_MAGIC0
+#define IMAGE_PRE_LOAD_SIG_OFFSET_IMG_LEN  4
+#define IMAGE_PRE_LOAD_SIG_OFFSET_SIG  8
+
+#define IMAGE_PRE_LOAD_PATH"/image/pre-load/sig"
+#define IMAGE_PRE_LOAD_PROP_ALGO_NAME  "algo-name"
+#define IMAGE_PRE_LOAD_PROP_PADDING_NAME   "padding-name"
+#define IMAGE_PRE_LOAD_PROP_SIG_SIZE   "signature-size"
+#define IMAGE_PRE_LOAD_PROP_PUBLIC_KEY "public-key"
+#define IMAGE_PRE_LOAD_PROP_MANDATORY  "mandatory"
+
+#ifndef CONFIG_SYS_BOOTM_LEN
+/* 

[PATCH v6 11/16] Makefile: provide sah-key to binman

2022-02-25 Thread Philippe Reynes
Set the variable key-path with the shell variable
KEY_PATH that contain the keys path (used for signature).
This variable key-path is provided to binman.

Signed-off-by: Philippe Reynes 
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 697cc51d67..c6da6cdba0 100644
--- a/Makefile
+++ b/Makefile
@@ -1335,6 +1335,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if 
$(BINMAN_DEBUG),-D) \
-a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \
-a spl-dtb=$(CONFIG_SPL_OF_REAL) \
-a tpl-dtb=$(CONFIG_TPL_OF_REAL) \
+   -a key-path=${KEY_PATH} \
$(BINMAN_$(@F))
 
 OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
-- 
2.17.1



[PATCH v6 09/16] common: spl: fit_ram: allow to use image pre load

2022-02-25 Thread Philippe Reynes
Add the support of image pre load in spl or tpl
when loading an image from ram.

Reviewed-by: Simon Glass 
Signed-off-by: Philippe Reynes 
---
 common/spl/spl_ram.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index 3f7f7accc1..8296459257 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -24,9 +24,17 @@
 static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
   ulong count, void *buf)
 {
+   ulong addr;
+
debug("%s: sector %lx, count %lx, buf %lx\n",
  __func__, sector, count, (ulong)buf);
-   memcpy(buf, (void *)(CONFIG_SPL_LOAD_FIT_ADDRESS + sector), count);
+
+   addr = (ulong)CONFIG_SPL_LOAD_FIT_ADDRESS + sector;
+   if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD))
+   addr += image_load_offset;
+
+   memcpy(buf, (void *)addr, count);
+
return count;
 }
 
@@ -37,6 +45,17 @@ static int spl_ram_load_image(struct spl_image_info 
*spl_image,
 
header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS;
 
+   if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD)) {
+   unsigned long addr = (unsigned long)header;
+   int ret = image_pre_load(addr);
+
+   if (ret)
+   return ret;
+
+   addr += image_load_offset;
+   header = (struct image_header *)addr;
+   }
+
 #if CONFIG_IS_ENABLED(DFU)
if (bootdev->boot_device == BOOT_DEVICE_DFU)
spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
-- 
2.17.1



[PATCH v6 03/16] lib: Kconfig: enhance the help of OID_REGISTRY

2022-02-25 Thread Philippe Reynes
Enhance the help for the config OID_REGISTRY.

Reviewed-by: Simon Glass 
Signed-off-by: Philippe Reynes 
---
 lib/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/Kconfig b/lib/Kconfig
index b0e5d60b3d..e749826f22 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -812,6 +812,10 @@ config ASN1_DECODER
 config OID_REGISTRY
bool
help
+ In computing, object identifiers or OIDs are an identifier mechanism
+ standardized by the International Telecommunication Union (ITU) and
+ ISO/IEC for naming any object, concept, or "thing" with a globally
+ unambiguous persistent name 
(https://en.wikipedia.org/wiki/Object_identifier).
  Enable fast lookup object identifier registry.
 
 config SMBIOS_PARSER
-- 
2.17.1



[PATCH v6 02/16] lib: Kconfig: enhance help for ASN1

2022-02-25 Thread Philippe Reynes
Enhance the help for configs ASN1_COMPILER
and ASN1_decoder.

Reviewed-by: Simon Glass 
Signed-off-by: Philippe Reynes 
---
 lib/Kconfig | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 3c6fa99b1a..b0e5d60b3d 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -791,11 +791,23 @@ endmenu
 
 config ASN1_COMPILER
bool
+   help
+ ASN.1 (Abstract Syntax Notation One) is a standard interface
+ description language for defining data structures that can be
+ serialized and deserialized in a cross-platform way. It is
+ broadly used in telecommunications and computer networking,
+ and especially in cryptography (https://en.wikipedia.org/wiki/ASN.1).
+ This option enables the support of the asn1 compiler.
 
 config ASN1_DECODER
bool
help
- Enable asn1 decoder library.
+ ASN.1 (Abstract Syntax Notation One) is a standard interface
+ description language for defining data structures that can be
+ serialized and deserialized in a cross-platform way. It is
+ broadly used in telecommunications and computer networking,
+ and especially in cryptography (https://en.wikipedia.org/wiki/ASN.1).
+ This option enables the support of the asn1 decoder.
 
 config OID_REGISTRY
bool
-- 
2.17.1



[PATCH v6 10/16] mkimage: add public key for image pre-load stage

2022-02-25 Thread Philippe Reynes
This commit enhances mkimage to update the node
/image/pre-load/sig with the public key.

Signed-off-by: Philippe Reynes 
---
 include/image.h|  15 ++
 tools/fit_image.c  |   3 ++
 tools/image-host.c | 114 +
 3 files changed, 132 insertions(+)

diff --git a/include/image.h b/include/image.h
index 496b7af3f3..498eb7f2e3 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1019,6 +1019,21 @@ int fit_image_hash_get_value(const void *fit, int 
noffset, uint8_t **value,
 
 int fit_set_timestamp(void *fit, int noffset, time_t timestamp);
 
+/**
+ * fit_pre_load_data() - add public key to fdt blob
+ *
+ * Adds public key to the node pre load.
+ *
+ * @keydir:Directory containing keys
+ * @keydest:   FDT blob to write public key
+ * @fit:   Pointer to the FIT format image header
+ *
+ * returns:
+ * 0, on success
+ * < 0, on failure
+ */
+int fit_pre_load_data(const char *keydir, void *keydest, void *fit);
+
 int fit_cipher_data(const char *keydir, void *keydest, void *fit,
const char *comment, int require_keys,
const char *engine_id, const char *cmdname);
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 15f7c82d61..1884a2eb0b 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -59,6 +59,9 @@ static int fit_add_file_data(struct image_tool_params 
*params, size_t size_inc,
ret = fit_set_timestamp(ptr, 0, time);
}
 
+   if (!ret)
+   ret = fit_pre_load_data(params->keydir, dest_blob, ptr);
+
if (!ret) {
ret = fit_cipher_data(params->keydir, dest_blob, ptr,
  params->comment,
diff --git a/tools/image-host.c b/tools/image-host.c
index eaeb76545c..ab6f756cf1 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -14,6 +14,11 @@
 #include 
 #include 
 
+#include 
+#include 
+
+#define IMAGE_PRE_LOAD_PATH "/image/pre-load/sig"
+
 /**
  * fit_set_hash_value - set hash value in requested has node
  * @fit: pointer to the FIT format image header
@@ -,6 +1116,115 @@ static int fit_config_add_verification_data(const char 
*keydir,
return 0;
 }
 
+/*
+ * 0) open file (open)
+ * 1) read certificate (PEM_read_X509)
+ * 2) get public key (X509_get_pubkey)
+ * 3) provide der format (d2i_RSAPublicKey)
+ */
+static int read_pub_key(const char *keydir, const void *name,
+   unsigned char **pubkey, int *pubkey_len)
+{
+   char path[1024];
+   EVP_PKEY *key = NULL;
+   X509 *cert;
+   FILE *f;
+   int ret;
+
+   memset(path, 0, 1024);
+   snprintf(path, sizeof(path), "%s/%s.crt", keydir, (char *)name);
+
+   /* Open certificate file */
+   f = fopen(path, "r");
+   if (!f) {
+   fprintf(stderr, "Couldn't open RSA certificate: '%s': %s\n",
+   path, strerror(errno));
+   return -EACCES;
+   }
+
+   /* Read the certificate */
+   cert = NULL;
+   if (!PEM_read_X509(f, , NULL, NULL)) {
+   printf("Couldn't read certificate");
+   ret = -EINVAL;
+   goto err_cert;
+   }
+
+   /* Get the public key from the certificate. */
+   key = X509_get_pubkey(cert);
+   if (!key) {
+   printf("Couldn't read public key\n");
+   ret = -EINVAL;
+   goto err_pubkey;
+   }
+
+   /* Get DER form */
+   ret = i2d_PublicKey(key, pubkey);
+   if (ret < 0) {
+   printf("Couldn't get DER form\n");
+   ret = -EINVAL;
+   goto err_pubkey;
+   }
+
+   *pubkey_len = ret;
+   ret = 0;
+
+err_pubkey:
+   X509_free(cert);
+err_cert:
+   fclose(f);
+   return ret;
+}
+
+int fit_pre_load_data(const char *keydir, void *keydest, void *fit)
+{
+   int pre_load_noffset;
+   const void *algo_name;
+   const void *key_name;
+   unsigned char *pubkey = NULL;
+   int ret, pubkey_len;
+
+   if (!keydir || !keydest || !fit)
+   return 0;
+
+   /* Search node pre-load sig */
+   pre_load_noffset = fdt_path_offset(keydest, IMAGE_PRE_LOAD_PATH);
+   if (pre_load_noffset < 0) {
+   ret = 0;
+   goto out;
+   }
+
+   algo_name = fdt_getprop(keydest, pre_load_noffset, "algo-name", NULL);
+   key_name  = fdt_getprop(keydest, pre_load_noffset, "key-name", NULL);
+
+   /* Check that all mandatory properties are present */
+   if (!algo_name || !key_name) {
+   if (!algo_name)
+   printf("The property algo-name is missing in the node 
%s\n",
+  IMAGE_PRE_LOAD_PATH);
+   if (!key_name)
+   printf("The property key-name is missing in the node 
%s\n",
+  IMAGE_PRE_LOAD_PATH);
+   ret = -ENODATA;
+   goto out;
+   }

[PATCH v6 06/16] lib: rsa: allow rsa verify with pkey in SPL

2022-02-25 Thread Philippe Reynes
This commit adds the option SPL_RSA_VERIFY_WITH_PKEY.

Reviewed-by: Simon Glass 
Signed-off-by: Philippe Reynes 
---
 lib/rsa/Kconfig | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/lib/rsa/Kconfig b/lib/rsa/Kconfig
index be9775bcce..b773f17c26 100644
--- a/lib/rsa/Kconfig
+++ b/lib/rsa/Kconfig
@@ -47,6 +47,25 @@ config RSA_VERIFY_WITH_PKEY
  directly specified in image_sign_info, where all the necessary
  key properties will be calculated on the fly in verification code.
 
+config SPL_RSA_VERIFY_WITH_PKEY
+   bool "Execute RSA verification without key parameters from FDT within 
SPL"
+   depends on SPL
+   select SPL_RSA_VERIFY
+   select SPL_ASYMMETRIC_KEY_TYPE
+   select SPL_ASYMMETRIC_PUBLIC_KEY_SUBTYPE
+   select SPL_RSA_PUBLIC_KEY_PARSER
+   help
+ The standard RSA-signature verification code (FIT_SIGNATURE) uses
+ pre-calculated key properties, that are stored in fdt blob, in
+ decrypting a signature.
+ This does not suit the use case where there is no way defined to
+ provide such additional key properties in standardized form,
+ particularly UEFI secure boot.
+ This options enables RSA signature verification with a public key
+ directly specified in image_sign_info, where all the necessary
+ key properties will be calculated on the fly in verification code
+ in the SPL.
+
 config RSA_SOFTWARE_EXP
bool "Enable driver for RSA Modular Exponentiation in software"
depends on DM
-- 
2.17.1



[PATCH v6 04/16] lib: allow to build asn1 decoder and oid registry in SPL

2022-02-25 Thread Philippe Reynes
This commit adds the options:
- SPL_ASN1_DECODER
- SPL_OID_REGISTRY

Signed-off-by: Philippe Reynes 
---
 lib/Kconfig  | 19 +++
 lib/Makefile |  4 ++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index e749826f22..effe735365 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -809,6 +809,16 @@ config ASN1_DECODER
  and especially in cryptography (https://en.wikipedia.org/wiki/ASN.1).
  This option enables the support of the asn1 decoder.
 
+config SPL_ASN1_DECODER
+   bool
+   help
+ ASN.1 (Abstract Syntax Notation One) is a standard interface
+ description language for defining data structures that can be
+ serialized and deserialized in a cross-platform way. It is
+ broadly used in telecommunications and computer networking,
+ and especially in cryptography (https://en.wikipedia.org/wiki/ASN.1).
+ This option enables the support of the asn1 decoder in the SPL.
+
 config OID_REGISTRY
bool
help
@@ -818,6 +828,15 @@ config OID_REGISTRY
  unambiguous persistent name 
(https://en.wikipedia.org/wiki/Object_identifier).
  Enable fast lookup object identifier registry.
 
+config SPL_OID_REGISTRY
+   bool
+   help
+ In computing, object identifiers or OIDs are an identifier mechanism
+ standardized by the International Telecommunication Union (ITU) and
+ ISO/IEC for naming any object, concept, or "thing" with a globally
+ unambiguous persistent name 
(https://en.wikipedia.org/wiki/Object_identifier).
+ Enable fast lookup object identifier registry in the SPL.
+
 config SMBIOS_PARSER
bool "SMBIOS parser"
help
diff --git a/lib/Makefile b/lib/Makefile
index 11b03d1cbe..13e5d8f7a6 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -17,7 +17,6 @@ obj-$(CONFIG_OF_LIVE) += of_live.o
 obj-$(CONFIG_CMD_DHRYSTONE) += dhry/
 obj-$(CONFIG_ARCH_AT91) += at91/
 obj-$(CONFIG_OPTEE_LIB) += optee/
-obj-$(CONFIG_ASN1_DECODER) += asn1_decoder.o
 obj-y += crypto/
 
 obj-$(CONFIG_AES) += aes.o
@@ -74,6 +73,7 @@ obj-$(CONFIG_SHA1) += sha1.o
 obj-$(CONFIG_SHA256) += sha256.o
 obj-$(CONFIG_SHA512) += sha512.o
 obj-$(CONFIG_CRYPT_PW) += crypt/
+obj-$(CONFIG_$(SPL_)ASN1_DECODER) += asn1_decoder.o
 
 obj-$(CONFIG_$(SPL_)ZLIB) += zlib/
 obj-$(CONFIG_$(SPL_)ZSTD) += zstd/
@@ -135,9 +135,9 @@ obj-$(CONFIG_$(SPL_TPL_)STRTO) += strto.o
 else
 # Main U-Boot always uses the full printf support
 obj-y += vsprintf.o strto.o
-obj-$(CONFIG_OID_REGISTRY) += oid_registry.o
 obj-$(CONFIG_SSCANF) += sscanf.o
 endif
+obj-$(CONFIG_$(SPL_)OID_REGISTRY) += oid_registry.o
 
 obj-y += abuf.o
 obj-y += date.o
-- 
2.17.1



[PATCH v6 05/16] lib: crypto: allow to build crypyo in SPL

2022-02-25 Thread Philippe Reynes
This commit adds the options:
- SPL_ASYMMETRIC_KEY_TYPE
- SPL_ASYMMETRIC_PUBLIC_KEY_SUBTYPE
- SPL_RSA_PUBLIC_KEY_PARSER

Reviewed-by: Simon Glass 
Signed-off-by: Philippe Reynes 
---
 lib/Makefile|  3 ++-
 lib/crypto/Kconfig  | 29 +
 lib/crypto/Makefile | 19 +--
 3 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/lib/Makefile b/lib/Makefile
index 13e5d8f7a6..13fe5fb7a4 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -17,7 +17,6 @@ obj-$(CONFIG_OF_LIVE) += of_live.o
 obj-$(CONFIG_CMD_DHRYSTONE) += dhry/
 obj-$(CONFIG_ARCH_AT91) += at91/
 obj-$(CONFIG_OPTEE_LIB) += optee/
-obj-y += crypto/
 
 obj-$(CONFIG_AES) += aes.o
 obj-$(CONFIG_AES) += aes/
@@ -63,6 +62,8 @@ obj-$(CONFIG_TPM_V1) += tpm-v1.o
 obj-$(CONFIG_TPM_V2) += tpm-v2.o
 endif
 
+obj-y += crypto/
+
 obj-$(CONFIG_$(SPL_TPL_)GENERATE_ACPI_TABLE) += acpi/
 obj-$(CONFIG_$(SPL_)MD5) += md5.o
 obj-$(CONFIG_ECDSA) += ecdsa/
diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig
index 6369bafac0..509bc28311 100644
--- a/lib/crypto/Kconfig
+++ b/lib/crypto/Kconfig
@@ -8,6 +8,15 @@ menuconfig ASYMMETRIC_KEY_TYPE
 
 if ASYMMETRIC_KEY_TYPE
 
+config SPL_ASYMMETRIC_KEY_TYPE
+   bool "Asymmetric (public-key cryptographic) key Support within SPL"
+   depends on SPL
+   help
+ This option provides support for a key type that holds the data for
+ the asymmetric keys used for public key cryptographic operations such
+ as encryption, decryption, signature generation and signature
+ verification in the SPL.
+
 config ASYMMETRIC_PUBLIC_KEY_SUBTYPE
bool "Asymmetric public-key crypto algorithm subtype"
help
@@ -16,6 +25,15 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE
  appropriate hash algorithms (such as SHA-1) must be available.
  ENOPKG will be reported if the requisite algorithm is unavailable.
 
+config SPL_ASYMMETRIC_PUBLIC_KEY_SUBTYPE
+   bool "Asymmetric public-key crypto algorithm subtype within SPL"
+   depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE
+   help
+ This option provides support for asymmetric public key type handling 
in the SPL.
+ If signature generation and/or verification are to be used,
+ appropriate hash algorithms (such as SHA-1) must be available.
+ ENOPKG will be reported if the requisite algorithm is unavailable.
+
 config RSA_PUBLIC_KEY_PARSER
bool "RSA public key parser"
depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE
@@ -27,6 +45,17 @@ config RSA_PUBLIC_KEY_PARSER
  public key data and provides the ability to instantiate a public
  key.
 
+config SPL_RSA_PUBLIC_KEY_PARSER
+   bool "RSA public key parser within SPL"
+   depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE
+   select SPL_ASN1_DECODER
+   select ASN1_COMPILER
+   select SPL_OID_REGISTRY
+   help
+ This option provides support for parsing a blob containing RSA
+ public key data and provides the ability to instantiate a public
+ key in the SPL.
+
 config X509_CERTIFICATE_PARSER
bool "X.509 certificate parser"
depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
index f3a414525d..6792b1d4f0 100644
--- a/lib/crypto/Makefile
+++ b/lib/crypto/Makefile
@@ -3,27 +3,34 @@
 # Makefile for asymmetric cryptographic keys
 #
 
-obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
+obj-$(CONFIG_$(SPL_)ASYMMETRIC_KEY_TYPE) += asymmetric_keys.o
 
 asymmetric_keys-y := asymmetric_type.o
 
-obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
+obj-$(CONFIG_$(SPL_)ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
 
 #
 # RSA public key parser
 #
-obj-$(CONFIG_RSA_PUBLIC_KEY_PARSER) += rsa_public_key.o
+obj-$(CONFIG_$(SPL_)RSA_PUBLIC_KEY_PARSER) += rsa_public_key.o
 rsa_public_key-y := \
rsapubkey.asn1.o \
rsa_helper.o
 
 $(obj)/rsapubkey.asn1.o: $(obj)/rsapubkey.asn1.c $(obj)/rsapubkey.asn1.h
+ifdef CONFIG_SPL_BUILD
+CFLAGS_rsapubkey.asn1.o += -I$(obj)
+endif
+
 $(obj)/rsa_helper.o: $(obj)/rsapubkey.asn1.h
+ifdef CONFIG_SPL_BUILD
+CFLAGS_rsa_helper.o += -I$(obj)
+endif
 
 #
 # X.509 Certificate handling
 #
-obj-$(CONFIG_X509_CERTIFICATE_PARSER) += x509_key_parser.o
+obj-$(CONFIG_$(SPL_)X509_CERTIFICATE_PARSER) += x509_key_parser.o
 x509_key_parser-y := \
x509.asn1.o \
x509_akid.asn1.o \
@@ -40,11 +47,11 @@ $(obj)/x509_akid.asn1.o: $(obj)/x509_akid.asn1.c 
$(obj)/x509_akid.asn1.h
 #
 # PKCS#7 message handling
 #
-obj-$(CONFIG_PKCS7_MESSAGE_PARSER) += pkcs7_message.o
+obj-$(CONFIG_$(SPL_)PKCS7_MESSAGE_PARSER) += pkcs7_message.o
 pkcs7_message-y := \
pkcs7.asn1.o \
pkcs7_parser.o
-obj-$(CONFIG_PKCS7_VERIFY) += pkcs7_verify.o
+obj-$(CONFIG_$(SPL_)PKCS7_VERIFY) += pkcs7_verify.o
 
 $(obj)/pkcs7_parser.o: $(obj)/pkcs7.asn1.h
 $(obj)/pkcs7.asn1.o: $(obj)/pkcs7.asn1.c $(obj)/pkcs7.asn1.h
-- 
2.17.1



[PATCH v6 08/16] cmd: bootm: add a stage pre-load

2022-02-25 Thread Philippe Reynes
Add a stage pre-load to the command bootm.
Right now, this stage may be used to read a
header and check the signature of the full
image.

Reviewed-by: Simon Glass 
Signed-off-by: Philippe Reynes 
---
 boot/bootm.c| 33 +
 cmd/Kconfig | 10 ++
 cmd/bootm.c |  2 +-
 include/image.h |  1 +
 4 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index 00c00aef84..714406ab66 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -87,6 +87,33 @@ static int bootm_start(struct cmd_tbl *cmdtp, int flag, int 
argc,
return 0;
 }
 
+static ulong bootm_data_addr(int argc, char *const argv[])
+{
+   ulong addr;
+
+   if (argc > 0)
+   addr = simple_strtoul(argv[0], NULL, 16);
+   else
+   addr = image_load_addr;
+
+   return addr;
+}
+
+static int bootm_pre_load(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+   ulong data_addr = bootm_data_addr(argc, argv);
+   int ret = 0;
+
+   if (CONFIG_IS_ENABLED(CMD_BOOTM_PRE_LOAD))
+   ret = image_pre_load(data_addr);
+
+   if (ret)
+   ret = CMD_RET_FAILURE;
+
+   return ret;
+}
+
 static int bootm_find_os(struct cmd_tbl *cmdtp, int flag, int argc,
 char *const argv[])
 {
@@ -677,6 +704,9 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int 
argc,
if (states & BOOTM_STATE_START)
ret = bootm_start(cmdtp, flag, argc, argv);
 
+   if (!ret && (states & BOOTM_STATE_PRE_LOAD))
+   ret = bootm_pre_load(cmdtp, flag, argc, argv);
+
if (!ret && (states & BOOTM_STATE_FINDOS))
ret = bootm_find_os(cmdtp, flag, argc, argv);
 
@@ -866,6 +896,9 @@ static const void *boot_get_kernel(struct cmd_tbl *cmdtp, 
int flag, int argc,
  _uname_config,
  _uname_kernel);
 
+   if (CONFIG_IS_ENABLED(CMD_BOOTM_PRE_LOAD))
+   img_addr += image_load_offset;
+
bootstage_mark(BOOTSTAGE_ID_CHECK_MAGIC);
 
/* check image type, for FIT images get FIT kernel node */
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 5e25e45fd2..87aa3fb11a 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -194,6 +194,16 @@ config CMD_BOOTM
help
  Boot an application image from the memory.
 
+config CMD_BOOTM_PRE_LOAD
+   bool "enable pre-load on bootm"
+   depends on CMD_BOOTM
+   depends on IMAGE_PRE_LOAD
+   default n
+   help
+ Enable support of stage pre-load for the bootm command.
+This stage allow to check or modify the image provided
+to the bootm command.
+
 config BOOTM_EFI
bool "Support booting UEFI FIT images"
depends on CMD_BOOTEFI && CMD_BOOTM && FIT
diff --git a/cmd/bootm.c b/cmd/bootm.c
index e8b7066888..c5de339fba 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -126,7 +126,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
}
 
return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START |
-   BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER |
+   BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD | 
BOOTM_STATE_FINDOTHER |
BOOTM_STATE_LOADOS |
 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
BOOTM_STATE_RAMDISK |
diff --git a/include/image.h b/include/image.h
index fbcf70f5e4..496b7af3f3 100644
--- a/include/image.h
+++ b/include/image.h
@@ -351,6 +351,7 @@ typedef struct bootm_headers {
 #defineBOOTM_STATE_OS_PREP (0x0100)
 #defineBOOTM_STATE_OS_FAKE_GO  (0x0200)/* 'Almost' run the OS 
*/
 #defineBOOTM_STATE_OS_GO   (0x0400)
+#defineBOOTM_STATE_PRE_LOAD0x0800
int state;
 
 #if defined(CONFIG_LMB) && !defined(USE_HOSTCC)
-- 
2.17.1



[PATCH v6 00/16] image: add a stage pre-load

2022-02-25 Thread Philippe Reynes
This serie adds a stage pre-load before launching an image.
This stage is used to read a header before the image and
this header contains the signature of the full image.
So u-boot may check the full image before using any
data of the image.

The support of this header is added to binman, and
a command verify checks the signature of a blob and
set the u-boot env variable "loadaddr_verified" to 
the beginning of the "real" image.

The support of this header is only added to binman,
but it may also be added to mkimage. 


Changelog:
v6:
- set values in big endian in the pre-load header
- binman: etypes: pre-load: read image from other entry
  instead of directly from a file
- binman: etypes: pre-load: add test unit
- lib: Makefile: no longer add -I$(obj) for SPL
   It was to fix build when oid is built on spl but not
   on u-boot. It is not longer possible.
v5:
- replace config SANDBOX_BINMAN by an imply
v4:
- add a config SANDBOX_BIN
- enhance help for asn1 and oid
- change the format of the pre-load header
- add the support of pre-load header in binman
- add py test for pre-load header
- add a command verify
v3:
- move image-pre-load.c to /boot
- update mkimage to add public key in u-boot device tree
- add script gen_pre_load_header.sh
v2:
- move the code to image-pre-load
- add support of stage pre-load for spl
- add support of stage pre-load on spl_ram

Philippe Reynes (16):
  arch: Kconfig: imply BINMAN for SANDBOX
  lib: Kconfig: enhance help for ASN1
  lib: Kconfig: enhance the help of OID_REGISTRY
  lib: allow to build asn1 decoder and oid registry in SPL
  lib: crypto: allow to build crypyo in SPL
  lib: rsa: allow rsa verify with pkey in SPL
  boot: image: add a stage pre-load
  cmd: bootm: add a stage pre-load
  common: spl: fit_ram: allow to use image pre load
  mkimage: add public key for image pre-load stage
  Makefile: provide sah-key to binman
  tools: binman: add support for pre-load header
  configs: sandbox_defconfig: enable stage pre-load in bootm
  test: py: vboot: add test for global image signature
  cmd: verify: initial import
  configs: sandbox_defconfig: enable config CMD_VERIFY

 Makefile  |   1 +
 arch/Kconfig  |   1 +
 arch/sandbox/dts/sandbox.dtsi |   3 +
 arch/sandbox/dts/test.dts |   3 +
 boot/Kconfig  |  55 +++
 boot/Makefile |   1 +
 boot/bootm.c  |  33 ++
 boot/image-pre-load.c | 416 ++
 cmd/Kconfig   |  17 +
 cmd/Makefile  |   1 +
 cmd/bootm.c   |   2 +-
 cmd/verify.c  |  53 +++
 common/spl/spl_ram.c  |  21 +-
 configs/sandbox_defconfig |   4 +
 include/image.h   |  30 ++
 lib/Kconfig   |  37 +-
 lib/Makefile  |   7 +-
 lib/crypto/Kconfig|  29 ++
 lib/crypto/Makefile   |  19 +-
 lib/rsa/Kconfig   |  19 +
 test/py/tests/test_fit.py |   3 +
 test/py/tests/test_vboot.py   | 125 +-
 test/py/tests/vboot/sandbox-binman-pss.dts|  25 ++
 test/py/tests/vboot/sandbox-binman.dts|  24 +
 .../tests/vboot/sandbox-u-boot-global-pss.dts |  28 ++
 test/py/tests/vboot/sandbox-u-boot-global.dts |  27 ++
 test/py/tests/vboot/sandbox-u-boot.dts|   3 +
 test/py/tests/vboot/simple-images.its |  36 ++
 tools/binman/etype/pre_load.py| 165 +++
 tools/binman/ftest.py |  45 ++
 tools/binman/test/225_dev.key |  28 ++
 tools/binman/test/225_pre_load.dts|  22 +
 tools/binman/test/226_pre_load_pkcs.dts   |  23 +
 tools/binman/test/227_pre_load_pss.dts|  23 +
 .../test/228_pre_load_invalid_padding.dts |  23 +
 .../binman/test/229_pre_load_invalid_sha.dts  |  23 +
 .../binman/test/230_pre_load_invalid_algo.dts |  23 +
 .../binman/test/231_pre_load_invalid_key.dts  |  23 +
 tools/fit_image.c |   3 +
 tools/image-host.c| 114 +
 40 files changed, 1510 insertions(+), 28 deletions(-)
 create mode 100644 boot/image-pre-load.c
 create mode 100644 cmd/verify.c
 create mode 100644 test/py/tests/vboot/sandbox-binman-pss.dts
 create mode 100644 test/py/tests/vboot/sandbox-binman.dts
 create mode 100644 test/py/tests/vboot/sandbox-u-boot-global-pss.dts
 create mode 100644 test/py/tests/vboot/sandbox-u-boot-global.dts
 create mode 100644 test/py/tests/vboot/simple-images.its
 create mode 100644 tools/binman/etype/pre_load.py
 create mode 100644 tools/binman/test/225_dev.key
 create mode 100644 

[PATCH v6 01/16] arch: Kconfig: imply BINMAN for SANDBOX

2022-02-25 Thread Philippe Reynes
To be able to use the tool binman on sandbox,
the config SANDBOX should imply BINMAN.

Reviewed-by: Simon Glass 
Signed-off-by: Philippe Reynes 
---
 arch/Kconfig   | 1 +
 arch/sandbox/dts/sandbox.dtsi  | 3 +++
 arch/sandbox/dts/test.dts  | 3 +++
 test/py/tests/test_fit.py  | 3 +++
 test/py/tests/vboot/sandbox-u-boot.dts | 3 +++
 5 files changed, 13 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index e6191446a3..35624377ca 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -203,6 +203,7 @@ config SANDBOX
imply KEYBOARD
imply PHYSMEM
imply GENERATE_ACPI_TABLE
+   imply BINMAN
 
 config SH
bool "SuperH architecture"
diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 66b813faad..826db26fc2 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -7,6 +7,9 @@
 #define USB_CLASS_HUB  9
 
 / {
+   binman {
+   };
+
chosen {
stdout-path = "/serial";
};
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 48ca3e1e47..c11ad8cb9f 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -61,6 +61,9 @@
osd0 = "/osd";
};
 
+   binman {
+   };
+
config {
testing-bool;
testing-int = <123>;
diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py
index 6d5b43c3ba..5856960be2 100755
--- a/test/py/tests/test_fit.py
+++ b/test/py/tests/test_fit.py
@@ -89,6 +89,9 @@ base_fdt = '''
model = "Sandbox Verified Boot Test";
compatible = "sandbox";
 
+   binman {
+   };
+
reset@0 {
compatible = "sandbox,reset";
reg = <0>;
diff --git a/test/py/tests/vboot/sandbox-u-boot.dts 
b/test/py/tests/vboot/sandbox-u-boot.dts
index 63f8f401de..5809c62fc1 100644
--- a/test/py/tests/vboot/sandbox-u-boot.dts
+++ b/test/py/tests/vboot/sandbox-u-boot.dts
@@ -4,6 +4,9 @@
model = "Sandbox Verified Boot Test";
compatible = "sandbox";
 
+   binman {
+   };
+
reset@0 {
compatible = "sandbox,reset";
};
-- 
2.17.1



Re: [PATCH 1/2] ARM: imx: imx8mn-evk: enable DM_SERIAL

2022-02-25 Thread Fabio Estevam
Hi Heiko,

On Fri, Feb 25, 2022 at 10:21 AM Heiko Thiery  wrote:
>
> Signed-off-by: Heiko Thiery 

Please provide a commit log explaining why you are doing this change.

Thanks


Re: [PATCH 1/1] cmd: pwm: fix typo 'eisable' -> 'disable'

2022-02-25 Thread Michal Simek




On 2/25/22 14:48, Sébastien Szymanski wrote:

Fixed misspelled 'disable' in help text.

Signed-off-by: Sébastien Szymanski 
---
  cmd/pwm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/pwm.c b/cmd/pwm.c
index 7947e61aee..7e82955239 100644
--- a/cmd/pwm.c
+++ b/cmd/pwm.c
@@ -111,5 +111,5 @@ U_BOOT_CMD(pwm, 6, 0, do_pwm,
   "invert- invert polarity\n"
   "pwm config - config 
PWM\n"
   "pwm enable   - enable PWM output\n"
-  "pwm disable   - eisable PWM output\n"
+  "pwm disable   - disable PWM output\n"
   "Note: All input values are in decimal");


Applied also with fixed tag added.
Fixes: a84d3b6c5634 ("cmd: pwm: Remove additional pwm description")

Thanks,
Michal


[PATCH 2/2] bootcount: Add pmic pfuze100 bootcount driver

2022-02-25 Thread Philip Oberfichtner
Use the MEMA - MEMD registers on the PFUZE100 as bootcount
registers.

Based on work from Heiko Schocher .
Signed-off-by: Philip Oberfichtner 

---

 drivers/bootcount/Kconfig   |  7 ++
 drivers/bootcount/Makefile  |  1 +
 drivers/bootcount/bootcount_pmic_pfuze100.c | 83 +
 3 files changed, 91 insertions(+)
 create mode 100644 drivers/bootcount/bootcount_pmic_pfuze100.c

diff --git a/drivers/bootcount/Kconfig b/drivers/bootcount/Kconfig
index 607027c968..9c37fa8ec8 100644
--- a/drivers/bootcount/Kconfig
+++ b/drivers/bootcount/Kconfig
@@ -73,6 +73,13 @@ config BOOTCOUNT_ENV
  So the Userspace Application must set the "upgrade_available"
  and "bootcount" variable to 0, if a boot was successfully.
 
+config BOOTCOUNT_PMIC_PFUZE100
+   bool "Enable Bootcount driver for PMIC PFUZE100"
+   depends on DM_PMIC_PFUZE100
+   help
+ Enable support for the bootcounter using PMIC PFUZE100 registers.
+ This works only, if the PMIC is not connected.
+
 config BOOTCOUNT_RAM
bool "Boot counter in RAM"
help
diff --git a/drivers/bootcount/Makefile b/drivers/bootcount/Makefile
index 3a784bb0a6..d167815b3c 100644
--- a/drivers/bootcount/Makefile
+++ b/drivers/bootcount/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_BOOTCOUNT_ENV) += bootcount_env.o
 obj-$(CONFIG_BOOTCOUNT_I2C)+= bootcount_i2c.o
 obj-$(CONFIG_BOOTCOUNT_EXT)+= bootcount_ext.o
 obj-$(CONFIG_BOOTCOUNT_AM33XX_NVMEM)   += bootcount_nvmem.o
+obj-$(CONFIG_BOOTCOUNT_PMIC_PFUZE100)  += bootcount_pmic_pfuze100.o
 
 obj-$(CONFIG_DM_BOOTCOUNT)  += bootcount-uclass.o
 obj-$(CONFIG_DM_BOOTCOUNT_RTC)  += rtc.o
diff --git a/drivers/bootcount/bootcount_pmic_pfuze100.c 
b/drivers/bootcount/bootcount_pmic_pfuze100.c
new file mode 100644
index 00..d732618218
--- /dev/null
+++ b/drivers/bootcount/bootcount_pmic_pfuze100.c
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Denx Software Engineering GmbH
+ * Heiko Schocher 
+ *
+ * A bootcount driver using the registers MEMA - MEMD on the PFUZE100.
+ * This works only, if the PMIC is not connected.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define PFUZE_BC_MAGIC 0xdead
+
+static ulong pfuze100_get_magic(struct udevice *dev)
+{
+   ulong magic;
+
+   magic = pmic_reg_read(dev, PFUZE100_MEMA);
+   magic += pmic_reg_read(dev, PFUZE100_MEMB) << 8;
+   return magic;
+}
+
+static void pfuze100_set_magic(struct udevice *dev)
+{
+   pmic_reg_write(dev, PFUZE100_MEMA, PFUZE_BC_MAGIC & 0xff);
+   pmic_reg_write(dev, PFUZE100_MEMB, (PFUZE_BC_MAGIC >> 8) & 0xff);
+}
+
+static ulong pfuze100_get_value(struct udevice *dev)
+{
+   ulong val;
+
+   val = pmic_reg_read(dev, PFUZE100_MEMC);
+   val += pmic_reg_read(dev, PFUZE100_MEMD) << 8;
+   return val;
+}
+
+static void pfuze100_set_val(struct udevice *dev, ulong val)
+{
+   pmic_reg_write(dev, PFUZE100_MEMC, val & 0xff);
+   pmic_reg_write(dev, PFUZE100_MEMD, (val >> 8) & 0xff);
+}
+
+void bootcount_store(ulong a)
+{
+   struct udevice *dev;
+   int ret;
+
+   ret = pmic_get("pfuze100@8", );
+   if (ret != 0)
+   return;
+
+   pfuze100_set_magic(dev);
+   pfuze100_set_val(dev, a);
+}
+
+ulong bootcount_load(void)
+{
+   struct udevice *dev;
+   int ret;
+   ulong val;
+   ulong magic;
+
+   ret = pmic_get("pfuze100@8", );
+   if (ret != 0)
+   return 0;
+
+   magic = pfuze100_get_magic(dev);
+   if (magic != PFUZE_BC_MAGIC)
+   return 0;
+
+   val = pfuze100_get_value(dev);
+   return val;
+}
-- 
2.34.1



[PATCH 1/2] power: pfuze100: Add MEMx register definitions

2022-02-25 Thread Philip Oberfichtner
Add missing MEMA - MEMD register definitions for PFUZE100.

Based on work from Heiko Schocher .
Signed-off-by: Philip Oberfichtner 

---

 include/power/pfuze100_pmic.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/power/pfuze100_pmic.h b/include/power/pfuze100_pmic.h
index f4383ed778..278f2549bf 100644
--- a/include/power/pfuze100_pmic.h
+++ b/include/power/pfuze100_pmic.h
@@ -18,6 +18,11 @@ enum {
PFUZE100_REVID  = 0x03,
PFUZE100_FABID  = 0x04,
 
+   PFUZE100_MEMA   = 0x1c,
+   PFUZE100_MEMB   = 0x1d,
+   PFUZE100_MEMC   = 0x1e,
+   PFUZE100_MEMD   = 0x1f,
+
PFUZE100_SW1ABVOL   = 0x20,
PFUZE100_SW1ABSTBY  = 0x21,
PFUZE100_SW1ABOFF   = 0x22,
-- 
2.34.1



[PATCH 0/2] Add pmic bootcount driver

2022-02-25 Thread Philip Oberfichtner


This series adds a new bootcount driver. The required register definitions
and the actual driver are separated in two patches.


Philip Oberfichtner (2):
  power: pfuze100: Add MEMx register definitions
  bootcount: Add pmic pfuze100 bootcount driver

 drivers/bootcount/Kconfig   |  7 ++
 drivers/bootcount/Makefile  |  1 +
 drivers/bootcount/bootcount_pmic_pfuze100.c | 83 +
 include/power/pfuze100_pmic.h   |  5 ++
 4 files changed, 96 insertions(+)
 create mode 100644 drivers/bootcount/bootcount_pmic_pfuze100.c

-- 
2.34.1



Re: IMX8MM 4GiB boundary issue

2022-02-25 Thread Marek Vasut

On 2/25/22 12:37, Mark Kettenis wrote:

From: Fabio Estevam 
Date: Fri, 25 Feb 2022 08:12:58 -0300

Hi Tim,

On Thu, Feb 24, 2022 at 6:46 PM Tim Harvey  wrote:


Fabio,

No, that commit is 'not' in v2021.07. Please test with master and you
should see that go away.


Yes, you are right.


Regardless, Marek's suggestion is the right fix if you can manage
that... we really don't want to limit 4GB boards to 3GB. I was hoping
NXP would step up and address the peripheral drivers for this.


Agreed, thanks!


But isn't the problem here that (some of) the hardware peripherals
simply can't address memory above the 4GB boundary?

OS kernels can work around such limitations by using an IOMMU (if
provided by the hardware) or by using bounce buffers (swiotlb in Linux
speak).


Right, see bounce_buffer in U-Boot.


The traditional way to deal with this in u-boot is to make
sure that u-boot only uses memory below the 4GB boundary by
implementing board_get_usable_ram_top() and making sure that all the
addresses in the u-boot environment are in "low" memory.


The board_get_usable_ram_top() purpose was something else entirely at 
the beginning, it only started being misused to work around driver 
issues instead of fixing them later and that is utterly wrong.



For EFI
support there is the CONFIG_EFI_LOADER_BOUNCE_BUFFER option, which
should be set to "y" in this case.


There is generic bounce buffer for drivers, see common/bouncebuf.c .


[PATCH 1/1] cmd: pwm: fix typo 'eisable' -> 'disable'

2022-02-25 Thread Sébastien Szymanski
Fixed misspelled 'disable' in help text.

Signed-off-by: Sébastien Szymanski 
---
 cmd/pwm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/pwm.c b/cmd/pwm.c
index 7947e61aee..7e82955239 100644
--- a/cmd/pwm.c
+++ b/cmd/pwm.c
@@ -111,5 +111,5 @@ U_BOOT_CMD(pwm, 6, 0, do_pwm,
   "invert- invert polarity\n"
   "pwm config - config 
PWM\n"
   "pwm enable   - enable PWM output\n"
-  "pwm disable   - eisable PWM output\n"
+  "pwm disable   - disable PWM output\n"
   "Note: All input values are in decimal");
-- 
2.34.1



RE: [PATCH] armv8: fsl-layerscape: use previous aligned address for gic_lpi_base

2022-02-25 Thread Z.Q. Hou
Hi Wasim, Marc and all,

> -Original Message-
> From: Wasim Khan (OSS) 
> Sent: 2022年2月21日 21:23
> To: Marc Zyngier ; Michael Walle ;
> Z.Q. Hou 
> Cc: Wasim Khan (OSS) ; s...@chromium.org;
> Priyanka Jain ; tred...@nvidia.com;
> twar...@nvidia.com; Varun Sethi ;
> u-boot@lists.denx.de
> Subject: RE: [PATCH] armv8: fsl-layerscape: use previous aligned address for
> gic_lpi_base
> 
> Hi Marc, Zhiqiang
> 
> > -Original Message-
> > From: Marc Zyngier 
> > Sent: Monday, February 21, 2022 4:23 PM
> > To: Michael Walle 
> > Cc: Wasim Khan (OSS) ; s...@chromium.org;
> > Priyanka Jain ; tred...@nvidia.com;
> > twar...@nvidia.com; Varun Sethi ; u-
> > b...@lists.denx.de; Wasim Khan 
> > Subject: Re: [PATCH] armv8: fsl-layerscape: use previous aligned
> > address for gic_lpi_base
> >
> > On Mon, 21 Feb 2022 10:24:36 +,
> > Michael Walle  wrote:
> > >
> > > Hi,
> > >
> > > Am 2022-02-21 11:16, schrieb Wasim Khan:
> > > > From: Wasim Khan 
> > > >
> > > > Memory after gd->arch.resv_ram is reserved for MC block.
> > > > Use ALIGN_DOWN to avoid updating MC block for unaligned address.
> > >
> > > I cannot really tell what you are trying to do here. But I know Marc
> > > has offered to also take a look at the GIC/LPI stuff. So I've put
> > > him on CC.
> > >
> > > -michael
> > >
> > > >
> > > > Signed-off-by: Wasim Khan 
> > > > ---
> > > >  arch/arm/cpu/armv8/fsl-layerscape/soc.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
> > > > b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
> > > > index d3a5cfaac1..746c93cf51 100644
> > > > --- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
> > > > +++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
> > > > @@ -65,7 +65,7 @@ int ls_gic_rd_tables_init(void *blob)
> > > > u64 gic_lpi_base;
> > > > int ret;
> > > >
> > > > -   gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
> > > > +   gic_lpi_base = ALIGN_DOWN(gd->arch.resv_ram - GIC_LPI_SIZE,
> > > > +SZ_64K);
> > > > ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base,
> > > > GIC_LPI_SIZE);
> > > > if (ret)
> > > > return ret;
> > >
> >
> > It is the usual accumulation of nonsense. We have
> >
> > #define ITS_MAX_LPI_NRBITS16
> >
> > which is not necessarily what the HW exposes
> >
> > #define PENDTABLE_MAX_SZALIGN(BIT(ITS_MAX_LPI_NRBITS),
> SZ_64K)
> >
> > The *base* of the pending table has to be 64kB aligned, but not its
> > size. Yes, that's a helpful shortcut, but that's still wrong.
> >
> > #define PROPTABLE_MAX_SZALIGN(BIT(ITS_MAX_LPI_NRBITS) /
> 8,
> > SZ_64K)
> >
> > This 64kB alignment is silly, specially considering the hardcoding of
> > the number of ID bits.
> >
> > #define GIC_LPI_SIZEALIGN(cpu_numcores() *
> PENDTABLE_MAX_SZ +
> > \
> > PROPTABLE_MAX_SZ, SZ_1M)
> >
> > This 1MB alignment doesn't exist. Convenience again?
> >
> > And then this patch adds some bizarre alignment for reasons that have
> > nothing to do with the GIC, but because there is so other reservations
> > this steps on, which probably means that the allocator is doing something
> wrong...
> >
> > The whole thing needs reworking from first principle, at which point
> > it will become clearer what this is trying to do.
> >
> > M.
> >
> > --
> > Without deviation from the norm, progress is not possible.
> 
> 
> Added Zhiqiang to respond to Marc's questions.

I've submit a patch to recode the whole gic-v3-its.c, with that patch we don't 
need these platform specific code anymore, I pasted its link below for your 
reference:
http://patchwork.ozlabs.org/project/uboot/patch/20220225134106.24186-1-zhiqiang@nxp.com/

Thanks,
Zhiqiang

> 
> 
> Regarding this patch:
> if gd->arch.resv_ram points to some address which is not 64K aligned (as per
> current code), Using ALIGN can be problematic in that case.
> 
> Ex:
> Currently MC reserved regions is [0x27_8000_ , 0x27__]
> gd->arch.resv_ram point to 0x27_8000_.
> 
> Now suppose if I have requirement to reserve a block (say XYZ) of 32KB size
> just before MC block,  i will update gd->arch.resv_ram to point to
> 0x27_7FFF_8000.
> Now, Calling ' gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE,
> SZ_64K);' will eat up space reserved for XYZ.
> 
> So, I think ALIGN_DOWN should be used for gic_lpi_base .
> gic_lpi_base = ALIGN_DOWN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);



[PATCH] arch: arm: recode the initialization of GICv3 ITS Re-Distributor tables

2022-02-25 Thread Zhiqiang Hou
From: Hou Zhiqiang 

The current implementation needs the caller provides the memory region
for the property and pending tables and the number of re-distibutor,
and it doesn't handle the address alignment of the tables and doesn't
help to add the reserved-memory node for the tables.

This patch change to use the device tree blob as argument and deal with
the aboves in the internal of this helper to make it easier to use.

Signed-off-by: Hou Zhiqiang 
---
 arch/arm/Kconfig|   1 -
 arch/arm/cpu/armv8/fsl-layerscape/fdt.c |   4 +-
 arch/arm/cpu/armv8/fsl-layerscape/soc.c |  46 +---
 arch/arm/include/asm/gic-v3.h   |   4 +-
 arch/arm/lib/gic-v3-its.c   | 142 ++--
 5 files changed, 62 insertions(+), 135 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 391a77c2b4..0f6a32b428 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -82,7 +82,6 @@ config GICV3
 
 config GIC_V3_ITS
bool "ARM GICV3 ITS"
-   select IRQ
help
  ARM GICV3 Interrupt translation service (ITS).
  Basic support for programming locality specific peripheral
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c 
b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
index 2fa7ebf163..10cb675fae 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014-2015 Freescale Semiconductor, Inc.
- * Copyright 2020-2021 NXP
+ * Copyright 2020-2022 NXP
  */
 
 #include 
@@ -653,7 +653,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)
 get_board_sys_clk(), 1);
 
 #ifdef CONFIG_GIC_V3_ITS
-   ls_gic_rd_tables_init(blob);
+   gic_lpi_tables_init(blob);
 #endif
 
 #if defined(CONFIG_PCIE_LAYERSCAPE) || defined(CONFIG_PCIE_LAYERSCAPE_GEN4)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index d3a5cfaac1..51ed942f57 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -1,17 +1,15 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014-2015 Freescale Semiconductor
- * Copyright 2019-2021 NXP
+ * Copyright 2019-2022 NXP
  */
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -21,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
 #include 
 #endif
@@ -36,47 +33,6 @@
 #include 
 #include 
 #include 
-#ifdef CONFIG_GIC_V3_ITS
-DECLARE_GLOBAL_DATA_PTR;
-#endif
-
-#ifdef CONFIG_GIC_V3_ITS
-#define PENDTABLE_MAX_SZ   ALIGN(BIT(ITS_MAX_LPI_NRBITS), SZ_64K)
-#define PROPTABLE_MAX_SZ   ALIGN(BIT(ITS_MAX_LPI_NRBITS) / 8, SZ_64K)
-#define GIC_LPI_SIZE   ALIGN(cpu_numcores() * PENDTABLE_MAX_SZ + \
-   PROPTABLE_MAX_SZ, SZ_1M)
-static int fdt_add_resv_mem_gic_rd_tables(void *blob, u64 base, size_t size)
-{
-   int err;
-   struct fdt_memory gic_rd_tables;
-
-   gic_rd_tables.start = base;
-   gic_rd_tables.end = base + size - 1;
-   err = fdtdec_add_reserved_memory(blob, "gic-rd-tables", _rd_tables,
-NULL, 0, NULL, 0);
-   if (err < 0)
-   debug("%s: failed to add reserved memory: %d\n", __func__, err);
-
-   return err;
-}
-
-int ls_gic_rd_tables_init(void *blob)
-{
-   u64 gic_lpi_base;
-   int ret;
-
-   gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
-   ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
-   if (ret)
-   return ret;
-
-   ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());
-   if (ret)
-   debug("%s: failed to init gic-lpi-tables\n", __func__);
-
-   return ret;
-}
-#endif
 
 bool soc_has_dp_ddr(void)
 {
diff --git a/arch/arm/include/asm/gic-v3.h b/arch/arm/include/asm/gic-v3.h
index 5131fabec4..e2e175f065 100644
--- a/arch/arm/include/asm/gic-v3.h
+++ b/arch/arm/include/asm/gic-v3.h
@@ -127,9 +127,9 @@
 #define GIC_REDISTRIBUTOR_OFFSET 0x2
 
 #ifdef CONFIG_GIC_V3_ITS
-int gic_lpi_tables_init(u64 base, u32 max_redist);
+int gic_lpi_tables_init(void *blob);
 #else
-int gic_lpi_tables_init(u64 base, u32 max_redist)
+int gic_lpi_tables_init(void *blob);
 {
return 0;
 }
diff --git a/arch/arm/lib/gic-v3-its.c b/arch/arm/lib/gic-v3-its.c
index f6211a2d92..3ef1e74954 100644
--- a/arch/arm/lib/gic-v3-its.c
+++ b/arch/arm/lib/gic-v3-its.c
@@ -1,92 +1,65 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2019 Broadcom.
+ * Copyright 2022 NXP
  */
+
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 static u32 lpi_id_bits;
 
 #define LPI_NRBITS lpi_id_bits
-#define LPI_PROPBASE_SZALIGN(BIT(LPI_NRBITS), SZ_64K)
+#define LPI_PROPBASE_SZ

[PATCH 2/2] ARM: imx: imx8mn-ddr4-evk: enable DM_SERIAL

2022-02-25 Thread Heiko Thiery
Signed-off-by: Heiko Thiery 
---
 configs/imx8mn_ddr4_evk_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/imx8mn_ddr4_evk_defconfig 
b/configs/imx8mn_ddr4_evk_defconfig
index c13885ab5e..05aa4fb259 100644
--- a/configs/imx8mn_ddr4_evk_defconfig
+++ b/configs/imx8mn_ddr4_evk_defconfig
@@ -77,6 +77,8 @@ CONFIG_PINCTRL_IMX8M=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
+# CONFIG_SPL_DM_SERIAL is not set
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
-- 
2.30.2



[PATCH 1/2] ARM: imx: imx8mn-evk: enable DM_SERIAL

2022-02-25 Thread Heiko Thiery
Signed-off-by: Heiko Thiery 
---
 configs/imx8mn_evk_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/imx8mn_evk_defconfig b/configs/imx8mn_evk_defconfig
index 95ac6f85fa..15909d545c 100644
--- a/configs/imx8mn_evk_defconfig
+++ b/configs/imx8mn_evk_defconfig
@@ -84,6 +84,8 @@ CONFIG_DM_REGULATOR=y
 CONFIG_SPL_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
+# CONFIG_SPL_DM_SERIAL is not set
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
-- 
2.30.2



[PATCH 0/2] enable DM_SERIAL on imx8mn-evk and imx8mn-ddr4-evk

2022-02-25 Thread Heiko Thiery
I was only able to test it on a 8MNANOD3L-EVK board. Please help testing
this change on the other 2 eval boards (8MNANOLPD4-EVK, 8MNANOD4-EVK).

Heiko Thiery (2):
  ARM: imx: imx8mn-evk: enable DM_SERIAL
  ARM: imx: imx8mn-ddr4-evk: enable DM_SERIAL

 configs/imx8mn_ddr4_evk_defconfig | 2 ++
 configs/imx8mn_evk_defconfig  | 2 ++
 2 files changed, 4 insertions(+)

-- 
2.30.2



Re: [PATCH v3] scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

2022-02-25 Thread Heiko Thiery
Hi,

Am Di., 22. Feb. 2022 um 14:55 Uhr schrieb Philippe Reynes
:
>
> There is a conflict between the static file
> lib/acpi/dsdt.c and the file dsdt.c generated
> dynamicaly by scripts/Makefile.lib. When a
> mrproper is done, the static file dsdt.c is
> removed. If a build with acpi enabled is
> launched after, the following error is raised:
>
>   CC  lib/acpi/acpi_table.o
> make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
> 'lib/acpi/dsdt.c'.  Stop.
> scripts/Makefile.build:394: recipe for target 'lib/acpi' failed
>
> To avoid such error, the generated file is named
> dsdt_generated.c instead of dstdt.c.

This issue can also be seen when doing a make clean and do a git status

-- 8< --
Changes not staged for commit:
  (use "git add/rm ..." to update what will be committed)
  (use "git restore ..." to discard changes in working directory)
deleted:lib/acpi/dsdt.c
-- 8< --

After applying this patch this cannot be seen anymore.

>
>
> Signed-off-by: Philippe Reynes 

Tested-by: Heiko Thiery 

> ---
>
> Changelog:
> v3:
> - update comments in file scripts/Makefile.lib
> - add changelog
> v2
> - change generated file name (dsdt_generated.c)
>   instead of changing the name of the static file
> - NOTE : forgot to call it v2 and forgot changelog
>
> Makefile| 3 ++-
>  board/advantech/som-db5800-som-6867/Makefile| 2 +-
>  board/congatec/conga-qeval20-qa3-e3845/Makefile | 2 +-
>  board/dfi/dfi-bt700/Makefile| 2 +-
>  board/google/chromebook_coral/Makefile  | 2 +-
>  board/intel/bayleybay/Makefile  | 2 +-
>  board/intel/edison/Makefile | 2 +-
>  board/intel/galileo/Makefile| 2 +-
>  board/intel/minnowmax/Makefile  | 2 +-
>  scripts/Makefile.lib| 8 
>  10 files changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 4b152249ca..94bc48f00c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2226,7 +2226,8 @@ clean: $(clean-dirs)
> -o -name '*.asn1.[ch]' \
> -o -name '*.symtypes' -o -name 'modules.order' \
> -o -name modules.builtin -o -name '.tmp_*.o.*' \
> -   -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' 
> \
> +   -o -name 'dsdt_generated.aml' -o -name 
> 'dsdt_generated.asl.tmp' \
> +   -o -name 'dsdt_generated.c' \
> -o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \
> -type f -print | xargs rm -f
>
> diff --git a/board/advantech/som-db5800-som-6867/Makefile 
> b/board/advantech/som-db5800-som-6867/Makefile
> index 7975547f41..95af6c4df7 100644
> --- a/board/advantech/som-db5800-som-6867/Makefile
> +++ b/board/advantech/som-db5800-som-6867/Makefile
> @@ -3,4 +3,4 @@
>  # Copyright (C) 2015, Google, Inc
>
>  obj-y  += som-db5800-som-6867.o
> -obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
> +obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
> diff --git a/board/congatec/conga-qeval20-qa3-e3845/Makefile 
> b/board/congatec/conga-qeval20-qa3-e3845/Makefile
> index 451a4fcd6c..215f5680dc 100644
> --- a/board/congatec/conga-qeval20-qa3-e3845/Makefile
> +++ b/board/congatec/conga-qeval20-qa3-e3845/Makefile
> @@ -3,4 +3,4 @@
>  # Copyright (C) 2015, Google, Inc
>
>  obj-y  += conga-qeval20-qa3.o
> -obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
> +obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
> diff --git a/board/dfi/dfi-bt700/Makefile b/board/dfi/dfi-bt700/Makefile
> index 50d88f2954..1c4329a058 100644
> --- a/board/dfi/dfi-bt700/Makefile
> +++ b/board/dfi/dfi-bt700/Makefile
> @@ -3,4 +3,4 @@
>  # Copyright (C) 2015, Google, Inc
>
>  obj-y  += dfi-bt700.o
> -obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
> +obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
> diff --git a/board/google/chromebook_coral/Makefile 
> b/board/google/chromebook_coral/Makefile
> index f7a0ca6cc0..846558d777 100644
> --- a/board/google/chromebook_coral/Makefile
> +++ b/board/google/chromebook_coral/Makefile
> @@ -3,4 +3,4 @@
>  # Copyright 2019 Google LLC
>
>  obj-y  += coral.o
> -obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
> +obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
> diff --git a/board/intel/bayleybay/Makefile b/board/intel/bayleybay/Makefile
> index d19447184a..fa263b7bf5 100644
> --- a/board/intel/bayleybay/Makefile
> +++ b/board/intel/bayleybay/Makefile
> @@ -3,4 +3,4 @@
>  # Copyright (C) 2015, Bin Meng 
>
>  obj-y  += bayleybay.o
> -obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
> +obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
> diff --git a/board/intel/edison/Makefile b/board/intel/edison/Makefile
> index 1eaf7ca7f8..f7f70dfaa7 100644
> --- a/board/intel/edison/Makefile
> +++ b/board/intel/edison/Makefile
> @@ -5,4 +5,4 @@
>  #
>
>  obj-y  += edison.o
> -obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
> +obj-$(CONFIG_GENERATE_ACPI_TABLE) += 

[PATCH 3/4] ARM: omap3_beagle: Enable Pinctrl

2022-02-25 Thread Romain Naour
The simple pinctrl driver currently available works with the omap3.
Enabling this will use the device tree to automatically set the
pin-muxing for various drivers.

Based on commit: 57dbf754e37d3347cad441f3869bf72c0d726a71

Signed-off-by: Romain Naour 
---
 configs/omap3_beagle_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/omap3_beagle_defconfig b/configs/omap3_beagle_defconfig
index 206118e6af..a9b2c15cee 100644
--- a/configs/omap3_beagle_defconfig
+++ b/configs/omap3_beagle_defconfig
@@ -83,6 +83,8 @@ CONFIG_SYS_NAND_BUSWIDTH_16BIT=y
 CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
 CONFIG_SYS_NAND_U_BOOT_OFFS=0x8
 CONFIG_DM_ETH=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_SINGLE=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_OMAP3_SPI=y
-- 
2.35.1



[PATCH 4/4] ARM: omap3_beagle: Enable DM_PMIC and DM_REGULATOR

2022-02-25 Thread Romain Naour
Enabling DM_PMIC, DM_REGULATOR_FIXED, and DM_REGULATOR_GPIO
gives us the ability to better monitor voltages and enable
hardware through the device tree. The TL4030 (TPS65950) is
not yet migrated to DM, so this patch only enables the fixed
and GPIO controlled regulators.

Based on commit [1][2].

[1] a40d3cc845756e1e38af5ac31986539417e64abb
[2] 2448e42d73fb91e4b56bb41b2677e18ab99a6c83

Signed-off-by: Romain Naour 
---
 configs/omap3_beagle_defconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/configs/omap3_beagle_defconfig b/configs/omap3_beagle_defconfig
index a9b2c15cee..c7111f4e63 100644
--- a/configs/omap3_beagle_defconfig
+++ b/configs/omap3_beagle_defconfig
@@ -85,6 +85,11 @@ CONFIG_SYS_NAND_U_BOOT_OFFS=0x8
 CONFIG_DM_ETH=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_SINGLE=y
+CONFIG_DM_PMIC=y
+# CONFIG_SPL_PMIC_CHILDREN is not set
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_OMAP3_SPI=y
-- 
2.35.1



[PATCH 2/4] ARM: omap3_beagle: Power on MMC when setting up PMIC

2022-02-25 Thread Romain Naour
The PMIC enables power to the MMC card by default, but depending
on the state it was left when restarted, it's possible the MMC
may be powered down.

This patch patch explicitly tells the twl4030 to power the MMC.

Based on commits [1][2].

[1] 64fd2d26140aa72b43428d079974f7c0e7f88353
[2] 27b653449178e80b333e7bc5a81eed3bd1bd6861

Signed-off-by: Romain Naour 
---
 board/ti/beagle/beagle.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index d5a122af2b..847d596646 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -447,6 +447,8 @@ int misc_init_r(void)
env_set(expansion_config.env_var, expansion_config.env_setting);
 
twl4030_power_init();
+   twl4030_power_mmc_init(0);
+
switch (get_board_revision()) {
case REVISION_XM_AB:
twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
@@ -499,10 +501,3 @@ void set_muxconf_regs(void)
 {
MUX_BEAGLE();
 }
-
-#if defined(CONFIG_MMC)
-void board_mmc_power_init(void)
-{
-   twl4030_power_mmc_init(0);
-}
-#endif
-- 
2.35.1



[PATCH 1/4] ARM: omap3_beagle: Remove non-DM initialization

2022-02-25 Thread Romain Naour
With DM_MMC working for both SPL and U-Boot, this patch removes
the legacy style of initializing the MMC driver.

Based on omap3_logic: 42140dd0962bc134c0aad27524d0f4cc3955f255.

Signed-off-by: Romain Naour 
---
 board/ti/beagle/beagle.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index 888a958491..d5a122af2b 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -500,13 +500,6 @@ void set_muxconf_regs(void)
MUX_BEAGLE();
 }
 
-#if defined(CONFIG_MMC)
-int board_mmc_init(struct bd_info *bis)
-{
-   return omap_mmc_init(0, 0, 0, -1, -1);
-}
-#endif
-
 #if defined(CONFIG_MMC)
 void board_mmc_power_init(void)
 {
-- 
2.35.1



Re: IMX8MM 4GiB boundary issue

2022-02-25 Thread Mark Kettenis
> From: Fabio Estevam 
> Date: Fri, 25 Feb 2022 08:12:58 -0300
> 
> Hi Tim,
> 
> On Thu, Feb 24, 2022 at 6:46 PM Tim Harvey  wrote:
> 
> > Fabio,
> >
> > No, that commit is 'not' in v2021.07. Please test with master and you
> > should see that go away.
> 
> Yes, you are right.
> 
> > Regardless, Marek's suggestion is the right fix if you can manage
> > that... we really don't want to limit 4GB boards to 3GB. I was hoping
> > NXP would step up and address the peripheral drivers for this.
> 
> Agreed, thanks!

But isn't the problem here that (some of) the hardware peripherals
simply can't address memory above the 4GB boundary?

OS kernels can work around such limitations by using an IOMMU (if
provided by the hardware) or by using bounce buffers (swiotlb in Linux
speak).  The traditional way to deal with this in u-boot is to make
sure that u-boot only uses memory below the 4GB boundary by
implementing board_get_usable_ram_top() and making sure that all the
addresses in the u-boot environment are in "low" memory.  For EFI
support there is the CONFIG_EFI_LOADER_BOUNCE_BUFFER option, which
should be set to "y" in this case.


Re: [RESEND RFC PATCH v2 1/4] efi_loader: add menu-driven boot device selection

2022-02-25 Thread Masahisa Kojima
Hi Heinrich,

On Fri, 25 Feb 2022 at 16:26, Heinrich Schuchardt  wrote:
>
> On 2/25/22 02:32, Masahisa Kojima wrote:
> > This patch enables the menu-driven boot device selection.
> > User can select the Boot included in BootOrder variable.
> >
> > If user quits thie menu, or the selected Boot fails to boot,
> > efi bootmgr continues to boot in accordance with BootOrder variable.
> >
> > This commit also moves the user input handling from cmd/bootmenu.c
> > to common/menu.c to reuse it from efi boot menu.
> >
> > Signed-off-by: Masahisa Kojima 
>
> With the series applied and CONFIG_EFI_BOOT_MENU=y I first see a line
> "Hit any key to stop autoboot:" with a count down and then the UEFI menu
> with a countdown. This duplication of countdowns does not make sense.

Thank you for your review.
I agree, this duplication does not make sense.

Anyway, my primary goal is to disable CLI, user can select the
UEFI boot option("Boot" variable) to boot the system, and user can edit
the UEFI boot option("Boot" and "BootOrder") through the menu.

I now realize that my patch series probably do not work without CLI,
and hooking the "bootefi bootmgr" command to show the new efi bootmenu
is probably wrong. I will investigate further.

>
> This is the content of the new menu:
>
>*** U-Boot EFI Boot Manager ***
>
>   Boot Manager
>   Boot Manager maintenance
>
>   Quit
>
> When selecting " Boot Manager maintenance" I see a second menu:
>
>*** U-Boot EFI Boot Manager ***
>
>   Add Boot Option
>   Delete Boot Option
>   Change Boot Order
>
>   Quit
>
>Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit
>
> When I select "Add Boot Option" the system (qemu_arm64_defconfig) simply
> hangs.

Sorry, there is something wrong on my code. I will try to reproduce.

>
> Why do we need the first menu? Compare it to your laptop experience when
> pressing the boot menu key (often  or ).
>
> Can't we have a simple countdown:

Yes, I could skip the first menu.

>
> "Hit any key for boot menu"
>
> If a key is hit show a menu showing the different boot options and the
> distro-boot devices:
>
> Debian (0001)
> Ubuntu (0002)
> SATA(1)
> SATA(2)
> NVMe(1)
> Boot manager settings
> Command line

The current scope of this patch series are disabling CLI and booting
the system with UEFI boot option.
I will check what I can do for distro-boot.

>
> Simon has proposed a patch series "Initial implementation of standard
> boot",
> https://patchwork.ozlabs.org/project/uboot/list/?series=281745=*.
> I think the proposed menu would have to iterate through all active boot
> methods.
>
> > ---
> > Changes in v2:
> > - move user input handling from cmd/bootmenu.c to common/menu.c
> > - keyboard buffer is drained before asking question in
> >common/menu.c::bootmenu_autoboot_loop()
> > - Add EFI_BOOT_MENU_DELAY Kconfig option to set delay for
> >autoboot and disable autoboot
> > - remove unnecessary "autoboot" member in struc efi_bootmgr_menu
> >
> >   cmd/bootmenu.c   | 145 
> >   common/menu.c| 137 
> >   include/menu.h   |  20 ++
> >   lib/efi_loader/Kconfig   |  20 ++
> >   lib/efi_loader/efi_bootmgr.c | 418 ++-
> >   5 files changed, 592 insertions(+), 148 deletions(-)
> >
> > diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
> > index 409ef9a848..f9fdebc450 100644
> > --- a/cmd/bootmenu.c
> > +++ b/cmd/bootmenu.c
> > @@ -33,21 +33,6 @@ struct bootmenu_entry {
> >   struct bootmenu_entry *next;/* next menu entry (num+1) */
> >   };
> >
> > -struct bootmenu_data {
> > - int delay;  /* delay for autoboot */
> > - int active; /* active menu entry */
> > - int count;  /* total count of menu entries */
> > - struct bootmenu_entry *first;   /* first menu entry */
> > -};
> > -
> > -enum bootmenu_key {
> > - KEY_NONE = 0,
> > - KEY_UP,
> > - KEY_DOWN,
> > - KEY_SELECT,
> > - KEY_QUIT,
> > -};
> > -
> >   static char *bootmenu_getoption(unsigned short int n)
> >   {
> >   char name[MAX_ENV_SIZE];
> > @@ -81,136 +66,6 @@ static void bootmenu_print_entry(void *data)
> >   puts(ANSI_COLOR_RESET);
> >   }
> >
> > -static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
> > - enum bootmenu_key *key, int *esc)
> > -{
> > - int i, c;
> > -
> > - if (menu->delay > 0) {
> > - printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
> > - printf("  Hit any key to stop autoboot: %2d ", menu->delay);
> > - }
> > -
> > - while (menu->delay > 0) {
> > - for (i = 0; i < 100; ++i) {
> > - if (!tstc()) {
> > - WATCHDOG_RESET();
> > - mdelay(10);
> > - continue;
> > - }
> > -
> > - 

Re: IMX8MM 4GiB boundary issue

2022-02-25 Thread Fabio Estevam
Hi Tim,

On Thu, Feb 24, 2022 at 6:46 PM Tim Harvey  wrote:

> Fabio,
>
> No, that commit is 'not' in v2021.07. Please test with master and you
> should see that go away.

Yes, you are right.

> Regardless, Marek's suggestion is the right fix if you can manage
> that... we really don't want to limit 4GB boards to 3GB. I was hoping
> NXP would step up and address the peripheral drivers for this.

Agreed, thanks!


[PATCH v2] clk: nuvoton: Add support for NPCM845

2022-02-25 Thread Stanley Chu
Add clock controller driver for NPCM845

Signed-off-by: Stanley Chu 
Reviewed-by: Sean Anderson 
---
v2:
  - simplify function arguments as comment by Sean Anderson
---
 drivers/clk/Makefile  |   1 +
 drivers/clk/nuvoton/Makefile  |   1 +
 drivers/clk/nuvoton/clk_npcm8xx.c | 469 ++
 .../dt-bindings/clock/nuvoton,npcm8xx-clock.h |  27 +
 4 files changed, 498 insertions(+)
 create mode 100644 drivers/clk/nuvoton/Makefile
 create mode 100644 drivers/clk/nuvoton/clk_npcm8xx.c
 create mode 100644 include/dt-bindings/clock/nuvoton,npcm8xx-clock.h

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 711ae5bc29..21e60bae0c 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_ARCH_ASPEED) += aspeed/
 obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/
 obj-$(CONFIG_ARCH_MTMIPS) += mtmips/
 obj-$(CONFIG_ARCH_MESON) += meson/
+obj-$(CONFIG_ARCH_NPCM) += nuvoton/
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
 obj-$(CONFIG_ARCH_SOCFPGA) += altera/
 obj-$(CONFIG_CLK_AT91) += at91/
diff --git a/drivers/clk/nuvoton/Makefile b/drivers/clk/nuvoton/Makefile
new file mode 100644
index 00..998e5329bb
--- /dev/null
+++ b/drivers/clk/nuvoton/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_NPCM8XX) += clk_npcm8xx.o
diff --git a/drivers/clk/nuvoton/clk_npcm8xx.c 
b/drivers/clk/nuvoton/clk_npcm8xx.c
new file mode 100644
index 00..6b8c54bb62
--- /dev/null
+++ b/drivers/clk/nuvoton/clk_npcm8xx.c
@@ -0,0 +1,469 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Nuvoton Technology Corp.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register offsets */
+#define CLKSEL 0x04/* clock source selection */
+#define CLKDIV10x08/* clock divider 1 */
+#define CLKDIV20x2C/* clock divider 2 */
+#define CLKDIV30x58/* clock divider 3 */
+#define PLLCON00x0C/* pll0 control */
+#define PLLCON10x10/* pll1 control */
+#define PLLCON20x54/* pll2 control */
+
+/* PLLCON bit filed */
+#define PLLCON_INDVGENMASK(5, 0)
+#define PLLCON_OTDV1   GENMASK(10, 8)
+#define PLLCON_OTDV2   GENMASK(15, 13)
+#define PLLCON_FBDVGENMASK(27, 16)
+
+/* CLKSEL bit filed */
+#define CPUCKSEL   GENMASK(2, 0)
+#define SDCKSELGENMASK(7, 6)
+#define UARTCKSEL  GENMASK(9, 8)
+
+/* CLKDIV1 bit filed */
+#define SPI3CKDIV  GENMASK(10, 6)
+#define MMCCKDIV   GENMASK(15, 11)
+#define UARTDIV1   GENMASK(20, 16)
+#define CLK4DIVGENMASK(27, 26)
+
+/* CLKDIV2 bit filed */
+#define APB5CKDIV  GENMASK(23, 22)
+#define APB2CKDIV  GENMASK(27, 26)
+
+/* CLKDIV3 bit filed */
+#define SPIXCKDIV  GENMASK(5, 1)
+#define SPI0CKDIV  GENMASK(10, 6)
+#define UARTDIV2   GENMASK(15, 11)
+#define SPI1CKDIV  GENMASK(23, 16)
+
+/* Flags */
+#define DIV_TYPE1  BIT(0)  /* div = clkdiv + 1 */
+#define DIV_TYPE2  BIT(1)  /* div = 1 << clkdiv */
+#define PRE_DIV2   BIT(2)  /* Pre divisor = 2 */
+#define POST_DIV2  BIT(3)  /* Post divisor = 2 */
+#define FIXED_PARENT   BIT(4)  /* clock source is fixed */
+
+struct npcm_clk_priv {
+   void __iomem *base;
+};
+
+/* Parameters of PLL configuration */
+struct npcm_clk_pll {
+   const int id;
+   const int parent_id;
+   u32 reg;
+   u32 flags;
+};
+
+/* Parent clock id to clksel mapping */
+struct parent_data {
+   int id;
+   int clksel;
+};
+
+/* Parameters of parent selection */
+struct npcm_clk_select {
+   const int id;
+   const struct parent_data *parents;
+   u32 reg;
+   u32 mask;
+   u8 num_parents;
+   u32 flags;
+};
+
+/* Parameters of clock divider */
+struct npcm_clk_div {
+   const int id;
+   u32 reg;
+   u32 mask;
+   u32 flags;
+};
+
+/* Parent clock map */
+static const struct parent_data pll_parents[] = {
+   {NPCM8XX_CLK_PLL0, 0},
+   {NPCM8XX_CLK_PLL1, 1},
+   {NPCM8XX_CLK_REFCLK, 2},
+   {NPCM8XX_CLK_PLL2DIV2, 3}
+};
+
+static const struct parent_data cpuck_parents[] = {
+   {NPCM8XX_CLK_PLL0, 0},
+   {NPCM8XX_CLK_PLL1, 1},
+   {NPCM8XX_CLK_REFCLK, 2},
+   {NPCM8XX_CLK_PLL2, 7}
+};
+
+static const struct parent_data apb_parent[] = {{NPCM8XX_CLK_AHB, 0}};
+
+static struct npcm_clk_pll npcm8xx_clk_plls[] = {
+   {NPCM8XX_CLK_PLL0, NPCM8XX_CLK_REFCLK, PLLCON0, 0},
+   {NPCM8XX_CLK_PLL1, NPCM8XX_CLK_REFCLK, PLLCON1, 0},
+   {NPCM8XX_CLK_PLL2, NPCM8XX_CLK_REFCLK, PLLCON2, 0},
+   {NPCM8XX_CLK_PLL2DIV2, NPCM8XX_CLK_REFCLK, PLLCON2, POST_DIV2}
+};
+
+static struct npcm_clk_select npcm8xx_clk_selectors[] = {
+   {NPCM8XX_CLK_AHB, cpuck_parents, CLKSEL, CPUCKSEL, 4, 0},
+   {NPCM8XX_CLK_APB2, apb_parent, 0, 0, 1, FIXED_PARENT},
+   {NPCM8XX_CLK_APB5, apb_parent, 0, 0, 1, FIXED_PARENT},
+   {NPCM8XX_CLK_SPI0,