Re: [RESEND PATCH] arm: kirkwood: nsa310s: Add Distro boot capability

2022-08-11 Thread Stefan Roese

Hi Tony,

On 12.08.22 01:40, Tony Dinh wrote:

- Add distro boot to board include file and deconfig file
- Miscellaneous changes:
- Remove Gerald from maintainer list (email bounced)
- Add CONFIG_SUPPORT_PASSING_ATAGS and friends to support legacy
kernel method of booting (e.g. OpenWrt) with appended DTB.
- Add CONFIG_UBIFS_SILENCE_MSG to reduce binary size.

Note that this patch is depended on the following patch:
https://patchwork.ozlabs.org/project/uboot/patch/20220807192709.21717-1-p...@kernel.org/

Signed-off-by: Tony Dinh 


So did you change anything here? Last time you mentioned, that you need
to resend this patch. I assumed that you needed to make some changes.

Thanks,
Stefan


---

  board/zyxel/nsa310s/MAINTAINERS |  1 -
  configs/nsa310s_defconfig   | 17 +
  include/configs/nsa310s.h   | 31 +--
  3 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/board/zyxel/nsa310s/MAINTAINERS b/board/zyxel/nsa310s/MAINTAINERS
index d153758c21..11106acf3e 100644
--- a/board/zyxel/nsa310s/MAINTAINERS
+++ b/board/zyxel/nsa310s/MAINTAINERS
@@ -1,5 +1,4 @@
  NSA310S BOARD
-M: Gerald Kerma 
  M:Tony Dinh 
  M:Luka Perkov 
  S:Maintained
diff --git a/configs/nsa310s_defconfig b/configs/nsa310s_defconfig
index 2b39ae74b3..a5f01ef88e 100644
--- a/configs/nsa310s_defconfig
+++ b/configs/nsa310s_defconfig
@@ -4,6 +4,9 @@ CONFIG_SYS_DCACHE_OFF=y
  CONFIG_ARCH_CPU_INIT=y
  CONFIG_SYS_THUMB_BUILD=y
  CONFIG_ARCH_KIRKWOOD=y
+CONFIG_SUPPORT_PASSING_ATAGS=y
+CONFIG_CMDLINE_TAG=y
+CONFIG_INITRD_TAG=y
  CONFIG_SYS_KWD_CONFIG="board/zyxel/nsa310s/kwbimage.cfg"
  CONFIG_SYS_TEXT_BASE=0x60
  CONFIG_SYS_MALLOC_F_LEN=0x400
@@ -14,35 +17,25 @@ CONFIG_ENV_OFFSET=0xE
  CONFIG_DEFAULT_DEVICE_TREE="kirkwood-nsa310s"
  CONFIG_IDENT_STRING="\nZyXEL NSA310S/320S 1/2-Bay Power Media Server"
  CONFIG_SYS_LOAD_ADDR=0x80
+CONFIG_DISTRO_DEFAULTS=y
  CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
  CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc8012000
  CONFIG_BOOTDELAY=3
-CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="setenv bootargs ${console} ${mtdparts} ${bootargs_root}; ubi 
part root; ubifsmount ubi:rootfs; ubifsload 0x80 ${kernel}; ubifsload 0x70 
${fdt}; ubifsumount; fdt addr 0x70; fdt resize; fdt chosen; bootz 0x80 - 
0x70"
  CONFIG_USE_PREBOOT=y
  # CONFIG_DISPLAY_BOARDINFO is not set
-CONFIG_HUSH_PARSER=y
  CONFIG_SYS_PROMPT="NSA310s> "
  CONFIG_SYS_MAXARGS=32
  CONFIG_SYS_PBSIZE=1050
-CONFIG_CMD_BOOTZ=y
  # CONFIG_CMD_FLASH is not set
  CONFIG_CMD_NAND=y
  CONFIG_CMD_SATA=y
  CONFIG_CMD_USB=y
  # CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_MII=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
  CONFIG_CMD_JFFS2=y
  CONFIG_CMD_MTDPARTS=y
  CONFIG_MTDIDS_DEFAULT="nand0=orion_nand"
  
CONFIG_MTDPARTS_DEFAULT="mtdparts=orion_nand:0xe@0x0(uboot),0x2@0xe(uboot_env),0x10@0x10(second_stage_uboot),-@0x20(root)"
  CONFIG_CMD_UBI=y
-CONFIG_ISO_PARTITION=y
  CONFIG_OF_CONTROL=y
  CONFIG_ENV_OVERWRITE=y
  CONFIG_ENV_IS_IN_NAND=y
@@ -65,6 +58,6 @@ CONFIG_MII=y
  CONFIG_SYS_NS16550=y
  CONFIG_USB=y
  CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_STORAGE=y
+CONFIG_UBIFS_SILENCE_MSG=y
  CONFIG_LZMA=y
  CONFIG_BZIP2=y
diff --git a/include/configs/nsa310s.h b/include/configs/nsa310s.h
index 027a47b5a3..62f0701180 100644
--- a/include/configs/nsa310s.h
+++ b/include/configs/nsa310s.h
@@ -9,15 +9,42 @@
  #ifndef _CONFIG_NSA310S_H
  #define _CONFIG_NSA310S_H
  
+/*

+ * mv-common.h should be defined after CMD configs since it used them
+ * to enable certain macros
+ */
  #include "mv-common.h"
  
-/* default environment variables */

+/* Include the common distro boot environment */
+#ifndef CONFIG_SPL_BUILD
+
+#define BOOT_TARGET_DEVICES(func) \
+   func(USB, usb, 0) \
+   func(SATA, sata, 0) \
+   func(DHCP, dhcp, na)
+
+#define KERNEL_ADDR_R  __stringify(0x80)
+#define FDT_ADDR_R __stringify(0x2c0)
+#define RAMDISK_ADDR_R __stringify(0x0110)
+#define SCRIPT_ADDR_R  __stringify(0x20)
+
+#define LOAD_ADDRESS_ENV_SETTINGS \
+   "kernel_addr_r=" KERNEL_ADDR_R "\0" \
+   "fdt_addr_r=" FDT_ADDR_R "\0" \
+   "ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
+   "scriptaddr=" SCRIPT_ADDR_R "\0"
+
+#include 
  
  #define CONFIG_EXTRA_ENV_SETTINGS \

"console=console=ttyS0,115200\0" \
"kernel=/boot/zImage\0" \
"fdt=/boot/nsa310s.dtb\0" \
-   "bootargs_root=ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rw\0"
+   "bootargs_root=ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rw\0" \
+   LOAD_ADDRESS_ENV_SETTINGS \
+   BOOTENV
+
+#endif /* CONFIG_SPL_BUILD */
  
  /* Ethernet driver configuration */

  #define CONFIG_MVGBE_PORTS{1, 0}  /* enable port 0 only */


Viele Grüße,
Stefan Roese

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194

[PATCH v2 23/24] efi: Drop ifname field from struct efi_disk_obj

2022-08-11 Thread Simon Glass
This is not used, so drop it.

Suggested-by: AKASHI Takahiro 
Signed-off-by: Simon Glass 
---

Changes in v2:
- Add new patch to drop ifname field from struct efi_disk_obj

 lib/efi_loader/efi_disk.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 2e905f61840..ad543bc117e 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -40,7 +40,6 @@ const efi_guid_t efi_system_partition_guid = 
PARTITION_SYSTEM_GUID;
 struct efi_disk_obj {
struct efi_object header;
struct efi_block_io ops;
-   const char *ifname;
int dev_index;
struct efi_block_io_media media;
struct efi_device_path *dp;
@@ -476,7 +475,6 @@ static efi_status_t efi_disk_add_dev(
return ret;
}
diskobj->ops = block_io_disk_template;
-   diskobj->ifname = if_typename;
diskobj->dev_index = dev_index;
 
/* Fill in EFI IO Media info (for read/write callbacks) */
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 20/24] blk: Switch over to using uclass IDs

2022-08-11 Thread Simon Glass
We currently have an if_type (interface type) and a uclass id. These are
closely related and we don't need to have both.

Drop the if_type values and use the uclass ones instead.

