[PATCH] rockchip: px30: sync serial flash controller bindings with mainline

2021-08-20 Thread Chris Morgan
From: Chris Morgan 

The devicetree submitted and approved for the mainline linux kernel is
slightly different than the one present here. This syncs both
devicetrees (for the Rockchip SFC node at least) present on the PX30
and the Odroid Go Advance. Changes include renaming the flash node,
reordering the values in the SFC node for the rk3326-odroid-go2,
changing the name of the cs pinctrl node to cs0, and updating the
u-boot specific tree to utilize the new flash node value.

Signed-off-by: Chris Morgan 
---
 arch/arm/dts/px30.dtsi | 4 ++--
 arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi | 2 +-
 arch/arm/dts/rk3326-odroid-go2.dts | 8 
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm/dts/px30.dtsi b/arch/arm/dts/px30.dtsi
index aaa8ae2235..ef706486dc 100644
--- a/arch/arm/dts/px30.dtsi
+++ b/arch/arm/dts/px30.dtsi
@@ -967,7 +967,7 @@
clocks = < SCLK_SFC>, < HCLK_SFC>;
clock-names = "clk_sfc", "hclk_sfc";
pinctrl-names = "default";
-   pinctrl-0 = <_clk _cs _bus4>;
+   pinctrl-0 = <_clk _cs0 _bus4>;
power-domains = < PX30_PD_MMC_NAND>;
status = "disabled";
};
@@ -1953,7 +1953,7 @@
<1 RK_PA1 3 _pull_none>;
};
 
-   sfc_cs: sfc-cs {
+   sfc_cs0: sfc-cs0 {
rockchip,pins =
<1 RK_PA4 3 _pull_none>;
};
diff --git a/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi 
b/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi
index 741e8dd935..0990005a15 100644
--- a/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi
+++ b/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi
@@ -70,7 +70,7 @@
u-boot,dm-pre-reloc;
 };
 
-_flash {
+&{/sfc@ff3a/flash@0} {
u-boot,dm-pre-reloc;
 };
 
diff --git a/arch/arm/dts/rk3326-odroid-go2.dts 
b/arch/arm/dts/rk3326-odroid-go2.dts
index 6f91f5040b..4e3dceecbe 100644
--- a/arch/arm/dts/rk3326-odroid-go2.dts
+++ b/arch/arm/dts/rk3326-odroid-go2.dts
@@ -618,18 +618,18 @@
 };
 
  {
+   pinctrl-0 = <_clk _cs0 _bus2>;
+   pinctrl-names = "default";
#address-cells = <1>;
#size-cells = <0>;
-   pinctrl-names = "default";
-   pinctrl-0 = <_clk _cs _bus2>;
status = "okay";
 
-   spi_flash: xt25f128b@0 {
+   flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <10800>;
spi-rx-bus-width = <2>;
-   spi-tx-bus-width = <2>;
+   spi-tx-bus-width = <1>;
};
 };
 
-- 
2.25.1



[PATCH v1 7/7] verdin-imx8mm: drop support for v1.0 hardware

2021-08-20 Thread Marcel Ziswiler
From: Max Krummenacher 

We drop support for Verdin iMX8M Mini V1.0B.

Related-to: ELB-3551
Signed-off-by: Max Krummenacher 
Signed-off-by: Marcel Ziswiler 

---

 board/toradex/verdin-imx8mm/verdin-imx8mm.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/board/toradex/verdin-imx8mm/verdin-imx8mm.c 
b/board/toradex/verdin-imx8mm/verdin-imx8mm.c
index 1644f4b3081..2d8b37ce26d 100644
--- a/board/toradex/verdin-imx8mm/verdin-imx8mm.c
+++ b/board/toradex/verdin-imx8mm/verdin-imx8mm.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -87,17 +88,13 @@ static void select_dt_from_module_version(void)
 
