Re: [PATCH 2/2] ARM: dts: uniphier: Sync DT with Linux v6.2

2023-02-27 Thread Marek Vasut

On 2/28/23 03:37, Kunihiko Hayashi wrote:

Synchronize devicetree sources with Linux v6.2.

- Use GIC interrupt definitions
- Add reg properties in USB-glue and SoC-glue node
- Fix node names to follow the generic names list in DT specification
- Add L2 cache and AHCI nodes
- Update nand and pcie nodes
- And some trivial fixes

Signed-off-by: Kunihiko Hayashi 


Acked-by: Marek Vasut 


Re: [PATCH 1/2] ARM: dts: uniphier: Switch USB node to the original

2023-02-27 Thread Marek Vasut

On 2/28/23 03:37, Kunihiko Hayashi wrote:

UniPhier DT applies its own USB node for U-Boot due to the USB driver
constrains. After solving this issue, u-boot allows the original USB node.

After switching USB node, synchronization of USB node with Linux becomes
possible.

Signed-off-by: Kunihiko Hayashi 


Very nice

Acked-by: Marek Vasut 


Re: [PATCH RFC u-boot-mvebu 00/59] arm: mvebu: Various fixes

2023-02-27 Thread Stefan Roese

Hi Martin,
Hi Pali,

On 2/27/23 12:29, Martin Rowe wrote:
On Mon, 27 Feb 2023 at 08:04, Pali Rohár > wrote:


On Monday 27 February 2023 08:44:30 Stefan Roese wrote:
 > Hi Pali,
 >
 > On 2/25/23 23:00, Pali Rohár wrote:
 > > On Tuesday 21 February 2023 21:18:26 Pali Rohár wrote:
 > > > This patch series contains various improvements and fixes for
existing
 > > > logical errors. Boot phase was adjusted to match behavior of
Armada 385
 > > > BootROM by inspecting and disassembling of BootROM binary
dump itself.
 > > > Important information are included in documentation patch for
kwboot.
 > > > Most of the changes are untested, hence this patch series is
just RFC.
 > > > So please test changes before applying, idealy on SPI, SATA
and SD/MMC.
 > > > Nevertheless all patches on github passed CI testing in this PR:
 > > > https://github.com/u-boot/u-boot/pull/275

 > >
 > > Patches were tested on more boards and seems there is no
reported issue,
 > > but other improvements.
 > >
 > > So do you need something to modify in this relatively big patch
series?
 > > If it is not really needed I would like to not send it again
because
 > > denx servers are not able to handle it. And it take me lot of
time to
 > > send patches over emails to denx servers.
 >
 > I'm fine with applying the series as-is. I'm a bit hesitant
though, if
 > it should be applied to master or to next. As Tom clearly
noticed, that
 > only fixes should be added after rc2 this time.
 >
 > What is your thinking on this?

Well, I do not know. AFAIK more patches here are fixing broken mvebu
boards (e.g. eMMC or SATA parts). Maybe Martin or Josua could comment?


A388 Clearfog was definitely broken prior to this patchset. There is 
quite a bit of churn that this has caused for some OpenWRT users [1] as 
well as for me. It would be nice to have a stable build for these boards.


[1] https://github.com/openwrt/openwrt/issues/11661 



Okay. Thanks for the explanation. So it makes sense to pull this
patchset at this stage IMHO.

BUT: While trying to apply the patches sent to me directly this fails at
this patch:

tools: kwbimage: Add support for XIP SPI/NOR images

I tried to fix this merge problem manually, but this looks a bit bogus.
That's why I followed your instruction to pull the patches directly from
github:

git fetch https://github.com/u-boot/u-boot.git refs/pull/275/merge:mvebu

This works and all patches apply clean. But looking into the patches I
noticed, that these patches from github do not include all patches
sent to the list. refs/pull/275/merge:mvebu stops after

tools: mkimage: Do not fill legacy_img_hdr for non-legacy XIP images

This is the patch directly before the failing patch mentioned above.

Pali, could you please explain what went wrong here? Maybe I'm missing
something?

Thanks,
Stefan



 > Thanks,
 > Stefan
 >
 > >
 > > >
 > > > Pali Rohár (59):
 > > >    tools: kwbimage: Fix generating, verifying and extracting SDIO
 > > >      kwbimage
 > > >    tools: kwboot: Fix parsing SDIO kwbimage
 > > >    arm: mvebu: spl: Fix parsing SDIO kwbimage
 > > >    cmd: mvebu/bubt: Fix parsing SDIO kwbimage
 > > >    tools: kwbimage: Fix generating, verifying and extracting SATA
 > > >      kwbimage
 > > >    tools: kwboot: Fix parsing SATA kwbimage
 > > >    arm: mvebu: spl: Fix parsing SATA kwbimage
 > > >    cmd: mvebu/bubt: Fix parsing SATA kwbimage
 > > >    arm: mvebu: spl: Remove checks for BOOT_DEVICE_MMC2 and
 > > >      BOOT_DEVICE_MMC2_2
 > > >    arm: mvebu: spl: Load proper U-Boot from selected eMMC
boot partition
 > > >    spl: mmc: Allow to disable SYS_MMCSD_FS_BOOT_PARTITION
 > > >    arm: mvebu: spl: Fix support for loading U-Boot proper
from SD card
 > > >    tools: kwboot: Add more documentation references
 > > >    tools: kwboot: Add image type documentation
 > > >    tools: kwboot: Fix parsing UART image without data checksum
 > > >    tools: kwboot: Validate optional kwbimage v1 headers
 > > >    tools: kwboot: Add check that kwbimage contains DDR init code
 > > >    tools: kwboot: Fix patching of SPI/NOR XIP images
 > > >    tools: kwboot: Show image type and error parsing reasons
 > > >    cmd: mvebu/bubt: Add support for selecting eMMC HW partition
 > > >    cmd: mvebu/bubt: Add support for writing image to SATA disk
 > > >    cmd: mvebu/bubt: Add support for reading image from the
SATA disk
 > > >      partition
 > > >    cmd: mvebu/bubt: Rename variable image_size to hdr_size
 > > >    cmd: mvebu/bubt: Mark all local symbols as static
 > > >    cmd: mvebu/bubt: Do not modify image in A8K

[PATCH 4/4] ARM: rmobile: Split R-Car Gen3 into separate Kconfig from common 64bit options

2023-02-27 Thread Marek Vasut
There are multiple shared Kconfig options between R-Car Gen3 and Gen4.
Keep the common options in Kconfig.64 and move the R-Car Gen3 specific
options into separate Kconfig.rcar3 . The Kconfig.rcar3 contains SoC
and board list, which is limited to R-Car Gen3.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/Kconfig.64| 206 +---
 arch/arm/mach-rmobile/Kconfig.rcar3 | 201 +++
 2 files changed, 206 insertions(+), 201 deletions(-)
 create mode 100644 arch/arm/mach-rmobile/Kconfig.rcar3

diff --git a/arch/arm/mach-rmobile/Kconfig.64 b/arch/arm/mach-rmobile/Kconfig.64
index 3ed5099c36e..3b14721dab5 100644
--- a/arch/arm/mach-rmobile/Kconfig.64
+++ b/arch/arm/mach-rmobile/Kconfig.64
@@ -1,207 +1,11 @@
-if RCAR_GEN3
-
-menu "Select Target SoC"
-
-config R8A774A1
-   bool "Renesas SoC R8A774A1"
-   select GICV2
-   imply CLK_R8A774A1
-   imply PINCTRL_PFC_R8A774A1
-
-config R8A774B1
-   bool "Renesas SoC R8A774B1"
-   select GICV2
-   imply CLK_R8A774B1
-   imply PINCTRL_PFC_R8A774B1
-
-config R8A774C0
-   bool "Renesas SoC R8A774C0"
-   select GICV2
-   imply CLK_R8A774C0
-   imply PINCTRL_PFC_R8A774C0
-
-config R8A774E1
-   bool "Renesas SoC R8A774E1"
-   select GICV2
-   imply CLK_R8A774E1
-   imply PINCTRL_PFC_R8A774E1
-
-config R8A7795
-   bool "Renesas SoC R8A7795"
-   select GICV2
-   imply CLK_R8A7795
-   imply PINCTRL_PFC_R8A77951
-
-config R8A7796
-   bool "Renesas SoC R8A7796"
-   select GICV2
-   imply CLK_R8A77960
-   imply CLK_R8A77961
-   imply PINCTRL_PFC_R8A77960
-   imply PINCTRL_PFC_R8A77961
-
-config R8A77965
-   bool "Renesas SoC R8A77965"
-   select GICV2
-   imply CLK_R8A77965
-   imply PINCTRL_PFC_R8A77965
-
-config R8A77970
-   bool "Renesas SoC R8A77970"
-   select GICV2
-   imply CLK_R8A77970
-   imply PINCTRL_PFC_R8A77970
-
-config R8A77980
-   bool "Renesas SoC R8A77980"
-   select GICV2
-   imply CLK_R8A77980
-   imply PINCTRL_PFC_R8A77980
-
-config R8A77990
-   bool "Renesas SoC R8A77990"
-   select GICV2
-   imply CLK_R8A77990
-   imply PINCTRL_PFC_R8A77990
-
-config R8A77995
-   bool "Renesas SoC R8A77995"
-   select GICV2
-   imply CLK_R8A77995
-   imply PINCTRL_PFC_R8A77995
-
-config R8A779A0
-   bool "Renesas SoC R8A779A0"
-   select GICV3
-   imply CLK_R8A779A0
-   imply PINCTRL_PFC_R8A779A0
-
-config RZ_G2
-   bool "Renesas ARM SoCs RZ/G2 (64bit)"
-
-endmenu
-
-choice
-   prompt "Renesas ARM64 SoCs board select"
-   optional
-
-config TARGET_BEACON_RZG2M
-   bool "Beacon EmbeddedWorks RZ/G2 Dev Kit"
-   select PINCTRL_PFC_R8A774A1
-   select PINCTRL_PFC_R8A774B1
-   select PINCTRL_PFC_R8A774E1
-   select R8A774A1
-   select R8A774B1
-   select R8A774E1
-   select RZ_G2
-   imply CLK_CCF
-   imply CLK_VERSACLOCK
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
-
-config TARGET_CONDOR
-   bool "Condor board"
-   imply R8A77980
-   help
-  Support for Renesas R-Car Gen3 Condor platform
-
-config TARGET_DRAAK
-   bool "Draak board"
-   imply R8A77995
-   help
-  Support for Renesas R-Car Gen3 Draak platform
-
-config TARGET_EAGLE
-   bool "Eagle board"
-   imply R8A77970
-   help
-  Support for Renesas R-Car Gen3 Eagle platform
-
-config TARGET_EBISU
-   bool "Ebisu board"
-   imply R8A77990
-   help
-  Support for Renesas R-Car Gen3 Ebisu platform
-
-config TARGET_FALCON
-   bool "Falcon board"
-   imply R8A779A0
-   help
-  Support for Renesas R-Car Gen3 Falcon platform
-
-config TARGET_HIHOPE_RZG2
-   bool "HiHope RZ/G2 board"
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
-   imply R8A774A1
-   imply R8A774B1
-   imply R8A774E1
-   imply RZ_G2
-   imply SYS_MALLOC_F
-   help
-  Support for RZG2 HiHope platform
-
-config TARGET_SILINUX_EK874
-   bool "Silicon Linux EK874 board"
-   imply R8A774C0
-   imply RZ_G2
-   help
-  Support for Silicon Linux EK874 platform
-
-config TARGET_SALVATOR_X
-   bool "Salvator-X board"
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
-   imply R8A7795
-   imply R8A7796
-   imply R8A77965
-   imply SYS_MALLOC_F
-   help
-  Support for Renesas R-Car Gen3 platform
-
-config TARGET_ULCB
-   bool "ULCB board"
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
-   imply R8A7795
-   imply R8A7796
-   imply R8A77965
-   imply SYS_MALLOC_F
-   help
-  Support for Renesas R-Car Gen3 ULCB platform
-
-endchoice
-
-source "board/renesas/condor/Kconfig"
-source "board/renesas/draak/Kconfig"
-source "board/renesas/eagle/Kconfig"
-source "

[PATCH 3/4] ARM: rmobile: Introduce CONFIG_RCAR_64 symbol

2023-02-27 Thread Marek Vasut
Introduce common Kconfig symbol for 64bit R-Car platforms and move
common configuration options into it. This is preparatory patch to
prevent duplication of Kconfig lists later on, when Gen4 is added.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/Kconfig | 29 +
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-rmobile/Kconfig b/arch/arm/mach-rmobile/Kconfig
index b69ccaee0a0..921153a8d9e 100644
--- a/arch/arm/mach-rmobile/Kconfig
+++ b/arch/arm/mach-rmobile/Kconfig
@@ -1,15 +1,8 @@
 if ARCH_RMOBILE
 
-choice
-   prompt "Target Renesas SoC select"
-   default RCAR_32
-
-config RCAR_32
-   bool "Renesas ARM SoCs R-Car Gen1/Gen2 (32bit)"
-   select CPU_V7A
-
-config RCAR_GEN3
-   bool "Renesas ARM SoCs R-Car Gen3 (64bit)"
+# Renesas ARM SoCs R-Car Gen3/Gen4 (64bit)
+config RCAR_64
+   bool
select ARM64
select CMD_CACHE
select OF_BOARD_SETUP
@@ -18,11 +11,24 @@ config RCAR_GEN3
select PINCTRL
select PINCTRL_PFC
select POSITION_INDEPENDENT
-   select SUPPORT_SPL
imply CMD_FS_UUID
imply CMD_GPT
imply CMD_MMC_SWRITE if MMC
imply CMD_UUID
+   imply SUPPORT_EMMC_RPMB if MMC
+
+choice
+   prompt "Target Renesas SoC select"
+   default RCAR_32
+
+config RCAR_32
+   bool "Renesas ARM SoCs R-Car Gen1/Gen2 (32bit)"
+   select CPU_V7A
+
+config RCAR_GEN3
+   bool "Renesas ARM SoCs R-Car Gen3 (64bit)"
+   select RCAR_64
+   select SUPPORT_SPL
imply SPL
imply SPL_BOARD_INIT
imply SPL_GZIP
@@ -33,7 +39,6 @@ config RCAR_GEN3
imply SPL_TINY_MEMSET
imply SPL_USE_TINY_PRINTF
imply SPL_YMODEM_SUPPORT
-   imply SUPPORT_EMMC_RPMB if MMC
 
 config RZA1
prompt "Renesas ARM SoCs RZ/A1 (32bit)"
-- 
2.39.2



[PATCH 2/4] ARM: rmobile: Factor out SYS_SOC Kconfig option

2023-02-27 Thread Marek Vasut
Pull the SYS_SOC Kconfig option to avoid duplication of this option
in Kconfig.{32,64,rza1} . The default value is the same, so just set
it in one location.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/Kconfig  | 3 +++
 arch/arm/mach-rmobile/Kconfig.32   | 3 ---
 arch/arm/mach-rmobile/Kconfig.64   | 3 ---
 arch/arm/mach-rmobile/Kconfig.rza1 | 3 ---
 4 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-rmobile/Kconfig b/arch/arm/mach-rmobile/Kconfig
index 9ff45f46313..b69ccaee0a0 100644
--- a/arch/arm/mach-rmobile/Kconfig
+++ b/arch/arm/mach-rmobile/Kconfig
@@ -41,6 +41,9 @@ config RZA1
 
 endchoice
 
+config SYS_SOC
+   default "rmobile" if ARCH_RMOBILE
+
 source "arch/arm/mach-rmobile/Kconfig.32"
 source "arch/arm/mach-rmobile/Kconfig.64"
 source "arch/arm/mach-rmobile/Kconfig.rza1"
diff --git a/arch/arm/mach-rmobile/Kconfig.32 b/arch/arm/mach-rmobile/Kconfig.32
index 31badc5a47d..1ac31c29d82 100644
--- a/arch/arm/mach-rmobile/Kconfig.32
+++ b/arch/arm/mach-rmobile/Kconfig.32
@@ -125,9 +125,6 @@ endchoice
 config TMU_TIMER
bool
 
-config SYS_SOC
-   default "rmobile"
-
 config RMOBILE_EXTRAM_BOOT
bool "Enable boot from RAM"
depends on TARGET_ALT || TARGET_BLANCHE || TARGET_KOELSCH || 
TARGET_LAGER || TARGET_PORTER || TARGET_SILK || TARGET_STOUT
diff --git a/arch/arm/mach-rmobile/Kconfig.64 b/arch/arm/mach-rmobile/Kconfig.64
index 33fd776f8af..3ed5099c36e 100644
--- a/arch/arm/mach-rmobile/Kconfig.64
+++ b/arch/arm/mach-rmobile/Kconfig.64
@@ -172,9 +172,6 @@ config TARGET_ULCB
 
 endchoice
 
-config SYS_SOC
-   default "rmobile"
-
 source "board/renesas/condor/Kconfig"
 source "board/renesas/draak/Kconfig"
 source "board/renesas/eagle/Kconfig"
diff --git a/arch/arm/mach-rmobile/Kconfig.rza1 
b/arch/arm/mach-rmobile/Kconfig.rza1
index 8cf033fb13c..e88f9a2eedb 100644
--- a/arch/arm/mach-rmobile/Kconfig.rza1
+++ b/arch/arm/mach-rmobile/Kconfig.rza1
@@ -19,9 +19,6 @@ config TARGET_GRPEACH
 
 endchoice
 
-config SYS_SOC
-   default "rmobile"
-
 # Renesas Supported Boards
 source "board/renesas/grpeach/Kconfig"
 
-- 
2.39.2



[PATCH 1/4] ARM: rmobile: Sort R-Car Gen3 Kconfig lists

2023-02-27 Thread Marek Vasut
Sort the 'imply' and 'select' lists in R-Car Gen3 Kconfig options.
No functional change.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/Kconfig| 10 +-
 arch/arm/mach-rmobile/Kconfig.64 | 22 +++---
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-rmobile/Kconfig b/arch/arm/mach-rmobile/Kconfig
index 0e9c0fa9962..9ff45f46313 100644
--- a/arch/arm/mach-rmobile/Kconfig
+++ b/arch/arm/mach-rmobile/Kconfig
@@ -11,19 +11,18 @@ config RCAR_32
 config RCAR_GEN3
bool "Renesas ARM SoCs R-Car Gen3 (64bit)"
select ARM64
-   select PHY
select CMD_CACHE
select OF_BOARD_SETUP
-   select PINCTRL
+   select PHY
select PINCONF
+   select PINCTRL
select PINCTRL_PFC
select POSITION_INDEPENDENT
select SUPPORT_SPL
imply CMD_FS_UUID
imply CMD_GPT
-   imply CMD_UUID
imply CMD_MMC_SWRITE if MMC
-   imply SUPPORT_EMMC_RPMB if MMC
+   imply CMD_UUID
imply SPL
imply SPL_BOARD_INIT
imply SPL_GZIP
@@ -32,8 +31,9 @@ config RCAR_GEN3
imply SPL_SERIAL
imply SPL_SYS_MALLOC_SIMPLE
imply SPL_TINY_MEMSET
-   imply SPL_YMODEM_SUPPORT
imply SPL_USE_TINY_PRINTF
+   imply SPL_YMODEM_SUPPORT
+   imply SUPPORT_EMMC_RPMB if MMC
 
 config RZA1
prompt "Renesas ARM SoCs RZ/A1 (32bit)"
diff --git a/arch/arm/mach-rmobile/Kconfig.64 b/arch/arm/mach-rmobile/Kconfig.64
index 554130b435b..33fd776f8af 100644
--- a/arch/arm/mach-rmobile/Kconfig.64
+++ b/arch/arm/mach-rmobile/Kconfig.64
@@ -87,17 +87,17 @@ choice
 
 config TARGET_BEACON_RZG2M
bool "Beacon EmbeddedWorks RZ/G2 Dev Kit"
+   select PINCTRL_PFC_R8A774A1
+   select PINCTRL_PFC_R8A774B1
+   select PINCTRL_PFC_R8A774E1
select R8A774A1
select R8A774B1
select R8A774E1
select RZ_G2
-   select PINCTRL_PFC_R8A774A1
-   select PINCTRL_PFC_R8A774B1
-   select PINCTRL_PFC_R8A774E1
+   imply CLK_CCF
+   imply CLK_VERSACLOCK
imply MULTI_DTB_FIT
imply MULTI_DTB_FIT_USER_DEFINED_AREA
-   imply CLK_VERSACLOCK
-   imply CLK_CCF
 
 config TARGET_CONDOR
bool "Condor board"
@@ -131,13 +131,13 @@ config TARGET_FALCON
 
 config TARGET_HIHOPE_RZG2
bool "HiHope RZ/G2 board"
+   imply MULTI_DTB_FIT
+   imply MULTI_DTB_FIT_USER_DEFINED_AREA
imply R8A774A1
imply R8A774B1
imply R8A774E1
imply RZ_G2
imply SYS_MALLOC_F
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
help
   Support for RZG2 HiHope platform
 
@@ -150,23 +150,23 @@ config TARGET_SILINUX_EK874
 
 config TARGET_SALVATOR_X
bool "Salvator-X board"
+   imply MULTI_DTB_FIT
+   imply MULTI_DTB_FIT_USER_DEFINED_AREA
imply R8A7795
imply R8A7796
imply R8A77965
imply SYS_MALLOC_F
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
help
   Support for Renesas R-Car Gen3 platform
 
 config TARGET_ULCB
bool "ULCB board"
+   imply MULTI_DTB_FIT
+   imply MULTI_DTB_FIT_USER_DEFINED_AREA
imply R8A7795
imply R8A7796
imply R8A77965
imply SYS_MALLOC_F
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
help
   Support for Renesas R-Car Gen3 ULCB platform
 
-- 
2.39.2



[PATCH] ARM: rmobile: Convert ifdef in rmobile_get_prr() to IS_ENABLED()

2023-02-27 Thread Marek Vasut
Switch ifdef in rmobile_get_prr() to IS_ENABLED() macro.
The CONFIG_RCAR_GEN3 will never have SPL counterpart, so
the IS_ENABLED() macro is the right one here. No functional
change, except for improved build test coverage.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/cpu_info-rcar.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-rmobile/cpu_info-rcar.c 
b/arch/arm/mach-rmobile/cpu_info-rcar.c
index 5bde24ae0e7..ac9c623eda7 100644
--- a/arch/arm/mach-rmobile/cpu_info-rcar.c
+++ b/arch/arm/mach-rmobile/cpu_info-rcar.c
@@ -14,11 +14,10 @@
 
 static u32 rmobile_get_prr(void)
 {
-#ifdef CONFIG_RCAR_GEN3
-   return readl(0xFFF00044);
-#else
+   if (IS_ENABLED(CONFIG_RCAR_GEN3))
+   return readl(0xFFF00044);
+
return readl(0xFF44);
-#endif
 }
 
 u32 rmobile_get_cpu_type(void)
-- 
2.39.2



[PATCH 2/2] pinctrl: renesas: Drop non-existent PFC info table entries

2023-02-27 Thread Marek Vasut
Remove PFC info table entries which are never instantiated,
since there are no drivers for those. No functional change.

Signed-off-by: Marek Vasut 
---
 drivers/pinctrl/renesas/sh_pfc.h | 15 ---
 1 file changed, 15 deletions(-)

diff --git a/drivers/pinctrl/renesas/sh_pfc.h b/drivers/pinctrl/renesas/sh_pfc.h
index 59d447ead5c..0ab743e80d5 100644
--- a/drivers/pinctrl/renesas/sh_pfc.h
+++ b/drivers/pinctrl/renesas/sh_pfc.h
@@ -309,21 +309,6 @@ extern const struct sh_pfc_soc_info r8a77980_pinmux_info;
 extern const struct sh_pfc_soc_info r8a77990_pinmux_info;
 extern const struct sh_pfc_soc_info r8a77995_pinmux_info;
 extern const struct sh_pfc_soc_info r8a779a0_pinmux_info;
-extern const struct sh_pfc_soc_info r8a779f0_pinmux_info;
-extern const struct sh_pfc_soc_info r8a779g0_pinmux_info;
-extern const struct sh_pfc_soc_info sh7203_pinmux_info;
-extern const struct sh_pfc_soc_info sh7264_pinmux_info;
-extern const struct sh_pfc_soc_info sh7269_pinmux_info;
-extern const struct sh_pfc_soc_info sh73a0_pinmux_info;
-extern const struct sh_pfc_soc_info sh7720_pinmux_info;
-extern const struct sh_pfc_soc_info sh7722_pinmux_info;
-extern const struct sh_pfc_soc_info sh7723_pinmux_info;
-extern const struct sh_pfc_soc_info sh7724_pinmux_info;
-extern const struct sh_pfc_soc_info sh7734_pinmux_info;
-extern const struct sh_pfc_soc_info sh7757_pinmux_info;
-extern const struct sh_pfc_soc_info sh7785_pinmux_info;
-extern const struct sh_pfc_soc_info sh7786_pinmux_info;
-extern const struct sh_pfc_soc_info shx3_pinmux_info;
 
 /* 
-
  * Helper macros to create pin and port lists
-- 
2.39.2



[PATCH 1/2] pinctrl: renesas: Replace ifdeffery with IS_ENABLED()

2023-02-27 Thread Marek Vasut
Switch ifdef in sh_gpio_get_value() to IS_ENABLED() macro.
The CONFIG_RCAR_GEN3 will never have SPL counterpart, so
the IS_ENABLED() macro is the right one here. No functional
change, except for improved build test coverage.

Signed-off-by: Marek Vasut 
---
 drivers/gpio/sh_pfc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/sh_pfc.c b/drivers/gpio/sh_pfc.c
index 988f7e9bbad..92522b63bbe 100644
--- a/drivers/gpio/sh_pfc.c
+++ b/drivers/gpio/sh_pfc.c
@@ -568,10 +568,10 @@ static int sh_gpio_get_value(struct pinmux_info *gpioc, 
unsigned gpio)
 
if (!gpioc || get_data_reg(gpioc, gpio, &dr, &bit) != 0)
return -1;
-#if defined(CONFIG_RCAR_GEN3)
-   if ((gpioc->gpios[gpio].flags & PINMUX_FLAG_TYPE) == PINMUX_TYPE_INPUT)
+
+   if (IS_ENABLED(CONFIG_RCAR_GEN3) &&
+   ((gpioc->gpios[gpio].flags & PINMUX_FLAG_TYPE) == 
PINMUX_TYPE_INPUT))
offset += 4;
-#endif
 
return gpio_read_bit(dr, offset, bit);
 }
-- 
2.39.2



[PATCH] clk: renesas: rcar-gen3: Replace SSCG caching with MDSEL/PE caching

2023-02-27 Thread Marek Vasut
Do not cache the single CPG MODE register bit 12, instead cache the
entire register value, and only pick the matching bit from the cached
value when core clock of type MDSEL or PE are used. Both MDSEL and PE
clock type currently define .offset field as 12 on Gen3, which means
this code will use bit 12 on Gen3 again, however there are additional
clock on Gen4 which use different bits, and having this flexibility
in place now will be useful when adding Gen4.

No functional change.

Signed-off-by: Marek Vasut 
---
 drivers/clk/renesas/clk-rcar-gen3.c | 18 +-
 drivers/clk/renesas/rcar-gen3-cpg.h |  2 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/renesas/clk-rcar-gen3.c 
b/drivers/clk/renesas/clk-rcar-gen3.c
index d778db6569d..9545e0a1435 100644
--- a/drivers/clk/renesas/clk-rcar-gen3.c
+++ b/drivers/clk/renesas/clk-rcar-gen3.c
@@ -55,6 +55,7 @@ static int gen3_clk_get_parent(struct gen3_clk_priv *priv, 
struct clk *clk,
   struct cpg_mssr_info *info, struct clk *parent)
 {
const struct cpg_core_clk *core;
+   u8 shift;
int ret;
 
if (!renesas_clk_is_mod(clk)) {
@@ -63,8 +64,9 @@ static int gen3_clk_get_parent(struct gen3_clk_priv *priv, 
struct clk *clk,
return ret;
 
if (core->type == CLK_TYPE_GEN3_MDSEL) {
+   shift = priv->cpg_mode & BIT(core->offset) ? 16 : 0;
parent->dev = clk->dev;
-   parent->id = core->parent >> (priv->sscg ? 16 : 0);
+   parent->id = core->parent >> shift;
parent->id &= 0x;
return 0;
}
@@ -183,6 +185,7 @@ static u64 gen3_clk_get_rate64(struct clk *clk)
priv->cpg_pll_config;
u32 value, div;
u64 rate = 0;
+   u8 shift;
int ret;
 
debug("%s[%i] Clock: id=%lu\n", __func__, __LINE__, clk->id);
@@ -277,11 +280,11 @@ static u64 gen3_clk_get_rate64(struct clk *clk)
"FIXED");
 
case CLK_TYPE_GEN3_MDSEL:
-   div = (core->div >> (priv->sscg ? 16 : 0)) & 0x;
+   shift = priv->cpg_mode & BIT(core->offset) ? 16 : 0;
+   div = (core->div >> shift) & 0x;
rate = gen3_clk_get_rate64(&parent) / div;
debug("%s[%i] PE clk: parent=%i div=%u => rate=%llu\n",
- __func__, __LINE__,
- (core->parent >> (priv->sscg ? 16 : 0)) & 0x,
+ __func__, __LINE__, (core->parent >> shift) & 0x,
  div, rate);
return rate;
 
@@ -407,7 +410,6 @@ static int gen3_clk_probe(struct udevice *dev)
struct cpg_mssr_info *info =
(struct cpg_mssr_info *)dev_get_driver_data(dev);
fdt_addr_t rst_base;
-   u32 cpg_mode;
int ret;
 
priv->base = dev_read_addr_ptr(dev);
@@ -423,15 +425,13 @@ static int gen3_clk_probe(struct udevice *dev)
if (rst_base == FDT_ADDR_T_NONE)
return -EINVAL;
 
-   cpg_mode = readl(rst_base + info->reset_modemr_offset);
+   priv->cpg_mode = readl(rst_base + info->reset_modemr_offset);
 
priv->cpg_pll_config =
-   (struct rcar_gen3_cpg_pll_config 
*)info->get_pll_config(cpg_mode);
+   (struct rcar_gen3_cpg_pll_config 
*)info->get_pll_config(priv->cpg_mode);
if (!priv->cpg_pll_config->extal_div)
return -EINVAL;
 
-   priv->sscg = !(cpg_mode & BIT(12));
-
if (info->reg_layout == CLK_REG_LAYOUT_RCAR_GEN2_AND_GEN3) {
priv->info->status_regs = mstpsr;
priv->info->control_regs = smstpcr;
diff --git a/drivers/clk/renesas/rcar-gen3-cpg.h 
b/drivers/clk/renesas/rcar-gen3-cpg.h
index 200e4adb906..894e3765495 100644
--- a/drivers/clk/renesas/rcar-gen3-cpg.h
+++ b/drivers/clk/renesas/rcar-gen3-cpg.h
@@ -132,7 +132,7 @@ struct gen3_clk_priv {
struct cpg_mssr_info*info;
struct clk  clk_extal;
struct clk  clk_extalr;
-   boolsscg;
+   u32 cpg_mode;
const struct rcar_gen3_cpg_pll_config *cpg_pll_config;
 };
 
-- 
2.39.2



[PATCH] mmc: tmio: Replace ifdeffery with IS_ENABLED/CONFIG_IS_ENABLED macros

2023-02-27 Thread Marek Vasut
Instead of #if and #ifdef, use IS_ENABLED and CONFIG_IS_ENABLED macros.
This improves build test coverage. The CONFIG_SPL_BUILD must remain an
ifdef, as CONFIG_SPL_STACK may not always be defined, e.g. in U-Boot
proper build. No functional change.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
---
 drivers/mmc/tmio-common.c | 59 +++
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
index e9c7d3a2e00..81bc6083dea 100644
--- a/drivers/mmc/tmio-common.c
+++ b/drivers/mmc/tmio-common.c
@@ -369,22 +369,23 @@ static bool tmio_sd_addr_is_dmaable(struct mmc_data *data)
if (!IS_ALIGNED(addr, TMIO_SD_DMA_MINALIGN))
return false;
 
-#if defined(CONFIG_RCAR_GEN3)
-   if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
-   return false;
-   /* Gen3 DMA has 32bit limit */
-   if (addr >> 32)
-   return false;
-#endif
+   if (IS_ENABLED(CONFIG_RCAR_GEN3)) {
+   if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
+   return false;
+   /* Gen3 DMA has 32bit limit */
+   if (addr >> 32)
+   return false;
+   }
 