Maintain the existing, subtle, one-way conversion between UCLASS_USB and
UCLASS_MASS_STORAGE for now, and add a comment.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 .../mach-stm32mp/cmd_stm32prog/stm32prog.c|  4 +-
 board/toradex/common/tdx-cfg-block.c  |  4 +-
 cmd/bcb.c |  4 +-
 cmd/ide.c |  2 +-
 cmd/mmc.c |  8 +--
 cmd/mvebu/bubt.c  |  2 +-
 cmd/nvme.c|  4 +-
 cmd/pvblock.c |  2 +-
 cmd/sata.c|  4 +-
 cmd/scsi.c|  2 +-
 cmd/usb.c |  2 +-
 cmd/virtio.c  |  2 +-
 common/spl/spl_sata.c |  2 +-
 common/spl/spl_usb.c  |  2 +-
 common/usb_storage.c  |  8 +--
 disk/part.c   | 52 +++
 doc/develop/uefi/uefi.rst |  2 +-
 drivers/ata/dwc_ahsata.c  |  2 +-
 drivers/ata/fsl_sata.c|  2 +-
 drivers/ata/sata.c|  2 +-
 drivers/ata/sata_mv.c |  2 +-
 drivers/ata/sata_sil.c|  2 +-
 drivers/block/blk-uclass.c| 64 ++-
 drivers/block/efi_blk.c   |  2 +-
 drivers/block/ide.c   |  8 +--
 drivers/block/sandbox.c   | 12 ++--
 drivers/dfu/dfu_mmc.c |  6 +-
 drivers/mmc/mmc-uclass.c  | 10 +--
 drivers/mmc/mmc_legacy.c  |  6 +-
 drivers/mmc/mmc_write.c   |  4 +-
 drivers/nvme/nvme.c   |  2 +-
 drivers/scsi/scsi.c   | 10 +--
 drivers/tee/optee/rpmb.c  |  4 +-
 drivers/virtio/virtio_blk.c   |  4 +-
 drivers/xen/pvblock.c |  6 +-
 env/mmc.c |  4 +-
 include/blk.h | 18 +-
 include/mmc.h |  2 +-
 lib/efi_driver/efi_block_device.c |  4 +-
 lib/efi_loader/efi_disk.c |  4 +-
 test/dm/blk.c | 24 +++
 41 files changed, 151 insertions(+), 159 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index c391b6c7abb..a720d0ba717 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -1823,7 +1823,7 @@ static int part_delete(struct stm32prog_data *data,
 * need to switch to associated hwpart 1 or 2
 */
if (part->part_id < 0)
-   if (blk_select_hwpart_devnum(IF_TYPE_MMC,
+   if (blk_select_hwpart_devnum(UCLASS_MMC,
 part->dev->dev_id,
 -part->part_id))
return -1;
@@ -1832,7 +1832,7 @@ static int part_delete(struct stm32prog_data *data,
 
/* return to user partition */
if (part->part_id < 0)
-   blk_select_hwpart_devnum(IF_TYPE_MMC,
+   blk_select_hwpart_devnum(UCLASS_MMC,
 part->dev->dev_id, 0);
if (blks != blks_size) {
ret = -1;
diff --git a/board/toradex/common/tdx-cfg-block.c 
b/board/toradex/common/tdx-cfg-block.c
index 22c67c6e388..11f4d5e14a8 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -211,7 +211,7 @@ static int tdx_cfg_block_mmc_storage(u8 *config_block, int 
write)
return -EINVAL;
}
if (part != mmc_get_blk_desc(mmc)->hwpart) {
-   if (blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part)) {
+   if (blk_select_hwpart_devnum(UCLASS_MMC, dev, part)) {
puts("MMC partition switch failed\n");
ret = -ENODEV;
goto out;
@@ -239,7 +239,7 @@ static int tdx_cfg_block_mmc_storage(u8 *config_block, int 
write)
 
 out:
/* Switch back to regular eMMC user partition */
-   blk_select_hwpart_devnum(IF_TYPE_MMC, 0, 0);
+   blk_select_hwpart_devnum(UCLASS_MMC, 0, 0);
 
return ret;
 }
diff --git a/cmd/bcb.c b/cmd/bcb.c
index 1bbd1fae998..8b87aa062fe 100644
--- a/cmd/bcb.c
+++ b/cmd/bcb.c
@@ -122,7 +122,7 @@ s

Re: [PATCH 21/23] blk: Switch over to using uclass IDs

2022-08-11 Thread Simon Glass
Hi Takahiro,

On Sun, 7 Aug 2022 at 19:05, AKASHI Takahiro  wrote:
>
> My comment below is not directly related to the change, but
>
> On Sun, Aug 07, 2022 at 09:47:06AM -0600, Simon Glass wrote:
> > We currently have an if_type (interface type) and a uclass id. These are
> > closely related and we don't need to have both.
> >
> > Drop the if_type values and use the uclass ones instead.
> >
> > Maintain the existing, subtle, one-way conversion between UCLASS_USB and
> > UCLASS_MASS_STORAGE for now, and add a comment.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  .../mach-stm32mp/cmd_stm32prog/stm32prog.c|  4 +-
> >  board/toradex/common/tdx-cfg-block.c  |  4 +-
> >  cmd/bcb.c |  4 +-
> >  cmd/ide.c |  2 +-
> >  cmd/mmc.c |  8 +--
> >  cmd/mvebu/bubt.c  |  2 +-
> >  cmd/nvme.c|  4 +-
> >  cmd/pvblock.c |  2 +-
> >  cmd/sata.c|  4 +-
> >  cmd/scsi.c|  2 +-
> >  cmd/usb.c |  2 +-
> >  cmd/virtio.c  |  2 +-
> >  common/spl/spl_sata.c |  2 +-
> >  common/spl/spl_usb.c  |  2 +-
> >  common/usb_storage.c  |  8 +--
> >  disk/part.c   | 52 
> >  doc/develop/uefi/uefi.rst |  2 +-
> >  drivers/ata/dwc_ahsata.c  |  2 +-
> >  drivers/ata/fsl_sata.c|  2 +-
> >  drivers/ata/sata.c|  2 +-
> >  drivers/ata/sata_mv.c |  2 +-
> >  drivers/ata/sata_sil.c|  2 +-
> >  drivers/block/blk-uclass.c| 62 ++-
> >  drivers/block/efi_blk.c   |  2 +-
> >  drivers/block/ide.c   |  8 +--
> >  drivers/block/sandbox.c   | 12 ++--
> >  drivers/dfu/dfu_mmc.c |  6 +-
> >  drivers/mmc/mmc-uclass.c  | 10 +--
> >  drivers/mmc/mmc_legacy.c  |  6 +-
> >  drivers/mmc/mmc_write.c   |  4 +-
> >  drivers/nvme/nvme.c   |  2 +-
> >  drivers/scsi/scsi.c   | 10 +--
> >  drivers/tee/optee/rpmb.c  |  4 +-
> >  drivers/virtio/virtio_blk.c   |  4 +-
> >  drivers/xen/pvblock.c |  6 +-
> >  env/mmc.c |  4 +-
> >  include/blk.h | 18 +-
> >  include/mmc.h |  2 +-
> >  lib/efi_driver/efi_block_device.c |  4 +-
> >  lib/efi_loader/efi_disk.c |  4 +-
> >  test/dm/blk.c | 24 +++
> >  41 files changed, 150 insertions(+), 158 deletions(-)
> >


> > diff --git a/disk/part.c b/disk/part.c
> > index 2bcc6f4f403..75aff7eba5a 100644
> > --- a/disk/part.c
> > +++ b/disk/part.c
> > @@ -121,34 +121,34 @@ void dev_print (struct blk_desc *dev_desc)
> >   }
>
> This function misses out the case of IF_TYPE_EFI_MEDIA and fails to handle it.

OK I will add a patch for it.

Regards,
Simon


[PATCH v2 00/24] blk: Rationalise the block interface

2022-08-11 Thread Simon Glass
The block interface has two separate implementations, one using driver
model and one not. The latter is really only needed for SPL, where
size constraints allegedly don't allow use of driver model. Of course
we still need space for filesystems and other code, so it isn't clear
that driver model is anything more than the straw that breaks the
camel's back.

The driver model version uses a uclass ID for the interface time, but
converts back and forth between that and if_type, which is the legacy
type.

The HAVE_BLOCK_DEVICE define is mostly a hangover from the old days.
At present its main purpose is to enable the legacy block implementation
in SPL.

Finally the use of 'select' to enable BLK does not work very well. It
causes kconfig errors when another option depends on BLK and it is
not recommended by the kconfig style guide.

This series aims to clean things up:
- Enable BLK based on whether different media types are used, but still
  allow boards to disable it
- Rename HAVE_BLOCK_DEVICE to indicates its real purpose
- Drop if_type and use the uclass instead
- Drop some obsolete if_type values

An issue not resolved by this series is that the sandbox host interface
does not actually have a device. At present it uses the root device, which
was convenience for the driver model conversion but not really correct. It
should be possible to clean this up, in a future series.

Another minor issue is the use of UCLASS_USB for a mass-storage device.
This has been the case for a while and is not addresed by this series,
other than to add a comment.

Note that this test relies on Tom Rini's series to drop various boards
including warp and cm_t335

Finally, a patch is included to make binman put fake files in a
subdirectory, since repeated runs of certain boards can cause unrelated
failues (e.g. chromebook_coral) when fake files are left around.

Changes in v2:
- Update commit message
- Fix SPL_PARTITIONS too
- Add SATA also
- Refer to a suffix, not a prefix
- Add new patch to handle UCLASS_EFI_MEDIA in dev_print()
- Add new patch to drop ifname field from struct efi_disk_obj
- Use conv_uclass_id() instead of the confusing uclass_id_to_uclass_id()

Simon Glass (24):
  disk: Correct help for TPL_PARTITIONS
  blk: Enable CONFIG_BLK for all media
  ata: Fix an instance of SPL_SATA_SUPPORT
  sandbox: Avoid defining HAVE_BLOCK_DEVICE in Konfig
  disk: Use Makefile to omit partition drivers
  blk: Use a function for whether block devices are available
  cmd: Drop use of HAVE_BLOCK_DEVICE
  blk: Drop unnecessary #ifdef in in blk_legacy
  blk: Rename HAVE_BLOCK_DEVICE
  blk: Select SPL_LEGACY_BLOCK automatically
  blk: Drop unnecessary CONFIG_SPL_LEGACY_BLOCK in defconfigs
  blk: Hide the BLK and SPL_LEGACY_BLOCK options
  blk: Drop IF_TYPE_DOC
  ide: Use a flag for an ATAPI device
  blk: Drop IF_TYPE_ATAPI
  blk: Drop IF_TYPE_SD
  blk: Rename var in blk_get_devnum_by_typename()
  blk: Rewrite if_type to name functions
  efi: Correct assumption about if_type
  blk: Switch over to using uclass IDs
  disk: Handle UCLASS_EFI_MEDIA in dev_print()
  blk: Drop if_type
  efi: Drop ifname field from struct efi_disk_obj
  blk: Rename if_type to uclass_id

 arch/Kconfig  |   1 -
 arch/arm/Kconfig  |   1 -
 .../mach-stm32mp/cmd_stm32prog/stm32prog.c|   4 +-
 board/st/common/stm32mp_dfu.c |   2 +-
 board/toradex/common/tdx-cfg-block.c  |   4 +-
 cmd/Kconfig   |   5 -
 cmd/Makefile  |   2 +-
 cmd/bcb.c |   4 +-
 cmd/blk_common.c  |  18 +-
 cmd/ide.c |   2 +-
 cmd/lsblk.c   |   2 +-
 cmd/mmc.c |  10 +-
 cmd/mvebu/bubt.c  |   2 +-
 cmd/nvme.c|   4 +-
 cmd/pvblock.c |   2 +-
 cmd/sata.c|   4 +-
 cmd/scsi.c|   2 +-
 cmd/usb.c |   2 +-
 cmd/virtio.c  |   2 +-
 common/spl/Kconfig|   2 -
 common/spl/spl_sata.c |   2 +-
 common/spl/spl_usb.c  |   2 +-
 common/usb_storage.c  |  10 +-
 configs/M5253DEMO_defconfig   |   1 +
 configs/axm_defconfig |   1 -
 configs/bcm968380gerg_ram_defconfig   |   1 -
 .../gardena-smart-gateway-mt7688_defconfig|   1 -
 configs/nsim_hs38_defconfig   |   1 -
 configs/qemu-ppce500_defconfig|   1 -
 disk/Kconfig  |   8 +-
 disk/Makefile |   4 +
 disk/disk-uclass.c|  11 +-
 disk/part.c 

[PATCH v2 24/24] blk: Rename if_type to uclass_id

2022-08-11 Thread Simon Glass
Use the word 'uclass' instead of 'if_type' to complete the conversion.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Use conv_uclass_id() instead of the confusing uclass_id_to_uclass_id()

 board/st/common/stm32mp_dfu.c|   2 +-
 cmd/blk_common.c |  18 +--
 cmd/lsblk.c  |   2 +-
 cmd/mmc.c|   2 +-
 common/usb_storage.c |   6 +-
 disk/disk-uclass.c   |   8 +-
 disk/part.c  |  12 +-
 doc/usage/partitions.rst |   2 +-
 drivers/ata/sata.c   |   2 +-
 drivers/block/blk-uclass.c   | 145 +++
 drivers/block/blk_legacy.c   |  58 -
 drivers/block/ide.c  |   8 +-
 drivers/block/sandbox.c  |   6 +-
 drivers/mmc/mmc-uclass.c |   2 +-
 drivers/mmc/mmc_legacy.c |   8 +-
 drivers/net/fsl_enetc.c  |  12 +-
 drivers/net/fsl_enetc.h  |   2 +-
 drivers/scsi/scsi.c  |   6 +-
 drivers/virtio/virtio_blk.c  |   2 +-
 drivers/xen/pvblock.c|   2 +-
 fs/fat/fat.c |   2 +-
 include/blk.h| 116 +-
 include/efi_api.h|   4 +-
 include/efi_loader.h |   4 +-
 lib/efi_loader/efi_device_path.c |   2 +-
 lib/efi_loader/efi_device_path_to_text.c |   4 +-
 lib/efi_loader/efi_disk.c|  26 ++--
 lib/efi_loader/efi_net.c |   2 +-
 lib/efi_loader/efi_var_file.c|   4 +-
 29 files changed, 234 insertions(+), 235 deletions(-)

diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
index fa48b2a35ee..0096f71dfc1 100644
--- a/board/st/common/stm32mp_dfu.c
+++ b/board/st/common/stm32mp_dfu.c
@@ -37,7 +37,7 @@ static void board_get_alt_info_mmc(struct udevice *dev, char 
*buf)
if (!desc)
return;
 
-   name = blk_get_if_type_name(desc->if_type);
+   name = blk_get_uclass_name(desc->uclass_id);
devnum = desc->devnum;
len = strlen(buf);
 
diff --git a/cmd/blk_common.c b/cmd/blk_common.c
index 369c5ae4bbe..75a072caf51 100644
--- a/cmd/blk_common.c
+++ b/cmd/blk_common.c
@@ -12,10 +12,10 @@
 #include 
 #include 
 
-int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
+int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id,
   int *cur_devnump)
 {
-   const char *if_name = blk_get_if_type_name(if_type);
+   const char *if_name = blk_get_uclass_name(uclass_id);
 
switch (argc) {
case 0:
@@ -23,16 +23,16 @@ int blk_common_cmd(int argc, char *const argv[], enum 
uclass_id if_type,
return CMD_RET_USAGE;
case 2:
if (strncmp(argv[1], "inf", 3) == 0) {
-   blk_list_devices(if_type);
+   blk_list_devices(uclass_id);
return 0;
} else if (strncmp(argv[1], "dev", 3) == 0) {
-   if (blk_print_device_num(if_type, *cur_devnump)) {
+   if (blk_print_device_num(uclass_id, *cur_devnump)) {
printf("\nno %s devices available\n", if_name);
return CMD_RET_FAILURE;
}
return 0;
} else if (strncmp(argv[1], "part", 4) == 0) {
-   if (blk_list_part(if_type))
+   if (blk_list_part(uclass_id))
printf("\nno %s partition table available\n",
   if_name);
return 0;
@@ -42,7 +42,7 @@ int blk_common_cmd(int argc, char *const argv[], enum 
uclass_id if_type,
if (strncmp(argv[1], "dev", 3) == 0) {
int dev = (int)dectoul(argv[2], NULL);
 
-   if (!blk_show_device(if_type, dev)) {
+   if (!blk_show_device(uclass_id, dev)) {
*cur_devnump = dev;
printf("... is now current device\n");
} else {
@@ -52,7 +52,7 @@ int blk_common_cmd(int argc, char *const argv[], enum 
uclass_id if_type,
} else if (strncmp(argv[1], "part", 4) == 0) {
int dev = (int)dectoul(argv[2], NULL);
 
-   if (blk_print_part_devnum(if_type, dev)) {
+   if (blk_print_part_devnum(uclass_id, dev)) {
printf("\n%s device %d not available\n",
   if_name, dev);
return CMD_RET_FAILURE;
@@ -71,7 +71,7 @@ int blk_common_cmd(int argc, char *const argv[], enum 
uclass_id if_type,

[PATCH v2 22/24] blk: Drop if_type

2022-08-11 Thread Simon Glass
Use the uclass ID instead.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/blk_common.c   |  2 +-
 drivers/block/blk-uclass.c | 34 +++
 drivers/block/blk_legacy.c | 20 +--
 include/blk.h  | 41 ++
 include/efi_loader.h   |  2 +-
 5 files changed, 48 insertions(+), 51 deletions(-)

diff --git a/cmd/blk_common.c b/cmd/blk_common.c
index 4e442f2918b..369c5ae4bbe 100644
--- a/cmd/blk_common.c
+++ b/cmd/blk_common.c
@@ -12,7 +12,7 @@
 #include 
 #include 
 
-int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
+int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
   int *cur_devnump)
 {
const char *if_name = blk_get_if_type_name(if_type);
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 436af764f91..a9a85aa37f3 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -34,7 +34,7 @@ static struct {
{ UCLASS_PVBLOCK, "pvblock" },
 };
 
-static enum if_type if_typename_to_iftype(const char *if_typename)
+static enum uclass_id if_typename_to_iftype(const char *if_typename)
 {
int i;
 
@@ -46,7 +46,7 @@ static enum if_type if_typename_to_iftype(const char 
*if_typename)
return UCLASS_INVALID;
 }
 
-static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
+static enum uclass_id if_type_to_uclass_id(enum uclass_id if_type)
 {
/*
 * This strange adjustment is used because we use UCLASS_MASS_STORAGE
@@ -71,7 +71,7 @@ static enum uclass_id if_type_to_uclass_id(enum if_type 
if_type)
return if_type;
 }
 
-const char *blk_get_if_type_name(enum if_type if_type)
+const char *blk_get_if_type_name(enum uclass_id if_type)
 {
int i;
 
@@ -83,7 +83,7 @@ const char *blk_get_if_type_name(enum if_type if_type)
return "(none)";
 }
 
-struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
+struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
 {
struct blk_desc *desc;
struct udevice *dev;
@@ -105,7 +105,7 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type 
if_type, int devnum)
 struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int 
devnum)
 {
enum uclass_id uclass_id;
-   enum if_type type;
+   enum uclass_id type;
struct udevice *dev;
struct uclass *uc;
int ret;
@@ -185,7 +185,7 @@ struct blk_desc *blk_get_by_device(struct udevice *dev)
  * with a higher device number, -ENOENT if there is no such device but there
  * is one with a higher number, or other -ve on other error.
  */
-static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
+static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc 
**descp)
 {
bool found_more = false;
struct udevice *dev;
@@ -218,7 +218,7 @@ static int get_desc(enum if_type if_type, int devnum, 
struct blk_desc **descp)
return found_more ? -ENOENT : -ENODEV;
 }
 
-int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
+int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
 {
struct udevice *dev;
int ret;
@@ -230,7 +230,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int 
devnum, int hwpart)
return blk_select_hwpart(dev, hwpart);
 }
 
-int blk_list_part(enum if_type if_type)
+int blk_list_part(enum uclass_id if_type)
 {
struct blk_desc *desc;
int devnum, ok;
@@ -255,7 +255,7 @@ int blk_list_part(enum if_type if_type)
return 0;
 }
 
-int blk_print_part_devnum(enum if_type if_type, int devnum)
+int blk_print_part_devnum(enum uclass_id if_type, int devnum)
 {
struct blk_desc *desc;
int ret;
@@ -270,7 +270,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
return 0;
 }
 
-void blk_list_devices(enum if_type if_type)
+void blk_list_devices(enum uclass_id if_type)
 {
struct blk_desc *desc;
int ret;
@@ -289,7 +289,7 @@ void blk_list_devices(enum if_type if_type)
}
 }
 
-int blk_print_device_num(enum if_type if_type, int devnum)
+int blk_print_device_num(enum uclass_id if_type, int devnum)
 {
struct blk_desc *desc;
int ret;
@@ -303,7 +303,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
return 0;
 }
 
-int blk_show_device(enum if_type if_type, int devnum)
+int blk_show_device(enum uclass_id if_type, int devnum)
 {
struct blk_desc *desc;
int ret;
@@ -324,7 +324,7 @@ int blk_show_device(enum if_type if_type, int devnum)
return 0;
 }
 
-ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
  lbaint_t blkcnt, void *buffer)
 {
struct blk_desc *desc;
@@ -341,7 +341,7 @@ ulong blk_read_devnum(enum if_type if_type, 

[PATCH v2 11/24] blk: Drop unnecessary CONFIG_SPL_LEGACY_BLOCK in defconfigs

2022-08-11 Thread Simon Glass
This is defined automatically when needed, so drop it from the few
defconfig files that define it manually.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 configs/axm_defconfig  | 1 -
 configs/bcm968380gerg_ram_defconfig| 1 -
 configs/gardena-smart-gateway-mt7688_defconfig | 1 -
 configs/nsim_hs38_defconfig| 1 -
 configs/qemu-ppce500_defconfig | 1 -
 5 files changed, 5 deletions(-)

diff --git a/configs/axm_defconfig b/configs/axm_defconfig
index c42fb37d6c9..89220d80852 100644
--- a/configs/axm_defconfig
+++ b/configs/axm_defconfig
@@ -80,7 +80,6 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SPL_DM=y
 CONFIG_BLK=y
-CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_CLK=y
 CONFIG_CLK_AT91=y
 CONFIG_AT91_GPIO=y
diff --git a/configs/bcm968380gerg_ram_defconfig 
b/configs/bcm968380gerg_ram_defconfig
index 246add6029c..29f317d85f9 100644
--- a/configs/bcm968380gerg_ram_defconfig
+++ b/configs/bcm968380gerg_ram_defconfig
@@ -42,7 +42,6 @@ CONFIG_CMD_NAND=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 # CONFIG_NET is not set
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_BCM6345_GPIO=y
 CONFIG_LED=y
 CONFIG_LED_BCM6328=y
diff --git a/configs/gardena-smart-gateway-mt7688_defconfig 
b/configs/gardena-smart-gateway-mt7688_defconfig
index fdfab14d53e..992e8509993 100644
--- a/configs/gardena-smart-gateway-mt7688_defconfig
+++ b/configs/gardena-smart-gateway-mt7688_defconfig
@@ -78,7 +78,6 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_DM=y
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index 3f23fc4189f..6196cd94819 100644
--- a/configs/nsim_hs38_defconfig
+++ b/configs/nsim_hs38_defconfig
@@ -30,7 +30,6 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
 CONFIG_BLK=y
-CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_DM_ETH=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/qemu-ppce500_defconfig b/configs/qemu-ppce500_defconfig
index 3241f5520eb..7793edac90b 100644
--- a/configs/qemu-ppce500_defconfig
+++ b/configs/qemu-ppce500_defconfig
@@ -40,7 +40,6 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DM=y
 CONFIG_SIMPLE_BUS_CORRECT_RANGE=y
 CONFIG_BLK=y
-CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_LBA48=y
 CONFIG_CHIP_SELECTS_PER_CTRL=0
 CONFIG_MPC8XXX_GPIO=y
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 21/24] disk: Handle UCLASS_EFI_MEDIA in dev_print()

2022-08-11 Thread Simon Glass
This is currently missing. Add it.

Fix the code style for the function while we are here.

Suggested-by: AKASHI Takahiro 
Signed-off-by: Simon Glass 
---

Changes in v2:
- Add new patch to handle UCLASS_EFI_MEDIA in dev_print()

 disk/part.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/disk/part.c b/disk/part.c
index 75aff7eba5a..5705c229d59 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -111,7 +111,7 @@ static lba512_t lba512_muldiv(lba512_t block_count, 
lba512_t mul_by,
return bc_quot * mul_by + ((bc_rem * mul_by) >> right_shift);
 }
 
-void dev_print (struct blk_desc *dev_desc)
+void dev_print(struct blk_desc *dev_desc)
 {
lba512_t lba512; /* number of blocks if 512bytes block size */
 
@@ -148,6 +148,9 @@ void dev_print (struct blk_desc *dev_desc)
case UCLASS_VIRTIO:
printf("%s VirtIO Block Device\n", dev_desc->vendor);
break;
+   case UCLASS_EFI_MEDIA:
+   printf("EFI media Block Device %d\n", dev_desc->devnum);
+   break;
case UCLASS_INVALID:
puts("device type unknown\n");
return;
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 18/24] blk: Rewrite if_type to name functions

2022-08-11 Thread Simon Glass
These are currently using a simple array lookup in one direction, and
relying on if_type being sequential.

With the move to uclass IDs this needs to change. Update the code to
prepare for the new way. This patch is intended to introduce no
functional change.

The returning of "(none)" from blk_get_if_type_name() is handling a case
that should not happen in either case.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/block/blk-uclass.c | 45 +++---
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 3738517d8d0..a68158c3f25 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -17,18 +17,21 @@
 #include 
 #include 
 
-static const char *if_typename_str[IF_TYPE_COUNT] = {
-   [IF_TYPE_IDE]   = "ide",
-   [IF_TYPE_SCSI]  = "scsi",
-   [IF_TYPE_USB]   = "usb",
-   [IF_TYPE_MMC]   = "mmc",
-   [IF_TYPE_SATA]  = "sata",
-   [IF_TYPE_HOST]  = "host",
-   [IF_TYPE_NVME]  = "nvme",
-   [IF_TYPE_EFI_MEDIA] = "efi",
-   [IF_TYPE_EFI_LOADER]= "efiloader",
-   [IF_TYPE_VIRTIO]= "virtio",
-   [IF_TYPE_PVBLOCK]   = "pvblock",
+static struct {
+   enum uclass_id id;
+   const char *name;
+} if_typename_str[] = {
+   { IF_TYPE_IDE, "ide" },
+   { IF_TYPE_SCSI, "scsi" },
+   { IF_TYPE_USB, "usb" },
+   { IF_TYPE_MMC,  "mmc" },
+   { IF_TYPE_SCSI, "sata" },
+   { IF_TYPE_HOST, "host" },
+   { IF_TYPE_NVME, "nvme" },
+   { IF_TYPE_EFI_MEDIA, "efi" },
+   { IF_TYPE_EFI_LOADER, "efiloader" },
+   { IF_TYPE_VIRTIO, "virtio" },
+   { IF_TYPE_PVBLOCK, "pvblock" },
 };
 
 static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
@@ -49,10 +52,9 @@ static enum if_type if_typename_to_iftype(const char 
*if_typename)
 {
int i;
 
-   for (i = 0; i < IF_TYPE_COUNT; i++) {
-   if (if_typename_str[i] &&
-   !strcmp(if_typename, if_typename_str[i]))
-   return i;
+   for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
+   if (!strcmp(if_typename, if_typename_str[i].name))
+   return if_typename_str[i].id;
}
 
return IF_TYPE_UNKNOWN;
@@ -65,7 +67,14 @@ static enum uclass_id if_type_to_uclass_id(enum if_type 
if_type)
 
 const char *blk_get_if_type_name(enum if_type if_type)
 {
-   return if_typename_str[if_type];
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
+   if ((int)if_typename_str[i].id == if_type)
+   return if_typename_str[i].name;
+   }
+
+   return "(none)";
 }
 
 struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
@@ -104,7 +113,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char 
*if_typename, int devnum)
uclass_id = if_type_to_uclass_id(type);
if (uclass_id == UCLASS_INVALID) {
debug("%s: Unknown uclass for interface type'\n",
- if_typename_str[type]);
+ blk_get_if_type_name(type));
return NULL;
}
 
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 12/24] blk: Hide the BLK and SPL_LEGACY_BLOCK options

2022-08-11 Thread Simon Glass
We don't want boards to be able to change these. They can be handled
as dependencies of options that need them, such as SPL_MMC. There is no
point in enabling the block interface without any storage devices to
create a block device.

Hide both options from the 'menuconfig' display and deny their use in
defconfig files.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/block/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index e82a779e6b8..707e2bcd238 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -1,5 +1,5 @@
 config BLK
-   bool "Support block devices"
+   bool # "Support block devices"
depends on DM
default y if MMC || USB || SCSI || NVME || IDE || AHCI || SATA
default y if EFI_MEDIA || VIRTIO_BLK || PVBLOCK
@@ -12,7 +12,7 @@ config BLK
  A filesystem can be placed in each partition.
 
 config SPL_LEGACY_BLOCK
-   bool "Enable Legacy Block Device"
+   bool # "Enable Legacy Block Device"
depends on SPL && !DM_SPL
default y if SPL_MMC || SPL_USB_STORAGE || SCSI || NVME || IDE
default y if SPL_AHCI_PCI
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 16/24] blk: Drop IF_TYPE_SD

2022-08-11 Thread Simon Glass
This is not really needed since it does the same things as MMC. Drop it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part.c| 2 --
 drivers/block/blk-uclass.c | 2 --
 include/blk.h  | 1 -
 3 files changed, 5 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index a5c1d7a0aec..2bcc6f4f403 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -135,7 +135,6 @@ void dev_print (struct blk_desc *dev_desc)
dev_desc->revision,
dev_desc->product);
break;
-   case IF_TYPE_SD:
case IF_TYPE_MMC:
case IF_TYPE_USB:
case IF_TYPE_NVME:
@@ -772,7 +771,6 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
devtype = "usbd";
break;
case IF_TYPE_MMC:
-   case IF_TYPE_SD:
devtype = "mmcsd";
break;
default:
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 57230e9bab7..2fa6a7e6883 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -22,7 +22,6 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
[IF_TYPE_SCSI]  = "scsi",
[IF_TYPE_USB]   = "usb",
[IF_TYPE_MMC]   = "mmc",
-   [IF_TYPE_SD]= "sd",
[IF_TYPE_SATA]  = "sata",
[IF_TYPE_HOST]  = "host",
[IF_TYPE_NVME]  = "nvme",
@@ -37,7 +36,6 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
[IF_TYPE_SCSI]  = UCLASS_SCSI,
[IF_TYPE_USB]   = UCLASS_MASS_STORAGE,
[IF_TYPE_MMC]   = UCLASS_MMC,
-   [IF_TYPE_SD]= UCLASS_INVALID,
[IF_TYPE_SATA]  = UCLASS_AHCI,
[IF_TYPE_HOST]  = UCLASS_ROOT,
[IF_TYPE_NVME]  = UCLASS_NVME,
diff --git a/include/blk.h b/include/blk.h
index c7461f9f35a..cc30e3861fa 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -33,7 +33,6 @@ enum if_type {
IF_TYPE_SCSI,
IF_TYPE_USB,
IF_TYPE_MMC,
-   IF_TYPE_SD,
IF_TYPE_SATA,
IF_TYPE_HOST,
IF_TYPE_NVME,
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 19/24] efi: Correct assumption about if_type

2022-08-11 Thread Simon Glass
efi_set_blk_dev_to_system_partition() assumes that 0 is an invalid
if_type. This is true now but is about to be false. Fix this bug to avoid
a test failure.

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
index 76a2ff9e412..994e66392fb 100644
--- a/lib/efi_loader/efi_var_file.c
+++ b/lib/efi_loader/efi_var_file.c
@@ -38,7 +38,7 @@ static efi_status_t __maybe_unused 
efi_set_blk_dev_to_system_partition(void)
char part_str[PART_STR_LEN];
int r;
 
-   if (!efi_system_partition.if_type) {
+   if (efi_system_partition.if_type == UCLASS_INVALID) {
log_err("No EFI system partition\n");
return EFI_DEVICE_ERROR;
}
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 17/24] blk: Rename var in blk_get_devnum_by_typename()

2022-08-11 Thread Simon Glass
At present we use a variable with the same name as the enum. Change this
since we plan to #define the enum to uclass_id.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/block/blk-uclass.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 2fa6a7e6883..3738517d8d0 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -90,21 +90,21 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type 
if_type, int devnum)
 struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int 
devnum)
 {
enum uclass_id uclass_id;
-   enum if_type if_type;
+   enum if_type type;
struct udevice *dev;
struct uclass *uc;
int ret;
 
-   if_type = if_typename_to_iftype(if_typename);
-   if (if_type == IF_TYPE_UNKNOWN) {
+   type = if_typename_to_iftype(if_typename);
+   if (type == IF_TYPE_UNKNOWN) {
debug("%s: Unknown interface type '%s'\n", __func__,
  if_typename);
return NULL;
}
-   uclass_id = if_type_to_uclass_id(if_type);
+   uclass_id = if_type_to_uclass_id(type);
if (uclass_id == UCLASS_INVALID) {
debug("%s: Unknown uclass for interface type'\n",
- if_typename_str[if_type]);
+ if_typename_str[type]);
return NULL;
}
 
@@ -115,7 +115,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char 
*if_typename, int devnum)
struct blk_desc *desc = dev_get_uclass_plat(dev);
 
debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
- if_type, devnum, dev->name, desc->if_type, desc->devnum);
+ type, devnum, dev->name, desc->if_type, desc->devnum);
if (desc->devnum != devnum)
continue;
 
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 15/24] blk: Drop IF_TYPE_ATAPI

2022-08-11 Thread Simon Glass
This is not really needed since it does the same things as IDE. Drop it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part.c| 5 -
 drivers/block/blk-uclass.c | 2 --
 include/blk.h  | 1 -
 3 files changed, 8 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 5f64da54e54..a5c1d7a0aec 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -128,7 +128,6 @@ void dev_print (struct blk_desc *dev_desc)
dev_desc->product,
dev_desc->revision);
break;
-   case IF_TYPE_ATAPI:
case IF_TYPE_IDE:
case IF_TYPE_SATA:
printf ("Model: %s Firm: %s Ser#: %s\n",
@@ -257,9 +256,6 @@ static void print_part_header(const char *type, struct 
blk_desc *dev_desc)
case IF_TYPE_SCSI:
puts ("SCSI");
break;
-   case IF_TYPE_ATAPI:
-   puts ("ATAPI");
-   break;
case IF_TYPE_USB:
puts ("USB");
break;
@@ -767,7 +763,6 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
switch (dev_desc->if_type) {
case IF_TYPE_IDE:
case IF_TYPE_SATA:
-   case IF_TYPE_ATAPI:
devtype = "hd";
break;
case IF_TYPE_SCSI:
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index f16cb279d4e..57230e9bab7 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -20,7 +20,6 @@
 static const char *if_typename_str[IF_TYPE_COUNT] = {
[IF_TYPE_IDE]   = "ide",
[IF_TYPE_SCSI]  = "scsi",
-   [IF_TYPE_ATAPI] = "atapi",
[IF_TYPE_USB]   = "usb",
[IF_TYPE_MMC]   = "mmc",
[IF_TYPE_SD]= "sd",
@@ -36,7 +35,6 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
 static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
[IF_TYPE_IDE]   = UCLASS_IDE,
[IF_TYPE_SCSI]  = UCLASS_SCSI,
-   [IF_TYPE_ATAPI] = UCLASS_INVALID,
[IF_TYPE_USB]   = UCLASS_MASS_STORAGE,
[IF_TYPE_MMC]   = UCLASS_MMC,
[IF_TYPE_SD]= UCLASS_INVALID,
diff --git a/include/blk.h b/include/blk.h
index 1898ebdda54..c7461f9f35a 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -31,7 +31,6 @@ enum if_type {
IF_TYPE_UNKNOWN = 0,
IF_TYPE_IDE,
IF_TYPE_SCSI,
-   IF_TYPE_ATAPI,
IF_TYPE_USB,
IF_TYPE_MMC,
IF_TYPE_SD,
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 14/24] ide: Use a flag for an ATAPI device

2022-08-11 Thread Simon Glass
Rather than setting a different interface type, use a flag to indicate
that a device is ATAPI.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/block/ide.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 3270a9f032f..6bc48e3402e 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -525,8 +525,8 @@ static void ide_ident(struct blk_desc *dev_desc)
 {
unsigned char c;
hd_driveid_t iop;
-
 #ifdef CONFIG_ATAPI
+   bool is_atapi = false;
int retries = 0;
 #endif
int device;
@@ -550,7 +550,7 @@ static void ide_ident(struct blk_desc *dev_desc)
(ide_inb(device, ATA_CYL_LOW) == 0x14) &&
(ide_inb(device, ATA_CYL_HIGH) == 0xEB)) {
/* ATAPI Signature found */
-   dev_desc->if_type = IF_TYPE_ATAPI;
+   is_atapi = true;
/*
 * Start Ident Command
 */
@@ -623,7 +623,7 @@ static void ide_ident(struct blk_desc *dev_desc)
dev_desc->removable = 0;
 
 #ifdef CONFIG_ATAPI
-   if (dev_desc->if_type == IF_TYPE_ATAPI) {
+   if (is_atapi) {
atapi_inquiry(dev_desc);
return;
}
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 13/24] blk: Drop IF_TYPE_DOC

2022-08-11 Thread Simon Glass
This doesn't seem to be used for anything and it isn't clear what it is.
It dates from the first U-Boot commit.

Drop it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part.c| 9 -
 drivers/block/blk-uclass.c | 2 --
 include/blk.h  | 1 -
 3 files changed, 12 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 9594bb432c4..5f64da54e54 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -150,9 +150,6 @@ void dev_print (struct blk_desc *dev_desc)
case IF_TYPE_VIRTIO:
printf("%s VirtIO Block Device\n", dev_desc->vendor);
break;
-   case IF_TYPE_DOC:
-   puts("device type DOC\n");
-   return;
case IF_TYPE_UNKNOWN:
puts("device type unknown\n");
return;
@@ -266,9 +263,6 @@ static void print_part_header(const char *type, struct 
blk_desc *dev_desc)
case IF_TYPE_USB:
puts ("USB");
break;
-   case IF_TYPE_DOC:
-   puts ("DOC");
-   break;
case IF_TYPE_MMC:
puts ("MMC");
break;
@@ -782,9 +776,6 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
case IF_TYPE_USB:
devtype = "usbd";
break;
-   case IF_TYPE_DOC:
-   devtype = "docd";
-   break;
case IF_TYPE_MMC:
case IF_TYPE_SD:
devtype = "mmcsd";
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 1a6e8f8c29d..f16cb279d4e 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -22,7 +22,6 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
[IF_TYPE_SCSI]  = "scsi",
[IF_TYPE_ATAPI] = "atapi",
[IF_TYPE_USB]   = "usb",
-   [IF_TYPE_DOC]   = "doc",
[IF_TYPE_MMC]   = "mmc",
[IF_TYPE_SD]= "sd",
[IF_TYPE_SATA]  = "sata",
@@ -39,7 +38,6 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
[IF_TYPE_SCSI]  = UCLASS_SCSI,
[IF_TYPE_ATAPI] = UCLASS_INVALID,
[IF_TYPE_USB]   = UCLASS_MASS_STORAGE,
-   [IF_TYPE_DOC]   = UCLASS_INVALID,
[IF_TYPE_MMC]   = UCLASS_MMC,
[IF_TYPE_SD]= UCLASS_INVALID,
[IF_TYPE_SATA]  = UCLASS_AHCI,
diff --git a/include/blk.h b/include/blk.h
index 5bdffe74015..1898ebdda54 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -33,7 +33,6 @@ enum if_type {
IF_TYPE_SCSI,
IF_TYPE_ATAPI,
IF_TYPE_USB,
-   IF_TYPE_DOC,
IF_TYPE_MMC,
IF_TYPE_SD,
IF_TYPE_SATA,
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 10/24] blk: Select SPL_LEGACY_BLOCK automatically

2022-08-11 Thread Simon Glass
Selecting this option can be handled in the Kconfig option itself, as it
is with BLK. Update this an drop the various 'select' clauses.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/spl/Kconfig |  2 --
 drivers/ata/Kconfig|  1 -
 drivers/block/Kconfig  | 11 +++
 drivers/mmc/Kconfig|  1 -
 drivers/nvme/Kconfig   |  1 -
 drivers/scsi/Kconfig   |  1 -
 drivers/xen/Kconfig|  1 -
 lib/efi_loader/Kconfig |  1 -
 8 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 4c3e74ae5eb..759fb468d1a 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -792,7 +792,6 @@ config SPL_DM_MAILBOX
 config SPL_MMC
bool "Support MMC"
depends on MMC
-   select SPL_LEGACY_BLOCK
help
  Enable support for MMC (Multimedia Card) within SPL. This enables
  the MMC protocol implementation and allows any enabled drivers to
@@ -1318,7 +1317,6 @@ config SPL_THERMAL
 
 config SPL_USB_HOST
bool "Support USB host drivers"
-   select SPL_LEGACY_BLOCK
help
  Enable access to USB (Universal Serial Bus) host devices so that
  SPL can load U-Boot from a connected USB peripheral, such as a USB
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index c3f2ac058a3..a063b221cd1 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -9,7 +9,6 @@ config AHCI
 
 config SATA
bool "Support SATA controllers"
-   select SPL_LEGACY_BLOCK
help
  This enables support for SATA (Serial Advanced Technology
  Attachment), a serial bus standard for connecting to hard drives and
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 5a0c434058a..e82a779e6b8 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -13,8 +13,14 @@ config BLK
 
 config SPL_LEGACY_BLOCK
bool "Enable Legacy Block Device"
+   depends on SPL && !DM_SPL
+   default y if SPL_MMC || SPL_USB_STORAGE || SCSI || NVME || IDE
+   default y if SPL_AHCI_PCI
help
- Some devices require block support whether or not DM is enabled
+ Some devices require block support whether or not DM is enabled. This
+ is only supported in SPL. With this, the blk uclass is not used, but
+ instead a legacy implementation of block devices is used, with all
+ devices consisting of 'struct blk_desc' records.
 
 config SPL_BLK
bool "Support block devices in SPL"
@@ -109,7 +115,6 @@ endif  # EFI_MEDIA
 
 config IDE
bool "Support IDE controllers"
-   select SPL_LEGACY_BLOCK
help
  Enables support for IDE (Integrated Drive Electronics) hard drives.
  This allows access to raw blocks and filesystems on an IDE drive
@@ -222,7 +227,6 @@ endif  # IDE
 
 config LBA48
bool "Enable LBA support for disks larger than 137GB"
-   depends on SPL_LEGACY_BLOCK
help
  Set this to enable support for disks larger than 137GB.
  Also look at CONFIG_SYS_64BIT_LBA.  Without both of these, LBA48
@@ -231,7 +235,6 @@ config LBA48
 
 config SYS_64BIT_LBA
bool "Enable 64bit number of blocks on a block device"
-   depends on SPL_LEGACY_BLOCK
help
  Make the block subsystem use 64bit sector addresses, rather than the
  default of 32bit.
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index d45ad1a541d..0679b7d9235 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -3,7 +3,6 @@ menu "MMC Host controller Support"
 config MMC
bool "MMC/SD/SDIO card support"
default ARM || PPC || SANDBOX
-   select SPL_LEGACY_BLOCK
select DM_MMC if DM
help
  This selects MultiMediaCard, Secure Digital and Secure
diff --git a/drivers/nvme/Kconfig b/drivers/nvme/Kconfig
index 7b6d54615f8..73edb355160 100644
--- a/drivers/nvme/Kconfig
+++ b/drivers/nvme/Kconfig
@@ -4,7 +4,6 @@
 
 config NVME
bool "NVM Express device support"
-   select SPL_LEGACY_BLOCK
help
  This option enables support for NVM Express devices.
  It supports basic functions of NVMe (read/write).
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 4d643816fcc..ad484ce8e88 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1,6 +1,5 @@
 config SCSI
bool "Support SCSI controllers"
-   select SPL_LEGACY_BLOCK
help
  This enables support for SCSI (Small Computer System Interface),
  a parallel interface widely used with storage peripherals such as
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 20db2c53065..0ee74d036c7 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -2,7 +2,6 @@ config PVBLOCK
bool "Xen para-virtualized block device"
depends on DM
select BLK
-   select SPL_LEGACY_BLOCK
help
  This driver implements the front-end of the Xen virtual
  block devic

[PATCH v2 09/24] blk: Rename HAVE_BLOCK_DEVICE

2022-08-11 Thread Simon Glass
This option is fact really related to SPL. For U-Boot proper we always use
driver model for block devices, so CONFIG_BLK is enabled if block devices
are in use.

It is only for SPL that we have two cases:

- SPL_BLK is enabled, in which case we use driver model and blk-uclass.c
- SPL_BLK is not enabled, in which case (if we need block devices) we must
  use blk_legacy.c

Rename the symbol to SPL_LEGACY_BLOCK to make this clear. This is
different enough from BLK and SPL_BLK that there should be no confusion.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/spl/Kconfig | 4 ++--
 configs/axm_defconfig  | 2 +-
 configs/bcm968380gerg_ram_defconfig| 2 +-
 configs/gardena-smart-gateway-mt7688_defconfig | 2 +-
 configs/nsim_hs38_defconfig| 2 +-
 configs/qemu-ppce500_defconfig | 2 +-
 disk/Makefile  | 4 ++--
 disk/disk-uclass.c | 3 +--
 doc/develop/driver-model/migration.rst | 2 +-
 drivers/Makefile   | 2 +-
 drivers/ata/Kconfig| 2 +-
 drivers/block/Kconfig  | 8 
 drivers/block/Makefile | 2 +-
 drivers/mmc/Kconfig| 2 +-
 drivers/nvme/Kconfig   | 2 +-
 drivers/scsi/Kconfig   | 2 +-
 drivers/xen/Kconfig| 2 +-
 include/blk.h  | 2 +-
 lib/efi_loader/Kconfig | 2 +-
 19 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index ee98810e9e9..4c3e74ae5eb 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -792,7 +792,7 @@ config SPL_DM_MAILBOX
 config SPL_MMC
bool "Support MMC"
depends on MMC
-   select HAVE_BLOCK_DEVICE
+   select SPL_LEGACY_BLOCK
help
  Enable support for MMC (Multimedia Card) within SPL. This enables
  the MMC protocol implementation and allows any enabled drivers to
@@ -1318,7 +1318,7 @@ config SPL_THERMAL
 
 config SPL_USB_HOST
bool "Support USB host drivers"
-   select HAVE_BLOCK_DEVICE
+   select SPL_LEGACY_BLOCK
help
  Enable access to USB (Universal Serial Bus) host devices so that
  SPL can load U-Boot from a connected USB peripheral, such as a USB
diff --git a/configs/axm_defconfig b/configs/axm_defconfig
index a5f60bd8d0c..c42fb37d6c9 100644
--- a/configs/axm_defconfig
+++ b/configs/axm_defconfig
@@ -80,7 +80,7 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SPL_DM=y
 CONFIG_BLK=y
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_CLK=y
 CONFIG_CLK_AT91=y
 CONFIG_AT91_GPIO=y
diff --git a/configs/bcm968380gerg_ram_defconfig 
b/configs/bcm968380gerg_ram_defconfig
index 0475535e991..246add6029c 100644
--- a/configs/bcm968380gerg_ram_defconfig
+++ b/configs/bcm968380gerg_ram_defconfig
@@ -42,7 +42,7 @@ CONFIG_CMD_NAND=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 # CONFIG_NET is not set
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_BCM6345_GPIO=y
 CONFIG_LED=y
 CONFIG_LED_BCM6328=y
diff --git a/configs/gardena-smart-gateway-mt7688_defconfig 
b/configs/gardena-smart-gateway-mt7688_defconfig
index b9ee281be9f..fdfab14d53e 100644
--- a/configs/gardena-smart-gateway-mt7688_defconfig
+++ b/configs/gardena-smart-gateway-mt7688_defconfig
@@ -78,7 +78,7 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_DM=y
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index 3c3d1812a79..3f23fc4189f 100644
--- a/configs/nsim_hs38_defconfig
+++ b/configs/nsim_hs38_defconfig
@@ -30,7 +30,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
 CONFIG_BLK=y
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_DM_ETH=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/qemu-ppce500_defconfig b/configs/qemu-ppce500_defconfig
index 034f7e6935b..3241f5520eb 100644
--- a/configs/qemu-ppce500_defconfig
+++ b/configs/qemu-ppce500_defconfig
@@ -40,7 +40,7 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DM=y
 CONFIG_SIMPLE_BUS_CORRECT_RANGE=y
 CONFIG_BLK=y
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_LBA48=y
 CONFIG_CHIP_SELECTS_PER_CTRL=0
 CONFIG_MPC8XXX_GPIO=y
diff --git a/disk/Makefile b/disk/Makefile
index 458e21e3fb7..45588cf66e4 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -10,8 +10,8 @@ ifdef CONFIG_$(SPL_TPL_)BLK
 obj-$(CONFIG_$(SPL_TPL_)PARTITIONS)  += disk-uclass.o
 endif
 
-# Must have BLK or HAVE_BLOCK_DEVICE to support partitions
-ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_HAVE_BLOCK_DE

[PATCH v2 08/24] blk: Drop unnecessary #ifdef in in blk_legacy

2022-08-11 Thread Simon Glass
We can rely on the compiler to eliminate any dead code.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/block/blk_legacy.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
index df9a3597545..bd8a17df6a9 100644
--- a/drivers/block/blk_legacy.c
+++ b/drivers/block/blk_legacy.c
@@ -70,7 +70,6 @@ static int get_desc(struct blk_driver *drv, int devnum, 
struct blk_desc **descp)
return drv->get_dev(devnum, descp);
 }
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
 int blk_list_part(enum if_type if_type)
 {
struct blk_driver *drv;
@@ -174,7 +173,6 @@ int blk_show_device(enum if_type if_type, int devnum)
 
return 0;
 }
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
 
 struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
 {
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 05/24] disk: Use Makefile to omit partition drivers

2022-08-11 Thread Simon Glass
At present these files have an #ifdef covering the whole file. Move the
condition to the Makefile instead.

Add BLK to the condition since future patches will adjust things so that
HAVE_BLOCK_DEVICE is only for SPL, but the partition drivers are needed
in U-Boot proper too.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/Makefile | 4 
 disk/part_amiga.c | 4 
 disk/part_dos.c   | 4 
 disk/part_efi.c   | 3 ---
 disk/part_iso.c   | 3 ---
 disk/part_mac.c   | 3 ---
 drivers/Makefile  | 1 +
 7 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/disk/Makefile b/disk/Makefile
index ec148832b33..458e21e3fb7 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -9,8 +9,12 @@ obj-$(CONFIG_$(SPL_TPL_)PARTITIONS)  += part.o
 ifdef CONFIG_$(SPL_TPL_)BLK
 obj-$(CONFIG_$(SPL_TPL_)PARTITIONS)  += disk-uclass.o
 endif
+
+# Must have BLK or HAVE_BLOCK_DEVICE to support partitions
+ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_HAVE_BLOCK_DEVICE),)
 obj-$(CONFIG_$(SPL_TPL_)MAC_PARTITION)   += part_mac.o
 obj-$(CONFIG_$(SPL_TPL_)DOS_PARTITION)   += part_dos.o
 obj-$(CONFIG_$(SPL_TPL_)ISO_PARTITION)   += part_iso.o
 obj-$(CONFIG_$(SPL_TPL_)AMIGA_PARTITION) += part_amiga.o
 obj-$(CONFIG_$(SPL_TPL_)EFI_PARTITION)   += part_efi.o
+endif
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index ac7ada54781..45d3a704866 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -11,8 +11,6 @@
 #include "part_amiga.h"
 #include 
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
 #undef AMIGA_DEBUG
 
 #ifdef AMIGA_DEBUG
@@ -387,5 +385,3 @@ U_BOOT_PART_TYPE(amiga) = {
.print  = part_print_amiga,
.test   = part_test_amiga,
 };
-
-#endif
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 94fae7166d7..a94702c5f34 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -23,8 +23,6 @@
 #include "part_dos.h"
 #include 
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
 #define DOS_PART_DEFAULT_SECTOR 512
 
 /* should this be configurable? It looks like it's not very common at all
@@ -518,5 +516,3 @@ U_BOOT_PART_TYPE(dos) = {
.print  = part_print_ptr(part_print_dos),
.test   = part_test_dos,
 };
-
-#endif
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 5090efd1192..ad94504ed90 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -28,8 +28,6 @@
 #include 
 #include 
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
 /* GUID for basic data partitons */
 #if CONFIG_IS_ENABLED(EFI_PARTITION)
 static const efi_guid_t partition_basic_data_guid = PARTITION_BASIC_DATA_GUID;
@@ -1204,4 +1202,3 @@ U_BOOT_PART_TYPE(a_efi) = {
.print  = part_print_ptr(part_print_efi),
.test   = part_test_efi,
 };
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
diff --git a/disk/part_iso.c b/disk/part_iso.c
index 1061f341d35..4cd619bf46d 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -12,8 +12,6 @@
 #include 
 #include "part_iso.h"
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
 /* #define ISO_PART_DEBUG */
 
 #ifdef ISO_PART_DEBUG
@@ -241,4 +239,3 @@ U_BOOT_PART_TYPE(iso) = {
.print  = part_print_iso,
.test   = part_test_iso,
 };
-#endif
diff --git a/disk/part_mac.c b/disk/part_mac.c
index e01ae745661..ae8263f755a 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -20,8 +20,6 @@
 #include "part_mac.h"
 #include 
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
 /* stdlib.h causes some compatibility problems; should fixe these! -- wd */
 #ifndef __ldiv_t_defined
 typedef struct {
@@ -247,4 +245,3 @@ U_BOOT_PART_TYPE(mac) = {
.print  = part_print_mac,
.test   = part_test_mac,
 };
-#endif
diff --git a/drivers/Makefile b/drivers/Makefile
index eba9940231f..f2154e15d6a 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -60,6 +60,7 @@ obj-$(CONFIG_SPL_USB_HOST) += usb/host/
 obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/
 obj-$(CONFIG_SPL_SATA) += ata/ scsi/
 obj-$(CONFIG_HAVE_BLOCK_DEVICE) += block/
+obj-$(CONFIG_SPL_BLK) += block/
 obj-$(CONFIG_SPL_THERMAL) += thermal/
 
 endif
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 07/24] cmd: Drop use of HAVE_BLOCK_DEVICE

2022-08-11 Thread Simon Glass
This condition is not needed for these commands, since BLK is enabled for
all boards which use block devices and commands are not available in SPL,
so even if SPL_BLK is not enabled, it doesn't affect commands.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/Kconfig  | 5 -
 cmd/Makefile | 2 +-
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 7d19706a8ec..e5ea4e188ab 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1082,7 +1082,6 @@ config CMD_PWM
 config CMD_GPT
bool "GPT (GUID Partition Table) command"
select EFI_PARTITION
-   select HAVE_BLOCK_DEVICE
select PARTITION_UUIDS
imply RANDOM_UUID
help
@@ -1194,7 +1193,6 @@ config CMD_LSBLK
 config CMD_MBR
bool "MBR (Master Boot Record) command"
select DOS_PARTITION
-   select HAVE_BLOCK_DEVICE
help
  Enable the 'mbr' command to ready and write MBR (Master Boot Record)
  style partition tables.
@@ -1326,7 +1324,6 @@ config CMD_OSD
 config CMD_PART
bool "part"
depends on PARTITIONS
-   select HAVE_BLOCK_DEVICE
select PARTITION_UUIDS
help
  Read and display information about the partition table on
@@ -1457,7 +1454,6 @@ config CMD_UNIVERSE
 config CMD_USB
bool "usb"
depends on USB_HOST
-   select HAVE_BLOCK_DEVICE
help
  USB support.
 
@@ -1497,7 +1493,6 @@ config CMD_PVBLOCK
 config CMD_VIRTIO
bool "virtio"
depends on VIRTIO
-   depends on HAVE_BLOCK_DEVICE
default y if VIRTIO
help
  VirtIO block device support
diff --git a/cmd/Makefile b/cmd/Makefile
index 5e43a1e022e..9314640b674 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -18,7 +18,7 @@ obj-$(CONFIG_CMD_AES) += aes.o
 obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o
 obj-$(CONFIG_CMD_ADC) += adc.o
 obj-$(CONFIG_CMD_ARMFLASH) += armflash.o
-obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_common.o
+obj-$(CONFIG_BLK) += blk_common.o
 obj-$(CONFIG_CMD_BOOTDEV) += bootdev.o
 obj-$(CONFIG_CMD_BOOTFLOW) += bootflow.o
 obj-$(CONFIG_CMD_BOOTMETH) += bootmeth.o
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 06/24] blk: Use a function for whether block devices are available

2022-08-11 Thread Simon Glass
At present we use HAVE_BLOCK_DEVICE to indicate when block devices are
available.

This is a very strange option, since it partially duplicates the BLK
option used by driver model. It also covers both U-Boot proper and SPL,
even though one might have block devices and another not.

As a first step towards correcting this, create a new inline function
called blk_enabled() which indicates if block devices are available.
This cannot be used in Makefiles, or #if clauses, but can be used in C
code.

A function is useful because we cannot use CONFIG_IS_ENABLED(BLK) to
decide if block devices are needed, since we must consider the legacy
block interface, enabled by HAVE_BLOCK_DEVICE

Update a few places where it can be used and drop some unnecessary #if
checks around some functions in disk/part.c - rely on the compiler's
dead-code elimination instead.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part.c| 80 --
 drivers/block/blk-uclass.c |  3 +-
 fs/fat/fat.c   |  2 +-
 include/blk.h  |  5 +++
 4 files changed, 40 insertions(+), 50 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 79955c7fb00..9594bb432c4 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -54,12 +54,13 @@ static struct part_driver *part_driver_lookup_type(struct 
blk_desc *dev_desc)
return NULL;
 }
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
 static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
 {
struct blk_desc *dev_desc;
int ret;
 
+   if (!blk_enabled())
+   return NULL;
dev_desc = blk_get_devnum_by_typename(ifname, dev);
if (!dev_desc) {
debug("%s: No device for iface '%s', dev %d\n", __func__,
@@ -78,21 +79,11 @@ static struct blk_desc *get_dev_hwpart(const char *ifname, 
int dev, int hwpart)
 
 struct blk_desc *blk_get_dev(const char *ifname, int dev)
 {
-   return get_dev_hwpart(ifname, dev, 0);
-}
-#else
-struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
-{
-   return NULL;
-}
+   if (!blk_enabled())
+   return NULL;
 
-struct blk_desc *blk_get_dev(const char *ifname, int dev)
-{
-   return NULL;
+   return get_dev_hwpart(ifname, dev, 0);
 }
-#endif
-
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
 
 /* - */
 /*
@@ -228,9 +219,6 @@ void dev_print (struct blk_desc *dev_desc)
puts ("Capacity: not available\n");
}
 }
-#endif
-
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
 
 void part_init(struct blk_desc *dev_desc)
 {
@@ -325,38 +313,36 @@ void part_print(struct blk_desc *dev_desc)
drv->print(dev_desc);
 }
 
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
-
 int part_get_info(struct blk_desc *dev_desc, int part,
   struct disk_partition *info)
 {
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
struct part_driver *drv;
 
+   if (blk_enabled()) {
 #if CONFIG_IS_ENABLED(PARTITION_UUIDS)
-   /* The common case is no UUID support */
-   info->uuid[0] = 0;
+   /* The common case is no UUID support */
+   info->uuid[0] = 0;
 #endif
 #ifdef CONFIG_PARTITION_TYPE_GUID
-   info->type_guid[0] = 0;
+   info->type_guid[0] = 0;
 #endif
 
-   drv = part_driver_lookup_type(dev_desc);
-   if (!drv) {
-   debug("## Unknown partition table type %x\n",
- dev_desc->part_type);
-   return -EPROTONOSUPPORT;
-   }
-   if (!drv->get_info) {
-   PRINTF("## Driver %s does not have the get_info() method\n",
-  drv->name);
-   return -ENOSYS;
-   }
-   if (drv->get_info(dev_desc, part, info) == 0) {
-   PRINTF("## Valid %s partition found ##\n", drv->name);
-   return 0;
+   drv = part_driver_lookup_type(dev_desc);
+   if (!drv) {
+   debug("## Unknown partition table type %x\n",
+ dev_desc->part_type);
+   return -EPROTONOSUPPORT;
+   }
+   if (!drv->get_info) {
+   PRINTF("## Driver %s does not have the get_info() 
method\n",
+  drv->name);
+   return -ENOSYS;
+   }
+   if (drv->get_info(dev_desc, part, info) == 0) {
+   PRINTF("## Valid %s partition found ##\n", drv->name);
+   return 0;
+   }
}
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
 
return -ENOENT;
 }
@@ -424,15 +410,15 @@ int blk_get_device_by_str(const char *ifname, const char 
*dev_hwpart_str,
goto cleanup;
}
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-   /*
-* Updates the partition table for the specified hw partition.
-* Always should be done, otherwise hw partition 0 will return 

[PATCH v2 02/24] blk: Enable CONFIG_BLK for all media

2022-08-11 Thread Simon Glass
Enable this option on all boards which support block devices. Drop the
related depencies on BLK since these are not needed anymore.

Disable BLOCK_CACHE on M5253DEMO as this causes a build error.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add SATA also

 arch/arm/Kconfig| 1 -
 configs/M5253DEMO_defconfig | 1 +
 drivers/ata/Kconfig | 1 -
 drivers/block/Kconfig   | 3 ++-
 drivers/nvme/Kconfig| 1 -
 drivers/scsi/Kconfig| 1 -
 drivers/virtio/Kconfig  | 1 -
 7 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 949ebb46ba2..3cb949af165 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1016,7 +1016,6 @@ config ARCH_NPCM
 config ARCH_APPLE
bool "Apple SoCs"
select ARM64
-   select BLK
select CLK
select CMD_USB
select DM
diff --git a/configs/M5253DEMO_defconfig b/configs/M5253DEMO_defconfig
index 79382eb0fe4..a73aca082c3 100644
--- a/configs/M5253DEMO_defconfig
+++ b/configs/M5253DEMO_defconfig
@@ -25,6 +25,7 @@ CONFIG_CMD_EXT2=y
 CONFIG_CMD_FAT=y
 CONFIG_MAC_PARTITION=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_BLOCK_CACHE is not set
 CONFIG_SYS_IDE_MAXBUS=1
 CONFIG_SYS_ATA_STRIDE=4
 CONFIG_SYS_ATA_DATA_OFFSET=0xA0
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 7715c403656..7d2315bd4a2 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -9,7 +9,6 @@ config AHCI
 
 config SATA
bool "Support SATA controllers"
-   depends on BLK
select HAVE_BLOCK_DEVICE
help
  This enables support for SATA (Serial Advanced Technology
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index b5b482086af..df242df9c5f 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -1,7 +1,8 @@
 config BLK
bool "Support block devices"
depends on DM
-   default y if DM_MMC || DM_USB
+   default y if MMC || USB || SCSI || NVME || IDE || AHCI || SATA
+   default y if EFI_MEDIA || VIRTIO_BLK || PVBLOCK
help
  Enable support for block devices, such as SCSI, MMC and USB
  flash sticks. These provide a block-level interface which permits
diff --git a/drivers/nvme/Kconfig b/drivers/nvme/Kconfig
index 0cb465160bb..2a103ab5ed7 100644
--- a/drivers/nvme/Kconfig
+++ b/drivers/nvme/Kconfig
@@ -4,7 +4,6 @@
 
 config NVME
bool "NVM Express device support"
-   depends on BLK
select HAVE_BLOCK_DEVICE
help
  This option enables support for NVM Express devices.
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index c400e2de16a..19872fb52d8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -10,7 +10,6 @@ config SCSI
 
 config DM_SCSI
bool "Support SCSI controllers with driver model"
-   depends on BLK
help
  This option enables the SCSI (Small Computer System Interface) uclass
  which supports SCSI and SATA HDDs. For every device configuration
diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index 586263ec884..852f6735b60 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -64,7 +64,6 @@ config VIRTIO_NET
 config VIRTIO_BLK
bool "virtio block driver"
depends on VIRTIO
-   depends on BLK
help
  This is the virtual block driver for virtio. It can be used with
  QEMU based targets.
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 03/24] ata: Fix an instance of SPL_SATA_SUPPORT

2022-08-11 Thread Simon Glass
The _SUPPORT suffix should be dropped. This happened because the rename
was applied around the same time as this new option, so did not include
renaming the new option.

The relevant commits are:

   f7560376ae sata: Rename SATA_SUPPORT to SATA
   73059529b2 ata: ahci-pci: Add new option CONFIG_SPL_AHCI_PCI

Fix it.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Refer to a suffix, not a prefix

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

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 7d2315bd4a2..70e6bd321a6 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -47,7 +47,7 @@ config SPL_AHCI_PCI
bool "Support for PCI-based AHCI controller for SPL"
depends on SPL
depends on SPL_PCI
-   depends on SPL_SATA_SUPPORT && DM_SCSI
+   depends on SPL_SATA && DM_SCSI
 
 config DWC_AHCI
bool "Enable Synopsys DWC AHCI driver support"
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 04/24] sandbox: Avoid defining HAVE_BLOCK_DEVICE in Konfig

2022-08-11 Thread Simon Glass
This is not needed as it is implied or selected by other options anyway.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 6495e780fec..d3c5d86fb5b 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -144,7 +144,6 @@ config SANDBOX
select DM_SPI
select DM_SPI_FLASH
select GZIP_COMPRESSED
-   select HAVE_BLOCK_DEVICE
select LZO
select OF_BOARD_SETUP
select PCI_ENDPOINT
-- 
2.37.1.595.g718a3a8f04-goog



[PATCH v2 01/24] disk: Correct help for TPL_PARTITIONS

2022-08-11 Thread Simon Glass
Fix a few typos in this help text. Fix a typo in SPL_PARTITIONS while
we are here.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Update commit message
- Fix SPL_PARTITIONS too

 disk/Kconfig | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/disk/Kconfig b/disk/Kconfig
index 81d8867ed7f..c9b9dbaf1a6 100644
--- a/disk/Kconfig
+++ b/disk/Kconfig
@@ -24,7 +24,7 @@ config SPL_PARTITIONS
select SPL_STRTO
help
  Enable this for base partition support in SPL. The required
- partition table types shold be enabled separately. This add a
+ partition table types shold be enabled separately. This adds a
  small amount of size to SPL, typically 500 bytes.
 
 config TPL_PARTITIONS
@@ -32,9 +32,9 @@ config TPL_PARTITIONS
select TPL_SPRINTF
select TPL_STRTO
help
- Enable this for base partition support in SPL. The required
- partition table types shold be enabled separately. This add a
- small amount of size to SPL, typically 500 bytes.
+ Enable this for base partition support in TPL. The required
+ partition table types shold be enabled separately. This adds a
+ small amount of size to TPL, typically 500 bytes.
 
 config MAC_PARTITION
bool "Enable Apple's MacOS partition table"
-- 
2.37.1.595.g718a3a8f04-goog



Re: [PATCH 13/23] blk: Hide the BLK and SPL_LEGACY_BLOCK options

2022-08-11 Thread Simon Glass
Hi Heinrich,

On Mon, 8 Aug 2022 at 02:09, Heinrich Schuchardt  wrote:
>
> On 8/7/22 17:46, Simon Glass wrote:
> > We don't want boards to be able to change these. They can be handled
> > as dependencies of options that need them, such as SPL_MMC. There is no
> > point in enabling the block interface without any storage devices to
> > create a block device.
> >
> > Hide both options from the 'menuconfig' display and deny their use in
> > defconfig files.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >   drivers/block/Kconfig | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
> > index 7bd37f760ca..b8ed3ef8d1f 100644
> > --- a/drivers/block/Kconfig
> > +++ b/drivers/block/Kconfig
> > @@ -1,5 +1,5 @@
> >   config BLK
> > - bool "Support block devices"
> > + bool # "Support block devices"
>
> This needs be merged into patch 3 to avoid misconfigurations when
> applying only patch 1-3.

Let's not do that, then. We should apply the whole series.

Regards,
Simon


Re: [PATCH 10/23] blk: Rename HAVE_BLOCK_DEVICE

2022-08-11 Thread Simon Glass
Hi Takahiro,

On Sun, 7 Aug 2022 at 18:49, AKASHI Takahiro  wrote:
>
> On Sun, Aug 07, 2022 at 09:46:55AM -0600, Simon Glass wrote:
> > This option is fact really related to SPL. For U-Boot proper we always use
> > driver model for block devices, so CONFIG_BLK is enabled if block devices
> > are in use.
> >
> > It is only for SPL that we have two cases:
> >
> > - SPL_BLK is enabled, in which case we use driver model and blk-uclass.c
> > - SPL_BLK is not enabled, in which case (if we need block devices) we must
> >   use blk_legacy.c
> >
> > Rename the symbol to SPL_LEGACY_BLOCK to make this clear. This is
> > different enough from BLK and SPL_BLK that there should be no confusion.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  common/spl/Kconfig | 4 ++--
> >  configs/axm_defconfig  | 2 +-
> >  configs/bcm968380gerg_ram_defconfig| 2 +-
> >  configs/gardena-smart-gateway-mt7688_defconfig | 2 +-
> >  configs/nsim_hs38_defconfig| 2 +-
> >  configs/qemu-ppce500_defconfig | 2 +-
> >  disk/Makefile  | 4 ++--
> >  disk/disk-uclass.c | 3 +--
> >  doc/develop/driver-model/migration.rst | 2 +-
> >  drivers/Makefile   | 2 +-
> >  drivers/ata/Kconfig| 2 +-
> >  drivers/block/Kconfig  | 8 
> >  drivers/block/Makefile | 2 +-
> >  drivers/mmc/Kconfig| 2 +-
> >  drivers/nvme/Kconfig   | 2 +-
> >  drivers/scsi/Kconfig   | 2 +-
> >  drivers/xen/Kconfig| 2 +-
> >  include/blk.h  | 2 +-
> >  lib/efi_loader/Kconfig | 2 +-
> >  19 files changed, 24 insertions(+), 25 deletions(-)
> >
> > diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> > index ee98810e9e9..4c3e74ae5eb 100644
> > --- a/common/spl/Kconfig
> > +++ b/common/spl/Kconfig
> > @@ -792,7 +792,7 @@ config SPL_DM_MAILBOX
> >  config SPL_MMC
> >   bool "Support MMC"
> >   depends on MMC
> > - select HAVE_BLOCK_DEVICE
> > + select SPL_LEGACY_BLOCK
> >   help
> > Enable support for MMC (Multimedia Card) within SPL. This enables
> > the MMC protocol implementation and allows any enabled drivers to
> > @@ -1318,7 +1318,7 @@ config SPL_THERMAL
> >
> >  config SPL_USB_HOST
> >   bool "Support USB host drivers"
> > - select HAVE_BLOCK_DEVICE
> > + select SPL_LEGACY_BLOCK
> >   help
> > Enable access to USB (Universal Serial Bus) host devices so that
> > SPL can load U-Boot from a connected USB peripheral, such as a USB
> > diff --git a/configs/axm_defconfig b/configs/axm_defconfig
> > index a5f60bd8d0c..c42fb37d6c9 100644
> > --- a/configs/axm_defconfig
> > +++ b/configs/axm_defconfig
> > @@ -80,7 +80,7 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
> >  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> >  CONFIG_SPL_DM=y
> >  CONFIG_BLK=y
> > -CONFIG_HAVE_BLOCK_DEVICE=y
> > +CONFIG_SPL_LEGACY_BLOCK=y
> >  CONFIG_CLK=y
> >  CONFIG_CLK_AT91=y
> >  CONFIG_AT91_GPIO=y
> > diff --git a/configs/bcm968380gerg_ram_defconfig 
> > b/configs/bcm968380gerg_ram_defconfig
> > index 0475535e991..246add6029c 100644
> > --- a/configs/bcm968380gerg_ram_defconfig
> > +++ b/configs/bcm968380gerg_ram_defconfig
> > @@ -42,7 +42,7 @@ CONFIG_CMD_NAND=y
> >  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> >  # CONFIG_NET is not set
> >  # CONFIG_DM_DEVICE_REMOVE is not set
> > -CONFIG_HAVE_BLOCK_DEVICE=y
> > +CONFIG_SPL_LEGACY_BLOCK=y
> >  CONFIG_BCM6345_GPIO=y
> >  CONFIG_LED=y
> >  CONFIG_LED_BCM6328=y
> > diff --git a/configs/gardena-smart-gateway-mt7688_defconfig 
> > b/configs/gardena-smart-gateway-mt7688_defconfig
> > index b9ee281be9f..fdfab14d53e 100644
> > --- a/configs/gardena-smart-gateway-mt7688_defconfig
> > +++ b/configs/gardena-smart-gateway-mt7688_defconfig
> > @@ -78,7 +78,7 @@ CONFIG_VERSION_VARIABLE=y
> >  CONFIG_NET_RANDOM_ETHADDR=y
> >  CONFIG_SPL_DM=y
> >  # CONFIG_DM_DEVICE_REMOVE is not set
> > -CONFIG_HAVE_BLOCK_DEVICE=y
> > +CONFIG_SPL_LEGACY_BLOCK=y
> >  CONFIG_BOOTCOUNT_LIMIT=y
> >  CONFIG_LED=y
> >  CONFIG_LED_BLINK=y
> > diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
> > index 3c3d1812a79..3f23fc4189f 100644
> > --- a/configs/nsim_hs38_defconfig
> > +++ b/configs/nsim_hs38_defconfig
> > @@ -30,7 +30,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> >  CONFIG_USE_BOOTFILE=y
> >  CONFIG_BOOTFILE="uImage"
> >  CONFIG_BLK=y
> > -CONFIG_HAVE_BLOCK_DEVICE=y
> > +CONFIG_SPL_LEGACY_BLOCK=y
> >  CONFIG_DM_ETH=y
> >  CONFIG_DM_SERIAL=y
> >  CONFIG_DEBUG_UART_SHIFT=2
> > diff --git a/configs/qemu-ppce500_defconfig b/configs/qemu-ppce500_defconfig
> > index 034f7e6935b..3241f5520eb 100644
> > --- a/configs/qemu-ppce500_defconfig
> > +++ b/configs/qemu-ppce500_defconfig
> > @@ -40,7 +40,7 @@ CONFIG_NET_RAND

Re: [PATCH 03/23] blk: Enable CONFIG_BLK for all media

2022-08-11 Thread Simon Glass
Hi Heinrich,

On Mon, 8 Aug 2022 at 02:00, Heinrich Schuchardt  wrote:
>
> On 8/7/22 17:46, Simon Glass wrote:
> > Enable this option on all boards which support block devices. Drop the
> > related depencies on BLK since these are not needed anymore.
> >
> > Disable BLOCK_CACHE on M5253DEMO as this causes a build error.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >   arch/arm/Kconfig| 1 -
> >   configs/M5253DEMO_defconfig | 1 +
> >   drivers/ata/Kconfig | 1 -
> >   drivers/block/Kconfig   | 3 ++-
> >   drivers/nvme/Kconfig| 1 -
> >   drivers/scsi/Kconfig| 1 -
> >   drivers/virtio/Kconfig  | 1 -
> >   7 files changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index 949ebb46ba2..3cb949af165 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -1016,7 +1016,6 @@ config ARCH_NPCM
> >   config ARCH_APPLE
> >   bool "Apple SoCs"
> >   select ARM64
> > - select BLK
> >   select CLK
> >   select CMD_USB
> >   select DM
> > diff --git a/configs/M5253DEMO_defconfig b/configs/M5253DEMO_defconfig
> > index 79382eb0fe4..a73aca082c3 100644
> > --- a/configs/M5253DEMO_defconfig
> > +++ b/configs/M5253DEMO_defconfig
> > @@ -25,6 +25,7 @@ CONFIG_CMD_EXT2=y
> >   CONFIG_CMD_FAT=y
> >   CONFIG_MAC_PARTITION=y
> >   CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> > +# CONFIG_BLOCK_CACHE is not set
> >   CONFIG_SYS_IDE_MAXBUS=1
> >   CONFIG_SYS_ATA_STRIDE=4
> >   CONFIG_SYS_ATA_DATA_OFFSET=0xA0
> > diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
> > index 7715c403656..7d2315bd4a2 100644
> > --- a/drivers/ata/Kconfig
> > +++ b/drivers/ata/Kconfig
> > @@ -9,7 +9,6 @@ config AHCI
> >
> >   config SATA
> >   bool "Support SATA controllers"
> > - depends on BLK
> >   select HAVE_BLOCK_DEVICE
> >   help
> > This enables support for SATA (Serial Advanced Technology
> > diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
> > index b5b482086af..79cdb62aa81 100644
> > --- a/drivers/block/Kconfig
> > +++ b/drivers/block/Kconfig
> > @@ -1,7 +1,8 @@
> >   config BLK
> >   bool "Support block devices"
> >   depends on DM
> > - default y if DM_MMC || DM_USB
> > + default y if MMC || USB || SCSI || NVME || IDE || AHCI
> > + default y if EFI_MEDIA || VIRTIO_BLK || PVBLOCK
>
> Shouldn't SATA be in this list?

OK I'll add it

>
> The logic in this patch is wrong.
>
> Default y means that a user may configure BLK=n even if VIRTIO_BLK=y.
> With patch 1-3 applied qemu-riscv64_smode_defconfig plus DM_MMC=n, BLK=n
> does not compile.
>
> VIRTIO_BLK must depend on BLK=y. Same for all other drivers.
> Or you must otherwise ensure that BLK=n does not lead to a build failure.

But this is changed in a later patch, so I think this is correct. I am
trying to do one thing at a time.

Regards,
Simon


Re: [PATCH 23/23] blk: Rename if_type to uclass_id

2022-08-11 Thread Simon Glass
Hi Takahiro,

On Sun, 7 Aug 2022 at 20:00, AKASHI Takahiro  wrote:
>
> On Mon, Aug 08, 2022 at 10:32:16AM +0900, AKASHI Takahiro wrote:
> > My comment below is not directly related to the change, but
>
> Another comment,
>

OK I did a patch for the first comment, but can I please leave you to
address the second one? It is a bit sideways to my series.

Regards,
Simon


Re: binman warning/failure when blobs are missing

2022-08-11 Thread Tom Rini
On Thu, Aug 11, 2022 at 06:08:51PM -0600, Simon Glass wrote:
> Hi,
> 
> On Thu, 11 Aug 2022 at 11:44, Tom Rini  wrote:
> >
> > On Thu, Aug 11, 2022 at 09:59:05AM -0700, Tim Harvey wrote:
> > > On Thu, Aug 11, 2022 at 9:48 AM Tom Rini  wrote:
> > > >
> > > > On Thu, Aug 11, 2022 at 09:27:44AM -0700, Tim Harvey wrote:
> > > >
> > > > > Greetings,
> > > > >
> > > > > After a couple of hours troubleshooting a bad boot image today I
> > > > > realized the issue was that I had some 0 byte files for the lpddr4
> > > > > training blobs that are part of the imx8mp binman created image.
> > > > >
> > > > > Digging in I found that if a blob referenced in the binman node is
> > > > > missing a warning will be output but the missing files will be
> > > > > 'created' as 0 byte files such that the next time you build you will
> > > > > get no warning (but will have a non-working image). Additionally the
> > > > > error does not cause a non-zero exit code.
> > > > >
> > > > > I'm not that fluent in python these days, and don't have the time for
> > > > > a while to try and fix this but I figured I would at least send this
> > > > > email in case someone else does.
> > > > >
> > > > > Example:
> > > > > # rm *lpddr4*.bin # make sure lpddr4*.bin files referenced in binman
> > > > > nodes are missing
> > > > > # make distclean imx8mp_venice_defconfig flash.bin && echo "build ok"
> > > > > ...
> > > > >   BINMAN  flash.bin
> > > > > Image 'main-section' is missing external blobs and is non-functional: 
> > > > > ddr-1d-ime
> > > > > m-fw ddr-1d-dmem-fw ddr-2d-imem-fw ddr-2d-dmem-fw
> > > > > Image 'main-section' has faked external blobs and is non-functional: 
> > > > > lpddr4_pmu_
> > > > > train_1d_imem_202006.bin lpddr4_pmu_train_1d_dmem_202006.bin 
> > > > > lpddr4_pmu_train_2d
> > > > > _imem_202006.bin lpddr4_pmu_train_2d_dmem_202006.bin
> > > > >
> > > > > Some images are invalid
> > > > > ^^^ excellent warning
> > > > > build ok
> > > > > ^^^ not so great that there is a successful exit code
> > > > > # make flash.bin && echo "build ok"
> > > > > ...
> > > > >   BINMAN  flash.bin
> > > > > build ok
> > > > > ^^^ absolutely horrible that 0 byte files were created and thus
> > > > > everything looks good this time around!
> > > > > # stat -c "%s %n" lpddr4*.bin
> > > > > 0 lpddr4_pmu_train_1d_dmem_202006.bin
> > > > > 0 lpddr4_pmu_train_1d_imem_202006.bin
> > > > > 0 lpddr4_pmu_train_2d_dmem_202006.bin
> > > > > 0 lpddr4_pmu_train_2d_imem_202006.bin
> > > >
> > > > So, this isn't the first time someone has had this problem. On the one
> > > > hand, we need CI to pass, and not require fetching of arbitrary further
> > > > images to assemble the binary. On the other hand, we don't want users
> > > > spending a bunch of time because something didn't work and the normal
> > > > way of conveying THIS WON'T WORK is a non-zero exit status. Can we
> > > > easily make some flag for buildman or binman that we do set in CI but
> > > > won't be set by users?
> > > >
> > >
> > > Tom,
> > >
> > > Ok - that makes sense as far as the exit status goes. It would be MUCH
> > > easier to catch an error like this if binman didn't create 0 byte
> > > files for missing files so that you at least get the (ascii colored)
> > > message indicating the image is wrong.
> 
> Please see this:
> 
> https://patchwork.ozlabs.org/project/uboot/patch/20220807154708.1418967-2-...@chromium.org/
> 
> > >
> > > I do love the idea of a flag for CI also!
> >
> > So, that's part of the root of the problem here.  We're passing
> > --fake-ext-blobs to binman so that it will create those 0 byte files
> > and it in turn complain. I think we didn't figure out a good way to
> > tell buildman to pass that to binman tho?
> 
> I hope the above patch will fix this part of the problem.

I'm not sure. What I really want to see is something like buildman
--fake-ext-blobs, which in turn does 'make BINMANFLAGS=--fake-ext-blobs'
or 'make BINMAN_FAKE_EXT_BLOBS=1' and that is what sets --fake-ext-blobs
to be passed inside of cmd_binman, so that we can tell CI to do that
(just like we do -E today, to ensure -Werror) but regular users get
build failures.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] board: gateworks: venice: poll I2C lines to wait for GSC firmware

2022-08-11 Thread Peng Fan




On 8/12/2022 2:59 AM, Tim Harvey wrote:

In some situations the GSC firmware where the EEPROM containing the
model and DRAM configuration may not be ready by the time the SoC
is ready to talk to it over I2C.

Instead of a hard delay, poll the I2C lines to wait until they are
released to avoid the I2C drivers 'Arbitation lost' error message.

Signed-off-by: Tim Harvey 
---
  arch/arm/dts/imx8mm-venice.dts | 13 +++-
  arch/arm/dts/imx8mn-venice.dts | 13 +++-
  arch/arm/dts/imx8mp-venice.dts | 13 +++-
  board/gateworks/venice/spl.c   | 39 ++
  4 files changed, 61 insertions(+), 17 deletions(-)

diff --git a/arch/arm/dts/imx8mm-venice.dts b/arch/arm/dts/imx8mm-venice.dts
index 39b030691e53..a1f292fbd9d3 100644
--- a/arch/arm/dts/imx8mm-venice.dts
+++ b/arch/arm/dts/imx8mm-venice.dts
@@ -23,8 +23,11 @@
  
  &i2c1 {

clock-frequency = <10>;
-   pinctrl-names = "default";
+   pinctrl-names = "default", "gpio";
pinctrl-0 = <&pinctrl_i2c1>;
+   pinctrl-1 = <&pinctrl_i2c1_gpio>;
+   scl-gpios = <&gpio5 14 GPIO_ACTIVE_HIGH>;
+   sda-gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>;
status = "okay";
  
  	gsc: gsc@20 {

@@ -89,6 +92,14 @@
>;
};
  
+	pinctrl_i2c1_gpio: i2c1grp-gpio-grp {

+   fsl,pins = <
+   MX8MM_IOMUXC_I2C1_SCL_GPIO5_IO140x41c3
+   MX8MM_IOMUXC_I2C1_SDA_GPIO5_IO150x41c3
+   >;
+   u-boot,dm-spl;

u-boot,dm-spl should be in xx-u-boot.dtsi


+   };
+
pinctrl_i2c2: i2c2grp {
fsl,pins = <
MX8MM_IOMUXC_I2C2_SCL_I2C2_SCL  0x41c3
diff --git a/arch/arm/dts/imx8mn-venice.dts b/arch/arm/dts/imx8mn-venice.dts
index eeae225632d7..8480a2e368aa 100644
--- a/arch/arm/dts/imx8mn-venice.dts
+++ b/arch/arm/dts/imx8mn-venice.dts
@@ -23,8 +23,11 @@
  
  &i2c1 {

clock-frequency = <10>;
-   pinctrl-names = "default";
+   pinctrl-names = "default", "gpio";
pinctrl-0 = <&pinctrl_i2c1>;
+   pinctrl-1 = <&pinctrl_i2c1_gpio>;
+   scl-gpios = <&gpio5 14 GPIO_ACTIVE_HIGH>;
+   sda-gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>;
status = "okay";
  
  	gsc: gsc@20 {

@@ -89,6 +92,14 @@
>;
};
  
+	pinctrl_i2c1_gpio: i2c1grp-gpio-grp {

+   fsl,pins = <
+   MX8MN_IOMUXC_I2C1_SCL_GPIO5_IO140x41c3
+   MX8MN_IOMUXC_I2C1_SDA_GPIO5_IO150x41c3
+   >;
+   u-boot,dm-spl;

Ditto.


+   };
+
pinctrl_i2c2: i2c2grp {
fsl,pins = <
MX8MN_IOMUXC_I2C2_SCL_I2C2_SCL  0x41c3
diff --git a/arch/arm/dts/imx8mp-venice.dts b/arch/arm/dts/imx8mp-venice.dts
index 6b1a7f1a89d4..93145b37049b 100644
--- a/arch/arm/dts/imx8mp-venice.dts
+++ b/arch/arm/dts/imx8mp-venice.dts
@@ -23,8 +23,11 @@
  
  &i2c1 {

clock-frequency = <10>;
-   pinctrl-names = "default";
+   pinctrl-names = "default", "gpio";
pinctrl-0 = <&pinctrl_i2c1>;
+   pinctrl-1 = <&pinctrl_i2c1_gpio>;
+   scl-gpios = <&gpio5 14 GPIO_ACTIVE_HIGH>;
+   sda-gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>;
status = "okay";
  
  	gsc: gsc@20 {

@@ -89,6 +92,14 @@
>;
};
  
+	pinctrl_i2c1_gpio: i2c1grp-gpio-grp {

+   fsl,pins = <
+   MX8MP_IOMUXC_I2C1_SCL__GPIO5_IO14   0x41c3
+   MX8MP_IOMUXC_I2C1_SDA__GPIO5_IO15   0x41c3
+   >;
+   u-boot,dm-spl;


Ditto.

Regards,
Peng.


+   };
+
pinctrl_i2c2: i2c2grp {
fsl,pins = <
MX8MP_IOMUXC_I2C2_SCL__I2C2_SCL 0x41c3
diff --git a/board/gateworks/venice/spl.c b/board/gateworks/venice/spl.c
index 914a56a96f52..ae460296cb99 100644
--- a/board/gateworks/venice/spl.c
+++ b/board/gateworks/venice/spl.c
@@ -16,10 +16,12 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -219,8 +221,8 @@ static int power_init_board(void)
  
  void board_init_f(ulong dummy)

  {
-   struct udevice *dev;
-   int ret;
+   struct udevice *bus, *dev;
+   int i, ret;
int dram_sz;
  
  	arch_cpu_init();

@@ -251,19 +253,28 @@ void board_init_f(ulong dummy)
 *
 * On a board with a missing/depleted backup battery for GSC, the
 * board may be ready to probe the GSC before its firmware is
-* running. We will wait here indefinately for the GSC EEPROM.
-*/
-#ifdef CONFIG_IMX8MN
-   /*
-* IMX8MN boots quicker than IMX8MM and exposes issue
-* where because GSC I2C state machine isn't running and its
-* SCL/SDA are driven low the I2C driver spams 'Arbitration lost'
-* I2C errors.
-*
-  

Re: [PATCH] arm: dts: imx8mm-venice-gw7902: add LTE modem gpios

2022-08-11 Thread Peng Fan




On 8/12/2022 3:02 AM, Tim Harvey wrote:

Add missing LTE_PWR# and LTE_RST gpio pinmux.

Signed-off-by: Tim Harvey 


If this not diverge from Linux dts,

Acked-by: Peng Fan 


---
  arch/arm/dts/imx8mm-venice-gw7902.dts | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/arch/arm/dts/imx8mm-venice-gw7902.dts 
b/arch/arm/dts/imx8mm-venice-gw7902.dts
index 407ab4592b4c..8e8d0d34c237 100644
--- a/arch/arm/dts/imx8mm-venice-gw7902.dts
+++ b/arch/arm/dts/imx8mm-venice-gw7902.dts
@@ -742,6 +742,9 @@
MX8MM_IOMUXC_GPIO1_IO13_GPIO1_IO13  0x4041 /* 
M2_RESET */
MX8MM_IOMUXC_NAND_DATA01_GPIO3_IO7  0x4119 /* 
M2_OFF# */
MX8MM_IOMUXC_GPIO1_IO15_GPIO1_IO15  0x4159 /* 
M2_WDIS# */
+   MX8MM_IOMUXC_SAI1_TXD6_GPIO4_IO18   0x4041 /* 
LTE_INT */
+   MX8MM_IOMUXC_SAI1_TXD5_GPIO4_IO17   0x4041 /* 
LTE_RST# */
+   MX8MM_IOMUXC_SAI1_TXD4_GPIO4_IO16   0x4041 /* 
LTE_PWR */
MX8MM_IOMUXC_SAI1_TXD2_GPIO4_IO14   0x4041 /* 
AMP GPIO1 */
MX8MM_IOMUXC_SAI1_TXD0_GPIO4_IO12   0x4041 /* 
AMP GPIO2 */
MX8MM_IOMUXC_SAI1_TXC_GPIO4_IO110x4041 /* 
AMP GPIO3 */


Re: [PATCH v2] imx8*_venice_defconfig: configure default MMC env device

2022-08-11 Thread Peng Fan




On 8/12/2022 2:53 AM, Tim Harvey wrote:

When booting from USB/SDP mmc_get_env_dev() returns
CONFIG_SYS_MMC_ENV_DEV as the MMC env device (while booting from MMC
will call board_mmc_get_env_dev() to get this). Configure
CONFIG_SYS_MMC_ENV_DEV for SDHC3 (devno=2) as all Gateworks Venice
boards use SDHC3 as eMMC so that persistent env works when booting from
USB/SDP.

Reviewed-by: Fabio Estevam 
Signed-off-by: Tim Harvey 


Reviewed-by: Peng Fan 


---
v2:
- add Fabio's Reviewed-by tag
- fixed spelling error in commit log
---
  configs/imx8mm_venice_defconfig | 1 +
  configs/imx8mn_venice_defconfig | 1 +
  configs/imx8mp_venice_defconfig | 1 +
  3 files changed, 3 insertions(+)

diff --git a/configs/imx8mm_venice_defconfig b/configs/imx8mm_venice_defconfig
index ac0cee9705b0..05be8e4a20b5 100644
--- a/configs/imx8mm_venice_defconfig
+++ b/configs/imx8mm_venice_defconfig
@@ -75,6 +75,7 @@ CONFIG_SPL_OF_CONTROL=y
  CONFIG_OF_LIST="imx8mm-venice imx8mm-venice-gw71xx-0x imx8mm-venice-gw72xx-0x 
imx8mm-venice-gw73xx-0x imx8mm-venice-gw7901 imx8mm-venice-gw7902 
imx8mm-venice-gw7903"
  CONFIG_ENV_IS_IN_MMC=y
  CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+CONFIG_SYS_MMC_ENV_DEV=2
  CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
  CONFIG_USE_ETHPRIME=y
  CONFIG_ETHPRIME="eth0"
diff --git a/configs/imx8mn_venice_defconfig b/configs/imx8mn_venice_defconfig
index 935de023161a..09287a5ae3f1 100644
--- a/configs/imx8mn_venice_defconfig
+++ b/configs/imx8mn_venice_defconfig
@@ -78,6 +78,7 @@ CONFIG_SPL_OF_CONTROL=y
  CONFIG_OF_LIST="imx8mn-venice imx8mn-venice-gw7902"
  CONFIG_ENV_IS_IN_MMC=y
  CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+CONFIG_SYS_MMC_ENV_DEV=2
  CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
  CONFIG_USE_ETHPRIME=y
  CONFIG_ETHPRIME="eth0"
diff --git a/configs/imx8mp_venice_defconfig b/configs/imx8mp_venice_defconfig
index 7fdde41b6da5..9013a1164e9b 100644
--- a/configs/imx8mp_venice_defconfig
+++ b/configs/imx8mp_venice_defconfig
@@ -77,6 +77,7 @@ CONFIG_SPL_OF_CONTROL=y
  CONFIG_OF_LIST="imx8mp-venice imx8mp-venice-gw74xx"
  CONFIG_ENV_IS_IN_MMC=y
  CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+CONFIG_SYS_MMC_ENV_DEV=2
  CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
  CONFIG_NET_RANDOM_ETHADDR=y
  CONFIG_IP_DEFRAG=y


Re: binman warning/failure when blobs are missing

2022-08-11 Thread Tim Harvey
On Thu, Aug 11, 2022 at 5:09 PM Simon Glass  wrote:
>
> Hi,
>
> On Thu, 11 Aug 2022 at 11:44, Tom Rini  wrote:
> >
> > On Thu, Aug 11, 2022 at 09:59:05AM -0700, Tim Harvey wrote:
> > > On Thu, Aug 11, 2022 at 9:48 AM Tom Rini  wrote:
> > > >
> > > > On Thu, Aug 11, 2022 at 09:27:44AM -0700, Tim Harvey wrote:
> > > >
> > > > > Greetings,
> > > > >
> > > > > After a couple of hours troubleshooting a bad boot image today I
> > > > > realized the issue was that I had some 0 byte files for the lpddr4
> > > > > training blobs that are part of the imx8mp binman created image.
> > > > >
> > > > > Digging in I found that if a blob referenced in the binman node is
> > > > > missing a warning will be output but the missing files will be
> > > > > 'created' as 0 byte files such that the next time you build you will
> > > > > get no warning (but will have a non-working image). Additionally the
> > > > > error does not cause a non-zero exit code.
> > > > >
> > > > > I'm not that fluent in python these days, and don't have the time for
> > > > > a while to try and fix this but I figured I would at least send this
> > > > > email in case someone else does.
> > > > >
> > > > > Example:
> > > > > # rm *lpddr4*.bin # make sure lpddr4*.bin files referenced in binman
> > > > > nodes are missing
> > > > > # make distclean imx8mp_venice_defconfig flash.bin && echo "build ok"
> > > > > ...
> > > > >   BINMAN  flash.bin
> > > > > Image 'main-section' is missing external blobs and is non-functional: 
> > > > > ddr-1d-ime
> > > > > m-fw ddr-1d-dmem-fw ddr-2d-imem-fw ddr-2d-dmem-fw
> > > > > Image 'main-section' has faked external blobs and is non-functional: 
> > > > > lpddr4_pmu_
> > > > > train_1d_imem_202006.bin lpddr4_pmu_train_1d_dmem_202006.bin 
> > > > > lpddr4_pmu_train_2d
> > > > > _imem_202006.bin lpddr4_pmu_train_2d_dmem_202006.bin
> > > > >
> > > > > Some images are invalid
> > > > > ^^^ excellent warning
> > > > > build ok
> > > > > ^^^ not so great that there is a successful exit code
> > > > > # make flash.bin && echo "build ok"
> > > > > ...
> > > > >   BINMAN  flash.bin
> > > > > build ok
> > > > > ^^^ absolutely horrible that 0 byte files were created and thus
> > > > > everything looks good this time around!
> > > > > # stat -c "%s %n" lpddr4*.bin
> > > > > 0 lpddr4_pmu_train_1d_dmem_202006.bin
> > > > > 0 lpddr4_pmu_train_1d_imem_202006.bin
> > > > > 0 lpddr4_pmu_train_2d_dmem_202006.bin
> > > > > 0 lpddr4_pmu_train_2d_imem_202006.bin
> > > >
> > > > So, this isn't the first time someone has had this problem. On the one
> > > > hand, we need CI to pass, and not require fetching of arbitrary further
> > > > images to assemble the binary. On the other hand, we don't want users
> > > > spending a bunch of time because something didn't work and the normal
> > > > way of conveying THIS WON'T WORK is a non-zero exit status. Can we
> > > > easily make some flag for buildman or binman that we do set in CI but
> > > > won't be set by users?
> > > >
> > >
> > > Tom,
> > >
> > > Ok - that makes sense as far as the exit status goes. It would be MUCH
> > > easier to catch an error like this if binman didn't create 0 byte
> > > files for missing files so that you at least get the (ascii colored)
> > > message indicating the image is wrong.
>
> Please see this:
>
> https://patchwork.ozlabs.org/project/uboot/patch/20220807154708.1418967-2-...@chromium.org/
>
> > >
> > > I do love the idea of a flag for CI also!
> >
> > So, that's part of the root of the problem here.  We're passing
> > --fake-ext-blobs to binman so that it will create those 0 byte files
> > and it in turn complain. I think we didn't figure out a good way to
> > tell buildman to pass that to binman tho?
>
> I hope the above patch will fix this part of the problem.
>

Simon,

Yes, that certainly is an improvement. That throws the big ugly
warning every build.

Thanks,

Tim


Re: binman warning/failure when blobs are missing

2022-08-11 Thread Simon Glass
Hi,

On Thu, 11 Aug 2022 at 11:44, Tom Rini  wrote:
>
> On Thu, Aug 11, 2022 at 09:59:05AM -0700, Tim Harvey wrote:
> > On Thu, Aug 11, 2022 at 9:48 AM Tom Rini  wrote:
> > >
> > > On Thu, Aug 11, 2022 at 09:27:44AM -0700, Tim Harvey wrote:
> > >
> > > > Greetings,
> > > >
> > > > After a couple of hours troubleshooting a bad boot image today I
> > > > realized the issue was that I had some 0 byte files for the lpddr4
> > > > training blobs that are part of the imx8mp binman created image.
> > > >
> > > > Digging in I found that if a blob referenced in the binman node is
> > > > missing a warning will be output but the missing files will be
> > > > 'created' as 0 byte files such that the next time you build you will
> > > > get no warning (but will have a non-working image). Additionally the
> > > > error does not cause a non-zero exit code.
> > > >
> > > > I'm not that fluent in python these days, and don't have the time for
> > > > a while to try and fix this but I figured I would at least send this
> > > > email in case someone else does.
> > > >
> > > > Example:
> > > > # rm *lpddr4*.bin # make sure lpddr4*.bin files referenced in binman
> > > > nodes are missing
> > > > # make distclean imx8mp_venice_defconfig flash.bin && echo "build ok"
> > > > ...
> > > >   BINMAN  flash.bin
> > > > Image 'main-section' is missing external blobs and is non-functional: 
> > > > ddr-1d-ime
> > > > m-fw ddr-1d-dmem-fw ddr-2d-imem-fw ddr-2d-dmem-fw
> > > > Image 'main-section' has faked external blobs and is non-functional: 
> > > > lpddr4_pmu_
> > > > train_1d_imem_202006.bin lpddr4_pmu_train_1d_dmem_202006.bin 
> > > > lpddr4_pmu_train_2d
> > > > _imem_202006.bin lpddr4_pmu_train_2d_dmem_202006.bin
> > > >
> > > > Some images are invalid
> > > > ^^^ excellent warning
> > > > build ok
> > > > ^^^ not so great that there is a successful exit code
> > > > # make flash.bin && echo "build ok"
> > > > ...
> > > >   BINMAN  flash.bin
> > > > build ok
> > > > ^^^ absolutely horrible that 0 byte files were created and thus
> > > > everything looks good this time around!
> > > > # stat -c "%s %n" lpddr4*.bin
> > > > 0 lpddr4_pmu_train_1d_dmem_202006.bin
> > > > 0 lpddr4_pmu_train_1d_imem_202006.bin
> > > > 0 lpddr4_pmu_train_2d_dmem_202006.bin
> > > > 0 lpddr4_pmu_train_2d_imem_202006.bin
> > >
> > > So, this isn't the first time someone has had this problem. On the one
> > > hand, we need CI to pass, and not require fetching of arbitrary further
> > > images to assemble the binary. On the other hand, we don't want users
> > > spending a bunch of time because something didn't work and the normal
> > > way of conveying THIS WON'T WORK is a non-zero exit status. Can we
> > > easily make some flag for buildman or binman that we do set in CI but
> > > won't be set by users?
> > >
> >
> > Tom,
> >
> > Ok - that makes sense as far as the exit status goes. It would be MUCH
> > easier to catch an error like this if binman didn't create 0 byte
> > files for missing files so that you at least get the (ascii colored)
> > message indicating the image is wrong.

Please see this:

https://patchwork.ozlabs.org/project/uboot/patch/20220807154708.1418967-2-...@chromium.org/

> >
> > I do love the idea of a flag for CI also!
>
> So, that's part of the root of the problem here.  We're passing
> --fake-ext-blobs to binman so that it will create those 0 byte files
> and it in turn complain. I think we didn't figure out a good way to
> tell buildman to pass that to binman tho?

I hope the above patch will fix this part of the problem.

Regards,
Simon


Re: [PATCH 09/11] binman: Allow the image name to be the data file

2022-08-11 Thread Simon Glass
Hi Quentin,

On Thu, 11 Aug 2022 at 09:04, Quentin Schulz
 wrote:
>
> Hi Simon,
>
> On 8/11/22 16:04, Simon Glass wrote:
> > Some image types use the -n parameter to pass in the data file. Add
> > support for this, with a new property.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >   tools/binman/entries.rst   | 15 +++
> >   tools/binman/etype/mkimage.py  | 26 --
> >   tools/binman/ftest.py  | 17 +
> >   tools/binman/test/235_mkimage_name.dts | 18 ++
> >   4 files changed, 74 insertions(+), 2 deletions(-)
> >   create mode 100644 tools/binman/test/235_mkimage_name.dts
> >
> > diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
> > index 8d7cbdc2e75..1d38c513ffa 100644
> > --- a/tools/binman/entries.rst
> > +++ b/tools/binman/entries.rst
> > @@ -1101,6 +1101,8 @@ Entry: mkimage: Binary produced by mkimage
> >
> >   Properties / Entry arguments:
> >   - args: Arguments to pass
> > +- data-to-imagename: Indicates that the -d data should be passed in as
> > +  the image name also (-n)
> >
> >   The data passed to mkimage via the -d flag is collected from subnodes of 
> > the
> >   mkimage node, e.g.::
> > @@ -1141,6 +1143,19 @@ this example which also produces four arguments::
> >   };
> >   };
> >
> > +If you need to pass the input data in with the -n argument as well, then 
> > use
> > +the 'data-to-imagename' property::
> > +
> > +mkimage {
> > +args = "-T imximage";
> > +data-to-imagename';
>
> Spurious quote.
>
> > +
> > +u-boot-spl {
> > +};
> > +};
> > +
> > +That will pass the data to mkimage both as the data file (with -d) and as
> > +the image name (with -n).
> >
>
> What exactly is passed to -n here? If I read the code correctly, that
> would be "spl/u-boot-spl.bin"?

Yes, that's right.

>
> I admittedly also have absolutely no clue what the mkimage -n option
> does, but I guess that's an issue more for mkimage than binman.

Yes, it is used to hold a config or data file with some types, e.g. imx8mm

Regards,
Simon


Re: [PATCH v2 2/6] console: Implement flush() function

2022-08-11 Thread Simon Glass
Hi Pali,

On Thu, 11 Aug 2022 at 08:50, Pali Rohár  wrote:
>
> On Thursday 11 August 2022 08:47:50 Simon Glass wrote:
> > > diff --git a/include/stdio_dev.h b/include/stdio_dev.h
> > > index 270fa2729fb2..06278366ae88 100644
> > > --- a/include/stdio_dev.h
> > > +++ b/include/stdio_dev.h
> > > @@ -37,6 +37,10 @@ struct stdio_dev {
> > > void (*putc)(struct stdio_dev *dev, const char c);
> > > /* To put a string (accelerator) */
> > > void (*puts)(struct stdio_dev *dev, const char *s);
> > > +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
> >
> > I'd argue it isn't worth the #ifdef and we might as well have this
> > member here always. Then you can drop some #ifdefs from your code.
>
> But then it will increase binary code size.

Using the member will increase code size. But I think the only place
you need an #ifdef for that is when you include it in the driver
struct. You can use __maybe_unused in the other place.

Having the member will only increase memory usage, not code size.

Regards,
Simon


Re: [PATCH v2 5/6] serial: Call flush() before changing baudrate

2022-08-11 Thread Simon Glass
Hi Pali,

On Thu, 11 Aug 2022 at 08:51, Pali Rohár  wrote:
>
> On Thursday 11 August 2022 08:47:53 Simon Glass wrote:
> > On Thu, 11 Aug 2022 at 06:39, Pali Rohár  wrote:
> > >
> > > Changing baudrate is sensitive operation. To ensure that U-Boot messages
> >
> > is a sensitive
> >
> > > printed before changing baudrate are not lost, call new U-Boot console
> > > flush() function.
> > >
> > > Signed-off-by: Pali Rohár 
> > > ---
> > >  cmd/load.c | 5 +
> > >  drivers/serial/serial-uclass.c | 1 +
> > >  drivers/serial/serial.c| 1 +
> > >  3 files changed, 7 insertions(+)
> > >
> > > diff --git a/cmd/load.c b/cmd/load.c
> > > index e44ae0d56b75..5c4f34781d45 100644
> > > --- a/cmd/load.c
> > > +++ b/cmd/load.c
> > > @@ -83,6 +83,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int 
> > > flag, int argc,
> > > printf("## Switch baudrate to %d bps and press ENTER 
> > > ...\n",
> > > load_baudrate);
> > > udelay(5);
> > > +   flush();
> > > gd->baudrate = load_baudrate;
> > > serial_setbrg();
> > > udelay(5);
> > > @@ -126,6 +127,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int 
> > > flag, int argc,
> > > printf("## Switch baudrate to %d bps and press ESC ...\n",
> > > current_baudrate);
> > > udelay(5);
> > > +   flush();
> > > gd->baudrate = current_baudrate;
> > > serial_setbrg();
> > > udelay(5);
> > > @@ -317,6 +319,7 @@ int do_save_serial(struct cmd_tbl *cmdtp, int flag, 
> > > int argc,
> > > printf("## Switch baudrate to %d bps and press ESC ...\n",
> > > (int)current_baudrate);
> > > udelay(5);
> > > +   flush();
> > > gd->baudrate = current_baudrate;
> > > serial_setbrg();
> > > udelay(5);
> > > @@ -471,6 +474,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, 
> > > int flag, int argc,
> > > printf("## Switch baudrate to %d bps and press ENTER 
> > > ...\n",
> > > load_baudrate);
> > > udelay(5);
> > > +   flush();
> > > gd->baudrate = load_baudrate;
> > > serial_setbrg();
> > > udelay(5);
> > > @@ -533,6 +537,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, 
> > > int flag, int argc,
> > > printf("## Switch baudrate to %d bps and press ESC ...\n",
> > > current_baudrate);
> > > udelay(5);
> > > +   flush();
> > > gd->baudrate = current_baudrate;
> > > serial_setbrg();
> > > udelay(5);
> > > diff --git a/drivers/serial/serial-uclass.c 
> > > b/drivers/serial/serial-uclass.c
> > > index 4e32270d4660..0f6860d9100e 100644
> > > --- a/drivers/serial/serial-uclass.c
> > > +++ b/drivers/serial/serial-uclass.c
> > > @@ -527,6 +527,7 @@ static int on_baudrate(const char *name, const char 
> > > *value, enum env_op op,
> > > printf("## Switch baudrate to %d bps and press 
> > > ENTER ...\n",
> > >baudrate);
> > > udelay(5);
> > > +   flush();
> > > }
> > >
> > > gd->baudrate = baudrate;
> > > diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
> > > index 6cdbb89841c1..4b525b644928 100644
> > > --- a/drivers/serial/serial.c
> > > +++ b/drivers/serial/serial.c
> > > @@ -81,6 +81,7 @@ static int on_baudrate(const char *name, const char 
> > > *value, enum env_op op,
> > > printf("## Switch baudrate to %d"
> > > " bps and press ENTER ...\n", baudrate);
> > > udelay(5);
> > > +   flush();
> >
> > Please don't implement new features in legacy code.
>
> Sorry, I do not know what is the legacy code in this spaghetti monster.

This file is legacy...you only need to change the uclass.

>
> > > }
> > >
> > > gd->baudrate = baudrate;
> > > --
> > > 2.20.1
> > >
> >
> > Regards,
> > SImon

Regards,
Simon


Re: [PATCH 0/5] arm: bcmbca: move bcm63158 support under CONFIG_ARCH_BCMBCA

2022-08-11 Thread William Zhang
Sorry forgot to mention.  This patch series need to apply on top of my 
previous patch series:


https://lists.denx.de/pipermail/u-boot/2022-August/491061.html

On 08/11/2022 04:17 PM, William Zhang wrote:

BCM63158 is one of the Broadcom Broadband origin DSL Gateway router SoC.
It was originally added by Philippe before Broadcom started to upstream
the support for broadband SoCs. The ARM based Broadcom Broadband SoC
family is now supported under the same ARCH_BCMBCA config. This patch
series migrate the BCM63158 support to ARCH_BCMBCA.


William Zhang (5):
   arm: bcmbca: add bcm63158 SoC support under CONFIG_ARCH_BCMBCA
   arm: bcmbca: remove bcm63158 support under CONFIG_ARCH_BCM63158
   arm: bcmbca: make bcm63158 driver depending on CONFIG_BCM63158
   MAINTAINERS: Add BCM63158 maintainer to BCMBCA entry
   arm: bcmbca: make reset_cpu function weak

  MAINTAINERS   |   2 +
  arch/arm/Kconfig  |   8 +-
  arch/arm/dts/Makefile |   5 +-
  arch/arm/dts/bcm63158.dtsi| 207 +-
  arch/arm/dts/bcm963158.dts|   6 +-
  arch/arm/mach-bcmbca/Kconfig  |   8 +
  arch/arm/mach-bcmbca/Makefile |   1 +
  arch/arm/mach-bcmbca/bcm63158/Kconfig |  17 ++
  arch/arm/mach-bcmbca/bcm63158/Makefile|   5 +
  arch/arm/mach-bcmbca/bcm63158/mmu_table.c |  32 
  board/broadcom/bcm963158/Kconfig  |  17 --
  board/broadcom/bcm963158/MAINTAINERS  |   6 -
  board/broadcom/bcm963158/Makefile |   3 -
  board/broadcom/bcm963158/bcm963158.c  |  62 ---
  board/broadcom/bcmbca/Kconfig |   7 +
  board/broadcom/bcmbca/board.c |   2 +-
  configs/bcm963158_defconfig   |  23 +++
  configs/bcm963158_ram_defconfig   |  10 +-
  drivers/gpio/Kconfig  |   2 +-
  drivers/led/Kconfig   |   2 +-
  drivers/mtd/nand/raw/Kconfig  |   2 +-
  drivers/spi/Kconfig   |   2 +-
  drivers/watchdog/Kconfig  |   2 +-
  include/configs/bcm963158.h   |  15 ++
  include/configs/broadcom_bcm963158.h  |  32 
  25 files changed, 254 insertions(+), 224 deletions(-)
  create mode 100644 arch/arm/mach-bcmbca/bcm63158/Kconfig
  create mode 100644 arch/arm/mach-bcmbca/bcm63158/Makefile
  create mode 100644 arch/arm/mach-bcmbca/bcm63158/mmu_table.c
  delete mode 100644 board/broadcom/bcm963158/Kconfig
  delete mode 100644 board/broadcom/bcm963158/MAINTAINERS
  delete mode 100644 board/broadcom/bcm963158/Makefile
  delete mode 100644 board/broadcom/bcm963158/bcm963158.c
  create mode 100644 configs/bcm963158_defconfig
  create mode 100644 include/configs/bcm963158.h
  delete mode 100644 include/configs/broadcom_bcm963158.h



smime.p7s
Description: S/MIME Cryptographic Signature


[RESEND PATCH] arm: kirkwood: nsa310s: Add Distro boot capability

2022-08-11 Thread Tony Dinh
- Add distro boot to board include file and deconfig file
- Miscellaneous changes:
- Remove Gerald from maintainer list (email bounced)
- Add CONFIG_SUPPORT_PASSING_ATAGS and friends to support legacy
kernel method of booting (e.g. OpenWrt) with appended DTB.
- Add CONFIG_UBIFS_SILENCE_MSG to reduce binary size.

Note that this patch is depended on the following patch:
https://patchwork.ozlabs.org/project/uboot/patch/20220807192709.21717-1-p...@kernel.org/

Signed-off-by: Tony Dinh 
---

 board/zyxel/nsa310s/MAINTAINERS |  1 -
 configs/nsa310s_defconfig   | 17 +
 include/configs/nsa310s.h   | 31 +--
 3 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/board/zyxel/nsa310s/MAINTAINERS b/board/zyxel/nsa310s/MAINTAINERS
index d153758c21..11106acf3e 100644
--- a/board/zyxel/nsa310s/MAINTAINERS
+++ b/board/zyxel/nsa310s/MAINTAINERS
@@ -1,5 +1,4 @@
 NSA310S BOARD
-M: Gerald Kerma 
 M: Tony Dinh 
 M: Luka Perkov 
 S: Maintained
diff --git a/configs/nsa310s_defconfig b/configs/nsa310s_defconfig
index 2b39ae74b3..a5f01ef88e 100644
--- a/configs/nsa310s_defconfig
+++ b/configs/nsa310s_defconfig
@@ -4,6 +4,9 @@ CONFIG_SYS_DCACHE_OFF=y
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_SYS_THUMB_BUILD=y
 CONFIG_ARCH_KIRKWOOD=y
+CONFIG_SUPPORT_PASSING_ATAGS=y
+CONFIG_CMDLINE_TAG=y
+CONFIG_INITRD_TAG=y
 CONFIG_SYS_KWD_CONFIG="board/zyxel/nsa310s/kwbimage.cfg"
 CONFIG_SYS_TEXT_BASE=0x60
 CONFIG_SYS_MALLOC_F_LEN=0x400
@@ -14,35 +17,25 @@ CONFIG_ENV_OFFSET=0xE
 CONFIG_DEFAULT_DEVICE_TREE="kirkwood-nsa310s"
 CONFIG_IDENT_STRING="\nZyXEL NSA310S/320S 1/2-Bay Power Media Server"
 CONFIG_SYS_LOAD_ADDR=0x80
+CONFIG_DISTRO_DEFAULTS=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc8012000
 CONFIG_BOOTDELAY=3
-CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="setenv bootargs ${console} ${mtdparts} ${bootargs_root}; 
ubi part root; ubifsmount ubi:rootfs; ubifsload 0x80 ${kernel}; ubifsload 
0x70 ${fdt}; ubifsumount; fdt addr 0x70; fdt resize; fdt chosen; bootz 
0x80 - 0x70"
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_BOARDINFO is not set
-CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="NSA310s> "
 CONFIG_SYS_MAXARGS=32
 CONFIG_SYS_PBSIZE=1050
-CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_NAND=y
 CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_MII=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_JFFS2=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=orion_nand"
 
CONFIG_MTDPARTS_DEFAULT="mtdparts=orion_nand:0xe@0x0(uboot),0x2@0xe(uboot_env),0x10@0x10(second_stage_uboot),-@0x20(root)"
 CONFIG_CMD_UBI=y
-CONFIG_ISO_PARTITION=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_NAND=y
@@ -65,6 +58,6 @@ CONFIG_MII=y
 CONFIG_SYS_NS16550=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_STORAGE=y
+CONFIG_UBIFS_SILENCE_MSG=y
 CONFIG_LZMA=y
 CONFIG_BZIP2=y
diff --git a/include/configs/nsa310s.h b/include/configs/nsa310s.h
index 027a47b5a3..62f0701180 100644
--- a/include/configs/nsa310s.h
+++ b/include/configs/nsa310s.h
@@ -9,15 +9,42 @@
 #ifndef _CONFIG_NSA310S_H
 #define _CONFIG_NSA310S_H
 
+/*
+ * mv-common.h should be defined after CMD configs since it used them
+ * to enable certain macros
+ */
 #include "mv-common.h"
 
-/* default environment variables */
+/* Include the common distro boot environment */
+#ifndef CONFIG_SPL_BUILD
+
+#define BOOT_TARGET_DEVICES(func) \
+   func(USB, usb, 0) \
+   func(SATA, sata, 0) \
+   func(DHCP, dhcp, na)
+
+#define KERNEL_ADDR_R  __stringify(0x80)
+#define FDT_ADDR_R __stringify(0x2c0)
+#define RAMDISK_ADDR_R __stringify(0x0110)
+#define SCRIPT_ADDR_R  __stringify(0x20)
+
+#define LOAD_ADDRESS_ENV_SETTINGS \
+   "kernel_addr_r=" KERNEL_ADDR_R "\0" \
+   "fdt_addr_r=" FDT_ADDR_R "\0" \
+   "ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
+   "scriptaddr=" SCRIPT_ADDR_R "\0"
+
+#include 
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
"console=console=ttyS0,115200\0" \
"kernel=/boot/zImage\0" \
"fdt=/boot/nsa310s.dtb\0" \
-   "bootargs_root=ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rw\0"
+   "bootargs_root=ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rw\0" \
+   LOAD_ADDRESS_ENV_SETTINGS \
+   BOOTENV
+
+#endif /* CONFIG_SPL_BUILD */
 
 /* Ethernet driver configuration */
 #define CONFIG_MVGBE_PORTS {1, 0}  /* enable port 0 only */
-- 
2.30.2



[PATCH 0/5] arm: bcmbca: move bcm63158 support under CONFIG_ARCH_BCMBCA

2022-08-11 Thread William Zhang
BCM63158 is one of the Broadcom Broadband origin DSL Gateway router SoC.
It was originally added by Philippe before Broadcom started to upstream
the support for broadband SoCs. The ARM based Broadcom Broadband SoC
family is now supported under the same ARCH_BCMBCA config. This patch
series migrate the BCM63158 support to ARCH_BCMBCA.


William Zhang (5):
  arm: bcmbca: add bcm63158 SoC support under CONFIG_ARCH_BCMBCA
  arm: bcmbca: remove bcm63158 support under CONFIG_ARCH_BCM63158
  arm: bcmbca: make bcm63158 driver depending on CONFIG_BCM63158
  MAINTAINERS: Add BCM63158 maintainer to BCMBCA entry
  arm: bcmbca: make reset_cpu function weak

 MAINTAINERS   |   2 +
 arch/arm/Kconfig  |   8 +-
 arch/arm/dts/Makefile |   5 +-
 arch/arm/dts/bcm63158.dtsi| 207 +-
 arch/arm/dts/bcm963158.dts|   6 +-
 arch/arm/mach-bcmbca/Kconfig  |   8 +
 arch/arm/mach-bcmbca/Makefile |   1 +
 arch/arm/mach-bcmbca/bcm63158/Kconfig |  17 ++
 arch/arm/mach-bcmbca/bcm63158/Makefile|   5 +
 arch/arm/mach-bcmbca/bcm63158/mmu_table.c |  32 
 board/broadcom/bcm963158/Kconfig  |  17 --
 board/broadcom/bcm963158/MAINTAINERS  |   6 -
 board/broadcom/bcm963158/Makefile |   3 -
 board/broadcom/bcm963158/bcm963158.c  |  62 ---
 board/broadcom/bcmbca/Kconfig |   7 +
 board/broadcom/bcmbca/board.c |   2 +-
 configs/bcm963158_defconfig   |  23 +++
 configs/bcm963158_ram_defconfig   |  10 +-
 drivers/gpio/Kconfig  |   2 +-
 drivers/led/Kconfig   |   2 +-
 drivers/mtd/nand/raw/Kconfig  |   2 +-
 drivers/spi/Kconfig   |   2 +-
 drivers/watchdog/Kconfig  |   2 +-
 include/configs/bcm963158.h   |  15 ++
 include/configs/broadcom_bcm963158.h  |  32 
 25 files changed, 254 insertions(+), 224 deletions(-)
 create mode 100644 arch/arm/mach-bcmbca/bcm63158/Kconfig
 create mode 100644 arch/arm/mach-bcmbca/bcm63158/Makefile
 create mode 100644 arch/arm/mach-bcmbca/bcm63158/mmu_table.c
 delete mode 100644 board/broadcom/bcm963158/Kconfig
 delete mode 100644 board/broadcom/bcm963158/MAINTAINERS
 delete mode 100644 board/broadcom/bcm963158/Makefile
 delete mode 100644 board/broadcom/bcm963158/bcm963158.c
 create mode 100644 configs/bcm963158_defconfig
 create mode 100644 include/configs/bcm963158.h
 delete mode 100644 include/configs/broadcom_bcm963158.h

-- 
2.37.1



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH 5/5] arm: bcmbca: make reset_cpu function weak

2022-08-11 Thread William Zhang
BCM63158 carries the CONFIG_SYSRESET from the original configuration. It
provide reset_cpu function already so need to define weak version of the
dummy reset_cpu for other BCMBCA SoCs to avoid linking error.

Signed-off-by: William Zhang 

---

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

diff --git a/board/broadcom/bcmbca/board.c b/board/broadcom/bcmbca/board.c
index 4aa1d659d5c7..811236afae6e 100644
--- a/board/broadcom/bcmbca/board.c
+++ b/board/broadcom/bcmbca/board.c
@@ -30,6 +30,6 @@ int print_cpuinfo(void)
return 0;
 }
 
-void reset_cpu(ulong addr)
+__weak void reset_cpu(ulong addr)
 {
 }
-- 
2.37.1



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH 4/5] MAINTAINERS: Add BCM63158 maintainer to BCMBCA entry

2022-08-11 Thread William Zhang
Since ARCH_BCM63158 SoC support is merged into ARCH_BCMBCA, add BCM63158
maintainer Philippe to bcmbca maintainer list.

Signed-off-by: William Zhang 
---

 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5b219d62f6bf..d0a5b2352cc8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -213,6 +213,7 @@ M:  Anand Gore 
 M: William Zhang 
 M: Kursad Oney 
 M: Joel Peshkin 
+M: Philippe Reynes 
 S: Maintained
 F: arch/arm/mach-bcmbca/
 F: board/broadcom/bcmbca/
-- 
2.37.1



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH 3/5] arm: bcmbca: make bcm63158 driver depending on CONFIG_BCM63158

2022-08-11 Thread William Zhang
As CONFIG_ARCH_BCM63158 is replaced with CONFIG_BCM63158, update the
driver Kconfig to use the new config symbol

Signed-off-by: William Zhang 
---

 drivers/gpio/Kconfig | 2 +-
 drivers/led/Kconfig  | 2 +-
 drivers/mtd/nand/raw/Kconfig | 2 +-
 drivers/spi/Kconfig  | 2 +-
 drivers/watchdog/Kconfig | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index aaa152fae73b..83f4f5089992 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -111,7 +111,7 @@ config BCM2835_GPIO
 config BCM6345_GPIO
bool "BCM6345 GPIO driver"
depends on DM_GPIO && (ARCH_BMIPS || ARCH_BCM68360 || \
-  ARCH_BCM6858 || ARCH_BCM63158 || \
+  ARCH_BCM6858 || BCM63158 || \
   ARCH_BCM6753)
help
  This driver supports the GPIO banks on BCM6345 SoCs.
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index ccdd7d7395c8..d777414dda8d 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -37,7 +37,7 @@ config LED_BCM6753
 
 config LED_BCM6858
bool "LED Support for BCM6858"
-   depends on LED && (ARCH_BCM68360 || ARCH_BCM6858 || ARCH_BCM63158)
+   depends on LED && (ARCH_BCM68360 || ARCH_BCM6858 || BCM63158)
help
  This option enables support for LEDs connected to the BCM6858
  HW has blinking capabilities and up to 32 LEDs can be controlled.
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index ce67d1abde25..24c27b6ecf7f 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -121,7 +121,7 @@ config NAND_BRCMNAND_6858
 
 config NAND_BRCMNAND_63158
bool "Support Broadcom NAND controller on bcm63158"
-   depends on NAND_BRCMNAND && ARCH_BCM63158
+   depends on NAND_BRCMNAND && BCM63158
help
  Enable support for broadcom nand driver on bcm63158.
 
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 75b794548b22..0a666eee80e7 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -92,7 +92,7 @@ config ATMEL_SPI
 config BCM63XX_HSSPI
bool "BCM63XX HSSPI driver"
depends on (ARCH_BMIPS || ARCH_BCM68360 || \
-   ARCH_BCM6858 || ARCH_BCM63158)
+   ARCH_BCM6858 || BCM63158)
help
  Enable the BCM6328 HSSPI driver. This driver can be used to
  access the SPI NOR flash on platforms embedding this Broadcom
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 50e6a1efba51..ff4d1ee530d2 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -129,7 +129,7 @@ config WDT_AT91
 config WDT_BCM6345
bool "BCM6345 watchdog timer support"
depends on WDT && (ARCH_BMIPS || ARCH_BCM68360 || \
-  ARCH_BCM6858 || ARCH_BCM63158 || \
+  ARCH_BCM6858 || BCM63158 || \
   ARCH_BCM6753)
help
  Select this to enable watchdog timer for BCM6345 SoCs.
-- 
2.37.1



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH 2/5] arm: bcmbca: remove bcm63158 support under CONFIG_ARCH_BCM63158