switch (get_pcb_revision()) {
case PCB_VERSION_1_0:
-   printf("Detected a V1.0 module\n");
-   if (is_wifi)
-   strncpy([0], "wifi", sizeof(variant));
-   else
-   strncpy([0], "nonwifi", sizeof(variant));
-   break;
+   printf("Detected a V1.0 module which is no longer supported in 
this BSP version\n");
+   hang();
default:
if (is_wifi)
-   strncpy([0], "wifi-v1.1", sizeof(variant));
+   strlcpy([0], "wifi", sizeof(variant));
else
-   strncpy([0], "nonwifi-v1.1", sizeof(variant));
+   strlcpy([0], "nonwifi", sizeof(variant));
break;
}
 
-- 
2.26.2



[PATCH v1 5/7] verdin-imx8mm: switch to use binman to pack images

2021-08-20 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Use binman to pack images.

Signed-off-by: Marcel Ziswiler 
---

 arch/arm/dts/imx8mm-verdin-u-boot.dtsi   | 122 ++-
 arch/arm/mach-imx/imx8m/Kconfig  |   1 +
 board/toradex/verdin-imx8mm/imximage.cfg |  11 +-
 configs/verdin-imx8mm_defconfig  |   2 +-
 doc/board/toradex/verdin-imx8mm.rst  |  54 +-
 5 files changed, 155 insertions(+), 35 deletions(-)

diff --git a/arch/arm/dts/imx8mm-verdin-u-boot.dtsi 
b/arch/arm/dts/imx8mm-verdin-u-boot.dtsi
index a97626fa0c1..ba4c8d0436c 100644
--- a/arch/arm/dts/imx8mm-verdin-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-verdin-u-boot.dtsi
@@ -1,11 +1,15 @@
 // SPDX-License-Identifier: GPL-2.0+ OR MIT
 /*
- * Copyright 2020 Toradex
+ * Copyright 2021 Toradex
  */
 
 #include "imx8mm-u-boot.dtsi"
 
 / {
+   binman: binman {
+   multiple-images;
+   };
+
firmware {
optee {
compatible = "linaro,optee-tz";
@@ -91,3 +95,119 @@
  {
u-boot,dm-spl;
 };
+
+ {
+u-boot-spl-ddr {
+   align = <4>;
+   align-size = <4>;
+   filename = "u-boot-spl-ddr.bin";
+   pad-byte = <0xff>;
+
+   u-boot-spl {
+   align-end = <4>;
+   };
+
+   blob_1: blob-ext@1 {
+   filename = "lpddr4_pmu_train_1d_imem.bin";
+   size = <0x8000>;
+   };
+
+   blob_2: blob-ext@2 {
+   filename = "lpddr4_pmu_train_1d_dmem.bin";
+   size = <0x4000>;
+   };
+
+   blob_3: blob-ext@3 {
+   filename = "lpddr4_pmu_train_2d_imem.bin";
+   size = <0x8000>;
+   };
+
+   blob_4: blob-ext@4 {
+   filename = "lpddr4_pmu_train_2d_dmem.bin";
+   size = <0x4000>;
+   };
+   };
+
+   spl {
+   mkimage {
+   args = "-n spl/u-boot-spl.cfgout -T imx8mimage -e 
0x7e1000";
+
+   blob {
+   filename = "u-boot-spl-ddr.bin";
+   };
+   };
+   };
+
+   itb {
+   filename = "u-boot.itb";
+
+   fit {
+   description = "Configuration to load ATF before U-Boot";
+   fit,external-offset = ;
+   #address-cells = <1>;
+
+   images {
+   uboot {
+   arch = "arm64";
+   compression = "none";
+   description = "U-Boot (64-bit)";
+   load = ;
+   type = "standalone";
+
+   uboot_blob: blob-ext {
+   filename = "u-boot-nodtb.bin";
+   };
+   };
+
+   atf {
+   arch = "arm64";
+   compression = "none";
+   description = "ARM Trusted Firmware";
+   entry = <0x92>;
+   load = <0x92>;
+   type = "firmware";
+
+   atf_blob: blob-ext {
+   filename = "bl31.bin";
+   };
+   };
+
+   fdt {
+   compression = "none";
+   description = "NAME";
+   type = "flat_dt";
+
+   uboot_fdt_blob: blob-ext {
+   filename = "u-boot.dtb";
+   };
+   };
+   };
+
+   configurations {
+   default = "conf";
+
+   conf {
+   description = "NAME";
+   fdt = "fdt";
+   firmware = "uboot";
+   loadables = "atf";
+   };
+   };
+   };
+   };
+
+   imx-boot {
+   filename = "flash.bin";
+   pad-byte = <0x00>;
+
+   spl: blob-ext@1 {
+   filename = "spl.bin";
+   offset = <0x0>;
+   };
+
+   uboot: blob-ext@2 {
+   filename = "u-boot.itb";
+  

[PATCH v1 6/7] verdin-imx8mm: enable sleep_moci output

2021-08-20 Thread Marcel Ziswiler
From: Max Krummenacher 

This powers some peripherals on the carrier board e.g. the USB hub.

Related-to: ELB-3206
Signed-off-by: Max Krummenacher 
Signed-off-by: Marcel Ziswiler 
---

 arch/arm/dts/imx8mm-verdin.dts  | 18 ++
 configs/verdin-imx8mm_defconfig |  1 +
 2 files changed, 19 insertions(+)

diff --git a/arch/arm/dts/imx8mm-verdin.dts b/arch/arm/dts/imx8mm-verdin.dts
index ac2a4b69d3c..a2331627d72 100644
--- a/arch/arm/dts/imx8mm-verdin.dts
+++ b/arch/arm/dts/imx8mm-verdin.dts
@@ -196,6 +196,18 @@
};
 };
 
+ {
+   ctrl_sleep_moci {
+   gpio-hog;
+   /* Verdin CTRL_SLEEP_MOCI# (SODIMM 256) */
+   gpios = <1 GPIO_ACTIVE_HIGH>;
+   line-name = "CTRL_SLEEP_MOCI#";
+   output-high;
+   pinctrl-names = "default";
+   pinctrl-0 = <_ctrl_sleep_moci>;
+   };
+};
+
 /* On-module I2C */
  {
clock-frequency = <40>;
@@ -548,6 +560,12 @@
>;
};
 
+   pinctrl_ctrl_sleep_moci: ctrlsleepmocigrp {
+   fsl,pins = <
+   MX8MM_IOMUXC_SAI3_TXD_GPIO5_IO1 0x1c4   
/* SODIMM 256 */
+   >;
+   };
+
pinctrl_dsi_bkl_en: dsi_bkl_en {
fsl,pins = <
MX8MM_IOMUXC_NAND_CE2_B_GPIO3_IO3   0x1c4   
/* SODIMM 21 */
diff --git a/configs/verdin-imx8mm_defconfig b/configs/verdin-imx8mm_defconfig
index b323ceb19af..ad9c00a3cc4 100644
--- a/configs/verdin-imx8mm_defconfig
+++ b/configs/verdin-imx8mm_defconfig
@@ -71,6 +71,7 @@ CONFIG_SPL_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_SPL_CLK_IMX8MM=y
 CONFIG_CLK_IMX8MM=y
+CONFIG_GPIO_HOG=y
 CONFIG_MXC_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
-- 
2.26.2



[PATCH v1 4/7] ARM: dts: imx8mm-verdin: prepare for dek blob encapsulation

2021-08-20 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Prepare for DEK blob encapsulation support through "dek_blob" command.
On ARMv8, u-boot runs in non-secure, thus cannot encapsulate a DEK blob
for encrypted boot.
The DEK blob is encapsulated by OP-TEE through a trusted application
call. U-boot sends and receives the DEK and the DEK blob binaries
through OP-TEE dynamic shared memory.

To enable the DEK blob encapsulation, add to the defconfig:
CONFIG_SECURE_BOOT=y
CONFIG_FAT_WRITE=y
CONFIG_CMD_DEKBLOB=y

Taken from NXP's commit 56d2050f4028 ("imx8m: Add DEK blob encapsulation
for imx8m").

Signed-off-by: Marcel Ziswiler 
---

 arch/arm/dts/imx8mm-verdin-u-boot.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/dts/imx8mm-verdin-u-boot.dtsi 
b/arch/arm/dts/imx8mm-verdin-u-boot.dtsi
index 67c31c49b6c..a97626fa0c1 100644
--- a/arch/arm/dts/imx8mm-verdin-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-verdin-u-boot.dtsi
@@ -6,6 +6,13 @@
 #include "imx8mm-u-boot.dtsi"
 
 / {
+   firmware {
+   optee {
+   compatible = "linaro,optee-tz";
+   method = "smc";
+   };
+   };
+
wdt-reboot {
compatible = "wdt-reboot";
wdt = <>;
-- 
2.26.2



[PATCH v1 3/7] verdin-imx8mm: fix ethernet

2021-08-20 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Turns out Microship (formerly Micrel) meanwhile integrated proper
support for the DLL setup on their KSZ9131. Unfortunately, this
conflicts with our previous board code doing that.
Fix this by getting rid of our board code and just relying on the
generic implementation relying on rgmii-id being used as phy-mode.

Fixes: commit c6df0e2ffdc4
   ("net: phy: micrel: add support for DLL setup on ksz9131")
Signed-off-by: Marcel Ziswiler 
---

 arch/arm/dts/imx8mm-verdin.dts  |  2 +-
 board/toradex/verdin-imx8mm/verdin-imx8mm.c | 64 -
 2 files changed, 1 insertion(+), 65 deletions(-)

diff --git a/arch/arm/dts/imx8mm-verdin.dts b/arch/arm/dts/imx8mm-verdin.dts
index fb0756d6e19..ac2a4b69d3c 100644
--- a/arch/arm/dts/imx8mm-verdin.dts
+++ b/arch/arm/dts/imx8mm-verdin.dts
@@ -160,7 +160,7 @@
  {
fsl,magic-packet;
phy-handle = <>;
-   phy-mode = "rgmii";
+   phy-mode = "rgmii-id";
phy-supply = <_ethphy>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <_fec1>;
diff --git a/board/toradex/verdin-imx8mm/verdin-imx8mm.c 
b/board/toradex/verdin-imx8mm/verdin-imx8mm.c
index 76f4a1e209a..1644f4b3081 100644
--- a/board/toradex/verdin-imx8mm/verdin-imx8mm.c
+++ b/board/toradex/verdin-imx8mm/verdin-imx8mm.c
@@ -36,70 +36,6 @@ static int setup_fec(void)
 
return 0;
 }
-
-int board_phy_config(struct phy_device *phydev)
-{
-   int tmp;
-
-   switch (ksz9xx1_phy_get_id(phydev) & MII_KSZ9x31_SILICON_REV_MASK) {
-   case PHY_ID_KSZ9031:
-   /*
-* The PHY adds 1.2ns for the RXC and 0ns for TXC clock by
-* default. The MAC and the layout don't add a skew between
-* clock and data.
-* Add 0.3ns for the RXC path and 0.96 + 0.42 ns (1.38 ns) for
-* the TXC path to get the required clock skews.
-*/
-   /* control data pad skew - devaddr = 0x02, register = 0x04 */
-   ksz9031_phy_extended_write(phydev, 0x02,
-  MII_KSZ9031_EXT_RGMII_CTRL_SIG_SKEW,
-  MII_KSZ9031_MOD_DATA_NO_POST_INC,
-  0x0070);
-   /* rx data pad skew - devaddr = 0x02, register = 0x05 */
-   ksz9031_phy_extended_write(phydev, 0x02,
-  MII_KSZ9031_EXT_RGMII_RX_DATA_SKEW,
-  MII_KSZ9031_MOD_DATA_NO_POST_INC,
-  0x);
-   /* tx data pad skew - devaddr = 0x02, register = 0x06 */
-   ksz9031_phy_extended_write(phydev, 0x02,
-  MII_KSZ9031_EXT_RGMII_TX_DATA_SKEW,
-  MII_KSZ9031_MOD_DATA_NO_POST_INC,
-  0x);
-   /* gtx and rx clock pad skew - devaddr = 0x02,register = 0x08 */
-   ksz9031_phy_extended_write(phydev, 0x02,
-  MII_KSZ9031_EXT_RGMII_CLOCK_SKEW,
-  MII_KSZ9031_MOD_DATA_NO_POST_INC,
-  0x03f4);
-   break;
-   case PHY_ID_KSZ9131:
-   default:
-   /* read rxc dll control - devaddr = 0x2, register = 0x4c */
-   tmp = ksz9031_phy_extended_read(phydev, 0x02,
-   MII_KSZ9131_EXT_RGMII_2NS_SKEW_RXDLL,
-   MII_KSZ9031_MOD_DATA_NO_POST_INC);
-   /* disable rxdll bypass (enable 2ns skew delay on RXC) */
-   tmp &= ~MII_KSZ9131_RXTXDLL_BYPASS;
-   /* rxc data pad skew 2ns - devaddr = 0x02, register = 0x4c */
-   tmp = ksz9031_phy_extended_write(phydev, 0x02,
-   MII_KSZ9131_EXT_RGMII_2NS_SKEW_RXDLL,
-   MII_KSZ9031_MOD_DATA_NO_POST_INC, tmp);
-   /* read txc dll control - devaddr = 0x02, register = 0x4d */
-   tmp = ksz9031_phy_extended_read(phydev, 0x02,
-   MII_KSZ9131_EXT_RGMII_2NS_SKEW_TXDLL,
-   MII_KSZ9031_MOD_DATA_NO_POST_INC);
-   /* disable txdll bypass (enable 2ns skew delay on TXC) */
-   tmp &= ~MII_KSZ9131_RXTXDLL_BYPASS;
-   /* rxc data pad skew 2ns - devaddr = 0x02, register = 0x4d */
-   tmp = ksz9031_phy_extended_write(phydev, 0x02,
-   MII_KSZ9131_EXT_RGMII_2NS_SKEW_TXDLL,
-   MII_KSZ9031_MOD_DATA_NO_POST_INC, tmp);
-   break;
-   }
-
-   if (phydev->drv->config)
-   phydev->drv->config(phydev);
-   return 0;
-}
 #endif
 
 int board_init(void)
-- 
2.26.2



[PATCH v1 2/7] imx8m: clean-up kconfig indentation

2021-08-20 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Replace spurious spaces with proper tabs.

Signed-off-by: Marcel Ziswiler 
---

 arch/arm/mach-imx/imx8m/Kconfig | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-imx/imx8m/Kconfig b/arch/arm/mach-imx/imx8m/Kconfig
index 1d08a2977f5..a2ba30cf332 100644
--- a/arch/arm/mach-imx/imx8m/Kconfig
+++ b/arch/arm/mach-imx/imx8m/Kconfig
@@ -25,14 +25,14 @@ config SYS_SOC
default "imx8m"
 
 choice
-   prompt  "NXP i.MX8M board select"
+   prompt "NXP i.MX8M board select"
optional
 
 config TARGET_IMX8MQ_CM
-bool "Ronetix iMX8MQ-CM SoM"
+   bool "Ronetix iMX8MQ-CM SoM"
select BINMAN
-select IMX8MQ
-select IMX8M_LPDDR4
+   select IMX8MQ
+   select IMX8M_LPDDR4
 
 config TARGET_IMX8MQ_EVK
bool "imx8mq_evk"
@@ -105,10 +105,10 @@ config TARGET_PICO_IMX8MQ
select IMX8M_LPDDR4
 
 config TARGET_VERDIN_IMX8MM
-   bool "Support Toradex Verdin iMX8M Mini module"
-   select IMX8MM
-   select SUPPORT_SPL
-   select IMX8M_LPDDR4
+   bool "Support Toradex Verdin iMX8M Mini module"
+   select IMX8MM
+   select SUPPORT_SPL
+   select IMX8M_LPDDR4
 
 config TARGET_IMX8MM_BEACON
bool "imx8mm Beacon Embedded devkit"
@@ -125,14 +125,14 @@ config TARGET_IMX8MN_BEACON
 config TARGET_PHYCORE_IMX8MM
bool "PHYTEC PHYCORE i.MX8MM"
select IMX8MM
-select SUPPORT_SPL
+   select SUPPORT_SPL
select IMX8M_LPDDR4
 
 config TARGET_PHYCORE_IMX8MP
bool "PHYTEC PHYCORE i.MX8MP"
select BINMAN
select IMX8MP
-select SUPPORT_SPL
+   select SUPPORT_SPL
select IMX8M_LPDDR4
 
 config TARGET_IMX8MM_CL_IOT_GATE
-- 
2.26.2



[PATCH v1 1/7] imx: mkimage_fit_atf: fix legacy image generation

2021-08-20 Thread Marcel Ziswiler
From: Marcel Ziswiler 

While most boards meanwhile migrated to using binman a few like the
verdin-imx8mm are still using the legacy image generation.
Unfortunately, the legacy image generation is currently broken which is
especially bad for any kind of bisection attempts.
Anyway, this fixes it even though we will also migrate to using binman
shortly.

Fixes: commit cb9faa6f98ae
 ("tools: Use a single target-independent config to enable OpenSSL")
Signed-off-by: Marcel Ziswiler 
---

 arch/arm/mach-imx/mkimage_fit_atf.sh | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-imx/mkimage_fit_atf.sh 
b/arch/arm/mach-imx/mkimage_fit_atf.sh
index 2a17968794c..2d6c46633c7 100755
--- a/arch/arm/mach-imx/mkimage_fit_atf.sh
+++ b/arch/arm/mach-imx/mkimage_fit_atf.sh
@@ -53,7 +53,7 @@ cat << __HEADER_EOF
description = "Configuration to load ATF before U-Boot";
 
images {
-   uboot@1 {
+   uboot_1 {
description = "U-Boot (64-bit)";
os = "u-boot";
data = /incbin/("$BL33");
@@ -68,7 +68,7 @@ cnt=1
 for dtname in $*
 do
cat << __FDT_IMAGE_EOF
-   fdt@$cnt {
+   fdt_$cnt {
description = "$(basename $dtname .dtb)";
data = /incbin/("$dtname");
type = "flat_dt";
@@ -79,7 +79,7 @@ cnt=$((cnt+1))
 done
 
 cat << __HEADER_EOF
-   atf@1 {
+   atf_1 {
description = "ARM Trusted Firmware";
os = "arm-trusted-firmware";
data = /incbin/("$BL31");
@@ -93,7 +93,7 @@ __HEADER_EOF
 
 if [ -f $BL32 ]; then
 cat << __HEADER_EOF
-   tee@1 {
+   tee_1 {
description = "TEE firmware";
data = /incbin/("$BL32");
type = "firmware";
@@ -108,7 +108,7 @@ fi
 cat << __CONF_HEADER_EOF
};
configurations {
-   default = "config@1";
+   default = "config_1";
 
 __CONF_HEADER_EOF
 
@@ -117,20 +117,20 @@ for dtname in $*
 do
 if [ -f $BL32 ]; then
 cat << __CONF_SECTION_EOF
-   config@$cnt {
+   config_$cnt {
description = "$(basename $dtname .dtb)";
-   firmware = "uboot@1";
-   loadables = "atf@1", "tee@1";
-   fdt = "fdt@$cnt";
+   firmware = "uboot_1";
+   loadables = "atf_1", "tee_1";
+   fdt = "fdt_$cnt";
};
 __CONF_SECTION_EOF
 else
 cat << __CONF_SECTION1_EOF
-   config@$cnt {
+   config_$cnt {
description = "$(basename $dtname .dtb)";
-   firmware = "uboot@1";
-   loadables = "atf@1";
-   fdt = "fdt@$cnt";
+   firmware = "uboot_1";
+   loadables = "atf_1";
+   fdt = "fdt_$cnt";
};
 __CONF_SECTION1_EOF
 fi
-- 
2.26.2



[PATCH v1 0/7] board: toradex: verdin-imx8mm: target refresh

2021-08-20 Thread Marcel Ziswiler
From: Marcel Ziswiler 


An assortment of fixes and improvements like a legacy image generation
fix, an Ethernet PHY configuration fix, DEK blob encapsulation
preparation, migration to using binman to pack images, SLEEP_MOCI#
enablement and dropping of V1.0 hardware support [1].

One last issue I am still trying to debug the root cause of. As already
once mentioned back here [2] it still prints the following error
message during boot:

imx_wdt watchdog@3028:
 pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

Note that this series is applied on top of Peng's Makefile fix [3] as
otherwise, it may not quite generate all binman artefacts in the right
order as discussed here [4].

[1] https://developer.toradex.com/verdin-sample-phase-over
[2] https://marc.info/?l=u-boot=161786572422973
[3] https://marc.info/?l=u-boot=162908373904742
[4] https://marc.info/?l=u-boot=162945614207220


Marcel Ziswiler (5):
  imx: mkimage_fit_atf: fix legacy image generation
  imx8m: clean-up kconfig indentation
  verdin-imx8mm: fix ethernet
  ARM: dts: imx8mm-verdin: prepare for dek blob encapsulation
  verdin-imx8mm: switch to use binman to pack images

Max Krummenacher (2):
  verdin-imx8mm: enable sleep_moci output
  verdin-imx8mm: drop support for v1.0 hardware

 arch/arm/dts/imx8mm-verdin-u-boot.dtsi  | 129 +++-
 arch/arm/dts/imx8mm-verdin.dts  |  20 ++-
 arch/arm/mach-imx/imx8m/Kconfig |  21 ++--
 arch/arm/mach-imx/mkimage_fit_atf.sh|  26 ++--
 board/toradex/verdin-imx8mm/imximage.cfg|  11 +-
 board/toradex/verdin-imx8mm/verdin-imx8mm.c |  77 +---
 configs/verdin-imx8mm_defconfig |   3 +-
 doc/board/toradex/verdin-imx8mm.rst |  54 
 8 files changed, 210 insertions(+), 131 deletions(-)

-- 
2.26.2



Re: Pull request for efi-2021-10-rc3

2021-08-20 Thread Simon Glass
Hi Heinrich,

On Fri, 20 Aug 2021 at 13:07, Heinrich Schuchardt  wrote:
>
> Hello Tom,
>
> Ilias will be back on Monday. Then he can clarify with Simon the series
> "efi: Minimal revert to rodata change"
> https://patchwork.ozlabs.org/project/uboot/list/?series=256272.

I think I already asked for the reverts to be applied right away,
rather than waiting any longer. Can you please apply it as part of
this PR? It has been over a month since this issue came up and we are
past RC2.

It took me quite a while to even find the patches as they are marked
both deferred and archived.

We still have time to figure out new patches before the release, but I
have not seen a lot of action so far and really this problem should
not have happened.

Regards,
Simon

>
> The following changes since commit a0da2dda4ed9d0aee5265e9cd8876734f9f80e09:
>
>Prepare v2021.10-rc2 (2021-08-16 14:18:45 -0400)
>
> are available in the Git repository at:
>
>https://source.denx.de/u-boot/custodians/u-boot-efi.git
> tags/efi-2021-10-rc3
>
> for you to fetch changes up to 9a4b3c8e914dbb9d06640d8e04db8a06dedca051:
>
>efi_loader: use EfiBootServicesData for DP to text (2021-08-17
> 17:24:08 +0200)
>
> 
> Pull request for efi-2021-10-rc3
>
> Documentation:
>
> * Rename Freescale to NXP
> * Document structures used for the UEFI TCG2 protocol
>
> UEFI:
>
> * Device paths must use EfiBootServicesData
>
> 
> Heinrich Schuchardt (8):
>doc: move i.MX7D/i.MX8MM A/B booting to board specific
>doc: rename Freescale to NXP
>doc: move doc/board/st/st.rst
>efi_loader: use an enum for the memory allocation types
>efi_loader rename enum efi_mem_type to efi_memory_type
>efi_loader: use correct type for AllocatePages, AllocatePool
>efi_loader: use EfiBootServicesData for device path
>efi_loader: use EfiBootServicesData for DP to text
>
> Masahisa Kojima (1):
>efi_loader: add comment for efi_tcg2.h
>
>   arch/x86/include/asm/hob.h   |  2 +-
>   doc/board/index.rst  |  2 +-
>   doc/board/{freescale => nxp}/imx8mm_evk.rst  |  0
>   doc/board/{freescale => nxp}/imx8mn_evk.rst  |  0
>   doc/board/{freescale => nxp}/imx8mp_evk.rst  |  0
>   doc/board/{freescale => nxp}/imx8mq_evk.rst  |  0
>   doc/board/{freescale => nxp}/imx8qxp_mek.rst |  0
>   doc/board/{freescale => nxp}/imxrt1020-evk.rst   |  0
>   doc/board/{freescale => nxp}/imxrt1050-evk.rst   |  0
>   doc/board/{freescale => nxp}/index.rst   |  5 ++-
>   doc/board/{freescale => nxp}/mx6sabreauto.rst|  0
>   doc/board/{freescale => nxp}/mx6sabresd.rst  |  0
>   doc/board/{freescale => nxp}/mx6ul_14x14_evk.rst |  0
>   doc/board/{freescale => nxp}/mx6ullevk.rst   |  0
>   doc/{imx/misc => board/nxp}/psb.rst  |  0
>   doc/board/st/index.rst   |  2 +-
>   doc/board/st/{st.rst => st-dt.rst}   |  0
>   doc/imx/index.rst|  9 
>   doc/imx/misc/index.rst   |  9 
>   doc/index.rst| 11 -
>   include/efi.h| 36 ---
>   include/efi_api.h|  2 +-
>   include/efi_loader.h |  9 ++--
>   include/efi_tcg2.h   | 57
> ++--
>   lib/efi_loader/efi_device_path.c |  2 +-
>   lib/efi_loader/efi_device_path_to_text.c |  2 +-
>   lib/efi_loader/efi_memory.c  |  5 ++-
>   27 files changed, 100 insertions(+), 53 deletions(-)
>   rename doc/board/{freescale => nxp}/imx8mm_evk.rst (100%)
>   rename doc/board/{freescale => nxp}/imx8mn_evk.rst (100%)
>   rename doc/board/{freescale => nxp}/imx8mp_evk.rst (100%)
>   rename doc/board/{freescale => nxp}/imx8mq_evk.rst (100%)
>   rename doc/board/{freescale => nxp}/imx8qxp_mek.rst (100%)
>   rename doc/board/{freescale => nxp}/imxrt1020-evk.rst (100%)
>   rename doc/board/{freescale => nxp}/imxrt1050-evk.rst (100%)
>   rename doc/board/{freescale => nxp}/index.rst (83%)
>   rename doc/board/{freescale => nxp}/mx6sabreauto.rst (100%)
>   rename doc/board/{freescale => nxp}/mx6sabresd.rst (100%)
>   rename doc/board/{freescale => nxp}/mx6ul_14x14_evk.rst (100%)
>   rename doc/board/{freescale => nxp}/mx6ullevk.rst (100%)
>   rename doc/{imx/misc => board/nxp}/psb.rst (100%)
>   rename doc/board/st/{st.rst => st-dt.rst} (100%)
>   delete mode 100644 doc/imx/index.rst
>   delete mode 100644 doc/imx/misc/index.rst


Pull request for efi-2021-10-rc3

2021-08-20 Thread Heinrich Schuchardt

Hello Tom,

Ilias will be back on Monday. Then he can clarify with Simon the series
"efi: Minimal revert to rodata change"
https://patchwork.ozlabs.org/project/uboot/list/?series=256272.

The following changes since commit a0da2dda4ed9d0aee5265e9cd8876734f9f80e09:

  Prepare v2021.10-rc2 (2021-08-16 14:18:45 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-efi.git
tags/efi-2021-10-rc3

for you to fetch changes up to 9a4b3c8e914dbb9d06640d8e04db8a06dedca051:

  efi_loader: use EfiBootServicesData for DP to text (2021-08-17
17:24:08 +0200)


Pull request for efi-2021-10-rc3

Documentation:

* Rename Freescale to NXP
* Document structures used for the UEFI TCG2 protocol

UEFI:

* Device paths must use EfiBootServicesData


Heinrich Schuchardt (8):
  doc: move i.MX7D/i.MX8MM A/B booting to board specific
  doc: rename Freescale to NXP
  doc: move doc/board/st/st.rst
  efi_loader: use an enum for the memory allocation types
  efi_loader rename enum efi_mem_type to efi_memory_type
  efi_loader: use correct type for AllocatePages, AllocatePool
  efi_loader: use EfiBootServicesData for device path
  efi_loader: use EfiBootServicesData for DP to text

Masahisa Kojima (1):
  efi_loader: add comment for efi_tcg2.h

 arch/x86/include/asm/hob.h   |  2 +-
 doc/board/index.rst  |  2 +-
 doc/board/{freescale => nxp}/imx8mm_evk.rst  |  0
 doc/board/{freescale => nxp}/imx8mn_evk.rst  |  0
 doc/board/{freescale => nxp}/imx8mp_evk.rst  |  0
 doc/board/{freescale => nxp}/imx8mq_evk.rst  |  0
 doc/board/{freescale => nxp}/imx8qxp_mek.rst |  0
 doc/board/{freescale => nxp}/imxrt1020-evk.rst   |  0
 doc/board/{freescale => nxp}/imxrt1050-evk.rst   |  0
 doc/board/{freescale => nxp}/index.rst   |  5 ++-
 doc/board/{freescale => nxp}/mx6sabreauto.rst|  0
 doc/board/{freescale => nxp}/mx6sabresd.rst  |  0
 doc/board/{freescale => nxp}/mx6ul_14x14_evk.rst |  0
 doc/board/{freescale => nxp}/mx6ullevk.rst   |  0
 doc/{imx/misc => board/nxp}/psb.rst  |  0
 doc/board/st/index.rst   |  2 +-
 doc/board/st/{st.rst => st-dt.rst}   |  0
 doc/imx/index.rst|  9 
 doc/imx/misc/index.rst   |  9 
 doc/index.rst| 11 -
 include/efi.h| 36 ---
 include/efi_api.h|  2 +-
 include/efi_loader.h |  9 ++--
 include/efi_tcg2.h   | 57
++--
 lib/efi_loader/efi_device_path.c |  2 +-
 lib/efi_loader/efi_device_path_to_text.c |  2 +-
 lib/efi_loader/efi_memory.c  |  5 ++-
 27 files changed, 100 insertions(+), 53 deletions(-)
 rename doc/board/{freescale => nxp}/imx8mm_evk.rst (100%)
 rename doc/board/{freescale => nxp}/imx8mn_evk.rst (100%)
 rename doc/board/{freescale => nxp}/imx8mp_evk.rst (100%)
 rename doc/board/{freescale => nxp}/imx8mq_evk.rst (100%)
 rename doc/board/{freescale => nxp}/imx8qxp_mek.rst (100%)
 rename doc/board/{freescale => nxp}/imxrt1020-evk.rst (100%)
 rename doc/board/{freescale => nxp}/imxrt1050-evk.rst (100%)
 rename doc/board/{freescale => nxp}/index.rst (83%)
 rename doc/board/{freescale => nxp}/mx6sabreauto.rst (100%)
 rename doc/board/{freescale => nxp}/mx6sabresd.rst (100%)
 rename doc/board/{freescale => nxp}/mx6ul_14x14_evk.rst (100%)
 rename doc/board/{freescale => nxp}/mx6ullevk.rst (100%)
 rename doc/{imx/misc => board/nxp}/psb.rst (100%)
 rename doc/board/st/{st.rst => st-dt.rst} (100%)
 delete mode 100644 doc/imx/index.rst
 delete mode 100644 doc/imx/misc/index.rst


Re: [PATCH V4] clk: clk_versaclock: Add support for versaclock driver

2021-08-20 Thread Sean Anderson




On 8/20/21 2:27 PM, Adam Ford wrote:

On Wed, Jun 30, 2021 at 7:32 AM Adam Ford  wrote:


On Fri, Jun 4, 2021 at 12:27 PM Sean Anderson  wrote:
>
>
>
> On 6/4/21 1:26 PM, Adam Ford wrote:
> > The driver is based on the Versaclock driver from the Linux code, but
> > due differences in the clock API between them, some pieces had to be
> > changed.
> >
> > This driver creates a mux, pfd, pll, and a series of fod ouputs.
> >   Rate   Usecnt  Name
> > --
> >   2500 0`-- x304-clock
> >   2500 0`-- clock-control...@6a.mux
> >   2500 0|-- clock-control...@6a.pfd
> >   28   0|   `-- clock-control...@6a.pll
> >    0|   |-- clock-controller@6a.fod0
> >    0|   |   `-- 
clock-controller@6a.out1
> >    0|   |-- clock-controller@6a.fod1
> >    0|   |   `-- 
clock-controller@6a.out2
> >   5000 0|   |-- clock-controller@6a.fod2
> >   5000 0|   |   `-- 
clock-controller@6a.out3
> >   125000|   `-- clock-controller@6a.fod3
> >   125000|   `-- 
clock-controller@6a.out4
> >   2500 0`-- 
clock-controller@6a.out0_sel_i2cb
> >
> > A translation function is added so the references to < X> get 
routed
> > to the corresponding clock-control...@6a.outx.
> >
> > Signed-off-by: Adam Ford 
> > ---
> > V4:  Remove a few printf's that I missed when removing debug.
> >
> > V3:  Streamline finding the out OUTx subnodes.
> >   Add error handling.
> >   Replace printf and pr_err with dev_dbg.
> >   Restore registers removed in V2.
> >
> > V2:  Remove unused registers.
> >   Fix spacing in Makefile.
> >   Make the versaclock driver dependent on CCF.
> >   Move the versaclock_ids next to U_BOOT_DRIVER(versaclock)
> >
> > diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> > index 40a5a5dd88..2a7507ea18 100644
> > --- a/drivers/clk/Kconfig
> > +++ b/drivers/clk/Kconfig
> > @@ -197,4 +197,13 @@ config SANDBOX_CLK_CCF
> > Enable this option if you want to test the Linux kernel's Common
> > Clock Framework [CCF] code in U-Boot's Sandbox clock driver.
> >
> > +config CLK_VERSACLOCK
> > + tristate "Enable VersaClock 5/6 devices"
> > + depends on CLK
> > + depends on CLK_CCF
> > + depends on OF_CONTROL
> > + help
> > +   This driver supports the IDT VersaClock 5 and VersaClock 6
> > +   programmable clock generators.
> > +
> >   endmenu
> > diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> > index 645709b855..6f5ddafd64 100644
> > --- a/drivers/clk/Makefile
> > +++ b/drivers/clk/Makefile
> > @@ -51,3 +51,4 @@ obj-$(CONFIG_SANDBOX_CLK_CCF) += clk_sandbox_ccf.o
> >   obj-$(CONFIG_STM32H7) += clk_stm32h7.o
> >   obj-$(CONFIG_CLK_VERSAL) += clk_versal.o
> >   obj-$(CONFIG_CLK_CDCE9XX) += clk-cdce9xx.o
> > +obj-$(CONFIG_CLK_VERSACLOCK) += clk_versaclock.o
> > diff --git a/drivers/clk/clk_versaclock.c b/drivers/clk/clk_versaclock.c
> > new file mode 100644
> > index 00..578668bcf8
> > --- /dev/null
> > +++ b/drivers/clk/clk_versaclock.c
> > @@ -0,0 +1,1100 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Driver for IDT Versaclock 5/6
> > + *
> > + * Derived from code Copyright (C) 2017 Marek Vasut 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +/* VersaClock5 registers */
> > +#define VC5_OTP_CONTROL  0x00
> > +
> > +/* Factory-reserved register block */
> > +#define VC5_RSVD_DEVICE_ID   0x01
> > +#define VC5_RSVD_ADC_GAIN_7_00x02
> > +#define VC5_RSVD_ADC_GAIN_15_8   0x03
> > +#define VC5_RSVD_ADC_OFFSET_7_0  0x04
> > +#define VC5_RSVD_ADC_OFFSET_15_8 0x05
> > +#define VC5_RSVD_TEMPY   0x06
> > +#define VC5_RSVD_OFFSET_TBIN 0x07
> > +#define VC5_RSVD_GAIN0x08
> > +#define VC5_RSVD_TEST_NP 0x09
> > +#define VC5_RSVD_UNUSED  0x0a
> > +#define VC5_RSVD_BANDGAP_TRIM_UP 0x0b
> > +#define VC5_RSVD_BANDGAP_TRIM_DN 0x0c
> > +#define VC5_RSVD_CLK_R_12_CLK_AMP_4  0x0d
> > +#define VC5_RSVD_CLK_R_34_CLK_AMP_4  0x0e
> > +#define VC5_RSVD_CLK_AMP_123 0x0f
> > +
> > +/* Configuration register block */
> > +#define VC5_PRIM_SRC_SHDN0x10
> > +#define VC5_PRIM_SRC_SHDN_EN_XTAL  

Re: [PATCH V4] clk: clk_versaclock: Add support for versaclock driver

2021-08-20 Thread Adam Ford
On Wed, Jun 30, 2021 at 7:32 AM Adam Ford  wrote:
>
> On Fri, Jun 4, 2021 at 12:27 PM Sean Anderson  wrote:
> >
> >
> >
> > On 6/4/21 1:26 PM, Adam Ford wrote:
> > > The driver is based on the Versaclock driver from the Linux code, but
> > > due differences in the clock API between them, some pieces had to be
> > > changed.
> > >
> > > This driver creates a mux, pfd, pll, and a series of fod ouputs.
> > >   Rate   Usecnt  Name
> > > --
> > >   2500 0`-- x304-clock
> > >   2500 0`-- clock-control...@6a.mux
> > >   2500 0|-- clock-control...@6a.pfd
> > >   28   0|   `-- clock-control...@6a.pll
> > >    0|   |-- 
> > > clock-controller@6a.fod0
> > >    0|   |   `-- 
> > > clock-controller@6a.out1
> > >    0|   |-- 
> > > clock-controller@6a.fod1
> > >    0|   |   `-- 
> > > clock-controller@6a.out2
> > >   5000 0|   |-- 
> > > clock-controller@6a.fod2
> > >   5000 0|   |   `-- 
> > > clock-controller@6a.out3
> > >   125000|   `-- 
> > > clock-controller@6a.fod3
> > >   125000|   `-- 
> > > clock-controller@6a.out4
> > >   2500 0`-- 
> > > clock-controller@6a.out0_sel_i2cb
> > >
> > > A translation function is added so the references to < X> get 
> > > routed
> > > to the corresponding clock-control...@6a.outx.
> > >
> > > Signed-off-by: Adam Ford 
> > > ---
> > > V4:  Remove a few printf's that I missed when removing debug.
> > >
> > > V3:  Streamline finding the out OUTx subnodes.
> > >   Add error handling.
> > >   Replace printf and pr_err with dev_dbg.
> > >   Restore registers removed in V2.
> > >
> > > V2:  Remove unused registers.
> > >   Fix spacing in Makefile.
> > >   Make the versaclock driver dependent on CCF.
> > >   Move the versaclock_ids next to U_BOOT_DRIVER(versaclock)
> > >
> > > diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> > > index 40a5a5dd88..2a7507ea18 100644
> > > --- a/drivers/clk/Kconfig
> > > +++ b/drivers/clk/Kconfig
> > > @@ -197,4 +197,13 @@ config SANDBOX_CLK_CCF
> > > Enable this option if you want to test the Linux kernel's Common
> > > Clock Framework [CCF] code in U-Boot's Sandbox clock driver.
> > >
> > > +config CLK_VERSACLOCK
> > > + tristate "Enable VersaClock 5/6 devices"
> > > + depends on CLK
> > > + depends on CLK_CCF
> > > + depends on OF_CONTROL
> > > + help
> > > +   This driver supports the IDT VersaClock 5 and VersaClock 6
> > > +   programmable clock generators.
> > > +
> > >   endmenu
> > > diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> > > index 645709b855..6f5ddafd64 100644
> > > --- a/drivers/clk/Makefile
> > > +++ b/drivers/clk/Makefile
> > > @@ -51,3 +51,4 @@ obj-$(CONFIG_SANDBOX_CLK_CCF) += clk_sandbox_ccf.o
> > >   obj-$(CONFIG_STM32H7) += clk_stm32h7.o
> > >   obj-$(CONFIG_CLK_VERSAL) += clk_versal.o
> > >   obj-$(CONFIG_CLK_CDCE9XX) += clk-cdce9xx.o
> > > +obj-$(CONFIG_CLK_VERSACLOCK) += clk_versaclock.o
> > > diff --git a/drivers/clk/clk_versaclock.c b/drivers/clk/clk_versaclock.c
> > > new file mode 100644
> > > index 00..578668bcf8
> > > --- /dev/null
> > > +++ b/drivers/clk/clk_versaclock.c
> > > @@ -0,0 +1,1100 @@
> > > +// SPDX-License-Identifier: GPL-2.0-or-later
> > > +/*
> > > + * Driver for IDT Versaclock 5/6
> > > + *
> > > + * Derived from code Copyright (C) 2017 Marek Vasut 
> > > 
> > > + */
> > > +
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +
> > > +#include 
> > > +
> > > +/* VersaClock5 registers */
> > > +#define VC5_OTP_CONTROL  0x00
> > > +
> > > +/* Factory-reserved register block */
> > > +#define VC5_RSVD_DEVICE_ID   0x01
> > > +#define VC5_RSVD_ADC_GAIN_7_00x02
> > > +#define VC5_RSVD_ADC_GAIN_15_8   0x03
> > > +#define VC5_RSVD_ADC_OFFSET_7_0  0x04
> > > +#define VC5_RSVD_ADC_OFFSET_15_8 0x05
> > > +#define VC5_RSVD_TEMPY   0x06
> > > +#define VC5_RSVD_OFFSET_TBIN 0x07
> > > +#define VC5_RSVD_GAIN0x08
> > > +#define VC5_RSVD_TEST_NP 0x09
> > > +#define VC5_RSVD_UNUSED  0x0a
> > > +#define VC5_RSVD_BANDGAP_TRIM_UP 0x0b
> > > +#define VC5_RSVD_BANDGAP_TRIM_DN 0x0c
> > > +#define VC5_RSVD_CLK_R_12_CLK_AMP_4  

Re: binman should create a list of output files

2021-08-20 Thread Simon Glass
Hi Heiko,

On Fri, 20 Aug 2021 at 00:49, Heiko Thiery  wrote:
>
> Hi Simon,
>
> During the discussion on [1] I had the idea if binman could create a
> list of all output files, so that it is possible to do a real clean in
> the u-boot makefile.
>
> Currently there are not all binaries listed in the files list and
> especially during the port of some boards to binman we had some
> trouble due to fragments of old/previous builds.
>
> What do you think?

Yes i like this. Perhaps something like:

binman ls-files output   - to list output files

We could also create a binman.filelist file in the target directory.

The interesting question is how to implement it. It might be best to
add a new method to Entry() which returns a list of output filenames.
Then we can simply call all the entries recursively to get the list,
as we do with other things today.

The other issue is temporary files, which are currently lumped into
the same output dir. One day I think we should distinguish between
output files that produce something useful and files that are just
there for debugging (e.g. the input file used for compression or
signing). The latter could go in a separate binman-working/ directory
inside the output dir, and could be removed wholesale.

Regards,
Simon


>
> [1] https://lists.denx.de/pipermail/u-boot/2021-August/458530.html
>
> --
> Heiko


Re: How should we deal with actual hush odd behavior?

2021-08-20 Thread Simon Glass
Hi Francis,

On Fri, 20 Aug 2021 at 10:12, Francis Laniel
 wrote:
>
> Hi.
>
>
> I hope you are fine and the same for your family and friends.
>
> In July, a proposal to add a new shell for U-Boot was posted on the mailing
> list [1].
> The community discussed a lot about this changes, some people did not agree
> with it because the new shell is not compatible with the actual one (hush)
> [2].
> So, a proposal to update U-Boot actual hush to follow what they currently have
> in Busybox was made [3].
>
> Porting 2021 Busybox hush to U-Boot seems, for me, to be a good idea as we
> would benefit from Busybox bug fixes as well as being compatible with actual
> hush (in theory).
> We could also add new features to U-Boot hush, like functions, as they were
> added to Busybox.
>
> Nonetheless, the idea of this port is to be compatible.
> In practice, I noted some cases when this is actually not the case.
> The first one can be related to how && and || operators were handled in hush.
> So, the following: false && false || true
> Returns 0 on Busybox 2021 hush and 1 on U-Boot.
> The behavior of 2021 is coherent with the definition of these operators [4]:
> >The return status of AND and OR lists is the exit
> >status of the last command executed in the list.
> An other example concerns variable expansion, where foo='bar "quux" is
> expanded to bar quux in U-Boot and bar "quux in Busybox.
>
> I do not have a real opinion on the second one, as I think local variable set
> in U-Boot scripts are quite simple as people do not try to do: foo="bar \"quux
> 'quuz' \"\"\"corge".
> The first one is maybe more problematic.
> Grepping "if test" shows me that the more complex if condition seems to be
> under the form:
> if first_test_ AND/OR second_test
> Here also, people seems to no try to write complex expression like: foo ||
> bar; echo quux && quuz.
>
> So, porting Busybox 2021 hush can solve bugs we have currently in U-Boot, but
> what if fixing these bugs lead to a board script failing and so a device not
> booting...
> I would like to have the opinion of the community on this question.

My feeling is that we should go with the newer (correct?) behaviour.
Boards not booting can be found with the existing release process.

Also if we keep the old hush around for a while people can still use
it, particularly if it is much smaller.

Regards,
SImon


Re: [PATCH 00/28] Initial implementation of bootmethod/bootflow

2021-08-20 Thread Simon Glass
Hi Takahiro,

On Thu, 19 Aug 2021 at 21:15, AKASHI Takahiro
 wrote:
>
> Hi Simon,
>
> On Thu, Aug 19, 2021 at 08:25:33AM -0600, Simon Glass wrote:
> > Hi Tom,
> >
> > On Thu, 19 Aug 2021 at 07:59, Tom Rini  wrote:
> > >
> > > On Wed, Aug 18, 2021 at 09:45:33PM -0600, Simon Glass wrote:
> > >
> > > > Bootmethod and bootflow provide a built-in way for U-Boot to 
> > > > automatically boot
> > > > an Operating System without custom scripting and other customisation:
> > > >
> > > >   - bootmethod - a method to scan a device to find bootflows (owned by 
> > > > U-Boot)
> > > >   - bootflow - a description of how to boot (owned by the distro)
> > > >
> > > > This series provides an initial implementation of these, enable to scan
> > > > for bootflows from MMC and Ethernet. The only bootflow supported is
> > > > distro boot, i.e. an extlinux.conf file included on a filesystem or
> > > > tftp server. It works similiarly to the existing script-based approach,
> > > > but is native to U-Boot.
> > > >
> > > > With this we can boot on a Raspberry Pi 3 with just one command:
> > > >
> > > >bootflow scan -lb
> > > >
> > > > which means to scan, listing (-l) each bootflow and trying to boot each
> > > > one (-b). The final patch shows this.
> > > >
> > > > It is intended that this approach be expanded to support mechanisms 
> > > > other
> > > > than distro boot, including EFI-related ones. With a standard way to
> > > > identify boot devices, these features become easier. It also should
> > > > support U-Boot scripts, for backwards compatibility only.
> > > >
> > > > The first patch of this series moves boot-related code out of common/ 
> > > > and
> > > > into a new boot/ directory. This helps to collect these related files
> > > > in one place, as common/ is quite large.
> > > >
> > > > Like sysboot, this feature makes use of the existing PXE implementation.
> > > > Much of this series consists of cleaning up that code and refactoring it
> > > > into something closer to a module that can be called, teasing apart its
> > > > reliance on the command-line interpreter to access filesystems and the
> > > > like. Also it now uses function arguments and its own context struct
> > > > internally rather than environment variables, which is very hard to
> > > > follow. No core functional change is included in the included PXE 
> > > > patches.
> > > >
> > > > For documentation, see the 'doc' patch.
> > > >
> > > > There is quite a long list of future work included in the documentation.
> > > > One question is the choice of naming. Since this is a bootloader, should
> > > > we just call this a 'method' and a 'flow' ? The 'boot' prefix is already
> > > > shared by other commands like bootm, booti, etc.
>
> Regarding the naming, I'm still a bit confused with bootmethod vs.
> bootflow. Personally, I prefer a more intuitive name against bootmethod,
> say, bootmedia or bootdevice (as the original distro_bootcmd uses).

I quite like bootmedia. Would just 'media' be OK? That would reduce
the use of the 'boot' prefix which I think is overused.

>
> > > > The design is described here:
> > > >
> > > > https://drive.google.com/file/d/1ggW0KJpUOR__vBkj3l61L2dav4ZkNC12/view?usp=sharing
> > > >
> > > > The series is available at u-boot-dm/bmea-working
> > >
> > > My question / concern is this.  Would the next step here be to
> > > implement the generic UEFI boot path?  Today, I can write Fedora 34 for
> > > AArch64 to a USB stick, boot U-Boot off of uSD card and the installer
> > > automatically boots.  I'm sure I could do the same with the BSDs.
> > > Reading the documentation left me with the impression that every OSV
> > > would be expected to write something, so that their installer / OS boot.
> > > But there's already standards for that, which they do, and we should be
> > > implementing (and do, via the current distro_boot) or making easier to
> > > enable.  Thanks!
>
> I had the same concern.

OK see my reply to Tom on this point. The separate of concerns between
providing media and booting an OS is a key purpose of this series.

I have Fedora 34 in my lab and will send an update for it next week.

>
> > Here you are talking about scanning for a bootflow. It is not actually
> > OS-specific. If it were, there would be no point to this :-)
> >
> > If you look in the distro scripts you will see 'scan_dev_for_efi' (and
> > also scan_dev_for_scrips). At least the first needs to be implemented
> > a bit like the distro boot is at present. So far I have only
> > implemented scan_dev_for_extlinux (plus pxe) as it is enough to show
> > the concept.
> >
> > Adding EFI it's likely to be about the same amount of code as distro.c
> > at present, perhaps a little less since we don't have the network
> > case. It is used by Fedora 34, I believe, so is easy enough for me to
> > do.  But I wanted to get something out as the concept is visible in
> > this series.
>
> If I correctly understand this framework, we will have to
> write several 

Re: [PATCH v6 10/12] watchdog: add gpio watchdog driver

2021-08-20 Thread Simon Glass
Hi Rasmus,

On Fri, 20 Aug 2021 at 00:22, Rasmus Villemoes
 wrote:
>
> On 19/08/2021 14.32, Wolfgang Denk wrote:
>
> > The existence of bad code is not a justification to add more of it.
>
> Obviously true and I agree.
>
> However, it is at the same time completely irrelevant in this context,
> because the pattern of using the return value of dev_get_priv() without
> a NULL check is neither bad or wrong, as has now been explained to you
> several times.
>
> If you really think checking the return value of dev_get_priv() must be
> done religiously, perhaps you could tap Stefan (737c3de09984), Marek
> (7e1f1e16fe75), or Heiko (6e31c62a175c) on the shoulder and tell them to
> stop cranking out "bad" code.
>
> On 19/08/2021 16.16, Wolfgang Denk wrote:
>
> > I mean, look at the implementation of dev_get_priv():
> >
> >  628 void *dev_get_priv(const struct udevice *dev)
> >  629 {
> >  630 if (!dev) {
> >  631 dm_warn("%s: null device\n", __func__);
> >  632 return NULL;
> >  633 }
> >  634
> >  635 return dm_priv_to_rw(dev->priv_);
> >  636 }
> >
> > If there is guaranteed no way that dev_get_priv() can return a NULL
> > pointer, that means that it must be guaranteed that the "dev"
> > argument can never be a NULL pointer, either.
>
> There's another logical fallacy right here. Sure, you've found an input
> value for which dev_get_priv() would return NULL. But any caller who
> knows they're not passing a NULL dev also know they won't follow that
> code path.
>
> A driver which doesn't populate the priv field by via a non-zero
> .priv_auto field may need to check the return value of dev_get_priv().
> I'm not claiming that checking that is always redundant. However,
> neither is it anywhere near true that checking is always required.

Just on this point, drivers should use the priv pointer without
priv_auto. If we do introduce run-time checks, it would fail with
those.

Regards,
Simon


Re: [PATCH v2 15/16] clk: Detect failure to set defaults

2021-08-20 Thread Simon Glass
Hi Harm,

On Wed, 18 Aug 2021 at 08:09, Harm Berntsen  wrote:
>
> On Thu, 2021-05-13 at 19:39 -0600, Simon Glass wrote:
> > When the default clocks cannot be set, the clock is silently probed and
> > the error is ignored. This is incorrect, since having the clocks at the
> > correct speed may be important for operation of the system.
> >
> > Fix it by checking the return code.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >  drivers/clk/clk-uclass.c | 6 +-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> > index 4ab3c402ed8..2a2e1cfbd61 100644
> > --- a/drivers/clk/clk-uclass.c
> > +++ b/drivers/clk/clk-uclass.c
> > @@ -796,13 +796,17 @@ void devm_clk_put(struct udevice *dev, struct clk
> > *clk)
> >
> >  int clk_uclass_post_probe(struct udevice *dev)
> >  {
> > +   int ret;
> > +
> > /*
> >  * when a clock provider is probed. Call clk_set_defaults()
> >  * also after the device is probed. This takes care of cases
> >  * where the DT is used to setup default parents and rates
> >  * using assigned-clocks
> >  */
> > -   clk_set_defaults(dev, 1);
> > +   ret = clk_set_defaults(dev, 1);
> > +   if (ret)
> > +   return log_ret(ret);
> >
> > return 0;
> >  }
>
> Note that this patch broke booting my imx8mn based board on U-Boot
> v2021.10-rc2. The failure is due to the clock-controller@3038
> configuration in the imx8mn.dtsi file. I had to remove the following
> clocks from the device tree to get my device to boot again (all from
> the assigned-clocks of clock-controller@3038):
>
> < IMX8MN_CLK_A53_CORE>,
> < IMX8MN_CLK_NOC>,
> < IMX8MN_CLK_AUDIO_AHB>,
> < IMX8MN_CLK_IPG_AUDIO_ROOT>,
> < IMX8MN_SYS_PLL3>,
> < IMX8MN_AUDIO_PLL1>,
> < IMX8MN_AUDIO_PLL2>;
>
> I looked into the clk-imx8mn.c code and I see that we indeed miss
> clocks there. Unfortunately I could not port code from the Linux
> kernel: we are missing the imx_clk_hw_mux2 function for the
> IMX8MN_CLK_A53_CORE clock. I did not look into the other clocks.


Perhaps the iMX maintainer could help with this? It does sound like a bug.

Regards,
SImon

>
>
> -- Harm


Re: [PATCH] ARM: dts: Fix node status to "okay" on TI boards

2021-08-20 Thread Nishanth Menon
On 13:41-20210820, Roger Quadros wrote:
> As per Device Tree core schema [1], status parameter of nodes can be either
> "okay" or "disabled".
> 
> U-boot Driver Model does not recognize status="ok" and treats
> the node as disabled.
> 

Did you miss:
[1] https://github.com/devicetree-org/devicetree-specification/releases/tag/v0.3

Also, I think it might be better to refer to the specification than the
schema implementation of the specification.

> Signed-off-by: Roger Quadros 
> ---
>  arch/arm/dts/am3517-evm-ui.dtsi | 4 ++--
>  arch/arm/dts/am3517-evm.dts | 2 +-
>  arch/arm/dts/am437x-gp-evm.dts  | 2 +-
>  arch/arm/dts/am43x-epos-evm.dts | 2 +-
>  arch/arm/dts/am57xx-beagle-x15-common.dtsi  | 6 +++---
>  arch/arm/dts/da850-evm.dts  | 2 +-
>  arch/arm/dts/dra7-evm.dts   | 2 +-
>  arch/arm/dts/dra72-evm-common.dtsi  | 6 +++---
>  arch/arm/dts/keystone-k2e-evm.dts   | 2 +-
>  arch/arm/dts/keystone-k2hk-evm.dts  | 2 +-
>  arch/arm/dts/keystone-k2l-evm.dts   | 2 +-
>  arch/arm/dts/omap3-beagle-xm.dts| 4 ++--
>  arch/arm/dts/omap3-beagle.dts   | 6 +++---
>  arch/arm/dts/omap3-igep0020-common.dtsi | 2 +-
>  arch/arm/dts/omap3-panel-sharp-ls037v7dw01.dtsi | 2 +-
>  arch/arm/dts/omap34xx.dtsi  | 2 +-
>  arch/arm/dts/omap36xx.dtsi  | 2 +-
>  arch/arm/dts/omap4-panda-common.dtsi| 6 +++---
>  arch/arm/dts/omap4-sdp.dts  | 8 
>  arch/arm/dts/omap5-board-common.dtsi| 4 ++--
>  20 files changed, 34 insertions(+), 34 deletions(-)
> 
> diff --git a/arch/arm/dts/am3517-evm-ui.dtsi b/arch/arm/dts/am3517-evm-ui.dtsi
> index e841918c1c..54aa2522aa 100644
> --- a/arch/arm/dts/am3517-evm-ui.dtsi
> +++ b/arch/arm/dts/am3517-evm-ui.dtsi
> @@ -186,14 +186,14 @@
>  };
>  
>   {
> - status = "ok";
> + status = "okay";
>   #sound-dai-cells = <0>;
>   pinctrl-names = "default";
>   pinctrl-0 = <_pins>;
>  };
>  
>   {
> - status = "ok";
> + status = "okay";
>   #sound-dai-cells = <0>;
>   pinctrl-names = "default";
>   pinctrl-0 = <_pins>;
> diff --git a/arch/arm/dts/am3517-evm.dts b/arch/arm/dts/am3517-evm.dts
> index 3527c0f2df..935c471c97 100644
> --- a/arch/arm/dts/am3517-evm.dts
> +++ b/arch/arm/dts/am3517-evm.dts
> @@ -193,7 +193,7 @@
>  };
>  
>   {
> - status = "ok";
> + status = "okay";
>  
>   pinctrl-names = "default";
>   pinctrl-0 = <_dpi_pins>;
> diff --git a/arch/arm/dts/am437x-gp-evm.dts b/arch/arm/dts/am437x-gp-evm.dts
> index 3c500d52db..21f7691f49 100644
> --- a/arch/arm/dts/am437x-gp-evm.dts
> +++ b/arch/arm/dts/am437x-gp-evm.dts
> @@ -742,7 +742,7 @@
>  };
>  
>   {
> - status = "ok";
> + status = "okay";
>  
>   pinctrl-names = "default";
>   pinctrl-0 = <_pins>;
> diff --git a/arch/arm/dts/am43x-epos-evm.dts b/arch/arm/dts/am43x-epos-evm.dts
> index 65f157ed59..b940bc6ccf 100644
> --- a/arch/arm/dts/am43x-epos-evm.dts
> +++ b/arch/arm/dts/am43x-epos-evm.dts
> @@ -752,7 +752,7 @@
>  };
>  
>   {
> - status = "ok";
> + status = "okay";
>  
>   pinctrl-names = "default";
>   pinctrl-0 = <_pins>;
> diff --git a/arch/arm/dts/am57xx-beagle-x15-common.dtsi 
> b/arch/arm/dts/am57xx-beagle-x15-common.dtsi
> index d6b94d528f..1912ea9a15 100644
> --- a/arch/arm/dts/am57xx-beagle-x15-common.dtsi
> +++ b/arch/arm/dts/am57xx-beagle-x15-common.dtsi
> @@ -528,13 +528,13 @@
>  };
>  
>   {
> - status = "ok";
> + status = "okay";
>  
>   vdda_video-supply = <_reg>;
>  };
>  
>   {
> - status = "ok";
> + status = "okay";
>   vdda-supply = <_reg>;
>  
>   port {
> @@ -545,7 +545,7 @@
>  };
>  
>  _rc {
> - status = "ok";
> + status = "okay";
>   gpios = < 8 GPIO_ACTIVE_LOW>;
>  };
>  
> diff --git a/arch/arm/dts/da850-evm.dts b/arch/arm/dts/da850-evm.dts
> index f04bc3e153..b331cefd18 100644
> --- a/arch/arm/dts/da850-evm.dts
> +++ b/arch/arm/dts/da850-evm.dts
> @@ -405,7 +405,7 @@
>   {
>   pinctrl-names = "default";
>   pinctrl-0 = <_pins>;
> - status = "ok";
> + statu

[PATCH 2/2] doc: rockchip: write all brand names with a capital

2021-08-20 Thread Johan Jonker
Brand names are supposed to be written with a capital,
so change them all.

Signed-off-by: Johan Jonker 
---
 doc/board/rockchip/rockchip.rst | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/doc/board/rockchip/rockchip.rst b/doc/board/rockchip/rockchip.rst
index 8d75efc0..144cb98e 100644
--- a/doc/board/rockchip/rockchip.rst
+++ b/doc/board/rockchip/rockchip.rst
@@ -16,10 +16,10 @@ Rockchip boards
 Rockchip is SoC solutions provider for tablets & PCs, streaming media
 TV boxes, AI audio & vision, IoT hardware.
 
-A wide range of Rockchip SoCs with associated boardsare supported in
+A wide range of Rockchip SoCs with associated boards are supported in
 mainline U-Boot.
 
-List of mainline supported rockchip boards:
+List of mainline supported Rockchip boards:
 
 * rk3036
  - Rockchip Evb-RK3036 (evb-rk3036)
@@ -93,7 +93,7 @@ To build TF-A::
 make realclean
 make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399
 
-Specify the PLAT= with desired rockchip platform to build TF-A for.
+Specify the PLAT= with desired Rockchip platform to build TF-A for.
 
 U-Boot
 ^^
@@ -130,7 +130,7 @@ Flashing
 SD Card
 ^^^
 
-All rockchip platforms, except rk3128 (which doesn't use SPL) are now
+All Rockchip platforms, except rk3128 (which doesn't use SPL) are now
 supporting single boot image using binman and pad_cat.
 
 To write an image that boots from an SD card (assumed to be /dev/sda)::
@@ -141,7 +141,7 @@ To write an image that boots from an SD card (assumed to be 
/dev/sda)::
 eMMC
 
 
-eMMC flash would probe on mmc0 in most of the rockchip platforms.
+eMMC flash would probe on mmc0 in most of the Rockchip platforms.
 
 Create GPT partition layout as defined in configurations::
 
@@ -164,7 +164,7 @@ Program the flash::
 sudo fastboot -i 0x2207 flash loader1 idbloader.img
 sudo fastboot -i 0x2207 flash loader2 u-boot.itb
 
-Note: for rockchip 32-bit platforms the U-Boot proper image
+Note: for Rockchip 32-bit platforms the U-Boot proper image
 is u-boot-dtb.img
 
 SPI
@@ -227,8 +227,8 @@ Note:
 TODO
 
 
-- Add rockchip idbloader image building
-- Add rockchip TPL image building
+- Add Rockchip idbloader image building
+- Add Rockchip TPL image building
 - Document SPI flash boot
 - Add missing SoC's with it boards list
 
-- 
2.20.1



[PATCH 1/2] doc: rockchip: sort rockchip support list for rk3188

2021-08-20 Thread Johan Jonker
In the list of mainline U-boot supported Rockchip boards
rk3188 is placed below under the name rv3188. Give back it's
original name and sort the list in alphabetical order.

Signed-off-by: Johan Jonker 
---
 doc/board/rockchip/rockchip.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/board/rockchip/rockchip.rst b/doc/board/rockchip/rockchip.rst
index fbb99839..8d75efc0 100644
--- a/doc/board/rockchip/rockchip.rst
+++ b/doc/board/rockchip/rockchip.rst
@@ -26,6 +26,8 @@ List of mainline supported rockchip boards:
  - Kylin (kylin_rk3036)
 * rk3128
  - Rockchip Evb-RK3128 (evb-rk3128)
+* rk3188
+ - Radxa Rock (rock)
 * rk3229
  - Rockchip Evb-RK3229 (evb-rk3229)
 * rk3288
@@ -75,8 +77,6 @@ List of mainline supported rockchip boards:
 * rv1108
  - Rockchip Evb-rv1108 (evb-rv1108)
  - Elgin-R1 (elgin-rv1108)
-* rv3188
- - Radxa Rock (rock)
 
 Building
 
-- 
2.20.1



Re: [PATCH v2 5/6] arm: Use armv8_switch_to_el1 env to switch to EL1

2021-08-20 Thread Tom Rini
On Fri, Aug 20, 2021 at 05:57:51PM +0100, Andre Przywara wrote:
> On 8/19/21 4:53 PM, Peter Hoyes wrote:
> 
> Hi,
> 
> > From: Peter Hoyes 
> > 
> > Use the environment variable armv8_switch_to_el1 to determine whether
> > to switch to EL1 at runtime. This is an alternative to the
> > CONFIG_ARMV8_SWITCH_TO_EL1 compile-time option.
> 
> This might be useful outside of the v8-R64 FVP. I cannot find
> CONFIG_ARMV8_SWITCH_TO_EL1 being set anywhere, which makes me wonder how
> this is used? Are there certain custom builds which define this somehow?

Adding Michal and asking for a Kconfig migration too :)

> 
> In any case forcing "kernel" entry in either EL1 or EL2, and deciding this
> at runtime sounds useful for certain scenarios in general, and be it for
> debugging and testing. So shall we get rid of this compile time option at
> all, or shall this be retained to avoid extra code?
> 
> > The environment variable will be ineffective if the ARMV8_MULTIENTRY
> > config is used.
> > 
> > This is required by the Armv8r64 architecture, which must be able to
> > boot at S-EL1 for Linux but may need to boot at other ELs for other
> > systems.
> > 
> > Signed-off-by: Peter Hoyes 
> > ---
> >   arch/arm/lib/bootm.c | 40 +---
> >   1 file changed, 25 insertions(+), 15 deletions(-)
> > 
> > diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
> > index f60ee3a7e6..ea9bfe7570 100644
> > --- a/arch/arm/lib/bootm.c
> > +++ b/arch/arm/lib/bootm.c
> > @@ -317,7 +317,6 @@ __weak void update_os_arch_secondary_cores(uint8_t 
> > os_arch)
> >   {
> >   }
> > -#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
> >   static void switch_to_el1(void)
> >   {
> > if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) &&
> > @@ -332,7 +331,6 @@ static void switch_to_el1(void)
> > ES_TO_AARCH64);
> >   }
> >   #endif
> > -#endif
> >   /* Subcommand: GO */
> >   static void boot_jump_linux(bootm_headers_t *images, int flag)
> > @@ -359,21 +357,33 @@ static void boot_jump_linux(bootm_headers_t *images, 
> > int flag)
> > update_os_arch_secondary_cores(images->os.arch);
> > -#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
> > -   armv8_switch_to_el2((u64)images->ft_addr, 0, 0, 0,
> > -   (u64)switch_to_el1, ES_TO_AARCH64);
> > +#ifdef CONFIG_ARMV8_MULTIENTRY
> > +   int armv8_switch_to_el1 = -1;
> >   #else
> > -   if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) &&
> > -   (images->os.arch == IH_ARCH_ARM))
> > -   armv8_switch_to_el2(0, (u64)gd->bd->bi_arch_number,
> > -   (u64)images->ft_addr, 0,
> > -   (u64)images->ep,
> > -   ES_TO_AARCH32);
> > -   else
> > -   armv8_switch_to_el2((u64)images->ft_addr, 0, 0, 0,
> > -   images->ep,
> > -   ES_TO_AARCH64);
> > +   int armv8_switch_to_el1 = env_get_yesno("armv8_switch_to_el1");
> >   #endif
> > +#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
> > +   if (armv8_switch_to_el1 == -1) {
> > +   armv8_switch_to_el1 = 1;
> > +   }
> > +#endif
> > +   if (armv8_switch_to_el1 == 1) {
> 
> This looks confusing. Can't we use CONFIG_IS_ENABLED() and override
> armv8_switch_to_el1, then use this one variable to trigger the action?
> 
> Cheers,
> Andre
> 
> > +   armv8_switch_to_el2((u64)images->ft_addr, 0, 0, 0,
> > +   (u64)switch_to_el1, ES_TO_AARCH64);
> > +   } else {
> > +   if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) &&
> > +   (images->os.arch == IH_ARCH_ARM))
> > +   armv8_switch_to_el2(0,
> > +   (u64)gd->bd->bi_arch_number,
> > +   (u64)images->ft_addr, 0,
> > +   (u64)images->ep,
> > +   ES_TO_AARCH32);
> > +   else
> > +   armv8_switch_to_el2((u64)images->ft_addr,
> > +   0, 0, 0,
> > +   images->ep,
> > +   ES_TO_AARCH64);
> > +   }
> > }
> >   #else
> > unsigned long machid = gd->bd->bi_arch_number;
> > 
> 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 5/6] arm: Use armv8_switch_to_el1 env to switch to EL1

2021-08-20 Thread Andre Przywara

On 8/19/21 4:53 PM, Peter Hoyes wrote:

Hi,


From: Peter Hoyes 

Use the environment variable armv8_switch_to_el1 to determine whether
to switch to EL1 at runtime. This is an alternative to the
CONFIG_ARMV8_SWITCH_TO_EL1 compile-time option.


This might be useful outside of the v8-R64 FVP. I cannot find 
CONFIG_ARMV8_SWITCH_TO_EL1 being set anywhere, which makes me wonder how 
this is used? Are there certain custom builds which define this somehow?


In any case forcing "kernel" entry in either EL1 or EL2, and deciding 
this at runtime sounds useful for certain scenarios in general, and be 
it for debugging and testing. So shall we get rid of this compile time 
option at all, or shall this be retained to avoid extra code?



The environment variable will be ineffective if the ARMV8_MULTIENTRY
config is used.

This is required by the Armv8r64 architecture, which must be able to
boot at S-EL1 for Linux but may need to boot at other ELs for other
systems.

Signed-off-by: Peter Hoyes 
---
  arch/arm/lib/bootm.c | 40 +---
  1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index f60ee3a7e6..ea9bfe7570 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -317,7 +317,6 @@ __weak void update_os_arch_secondary_cores(uint8_t os_arch)
  {
  }
  
-#ifdef CONFIG_ARMV8_SWITCH_TO_EL1

  static void switch_to_el1(void)
  {
if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) &&
@@ -332,7 +331,6 @@ static void switch_to_el1(void)
ES_TO_AARCH64);
  }
  #endif
-#endif
  
  /* Subcommand: GO */

  static void boot_jump_linux(bootm_headers_t *images, int flag)
@@ -359,21 +357,33 @@ static void boot_jump_linux(bootm_headers_t *images, int 
flag)
  
  		update_os_arch_secondary_cores(images->os.arch);
  
-#ifdef CONFIG_ARMV8_SWITCH_TO_EL1

-   armv8_switch_to_el2((u64)images->ft_addr, 0, 0, 0,
-   (u64)switch_to_el1, ES_TO_AARCH64);
+#ifdef CONFIG_ARMV8_MULTIENTRY
+   int armv8_switch_to_el1 = -1;
  #else
-   if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) &&
-   (images->os.arch == IH_ARCH_ARM))
-   armv8_switch_to_el2(0, (u64)gd->bd->bi_arch_number,
-   (u64)images->ft_addr, 0,
-   (u64)images->ep,
-   ES_TO_AARCH32);
-   else
-   armv8_switch_to_el2((u64)images->ft_addr, 0, 0, 0,
-   images->ep,
-   ES_TO_AARCH64);
+   int armv8_switch_to_el1 = env_get_yesno("armv8_switch_to_el1");
  #endif
+#ifdef CONFIG_ARMV8_SWITCH_TO_EL1
+   if (armv8_switch_to_el1 == -1) {
+   armv8_switch_to_el1 = 1;
+   }
+#endif
+   if (armv8_switch_to_el1 == 1) {


This looks confusing. Can't we use CONFIG_IS_ENABLED() and override 
armv8_switch_to_el1, then use this one variable to trigger the action?


Cheers,
Andre


+   armv8_switch_to_el2((u64)images->ft_addr, 0, 0, 0,
+   (u64)switch_to_el1, ES_TO_AARCH64);
+   } else {
+   if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) &&
+   (images->os.arch == IH_ARCH_ARM))
+   armv8_switch_to_el2(0,
+   (u64)gd->bd->bi_arch_number,
+   (u64)images->ft_addr, 0,
+   (u64)images->ep,
+   ES_TO_AARCH32);
+   else
+   armv8_switch_to_el2((u64)images->ft_addr,
+   0, 0, 0,
+   images->ep,
+   ES_TO_AARCH64);
+   }
}
  #else
unsigned long machid = gd->bd->bi_arch_number;





Re: [v6 15/17] arm: dts: Add base dtsi and devkit dts for Intel N5X device

2021-08-20 Thread Ley Foon Tan
On Tue, Aug 10, 2021 at 11:27 AM Siew Chin Lim
 wrote:
>
> Add device tree for N5X.
>
> Signed-off-by: Siew Chin Lim 
> Signed-off-by: Tien Fong Chee 
>
> ---
> v6:
> - Sort the node name in alphanumeric order in socfpga_n5x_socdk-u-boot.dtsi
> - Remove duplicated qspi node from socfpga_n5x_socdk-u-boot.dtsi,
>   It is defined in socfpga_n5x_socdk.dtsi
> - Remove the incorrect clkmgr compatible name in socfpga_n5x_socdk.dtsi
>
> v5:
> - Obsolete 5th version of patch because it set the wrong compatible name for 
> clkmgr in device tree.
>
> v4:
> - Reuse socfpga_n5x_socdk.dts from Linux and add U-boot specifc dts
>   to u-boot.dtsi. Linux socfpga_n5x_socdk.dts:
>   
> https://github.com/altera-opensource/linux-socfpga/blob/socfpga-5.4.114-lts/arch/arm64/boot/dts/intel/socfpga_n5x_socdk.dts
>
> v3:
> - Update comment for memory example code
> - Move all common dts settings for N5X from
>   socfpga_n5x_socdk.dts to socfpga_n5x-u-boot.dtsi
> - Remove unused parameter "u-boot,boot0"
>
> v2:
> - Remove socfpga_n5x.dtsi
> - Reuse socfpga_agilex.dtsi in socfpga_n5x_socdk.dts and update
>   n5x data accordingly.
> ---
>  arch/arm/dts/Makefile  |   1 +
>  arch/arm/dts/socfpga_n5x-u-boot.dtsi   | 191 
> +
>  arch/arm/dts/socfpga_n5x_socdk-u-boot.dtsi |  63 +++
>  ...fpga_agilex_socdk.dts => socfpga_n5x_socdk.dts} |  59 +++
>  4 files changed, 275 insertions(+), 39 deletions(-)
>  create mode 100644 arch/arm/dts/socfpga_n5x-u-boot.dtsi
>  create mode 100644 arch/arm/dts/socfpga_n5x_socdk-u-boot.dtsi
>  copy arch/arm/dts/{socfpga_agilex_socdk.dts => socfpga_n5x_socdk.dts} (82%)
>

Reviewed-by: Ley Foon Tan 

Regards
Ley Foon


How should we deal with actual hush odd behavior?

2021-08-20 Thread Francis Laniel
Hi.


I hope you are fine and the same for your family and friends.

In July, a proposal to add a new shell for U-Boot was posted on the mailing 
list [1].
The community discussed a lot about this changes, some people did not agree 
with it because the new shell is not compatible with the actual one (hush) 
[2].
So, a proposal to update U-Boot actual hush to follow what they currently have 
in Busybox was made [3].

Porting 2021 Busybox hush to U-Boot seems, for me, to be a good idea as we 
would benefit from Busybox bug fixes as well as being compatible with actual 
hush (in theory).
We could also add new features to U-Boot hush, like functions, as they were 
added to Busybox.

Nonetheless, the idea of this port is to be compatible.
In practice, I noted some cases when this is actually not the case.
The first one can be related to how && and || operators were handled in hush.
So, the following: false && false || true
Returns 0 on Busybox 2021 hush and 1 on U-Boot.
The behavior of 2021 is coherent with the definition of these operators [4]:
>The return status of AND and OR lists is the exit 
>status of the last command executed in the list.
An other example concerns variable expansion, where foo='bar "quux" is 
expanded to bar quux in U-Boot and bar "quux in Busybox.

I do not have a real opinion on the second one, as I think local variable set 
in U-Boot scripts are quite simple as people do not try to do: foo="bar \"quux 
'quuz' \"\"\"corge".
The first one is maybe more problematic.
Grepping "if test" shows me that the more complex if condition seems to be 
under the form:
if first_test_ AND/OR second_test
Here also, people seems to no try to write complex expression like: foo || 
bar; echo quux && quuz.

So, porting Busybox 2021 hush can solve bugs we have currently in U-Boot, but 
what if fixing these bugs lead to a board script failing and so a device not 
booting...
I would like to have the opinion of the community on this question.


Best regards.

---
[1] https://lists.denx.de/pipermail/u-boot/2021-July/453347.html
[2] https://lists.denx.de/pipermail/u-boot/2021-July/453790.html
[3] https://lists.denx.de/pipermail/u-boot/2021-July/453848.html
[4] https://linux.die.net/man/1/bash




[RFC PATCH 6/6] test: hush: Test hush loops.

2021-08-20 Thread Francis Laniel
The added tests ensure correct behavior of for, while and until loops.

Signed-off-by: Francis Laniel 
---
 test/hush/Makefile |  1 +
 test/hush/loop.c   | 64 ++
 2 files changed, 65 insertions(+)
 create mode 100644 test/hush/loop.c

diff --git a/test/hush/Makefile b/test/hush/Makefile
index ff4fe7700b..a2d98815e5 100644
--- a/test/hush/Makefile
+++ b/test/hush/Makefile
@@ -7,3 +7,4 @@ obj-y += cmd_ut_hush.o
 obj-y += if.o
 obj-y += dollar.o
 obj-y += list.o
+obj-y += loop.o
diff --git a/test/hush/loop.c b/test/hush/loop.c
new file mode 100644
index 00..519c78ef7e
--- /dev/null
+++ b/test/hush/loop.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int hush_test_for(struct unit_test_state *uts)
+{
+   console_record_reset_enable();
+
+   ut_assertok(run_command("for loop_i in foo bar quux; do echo $loop_i; 
done", 0));
+   ut_assert_nextline("foo");
+   ut_assert_nextline("bar");
+   ut_assert_nextline("quux");
+   ut_assert_console_end();
+
+   puts("Beware: this test set local variable loop_i and it cannot be 
unset!");
+
+   return 0;
+}
+HUSH_TEST(hush_test_for, 0);
+
+static int hush_test_while(struct unit_test_state *uts)
+{
+   console_record_reset_enable();
+
+   /* Exit status is that of test, so 1 since test is false to quit the 
loop. */
+   ut_asserteq(1, run_command("while test -z \"$loop_foo\"; do echo bar; 
loop_foo=quux; done", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   puts("Beware: this test set local variable loop_foo and it cannot be 
unset!");
+
+   return 0;
+}
+HUSH_TEST(hush_test_while, 0);
+
+static int hush_test_until(struct unit_test_state *uts)
+{
+   console_record_reset_enable();
+   env_set("loop_bar", "bar");
+
+   /*
+* WARNING We have to use environment variable because it is not 
possible
+* resetting local variable.
+*/
+   ut_assertok(run_command("until test -z \"$loop_bar\"; do echo quux; 
setenv loop_bar; done", 0));
+   ut_assert_nextline("quux");
+   ut_assert_console_end();
+
+   /*
+* Loop normally resets foo environment variable, but we reset it here 
in
+* case the test failed.
+*/
+   env_set("loop_bar", NULL);
+   return 0;
+}
+HUSH_TEST(hush_test_until, 0);
-- 
2.25.1



[RFC PATCH 5/6] test: hush: Test hush commands list.

2021-08-20 Thread Francis Laniel
This commit ensures behavior of commands separated by ';', '&&' and '||'.

Signed-off-by: Francis Laniel 
---
 test/hush/Makefile |  1 +
 test/hush/list.c   | 79 ++
 2 files changed, 80 insertions(+)
 create mode 100644 test/hush/list.c

diff --git a/test/hush/Makefile b/test/hush/Makefile
index feb4f71956..ff4fe7700b 100644
--- a/test/hush/Makefile
+++ b/test/hush/Makefile
@@ -6,3 +6,4 @@
 obj-y += cmd_ut_hush.o
 obj-y += if.o
 obj-y += dollar.o
+obj-y += list.o
diff --git a/test/hush/list.c b/test/hush/list.c
new file mode 100644
index 00..052cf2783c
--- /dev/null
+++ b/test/hush/list.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int hush_test_semicolon(struct unit_test_state *uts)
+{
+   /* A; B = B truth table. */
+   ut_asserteq(1, run_command("false; false", 0));
+   ut_assertok(run_command("false; true", 0));
+   ut_assertok(run_command("true; true", 0));
+   ut_asserteq(1, run_command("true; false", 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_semicolon, 0);
+
+static int hush_test_and(struct unit_test_state *uts)
+{
+   /* A && B truth table. */
+   ut_asserteq(1, run_command("false && false", 0));
+   ut_asserteq(1, run_command("false && true", 0));
+   ut_assertok(run_command("true && true", 0));
+   ut_asserteq(1, run_command("true && false", 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_and, 0);
+
+static int hush_test_or(struct unit_test_state *uts)
+{
+   /* A || B truth table. */
+   ut_asserteq(1, run_command("false || false", 0));
+   ut_assertok(run_command("false || true", 0));
+   ut_assertok(run_command("true || true", 0));
+   ut_assertok(run_command("true || false", 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_or, 0);
+
+static int hush_test_and_or(struct unit_test_state *uts)
+{
+   /* A && B || C truth table. */
+   ut_asserteq(1, run_command("false && false || false", 0));
+   ut_asserteq(1, run_command("false && false || true", 0));
+   ut_asserteq(1, run_command("false && true || true", 0));
+   ut_asserteq(1, run_command("false && true || false", 0));
+   ut_assertok(run_command("true && true || false", 0));
+   ut_asserteq(1, run_command("true && false || false", 0));
+   ut_assertok(run_command("true && false || true", 0));
+   ut_assertok(run_command("true && true || true", 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_and_or, 0);
+
+static int hush_test_or_and(struct unit_test_state *uts)
+{
+   /* A || B && C truth table. */
+   ut_asserteq(1, run_command("false || false && false", 0));
+   ut_asserteq(1, run_command("false || false && true", 0));
+   ut_assertok(run_command("false || true && true", 0));
+   ut_asserteq(1, run_command("false || true && false", 0));
+   ut_assertok(run_command("true || true && false", 0));
+   ut_assertok(run_command("true || false && false", 0));
+   ut_assertok(run_command("true || false && true", 0));
+   ut_assertok(run_command("true || true && true", 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_or_and, 0);
-- 
2.25.1



[RFC PATCH 4/6] test: hush: Test hush variable expansion.

2021-08-20 Thread Francis Laniel
This commit ensures shell variables are replaced by their values.

Signed-off-by: Francis Laniel 
---
 test/hush/Makefile |   1 +
 test/hush/dollar.c | 188 +
 2 files changed, 189 insertions(+)
 create mode 100644 test/hush/dollar.c

diff --git a/test/hush/Makefile b/test/hush/Makefile
index a3c9ae5106..feb4f71956 100644
--- a/test/hush/Makefile
+++ b/test/hush/Makefile
@@ -5,3 +5,4 @@
 
 obj-y += cmd_ut_hush.o
 obj-y += if.o
+obj-y += dollar.o
diff --git a/test/hush/dollar.c b/test/hush/dollar.c
new file mode 100644
index 00..4f153958ae
--- /dev/null
+++ b/test/hush/dollar.c
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int hush_test_simple_dollar(struct unit_test_state *uts)
+{
+   console_record_reset_enable();
+   ut_assertok(run_command("echo $dollar_foo", 0));
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-zero-length"
+   /*
+* Next line is empty as $dollar_foo was not set before, but compiler
+* complains about the format being empty, so we disable this warning
+* only for this line.
+*/
+   ut_assert_nextline("");
+#pragma GCC diagnostic pop
+   ut_assert_console_end();
+
+   ut_assertok(run_command("echo ${dollar_foo}", 0));
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-zero-length"
+   /*
+* Next line is empty as $dollar_foo was not set before, but compiler
+* complains about the format being empty, so we disable this warning
+* only for this line.
+*/
+   ut_assert_nextline("");
+#pragma GCC diagnostic pop
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_foo=bar", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("echo ${dollar_foo}", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   /*
+* R is way of giving raw string literals in C++.
+* It means a "\n" is a R string literal will not be interpreted as line
+* feed but printed as "\n".
+* GCC provides it for C as an extension.
+*/
+   ut_assertok(run_command(R"(dollar_foo=\$bar)", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("$bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_foo='$bar'", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("$bar");
+   ut_assert_console_end();
+
+   ut_asserteq(1, run_command("dollar_foo=bar quux", 0));
+   /* Next line contains error message. */
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   ut_asserteq(1, run_command("dollar_foo='bar quux", 0));
+   /* Next line contains error message. */
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   ut_asserteq(1, run_command(R"(dollar_foo=bar quux")", 0));
+   /* Two next lines contain error message. */
+   ut_assert_skipline();
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   ut_assertok(run_command(R"(dollar_foo='bar "quux')", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   /*
+* This one is buggy.
+* ut_assert_nextline(R"(bar "quux)");
+* ut_assert_console_end();
+*/
+
+   ut_asserteq(1, run_command(R"(dollar_foo="bar 'quux")", 0));
+   /* Next line contains error message. */
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_foo='bar quux'", 0));
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("bar quux");
+   ut_assert_console_end();
+
+   puts("Beware: this test set local variable dollar_foo and it cannot be 
unset!");
+
+   return 0;
+}
+HUSH_TEST(hush_test_simple_dollar, 0);
+
+static int hush_test_env_dollar(struct unit_test_state *uts)
+{
+   env_set("env_foo", "bar");
+   console_record_reset_enable();
+
+   ut_assertok(run_command("echo $env_foo", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("echo ${env_foo}", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   /* Environment variables have precedence over local variable. */
+   ut_assertok(run_command("env_foo=quux", 0));
+   ut_assertok(run_command("echo ${env_foo}", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   /* Clean up setting the variable. */
+   env_set("env_foo", NULL);
+
+   puts("Beware: this test set local variable env_foo and it cannot be 
unset!");
+
+   return 0;
+}

[RFC PATCH 3/6] test/py: hush_if_test: Remove the test file.

2021-08-20 Thread Francis Laniel
Commit 9087ab2cc4 ("test/py: hush_if_test: Remove the test file.") translated
this test to a C test, so this python file is no more needed.

Signed-off-by: Francis Laniel 
---
 test/py/tests/test_hush_if_test.py | 192 -
 1 file changed, 192 deletions(-)
 delete mode 100644 test/py/tests/test_hush_if_test.py

diff --git a/test/py/tests/test_hush_if_test.py 
b/test/py/tests/test_hush_if_test.py
deleted file mode 100644
index d117921a6a..00
--- a/test/py/tests/test_hush_if_test.py
+++ /dev/null
@@ -1,192 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
-
-# Test operation of the "if" shell command.
-
-import os
-import os.path
-import pytest
-
-# TODO: These tests should be converted to a C test.
-# For more information please take a look at the thread
-# https://lists.denx.de/pipermail/u-boot/2019-October/388732.html
-
-pytestmark = pytest.mark.buildconfigspec('hush_parser')
-
-# The list of "if test" conditions to test.
-subtests = (
-# Base if functionality.
-
-('true', True),
-('false', False),
-
-# Basic operators.
-
-('test aaa = aaa', True),
-('test aaa = bbb', False),
-
-('test aaa != bbb', True),
-('test aaa != aaa', False),
-
-('test aaa < bbb', True),
-('test bbb < aaa', False),
-
-('test bbb > aaa', True),
-('test aaa > bbb', False),
-
-('test 123 -eq 123', True),
-('test 123 -eq 456', False),
-
-('test 123 -ne 456', True),
-('test 123 -ne 123', False),
-
-('test 123 -lt 456', True),
-('test 123 -lt 123', False),
-('test 456 -lt 123', False),
-
-('test 123 -le 456', True),
-('test 123 -le 123', True),
-('test 456 -le 123', False),
-
-('test 456 -gt 123', True),
-('test 123 -gt 123', False),
-('test 123 -gt 456', False),
-
-('test 456 -ge 123', True),
-('test 123 -ge 123', True),
-('test 123 -ge 456', False),
-
-# Octal tests
-
-('test 010 -eq 010', True),
-('test 010 -eq 011', False),
-
-('test 010 -ne 011', True),
-('test 010 -ne 010', False),
-
-# Hexadecimal tests
-
-('test 0x200 -gt 0x201', False),
-('test 0x200 -gt 0x200', False),
-('test 0x200 -gt 0x1ff', True),
-
-# Mixed tests
-
-('test 010 -eq 10', False),
-('test 010 -ne 10', True),
-('test 0xa -eq 10', True),
-('test 0xa -eq 012', True),
-
-('test 200 -gt 0x1ff', False),
-('test 0x200 -gt 1ff', True),
-('test 0x200 -lt 1ff', False),
-('test 0x200 -eq 200', False),
-('test 0x200 -ne 200', True),
-
-('test -z ""', True),
-('test -z "aaa"', False),
-
-('test -n "aaa"', True),
-('test -n ""', False),
-
-# Inversion of simple tests.
-
-('test ! aaa = aaa', False),
-('test ! aaa = bbb', True),
-('test ! ! aaa = aaa', True),
-('test ! ! aaa = bbb', False),
-
-# Binary operators.
-
-('test aaa != aaa -o bbb != bbb', False),
-('test aaa != aaa -o bbb = bbb', True),
-('test aaa = aaa -o bbb != bbb', True),
-('test aaa = aaa -o bbb = bbb', True),
-
-('test aaa != aaa -a bbb != bbb', False),
-('test aaa != aaa -a bbb = bbb', False),
-('test aaa = aaa -a bbb != bbb', False),
-('test aaa = aaa -a bbb = bbb', True),
-
-# Inversion within binary operators.
-
-('test ! aaa != aaa -o ! bbb != bbb', True),
-('test ! aaa != aaa -o ! bbb = bbb', True),
-('test ! aaa = aaa -o ! bbb != bbb', True),
-('test ! aaa = aaa -o ! bbb = bbb', False),
-
-('test ! ! aaa != aaa -o ! ! bbb != bbb', False),
-('test ! ! aaa != aaa -o ! ! bbb = bbb', True),
-('test ! ! aaa = aaa -o ! ! bbb != bbb', True),
-('test ! ! aaa = aaa -o ! ! bbb = bbb', True),
-
-# -z operator.
-
-('test -z "$ut_var_nonexistent"', True),
-('test -z "$ut_var_exists"', False),
-)
-
-def exec_hush_if(u_boot_console, expr, result):
-"""Execute a shell "if" command, and validate its result."""
-
-config = u_boot_console.config.buildconfig
-maxargs = int(config.get('config_sys_maxargs', '0'))
-args = len(expr.split(' ')) - 1
-if args > maxargs:
-u_boot_console.log.warning('CONFIG_SYS_MAXARGS too low; need ' +
-str(args))
-pytest.skip()
-
-cmd = 'if ' + expr + '; then echo true; else echo false; fi'
-response = u_boot_console.run_command(cmd)
-assert response.strip() == str(result).lower()
-
-def test_hush_if_test_setup(u_boot_console):
-"""Set up environment variables used during the "if" tests."""
-
-u_boot_console.run_command('setenv ut_var_nonexistent')
-u_boot_console.run_command('setenv ut_var_exists 1')
-
-@pytest.mark.buildconfigspec('cmd_echo')
-@pytest.mark.parametrize('expr,result', subtests)
-def test_hush_if_test(u_boot_console, expr, result):
-"""Test a single "if test" condition."""
-
-exec_hush_if(u_boot_console, expr, result)
-
-def 

[RFC PATCH 2/6] test: hush: Test hush if/else.

2021-08-20 Thread Francis Laniel
As asked in commit 9c6bf1715f6a ("test/py: hush_if_test: Add tests to cover
octal/hex values"), this commit translates test_hush_if_test.py to a C test.

Signed-off-by: Francis Laniel 
---
 test/hush/Makefile |   1 +
 test/hush/if.c | 308 +
 2 files changed, 309 insertions(+)
 create mode 100644 test/hush/if.c

diff --git a/test/hush/Makefile b/test/hush/Makefile
index dfa2a92615..a3c9ae5106 100644
--- a/test/hush/Makefile
+++ b/test/hush/Makefile
@@ -4,3 +4,4 @@
 # Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
 
 obj-y += cmd_ut_hush.o
+obj-y += if.o
diff --git a/test/hush/if.c b/test/hush/if.c
new file mode 100644
index 00..a57d88850f
--- /dev/null
+++ b/test/hush/if.c
@@ -0,0 +1,308 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * All tests will execute the following:
+ * if condition_to_test; then
+ *   true
+ * else
+ *   false
+ * fi
+ * If condition is true, command returns 1, 0 otherwise.
+ */
+const char *if_format = "if %s; then true; else false; fi";
+
+static int hush_test_if_base(struct unit_test_state *uts)
+{
+   char if_formatted[128];
+
+   sprintf(if_formatted, if_format, "true");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "false");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_if_base, 0);
+
+static int hush_test_if_basic_operators(struct unit_test_state *uts)
+{
+   char if_formatted[128];
+
+   sprintf(if_formatted, if_format, "test aaa = aaa");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test aaa = bbb");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test aaa != bbb");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test aaa != aaa");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test aaa < bbb");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test bbb < aaa");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test bbb > aaa");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test aaa > bbb");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -eq 123");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -eq 456");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -ne 456");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -ne 123");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -lt 456");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -lt 123");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 456 -lt 123");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -le 456");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -le 123");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 456 -le 123");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 456 -gt 123");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -gt 123");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -gt 456");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 456 -ge 123");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -ge 123");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -ge 456");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_if_basic_operators, 0);
+
+static int hush_test_if_octal(struct unit_test_state *uts)
+{
+   char if_formatted[128];
+
+   sprintf(if_formatted, if_format, "test 010 -eq 010");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 010 -eq 011");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 010 -ne 011");
+   ut_assertok(run_command(if_formatted, 0));
+
+   

[RFC PATCH 1/6] test: Add framework to test hush behavior.

2021-08-20 Thread Francis Laniel
This commit introduces a new subcommand to ut: ut hush.
For the moment, this command does nothing, future commits will add tests which
will be run on command call.

Note that CONFIG_HUSH_PARSER must be defined to compile this new subcommand.

Signed-off-by: Francis Laniel 
---
 include/test/hush.h | 15 +++
 include/test/suites.h   |  1 +
 test/Makefile   |  3 +++
 test/cmd_ut.c   |  6 ++
 test/hush/Makefile  |  6 ++
 test/hush/cmd_ut_hush.c | 20 
 6 files changed, 51 insertions(+)
 create mode 100644 include/test/hush.h
 create mode 100644 test/hush/Makefile
 create mode 100644 test/hush/cmd_ut_hush.c

diff --git a/include/test/hush.h b/include/test/hush.h
new file mode 100644
index 00..cca66544a0
--- /dev/null
+++ b/include/test/hush.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#ifndef __TEST_HUSH_H__
+#define __TEST_HUSH_H__
+
+#include 
+
+/* Declare a new environment test */
+#define HUSH_TEST(_name, _flags)   UNIT_TEST(_name, _flags, hush_test)
+
+#endif /* __TEST_HUSH_H__ */
diff --git a/include/test/suites.h b/include/test/suites.h
index d35cd83a4e..35a8429e18 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -36,6 +36,7 @@ int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int 
argc,
  char *const argv[]);
 int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/Makefile b/test/Makefile
index b3b2902e2e..c471125982 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -16,6 +16,9 @@ obj-$(CONFIG_$(SPL_)CMDLINE) += cmd_ut.o
 obj-$(CONFIG_$(SPL_)CMDLINE) += command_ut.o
 obj-$(CONFIG_$(SPL_)UT_COMPRESSION) += compression.o
 obj-y += dm/
+ifneq ($(CONFIG_HUSH_PARSER),)
+obj-$(CONFIG_CMDLINE) += hush/
+endif
 obj-$(CONFIG_$(SPL_)CMDLINE) += print_ut.o
 obj-$(CONFIG_$(SPL_)CMDLINE) += str_ut.o
 obj-$(CONFIG_UT_TIME) += time_ut.o
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 90b260f72d..714b7e7417 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -70,6 +70,9 @@ static struct cmd_tbl cmd_ut_sub[] = {
 #ifdef CONFIG_CMD_ADDRMAP
U_BOOT_CMD_MKENT(addrmap, CONFIG_SYS_MAXARGS, 1, do_ut_addrmap, "", ""),
 #endif
+#if CONFIG_IS_ENABLED(HUSH_PARSER)
+   U_BOOT_CMD_MKENT(hush, CONFIG_SYS_MAXARGS, 1, do_ut_hush, "", ""),
+#endif
 };
 
 static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -148,6 +151,9 @@ static char ut_help_text[] =
 #endif
 #ifdef CONFIG_CMD_ADDRMAP
"ut addrmap - Very basic test of addrmap command\n"
+#endif
+#if CONFIG_IS_ENABLED(HUSH_PARSER)
+   "ut hush [test-name] - Test hush behavior\n"
 #endif
;
 #endif /* CONFIG_SYS_LONGHELP */
diff --git a/test/hush/Makefile b/test/hush/Makefile
new file mode 100644
index 00..dfa2a92615
--- /dev/null
+++ b/test/hush/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2021
+# Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+
+obj-y += cmd_ut_hush.o
diff --git a/test/hush/cmd_ut_hush.c b/test/hush/cmd_ut_hush.c
new file mode 100644
index 00..48a1adbf28
--- /dev/null
+++ b/test/hush/cmd_ut_hush.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+   struct unit_test *tests = UNIT_TEST_SUITE_START(hush_test);
+   const int n_ents = UNIT_TEST_SUITE_COUNT(hush_test);
+
+   return cmd_ut_category("hush", "hush_test_",
+  tests, n_ents, argc, argv);
+}
-- 
2.25.1



[RFC PATCH 0/6] Add C tests for hush

2021-08-20 Thread Francis Laniel
Hi everyone.


First, I hope you are fine and the same for your relatives.

This series introduces C tests for hush.
The main goal of these tests is to act as regression tests in case of hush being
modified.
During their writings some bugs were found, unfortunately I did not write
patches to fix them.
First, I think these bugs were present in Busybox when hush was taken from.
Also, as the whole U-Boot board scripts seem to work with these bugs maybe
correcting them can lead to breaking things somewhere...
This is why I marked this series as RFC as I would like the hear the opinion of
the community on this problem.

Regarding the series, first commit introduces a new subcommand to ut: ut hush.
Then, others add tests for the following:
* if test condition: All these tests were taken from test_hush_if_test.py which
was then removed.
* variable expansion: These tests ensures variable expansion is correct. While
writing them a bug was found in hush where the following:
foo='bar "quux'
echo $foo
prints:
bar quux
instead of:
bar "quux
* commands lists: These tests test several command separated by ';', "&&" and
"||". Here also, some bugs were found, indeed the following:
false && false || true
returns 0 in actual (2021) hush's Busybox, while it returns 1 in U-Boot.
* loops: This test is quite simple as we do not have math support in U-Boot,
this can be tricky to heavily test while and until loops.

To conclude, here is this series diffstat:
Francis Laniel (6):
  test: Add framework to test hush behavior.
  test: hush: Test hush if/else.
  test/py: hush_if_test: Remove the test file.
  test: hush: Test hush variable expansion.
  test: hush: Test hush commands list.
  test: hush: Test hush loops.

 include/test/hush.h|  15 ++
 include/test/suites.h  |   1 +
 test/Makefile  |   3 +
 test/cmd_ut.c  |   6 +
 test/hush/Makefile |  10 +
 test/hush/cmd_ut_hush.c|  20 ++
 test/hush/dollar.c | 188 ++
 test/hush/if.c | 308 +
 test/hush/list.c   |  79 
 test/hush/loop.c   |  64 ++
 test/py/tests/test_hush_if_test.py | 192 --
 11 files changed, 694 insertions(+), 192 deletions(-)
 create mode 100644 include/test/hush.h
 create mode 100644 test/hush/Makefile
 create mode 100644 test/hush/cmd_ut_hush.c
 create mode 100644 test/hush/dollar.c
 create mode 100644 test/hush/if.c
 create mode 100644 test/hush/list.c
 create mode 100644 test/hush/loop.c
 delete mode 100644 test/py/tests/test_hush_if_test.py


Best regards.
--
2.25.1



Re: [PATCH v2 3/6] armv8: Add ARMv8 MPU configuration logic

2021-08-20 Thread Andre Przywara

On 8/19/21 4:53 PM, Peter Hoyes wrote:

Hi,


From: Peter Hoyes 

Armv8r64 is the first Armv8 platform that only has a PMSA at the
current exception level. The architecture supplement for Armv8r64
describes new fields in ID_AA64MMFR0_EL1 which can be used to detect
whether a VMSA or PMSA is present. These fields are RES0 on Armv8a.

Add logic to read these fields and, for the protection of the memory
used by U-Boot, initialize the MPU instead of the MMU during init, then
clear the MPU regions before transition to the next stage.

Provide a default (blank) MPU memory map, which can be overridden by
board configurations.


So while this MPU feature is indeed architecturally discoverable, and 
that works fine even on existing ARMv8-A cores, this adds some code to 
the generic ARMv8 code path, which almost no one needs. So to avoid code 
bloat, I was wondering if we should move this code to a separate file 
and only include it when a new Kconfig symbol (for v8-R64) is defined?

The new board can then select this symbol.
We can then have either weak functions or static inline versions of the 
new functions (el_has_mmu(), mpu_setup()), to keep the existing code path.


Cheers,
Andre



Signed-off-by: Peter Hoyes 
---
  arch/arm/cpu/armv8/cache_v8.c| 96 +++-
  arch/arm/include/asm/armv8/mpu.h | 61 
  2 files changed, 154 insertions(+), 3 deletions(-)
  create mode 100644 arch/arm/include/asm/armv8/mpu.h

diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index 3de18c7675..46625675bd 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -15,6 +15,7 @@
  #include 
  #include 
  #include 
+#include 
  
  DECLARE_GLOBAL_DATA_PTR;
  
@@ -365,6 +366,86 @@ __weak u64 get_page_table_size(void)

return size;
  }
  
+static void mpu_clear_regions(void)

+{
+   int i;
+
+   for (i = 0; mpu_mem_map[i].end || mpu_mem_map[i].attrs; i++) {
+   setup_el2_mpu_region(i, 0, 0);
+   }
+}
+
+static struct mpu_region default_mpu_mem_map[] = {{0,}};
+__weak struct mpu_region *mpu_mem_map = default_mpu_mem_map;
+
+static void mpu_setup(void)
+{
+   int i;
+
+   if (current_el() != 2) {
+   panic("MPU configuration is only supported at EL2");
+   }
+
+   set_sctlr(get_sctlr() & ~(CR_M | CR_WXN));
+
+   asm volatile("msr MAIR_EL2, %0" : : "r" MEMORY_ATTRIBUTES);
+
+   for (i = 0; mpu_mem_map[i].end || mpu_mem_map[i].attrs; i++) {
+   setup_el2_mpu_region(i,
+   PRBAR_ADDRESS(mpu_mem_map[i].start)
+   | PRBAR_OUTER_SH | PRBAR_AP_RW_ANY,
+   PRLAR_ADDRESS(mpu_mem_map[i].end)
+   | mpu_mem_map[i].attrs | PRLAR_EN_BIT
+   );
+   }
+
+   set_sctlr(get_sctlr() | CR_M);
+}
+
+static bool el_has_mmu(void)
+{
+   uint64_t id_aa64mmfr0;
+   asm volatile("mrs %0, id_aa64mmfr0_el1"
+   : "=r" (id_aa64mmfr0) : : "cc");
+   uint64_t msa = id_aa64mmfr0 & ID_AA64MMFR0_EL1_MSA_MASK;
+   uint64_t msa_frac = id_aa64mmfr0 & ID_AA64MMFR0_EL1_MSA_FRAC_MASK;
+
+   switch (msa) {
+   case ID_AA64MMFR0_EL1_MSA_VMSA:
+   /*
+* VMSA supported in all translation regimes.
+* No support for PMSA.
+*/
+   return true;
+   case ID_AA64MMFR0_EL1_MSA_USE_FRAC:
+   /* See MSA_frac for the supported MSAs. */
+   switch (msa_frac) {
+   case ID_AA64MMFR0_EL1_MSA_FRAC_NO_PMSA:
+   /*
+* PMSA not supported in any translation
+* regime.
+*/
+   return true;
+   case ID_AA64MMFR0_EL1_MSA_FRAC_VMSA:
+   /*
+   * PMSA supported in all translation
+   * regimes. No support for VMSA.
+   */
+   case ID_AA64MMFR0_EL1_MSA_FRAC_PMSA:
+   /*
+* PMSA supported in all translation
+* regimes.
+*/
+   return false;
+   default:
+   panic("Unsupported id_aa64mmfr0_el1 " \
+   "MSA_frac value");
+   }
+   default:
+   panic("Unsupported id_aa64mmfr0_el1 MSA value");
+   }
+}
+
  void setup_pgtables(void)
  {

Re: [PATCH v2 1/6] armv8: Disable pointer authentication traps for EL1

2021-08-20 Thread Michael Walle

Hi,

Am 2021-08-20 16:44, schrieb Andre Przywara:

On 8/19/21 4:53 PM, Peter Hoyes wrote:

From: Peter Hoyes 

The use of ARMv8.3 pointer authentication (PAuth) is governed by 
fields

in HCR_EL2, which trigger a 'trap to EL2' if not enabled. The reset
value of these fields is 'architecturally unknown' so we must ensure
that the fields are enabled (to disable the traps) if we are entering
the kernel at EL1.

The APK field disables PAuth instruction traps and the API field
disables PAuth register traps

Add code to disable the traps in armv8_switch_to_el1_m. Prior to doing
so, it checks fields in the ID_AA64ISAR1_EL1 register to ensure 
pointer

authentication is supported by the hardware.

The runtime checks require a second temporary register, so add this to
the EL1 transition macro signature and update 2 call sites.




So can we get rid of the rather fragile macro, and just have one
normal function, in transition.S, which fsl-layerscape/spintable.S
calls? The code does not seem to return, and also the FSL call site
does not seem to be in some special section or so, so not sure why
this was a macro in the first place?


The spin tables will be marked as reserved memory at
  
https://elixir.bootlin.com/u-boot/v2021.10-rc2/source/arch/arm/cpu/armv8/fsl-layerscape/fdt.c#L147

also the code will be moved around:
  
https://elixir.bootlin.com/u-boot/v2021.10-rc2/source/arch/arm/cpu/armv8/fsl-layerscape/mp.c#L97


-michael


Re: [PATCH v6 10/12] watchdog: add gpio watchdog driver

2021-08-20 Thread Simon Glass
Hi Wolfgang,

On Thu, 19 Aug 2021 at 08:58, Wolfgang Denk  wrote:
>
> Dear Simon,
>
> In message 
>  you 
> wrote:
> >
> > - programming errors
> > - security errors where user input is insufficiently checked
> >
> > IMO the former should not be present if you have sufficient tests and
> > trying to catch them in the field at runtime is not very kind to your
> > users.
>
> Wow.
>
> I think I'll add this to my signature database:
>
> | "Trying to catch [programming errors] in the field at runtime is not
> | very kind to your users."
> |
> | - Simon Glass in 
> 

Well you've taken it out of context :-) It would make more sense if
you mention the need for tests

Regards,
Simon


Re: [PATCH v2 1/6] armv8: Disable pointer authentication traps for EL1

2021-08-20 Thread Andre Przywara

On 8/19/21 4:53 PM, Peter Hoyes wrote:

From: Peter Hoyes 

The use of ARMv8.3 pointer authentication (PAuth) is governed by fields
in HCR_EL2, which trigger a 'trap to EL2' if not enabled. The reset
value of these fields is 'architecturally unknown' so we must ensure
that the fields are enabled (to disable the traps) if we are entering
the kernel at EL1.

The APK field disables PAuth instruction traps and the API field
disables PAuth register traps

Add code to disable the traps in armv8_switch_to_el1_m. Prior to doing
so, it checks fields in the ID_AA64ISAR1_EL1 register to ensure pointer
authentication is supported by the hardware.

The runtime checks require a second temporary register, so add this to
the EL1 transition macro signature and update 2 call sites.




So can we get rid of the rather fragile macro, and just have one normal 
function, in transition.S, which fsl-layerscape/spintable.S calls? The 
code does not seem to return, and also the FSL call site does not seem 
to be in some special section or so, so not sure why this was a macro in 
the first place?


Cheers,
Andre



Signed-off-by: Peter Hoyes 
---
  arch/arm/cpu/armv8/fsl-layerscape/spintable.S |  2 +-
  arch/arm/cpu/armv8/transition.S   |  2 +-
  arch/arm/include/asm/macro.h  | 11 +--
  arch/arm/include/asm/system.h | 15 +++
  4 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spintable.S 
b/arch/arm/cpu/armv8/fsl-layerscape/spintable.S
index 363ded03e6..d6bd188459 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/spintable.S
+++ b/arch/arm/cpu/armv8/fsl-layerscape/spintable.S
@@ -93,7 +93,7 @@ __secondary_boot_func:
  4:
  #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
switch_el x7, _dead_loop, 0f, _dead_loop
-0: armv8_switch_to_el1_m x4, x6, x7
+0: armv8_switch_to_el1_m x4, x6, x7, x9
  #else
switch_el x7, 0f, _dead_loop, _dead_loop
  0:armv8_switch_to_el2_m x4, x6, x7
diff --git a/arch/arm/cpu/armv8/transition.S b/arch/arm/cpu/armv8/transition.S
index a31af4ffc8..9dbdff3a4f 100644
--- a/arch/arm/cpu/armv8/transition.S
+++ b/arch/arm/cpu/armv8/transition.S
@@ -40,7 +40,7 @@ ENTRY(armv8_switch_to_el1)
 * now, jump to the address saved in x4.
 */
br x4
-1: armv8_switch_to_el1_m x4, x5, x6
+1: armv8_switch_to_el1_m x4, x5, x6, x7
  ENDPROC(armv8_switch_to_el1)
  .popsection
  
diff --git a/arch/arm/include/asm/macro.h b/arch/arm/include/asm/macro.h

index 485310d660..e1eefc283f 100644
--- a/arch/arm/include/asm/macro.h
+++ b/arch/arm/include/asm/macro.h
@@ -256,7 +256,7 @@ lr  .reqx30
   * For loading 64-bit OS, x0 is physical address to the FDT blob.
   * They will be passed to the guest.
   */
-.macro armv8_switch_to_el1_m, ep, flag, tmp
+.macro armv8_switch_to_el1_m, ep, flag, tmp, tmp2
/* Initialize Generic Timers */
mrs \tmp, cnthctl_el2
/* Enable EL1 access to timers */
@@ -306,7 +306,14 @@ lr .reqx30
b.eq1f
  
  	/* Initialize HCR_EL2 */

-   ldr \tmp, =(HCR_EL2_RW_AARCH64 | HCR_EL2_HCD_DIS)
+   /* Only disable PAuth traps if PAuth is supported */
+   mrs \tmp, id_aa64isar1_el1
+   ldr \tmp2, =(ID_AA64ISAR1_EL1_GPI | ID_AA64ISAR1_EL1_GPA | \
+ ID_AA64ISAR1_EL1_API | ID_AA64ISAR1_EL1_APA)
+   tst \tmp, \tmp2
+   mov \tmp2, #(HCR_EL2_RW_AARCH64 | HCR_EL2_HCD_DIS)
+   orr \tmp, \tmp2, #(HCR_EL2_APK | HCR_EL2_API)
+   csel\tmp, \tmp2, \tmp, eq
msr hcr_el2, \tmp
  
  	/* Return to the EL1_SP1 mode from EL2 */

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 8b3a54e64c..77aa18909e 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -75,10 +75,25 @@
  /*
   * HCR_EL2 bits definitions
   */
+#define HCR_EL2_API(1 << 41) /* Trap pointer authentication
+instructions */
+#define HCR_EL2_APK(1 << 40) /* Trap pointer authentication
+key access   */
  #define HCR_EL2_RW_AARCH64(1 << 31) /* EL1 is AArch64   */
  #define HCR_EL2_RW_AARCH32(0 << 31) /* Lower levels are AArch32 */
  #define HCR_EL2_HCD_DIS   (1 << 29) /* Hypervisor Call disabled   
  */
  
+/*

+ * ID_AA64ISAR1_EL1 bits definitions
+ */
+#define ID_AA64ISAR1_EL1_GPI   (0xF << 28) /* Implementation-defined generic
+  code auth algorithm*/
+#define ID_AA64ISAR1_EL1_GPA   (0xF << 24) /* QARMA generic code auth
+  algorithm  */
+#define ID_AA64ISAR1_EL1_API   (0xF << 8)  /* Implementation-defined address
+  auth 

Re: [PATCH v3 1/2] imx8mm-evk: Generate a single bootable flash.bin again

2021-08-20 Thread Marcel Ziswiler
On Fri, 2021-08-20 at 12:47 +0200, Heiko Thiery wrote:
> Hi Fabio,
> 
> > > Yes, I believe it really requires explicitly setting the filename as I 
> > > previously suggested.
> > > 
> > > 
> > > https://marc.info/?l=u-boot=162940109314578
> > 
> > Peng Fan has sent a patch fixing this:
> > https://www.mail-archive.com/u-boot@lists.denx.de/msg414966.html
> 
> Ah ok. Thanks

Yes, I can confirm that Peng's patch fixes this. I guess, me explicitly adding 
the filename did not really
change anything but due to me running make again it subsequently picked up the 
previously generated artifact.
Sorry for the noise.


Re: [PATCH] global: Remove dead code that starts with CONFIG_[0-9A]

2021-08-20 Thread Tom Rini
On Fri, Aug 20, 2021 at 03:01:19PM +0200, Rasmus Villemoes wrote:
> On 19/08/2021 21.02, Tom Rini wrote:
> > This removes a number of spots of dead code based on symbols that start
> > with CONFIG_[0-9] or CONFIG_A.
> 
> How did you find those symbols? I suppose the actual patch is just
> generated with unifdef or similar.

The entire list is at scripts/config_whitelist.txt and I just used `git
grep -Ovim ...` and removed by hand.

> >  include/configs/vexpress_common.h |   3 -
> >  14 files changed, 3 insertions(+), 253 deletions(-)
> 
> Shouldn't they also be removed from scripts/config_whitelist.txt ?

I don't bother because there's so many conflicts and it's a generated
by scripts/build-whitelist.sh

> More generally, running
> 
> for x in $(cat scripts/config_whitelist.txt) ; do git grep -w -q $x -- .
> ':!scripts/config_whitelist.txt' || echo $x ; done
> 
> [I'm sure there's a more efficient way...] shows a few symbols that
> could be removed from that file, along with the places where they are
> set via a CONFIG_SYS_EXTRA_OPTIONS.

Yes, finishing the migration of CONFIG_SYS_EXTRA_OPTIONS is also on the
list.  I'm just running down the list looking for chunks of symbols that
hopefully aren't in the categories of:
- Abusing tests for CONFIG_SPL_BUILD to set/unset based on SPL build or
  not.
- Sometimes a value, sometimes a function name.
- Some other kind of game cpp lets you do, but that's not so easy to
  move to Kconfig.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 5/7] imx: makefile: drop the use of imx8mimage.sh

2021-08-20 Thread Marcel Ziswiler
On Thu, 2021-08-19 at 12:32 +0200, Frieder Schrempf wrote:
> On 16.08.21 05:48, Peng Fan (OSS) wrote:
> > From: Peng Fan 
> > 
> > After switch to use binman, no need to use the bash script
> > to check file exsiting or not. And there is bug that
> > the script will be executed everytime Makefile is used which is
> > confusing people.
> > 
> > Signed-off-by: Peng Fan 
> 
> For my mx8mm board config using binman, this resolves the following warning:
> 
> WARNING 'mkimage.flash.mkimage' not found, resulting binary is not-functional
> 
> Tested-by: Frieder Schrempf 
> 
> Is this save to be used with boards that haven't been converted to binman yet?

No, unfortunately not:

...
  LD  spl/u-boot-spl
  OBJCOPY spl/u-boot-spl-nodtb.bin
  SYM spl/u-boot-spl.sym
  CAT spl/u-boot-spl-dtb.bin
  COPYspl/u-boot-spl.bin
  CFGSspl/u-boot-spl.cfgout
  MKIMAGE flash.bin
./tools/mkimage: Can't open spl/u-boot-spl-ddr.bin: No such file or directory
make[1]: *** [arch/arm/mach-imx/Makefile:166: flash.bin] Error 1
make[1]: *** Deleting file 'flash.bin'
make: *** [Makefile:1532: flash.bin] Error 2

But that legacy image creation stuff is anyway already broken since quite a 
while!

Anyway, I am about to send both a fix for the legacy image creation as well as 
convert verdin-imx8mm to using
binman shortly. So, I guess, we could just ignore this issue for now and move 
forward...

> > ---
> >  arch/arm/mach-imx/Makefile | 13 +++--
> >  1 file changed, 7 insertions(+), 6 deletions(-)
> > 
> > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> > index 0ef269563d..f629751c48 100644
> > --- a/arch/arm/mach-imx/Makefile
> > +++ b/arch/arm/mach-imx/Makefile
> > @@ -114,8 +114,7 @@ endif
> >  DEPFILE_EXISTS := $(shell $(CPP) $(cpp_flags) -x c -o u-boot-dtb.cfgout 
> > $(srctree)/$(IMX_CONFIG); if [ -f u-
> > boot-dtb.cfgout ]; then $(CNTR_DEPFILES) u-boot-dtb.cfgout; echo $$?; fi)
> >  else ifeq ($(CONFIG_ARCH_IMX8M), y)
> >  IMAGE_TYPE := imx8mimage
> > -IMX8M_DEPFILES := $(srctree)/tools/imx8m_image.sh
> > -DEPFILE_EXISTS := $(shell $(CPP) $(cpp_flags) -x c -o 
> > spl/u-boot-spl.cfgout $(srctree)/$(IMX_CONFIG);if [ -f
> > spl/u-boot-spl.cfgout ]; then $(IMX8M_DEPFILES) spl/u-boot-spl.cfgout 0; 
> > echo $$?; fi)
> > +DEPFILE_EXISTS := 0
> >  else
> >  IMAGE_TYPE := imximage
> >  DEPFILE_EXISTS := 0
> > @@ -150,16 +149,18 @@ endif
> >  
> >  ifdef CONFIG_ARM64
> >  ifeq ($(CONFIG_ARCH_IMX8M), y)
> > -SPL:
> > +
> > +SPL: spl/u-boot-spl.bin spl/u-boot-spl.cfgout FORCE
> >  
> >  MKIMAGEFLAGS_flash.bin = -n spl/u-boot-spl.cfgout \
> >    -T $(IMAGE_TYPE) -e $(CONFIG_SPL_TEXT_BASE)
> >  flash.bin: MKIMAGEOUTPUT = flash.log
> >  
> > +spl/u-boot-spl.cfgout: $(IMX_CONFIG) FORCE
> > +   $(Q)mkdir -p $(dir $@)
> > +   $(call if_changed_dep,cpp_cfg)
> > +
> >  spl/u-boot-spl-ddr.bin: spl/u-boot-spl.bin spl/u-boot-spl.cfgout FORCE
> > -ifeq ($(DEPFILE_EXISTS),0)
> > -   $(IMX8M_DEPFILES) spl/u-boot-spl.cfgout 1
> > -endif
> >  
> >  flash.bin: spl/u-boot-spl-ddr.bin u-boot.itb FORCE
> > $(call if_changed,mkimage)
-- 
Best regards - Mit freundlichen Grüssen - Meilleures salutations

Marcel Ziswiler
Software Team Lead - Embedded Linux BSP

Toradex AG
Ebenaustrasse 10 | 6048 Horw/Luzern | Switzerland | T: +41 41 500 4800


Re: [PATCH] global: Remove dead code that starts with CONFIG_[0-9A]

2021-08-20 Thread Rasmus Villemoes
On 19/08/2021 21.02, Tom Rini wrote:
> This removes a number of spots of dead code based on symbols that start
> with CONFIG_[0-9] or CONFIG_A.

How did you find those symbols? I suppose the actual patch is just
generated with unifdef or similar.

>  include/configs/vexpress_common.h |   3 -
>  14 files changed, 3 insertions(+), 253 deletions(-)

Shouldn't they also be removed from scripts/config_whitelist.txt ?

More generally, running

for x in $(cat scripts/config_whitelist.txt) ; do git grep -w -q $x -- .
':!scripts/config_whitelist.txt' || echo $x ; done

[I'm sure there's a more efficient way...] shows a few symbols that
could be removed from that file, along with the places where they are
set via a CONFIG_SYS_EXTRA_OPTIONS.

Rasmus


[PATCH v2 4/4] mtd: spi-nor-core: Add support for Macronix Octal flash

2021-08-20 Thread JaimeLiao
Adding Macronix Octal flash for Octal DTR support.

The octaflash series can be divided into the following types:

MX25 series : Serial NOR Flash.
MX66 series : Serial NOR Flash with stacked die.(Size larger than 1Gb)
LM/UM series : Up to 250MHz clock frequency with both DTR/STR operation.
LW/UW series : Support simultaneous Read-while-Write operation in multiple
   bank architecture. Read-while-write feature which means read
   data one bank while another bank is programing or erasing.

MX25LM : 3.0V Octal I/O
 
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/7841/MX25LM51245G,%203V,%20512Mb,%20v1.1.pdf

MX25UM : 1.8V Octal I/O
 
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/7525/MX25UM51245G%20Extreme%20Speed,%201.8V,%20512Mb,%20v1.0.pdf

MX66LM : 3.0V Octal I/O with stacked die
 
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/7929/MX66LM1G45G,%203V,%201Gb,%20v1.1.pdf

MX66UM : 1.8V Octal I/O with stacked die
 
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/7721/MX66UM1G45G,%201.8V,%201Gb,%20v1.1.pdf

MX25LW : 3.0V Octal I/O with Read-while-Write
MX25UW : 1.8V Octal I/O with Read-while-Write
MX66LW : 3.0V Octal I/O with Read-while-Write and stack die
MX66UW : 1.8V Octal I/O with Read-while-Write and stack die

About LW/UW series, please contact us freely if you have any
questions. For adding Octal NOR Flash IDs, we have validated
each Flash on plateform zynq-picozed.

Signed-off-by: JaimeLiao 
---
 drivers/mtd/spi/spi-nor-ids.c | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index cb3a08872d..5c13ea3a78 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -169,7 +169,27 @@ const struct flash_info spi_nor_ids[] = {
{ INFO("mx66l1g45g",  0xc2201b, 0, 64 * 1024, 2048, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ INFO("mx25l1633e", 0xc22415, 0, 64 * 1024,   32, SPI_NOR_QUAD_READ | 
SPI_NOR_4B_OPCODES | SECT_4K) },
{ INFO("mx25r6435f", 0xc22817, 0, 64 * 1024,   128,  SECT_4K) },
-   { INFO("mx66uw2g345g", 0xc2943c, 0, 64 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx66uw2g345gx0", 0xc2943c, 0, 64 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx66lm1g45g",0xc2853b, 0, 32 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25lm51245g",   0xc2853a, 0, 16 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25lw51245g",   0xc2863a, 0, 16 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25lm25645g",   0xc28539, 0, 8 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx66um2g45g",0xc2803c, 0, 64 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx66uw2g345g",   0xc2843c, 0, 64 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx66um1g45g",0xc2803b, 0, 32 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx66uw1g45g",0xc2813b, 0, 32 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25um51245g",   0xc2803a, 0, 16 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25uw51245g",   0xc2813a, 0, 16 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25uw51345g",   0xc2843a, 0, 16 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25um25645g",   0xc28039, 0, 8 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25uw25645g",   0xc28139, 0, 8 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25um25345g",   0xc28339, 0, 8 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25uw25345g",   0xc28439, 0, 8 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25uw12845g",   0xc28138, 0, 4 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25uw12a45g",   0xc28938, 0, 4 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25uw12345g",   0xc28438, 0, 4 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25uw6445g",0xc28137, 0, 2 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("mx25uw6345g",0xc28437, 0, 2 * 1024, 4096, SECT_4K | 
SPI_NOR_OCTAL_DTR_READ | SPI_NOR_4B_OPCODES) },
 #endif
 
 #ifdef CONFIG_SPI_FLASH_STMICRO/* STMICRO */
-- 
2.17.1



[PATCH v2 3/4] mtd: spi-nor-core: set 4byte opcode when possible

2021-08-20 Thread JaimeLiao
Following linux kernel to check address width and 4byte flag to enable
4byte opcode setting.

Signed-off-by: JaimeLiao 
---
 drivers/mtd/spi/spi-nor-core.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 707eb9c1d2..069c6f4630 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3927,6 +3927,10 @@ int spi_nor_scan(struct spi_nor *nor)
return -EINVAL;
}
 
+   /* Set 4byte opcodes when possible. */
+   if (nor->addr_width == 4 && info->flags & SPI_NOR_4B_OPCODES)
+   spi_nor_set_4byte_opcodes(nor, info);
+
/* Send all the required SPI flash commands to initialize device */
ret = spi_nor_init(nor);
if (ret)
-- 
2.17.1



[PATCH v2 2/4] mtd: spi-nor-core: Adding different type of command extension in Soft Reset

2021-08-20 Thread JaimeLiao
Power-on-Reset is a method to restore flash back to 1S-1S-1S mode from 8D-8D-8D
in the begging of probe.

Command extension type is not standardized across flash vendors in DTR mode.

For suiting different vendor flash devices, having second times Softreset with
different types is clumsy but useful in the begging of probe.

Signed-off-by: JaimeLiao 
---
 drivers/mtd/spi/spi-nor-core.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 351ca9c3a8..707eb9c1d2 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3692,6 +3692,36 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
 */
udelay(SPI_NOR_SRST_SLEEP_LEN);
 
+   /* Manufacturers with different command extension type. For suitting
+* different flash devices, using command extension type is equal 
"INVERT"
+* when second time Software Reset.
+*/
+
+   nor->cmd_ext_type = SPI_NOR_EXT_INVERT;
+   op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRSTEN, 0),
+   SPI_MEM_OP_NO_DUMMY,
+   SPI_MEM_OP_NO_ADDR,
+   SPI_MEM_OP_NO_DATA);
+   spi_nor_setup_op(nor, , SNOR_PROTO_8_8_8_DTR);
+   ret = spi_mem_exec_op(nor->spi, );
+   if (ret) {
+   dev_warn(nor->dev, "Software reset enable failed: %d\n", ret);
+   goto out;
+   }
+
+   op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRST, 0),
+   SPI_MEM_OP_NO_DUMMY,
+   SPI_MEM_OP_NO_ADDR,
+   SPI_MEM_OP_NO_DATA);
+   spi_nor_setup_op(nor, , SNOR_PROTO_8_8_8_DTR);
+   ret = spi_mem_exec_op(nor->spi, );
+   if (ret) {
+   dev_warn(nor->dev, "Software reset failed: %d\n", ret);
+   goto out;
+   }
+
+   udelay(SPI_NOR_SRST_SLEEP_LEN);
+
 out:
nor->cmd_ext_type = ext;
return ret;
-- 
2.17.1



[PATCH v2 1/4] mtd: spi-nor: macronix: add support for Macronix Octal flash

2021-08-20 Thread JaimeLiao
Follow patch "f6adec1af4b2f5d3012480c6cdce7743b74a6156" for adding
Macronix flash in Octal DTR mode.

Enable Octal DTR mode with 20 dummy cycles to allow running at the
maximum supported frequency.
 
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/7841/MX25LM51245G,%203V,%20512Mb,%20v1.1.pdf

Signed-off-by: JaimeLiao 
---
 drivers/mtd/spi/spi-nor-core.c | 83 ++
 include/linux/mtd/spi-nor.h| 13 +-
 2 files changed, 94 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index d5d905fa5a..351ca9c3a8 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3489,6 +3489,85 @@ static struct spi_nor_fixups mt35xu512aba_fixups = {
 };
 #endif /* CONFIG_SPI_FLASH_MT35XU */
 
+#ifdef CONFIG_SPI_FLASH_MACRONIX
+/**
+ * spi_nor_macronix_octal_dtr_enable() - set DTR OPI Enable bit in 
Configuration Register 2.
+ * @nor:   pointer to a 'struct spi_nor'
+ *
+ * Set the DTR OPI Enable (DOPI) bit in Configuration Register 2.
+ * Bit 2 of  Configuration Register 2 is the DOPI bit for Macronix like OPI 
memories.
+ *
+ * Return: 0 on success, -errno otherwise.
+ */
+static int spi_nor_macronix_octal_dtr_enable(struct spi_nor *nor)
+{
+   struct spi_mem_op op;
+   int ret;
+   u8 buf;
+
+   write_enable(nor);
+   if (ret)
+   return ret;
+
+   buf = SPINOR_REG_MXIC_DC_20;
+   op = (struct spi_mem_op)
+   SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WR_CR2, 1),
+  SPI_MEM_OP_ADDR(4, SPINOR_REG_MXIC_CR2_DC, 1),
+  SPI_MEM_OP_NO_DUMMY,
+  SPI_MEM_OP_DATA_OUT(1, , 1));
+
+   ret = spi_mem_exec_op(nor->spi, );
+   if (ret)
+   return ret;
+
+   ret = spi_nor_wait_till_ready(nor);
+   if (ret)
+   return ret;
+
+   nor->read_dummy = MXIC_MAX_DC;
+   write_enable(nor);
+   if (ret)
+   return ret;
+
+   buf = SPINOR_REG_MXIC_OPI_DTR_EN;
+   op = (struct spi_mem_op)
+   SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WR_CR2, 1),
+  SPI_MEM_OP_ADDR(4, SPINOR_REG_MXIC_CR2_MODE, 1),
+  SPI_MEM_OP_NO_DUMMY,
+  SPI_MEM_OP_DATA_OUT(1, , 1));
+
+   ret = spi_mem_exec_op(nor->spi, );
+   if (ret) {
+   dev_err(nor->dev, "Failed to enable octal DTR mode\n");
+   return ret;
+   }
+   nor->reg_proto = SNOR_PROTO_8_8_8_DTR;
+
+   return 0;
+}
+
+static void macronix_default_init(struct spi_nor *nor)
+{
+   nor->octal_dtr_enable = spi_nor_macronix_octal_dtr_enable;
+}
+
+static void macronix_post_sfdp_fixup(struct spi_nor *nor,
+struct spi_nor_flash_parameter *params)
+{
+   /*
+* Adding SNOR_HWCAPS_PP_8_8_8_DTR in hwcaps.mask when
+* SPI_NOR_OCTAL_DTR_READ flag exists.
+*/
+   if (params->hwcaps.mask & SNOR_HWCAPS_READ_8_8_8_DTR)
+   params->hwcaps.mask |= SNOR_HWCAPS_PP_8_8_8_DTR;
+}
+
+static struct spi_nor_fixups macronix_fixups = {
+   .default_init = macronix_default_init,
+   .post_sfdp = macronix_post_sfdp_fixup,
+};
+#endif /* CONFIG_SPI_FLASH_MACRONIX */
+
 /** spi_nor_octal_dtr_enable() - enable Octal DTR I/O if needed
  * @nor: pointer to a 'struct spi_nor'
  *
@@ -3655,6 +3734,10 @@ void spi_nor_set_fixups(struct spi_nor *nor)
if (!strcmp(nor->info->name, "mt35xu512aba"))
nor->fixups = _fixups;
 #endif
+
+#ifdef CONFIG_SPI_FLASH_MACRONIX
+   nor->fixups = _fixups;
+#endif
 }
 
 int spi_nor_scan(struct spi_nor *nor)
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 7ddc4ba2bf..2ad579f66d 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -116,8 +116,17 @@
 #define XSR_RDYBIT(7)  /* Ready */
 
 /* Used for Macronix and Winbond flashes. */
-#define SPINOR_OP_EN4B 0xb7/* Enter 4-byte mode */
-#define SPINOR_OP_EX4B 0xe9/* Exit 4-byte mode */
+#define SPINOR_OP_EN4B 0xb7/* Enter 4-byte mode */
+#define SPINOR_OP_EX4B 0xe9/* Exit 4-byte mode */
+#define SPINOR_OP_RD_CR2   0x71/* Read configuration 
register 2 */
+#define SPINOR_OP_WR_CR2   0x72/* Write configuration 
register 2 */
+#define SPINOR_OP_MXIC_DTR_RD  0xee/* Fast Read opcode in 
DTR mode */
+#define SPINOR_REG_MXIC_CR2_MODE   0x  /* For setting octal 
DTR mode */
+#define SPINOR_REG_MXIC_OPI_DTR_EN 0x2 /* Enable Octal DTR */
+#define SPINOR_REG_MXIC_OPI_DTR_DIS0x1 /* Disable Octal DTR */
+#define SPINOR_REG_MXIC_CR2_DC 0x0300  /* For setting dummy 
cycles */
+#define SPINOR_REG_MXIC_DC_20  0x0 /* Setting 

[PATCH v2 0/4] Add octal DTR support for Macronix flash

2021-08-20 Thread JaimeLiao
This series add support for Macronix octal DTR flash, add second time
Softreset with "INVERT" command extension type and follow linux kernel
to enable 4byte opcode when possible.

JaimeLiao (4):
  mtd: spi-nor: macronix: add support for Macronix Octal flash
  mtd: spi-nor-core: Adding different type of command extension in Soft
Reset
  mtd: spi-nor-core: set 4byte opcode when possible
  mtd: spi-nor-core: Add support for Macronix Octal flash

 drivers/mtd/spi/spi-nor-core.c | 117 +
 drivers/mtd/spi/spi-nor-ids.c  |  22 ++-
 include/linux/mtd/spi-nor.h|  13 +++-
 3 files changed, 149 insertions(+), 3 deletions(-)

-- 
2.17.1



[PATCH] ARM: meson: Add S905Y2 SOC ID

2021-08-20 Thread Christian Hewitt
Add the SOC ID for the S905Y2 to board info, see below for before/after
tested with a Radxa Zero board:

SoC:   Amlogic Meson G12A (Unknown) Revision 28:b (30:2)
SoC:   Amlogic Meson G12A (S905Y2) Revision 28:b (30:2)

Signed-off-by: Christian Hewitt 
---
 arch/arm/mach-meson/board-info.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-meson/board-info.c b/arch/arm/mach-meson/board-info.c
index d16d3f194d..2421acd817 100644
--- a/arch/arm/mach-meson/board-info.c
+++ b/arch/arm/mach-meson/board-info.c
@@ -64,6 +64,7 @@ static const struct meson_gx_package_id {
{ "A113X",  0x25, 0x37, 0xff },
{ "A113D",  0x25, 0x22, 0xff },
{ "S905D2", 0x28, 0x10, 0xf0 },
+   { "S905Y2", 0x28, 0x30, 0xf0 },
{ "S905X2", 0x28, 0x40, 0xf0 },
{ "A311D",  0x29, 0x10, 0xf0 },
{ "S922X",  0x29, 0x40, 0xf0 },
-- 
2.17.1



[PATCH] configs: ls1046aqds: Configure environment related configs

2021-08-20 Thread Kuldeep Singh
LS1046A-QDS board requires updation in few environment configs in TFA
defconfigs of the board.

Following are the changes:
- Update CONFIG_ENV_ADDR
- Update CONFIG_ENV_SECT_SIZE
- Enable CONFIG_SYS_RELOC_GD_ENV_ADDR

Signed-off-by: Kuldeep Singh 
---
 configs/ls1046aqds_tfa_defconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/configs/ls1046aqds_tfa_defconfig b/configs/ls1046aqds_tfa_defconfig
index 8ae5159f42..1c228f370a 100644
--- a/configs/ls1046aqds_tfa_defconfig
+++ b/configs/ls1046aqds_tfa_defconfig
@@ -7,7 +7,7 @@ CONFIG_SYS_MEMTEST_START=0x8000
 CONFIG_SYS_MEMTEST_END=0x9fff
 CONFIG_ENV_SIZE=0x2000
 CONFIG_ENV_OFFSET=0x50
-CONFIG_ENV_SECT_SIZE=0x1
+CONFIG_ENV_SECT_SIZE=0x2
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1046a-qds-duart"
 CONFIG_FSL_USE_PCA9547_MUX=y
@@ -45,7 +45,8 @@ CONFIG_ENV_IS_IN_NAND=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_USE_ENV_SPI_BUS=y
 CONFIG_ENV_SPI_BUS=0
-CONFIG_ENV_ADDR=0x4050
+CONFIG_ENV_ADDR=0x6050
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_SATA_CEVA=y
 CONFIG_FSL_CAAM=y
-- 
2.25.1



Remove the gitlab-ci-runner on source.denx.de?

2021-08-20 Thread Bin Meng
Hi Tom,

As the Dockerfile used for U-Boot CI testing is now integrated into
the U-Boot source tree, I suggest we remote the gitlab-ci-runner repo
to avoid confusion.

https://source.denx.de/u-boot/gitlab-ci-runner

Regards,
Bin


Re: [PATCH v3 1/2] imx8mm-evk: Generate a single bootable flash.bin again

2021-08-20 Thread Heiko Thiery
Hi Fabio,

> > Yes, I believe it really requires explicitly setting the filename as I 
> > previously suggested.
> >
> >
> > https://marc.info/?l=u-boot=162940109314578
>
> Peng Fan has sent a patch fixing this:
> https://www.mail-archive.com/u-boot@lists.denx.de/msg414966.html

Ah ok. Thanks

-- 
Heiko


Re: [PATCH v3 1/2] imx8mm-evk: Generate a single bootable flash.bin again

2021-08-20 Thread Fabio Estevam
Hi Heiko and Marcel,

On Fri, Aug 20, 2021 at 4:31 AM Marcel Ziswiler
 wrote:
>
> On Fri, 2021-08-20 at 07:41 +0200, Heiko Thiery wrote:
> >
> > ...
> >
> > When building from a clean checkout I see the following warnings. It
> > seems that there are some dependency checks that are looking for the
> > files in mkimage config file.
> >
> >   AR  arch/arm/lib/lib.a
> >   AS  arch/arm/lib/crt0_aarch64_efi.o
> >   CC  arch/arm/lib/reloc_aarch64_efi.o
> > WARNING 'mkimage.spl.mkimage' not found, resulting binary is not-functional
> >   AS  arch/arm/mach-imx/imx8m/lowlevel_init.o
> >   CC  arch/arm/mach-imx/imx8m/clock_slice.o
> >   CC  arch/arm/mach-imx/imx8m/soc.o
> > :
> > :
> >   AS  spl/arch/arm/lib/crt0_aarch64_efi.o
> >   CC  spl/arch/arm/lib/reloc_aarch64_efi.o
> > WARNING 'mkimage.spl.mkimage' not found, resulting binary is not-functional
> >   AS  spl/arch/arm/mach-imx/imx8m/lowlevel_init.o
> >   CC  spl/arch/arm/mach-imx/imx8m/clock_slice.o
> >   CC  spl/arch/arm/mach-imx/imx8m/soc.o
> > :
> > :
> >   COPYspl/u-boot-spl.bin
> >   SYM spl/u-boot-spl.sym
> > WARNING 'mkimage.spl.mkimage' not found, resulting binary is not-functional
> > make[1]: Nothing to be done for 'SPL'.
> >   OBJCOPY u-boot.srec
> >   OBJCOPY u-boot-nodtb.bin
>
> Yes, I believe it really requires explicitly setting the filename as I 
> previously suggested.
>
>
> https://marc.info/?l=u-boot=162940109314578

Peng Fan has sent a patch fixing this:
https://www.mail-archive.com/u-boot@lists.denx.de/msg414966.html

Thanks


[PATCH] ARM: dts: Fix node status to "okay" on TI boards

2021-08-20 Thread Roger Quadros
As per Device Tree core schema [1], status parameter of nodes can be either
"okay" or "disabled".

U-boot Driver Model does not recognize status="ok" and treats
the node as disabled.

Signed-off-by: Roger Quadros 
---
 arch/arm/dts/am3517-evm-ui.dtsi | 4 ++--
 arch/arm/dts/am3517-evm.dts | 2 +-
 arch/arm/dts/am437x-gp-evm.dts  | 2 +-
 arch/arm/dts/am43x-epos-evm.dts | 2 +-
 arch/arm/dts/am57xx-beagle-x15-common.dtsi  | 6 +++---
 arch/arm/dts/da850-evm.dts  | 2 +-
 arch/arm/dts/dra7-evm.dts   | 2 +-
 arch/arm/dts/dra72-evm-common.dtsi  | 6 +++---
 arch/arm/dts/keystone-k2e-evm.dts   | 2 +-
 arch/arm/dts/keystone-k2hk-evm.dts  | 2 +-
 arch/arm/dts/keystone-k2l-evm.dts   | 2 +-
 arch/arm/dts/omap3-beagle-xm.dts| 4 ++--
 arch/arm/dts/omap3-beagle.dts   | 6 +++---
 arch/arm/dts/omap3-igep0020-common.dtsi | 2 +-
 arch/arm/dts/omap3-panel-sharp-ls037v7dw01.dtsi | 2 +-
 arch/arm/dts/omap34xx.dtsi  | 2 +-
 arch/arm/dts/omap36xx.dtsi  | 2 +-
 arch/arm/dts/omap4-panda-common.dtsi| 6 +++---
 arch/arm/dts/omap4-sdp.dts  | 8 
 arch/arm/dts/omap5-board-common.dtsi| 4 ++--
 20 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/arch/arm/dts/am3517-evm-ui.dtsi b/arch/arm/dts/am3517-evm-ui.dtsi
index e841918c1c..54aa2522aa 100644
--- a/arch/arm/dts/am3517-evm-ui.dtsi
+++ b/arch/arm/dts/am3517-evm-ui.dtsi
@@ -186,14 +186,14 @@
 };
 
  {
-   status = "ok";
+   status = "okay";
#sound-dai-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <_pins>;
 };
 
  {
-   status = "ok";
+   status = "okay";
#sound-dai-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <_pins>;
diff --git a/arch/arm/dts/am3517-evm.dts b/arch/arm/dts/am3517-evm.dts
index 3527c0f2df..935c471c97 100644
--- a/arch/arm/dts/am3517-evm.dts
+++ b/arch/arm/dts/am3517-evm.dts
@@ -193,7 +193,7 @@
 };
 
  {
-   status = "ok";
+   status = "okay";
 
pinctrl-names = "default";
pinctrl-0 = <_dpi_pins>;
diff --git a/arch/arm/dts/am437x-gp-evm.dts b/arch/arm/dts/am437x-gp-evm.dts
index 3c500d52db..21f7691f49 100644
--- a/arch/arm/dts/am437x-gp-evm.dts
+++ b/arch/arm/dts/am437x-gp-evm.dts
@@ -742,7 +742,7 @@
 };
 
  {
-   status = "ok";
+   status = "okay";
 
pinctrl-names = "default";
pinctrl-0 = <_pins>;
diff --git a/arch/arm/dts/am43x-epos-evm.dts b/arch/arm/dts/am43x-epos-evm.dts
index 65f157ed59..b940bc6ccf 100644
--- a/arch/arm/dts/am43x-epos-evm.dts
+++ b/arch/arm/dts/am43x-epos-evm.dts
@@ -752,7 +752,7 @@
 };
 
  {
-   status = "ok";
+   status = "okay";
 
pinctrl-names = "default";
pinctrl-0 = <_pins>;
diff --git a/arch/arm/dts/am57xx-beagle-x15-common.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-common.dtsi
index d6b94d528f..1912ea9a15 100644
--- a/arch/arm/dts/am57xx-beagle-x15-common.dtsi
+++ b/arch/arm/dts/am57xx-beagle-x15-common.dtsi
@@ -528,13 +528,13 @@
 };
 
  {
-   status = "ok";
+   status = "okay";
 
vdda_video-supply = <_reg>;
 };
 
  {
-   status = "ok";
+   status = "okay";
vdda-supply = <_reg>;
 
port {
@@ -545,7 +545,7 @@
 };
 
 _rc {
-   status = "ok";
+   status = "okay";
gpios = < 8 GPIO_ACTIVE_LOW>;
 };
 
diff --git a/arch/arm/dts/da850-evm.dts b/arch/arm/dts/da850-evm.dts
index f04bc3e153..b331cefd18 100644
--- a/arch/arm/dts/da850-evm.dts
+++ b/arch/arm/dts/da850-evm.dts
@@ -405,7 +405,7 @@
  {
pinctrl-names = "default";
pinctrl-0 = <_pins>;
-   status = "ok";
+   status = "okay";
cs3 {
#address-cells = <2>;
#size-cells = <1>;
diff --git a/arch/arm/dts/dra7-evm.dts b/arch/arm/dts/dra7-evm.dts
index 43de9638e3..8e9a1a80a8 100644
--- a/arch/arm/dts/dra7-evm.dts
+++ b/arch/arm/dts/dra7-evm.dts
@@ -501,7 +501,7 @@
 };
 
  {
-   status = "ok";
+   status = "okay";
pinctrl-names = "default", "sleep", "active";
pinctrl-0 = <_pins_sleep>;
pinctrl-1 = <_pins_sleep>;
diff --git a/arch/arm/dts/dra72-evm-common.dtsi 
b/arch/arm/dts/dra72-evm-common.dtsi
index 2e485a13df..964e5e9b90 100644
--- a/arch/arm/dts/dra72-evm-common.dtsi
+++ b/arch/arm/dts/dra72-evm-common.dtsi
@@ -430,7 +430,7 @@
 };
 
  {
-   status = "ok";
+   status = "okay";
pinctrl-names = "default", "sleep", "active";
pinctrl-0 = <_pins_sleep>;
pinctrl-1 = <_pins_sleep>;
@@ -499,11 +499,11 @@
 };
 
  {
-   status = "ok";
+   status = "okay";
 };
 
  {
-   status = "ok";
+   status = "okay";
 
port {
hdmi_out: endpoint {
diff --git a/arch/arm/dts/keystone-k2e-evm.dts 
b/arch/arm/dts/keystone-k2e-evm.dts
index 9288df21ce..bb197e133e 100644
--- 

Re: status="ok" treated as disabled by DM

2021-08-20 Thread Roger Quadros



On 19/08/2021 14:37, Nishanth Menon wrote:
> On 14:03-20210819, Roger Quadros wrote:
>> Hi,
>>
>> If the device tree node has status="ok" then the u-boot DM will treat the 
>> device as disabled.
>> There are still quite many devices using "ok" instead of "okay" or no status 
>> and those devices will not be bound.
>>
>> What is the right fix?
>> 1) make u-boot DM to treat satus="ok" as enabled.
>> 2) fix device tree by changing "ok" to "okay".
>>
>> cheers,
>> -roger
> https://github.com/devicetree-org/dt-schema/blob/master/schemas/dt-core.yaml#L36
> 
> 
> I believe, the correct fix is (2) change the dt to "okay".
> 

Also in u-boot code it does mention to fix DT node status to "okay".
https://elixir.bootlin.com/u-boot/v2021.07/source/lib/fdtdec.c#L278

--
cheers,
-roger


Re: [PATCH] nand: vf610_nfc: Do not abuse CONFIG namespace

2021-08-20 Thread Bin Meng
On Fri, Aug 20, 2021 at 1:56 AM Tom Rini  wrote:
>
> This driver uses the CONFIG namespace to set the chips internal CONFIG
> namespace related bits.  However, CONFIG is reserved for the top-level
> Kconfig based configuration system.  Use CFG as the namespace here
> instead to avoid pollution.
>
> Signed-off-by: Tom Rini 
> ---
>  drivers/mtd/nand/raw/vf610_nfc.c | 54 
>  1 file changed, 27 insertions(+), 27 deletions(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH] spi: altera_spi: Do not abuse CONFIG namespace

2021-08-20 Thread Bin Meng
On Fri, Aug 20, 2021 at 3:07 AM Tom Rini  wrote:
>
> The value CONFIG_ALTERA_SPI_IDLE_VAL is never re-defined by a board.
> Rename this to ALTERA_SPI_IDLE_VAL.
>
> Signed-off-by: Tom Rini 
> ---
>  drivers/spi/altera_spi.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH] video: Remove ati_radeon_fb

2021-08-20 Thread Bin Meng
On Fri, Aug 20, 2021 at 3:08 AM Tom Rini  wrote:
>
> This driver is currently unused.  Remove.
>
> Signed-off-by: Tom Rini 
> ---
>  drivers/video/Makefile|1 -
>  drivers/video/ati_ids.h   |  211 
>  drivers/video/ati_radeon_fb.c |  761 -
>  drivers/video/ati_radeon_fb.h |  282 -
>  include/radeon.h  | 1988 -
>  5 files changed, 3243 deletions(-)
>  delete mode 100644 drivers/video/ati_ids.h
>  delete mode 100644 drivers/video/ati_radeon_fb.c
>  delete mode 100644 drivers/video/ati_radeon_fb.h
>  delete mode 100644 include/radeon.h
>

Reviewed-by: Bin Meng 


Re: [PATCH] mpc83xx: Update comment

2021-08-20 Thread Bin Meng
On Fri, Aug 20, 2021 at 3:15 AM Tom Rini  wrote:
>
> Update the comment here to refer to PCI_CONFIG_ADDRESS rather than
> CONFIG_ADDRESS.
>
> Signed-off-by: Tom Rini 
> ---
>  include/mpc83xx.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH] i8042: Do not abuse CONFIG namespace

2021-08-20 Thread Bin Meng
On Fri, Aug 20, 2021 at 2:58 AM Tom Rini  wrote:
>
> This driver uses the CONFIG namespace to set the chips internal CONFIG
> namespace related bits.  However, CONFIG is reserved for the top-level
> Kconfig based configuration system.  Use CFG as the namespace here
> instead to avoid pollution.
>
> Signed-off-by: Tom Rini 
> ---
>  drivers/input/i8042.c |  4 ++--
>  include/i8042.h   | 12 ++--
>  2 files changed, 8 insertions(+), 8 deletions(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH v3 1/2] imx8mm-evk: Generate a single bootable flash.bin again

2021-08-20 Thread Marcel Ziswiler
On Fri, 2021-08-20 at 07:41 +0200, Heiko Thiery wrote:
> 
> ...
> 
> When building from a clean checkout I see the following warnings. It
> seems that there are some dependency checks that are looking for the
> files in mkimage config file.
> 
>   AR  arch/arm/lib/lib.a
>   AS  arch/arm/lib/crt0_aarch64_efi.o
>   CC  arch/arm/lib/reloc_aarch64_efi.o
> WARNING 'mkimage.spl.mkimage' not found, resulting binary is not-functional
>   AS  arch/arm/mach-imx/imx8m/lowlevel_init.o
>   CC  arch/arm/mach-imx/imx8m/clock_slice.o
>   CC  arch/arm/mach-imx/imx8m/soc.o
>     :
>     :
>   AS  spl/arch/arm/lib/crt0_aarch64_efi.o
>   CC  spl/arch/arm/lib/reloc_aarch64_efi.o
> WARNING 'mkimage.spl.mkimage' not found, resulting binary is not-functional
>   AS  spl/arch/arm/mach-imx/imx8m/lowlevel_init.o
>   CC  spl/arch/arm/mach-imx/imx8m/clock_slice.o
>   CC  spl/arch/arm/mach-imx/imx8m/soc.o
>     :
>     :
>   COPY    spl/u-boot-spl.bin
>   SYM spl/u-boot-spl.sym
> WARNING 'mkimage.spl.mkimage' not found, resulting binary is not-functional
> make[1]: Nothing to be done for 'SPL'.
>   OBJCOPY u-boot.srec
>   OBJCOPY u-boot-nodtb.bin

Yes, I believe it really requires explicitly setting the filename as I 
previously suggested.


https://marc.info/?l=u-boot=162940109314578


Re: [PATCH v3 2/2] Makefile: Clean the i.MX8MM artifacts

2021-08-20 Thread Heiko Thiery
Hi,

Am Fr., 20. Aug. 2021 um 07:34 Uhr schrieb Heiko Thiery
:
>
> Hi Fabio,
>
> Am Do., 19. Aug. 2021 um 21:28 Uhr schrieb Fabio Estevam :
> >
> > Clean the binaries generated by binman on imx8mm-evk:
> > spl.* mkimage*.mkimage imx-boot.*
> >
> > Reported-by: Frieder Schrempf 
> > Signed-off-by: Fabio Estevam 
> > ---
> > Changes since v2:
> > - None. Newly introducedin this series.
> >
> >  Makefile | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 3c8437d21a..7096fdf895 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -2095,7 +2095,8 @@ CLEAN_FILES += include/bmp_logo.h 
> > include/bmp_logo_data.h tools/version.h \
> >boot* u-boot* MLO* SPL System.map fit-dtb.blob* \
> >u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log 
> > \
> >lpc32xx-* bl31.c bl31.elf bl31_*.bin image.map tispl.bin* \
> > -  idbloader.img flash.bin flash.log defconfig keep-syms-lto.c
> > +  idbloader.img flash.bin flash.log defconfig keep-syms-lto.c \
> > +  spl.* mkimage*.mkimage imx-boot.*
>
> it might be useful to use one variable for all BINMAN clean files.
> Otherwise it is difficult to understand by whom the files were
> created.
>
> Something like that:
>
> --- a/Makefile
> +++ b/Makefile
> @@ -2091,12 +2091,14 @@ CLEAN_DIRS  += $(MODVERDIR) \
>$(foreach d, spl tpl, $(patsubst %,$d/%, \
> $(filter-out include, $(shell ls -1 $d 2>/dev/null
>
> +BINMAN_CLEAN_FILES = spl.* mkimage*.mkimage

While looking at it a second time, I noticed that itb.fit.fit and
itb.fit.itb were also created by binman.

-- 
Heiko


binman should create a list of output files

2021-08-20 Thread Heiko Thiery
Hi Simon,

During the discussion on [1] I had the idea if binman could create a
list of all output files, so that it is possible to do a real clean in
the u-boot makefile.

Currently there are not all binaries listed in the files list and
especially during the port of some boards to binman we had some
trouble due to fragments of old/previous builds.

What do you think?

[1] https://lists.denx.de/pipermail/u-boot/2021-August/458530.html

-- 
Heiko


Re: [PATCH 3/4] ARM: dts: at91: sama5d2: fix dtc warning for ohci and ehci

2021-08-20 Thread Alexander Dahl
Hello,

Am Tue, Aug 17, 2021 at 01:29:24PM +0300 schrieb Eugen Hristev:
> Fixed the following DTC build warning (reproducible with W=1)
> 
> arch/arm/dts/at91-sama5d2_icp.dtb: Warning (unit_address_format): 
> /ahb/ohci@0040: unit name should not have leading 0s
> arch/arm/dts/at91-sama5d2_icp.dtb: Warning (unit_address_format): 
> /ahb/ehci@0050: unit name should not have leading 0s
> 
> Signed-off-by: Eugen Hristev 
> ---
>  arch/arm/dts/at91-sama5d27_som1_ek.dts | 4 ++--
>  arch/arm/dts/at91-sama5d2_ptc_ek.dts   | 4 ++--
>  arch/arm/dts/at91-sama5d2_xplained.dts | 4 ++--
>  arch/arm/dts/sama5d2.dtsi  | 4 ++--
>  4 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm/dts/at91-sama5d27_som1_ek.dts 
> b/arch/arm/dts/at91-sama5d27_som1_ek.dts
> index ee851a1bef..efd1a5d197 100644
> --- a/arch/arm/dts/at91-sama5d27_som1_ek.dts
> +++ b/arch/arm/dts/at91-sama5d27_som1_ek.dts
> @@ -68,7 +68,7 @@
>   };
>  
>   ahb {
> - usb1: ohci@0040 {
> + usb1: ohci@40 {
>   num-ports = <3>;
>   atmel,vbus-gpio = < 42 0>;
>   pinctrl-names = "default";
> @@ -76,7 +76,7 @@
>   status = "okay";
>   };
>  
> - usb2: ehci@0050 {
> + usb2: ehci@50 {
>   status = "okay";
>   };
>  
> diff --git a/arch/arm/dts/at91-sama5d2_ptc_ek.dts 
> b/arch/arm/dts/at91-sama5d2_ptc_ek.dts
> index cd3711a02a..f45fb1ef26 100644
> --- a/arch/arm/dts/at91-sama5d2_ptc_ek.dts
> +++ b/arch/arm/dts/at91-sama5d2_ptc_ek.dts
> @@ -76,7 +76,7 @@
>   status = "okay";
>   };
>  
> - usb1: ohci@0040 {
> + usb1: ohci@40 {
>   num-ports = <3>;
>   atmel,vbus-gpio = <0
>   PIN_PB12 GPIO_ACTIVE_HIGH
> @@ -87,7 +87,7 @@
>   status = "okay";
>   };
>  
> - usb2: ehci@0050 {
> + usb2: ehci@50 {
>   status = "okay";
>   };
>  
> diff --git a/arch/arm/dts/at91-sama5d2_xplained.dts 
> b/arch/arm/dts/at91-sama5d2_xplained.dts
> index b733c4d4ce..e7c91c5fec 100644
> --- a/arch/arm/dts/at91-sama5d2_xplained.dts
> +++ b/arch/arm/dts/at91-sama5d2_xplained.dts
> @@ -25,7 +25,7 @@
>   };
>  
>   ahb {
> - usb1: ohci@0040 {
> + usb1: ohci@40 {
>   num-ports = <3>;
>   atmel,vbus-gpio = < 42 0>;
>   pinctrl-names = "default";
> @@ -33,7 +33,7 @@
>   status = "okay";
>   };
>  
> - usb2: ehci@0050 {
> + usb2: ehci@50 {
>   status = "okay";
>   };
>  
> diff --git a/arch/arm/dts/sama5d2.dtsi b/arch/arm/dts/sama5d2.dtsi
> index 6fb2cb25f9..d8a125b073 100644
> --- a/arch/arm/dts/sama5d2.dtsi
> +++ b/arch/arm/dts/sama5d2.dtsi
> @@ -32,7 +32,7 @@
>   #size-cells = <1>;
>   u-boot,dm-pre-reloc;
>  
> - usb1: ohci@0040 {
> + usb1: ohci@40 {
>   compatible = "atmel,at91rm9200-ohci", "usb-ohci";
>   reg = <0x0040 0x10>;
>   clocks = <_clk>, <_clk>, <>;
> @@ -40,7 +40,7 @@
>   status = "disabled";
>   };
>  
> - usb2: ehci@0050 {
> + usb2: ehci@50 {
>   compatible = "atmel,at91sam9g45-ehci", "usb-ehci";
>   reg = <0x0050 0x10>;
>   clocks = <>, <_clk>;

Reviewed-by: Alexander Dahl 

Greets
Alex



Re: [PATCH v6 10/12] watchdog: add gpio watchdog driver

2021-08-20 Thread Rasmus Villemoes
On 19/08/2021 14.32, Wolfgang Denk wrote:

> The existence of bad code is not a justification to add more of it.

Obviously true and I agree.

However, it is at the same time completely irrelevant in this context,
because the pattern of using the return value of dev_get_priv() without
a NULL check is neither bad or wrong, as has now been explained to you
several times.

If you really think checking the return value of dev_get_priv() must be
done religiously, perhaps you could tap Stefan (737c3de09984), Marek
(7e1f1e16fe75), or Heiko (6e31c62a175c) on the shoulder and tell them to
stop cranking out "bad" code.

On 19/08/2021 16.16, Wolfgang Denk wrote:

> I mean, look at the implementation of dev_get_priv():
>
>  628 void *dev_get_priv(const struct udevice *dev)
>  629 {
>  630 if (!dev) {
>  631 dm_warn("%s: null device\n", __func__);
>  632 return NULL;
>  633 }
>  634
>  635 return dm_priv_to_rw(dev->priv_);
>  636 }
>
> If there is guaranteed no way that dev_get_priv() can return a NULL
> pointer, that means that it must be guaranteed that the "dev"
> argument can never be a NULL pointer, either.

There's another logical fallacy right here. Sure, you've found an input
value for which dev_get_priv() would return NULL. But any caller who
knows they're not passing a NULL dev also know they won't follow that
code path.

A driver which doesn't populate the priv field by via a non-zero
.priv_auto field may need to check the return value of dev_get_priv().
I'm not claiming that checking that is always redundant. However,
neither is it anywhere near true that checking is always required.

Rasmus