-#if defined(CONFIG_ARCH_UNIPHIER) && !defined(CONFIG_ARM64) && \
-   defined(CONFIG_SPL_BUILD)
-   /*
-* For UniPhier ARMv7 SoCs, the stack is allocated in the locked ways
-* of L2, which is unreachable from the DMA engine.
-*/
-   if (addr < CONFIG_SPL_STACK)
-   return false;
+#ifdef CONFIG_SPL_BUILD
+   if (IS_ENABLED(CONFIG_ARCH_UNIPHIER) && 
!CONFIG_IS_ENABLED(CONFIG_ARM64)) {
+   /*
+* For UniPhier ARMv7 SoCs, the stack is allocated in locked
+* ways of L2, which is unreachable from the DMA engine.
+*/
+   if (addr < CONFIG_SPL_STACK)
+   return false;
+   }
 #endif
 
return true;
@@ -622,25 +623,22 @@ static void tmio_sd_set_clk_rate(struct tmio_sd_priv 
*priv, struct mmc *mmc)
 static void tmio_sd_set_pins(struct udevice *dev)
 {
__maybe_unused struct mmc *mmc = mmc_get_mmc_dev(dev);
-
-#ifdef CONFIG_DM_REGULATOR
struct tmio_sd_priv *priv = dev_get_priv(dev);
 
-   if (priv->vqmmc_dev) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->vqmmc_dev) {
if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
regulator_set_value(priv->vqmmc_dev, 180);
else
regulator_set_value(priv->vqmmc_dev, 330);
regulator_set_enable(priv->vqmmc_dev, true);
}
-#endif
 
-#ifdef CONFIG_PINCTRL
-   if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
-   pinctrl_select_state(dev, "state_uhs");
-   else
-   pinctrl_select_state(dev, "default");
-#endif
+   if (CONFIG_IS_ENABLED(PINCTRL)) {
+   if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
+   pinctrl_select_state(dev, "state_uhs");
+   else
+   pinctrl_select_state(dev, "default");
+   }
 }
 
 int tmio_sd_set_ios(struct udevice *dev)
@@ -734,11 +732,12 @@ int tmio_sd_probe(struct udevice *dev, u32 quirks)
if (!priv->regbase)
return -ENOMEM;
 
-#ifdef CONFIG_DM_REGULATOR
-   device_get_supply_regulator(dev, "vqmmc-supply", &priv->vqmmc_dev);
-   if (priv->vqmmc_dev)
-   regulator_set_value(priv->vqmmc_dev, 330);
-#endif
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
+   device_get_supply_regulator(dev, "vqmmc-supply",
+   &priv->vqmmc_dev);
+   if (priv->vqmmc_dev)
+   regulator_set_value(priv->vqmmc_dev, 330);
+   }
 