2022-08-11 Thread William Zhang
Now that BCM63158 is supported under CONFIG_ARCH_BCMBCA and
CONFIG_BCM63158, remove the original ARCH_BCM63158 support and migrate
configuration settings.

Signed-off-by: William Zhang 
---

 arch/arm/Kconfig |  8 +---
 arch/arm/dts/Makefile|  3 --
 board/broadcom/bcm963158/Kconfig | 17 
 board/broadcom/bcm963158/MAINTAINERS |  6 ---
 board/broadcom/bcm963158/Makefile|  3 --
 board/broadcom/bcm963158/bcm963158.c | 62 
 configs/bcm963158_ram_defconfig  | 10 ++---
 include/configs/bcm963158.h  |  4 ++
 include/configs/broadcom_bcm963158.h | 32 --
 9 files changed, 10 insertions(+), 135 deletions(-)
 delete mode 100644 board/broadcom/bcm963158/Kconfig
 delete mode 100644 board/broadcom/bcm963158/MAINTAINERS
 delete mode 100644 board/broadcom/bcm963158/Makefile
 delete mode 100644 board/broadcom/bcm963158/bcm963158.c
 delete mode 100644 include/configs/broadcom_bcm963158.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 0d4903a2eb5b..da4defa08466 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -665,12 +665,6 @@ config ARCH_BCM283X