ret = mmc_of_parse(dev, &plat->cfg);
if (ret < 0) {
-- 
2.39.2



[PATCH] Kconfig: Sort the BUILD_TARGET list

2023-02-27 Thread Marek Vasut
Sort the defaults list in BUILD_TARGET Kconfig option. No functional change.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 Kconfig | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Kconfig b/Kconfig
index a75cce7e28f..6dd524b0acb 100644
--- a/Kconfig
+++ b/Kconfig
@@ -454,16 +454,16 @@ config REMAKE_ELF
 
 config BUILD_TARGET
string "Build target special images"
+   default "u-boot-elf.srec" if RCAR_GEN3
+   default "u-boot-with-spl.bin" if ARCH_AT91 && SPL_NAND_SUPPORT
+   default "u-boot-with-spl.bin" if MPC85xx && !E500MC && !E5500 && !E6500 
&& SPL
+   default "u-boot-with-spl.imx" if ARCH_MX6 && SPL
+   default "u-boot-with-spl.kwb" if ARMADA_32BIT && SPL
default "u-boot-with-spl.sfp" if TARGET_SOCFPGA_ARRIA10
default "u-boot-with-spl.sfp" if TARGET_SOCFPGA_GEN5
-   default "u-boot-with-spl.kwb" if ARMADA_32BIT && SPL
-   default "u-boot-elf.srec" if RCAR_GEN3
default "u-boot.itb" if !BINMAN && SPL_LOAD_FIT && (ARCH_ROCKCHIP || \
ARCH_SUNXI || RISCV || ARCH_ZYNQMP)
default "u-boot.kwb" if (ARCH_KIRKWOOD || ARMADA_32BIT) && !SPL
-   default "u-boot-with-spl.bin" if MPC85xx && !E500MC && !E5500 && !E6500 
&& SPL
-   default "u-boot-with-spl.bin" if ARCH_AT91 && SPL_NAND_SUPPORT
-   default "u-boot-with-spl.imx" if ARCH_MX6 && SPL
help
  Some SoCs need special image types (e.g. U-Boot binary
  with a special header) as build targets. By defining
-- 
2.39.2



Re: [PATCH] clk: rockchip: rk3568: add more supported clk rates for sdmmc and emmc

2023-02-27 Thread Kever Yang



On 2023/2/24 05:03, Vasily Khoruzhick wrote:

SDHCI driver may attempt to set 26MHz clock, but clk_rk3568
will return error in this case. Apparently, SDHCI silently ignores the
error and as a result eMMC initialization fails.

Add 25 MHz and 26 MHz clk rates for sdmmc and emmc on rk3568 to fix that.

Signed-off-by: Vasily Khoruzhick 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  drivers/clk/rockchip/clk_rk3568.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/clk/rockchip/clk_rk3568.c 
b/drivers/clk/rockchip/clk_rk3568.c
index c83ae22dc3..253b69504f 100644
--- a/drivers/clk/rockchip/clk_rk3568.c
+++ b/drivers/clk/rockchip/clk_rk3568.c
@@ -1443,6 +1443,7 @@ static ulong rk3568_sdmmc_set_clk(struct rk3568_clk_priv 
*priv,
switch (rate) {
case OSC_HZ:
case 26 * MHz:
+   case 25 * MHz:
src_clk = CLK_SDMMC_SEL_24M;
break;
case 400 * MHz:
@@ -1632,6 +1633,8 @@ static ulong rk3568_emmc_set_clk(struct rk3568_clk_priv 
*priv, ulong rate)
  
  	switch (rate) {

case OSC_HZ:
+   case 26 * MHz:
+   case 25 * MHz:
src_clk = CCLK_EMMC_SEL_24M;
break;
case 52 * MHz:


Re: [PATCH v2 12/12] rockchip: rk3588: Read cpuid from otp

2023-02-27 Thread Kever Yang



On 2023/2/23 06:44, Jonas Karlman wrote:

Read cpuid from otp and set ethaddr for RK3588.

Signed-off-by: Jonas Karlman 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
v2:
- New patch

  arch/arm/dts/rk3588s-u-boot.dtsi | 12 
  arch/arm/mach-rockchip/Kconfig   |  2 ++
  2 files changed, 14 insertions(+)

diff --git a/arch/arm/dts/rk3588s-u-boot.dtsi b/arch/arm/dts/rk3588s-u-boot.dtsi
index 58123489f3c1..f880f4a16741 100644
--- a/arch/arm/dts/rk3588s-u-boot.dtsi
+++ b/arch/arm/dts/rk3588s-u-boot.dtsi
@@ -31,6 +31,18 @@
pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_det &sdmmc_bus4>;
status = "disabled";
};
+
+   otp: nvmem@fecc {
+   compatible = "rockchip,rk3588-otp";
+   reg = <0x0 0xfecc 0x0 0x400>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   status = "okay";
+
+   cpu_id: id@7 {
+   reg = <0x07 0x10>;
+   };
+   };
  };
  
  &xin24m {

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 88be06811c53..0390431601f9 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -310,6 +310,8 @@ config ROCKCHIP_RK3588
select SYSCON
select BOARD_LATE_INIT
imply ROCKCHIP_COMMON_BOARD
+   imply ROCKCHIP_OTP
+   imply MISC_INIT_R
help
  The Rockchip RK3588 is a ARM-based SoC with quad-core Cortex-A76 and
  quad-core Cortex-A55 including NEON and GPU, 6TOPS NPU, Mali-G610 MP4,


Re: [PATCH v2 2/2] board: rock5b-rk3588: add memory gaps into kernel's DTB

2023-02-27 Thread Kever Yang



On 2023/2/22 17:05, Eugen Hristev wrote:

RK3588 has two memory gaps when using 16 GiB DRAM size:
[0x3fc00 , 0x3fc50]
and
[0x3fff0 , 0x3]

If the kernel is agnostic to these gaps, accessing the area causes
a SError panic.

Hence, add reserved memory areas in kernel's DTB before booting.

Signed-off-by: Eugen Hristev 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---

Hi,

These memory gaps are required because the kernel crashes with a SError if
accessing that area.
It appears the ATAGs provide DDR banks that do not include those specific
two regions.
To be able to boot the kernel, those areas have to be reserved.
Maybe someone from Rockchip could have an explanation to this behavior?
Otherwise we have to block them at this level.
If those memory ranges are reserved for a dedicated purpose we can come up
with a better solution, w.r.t. the purpose of the regions.

Thanks !
Eugen

  board/radxa/rock5b-rk3588/rock5b-rk3588.c | 35 +++
  configs/rock5b-rk3588_defconfig   |  1 +
  2 files changed, 36 insertions(+)

diff --git a/board/radxa/rock5b-rk3588/rock5b-rk3588.c 
b/board/radxa/rock5b-rk3588/rock5b-rk3588.c
index b5d74798f3b9..5c3b52b94898 100644
--- a/board/radxa/rock5b-rk3588/rock5b-rk3588.c
+++ b/board/radxa/rock5b-rk3588/rock5b-rk3588.c
@@ -2,3 +2,38 @@
  /*
   * Copyright (c) 2023 Collabora Ltd.
   */
+
+#include 
+#include 
+
+#ifdef CONFIG_OF_BOARD_SETUP
+int rock5b_add_reserved_memory_fdt_nodes(void *new_blob)
+{
+   struct fdt_memory gap1 = {
+   .start = 0x3fc00,
+   .end = 0x3fc4f,
+   };
+   struct fdt_memory gap2 = {
+   .start = 0x3fff0,
+   .end = 0x3,
+   };
+   unsigned long flags = FDTDEC_RESERVED_MEMORY_NO_MAP;
+   unsigned int ret;
+
+   /*
+* Inject the reserved-memory nodes into the DTS
+*/
+   ret = fdtdec_add_reserved_memory(new_blob, "gap1", &gap1,  NULL, 0,
+NULL, flags);
+   if (ret)
+   return ret;
+
+   return fdtdec_add_reserved_memory(new_blob, "gap2", &gap2,  NULL, 0,
+ NULL, flags);
+}
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+   return rock5b_add_reserved_memory_fdt_nodes(blob);
+}
+#endif
diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-rk3588_defconfig
index 9b7db7de64be..f3026c7ea166 100644
--- a/configs/rock5b-rk3588_defconfig
+++ b/configs/rock5b-rk3588_defconfig
@@ -26,6 +26,7 @@ CONFIG_FIT=y
  CONFIG_FIT_VERBOSE=y
  CONFIG_SPL_FIT_SIGNATURE=y
  CONFIG_SPL_LOAD_FIT=y
+CONFIG_OF_BOARD_SETUP=y
  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-rock-5b.dtb"
  # CONFIG_DISPLAY_CPUINFO is not set
  CONFIG_DISPLAY_BOARDINFO_LATE=y


Re: [PATCH v2 1/2] board: rockchip: add Radxa ROCK5B Rk3588 board

2023-02-27 Thread Kever Yang



On 2023/2/22 17:05, Eugen Hristev wrote:

ROCK 5B is a Rockchip RK3588 based SBC (Single Board Computer) by Radxa.

There are tree variants depending on the DRAM size : 4G, 8G and 16G.

Specification:

 Rockchip Rk3588 SoC
 4x ARM Cortex-A76, 4x ARM Cortex-A55
 4/8/16GB memory LPDDR4x
 Mali G610MC4 GPU
 MIPI CSI 2 multiple lanes connector
 eMMC module connector
 uSD slot (up to 128GB)
 2x USB 2.0, 2x USB 3.0
 2x HDMI output, 1x HDMI input
 Ethernet port
 40-pin IO header including UART, SPI, I2C and 5V DC power in
 USB PD over USB Type-C
 Size: 85mm x 54mm

Kernel commits:
a1d3281450ab ("arm64: dts: rockchip: Add rock-5b board")
6fb13f888f2a ("arm64: dts: rockchip: Update sdhci alias for rock-5b")

Signed-off-by: Eugen Hristev 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---

Changes in v2:
- added kernel commits that added the DT for the board in Kernel.

This board comes on top of Jagan's series for adding the rk3588 support:
https://lists.denx.de/pipermail/u-boot/2023-January/506784.html
And Jonas' series of patches that adds support for DDR v3 :
https://lists.denx.de/pipermail/u-boot/2023-January/504923.html
and another series from Jonas about rockchip TPL
https://lists.denx.de/pipermail/u-boot/2023-February/509051.html
And a workaround to make SD-Card 400 kHz clock working from Jonas' private tree

Thanks,
Eugen

  arch/arm/dts/rk3588-rock-5b-u-boot.dtsi   | 22 +++
  arch/arm/dts/rk3588-rock-5b.dts   | 44 ++
  arch/arm/mach-rockchip/rk3588/Kconfig | 26 +
  board/radxa/rock5b-rk3588/Kconfig | 15 +
  board/radxa/rock5b-rk3588/MAINTAINERS |  6 ++
  board/radxa/rock5b-rk3588/Makefile|  6 ++
  board/radxa/rock5b-rk3588/rock5b-rk3588.c |  4 ++
  configs/rock5b-rk3588_defconfig   | 71 +++
  doc/board/rockchip/rockchip.rst   |  1 +
  include/configs/rock5b-rk3588.h   | 15 +
  10 files changed, 210 insertions(+)
  create mode 100644 arch/arm/dts/rk3588-rock-5b-u-boot.dtsi
  create mode 100644 arch/arm/dts/rk3588-rock-5b.dts
  create mode 100644 board/radxa/rock5b-rk3588/Kconfig
  create mode 100644 board/radxa/rock5b-rk3588/MAINTAINERS
  create mode 100644 board/radxa/rock5b-rk3588/Makefile
  create mode 100644 board/radxa/rock5b-rk3588/rock5b-rk3588.c
  create mode 100644 configs/rock5b-rk3588_defconfig
  create mode 100644 include/configs/rock5b-rk3588.h

diff --git a/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi 
b/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi
new file mode 100644
index ..2386edf90deb
--- /dev/null
+++ b/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2023 Collabora Ltd.
+ */
+
+#include "rk3588-u-boot.dtsi"
+
+/ {
+   aliases {
+   mmc0 = &sdmmc;
+   };
+
+   chosen {
+   u-boot,spl-boot-order = &sdmmc;
+   };
+};
+
+&sdmmc {
+   bus-width = <4>;
+   u-boot,dm-spl;
+   status = "okay";
+};
diff --git a/arch/arm/dts/rk3588-rock-5b.dts b/arch/arm/dts/rk3588-rock-5b.dts
new file mode 100644
index ..95805cb0adfa
--- /dev/null
+++ b/arch/arm/dts/rk3588-rock-5b.dts
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+/dts-v1/;
+
+#include "rk3588.dtsi"
+
+/ {
+   model = "Radxa ROCK 5 Model B";
+   compatible = "radxa,rock-5b", "rockchip,rk3588";
+
+   aliases {
+   mmc0 = &sdhci;
+   serial2 = &uart2;
+   };
+
+   chosen {
+   stdout-path = "serial2:150n8";
+   };
+
+   vcc5v0_sys: vcc5v0-sys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   };
+};
+
+&sdhci {
+   bus-width = <8>;
+   no-sdio;
+   no-sd;
+   non-removable;
+   max-frequency = <2>;
+   mmc-hs400-1_8v;
+   mmc-hs400-enhanced-strobe;
+   status = "okay";
+};
+
+&uart2 {
+   pinctrl-0 = <&uart2m0_xfer>;
+   status = "okay";
+};
diff --git a/arch/arm/mach-rockchip/rk3588/Kconfig 
b/arch/arm/mach-rockchip/rk3588/Kconfig
index def4094e2e44..aee71ca1dab8 100644
--- a/arch/arm/mach-rockchip/rk3588/Kconfig
+++ b/arch/arm/mach-rockchip/rk3588/Kconfig
@@ -13,6 +13,31 @@ config TARGET_RK3588_NEU6
  IO board and Neu6a needs to mount on top of this IO board in order to
  create complete Edgeble Neural Compute Module 6(Neu6) IO platform.
  
+config TARGET_ROCK5B_RK3588

+   bool "Radxa ROCK5B RK3588 board"
+   select BOARD_LATE_INIT
+   help
+ Radxa ROCK5B is a Rockchip RK3588 based SBC (Single Board Computer)
+ by Radxa.
+
+ There are tree variants depending on the DRAM size : 4G, 8G and 16G.
+
+ Specification:
+
+

Re: [PATCH] Reads high bits of DDR type for Rockchip

2023-02-27 Thread Recursive G
Hi Jonas,

Thank you for the reply and your patch does work.
How do I mark mine as retracted?

Best,
R.

Jonas Karlman  于2023年2月26日周日 09:00写道:
>
> Hi,
>
> Please try the series at [1], it should solve the same issue you are
> trying to solve with this patch. That series is also queued in the
> rockchip U-Boot Custodian Tree.
>
> [1] 
> https://patchwork.ozlabs.org/project/uboot/cover/20230207172707.4094859-1-jo...@kwiboo.se/
>
> Regards,
> Jonas
>
> On 2023-02-25 20:15, Recursive G wrote:
> > Bit layout decipered from
> > https://github.com/rockchip-linux/u-boot/commit/c69667e0e2bf4290ab1f408fcde58b8806ac266b>>
> >  Tested on a rk3568 device.
> >
> > Signed-off-by: Recursive G 
> > ---
> >  arch/arm/include/asm/arch-rockchip/sdram.h | 3 +++
> >  arch/arm/mach-rockchip/sdram.c | 1 +
> >  2 files changed, 4 insertions(+)
> >
> > diff --git a/arch/arm/include/asm/arch-rockchip/sdram.h
> > b/arch/arm/include/asm/arch-rockchip/sdram.h
> > index cf2a7b7d10..dec83420bc 100644
> > --- a/arch/arm/include/asm/arch-rockchip/sdram.h
> > +++ b/arch/arm/include/asm/arch-rockchip/sdram.h
> > @@ -61,6 +61,7 @@ enum {
> >
> >  /*
> >   * sys_reg3 bitfield struct
> > + * [13:12] high bits of ddrtype
> >   * [7] high bit of cs0_row_ch1
> >   * [6] high bit of cs1_row_ch1
> >   * [5] high bit of cs0_row_ch0
> > @@ -76,6 +77,8 @@ enum {
> >  #define SYS_REG_EXTEND_CS1_ROW_MASK 1
> >  #define SYS_REG_CS1_COL_SHIFT(ch) (0 + (ch) * 2)
> >  #define SYS_REG_CS1_COL_MASK 3
> > +#define SYS_REG_DDRTYPE_HI_SHIFT 9
> > +#define SYS_REG_DDRTYPE_HI_MASK 0x18
> >
> >  /* Get sdram size decode from reg */
> >  size_t rockchip_sdram_size(phys_addr_t reg);
> > diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c
> > index e086c47f3c..60ef48eb67 100644
> > --- a/arch/arm/mach-rockchip/sdram.c
> > +++ b/arch/arm/mach-rockchip/sdram.c
> > @@ -90,6 +90,7 @@ size_t rockchip_sdram_size(phys_addr_t reg)
> >  & SYS_REG_NUM_CH_MASK);
> >
> >   dram_type = (sys_reg2 >> SYS_REG_DDRTYPE_SHIFT) & SYS_REG_DDRTYPE_MASK;
> > + dram_type |= (sys_reg3 >> SYS_REG_DDRTYPE_HI_SHIFT) & 
> > SYS_REG_DDRTYPE_HI_MASK;
> >   debug("%s %x %x\n", __func__, (u32)reg, sys_reg2);
> >   for (ch = 0; ch < ch_num; ch++) {
> >   rank = 1 + (sys_reg2 >> SYS_REG_RANK_SHIFT(ch) &
>


Re: [PATCH] rockchip: rk3288: Use ft_system_setup instead of ft_board_setup

2023-02-27 Thread Kever Yang



On 2023/2/24 03:28, John Keeping wrote:

ft_board_setup() should be availble for use in board files but using it
in the rk3288 machine file blocks this functionality.

ft_system_setup() is the more appropriate function to use in a machine
definition.

Signed-off-by: John Keeping 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  arch/arm/mach-rockchip/Kconfig | 2 +-
  arch/arm/mach-rockchip/rk3288/rk3288.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index b678ec41318..3fbfd1b1564 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -119,7 +119,7 @@ config ROCKCHIP_RK322X
  config ROCKCHIP_RK3288
bool "Support Rockchip RK3288"
select CPU_V7A
-   select OF_BOARD_SETUP
+   select OF_SYSTEM_SETUP
select SKIP_LOWLEVEL_INIT_ONLY
select SUPPORT_SPL
select SPL
diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c 
b/arch/arm/mach-rockchip/rk3288/rk3288.c
index 3ad2887575d..26c7e41cd89 100644
--- a/arch/arm/mach-rockchip/rk3288/rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
@@ -138,7 +138,7 @@ static int ft_rk3288w_setup(void *blob)
return ret;
  }
  
-int ft_board_setup(void *blob, struct bd_info *bd)

+int ft_system_setup(void *blob, struct bd_info *bd)
  {
if (soc_is_rk3288w())
return ft_rk3288w_setup(blob);


Re: [PATCH v5 6/6] binman: Mark mkimage entry missing when its subnodes is missing

2023-02-27 Thread Kever Yang



On 2023/2/26 03:01, Jonas Karlman wrote:

Using the mkimage entry with the multiple-data-files prop and having a
missing external blob result in an unexpected ValueError exception using
the --allow-missing flag.

   ValueError: Filename 'missing.bin' not found in input path (...)

Fix this by using _pathname that is resolved by ObtainContents for blob
entries, ObtainContents also handles allow missing for external blobs.

Mark mkimage entry as missing and return without running mkimage when
missing entries is reported by CheckMissing.

Signed-off-by: Jonas Karlman 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
v5:
- New patch based on [1]

[1] 
https://patchwork.ozlabs.org/project/uboot/patch/20230219220158.4160763-7-jo...@kwiboo.se/

  tools/binman/etype/mkimage.py | 24 ++-
  tools/binman/ftest.py | 11 +
  .../test/278_mkimage_missing_multiple.dts | 19 +++
  3 files changed, 53 insertions(+), 1 deletion(-)
  create mode 100644 tools/binman/test/278_mkimage_missing_multiple.dts

diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index cb264c3cad0b..8a13d5ea8d77 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -156,7 +156,8 @@ class Entry_mkimage(Entry):
  for entry in self._mkimage_entries.values():
  if not entry.ObtainContents(fake_size=fake_size):
  return False
-
fnames.append(tools.get_input_filename(entry.GetDefaultFilename()))
+if entry._pathname:
+fnames.append(entry._pathname)
  input_fname = ":".join(fnames)
  else:
  data, input_fname, uniq = self.collect_contents_to_file(
@@ -171,6 +172,13 @@ class Entry_mkimage(Entry):
  outfile = self._filename if self._filename else 'mkimage-out.%s' % 
uniq
  output_fname = tools.get_output_filename(outfile)
  
+missing_list = []

+self.CheckMissing(missing_list)
+self.missing = bool(missing_list)
+if self.missing:
+self.SetContents(b'')
+return self.allow_missing
+
  args = ['-d', input_fname]
  if self._data_to_imagename:
  args += ['-n', input_fname]
@@ -216,6 +224,20 @@ class Entry_mkimage(Entry):
  if self._imagename:
  self._imagename.SetAllowFakeBlob(allow_fake)
  
+def CheckMissing(self, missing_list):

+"""Check if any entries in this section have missing external blobs
+
+If there are missing (non-optional) blobs, the entries are added to the
+list
+
+Args:
+missing_list: List of Entry objects to be added to
+"""
+for entry in self._mkimage_entries.values():
+entry.CheckMissing(missing_list)
+if self._imagename:
+self._imagename.CheckMissing(missing_list)
+
  def CheckFakedBlobs(self, faked_blobs_list):
  """Check if any entries in this section have faked external blobs
  
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py

index 48ac1540bfd8..d74aa90a6207 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -6393,6 +6393,17 @@ fdt fdtmapExtract the devicetree 
blob from the fdtmap
  data = self._DoReadFile('277_rockchip_tpl.dts')
  self.assertEqual(ROCKCHIP_TPL_DATA, data[:len(ROCKCHIP_TPL_DATA)])
  
+def testMkimageMissingBlobMultiple(self):

+"""Test missing blob with mkimage entry and multiple-data-files"""
+with test_util.capture_sys_output() as (stdout, stderr):
+self._DoTestFile('278_mkimage_missing_multiple.dts', 
allow_missing=True)
+err = stderr.getvalue()
+self.assertIn("is missing external blobs and is non-functional", err)
+
+with self.assertRaises(ValueError) as e:
+self._DoTestFile('278_mkimage_missing_multiple.dts', 
allow_missing=False)
+self.assertIn("not found in input path", str(e.exception))
+
  
  if __name__ == "__main__":

  unittest.main()
diff --git a/tools/binman/test/278_mkimage_missing_multiple.dts 
b/tools/binman/test/278_mkimage_missing_multiple.dts
new file mode 100644
index ..f84aea49ead9
--- /dev/null
+++ b/tools/binman/test/278_mkimage_missing_multiple.dts
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   binman {
+   mkimage {
+   args = "-n test -T script";
+   multiple-data-files;
+
+   blob-ext {
+   filename = "missing.bin";
+   };
+   };
+   };
+};


[PATCH 2/2] ARM: dts: uniphier: Sync DT with Linux v6.2

2023-02-27 Thread Kunihiko Hayashi
Synchronize devicetree sources with Linux v6.2.

- Use GIC interrupt definitions
- Add reg properties in USB-glue and SoC-glue node
- Fix node names to follow the generic names list in DT specification
- Add L2 cache and AHCI nodes
- Update nand and pcie nodes
- And some trivial fixes

Signed-off-by: Kunihiko Hayashi 
---
 arch/arm/dts/uniphier-ld11-global.dts |   4 +
 arch/arm/dts/uniphier-ld11-ref.dts|   6 +-
 arch/arm/dts/uniphier-ld11.dtsi   |  94 ++--
 arch/arm/dts/uniphier-ld20.dtsi   | 129 +---
 arch/arm/dts/uniphier-ld4-ref.dts |  10 +-
 arch/arm/dts/uniphier-ld4.dtsi|  76 ++
 arch/arm/dts/uniphier-pro4-ace.dts|   8 +
 arch/arm/dts/uniphier-pro4-ref.dts|  18 ++-
 arch/arm/dts/uniphier-pro4-sanji.dts  |   6 +-
 arch/arm/dts/uniphier-pro4.dtsi   | 205 +++--
 arch/arm/dts/uniphier-pro5.dtsi   | 101 +++--
 arch/arm/dts/uniphier-pxs2-gentil.dts |   4 +
 arch/arm/dts/uniphier-pxs2.dtsi   | 155 ---
 arch/arm/dts/uniphier-pxs3-ref.dts|  18 ++-
 arch/arm/dts/uniphier-pxs3.dtsi   | 206 +++---
 arch/arm/dts/uniphier-sld8-ref.dts|  10 +-
 arch/arm/dts/uniphier-sld8.dtsi   |  77 ++
 17 files changed, 754 insertions(+), 373 deletions(-)

diff --git a/arch/arm/dts/uniphier-ld11-global.dts 
b/arch/arm/dts/uniphier-ld11-global.dts
index 644ffb9707..da44a15a8a 100644
--- a/arch/arm/dts/uniphier-ld11-global.dts
+++ b/arch/arm/dts/uniphier-ld11-global.dts
@@ -164,4 +164,8 @@
 
 &nand {
status = "okay";
+
+   nand@0 {
+   reg = <0>;
+   };
 };
diff --git a/arch/arm/dts/uniphier-ld11-ref.dts 
b/arch/arm/dts/uniphier-ld11-ref.dts
index 617d2b1e9b..414aeb99e6 100644
--- a/arch/arm/dts/uniphier-ld11-ref.dts
+++ b/arch/arm/dts/uniphier-ld11-ref.dts
@@ -39,11 +39,11 @@
 };
 
 ðsc {
-   interrupts = <0 8>;
+   interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
 };
 
 &serialsc {
-   interrupts = <0 8>;
+   interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
 };
 
 &serial0 {
@@ -51,7 +51,7 @@
 };
 
 &gpio {
-   xirq0 {
+   xirq0-hog {
gpio-hog;
gpios = ;
input;
diff --git a/arch/arm/dts/uniphier-ld11.dtsi b/arch/arm/dts/uniphier-ld11.dtsi
index 104d56d625..7bb36b0714 100644
--- a/arch/arm/dts/uniphier-ld11.dtsi
+++ b/arch/arm/dts/uniphier-ld11.dtsi
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 
 / {
compatible = "socionext,uniphier-ld11";
@@ -35,6 +36,7 @@
reg = <0 0x000>;
clocks = <&sys_clk 33>;
enable-method = "psci";
+   next-level-cache = <&l2>;
operating-points-v2 = <&cluster0_opp>;
};
 
@@ -44,8 +46,13 @@
reg = <0 0x001>;
clocks = <&sys_clk 33>;
enable-method = "psci";
+   next-level-cache = <&l2>;
operating-points-v2 = <&cluster0_opp>;
};
+
+   l2: l2-cache {
+   compatible = "cache";
+   };
};
 
cluster0_opp: opp-table {
@@ -102,10 +109,10 @@
 
timer {
compatible = "arm,armv8-timer";
-   interrupts = <1 13 4>,
-<1 14 4>,
-<1 11 4>,
-<1 10 4>;
+   interrupts = ,
+,
+,
+;
};
 
reserved-memory {
@@ -131,7 +138,7 @@
reg = <0x54006000 0x100>;
#address-cells = <1>;
#size-cells = <0>;
-   interrupts = <0 39 4>;
+   interrupts = ;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_spi0>;
clocks = <&peri_clk 11>;
@@ -144,7 +151,7 @@
reg = <0x54006100 0x100>;
#address-cells = <1>;
#size-cells = <0>;
-   interrupts = <0 216 4>;
+   interrupts = ;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_spi1>;
clocks = <&peri_clk 12>;
@@ -155,7 +162,7 @@
compatible = "socionext,uniphier-uart";
status = "disabled";
reg = <0x54006800 0x40>;
-   interrupts = <0 33 4>;
+   interrupts = ;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart0>;
clocks = <&peri_clk 0>;
@@ -166,7 +173,7 @@
compatible = "socionext,uniphier-uart";
status = "disabled";
   

[PATCH 1/2] ARM: dts: uniphier: Switch USB node to the original

2023-02-27 Thread Kunihiko Hayashi
UniPhier DT applies its own USB node for U-Boot due to the USB driver
constrains. After solving this issue, u-boot allows the original USB node.

After switching USB node, synchronization of USB node with Linux becomes
possible.

Signed-off-by: Kunihiko Hayashi 
---
 arch/arm/dts/uniphier-ld20.dtsi | 21 +
 arch/arm/dts/uniphier-pro4.dtsi | 42 ++---
 arch/arm/dts/uniphier-pxs2.dtsi | 42 ++---
 arch/arm/dts/uniphier-pxs3.dtsi | 42 ++---
 4 files changed, 7 insertions(+), 140 deletions(-)

diff --git a/arch/arm/dts/uniphier-ld20.dtsi b/arch/arm/dts/uniphier-ld20.dtsi
index 4549935c42..1aad4cff5b 100644
--- a/arch/arm/dts/uniphier-ld20.dtsi
+++ b/arch/arm/dts/uniphier-ld20.dtsi
@@ -744,7 +744,7 @@
};
};
 
-   _usb: usb@65a0 {
+   usb: usb@65a0 {
compatible = "socionext,uniphier-dwc3", "snps,dwc3";
status = "disabled";
reg = <0x65a0 0xcd00>;
@@ -894,25 +894,6 @@
};
};
 
-   /* FIXME: U-Boot own node */
-   usb: usb@65b0 {
-   compatible = "socionext,uniphier-ld20-dwc3";
-   reg = <0x65b0 0x1000>;
-   #address-cells = <1>;
-   #size-cells = <1>;
-   ranges;
-   pinctrl-names = "default";
-   pinctrl-0 = <&pinctrl_usb0>, <&pinctrl_usb1>,
-   <&pinctrl_usb2>, <&pinctrl_usb3>;
-   dwc3@65a0 {
-   compatible = "snps,dwc3";
-   reg = <0x65a0 0x1>;
-   interrupts = <0 134 4>;
-   dr_mode = "host";
-   tx-fifo-resize;
-   };
-   };
-
pcie: pcie@6600 {
compatible = "socionext,uniphier-pcie", "snps,dw-pcie";
status = "disabled";
diff --git a/arch/arm/dts/uniphier-pro4.dtsi b/arch/arm/dts/uniphier-pro4.dtsi
index 9dae4e9b23..cd706f485e 100644
--- a/arch/arm/dts/uniphier-pro4.dtsi
+++ b/arch/arm/dts/uniphier-pro4.dtsi
@@ -503,7 +503,7 @@
};
};
 
-   _usb0: usb@65a0 {
+   usb0: usb@65a0 {
compatible = "socionext,uniphier-dwc3", "snps,dwc3";
status = "disabled";
reg = <0x65a0 0xcd00>;
@@ -556,26 +556,7 @@
};
};
 
-   /* FIXME: U-Boot own node */
-   usb0: usb@65b0 {
-   compatible = "socionext,uniphier-pro4-dwc3";
-   status = "disabled";
-   reg = <0x65b0 0x1000>;
-   #address-cells = <1>;
-   #size-cells = <1>;
-   ranges;
-   pinctrl-names = "default";
-   pinctrl-0 = <&pinctrl_usb0>;
-   dwc3@65a0 {
-   compatible = "snps,dwc3";
-   reg = <0x65a0 0x1>;
-   interrupts = <0 134 4>;
-   dr_mode = "host";
-   tx-fifo-resize;
-   };
-   };
-
-   _usb1: usb@65c0 {
+   usb1: usb@65c0 {
compatible = "socionext,uniphier-dwc3", "snps,dwc3";
status = "disabled";
reg = <0x65c0 0xcd00>;
@@ -617,25 +598,6 @@
};
};
 
-   /* FIXME: U-Boot own node */
-   usb1: usb@65d0 {
-   compatible = "socionext,uniphier-pro4-dwc3";
-   status = "disabled";
-   reg = <0x65d0 0x1000>;
-   #address-cells = <1>;
-   #size-cells = <1>;
-   ranges;
-   pinctrl-names = "default";
-   pinctrl-0 = <&pinctrl_usb1>;
-   dwc3@65c0 {
-   compatible = "snps,dwc3";
-   reg = <0x65c0 0x1>;
-   interrupts = <0 137 4>;
-   dr_mode = "host";
-   tx-fifo-resize;
-   };
-   };
-
nand: nand-controller@6800 {
compatible = "socionext,uniphier-denali-nand-v5a";
status = "disabled";
diff --git a/arch/arm/dts/uniphier-pxs2.dtsi b/arch/arm/dts/uniphier-px

[PATCH 0/2] Update UniPhier devicetree

2023-02-27 Thread Kunihiko Hayashi
Migrate the USB node to the original node after updating dwc3-generic and
dwc3-uniphier.
https://lists.denx.de/pipermail/u-boot/2023-February/509635.html

And synchronize UniPhier devicetree with Linux v6.2.

Kunihiko Hayashi (2):
  ARM: dts: uniphier: Switch USB node to the original
  ARM: dts: uniphier: Sync DT with Linux v6.2

 arch/arm/dts/uniphier-ld11-global.dts |   4 +
 arch/arm/dts/uniphier-ld11-ref.dts|   6 +-
 arch/arm/dts/uniphier-ld11.dtsi   |  94 +-
 arch/arm/dts/uniphier-ld20.dtsi   | 150 
 arch/arm/dts/uniphier-ld4-ref.dts |  10 +-
 arch/arm/dts/uniphier-ld4.dtsi|  76 
 arch/arm/dts/uniphier-pro4-ace.dts|   8 +
 arch/arm/dts/uniphier-pro4-ref.dts|  18 +-
 arch/arm/dts/uniphier-pro4-sanji.dts  |   6 +-
 arch/arm/dts/uniphier-pro4.dtsi   | 247 -
 arch/arm/dts/uniphier-pro5.dtsi   | 101 ++-
 arch/arm/dts/uniphier-pxs2-gentil.dts |   4 +
 arch/arm/dts/uniphier-pxs2.dtsi   | 197 ++--
 arch/arm/dts/uniphier-pxs3-ref.dts|  18 +-
 arch/arm/dts/uniphier-pxs3.dtsi   | 248 --
 arch/arm/dts/uniphier-sld8-ref.dts|  10 +-
 arch/arm/dts/uniphier-sld8.dtsi   |  77 
 17 files changed, 761 insertions(+), 513 deletions(-)

-- 
2.25.1



[PATCH v2] CI: gitlab: Collect pytest artifacts

2023-02-27 Thread Marek Vasut
Copy build artifacts for all test.py tests, so they show up in
artifacts storage for later inspection. The test.py tests output
in CI is basically useless, but it is far more useful in the html
output for analysis and debugging.

Reviewed-by: Tom Rini 
Suggested-by: Simon Glass 
Signed-off-by: Marek Vasut 
---
Cc: Simon Glass 
Cc: Tom Rini 
---
V2: - Drop bogus comment
- Add RB from Tom
---
 .gitlab-ci.yml | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 272d69e2206..3a2fd3dee08 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -76,10 +76,12 @@ stages:
   ./test/py/test.py -ra --bd ${TEST_PY_BD} ${TEST_PY_ID}
 ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"}
 --build-dir "$UBOOT_TRAVIS_BUILD_DIR"
-# It seems that the files in /tmp go away, so copy out what we need
-- if [[ "${TEST_PY_BD}" == "coreboot" ]]; then
-cp -v /tmp/coreboot/*.{html,css} .;
-  fi
+- cp -v /tmp/${TEST_PY_BD}/*.{html,css} .
+  artifacts:
+paths:
+  - "*.html"
+  - "*.css"
+expire_in: 1 week
 
 build all 32bit ARM platforms:
   stage: world build
@@ -454,9 +456,4 @@ coreboot test.py:
 TEST_PY_BD: "coreboot"
 TEST_PY_TEST_SPEC: "not sleep"
 TEST_PY_ID: "--id qemu"
-  artifacts:
-paths:
-  - "*.html"
-  - "*.css"
-expire_in: 1 week
   <<: *buildman_and_testpy_dfn
-- 
2.39.2



Re: [PATCH] CI: gitlab: Collect pytest artifacts

2023-02-27 Thread Marek Vasut

On 2/28/23 00:36, Tom Rini wrote:

[...]


@@ -454,9 +457,4 @@ coreboot test.py:
  TEST_PY_BD: "coreboot"
  TEST_PY_TEST_SPEC: "not sleep"
  TEST_PY_ID: "--id qemu"
-  artifacts:
-paths:
-  - "*.html"
-  - "*.css"
-expire_in: 1 week
<<: *buildman_and_testpy_dfn


So, what looks like a debugging artifact was included in the proper
patch and merged, and yes,
https://u-boot.source-pages.denx.de/-/u-boot/-/jobs/585388/artifacts/test-log.html
is quite handy in the case of test failure.


Do you also get SSL_ERROR_BAD_CERT_DOMAIN warning ? That might be 
something to fix. +CC Harald.


[PATCH 6/6] video: tl070wsh30: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/video/tdo-tl070wsh30.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/tdo-tl070wsh30.c b/drivers/video/tdo-tl070wsh30.c
index 7ad0af73f05..273672db024 100644
--- a/drivers/video/tdo-tl070wsh30.c
+++ b/drivers/video/tdo-tl070wsh30.c
@@ -75,7 +75,7 @@ static int tl070wsh30_panel_of_to_plat(struct udevice *dev)
struct tl070wsh30_panel_priv *priv = dev_get_priv(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
ret =  device_get_supply_regulator(dev, "power-supply",
   &priv->reg);
if (ret && ret != -ENOENT) {
@@ -108,7 +108,7 @@ static int tl070wsh30_panel_probe(struct udevice *dev)
struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->reg) {
ret = regulator_set_enable(priv->reg, true);
if (ret)
return ret;
-- 
2.39.2



[PATCH 5/6] video: simple-panel: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/video/simple_panel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c
index 91c91ee75d8..092906c82c9 100644
--- a/drivers/video/simple_panel.c
+++ b/drivers/video/simple_panel.c
@@ -53,7 +53,7 @@ static int simple_panel_of_to_plat(struct udevice *dev)
struct simple_panel_priv *priv = dev_get_priv(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
   "power-supply", &priv->reg);
if (ret) {
@@ -89,7 +89,7 @@ static int simple_panel_probe(struct udevice *dev)
struct simple_panel_priv *priv = dev_get_priv(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->reg) {
debug("%s: Enable regulator '%s'\n", __func__, priv->reg->name);
ret = regulator_set_enable(priv->reg, true);
if (ret)
-- 
2.39.2



[PATCH 3/6] video: otm8009a: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/video/orisetech_otm8009a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/orisetech_otm8009a.c 
b/drivers/video/orisetech_otm8009a.c
index 95738e34bf6..848f174b6e4 100644
--- a/drivers/video/orisetech_otm8009a.c
+++ b/drivers/video/orisetech_otm8009a.c
@@ -300,7 +300,7 @@ static int otm8009a_panel_of_to_plat(struct udevice *dev)
struct otm8009a_panel_priv *priv = dev_get_priv(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
ret =  device_get_supply_regulator(dev, "power-supply",
   &priv->reg);
if (ret && ret != -ENOENT) {
@@ -326,7 +326,7 @@ static int otm8009a_panel_probe(struct udevice *dev)
struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->reg) {
dev_dbg(dev, "enable regulator '%s'\n", priv->reg->name);
ret = regulator_set_enable(priv->reg, true);
if (ret)
-- 
2.39.2



[PATCH 2/6] mmc: npcm_sdhci: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/mmc/npcm_sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/npcm_sdhci.c b/drivers/mmc/npcm_sdhci.c
index 7eb17cce0b3..d63521d6855 100644
--- a/drivers/mmc/npcm_sdhci.c
+++ b/drivers/mmc/npcm_sdhci.c
@@ -36,7 +36,7 @@ static int npcm_sdhci_probe(struct udevice *dev)
return ret;
}
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
device_get_supply_regulator(dev, "vqmmc-supply", &vqmmc_supply);
vqmmc_uv = dev_read_u32_default(dev, "vqmmc-microvolt", 0);
/* Set IO voltage */
-- 
2.39.2



[PATCH 4/6] video: rm68200: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/video/raydium-rm68200.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/raydium-rm68200.c b/drivers/video/raydium-rm68200.c
index 373668d28bf..f1fce55a2cb 100644
--- a/drivers/video/raydium-rm68200.c
+++ b/drivers/video/raydium-rm68200.c
@@ -266,7 +266,7 @@ static int rm68200_panel_of_to_plat(struct udevice *dev)
struct rm68200_panel_priv *priv = dev_get_priv(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
ret =  device_get_supply_regulator(dev, "power-supply",
   &priv->reg);
if (ret && ret != -ENOENT) {
@@ -299,7 +299,7 @@ static int rm68200_panel_probe(struct udevice *dev)
struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->reg) {
ret = regulator_set_enable(priv->reg, true);
if (ret)
return ret;
-- 
2.39.2



[PATCH 1/6] misc: ub251xb: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/misc/usb251xb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/usb251xb.c b/drivers/misc/usb251xb.c
index a78ad1843ae..92e92ba5e62 100644
--- a/drivers/misc/usb251xb.c
+++ b/drivers/misc/usb251xb.c
@@ -334,7 +334,7 @@ static int usb251xb_probe(struct udevice *dev)
struct usb251xb *hub = dev_get_priv(dev);
int err;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR) && hub->vdd) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && hub->vdd) {
err = regulator_set_enable(hub->vdd, true);
if (err)
return err;
@@ -391,7 +391,7 @@ static int usb251xb_of_to_plat(struct udevice *dev)
return err;
}
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
err = device_get_supply_regulator(dev, "vdd-supply",
  &hub->vdd);
if (err && err != -ENOENT) {
-- 
2.39.2



Re: [PATCHv4 2/5] fwu: move meta-data management in core

2023-02-27 Thread Jassi Brar
Hi Ilias,

On Thu, Feb 23, 2023 at 2:36 AM Ilias Apalodimas
 wrote:
> > +int fwu_get_verified_mdata(struct fwu_mdata *mdata)
> > +{
> > + int err;
> > + bool pri_ok, sec_ok;
> > + struct fwu_mdata s, *p_mdata, *s_mdata;
> > +
> > + p_mdata = &g_mdata;
> > + s_mdata = &s;
> > +
> > + /* if mdata already read and ready */
> > + err = mdata_crc_check(p_mdata);
> > + if (!err)
> > + goto ret_mdata;
> > + /* else read, verify and, if needed, fix mdata */
> > +
> > + pri_ok = false;
> > + err = fwu_read_mdata(g_dev, p_mdata, true);
> > + if (!err) {
> > + err = mdata_crc_check(p_mdata);
> > + if (!err)
> > + pri_ok = true;
> > + else
> > + log_debug("primary mdata: crc32 failed\n");
> > + }
> > +
> > + sec_ok = false;
> > + err = fwu_read_mdata(g_dev, s_mdata, false);
> > + if (!err) {
> > + err = mdata_crc_check(s_mdata);
> > + if (!err)
> > + sec_ok = true;
> > + else
> > + log_debug("secondary mdata: crc32 failed\n");
> > + }
>
> Isn't it better to define pri_ok, sec_ok and their equivalent mdata as
> arrays ? IOW something along the lines of
>
> bool parts_ok[2] = { false };
> struct fwu_mdata parts_mdata[2];
>
> parts_mdata[0] = &g_mdata;
> parts_mdata[1] = .
> for (i = 0; i < 2; i++) {
> err = fwu_read_mdata(g_dev, parts_mdata[i], !(i % 2) ? true : false);
> if (!err)
> err = mdata_crc_check(parts_mdata[i]);
> etc
> }
>
> > +
> > + if (pri_ok && sec_ok) {
>
> And then also adjust this part?
>
> > + /*
> > +  * Before returning, check that both the
> > +  * FWU metadata copies are the same.
> > +  */
> > + err = memcmp(p_mdata, s_mdata, sizeof(struct fwu_mdata));
> > + if (!err)
> > + goto ret_mdata;
> > +
> > + /*
> > +  * If not, populate the secondary partition from the
> > +  * primary partition copy.
> > +  */
> > + log_info("Both FWU metadata copies are valid but do not 
> > match.");
> > + log_info(" Restoring the secondary partition from the 
> > primary\n");
> > + sec_ok = false;
> > + }
> > +
> > + if (!pri_ok) {
> > + memcpy(p_mdata, s_mdata, sizeof(struct fwu_mdata));
> > + err = fwu_sync_mdata(p_mdata, PRIMARY_PART);
> > + if (err) {
> > + log_debug("mdata : primary write failed\n");
> > + return err;
> > + }
> > + }
> > +
> > + if (!sec_ok) {
> > + memcpy(s_mdata, p_mdata, sizeof(struct fwu_mdata));
> > + err = fwu_sync_mdata(s_mdata, SECONDARY_PART);
> > + if (err) {
> > + log_debug("mdata : secondary write failed\n");
> > + return err;
> > + }
> > + }
>
> And this could also be folded into a for loop
>
I have done these modifications and submitted v5.

Thanks.


Re: [PATCH v5 0/6] FWU: Handle meta-data in common code

2023-02-27 Thread Jassi Brar
On Mon, Feb 27, 2023 at 7:28 PM Tom Rini  wrote:
>
> On Mon, Feb 27, 2023 at 07:00:10PM -0600, Jassi Brar wrote:
> > On Mon, 27 Feb 2023 at 18:58, Tom Rini  wrote:
> > >
> > > On Mon, Feb 27, 2023 at 06:51:35PM -0600, jassisinghb...@gmail.com wrote:
> > >
> > > > From: Jassi Brar 
> > > >
> > > > The patchset reduces ~400 lines of code, while keeping the 
> > > > functionality same and making
> > > > meta-data operations much faster (by using cached structures).
> > > >
> > > > Issue:
> > > >  meta-data copies (primary and secondary) are being handled by the 
> > > > backend/storage layer
> > > > instead of the common core in fwu.c (as also noted by Ilias)  that is, 
> > > > gpt_blk.c manages
> > > > meta-data and similarly raw_mtd.c will have to do the same when it 
> > > > arrives. The code
> > > > could by make smaller, cleaner and optimised.
> > > >
> > > > Basic idea:
> > > >  Introduce  .read_mdata() and .write_mdata() in fwu_mdata_ops  that 
> > > > simply read/write
> > > > meta-data copy. The core code takes care of integrity and redundancy of 
> > > > the meta-data,
> > > > as a result we can get rid of every other callback .get_mdata() 
> > > > .update_mdata()
> > > > .get_mdata_part_num()  .read_mdata_partition()  
> > > > .write_mdata_partition() and the
> > > > corresponding wrapper functions thereby making the code 100s of LOC 
> > > > smaller.
> > > >
> > > > Get rid of fwu_check_mdata_validity() and fwu_mdata_check() which 
> > > > expected underlying
> > > > layer to manage and verify mdata copies.
> > > > Implement  fwu_get_verified_mdata(struct fwu_mdata *mdata) public 
> > > > function that reads,
> > > > verifies and, if needed, fixes the meta-data copies.
> > > >
> > > > Verified copy of meta-data is now cached as 'g_mdata' in fwu.c, which 
> > > > avoids multiple
> > > > low-level expensive read and parse calls.
> > > > gpt meta-data partition numbers are now cached in gpt_blk.c, so that we 
> > > > don't have to do expensive part_get_info() and uid ops.
> > > >
> > > > Changes since v4:
> > > > * Change fwu-mdata-mtd bindings to not require external changes
> > > > * Handle 'part == BOTH_PARTS' in fwu_sync_mdata
> > > > * use parts_ok[] and parts_mdata[] instead of pri/sec_ok and 
> > > > p/s_mdata
> > >
> > > Did you run this through CI / build sandbox? This doesn't read like you
> > > fixed the problem I reported in CI, when I was trying to merge v4.
> > >
> > I know that remains to be done.
> > The dt-bindings for fwu-mdata is changed in this patchset and I
> > thought any testcase may be impacted by it.
>
> So you're not expecting this iteration to be merged, as CI doesn't pass,
> and that's known? OK.
>
I am more concerned if the bindings displease someone and I have to
drop any code.
If I get acks on all patches, the next revision will only add the test cases.

thanks


Re: [PATCH 2/7] dlmalloc: Fix a warning with clang-15

2023-02-27 Thread Tom Rini
On Mon, Feb 27, 2023 at 05:35:30PM -0700, Simon Glass wrote:
> Hi Tom,
> 
> On Mon, 27 Feb 2023 at 15:08, Tom Rini  wrote:
> >
> > With clang-15 we now will get warnings such as:
> >
> > warning: a function declaration without a prototype is deprecated in all
> > versions of C [-Wstrict-prototypes]
> >
> > And it is easy enough to address this warning here, as we aren't
> > concerned with re-syncing with an upstream.
> >
> > Signed-off-by: Tom Rini 
> > ---
> >  common/dlmalloc.c | 8 
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> Reviewed-by: Simon Glass 
> 
> >
> > diff --git a/common/dlmalloc.c b/common/dlmalloc.c
> > index 41c7230424cc..0f9b7262d512 100644
> > --- a/common/dlmalloc.c
> > +++ b/common/dlmalloc.c
> > @@ -80,7 +80,7 @@ GmListElement* makeGmListElement (void* bas)
> > return this;
> >  }
> >
> > -void gcleanup ()
> > +void gcleanup (void)
> 
> drop space before ( ?

The file is so badly out of sync with our coding style I literally just
went and did %s/()$/(void)/ to move on to the next sets of problems. So
I'd rather not fix one more style issue here when I suspect there's a
barely exaggerated thousand more.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 0/6] FWU: Handle meta-data in common code

2023-02-27 Thread Tom Rini
On Mon, Feb 27, 2023 at 07:00:10PM -0600, Jassi Brar wrote:
> On Mon, 27 Feb 2023 at 18:58, Tom Rini  wrote:
> >
> > On Mon, Feb 27, 2023 at 06:51:35PM -0600, jassisinghb...@gmail.com wrote:
> >
> > > From: Jassi Brar 
> > >
> > > The patchset reduces ~400 lines of code, while keeping the functionality 
> > > same and making
> > > meta-data operations much faster (by using cached structures).
> > >
> > > Issue:
> > >  meta-data copies (primary and secondary) are being handled by the 
> > > backend/storage layer
> > > instead of the common core in fwu.c (as also noted by Ilias)  that is, 
> > > gpt_blk.c manages
> > > meta-data and similarly raw_mtd.c will have to do the same when it 
> > > arrives. The code
> > > could by make smaller, cleaner and optimised.
> > >
> > > Basic idea:
> > >  Introduce  .read_mdata() and .write_mdata() in fwu_mdata_ops  that 
> > > simply read/write
> > > meta-data copy. The core code takes care of integrity and redundancy of 
> > > the meta-data,
> > > as a result we can get rid of every other callback .get_mdata() 
> > > .update_mdata()
> > > .get_mdata_part_num()  .read_mdata_partition()  .write_mdata_partition() 
> > > and the
> > > corresponding wrapper functions thereby making the code 100s of LOC 
> > > smaller.
> > >
> > > Get rid of fwu_check_mdata_validity() and fwu_mdata_check() which 
> > > expected underlying
> > > layer to manage and verify mdata copies.
> > > Implement  fwu_get_verified_mdata(struct fwu_mdata *mdata) public 
> > > function that reads,
> > > verifies and, if needed, fixes the meta-data copies.
> > >
> > > Verified copy of meta-data is now cached as 'g_mdata' in fwu.c, which 
> > > avoids multiple
> > > low-level expensive read and parse calls.
> > > gpt meta-data partition numbers are now cached in gpt_blk.c, so that we 
> > > don't have to do expensive part_get_info() and uid ops.
> > >
> > > Changes since v4:
> > > * Change fwu-mdata-mtd bindings to not require external changes
> > > * Handle 'part == BOTH_PARTS' in fwu_sync_mdata
> > > * use parts_ok[] and parts_mdata[] instead of pri/sec_ok and 
> > > p/s_mdata
> >
> > Did you run this through CI / build sandbox? This doesn't read like you
> > fixed the problem I reported in CI, when I was trying to merge v4.
> >
> I know that remains to be done.
> The dt-bindings for fwu-mdata is changed in this patchset and I
> thought any testcase may be impacted by it.

So you're not expecting this iteration to be merged, as CI doesn't pass,
and that's known? OK.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/2] arm: mvebu: clearfog: Add defconfig for SPI booting

2023-02-27 Thread Tony Dinh
Hi Pali,

On Mon, Feb 27, 2023 at 4:42 PM Tony Dinh  wrote:
>
> Hi Pali,
>
> On Mon, Feb 27, 2023 at 3:41 PM Tony Dinh  wrote:
> >
> > Hi Pali,
> >
> > On Mon, Feb 27, 2023 at 1:57 PM Tony Dinh  wrote:
> > >
> > > Hi Stefan,
> > >
> > > On Sun, Feb 26, 2023 at 11:40 PM Stefan Roese  wrote:
> > > >
> > > > Hi Tony,
> > > >
> > > > On 2/27/23 01:11, Tony Dinh wrote:
> > > > > Hi Pali,
> > > > >
> > > > > On Sun, Feb 26, 2023 at 2:52 AM Pali Rohár  wrote:
> > > > >>
> > > > >> On Saturday 25 February 2023 20:56:10 Tony Dinh wrote:
> > > > >>> Hi Martin,
> > > > >>>
> > > > >>> On Sat, Feb 25, 2023 at 6:17 PM Martin Rowe 
> > > > >>>  wrote:
> > > > 
> > > > >>> I'm not sure how to run proper timing tests on the process, but
> > > > >>> stopwatch timing just between seeing "Trying to boot" and 
> > > > >>> "U-Boot
> > > > >>> 2023.04-rc2" showed the return to BootROM under 1 second, and 
> > > > >>> the
> > > > >>> direct from SPI around 4 seconds. I thought the goal of loading 
> > > > >>> from
> > > > >>> SPI directly was speed, but returning to BootROM is 
> > > > >>> significantly
> > > > >>> faster on this board.
> > > > >>
> > > > >> You should check SPI speed in DTS file and also in the defconfig.
> > > > >
> > > > > I think we have probably seen this slowdown before. There is a 
> > > > > TODO in
> > > > > the way the DTS nodes are parsed by DM uclass. So this config 
> > > > > must be
> > > > > set in defconfig to get around that bug:
> > > > > CONFIG_SF_DEFAULT_SPEED=5000
> > > > 
> > > >  That works and is much faster now. I'll submit it in a V2 for these
> > > >  two patches once Pali's mvebu changes are accepted. Only question I
> > > >  have is: should the faster speed be applied to all three 
> > > >  defconfigs?
> > > >  CONFIG_SF_DEFAULT_SPEED=100 (50x less) is implicitly added to 
> > > >  the
> > > >  MMC and SATA configs at the moment.
> > > > >>>
> > > > >>> This is only a workaround to get the SPI probe to work correctly. 
> > > > >>> The
> > > > >>> real fix should be in spi_flash_probe()
> > > > >>> ./common/spl/spl_spi.c
> > > > >>>  flash = spi_flash_probe(sf_bus, sf_cs,
> > > > >>>  CONFIG_SF_DEFAULT_SPEED,
> > > > >>>  CONFIG_SF_DEFAULT_MODE);
> > > > >>> If spi_flash_probe() failed to get SPI max_hz from the DTS, the
> > > > >>> fallback is CONFIG_SF_DEFAULT_SPEED.
> > > > >>>
> > > > >>> IMO, perhaps we could add CONFIG_SF_DEFAULT_SPEED and
> > > > >>> CONFIG_SF_DEFAULT_MODE selection to arch/arm/mach-mvebu/Kconfig or
> > > > >>> some other common place. And when we will have fixed the DTS parsing
> > > > >>> problem, they can be removed.
> > > > >>>
> > > > >>> I'd like to hear from Stefan and Pali if this approach sounds good.
> > > > >>>
> > > > >>> All the best,
> > > > >>> Tony
> > > > >>
> > > > >> Well, the maximal SPI speed depends on the wiring. You can have on 
> > > > >> the
> > > > >> board some SPI device which does not support high frequency.
> > > > >>
> > > > >> But having some sane defaults in Kconfig for mvebu makes sense.
> > > >
> > > > Agreed.
> > > >
> > > > > The CONFIG_SF_DEFAULT_SPEED is set to 1_000_000 if the board defconfig
> > > > > does not specify it. I think the sane default value is 10_000_000
> > > > > (grepping the Armada* DTS files showing the slowest spi-max-frequency
> > > > > is 10_000_000). While a big improvement, it is not fast enough for
> > > > > many other boards. So we still need to define it in those board
> > > > > defconfigs (before fixing that bug), or use return to BootROM.
> > > >
> > > > I'm fine with setting CONFIG_SF_DEFAULT_SPEED to 10.000.000 for MVEBU.
> > > > Not sure if this should be done in drivers/mtd/spi/Kconfig, as this
> > > > currently has no platform- / board- specific configurations. Perhaps
> > > > it can be done in a mach-mvebu Kconfig file instead?
> > >
> > > Yes, I think it should be done in mach-mvebu Kconfig, too. I will run
> > > some tests.
> >
> > It is not related to this patch series (I also tested without the
> > patch series to confirm). But it is strange that I can no longer get
> > the configuration to boot from SPI. The 1st device in the boot order
> > is alway BOOTROM. The spl_boot_list is printed out below.
> >
> > 
> > High speed PHY - Ended Successfully
> > mv_ddr: 14.0.0
> > DDR4 Training Sequence - Switching XBAR Window to FastPath Window
> > mv_ddr: completed successfully
> > board_boot_order spl_boot_list[0] = 15
> > Trying to boot from BOOTROM
> > Returning to BootROM (return address 0x05c4)...
> > BootROM: Image checksum verification PASSED
> > 
> >
> > The SPL SPI configs (board Thecus N2350) are:
> > # grep SPL .config| grep SPI
> >
> > CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI=y
> > CONFIG_SPL_DM_SPI=y
> > CONFIG_SPL_SPI_FLASH_SUPPORT=y
> > CONFIG_SPL_SPI=y
> > CONFIG_SPL_DM_SPI_FLASH=y
> > CONFIG_SP

Re: [PATCH v5 0/6] FWU: Handle meta-data in common code

2023-02-27 Thread Jassi Brar
On Mon, 27 Feb 2023 at 18:58, Tom Rini  wrote:
>
> On Mon, Feb 27, 2023 at 06:51:35PM -0600, jassisinghb...@gmail.com wrote:
>
> > From: Jassi Brar 
> >
> > The patchset reduces ~400 lines of code, while keeping the functionality 
> > same and making
> > meta-data operations much faster (by using cached structures).
> >
> > Issue:
> >  meta-data copies (primary and secondary) are being handled by the 
> > backend/storage layer
> > instead of the common core in fwu.c (as also noted by Ilias)  that is, 
> > gpt_blk.c manages
> > meta-data and similarly raw_mtd.c will have to do the same when it arrives. 
> > The code
> > could by make smaller, cleaner and optimised.
> >
> > Basic idea:
> >  Introduce  .read_mdata() and .write_mdata() in fwu_mdata_ops  that simply 
> > read/write
> > meta-data copy. The core code takes care of integrity and redundancy of the 
> > meta-data,
> > as a result we can get rid of every other callback .get_mdata() 
> > .update_mdata()
> > .get_mdata_part_num()  .read_mdata_partition()  .write_mdata_partition() 
> > and the
> > corresponding wrapper functions thereby making the code 100s of LOC smaller.
> >
> > Get rid of fwu_check_mdata_validity() and fwu_mdata_check() which expected 
> > underlying
> > layer to manage and verify mdata copies.
> > Implement  fwu_get_verified_mdata(struct fwu_mdata *mdata) public function 
> > that reads,
> > verifies and, if needed, fixes the meta-data copies.
> >
> > Verified copy of meta-data is now cached as 'g_mdata' in fwu.c, which 
> > avoids multiple
> > low-level expensive read and parse calls.
> > gpt meta-data partition numbers are now cached in gpt_blk.c, so that we 
> > don't have to do expensive part_get_info() and uid ops.
> >
> > Changes since v4:
> > * Change fwu-mdata-mtd bindings to not require external changes
> > * Handle 'part == BOTH_PARTS' in fwu_sync_mdata
> > * use parts_ok[] and parts_mdata[] instead of pri/sec_ok and 
> > p/s_mdata
>
> Did you run this through CI / build sandbox? This doesn't read like you
> fixed the problem I reported in CI, when I was trying to merge v4.
>
I know that remains to be done.
The dt-bindings for fwu-mdata is changed in this patchset and I
thought any testcase may be impacted by it.

thanks.


Re: [PATCHv3 1/5] FWU: Add FWU metadata access driver for MTD storage regions

2023-02-27 Thread Jassi Brar
On Sat, 4 Feb 2023 at 22:09, Jassi Brar  wrote:
> >
> > +   fwu-mdata {
> > +   compatible = "u-boot,fwu-mdata-mtd";
> > +   fwu-mdata-store = <&spi_flash>;
> > +   mdata-offsets = <0x50 0x53>;
> > +   };
> >
> > which is based on DT going to location which is already labelled.
> >
> >   79 partition@50 {
> >   80 label = "Ex-OPTEE";
> >   81 reg = <0x50 0x20>;
> >   82 };
> >
> The 'ex-optee' is actually unused so we never faced any issue. But
> yes, this is inconsistent.
>
> > I don't know what this space is used for but the whole code around is using 
> > MTD
> > partitions and it's infrastructure and this is using RAW access without MTD.
> >
> > Why not to create separate partitions just for storing metadata?
> > And also identify them like that.
> >
> > Or just switch it to complete RAW mode without MTD and then offsets can be 
> > used
> > (but I expect with different dt description).
> >
> The design predates my involvement in fwu. I guess the reason was to
> have a mechanism similar to GPT based implementation which uses a
> similar fwu-mdata {} node structure.  It does make sense to have
> dedicated partitions for primary and  secondary meta-data, identified
> by uuid (like Banks) or standard labels. But may be Sughosh/Ilias know
> why the current approach was chosen.
>
I changed the bindings to not require any changes to any non-FWU subsystem.
Now every bit of info is contained in 'fwu-mdata' node.
   
https://lore.kernel.org/u-boot/20230228005218.1635781-1-jassisinghb...@gmail.com/T/#u

Thanks.


Re: [PATCH v5 0/6] FWU: Handle meta-data in common code

2023-02-27 Thread Tom Rini
On Mon, Feb 27, 2023 at 06:51:35PM -0600, jassisinghb...@gmail.com wrote:

> From: Jassi Brar 
> 
> The patchset reduces ~400 lines of code, while keeping the functionality same 
> and making
> meta-data operations much faster (by using cached structures).
> 
> Issue:
>  meta-data copies (primary and secondary) are being handled by the 
> backend/storage layer
> instead of the common core in fwu.c (as also noted by Ilias)  that is, 
> gpt_blk.c manages
> meta-data and similarly raw_mtd.c will have to do the same when it arrives. 
> The code
> could by make smaller, cleaner and optimised.
> 
> Basic idea:
>  Introduce  .read_mdata() and .write_mdata() in fwu_mdata_ops  that simply 
> read/write
> meta-data copy. The core code takes care of integrity and redundancy of the 
> meta-data,
> as a result we can get rid of every other callback .get_mdata() 
> .update_mdata()
> .get_mdata_part_num()  .read_mdata_partition()  .write_mdata_partition() and 
> the
> corresponding wrapper functions thereby making the code 100s of LOC smaller.
> 
> Get rid of fwu_check_mdata_validity() and fwu_mdata_check() which expected 
> underlying
> layer to manage and verify mdata copies.
> Implement  fwu_get_verified_mdata(struct fwu_mdata *mdata) public function 
> that reads,
> verifies and, if needed, fixes the meta-data copies.
> 
> Verified copy of meta-data is now cached as 'g_mdata' in fwu.c, which avoids 
> multiple
> low-level expensive read and parse calls.
> gpt meta-data partition numbers are now cached in gpt_blk.c, so that we don't 
> have to do expensive part_get_info() and uid ops.
> 
> Changes since v4:
> * Change fwu-mdata-mtd bindings to not require external changes
> * Handle 'part == BOTH_PARTS' in fwu_sync_mdata
> * use parts_ok[] and parts_mdata[] instead of pri/sec_ok and p/s_mdata

Did you run this through CI / build sandbox? This doesn't read like you
fixed the problem I reported in CI, when I was trying to merge v4.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v5 6/6] fwu: rename fwu_get_verified_mdata to fwu_get_mdata

2023-02-27 Thread jassisinghbrar
From: Jassi Brar 

fwu_get_mdata() sounds more appropriate than fwu_get_verified_mdata()

Signed-off-by: Jassi Brar 
Reviewed-by: Etienne Carriere 
Reviewed-by: Ilias Apalodimas 
---
 cmd/fwu_mdata.c   | 2 +-
 include/fwu.h | 4 ++--
 lib/fwu_updates/fwu.c | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/cmd/fwu_mdata.c b/cmd/fwu_mdata.c
index 9b70340368..5ecda455df 100644
--- a/cmd/fwu_mdata.c
+++ b/cmd/fwu_mdata.c
@@ -46,7 +46,7 @@ int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag,
int ret = CMD_RET_SUCCESS, res;
struct fwu_mdata mdata;
 
-   res = fwu_get_verified_mdata(&mdata);
+   res = fwu_get_mdata(&mdata);
if (res < 0) {
log_err("Unable to get valid FWU metadata\n");
ret = CMD_RET_FAILURE;
diff --git a/include/fwu.h b/include/fwu.h
index 23bd97fe86..ea25aca2cd 100644
--- a/include/fwu.h
+++ b/include/fwu.h
@@ -80,7 +80,7 @@ int fwu_read_mdata(struct udevice *dev, struct fwu_mdata 
*mdata, bool primary);
 int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool 
primary);
 
 /**
- * fwu_get_verified_mdata() - Read, verify and return the FWU metadata
+ * fwu_get_mdata() - Read, verify and return the FWU metadata
  *
  * Read both the metadata copies from the storage media, verify their checksum,
  * and ascertain that both copies match. If one of the copies has gone bad,
@@ -88,7 +88,7 @@ int fwu_write_mdata(struct udevice *dev, struct fwu_mdata 
*mdata, bool primary);
  *
  * Return: 0 if OK, -ve on error
 */
-int fwu_get_verified_mdata(struct fwu_mdata *mdata);
+int fwu_get_mdata(struct fwu_mdata *mdata);
 
 /**
  * fwu_get_active_index() - Get active_index from the FWU metadata
diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
index 14a2af2c74..562aa7df8c 100644
--- a/lib/fwu_updates/fwu.c
+++ b/lib/fwu_updates/fwu.c
@@ -189,7 +189,7 @@ static inline int mdata_crc_check(struct fwu_mdata *mdata)
 }
 
 /**
- * fwu_get_verified_mdata() - Read, verify and return the FWU metadata
+ * fwu_get_mdata() - Read, verify and return the FWU metadata
  *
  * Read both the metadata copies from the storage media, verify their checksum,
  * and ascertain that both copies match. If one of the copies has gone bad,
@@ -197,7 +197,7 @@ static inline int mdata_crc_check(struct fwu_mdata *mdata)
  *
  * Return: 0 if OK, -ve on error
  */
-int fwu_get_verified_mdata(struct fwu_mdata *mdata)
+int fwu_get_mdata(struct fwu_mdata *mdata)
 {
int err;
bool parts_ok[2] = { false };
@@ -614,7 +614,7 @@ static int fwu_boottime_checks(void *ctx, struct event 
*event)
return ret;
}
 
-   ret = fwu_get_verified_mdata(NULL);
+   ret = fwu_get_mdata(NULL);
if (ret) {
log_debug("Unable to read meta-data\n");
return ret;
-- 
2.34.1



[PATCH v5 5/6] fwu: meta-data: switch to management by common code

2023-02-27 Thread jassisinghbrar
From: Jassi Brar 

The common code can now read, verify and fix meta-data copies
while exposing one consistent structure to users.
 Only the .read_mdata() and .write_mdata() callbacks of fwu_mdata_ops
are needed. Get rid of .get_mdata() .update_mdata() .get_mdata_part_num()
.read_mdata_partition() and .write_mdata_partition() and also the
corresponding wrapper functions.

Signed-off-by: Jassi Brar 
Reviewed-by: Etienne Carriere 
---
 cmd/fwu_mdata.c  |  17 +-
 drivers/fwu-mdata/fwu-mdata-uclass.c | 165 ---
 drivers/fwu-mdata/gpt_blk.c  | 124 +-
 include/fwu.h| 199 ---
 lib/fwu_updates/fwu.c| 235 ---
 5 files changed, 38 insertions(+), 702 deletions(-)

diff --git a/cmd/fwu_mdata.c b/cmd/fwu_mdata.c
index f04af27de6..9b70340368 100644
--- a/cmd/fwu_mdata.c
+++ b/cmd/fwu_mdata.c
@@ -43,23 +43,10 @@ static void print_mdata(struct fwu_mdata *mdata)
 int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag,
 int argc, char * const argv[])
 {
-   struct udevice *dev;
int ret = CMD_RET_SUCCESS, res;
-   struct fwu_mdata mdata = { 0 };
+   struct fwu_mdata mdata;
 
-   if (uclass_get_device(UCLASS_FWU_MDATA, 0, &dev) || !dev) {
-   log_err("Unable to get FWU metadata device\n");
-   return CMD_RET_FAILURE;
-   }
-
-   res = fwu_check_mdata_validity();
-   if (res < 0) {
-   log_err("FWU Metadata check failed\n");
-   ret = CMD_RET_FAILURE;
-   goto out;
-   }
-
-   res = fwu_get_mdata(dev, &mdata);
+   res = fwu_get_verified_mdata(&mdata);
if (res < 0) {
log_err("Unable to get valid FWU metadata\n");
ret = CMD_RET_FAILURE;
diff --git a/drivers/fwu-mdata/fwu-mdata-uclass.c 
b/drivers/fwu-mdata/fwu-mdata-uclass.c
index e03773c584..0a8edaaa41 100644
--- a/drivers/fwu-mdata/fwu-mdata-uclass.c
+++ b/drivers/fwu-mdata/fwu-mdata-uclass.c
@@ -14,7 +14,6 @@
 
 #include 
 #include 
-#include 
 
 /**
  * fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata()
@@ -50,170 +49,6 @@ int fwu_write_mdata(struct udevice *dev, struct fwu_mdata 
*mdata, bool primary)
return ops->write_mdata(dev, mdata, primary);
 }
 
-/**
- * fwu_get_mdata_part_num() - Get the FWU metadata partition numbers
- * @dev: FWU metadata device
- * @mdata_parts: array for storing the metadata partition numbers
- *
- * Get the partition numbers on the storage device on which the
- * FWU metadata is stored. Two partition numbers will be returned.
- *
- * Return: 0 if OK, -ve on error
- *
- */
-int fwu_get_mdata_part_num(struct udevice *dev, uint *mdata_parts)
-{
-   const struct fwu_mdata_ops *ops = device_get_ops(dev);
-
-   if (!ops->get_mdata_part_num) {
-   log_debug("get_mdata_part_num() method not defined\n");
-   return -ENOSYS;
-   }
-
-   return ops->get_mdata_part_num(dev, mdata_parts);
-}
-
-/**
- * fwu_read_mdata_partition() - Read the FWU metadata from a partition
- * @dev: FWU metadata device
- * @mdata: Copy of the FWU metadata
- * @part_num: Partition number from which FWU metadata is to be read
- *
- * Read the FWU metadata from the specified partition number
- *
- * Return: 0 if OK, -ve on error
- *
- */
-int fwu_read_mdata_partition(struct udevice *dev, struct fwu_mdata *mdata,
-uint part_num)
-{
-   const struct fwu_mdata_ops *ops = device_get_ops(dev);
-
-   if (!ops->read_mdata_partition) {
-   log_debug("read_mdata_partition() method not defined\n");
-   return -ENOSYS;
-   }
-
-   return ops->read_mdata_partition(dev, mdata, part_num);
-}
-
-/**
- * fwu_write_mdata_partition() - Write the FWU metadata to a partition
- * @dev: FWU metadata device
- * @mdata: Copy of the FWU metadata
- * @part_num: Partition number to which FWU metadata is to be written
- *
- * Write the FWU metadata to the specified partition number
- *
- * Return: 0 if OK, -ve on error
- *
- */
-int fwu_write_mdata_partition(struct udevice *dev, struct fwu_mdata *mdata,
- uint part_num)
-{
-   const struct fwu_mdata_ops *ops = device_get_ops(dev);
-
-   if (!ops->write_mdata_partition) {
-   log_debug("write_mdata_partition() method not defined\n");
-   return -ENOSYS;
-   }
-
-   return ops->write_mdata_partition(dev, mdata, part_num);
-}
-
-/**
- * fwu_mdata_check() - Check if the FWU metadata is valid
- * @dev: FWU metadata device
- *
- * Validate both copies of the FWU metadata. If one of the copies
- * has gone bad, restore it from the other copy.
- *
- * Return: 0 if OK, -ve on error
- *
- */
-int fwu_mdata_check(struct udevice *dev)
-{
-   const struct fwu_mdata_ops *ops = device_get_ops(dev);
-
-   if (!ops->check_mdata) {
-   log_debug("check_mdata() method

[PATCH v5 4/6] fwu: gpt: implement read_mdata and write_mdata callbacks

2023-02-27 Thread jassisinghbrar
From: Jassi Brar 

Moving towards using common code for meta-data management,
implement the read/write mdata hooks.

Signed-off-by: Jassi Brar 
Reviewed-by: Etienne Carriere 
Reviewed-by: Ilias Apalodimas 
---
 drivers/fwu-mdata/gpt_blk.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/drivers/fwu-mdata/gpt_blk.c b/drivers/fwu-mdata/gpt_blk.c
index 28f5d23e1e..bdaa10cd1d 100644
--- a/drivers/fwu-mdata/gpt_blk.c
+++ b/drivers/fwu-mdata/gpt_blk.c
@@ -272,7 +272,43 @@ static int fwu_mdata_gpt_blk_probe(struct udevice *dev)
return 0;
 }
 
+static int fwu_gpt_read_mdata(struct udevice *dev, struct fwu_mdata *mdata,
+bool primary)
+{
+   struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev);
+   struct blk_desc *desc = dev_get_uclass_plat(priv->blk_dev);
+   int ret;
+
+   ret = gpt_get_mdata_partitions(desc);
+   if (ret < 0) {
+   log_debug("Error getting the FWU metadata partitions\n");
+   return -ENOENT;
+   }
+
+   return gpt_read_write_mdata(desc, mdata, MDATA_READ,
+primary ? g_mdata_part[0] : g_mdata_part[1]);
+}
+
+static int fwu_gpt_write_mdata(struct udevice *dev, struct fwu_mdata *mdata,
+bool primary)
+{
+   struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev);
+   struct blk_desc *desc = dev_get_uclass_plat(priv->blk_dev);
+   int ret;
+
+   ret = gpt_get_mdata_partitions(desc);
+   if (ret < 0) {
+   log_debug("Error getting the FWU metadata partitions\n");
+   return -ENOENT;
+   }
+
+   return gpt_read_write_mdata(desc, mdata, MDATA_WRITE,
+primary ? g_mdata_part[0] : g_mdata_part[1]);
+}
+
 static const struct fwu_mdata_ops fwu_gpt_blk_ops = {
+   .read_mdata = fwu_gpt_read_mdata,
+   .write_mdata = fwu_gpt_write_mdata,
.get_mdata = fwu_gpt_get_mdata,
.update_mdata = fwu_gpt_update_mdata,
.get_mdata_part_num = fwu_gpt_get_mdata_partitions,
-- 
2.34.1



[PATCH v5 3/6] fwu: move meta-data management in core

2023-02-27 Thread jassisinghbrar
From: Jassi Brar 

Instead of each i/f having to implement their own meta-data verification
and storage, move the logic in common code. This simplifies the i/f code
much simpler and compact.

Signed-off-by: Jassi Brar 
---
 drivers/fwu-mdata/fwu-mdata-uclass.c |  34 +++
 include/fwu.h|  41 +
 lib/fwu_updates/fwu.c| 130 +--
 3 files changed, 200 insertions(+), 5 deletions(-)

diff --git a/drivers/fwu-mdata/fwu-mdata-uclass.c 
b/drivers/fwu-mdata/fwu-mdata-uclass.c
index b477e9603f..e03773c584 100644
--- a/drivers/fwu-mdata/fwu-mdata-uclass.c
+++ b/drivers/fwu-mdata/fwu-mdata-uclass.c
@@ -16,6 +16,40 @@
 #include 
 #include 
 
+/**
+ * fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata()
+ *
+ * Return: 0 if OK, -ve on error
+ */
+int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary)
+{
+   const struct fwu_mdata_ops *ops = device_get_ops(dev);
+
+   if (!ops->read_mdata) {
+   log_debug("read_mdata() method not defined\n");
+   return -ENOSYS;
+   }
+
+   return ops->read_mdata(dev, mdata, primary);
+}
+
+/**
+ * fwu_write_mdata() - Wrapper around fwu_mdata_ops.write_mdata()
+ *
+ * Return: 0 if OK, -ve on error
+ */
+int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary)
+{
+   const struct fwu_mdata_ops *ops = device_get_ops(dev);
+
+   if (!ops->write_mdata) {
+   log_debug("write_mdata() method not defined\n");
+   return -ENOSYS;
+   }
+
+   return ops->write_mdata(dev, mdata, primary);
+}
+
 /**
  * fwu_get_mdata_part_num() - Get the FWU metadata partition numbers
  * @dev: FWU metadata device
diff --git a/include/fwu.h b/include/fwu.h
index 0919ced812..1a700c9e6a 100644
--- a/include/fwu.h
+++ b/include/fwu.h
@@ -24,6 +24,26 @@ struct fwu_mdata_gpt_blk_priv {
  * @update_mdata() - Update the FWU metadata copy
  */
 struct fwu_mdata_ops {
+   /**
+* read_mdata() - Populate the asked FWU metadata copy
+* @dev: FWU metadata device
+* @mdata: Copy of the FWU metadata
+* @primary: If primary or secondary copy of meta-data is to be read
+*
+* Return: 0 if OK, -ve on error
+*/
+   int (*read_mdata)(struct udevice *dev, struct fwu_mdata *mdata, bool 
primary);
+
+   /**
+* write_mdata() - Write the given FWU metadata copy
+* @dev: FWU metadata device
+* @mdata: Copy of the FWU metadata
+* @primary: If primary or secondary copy of meta-data is to be written
+*
+* Return: 0 if OK, -ve on error
+*/
+   int (*write_mdata)(struct udevice *dev, struct fwu_mdata *mdata, bool 
primary);
+
/**
 * check_mdata() - Check if the FWU metadata is valid
 * @dev:FWU device
@@ -126,6 +146,27 @@ struct fwu_mdata_ops {
EFI_GUID(0x0c996046, 0xbcc0, 0x4d04, 0x85, 0xec, \
 0xe1, 0xfc, 0xed, 0xf1, 0xc6, 0xf8)
 
+/**
+ * fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata()
+ */
+int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary);
+
+/**
+ * fwu_write_mdata() - Wrapper around fwu_mdata_ops.write_mdata()
+ */
+int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool 
primary);
+
+/**
+ * fwu_get_verified_mdata() - Read, verify and return the FWU metadata
+ *
+ * Read both the metadata copies from the storage media, verify their checksum,
+ * and ascertain that both copies match. If one of the copies has gone bad,
+ * restore it from the good copy.
+ *
+ * Return: 0 if OK, -ve on error
+*/
+int fwu_get_verified_mdata(struct fwu_mdata *mdata);
+
 /**
  * fwu_check_mdata_validity() - Check for validity of the FWU metadata copies
  *
diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
index 5313d07302..7d195964a2 100644
--- a/lib/fwu_updates/fwu.c
+++ b/lib/fwu_updates/fwu.c
@@ -15,13 +15,13 @@
 #include 
 #include 
 
+#include 
+
+static struct fwu_mdata g_mdata; /* = {0} makes uninit crc32 always invalid */
+static struct udevice *g_dev;
 static u8 in_trial;
 static u8 boottime_check;
 
-#include 
-#include 
-#include 
-
 enum {
IMAGE_ACCEPT_SET = 1,
IMAGE_ACCEPT_CLEAR,
@@ -161,6 +161,126 @@ static int fwu_get_image_type_id(u8 *image_index, 
efi_guid_t *image_type_id)
return -ENOENT;
 }
 
+/**
+ * fwu_sync_mdata() - Update given meta-data partition(s) with the copy 
provided
+ * @mdata: FWU metadata structure
+ * @part: Bitmask of FWU metadata partitions to be written to
+ *
+ * Return: 0 if OK, -ve on error
+ */
+static int fwu_sync_mdata(struct fwu_mdata *mdata, int part)
+{
+   void *buf = &mdata->version;
+   int err;
+
+   if (part == BOTH_PARTS) {
+   err = fwu_sync_mdata(mdata, SECONDARY_PART);
+   if (err)
+   return err;
+   part = PRIMARY_PART;
+   }
+
+   /*
+* Calculate th

[PATCH v5 2/6] fwu: gpt: use cached meta-data partition numbers

2023-02-27 Thread jassisinghbrar
From: Jassi Brar 

Use cached values and avoid parsing and scanning through partitions
everytime for meta-data partitions because they can't change after bootup.

Acked-by: Etienne Carriere 
Reviewed-by: Ilias Apalodimas 
Signed-off-by: Jassi Brar 
---
 drivers/fwu-mdata/gpt_blk.c | 43 +
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/fwu-mdata/gpt_blk.c b/drivers/fwu-mdata/gpt_blk.c
index d35ce49c5c..28f5d23e1e 100644
--- a/drivers/fwu-mdata/gpt_blk.c
+++ b/drivers/fwu-mdata/gpt_blk.c
@@ -24,8 +24,9 @@ enum {
MDATA_WRITE,
 };
 
-static int gpt_get_mdata_partitions(struct blk_desc *desc,
-   uint mdata_parts[2])
+static uint g_mdata_part[2]; /* = {0, 0} to check against uninit parts */
+
+static int gpt_get_mdata_partitions(struct blk_desc *desc)
 {
int i, ret;
u32 nparts;
@@ -33,18 +34,19 @@ static int gpt_get_mdata_partitions(struct blk_desc *desc,
struct disk_partition info;
const efi_guid_t fwu_mdata_guid = FWU_MDATA_GUID;
 
+   /* if primary and secondary partitions already found */
+   if (g_mdata_part[0] && g_mdata_part[1])
+   return 0;
+
nparts = 0;
-   for (i = 1; i < MAX_SEARCH_PARTITIONS; i++) {
+   for (i = 1; i < MAX_SEARCH_PARTITIONS && nparts < 2; i++) {
if (part_get_info(desc, i, &info))
continue;
uuid_str_to_bin(info.type_guid, part_type_guid.b,
UUID_STR_FORMAT_GUID);
 
-   if (!guidcmp(&fwu_mdata_guid, &part_type_guid)) {
-   if (nparts < 2)
-   mdata_parts[nparts] = i;
-   ++nparts;
-   }
+   if (!guidcmp(&fwu_mdata_guid, &part_type_guid))
+   g_mdata_part[nparts++] = i;
}
 
if (nparts != 2) {
@@ -127,26 +129,25 @@ static int fwu_gpt_update_mdata(struct udevice *dev, 
struct fwu_mdata *mdata)
 {
int ret;
struct blk_desc *desc;
-   uint mdata_parts[2];
struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev);
 
desc = dev_get_uclass_plat(priv->blk_dev);
 
-   ret = gpt_get_mdata_partitions(desc, mdata_parts);
+   ret = gpt_get_mdata_partitions(desc);
if (ret < 0) {
log_debug("Error getting the FWU metadata partitions\n");
return -ENOENT;
}
 
/* First write the primary partition */
-   ret = gpt_read_write_mdata(desc, mdata, MDATA_WRITE, mdata_parts[0]);
+   ret = gpt_read_write_mdata(desc, mdata, MDATA_WRITE, g_mdata_part[0]);
if (ret < 0) {
log_debug("Updating primary FWU metadata partition failed\n");
return ret;
}
 
/* And now the replica */
-   ret = gpt_read_write_mdata(desc, mdata, MDATA_WRITE, mdata_parts[1]);
+   ret = gpt_read_write_mdata(desc, mdata, MDATA_WRITE, g_mdata_part[1]);
if (ret < 0) {
log_debug("Updating secondary FWU metadata partition failed\n");
return ret;
@@ -158,16 +159,14 @@ static int fwu_gpt_update_mdata(struct udevice *dev, 
struct fwu_mdata *mdata)
 static int gpt_get_mdata(struct blk_desc *desc, struct fwu_mdata *mdata)
 {
int ret;
-   uint mdata_parts[2];
-
-   ret = gpt_get_mdata_partitions(desc, mdata_parts);
 
+   ret = gpt_get_mdata_partitions(desc);
if (ret < 0) {
log_debug("Error getting the FWU metadata partitions\n");
return -ENOENT;
}
 
-   ret = gpt_read_write_mdata(desc, mdata, MDATA_READ, mdata_parts[0]);
+   ret = gpt_read_write_mdata(desc, mdata, MDATA_READ, g_mdata_part[0]);
if (ret < 0) {
log_debug("Failed to read the FWU metadata from the device\n");
return -EIO;
@@ -182,7 +181,7 @@ static int gpt_get_mdata(struct blk_desc *desc, struct 
fwu_mdata *mdata)
 * Try to read the replica.
 */
memset(mdata, '\0', sizeof(struct fwu_mdata));
-   ret = gpt_read_write_mdata(desc, mdata, MDATA_READ, mdata_parts[1]);
+   ret = gpt_read_write_mdata(desc, mdata, MDATA_READ, g_mdata_part[1]);
if (ret < 0) {
log_debug("Failed to read the FWU metadata from the device\n");
return -EIO;
@@ -206,9 +205,15 @@ static int fwu_gpt_get_mdata(struct udevice *dev, struct 
fwu_mdata *mdata)
 static int fwu_gpt_get_mdata_partitions(struct udevice *dev, uint *mdata_parts)
 {
struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev);
+   int err;
+
+   err = gpt_get_mdata_partitions(dev_get_uclass_plat(priv->blk_dev));
+   if (!err) {
+   mdata_parts[0] = g_mdata_part[0];
+   mdata_parts[1] = g_mdata_part[1];
+   }
 
-   return gpt_get_mdata_partitions(dev_get_uclass_plat(priv->blk_dev),
-   mdata_parts)

[PATCH v5 1/6] dt/bindings: fwu-mdata-mtd: drop changes outside FWU

2023-02-27 Thread jassisinghbrar
From: Jassi Brar 

Any requirement of FWU should not require changes to bindings
of other subsystems. For example, for mtd-backed storage we
can do without requiring 'fixed-partitions' children to also
carry 'uuid', a property which is non-standard and not in the
bindings.

 There exists no code yet, so we can change the fwu-mtd bindings
to contain all properties within the fwu-mdata node.

Signed-off-by: Jassi Brar 
---
 .../firmware/fwu-mdata-mtd.yaml   | 105 +++---
 1 file changed, 91 insertions(+), 14 deletions(-)

diff --git a/doc/device-tree-bindings/firmware/fwu-mdata-mtd.yaml 
b/doc/device-tree-bindings/firmware/fwu-mdata-mtd.yaml
index 4f5404f999..4b87fb8624 100644
--- a/doc/device-tree-bindings/firmware/fwu-mdata-mtd.yaml
+++ b/doc/device-tree-bindings/firmware/fwu-mdata-mtd.yaml
@@ -1,13 +1,13 @@
 # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
 %YAML 1.2
 ---
-$id: http://devicetree.org/schemas/firmware/u-boot,fwu-mdata-sf.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
+$id: http://devicetree.org/schemas/firmware/u-boot,fwu-mdata-mtd.yaml#
+$schema: http://devicetree.org/meta-schemas/base.yaml#
 
 title: FWU metadata on MTD device without GPT
 
 maintainers:
- - Masami Hiramatsu 
+ - Jassi Brar 
 
 properties:
   compatible:
@@ -15,24 +15,101 @@ properties:
   - const: u-boot,fwu-mdata-mtd
 
   fwu-mdata-store:
-maxItems: 1
-description: Phandle of the MTD device which contains the FWU medatata.
+$ref: /schemas/types.yaml#/definitions/phandle
+description: Phandle of the MTD device which contains the FWU MetaData and 
Banks.
 
-  mdata-offsets:
+  mdata-parts:
+$ref: /schemas/types.yaml#/definitions/non-unique-string-array
 minItems: 2
-description: Offsets of the primary and secondary FWU metadata in the NOR 
flash.
+maxItems: 2
+description: labels of the primary and secondary FWU metadata partitions 
in the 'fixed-partitions' subnode of the 'jedec,spi-nor' flash device node.
+
+  patternProperties:
+"fwu-bank@[0-9]":
+type: object
+description: List of FWU mtd-backed banks. Typically two banks.
+
+properties:
+  id:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: Index of the bank.
+
+  label:
+$ref: /schemas/types.yaml#/definitions/non-unique-string-array
+minItems: 1
+maxItems: 1
+description: label of the partition, in the 'fixed-partitions' subnode 
of the 'jedec,spi-nor' flash device node, that holds this bank.
+
+  patternProperties:
+"fwu-image@[0-9]":
+type: object
+description: List of images in the FWU mtd-backed bank.
+
+properties:
+  id:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: Index of the bank.
+
+  offset:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: Offset, from start of the bank, where the image is 
located.
+
+  size:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: Size reserved for the image.
+
+  uuid:
+$ref: /schemas/types.yaml#/definitions/non-unique-string-array
+minItems: 1
+maxItems: 1
+description: UUID of the image.
+
+required:
+  - id
+  - offset
+  - size
+  - uuid
+additionalProperties: false
+
+required:
+  - id
+  - label
+  - fwu-images
+additionalProperties: false
 
 required:
   - compatible
   - fwu-mdata-store
-  - mdata-offsets
-
+  - mdata-parts
+  - fwu-banks
 additionalProperties: false
 
 examples:
   - |
-fwu-mdata {
-compatible = "u-boot,fwu-mdata-mtd";
-fwu-mdata-store = <&spi-flash>;
-mdata-offsets = <0x50 0x53>;
-};
+   fwu-mdata {
+   compatible = "u-boot,fwu-mdata-mtd";
+   fwu-mdata-store = <&flash0>;
+   mdata-parts = "MDATA-Pri", "MDATA-Sec";
+
+   fwu-bank@0 {
+   id = <0>;
+   label = "FIP-Bank0";
+   fwu-image@0 {
+   id = <0>;
+   offset = <0x0>;
+   size = <0x40>;
+   uuid = "5a66a702-99fd-4fef-a392-c26e261a2828";
+   };
+   };
+   fwu-bank@1 {
+   id = <1>;
+   label = "FIP-Bank1";
+   fwu-image@0 {
+   id = <0>;
+   offset = <0x0>;
+   size = <0x40>;
+   uuid = "a8f868a1-6e5c-4757-878d-ce63375ef2c0";
+   };
+   };
+   };
+...
-- 
2.34.1



[PATCH v5 0/6] FWU: Handle meta-data in common code

2023-02-27 Thread jassisinghbrar
From: Jassi Brar 

The patchset reduces ~400 lines of code, while keeping the functionality same 
and making
meta-data operations much faster (by using cached structures).

Issue:
 meta-data copies (primary and secondary) are being handled by the 
backend/storage layer
instead of the common core in fwu.c (as also noted by Ilias)  that is, 
gpt_blk.c manages
meta-data and similarly raw_mtd.c will have to do the same when it arrives. The 
code
could by make smaller, cleaner and optimised.

Basic idea:
 Introduce  .read_mdata() and .write_mdata() in fwu_mdata_ops  that simply 
read/write
meta-data copy. The core code takes care of integrity and redundancy of the 
meta-data,
as a result we can get rid of every other callback .get_mdata() .update_mdata()
.get_mdata_part_num()  .read_mdata_partition()  .write_mdata_partition() and the
corresponding wrapper functions thereby making the code 100s of LOC smaller.

Get rid of fwu_check_mdata_validity() and fwu_mdata_check() which expected 
underlying
layer to manage and verify mdata copies.
Implement  fwu_get_verified_mdata(struct fwu_mdata *mdata) public function that 
reads,
verifies and, if needed, fixes the meta-data copies.

Verified copy of meta-data is now cached as 'g_mdata' in fwu.c, which avoids 
multiple
low-level expensive read and parse calls.
gpt meta-data partition numbers are now cached in gpt_blk.c, so that we don't 
have to do expensive part_get_info() and uid ops.

Changes since v4:
* Change fwu-mdata-mtd bindings to not require external changes
* Handle 'part == BOTH_PARTS' in fwu_sync_mdata
* use parts_ok[] and parts_mdata[] instead of pri/sec_ok and p/s_mdata

Changes since v3:
* Fix error log wording
* call fwu_write_mdata() with part & PRIMARY_PART ? true: false

Changes since v2:
* Drop whitespace changes
* Fix missing mdata copy before return

Changes since v1:
* Fix typos and misc cosmetic changes
* Catch error returns

Jassi Brar (6):
  dt/bindings: fwu-mdata-mtd: drop changes outside FWU
  fwu: gpt: use cached meta-data partition numbers
  fwu: move meta-data management in core
  fwu: gpt: implement read_mdata and write_mdata callbacks
  fwu: meta-data: switch to management by common code
  fwu: rename fwu_get_verified_mdata to fwu_get_mdata

 cmd/fwu_mdata.c   |  17 +-
 .../firmware/fwu-mdata-mtd.yaml   | 105 ++-
 drivers/fwu-mdata/fwu-mdata-uclass.c  | 151 +
 drivers/fwu-mdata/gpt_blk.c   | 175 +++
 include/fwu.h | 198 ++--
 lib/fwu_updates/fwu.c | 295 +++---
 6 files changed, 295 insertions(+), 646 deletions(-)

-- 
2.34.1



Re: [PATCH 2/2] arm: mvebu: clearfog: Add defconfig for SPI booting

2023-02-27 Thread Tony Dinh
Hi Pali,

On Mon, Feb 27, 2023 at 3:41 PM Tony Dinh  wrote:
>
> Hi Pali,
>
> On Mon, Feb 27, 2023 at 1:57 PM Tony Dinh  wrote:
> >
> > Hi Stefan,
> >
> > On Sun, Feb 26, 2023 at 11:40 PM Stefan Roese  wrote:
> > >
> > > Hi Tony,
> > >
> > > On 2/27/23 01:11, Tony Dinh wrote:
> > > > Hi Pali,
> > > >
> > > > On Sun, Feb 26, 2023 at 2:52 AM Pali Rohár  wrote:
> > > >>
> > > >> On Saturday 25 February 2023 20:56:10 Tony Dinh wrote:
> > > >>> Hi Martin,
> > > >>>
> > > >>> On Sat, Feb 25, 2023 at 6:17 PM Martin Rowe  
> > > >>> wrote:
> > > 
> > > >>> I'm not sure how to run proper timing tests on the process, but
> > > >>> stopwatch timing just between seeing "Trying to boot" and "U-Boot
> > > >>> 2023.04-rc2" showed the return to BootROM under 1 second, and the
> > > >>> direct from SPI around 4 seconds. I thought the goal of loading 
> > > >>> from
> > > >>> SPI directly was speed, but returning to BootROM is significantly
> > > >>> faster on this board.
> > > >>
> > > >> You should check SPI speed in DTS file and also in the defconfig.
> > > >
> > > > I think we have probably seen this slowdown before. There is a TODO 
> > > > in
> > > > the way the DTS nodes are parsed by DM uclass. So this config must 
> > > > be
> > > > set in defconfig to get around that bug:
> > > > CONFIG_SF_DEFAULT_SPEED=5000
> > > 
> > >  That works and is much faster now. I'll submit it in a V2 for these
> > >  two patches once Pali's mvebu changes are accepted. Only question I
> > >  have is: should the faster speed be applied to all three defconfigs?
> > >  CONFIG_SF_DEFAULT_SPEED=100 (50x less) is implicitly added to the
> > >  MMC and SATA configs at the moment.
> > > >>>
> > > >>> This is only a workaround to get the SPI probe to work correctly. The
> > > >>> real fix should be in spi_flash_probe()
> > > >>> ./common/spl/spl_spi.c
> > > >>>  flash = spi_flash_probe(sf_bus, sf_cs,
> > > >>>  CONFIG_SF_DEFAULT_SPEED,
> > > >>>  CONFIG_SF_DEFAULT_MODE);
> > > >>> If spi_flash_probe() failed to get SPI max_hz from the DTS, the
> > > >>> fallback is CONFIG_SF_DEFAULT_SPEED.
> > > >>>
> > > >>> IMO, perhaps we could add CONFIG_SF_DEFAULT_SPEED and
> > > >>> CONFIG_SF_DEFAULT_MODE selection to arch/arm/mach-mvebu/Kconfig or
> > > >>> some other common place. And when we will have fixed the DTS parsing
> > > >>> problem, they can be removed.
> > > >>>
> > > >>> I'd like to hear from Stefan and Pali if this approach sounds good.
> > > >>>
> > > >>> All the best,
> > > >>> Tony
> > > >>
> > > >> Well, the maximal SPI speed depends on the wiring. You can have on the
> > > >> board some SPI device which does not support high frequency.
> > > >>
> > > >> But having some sane defaults in Kconfig for mvebu makes sense.
> > >
> > > Agreed.
> > >
> > > > The CONFIG_SF_DEFAULT_SPEED is set to 1_000_000 if the board defconfig
> > > > does not specify it. I think the sane default value is 10_000_000
> > > > (grepping the Armada* DTS files showing the slowest spi-max-frequency
> > > > is 10_000_000). While a big improvement, it is not fast enough for
> > > > many other boards. So we still need to define it in those board
> > > > defconfigs (before fixing that bug), or use return to BootROM.
> > >
> > > I'm fine with setting CONFIG_SF_DEFAULT_SPEED to 10.000.000 for MVEBU.
> > > Not sure if this should be done in drivers/mtd/spi/Kconfig, as this
> > > currently has no platform- / board- specific configurations. Perhaps
> > > it can be done in a mach-mvebu Kconfig file instead?
> >
> > Yes, I think it should be done in mach-mvebu Kconfig, too. I will run
> > some tests.
>
> It is not related to this patch series (I also tested without the
> patch series to confirm). But it is strange that I can no longer get
> the configuration to boot from SPI. The 1st device in the boot order
> is alway BOOTROM. The spl_boot_list is printed out below.
>
> 
> High speed PHY - Ended Successfully
> mv_ddr: 14.0.0
> DDR4 Training Sequence - Switching XBAR Window to FastPath Window
> mv_ddr: completed successfully
> board_boot_order spl_boot_list[0] = 15
> Trying to boot from BOOTROM
> Returning to BootROM (return address 0x05c4)...
> BootROM: Image checksum verification PASSED
> 
>
> The SPL SPI configs (board Thecus N2350) are:
> # grep SPL .config| grep SPI
>
> CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI=y
> CONFIG_SPL_DM_SPI=y
> CONFIG_SPL_SPI_FLASH_SUPPORT=y
> CONFIG_SPL_SPI=y
> CONFIG_SPL_DM_SPI_FLASH=y
> CONFIG_SPL_SPI_FLASH_TINY=y
> # CONFIG_SPL_SPI_FLASH_MTD is not set
> CONFIG_SPL_SPI_LOAD=y
>
> Did I miss something new lately?
>
> Thanks,
> Tony
>
> Trying to boot from BOOTROM
> Returning to BootROM (return address 0x05c4)...
> BootROM: Image checksum verification PASSED

It turns out that the board strapping register itself is the problem.
boot_device=0x9 was printed out in arch/arm/mach-mv

Re: [RFC PATCH] binman: bintool: etype: Add support for ti-secure entry

2023-02-27 Thread Simon Glass
Hi Neha,

On Fri, 24 Feb 2023 at 05:03, Neha Malcom Francis  wrote:
>
> core-secdev-k3 is the TI security development package provided for K3
> platform devices. This tool helps sign bootloader images with the x509
> ceritificate header.
>
> Signed-off-by: Neha Malcom Francis 
> ---
> This patch depends on 
> https://patchwork.ozlabs.org/project/uboot/patch/20230224115101.563729-1-n-fran...@ti.com/
> and on ongoing development in 
> https://git.ti.com/cgit/security-development-tools/core-secdev-k3
>
>  tools/binman/btool/tisecuretool.py|  72 +++
>  tools/binman/etype/ti_secure.py   | 114 ++
>  tools/binman/ftest.py |  36 ++
>  tools/binman/test/278_ti_secure_rom.dts   |  11 ++
>  tools/binman/test/279_ti_secure.dts   |  11 ++
>  .../binman/test/280_ti_secure_nofilename.dts  |  10 ++
>  tools/binman/test/281_ti_secure_combined.dts  |  12 ++
>  7 files changed, 266 insertions(+)
>  create mode 100644 tools/binman/btool/tisecuretool.py
>  create mode 100644 tools/binman/etype/ti_secure.py
>  create mode 100644 tools/binman/test/278_ti_secure_rom.dts
>  create mode 100644 tools/binman/test/279_ti_secure.dts
>  create mode 100644 tools/binman/test/280_ti_secure_nofilename.dts
>  create mode 100644 tools/binman/test/281_ti_secure_combined.dts

Now that I see what you are doing, this it not quite the right way.

See this hack-up of how you can call the openssl thing. Basically you
should not have a shell script in the way, but instead make your
bintool do it.

https://github.com/sjg20/u-boot/commit/03c0d74f81106570b18d8e4fe7a3355bfeb0d5da#r100378804

I suppose we can have an openssl bintool that others build on top of?

Regards,
Simon


>
> diff --git a/tools/binman/btool/tisecuretool.py 
> b/tools/binman/btool/tisecuretool.py
> new file mode 100644
> index 00..5102bb1f7d
> --- /dev/null
> +++ b/tools/binman/btool/tisecuretool.py
> @@ -0,0 +1,72 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +# Copyright (c) 2022 Texas Instruments Incorporated - https://www.ti.com/
> +# Written by Neha Malcom Francis 
> +#
> +"""Bintool implementation for TI security development tools
> +
> +tisecuretool helps add x509 certification for bootloader images for K3 
> platform devices
> +
> +Source code:
> +https://git.ti.com/cgit/security-development-tools/core-secdev-k3/""";
> +
> +import os
> +
> +from binman import bintool
> +from patman import tout
> +from patman import tools
> +
> +class Bintooltisecuretool(bintool.Bintool):
> +"""Signing tool for TI bootloaders"""
> +name = 'tisecuretool'
> +def __init__(self, name):
> +super().__init__(name, 'TI secure tool')
> +
> +def sign_binary_secure(self, fname, out_fname):
> +"""Create a signed binary
> +
> +Args:
> +fname (str): Filename to sign
> +out_fname (str): Output filename
> +
> +Returns:
> +str: Tool output
> +or None
> +"""
> +tool_path = self.get_path()
> +script_path = os.path.join(tool_path, 
> 'scripts/secure-binary-image.sh')
> +args = [
> +'sh',
> +script_path,
> +fname,
> +out_fname
> +]
> +output = self.run_cmd(*args, add_name=False)
> +return output
> +
> +def sign_binary_rom(self, args):
> +"""Create a signed binary that is booted by ROM
> +
> +Args:
> +fname (str): Filename to sign
> +out_fname (str): Output filename"""
> +tool_path = self.get_path()
> +script_path = os.path.join(tool_path, 
> 'scripts/secure-rom-boot-image.sh')
> +#args.insert(0, script_path)
> +args.insert(0, script_path)
> +output = self.run_cmd(*args, add_name=False)
> +return output
> +
> +def fetch(self, method):
> +"""Fetch handler for TI secure tool
> +
> +This builds the tool from source
> +
> +Returns:
> +True if the file was fetched, None if a method other than 
> FETCH_SOURCE
> +was requested
> +"""
> +if method != bintool.FETCH_SOURCE:
> +return None
> +result = self.fetch_from_git(
> +
> 'git://git.ti.com/security-development-tools/core-secdev-k3.git', 
> 'tisecuretool')
> +return result
> diff --git a/tools/binman/etype/ti_secure.py b/tools/binman/etype/ti_secure.py
> new file mode 100644
> index 00..26f81ff8e8
> --- /dev/null
> +++ b/tools/binman/etype/ti_secure.py
> @@ -0,0 +1,114 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +# Copyright (c) 2022 Texas Instruments Incorporated - https://www.ti.com/
> +# Written by Neha Malcom Francis 
> +#
> +# Entry-type module for signed binaries for TI K3 platform
> +#
> +
> +from binman.etype.blob import Entry_blob
> +from binman import bintool
> +
> +from dtoc import fdt_util
> +from patman import terminal
> +from patman import tools
> +from patman

Re: [PATCH 3/7] libavb: Fix a warning with clang-15

2023-02-27 Thread Simon Glass
On Mon, 27 Feb 2023 at 15:09, Tom Rini  wrote:
>
> With clang-15 we now will get warnings such as:
>
> warning: a function declaration without a prototype is deprecated in all
> versions of C [-Wstrict-prototypes]
>
> And it is easy enough to address this warning here, as we aren't
> concerned with re-syncing with an upstream.
>
> Signed-off-by: Tom Rini 
> ---
> Cc: Igor Opaniuk 
> ---
>  lib/libavb/avb_cmdline.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH v7 05/10] video console: move vidconsole_get_font_size() logic to driver ops

2023-02-27 Thread Simon Glass
On Mon, 27 Feb 2023 at 10:37, Dzmitry Sankouski  wrote:
>
> Since multiple vidconsole drivers exists, vidconsole_get_font_size()
> implementation cannot longer live in vidconsole_uclass.c file.
>
> Move current vidconsole_get_font_size logic to truetype driver ops.
>
> Signed-off-by: Dzmitry Sankouski 
> ---
> Changes for v2: N/A
> Changes for v3: N/A
> Charges for v4: N/A
> Charges for v5: N/A
> Charges for v6: N/A
> Charges for v7: N/A
>
>  cmd/font.c|  6 +-
>  drivers/video/console_truetype.c  |  3 ++-
>  drivers/video/vidconsole-uclass.c | 11 +++
>  include/video_console.h   | 14 --
>  test/cmd/font.c   | 13 +++--
>  5 files changed, 37 insertions(+), 10 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v7 09/10] video console: sandbox_defconfig: add 12x22 font

2023-02-27 Thread Simon Glass
On Mon, 27 Feb 2023 at 10:37, Dzmitry Sankouski  wrote:
>
> Add 12x22 font in order to write a test for it.
> Run savedefconfig.
>
> Signed-off-by: Dzmitry Sankouski 
> ---
> Changes for v2: N/A
> Changes for v3: N/A
> Charges for v4: N/A
> Charges for v5: N/A
> Charges for v6: N/A
> Charges for v7: none
>
>  configs/sandbox_defconfig | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
Reviewed-by: Simon Glass 


Re: [PATCH 2/7] dlmalloc: Fix a warning with clang-15

2023-02-27 Thread Simon Glass
Hi Tom,

On Mon, 27 Feb 2023 at 15:08, Tom Rini  wrote:
>
> With clang-15 we now will get warnings such as:
>
> warning: a function declaration without a prototype is deprecated in all
> versions of C [-Wstrict-prototypes]
>
> And it is easy enough to address this warning here, as we aren't
> concerned with re-syncing with an upstream.
>
> Signed-off-by: Tom Rini 
> ---
>  common/dlmalloc.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass 

>
> diff --git a/common/dlmalloc.c b/common/dlmalloc.c
> index 41c7230424cc..0f9b7262d512 100644
> --- a/common/dlmalloc.c
> +++ b/common/dlmalloc.c
> @@ -80,7 +80,7 @@ GmListElement* makeGmListElement (void* bas)
> return this;
>  }
>
> -void gcleanup ()
> +void gcleanup (void)

drop space before ( ?

>  {
> BOOL rval;
> assert ( (head == NULL) || (head->base == (void*)gAddressBase));
> @@ -2340,7 +2340,7 @@ size_t malloc_usable_size(mem) Void_t* mem;
>  /* Utility to update current_mallinfo for malloc_stats and mallinfo() */
>
>  #ifdef DEBUG
> -static void malloc_update_mallinfo()
> +static void malloc_update_mallinfo(void)
>  {
>int i;
>mbinptr b;
> @@ -2397,7 +2397,7 @@ static void malloc_update_mallinfo()
>  */
>
>  #ifdef DEBUG
> -void malloc_stats()
> +void malloc_stats(void)
>  {
>malloc_update_mallinfo();
>printf("max system bytes = %10u\n",
> @@ -2418,7 +2418,7 @@ void malloc_stats()
>  */
>
>  #ifdef DEBUG
> -struct mallinfo mALLINFo()
> +struct mallinfo mALLINFo(void)
>  {
>malloc_update_mallinfo();
>return current_mallinfo;
> --
> 2.34.1
>

Regards,
Simon


Re: [PATCH 6/7] proftool: Remove unused variables in make_flame_tree

2023-02-27 Thread Simon Glass
On Mon, 27 Feb 2023 at 15:08, Tom Rini  wrote:
>
> With clang-15 we now get reported that in the make_flame_tree function,
> neither the missing_count nor depth variables are used, only
> incremenete/decremented. Remove these.
>
> Signed-off-by: Tom Rini 
> ---
> Cc: Simon Glass 
> ---
>  tools/proftool.c | 15 +--
>  1 file changed, 1 insertion(+), 14 deletions(-)

Reviewed-by: Simon Glass 

Yes I removed the debugging but wasn't 100% sure it wasn't needed,
then forgot about it :-)


Re: [PATCH 7/7] CI: Move to clang-15

2023-02-27 Thread Simon Glass
On Mon, 27 Feb 2023 at 15:10, Tom Rini  wrote:
>
> As this is now the stable release, move to using that now for our tests.
>
> Signed-off-by: Tom Rini 
> ---
>  .azure-pipelines.yml| 6 +++---
>  .gitlab-ci.yml  | 4 ++--
>  tools/docker/Dockerfile | 4 ++--
>  3 files changed, 7 insertions(+), 7 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 5/7] imx8image: Remove unused cont_img_count variable

2023-02-27 Thread Simon Glass
On Mon, 27 Feb 2023 at 15:09, Tom Rini  wrote:
>
> With clang-15, it is now reported that cont_img_count is unused. This is
> true as the code will increment / reset this counter, but never
> functionally use it. Remove it.
>
> Signed-off-by: Tom Rini 
> ---
> Cc: Peng Fan 
> Cc: Mikhail Ilin 
> Cc: Stefano Babic 
> Cc: Fabio Estevam 
> Cc: "NXP i.MX U-Boot Team" 
> ---
>  tools/imx8image.c | 5 -
>  1 file changed, 5 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/7] global: Disable deprecated-non-prototype warning with clang

2023-02-27 Thread Simon Glass
On Mon, 27 Feb 2023 at 15:09, Tom Rini  wrote:
>
> We have a number of places in the code which use the following syntax:
>
> void func(a, b, c)
> int a; /* Does a */
> something_t *b; /* Pointer to b */
> int c; /* Does c */
> {
> ...
> }
>
> Which while not what we document as our coding style, this is also code
> which we have imported from other projects, and would like to re-sync
> with in the future. While the biggest example of this is the zlib code,
> there are other places as well. For now, we will silence this warning.
>
> Signed-off-by: Tom Rini 
> ---
>  Makefile | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Simon Glass 


Re: [PATCH 4/7] zlib: trees.c: Fix a warning with clang-15

2023-02-27 Thread Simon Glass
On Mon, 27 Feb 2023 at 15:09, Tom Rini  wrote:
>
> With clang-15 we now will get warnings such as:
>
> warning: a function declaration without a prototype is deprecated in all
> versions of C [-Wstrict-prototypes]
>
> And it is easy enough to address this warning here, even if we would
> like to stay in sync more with upstream as it's a single location.
>
> Signed-off-by: Tom Rini 
> ---
>  lib/zlib/trees.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH 2/2] arm: mvebu: clearfog: Add defconfig for SPI booting

2023-02-27 Thread Tony Dinh
Hi Pali,

On Mon, Feb 27, 2023 at 1:57 PM Tony Dinh  wrote:
>
> Hi Stefan,
>
> On Sun, Feb 26, 2023 at 11:40 PM Stefan Roese  wrote:
> >
> > Hi Tony,
> >
> > On 2/27/23 01:11, Tony Dinh wrote:
> > > Hi Pali,
> > >
> > > On Sun, Feb 26, 2023 at 2:52 AM Pali Rohár  wrote:
> > >>
> > >> On Saturday 25 February 2023 20:56:10 Tony Dinh wrote:
> > >>> Hi Martin,
> > >>>
> > >>> On Sat, Feb 25, 2023 at 6:17 PM Martin Rowe  
> > >>> wrote:
> > 
> > >>> I'm not sure how to run proper timing tests on the process, but
> > >>> stopwatch timing just between seeing "Trying to boot" and "U-Boot
> > >>> 2023.04-rc2" showed the return to BootROM under 1 second, and the
> > >>> direct from SPI around 4 seconds. I thought the goal of loading from
> > >>> SPI directly was speed, but returning to BootROM is significantly
> > >>> faster on this board.
> > >>
> > >> You should check SPI speed in DTS file and also in the defconfig.
> > >
> > > I think we have probably seen this slowdown before. There is a TODO in
> > > the way the DTS nodes are parsed by DM uclass. So this config must be
> > > set in defconfig to get around that bug:
> > > CONFIG_SF_DEFAULT_SPEED=5000
> > 
> >  That works and is much faster now. I'll submit it in a V2 for these
> >  two patches once Pali's mvebu changes are accepted. Only question I
> >  have is: should the faster speed be applied to all three defconfigs?
> >  CONFIG_SF_DEFAULT_SPEED=100 (50x less) is implicitly added to the
> >  MMC and SATA configs at the moment.
> > >>>
> > >>> This is only a workaround to get the SPI probe to work correctly. The
> > >>> real fix should be in spi_flash_probe()
> > >>> ./common/spl/spl_spi.c
> > >>>  flash = spi_flash_probe(sf_bus, sf_cs,
> > >>>  CONFIG_SF_DEFAULT_SPEED,
> > >>>  CONFIG_SF_DEFAULT_MODE);
> > >>> If spi_flash_probe() failed to get SPI max_hz from the DTS, the
> > >>> fallback is CONFIG_SF_DEFAULT_SPEED.
> > >>>
> > >>> IMO, perhaps we could add CONFIG_SF_DEFAULT_SPEED and
> > >>> CONFIG_SF_DEFAULT_MODE selection to arch/arm/mach-mvebu/Kconfig or
> > >>> some other common place. And when we will have fixed the DTS parsing
> > >>> problem, they can be removed.
> > >>>
> > >>> I'd like to hear from Stefan and Pali if this approach sounds good.
> > >>>
> > >>> All the best,
> > >>> Tony
> > >>
> > >> Well, the maximal SPI speed depends on the wiring. You can have on the
> > >> board some SPI device which does not support high frequency.
> > >>
> > >> But having some sane defaults in Kconfig for mvebu makes sense.
> >
> > Agreed.
> >
> > > The CONFIG_SF_DEFAULT_SPEED is set to 1_000_000 if the board defconfig
> > > does not specify it. I think the sane default value is 10_000_000
> > > (grepping the Armada* DTS files showing the slowest spi-max-frequency
> > > is 10_000_000). While a big improvement, it is not fast enough for
> > > many other boards. So we still need to define it in those board
> > > defconfigs (before fixing that bug), or use return to BootROM.
> >
> > I'm fine with setting CONFIG_SF_DEFAULT_SPEED to 10.000.000 for MVEBU.
> > Not sure if this should be done in drivers/mtd/spi/Kconfig, as this
> > currently has no platform- / board- specific configurations. Perhaps
> > it can be done in a mach-mvebu Kconfig file instead?
>
> Yes, I think it should be done in mach-mvebu Kconfig, too. I will run
> some tests.

It is not related to this patch series (I also tested without the
patch series to confirm). But it is strange that I can no longer get
the configuration to boot from SPI. The 1st device in the boot order
is alway BOOTROM. The spl_boot_list is printed out below.


High speed PHY - Ended Successfully
mv_ddr: 14.0.0
DDR4 Training Sequence - Switching XBAR Window to FastPath Window
mv_ddr: completed successfully
board_boot_order spl_boot_list[0] = 15
Trying to boot from BOOTROM
Returning to BootROM (return address 0x05c4)...
BootROM: Image checksum verification PASSED


The SPL SPI configs (board Thecus N2350) are:
# grep SPL .config| grep SPI

CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI=y
CONFIG_SPL_DM_SPI=y
CONFIG_SPL_SPI_FLASH_SUPPORT=y
CONFIG_SPL_SPI=y
CONFIG_SPL_DM_SPI_FLASH=y
CONFIG_SPL_SPI_FLASH_TINY=y
# CONFIG_SPL_SPI_FLASH_MTD is not set
CONFIG_SPL_SPI_LOAD=y

Did I miss something new lately?

Thanks,
Tony

Trying to boot from BOOTROM
Returning to BootROM (return address 0x05c4)...
BootROM: Image checksum verification PASSED


Re: [PATCH] CI: gitlab: Collect pytest artifacts

2023-02-27 Thread Tom Rini
On Mon, Feb 27, 2023 at 11:51:30PM +0100, Marek Vasut wrote:

> Copy build artifacts for all test.py tests, so they show up in
> artifacts storage for later inspection. The test.py tests output
> in CI is basically useless, but it is far more useful in the html
> output for analysis and debugging.
> 
> Suggested-by: Simon Glass 
> Signed-off-by: Marek Vasut 
> ---
> Cc: Simon Glass 
> Cc: Tom Rini 
> ---
>  .gitlab-ci.yml | 14 ++
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 272d69e2206..1b761f26e9a 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -77,9 +77,12 @@ stages:
>  ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"}
>  --build-dir "$UBOOT_TRAVIS_BUILD_DIR"
>  # It seems that the files in /tmp go away, so copy out what we need

We can drop this comment.

> -- if [[ "${TEST_PY_BD}" == "coreboot" ]]; then
> -cp -v /tmp/coreboot/*.{html,css} .;
> -  fi
> +- cp -v /tmp/${TEST_PY_BD}/*.{html,css} .
> +  artifacts:
> +paths:
> +  - "*.html"
> +  - "*.css"
> +expire_in: 1 week
>  
>  build all 32bit ARM platforms:
>stage: world build
> @@ -454,9 +457,4 @@ coreboot test.py:
>  TEST_PY_BD: "coreboot"
>  TEST_PY_TEST_SPEC: "not sleep"
>  TEST_PY_ID: "--id qemu"
> -  artifacts:
> -paths:
> -  - "*.html"
> -  - "*.css"
> -expire_in: 1 week
><<: *buildman_and_testpy_dfn

So, what looks like a debugging artifact was included in the proper
patch and merged, and yes,
https://u-boot.source-pages.denx.de/-/u-boot/-/jobs/585388/artifacts/test-log.html
is quite handy in the case of test failure.

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCHv4 2/5] fwu: move meta-data management in core

2023-02-27 Thread Etienne Carriere
-   err = fwu_write_mdata(g_dev, mdata, part & PRIMARY_PART ? true : false);

On Mon, 27 Feb 2023 at 17:46, Jassi Brar  wrote:
>
> On Mon, Feb 27, 2023 at 10:30 AM Etienne Carriere
>  wrote:
> >
> > Hello Jassi,
> >
> > On Sun, 5 Feb 2023 at 04:01,  wrote:
> > >
> > > From: Jassi Brar 
> > >
> > > Instead of each i/f having to implement their own meta-data verification
> > > and storage, move the logic in common code. This simplifies the i/f code
> > > much simpler and compact.
> > >
> > > Signed-off-by: Jassi Brar 
> > > ---
> > >  drivers/fwu-mdata/fwu-mdata-uclass.c |  34 +++
> > >  include/fwu.h|  41 
> > >  lib/fwu_updates/fwu.c| 135 ++-
> > >  3 files changed, 206 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/fwu-mdata/fwu-mdata-uclass.c 
> > > b/drivers/fwu-mdata/fwu-mdata-uclass.c
> > > index b477e9603f..e03773c584 100644
> > > --- a/drivers/fwu-mdata/fwu-mdata-uclass.c
> > > +++ b/drivers/fwu-mdata/fwu-mdata-uclass.c
> > > @@ -16,6 +16,40 @@
> > >  #include 
> > >  #include 
> > >
> > > +/**
> > > + * fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata()
> > > + *
> > > + * Return: 0 if OK, -ve on error
> > > + */
> > > +int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool 
> > > primary)
> > > +{
> > > +   const struct fwu_mdata_ops *ops = device_get_ops(dev);
> > > +
> > > +   if (!ops->read_mdata) {
> > > +   log_debug("read_mdata() method not defined\n");
> > > +   return -ENOSYS;
> > > +   }
> > > +
> > > +   return ops->read_mdata(dev, mdata, primary);
> > > +}
> > > +
> > > +/**
> > > + * fwu_write_mdata() - Wrapper around fwu_mdata_ops.write_mdata()
> > > + *
> > > + * Return: 0 if OK, -ve on error
> > > + */
> > > +int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool 
> > > primary)
> > > +{
> > > +   const struct fwu_mdata_ops *ops = device_get_ops(dev);
> > > +
> > > +   if (!ops->write_mdata) {
> > > +   log_debug("write_mdata() method not defined\n");
> > > +   return -ENOSYS;
> > > +   }
> > > +
> > > +   return ops->write_mdata(dev, mdata, primary);
> > > +}
> > > +
> > >  /**
> > >   * fwu_get_mdata_part_num() - Get the FWU metadata partition numbers
> > >   * @dev: FWU metadata device
> > > diff --git a/include/fwu.h b/include/fwu.h
> > > index 0919ced812..1a700c9e6a 100644
> > > --- a/include/fwu.h
> > > +++ b/include/fwu.h
> > > @@ -24,6 +24,26 @@ struct fwu_mdata_gpt_blk_priv {
> > >   * @update_mdata() - Update the FWU metadata copy
> > >   */
> > >  struct fwu_mdata_ops {
> > > +   /**
> > > +* read_mdata() - Populate the asked FWU metadata copy
> > > +* @dev: FWU metadata device
> > > +* @mdata: Copy of the FWU metadata
> > > +* @primary: If primary or secondary copy of meta-data is to be 
> > > read
> > > +*
> > > +* Return: 0 if OK, -ve on error
> > > +*/
> > > +   int (*read_mdata)(struct udevice *dev, struct fwu_mdata *mdata, 
> > > bool primary);
> > > +
> > > +   /**
> > > +* write_mdata() - Write the given FWU metadata copy
> > > +* @dev: FWU metadata device
> > > +* @mdata: Copy of the FWU metadata
> > > +* @primary: If primary or secondary copy of meta-data is to be 
> > > written
> > > +*
> > > +* Return: 0 if OK, -ve on error
> > > +*/
> > > +   int (*write_mdata)(struct udevice *dev, struct fwu_mdata *mdata, 
> > > bool primary);
> > > +
> > > /**
> > >  * check_mdata() - Check if the FWU metadata is valid
> > >  * @dev:FWU device
> > > @@ -126,6 +146,27 @@ struct fwu_mdata_ops {
> > > EFI_GUID(0x0c996046, 0xbcc0, 0x4d04, 0x85, 0xec, \
> > >  0xe1, 0xfc, 0xed, 0xf1, 0xc6, 0xf8)
> > >
> > > +/**
> > > + * fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata()
> > > + */
> > > +int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool 
> > > primary);
> > > +
> > > +/**
> > > + * fwu_write_mdata() - Wrapper around fwu_mdata_ops.write_mdata()
> > > + */
> > > +int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool 
> > > primary);
> > > +
> > > +/**
> > > + * fwu_get_verified_mdata() - Read, verify and return the FWU metadata
> > > + *
> > > + * Read both the metadata copies from the storage media, verify their 
> > > checksum,
> > > + * and ascertain that both copies match. If one of the copies has gone 
> > > bad,
> > > + * restore it from the good copy.
> > > + *
> > > + * Return: 0 if OK, -ve on error
> > > +*/
> > > +int fwu_get_verified_mdata(struct fwu_mdata *mdata);
> > > +
> > >  /**
> > >   * fwu_check_mdata_validity() - Check for validity of the FWU metadata 
> > > copies
> > >   *
> > > diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
> > > index 5313d07302..56299f1b2f 100644
> > > --- a/lib/fwu_updates/fwu.c
> > > 

[PATCH] net: ravb: Support fixed PHY in R-Car

2023-02-27 Thread Marek Vasut
From: Mikhail Lappo 

Calling old U-Boot API doesn't allow to use fixed PHY.
Searching by mask is the part of new function, after
scanning FDT for a fixed PHY definition

Fixes: e821a7bdb13 ("net: ravb: Detect PHY correctly")
Reviewed-by: Marek Vasut 
Signed-off-by: Mikhail Lappo 
Signed-off-by: Hai Pham 
[Hai Pham: Drop phy_connect_dev since it's called in phy_connect]
Signed-off-by: Marek Vasut 
[Marek: Use mask -1 instead of 0 to reinstate the search behavior
over all PHY addresses. Add Fixes tag, sort the tag list.]
---
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
 drivers/net/ravb.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 5a835cc06ff..0bc50dc7335 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -310,7 +310,7 @@ static int ravb_phy_config(struct udevice *dev)
struct ravb_priv *eth = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_plat(dev);
struct phy_device *phydev;
-   int mask = 0x, reg;
+   int reg;
 
if (dm_gpio_is_valid(ð->reset_gpio)) {
dm_gpio_set_value(ð->reset_gpio, 1);
@@ -319,12 +319,10 @@ static int ravb_phy_config(struct udevice *dev)
mdelay(1);
}
 
-   phydev = phy_find_by_mask(eth->bus, mask);
+   phydev = phy_connect(eth->bus, -1, dev, pdata->phy_interface);
if (!phydev)
return -ENODEV;
 
-   phy_connect_dev(phydev, dev, pdata->phy_interface);
-
eth->phydev = phydev;
 
phydev->supported &= SUPPORTED_100baseT_Full |
-- 
2.39.2



[PATCH 2/2] i2c: rcar_i2c: Sort Kconfig depends list ascending

2023-02-27 Thread Marek Vasut
Sort the list of "depends" symbols in ascending order.
No functional change.

Signed-off-by: Marek Vasut 
---
Cc: Heiko Schocher 
---
 drivers/i2c/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index aa51f0c869e..1d998d14732 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -486,7 +486,7 @@ config SYS_I2C_OMAP24XX
 
 config SYS_I2C_RCAR_I2C
bool "Renesas RCar I2C driver"
-   depends on (RCAR_GEN3 || RCAR_GEN2) && DM_I2C
+   depends on (RCAR_GEN2 || RCAR_GEN3) && DM_I2C
help
  Support for Renesas RCar I2C controller.
 
-- 
2.39.2



[PATCH 1/2] i2c: rcar_iic: Sort Kconfig depends list ascending

2023-02-27 Thread Marek Vasut
Sort the list of "depends" symbols in ascending order.
No functional change.

Signed-off-by: Marek Vasut 
---
Cc: Heiko Schocher 
---
 drivers/i2c/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 3279fef1eb0..aa51f0c869e 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -492,7 +492,7 @@ config SYS_I2C_RCAR_I2C
 
 config SYS_I2C_RCAR_IIC
bool "Renesas RCar Gen3 IIC driver"
-   depends on (RCAR_GEN3 || RCAR_GEN2) && DM_I2C
+   depends on (RCAR_GEN2 || RCAR_GEN3) && DM_I2C
help
  Support for Renesas RCar Gen3 IIC controller.
 
-- 
2.39.2



[PATCH 2/2] ARM: renesas: falcon: Enable RWDT reset for V3U Falcon

2023-02-27 Thread Marek Vasut
From: Hai Pham 

Enable RWDT reset on Reset Controller so that it can be used as
reset trigger source for V3U Falcon.

Reviewed-by: Marek Vasut 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut  # Use one 
current_el() in board_init
---
 board/renesas/falcon/falcon.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/board/renesas/falcon/falcon.c b/board/renesas/falcon/falcon.c
index b7e7fd9003a..ab7464d0ee3 100644
--- a/board/renesas/falcon/falcon.c
+++ b/board/renesas/falcon/falcon.c
@@ -83,21 +83,27 @@ int board_early_init_f(void)
return 0;
 }
 
+#define RST_BASE   0xE616 /* Domain0 */
+#define RST_SRESCR0(RST_BASE + 0x18)
+#define RST_SPRES  0x5AA58000
+#define RST_WDTRSTCR   (RST_BASE + 0x10)
+#define RST_RWDT   0xA55A8002
+
 int board_init(void)
 {
/* address of boot parameters */
gd->bd->bi_boot_params = CONFIG_TEXT_BASE + 0x5;
 
-   if (current_el() == 3)
+   if (current_el() == 3) {
init_gic_v3();
 
+   /* Enable RWDT reset */
+   writel(RST_RWDT, RST_WDTRSTCR);
+   }
+
return 0;
 }
 