imply CMD_DM
imply FAT_WRITE
 
-config ARCH_BCM63158
-   bool "Broadcom BCM63158 family"
-   select DM
-   select OF_CONTROL
-   imply CMD_DM
-
 config ARCH_BCM6753
bool "Broadcom BCM6753 family"
select CPU_V7A
@@ -706,6 +700,7 @@ config ARCH_BCMBCA
bool "Broadcom broadband chip family"
select DM
select OF_CONTROL
+   imply CMD_DM
 
 config TARGET_VEXPRESS_CA9X4
bool "Support vexpress_ca9x4"
@@ -2284,7 +2279,6 @@ source "board/Marvell/octeontx2/Kconfig"
 source "board/armltd/vexpress/Kconfig"
 source "board/armltd/vexpress64/Kconfig"
 source "board/cortina/presidio-asic/Kconfig"
-source "board/broadcom/bcm963158/Kconfig"
 source "board/broadcom/bcm96753ref/Kconfig"
 source "board/broadcom/bcm968360bg/Kconfig"
 source "board/broadcom/bcm968580xref/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index a7fc3d7d7021..c55bc3569662 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1147,9 +1147,6 @@ dtb-$(CONFIG_ARCH_BCM283X) += \
bcm2837-rpi-cm3-io3.dtb \
bcm2711-rpi-4-b.dtb
 