-#define RST_BASE   0xE616 /* Domain0 */
-#define RST_SRESCR0(RST_BASE + 0x18)
-#define RST_SPRES  0x5AA58000
-
 void reset_cpu(void)
 {
writel(RST_SPRES, RST_SRESCR0);
-- 
2.39.2



[PATCH 1/2] ARM: renesas: falcon: Initialize ARM generic timer and GICv3 if EL3

2023-02-27 Thread Marek Vasut
From: Hai Pham 

U-Boot executes at EL3 is required to initalize those settings.
In other cases, they will be done by prior-stage firmware instead.

This fixes crash when U-Boot is at non-secure exception level.

Reviewed-by: Marek Vasut 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
---
 board/renesas/falcon/falcon.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/board/renesas/falcon/falcon.c b/board/renesas/falcon/falcon.c
index b0cb4e747b6..b7e7fd9003a 100644
--- a/board/renesas/falcon/falcon.c
+++ b/board/renesas/falcon/falcon.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -69,7 +70,8 @@ static void init_gic_v3(void)
 
 void s_init(void)
 {
-   init_generic_timer();
+   if (current_el() == 3)
+   init_generic_timer();
 }
 
 int board_early_init_f(void)
@@ -86,7 +88,8 @@ int board_init(void)
/* address of boot parameters */
gd->bd->bi_boot_params = CONFIG_TEXT_BASE + 0x5;
 
-   init_gic_v3();
+   if (current_el() == 3)
+   init_gic_v3();
 
return 0;
 }
-- 
2.39.2



[PATCH] ARM: renesas: Enable DTO support by default on R-Car Gen3

2023-02-27 Thread Marek Vasut
All R-Car Gen3 defconfigs present in U-Boot do enable DTO support,
enable it for all of R-Car Gen3 by default in Kconfig instead, so
that no new boards would miss this functionality.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/Kconfig.64 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-rmobile/Kconfig.64 b/arch/arm/mach-rmobile/Kconfig.64
index 8e617e58244..554130b435b 100644
--- a/arch/arm/mach-rmobile/Kconfig.64
+++ b/arch/arm/mach-rmobile/Kconfig.64
@@ -204,4 +204,7 @@ config SYS_MALLOC_F_LEN
 config DM_RESET
default y if RCAR_GEN3
 
+config OF_LIBFDT_OVERLAY
+   default y if RCAR_GEN3
+
 endif
-- 
2.39.2



[PATCH] ARM: renesas: Demote overlap memory nodes message to debug on Gen3

2023-02-27 Thread Marek Vasut
From: Hai Pham 

The R-Car DTs might contains multiple /memory@* nodes from various
sources, i.e. prior firmware, u-boot itself or the OS

The duplicates are likely to happen so the messages are not meaningful
in the default setting since we have already handled that.

Reduce the message to debug level.