-dtb-$(CONFIG_ARCH_BCM63158) += \
-   bcm963158.dtb
-
 dtb-$(CONFIG_ARCH_BCM68360) += \
bcm968360bg.dtb
 
diff --git a/board/broadcom/bcm963158/Kconfig b/board/broadcom/bcm963158/Kconfig
deleted file mode 100644
index 08a8bc1c14d3..
--- a/board/broadcom/bcm963158/Kconfig
+++ /dev/null
@@ -1,17 +0,0 @@
-if TARGET_BCM963158
-
-config SYS_VENDOR
-   default "broadcom"
-
-config SYS_BOARD
-   default "bcm963158"
-
-config SYS_CONFIG_NAME
-   default "broadcom_bcm963158"
-
-endif
-
-config TARGET_BCM963158
-   bool "Support Broadcom bcm963158"
-   depends on ARCH_BCM63158
-   select ARM64
diff --git a/board/broadcom/bcm963158/MAINTAINERS 
b/board/broadcom/bcm963158/MAINTAINERS
deleted file mode 100644
index d28d971f9d36..
--- a/board/broadcom/bcm963158/MAINTAINERS
+++ /dev/null
@@ -1,6 +0,0 @@
-BROADCOM BCM963158
-M: Philippe Reynes 
-S: Maintained
-F: board/broadcom/bcm963158/
-F: include/configs/broadcom_bcm963158.h
-F: configs/bcm963158_ram_defconfig
diff --git a/board/broadcom/bcm963158/Makefile 
b/board/broadcom/bcm963158/Makefile
deleted file mode 100644
index 0a902c9cf618..
--- a/board/broadcom/bcm963158/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-
-obj-y  += bcm963158.o
diff --git a/board/broadcom/bcm963158/bcm963158.c 
b/board/broadcom/bcm963158/bcm963158.c
deleted file mode 100644
index 9feaee3c0fc4..
--- a/board/broadcom/bcm963158/bcm963158.c
+++ /dev/null
@@ -1,62 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2019 Philippe Reynes 
- */
-
-#include 
-#include 
-#include 
-#include 
-
-#ifdef CONFIG_ARM64
-#include 
-
-static struct mm_region broadcom_bcm963158_mem_map[] = {
-   {
-   /* RAM */
-   .virt = 0xUL,
-   .phys = 0xUL,
-   .size = 8UL * SZ_1G,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-PTE_BLOCK_INNER_SHARE
-   }, {
-   /* SoC */
-   .virt = 0x8000UL,
-   .phys = 0x8000UL,
-   .size = 0xff8000UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-PTE_BLOCK_NON_SHARE |
-PTE_BLOCK_PXN | PTE_BLOCK_UXN
-   }, {
-   /* List terminator */
-   0,
-   }
-};
-
-struct mm_region *mem_map = broadcom_bcm963158_mem_map;
-#endif
-
-int board_init(void)
-{
-   return 0;
-}
-
-int dram_init(void)
-{
-   if (fdtdec_setup_mem_size_base() != 0)
-   printf("fdtdec_setup_mem_size_base() has failed\n");
-
-   return 0;
-}
-
-int dram

[PATCH 1/5] arm: bcmbca: add bcm63158 SoC support under CONFIG_ARCH_BCMBCA

2022-08-11 Thread William Zhang
BCM63158 is a Broadcom B53 based DSL Gateway SoC. It is part of the
BCA (Broadband Carrier Access origin) chipset family. Like other
Broadband SoC, this patch adds it under CONFIG_BCM63158 chip
config and CONFIG_ARCH_BCMBCA platform config.

This initial support includes a bare-bone implementation and the
original dts is updated with the one from linux next git repository.

The u-boot image can be loaded from flash or network to the entry
point address in the memory and boot from there to the console.

Signed-off-by: William Zhang 
---

 MAINTAINERS   |   1 +
 arch/arm/dts/Makefile |   2 +
 arch/arm/dts/bcm63158.dtsi| 207 +-
 arch/arm/dts/bcm963158.dts|   6 +-
 arch/arm/mach-bcmbca/Kconfig  |   8 +
 arch/arm/mach-bcmbca/Makefile |   1 +
 arch/arm/mach-bcmbca/bcm63158/Kconfig |  17 ++
 arch/arm/mach-bcmbca/bcm63158/Makefile|   5 +
 arch/arm/mach-bcmbca/bcm63158/mmu_table.c |  32 
 board/broadcom/bcmbca/Kconfig |   7 +
 configs/bcm963158_defconfig   |  23 +++
 include/configs/bcm963158.h   |  11 ++
 12 files changed, 237 insertions(+), 83 deletions(-)
 create mode 100644 arch/arm/mach-bcmbca/bcm63158/Kconfig
 create mode 100644 arch/arm/mach-bcmbca/bcm63158/Makefile
 create mode 100644 arch/arm/mach-bcmbca/bcm63158/mmu_table.c
 create mode 100644 configs/bcm963158_defconfig
 create mode 100644 include/configs/bcm963158.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 3f250942ced1..5b219d62f6bf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -224,6 +224,7 @@ N:  bcm[9]?4912
 N: bcm[9]?63138
 N: bcm[9]?63146
 N: bcm[9]?63148
+N: bcm[9]?63158
 N: bcm[9]?63178
 N: bcm[9]?6756
 N: bcm[9]?6813
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9a6582d9c1c8..a7fc3d7d7021 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1175,6 +1175,8 @@ dtb-$(CONFIG_BCM63146) += \
bcm963146.dtb
 dtb-$(CONFIG_BCM63148) += \
bcm963148.dtb
+dtb-$(CONFIG_BCM63158) += \
+   bcm963158.dtb
 dtb-$(CONFIG_BCM63178) += \
bcm963178.dtb
 dtb-$(CONFIG_BCM6756) += \
diff --git a/arch/arm/dts/bcm63158.dtsi b/arch/arm/dts/bcm63158.dtsi
index 7dd285843849..8b179ba0fca8 100644
--- a/arch/arm/dts/bcm63158.dtsi
+++ b/arch/arm/dts/bcm63158.dtsi
@@ -1,122 +1,167 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2019 Philippe Reynes 
+ * Copyright 2022 Broadcom Ltd.
  */
 