Reviewed-by: Marek Vasut 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
---
 board/renesas/rcar-common/common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/board/renesas/rcar-common/common.c 
b/board/renesas/rcar-common/common.c
index daa1beb14f8..0ddae95e230 100644
--- a/board/renesas/rcar-common/common.c
+++ b/board/renesas/rcar-common/common.c
@@ -73,9 +73,9 @@ static int is_mem_overlap(void *blob, int first_mem_node, int 
curr_mem_node)
if (curr_mem_res.start >= first_mem_res.end)
continue;
 
-   printf("Overlap found: 0x%llx..0x%llx / 
0x%llx..0x%llx\n",
-   first_mem_res.start, first_mem_res.end,
-   curr_mem_res.start, curr_mem_res.end);
+   log_debug("Overlap found: 0x%llx..0x%llx / 
0x%llx..0x%llx\n",
+ first_mem_res.start, first_mem_res.end,
+ curr_mem_res.start, curr_mem_res.end);
 
return 1;
}
-- 
2.39.2



[PATCH] ARM: renesas: Remove defines for USB on Eagle/Condor

2023-02-27 Thread Marek Vasut
From: Hai Pham 

The Eagle board based on R-Car V3M, which does not support any USB
interfaces. The same applies for the Condor board based on R-Car V3H.

Remove the defines.

Reviewed-by: Marek Vasut 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
---
 configs/r8a77970_eagle_defconfig  | 6 --
 configs/r8a77980_condor_defconfig | 6 --
 2 files changed, 12 deletions(-)

diff --git a/configs/r8a77970_eagle_defconfig b/configs/r8a77970_eagle_defconfig
index efbfd6559e7..37af576493b 100644
--- a/configs/r8a77970_eagle_defconfig
+++ b/configs/r8a77970_eagle_defconfig
@@ -37,7 +37,6 @@ CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_SPI=y
-CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
@@ -82,9 +81,4 @@ CONFIG_DM_SPI=y
 CONFIG_RENESAS_RPC_SPI=y
 CONFIG_TEE=y
 CONFIG_OPTEE=y
-CONFIG_USB=y
-CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_EHCI_GENERIC=y
-CONFIG_USB_STORAGE=y
 CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/r8a77980_condor_defconfig 
b/configs/r8a77980_condor_defconfig
index e1b3dc5d38a..687a894d80c 100644
--- a/configs/r8a77980_condor_defconfig
+++ b/configs/r8a77980_condor_defconfig
@@ -39,7 +39,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SPI=y
-CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
@@ -91,9 +90,4 @@ CONFIG_RENESAS_RPC_SPI=y
 CONFIG_SYSINFO=y
 CONFIG_TEE=y
 CONFIG_OPTEE=y
-CONFIG_USB=y
-CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_EHCI_GENERIC=y
-CONFIG_USB_STORAGE=y
 CONFIG_OF_LIBFDT_OVERLAY=y
-- 
2.39.2



[PATCH 2/3] ARM: dts: renesas: Enable sysinfo on R-Car V3H Condor/Condor-I

2023-02-27 Thread Marek Vasut
From: Tam Nguyen 

Add new sysinfo IDs for R-Car V3H Condor/Condor-I .

Enable support for sysinfo on R-Car V3H Condor/Condor-I. The sysinfo is
used e.g. to access and decode board-specific information and then in
turn used by board-info to print those information.

Reviewed-by: Marek Vasut 
Signed-off-by: Tam Nguyen 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
[Marek: Drop compatible from I2C node, this is in r8a77980.dtsi already.
Drop status = "okay" from EEPROM node.
Add dts: tag.
Update the commit message, note the new sysinfo IDs.
Fix Kconfig EEPROM address to be 0x50 and match the DT, sync config.]
---
 arch/arm/dts/r8a77980-condor-u-boot.dts | 17 +
 configs/r8a77980_condor_defconfig   |  5 +
 drivers/sysinfo/rcar3.c | 15 +++
 3 files changed, 37 insertions(+)

diff --git a/arch/arm/dts/r8a77980-condor-u-boot.dts 
b/arch/arm/dts/r8a77980-condor-u-boot.dts
index 576a74e6030..530abdb72bc 100644
--- a/arch/arm/dts/r8a77980-condor-u-boot.dts
+++ b/arch/arm/dts/r8a77980-condor-u-boot.dts
@@ -12,6 +12,23 @@
aliases {
spi0 = &rpc;
};
+
+   sysinfo {
+   compatible = "renesas,rcar-sysinfo";
+   i2c-eeprom = <&sysinfo_eeprom>;
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c0 {
+   u-boot,dm-pre-reloc;
+
+   sysinfo_eeprom: eeprom@50 {
+   compatible = "rohm,br24t01", "atmel,24c01";
+   reg = <0x50>;
+   pagesize = <8>;
+   u-boot,dm-pre-reloc;
+   };
 };
 
 &rpc {
diff --git a/configs/r8a77980_condor_defconfig 
b/configs/r8a77980_condor_defconfig
index 0c3493cdf8d..e1b3dc5d38a 100644
--- a/configs/r8a77980_condor_defconfig
+++ b/configs/r8a77980_condor_defconfig
@@ -33,6 +33,7 @@ CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=64
 CONFIG_SYS_PBSIZE=2068
 CONFIG_CMD_BOOTZ=y
+CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=10
 CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
@@ -64,6 +65,9 @@ CONFIG_DFU_SF=y
 CONFIG_RCAR_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_RCAR_I2C=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
+CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 CONFIG_MMC_IO_VOLTAGE=y
 CONFIG_MMC_UHS_SUPPORT=y
 CONFIG_MMC_HS200_SUPPORT=y
@@ -84,6 +88,7 @@ CONFIG_SCIF_CONSOLE=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_RENESAS_RPC_SPI=y
+CONFIG_SYSINFO=y
 CONFIG_TEE=y
 CONFIG_OPTEE=y
 CONFIG_USB=y
diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
index c0afc92f675..7b127986da7 100644
--- a/drivers/sysinfo/rcar3.c
+++ b/drivers/sysinfo/rcar3.c
@@ -18,10 +18,12 @@
 #define BOARD_STARTER_KIT  0x2
 #define BOARD_EAGLE0x3
 #define BOARD_SALVATOR_XS  0x4
+#define BOARD_CONDOR   0x6
 #define BOARD_DRAAK0x7
 #define BOARD_EBISU0x8
 #define BOARD_STARTER_KIT_PRE  0xB
 #define BOARD_EBISU_4D 0xD
+#define BOARD_CONDOR_I 0x10
 
 /**
  * struct sysinfo_rcar_priv - sysinfo private data
@@ -65,6 +67,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
const u8 board_rev = priv->val & BOARD_REV_MASK;
bool salvator_xs = false;
bool ebisu_4d = false;
+   bool condor_i = false;
char rev_major = '?';
char rev_minor = '?';
 
@@ -138,6 +141,18 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv 
*priv)
 "Renesas Kriek board rev %c.%c",
 rev_major, rev_minor);
return;
+   case BOARD_CONDOR_I:
+   condor_i = true;
+   fallthrough;
+   case BOARD_CONDOR:
+   if (!board_rev) { /* Only rev 0 is valid */
+   rev_major = '1';
+   rev_minor = '0';
+   }
+   snprintf(priv->boardmodel, sizeof(priv->boardmodel),
+   "Renesas Condor%s board rev %c.%c",
+   condor_i ? "-I" : "", rev_major, rev_minor);
+   return;
default:
snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 "Renesas -Unknown- board rev ?.?");
-- 
2.39.2



[PATCH 3/3] ARM: dts: renesas: Enable sysinfo on R-Car D3 Draak

2023-02-27 Thread Marek Vasut
From: Tam Nguyen 

Enable support for sysinfo on R-Car D3 Draak board. The sysinfo is used
e.g. to access and decode board-specific information and then in turn
used by board-info to print those information.

Reviewed-by: Marek Vasut 
Signed-off-by: Tam Nguyen 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
[Marek: Drop compatible from I2C node, this is in r8a77995.dtsi already.
Drop status = "okay" from EEPROM node.
Add dts: tag.
Fix Kconfig EEPROM address to be 0x50 and match the DT, sync config.]
---
 arch/arm/dts/r8a77995-draak-u-boot.dts | 19 +++
 configs/r8a77995_draak_defconfig   |  5 +
 2 files changed, 24 insertions(+)

diff --git a/arch/arm/dts/r8a77995-draak-u-boot.dts 
b/arch/arm/dts/r8a77995-draak-u-boot.dts
index 0ea2570c1dc..260bc5da19f 100644
--- a/arch/arm/dts/r8a77995-draak-u-boot.dts
+++ b/arch/arm/dts/r8a77995-draak-u-boot.dts
@@ -8,6 +8,25 @@
 #include "r8a77995-draak.dts"
 #include "r8a77995-u-boot.dtsi"
 