-#include "skeleton64.dtsi"
+#include 
+#include 
 
 / {
-   compatible = "brcm,bcm63158";
+   compatible = "brcm,bcm63158", "brcm,bcmbca";
#address-cells = <2>;
#size-cells = <2>;
 
-   aliases {
-   spi0 = &hsspi;
-   };
+   interrupt-parent = <&gic>;
 
cpus {
#address-cells = <2>;
#size-cells = <0>;
-   u-boot,dm-pre-reloc;
 
-   cpu0: cpu@0 {
-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_0: cpu@0 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x0>;
-   next-level-cache = <&l2>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <&L2_0>;
+   enable-method = "psci";
};
 
-   cpu1: cpu@1 {
-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_1: cpu@1 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x1>;
-   next-level-cache = <&l2>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <&L2_0>;
+   enable-method = "psci";
};
 
-   cpu2: cpu@2 {
-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_2: cpu@2 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x2>;
-   next-level-cache = <&l2>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <&L2_0>;
+   enable-method = "psci";
};
 
-   cpu3: cpu@3 {
-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_3: cpu@3 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x3>;
-   next-level-cache = <&l2>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <&L2_0>;
+   enable-method = "psci";
};
 
-   l2: l2-cache0 {
+   L2_0: l2-cache0 {
   

Re: [PULL] u-boot-riscv/master

2022-08-11 Thread Leo Liang
On Mon, May 30, 2022 at 11:05:54AM -0400, Tom Rini wrote:
> On Sat, May 28, 2022 at 09:02:09AM +, Leo Liang wrote:
> > On Fri, May 27, 2022 at 09:30:49AM -0400, Tom Rini wrote:
> > > On Fri, May 27, 2022 at 02:36:29AM +, Leo Liang wrote:
> > > 
> > > > Hi Tom, 
> > > > 
> > > > The following changes since commit 
> > > > 7e0edcadb09d55d5319fdc862041fd1b874476f5:
> > > > 
> > > >   Merge branch 'master' of 
> > > > https://source.denx.de/u-boot/custodians/u-boot-sunxi (2022-05-24 
> > > > 23:29:00 -0400)
> > > > 
> > > > are available in the Git repository at:
> > > > 
> > > >   https://source.denx.de/u-boot/custodians/u-boot-riscv.git
> > > > 
> > > > for you to fetch changes up to c544b281cd3e549a4fcbf4ba9a05a5d72c9557dd:
> > > > 
> > > >   riscv: qemu: Set kernel_comp_addr_r for compressed kernel (2022-05-26 
> > > > 18:42:34 +0800)
> > > > 
> > > > CI result shows no issue: 
> > > > https://source.denx.de/u-boot/custodians/u-boot-riscv/-/pipelines/12131
> > > 
> > > First, I've applied this to u-boot/master now.  Second, will
> > > https://patchwork.ozlabs.org/project/uboot/patch/ph7pr14mb5594fd11d1be74284f554bebce...@ph7pr14mb5594.namprd14.prod.outlook.com/
> > > be coming soon?  Thanks!
> > 
> > Hi Tom, 
> > 
> > This patch you mentioned will not pass CI, and the reason for that 
> > is the toolchain used for RISC-V in CI does not have corresponding 
> > settings for zifencei and zicsr.
> > (detailed disscussion: 
> > https://patchwork.ozlabs.org/project/uboot/patch/20220128134713.2322800-1-alexandre.gh...@canonical.com/)
> > (CI result: 
> > https://source.denx.de/u-boot/custodians/u-boot-riscv/-/jobs/440735)
> > 
> > The patch looks valid, but will fail CI on 32-bit configs.
> > If we use 32-bit toolchain to test 32-bit configs, then 
> > problems solved.
> > 
> > Do you have any comments?
> 
> I guess I'm OK with saying we should use a 32bit toolchain for 32bit
> riscv, if  that's how things should be handled moving forward for
> everyone else.
> 
> -- 
> Tom

Hi Tom,

Sorry for taking such a long time to reply.

Recap:
All the "riscv: fix compitible with binutils 2.38" patches that 
try to support new RISC-V ISA extension will cause U-Boot CI to fail
because the toolchain used in U-Boot CI do not support the new multilib 
settings. 
(original discussion: 
https://patchwork.ozlabs.org/project/uboot/patch/20220128134713.2322800-1-alexandre.gh...@canonical.com/)

We found that current RISC-V toolchains from kernel.org do not
support zifencei and zicsr extensions' multilib settings, 
regardless of the toolchain version. 
(Both gcc 11.1.0, 12.1.0 do not support the needed settings.
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.1.0/)

But we also found that if we use recent upstream riscv-gnu-toolchain,
we could build an gcc-12.1.0 toolchain that does support multilib
settings and could fix this issue.

We have provided a Dockerfile as a reference build script[1] and
a prebuilt toolchain[2] for U-Boot CI to use.

We have also verified the CI process could execute successfully
with your base image and the provided riscv64-linux toolchain[3].

I guess the coming update of the toolchain in kernel.org should 
contain the new multilib settings, so I was wondering if we could 
replace the riscv64-linux toolchain from kernel.org with this prebuilt 
toolchain we've provided on github[2] temporarily?

After studying a bit of the buildman tool, the earlier idea that 
"use different toolchains for different board configs" would require 
an amount of modification, thus we think its best to replace the toolchain 
temporarily to fix this issue, then the patch could be applied without CI 
failure.

[1] https://github.com/ycliang-andes/riscv-toolchain/blob/master/Dockerfile
[2] 
https://github.com/ycliang-andes/riscv-toolchain/releases/download/v1.0/x86_64-gcc-12.1.0-nolibc-riscv64-linux.tar.xz
[3] https://source.denx.de/u-boot/custodians/u-boot-riscv/-/pipelines/13129


[PULL] u-boot-riscv/master

2022-08-11 Thread Leo Liang
Hi Tom,

The following changes since commit cdebee1fd9fa04cc4c972f826bae19b28c253eb0:

  Merge branch '2022-08-10-assorted-updates' (2022-08-10 17:49:20 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-riscv.git

for you to fetch changes up to aa0eda17cf98448c3ef826204f38c76bf48b3345:

  spl: opensbi: convert scratch options to config (2022-08-11 18:46:41 +0800)

CI result shows no issue: 
https://source.denx.de/u-boot/custodians/u-boot-riscv/-/pipelines/13119


Leo Yu-Chi Liang (1):
  riscv: ae350: Fix XIP config boot failure

Nikita Shubin (3):
  riscv: cpu: set gp before board_init_f_init_reserve
  spl: opensbi: fix typo
  spl: opensbi: convert scratch options to config

 arch/riscv/cpu/start.S  |  5 -
 board/AndesTech/ax25-ae350/ax25-ae350.c | 17 +++--
 common/spl/Kconfig  |  8 
 common/spl/spl_opensbi.c|  4 ++--
 4 files changed, 25 insertions(+), 9 deletions(-)

Best regards,
Leo


[PATCH] arm: Set default MACH_TYPE in Kconfig

2022-08-11 Thread Pali Rohár
For boards which requires correct MACH_TYPE, set their correct default
values directly in Kconfig.

Signed-off-by: Pali Rohár 
---
 arch/arm/Kconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9898c7d68e1b..f78726f7c1be 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -2119,6 +2119,7 @@ config SERIAL_TAG
 
 config STATIC_MACH_TYPE
bool "Statically define the Machine ID number"
+   default y if TARGET_DS109 || TARGET_NOKIA_RX51 || TARGET_DS414 || 
DEFAULT_DEVICE_TREE = "sun7i-a20-icnova-swac"
help
  When booting via ATAGs, enable this option if we know the correct
  machine ID number to use at compile time.  Some systems will be
@@ -2127,6 +2128,10 @@ config STATIC_MACH_TYPE
 config MACH_TYPE
int "Machine ID number"
depends on STATIC_MACH_TYPE
+   default 527 if TARGET_DS109
+   default 1955 if TARGET_NOKIA_RX51
+   default 3036 if TARGET_DS414
+   default 4283 if DEFAULT_DEVICE_TREE = "sun7i-a20-icnova-swac"
help
  When booting via ATAGs, the machine type must be passed as a number.
  For the full list see https://www.arm.linux.org.uk/developer/machines
-- 
2.20.1



[PATCH 3/5] Nokia RX-51: Simplify copy kernel code

2022-08-11 Thread Pali Rohár
Expression (r + (r0 - r1)) produce same result as (r - (r1 - r0)). So it
does not matter which one is called. Always call the first option and
remove second one.

Signed-off-by: Pali Rohár 
---
 board/nokia/rx51/lowlevel_init.S | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/board/nokia/rx51/lowlevel_init.S b/board/nokia/rx51/lowlevel_init.S
index dd3c830cc2e2..4f76e80b20f1 100644
--- a/board/nokia/rx51/lowlevel_init.S
+++ b/board/nokia/rx51/lowlevel_init.S
@@ -55,16 +55,13 @@ save_boot_params:
 copy_kernel_start:
adr r0, relocaddr   /* r0 - address of section relocaddr */
ldr r1, relocaddr   /* r1 - address of relocaddr after relocation */
-   cmp r0, r1
 
/* r4 - calculated offset */
-   subhi   r4, r0, r1
-   sublo   r4, r1, r0
+   sub r4, r0, r1
 
/* r0 - start of kernel before */
ldr r0, startaddr
-   addhi   r0, r0, r4
-   sublo   r0, r0, r4
+   add r0, r0, r4
ldr r1, kernoffs
add r0, r0, r1
 
-- 
2.20.1



[PATCH 2/5] Nokia RX-51: Use U-Boot generic position independent code

2022-08-11 Thread Pali Rohár
Switch from custom board specific fixup/copy code to U-Boot generic
position independent code provided by config option POSITION_INDEPENDENT.

This also slightly decrease size of u-boot.bin binary (by 52 bytes). Note
that option POSITION_INDEPENDENT increase size but not more than custom
board fixup/copy code which is being deleted (as it is not needed anymore).

Signed-off-by: Pali Rohár 
---
 arch/arm/mach-omap2/omap3/Kconfig |   1 +
 board/nokia/rx51/lowlevel_init.S  | 127 --
 configs/nokia_rx51_defconfig  |   1 -
 3 files changed, 16 insertions(+), 113 deletions(-)

diff --git a/arch/arm/mach-omap2/omap3/Kconfig 
b/arch/arm/mach-omap2/omap3/Kconfig
index 81c898b66e34..18574ab2b2ea 100644
--- a/arch/arm/mach-omap2/omap3/Kconfig
+++ b/arch/arm/mach-omap2/omap3/Kconfig
@@ -107,6 +107,7 @@ config TARGET_OMAP3_LOGIC
 
 config TARGET_NOKIA_RX51
bool "Nokia RX51"
+   select POSITION_INDEPENDENT
 
 config TARGET_TAO3530
bool "TAO3530"
diff --git a/board/nokia/rx51/lowlevel_init.S b/board/nokia/rx51/lowlevel_init.S
index 632595f83785..dd3c830cc2e2 100644
--- a/board/nokia/rx51/lowlevel_init.S
+++ b/board/nokia/rx51/lowlevel_init.S
@@ -33,16 +33,24 @@ z_magic:/* LINUX_ARM_ZIMAGE_MAGIC */
 /*
  * Routine: save_boot_params (called after reset from start.S)
  * Description: Copy attached kernel to address KERNEL_ADDRESS
- *  Copy u-boot to address CONFIG_SYS_TEXT_BASE
- *  Return to copied u-boot address
  */
 
 .global save_boot_params
 save_boot_params:
-   /* Get return address */
-   ldr lr, =save_boot_params_ret
 
-/* Copy valid attached kernel to address KERNEL_ADDRESS */
+/*
+ * Copy valid attached kernel to absolute address KERNEL_ADDRESS
+ *
+ * Nokia X-Loader is loading secondary image to address 0x8040.
+ * NOLO is loading boot image to random place, so it doesn't really
+ * matter what is set in CONFIG_SYS_TEXT_BASE. We have to detect
+ * KERNEL_OFFSET from the current execution address and copy it to
+ * absolute address KERNEL_ADDRESS.
+ *
+ * Note that U-Boot has to be compiled with CONFIG_POSITION_INDEPENDENT
+ * because it is loaded at random address and not to the fixed address
+ * (CONFIG_SYS_TEXT_BASE).
+ */
 
 copy_kernel_start:
adr r0, relocaddr   /* r0 - address of section relocaddr */
@@ -100,110 +108,5 @@ copy_kernel_end:
str r5, [r0]/* remove 4 bytes header of kernel uImage */
str r5, [r0, #36]   /* remove 4 bytes header of kernel zImage */
 
-
-/* Fix u-boot code */
-
-fix_start:
-   adr r0, relocaddr   /* r0 - address of section relocaddr */
-   ldr r1, relocaddr   /* r1 - address of relocaddr after relocation */
-   cmp r0, r1
-
-   beq copy_uboot_end  /* skip if u-boot is on correct address */
-
-   /* r5 - calculated offset */
-   subhi   r5, r0, r1
-   sublo   r5, r1, r0
-
-   /* r6 - maximal u-boot size */
-   ldr r6, imagesize
-
-   /* r1 - start of u-boot after */
-   ldr r1, startaddr
-
-   /* r0 - start of u-boot before */
-   addhi   r0, r1, r5
-   sublo   r0, r1, r5
-
-   /* check if we need to move uboot copy code before calling it */
-   cmp r5, r6
-   bhi copy_uboot_start /* now coping u-boot code directly is safe */
-
-
-copy_code_start:
-   /* r0 - start of u-boot before */
-   /* r1 - start of u-boot after */
-   /* r6 - maximal u-boot size */
-
-   /* r7 - maximal kernel size */
-   ldr r7, kernsize
-
-   /* r4 - end of kernel before */
-   add r4, r0, r6
-   add r4, r4, r7
-
-   /* r5 - end of u-boot after */
-   ldr r5, startaddr
-   add r5, r5, r6
-
-   /* r2 - start of loop code after */
-   cmp r4, r5  /* higher address (r4 or r5) */
-   movhs   r2, r4
-   movlo   r2, r5
-
-   /* r3 - end of loop code before */
-   adr r3, end
-
-   /* r4 - end of loop code after */
-   adr r4, copy_uboot_start
-   sub r4, r3, r4
-   add r4, r2, r4
-
-copy_code_loop:
-   ldmdb   r3!, {r7 - r10}
-   stmdb   r4!, {r7 - r10}
-   cmp r4, r2
-   bhi copy_code_loop
-
-copy_code_end:
-   mov pc, r2
-
-
-/*
- * Copy u-boot to address CONFIG_SYS_TEXT_BASE
- *
- * Nokia X-Loader loading secondary image to address 0x8040
- * NOLO loading boot image to random place, so it doesn't really
- * matter what is set in CONFIG_SYS_TEXT_BASE. We have to copy
- * u-boot to CONFIG_SYS_TEXT_BASE address.
- */
-
-copy_uboot_start:
-   /* r0 - start of u-boot before */
-   /* r1 - start of u-boot after */
-   /* r6 - maximal u-boot size */
-
-   /* r2 - end of u-boot after */
-   add r2, r1, r6
-
-   /* condition for copying from left to right */
-   cmp r0, r1
-   addlo   r1, r0, r6  /* r1 - end of u-boot before */
-   blo copy_uboot_loop_right
-

[PATCH 4/5] Nokia RX-51: Simplify calculation of attached kernel image address

2022-08-11 Thread Pali Rohár
Now when board starup code does not copy image to CONFIG_SYS_TEXT_BASE
address there is no need to calculate all addresses from base address at
runtime. The only address which needs to be calculated is attached kernel
image address which can be simplified at compile time without need to know
CONFIG_SYS_TEXT_BASE address or relocation address at the runtime.

Signed-off-by: Pali Rohár 
---
 board/nokia/rx51/lowlevel_init.S | 21 -
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/board/nokia/rx51/lowlevel_init.S b/board/nokia/rx51/lowlevel_init.S
index 4f76e80b20f1..c1785bc3f72f 100644
--- a/board/nokia/rx51/lowlevel_init.S
+++ b/board/nokia/rx51/lowlevel_init.S
@@ -6,11 +6,8 @@
 
 #include 
 
-relocaddr: /* address of this relocaddr section after coping */
-   .word . /* address of section (calculated at compile time) */
-
-startaddr: /* address of u-boot after copying */
-   .word CONFIG_SYS_TEXT_BASE
+kernoffs:  /* offset of kernel image from this address */
+   .word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)
 
 kernaddr:  /* address of kernel after copying */
.word KERNEL_ADDRESS
@@ -18,9 +15,6 @@ kernaddr: /* address of kernel after copying */
 kernsize:  /* maximal size of kernel image */
.word KERNEL_MAXSIZE
 
-kernoffs:  /* offset of kernel image in loaded u-boot */
-   .word KERNEL_OFFSET
-
 imagesize: /* maximal size of image */
.word IMAGE_MAXSIZE
 
@@ -53,16 +47,9 @@ save_boot_params:
  */
 
 copy_kernel_start:
-   adr r0, relocaddr   /* r0 - address of section relocaddr */
-   ldr r1, relocaddr   /* r1 - address of relocaddr after relocation */
-
-   /* r4 - calculated offset */
-   sub r4, r0, r1
-
/* r0 - start of kernel before */
-   ldr r0, startaddr
-   add r0, r0, r4
-   ldr r1, kernoffs
+   adr r0, kernoffs/* r0 - current address of kernoffs section */
+   ldr r1, kernoffs/* r1 - offset of kernel image from kernoffs 
section */
add r0, r0, r1
 
/* r3 - start of kernel after */
-- 
2.20.1



[PATCH 5/5] Nokia RX-51: Move board required options from defconfig to Kconfig

2022-08-11 Thread Pali Rohár
Some of config options are board specific and should be set in into their
default values automatically. So move them from defconfig file to Kconfig
definitions to ensure that possible user custom defconfig files would have
these required options also enabled.

Signed-off-by: Pali Rohár 
---
 arch/arm/mach-omap2/omap3/Kconfig | 5 +
 board/nokia/rx51/Kconfig  | 6 ++
 configs/nokia_rx51_defconfig  | 7 ---
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/omap3/Kconfig 
b/arch/arm/mach-omap2/omap3/Kconfig
index 18574ab2b2ea..3e97ec262951 100644
--- a/arch/arm/mach-omap2/omap3/Kconfig
+++ b/arch/arm/mach-omap2/omap3/Kconfig
@@ -108,6 +108,11 @@ config TARGET_OMAP3_LOGIC
 config TARGET_NOKIA_RX51
bool "Nokia RX51"
select POSITION_INDEPENDENT
+   select SKIP_LOWLEVEL_INIT
+   select SUPPORT_PASSING_ATAGS
+   select CMDLINE_TAG
+   select INITRD_TAG
+   select REVISION_TAG
 
 config TARGET_TAO3530
bool "TAO3530"
diff --git a/board/nokia/rx51/Kconfig b/board/nokia/rx51/Kconfig
index ec6a571a2263..7cf05077dad1 100644
--- a/board/nokia/rx51/Kconfig
+++ b/board/nokia/rx51/Kconfig
@@ -1,5 +1,8 @@
 if TARGET_NOKIA_RX51
 
+config NR_DRAM_BANKS
+   default 2
+
 config SYS_BOARD
default "rx51"
 
@@ -9,4 +12,7 @@ config SYS_VENDOR
 config SYS_CONFIG_NAME
default "nokia_rx51"
 
+config SYS_PROMPT
+   default "Nokia RX-51 # "
+
 endif
diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig
index 3365f7ae58df..4414ebc25e36 100644
--- a/configs/nokia_rx51_defconfig
+++ b/configs/nokia_rx51_defconfig
@@ -1,16 +1,10 @@
 CONFIG_ARM=y
-CONFIG_SKIP_LOWLEVEL_INIT=y
 # CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_SYS_L2CACHE_OFF=y
 CONFIG_ARCH_OMAP2PLUS=y
-CONFIG_SUPPORT_PASSING_ATAGS=y
-CONFIG_CMDLINE_TAG=y
-CONFIG_INITRD_TAG=y
-CONFIG_REVISION_TAG=y
 CONFIG_STATIC_MACH_TYPE=y
 CONFIG_MACH_TYPE=1955
 CONFIG_SYS_MALLOC_LEN=0xc
-CONFIG_NR_DRAM_BANKS=2
 CONFIG_TARGET_NOKIA_RX51=y
 CONFIG_SYS_LOAD_ADDR=0x8000
 CONFIG_OPTIMIZE_INLINING=y
@@ -26,7 +20,6 @@ CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="run preboot"
 # CONFIG_SYS_DEVICE_NULLDEV is not set
 CONFIG_HUSH_PARSER=y
-CONFIG_SYS_PROMPT="Nokia RX-51 # "
 # CONFIG_CMD_BDI is not set
 CONFIG_CMD_BOOTZ=y
 # CONFIG_BOOTM_NETBSD is not set
-- 
2.20.1



[PATCH 1/5] Nokia RX-51: Fix invalidating zImage kernel format

2022-08-11 Thread Pali Rohár
Prior starting copy of kernel image to target location, invalidate also
zImage magic header. This ensures that on target location would be image
with valid header only in the case valid header was also in the source
location and copy from source to target finished successfully. Copy is
always skipped when kernel image in source location is invalid.

Add also comment to the code which explain what is the code doing.

Fixes: cc434fccba4c ("Nokia RX-51: Add support for booting kernel in zImage 
format")
Signed-off-by: Pali Rohár 
---
 board/nokia/rx51/lowlevel_init.S | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/board/nokia/rx51/lowlevel_init.S b/board/nokia/rx51/lowlevel_init.S
index 11c2cbef89a6..632595f83785 100644
--- a/board/nokia/rx51/lowlevel_init.S
+++ b/board/nokia/rx51/lowlevel_init.S
@@ -72,7 +72,8 @@ copy_kernel_start:
 
/* remove header in target kernel */
mov r5, #0
-   str r5, [r3]
+   str r5, [r3]/* remove 4 bytes header of kernel uImage */
+   str r5, [r3, #36]   /* remove 4 bytes header of kernel zImage */
 
/* check for valid kernel uImage */
ldr r4, [r0]/* r4 - 4 bytes header of kernel */
@@ -93,6 +94,8 @@ copy_kernel_loop:
bhi copy_kernel_loop
 
 copy_kernel_end:
+
+   /* remove header in source kernel image */
mov r5, #0
str r5, [r0]/* remove 4 bytes header of kernel uImage */
str r5, [r0, #36]   /* remove 4 bytes header of kernel zImage */
-- 
2.20.1



Re: ethernet dt aliases implications in U-Boot and Linux

2022-08-11 Thread Sean Anderson



On 8/10/22 11:35 AM, Michal Suchánek wrote:
> On Wed, Aug 10, 2022 at 05:17:56PM +0200, Andrew Lunn wrote:
>> > > I guess you are new to the netdev list :-)
>> > > 
>> > > This is one of those FAQ sort of things, discussed every
>> > > year. Anything like this is always NACKed. I don't see why this time
>> > > should be any different.
>> > > 
>> > > DSA is somewhat special because it is very old. It comes from before
>> > > the times of DT. Its DT binding was proposed relatively earl in DT
>> > > times, and would be rejected in modern days. But the rules of ABI mean
>> > > the label property will be valid forever. But i very much doubt it
>> > > will spread to interfaces in general.
>> > 
>> > And if this is a FAQ maybe you can point to a summary (perhaps in
>> > previous mail discusssion) that explains how to provide stable interface
>> > names for Ethernet devices on a DT based platform?
>> 
>> As far so the kernel is concerned, interface names are unstable. They
>> have never been truly stable, but they have got more unstable in the
>> past decade with multiple busses being probed in parallel, which did
>> not happen before so much.
>> 
>> > On x86 there is a name derived from the device location in the bus
>> > topology
>> 
>> This is nothing to do with x86. That is userspace, e.g. systemd,
>> renaming the interfaces. This applies for any architecture for which
>> systemd runs on.
>> 
>> > which may be somewhat stable but it is not clear that it
>> > cannot change, and there is an optional BIOS provided table that can
>> > asssign meaningful names to the interfaces.
>> 
>> I doubt the kernel is looking at ACPI tables. It is user space which
>> does that.
>> 
>> The kernel provides udev with a bunch of information about the
>> interface, its bus location, MAC address, etc. Userspace can then
>> decide what it wants to call it, and what its alternative names are,
>> etc.
>> 
>> Also, this is not just a network interface name problem. Any device
>> with a number/letter in it is unstable. I2C bus devices: i2c0,
>> i2c1... SPI bus deviceS: spi0, spi1...,
> 
> Thees do have numbered aliases in the DT. I don't know if the kernel
> uses them for anything.

This is an issue for serial devices IMO. The only way to specify a
stable console is to use its address! Things like /dev/ttyS0 can
easily be reordered just by plugging/unplugging a card. You can of
course add a udev rule to create some stable symlinks, but that's
too late.

>> Block devices, sda, sdb, sdc,
> 
> These too, at least mmc.


Which I am very grateful exists. While the block device situation is
not as bad due to e.g. /dev/block/by-foo, it's still nice to be able
to have a consistent name.

--Sean


[PATCH] board: gateworks: venice: rename eeprom_init

2022-08-11 Thread Tim Harvey
rename eeprom_init to avoid build failure when using CMD_EEPROM.

Signed-off-by: Tim Harvey 
---
 board/gateworks/venice/eeprom.c | 2 +-
 board/gateworks/venice/eeprom.h | 2 +-
 board/gateworks/venice/spl.c| 2 +-
 board/gateworks/venice/venice.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/board/gateworks/venice/eeprom.c b/board/gateworks/venice/eeprom.c
index ac52cc0a9ec9..6aea60ad05c7 100644
--- a/board/gateworks/venice/eeprom.c
+++ b/board/gateworks/venice/eeprom.c
@@ -299,7 +299,7 @@ static int eeprom_info(bool verbose)
return 0;
 }
 
-int eeprom_init(int quiet)
+int venice_eeprom_init(int quiet)
 {
char rev_pcb;
int rev_bom;
diff --git a/board/gateworks/venice/eeprom.h b/board/gateworks/venice/eeprom.h
index 8ea7318d7dfc..bb7a5fa9ad1f 100644
--- a/board/gateworks/venice/eeprom.h
+++ b/board/gateworks/venice/eeprom.h
@@ -24,7 +24,7 @@ struct venice_board_info {
u8 chksum[2];   /* 0x4E */
 };
 
-int eeprom_init(int quiet);
+int venice_eeprom_init(int quiet);
 const char *eeprom_get_model(void);
 const char *eeprom_get_baseboard_model(void);
 const char *eeprom_get_dtb_name(int level, char *buf, int len);
diff --git a/board/gateworks/venice/spl.c b/board/gateworks/venice/spl.c
index ae460296cb99..14241e5e2fb6 100644
--- a/board/gateworks/venice/spl.c
+++ b/board/gateworks/venice/spl.c
@@ -280,7 +280,7 @@ void board_init_f(ulong dummy)
break;
mdelay(1);
}
-   dram_sz = eeprom_init(0);
+   dram_sz = venice_eeprom_init(0);
 
/* PMIC */
power_init_board();
diff --git a/board/gateworks/venice/venice.c b/board/gateworks/venice/venice.c
index 32b25ffd3edf..d94f6b8a577d 100644
--- a/board/gateworks/venice/venice.c
+++ b/board/gateworks/venice/venice.c
@@ -111,7 +111,7 @@ int board_phy_config(struct phy_device *phydev)
 
 int board_init(void)
 {
-   eeprom_init(1);
+   venice_eeprom_init(1);
 
if (IS_ENABLED(CONFIG_FEC_MXC))
setup_fec();
-- 
2.25.1



[PATCH] arm: dts: imx8mm-venice-gw7902: add LTE modem gpios

2022-08-11 Thread Tim Harvey
Add missing LTE_PWR# and LTE_RST gpio pinmux.

Signed-off-by: Tim Harvey 
---
 arch/arm/dts/imx8mm-venice-gw7902.dts | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/dts/imx8mm-venice-gw7902.dts 
b/arch/arm/dts/imx8mm-venice-gw7902.dts
index 407ab4592b4c..8e8d0d34c237 100644
--- a/arch/arm/dts/imx8mm-venice-gw7902.dts
+++ b/arch/arm/dts/imx8mm-venice-gw7902.dts
@@ -742,6 +742,9 @@
MX8MM_IOMUXC_GPIO1_IO13_GPIO1_IO13  0x4041 /* 
M2_RESET */
MX8MM_IOMUXC_NAND_DATA01_GPIO3_IO7  0x4119 /* 
M2_OFF# */
MX8MM_IOMUXC_GPIO1_IO15_GPIO1_IO15  0x4159 /* 
M2_WDIS# */
+   MX8MM_IOMUXC_SAI1_TXD6_GPIO4_IO18   0x4041 /* 
LTE_INT */
+   MX8MM_IOMUXC_SAI1_TXD5_GPIO4_IO17   0x4041 /* 
LTE_RST# */
+   MX8MM_IOMUXC_SAI1_TXD4_GPIO4_IO16   0x4041 /* 
LTE_PWR */
MX8MM_IOMUXC_SAI1_TXD2_GPIO4_IO14   0x4041 /* 
AMP GPIO1 */
MX8MM_IOMUXC_SAI1_TXD0_GPIO4_IO12   0x4041 /* 
AMP GPIO2 */
MX8MM_IOMUXC_SAI1_TXC_GPIO4_IO110x4041 /* 
AMP GPIO3 */
-- 
2.25.1



[PATCH] board: gateworks: venice: poll I2C lines to wait for GSC firmware

2022-08-11 Thread Tim Harvey
In some situations the GSC firmware where the EEPROM containing the
model and DRAM configuration may not be ready by the time the SoC
is ready to talk to it over I2C.

Instead of a hard delay, poll the I2C lines to wait until they are
released to avoid the I2C drivers 'Arbitation lost' error message.

Signed-off-by: Tim Harvey 
---
 arch/arm/dts/imx8mm-venice.dts | 13 +++-
 arch/arm/dts/imx8mn-venice.dts | 13 +++-
 arch/arm/dts/imx8mp-venice.dts | 13 +++-
 board/gateworks/venice/spl.c   | 39 ++
 4 files changed, 61 insertions(+), 17 deletions(-)

diff --git a/arch/arm/dts/imx8mm-venice.dts b/arch/arm/dts/imx8mm-venice.dts
index 39b030691e53..a1f292fbd9d3 100644
--- a/arch/arm/dts/imx8mm-venice.dts
+++ b/arch/arm/dts/imx8mm-venice.dts
@@ -23,8 +23,11 @@
 
 &i2c1 {
clock-frequency = <10>;
-   pinctrl-names = "default";
+   pinctrl-names = "default", "gpio";
pinctrl-0 = <&pinctrl_i2c1>;
+   pinctrl-1 = <&pinctrl_i2c1_gpio>;
+   scl-gpios = <&gpio5 14 GPIO_ACTIVE_HIGH>;
+   sda-gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>;
status = "okay";
 
gsc: gsc@20 {
@@ -89,6 +92,14 @@
>;
};
 
+   pinctrl_i2c1_gpio: i2c1grp-gpio-grp {
+   fsl,pins = <
+   MX8MM_IOMUXC_I2C1_SCL_GPIO5_IO140x41c3
+   MX8MM_IOMUXC_I2C1_SDA_GPIO5_IO150x41c3
+   >;
+   u-boot,dm-spl;
+   };
+
pinctrl_i2c2: i2c2grp {
fsl,pins = <
MX8MM_IOMUXC_I2C2_SCL_I2C2_SCL  0x41c3
diff --git a/arch/arm/dts/imx8mn-venice.dts b/arch/arm/dts/imx8mn-venice.dts
index eeae225632d7..8480a2e368aa 100644
--- a/arch/arm/dts/imx8mn-venice.dts
+++ b/arch/arm/dts/imx8mn-venice.dts
@@ -23,8 +23,11 @@
 
 &i2c1 {
clock-frequency = <10>;
-   pinctrl-names = "default";
+   pinctrl-names = "default", "gpio";
pinctrl-0 = <&pinctrl_i2c1>;
+   pinctrl-1 = <&pinctrl_i2c1_gpio>;
+   scl-gpios = <&gpio5 14 GPIO_ACTIVE_HIGH>;
+   sda-gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>;
status = "okay";
 
gsc: gsc@20 {
@@ -89,6 +92,14 @@
>;
};
 
+   pinctrl_i2c1_gpio: i2c1grp-gpio-grp {
+   fsl,pins = <
+   MX8MN_IOMUXC_I2C1_SCL_GPIO5_IO140x41c3
+   MX8MN_IOMUXC_I2C1_SDA_GPIO5_IO150x41c3
+   >;
+   u-boot,dm-spl;
+   };
+
pinctrl_i2c2: i2c2grp {
fsl,pins = <
MX8MN_IOMUXC_I2C2_SCL_I2C2_SCL  0x41c3
diff --git a/arch/arm/dts/imx8mp-venice.dts b/arch/arm/dts/imx8mp-venice.dts
index 6b1a7f1a89d4..93145b37049b 100644
--- a/arch/arm/dts/imx8mp-venice.dts
+++ b/arch/arm/dts/imx8mp-venice.dts
@@ -23,8 +23,11 @@
 
 &i2c1 {
clock-frequency = <10>;
-   pinctrl-names = "default";
+   pinctrl-names = "default", "gpio";
pinctrl-0 = <&pinctrl_i2c1>;
+   pinctrl-1 = <&pinctrl_i2c1_gpio>;
+   scl-gpios = <&gpio5 14 GPIO_ACTIVE_HIGH>;
+   sda-gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>;
status = "okay";
 
gsc: gsc@20 {
@@ -89,6 +92,14 @@
>;
};
 
+   pinctrl_i2c1_gpio: i2c1grp-gpio-grp {
+   fsl,pins = <
+   MX8MP_IOMUXC_I2C1_SCL__GPIO5_IO14   0x41c3
+   MX8MP_IOMUXC_I2C1_SDA__GPIO5_IO15   0x41c3
+   >;
+   u-boot,dm-spl;
+   };
+
pinctrl_i2c2: i2c2grp {
fsl,pins = <
MX8MP_IOMUXC_I2C2_SCL__I2C2_SCL 0x41c3
diff --git a/board/gateworks/venice/spl.c b/board/gateworks/venice/spl.c
index 914a56a96f52..ae460296cb99 100644
--- a/board/gateworks/venice/spl.c
+++ b/board/gateworks/venice/spl.c
@@ -16,10 +16,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -219,8 +221,8 @@ static int power_init_board(void)
 
 void board_init_f(ulong dummy)
 {
-   struct udevice *dev;
-   int ret;
+   struct udevice *bus, *dev;
+   int i, ret;
int dram_sz;
 
arch_cpu_init();
@@ -251,19 +253,28 @@ void board_init_f(ulong dummy)
 *
 * On a board with a missing/depleted backup battery for GSC, the
 * board may be ready to probe the GSC before its firmware is
-* running. We will wait here indefinately for the GSC EEPROM.
-*/
-#ifdef CONFIG_IMX8MN
-   /*
-* IMX8MN boots quicker than IMX8MM and exposes issue
-* where because GSC I2C state machine isn't running and its
-* SCL/SDA are driven low the I2C driver spams 'Arbitration lost'
-* I2C errors.
-*
-* TODO: Put a loop here that somehow waits for I2C CLK/DAT to be high
+* running. Wait here for 50ms for the GSC firmware

[PATCH v3] board: gateworks: venice: add GW7903 PMIC

2022-08-11 Thread Tim Harvey
The GW7903 has a BD71847 PMIC on I2C1. Adjust the model compare strings
to add it.

Signed-off-by: Tim Harvey 
Reviewed-by: Fabio Estevam 
Reviewed-by: Jaehoon Chung 
---
v3: add Jaehoon's Reviewed-By tag
v2: fixed typo in commit log and added Fabio's rb tag
---
 board/gateworks/venice/spl.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/board/gateworks/venice/spl.c b/board/gateworks/venice/spl.c
index 4c0feb4381c9..914a56a96f52 100644
--- a/board/gateworks/venice/spl.c
+++ b/board/gateworks/venice/spl.c
@@ -173,11 +173,12 @@ static int power_init_board(void)
}
 
else if ((!strncmp(model, "GW7901", 6)) ||
-(!strncmp(model, "GW7902", 6))) {
-   if (!strncmp(model, "GW7901", 6))
-   ret = uclass_get_device_by_seq(UCLASS_I2C, 1, &bus);
-   else
+(!strncmp(model, "GW7902", 6)) ||
+(!strncmp(model, "GW7903", 6))) {
+   if (!strncmp(model, "GW7902", 6))
ret = uclass_get_device_by_seq(UCLASS_I2C, 0, &bus);
+   else
+   ret = uclass_get_device_by_seq(UCLASS_I2C, 1, &bus);
if (ret) {
printf("PMIC: failed I2C2 probe: %d\n", ret);
return ret;
-- 
2.25.1



[RESEND PATCH] board: gateworks: venice: add fixup for GW73xx-C+

2022-08-11 Thread Tim Harvey
The GW73xx-C revision and onward replaced the 5-port PCIe switch with a
4-port (dropping PCIe to one of the miniPCIe sockets) due to part
availability. This moved the PCI bus of the GbE eth1 device. Use a fixup
to adjust the dt accordingly so that local-mac-address assigned from dt
works on new revision boards.

While we are at it, rename 'blob' to 'fdt' for clarity.

Signed-off-by: Tim Harvey 
---
 board/gateworks/venice/eeprom.c |  7 ++
 board/gateworks/venice/eeprom.h |  3 +++
 board/gateworks/venice/venice.c | 43 +++--
 3 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/board/gateworks/venice/eeprom.c b/board/gateworks/venice/eeprom.c
index 7a46f44828ce..ac52cc0a9ec9 100644
--- a/board/gateworks/venice/eeprom.c
+++ b/board/gateworks/venice/eeprom.c
@@ -20,6 +20,7 @@
 struct venice_board_info som_info;
 struct venice_board_info base_info;
 char venice_model[32];
+char venice_baseboard_model[32];
 u32 venice_serial;
 
 /* return a mac address from EEPROM info */
@@ -321,6 +322,7 @@ int eeprom_init(int quiet)
base_info.model[3], /* baseboard */
base_info.model[4], base_info.model[5], /* subload of 
baseboard */
som_info.model[4], som_info.model[5]); /* last 2digits 
of SOM */
+   strlcpy(venice_baseboard_model, base_info.model, 
sizeof(venice_baseboard_model));
 
/* baseboard revision */
rev_pcb = get_pcb_rev(base_info.model);
@@ -357,6 +359,11 @@ const char *eeprom_get_model(void)
return venice_model;
 }
 
+const char *eeprom_get_baseboard_model(void)
+{
+   return venice_baseboard_model;
+}
+
 u32 eeprom_get_serial(void)
 {
return venice_serial;
diff --git a/board/gateworks/venice/eeprom.h b/board/gateworks/venice/eeprom.h
index 37bfe76ad81e..8ea7318d7dfc 100644
--- a/board/gateworks/venice/eeprom.h
+++ b/board/gateworks/venice/eeprom.h
@@ -26,8 +26,11 @@ struct venice_board_info {
 
 int eeprom_init(int quiet);
 const char *eeprom_get_model(void);
+const char *eeprom_get_baseboard_model(void);
 const char *eeprom_get_dtb_name(int level, char *buf, int len);
 int eeprom_getmac(int index, uint8_t *enetaddr);
 uint32_t eeprom_get_serial(void);
+int get_bom_rev(const char *str);
+char get_pcb_rev(const char *str);
 
 #endif
diff --git a/board/gateworks/venice/venice.c b/board/gateworks/venice/venice.c
index f1efabb203d7..32b25ffd3edf 100644
--- a/board/gateworks/venice/venice.c
+++ b/board/gateworks/venice/venice.c
@@ -3,6 +3,7 @@
  * Copyright 2021 Gateworks Corporation
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -169,26 +170,54 @@ int board_mmc_get_env_dev(int devno)
return devno;
 }
 
-int ft_board_setup(void *blob, struct bd_info *bd)
+int ft_board_setup(void *fdt, struct bd_info *bd)
 {
+   const char *base_model = eeprom_get_baseboard_model();
+   char pcbrev;
int off;
 
/* set board model dt prop */
-   fdt_setprop_string(blob, 0, "board", eeprom_get_model());
+   fdt_setprop_string(fdt, 0, "board", eeprom_get_model());
 
/* update temp thresholds */
-   off = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips");
+   off = fdt_path_offset(fdt, "/thermal-zones/cpu-thermal/trips");
if (off >= 0) {
int minc, maxc, prop;
 
get_cpu_temp_grade(&minc, &maxc);
-   fdt_for_each_subnode(prop, blob, off) {
-   const char *type = fdt_getprop(blob, prop, "type", 
NULL);
+   fdt_for_each_subnode(prop, fdt, off) {
+   const char *type = fdt_getprop(fdt, prop, "type", NULL);
 
if (type && (!strcmp("critical", type)))
-   fdt_setprop_u32(blob, prop, "temperature", maxc 
* 1000);
+   fdt_setprop_u32(fdt, prop, "temperature", maxc 
* 1000);
else if (type && (!strcmp("passive", type)))
-   fdt_setprop_u32(blob, prop, "temperature", 
(maxc - 10) * 1000);
+   fdt_setprop_u32(fdt, prop, "temperature", (maxc 
- 10) * 1000);
+   }
+   }
+
+   if (!strncmp(base_model, "GW73", 4)) {
+   pcbrev = get_pcb_rev(base_model);
+
+   if (pcbrev > 'B') {
+   printf("adjusting dt for %s\n", base_model);
+
+   /*
+* revC replaced PCIe 5-port switch with 4-port
+* which changed ethernet1 PCIe GbE
+* from: pcie@0,0/pcie@1,0/pcie@2,4/pcie@6.0
+*   to: pcie@0,0/pcie@1,0/pcie@2,3/pcie@5.0
+*/
+   off = fdt_path_offset(fdt, "ethernet1");
+   if (off > 0) {
+   u32 reg[5];
+
+   fdt_set_name(fdt, off, "pcie@5,0");
+

[PATCH v2] imx8*_venice_defconfig: configure default MMC env device

2022-08-11 Thread Tim Harvey
When booting from USB/SDP mmc_get_env_dev() returns
CONFIG_SYS_MMC_ENV_DEV as the MMC env device (while booting from MMC
will call board_mmc_get_env_dev() to get this). Configure
CONFIG_SYS_MMC_ENV_DEV for SDHC3 (devno=2) as all Gateworks Venice
boards use SDHC3 as eMMC so that persistent env works when booting from
USB/SDP.

Reviewed-by: Fabio Estevam 
Signed-off-by: Tim Harvey 
---
v2:
- add Fabio's Reviewed-by tag
- fixed spelling error in commit log
---
 configs/imx8mm_venice_defconfig | 1 +
 configs/imx8mn_venice_defconfig | 1 +
 configs/imx8mp_venice_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/imx8mm_venice_defconfig b/configs/imx8mm_venice_defconfig
index ac0cee9705b0..05be8e4a20b5 100644
--- a/configs/imx8mm_venice_defconfig
+++ b/configs/imx8mm_venice_defconfig
@@ -75,6 +75,7 @@ CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIST="imx8mm-venice imx8mm-venice-gw71xx-0x imx8mm-venice-gw72xx-0x 
imx8mm-venice-gw73xx-0x imx8mm-venice-gw7901 imx8mm-venice-gw7902 
imx8mm-venice-gw7903"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+CONFIG_SYS_MMC_ENV_DEV=2
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_USE_ETHPRIME=y
 CONFIG_ETHPRIME="eth0"
diff --git a/configs/imx8mn_venice_defconfig b/configs/imx8mn_venice_defconfig
index 935de023161a..09287a5ae3f1 100644
--- a/configs/imx8mn_venice_defconfig
+++ b/configs/imx8mn_venice_defconfig
@@ -78,6 +78,7 @@ CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIST="imx8mn-venice imx8mn-venice-gw7902"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+CONFIG_SYS_MMC_ENV_DEV=2
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_USE_ETHPRIME=y
 CONFIG_ETHPRIME="eth0"
diff --git a/configs/imx8mp_venice_defconfig b/configs/imx8mp_venice_defconfig
index 7fdde41b6da5..9013a1164e9b 100644
--- a/configs/imx8mp_venice_defconfig
+++ b/configs/imx8mp_venice_defconfig
@@ -77,6 +77,7 @@ CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIST="imx8mp-venice imx8mp-venice-gw74xx"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+CONFIG_SYS_MMC_ENV_DEV=2
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_IP_DEFRAG=y
-- 
2.25.1



[PATCH] [RFC] cmd: i2c: fix default address len for DM_I2C

2022-08-11 Thread Tim Harvey
According to the comment block "The default {addr} parameter is one byte
(.1) which works well for memories and registers with 8 bits of address
space."

While this is true for legacy I2C a default length of -1 is being passed
for DM_I2C which results in a usage error.

Restore the documented behavior by always using a default alen of 1.

Signed-off-by: Tim Harvey 

This is an RFC as I'm unclear if we want to restore the legacy usage or
enforce a new usage (in which case the comment block should be updated)
and I'm not clear if this is documented in other places. If the decision
is to enforce a new usage then it is unclear to me how to specifiy the
default alen as there is no command for that (i2c alen [len]?).
---
 cmd/i2c.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/cmd/i2c.c b/cmd/i2c.c
index bd04b14024be..c57271479e81 100644
--- a/cmd/i2c.c
+++ b/cmd/i2c.c
@@ -118,17 +118,7 @@ static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES;
 #endif
 
 #define DISP_LINE_LEN  16
-
-/*
- * Default for driver model is to use the chip's existing address length.
- * For legacy code, this is not stored, so we need to use a suitable
- * default.
- */
-#if CONFIG_IS_ENABLED(DM_I2C)
-#define DEFAULT_ADDR_LEN   (-1)
-#else
 #define DEFAULT_ADDR_LEN   1
-#endif
 
 #if CONFIG_IS_ENABLED(DM_I2C)
 static struct udevice *i2c_cur_bus;
-- 
2.25.1



Re: binman warning/failure when blobs are missing

2022-08-11 Thread Tom Rini
On Thu, Aug 11, 2022 at 09:59:05AM -0700, Tim Harvey wrote:
> On Thu, Aug 11, 2022 at 9:48 AM Tom Rini  wrote:
> >
> > On Thu, Aug 11, 2022 at 09:27:44AM -0700, Tim Harvey wrote:
> >
> > > Greetings,
> > >
> > > After a couple of hours troubleshooting a bad boot image today I
> > > realized the issue was that I had some 0 byte files for the lpddr4
> > > training blobs that are part of the imx8mp binman created image.
> > >
> > > Digging in I found that if a blob referenced in the binman node is
> > > missing a warning will be output but the missing files will be
> > > 'created' as 0 byte files such that the next time you build you will
> > > get no warning (but will have a non-working image). Additionally the
> > > error does not cause a non-zero exit code.
> > >
> > > I'm not that fluent in python these days, and don't have the time for
> > > a while to try and fix this but I figured I would at least send this
> > > email in case someone else does.
> > >
> > > Example:
> > > # rm *lpddr4*.bin # make sure lpddr4*.bin files referenced in binman
> > > nodes are missing
> > > # make distclean imx8mp_venice_defconfig flash.bin && echo "build ok"
> > > ...
> > >   BINMAN  flash.bin
> > > Image 'main-section' is missing external blobs and is non-functional: 
> > > ddr-1d-ime
> > > m-fw ddr-1d-dmem-fw ddr-2d-imem-fw ddr-2d-dmem-fw
> > > Image 'main-section' has faked external blobs and is non-functional: 
> > > lpddr4_pmu_
> > > train_1d_imem_202006.bin lpddr4_pmu_train_1d_dmem_202006.bin 
> > > lpddr4_pmu_train_2d
> > > _imem_202006.bin lpddr4_pmu_train_2d_dmem_202006.bin
> > >
> > > Some images are invalid
> > > ^^^ excellent warning
> > > build ok
> > > ^^^ not so great that there is a successful exit code
> > > # make flash.bin && echo "build ok"
> > > ...
> > >   BINMAN  flash.bin
> > > build ok
> > > ^^^ absolutely horrible that 0 byte files were created and thus
> > > everything looks good this time around!
> > > # stat -c "%s %n" lpddr4*.bin
> > > 0 lpddr4_pmu_train_1d_dmem_202006.bin
> > > 0 lpddr4_pmu_train_1d_imem_202006.bin
> > > 0 lpddr4_pmu_train_2d_dmem_202006.bin
> > > 0 lpddr4_pmu_train_2d_imem_202006.bin
> >
> > So, this isn't the first time someone has had this problem. On the one
> > hand, we need CI to pass, and not require fetching of arbitrary further
> > images to assemble the binary. On the other hand, we don't want users
> > spending a bunch of time because something didn't work and the normal
> > way of conveying THIS WON'T WORK is a non-zero exit status. Can we
> > easily make some flag for buildman or binman that we do set in CI but
> > won't be set by users?
> >
> 
> Tom,
> 
> Ok - that makes sense as far as the exit status goes. It would be MUCH
> easier to catch an error like this if binman didn't create 0 byte
> files for missing files so that you at least get the (ascii colored)
> message indicating the image is wrong.
> 
> I do love the idea of a flag for CI also!

So, that's part of the root of the problem here.  We're passing
--fake-ext-blobs to binman so that it will create those 0 byte files
and it in turn complain. I think we didn't figure out a good way to
tell buildman to pass that to binman tho?

-- 
Tom


signature.asc
Description: PGP signature


Re: Submitting patches

2022-08-11 Thread Tom Rini
On Wed, Aug 03, 2022 at 11:04:45AM +0100, Martin Bonner wrote:

> I and my colleagues have a number of patches we would like to
> contribute back to the community, however for various reasons
> (principally operating inside corporate firewalls), it isn't possible
> to use `git send-email`, and I haven't been able to create a plain
> text email which is acceptable to `git am`.
> 
> Is it possible to fork u-boot on Git[HL][au]b or similar hosting site,
> and then send an email to the list pointing at the commit?

Sorry for the delay. If you really cannot configure git send-email
(which is pretty flexible these days) to talk with your corporate mail
server, and IT policy has access to external email providers also
blocked, that's just a tricky spot. I don't want to promote further
centralization of software by telling users to start using github or
gitlab directly, and I'm not sure we can sustain the overhead of
allowing users to have access to a "contrib" repository. So, as long as
it's not against corporate policy (as that would in turn violate the
rules behind a Signed-off-by tag), taking the patches out of the
corporate environment and to a personal machine where in turn you can
configure git send-email and gmail (or what have you) is the best
general answer.

-- 
Tom


signature.asc
Description: PGP signature


Re: binman warning/failure when blobs are missing

2022-08-11 Thread Tim Harvey
On Thu, Aug 11, 2022 at 9:48 AM Tom Rini  wrote:
>
> On Thu, Aug 11, 2022 at 09:27:44AM -0700, Tim Harvey wrote:
>
> > Greetings,
> >
> > After a couple of hours troubleshooting a bad boot image today I
> > realized the issue was that I had some 0 byte files for the lpddr4
> > training blobs that are part of the imx8mp binman created image.
> >
> > Digging in I found that if a blob referenced in the binman node is
> > missing a warning will be output but the missing files will be
> > 'created' as 0 byte files such that the next time you build you will
> > get no warning (but will have a non-working image). Additionally the
> > error does not cause a non-zero exit code.
> >
> > I'm not that fluent in python these days, and don't have the time for
> > a while to try and fix this but I figured I would at least send this
> > email in case someone else does.
> >
> > Example:
> > # rm *lpddr4*.bin # make sure lpddr4*.bin files referenced in binman
> > nodes are missing
> > # make distclean imx8mp_venice_defconfig flash.bin && echo "build ok"
> > ...
> >   BINMAN  flash.bin
> > Image 'main-section' is missing external blobs and is non-functional: 
> > ddr-1d-ime
> > m-fw ddr-1d-dmem-fw ddr-2d-imem-fw ddr-2d-dmem-fw
> > Image 'main-section' has faked external blobs and is non-functional: 
> > lpddr4_pmu_
> > train_1d_imem_202006.bin lpddr4_pmu_train_1d_dmem_202006.bin 
> > lpddr4_pmu_train_2d
> > _imem_202006.bin lpddr4_pmu_train_2d_dmem_202006.bin
> >
> > Some images are invalid
> > ^^^ excellent warning
> > build ok
> > ^^^ not so great that there is a successful exit code
> > # make flash.bin && echo "build ok"
> > ...
> >   BINMAN  flash.bin
> > build ok
> > ^^^ absolutely horrible that 0 byte files were created and thus
> > everything looks good this time around!
> > # stat -c "%s %n" lpddr4*.bin
> > 0 lpddr4_pmu_train_1d_dmem_202006.bin
> > 0 lpddr4_pmu_train_1d_imem_202006.bin
> > 0 lpddr4_pmu_train_2d_dmem_202006.bin
> > 0 lpddr4_pmu_train_2d_imem_202006.bin
>
> So, this isn't the first time someone has had this problem. On the one
> hand, we need CI to pass, and not require fetching of arbitrary further
> images to assemble the binary. On the other hand, we don't want users
> spending a bunch of time because something didn't work and the normal
> way of conveying THIS WON'T WORK is a non-zero exit status. Can we
> easily make some flag for buildman or binman that we do set in CI but
> won't be set by users?
>

Tom,

Ok - that makes sense as far as the exit status goes. It would be MUCH
easier to catch an error like this if binman didn't create 0 byte
files for missing files so that you at least get the (ascii colored)
message indicating the image is wrong.

I do love the idea of a flag for CI also!

Best Regards,

Tim


Re: [PATCH v2] Restore pcm051_rev3_defconfig config

2022-08-11 Thread Tom Rini
On Thu, Aug 11, 2022 at 05:18:12PM +0300, Matwey V. Kornilov wrote:

> pcm051_rev3_defconfig config (Phytec Wega board) has been dropped in
> 
> 64efd11d ("arm: Remove pcm051 board")
> 
> due to expired migration deadlines. Here, pcm051_rev3_defconfig support is
> reintroduced.
> 
> Signed-off-by: Matwey V. Kornilov 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: binman warning/failure when blobs are missing

2022-08-11 Thread Tom Rini
On Thu, Aug 11, 2022 at 09:27:44AM -0700, Tim Harvey wrote:

> Greetings,
> 
> After a couple of hours troubleshooting a bad boot image today I
> realized the issue was that I had some 0 byte files for the lpddr4
> training blobs that are part of the imx8mp binman created image.
> 
> Digging in I found that if a blob referenced in the binman node is
> missing a warning will be output but the missing files will be
> 'created' as 0 byte files such that the next time you build you will
> get no warning (but will have a non-working image). Additionally the
> error does not cause a non-zero exit code.
> 
> I'm not that fluent in python these days, and don't have the time for
> a while to try and fix this but I figured I would at least send this
> email in case someone else does.
> 
> Example:
> # rm *lpddr4*.bin # make sure lpddr4*.bin files referenced in binman
> nodes are missing
> # make distclean imx8mp_venice_defconfig flash.bin && echo "build ok"
> ...
>   BINMAN  flash.bin
> Image 'main-section' is missing external blobs and is non-functional: 
> ddr-1d-ime
> m-fw ddr-1d-dmem-fw ddr-2d-imem-fw ddr-2d-dmem-fw
> Image 'main-section' has faked external blobs and is non-functional: 
> lpddr4_pmu_
> train_1d_imem_202006.bin lpddr4_pmu_train_1d_dmem_202006.bin 
> lpddr4_pmu_train_2d
> _imem_202006.bin lpddr4_pmu_train_2d_dmem_202006.bin
> 
> Some images are invalid
> ^^^ excellent warning
> build ok
> ^^^ not so great that there is a successful exit code
> # make flash.bin && echo "build ok"
> ...
>   BINMAN  flash.bin
> build ok
> ^^^ absolutely horrible that 0 byte files were created and thus
> everything looks good this time around!
> # stat -c "%s %n" lpddr4*.bin
> 0 lpddr4_pmu_train_1d_dmem_202006.bin
> 0 lpddr4_pmu_train_1d_imem_202006.bin
> 0 lpddr4_pmu_train_2d_dmem_202006.bin
> 0 lpddr4_pmu_train_2d_imem_202006.bin

So, this isn't the first time someone has had this problem. On the one
hand, we need CI to pass, and not require fetching of arbitrary further
images to assemble the binary. On the other hand, we don't want users
spending a bunch of time because something didn't work and the normal
way of conveying THIS WON'T WORK is a non-zero exit status. Can we
easily make some flag for buildman or binman that we do set in CI but
won't be set by users?

-- 
Tom


signature.asc
Description: PGP signature


binman warning/failure when blobs are missing

2022-08-11 Thread Tim Harvey
Greetings,

After a couple of hours troubleshooting a bad boot image today I
realized the issue was that I had some 0 byte files for the lpddr4
training blobs that are part of the imx8mp binman created image.

Digging in I found that if a blob referenced in the binman node is
missing a warning will be output but the missing files will be
'created' as 0 byte files such that the next time you build you will
get no warning (but will have a non-working image). Additionally the
error does not cause a non-zero exit code.

I'm not that fluent in python these days, and don't have the time for
a while to try and fix this but I figured I would at least send this
email in case someone else does.

Example:
# rm *lpddr4*.bin # make sure lpddr4*.bin files referenced in binman
nodes are missing
# make distclean imx8mp_venice_defconfig flash.bin && echo "build ok"
...
  BINMAN  flash.bin
Image 'main-section' is missing external blobs and is non-functional: ddr-1d-ime
m-fw ddr-1d-dmem-fw ddr-2d-imem-fw ddr-2d-dmem-fw
Image 'main-section' has faked external blobs and is non-functional: lpddr4_pmu_
train_1d_imem_202006.bin lpddr4_pmu_train_1d_dmem_202006.bin lpddr4_pmu_train_2d
_imem_202006.bin lpddr4_pmu_train_2d_dmem_202006.bin

Some images are invalid
^^^ excellent warning
build ok
^^^ not so great that there is a successful exit code
# make flash.bin && echo "build ok"
...
  BINMAN  flash.bin
build ok
^^^ absolutely horrible that 0 byte files were created and thus
everything looks good this time around!
# stat -c "%s %n" lpddr4*.bin
0 lpddr4_pmu_train_1d_dmem_202006.bin
0 lpddr4_pmu_train_1d_imem_202006.bin
0 lpddr4_pmu_train_2d_dmem_202006.bin
0 lpddr4_pmu_train_2d_imem_202006.bin

Best Regards,

Tim


Re: Please pull u-boot-dm

2022-08-11 Thread Tom Rini
On Wed, Aug 10, 2022 at 09:18:11PM -0600, Simon Glass wrote:

> Hi Tom,
> 
> I've dropped the setuptools patch and will look at it later.
> 
> https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/13113
> 
> 
> The following changes since commit 3dd4e916324efc825a7ee8e412f5cf1ded839021:
> 
>   Merge https://source.denx.de/u-boot/custodians/u-boot-marvell
> (2022-08-09 08:16:14 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-dm.git tags/dm-pull-9aug22-take2
> 
> for you to fetch changes up to be43a35bff17550fa707795a06eaed6114eb1742:
> 
>   boot: allow bootmeth-distro without CONFIG_NET (2022-08-10 13:42:56 -0600)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [BISECTED] BeagleBone Black doesn't boot after a58147c2dbbf

2022-08-11 Thread Matwey V. Kornilov
чт, 11 авг. 2022 г. в 15:53, Alex Kiernan :
>
> On Thu, Aug 11, 2022 at 1:46 PM Tom Rini  wrote:
> >
> > On Thu, Aug 11, 2022 at 10:47:18AM +0300, Matwey V. Kornilov wrote:
> >
> > > Can somebody please advise me working CONFIG_DEBUG_UART _* values for
> > > the board? I think I need to obtain some output from the board to
> > > debug it further.
> >
> > Reading arch/arm/dts/am33xx-l4.dtsi isn't as easy to read as I would
> > personally like but 0x44e09000 is UART0 and so forth. Updating
> > doc/board/ti/am335x_evm.rst once you're done with a note about using
> > DEBUG_UART would be appreciated, thanks.
> >
>
> Some notes I have from a previous life which may be useful, but I'm
> afraid I've no way of checking these days:
>
> * CONFIG_DEBUG_UART=y
> * CONFIG_DEBUG_UART_BASE=0x44e09000
> * CONFIG_DEBUG_UART_CLOCK=4800
> * CONFIG_DEBUG_UART_OMAP=y
> * CONFIG_DEBUG_UART_SHIFT=2
> * CONFIG_DEBUG_UART_BOARD_INIT=y
> * CONFIG_DEBUG_UART_ANNOUNCE=y
>

Thanks. Unfortunately, these don't work.

> --
> Alex Kiernan



-- 
With best regards,
Matwey V. Kornilov


Re: [PATCH 05/11] binman: Add a function to check for missing properties

2022-08-11 Thread Quentin Schulz

Hi Simon,

On 8/11/22 16:04, Simon Glass wrote:

Add a new function to Entry to check for missing properties, since this
is likely to be come a common requirement.

Signed-off-by: Simon Glass 
---

  tools/binman/entry.py  | 16 
  tools/binman/etype/fill.py |  3 +--
  tools/binman/ftest.py  |  2 +-
  3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 41f0eb58ae0..3be074ccd66 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -1179,3 +1179,19 @@ features to produce new behaviours.
  if not os.path.exists(cls.fake_dir):
  os.mkdir(cls.fake_dir)
  tout.notice(f"Fake-blob dir is '{cls.fake_dir}'")
+
+def ensure_props(self, prop_list):
+"""Raise an exception if properties are missing
+
+Args:
+prop_list (list of str): List of properties to check for
+
+Raises:
+ValueError: Any property is missing
+"""
+not_present = []
+for prop in prop_list:
+if not prop in self._node.props:
+not_present.append(prop)
+if not_present:
+self.Raise(f"'{self.etype}' entry is missing properties: {' 
'.join(not_present)}")
diff --git a/tools/binman/etype/fill.py b/tools/binman/etype/fill.py
index cd382799199..0b068ba3268 100644
--- a/tools/binman/etype/fill.py
+++ b/tools/binman/etype/fill.py
@@ -26,8 +26,7 @@ class Entry_fill(Entry):
  
  def ReadNode(self):

  super().ReadNode()
-if self.size is None:
-self.Raise("'fill' entry must have a size property")
+self.ensure_props(['size'])


What about having a Dict in Entry for all required properties and then 
check them in Entry.ReadNode directly? So that other classes inheriting 
from Entry don't have to explicitly call ensure_props in ReadNode? Just 
need to add the property name to this Entry.required_props Dict?


Cheers,
Quentin


Re: [PATCH 08/11] binman: Improve mkimage documentation

2022-08-11 Thread Quentin Schulz

Hi Simon,

On 8/11/22 16:04, Simon Glass wrote:

Expand this a little to make things clearer. Also drop the invalid
entry arg.

Signed-off-by: Simon Glass 
---

  tools/binman/entries.rst  | 28 +---
  tools/binman/etype/mkimage.py | 28 +---
  2 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index a77e61800dd..8d7cbdc2e75 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1100,11 +1100,10 @@ Entry: mkimage: Binary produced by mkimage
  --
  
  Properties / Entry arguments:

-- datafile: Filename for -d argument
-- args: Other arguments to pass
+- args: Arguments to pass
  
-The data passed to mkimage is collected from subnodes of the mkimage node,

-e.g.::
+The data passed to mkimage via the -d flag is collected from subnodes of the
+mkimage node, e.g.::
  
  mkimage {

  args = "-n test -T imximage";
@@ -1113,9 +1112,24 @@ e.g.::
  };
  };
  
-This calls mkimage to create an imximage with u-boot-spl.bin as the input

-file. The output from mkimage then becomes part of the image produced by
-binman.
+This calls mkimage to create an imximage with `u-boot-spl.bin` as the data
+file, which mkimage being called like this::


"as if mkimage was being called like this::" ?


+
+mkimage -d  -n test -T imximage 
+
+The output from mkimage then becomes part of the image produced by
+binman. If you need to put mulitple things in the data file, you can use


s/mulitple/multiple/


+a section, or just multiple subnodes like this::
+


I think it is important to mention that those subnodes are concatenated 
by binman prior to being passed to mkimage, e.g. here we'll have one big 
temporary data file which is the concatenation of u-boot-spl and 
u-boot-tpl and passed to mkimage with -d tmp-data-file. It's not going 
to pass it like -d u-boot-spl:u-boot-tpl (hoping to have my series 
merged one day to support that though :) ).


Cheers,
Quentin


Re: [PATCH 09/11] binman: Allow the image name to be the data file

2022-08-11 Thread Quentin Schulz

Hi Simon,

On 8/11/22 16:04, Simon Glass wrote:

Some image types use the -n parameter to pass in the data file. Add
support for this, with a new property.

Signed-off-by: Simon Glass 
---

  tools/binman/entries.rst   | 15 +++
  tools/binman/etype/mkimage.py  | 26 --
  tools/binman/ftest.py  | 17 +
  tools/binman/test/235_mkimage_name.dts | 18 ++
  4 files changed, 74 insertions(+), 2 deletions(-)
  create mode 100644 tools/binman/test/235_mkimage_name.dts

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 8d7cbdc2e75..1d38c513ffa 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1101,6 +1101,8 @@ Entry: mkimage: Binary produced by mkimage
  
  Properties / Entry arguments:

  - args: Arguments to pass
+- data-to-imagename: Indicates that the -d data should be passed in as
+  the image name also (-n)
  
  The data passed to mkimage via the -d flag is collected from subnodes of the

  mkimage node, e.g.::
@@ -1141,6 +1143,19 @@ this example which also produces four arguments::
  };
  };
  
+If you need to pass the input data in with the -n argument as well, then use

+the 'data-to-imagename' property::
+
+mkimage {
+args = "-T imximage";
+data-to-imagename';


Spurious quote.


+
+u-boot-spl {
+};
+};
+
+That will pass the data to mkimage both as the data file (with -d) and as
+the image name (with -n).
  


What exactly is passed to -n here? If I read the code correctly, that 
would be "spl/u-boot-spl.bin"?


I admittedly also have absolutely no clue what the mkimage -n option 
does, but I guess that's an issue more for mkimage than binman.


Cheers,
Quentin


[PATCH 11/11] binman: Allow collection to use entries from other sections

2022-08-11 Thread Simon Glass
At present the collections etype only works with entries in the same
section. This can be limiting, since in some cases the data may be inside
a subsection, e.g. if there are alignment constraints.

Add a function to find the entries in an etype and have it search
recursively. Make use of this for mkimage also.

Signed-off-by: Simon Glass 
---

 tools/binman/entries.rst   |  3 +++
 tools/binman/entry.py  | 22 
 tools/binman/etype/collection.py   |  3 +++
 tools/binman/etype/mkimage.py  |  7 ++
 tools/binman/etype/section.py  |  8 +++---
 tools/binman/ftest.py  | 14 +++
 tools/binman/test/239_collection_other.dts | 29 ++
 tools/binman/test/240_mkimage_coll.dts | 27 
 8 files changed, 109 insertions(+), 4 deletions(-)
 create mode 100644 tools/binman/test/239_collection_other.dts
 create mode 100644 tools/binman/test/240_mkimage_coll.dts

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 682159ac6d3..3fa027a241c 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -427,6 +427,9 @@ listed entries are combined to form this entry. This serves 
as a useful
 base class for entry types which need to process data from elsewhere in
 the image, not necessarily child entries.
 
+The entries can generally be anywhere in the same image, even if they are in
+a different section from this entry.
+
 
 
 Entry: cros-ec-rw: A blob entry which contains a Chromium OS read-write EC 
image
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 3be074ccd66..b9995254982 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -684,6 +684,28 @@ class Entry(object):
 """
 return None
 
+def FindEntryByNode(self, find_node):
+"""Find a node in an entry, searching all subentries
+
+This does a recursive search.
+
+Args:
+find_node (fdt.Node): Node to find
+
+Returns:
+Entry: entry, if found, else None
+"""
+entries = self.GetEntries()
+if entries:
+for entry in entries.values():
+if entry._node == find_node:
+return entry
+found = entry.FindEntryByNode(find_node)
+if found:
+return found
+
+return None
+
 def GetArg(self, name, datatype=str):
 """Get the value of an entry argument or device-tree-node property
 
diff --git a/tools/binman/etype/collection.py b/tools/binman/etype/collection.py
index 442b40b48b3..c532aafe3e7 100644
--- a/tools/binman/etype/collection.py
+++ b/tools/binman/etype/collection.py
@@ -21,6 +21,9 @@ class Entry_collection(Entry):
 listed entries are combined to form this entry. This serves as a useful
 base class for entry types which need to process data from elsewhere in
 the image, not necessarily child entries.
+
+The entries can generally be anywhere in the same image, even if they are 
in
+a different section from this entry.
 """
 def __init__(self, section, etype, node):
 super().__init__(section, etype, node)
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index dd82d51bdb6..36eef973f21 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -144,6 +144,13 @@ class Entry_mkimage(Entry):
 
 return True
 
+def GetEntries(self):
+# Make a copy so we don't change the original
+entries = OrderedDict(self._mkimage_entries)
+if self._imagename:
+entries['imagename'] = self._imagename
+return entries
+
 def SetAllowMissing(self, allow_missing):
 """Set whether a section allows missing external blobs
 
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index bd67238b919..5c326a75e8c 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -506,10 +506,10 @@ class Entry_section(Entry):
 node = self._node.GetFdt().LookupPhandle(phandle)
 if not node:
 source_entry.Raise("Cannot find node for phandle %d" % phandle)
-for entry in self._entries.values():
-if entry._node == node:
-return entry.GetData(required)
-source_entry.Raise("Cannot find entry for node '%s'" % node.name)
+entry = self.FindEntryByNode(node)
+if not entry:
+source_entry.Raise("Cannot find entry for node '%s'" % node.name)
+return entry.GetData(required)
 
 def LookupSymbol(self, sym_name, optional, msg, base_addr, entries=None):
 """Look up a symbol in an ELF file
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 9b10fd8698d..737dbcc2466 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -5773,6 +5773,20 @@ fdt fdtmapExtract the devicetree 
blo

Re: [PATCH v2 5/6] serial: Call flush() before changing baudrate

2022-08-11 Thread Pali Rohár
On Thursday 11 August 2022 08:47:53 Simon Glass wrote:
> On Thu, 11 Aug 2022 at 06:39, Pali Rohár  wrote:
> >
> > Changing baudrate is sensitive operation. To ensure that U-Boot messages
> 
> is a sensitive
> 
> > printed before changing baudrate are not lost, call new U-Boot console
> > flush() function.
> >
> > Signed-off-by: Pali Rohár 
> > ---
> >  cmd/load.c | 5 +
> >  drivers/serial/serial-uclass.c | 1 +
> >  drivers/serial/serial.c| 1 +
> >  3 files changed, 7 insertions(+)
> >
> > diff --git a/cmd/load.c b/cmd/load.c
> > index e44ae0d56b75..5c4f34781d45 100644
> > --- a/cmd/load.c
> > +++ b/cmd/load.c
> > @@ -83,6 +83,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int 
> > flag, int argc,
> > printf("## Switch baudrate to %d bps and press ENTER ...\n",
> > load_baudrate);
> > udelay(5);
> > +   flush();
> > gd->baudrate = load_baudrate;
> > serial_setbrg();
> > udelay(5);
> > @@ -126,6 +127,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int 
> > flag, int argc,
> > printf("## Switch baudrate to %d bps and press ESC ...\n",
> > current_baudrate);
> > udelay(5);
> > +   flush();
> > gd->baudrate = current_baudrate;
> > serial_setbrg();
> > udelay(5);
> > @@ -317,6 +319,7 @@ int do_save_serial(struct cmd_tbl *cmdtp, int flag, int 
> > argc,
> > printf("## Switch baudrate to %d bps and press ESC ...\n",
> > (int)current_baudrate);
> > udelay(5);
> > +   flush();
> > gd->baudrate = current_baudrate;
> > serial_setbrg();
> > udelay(5);
> > @@ -471,6 +474,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, 
> > int flag, int argc,
> > printf("## Switch baudrate to %d bps and press ENTER ...\n",
> > load_baudrate);
> > udelay(5);
> > +   flush();
> > gd->baudrate = load_baudrate;
> > serial_setbrg();
> > udelay(5);
> > @@ -533,6 +537,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, 
> > int flag, int argc,
> > printf("## Switch baudrate to %d bps and press ESC ...\n",
> > current_baudrate);
> > udelay(5);
> > +   flush();
> > gd->baudrate = current_baudrate;
> > serial_setbrg();
> > udelay(5);
> > diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> > index 4e32270d4660..0f6860d9100e 100644
> > --- a/drivers/serial/serial-uclass.c
> > +++ b/drivers/serial/serial-uclass.c
> > @@ -527,6 +527,7 @@ static int on_baudrate(const char *name, const char 
> > *value, enum env_op op,
> > printf("## Switch baudrate to %d bps and press 
> > ENTER ...\n",
> >baudrate);
> > udelay(5);
> > +   flush();
> > }
> >
> > gd->baudrate = baudrate;
> > diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
> > index 6cdbb89841c1..4b525b644928 100644
> > --- a/drivers/serial/serial.c
> > +++ b/drivers/serial/serial.c
> > @@ -81,6 +81,7 @@ static int on_baudrate(const char *name, const char 
> > *value, enum env_op op,
> > printf("## Switch baudrate to %d"
> > " bps and press ENTER ...\n", baudrate);
> > udelay(5);
> > +   flush();
> 
> Please don't implement new features in legacy code.

Sorry, I do not know what is the legacy code in this spaghetti monster.

> > }
> >
> > gd->baudrate = baudrate;
> > --
> > 2.20.1
> >
> 
> Regards,
> SImon


Re: [PATCH v2 2/6] console: Implement flush() function

2022-08-11 Thread Pali Rohár
On Thursday 11 August 2022 08:47:50 Simon Glass wrote:
> > diff --git a/include/stdio_dev.h b/include/stdio_dev.h
> > index 270fa2729fb2..06278366ae88 100644
> > --- a/include/stdio_dev.h
> > +++ b/include/stdio_dev.h
> > @@ -37,6 +37,10 @@ struct stdio_dev {
> > void (*putc)(struct stdio_dev *dev, const char c);
> > /* To put a string (accelerator) */
> > void (*puts)(struct stdio_dev *dev, const char *s);
> > +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
> 
> I'd argue it isn't worth the #ifdef and we might as well have this
> member here always. Then you can drop some #ifdefs from your code.

But then it will increase binary code size.

> > +   /* To flush output queue */
> > +   void (*flush)(struct stdio_dev *dev);
> > +#endif
> >
> >  /* INPUT functions */
> >
> > --
> > 2.20.1
> >
> 
> Regards,
> SImon


Re: u-boot patch "[v2,02/16] arm: qemu: Add an SPL build" issue help

2022-08-11 Thread Simon Glass
Hi ziheng,

On Thu, 11 Aug 2022 at 00:26, 曹子恒  wrote:
>
> Hi, Simon Glass:
> we have an issue based on this patch below, can you help us ?
> 
> Patch:https://patchwork.ozlabs.org/project/uboot/patch/20220117150428.1580273-2-...@chromium.org/
>
> Our Environment:
> Qemu Version:7.0.0
> U-boot Baseline Version: 2021.10
>
> Steps:
> 1. we have only patched "[v2,02/16] arm: qemu: Add an SPL build", not 
> all the "passage: Define a standard for firmware data flow" series patchs.
>
> 2. Baseed on this patch, we have made the following modifications:
> a. arch/arm/dts/qemu-arm-u-boot.dtsi (Left is original, right 
> is modified, we think they are actually the same)
> 3. After compiling, image.bin is generated, image.map is as 
> follows(we think it's ok, spl base addr is 0x, and u-boot base addr 
> is 0x0001):
>   4. but when we use following command to execute, it will block.
> command: ./qemu-system-arm -machine virt -nographic -bios image.bin
> result:
>  5.  some key files size:
> image.bin: 767936
> u-boot.bin:694764
> u-boot-spl.bin:15112
>
> We don't know what could be causing this problem, hope you can help us !

I cannot repeat this problem.

$ qemu-system-arm -machine virt -nographic -bios
/tmp/b/qemu_arm_spl/image.bin -version
QEMU emulator version 4.2.1 (Debian 1:4.2-3ubuntu6.23)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers

I use the tree here:

https://github.com/sjg20/u-boot/tree/try-qemu

buildman -k -o /tmp/b/qemu_arm_spl -w qemu_arm_spl

$ qemu-system-arm -machine virt -nographic -bios /tmp/b/qemu_arm_spl/image.bin

U-Boot SPL 2022.10-rc2-00042-g5dac8f83d0d-dirty (Aug 11 2022 - 08:36:05 -0600)
Trying to boot from QEMU


U-Boot 2022.10-rc2-00042-g5dac8f83d0d-dirty (Aug 11 2022 - 08:36:05 -0600)

DRAM:  128 MiB
Core:  47 devices, 14 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from Flash... *** Warning - bad CRC, using default
environment

In:pl011@900
Out:   pl011@900
Err:   pl011@900
Net:   eth0: virtio-net#32
Hit any key to stop autoboot:  0
=> QEMU: Terminated

 Regards,
Simon


Re: [PATCH v2 6/6] boot: Call flush() before booting

2022-08-11 Thread Simon Glass
On Thu, 11 Aug 2022 at 06:39, Pali Rohár  wrote:
>
> In lot of cases kernel resets UART HW. To ensure that U-Boot messages

In a lot

> printed before booting kernel are not lost, call new U-Boot console flush()

booting the kernel

> function.
>
> Signed-off-by: Pali Rohár 
> ---
>  boot/bootm_os.c | 1 +
>  cmd/boot.c  | 1 +
>  cmd/elf.c   | 2 ++
>  3 files changed, 4 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH v2 2/6] console: Implement flush() function

2022-08-11 Thread Simon Glass
Hi Pali,

On Thu, 11 Aug 2022 at 06:39, Pali Rohár  wrote:
>
> On certain places it is required to flush output print buffers to ensure
> that text strings were sent to console or serial devices. For example when
> printing message that U-Boot is going to boot kernel or when U-Boot is
> going to change baudrate of terminal device.
>
> Therefore introduce a new flush() and fflush() functions into console code.
> These functions will call .flush callback of associated stdio_dev device.
>
> As this function may increase U-Boot side, allow to compile U-Boot without
> this function. For this purpose there is a new config CONSOLE_FLUSH_SUPPORT
> which is enabled by default and can be disabled. It is a good idea to have
> this option enabled for all boards which have enough space for it.
>
> When option is disabled when U-Boot defines just empty static inline
> function fflush() to avoid ifdefs in other code.
>
> Signed-off-by: Pali Rohár 
> ---
>  common/Kconfig  |  6 +
>  common/console.c| 63 +
>  include/_exports.h  |  3 +++
>  include/stdio.h | 15 +++
>  include/stdio_dev.h |  4 +++
>  5 files changed, 91 insertions(+)
>
> diff --git a/common/Kconfig b/common/Kconfig
> index e7914ca750a3..109741cc6c44 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -186,6 +186,12 @@ config PRE_CON_BUF_ADDR
>   We should consider removing this option and allocating the memory
>   in board_init_f_init_reserve() instead.
>
> +config CONSOLE_FLUSH_SUPPORT
> +   bool "Enable console flush support"
> +   default y
> +   help
> + This enables compilation of flush() function for console flush 
> support.

This needs at least two more lines, I think. Perhaps you can explain
what flush does and the fact that there is no timeout?

> +
>  config CONSOLE_MUX
> bool "Enable console multiplexing"
> default y if DM_VIDEO || VIDEO || LCD
> diff --git a/common/console.c b/common/console.c
> index dc071f1ed665..42415e34d16f 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -198,6 +198,9 @@ static int console_setfile(int file, struct stdio_dev * 
> dev)
> case stdout:
> gd->jt->putc  = putc;
> gd->jt->puts  = puts;
> +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT

How about CONFIG_IS_ENABLED() so we don't enable this in SPL too?

> +   gd->jt->flush = flush;
> +#endif
> gd->jt->printf = printf;
> break;
> }
> @@ -363,6 +366,19 @@ static void console_puts(int file, const char *s)
> }
>  }
>
> +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
> +static void console_flush(int file)
> +{
> +   int i;
> +   struct stdio_dev *dev;
> +
> +   for_each_console_dev(i, file, dev) {
> +   if (dev->flush != NULL)
> +   dev->flush(dev);
> +   }
> +}
> +#endif
> +
>  #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
>  static inline void console_doenv(int file, struct stdio_dev *dev)
>  {
> @@ -412,6 +428,14 @@ static inline void console_puts(int file, const char *s)
> stdio_devices[file]->puts(stdio_devices[file], s);
>  }
>
> +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT

I hope you can drop this #ifdef - see below.

> +static inline void console_flush(int file)
> +{
> +   if (stdio_devices[file]->flush)
> +   stdio_devices[file]->flush(stdio_devices[file]);
> +}
> +#endif
> +
>  #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
>  static inline void console_doenv(int file, struct stdio_dev *dev)
>  {
> @@ -525,6 +549,14 @@ void fputs(int file, const char *s)
> console_puts(file, s);
>  }
>
> +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
> +void fflush(int file)
> +{
> +   if (file < MAX_FILES)
> +   console_flush(file);
> +}
> +#endif
> +
>  int fprintf(int file, const char *fmt, ...)
>  {
> va_list args;
> @@ -731,6 +763,37 @@ void puts(const char *s)
> }
>  }
>
> +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
> +void flush(void)
> +{
> +   if (!gd)
> +   return;
> +
> +   /* sandbox can send characters to stdout before it has a console */
> +   if (IS_ENABLED(CONFIG_SANDBOX) && !(gd->flags & GD_FLG_SERIAL_READY)) 
> {
> +   os_flush();
> +   return;
> +   }
> +
> +   if (IS_ENABLED(CONFIG_DEBUG_UART) && !(gd->flags & 
> GD_FLG_SERIAL_READY))
> +   return;
> +
> +   if (IS_ENABLED(CONFIG_SILENT_CONSOLE) && (gd->flags & GD_FLG_SILENT))
> +   return;
> +
> +   if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & 
> GD_FLG_DISABLE_CONSOLE))
> +   return;
> +
> +   if (!gd->have_console)
> +   return;
> +
> +   if (gd->flags & GD_FLG_DEVINIT) {
> +   /* Send to the standard output */
> +   fflush(stdout);
> +   }
> +}
> +#endif
> +
>  #ifdef CONFIG_CONSOLE_RECORD

Re: [PATCH v2 5/6] serial: Call flush() before changing baudrate

2022-08-11 Thread Simon Glass
On Thu, 11 Aug 2022 at 06:39, Pali Rohár  wrote:
>
> Changing baudrate is sensitive operation. To ensure that U-Boot messages

is a sensitive

> printed before changing baudrate are not lost, call new U-Boot console
> flush() function.
>
> Signed-off-by: Pali Rohár 
> ---
>  cmd/load.c | 5 +
>  drivers/serial/serial-uclass.c | 1 +
>  drivers/serial/serial.c| 1 +
>  3 files changed, 7 insertions(+)
>
> diff --git a/cmd/load.c b/cmd/load.c
> index e44ae0d56b75..5c4f34781d45 100644
> --- a/cmd/load.c
> +++ b/cmd/load.c
> @@ -83,6 +83,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, 
> int argc,
> printf("## Switch baudrate to %d bps and press ENTER ...\n",
> load_baudrate);
> udelay(5);
> +   flush();
> gd->baudrate = load_baudrate;
> serial_setbrg();
> udelay(5);
> @@ -126,6 +127,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int 
> flag, int argc,
> printf("## Switch baudrate to %d bps and press ESC ...\n",
> current_baudrate);
> udelay(5);
> +   flush();
> gd->baudrate = current_baudrate;
> serial_setbrg();
> udelay(5);
> @@ -317,6 +319,7 @@ int do_save_serial(struct cmd_tbl *cmdtp, int flag, int 
> argc,
> printf("## Switch baudrate to %d bps and press ESC ...\n",
> (int)current_baudrate);
> udelay(5);
> +   flush();
> gd->baudrate = current_baudrate;
> serial_setbrg();
> udelay(5);
> @@ -471,6 +474,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, int 
> flag, int argc,
> printf("## Switch baudrate to %d bps and press ENTER ...\n",
> load_baudrate);
> udelay(5);
> +   flush();
> gd->baudrate = load_baudrate;
> serial_setbrg();
> udelay(5);
> @@ -533,6 +537,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, int 
> flag, int argc,
> printf("## Switch baudrate to %d bps and press ESC ...\n",
> current_baudrate);
> udelay(5);
> +   flush();
> gd->baudrate = current_baudrate;
> serial_setbrg();
> udelay(5);
> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index 4e32270d4660..0f6860d9100e 100644
> --- a/drivers/serial/serial-uclass.c
> +++ b/drivers/serial/serial-uclass.c
> @@ -527,6 +527,7 @@ static int on_baudrate(const char *name, const char 
> *value, enum env_op op,
> printf("## Switch baudrate to %d bps and press ENTER 
> ...\n",
>baudrate);
> udelay(5);
> +   flush();
> }
>
> gd->baudrate = baudrate;
> diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
> index 6cdbb89841c1..4b525b644928 100644
> --- a/drivers/serial/serial.c
> +++ b/drivers/serial/serial.c
> @@ -81,6 +81,7 @@ static int on_baudrate(const char *name, const char *value, 
> enum env_op op,
> printf("## Switch baudrate to %d"
> " bps and press ENTER ...\n", baudrate);
> udelay(5);
> +   flush();

Please don't implement new features in legacy code.

> }
>
> gd->baudrate = baudrate;
> --
> 2.20.1
>

Regards,
SImon


Re: [PATCH v2 3/6] serial: Implement flush callback

2022-08-11 Thread Simon Glass
On Thu, 11 Aug 2022 at 06:39, Pali Rohár  wrote:
>
> UART drivers have putc/puts functions which just put characters into HW
> transmit queue and do not wait until all data are transmitted.
>
> Implement flush callback via serial driver's pending(false) callback which
> waits until HW transmit all characters from the queue.
>
> Signed-off-by: Pali Rohár 
> ---
>  drivers/serial/serial-uclass.c | 22 ++
>  1 file changed, 22 insertions(+)

Reviewed-by: Simon Glass 

But let's always add this to the struct.



>
> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index 4b7819fa473b..71ea88e31c9f 100644
> --- a/drivers/serial/serial-uclass.c
> +++ b/drivers/serial/serial-uclass.c
> @@ -238,6 +238,18 @@ static void _serial_puts(struct udevice *dev, const char 
> *str)
> } while (*str);
>  }
>
> +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
> +static void _serial_flush(struct udevice *dev)
> +{
> +   struct dm_serial_ops *ops = serial_get_ops(dev);
> +
> +   if (!ops->pending)
> +   return;
> +   while (ops->pending(dev, false) > 0)
> +   ;
> +}
> +#endif
> +
>  static int __serial_getc(struct udevice *dev)
>  {
> struct dm_serial_ops *ops = serial_get_ops(dev);
> @@ -412,6 +424,13 @@ static void serial_stub_puts(struct stdio_dev *sdev, 
> const char *str)
> _serial_puts(sdev->priv, str);
>  }
>
> +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
> +static void serial_stub_flush(struct stdio_dev *sdev)
> +{
> +   _serial_flush(sdev->priv);
> +}
> +#endif
> +
>  static int serial_stub_getc(struct stdio_dev *sdev)
>  {
> return _serial_getc(sdev->priv);
> @@ -571,6 +590,9 @@ static int serial_post_probe(struct udevice *dev)
> sdev.priv = dev;
> sdev.putc = serial_stub_putc;
> sdev.puts = serial_stub_puts;
> +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
> +   sdev.flush = serial_stub_flush;
> +#endif
> sdev.getc = serial_stub_getc;
> sdev.tstc = serial_stub_tstc;
>
> --
> 2.20.1
>


Re: [PATCH v2 4/6] serial: Implement serial_flush() function for console flush() fallback

2022-08-11 Thread Simon Glass
Hi Pali,

On Thu, 11 Aug 2022 at 06:39, Pali Rohár  wrote:
>
> Like in all other console functions, implement also serial_flush() function
> as a fallback int console flush() function.
>
> Flush support is available only when config option CONSOLE_FLUSH_SUPPORT is
> enabled. So when it is disabled then provides just empty static inline
> function serial_flush().
>
> Signed-off-by: Pali Rohár 
> ---
>  common/console.c   |  3 +++
>  common/stdio.c | 10 ++
>  drivers/serial/serial-uclass.c | 10 ++
>  include/serial.h   |  5 +
>  4 files changed, 28 insertions(+)

Reviewed-by: Simon Glass 


Re: [RESEND 3/3] ram: rk3399: Conduct memory training at 400MHz

2022-08-11 Thread Simon Glass
On Thu, 11 Aug 2022 at 05:09, Lee Jones  wrote:
>
> Currently the default initialisation frequency is 50MHz.  Although
> this does appear to be suitable for some LPDDR4 RAM chips, training at
> this low frequency has been seen to cause Column errors, leading to
> Capacity check errors on others.
>
> Here we force RAM initialisation to happen at 400MHz before ramping up
> to the final value running value of 800MHz after everything has been
> successfully configured.
>
> Link: https://lore.kernel.org/u-boot/yo4v3juehxtov...@google.com/
> Suggested-by: YouMin Chen 
> Signed-off-by: Lee Jones 
> Tested-by: Xavier Drudis Ferran 
> Reviewed-by: Kever Yang 
> ---
>  drivers/ram/rockchip/sdram_rk3399.c | 36 +
>  1 file changed, 21 insertions(+), 15 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH] bootstage: Show func name for bootstage_mark/error

2022-08-11 Thread Simon Glass
Hi Michal,

On Thu, 11 Aug 2022 at 06:46, Michal Simek  wrote:
>
> bootstage_mark() and bootstate_error() are not recording any name and in
> report it is showing as id=. That's not useful and it is better to
> show function name which calls it.
> That's why use macros with passing __func__ as recorded name for bootstage.
>
> Origin report looks like this:
> ZynqMP> bootstage report
> Timer summary in microseconds (10 records):
>MarkElapsed  Stage
>   0  0  reset
>   2,482,383  2,482,383  board_init_f
>   4,278,821  1,796,438  board_init_r
>   4,825,331546,510  id=64
>   4,858,409 33,078  id=65
>   4,862,382  3,973  main_loop
>   4,921,713 59,331  usb_start
>   9,345,345  4,423,632  id=175
>
> When this patch is applied.
> ZynqMP> bootstage report
> Timer summary in microseconds (31 records):
>MarkElapsed  Stage
>   0  0  reset
>   2,465,624  2,465,624  board_init_f
>   4,278,628  1,813,004  board_init_r
>   4,825,139546,511  eth_common_init
>   4,858,228 33,089  eth_initialize
>   4,862,201  3,973  main_loop
>   4,921,530 59,329  usb_start
>   8,885,334  3,963,804  cli_loop
>
> Signed-off-by: Michal Simek 
> ---
>
>  common/bootstage.c  | 10 ++
>  include/bootstage.h |  5 +++--
>  2 files changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/common/bootstage.c b/common/bootstage.c
> index 0fd33be97eae..326c40f1561f 100644
> --- a/common/bootstage.c
> +++ b/common/bootstage.c
> @@ -147,15 +147,9 @@ ulong bootstage_add_record(enum bootstage_id id, const 
> char *name,
> return mark;
>  }
>
> -
> -ulong bootstage_mark(enum bootstage_id id)
> -{
> -   return bootstage_add_record(id, NULL, 0, timer_get_boot_us());
> -}
> -
> -ulong bootstage_error(enum bootstage_id id)
> +ulong bootstage_error_name(enum bootstage_id id, const char *name)
>  {
> -   return bootstage_add_record(id, NULL, BOOTSTAGEF_ERROR,
> +   return bootstage_add_record(id, name, BOOTSTAGEF_ERROR,
> timer_get_boot_us());
>  }
>
> diff --git a/include/bootstage.h b/include/bootstage.h
> index bca9438418f5..8d9ef7362f8b 100644
> --- a/include/bootstage.h
> +++ b/include/bootstage.h
> @@ -268,9 +268,10 @@ ulong bootstage_add_record(enum bootstage_id id, const 
> char *name,
>  /**
>   * Mark a time stamp for the current boot stage.
>   */
> -ulong bootstage_mark(enum bootstage_id id);
> +#define bootstage_mark(id) bootstage_mark_name(id, __func__)
> +#define bootstage_error(id)bootstage_error_name(id, __func__)
>
> -ulong bootstage_error(enum bootstage_id id);
> +ulong bootstage_error_name(enum bootstage_id id, const char *name);

Please can you add proper comments to these functions?
>
>  ulong bootstage_mark_name(enum bootstage_id id, const char *name);

Also I think you need to add code for when BOOTSTAGE is not enabled,
later in the header.

>
> --
> 2.36.1
>

Regards,
Simon


Re: [RESEND 2/3] ram: rk3399: Fix faulty frequency change reports

2022-08-11 Thread Simon Glass
On Thu, 11 Aug 2022 at 05:09, Lee Jones  wrote:
>
> Frequency changes to 400MHz are presently reported as:
>
>   lpddr4_set_rate_0: change freq to 4 mhz 0, 1
>
> This is obviously wrong by 6 orders of magnitude.
>
> Ensure frequency changes are reported accurately.
>
> Signed-off-by: Lee Jones 
> Tested-by: Xavier Drudis Ferran 
> Reviewed-by: Kever Yang 
> ---
>  drivers/ram/rockchip/sdram_rk3399.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 1/6] sandbox: Add function os_flush()

2022-08-11 Thread Simon Glass
On Thu, 11 Aug 2022 at 06:39, Pali Rohár  wrote:
>
> It flushes stdout.
>
> Signed-off-by: Pali Rohár 
> ---
>  arch/sandbox/cpu/os.c | 5 +
>  include/os.h  | 8 
>  2 files changed, 13 insertions(+)

Reviewed-by: Simon Glass 


Re: [RESEND 1/3] ram: rk3399: Fix .set_rate_index() error handling

2022-08-11 Thread Simon Glass
On Thu, 11 Aug 2022 at 05:09, Lee Jones  wrote:
>
> Functions pointed to by this op pointer can return non-zero values
> indicating an error.  Ensure any error value is propagated back up the
> call-chain.
>
> Signed-off-by: Lee Jones 
> Tested-by: Xavier Drudis Ferran 
> Reviewed-by: Kever Yang 
> ---
>  drivers/ram/rockchip/sdram_rk3399.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH 3/3] ram: rk3399: Conduct memory training at 400MHz

2022-08-11 Thread Michal Suchánek
On Thu, Aug 11, 2022 at 08:58:48AM +0100, Lee Jones wrote:
> Currently the default initialisation frequency is 50MHz.  Although
> this does appear to be suitable for some LPDDR4 RAM chips, training at
> this low frequency has been seen to cause Column errors, leading to
> Capacity check errors on others.
> 
> Here we force RAM initialisation to happen at 400MHz before ramping up
> to the final value running value of 800MHz after everything has been
> successfully configured.
> 
> Link: https://lore.kernel.org/u-boot/yo4v3juehxtov...@google.com/
> Suggested-by: YouMin Chen 
> Signed-off-by: Lee Jones 
> Tested-by: Xavier Drudis Ferran 

Also does not cause any regression on a Pinebook Pro

Tested-by: Michal Suchánek 

Thanks

Michal

> Reviewed-by: Kever Yang 
> ---
>  drivers/ram/rockchip/sdram_rk3399.c | 36 +
>  1 file changed, 21 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/ram/rockchip/sdram_rk3399.c 
> b/drivers/ram/rockchip/sdram_rk3399.c
> index 34d6c93f95..b05c5925d5 100644
> --- a/drivers/ram/rockchip/sdram_rk3399.c
> +++ b/drivers/ram/rockchip/sdram_rk3399.c
> @@ -85,7 +85,7 @@ struct sdram_rk3399_ops {
>   int (*data_training_first)(struct dram_info *dram, u32 channel, u8 rank,
>  struct rk3399_sdram_params *sdram);
>   int (*set_rate_index)(struct dram_info *dram,
> -   struct rk3399_sdram_params *params);
> +   struct rk3399_sdram_params *params, u32 ctl_fn);
>   void (*modify_param)(const struct chan_info *chan,
>struct rk3399_sdram_params *params);
>   struct rk3399_sdram_params *
> @@ -1644,7 +1644,8 @@ static int data_training_first(struct dram_info *dram, 
> u32 channel, u8 rank,
>  }
>  
>  static int switch_to_phy_index1(struct dram_info *dram,
> - struct rk3399_sdram_params *params)
> + struct rk3399_sdram_params *params,
> + u32 unused)
>  {
>   u32 channel;
>   u32 *denali_phy;
> @@ -2539,26 +2540,25 @@ static int lpddr4_set_ctl(struct dram_info *dram,
>  }
>  
>  static int lpddr4_set_rate(struct dram_info *dram,
> -struct rk3399_sdram_params *params)
> + struct rk3399_sdram_params *params,
> + u32 ctl_fn)
>  {
> - u32 ctl_fn;
>   u32 phy_fn;
>  
> - for (ctl_fn = 0; ctl_fn < 2; ctl_fn++) {
> - phy_fn = lpddr4_get_phy_fn(params, ctl_fn);
> + phy_fn = lpddr4_get_phy_fn(params, ctl_fn);
>  
> - lpddr4_set_phy(dram, params, phy_fn, &dfs_cfgs_lpddr4[ctl_fn]);
> - lpddr4_set_ctl(dram, params, ctl_fn,
> -dfs_cfgs_lpddr4[ctl_fn].base.ddr_freq);
> + lpddr4_set_phy(dram, params, phy_fn, &dfs_cfgs_lpddr4[ctl_fn]);
> + lpddr4_set_ctl(dram, params, ctl_fn,
> +dfs_cfgs_lpddr4[ctl_fn].base.ddr_freq);
>  
> - if (IS_ENABLED(CONFIG_RAM_ROCKCHIP_DEBUG))
> - printf("%s: change freq to %dMHz %d, %d\n", __func__,
> -dfs_cfgs_lpddr4[ctl_fn].base.ddr_freq / MHz,
> -ctl_fn, phy_fn);
> - }
> + if (IS_ENABLED(CONFIG_RAM_ROCKCHIP_DEBUG))
> + printf("%s: change freq to %dMHz %d, %d\n", __func__,
> +dfs_cfgs_lpddr4[ctl_fn].base.ddr_freq / MHz,
> +ctl_fn, phy_fn);
>  
>   return 0;
>  }
> +
>  #endif /* CONFIG_RAM_RK3399_LPDDR4 */
>  
>  /* CS0,n=1
> @@ -2955,6 +2955,12 @@ static int sdram_init(struct dram_info *dram,
>   params->ch[ch].cap_info.rank = rank;
>   }
>  
> +#if defined(CONFIG_RAM_RK3399_LPDDR4)
> + /* LPDDR4 needs to be trained at 400MHz */
> + lpddr4_set_rate(dram, params, 0);
> + params->base.ddr_freq = dfs_cfgs_lpddr4[0].base.ddr_freq / MHz;
> +#endif
> +
>   params->base.num_channels = 0;
>   for (channel = 0; channel < 2; channel++) {
>   const struct chan_info *chan = &dram->chan[channel];
> @@ -3005,7 +3011,7 @@ static int sdram_init(struct dram_info *dram,
>   params->base.stride = calculate_stride(params);
>   dram_all_config(dram, params);
>  
> - ret = dram->ops->set_rate_index(dram, params);
> + ret = dram->ops->set_rate_index(dram, params, 1);
>   if (ret)
>   return ret;
>  
> -- 
> 2.37.1.559.g78731f0fdb-goog
> 


[PATCH v2] Restore pcm051_rev3_defconfig config

2022-08-11 Thread Matwey V. Kornilov
pcm051_rev3_defconfig config (Phytec Wega board) has been dropped in

64efd11d ("arm: Remove pcm051 board")

due to expired migration deadlines. Here, pcm051_rev3_defconfig support is
reintroduced.

Signed-off-by: Matwey V. Kornilov 
---
Changes since v1:
  - Do not add symbols to whitelist

 arch/arm/dts/am335x-wega-rdk-u-boot.dtsi | 12 +
 board/phytec/phycore_am335x_r2/Kconfig   |  2 +-
 board/phytec/phycore_am335x_r2/board.c   | 26 +
 configs/pcm051_rev3_defconfig| 69 
 4 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100644 configs/pcm051_rev3_defconfig

diff --git a/arch/arm/dts/am335x-wega-rdk-u-boot.dtsi 
b/arch/arm/dts/am335x-wega-rdk-u-boot.dtsi
index 28fd62e231..b3f21e7f52 100644
--- a/arch/arm/dts/am335x-wega-rdk-u-boot.dtsi
+++ b/arch/arm/dts/am335x-wega-rdk-u-boot.dtsi
@@ -16,6 +16,18 @@
 
ocp {
u-boot,dm-pre-reloc;
+
+   l4_wkup@44c0 {
+   u-boot,dm-pre-reloc;
+
+   segment@20 {
+   u-boot,dm-pre-reloc;
+
+   target-module@9000 {
+   u-boot,dm-pre-reloc;
+   };
+   };
+   };
};
 };
 
diff --git a/board/phytec/phycore_am335x_r2/Kconfig 
b/board/phytec/phycore_am335x_r2/Kconfig
index 77055e043c..4183c2410e 100644
--- a/board/phytec/phycore_am335x_r2/Kconfig
+++ b/board/phytec/phycore_am335x_r2/Kconfig
@@ -1,4 +1,4 @@
-if TARGET_PHYCORE_AM335X_R2
+if TARGET_PCM051 || TARGET_PHYCORE_AM335X_R2
 
 config SYS_BOARD
default "phycore_am335x_r2"
diff --git a/board/phytec/phycore_am335x_r2/board.c 
b/board/phytec/phycore_am335x_r2/board.c
index 5ca9415204..d97ebd0151 100644
--- a/board/phytec/phycore_am335x_r2/board.c
+++ b/board/phytec/phycore_am335x_r2/board.c
@@ -31,7 +31,11 @@ DECLARE_GLOBAL_DATA_PTR;
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
 /* DDR RAM defines */
+#if defined(CONFIG_TARGET_PCM051)
+#define DDR_CLK_MHZ303 /* DDR_DPLL_MULT value */
+#else
 #define DDR_CLK_MHZ400 /* DDR_DPLL_MULT value */
+#endif
 
 #define OSC(V_OSCK / 100)
 const struct dpll_params dpll_ddr = {
@@ -65,6 +69,7 @@ enum {
PHYCORE_R2_MT41K128M16JT_256MB,
PHYCORE_R2_MT41K256M16TW107IT_512MB,
PHYCORE_R2_MT41K512M16HA125IT_1024MB,
+   PHYCORE_R13_MT41K256M16HA125E_256MB,
 };
 
 struct am335x_sdram_timings {
@@ -127,10 +132,30 @@ static struct am335x_sdram_timings physom_timings[] = {
.datawrsratio0 = 0x82,
},
},
+   [PHYCORE_R13_MT41K256M16HA125E_256MB] = {
+   .ddr3_emif_reg_data = {
+   .sdram_config = MT41K256M16HA125E_EMIF_SDCFG,
+   .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF,
+   .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1,
+   .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2,
+   .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3,
+   .zq_config = MT41K256M16HA125E_ZQ_CFG,
+   .emif_ddr_phy_ctlr_1 = 
MT41K256M16HA125E_EMIF_READ_LATENCY | PHY_EN_DYN_PWRDN,
+   },
+   .ddr3_data = {
+   .datardsratio0 = MT41K256M16HA125E_RD_DQS,
+   .datawdsratio0 = MT41K256M16HA125E_WR_DQS,
+   .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE,
+   .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA,
+   },
+   },
 };
 
 void sdram_init(void)
 {
+#if defined(CONFIG_TARGET_PCM051)
+   int ram_type_index = PHYCORE_R13_MT41K256M16HA125E_256MB;
+#else
/* Configure memory to maximum supported size for detection */
int ram_type_index = PHYCORE_R2_MT41K512M16HA125IT_1024MB;
 
@@ -157,6 +182,7 @@ void sdram_init(void)
ram_type_index = PHYCORE_R2_MT41K128M16JT_256MB;
break;
}
+#endif
config_ddr(DDR_CLK_MHZ, &ioregs,
   &physom_timings[ram_type_index].ddr3_data,
   &ddr3_cmd_ctrl_data,
diff --git a/configs/pcm051_rev3_defconfig b/configs/pcm051_rev3_defconfig
new file mode 100644
index 00..624113d61a
--- /dev/null
+++ b/configs/pcm051_rev3_defconfig
@@ -0,0 +1,69 @@
+CONFIG_ARM=y
+CONFIG_ARCH_CPU_INIT=y
+CONFIG_ARCH_OMAP2PLUS=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_DEFAULT_DEVICE_TREE="am335x-wega-rdk"
+CONFIG_AM33XX=y
+CONFIG_TARGET_PCM051=y
+CONFIG_SPL_MMC=y
+CONFIG_SPL_SERIAL=y
+CONFIG_SPL=y
+CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x4030ff00
+CONFIG_OF_BOARD_SETUP=y
+CONFIG_DEFAULT_FDT_FILE="am335x-wega-rdk.dtb"
+CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_ARCH_MISC_INIT=y
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_SPL

Re: [PATCH 01/11] doc: Build documentation in parallel

2022-08-11 Thread Quentin Schulz

Hi Simon,

On 8/11/22 16:04, Simon Glass wrote:

With the addition of the revision stats this now takes over a minute. Use
a parallel build to reduce it a bit (24 seconds for me).

Signed-off-by: Simon Glass 
---

  doc/Makefile | 1 +
  1 file changed, 1 insertion(+)

diff --git a/doc/Makefile b/doc/Makefile
index 050d9dd2391..008a516cb64 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -57,6 +57,7 @@ quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath 
$(BUILDDIR)/$3/$4)
BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath 
$(srctree)/$(src)/$5/$(SPHINX_CONF)) \
$(SPHINXBUILD) \
-b $2 \
+   -j $(shell nproc) \


Nitpick:

-j auto
does the same since Sphinx 1.7 and saves a shell call.

Cheers,
Quentin


[PATCH 10/11] binman: Allow passing entries using -n

2022-08-11 Thread Simon Glass
Also control over what goes in the file passed with -n using a separate
imagename subnode. This can include a section or any other entry type.

Signed-off-by: Simon Glass 
---

 tools/binman/entries.rst  | 18 +
 tools/binman/etype/mkimage.py | 39 ++-
 tools/binman/ftest.py | 34 
 tools/binman/test/236_mkimage_image.dts   | 21 ++
 .../test/237_mkimage_image_no_content.dts | 22 +++
 tools/binman/test/238_mkimage_image_bad.dts   | 22 +++
 6 files changed, 155 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/236_mkimage_image.dts
 create mode 100644 tools/binman/test/237_mkimage_image_no_content.dts
 create mode 100644 tools/binman/test/238_mkimage_image_bad.dts

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 1d38c513ffa..682159ac6d3 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1157,6 +1157,24 @@ the 'data-to-imagename' property::
 That will pass the data to mkimage both as the data file (with -d) and as
 the image name (with -n).
 
+If need to pass different data in with -n, then use an imagename subnode::
+
+mkimage {
+args = "-T imximage";
+
+imagename {
+blob {
+filename = "spl/u-boot-spl.cfgout"
+};
+};
+
+u-boot-spl {
+};
+};
+
+This will pass in u-boot-spl as the input data and the .cfgout file as the
+-n data.
+
 
 
 Entry: opensbi: RISC-V OpenSBI fw_dynamic blob
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index 3295f451f79..dd82d51bdb6 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -71,10 +71,29 @@ class Entry_mkimage(Entry):
 
 That will pass the data to mkimage both as the data file (with -d) and as
 the image name (with -n).
+
+If need to pass different data in with -n, then use an imagename subnode::
+
+mkimage {
+args = "-T imximage";
+
+imagename {
+blob {
+filename = "spl/u-boot-spl.cfgout"
+};
+};
+
+u-boot-spl {
+};
+};
+
+This will pass in u-boot-spl as the input data and the .cfgout file as the
+-n data.
 """
 def __init__(self, section, etype, node):
 super().__init__(section, etype, node)
 self._mkimage_entries = OrderedDict()
+self._imagename = None
 self.align_default = None
 
 def ReadNode(self):
@@ -82,6 +101,8 @@ class Entry_mkimage(Entry):
 self._args = fdt_util.GetArgs(self._node, 'args')
 self._data_to_imagename = fdt_util.GetBool(self._node,
'data-to-imagename')
+if self._data_to_imagename and self._node.FindNode('imagename'):
+self.Raise('Cannot use both imagename node and data-to-imagename')
 self.ReadEntries()
 
 def ReadEntries(self):
@@ -89,7 +110,10 @@ class Entry_mkimage(Entry):
 for node in self._node.subnodes:
 entry = Entry.Create(self, node)
 entry.ReadNode()
-self._mkimage_entries[entry.name] = entry
+if entry.name == 'imagename':
+self._imagename = entry
+else:
+self._mkimage_entries[entry.name] = entry
 
 def ObtainContents(self):
 # Use a non-zero size for any fake files to keep mkimage happy
@@ -98,11 +122,18 @@ class Entry_mkimage(Entry):
 self._mkimage_entries.values(), 'mkimage', 1024)
 if data is None:
 return False
+if self._imagename:
+image_data, imagename_fname, _ = self.collect_contents_to_file(
+[self._imagename], 'mkimage-n', 1024)
+if image_data is None:
+return False
 output_fname = tools.get_output_filename('mkimage-out.%s' % uniq)
 
 args = ['-d', input_fname]
 if self._data_to_imagename:
 args += ['-n', input_fname]
+elif self._imagename:
+args += ['-n', imagename_fname]
 args += self._args + [output_fname]
 if self.mkimage.run_cmd(*args) is not None:
 self.SetContents(tools.read_file(output_fname))
@@ -122,6 +153,8 @@ class Entry_mkimage(Entry):
 self.allow_missing = allow_missing
 for entry in self._mkimage_entries.values():
 entry.SetAllowMissing(allow_missing)
+if self._imagename:
+self._imagename.SetAllowMissing(allow_missing)
 
 def SetAllowFakeBlob(self, allow_fake):
 """Set whether the sub nodes allows to create a fake blob
@@ -131,6 +164,8 @@ class Entry_mkimage(Entry):
 """
 for entry in self._mkimage_entries.values():
 entry.SetAllowFakeBlob(allow_fake)
+if self._imagename:
+self._imagename.SetAllowFakeBlob(al

[PATCH 11/11] binman: Allow collection to use entries from other sections

2022-08-11 Thread Simon Glass
At present the collections etype only works with entries in the same
section. This can be limiting, since in some cases the data may be inside
a subsection, e.g. if there are alignment constraints.

Add a function to find the entries in an etype and have it search
recursively. Make use of this for mkimage also.

Signed-off-by: Simon Glass 
---

 tools/binman/entries.rst   |  3 +++
 tools/binman/entry.py  | 22 
 tools/binman/etype/collection.py   |  3 +++
 tools/binman/etype/mkimage.py  |  7 ++
 tools/binman/etype/section.py  |  8 +++---
 tools/binman/ftest.py  | 14 +++
 tools/binman/test/239_collection_other.dts | 29 ++
 7 files changed, 82 insertions(+), 4 deletions(-)
 create mode 100644 tools/binman/test/239_collection_other.dts

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 682159ac6d3..3fa027a241c 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -427,6 +427,9 @@ listed entries are combined to form this entry. This serves 
as a useful
 base class for entry types which need to process data from elsewhere in
 the image, not necessarily child entries.
 
+The entries can generally be anywhere in the same image, even if they are in
+a different section from this entry.
+
 
 
 Entry: cros-ec-rw: A blob entry which contains a Chromium OS read-write EC 
image
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 3be074ccd66..b9995254982 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -684,6 +684,28 @@ class Entry(object):
 """
 return None
 
+def FindEntryByNode(self, find_node):
+"""Find a node in an entry, searching all subentries
+
+This does a recursive search.
+
+Args:
+find_node (fdt.Node): Node to find
+
+Returns:
+Entry: entry, if found, else None
+"""
+entries = self.GetEntries()
+if entries:
+for entry in entries.values():
+if entry._node == find_node:
+return entry
+found = entry.FindEntryByNode(find_node)
+if found:
+return found
+
+return None
+
 def GetArg(self, name, datatype=str):
 """Get the value of an entry argument or device-tree-node property
 
diff --git a/tools/binman/etype/collection.py b/tools/binman/etype/collection.py
index 442b40b48b3..c532aafe3e7 100644
--- a/tools/binman/etype/collection.py
+++ b/tools/binman/etype/collection.py
@@ -21,6 +21,9 @@ class Entry_collection(Entry):
 listed entries are combined to form this entry. This serves as a useful
 base class for entry types which need to process data from elsewhere in
 the image, not necessarily child entries.
+
+The entries can generally be anywhere in the same image, even if they are 
in
+a different section from this entry.
 """
 def __init__(self, section, etype, node):
 super().__init__(section, etype, node)
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index dd82d51bdb6..36eef973f21 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -144,6 +144,13 @@ class Entry_mkimage(Entry):
 
 return True
 
+def GetEntries(self):
+# Make a copy so we don't change the original
+entries = OrderedDict(self._mkimage_entries)
+if self._imagename:
+entries['imagename'] = self._imagename
+return entries
+
 def SetAllowMissing(self, allow_missing):
 """Set whether a section allows missing external blobs
 
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index bd67238b919..5c326a75e8c 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -506,10 +506,10 @@ class Entry_section(Entry):
 node = self._node.GetFdt().LookupPhandle(phandle)
 if not node:
 source_entry.Raise("Cannot find node for phandle %d" % phandle)
-for entry in self._entries.values():
-if entry._node == node:
-return entry.GetData(required)
-source_entry.Raise("Cannot find entry for node '%s'" % node.name)
+entry = self.FindEntryByNode(node)
+if not entry:
+source_entry.Raise("Cannot find entry for node '%s'" % node.name)
+return entry.GetData(required)
 
 def LookupSymbol(self, sym_name, optional, msg, base_addr, entries=None):
 """Look up a symbol in an ELF file
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 9b10fd8698d..737dbcc2466 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -5773,6 +5773,20 @@ fdt fdtmapExtract the devicetree 
blob from the fdtmap
 self.assertIn('Cannot use both imagename node and data-to-imagename',
   str(exc.ex

[PATCH 08/11] binman: Improve mkimage documentation

2022-08-11 Thread Simon Glass
Expand this a little to make things clearer. Also drop the invalid
entry arg.

Signed-off-by: Simon Glass 
---

 tools/binman/entries.rst  | 28 +---
 tools/binman/etype/mkimage.py | 28 +---
 2 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index a77e61800dd..8d7cbdc2e75 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1100,11 +1100,10 @@ Entry: mkimage: Binary produced by mkimage
 --
 
 Properties / Entry arguments:
-- datafile: Filename for -d argument
-- args: Other arguments to pass
+- args: Arguments to pass
 
-The data passed to mkimage is collected from subnodes of the mkimage node,
-e.g.::
+The data passed to mkimage via the -d flag is collected from subnodes of the
+mkimage node, e.g.::
 
 mkimage {
 args = "-n test -T imximage";
@@ -1113,9 +1112,24 @@ e.g.::
 };
 };
 
-This calls mkimage to create an imximage with u-boot-spl.bin as the input
-file. The output from mkimage then becomes part of the image produced by
-binman.
+This calls mkimage to create an imximage with `u-boot-spl.bin` as the data
+file, which mkimage being called like this::
+
+mkimage -d  -n test -T imximage 
+
+The output from mkimage then becomes part of the image produced by
+binman. If you need to put mulitple things in the data file, you can use
+a section, or just multiple subnodes like this::
+
+mkimage {
+args = "-n test -T imximage";
+
+u-boot-spl {
+};
+
+u-boot-tpl {
+};
+};
 
 To use CONFIG options in the arguments, use a string list instead, as in
 this example which also produces four arguments::
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index f3b3df6fe04..28f7eb31343 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -15,11 +15,10 @@ class Entry_mkimage(Entry):
 """Binary produced by mkimage
 
 Properties / Entry arguments:
-- datafile: Filename for -d argument
-- args: Other arguments to pass
+- args: Arguments to pass
 
-The data passed to mkimage is collected from subnodes of the mkimage node,
-e.g.::
+The data passed to mkimage via the -d flag is collected from subnodes of 
the
+mkimage node, e.g.::
 
 mkimage {
 args = "-n test -T imximage";
@@ -28,9 +27,24 @@ class Entry_mkimage(Entry):
 };
 };
 
-This calls mkimage to create an imximage with u-boot-spl.bin as the input
-file. The output from mkimage then becomes part of the image produced by
-binman.
+This calls mkimage to create an imximage with `u-boot-spl.bin` as the data
+file, which mkimage being called like this::
+
+mkimage -d  -n test -T imximage 
+
+The output from mkimage then becomes part of the image produced by
+binman. If you need to put mulitple things in the data file, you can use
+a section, or just multiple subnodes like this::
+
+mkimage {
+args = "-n test -T imximage";
+
+u-boot-spl {
+};
+
+u-boot-tpl {
+};
+};
 
 To use CONFIG options in the arguments, use a string list instead, as in
 this example which also produces four arguments::
-- 
2.37.1.559.g78731f0fdb-goog



[PATCH 09/11] binman: Allow the image name to be the data file

2022-08-11 Thread Simon Glass
Some image types use the -n parameter to pass in the data file. Add
support for this, with a new property.

Signed-off-by: Simon Glass 
---

 tools/binman/entries.rst   | 15 +++
 tools/binman/etype/mkimage.py  | 26 --
 tools/binman/ftest.py  | 17 +
 tools/binman/test/235_mkimage_name.dts | 18 ++
 4 files changed, 74 insertions(+), 2 deletions(-)
 create mode 100644 tools/binman/test/235_mkimage_name.dts

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 8d7cbdc2e75..1d38c513ffa 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1101,6 +1101,8 @@ Entry: mkimage: Binary produced by mkimage
 
 Properties / Entry arguments:
 - args: Arguments to pass
+- data-to-imagename: Indicates that the -d data should be passed in as
+  the image name also (-n)
 
 The data passed to mkimage via the -d flag is collected from subnodes of the
 mkimage node, e.g.::
@@ -1141,6 +1143,19 @@ this example which also produces four arguments::
 };
 };
 
+If you need to pass the input data in with the -n argument as well, then use
+the 'data-to-imagename' property::
+
+mkimage {
+args = "-T imximage";
+data-to-imagename';
+
+u-boot-spl {
+};
+};
+
+That will pass the data to mkimage both as the data file (with -d) and as
+the image name (with -n).
 
 
 
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index 28f7eb31343..3295f451f79 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -16,6 +16,8 @@ class Entry_mkimage(Entry):
 
 Properties / Entry arguments:
 - args: Arguments to pass
+- data-to-imagename: Indicates that the -d data should be passed in as
+  the image name also (-n)
 
 The data passed to mkimage via the -d flag is collected from subnodes of 
the
 mkimage node, e.g.::
@@ -56,6 +58,19 @@ class Entry_mkimage(Entry):
 };
 };
 
+If you need to pass the input data in with the -n argument as well, then 
use
+the 'data-to-imagename' property::
+
+mkimage {
+args = "-T imximage";
+data-to-imagename';
+
+u-boot-spl {
+};
+};
+
+That will pass the data to mkimage both as the data file (with -d) and as
+the image name (with -n).
 """
 def __init__(self, section, etype, node):
 super().__init__(section, etype, node)
@@ -65,6 +80,8 @@ class Entry_mkimage(Entry):
 def ReadNode(self):
 super().ReadNode()
 self._args = fdt_util.GetArgs(self._node, 'args')
+self._data_to_imagename = fdt_util.GetBool(self._node,
+   'data-to-imagename')
 self.ReadEntries()
 
 def ReadEntries(self):
@@ -76,13 +93,18 @@ class Entry_mkimage(Entry):
 
 def ObtainContents(self):
 # Use a non-zero size for any fake files to keep mkimage happy
+# Note that testMkimageImagename() relies on this 'mkimage' parameter
 data, input_fname, uniq = self.collect_contents_to_file(
 self._mkimage_entries.values(), 'mkimage', 1024)
 if data is None:
 return False
 output_fname = tools.get_output_filename('mkimage-out.%s' % uniq)
-if self.mkimage.run_cmd('-d', input_fname, *self._args,
-output_fname) is not None:
+
+args = ['-d', input_fname]
+if self._data_to_imagename:
+args += ['-n', input_fname]
+args += self._args + [output_fname]
+if self.mkimage.run_cmd(*args) is not None:
 self.SetContents(tools.read_file(output_fname))
 else:
 # Bintool is missing; just use the input data as the output
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index ac54183c399..e88eedff51b 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -5722,6 +5722,23 @@ fdt fdtmapExtract the devicetree 
blob from the fdtmap
 "Node '/section': Replacing sections is not implemented yet",
 str(exc.exception))
 
+def testMkimageImagename(self):
+"""Test using mkimage with -n holding the data too"""
+data = self._DoReadFile('235_mkimage_name.dts')
+
+# Check that the data appears in the file somewhere
+self.assertIn(U_BOOT_SPL_DATA, data)
+
+# Get struct image_header -> ih_name
+name = data[0x20:0x40]
+
+# Build the filename that we expect to be placed in there, by virtue of
+# the -n paraameter
+expect = os.path.join(tools.get_output_dir(), 'mkimage.mkimage')
+
+# Check that the image name is set to the temporary filename used
+self.assertEqual(expect.encode('utf-8')[:0x20], name)
+
 
 if __name__ == "__main__":
 unittest.main()
diff --git a/tools/binman/test/235

[PATCH 07/11] binman: Avoid use of expected failure

2022-08-11 Thread Simon Glass
The testReplaceSectionSimple() test is the only one which expects failure.
It looks odd in the output and takes time to glance at it to see that all
is in fact well. Also it does not check that the right exception is
generated.

Use the more common (in binman) approach of checking for an exception.

Signed-off-by: Simon Glass 
---

 tools/binman/ftest.py | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 4f696c68600..ac54183c399 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -5712,14 +5712,15 @@ fdt fdtmapExtract the 
devicetree blob from the fdtmap
 self.assertIsNotNone(path)
 self.assertEqual(expected_fdtmap, fdtmap)
 
-@unittest.expectedFailure
 def testReplaceSectionSimple(self):
 """Test replacing a simple section with arbitrary data"""
 new_data = b'w' * len(COMPRESS_DATA + U_BOOT_DATA)
-data, expected_fdtmap, _ = self._RunReplaceCmd(
-'section', new_data,
-dts='234_replace_section_simple.dts')
-self.assertEqual(new_data, data)
+with self.assertRaises(ValueError) as exc:
+self._RunReplaceCmd('section', new_data,
+dts='234_replace_section_simple.dts')
+self.assertIn(
+"Node '/section': Replacing sections is not implemented yet",
+str(exc.exception))
 
 
 if __name__ == "__main__":
-- 
2.37.1.559.g78731f0fdb-goog



[PATCH 06/11] binman: Adjust mkimage etype node reading

2022-08-11 Thread Simon Glass
Since this is implemented as a section, it should really be split into
several functions, one to read the node and one to read the entries. Do
this so that it matches how Entry_section works.

Signed-off-by: Simon Glass 
---

 tools/binman/etype/mkimage.py | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index 5f6def2287f..f3b3df6fe04 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -45,11 +45,21 @@ class Entry_mkimage(Entry):
 """
 def __init__(self, section, etype, node):
 super().__init__(section, etype, node)
-self._args = fdt_util.GetArgs(self._node, 'args')
 self._mkimage_entries = OrderedDict()
 self.align_default = None
+
+def ReadNode(self):
+super().ReadNode()
+self._args = fdt_util.GetArgs(self._node, 'args')
 self.ReadEntries()
 
+def ReadEntries(self):
+"""Read the subnodes to find out what should go in this image"""
+for node in self._node.subnodes:
+entry = Entry.Create(self, node)
+entry.ReadNode()
+self._mkimage_entries[entry.name] = entry
+
 def ObtainContents(self):
 # Use a non-zero size for any fake files to keep mkimage happy
 data, input_fname, uniq = self.collect_contents_to_file(
@@ -67,13 +77,6 @@ class Entry_mkimage(Entry):
 
 return True
 
-def ReadEntries(self):
-"""Read the subnodes to find out what should go in this image"""
-for node in self._node.subnodes:
-entry = Entry.Create(self, node)
-entry.ReadNode()
-self._mkimage_entries[entry.name] = entry
-
 def SetAllowMissing(self, allow_missing):
 """Set whether a section allows missing external blobs
 
-- 
2.37.1.559.g78731f0fdb-goog



[PATCH 05/11] binman: Add a function to check for missing properties

2022-08-11 Thread Simon Glass
Add a new function to Entry to check for missing properties, since this
is likely to be come a common requirement.

Signed-off-by: Simon Glass 
---

 tools/binman/entry.py  | 16 
 tools/binman/etype/fill.py |  3 +--
 tools/binman/ftest.py  |  2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 41f0eb58ae0..3be074ccd66 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -1179,3 +1179,19 @@ features to produce new behaviours.
 if not os.path.exists(cls.fake_dir):
 os.mkdir(cls.fake_dir)
 tout.notice(f"Fake-blob dir is '{cls.fake_dir}'")
+
+def ensure_props(self, prop_list):
+"""Raise an exception if properties are missing
+
+Args:
+prop_list (list of str): List of properties to check for
+
+Raises:
+ValueError: Any property is missing
+"""
+not_present = []
+for prop in prop_list:
+if not prop in self._node.props:
+not_present.append(prop)
+if not_present:
+self.Raise(f"'{self.etype}' entry is missing properties: {' 
'.join(not_present)}")
diff --git a/tools/binman/etype/fill.py b/tools/binman/etype/fill.py
index cd382799199..0b068ba3268 100644
--- a/tools/binman/etype/fill.py
+++ b/tools/binman/etype/fill.py
@@ -26,8 +26,7 @@ class Entry_fill(Entry):
 
 def ReadNode(self):
 super().ReadNode()
-if self.size is None:
-self.Raise("'fill' entry must have a size property")
+self.ensure_props(['size'])
 self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0)
 
 def ObtainContents(self):
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index c8bab5c9416..4f696c68600 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -1693,7 +1693,7 @@ class TestFunctional(unittest.TestCase):
 """Test for an fill entry type with no size"""
 with self.assertRaises(ValueError) as e:
 self._DoReadFile('070_fill_no_size.dts')
-self.assertIn("'fill' entry must have a size property",
+self.assertIn("'fill' entry is missing properties: size",
   str(e.exception))
 
 def _HandleGbbCommand(self, pipe_list):
-- 
2.37.1.559.g78731f0fdb-goog



[PATCH 04/11] binman: Fix up the entry-docs for Entry_pre_load

2022-08-11 Thread Simon Glass
This has got out of sync and needs a line wrap. Fix it.

Signed-off-by: Simon Glass 
---

 tools/binman/entries.rst   | 3 ++-
 tools/binman/etype/pre_load.py | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index ae4305c99e4..a77e61800dd 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1159,7 +1159,8 @@ Entry: pre-load: Pre load image header
 --
 
 Properties / Entry arguments:
-- key-path: Path of the directory that store key (provided by the 
environment variable KEY_PATH)
+- pre-load-key-path: Path of the directory that store key (provided by
+  the environment variable PRE_LOAD_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)
diff --git a/tools/binman/etype/pre_load.py b/tools/binman/etype/pre_load.py
index 245ee755259..b6222811592 100644
--- a/tools/binman/etype/pre_load.py
+++ b/tools/binman/etype/pre_load.py
@@ -37,7 +37,8 @@ class Entry_pre_load(Entry_collection):
 """Pre load image header
 
 Properties / Entry arguments:
-- pre-load-key-path: Path of the directory that store key (provided by 
the environment variable PRE_LOAD_KEY_PATH)
+- pre-load-key-path: Path of the directory that store key (provided by
+  the environment variable PRE_LOAD_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)
-- 
2.37.1.559.g78731f0fdb-goog



  1   2   >