+/ {
+   sysinfo {
+   compatible = "renesas,rcar-sysinfo";
+   i2c-eeprom = <&sysinfo_eeprom>;
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c0 {
+   u-boot,dm-pre-reloc;
+
+   sysinfo_eeprom: eeprom@50 {
+   compatible = "rohm,br24t01", "atmel,24c01";
+   reg = <0x50>;
+   pagesize = <8>;
+   u-boot,dm-pre-reloc;
+   };
+};
+
 &rpc {
reg = <0 0xee20 0 0x100>, <0 0x0800 0 0x0400>;
status = "disabled";
diff --git a/configs/r8a77995_draak_defconfig b/configs/r8a77995_draak_defconfig
index 4ddb66aef9c..a09b33e7740 100644
--- a/configs/r8a77995_draak_defconfig
+++ b/configs/r8a77995_draak_defconfig
@@ -33,6 +33,7 @@ CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=64
 CONFIG_SYS_PBSIZE=2068
 CONFIG_CMD_BOOTZ=y
+CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=10
 CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
@@ -65,6 +66,9 @@ CONFIG_DFU_SF=y
 CONFIG_RCAR_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_RCAR_I2C=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
+CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 CONFIG_MMC_IO_VOLTAGE=y
 CONFIG_MMC_UHS_SUPPORT=y
 CONFIG_MMC_HS200_SUPPORT=y
@@ -94,6 +98,7 @@ CONFIG_SCIF_CONSOLE=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_RENESAS_RPC_SPI=y
+CONFIG_SYSINFO=y
 CONFIG_TEE=y
 CONFIG_OPTEE=y
 CONFIG_USB=y
-- 
2.39.2



[PATCH 1/3] sysinfo: rcar3: Fix Draak and Eagle board code

2023-02-27 Thread Marek Vasut
From: Tam Nguyen 

Correct the board code ID based on the hardware documentation

Reviewed-by: Marek Vasut 
Signed-off-by: Tam Nguyen 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
---
 drivers/sysinfo/rcar3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
index c2f4ddfbbe3..c0afc92f675 100644
--- a/drivers/sysinfo/rcar3.c
+++ b/drivers/sysinfo/rcar3.c
@@ -16,12 +16,12 @@
 #define BOARD_SALVATOR_X   0x0
 #define BOARD_KRIEK0x1
 #define BOARD_STARTER_KIT  0x2
+#define BOARD_EAGLE0x3
 #define BOARD_SALVATOR_XS  0x4
+#define BOARD_DRAAK0x7
 #define BOARD_EBISU0x8
 #define BOARD_STARTER_KIT_PRE  0xB
 #define BOARD_EBISU_4D 0xD
-#define BOARD_DRAAK0xE
-#define BOARD_EAGLE0xF
 
 /**
  * struct sysinfo_rcar_priv - sysinfo private data
-- 
2.39.2



[PATCH] CI: gitlab: Collect pytest artifacts

2023-02-27 Thread Marek Vasut
Copy build artifacts for all test.py tests, so they show up in
artifacts storage for later inspection. The test.py tests output
in CI is basically useless, but it is far more useful in the html
output for analysis and debugging.

Suggested-by: Simon Glass 
Signed-off-by: Marek Vasut 
---
Cc: Simon Glass 
Cc: Tom Rini 
---
 .gitlab-ci.yml | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 272d69e2206..1b761f26e9a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -77,9 +77,12 @@ stages:
 ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"}
 --build-dir "$UBOOT_TRAVIS_BUILD_DIR"
 # It seems that the files in /tmp go away, so copy out what we need
-- if [[ "${TEST_PY_BD}" == "coreboot" ]]; then
-cp -v /tmp/coreboot/*.{html,css} .;
-  fi
+- cp -v /tmp/${TEST_PY_BD}/*.{html,css} .
+  artifacts:
+paths:
+  - "*.html"
+  - "*.css"
+expire_in: 1 week
 
 build all 32bit ARM platforms:
   stage: world build
@@ -454,9 +457,4 @@ coreboot test.py:
 TEST_PY_BD: "coreboot"
 TEST_PY_TEST_SPEC: "not sleep"
 TEST_PY_ID: "--id qemu"
-  artifacts:
-paths:
-  - "*.html"
-  - "*.css"
-expire_in: 1 week
   <<: *buildman_and_testpy_dfn
-- 
2.39.2



[PATCH 2/2] mmc: renesas-sdhi: Add proper probe error fail path

2023-02-27 Thread Marek Vasut
In case one of the calls in probe fail, trigger a fail path and
undo all the steps done in probe until the point of failure.
The current implementation failed to stop controller clock and
free claimed clock, so fix that. Furthermore, print return code
in error prints for easier debugging.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
---
 drivers/mmc/renesas-sdhi.c | 26 +-
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 2473261f3c4..34119f949aa 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -982,37 +982,45 @@ static int renesas_sdhi_probe(struct udevice *dev)
} else {
ret = clk_set_rate(&priv->clkh, 8);
if (ret < 0) {
-   dev_err(dev, "failed to set rate for SDnH clock\n");
-   clk_free(&priv->clk);
-   return ret;
+   dev_err(dev, "failed to set rate for SDnH clock 
(%d)\n", ret);
+   goto err_clk;
}
}
 
/* set to max rate */
ret = clk_set_rate(&priv->clk, 2);
if (ret < 0) {
-   dev_err(dev, "failed to set rate for host clock\n");
-   clk_free(&priv->clk);
-   return ret;
+   dev_err(dev, "failed to set rate for SDn clock (%d)\n", ret);
+   goto err_clkh;
}
 
ret = clk_enable(&priv->clk);
if (ret) {
-   dev_err(dev, "failed to enable host clock\n");
-   return ret;
+   dev_err(dev, "failed to enable SDn clock (%d)\n", ret);
+   goto err_clkh;
}
 
priv->quirks = quirks;
ret = tmio_sd_probe(dev, quirks);
+   if (ret)
+   goto err_tmio_probe;
 
renesas_sdhi_filter_caps(dev);
 
 #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \
 CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
 CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
-   if (!ret && (priv->caps & TMIO_SD_CAP_RCAR_UHS))
+   if (priv->caps & TMIO_SD_CAP_RCAR_UHS)
renesas_sdhi_reset_tuning(priv);
 #endif
+   return 0;
+
+err_tmio_probe:
+   clk_disable(&priv->clk);
+err_clkh:
+   clk_free(&priv->clkh);
+err_clk:
+   clk_free(&priv->clk);
return ret;
 }
 
-- 
2.39.2



[PATCH 1/2] mmc: renesas-sdhi: Always configure default SDnH clock rate to 800 MHz

2023-02-27 Thread Marek Vasut
The prior stage bootloader might have left the SDnCKCR register in completely
arbitrary state before passing control to U-Boot, which includes the register
being populated with incorrect values. Currently the SDHI driver will attempt
to use clock framework to configure SDn clock, which may fail in case SDnCKCR
contains invalid values for the SDnH clock, because the clock framework would
not be able to determine SDnH clock rate and would get -EINVAL instead, which
in turn would not allow the clock framework to determine the correct SDn clock
divider ratio.

This failure occurs specifically in case SDnCKCR reads back 0x209 .

Correct the problem by first setting default SDnH clock rate to 800 MHz, thus
assuring the SDnCKCR SDnH bits are correct, and only afterward set up the SDn
clock rate to default 200 MHz.

Note that the SDHI driver may reconfigure SDnH clock later based on IOS
settings obtained from the attached card, the 800 MHz set up here is only
the default value.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
---
 drivers/mmc/renesas-sdhi.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 4a1accebfcb..2473261f3c4 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -977,8 +977,16 @@ static int renesas_sdhi_probe(struct udevice *dev)
 
/* optional SDnH clock */
ret = clk_get_by_name(dev, "clkh", &priv->clkh);
-   if (ret < 0)
+   if (ret < 0) {
dev_dbg(dev, "failed to get clkh\n");
+   } else {
+   ret = clk_set_rate(&priv->clkh, 8);
+   if (ret < 0) {
+   dev_err(dev, "failed to set rate for SDnH clock\n");
+   clk_free(&priv->clk);
+   return ret;
+   }
+   }
 
/* set to max rate */
ret = clk_set_rate(&priv->clk, 2);
-- 
2.39.2



[ANN] U-Boot v2023.04-rc3 released

2023-02-27 Thread Tom Rini
Hey all,

It's the scheduled day for -rc3, and it's the end of my day, mainly
because I got side-tracked. The delta between -rc2 and -rc3 is bigger
than I'd have liked, but, I can accept it. I will be more stringent
moving forward, and at this point the only "big" changes I'm expecting
are the fixes for m68k, and powerpc 8xx platforms, which have been
posted for a while and I believe it's a matter of custodian time to
collect and test everything.

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

Continuing on schedule now and that means the rest of the rcs every
other Monday, and with final release on April 3rd, 2023.  Thanks all!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 6/7] proftool: Remove unused variables in make_flame_tree

2023-02-27 Thread Tom Rini
With clang-15 we now get reported that in the make_flame_tree function,
neither the missing_count nor depth variables are used, only
incremenete/decremented. Remove these.

Signed-off-by: Tom Rini 
---
Cc: Simon Glass 
---
 tools/proftool.c | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/tools/proftool.c b/tools/proftool.c
index 089360428c2c..101bcb63334e 100644
--- a/tools/proftool.c
+++ b/tools/proftool.c
@@ -1713,18 +1713,11 @@ static int make_flame_tree(enum out_format_t out_format,
struct flame_state state;
struct flame_node *tree;
struct trace_call *call;
-   int missing_count = 0;
-   int i, depth;
+   int i;
 
/* maintain a stack of start times, etc. for 'calling' functions */
state.stack_ptr = 0;
 
-   /*
-* The first thing in the trace may not be the top-level function, so
-* set the initial depth so that no function goes below depth 0
-*/
-   depth = -calc_min_depth();
-
tree = create_node("tree");
if (!tree)
return -1;
@@ -1736,16 +1729,10 @@ static int make_flame_tree(enum out_format_t out_format,
ulong timestamp = call->flags & FUNCF_TIMESTAMP_MASK;
struct func_info *func;
 
-   if (entry)
-   depth++;
-   else
-   depth--;
-
func = find_func_by_offset(call->func);
if (!func) {
warn("Cannot find function at %lx\n",
 text_offset + call->func);
-   missing_count++;
continue;
}
 
-- 
2.34.1



[PATCH 7/7] CI: Move to clang-15

2023-02-27 Thread Tom Rini
As this is now the stable release, move to using that now for our tests.

Signed-off-by: Tom Rini 
---
 .azure-pipelines.yml| 6 +++---
 .gitlab-ci.yml  | 4 ++--
 tools/docker/Dockerfile | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 30025ff7517e..59629b39265c 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -2,7 +2,7 @@ variables:
   windows_vm: windows-2019
   ubuntu_vm: ubuntu-22.04
   macos_vm: macOS-12
-  ci_runner_image: trini/u-boot-gitlab-ci-runner:jammy-20230126-17Feb2023
+  ci_runner_image: trini/u-boot-gitlab-ci-runner:jammy-20230126-27Feb2023
   # Add '-u 0' options for Azure pipelines, otherwise we get "permission
   # denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer",
   # since our $(ci_runner_image) user is not root.
@@ -244,7 +244,7 @@ stages:
   TEST_PY_BD: "sandbox"
 sandbox_clang:
   TEST_PY_BD: "sandbox"
-  OVERRIDE: "-O clang-14"
+  OVERRIDE: "-O clang-15"
 sandbox_nolto:
   TEST_PY_BD: "sandbox"
   BUILD_ENV: "NO_LTO=1"
@@ -498,7 +498,7 @@ stages:
   OVERRIDE: "-a ASAN"
 sandbox_clang_asan:
   BUILDMAN: "sandbox"
-  OVERRIDE: "-O clang-14 -a ASAN"
+  OVERRIDE: "-O clang-15 -a ASAN"
 samsung_socfpga:
   BUILDMAN: "samsung socfpga"
 sun4i:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e320a24ef31e..068f39eb1114 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@
 
 # Grab our configured image.  The source for this is found
 # in the u-boot tree at tools/docker/Dockerfile
-image: trini/u-boot-gitlab-ci-runner:jammy-20230126-17Feb2023
+image: trini/u-boot-gitlab-ci-runner:jammy-20230126-27Feb2023
 
 # We run some tests in different order, to catch some failures quicker.
 stages:
@@ -260,7 +260,7 @@ sandbox test.py:
 sandbox with clang test.py:
   variables:
 TEST_PY_BD: "sandbox"
-OVERRIDE: "-O clang-14"
+OVERRIDE: "-O clang-15"
   <<: *buildman_and_testpy_dfn
 
 sandbox without LTO test.py:
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index c367bb482b4d..99da8cd38cae 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -12,7 +12,7 @@ ENV DEBIAN_FRONTEND=noninteractive
 # Add LLVM repository
 RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf 
/var/lib/apt/lists/*
 RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
-RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main | tee 
/etc/apt/sources.list.d/llvm.list
+RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main | tee 
/etc/apt/sources.list.d/llvm.list
 
 # Manually install the kernel.org "Crosstool" based toolchains for gcc-12.2.0
 RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-aarch64-linux.tar.xz
 | tar -C /opt -xJ
@@ -39,7 +39,7 @@ RUN apt-get update && apt-get install -y \
binutils-dev \
bison \
build-essential \
-   clang-14 \
+   clang-15 \
coreutils \
cpio \
cppcheck \
-- 
2.34.1



[PATCH 5/7] imx8image: Remove unused cont_img_count variable

2023-02-27 Thread Tom Rini
With clang-15, it is now reported that cont_img_count is unused. This is
true as the code will increment / reset this counter, but never
functionally use it. Remove it.

Signed-off-by: Tom Rini 
---
Cc: Peng Fan 
Cc: Mikhail Ilin 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: "NXP i.MX U-Boot Team" 
---
 tools/imx8image.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/tools/imx8image.c b/tools/imx8image.c
index 395d5c64bdf0..c25ea84e25c5 100644
--- a/tools/imx8image.c
+++ b/tools/imx8image.c
@@ -829,7 +829,6 @@ static int build_container(soc_type_t soc, uint32_t 
sector_size,
int ret;
 
int container = -1;
-   int cont_img_count = 0; /* indexes to arrange the container */
 
memset((char *)&imx_header, 0, sizeof(imx_header_v3_t));
 
@@ -879,7 +878,6 @@ static int build_container(soc_type_t soc, uint32_t 
sector_size,
img_sp->src = file_off;
 
file_off += ALIGN(sbuf.st_size, sector_size);
-   cont_img_count++;
break;
 
case SECO:
@@ -899,7 +897,6 @@ static int build_container(soc_type_t soc, uint32_t 
sector_size,
img_sp->src = file_off;
 
file_off += sbuf.st_size;
-   cont_img_count++;
break;
 
case NEW_CONTAINER:
@@ -908,8 +905,6 @@ static int build_container(soc_type_t soc, uint32_t 
sector_size,
  CONTAINER_ALIGNMENT,
  CONTAINER_FLAGS_DEFAULT,
  fuse_version);
-   /* reset img count when moving to new container */
-   cont_img_count = 0;
scfw_flags = 0;
break;
 
-- 
2.34.1



[PATCH 3/7] libavb: Fix a warning with clang-15

2023-02-27 Thread Tom Rini
With clang-15 we now will get warnings such as:

warning: a function declaration without a prototype is deprecated in all
versions of C [-Wstrict-prototypes]

And it is easy enough to address this warning here, as we aren't
concerned with re-syncing with an upstream.

Signed-off-by: Tom Rini 
---
Cc: Igor Opaniuk 
---
 lib/libavb/avb_cmdline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libavb/avb_cmdline.c b/lib/libavb/avb_cmdline.c
index cb54e658c487..a58ce6c48c01 100644
--- a/lib/libavb/avb_cmdline.c
+++ b/lib/libavb/avb_cmdline.c
@@ -394,7 +394,7 @@ out:
   return ret;
 }
 
-AvbCmdlineSubstList* avb_new_cmdline_subst_list() {
+AvbCmdlineSubstList* avb_new_cmdline_subst_list(void) {
   return (AvbCmdlineSubstList*)avb_calloc(sizeof(AvbCmdlineSubstList));
 }
 
-- 
2.34.1



[PATCH 4/7] zlib: trees.c: Fix a warning with clang-15

2023-02-27 Thread Tom Rini
With clang-15 we now will get warnings such as:

warning: a function declaration without a prototype is deprecated in all
versions of C [-Wstrict-prototypes]

And it is easy enough to address this warning here, even if we would
like to stay in sync more with upstream as it's a single location.

Signed-off-by: Tom Rini 
---
 lib/zlib/trees.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/zlib/trees.c b/lib/zlib/trees.c
index 970bc5dbc64e..e040617686a1 100644
--- a/lib/zlib/trees.c
+++ b/lib/zlib/trees.c
@@ -237,7 +237,7 @@ local void send_bits(s, value, length)
 /* ===
  * Initialize the various 'constant' tables.
  */
-local void tr_static_init()
+local void tr_static_init(void)
 {
 #if defined(GEN_TREES_H) || !defined(STDC)
 static int static_init_done = 0;
-- 
2.34.1



[PATCH 1/7] global: Disable deprecated-non-prototype warning with clang

2023-02-27 Thread Tom Rini
We have a number of places in the code which use the following syntax:

void func(a, b, c)
int a; /* Does a */
something_t *b; /* Pointer to b */
int c; /* Does c */
{
...
}

Which while not what we document as our coding style, this is also code
which we have imported from other projects, and would like to re-sync
with in the future. While the biggest example of this is the zlib code,
there are other places as well. For now, we will silence this warning.

Signed-off-by: Tom Rini 
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 54f894dab841..d2c132be6e09 100644
--- a/Makefile
+++ b/Makefile
@@ -790,6 +790,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, 
tautological-compare)
 # See modpost pattern 2
 KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
 KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
+KBUILD_CFLAGS += $(call cc-disable-warning, deprecated-non-prototype)
 endif
 
 # These warnings generated too much noise in a regular build.
-- 
2.34.1



[PATCH 2/7] dlmalloc: Fix a warning with clang-15

2023-02-27 Thread Tom Rini
With clang-15 we now will get warnings such as:

warning: a function declaration without a prototype is deprecated in all
versions of C [-Wstrict-prototypes]

And it is easy enough to address this warning here, as we aren't
concerned with re-syncing with an upstream.

Signed-off-by: Tom Rini 
---
 common/dlmalloc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 41c7230424cc..0f9b7262d512 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -80,7 +80,7 @@ GmListElement* makeGmListElement (void* bas)
return this;
 }
 
-void gcleanup ()
+void gcleanup (void)
 {
BOOL rval;
assert ( (head == NULL) || (head->base == (void*)gAddressBase));
@@ -2340,7 +2340,7 @@ size_t malloc_usable_size(mem) Void_t* mem;
 /* Utility to update current_mallinfo for malloc_stats and mallinfo() */
 
 #ifdef DEBUG
-static void malloc_update_mallinfo()
+static void malloc_update_mallinfo(void)
 {
   int i;
   mbinptr b;
@@ -2397,7 +2397,7 @@ static void malloc_update_mallinfo()
 */
 
 #ifdef DEBUG
-void malloc_stats()
+void malloc_stats(void)
 {
   malloc_update_mallinfo();
   printf("max system bytes = %10u\n",
@@ -2418,7 +2418,7 @@ void malloc_stats()
 */
 
 #ifdef DEBUG
-struct mallinfo mALLINFo()
+struct mallinfo mALLINFo(void)
 {
   malloc_update_mallinfo();
   return current_mallinfo;
-- 
2.34.1



Re: [PATCH 2/2] arm: mvebu: clearfog: Add defconfig for SPI booting

2023-02-27 Thread Tony Dinh
Hi Stefan,

On Sun, Feb 26, 2023 at 11:40 PM Stefan Roese  wrote:
>
> Hi Tony,
>
> On 2/27/23 01:11, Tony Dinh wrote:
> > Hi Pali,
> >
> > On Sun, Feb 26, 2023 at 2:52 AM Pali Rohár  wrote:
> >>
> >> On Saturday 25 February 2023 20:56:10 Tony Dinh wrote:
> >>> Hi Martin,
> >>>
> >>> On Sat, Feb 25, 2023 at 6:17 PM Martin Rowe  
> >>> wrote:
> 
> >>> I'm not sure how to run proper timing tests on the process, but
> >>> stopwatch timing just between seeing "Trying to boot" and "U-Boot
> >>> 2023.04-rc2" showed the return to BootROM under 1 second, and the
> >>> direct from SPI around 4 seconds. I thought the goal of loading from
> >>> SPI directly was speed, but returning to BootROM is significantly
> >>> faster on this board.
> >>
> >> You should check SPI speed in DTS file and also in the defconfig.
> >
> > I think we have probably seen this slowdown before. There is a TODO in
> > the way the DTS nodes are parsed by DM uclass. So this config must be
> > set in defconfig to get around that bug:
> > CONFIG_SF_DEFAULT_SPEED=5000
> 
>  That works and is much faster now. I'll submit it in a V2 for these
>  two patches once Pali's mvebu changes are accepted. Only question I
>  have is: should the faster speed be applied to all three defconfigs?
>  CONFIG_SF_DEFAULT_SPEED=100 (50x less) is implicitly added to the
>  MMC and SATA configs at the moment.
> >>>
> >>> This is only a workaround to get the SPI probe to work correctly. The
> >>> real fix should be in spi_flash_probe()
> >>> ./common/spl/spl_spi.c
> >>>  flash = spi_flash_probe(sf_bus, sf_cs,
> >>>  CONFIG_SF_DEFAULT_SPEED,
> >>>  CONFIG_SF_DEFAULT_MODE);
> >>> If spi_flash_probe() failed to get SPI max_hz from the DTS, the
> >>> fallback is CONFIG_SF_DEFAULT_SPEED.
> >>>
> >>> IMO, perhaps we could add CONFIG_SF_DEFAULT_SPEED and
> >>> CONFIG_SF_DEFAULT_MODE selection to arch/arm/mach-mvebu/Kconfig or
> >>> some other common place. And when we will have fixed the DTS parsing
> >>> problem, they can be removed.
> >>>
> >>> I'd like to hear from Stefan and Pali if this approach sounds good.
> >>>
> >>> All the best,
> >>> Tony
> >>
> >> Well, the maximal SPI speed depends on the wiring. You can have on the
> >> board some SPI device which does not support high frequency.
> >>
> >> But having some sane defaults in Kconfig for mvebu makes sense.
>
> Agreed.
>
> > The CONFIG_SF_DEFAULT_SPEED is set to 1_000_000 if the board defconfig
> > does not specify it. I think the sane default value is 10_000_000
> > (grepping the Armada* DTS files showing the slowest spi-max-frequency
> > is 10_000_000). While a big improvement, it is not fast enough for
> > many other boards. So we still need to define it in those board
> > defconfigs (before fixing that bug), or use return to BootROM.
>
> I'm fine with setting CONFIG_SF_DEFAULT_SPEED to 10.000.000 for MVEBU.
> Not sure if this should be done in drivers/mtd/spi/Kconfig, as this
> currently has no platform- / board- specific configurations. Perhaps
> it can be done in a mach-mvebu Kconfig file instead?

Yes, I think it should be done in mach-mvebu Kconfig, too. I will run
some tests.

Thanks,
Tony


[PATCH] image: Fix potentially uninitialized data variable

2023-02-27 Thread Marek Vasut
In case fitImage support is disabled, and image_locate_script() is
passed a fitImage, then the 'data' variable is used uninitialized.
Drop into the default: branch of the switch-case statement and do
not return the uninitialized data, and do not modify the return
pointer either, just print an error message.

Reported by clang build:
"
$ make HOSTCC=clang CC=clang KCFLAGS=-Werror sandbox64_defconfig && make 
HOSTCC=clang CC=clang KCFLAGS=-Werror
...
boot/image-board.c:1006:7: error: variable 'data' is used uninitialized 
whenever switch case is taken [-Werror,-Wsometimes-uninitialized]
case IMAGE_FORMAT_LEGACY:
 ^~~
include/image.h:608:29: note: expanded from macro 'IMAGE_FORMAT_LEGACY'
^~~~
boot/image-board.c:1128:19: note: uninitialized use occurs here
*datap = (char *)data;
 ^~~~
boot/image-board.c:1001:11: note: initialize the variable 'data' to silence 
this warning
u32 *data;
 ^
  = NULL
"

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Michal Simek 
Cc: Oleksandr Suvorov 
Cc: Simon Glass 
Cc: Stefan Roese 
Cc: Tom Rini 
---
 boot/image-board.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/boot/image-board.c b/boot/image-board.c
index 25b60ec30b3..9bf70824cb7 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -1004,7 +1004,9 @@ int image_locate_script(void *buf, int size, const char 
*fit_uname,
 
switch (genimg_get_format(buf)) {
case IMAGE_FORMAT_LEGACY:
-   if (IS_ENABLED(CONFIG_LEGACY_IMAGE_FORMAT)) {
+   if (!IS_ENABLED(CONFIG_LEGACY_IMAGE_FORMAT)) {
+   goto exit_image_format;
+   } else {
hdr = buf;
 
if (!image_check_magic(hdr)) {
@@ -1047,7 +1049,9 @@ int image_locate_script(void *buf, int size, const char 
*fit_uname,
}
break;
case IMAGE_FORMAT_FIT:
-   if (IS_ENABLED(CONFIG_FIT)) {
+   if (!IS_ENABLED(CONFIG_FIT)) {
+   goto exit_image_format;
+   } else {
fit_hdr = buf;
if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) {
puts("Bad FIT image format\n");
@@ -1121,12 +1125,15 @@ fallback:
}
break;
default:
-   puts("Wrong image format for \"source\" command\n");
-   return -EPERM;
+   goto exit_image_format;
}
 
*datap = (char *)data;
*lenp = len;
 
return 0;
+
+exit_image_format:
+   puts("Wrong image format for \"source\" command\n");
+   return -EPERM;
 }
-- 
2.39.2



[PATCH] console: Use only 0x00 as line separator for console recording

2023-02-27 Thread Marek Vasut
In case character 0x20 (space) is used as line separator,
character 0x9 (tab) is treated end of line. Commands which
output a lot of tabs, i.e. various tree printing commands
like 'fdt print' then end up generating a lot of newlines
in the recorded output, and the recorded output is corrupted.

Use character 0x00 (NUL) as separator instead to treat the
tabs as valid part of recorded line.

Suggested-by: Simon Glass 
Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 common/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/console.c b/common/console.c
index e4301a49322..71ad8efd6f4 100644
--- a/common/console.c
+++ b/common/console.c
@@ -842,7 +842,7 @@ int console_record_readline(char *str, int maxlen)
return -ENOSPC;
 
return membuff_readline((struct membuff *)&gd->console_out, str,
-   maxlen, ' ');
+   maxlen, '\0');
 }
 
 int console_record_avail(void)
-- 
2.39.2



[PATCH 31/32] test: cmd: fdt: Test fdt apply

2023-02-27 Thread Marek Vasut
Add 'fdt chosen' test which works as follows:
- Create basic DT, map it to sysmem
- Apply DTO which adds single property via fragment (without address spec)
- Apply DTO which adds more properties (string, u32, empty) and a subnode,
  with phandle via frament@0 and thus tests /__symbols__ node
- Apply DTO which modifies property of the previous DTO via phandle and thus
  tests the /__fixups__ node
- Print modified DT, verify it contains updates from DTOs

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 152 +
 1 file changed, 152 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 721916b070d..02c13e2d9b9 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1338,6 +1338,158 @@ static int fdt_test_chosen(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_chosen, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_apply(struct unit_test_state *uts)
+{
+   char fdt[8192], fdto[8192];
+   ulong addr, addro;
+
+   /* Create base DT with __symbols__ node */
+   ut_assertok(fdt_create(fdt, sizeof(fdt)));
+   ut_assertok(fdt_finish_reservemap(fdt));
+   ut_assert(fdt_begin_node(fdt, "") >= 0);
+   ut_assert(fdt_begin_node(fdt, "__symbols__") >= 0);
+   ut_assertok(fdt_end_node(fdt));
+   ut_assertok(fdt_end_node(fdt));
+   ut_assertok(fdt_finish(fdt));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Create DTO which adds single property to root node / */
+   ut_assertok(fdt_create(fdto, sizeof(fdto)));
+   ut_assertok(fdt_finish_reservemap(fdto));
+   ut_assert(fdt_begin_node(fdto, "") >= 0);
+   ut_assert(fdt_begin_node(fdto, "fragment") >= 0);
+   ut_assertok(fdt_property_string(fdto, "target-path", "/"));
+   ut_assert(fdt_begin_node(fdto, "__overlay__") >= 0);
+   ut_assertok(fdt_property_string(fdto, "newstring", "newvalue"));
+   ut_assertok(fdt_end_node(fdto));
+   ut_assertok(fdt_end_node(fdto));
+   ut_assertok(fdt_finish(fdto));
+   addro = map_to_sysmem(fdto);
+
+   /* Test default DT print */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt print /"));
+   ut_assert_nextline("/ {");
+   ut_assert_nextline("\t__symbols__ {");
+   ut_assert_nextline("\t};");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test simple DTO application */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt apply 0x%08x", addro));
+   ut_assertok(run_commandf("fdt print /"));
+   ut_assert_nextline("/ {");
+   ut_assert_nextline("\tnewstring = \"newvalue\";");
+   ut_assert_nextline("\t__symbols__ {");
+   ut_assert_nextline("\t};");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Create complex DTO which:
+* - modifies newstring property in root node /
+* - adds new properties to root node /
+* - adds new subnode with properties to root node /
+* - adds phandle to the subnode and therefore __symbols__ node
+*/
+   ut_assertok(fdt_create(fdto, sizeof(fdto)));
+   ut_assertok(fdt_finish_reservemap(fdto));
+   ut_assert(fdt_begin_node(fdto, "") >= 0);
+   ut_assertok(fdt_property_cell(fdto, "#address-cells", 1));
+   ut_assertok(fdt_property_cell(fdto, "#size-cells", 0));
+
+   ut_assert(fdt_begin_node(fdto, "fragment@0") >= 0);
+   ut_assertok(fdt_property_string(fdto, "target-path", "/"));
+   ut_assert(fdt_begin_node(fdto, "__overlay__") >= 0);
+   ut_assertok(fdt_property_string(fdto, "newstring", "newervalue"));
+   ut_assertok(fdt_property_u32(fdto, "newu32", 0x12345678));
+   ut_assertok(fdt_property(fdto, "empty-property", NULL, 0));
+   ut_assert(fdt_begin_node(fdto, "subnode") >= 0);
+   ut_assertok(fdt_property_string(fdto, "subnewstring", "newervalue"));
+   ut_assertok(fdt_property_u32(fdto, "subnewu32", 0x12345678));
+   ut_assertok(fdt_property(fdto, "subempty-property", NULL, 0));
+   ut_assertok(fdt_property_u32(fdto, "phandle", 0x01));
+   ut_assertok(fdt_end_node(fdto));
+   ut_assertok(fdt_end_node(fdto));
+   ut_assertok(fdt_end_node(fdto));
+
+   ut_assert(fdt_begin_node(fdto, "__symbols__") >= 0);
+   ut_assertok(fdt_property_string(fdto, "subnodephandle", 
"/fragment@0/__overlay__/subnode"));
+   ut_assertok(fdt_end_node(fdto));
+   ut_assertok(fdt_finish(fdto));
+   addro = map_to_sysmem(fdto);
+
+   /* Test complex DTO application */
+   ut_assertok(console_record_reset_enable());
+   ut_asser

[PATCH 32/32] test: cmd: fdt: Add list of remaining missing tests

2023-02-27 Thread Marek Vasut
Add list of missing tests for the 'fdt' command, currently
the missing sandbox tests are only 'fdt boardsetup' and
'fdt checksign' .

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 02c13e2d9b9..cb9379cdd4f 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -15,6 +15,13 @@
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
+/*
+ * Missing tests:
+ * fdt boardsetup - Do board-specific set up
+ * fdt checksign [] - check FIT signature
+ *   - address of key blob
+ *   default gd->fdt_blob
+ */
 
 /* Declare a new fdt test */
 #define FDT_TEST(_name, _flags)UNIT_TEST(_name, _flags, fdt_test)
-- 
2.39.2



[PATCH 28/32] test: cmd: fdt: Test fdt memory

2023-02-27 Thread Marek Vasut
Add 'fdt memory' test which works as follows:
- Create custom FDT with /memory node, with select #*cells, map it to sysmem
- Perform memory fixup
- Read back the /memory node and validate its content

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 83 ++
 1 file changed, 83 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index f4dd4238ad2..ff97571a64b 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1144,6 +1144,89 @@ static int fdt_test_bootcpu(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_bootcpu, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_memory_cells(struct unit_test_state *uts,
+const unsigned int cells)
+{
+   unsigned char *pada, *pads;
+   unsigned char *seta, *sets;
+   char fdt[8192];
+   const int size = sizeof(fdt);
+   fdt32_t *regs;
+   ulong addr;
+   char *spc;
+   int i;
+
+   /* Create DT with node /memory { regs = <0x100 0x200>; } and #*cells */
+   ut_assertnonnull(regs = calloc(2 * cells, sizeof(*regs)));
+   ut_assertnonnull(pada = calloc(12, cells));
+   ut_assertnonnull(pads = calloc(12, cells));
+   ut_assertnonnull(seta = calloc(12, cells));
+   ut_assertnonnull(sets = calloc(12, cells));
+   for (i = cells; i >= 1; i--) {
+   regs[cells - 1] = cpu_to_fdt32(i * 0x1);
+   regs[(cells * 2) - 1] = cpu_to_fdt32(~i);
+   snprintf(seta + (8 * (cells - i)), 9, "%08x", i * 0x1);
+   snprintf(sets + (8 * (cells - i)), 9, "%08x", ~i);
+   spc = (i != 1) ? " " : "";
+   snprintf(pada + (11 * (cells - i)), 12, "0x%08x%s", i * 
0x1, spc);
+   snprintf(pads + (11 * (cells - i)), 12, "0x%08x%s", ~i, spc);
+   }
+
+   ut_assertok(fdt_create(fdt, size));
+   ut_assertok(fdt_finish_reservemap(fdt));
+   ut_assert(fdt_begin_node(fdt, "") >= 0);
+   ut_assertok(fdt_property_u32(fdt, "#address-cells", cells));
+   ut_assertok(fdt_property_u32(fdt, "#size-cells", cells));
+   ut_assert(fdt_begin_node(fdt, "memory") >= 0);
+   ut_assertok(fdt_property_string(fdt, "device_type", "memory"));
+   ut_assertok(fdt_property(fdt, "reg", ®s, cells * 2));
+   ut_assertok(fdt_end_node(fdt));
+   ut_assertok(fdt_end_node(fdt));
+   ut_assertok(fdt_finish(fdt));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test updating the memory node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt memory 0x%s 0x%s", seta, sets));
+   ut_assertok(run_commandf("fdt print /memory"));
+   ut_assert_nextline("memory {");
+   ut_assert_nextline("\tdevice_type = \"memory\";");
+   ut_assert_nextline("\treg = <%s %s>;", pada, pads);
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   free(sets);
+   free(seta);
+   free(pads);
+   free(pada);
+   free(regs);
+
+   return 0;
+}
+
+static int fdt_test_memory(struct unit_test_state *uts)
+{
+   /*
+* Test memory fixup for 32 and 64 bit systems, anything bigger is
+* so far unsupported and fails because of simple_stroull() being
+* 64bit tops in the 'fdt memory' command implementation.
+*/
+   fdt_test_memory_cells(uts, 1);
+   fdt_test_memory_cells(uts, 2);
+
+   /*
+* The 'fdt memory' command is limited to /memory node, it does
+* not support any other valid DT memory node format, which is
+* either one or multiple /memory@adresss nodes. Therefore, this
+* DT variant is not tested here.
+*/
+
+   return 0;
+}
+FDT_TEST(fdt_test_memory, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 29/32] test: cmd: fdt: Test fdt rsvmem

2023-02-27 Thread Marek Vasut
Add 'fdt rsvmem' test which works as follows:
- Create custom FDT with single reserved memory (rsvmem) entry, map it to sysmem
- Add new rsvmem entry
- Delete existing older rsvmem entry
- Add new rsvmem entry again
- Always print the rsvmem list and validate it

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 63 ++
 1 file changed, 63 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index ff97571a64b..8f7a62584da 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1227,6 +1227,69 @@ static int fdt_test_memory(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_memory, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_rsvmem(struct unit_test_state *uts)
+{
+   char fdt[8192];
+   ulong addr;
+
+   ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   fdt_add_mem_rsv(fdt, 0x42, 0x1701);
+   fdt_add_mem_rsv(fdt, 0x74656, 0x9);
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test default reserved memory node presence */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rsvmem print"));
+   ut_assert_nextline("index\t\t   start\t\tsize");
+   ut_assert_nextline("");
+   ut_assert_nextline("%x\t%016x\t%016x", 0, 0x42, 0x1701);
+   ut_assert_nextline("%x\t%016x\t%016x", 1, 0x74656, 0x9);
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test add new reserved memory node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rsvmem add 0x1234 0x5678"));
+   ut_assertok(run_commandf("fdt rsvmem print"));
+   ut_assert_nextline("index\t\t   start\t\tsize");
+   ut_assert_nextline("");
+   ut_assert_nextline("%x\t%016x\t%016x", 0, 0x42, 0x1701);
+   ut_assert_nextline("%x\t%016x\t%016x", 1, 0x74656, 0x9);
+   ut_assert_nextline("%x\t%016x\t%016x", 2, 0x1234, 0x5678);
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test delete reserved memory node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rsvmem delete 0"));
+   ut_assertok(run_commandf("fdt rsvmem print"));
+   ut_assert_nextline("index\t\t   start\t\tsize");
+   ut_assert_nextline("");
+   ut_assert_nextline("%x\t%016x\t%016x", 0, 0x74656, 0x9);
+   ut_assert_nextline("%x\t%016x\t%016x", 1, 0x1234, 0x5678);
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test re-add new reserved memory node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rsvmem add 0x42 0x1701"));
+   ut_assertok(run_commandf("fdt rsvmem print"));
+   ut_assert_nextline("index\t\t   start\t\tsize");
+   ut_assert_nextline("");
+   ut_assert_nextline("%x\t%016x\t%016x", 0, 0x74656, 0x9);
+   ut_assert_nextline("%x\t%016x\t%016x", 1, 0x1234, 0x5678);
+   ut_assert_nextline("%x\t%016x\t%016x", 2, 0x42, 0x1701);
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test delete nonexistent reserved memory node */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt rsvmem delete 10"));
+   ut_assert_nextline("libfdt fdt_del_mem_rsv(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_rsvmem, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 30/32] test: cmd: fdt: Test fdt chosen

2023-02-27 Thread Marek Vasut
Add 'fdt chosen' test which works as follows:
- Create basic DT, map it to sysmem
- Print /chosen node, verify it is nonexistent
- Create chosen node
- Print /chosen node, verify it contains only version
- Create /chosen node with initrd entries
- Print /chosen node, verify it contains version and initrd entries

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 48 
 1 file changed, 48 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 8f7a62584da..721916b070d 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1290,6 +1290,54 @@ static int fdt_test_rsvmem(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_rsvmem, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_chosen(struct unit_test_state *uts)
+{
+   const char *env_bootargs = env_get("bootargs");
+   char fdt[8192];
+   ulong addr;
+
+   ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test default chosen node presence, fail as there is no /chosen node 
*/
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt print /chosen"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test add new chosen node without initrd */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt chosen"));
+   ut_assertok(run_commandf("fdt print /chosen"));
+   ut_assert_nextline("chosen {");
+   ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version 
string */
+   if (env_bootargs)
+   ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs);
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test add new chosen node with initrd */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt chosen 0x1234 0x5678"));
+   ut_assertok(run_commandf("fdt print /chosen"));
+   ut_assert_nextline("chosen {");
+   ut_assert_nextline("\tlinux,initrd-end = <0x%08x 0x%08x>;",
+  upper_32_bits(0x1234 + 0x5678 - 1),
+  lower_32_bits(0x1234 + 0x5678 - 1));
+   ut_assert_nextline("\tlinux,initrd-start = <0x%08x 0x%08x>;",
+  upper_32_bits(0x1234), lower_32_bits(0x1234));
+   ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version 
string */
+   if (env_bootargs)
+   ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs);
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_chosen, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 27/32] test: cmd: fdt: Test fdt bootcpu

2023-02-27 Thread Marek Vasut
Add 'fdt bootcpu' test which works as follows:
- Create basic FDT, map it to sysmem
- Print the FDT bootcpu
- Set the FDT bootcpu and read the value back using 'fdt header get'
- Perform the previous step twice to validate bootcpu overwrite

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index b0c7ff52ca3..f4dd4238ad2 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -,6 +,39 @@ static int fdt_test_header(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_header, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_bootcpu(struct unit_test_state *uts)
+{
+   char fdt[256];
+   ulong addr;
+   int i;
+
+   ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test getting default bootcpu entry */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt header get bootcpu boot_cpuid_phys"));
+   ut_asserteq(0, env_get_ulong("bootcpu", 10, 0x1234));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test setting and getting new bootcpu entry, twice, to test overwrite 
*/
+   for (i = 42; i <= 43; i++) {
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt bootcpu %d", i));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting new bootcpu entry */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt header get bootcpu 
boot_cpuid_phys"));
+   ut_asserteq(i, env_get_ulong("bootcpu", 10, 0x1234));
+   ut_assertok(ut_check_console_end(uts));
+   }
+
+   return 0;
+}
+FDT_TEST(fdt_test_bootcpu, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 26/32] test: cmd: fdt: Test fdt header

2023-02-27 Thread Marek Vasut
Add 'fdt header' test which works as follows:
- Create basic FDT, map it to sysmem
- Print the FDT header
- Get all members of the FDT header into variable and
  verify the variables contain correct data

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 59 ++
 1 file changed, 59 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 39a20337c95..b0c7ff52ca3 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1052,6 +1052,65 @@ static int fdt_test_rm(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_rm, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_header_get(struct unit_test_state *uts, char fdt[4096],
+  const char *field, const unsigned long val)
+{
+   /* Test getting valid header entry */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt header get fvar %s", field));
+   ut_asserteq(val, env_get_hex("fvar", 0x1234));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting malformed header entry */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt header get fvar typo%stypo", field));
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_header(struct unit_test_state *uts)
+{
+   char fdt[256];
+   ulong addr;
+
+   ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test header print */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt header"));
+   ut_assert_nextline("magic:\t\t\t0x%x", fdt_magic(fdt));
+   ut_assert_nextline("totalsize:\t\t0x%x (%d)", fdt_totalsize(fdt), 
fdt_totalsize(fdt));
+   ut_assert_nextline("off_dt_struct:\t\t0x%x", fdt_off_dt_struct(fdt));
+   ut_assert_nextline("off_dt_strings:\t\t0x%x", fdt_off_dt_strings(fdt));
+   ut_assert_nextline("off_mem_rsvmap:\t\t0x%x", fdt_off_mem_rsvmap(fdt));
+   ut_assert_nextline("version:\t\t%d", fdt_version(fdt));
+   ut_assert_nextline("last_comp_version:\t%d", 
fdt_last_comp_version(fdt));
+   ut_assert_nextline("boot_cpuid_phys:\t0x%x", fdt_boot_cpuid_phys(fdt));
+   ut_assert_nextline("size_dt_strings:\t0x%x", fdt_size_dt_strings(fdt));
+   ut_assert_nextline("size_dt_struct:\t\t0x%x", fdt_size_dt_struct(fdt));
+   ut_assert_nextline("number mem_rsv:\t\t0x%x", fdt_num_mem_rsv(fdt));
+   ut_assert_nextline_empty();
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test header get */
+   fdt_test_header_get(uts, fdt, "magic", fdt_magic(fdt));
+   fdt_test_header_get(uts, fdt, "totalsize", fdt_totalsize(fdt));
+   fdt_test_header_get(uts, fdt, "off_dt_struct", fdt_off_dt_struct(fdt));
+   fdt_test_header_get(uts, fdt, "off_dt_strings", 
fdt_off_dt_strings(fdt));
+   fdt_test_header_get(uts, fdt, "off_mem_rsvmap", 
fdt_off_mem_rsvmap(fdt));
+   fdt_test_header_get(uts, fdt, "version", fdt_version(fdt));
+   fdt_test_header_get(uts, fdt, "last_comp_version", 
fdt_last_comp_version(fdt));
+   fdt_test_header_get(uts, fdt, "boot_cpuid_phys", 
fdt_boot_cpuid_phys(fdt));
+   fdt_test_header_get(uts, fdt, "size_dt_strings", 
fdt_size_dt_strings(fdt));
+   fdt_test_header_get(uts, fdt, "size_dt_struct", 
fdt_size_dt_struct(fdt));
+
+   return 0;
+}
+FDT_TEST(fdt_test_header, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 25/32] test: cmd: fdt: Test fdt rm

2023-02-27 Thread Marek Vasut
Add 'fdt rm' test which works as follows:
- Create fuller FDT, map it to sysmem
- Selectively delete nodes or properties by both path and aliases
- Verify created nodes or properties using fdt print command

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 84 ++
 1 file changed, 84 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index dec783f6e26..39a20337c95 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -968,6 +968,90 @@ static int fdt_test_mknode(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_mknode, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_rm(struct unit_test_state *uts)
+{
+   char fdt[4096];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test removal of property in root node / */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt print / compatible"));
+   ut_assert_nextline("compatible = \"u-boot,fdt-test\"");
+   ut_assertok(run_commandf("fdt rm / compatible"));
+   ut_asserteq(1, run_commandf("fdt print / compatible"));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of property clock-names in subnode /test-node@1234 */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt print /test-node@1234 clock-names"));
+   ut_assert_nextline("clock-names = \"fixed\", \"i2c\", \"spi\", 
\"uart2\", \"uart1\"");
+   ut_assertok(run_commandf("fdt rm /test-node@1234 clock-names"));
+   ut_asserteq(1, run_commandf("fdt print /test-node@1234 clock-names"));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of property u-boot,empty-property in subnode 
/test-node@1234 by alias */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt print testnodealias 
u-boot,empty-property"));
+   ut_assert_nextline("testnodealias u-boot,empty-property");
+   ut_assertok(run_commandf("fdt rm testnodealias u-boot,empty-property"));
+   ut_asserteq(1, run_commandf("fdt print testnodealias 
u-boot,empty-property"));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of non-existent property noprop in subnode 
/test-node@1234 */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt rm /test-node@1234 noprop"));
+   ut_assert_nextline("libfdt fdt_delprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of non-existent node /no-node@5678 */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt rm /no-node@5678"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of subnode /test-node@1234/subnode by alias */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rm subnodealias"));
+   ut_asserteq(1, run_commandf("fdt print /test-node@1234/subnode"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of node by non-existent alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt rm noalias"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of node by bad alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt rm noalias"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of node /test-node@1234 */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rm /test-node@1234"));
+   ut_asserteq(1, run_commandf("fdt print /test-node@1234"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of node / */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rm /"));
+   ut_asserteq(1, run_commandf("fdt print /"));
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_rm, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int 

[PATCH 24/32] test: cmd: fdt: Test fdt mknode

2023-02-27 Thread Marek Vasut
Add 'fdt mknode' test which works as follows:
- Create fuller FDT, map it to sysmem
- Create node either in / or subnode
- Attempt to create node over existing node, which fails
- Attempt to create subnodes in non-existing nodes or aliases
- Verify created nodes using fdt list command

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 68 ++
 1 file changed, 68 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 42d067090aa..dec783f6e26 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -900,6 +900,74 @@ static int fdt_test_set(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_set, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_mknode(struct unit_test_state *uts)
+{
+   char fdt[8192];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test creation of new node in / */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt mknode / newnode"));
+   ut_assertok(run_commandf("fdt list /newnode"));
+   ut_assert_nextline("newnode {");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in /test-node@1234 */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt mknode /test-node@1234 newsubnode"));
+   ut_assertok(run_commandf("fdt list /test-node@1234/newsubnode"));
+   ut_assert_nextline("newsubnode {");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in /test-node@1234 by alias */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt mknode testnodealias newersubnode"));
+   ut_assertok(run_commandf("fdt list testnodealias/newersubnode"));
+   ut_assert_nextline("newersubnode {");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in /test-node@1234 over existing node */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt mknode testnodealias newsubnode"));
+   ut_assert_nextline("libfdt fdt_add_subnode(): FDT_ERR_EXISTS");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in /test-node@1234 by alias over existing 
node */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt mknode testnodealias newersubnode"));
+   ut_assert_nextline("libfdt fdt_add_subnode(): FDT_ERR_EXISTS");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in non-existent node */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt mknode /no-node newnosubnode"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in non-existent alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt mknode noalias newfailsubnode"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in bad alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt mknode badalias newbadsubnode"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_mknode, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 23/32] test: cmd: fdt: Test fdt set

2023-02-27 Thread Marek Vasut
Add 'fdt set' test which works as follows:
- Create fuller FDT, map it to sysmem
- Set either existing property to overwrite it, or new property
- Test setting both single properties as well as string and integer arrays
- Test setting to non-existent nodes and aliases
- Verify set values using 'fdt get value'

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 123 +
 1 file changed, 123 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index ae67b468b71..42d067090aa 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -777,6 +777,129 @@ static int fdt_test_get_size(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_get_size, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_set_single(struct unit_test_state *uts,
+  const char *path, const char *prop,
+  const char *sval, int ival, bool integer)
+{
+   ut_assertok(console_record_reset_enable());
+   if (sval) {
+   ut_assertok(run_commandf("fdt set %s %s %s", path, prop, sval));
+   } else if (integer) {
+   ut_assertok(run_commandf("fdt set %s %s <%d>", path, prop, 
ival));
+   } else {
+   ut_assertok(run_commandf("fdt set %s %s", path, prop));
+   }
+
+   ut_assertok(run_commandf("fdt get value svar %s %s", path, prop));
+   if (sval) {
+   ut_asserteq_str(sval, env_get("svar"));
+   } else if (integer) {
+   ut_asserteq(ival, env_get_hex("svar", 0x1234));
+   } else {
+   ut_assertnull(env_get("svar"));
+   }
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_set_multi(struct unit_test_state *uts,
+ const char *path, const char *prop,
+ const char *sval1, const char *sval2,
+ int ival1, int ival2)
+{
+   ut_assertok(console_record_reset_enable());
+   if (sval1 && sval2) {
+   ut_assertok(run_commandf("fdt set %s %s %s %s end", path, prop, 
sval1, sval2));
+   ut_assertok(run_commandf("fdt set %s %s %s %s", path, prop, 
sval1, sval2));
+   } else {
+   ut_assertok(run_commandf("fdt set %s %s <%d %d 10>", path, 
prop, ival1, ival2));
+   ut_assertok(run_commandf("fdt set %s %s <%d %d>", path, prop, 
ival1, ival2));
+   }
+
+   /*
+* The "end/10" above and "svarn" below is used to validate that
+* previous 'fdt set' to longer array does not polute newly set
+* shorter array.
+*/
+   ut_assertok(run_commandf("fdt get value svar1 %s %s 0", path, prop));
+   ut_assertok(run_commandf("fdt get value svar2 %s %s 1", path, prop));
+   ut_asserteq(1, run_commandf("fdt get value svarn %s %s 2", path, prop));
+   if (sval1 && sval2) {
+   ut_asserteq_str(sval1, env_get("svar1"));
+   ut_asserteq_str(sval2, env_get("svar2"));
+   ut_assertnull(env_get("svarn"));
+   } else {
+   ut_asserteq(ival1, env_get_hex("svar1", 0x1234));
+   ut_asserteq(ival2, env_get_hex("svar2", 0x1234));
+   ut_assertnull(env_get("svarn"));
+   }
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_set_node(struct unit_test_state *uts,
+const char *path, const char *prop)
+{
+   fdt_test_set_single(uts, path, prop, "new", 0, false);
+   fdt_test_set_single(uts, path, prop, "rewrite", 0, false);
+   fdt_test_set_single(uts, path, prop, NULL, 42, true);
+   fdt_test_set_single(uts, path, prop, NULL, 0, false);
+   fdt_test_set_multi(uts, path, prop, NULL, NULL, 42, 1701);
+   fdt_test_set_multi(uts, path, prop, NULL, NULL, 74656, 9);
+   fdt_test_set_multi(uts, path, prop, "42", "1701", 0, 0);
+   fdt_test_set_multi(uts, path, prop, "74656", "9", 0, 0);
+
+   return 0;
+}
+
+static int fdt_test_set(struct unit_test_state *uts)
+{
+   char fdt[8192];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test setting of root node / existing property "compatible" */
+   fdt_test_set_node(uts, "/", "compatible");
+
+   /* Test setting of root node / new property "newproperty" */
+   fdt_test_set_node(uts, "/", "newproperty");
+
+   /* Test setting of subnode existing property "compatible" */
+   fdt_test_set_node(uts, "/test-node@1234/subnode", "compatible");
+   fdt_test_set_node(uts, "subnodealias", "compatible");
+
+   /* Test setting of s

[PATCH 22/32] test: cmd: fdt: Test fdt get size

2023-02-27 Thread Marek Vasut
Add 'fdt get size' test which works as follows:
- Create fuller FDT, map it to sysmem
- Get size of various properties
- Get node count of available nodes
- Test non-existent nodes and properties

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 87 ++
 1 file changed, 87 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index e829052bfd9..ae67b468b71 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -690,6 +690,93 @@ static int fdt_test_get_addr(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_get_addr, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_get_size_common(struct unit_test_state *uts,
+const char *path, const char *prop,
+const unsigned int val)
+{
+   ut_assertok(console_record_reset_enable());
+   if (prop) {
+   ut_assertok(run_commandf("fdt get size sstr %s %s", path, 
prop));
+   } else {
+   ut_assertok(run_commandf("fdt get size sstr %s", path));
+   }
+   ut_asserteq(val, env_get_hex("sstr", 0x1234));
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_get_size(struct unit_test_state *uts)
+{
+   char fdt[4096];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test getting size of root node / string property "compatible" */
+   fdt_test_get_size_common(uts, "/", "compatible", 16);
+
+   /* Test getting size of node /test-node@1234 stringlist property 
"clock-names" */
+   fdt_test_get_size_common(uts, "/test-node@1234", "clock-names", 26);
+   fdt_test_get_size_common(uts, "testnodealias", "clock-names", 26);
+
+   /* Test getting size of node /test-node@1234 u32 property 
"clock-frequency" */
+   fdt_test_get_size_common(uts, "/test-node@1234", "clock-frequency", 4);
+   fdt_test_get_size_common(uts, "testnodealias", "clock-frequency", 4);
+
+   /* Test getting size of node /test-node@1234 empty property 
"u-boot,empty-property" */
+   fdt_test_get_size_common(uts, "/test-node@1234", 
"u-boot,empty-property", 0);
+   fdt_test_get_size_common(uts, "testnodealias", "u-boot,empty-property", 
0);
+
+   /* Test getting size of node /test-node@1234 array property "regs" */
+   fdt_test_get_size_common(uts, "/test-node@1234", "regs", 8);
+   fdt_test_get_size_common(uts, "testnodealias", "regs", 8);
+
+   /* Test getting node count of node / */
+   fdt_test_get_size_common(uts, "/", NULL, 2);
+
+   /* Test getting node count of node /test-node@1234/subnode */
+   fdt_test_get_size_common(uts, "/test-node@1234/subnode", NULL, 0);
+   fdt_test_get_size_common(uts, "subnodealias", NULL, 0);
+
+   /* Test getting size of node /test-node@1234/subnode non-existent 
property "noprop" */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get size pnoprop 
/test-node@1234/subnode noprop", 1));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_asserteq(1, run_command("fdt get size pnoprop subnodealias noprop", 
1));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting size of non-existent node /test-node@1234/nonode@1 
property "noprop" */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get size pnonode 
/test-node@1234/nonode@1 noprop", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting node count of non-existent node 
/test-node@1234/nonode@1 */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get size pnonode 
/test-node@1234/nonode@1", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting node count of bad alias badalias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get size pnonode badalias noprop", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting node count of non-existent alias noalias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get size pnonode noalias", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test

[PATCH 21/32] test: cmd: fdt: Test fdt get addr

2023-02-27 Thread Marek Vasut
Add 'fdt get addr' test which works as follows:
- Create fuller FDT, map it to sysmem
- Get address of various properties
- Compare addresses calculated by UT and fdt command

This test is special in that it has to go through gruesome remapping scheme
where the test calculates:
- pointer offsets of the generated FDT root and the property being tested
- map_sysmem() result of environment variable "fdtaddr" and the one set
  by the test matching address of property being tested
- difference between the later and the former, to obtain offset of the
  DT property from start of DT
The offsets must match in both the UT and the tested U-Boot, if they do
not, the test fails.

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 66 ++
 1 file changed, 66 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index fa95241c8f2..e829052bfd9 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -624,6 +624,72 @@ static int fdt_test_get_name(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_get_name, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_get_addr_common(struct unit_test_state *uts, char *fdt,
+   const char *path, const char *prop)
+{
+   unsigned int offset;
+   int path_offset;
+   void *prop_ptr;
+   int len = 0;
+
+   ut_assert((path_offset = fdt_path_offset(fdt, path)) >= 0);
+   ut_assertnonnull(prop_ptr = (void *)fdt_getprop(fdt, path_offset,
+   prop, &len));
+   offset = (char *)prop_ptr - fdt;
+
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt get addr pstr %s %s", path, prop));
+   ut_asserteq((ulong)map_sysmem(env_get_hex("fdtaddr", 0x1234), 0),
+   (ulong)(map_sysmem(env_get_hex("pstr", 0x1234), 0) - 
offset));
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_get_addr(struct unit_test_state *uts)
+{
+   char fdt[4096];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test getting address of root node / string property "compatible" */
+   fdt_test_get_addr_common(uts, fdt, "/", "compatible");
+
+   /* Test getting address of node /test-node@1234 stringlist property 
"clock-names" */
+   fdt_test_get_addr_common(uts, fdt, "/test-node@1234", "clock-names");
+   fdt_test_get_addr_common(uts, fdt, "testnodealias", "clock-names");
+
+   /* Test getting address of node /test-node@1234 u32 property 
"clock-frequency" */
+   fdt_test_get_addr_common(uts, fdt, "/test-node@1234", 
"clock-frequency");
+   fdt_test_get_addr_common(uts, fdt, "testnodealias", "clock-frequency");
+
+   /* Test getting address of node /test-node@1234 empty property 
"u-boot,empty-property" */
+   fdt_test_get_addr_common(uts, fdt, "/test-node@1234", 
"u-boot,empty-property");
+   fdt_test_get_addr_common(uts, fdt, "testnodealias", 
"u-boot,empty-property");
+
+   /* Test getting address of node /test-node@1234 array property "regs" */
+   fdt_test_get_addr_common(uts, fdt, "/test-node@1234", "regs");
+   fdt_test_get_addr_common(uts, fdt, "testnodealias", "regs");
+
+   /* Test getting address of node /test-node@1234/subnode non-existent 
property "noprop" */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get addr pnoprop 
/test-node@1234/subnode noprop", 1));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting address of non-existent node /test-node@1234/nonode@1 
property "noprop" */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get addr pnonode 
/test-node@1234/nonode@1 noprop", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_get_addr, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 20/32] test: cmd: fdt: Test fdt get name

2023-02-27 Thread Marek Vasut
Add 'fdt get name' test which works as follows:
- Create fuller FDT, map it to sysmem
- Get name of / node 0, 1 and /clk-test node 0
- Compare output and validate the node name
- Get name of / node 2 and /clk-test node 1
- Compare output and validate the node is not present
- Get name of / node -1 and /clk-test node -1
- Compare output and validate the node name equals node 0 name
- Check nonexistent node, verify the command errors out

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 79 ++
 1 file changed, 79 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 793525c02c5..fa95241c8f2 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -545,6 +545,85 @@ static int fdt_test_get_value(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_get_value, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_get_name(struct unit_test_state *uts)
+{
+   char fdt[4096];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test getting name of node 0 in /, which is /aliases node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_command("fdt get name nzero / 0", 0));
+   ut_asserteq_str("aliases", env_get("nzero"));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node 1 in /, which is /test-node@1234 node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_command("fdt get name none / 1", 0));
+   ut_asserteq_str("test-node@1234", env_get("none"));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node -1 in /, which is /aliases node, same as 0 
*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_command("fdt get name nmone / -1", 0));
+   ut_asserteq_str("aliases", env_get("nmone"));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node 2 in /, which does not exist */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get name ntwo / 2", 1));
+   ut_assert_nextline("libfdt node not found");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node 0 in /test-node@1234, which is /subnode 
node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_command("fdt get name snzero /test-node@1234 0", 0));
+   ut_asserteq_str("subnode", env_get("snzero"));
+   ut_assertok(run_command("fdt get name asnzero testnodealias 0", 0));
+   ut_asserteq_str("subnode", env_get("asnzero"));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node 1 in /test-node@1234, which does not exist 
*/
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get name snone /test-node@1234 1", 1));
+   ut_assert_nextline("libfdt node not found");
+   ut_asserteq(1, run_command("fdt get name asnone testnodealias 1", 1));
+   ut_assert_nextline("libfdt node not found");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node -1 in /test-node@1234, which is /subnode 
node, same as 0 */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_command("fdt get name snmone /test-node@1234 -1", 0));
+   ut_asserteq_str("subnode", env_get("snmone"));
+   ut_assertok(run_command("fdt get name asnmone testnodealias -1", 0));
+   ut_asserteq_str("subnode", env_get("asnmone"));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of nonexistent node */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get name nonode /nonexistent 0", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of bad alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get name vbadalias badalias 0", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of nonexistent alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get name vnoalias noalias 0", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_get_name, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 

[PATCH 19/32] test: cmd: fdt: Test fdt print and list

2023-02-27 Thread Marek Vasut
Add 'fdt print' and 'fdt list' test which works as follows:
- Create fuller FDT, map it to sysmem
- Print the entire FDT, parts of the FDT and select properties
- Compare output from the print or list

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 143 +
 1 file changed, 143 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 266fb6e3ed0..793525c02c5 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -296,6 +296,149 @@ static int fdt_test_resize(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_resize, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_print_list_common(struct unit_test_state *uts,
+ const char *opc, const char *node)
+{
+   /*
+* Test printing/listing the working FDT
+* subnode $node/subnode
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s/subnode", opc, node));
+   ut_assert_nextline("subnode {");
+   ut_assert_nextline("\t#address-cells = <0x>;");
+   ut_assert_nextline("\t#size-cells = <0x>;");
+   ut_assert_nextline("\tcompatible = 
\"u-boot,fdt-subnode-test-device\";");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path / string property model
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s / model", opc));
+   ut_assert_nextline("model = \"U-Boot FDT test\"");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path $node string property compatible
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s compatible", opc, node));
+   ut_assert_nextline("compatible = \"u-boot,fdt-test-device1\"");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path $node stringlist property clock-names
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s clock-names", opc, node));
+   ut_assert_nextline("clock-names = \"fixed\", \"i2c\", \"spi\", 
\"uart2\", \"uart1\"");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path $node u32 property clock-frequency
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s clock-frequency", opc, node));
+   ut_assert_nextline("clock-frequency = <0x00fde800>");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path $node empty property u-boot,empty-property
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s u-boot,empty-property", opc, node));
+   /*
+* This is the only 'fdt print' / 'fdt list' incantation which
+* prefixes the property with node path. This has been in U-Boot
+* since the beginning of the command 'fdt', keep it.
+*/
+   ut_assert_nextline("%s u-boot,empty-property", node);
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path $node prop-encoded array property regs
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s regs", opc, node));
+   ut_assert_nextline("regs = <0x1234 0x1000>");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_print_list(struct unit_test_state *uts, bool print)
+{
+   const char *opc = print ? "print" : "list";
+   char fdt[4096];
+   ulong addr;
+   int ret;
+
+   /* Original source DT */
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test printing/listing the working FDT -- node / */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s", opc));
+   ut_assert_nextline("/ {");
+   ut_assert_nextline("\t#address-cells = <0x0001>;");
+   ut_assert_nextline("\t#size-cells = <0x0001>;");
+   ut_assert_nextline("\tcompatible = \"u-boot,fdt-test\";");
+   ut_assert_nextline("\tmodel = \"U-Boot FDT test\";");
+   ut_assert_nextline("\taliases {");
+   if (print) {
+   ut_assert_nextline("\t\tbadalias = \"/bad/alias\";");
+   ut_assert_nextline("\t\tsubnodealias = 
\"/test-node@1234/subnode\";");
+   ut_assert_nextlin

[PATCH 18/32] test: cmd: fdt: Test fdt resize

2023-02-27 Thread Marek Vasut
Add 'fdt resize' test which works as follows:
- Create simple FDT with extra size 0, map it to sysmem
- 'resize' the FDT by 0x2000 bytes
- Verify the new space has been added to the FDT

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 023b83eb019..266fb6e3ed0 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -272,6 +272,30 @@ static int fdt_test_move(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_move, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_resize(struct unit_test_state *uts)
+{
+   char fdt[256];
+   const unsigned int newsize = 0x2000;
+   uint32_t ts;
+   ulong addr;
+
+   /* Original source DT */
+   ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+   fdt_shrink_to_minimum(fdt, 0);  /* Resize with 0 extra bytes */
+   ts = fdt_totalsize(fdt);
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test resizing the working FDT and verify the new space was added */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt resize %x", newsize));
+   ut_asserteq(ts + newsize, fdt_totalsize(fdt));
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_resize, UT_TESTF_CONSOLE_REC);
+
 /* Test 'fdt get value' reading an fdt */
 static int fdt_test_get_value_string(struct unit_test_state *uts,
 const char *node, const char *prop,
-- 
2.39.2



  1   2   >