[PATCH v6 7/7] board: htc: endeavoru: add One X support

2023-06-08 Thread Svyatoslav Ryhel
The HTC One X is a touchscreen-based, slate-sized smartphone
designed and manufactured by HTC that runs the Android operating
system. The One X features a 4.7" display, an Nvidia Tegra 3
quad-core chip, 1 GB of RAM and non-extendable 32 GB of internal
storage. UART-A is default debug port.

Tested-by: Andreas Westman Dorcsak 
Tested-by: Ion Agorria 
Tested-by: Svyatoslav Ryhel 
Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/tegra30-htc-endeavoru.dts| 166 
 arch/arm/mach-tegra/tegra30/Kconfig   |   5 +
 board/htc/endeavoru/Kconfig   |  12 +
 board/htc/endeavoru/MAINTAINERS   |   7 +
 board/htc/endeavoru/Makefile  |  11 +
 board/htc/endeavoru/endeavoru-spl.c   |  47 +++
 board/htc/endeavoru/endeavoru.c   | 116 ++
 board/htc/endeavoru/pinmux-config-endeavoru.h | 362 ++
 configs/endeavoru_defconfig   |  84 
 doc/board/htc/endeavoru.rst   |  90 +
 doc/board/htc/index.rst   |   9 +
 doc/board/index.rst   |   1 +
 include/configs/endeavoru.h   |  65 
 13 files changed, 975 insertions(+)
 create mode 100644 arch/arm/dts/tegra30-htc-endeavoru.dts
 create mode 100644 board/htc/endeavoru/Kconfig
 create mode 100644 board/htc/endeavoru/MAINTAINERS
 create mode 100644 board/htc/endeavoru/Makefile
 create mode 100644 board/htc/endeavoru/endeavoru-spl.c
 create mode 100644 board/htc/endeavoru/endeavoru.c
 create mode 100644 board/htc/endeavoru/pinmux-config-endeavoru.h
 create mode 100644 configs/endeavoru_defconfig
 create mode 100644 doc/board/htc/endeavoru.rst
 create mode 100644 doc/board/htc/index.rst
 create mode 100644 include/configs/endeavoru.h

diff --git a/arch/arm/dts/tegra30-htc-endeavoru.dts 
b/arch/arm/dts/tegra30-htc-endeavoru.dts
new file mode 100644
index 00..c55e193d1d
--- /dev/null
+++ b/arch/arm/dts/tegra30-htc-endeavoru.dts
@@ -0,0 +1,166 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+
+/* This dts file describes the HTC One X smartphone */
+/* CPU Speedo ID 4, Soc Speedo ID 1, CPU Process: 1, Core Process: 0 */
+
+#include 
+
+#include "tegra30.dtsi"
+
+/ {
+   model = "HTC One X";
+   compatible = "htc,endeavoru", "nvidia,tegra30";
+
+   chosen {
+   stdout-path = 
+   };
+
+   aliases {
+   i2c0 = _i2c;
+
+   mmc0 =  /* eMMC */
+
+   rtc0 = 
+   rtc1 = "/rtc@7000e000";
+
+   usb0 = _usb;
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x4000>;
+   };
+
+   host1x@5000 {
+   dc@5420 {
+   clocks = <_car TEGRA30_CLK_DISP1>,
+<_car TEGRA30_CLK_PLL_D_OUT0>;
+
+   rgb {
+   status = "okay";
+
+   nvidia,panel = <>;
+   };
+   };
+
+   dsia: dsi@5430 {
+   status = "okay";
+
+   avdd-dsi-csi-supply = <_dsi_csi>;
+
+   panel = <>;
+   };
+   };
+
+   uarta: serial@70006000 {
+   status = "okay";
+   };
+
+   pwr_i2c: i2c@7000d000 {
+   status = "okay";
+   clock-frequency = <10>;
+
+   /* Texas Instruments TPS80032 PMIC */
+   pmic: tps80032@48 {
+   compatible = "ti,tps80032";
+   reg = <0x48>;
+
+   regulators {
+   /* DSI VDD */
+   avdd_dsi_csi: ldo1 {
+   regulator-name = "avdd_dsi_csi";
+   regulator-min-microvolt = <120>;
+   regulator-max-microvolt = <120>;
+   regulator-always-on;
+   };
+   };
+   };
+   };
+
+   sdmmc4: sdhci@78000600 {
+   status = "okay";
+   bus-width = <8>;
+   non-removable;
+   };
+
+   micro_usb: usb@7d00 {
+   status = "okay";
+   dr_mode = "otg";
+   };
+
+   backlight: backlight {
+   compatible = "nvidia,tegra-pwm-backlight";
+
+   nvidia,pwm-source = <1>;
+   nvidia,default-brightness = <0x8E>;
+   };
+
+   /* PMIC has a built-in 32KHz oscillator which is used by PMC */
+   clk32k_in: clock-32k {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <32768>;
+   clock-output-names = "pmic-oscillator";
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   key-power {
+  

[PATCH v6 4/7] board: asus: transformer: add ASUS Transformer T30 family support

2023-06-08 Thread Svyatoslav Ryhel
The ASUS Transformer T30 family are 2-in-1 detachable tablets
and AiO developed by ASUS that run the Android operating system
(TF600T runs Windows RT and P1801-T runs Android and Windows).
The T30 Transformers feature a 10.1-inch display (apart P1801-T),
an Nvidia Tegra 3 quad-core chip, 1/2 GB of RAM, and 16/32 GB of
storage. Transformers board derives from Nvidia Cardhu development
board.

This patch brings support for 7 known Transformer devices:
- ASUS Transformer Prime TF201
- ASUS Transformer Pad TF300T/TF300TG/TF300TL
- ASUS VivoTab RT TF600T (Windows RT based)
- ASUS Transformer Infinity TF700T
- ASUS Transformer AiO P1801-T

Tested-by: Andreas Westman Dorcsak  # all devices
Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/Makefile |   7 +
 arch/arm/dts/tegra30-asus-p1801-t.dts |  17 +
 arch/arm/dts/tegra30-asus-tf201.dts   |   9 +
 arch/arm/dts/tegra30-asus-tf300t.dts  |  18 +
 arch/arm/dts/tegra30-asus-tf300tg.dts |   9 +
 arch/arm/dts/tegra30-asus-tf300tl.dts |   9 +
 arch/arm/dts/tegra30-asus-tf600t.dts  |  89 +
 arch/arm/dts/tegra30-asus-tf700t.dts  |  13 +
 arch/arm/dts/tegra30-asus-transformer.dtsi| 211 ++
 arch/arm/mach-tegra/tegra30/Kconfig   |   5 +
 board/asus/transformer-t30/Kconfig|  23 ++
 board/asus/transformer-t30/MAINTAINERS|  15 +
 board/asus/transformer-t30/Makefile   |  11 +
 .../pinmux-config-transformer.h   | 365 ++
 .../transformer-t30/transformer-t30-spl.c |  41 ++
 board/asus/transformer-t30/transformer-t30.c  | 201 ++
 configs/p1801-t.config|   2 +
 configs/tf201.config  |   2 +
 configs/tf300t.config |   2 +
 configs/tf300tg.config|   2 +
 configs/tf300tl.config|   2 +
 configs/tf600t.config |   4 +
 configs/tf700t.config |   2 +
 configs/transformer_t30_defconfig |  85 
 doc/board/asus/index.rst  |   9 +
 doc/board/asus/transformer_t30.rst|  96 +
 doc/board/index.rst   |   1 +
 include/configs/transformer-common.h  |  94 +
 include/configs/transformer-t30.h |  23 ++
 29 files changed, 1367 insertions(+)
 create mode 100644 arch/arm/dts/tegra30-asus-p1801-t.dts
 create mode 100644 arch/arm/dts/tegra30-asus-tf201.dts
 create mode 100644 arch/arm/dts/tegra30-asus-tf300t.dts
 create mode 100644 arch/arm/dts/tegra30-asus-tf300tg.dts
 create mode 100644 arch/arm/dts/tegra30-asus-tf300tl.dts
 create mode 100644 arch/arm/dts/tegra30-asus-tf600t.dts
 create mode 100644 arch/arm/dts/tegra30-asus-tf700t.dts
 create mode 100644 arch/arm/dts/tegra30-asus-transformer.dtsi
 create mode 100644 board/asus/transformer-t30/Kconfig
 create mode 100644 board/asus/transformer-t30/MAINTAINERS
 create mode 100644 board/asus/transformer-t30/Makefile
 create mode 100644 board/asus/transformer-t30/pinmux-config-transformer.h
 create mode 100644 board/asus/transformer-t30/transformer-t30-spl.c
 create mode 100644 board/asus/transformer-t30/transformer-t30.c
 create mode 100644 configs/p1801-t.config
 create mode 100644 configs/tf201.config
 create mode 100644 configs/tf300t.config
 create mode 100644 configs/tf300tg.config
 create mode 100644 configs/tf300tl.config
 create mode 100644 configs/tf600t.config
 create mode 100644 configs/tf700t.config
 create mode 100644 configs/transformer_t30_defconfig
 create mode 100644 doc/board/asus/index.rst
 create mode 100644 doc/board/asus/transformer_t30.rst
 create mode 100644 include/configs/transformer-common.h
 create mode 100644 include/configs/transformer-t30.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 480269fa60..c87729d45e 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -237,6 +237,13 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
tegra20-ventana.dtb \
tegra20-colibri.dtb \
tegra30-apalis.dtb \
+   tegra30-asus-p1801-t.dtb \
+   tegra30-asus-tf201.dtb \
+   tegra30-asus-tf300t.dtb \
+   tegra30-asus-tf300tg.dtb \
+   tegra30-asus-tf300tl.dtb \
+   tegra30-asus-tf600t.dtb \
+   tegra30-asus-tf700t.dtb \
tegra30-beaver.dtb \
tegra30-cardhu.dtb \
tegra30-colibri.dtb \
diff --git a/arch/arm/dts/tegra30-asus-p1801-t.dts 
b/arch/arm/dts/tegra30-asus-p1801-t.dts
new file mode 100644
index 00..879373a5e8
--- /dev/null
+++ b/arch/arm/dts/tegra30-asus-p1801-t.dts
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+
+#include "tegra30-asus-transformer.dtsi"
+
+/ {
+   model = "ASUS Transformer AiO P1801-T";
+   compatible = "asus,p1801-t", "nvidia,tegra30";
+
+   /delete-node/ host1x@5000;
+
+   /delete-node/ backlight;
+   /delete-node/ panel;
+
+   

[PATCH v6 6/7] board: lg: x3: add Optimus 4X HD and Optimus Vu support

2023-06-08 Thread Svyatoslav Ryhel
LG X3 is a development board based on Nvidia Tegra 3 SoC
on base of which Optimus 4X HD and Optimus Vu were created.
Both smartphones feature a 4.7" and 5" panels respectively,
an Nvidia Tegra 3 quad-core chip, 1 GB of RAM and 16/32 GB
of internal storage. Optimux 4X HD additionally has a micro
SD slot.

Tested-by: Andreas Westman Dorcsak  # LG P880 T30
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/Makefile   |   2 +
 arch/arm/dts/tegra30-lg-p880.dts|  40 +++
 arch/arm/dts/tegra30-lg-p895.dts|  50 
 arch/arm/dts/tegra30-lg-x3.dtsi | 180 +++
 arch/arm/mach-tegra/tegra30/Kconfig |   5 +
 board/lg/x3-t30/Kconfig |  26 ++
 board/lg/x3-t30/MAINTAINERS |   9 +
 board/lg/x3-t30/Makefile|  11 +
 board/lg/x3-t30/pinmux-config-x3.h  | 449 
 board/lg/x3-t30/x3-t30-spl.c|  48 +++
 board/lg/x3-t30/x3-t30.c| 176 +++
 configs/p880.config |   4 +
 configs/p895.config |   4 +
 configs/x3_t30_defconfig|  88 ++
 doc/board/index.rst |   1 +
 doc/board/lg/index.rst  |   9 +
 doc/board/lg/x3_t30.rst |  93 ++
 include/configs/x3-t30.h|  77 +
 18 files changed, 1272 insertions(+)
 create mode 100644 arch/arm/dts/tegra30-lg-p880.dts
 create mode 100644 arch/arm/dts/tegra30-lg-p895.dts
 create mode 100644 arch/arm/dts/tegra30-lg-x3.dtsi
 create mode 100644 board/lg/x3-t30/Kconfig
 create mode 100644 board/lg/x3-t30/MAINTAINERS
 create mode 100644 board/lg/x3-t30/Makefile
 create mode 100644 board/lg/x3-t30/pinmux-config-x3.h
 create mode 100644 board/lg/x3-t30/x3-t30-spl.c
 create mode 100644 board/lg/x3-t30/x3-t30.c
 create mode 100644 configs/p880.config
 create mode 100644 configs/p895.config
 create mode 100644 configs/x3_t30_defconfig
 create mode 100644 doc/board/lg/index.rst
 create mode 100644 doc/board/lg/x3_t30.rst
 create mode 100644 include/configs/x3-t30.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index f2b4044a01..f31cabc27b 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -250,6 +250,8 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
tegra30-beaver.dtb \
tegra30-cardhu.dtb \
tegra30-colibri.dtb \
+   tegra30-lg-p880.dtb \
+   tegra30-lg-p895.dtb \
tegra30-tec-ng.dtb \
tegra114-dalmore.dtb \
tegra124-apalis.dtb \
diff --git a/arch/arm/dts/tegra30-lg-p880.dts b/arch/arm/dts/tegra30-lg-p880.dts
new file mode 100644
index 00..81d364310d
--- /dev/null
+++ b/arch/arm/dts/tegra30-lg-p880.dts
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+
+#include "tegra30-lg-x3.dtsi"
+
+/ {
+   model = "LG Optimus 4X HD";
+   compatible = "lge,p880", "nvidia,tegra30";
+
+   aliases {
+   mmc1 =  /* uSD slot */
+   };
+
+   sdmmc3: sdhci@78000400  {
+   status = "okay";
+   bus-width = <4>;
+
+   cd-gpios = < TEGRA_GPIO(W, 5) GPIO_ACTIVE_LOW>;
+
+   vmmc-supply = <_usd>;
+   vqmmc-supply = <_1v8_vio>;
+   };
+
+   gpio-keys {
+   key-volume-up {
+   label = "Volume Up";
+   gpios = < TEGRA_GPIO(O, 7) GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+   };
+
+   panel: panel {
+   compatible = "jdi,dx12d100vm0eaa";
+
+   enable-gpios = < TEGRA_GPIO(Y, 0) GPIO_ACTIVE_HIGH>;
+   reset-gpios = < TEGRA_GPIO(W, 0) GPIO_ACTIVE_HIGH>;
+
+   backlight = <>;
+   };
+};
diff --git a/arch/arm/dts/tegra30-lg-p895.dts b/arch/arm/dts/tegra30-lg-p895.dts
new file mode 100644
index 00..074205d5a9
--- /dev/null
+++ b/arch/arm/dts/tegra30-lg-p895.dts
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+
+#include "tegra30-lg-x3.dtsi"
+
+/ {
+   model = "LG Optimus Vu";
+   compatible = "lge,p895", "nvidia,tegra30";
+
+   gpio-keys {
+   key-volume-up {
+   label = "Volume Up";
+   gpios = < TEGRA_GPIO(I, 6) GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+   };
+
+   panel: panel {
+   compatible = "hitachi,tx13d100vm0eaa";
+
+   reset-gpios = < TEGRA_GPIO(W, 0) GPIO_ACTIVE_HIGH>;
+
+   renesas,gamma = <3>;
+   renesas,inversion;
+   renesas,contrast;
+
+   vcc-supply = <_3v0_lcd>;
+   iovcc-supply = <_1v8_lcd>;
+
+   backlight = <>;
+   };
+
+   vcc_3v0_lcd: regulator-lcd {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_3v0_lcd";
+   regulator-min-microvolt = <300>;
+   regulator-max-microvolt = <300>;
+   gpio = < 

[PATCH v6 5/7] board: asus: grouper: add Google Nexus 7 (2012) support

2023-06-08 Thread Svyatoslav Ryhel
Nexus 7 is a mini tablet computer co-developed by Google and Asus
that runs the Android operating system. The Nexus 7 features a 7"
display, an Nvidia Tegra 3 quad-core chip, 1 GB of RAM and 8/16 GB
of internal storage.

This patch brings support for all 3 known ASUS/Google devices:
- Nexus 7 (2012) E1565
- Nexus 7 (2012) PM269
- Nexus 7 (2012) 3G - tilapia

Tested-by: Andreas Westman Dorcsak  # ASUS Grouper E1565
Tested-by: Svyatoslav Ryhel  # ASUS Grouper E1565
Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/Makefile |   3 +
 arch/arm/dts/tegra30-asus-grouper-common.dtsi | 157 
 .../dts/tegra30-asus-nexus7-grouper-E1565.dts |  43 +++
 .../dts/tegra30-asus-nexus7-grouper-PM269.dts |  36 ++
 .../dts/tegra30-asus-nexus7-tilapia-E1565.dts |  62 +++
 arch/arm/mach-tegra/tegra30/Kconfig   |   5 +
 board/asus/grouper/Kconfig|  22 ++
 board/asus/grouper/MAINTAINERS|  10 +
 board/asus/grouper/Makefile   |  14 +
 board/asus/grouper/grouper-spl-max.c  |  45 +++
 board/asus/grouper/grouper-spl-ti.c   |  41 ++
 board/asus/grouper/grouper.c  | 202 ++
 board/asus/grouper/pinmux-config-grouper.h| 362 ++
 configs/grouper_E1565.config  |   2 +
 configs/grouper_PM269.config  |   2 +
 configs/grouper_common_defconfig  |  84 
 configs/tilapia.config|   3 +
 doc/board/asus/grouper_common.rst |  95 +
 doc/board/asus/index.rst  |   1 +
 include/configs/grouper.h |  61 +++
 20 files changed, 1250 insertions(+)
 create mode 100644 arch/arm/dts/tegra30-asus-grouper-common.dtsi
 create mode 100644 arch/arm/dts/tegra30-asus-nexus7-grouper-E1565.dts
 create mode 100644 arch/arm/dts/tegra30-asus-nexus7-grouper-PM269.dts
 create mode 100644 arch/arm/dts/tegra30-asus-nexus7-tilapia-E1565.dts
 create mode 100644 board/asus/grouper/Kconfig
 create mode 100644 board/asus/grouper/MAINTAINERS
 create mode 100644 board/asus/grouper/Makefile
 create mode 100644 board/asus/grouper/grouper-spl-max.c
 create mode 100644 board/asus/grouper/grouper-spl-ti.c
 create mode 100644 board/asus/grouper/grouper.c
 create mode 100644 board/asus/grouper/pinmux-config-grouper.h
 create mode 100644 configs/grouper_E1565.config
 create mode 100644 configs/grouper_PM269.config
 create mode 100644 configs/grouper_common_defconfig
 create mode 100644 configs/tilapia.config
 create mode 100644 doc/board/asus/grouper_common.rst
 create mode 100644 include/configs/grouper.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index c87729d45e..f2b4044a01 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -237,6 +237,9 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
tegra20-ventana.dtb \
tegra20-colibri.dtb \
tegra30-apalis.dtb \
+   tegra30-asus-nexus7-grouper-PM269.dtb \
+   tegra30-asus-nexus7-grouper-E1565.dtb \
+   tegra30-asus-nexus7-tilapia-E1565.dtb \
tegra30-asus-p1801-t.dtb \
tegra30-asus-tf201.dtb \
tegra30-asus-tf300t.dtb \
diff --git a/arch/arm/dts/tegra30-asus-grouper-common.dtsi 
b/arch/arm/dts/tegra30-asus-grouper-common.dtsi
new file mode 100644
index 00..4fa980f24f
--- /dev/null
+++ b/arch/arm/dts/tegra30-asus-grouper-common.dtsi
@@ -0,0 +1,157 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include 
+
+#include "tegra30.dtsi"
+
+/ {
+   chosen {
+   stdout-path = 
+   };
+
+   aliases {
+   i2c0 = _i2c;
+
+   mmc0 =  /* eMMC */
+
+   rtc0 = 
+   rtc1 = "/rtc@7000e000";
+
+   usb0 = 
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x4000>;
+   };
+
+   host1x@5000 {
+   dc@5420 {
+   nvidia,180-rotation;
+   rgb {
+   status = "okay";
+
+   nvidia,panel = <>;
+   };
+   };
+   };
+
+   gpio@6000d000 {
+   volume-buttons-hog {
+   gpio-hog;
+   gpios = ,
+   ;
+   output-low;
+   };
+   };
+
+   uarta: serial@70006000 {
+   status = "okay";
+   };
+
+   pwm: pwm@7000a000 {
+   status = "okay";
+   };
+
+   pwr_i2c: i2c@7000d000 {
+   status = "okay";
+   clock-frequency = <40>;
+   };
+
+   sdmmc4: sdhci@78000600 {
+   status = "okay";
+   bus-width = <8>;
+   non-removable;
+   };
+
+   usb1: usb@7d00 {
+   status = "okay";
+   dr_mode = "otg";
+   };
+
+   backlight: backlight {
+   compatible = 

[PATCH v6 3/7] ARM: tegra: add SoC UID calculation function

2023-06-08 Thread Svyatoslav Ryhel
This is a small tool for calculation of SoC UID based on the same
Linux function. It can be further used for generation of device
unique data like mac address or exposing it as serial number.

Tested-by: Andreas Westman Dorcsak  # ASUS Grouper E1565
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/include/asm/arch-tegra/fuse.h |   7 ++
 arch/arm/mach-tegra/Makefile   |   4 +
 arch/arm/mach-tegra/fuse.c | 151 +
 3 files changed, 162 insertions(+)
 create mode 100644 arch/arm/mach-tegra/fuse.c

diff --git a/arch/arm/include/asm/arch-tegra/fuse.h 
b/arch/arm/include/asm/arch-tegra/fuse.h
index 5b8e0bd8d1..f3f2ad8e3f 100644
--- a/arch/arm/include/asm/arch-tegra/fuse.h
+++ b/arch/arm/include/asm/arch-tegra/fuse.h
@@ -19,4 +19,11 @@ struct fuse_regs {
u32 security_mode;  /* 0x1A0: FUSE_SECURITY_MODE */
 };
 
+/**
+ * Calculate SoC UID
+ *
+ * Return: uid if ok, 0 on error
+ */
+unsigned long long tegra_chip_uid(void);
+
 #endif /* ifndef _FUSE_H_ */
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index 9147050b32..a5733b0bf6 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -32,6 +32,10 @@ endif
 obj-$(CONFIG_DISPLAY_CPUINFO) += sys_info.o
 obj-y += pmc.o
 
+ifndef CONFIG_TEGRA186
+obj-y += fuse.o
+endif
+
 obj-$(CONFIG_TEGRA20) += tegra20/
 obj-$(CONFIG_TEGRA30) += tegra30/
 obj-$(CONFIG_TEGRA114) += tegra114/
diff --git a/arch/arm/mach-tegra/fuse.c b/arch/arm/mach-tegra/fuse.c
new file mode 100644
index 00..83bd505538
--- /dev/null
+++ b/arch/arm/mach-tegra/fuse.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  (C) Copyright 2012-2013
+ *  NVIDIA Corporation 
+ *
+ *  (C) Copyright 2022
+ *  Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "cpu.h"
+
+#define FUSE_UID_LOW   0x108
+#define FUSE_UID_HIGH  0x10c
+
+#define FUSE_VENDOR_CODE   0x200
+#define FUSE_FAB_CODE  0x204
+#define FUSE_LOT_CODE_00x208
+#define FUSE_LOT_CODE_10x20c
+#define FUSE_WAFER_ID  0x210
+#define FUSE_X_COORDINATE  0x214
+#define FUSE_Y_COORDINATE  0x218
+
+#define FUSE_VENDOR_CODE_MASK  0xf
+#define FUSE_FAB_CODE_MASK 0x3f
+#define FUSE_WAFER_ID_MASK 0x3f
+#define FUSE_X_COORDINATE_MASK 0x1ff
+#define FUSE_Y_COORDINATE_MASK 0x1ff
+
+static u32 tegra_fuse_readl(unsigned long offset)
+{
+   return readl(NV_PA_FUSE_BASE + offset);
+}
+
+static void tegra_fuse_init(void)
+{
+   u32 reg;
+
+   /*
+* Performed by downstream and is not
+* documented by TRM. Whithout setting
+* this bit fuse region will not work.
+*/
+   reg = readl_relaxed(NV_PA_CLK_RST_BASE + 0x48);
+   reg |= BIT(28);
+   writel(reg, NV_PA_CLK_RST_BASE + 0x48);
+
+   clock_enable(PERIPH_ID_FUSE);
+   udelay(2);
+   reset_set_enable(PERIPH_ID_FUSE, 0);
+}
+
+unsigned long long tegra_chip_uid(void)
+{
+   u64 uid = 0ull;
+   u32 reg;
+   u32 cid;
+   u32 vendor;
+   u32 fab;
+   u32 lot;
+   u32 wafer;
+   u32 x;
+   u32 y;
+   u32 i;
+
+   tegra_fuse_init();
+
+   /* This used to be so much easier in prior chips. Unfortunately, there
+  is no one-stop shopping for the unique id anymore. It must be
+  constructed from various bits of information burned into the fuses
+  during the manufacturing process. The 64-bit unique id is formed
+  by concatenating several bit fields. The notation used for the
+  various fields is  with the UID composed
+  thusly:
+  
+  Where:
+   FieldBits  Position Data
+   ---     
+   CID4 60 Chip id
+   VENDOR 4 56 Vendor code
+   FAB6 50 FAB code
+   LOT   26 24 Lot code (5-digit base-36-coded-decimal,
+   re-encoded to 26 bits binary)
+   WAFER  6 18 Wafer id
+   X  9  9 Wafer X-coordinate
+   Y  9  0 Wafer Y-coordinate
+   ---  
+   Total 64
+   */
+
+   switch (tegra_get_chip()) {
+   case CHIPID_TEGRA20:
+   /* T20 has simple calculation */
+   return ((unsigned long long)tegra_fuse_readl(FUSE_UID_HIGH) << 
32ull) |
+   (unsigned long long)tegra_fuse_readl(FUSE_UID_LOW);
+   case CHIPID_TEGRA30:
+   /* T30 chip id is 0 */
+   cid = 0;
+   break;
+   case CHIPID_TEGRA114:
+   /* T11x chip id is 1 */
+   cid = 1;
+   break;
+   case CHIPID_TEGRA124:
+   /* 

[PATCH v6 2/7] configs: tegra-common-post: make PXE and DHCP boot targets optional

2023-06-08 Thread Svyatoslav Ryhel
From: Jonas Schwöbel 

Disabling the network related features in defconfig causes build to
fail so make them optional.

Tested-by: Andreas Westman Dorcsak  # ASUS Grouper E1565
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Jonas Schwöbel 
Signed-off-by: Svyatoslav Ryhel 
---
 include/configs/tegra-common-post.h | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/include/configs/tegra-common-post.h 
b/include/configs/tegra-common-post.h
index 2d5095639a..0d0965ecce 100644
--- a/include/configs/tegra-common-post.h
+++ b/include/configs/tegra-common-post.h
@@ -8,9 +8,21 @@
 #define __TEGRA_COMMON_POST_H
 
 #if IS_ENABLED(CONFIG_CMD_USB)
-# define BOOT_TARGET_USB(func) func(USB, usb, 0)
+#define BOOT_TARGET_USB(func) func(USB, usb, 0)
 #else
-# define BOOT_TARGET_USB(func)
+#define BOOT_TARGET_USB(func)
+#endif
+
+#if CONFIG_IS_ENABLED(CMD_DHCP) && CONFIG_IS_ENABLED(CMD_PXE)
+#define BOOT_TARGET_PXE(func) func(PXE, pxe, na)
+#else
+#define BOOT_TARGET_PXE(func)
+#endif
+
+#if CONFIG_IS_ENABLED(CMD_DHCP)
+#define BOOT_TARGET_DHCP(func) func(DHCP, dhcp, na)
+#else
+#define BOOT_TARGET_DHCP(func)
 #endif
 
 #ifndef BOOT_TARGET_DEVICES
@@ -18,8 +30,8 @@
func(MMC, mmc, 1) \
func(MMC, mmc, 0) \
BOOT_TARGET_USB(func) \
-   func(PXE, pxe, na) \
-   func(DHCP, dhcp, na)
+   BOOT_TARGET_PXE(func) \
+   BOOT_TARGET_DHCP(func)
 #endif
 #include 
 
-- 
2.39.2



[PATCH v6 0/7] Tegra: add ASUS/Google Nexus 7 (2012) support

2023-06-08 Thread Svyatoslav Ryhel
This patchset adds support for native use of U-Boot on:
- ASUS T30 Transformers (7 devices, all models);
- ASUS/Google Nexus 7 (2012), both grouper and tilapia
- LG Optimus 4X HD (P880) and Optimus Vu (P895)
- HTC One X (endeavoru)
as a replacement for the vendor bootloader.

Current commits are designed to work on re-crypted devices but can
be used on clean unmodified devices with slight restrictions (like
no booting/mounting emmc and no self updating feature).

All device setup commits fall under the same pattern. Alongside device
bringup tegra requires few small patches:
 - add gpio keyboard as stdin device
 - make networking boot options optional
 - add a small tool to generate SoC UID

Commits passed ./tools/buildman/buildman tegra
Building current source for 30 boards (12 threads, 1 job per thread)
   3000 /30 0:00:06  : apalis_t30
Completed: 30 total built, 30 newly), duration 0:05:23, rate 0.09

Passed 50/53 GitLab CI Pipelines and then I ran off CI minures. 

---
Changes from v5:
- fixed maintained files inclusion

Changes from v4:
- fixed documentation
- fixed CONFIG_* definitions

Changes from v3:
- extended amount of devices supported

Changes from v2:
 - fuse build is excluded for T186 (it is not supported in it anyway)

Changes from v1:
 - fix fuse headers for newer Tegra generations
 - allow grouper_common_defconfig to pass without fragments
---

Jonas Schwöbel (1):
  configs: tegra-common-post: make PXE and DHCP boot targets optional

Svyatoslav Ryhel (6):
  configs: tegra-common-post: add GPIO keyboard as STDIN device
  ARM: tegra: add SoC UID calculation function
  board: asus: transformer: add ASUS Transformer T30 family support
  board: asus: grouper: add Google Nexus 7 (2012) support
  board: lg: x3: add Optimus 4X HD and Optimus Vu support
  board: htc: endeavoru: add One X support

 arch/arm/dts/Makefile |  12 +
 arch/arm/dts/tegra30-asus-grouper-common.dtsi | 157 ++
 .../dts/tegra30-asus-nexus7-grouper-E1565.dts |  43 ++
 .../dts/tegra30-asus-nexus7-grouper-PM269.dts |  36 ++
 .../dts/tegra30-asus-nexus7-tilapia-E1565.dts |  62 +++
 arch/arm/dts/tegra30-asus-p1801-t.dts |  17 +
 arch/arm/dts/tegra30-asus-tf201.dts   |   9 +
 arch/arm/dts/tegra30-asus-tf300t.dts  |  18 +
 arch/arm/dts/tegra30-asus-tf300tg.dts |   9 +
 arch/arm/dts/tegra30-asus-tf300tl.dts |   9 +
 arch/arm/dts/tegra30-asus-tf600t.dts  |  89 
 arch/arm/dts/tegra30-asus-tf700t.dts  |  13 +
 arch/arm/dts/tegra30-asus-transformer.dtsi| 211 
 arch/arm/dts/tegra30-htc-endeavoru.dts| 166 +++
 arch/arm/dts/tegra30-lg-p880.dts  |  40 ++
 arch/arm/dts/tegra30-lg-p895.dts  |  50 ++
 arch/arm/dts/tegra30-lg-x3.dtsi   | 180 +++
 arch/arm/include/asm/arch-tegra/fuse.h|   7 +
 arch/arm/mach-tegra/Makefile  |   4 +
 arch/arm/mach-tegra/fuse.c| 151 ++
 arch/arm/mach-tegra/tegra30/Kconfig   |  20 +
 board/asus/grouper/Kconfig|  22 +
 board/asus/grouper/MAINTAINERS|  10 +
 board/asus/grouper/Makefile   |  14 +
 board/asus/grouper/grouper-spl-max.c  |  45 ++
 board/asus/grouper/grouper-spl-ti.c   |  41 ++
 board/asus/grouper/grouper.c  | 202 
 board/asus/grouper/pinmux-config-grouper.h| 362 ++
 board/asus/transformer-t30/Kconfig|  23 +
 board/asus/transformer-t30/MAINTAINERS|  15 +
 board/asus/transformer-t30/Makefile   |  11 +
 .../pinmux-config-transformer.h   | 365 ++
 .../transformer-t30/transformer-t30-spl.c |  41 ++
 board/asus/transformer-t30/transformer-t30.c  | 201 
 board/htc/endeavoru/Kconfig   |  12 +
 board/htc/endeavoru/MAINTAINERS   |   7 +
 board/htc/endeavoru/Makefile  |  11 +
 board/htc/endeavoru/endeavoru-spl.c   |  47 ++
 board/htc/endeavoru/endeavoru.c   | 116 +
 board/htc/endeavoru/pinmux-config-endeavoru.h | 362 ++
 board/lg/x3-t30/Kconfig   |  26 +
 board/lg/x3-t30/MAINTAINERS   |   9 +
 board/lg/x3-t30/Makefile  |  11 +
 board/lg/x3-t30/pinmux-config-x3.h| 449 ++
 board/lg/x3-t30/x3-t30-spl.c  |  48 ++
 board/lg/x3-t30/x3-t30.c  | 176 +++
 configs/endeavoru_defconfig   |  84 
 configs/grouper_E1565.config  |   2 +
 configs/grouper_PM269.config  |   2 +
 configs/grouper_common_defconfig  |  84 
 configs/p1801-t.config|   2 +
 configs/p880.config   |   4 +
 configs/p895.config   |   4 +
 configs/tf201.config  |   2 +
 configs/tf300t.config  

[PATCH v6 1/7] configs: tegra-common-post: add GPIO keyboard as STDIN device

2023-06-08 Thread Svyatoslav Ryhel
GPIO keyboard is used on many newly upstreamed devices.

Tested-by: Andreas Westman Dorcsak  # ASUS Grouper E1565
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Svyatoslav Ryhel 
---
 include/configs/tegra-common-post.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/configs/tegra-common-post.h 
b/include/configs/tegra-common-post.h
index 991ffbb7df..2d5095639a 100644
--- a/include/configs/tegra-common-post.h
+++ b/include/configs/tegra-common-post.h
@@ -35,6 +35,12 @@
 #define STDIN_KBD_USB ""
 #endif
 
+#ifdef CONFIG_BUTTON_KEYBOARD
+#define STDIN_BTN_KBD ",button-kbd"
+#else
+#define STDIN_BTN_KBD ""
+#endif
+
 #ifdef CONFIG_VIDEO
 #define STDOUT_VIDEO ",vidconsole"
 #else
@@ -48,7 +54,7 @@
 #endif
 
 #define TEGRA_DEVICE_SETTINGS \
-   "stdin=serial" STDIN_KBD_KBC STDIN_KBD_USB STDOUT_CROS_EC "\0" \
+   "stdin=serial" STDIN_KBD_KBC STDIN_KBD_USB STDOUT_CROS_EC STDIN_BTN_KBD 
"\0" \
"stdout=serial" STDOUT_VIDEO "\0" \
"stderr=serial" STDOUT_VIDEO "\0" \
""
-- 
2.39.2



Re: [PATCH] phy: phy-imx8mq-usb: add vbus regulator support

2023-06-08 Thread Adam Ford
On Thu, Jun 8, 2023 at 8:29 PM Tim Harvey  wrote:
>
> Add support for enabling and disabling vbus-supply regulator found
> on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.
>
> Without this I suspect U-Boot usb does not work on the following:
>  - imx8mp-beacon-kit

The Host-only port works on the Beacon board, but the dual-role, usb
type-c port doesn't appear to have been impacted.  I am guessing it's
due to the lack of a proper type-c driver. Despite that,  I think it's
the right thing to do for this platform, and I'll give some feedback
below.

>  - imx8mp-msc-sm2s
>  - imx8mp-verdin-wifi-dev
>

Reviewed-by: Adam Ford 

> Signed-off-by: Tim Harvey 
> ---
>  drivers/phy/phy-imx8mq-usb.c | 24 ++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/phy/phy-imx8mq-usb.c b/drivers/phy/phy-imx8mq-usb.c
> index 69f01de55538..eed9c07848f4 100644
> --- a/drivers/phy/phy-imx8mq-usb.c
> +++ b/drivers/phy/phy-imx8mq-usb.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define PHY_CTRL0  0x0
>  #define PHY_CTRL0_REF_SSP_EN   BIT(2)
> @@ -81,6 +82,7 @@ struct imx8mq_usb_phy {
>  #endif
> void __iomem *base;
> enum imx8mpq_phy_type type;
> +   struct udevice *vbus_supply;
>  };
>
>  static const struct udevice_id imx8mq_usb_phy_of_match[] = {
> @@ -173,9 +175,9 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
> struct udevice *dev = usb_phy->dev;
> struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> u32 value;
> +   int ret;

In the unlikely event that neither CONFIG_CLK nor CONFIG_DM_REGULATOR
is configured, will defining ret here throw a compiler warning that
it's unused? I wonder if __maybe_unused attribute would be permissible
here or if this should be inside an #if statement.

>
>  #if CONFIG_IS_ENABLED(CLK)
> -   int ret;
> ret = clk_enable(_phy->phy_clk);
> if (ret) {
> printf("Failed to enable usb phy clock\n");
> @@ -183,6 +185,12 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
> }
>  #endif
>
> +   if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> +   ret = regulator_set_enable(imx_phy->vbus_supply, true);
> +   if (ret)

I am personally a fan of error messages.  There is an error message if
the clock fails, so unless there is an objection, can we have one here
too?  One was also added to the probe function.

> +   return ret;
> +   }
> +
> /* Disable rx term override */
> value = readl(imx_phy->base + PHY_CTRL6);
> value &= ~PHY_CTRL6_RXTERM_OVERRIDE_SEL;
> @@ -206,6 +214,9 @@ static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
> clk_disable(_phy->phy_clk);
>  #endif
>
> +   if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply)
> +   return regulator_set_enable(imx_phy->vbus_supply, false);
> +
> return 0;
>  }
>
> @@ -224,6 +235,7 @@ struct phy_ops imx8mq_usb_phy_ops = {
>  int imx8mq_usb_phy_probe(struct udevice *dev)
>  {
> struct imx8mq_usb_phy *priv = dev_get_priv(dev);
> +   int ret;

Same comment as above regarding whether or not this might be unused.
>
> priv->type = dev_get_driver_data(dev);
> priv->base = dev_read_addr_ptr(dev);
> @@ -232,7 +244,6 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
> return -EINVAL;
>
>  #if CONFIG_IS_ENABLED(CLK)
> -   int ret;
>
> /* Assigned clock already set clock */
> ret = clk_get_by_name(dev, "phy", >phy_clk);
> @@ -242,6 +253,15 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
> }
>  #endif
>
> +   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
> +   ret = device_get_supply_regulator(dev, "vbus-supply",
> + >vbus_supply);
> +   if (ret && ret != -ENOENT) {
> +   pr_err("Failed to get PHY regulator\n");
> +   return ret;
> +   }
> +   }
> +
> return 0;
>  }
>
> --
> 2.25.1
>


[PATCH] phy: phy-imx8mq-usb: add vbus regulator support

2023-06-08 Thread Tim Harvey
Add support for enabling and disabling vbus-supply regulator found
on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.

Without this I suspect U-Boot usb does not work on the following:
 - imx8mp-beacon-kit
 - imx8mp-msc-sm2s
 - imx8mp-verdin-wifi-dev

Signed-off-by: Tim Harvey 
---
 drivers/phy/phy-imx8mq-usb.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/phy-imx8mq-usb.c b/drivers/phy/phy-imx8mq-usb.c
index 69f01de55538..eed9c07848f4 100644
--- a/drivers/phy/phy-imx8mq-usb.c
+++ b/drivers/phy/phy-imx8mq-usb.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define PHY_CTRL0  0x0
 #define PHY_CTRL0_REF_SSP_EN   BIT(2)
@@ -81,6 +82,7 @@ struct imx8mq_usb_phy {
 #endif
void __iomem *base;
enum imx8mpq_phy_type type;
+   struct udevice *vbus_supply;
 };
 
 static const struct udevice_id imx8mq_usb_phy_of_match[] = {
@@ -173,9 +175,9 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
struct udevice *dev = usb_phy->dev;
struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
u32 value;
+   int ret;
 
 #if CONFIG_IS_ENABLED(CLK)
-   int ret;
ret = clk_enable(_phy->phy_clk);
if (ret) {
printf("Failed to enable usb phy clock\n");
@@ -183,6 +185,12 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
}
 #endif
 
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
+   ret = regulator_set_enable(imx_phy->vbus_supply, true);
+   if (ret)
+   return ret;
+   }
+
/* Disable rx term override */
value = readl(imx_phy->base + PHY_CTRL6);
value &= ~PHY_CTRL6_RXTERM_OVERRIDE_SEL;
@@ -206,6 +214,9 @@ static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
clk_disable(_phy->phy_clk);
 #endif
 
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply)
+   return regulator_set_enable(imx_phy->vbus_supply, false);
+
return 0;
 }
 
@@ -224,6 +235,7 @@ struct phy_ops imx8mq_usb_phy_ops = {
 int imx8mq_usb_phy_probe(struct udevice *dev)
 {
struct imx8mq_usb_phy *priv = dev_get_priv(dev);
+   int ret;
 
priv->type = dev_get_driver_data(dev);
priv->base = dev_read_addr_ptr(dev);
@@ -232,7 +244,6 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
return -EINVAL;
 
 #if CONFIG_IS_ENABLED(CLK)
-   int ret;
 
/* Assigned clock already set clock */
ret = clk_get_by_name(dev, "phy", >phy_clk);
@@ -242,6 +253,15 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
}
 #endif
 
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
+   ret = device_get_supply_regulator(dev, "vbus-supply",
+ >vbus_supply);
+   if (ret && ret != -ENOENT) {
+   pr_err("Failed to get PHY regulator\n");
+   return ret;
+   }
+   }
+
return 0;
 }
 
-- 
2.25.1



Re: [PATCH v2] usb: musb-new: sunxi: remove unused define

2023-06-08 Thread Marek Vasut

On 6/8/23 20:45, Sam Edwards wrote:

This is a remnant from when the USB controller driver managed
the reset signal itself. A patch from the very end of 2018 changed
this driver to delegate reset (and clock) management to the proper
control unit driver, but left this unused define behind.

Signed-off-by: Sam Edwards 
Reviewed-by: Marek Vasut 
---
  drivers/usb/musb-new/sunxi.c | 2 --
  1 file changed, 2 deletions(-)

diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 2b954601a0..85d815ad75 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -81,8 +81,6 @@
   * From usbc/usbc.c
   
**/
  
-#define OFF_SUN6I_AHB_RESET0	0x2c0

-
  struct sunxi_musb_config {
struct musb_hdrc_config *config;
bool has_sram;


Applied to usb/master, thanks


Re: [PATCH] cmd: usb: Prevent reset in usb tree/info command

2023-06-08 Thread Marek Vasut

On 6/8/23 09:39, Xavier Drudis Ferran wrote:

El Thu, Jun 08, 2023 at 12:05:18AM +0200, Marek Vasut deia:

On 6/5/23 17:20, Xavier Drudis Ferran wrote:

Add a check to avoid dommed (by null pointer dereference) recursive
call, not only for UCLASS_BLK.

When booting my Rock Pi 4B+ with a USB mass storage stick plugged
into one of the USB 2 ports (EHCI), when it is plugged before power
on, when issuing a

usb tree

or

usb info


I cannot reproduce the problem. Do you perform any other interaction with
the USB stack, like e.g. 'usb start' or 'usb reset' before issuing the
aforementioned commands ?



No. Well, in some tests yes and some no, but I got the error in all cases.


This is doubtful. It is mandatory to run 'usb start' or 'usb reset' 
before you would get any meaningful result out of 'usb info'. Without 
either, you would get 'USB is stopped.' message. Could it be there are 
some extra scripts in your environment that manipulate the USB ?



Btw, I was testing on the next branch. I had those two commits on top
https://patchwork.ozlabs.org/project/uboot/patch/202013db5a47ecbac4a53c360ed1ca91ca663996.1685974993.git.xdru...@tinet.cat/
https://patchwork.ozlabs.org/project/uboot/patch/464111fca83008503022e8ada5305e69ffd1afbd.1685974993.git.xdru...@tinet.cat/

And minor configuration changes (but I had bootstage active, might or might not 
be related)

U-Boot was in a microSD card.


Can you test with stock U-Boot ?

Can you test with another USB stick, i.e. is the issue specific to this 
USB stick ?


Is the issue specific to this partition layout of this USB stick, i.e. 
if you clone (dd if=... of=...) the content of the USB stick to another 
USB stick, does the error still occur.


[...]


Model: Radxa ROCK Pi 4B
Net:   eth0: ethernet@fe30
Hit any key to stop autoboot:  2  1  0
rockchip_pcie pcie@f800: PCIe link training gen1 timeout!
Bus usb@fe38: USB EHCI 1.00
Bus usb@fe3c: USB EHCI 1.00
Bus usb@fe80: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
Bus usb@fe90: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe38 for devices... 1 USB Device(s) found
scanning bus usb@fe3c for devices... 2 USB Device(s) found
scanning bus usb@fe80 for devices... 1 USB Device(s) found
scanning bus usb@fe90 for devices... 1 USB Device(s) found
rockchip_pcie pcie@f800: failed to find ep-gpios property
ethernet@fe30 Waiting for PHY auto negotiation to complete. TIMEOUT 
!
Could not initialize PHY ethernet@fe30
rockchip_pcie pcie@f800: failed to find ep-gpios property
ethernet@fe30 Waiting for PHY auto negotiation to complete. TIMEOUT 
!
Could not initialize PHY ethernet@fe30


Is this some $preboot script which initializes your hardware ?

=> printenv preboot


=> usb tree
USB device tree:
   1  Hub (480 Mb/s, 0mA)
  u-boot EHCI Host Controller

   1  Hub (480 Mb/s, 0mA)

   |  u-boot EHCI Host Controller
   |
uclass_id=64
   |+-2  Mass Storage (480 Mb/s, 200mA)
TDK LoR TF10 07032B6B1D0ACB96
  
uclass_id=22

uclass_id=25
  "Synchronous Abort" handler, esr 0x9610, far 0x948
elr: 002157d4 lr : 002157d4 (reloc)
elr: f3f4f7d4 lr : f3f4f7d4


Take the u-boot (unstripped elf) which matches this binary, and run 
aarch64-...objdump -lSD on it, then search for the $lr value, see 
doc/develop/crash_dumps.rst for details. That should tell you where 
exactly the crash occurred. Where did it occur ?



x0 : 0005 x1 : 
x2 : 0020 x3 : ff1a
x4 : ff1a x5 : 
x6 : f1f1c000 x7 : 0001
x8 : 0001 x9 : ffd0
x10: 0006 x11: 0001869f
x12: 0200 x13: 
x14:  x15: f1f1bbc9
x16: 7e4f2113 x17: 9a11f13e
x18: f1f31d80 x19: 
x20: f1f1c110 x21: 0004
x22: f1f1c114 x23: f1f65398
x24: f1f653b8 x25: 
x26:  x27: 
x28:  x29: f1f1c000

Code: aa0003f5 93c0 9123b800 940191f5 (f944a660)
Resetting CPU ...

resetting ...



command I get a "Synchronous Error" and a reset just after printing the
mass storage device in the usb tree or usb info. It might depend on the
contents of the USB stick too, I'm not sure.

It seems like I have two devices as children of the mass storage
device.  When there's only a UCLASS_BLK it works fine, but when there's
a UCLASS_BLK and a UCLASS_BOOTDEV, it recurses with a null udev as
first parameter and fails.

Likewise for usb_show_info().

Not sure if this should be a patch, an RFC or a bug report.  There may
be a better way to solve this, I haven't researched commit
201417d700a2ab09 ("bootstd: Add the bootdev uclass") and 

Re: rk3328 efuse return just 0

2023-06-08 Thread Jonas Karlman
Hi Marek,

On 2023-06-08 15:06, Belisko Marek wrote:
> Hi,
> 
> I'm using tip of actual master and with this small patches:
> --- a/configs/rock-pi-e-rk3328_defconfig
> +++ b/configs/rock-pi-e-rk3328_defconfig
> @@ -73,6 +73,8 @@ CONFIG_FASTBOOT_BUF_ADDR=0x800800
>  CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
>  CONFIG_ROCKCHIP_GPIO=y
>  CONFIG_SYS_I2C_ROCKCHIP=y
> +CONFIG_MISC=y
> +CONFIG_ROCKCHIP_EFUSE=y
>  CONFIG_MMC_DW=y
>  CONFIG_MMC_DW_ROCKCHIP=y
>  CONFIG_ETH_DESIGNWARE=y
> 
> --- a/configs/rock-pi-e-rk3328_defconfig
> +++ b/configs/rock-pi-e-rk3328_defconfig
> @@@ -45,8 -34,6 +45,7 @@@ CONFIG_SPL_I2C=
>   CONFIG_SPL_POWER=y
>   CONFIG_SPL_ATF=y
>   CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
>  +CONFIG_TPL_SYS_MALLOC_SIMPLE=y
> - CONFIG_TPL_DRIVERS_MISC=y
>   CONFIG_CMD_BOOTZ=y
>   CONFIG_CMD_GPT=y
>   CONFIG_CMD_MMC=y
> 
> as for the following issue:
> /home/marek/data/projects/u-boot/drivers/misc/rockchip-efuse.c:273:(.text.rockchip_efuse_of_to_plat+0x1c):
> relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol
> `dev_read_addr_ptr'
> 
> I'm trying to enable proper ethaddr handling (as in this case cpuid# is
> used for ethaddr generation).
> 
> With those enabled options I'm still getting an cpuid# variable set to all
> '0'. Is there some other fix necessary maybe?

I was able to reproduce this issue on my Rock Pi E using plain mainline
arm-trusted-firmware. To use efuse on RK3328 the efuse block needs to be
initialized, u-boot does not do this.

Two options to work around this can be:
1. Use vendor bl31 blob from [1]
2. Patch mainline atf with a patch from [2]

[1] 
https://github.com/rockchip-linux/rkbin/blob/master/bin/rk33/rk322xh_bl31_v1.49.elf
[2] 
https://github.com/armbian/build/blob/main/patch/atf/atf-rockchip64/rk3328-efuse-init.patch

Regards,
Jonas

> 
> Thanks and BR,
> 
> marek



[PULL] u-boot-usb/master

2023-06-08 Thread Marek Vasut
The following changes since commit 0a8a4b86422650d6955a2382796089735453902d:

  Merge tag 'u-boot-amlogic-20230607' of 
https://source.denx.de/u-boot/custodians/u-boot-amlogic (2023-06-07 12:17:06 
-0400)

are available in the Git repository at:

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

for you to fetch changes up to e10f96414934edaca958e4323f82149a030e56a4:

  usb: musb-new: sunxi: remove unused define (2023-06-08 21:57:01 +0200)


Sam Edwards (2):
  usb: musb-new: sunxi: fix error check
  usb: musb-new: sunxi: remove unused define

Xavier Drudis Ferran (2):
  phy: rockchip-inno-usb2: Add usb2phy clock provider of 480MHz clock
  phy: rockchip-inno-usb2: Implement clock operations for usb2phy clock

 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 109 +-
 drivers/usb/musb-new/sunxi.c  |   4 +-
 2 files changed, 107 insertions(+), 6 deletions(-)


Re: [PATCH v2 8/8] configs: am62x_evm_*: Enable USB and DFU support

2023-06-08 Thread Marcel Ziswiler
Hi Sjoerd

Thanks for this series.

On Thu, 2023-04-06 at 20:55 +0200, Sjoerd Simons wrote:
> Enable USB host as well as USB gadget and DFU support for a53; For the
> r5 due to the smaller available size create a new config just for
> DFU support
> 
> Signed-off-by: Sjoerd Simons 

With the nitpick about CONFIG_USB_XHCI_DWC3 (needs to be removed) below.

Tested-by: Marcel Ziswiler 

I tested both USB device aka gadget (with DFU and UMS) as well as USB host on 
both the TI AM625 EVM aka SK as
well as the Toradex Verdin AM62 [1] (plus USB integration analogous to EVM/SK 
to be posted later).

[1] https://lore.kernel.org/all/20230607120639.82087-1-mar...@ziswiler.com/

> ---
> 
> Changes in v2:
> - Create a seperate defconfig for R5
> 
>  configs/am62x_evm_a53_defconfig   |  35 +++-
>  configs/am62x_evm_r5_usbdfu_defconfig | 116 ++
>  2 files changed, 148 insertions(+), 3 deletions(-)
>  create mode 100644 configs/am62x_evm_r5_usbdfu_defconfig
> 
> diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
> index cc9c8eab3e3..7dbf2f54050 100644
> --- a/configs/am62x_evm_a53_defconfig
> +++ b/configs/am62x_evm_a53_defconfig
> @@ -1,5 +1,6 @@
>  CONFIG_ARM=y
>  CONFIG_ARCH_K3=y
> +CONFIG_SYS_MALLOC_LEN=0x200
>  CONFIG_SYS_MALLOC_F_LEN=0x8000
>  CONFIG_SPL_LIBCOMMON_SUPPORT=y
>  CONFIG_SPL_LIBGENERIC_SUPPORT=y
> @@ -9,9 +10,11 @@ CONFIG_K3_ATF_LOAD_ADDR=0x9e78
>  CONFIG_TARGET_AM625_A53_EVM=y
>  CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
>  CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8048
> +CONFIG_SF_DEFAULT_SPEED=2500
>  CONFIG_SPL_DM_SPI=y
>  CONFIG_DEFAULT_DEVICE_TREE="k3-am625-sk"
>  CONFIG_SPL_TEXT_BASE=0x8008
> +CONFIG_OF_LIBFDT_OVERLAY=y
>  CONFIG_DM_RESET=y
>  CONFIG_SPL_MMC=y
>  CONFIG_SPL_SERIAL=y
> @@ -33,17 +36,23 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
>  CONFIG_SPL_STACK_R=y
>  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
>  CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
> +CONFIG_SPL_ENV_SUPPORT=y
>  CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
>  CONFIG_SPL_DM_MAILBOX=y
>  CONFIG_SPL_DM_SPI_FLASH=y
>  CONFIG_SPL_POWER_DOMAIN=y
> +CONFIG_SPL_RAM_SUPPORT=y
> +CONFIG_SPL_RAM_DEVICE=y
>  # CONFIG_SPL_SPI_FLASH_TINY is not set
>  CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
>  CONFIG_SPL_SPI_LOAD=y
>  CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
> +CONFIG_SPL_USB_GADGET=y
> +CONFIG_SPL_DFU=y
>  CONFIG_SPL_YMODEM_SUPPORT=y
> -CONFIG_SYS_BOOTM_LEN=0x80
> +CONFIG_CMD_DFU=y
>  CONFIG_CMD_MMC=y
> +CONFIG_CMD_USB=y
>  CONFIG_OF_CONTROL=y
>  CONFIG_SPL_OF_CONTROL=y
>  CONFIG_MULTI_DTB_FIT=y
> @@ -54,10 +63,17 @@ CONFIG_SPL_DM=y
>  CONFIG_SPL_DM_SEQ_ALIAS=y
>  CONFIG_REGMAP=y
>  CONFIG_SPL_REGMAP=y
> +CONFIG_SYSCON=y
> +CONFIG_SPL_SYSCON=y
>  CONFIG_SPL_OF_TRANSLATE=y
>  CONFIG_CLK=y
>  CONFIG_SPL_CLK=y
>  CONFIG_CLK_TI_SCI=y
> +CONFIG_DFU_MMC=y
> +CONFIG_DFU_RAM=y
> +CONFIG_DFU_SF=y
> +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x5000
> +CONFIG_SYS_DFU_MAX_FILE_SIZE=0x80
>  CONFIG_DMA_CHANNELS=y
>  CONFIG_TI_K3_NAVSS_UDMA=y
>  CONFIG_TI_SCI_PROTOCOL=y
> @@ -68,7 +84,6 @@ CONFIG_MMC_SDHCI_ADMA=y
>  CONFIG_SPL_MMC_SDHCI_ADMA=y
>  CONFIG_MMC_SDHCI_AM654=y
>  CONFIG_DM_SPI_FLASH=y
> -CONFIG_SF_DEFAULT_SPEED=2500
>  CONFIG_SPI_FLASH_SFDP_SUPPORT=y
>  CONFIG_SPI_FLASH_SOFT_RESET=y
>  CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
> @@ -96,5 +111,19 @@ CONFIG_CADENCE_QSPI=y
>  CONFIG_SYSRESET=y
>  CONFIG_SPL_SYSRESET=y
>  CONFIG_SYSRESET_TI_SCI=y
> +CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
> +CONFIG_SPL_DM_USB_GADGET=y
> +CONFIG_USB_XHCI_HCD=y
> +CONFIG_USB_XHCI_DWC3=y

I believe the above got superseded by CONFIG_USB_DWC3_AM62 further below, not?

At least in my testing it always crashed as follows unless I removed 
CONFIG_USB_XHCI_DWC3:

=> usb start
starting USB...
Bus usb@3100: generic_phy_get_bulk : no phys property
Register 1000840 NbrPorts 1
Starting the controller
USB XHCI 1.10
Bus usb@3110: generic_phy_get_bulk : no phys property
Register 1000840 NbrPorts 1
Starting the controller
USB XHCI 1.10
Bus usb@3110: generic_phy_get_bulk : no phys property
Register 1000840 NbrPorts 1
Starting the controller
USB XHCI 1.10
scanning bus usb@3100 for devices... 1 USB Device(s) found
scanning bus usb@3110 for devices... XHCI timeout on event type 33... 
cannot recover.
BUG at drivers/usb/host/xhci-ring.c:496/xhci_wait_for_event()!
BUG!
resetting ...
System reset not supported on this platform
### ERROR ### Please RESET the board ###

> +CONFIG_USB_DWC3=y
> +CONFIG_USB_DWC3_GENERIC=y
> +CONFIG_SPL_USB_DWC3_GENERIC=y
> +CONFIG_SPL_USB_DWC3_AM62=y
> +CONFIG_USB_DWC3_AM62=y
> +CONFIG_USB_GADGET=y
> +CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
> +CONFIG_USB_GADGET_VENDOR_NUM=0x0451
> +CONFIG_USB_GADGET_PRODUCT_NUM=0x6165
> +CONFIG_USB_GADGET_DOWNLOAD=y
>  CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
> -CONFIG_OF_LIBFDT_OVERLAY=y
> diff --git a/configs/am62x_evm_r5_usbdfu_defconfig 
> b/configs/am62x_evm_r5_usbdfu_defconfig
> new file mode 100644
> index 000..00a0821b6df
> --- 

[PULL] u-boot-sh/master_soc/fixes

2023-06-08 Thread Marek Vasut
The following changes since commit 661332a0744dad6a1a4bfbbdea2a4e5ae9835e52:

  Merge https://source.denx.de/u-boot/custodians/u-boot-sunxi (2023-06-07 
22:05:16 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-sh.git master_soc/fixes

for you to fetch changes up to b597b6f9861c2d5531b0055249622ee0e663577c:

  pinctrl: renesas: r8a779a0: Remove incorrect AVB[01] pinmux configuration 
(2023-06-08 22:22:38 +0200)


Hai Pham (2):
  ARM: rmobile: Identify R-Car D3 R8A77995 r1.1 SoC
  pinctrl: renesas: r8a779a0: Remove incorrect AVB[01] pinmux configuration

Hiroyuki Yokoyama (1):
  ARM: rmobile: Identify R-Car M3-W R8A7796 r1.1/1.2 SoC

 arch/arm/mach-rmobile/cpu_info-rcar.c  | 6 --
 arch/arm/mach-rmobile/cpu_info.c   | 7 +++
 drivers/pinctrl/renesas/pfc-r8a779a0.c | 8 
 3 files changed, 11 insertions(+), 10 deletions(-)


[PULL] u-boot-sh/next_soc/v3x

2023-06-08 Thread Marek Vasut
The following changes since commit 3aa4fb12f4abd31bce7fe6294dd47fd0966a791a:

  Merge tag 'efi-next-20230608' of 
https://source.denx.de/u-boot/custodians/u-boot-efi into next (2023-06-08 
11:19:27 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-sh.git next_soc/v3x

for you to fetch changes up to ed2f65f0105dacb98e5c4d2b435dd009de06c2d1:

  ARM: renesas: Add R8A77980 V3HSK board and CPLD code (2023-06-08 22:26:52 
+0200)


Marek Vasut (6):
  ARM: rmobile: Deduplicate R-Car Gen3/Gen4 reset_cpu()
  ARM: rmobile: Reduce R-Car E3 Ebisu header usage
  ARM: rmobile: Reduce R-Car V3H Condor header usage
  ARM: rmobile: Factor out common R-Car V3M/V3H board code
  ARM: rmobile: Drop eagle.h config of R8A77970 V3M Eagle board
  ARM: rmobile: Introduce weak default board_init()

Valentine Barshak (4):
  ARM: dts: renesas: Add R8A77970 V3MSK DTs
  ARM: renesas: Add R8A77970 V3MSK board and CPLD code
  ARM: dts: renesas: Add R8A77980 V3HSK DTs
  ARM: renesas: Add R8A77980 V3HSK board and CPLD code

 arch/arm/dts/Makefile  |   2 +
 arch/arm/dts/r8a77970-v3msk-u-boot.dts |  65 ++
 arch/arm/dts/r8a77970-v3msk.dts| 303 +++
 arch/arm/dts/r8a77980-v3hsk-u-boot.dts |  42 
 arch/arm/dts/r8a77980-v3hsk.dts| 292 ++
 arch/arm/mach-rmobile/Kconfig.rcar3|  12 ++
 board/renesas/condor/Makefile  |   2 +-
 board/renesas/condor/condor.c  |  47 -
 board/renesas/draak/draak.c|   9 -
 board/renesas/eagle/Kconfig|   2 +-
 board/renesas/eagle/Makefile   |   2 +-
 board/renesas/eagle/eagle.c|  92 -
 board/renesas/ebisu/Makefile   |   2 +-
 board/renesas/ebisu/ebisu.c|  45 
 board/renesas/falcon/falcon.c  |   7 -
 board/renesas/rcar-common/common.c |  42 
 board/renesas/rcar-common/v3-common.c  |  41 
 board/renesas/salvator-x/salvator-x.c  |  13 +-
 board/renesas/spider/spider.c  |   5 -
 board/renesas/v3hsk/Kconfig|  15 ++
 board/renesas/v3hsk/Makefile   |  15 ++
 board/renesas/v3hsk/cpld.c | 180 
 board/renesas/v3msk/Kconfig|  15 ++
 board/renesas/v3msk/MAINTAINERS|   6 +
 board/renesas/v3msk/Makefile   |  15 ++
 board/renesas/v3msk/cpld.c | 368 +
 board/renesas/whitehawk/whitehawk.c|   5 -
 configs/r8a77970_v3msk_defconfig   |  87 
 configs/r8a77980_v3hsk_defconfig   |  83 
 doc/README.rmobile |   1 +
 include/configs/eagle.h|  19 --
 include/configs/v3hsk.h|  28 +++
 32 files changed, 1618 insertions(+), 244 deletions(-)
 create mode 100644 arch/arm/dts/r8a77970-v3msk-u-boot.dts
 create mode 100644 arch/arm/dts/r8a77970-v3msk.dts
 create mode 100644 arch/arm/dts/r8a77980-v3hsk-u-boot.dts
 create mode 100644 arch/arm/dts/r8a77980-v3hsk.dts
 delete mode 100644 board/renesas/condor/condor.c
 delete mode 100644 board/renesas/eagle/eagle.c
 delete mode 100644 board/renesas/ebisu/ebisu.c
 create mode 100644 board/renesas/rcar-common/v3-common.c
 create mode 100644 board/renesas/v3hsk/Kconfig
 create mode 100644 board/renesas/v3hsk/Makefile
 create mode 100644 board/renesas/v3hsk/cpld.c
 create mode 100644 board/renesas/v3msk/Kconfig
 create mode 100644 board/renesas/v3msk/MAINTAINERS
 create mode 100644 board/renesas/v3msk/Makefile
 create mode 100644 board/renesas/v3msk/cpld.c
 create mode 100644 configs/r8a77970_v3msk_defconfig
 create mode 100644 configs/r8a77980_v3hsk_defconfig
 delete mode 100644 include/configs/eagle.h
 create mode 100644 include/configs/v3hsk.h


[PATCH v2 2/2] usb: musb-new: sunxi: make compatible with UDC/DM gadget model

2023-06-08 Thread Sam Edwards
Since many sunxi boards do not implement a `board_usb_init`, it's
better if we just make the sunxi USB driver compatible with the
DM gadget model, as many other musb-new variants already are.

This change has been verified working on a T113s.

Signed-off-by: Sam Edwards 
---
 drivers/usb/musb-new/sunxi.c | 50 +++-
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 510b254f7d..6658cd995d 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -444,6 +444,16 @@ static struct musb_hdrc_config musb_config_h3 = {
.ram_bits   = SUNXI_MUSB_RAM_BITS,
 };
 
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev) {
+   struct sunxi_glue *glue = dev_get_priv(dev);
+   struct musb_host_data *host = >mdata;
+
+   host->host->isr(0, host->host);
+   return 0;
+}
+#endif
+
 static int musb_usb_probe(struct udevice *dev)
 {
struct sunxi_glue *glue = dev_get_priv(dev);
@@ -452,10 +462,6 @@ static int musb_usb_probe(struct udevice *dev)
void *base = dev_read_addr_ptr(dev);
int ret;
 
-#ifdef CONFIG_USB_MUSB_HOST
-   struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
-#endif
-
if (!base)
return -EINVAL;
 
@@ -486,23 +492,31 @@ static int musb_usb_probe(struct udevice *dev)
pdata.platform_ops = _musb_ops;
pdata.config = glue->cfg->config;
 
-#ifdef CONFIG_USB_MUSB_HOST
-   priv->desc_before_addr = true;
+   if (IS_ENABLED(CONFIG_USB_MUSB_HOST)) {
+   struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
+   priv->desc_before_addr = true;
 
-   pdata.mode = MUSB_HOST;
-   host->host = musb_init_controller(, >dev, base);
-   if (!host->host)
-   return -EIO;
+   pdata.mode = MUSB_HOST;
+   host->host = musb_init_controller(, >dev, base);
+   if (!host->host)
+   return -EIO;
 
-   return musb_lowlevel_init(host);
-#else
-   pdata.mode = MUSB_PERIPHERAL;
-   host->host = musb_register(, >dev, base);
-   if (IS_ERR_OR_NULL(host->host))
-   return -EIO;
+   return musb_lowlevel_init(host);
+   } else if (CONFIG_IS_ENABLED(DM_USB_GADGET)) {
+   pdata.mode = MUSB_PERIPHERAL;
+   host->host = musb_init_controller(, >dev, base);
+   if (!host->host)
+   return -EIO;
 
-   return 0;
-#endif
+   return usb_add_gadget_udc(>dev, >host->g);
+   } else {
+   pdata.mode = MUSB_PERIPHERAL;
+   host->host = musb_register(, >dev, base);
+   if (IS_ERR_OR_NULL(host->host))
+   return -EIO;
+
+   return 0;
+   }
 }
 
 static int musb_usb_remove(struct udevice *dev)
-- 
2.39.2



[PATCH v2 1/2] usb: musb-new: sunxi: remove unwanted printfs

2023-06-08 Thread Sam Edwards
Per Marek's feedback, unconditional printfs in the probe function of this
USB controller driver should be removed.

This patch also slightly tidies up the return path, in preparation for
DM support.

Signed-off-by: Sam Edwards 
Cc: Marek Vasut 
---
 drivers/usb/musb-new/sunxi.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index c1c0087f7d..510b254f7d 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -494,19 +494,15 @@ static int musb_usb_probe(struct udevice *dev)
if (!host->host)
return -EIO;
 
-   ret = musb_lowlevel_init(host);
-   if (!ret)
-   printf("Allwinner mUSB OTG (Host)\n");
+   return musb_lowlevel_init(host);
 #else
pdata.mode = MUSB_PERIPHERAL;
host->host = musb_register(, >dev, base);
if (IS_ERR_OR_NULL(host->host))
return -EIO;
 
-   printf("Allwinner mUSB OTG (Peripheral)\n");
+   return 0;
 #endif
-
-   return ret;
 }
 
 static int musb_usb_remove(struct udevice *dev)
-- 
2.39.2



[PATCH v2 0/2] sunxi, usb: UDC/DM gadget model support

2023-06-08 Thread Sam Edwards
Happy Thursday, U-Boot list!

Here is attempt 2 at making this USB controller driver compatible with
DM's gadget model, following what most of the other musb variants do.

v2 removes the unwanted printfs in the probe func, per feedback from Marek.
I received no other feedback against v1 of this patch.

Cheers,
Sam

Sam Edwards (2):
  usb: musb-new: sunxi: remove unwanted printfs
  usb: musb-new: sunxi: make compatible with UDC/DM gadget model

 drivers/usb/musb-new/sunxi.c | 52 +---
 1 file changed, 31 insertions(+), 21 deletions(-)

-- 
2.39.2



Re: [PATCH v1] dt-bindings: riscv: deprecate riscv,isa

2023-06-08 Thread Conor Dooley
On Thu, Jun 08, 2023 at 01:15:37PM -0600, Rob Herring wrote:
> On Tue, May 30, 2023 at 03:12:12PM +0100, Conor Dooley wrote:
> > On Thu, May 18, 2023 at 10:42:34PM +0100, Conor Dooley wrote:
> > > On Thu, May 18, 2023 at 02:30:53PM -0400, Sean Anderson wrote:
> > 
> > > > 
> > > > Why not just have something like
> > > > 
> > > > mycpu {
> > > > ...
> > > > riscv,isa {
> > > > i;
> > > > m;
> > > > a;
> > > > zicsr;
> > > > ...
> 
> I prefer property names be globally unique. The tools are geared towards 
> that too. That's largely a symptom of having 0 type information in the 
> DT.
> 
> For example if you had an extension called 'reg', it would be a problem.

Per the current ISA rules, that'd not be valid. But then again, I do
have trust issues & it's not like "reg" is the only property name in DT
land.

> > > Naming of the node aside (perhaps that could be riscv,isa-extensions)
> > > there's not something hitting me immediately as to why that is a no-no.
> > > If the size is a concern, this would certainly be more efficient & not
> > > like the probing would be anything other than trivial more difficult
> > > what I have in my proposal.
> > 
> > Having started messing around with this, one of the main advantages, to
> > me, of this approach is proper validation.
> > cpus.yaml has additionalProperties: true in it, which would have had to
> > be sorted out, or worked around, but creating a child-node with the
> > properties in it allows setting additionalProperties: false.
> 
> That's an issue on my radar to fix. I started that for the Arm cpus.yaml 
> a while back. Sadly it involves adding all the misc properties vendors 
> added. It's not a lot, but still better to get in front of that for 
> Risc-V.

Yeah, guess I can append that to my todo list.

> > > Rob's AFK at the moment, and I was hoping that he would take a look at
> > > the idea, so I won't respin til he is back, but I'll give this a go in
> > > the interim.
> > 
> > Mechanically, the conversion of the patch isn't difficult, but I'll still
> > wait for Rob to come back before sending a v2. But that v2 will more
> > than likely implement your suggestion.
> 
> I haven't read the whole thread, but the initial proposal looks okay to 
> me.
> 
> Another way you could do this is a list of strings:
> 
> riscv,isa-ext = "i", "m", "zicsr";
> 
> I think we have a helper to test is a string in the list.

Perhaps I should've waited a bit longer than a month for a v2 - I sent
one this afternoon doing what Sean suggested:
https://lore.kernel.org/all/20230608-sitting-bath-31eddc03c5a5@spud/

I'll do some poking at the strings and see what I think of it.

Cheers,
Conor.


signature.asc
Description: PGP signature


Re: [PATCH v1] dt-bindings: riscv: deprecate riscv,isa

2023-06-08 Thread Rob Herring
On Tue, May 30, 2023 at 03:12:12PM +0100, Conor Dooley wrote:
> On Thu, May 18, 2023 at 10:42:34PM +0100, Conor Dooley wrote:
> > On Thu, May 18, 2023 at 02:30:53PM -0400, Sean Anderson wrote:
> 
> > > 
> > > Why not just have something like
> > > 
> > > mycpu {
> > >   ...
> > >   riscv,isa {
> > >   i;
> > >   m;
> > >   a;
> > >   zicsr;
> > >   ...

I prefer property names be globally unique. The tools are geared towards 
that too. That's largely a symptom of having 0 type information in the 
DT.

For example if you had an extension called 'reg', it would be a problem.

> > >   };
> > > };
> >
> > Naming of the node aside (perhaps that could be riscv,isa-extensions)
> > there's not something hitting me immediately as to why that is a no-no.
> > If the size is a concern, this would certainly be more efficient & not
> > like the probing would be anything other than trivial more difficult
> > what I have in my proposal.
> 
> Having started messing around with this, one of the main advantages, to
> me, of this approach is proper validation.
> cpus.yaml has additionalProperties: true in it, which would have had to
> be sorted out, or worked around, but creating a child-node with the
> properties in it allows setting additionalProperties: false.

That's an issue on my radar to fix. I started that for the Arm cpus.yaml 
a while back. Sadly it involves adding all the misc properties vendors 
added. It's not a lot, but still better to get in front of that for 
Risc-V.

> > Rob's AFK at the moment, and I was hoping that he would take a look at
> > the idea, so I won't respin til he is back, but I'll give this a go in
> > the interim.
> 
> Mechanically, the conversion of the patch isn't difficult, but I'll still
> wait for Rob to come back before sending a v2. But that v2 will more
> than likely implement your suggestion.

I haven't read the whole thread, but the initial proposal looks okay to 
me.

Another way you could do this is a list of strings:

riscv,isa-ext = "i", "m", "zicsr";

I think we have a helper to test is a string in the list.

Rob


Re: [PATCH v5 4/7] board: asus: transformer: add ASUS Transformer T30 family support

2023-06-08 Thread Svyatoslav Ryhel
чт, 8 черв. 2023 р. о 20:09 Tom Rini  пише:
>
> On Thu, Jun 08, 2023 at 07:54:54PM +0300, Svyatoslav Ryhel wrote:
> > чт, 8 черв. 2023 р. о 19:40 Tom Rini  пише:
> > >
> > > On Thu, Jun 08, 2023 at 06:11:57PM +0300, Svyatoslav Ryhel wrote:
> > > > вт, 6 черв. 2023 р. о 22:47 Tom Rini  пише:
> > > > >
> > > > > On Tue, Jun 06, 2023 at 10:40:53PM +0300, Svyatoslav Ryhel wrote:
> > > > > >
> > > > > >
> > > > > > 6 червня 2023 р. 22:19:44 GMT+03:00, Tom Rini  
> > > > > > написав(-ла):
> > > > > > >On Tue, Jun 06, 2023 at 10:18:47AM +0300, Svyatoslav Ryhel wrote:
> > > > > > >
> > > > > > >> The ASUS Transformer T30 family are 2-in-1 detachable tablets
> > > > > > >> and AiO developed by ASUS that run the Android operating system
> > > > > > >> (TF600T runs Windows RT and P1801-T runs Android and Windows).
> > > > > > >> The T30 Transformers feature a 10.1-inch display (apart P1801-T),
> > > > > > >> an Nvidia Tegra 3 quad-core chip, 1/2 GB of RAM, and 16/32 GB of
> > > > > > >> storage. Transformers board derives from Nvidia Cardhu 
> > > > > > >> development
> > > > > > >> board.
> > > > > > >>
> > > > > > >> This patch brings support for 7 known Transformer devices:
> > > > > > >> - ASUS Transformer Prime TF201
> > > > > > >> - ASUS Transformer Pad TF300T/TF300TG/TF300TL
> > > > > > >> - ASUS VivoTab RT TF600T (Windows RT based)
> > > > > > >> - ASUS Transformer Infinity TF700T
> > > > > > >> - ASUS Transformer AiO P1801-T
> > > > > > >>
> > > > > > >> Tested-by: Andreas Westman Dorcsak  # all 
> > > > > > >> devices
> > > > > > >> Signed-off-by: Svyatoslav Ryhel 
> > > > > > >> ---
> > > > > > >>  arch/arm/dts/Makefile |   7 +
> > > > > > >>  arch/arm/dts/tegra30-asus-p1801-t.dts |  17 +
> > > > > > >>  arch/arm/dts/tegra30-asus-tf201.dts   |   9 +
> > > > > > >>  arch/arm/dts/tegra30-asus-tf300t.dts  |  18 +
> > > > > > >>  arch/arm/dts/tegra30-asus-tf300tg.dts |   9 +
> > > > > > >>  arch/arm/dts/tegra30-asus-tf300tl.dts |   9 +
> > > > > > >>  arch/arm/dts/tegra30-asus-tf600t.dts  |  89 +
> > > > > > >>  arch/arm/dts/tegra30-asus-tf700t.dts  |  13 +
> > > > > > >>  arch/arm/dts/tegra30-asus-transformer.dtsi| 211 ++
> > > > > > >>  arch/arm/mach-tegra/tegra30/Kconfig   |   5 +
> > > > > > >>  board/asus/transformer-t30/Kconfig|  23 ++
> > > > > > >>  board/asus/transformer-t30/MAINTAINERS|   6 +
> > > > > > >>  board/asus/transformer-t30/Makefile   |  11 +
> > > > > > >>  .../pinmux-config-transformer.h   | 365 
> > > > > > >> ++
> > > > > > >>  .../transformer-t30/transformer-t30-spl.c |  41 ++
> > > > > > >>  board/asus/transformer-t30/transformer-t30.c  | 201 ++
> > > > > > >>  configs/p1801-t.config|   2 +
> > > > > > >>  configs/tf201.config  |   2 +
> > > > > > >>  configs/tf300t.config |   2 +
> > > > > > >>  configs/tf300tg.config|   2 +
> > > > > > >>  configs/tf300tl.config|   2 +
> > > > > > >>  configs/tf600t.config |   4 +
> > > > > > >>  configs/tf700t.config |   2 +
> > > > > > >>  configs/transformer_t30_defconfig |  85 
> > > > > > >
> > > > > > >Sorry for not noticing this part sooner.  Looking in the kernel,
> > > > > > >arch/{riscv,powerpc}/Makefile both provide examples of how to 
> > > > > > >automate
> > > > > > >generating the resulting defconfigs directly. I think we really 
> > > > > > >want
> > > > > > >that, and also the config fragments need to be listed in the 
> > > > > > >MAINTAINERS
> > > > > > >file.
> > > > > >
> > > > > > Not sure if adding this is a good idea, plus adding fragments into
> > > > > > MAINTAINERS may cause even more issues. Iirc buildman uses it as a
> > > > > > config source and defining multiple fragments may fail not only for
> > > > > > boards under question, but those, already existing in u-boot, as 
> > > > > > well.
> > > > >
> > > > > If this causes buildman problems then we'll need to figure out
> > > > > something, but it shouldn't.
> > > >
> > > > Adding fragments into MAINTAINERS does not cause issues but seems to
> > > > not have any effect either.
> > >
> > > Well, get_maintainers.pl will now report who owns them, which it didn't
> > > before, yes?
> > >
> >
> > It does report me if get_maintainers.pl is used anyway, even if no
> > files are specified in MAINTAINERS
>
> As maintainer, or as git heuristics?  But all the same, the rule about
> defconfigs needing to be in MAINTAINERS entires should extend to config
> fragments.
>
> > > > > > Issue is not in the arch dir to tweak arch's makefile, fragments are
> > > > > > used by some boards and issue lays in omitting their existence by
> > > > > > system of autobuild.
> > > > >
> > > > > Yes, and I'd like to set some good examples for the 

Re: [PATCH] usb: musb-new: sunxi: remove unused define

2023-06-08 Thread Sam Edwards

Hi Marek,


Please add missing commit message and send V2.


Ah, apologies! I had (mistakenly) believed that the summary line would 
be a sufficient commit message for something so trivial.


Instead I did a little research into how this got here and wrote a quick 
explanation of why it's unused. I figure that would be a bit more 
helpful for someone reading the commit history than just reiterating 
that "It's, y'know, unused." :)



Otherwise

Reviewed-by: Marek Vasut 


Thank you for the speedy review!

Cheers,
Sam


[PATCH v2] usb: musb-new: sunxi: remove unused define

2023-06-08 Thread Sam Edwards
This is a remnant from when the USB controller driver managed
the reset signal itself. A patch from the very end of 2018 changed
this driver to delegate reset (and clock) management to the proper
control unit driver, but left this unused define behind.

Signed-off-by: Sam Edwards 
Reviewed-by: Marek Vasut 
---
 drivers/usb/musb-new/sunxi.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 2b954601a0..85d815ad75 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -81,8 +81,6 @@
  * From usbc/usbc.c
  
**/
 
-#define OFF_SUN6I_AHB_RESET0   0x2c0
-
 struct sunxi_musb_config {
struct musb_hdrc_config *config;
bool has_sram;
-- 
2.39.2



[RFC PATCH v9 10/23] global_data.h: add GD_FLG_HUSH_OLD_PARSER flag

2023-06-08 Thread Francis Laniel
This flag is used to indicate we are using the hush parser.

Reviewed-by: Simon Glass 
Signed-off-by: Francis Laniel 
---
 common/cli.c  | 2 ++
 include/asm-generic/global_data.h | 4 
 2 files changed, 6 insertions(+)

diff --git a/common/cli.c b/common/cli.c
index 3916a7b10a..e5fe1060d0 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -268,6 +268,8 @@ void cli_loop(void)
 void cli_init(void)
 {
 #ifdef CONFIG_HUSH_PARSER
+   if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER))
+   gd->flags |= GD_FLG_HUSH_OLD_PARSER;
u_boot_hush_start();
 #endif
 
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index a1e1b9d640..120f1189ee 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -654,6 +654,10 @@ enum gd_flags {
 * @GD_FLG_OF_TAG_MIGRATE: Device tree has old u-boot,dm- tags
 */
GD_FLG_OF_TAG_MIGRATE = 0x20,
+   /**
+* @GD_FLG_HUSH_OLD_PARSER: Use hush old parser.
+*/
+   GD_FLG_HUSH_OLD_PARSER = 0x40,
 };
 
 #endif /* __ASSEMBLY__ */
-- 
2.34.1



[RFC PATCH v9 21/23] test: hush: Fix loop tests for hush 2021

2023-06-08 Thread Francis Laniel
Modifies return code got from while loop as hush 2021 always returns 0 from
while loop.

Reviewed-by: Simon Glass 
Signed-off-by: Francis Laniel 
---
 test/hush/loop.c | 34 ++
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/test/hush/loop.c b/test/hush/loop.c
index ca777e38fe..add5402a32 100644
--- a/test/hush/loop.c
+++ b/test/hush/loop.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static int hush_test_for(struct unit_test_state *uts)
 {
@@ -21,7 +24,12 @@ static int hush_test_for(struct unit_test_state *uts)
ut_assert_nextline("quux");
ut_assert_console_end();
 
-   puts("Beware: this test set local variable loop_i and it cannot be 
unset!");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* Reset local variable. */
+   ut_assertok(run_command("loop_i=", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   puts("Beware: this test set local variable loop_i and it cannot 
be unset!");
+   }
 
return 0;
 }
@@ -31,12 +39,30 @@ 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));
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* Hush 2021 always returns 0 from while loop...
+* You can see code snippet near this line to have a better
+* understanding:
+* debug_printf_exec(": while expr is false: breaking 
(exitcode:EXIT_SUCCESS)\n");
+*/
+   ut_assertok(run_command("while test -z \"$loop_foo\"; do echo 
bar; loop_foo=quux; done", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   /*
+* 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!");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* Reset local variable. */
+   ut_assertok(run_command("loop_foo=", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   puts("Beware: this test set local variable loop_foo and it 
cannot be unset!");
+   }
 
return 0;
 }
-- 
2.34.1



[RFC PATCH v9 23/23] DO NOT MERGE: only to make CI happy

2023-06-08 Thread Francis Laniel
This commit set CONFIG_HUSH_PARSER_2021 as the default to trigger the CI with
this parser.

Nonetheless, the keymile (i.e. VENDOR_KM) board family is not compatible with
new 2021 hush parser.
Indeed, This boards used set_local_var() to store some variables as local shell.
They then used get_local_var() to retrieve the variables values.
Sadly, this two functions do not exist with CONFIG_HUSH_PARSER_2021.
A patch was proposed to use environment variables rather than local variables
but it does not tackle the problem, so complementary work is needed to make
this boards use CONFIG_HUSH_PARSER_2021 [1].

We also remove a #undef of CONFIG_FEATURE_SH_STANDALONE as it does not exist in
U-Boot and causes troubles in the CI.

We also set CONFIG_LTO for kirkwoord sheevaplug and phytec bk4r1, otherwise it
hits its board size limit.

We also disable some check for pylint as it was not able to find future for
commit object.

Acked-by: Tony Dinh 
Signed-off-by: Francis Laniel 
[1] https://marc.info/?l=u-boot=165541917618725=2
---
 cmd/Kconfig  | 3 ++-
 common/cli_hush_upstream.c   | 1 -
 configs/sheevaplug_defconfig | 1 +
 tools/patman/series.py   | 4 
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index fc4ae40cc3..f5258cc0b0 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -28,7 +28,7 @@ menu "Hush flavor to use"
 
config HUSH_OLD_PARSER
bool "Use hush old parser"
-   default y
+   default y if VENDOR_KM
help
  This option enables the old flavor of hush based on hush 
Busybox from
  2005.
@@ -37,6 +37,7 @@ menu "Hush flavor to use"
 
config HUSH_2021_PARSER
bool "Use hush 2021 parser"
+   default y if !VENDOR_KM
help
  This option enables the new flavor of hush based on hush 
Busybox from
  2021.
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index ab75c55c83..2296cb2699 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -427,7 +427,6 @@
 #include "NUM_APPLETS.h"
 #if NUM_APPLETS == 1
 /* STANDALONE does not make sense, and won't compile */
-# undef CONFIG_FEATURE_SH_STANDALONE
 # undef ENABLE_FEATURE_SH_STANDALONE
 # undef IF_FEATURE_SH_STANDALONE
 # undef IF_NOT_FEATURE_SH_STANDALONE
diff --git a/configs/sheevaplug_defconfig b/configs/sheevaplug_defconfig
index 2e4901b840..365f779cc8 100644
--- a/configs/sheevaplug_defconfig
+++ b/configs/sheevaplug_defconfig
@@ -16,6 +16,7 @@ CONFIG_ENV_OFFSET=0x8
 CONFIG_DEFAULT_DEVICE_TREE="kirkwood-sheevaplug"
 CONFIG_IDENT_STRING="\nMarvell-Sheevaplug"
 CONFIG_SYS_LOAD_ADDR=0x80
+CONFIG_LTO=y
 CONFIG_HAS_BOARD_SIZE_LIMIT=y
 CONFIG_BOARD_SIZE_LIMIT=524288
 CONFIG_BOOTDELAY=3
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 6866e1dbd0..f99818e33a 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -316,6 +316,8 @@ class Series(dict):
 # Show progress any commits that are taking forever
 lastlen = 0
 while True:
+# pylint does not find future which is set above.
+# pylint: disable=E1101
 left = [commit for commit in self.commits
 if not commit.future.done()]
 if not left:
@@ -333,6 +335,8 @@ class Series(dict):
 print('Cc processing complete')
 
 for commit in self.commits:
+# pylint does not find future which is set above.
+# pylint: disable=E1101
 cc = commit.future.result()
 all_ccs += cc
 print(commit.patch, '\0'.join(sorted(set(cc))), file=fd)
-- 
2.34.1



[RFC PATCH v9 22/23] cli: hush_2021: Add upstream commits up to 25th May 2023.

2023-06-08 Thread Francis Laniel
This commit adds the following hush busybox upstream commits:
b5be8da350b5 ("hush: make "false" built-in")
6824298ab4d3 ("hush: fix ELIF cmd1;cmd2 THEN ... not executing cmd2, closes 
15571")
3a7f00eadcf4 ("hush: add comment about abort on syntax error %{^}")
acae889dd972 ("ash,hush: tab completion of functions and aliases")
90b607d79a13 ("hush: quote variable values printed by "set" (match ash 
behavior)")
6748e6494c22 ("hush (NOMMU): fix LINENO in execed children")
fd5fb2d2b596 ("hush: speed up "big heredoc" code")
1409432d072e ("hush: add TODO comment")
93ae7464e6e4 ("hush: restore SIGHUP handling, this time explain why we do what 
we do")
1fdb33bd07e5 ("hush: restore tty pgrp on SIGHUP")
6101b6d3eaa0 ("hush: remove special handling of SIGHUP")
93e0898c663a ("shell: fix SIGWINCH and SIGCHLD (in hush) interrupting line 
input, closes 15256")
969e00816835 ("hush: code shrink")
27be0e8cfeb6 ("shell: fix compile failures in some configs")
7d1c7d833785 ("ash,hush: use HOME for tab completion and prompts")
21afddefd258 ("hush: fix "error: invalid preprocessing directive ##"")
e53c7dbafc78 ("hush: fix set -n to act immediately, not just after run_list()
")
574b9c446da1 ("hush: fix var_LINENO3.tests failure")
49bcf9f40cff ("hush: speed up ${x//\*/|} too")
53b2fdcdba4c ("*: add NOINLINEs where code noticeably shrinks")
7c3e96d4b3d4 ("shell: use more compact SHELL_ASH / HUSH config defines. no code 
changes")
62f1eed1e191 ("hush: in a comment, document what -i might be doing")
aaf3d5ba74c5 ("shell: tweak --help")
db5546ca1018 ("libbb: code shrink: introduce and use [_]exit_SUCCESS()")
931c55f9e2b4 ("libbb: invert the meaning of SETUP_ENV_NO_CHDIR -> 
SETUP_ENV_CHDIR")
12566e7f9b5e ("ash,hush: fix handling of SIGINT while waiting for interactive 
input")
987be932ed3c ("*: slap on a few ALIGN_PTR where appropriate")

Signed-off-by: Francis Laniel 
---
 common/cli_hush_2021.c |   2 +-
 common/cli_hush_upstream.c | 329 -
 2 files changed, 250 insertions(+), 81 deletions(-)

diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c
index 0a207d147b..4c46176cb2 100644
--- a/common/cli_hush_2021.c
+++ b/common/cli_hush_2021.c
@@ -26,7 +26,7 @@
 /*
  * BusyBox Version: UPDATE THIS WHEN PULLING NEW UPSTREAM REVISION!
  */
-#define BB_VER "1.34.0.git37460f5daff9"
+#define BB_VER "1.35.0.git7d1c7d833785"
 
 /*
  * Define hush features by the names used upstream.
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 23392939e1..ab75c55c83 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -339,7 +339,7 @@
  * therefore we don't show them either.
  */
 //usage:#define hush_trivial_usage
-//usage:   "[-enxl] [-c 'SCRIPT' [ARG0 ARGS] | FILE [ARGS] | -s [ARGS]]"
+//usage:   "[-enxl] [-c 'SCRIPT' [ARG0 ARGS] | FILE ARGS | -s ARGS]"
 //usage:#define hush_full_usage "\n\n"
 //usage:   "Unix shell interpreter"
 
@@ -374,7 +374,7 @@
 # define F_DUPFD_CLOEXEC F_DUPFD
 #endif
 
-#if ENABLE_FEATURE_SH_EMBEDDED_SCRIPTS && !(ENABLE_ASH || ENABLE_SH_IS_ASH || 
ENABLE_BASH_IS_ASH)
+#if ENABLE_FEATURE_SH_EMBEDDED_SCRIPTS && !ENABLE_SHELL_ASH
 # include "embedded_scripts.h"
 #else
 # define NUM_SCRIPTS 0
@@ -574,7 +574,7 @@ enum {
 #define NULL_O_STRING { NULL }
 
 #ifndef debug_printf_parse
-static const char *const assignment_flag[] = {
+static const char *const assignment_flag[] ALIGN_PTR = {
"MAYBE_ASSIGNMENT",
"DEFINITELY_ASSIGNMENT",
"NOT_ASSIGNMENT",
@@ -958,6 +958,7 @@ struct globals {
 #if ENABLE_HUSH_INTERACTIVE
smallint promptmode; /* 0: PS1, 1: PS2 */
 #endif
+   /* set by signal handler if SIGINT is received _and_ its trap is not 
set */
smallint flag_SIGINT;
 #ifndef __U_BOOT__
 #if ENABLE_HUSH_LOOPS
@@ -1134,6 +1135,7 @@ static int builtin_export(char **argv) FAST_FUNC;
 #if ENABLE_HUSH_READONLY
 static int builtin_readonly(char **argv) FAST_FUNC;
 #endif
+static int builtin_false(char **argv) FAST_FUNC;
 #if ENABLE_HUSH_JOB
 static int builtin_fg_bg(char **argv) FAST_FUNC;
 static int builtin_jobs(char **argv) FAST_FUNC;
@@ -1234,6 +1236,7 @@ static const struct built_in_command bltins1[] ALIGN_PTR 
= {
 #if ENABLE_HUSH_EXPORT
BLTIN("export"   , builtin_export  , "Set environment variables"),
 #endif
+   BLTIN("false", builtin_false   , NULL),
 #if ENABLE_HUSH_JOB
BLTIN("fg"   , builtin_fg_bg   , "Bring job to foreground"),
 #endif
@@ -1507,6 +1510,7 @@ static void syntax_error_unterm_str(unsigned lineno 
UNUSED_PARAM, const char *s)
 {
bb_error_msg("syntax error: unterminated %s", s);
 //? source4.tests fails: in bash, echo ${^} in script does not terminate the 
script
+// (but bash --posix, or if bash is run as "sh", does terminate in script, so 
maybe uncomment this?)
 // die_if_script();
 }
 
@@ -1918,7 +1922,13 @@ static void restore_G_args(save_arg_t *sv, char **argv)
  * SIGQUIT: ignore
  * SIGTERM 

[RFC PATCH v9 20/23] cli: hush_2021: Enable loops

2023-06-08 Thread Francis Laniel
Enables the use of for, while and until loops for command line as
well as with run_command().

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 common/cli_hush_2021.c |  1 +
 common/cli_hush_upstream.c | 15 ++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c
index aba5dcbbcd..0a207d147b 100644
--- a/common/cli_hush_2021.c
+++ b/common/cli_hush_2021.c
@@ -34,6 +34,7 @@
 #define ENABLE_HUSH_INTERACTIVE1
 #define ENABLE_FEATURE_EDITING 1
 #define ENABLE_HUSH_IF 1
+#define ENABLE_HUSH_LOOPS  1
 /* No MMU in U-Boot */
 #define BB_MMU 0
 #define USE_FOR_NOMMU(...) __VA_ARGS__
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 9b65dcbde1..23392939e1 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -10349,7 +10349,7 @@ static int run_list(struct pipe *pi)
 #ifndef __U_BOOT__
for (; pi; pi = IF_HUSH_LOOPS(rword == RES_DONE ? loop_top : ) 
pi->next) {
 #else /* __U_BOOT__ */
-   for (; pi; pi = pi->next) {
+   for (; pi; pi = rword == RES_DONE ? loop_top : pi->next) {
 #endif /* __U_BOOT__ */
int r;
int sv_errexit_depth;
@@ -10451,7 +10451,20 @@ static int run_list(struct pipe *pi)
}
/* Insert next value from for_lcur */
/* note: *for_lcur already has quotes removed, $var 
expanded, etc */
+#ifndef __U_BOOT__
set_local_var(xasprintf("%s=%s", pi->cmds[0].argv[0], 
*for_lcur++), /*flag:*/ 0);
+#else /* __U_BOOT__ */
+   /* We cannot use xasprintf, so we emulate it. */
+   char *full_var;
+   char *var = pi->cmds[0].argv[0];
+   char *val = *for_lcur++;
+
+   /* + 1 to take into account =. */
+   full_var = xmalloc(strlen(var) + strlen(val) + 1);
+   sprintf(full_var, "%s=%s", var, val);
+
+   set_local_var_2021(full_var, /*flag:*/ 0);
+#endif /* __U_BOOT__ */
continue;
}
if (rword == RES_IN) {
-- 
2.34.1



[RFC PATCH v9 19/23] cli: hush_2021: Enable if keyword

2023-06-08 Thread Francis Laniel
Adds support for "if then else" construct both for command line interface and
through run_command().

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 common/cli_hush_2021.c | 11 +++
 common/cli_hush_upstream.c | 12 
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c
index 7dd30ea0ef..aba5dcbbcd 100644
--- a/common/cli_hush_2021.c
+++ b/common/cli_hush_2021.c
@@ -33,6 +33,7 @@
  */
 #define ENABLE_HUSH_INTERACTIVE1
 #define ENABLE_FEATURE_EDITING 1
+#define ENABLE_HUSH_IF 1
 /* No MMU in U-Boot */
 #define BB_MMU 0
 #define USE_FOR_NOMMU(...) __VA_ARGS__
@@ -124,6 +125,11 @@ static void bb_error_msg(const char *s, ...)
va_end(p);
 }
 
+static void bb_simple_error_msg(const char *s)
+{
+   bb_error_msg("%s", s);
+}
+
 static void *xmalloc(size_t size)
 {
void *p = NULL;
@@ -147,6 +153,11 @@ static void *xrealloc(void *ptr, size_t size)
return p;
 }
 
+static void *xmemdup(const void *s, int n)
+{
+   return memcpy(xmalloc(n), s, n);
+}
+
 #define xstrdupstrdup
 #define xstrndup   strndup
 
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 68a9a4bb72..9b65dcbde1 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -1488,7 +1488,6 @@ static void msg_and_die_if_script(unsigned lineno, const 
char *fmt, ...)
die_if_script();
 }
 
-#ifndef __U_BOOT__
 static void syntax_error(unsigned lineno UNUSED_PARAM, const char *msg)
 {
if (msg)
@@ -1497,7 +1496,6 @@ static void syntax_error(unsigned lineno UNUSED_PARAM, 
const char *msg)
bb_simple_error_msg("syntax error");
die_if_script();
 }
-#endif /* !__U_BOOT__ */
 
 static void syntax_error_at(unsigned lineno UNUSED_PARAM, const char *msg)
 {
@@ -3962,7 +3960,6 @@ static void debug_print_tree(struct pipe *pi, int lvl)
[PIPE_OR ] = "OR" ,
[PIPE_BG ] = "BG" ,
};
-#ifndef __U_BOOT__
static const char *RES[] = {
[RES_NONE ] = "NONE" ,
 # if ENABLE_HUSH_IF
@@ -3992,7 +3989,6 @@ static void debug_print_tree(struct pipe *pi, int lvl)
[RES_ ] = "" ,
[RES_SNTX ] = "SNTX" ,
};
-#endif /* !__U_BOOT__ */
static const char *const CMDTYPE[] = {
"{}",
"()",
@@ -4010,10 +4006,8 @@ static void debug_print_tree(struct pipe *pi, int lvl)
lvl*2, "",
pin,
pi->num_cmds,
-#ifdef __U_BOOT__
(IF_HAS_KEYWORDS(pi->pi_inverted ? "! " :) ""),
RES[pi->res_word],
-#endif /* !__U_BOOT__ */
pi->followup, PIPE[pi->followup]
);
prn = 0;
@@ -9833,6 +9827,7 @@ static NOINLINE int run_pipe(struct pipe *pi)
rcode = 1; /* exitcode if redir failed */
 #ifndef __U_BOOT__
if (setup_redirects(command, ) == 0) {
+#endif /* !__U_BOOT__ */
debug_printf_exec(": run_list\n");
 //FIXME: we need to pass squirrel down into run_list()
 //for SH_STANDALONE case, or else this construct:
@@ -9841,10 +9836,11 @@ static NOINLINE int run_pipe(struct pipe *pi)
 //and in SH_STANDALONE mode, "find" is not execed,
 //therefore CLOEXEC on saved fd does not help.
rcode = run_list(command->group) & 0xff;
+#ifndef __U_BOOT__
}
restore_redirects(squirrel);
-   IF_HAS_KEYWORDS(if (pi->pi_inverted) rcode = !rcode;)
 #endif /* !__U_BOOT__ */
+   IF_HAS_KEYWORDS(if (pi->pi_inverted) rcode = !rcode;)
debug_leave();
debug_printf_exec("run_pipe: return %d\n", rcode);
return rcode;
@@ -10363,12 +10359,12 @@ static int run_list(struct pipe *pi)
break;
if (G_flag_return_in_progress == 1)
break;
+#endif /* !__U_BOOT__ */
 
IF_HAS_KEYWORDS(rword = pi->res_word;)
debug_printf_exec(": rword=%d cond_code=%d last_rword=%d\n",
rword, cond_code, last_rword);
 
-#endif /* !__U_BOOT__ */
sv_errexit_depth = G.errexit_depth;
if (
 #if ENABLE_HUSH_IF
-- 
2.34.1



[RFC PATCH v9 16/23] test: hush: Fix instructions list tests for hush 2021

2023-06-08 Thread Francis Laniel
Modifies the expected result for hush 2021.
Indeed, there were bugs in actual U-Boot hush which were fixed in upstream
Busybox.
As hush 2021 is based on upstream Busybox, these bugs no longer exist.

Reviewed-by: Simon Glass 
Signed-off-by: Francis Laniel 
---
 test/hush/list.c | 69 +---
 1 file changed, 65 insertions(+), 4 deletions(-)

diff --git a/test/hush/list.c b/test/hush/list.c
index 052cf2783c..6f8f10f15e 100644
--- a/test/hush/list.c
+++ b/test/hush/list.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int hush_test_semicolon(struct unit_test_state *uts)
 {
@@ -46,12 +47,43 @@ static int hush_test_or(struct unit_test_state *uts)
 }
 HUSH_TEST(hush_test_or, 0);
 
+DECLARE_GLOBAL_DATA_PTR;
+
 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));
+
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_asserteq(1, run_command("false && false || true", 0));
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+*
+* Indeed, the following expression can be seen like this:
+* (false && false) || true
+* So, (false && false) returns 1, the second false is not
+* executed, and true is executed because of ||.
+*/
+   ut_assertok(run_command("false && false || true", 0));
+   }
+
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_asserteq(1, run_command("false && true || true", 0));
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+*
+* Indeed, the following expression can be seen like this:
+* (false && true) || true
+* So, (false && true) returns 1, the true is not executed, and
+* true is executed because of ||.
+*/
+   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_asserteq(1, run_command("true && false || false", 0));
@@ -69,8 +101,37 @@ static int hush_test_or_and(struct unit_test_state *uts)
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));
+
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assertok(run_command("true || true && false", 0));
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+*
+* Indeed, the following expression can be seen like this:
+* (true || true) && false
+* So, (true || true) returns 0, the second true is not
+* executed, and then false is executed because of &&.
+*/
+   ut_asserteq(1, run_command("true || true && false", 0));
+   }
+
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assertok(run_command("true || false && false", 0));
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+*
+* Indeed, the following expression can be seen like this:
+* (true || false) && false
+* So, (true || false) returns 0, the false is not executed, and
+* then false is executed because of &&.
+*/
+   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));
 
-- 
2.34.1



[RFC PATCH v9 13/23] cli: hush_2021: Enable variables expansion for hush 2021

2023-06-08 Thread Francis Laniel
Enables variables expansion for hush 2021, both for local and environment
variables.
So the following commands:
foo=bar
echo $foo
setenv bar foo
echo $bar
leads to "bar" and "foo" being printed on console output.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 common/cli_hush_2021.c | 17 +++
 common/cli_hush_upstream.c | 91 +++---
 2 files changed, 103 insertions(+), 5 deletions(-)

diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c
index 653ea52929..7dd30ea0ef 100644
--- a/common/cli_hush_2021.c
+++ b/common/cli_hush_2021.c
@@ -207,6 +207,23 @@ static const char* endofname(const char *name)
return name;
 }
 
+/**
+ * list_size() - returns the number of elements in char ** before NULL.
+ *
+ * Argument must contain NULL to signalize its end.
+ *
+ * @list The list to count the number of element.
+ * @return The number of element in list.
+ */
+static size_t list_size(char **list)
+{
+   size_t size;
+
+   for (size = 0; list[size] != NULL; size++);
+
+   return size;
+}
+
 struct in_str;
 static int u_boot_cli_readline(struct in_str *i);
 
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 84227a248e..b806c5c653 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -3486,7 +3486,6 @@ static int o_get_last_ptr(o_string *o, int n)
return ((int)(uintptr_t)list[n-1]) + string_start;
 }
 
-#ifndef __U_BOOT__
 /*
  * Globbing routines.
  *
@@ -3741,8 +3740,10 @@ static int glob_needed(const char *s)
  */
 static int perform_glob(o_string *o, int n)
 {
+#ifndef __U_BOOT__
glob_t globdata;
int gr;
+#endif /* __U_BOOT__ */
char *pattern;
 
debug_printf_glob("start perform_glob: n:%d o->data:%p\n", n, o->data);
@@ -3751,13 +3752,16 @@ static int perform_glob(o_string *o, int n)
pattern = o->data + o_get_last_ptr(o, n);
debug_printf_glob("glob pattern '%s'\n", pattern);
if (!glob_needed(pattern)) {
+#ifndef __U_BOOT__
  literal:
+#endif /* __U_BOOT__ */
/* unbackslash last string in o in place, fix length */
o->length = unbackslash(pattern) - o->data;
debug_printf_glob("glob pattern '%s' is literal\n", pattern);
return o_save_ptr_helper(o, n);
}
 
+#ifndef __U_BOOT__
memset(, 0, sizeof(globdata));
/* Can't use GLOB_NOCHECK: it does not unescape the string.
 * If we glob "*.\*" and don't find anything, we need
@@ -3793,16 +3797,22 @@ static int perform_glob(o_string *o, int n)
if (DEBUG_GLOB)
debug_print_list("perform_glob returning", o, n);
return n;
+#else /* __U_BOOT__ */
+   /*
+* NOTE We only use perform glob to call unbackslash to remove backslash
+* from string once expanded.
+* So, it seems OK to return this if no previous return was done.
+*/
+   return o_save_ptr_helper(o, n);
+#endif /* __U_BOOT__ */
 }
 
-#endif /* !__U_BOOT__ */
 #endif /* !HUSH_BRACE_EXPANSION */
 
 /* If o->o_expflags & EXP_FLAG_GLOB, glob the string so far remembered.
  * Otherwise, just finish current list[] and start new */
 static int o_save_ptr(o_string *o, int n)
 {
-#ifndef __U_BOOT__
if (o->o_expflags & EXP_FLAG_GLOB) {
/* If o->has_empty_slot, list[n] was already globbed
 * (if it was requested back then when it was filled)
@@ -3810,7 +3820,6 @@ static int o_save_ptr(o_string *o, int n)
if (!o->has_empty_slot)
return perform_glob(o, n); /* o_save_ptr_helper is 
inside */
}
-#endif /* !__U_BOOT__ */
return o_save_ptr_helper(o, n);
 }
 
@@ -5456,7 +5465,20 @@ static int parse_dollar(o_string *as_string,
nommu_addchr(as_string, ch);
if (ch == '}')
break;
+#ifndef __U_BOOT__
if (!isalnum(ch) && ch != '_') {
+#else /* __U_BOOT__ */
+   /*
+* In several places in U-Boot, we use variable like
+* foo# (e.g. serial#), particularly in env.
+* So, we need to authorize # to appear inside
+* variable name and then expand this variable.
+* NOTE Having # in variable name is not permitted in
+* upstream hush but expansion will be done (even though
+* the result will be empty).
+*/
+   if (!isalnum(ch) && ch != '_' && ch != '#') {
+#endif /* __U_BOOT__ */
unsigned end_ch;
 #ifndef __U_BOOT__
unsigned char last_ch;
@@ -7031,7 +7053,20 @@ static NOINLINE int expand_one_var(o_string *output, int 
n,
}
 #endif /* !__U_BOOT__ */
default:
+#ifndef __U_BOOT__
  

[RFC PATCH v9 17/23] test: hush: Fix variable expansion tests for hush 2021

2023-06-08 Thread Francis Laniel
Modifies the expected result for hush 2021.
Indeed, there were bugs in actual U-Boot hush which were fixed in upstream
Busybox.
As hush 2021 is based on upstream Busybox, these bugs no longer exist.

Reviewed-by: Simon Glass 
Signed-off-by: Francis Laniel 
---
 test/hush/dollar.c | 79 --
 1 file changed, 69 insertions(+), 10 deletions(-)

diff --git a/test/hush/dollar.c b/test/hush/dollar.c
index defb2c3fd0..f23392c72d 100644
--- a/test/hush/dollar.c
+++ b/test/hush/dollar.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static int hush_test_simple_dollar(struct unit_test_state *uts)
 {
@@ -51,13 +54,29 @@ static int hush_test_simple_dollar(struct unit_test_state 
*uts)
ut_asserteq(1, run_command("dollar_foo='bar quux", 0));
/* Next line contains error message */
ut_assert_skipline();
-   ut_assert_console_end();
+
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* For some strange reasons, the console is not empty after
+* running above command.
+* So, we reset it to not have side effects for other tests.
+*/
+   console_record_reset_enable();
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assert_console_end();
+   }
 
ut_asserteq(1, run_command("dollar_foo=bar quux\"", 0));
/* Two next lines contain error message */
ut_assert_skipline();
ut_assert_skipline();
-   ut_assert_console_end();
+
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* See above comments. */
+   console_record_reset_enable();
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assert_console_end();
+   }
 
ut_assertok(run_command("dollar_foo='bar \"quux'", 0));
 
@@ -71,17 +90,35 @@ static int hush_test_simple_dollar(struct unit_test_state 
*uts)
 */
console_record_reset_enable();
 
-   ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0));
-   /* Next line contains error message */
-   ut_assert_skipline();
-   ut_assert_console_end();
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* Old parser returns an error because it waits for closing
+* '\'', but this behavior is wrong as the '\'' is surrounded by
+* '"', so no need to wait for a closing one.
+*/
+   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();
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_asserteq(1, run_command("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!");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* Reset local variable. */
+   ut_assertok(run_command("dollar_foo=", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   puts("Beware: this test set local variable dollar_foo and it 
cannot be unset!");
+   }
 
return 0;
 }
@@ -109,7 +146,12 @@ static int hush_test_env_dollar(struct unit_test_state 
*uts)
/* Clean up setting the variable */
env_set("env_foo", NULL);
 
-   puts("Beware: this test set local variable env_foo and it cannot be 
unset!");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* Reset local variable. */
+   ut_assertok(run_command("env_foo=", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   puts("Beware: this test set local variable env_foo and it 
cannot be unset!");
+   }
 
return 0;
 }
@@ -144,7 +186,18 @@ static int hush_test_command_dollar(struct unit_test_state 
*uts)
ut_assertok(run_command("dollar_bar='echo bar\\n'", 0));
 
ut_assertok(run_command("$dollar_bar", 0));
-   ut_assert_nextline("barn");
+
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+* Behavior of hush 2021 is coherent with bash and other shells.
+*/
+   ut_assert_nextline("bar\\n");
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assert_nextline("barn");
+   }
+
ut_assert_console_end();
 

[RFC PATCH v9 15/23] cli: add hush 2021 as parser for run_command*()

2023-06-08 Thread Francis Laniel
Enables using, in code, hush 2021 as parser for run_command function family.
It also enables the command run to be used by CLI user of hush 2021.

Reviewed-by: Simon Glass 
Signed-off-by: Francis Laniel 
---
 common/cli.c   | 63 --
 common/cli_hush_upstream.c |  2 +-
 2 files changed, 48 insertions(+), 17 deletions(-)

diff --git a/common/cli.c b/common/cli.c
index e3e2bc7fe1..899007da9d 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -43,14 +43,31 @@ int run_command(const char *cmd, int flag)
return 1;
 
return 0;
-#elif CONFIG_IS_ENABLED(HUSH_OLD_PARSER)
-   int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP;
-
-   if (flag & CMD_FLAG_ENV)
-   hush_flags |= FLAG_CONT_ON_NEWLINE;
-   return parse_string_outer(cmd, hush_flags);
-#else /* HUSH_2021_PARSER */
-   /* Not yet implemented. */
+#else
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP;
+
+   if (flag & CMD_FLAG_ENV)
+   hush_flags |= FLAG_CONT_ON_NEWLINE;
+   return parse_string_outer(cmd, hush_flags);
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* Possible values for flags are the following:
+* FLAG_EXIT_FROM_LOOP: This flags ensures we exit from loop in
+* parse_and_run_stream() after first iteration while normal
+* behavior, * i.e. when called from cli_loop(), is to loop
+* infinitely.
+* FLAG_PARSE_SEMICOLON: Hush 2021 parses ';' and does not stop
+* first time it sees one. So, I think we do not need this flag.
+* FLAG_REPARSING: For the moment, I do not understand the goal
+* of this flag.
+* FLAG_CONT_ON_NEWLINE: This flag seems to be used to continue
+* parsing even when reading '\n' when coming from
+* run_command(). In this case, Hush 2021 reads until it finds
+* '\0'. So, I think we do not need this flag.
+*/
+   return parse_string_outer_2021(cmd, FLAG_EXIT_FROM_LOOP);
+   }
return 1;
 #endif
 }
@@ -67,12 +84,25 @@ int run_command_repeatable(const char *cmd, int flag)
 #ifndef CONFIG_HUSH_PARSER
return cli_simple_run_command(cmd, flag);
 #else
+   int ret;
+
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ret = parse_string_outer(cmd,
+FLAG_PARSE_SEMICOLON
+| FLAG_EXIT_FROM_LOOP);
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   ret = parse_string_outer_2021(cmd,
+ FLAG_PARSE_SEMICOLON
+ | FLAG_EXIT_FROM_LOOP);
+   } else {
+   ret = 1;
+   }
+
/*
 * parse_string_outer() returns 1 for failure, so clean up
 * its result.
 */
-   if (parse_string_outer(cmd,
-  FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP))
+   if (ret)
return -1;
 
return 0;
@@ -111,12 +141,13 @@ int run_command_list(const char *cmd, int len, int flag)
buff[len] = '\0';
}
 #ifdef CONFIG_HUSH_PARSER
-#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER)
-   rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON);
-#else /* HUSH_2021_PARSER */
-   /* Not yet implemented. */
-   rcode = 1;
-#endif
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON);
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   rcode = parse_string_outer_2021(buff, FLAG_PARSE_SEMICOLON);
+   } else {
+   rcode = 1;
+   }
 #else
/*
 * This function will overwrite any \n it sees with a \0, which
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index b11445c3ac..dbf77ad503 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -8023,7 +8023,7 @@ static int parse_and_run_string(const char *s)
 }
 
 #ifdef __U_BOOT__
-int parse_string_outer(const char *cmd, int flags)
+int parse_string_outer_2021(const char *cmd, int flags)
 {
int ret;
int old_flags;
-- 
2.34.1



[RFC PATCH v9 18/23] cli: hush_2021: Enable using < and > as string compare operators

2023-06-08 Thread Francis Laniel
In Busybox hush, '<' and '>' are used as redirection operators.
For example, cat foo > bar will write content of file foo inside file bar.
In U-Boot, we do not have file system, so we can hardly redirect command output
inside a file.

But, in actual U-Boot hush, these operators ('<' and '>') are used as string
compare operators.
For example, test aaa < bbb returns 0 as aaa is before bbb in the dictionary.
Busybox hush also permits this, but operators need to be escaped ('\<' and
'\>').
Indeed, if escaping is needed it permits the developer to think about its code,
as in a lot of case, we want to compare integers (using '-lt' or '-gt') rather
than strings.

As testing in U-Boot is handled by the test command, we will stick with the
original behaviour and not adapt to Busybox one.

Nonetheless, if one day we decide to implement test with '[[ ]]', we will then
stick to upstream Busybox behavior.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 common/cli_hush_upstream.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index dbf77ad503..68a9a4bb72 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -6160,7 +6160,28 @@ static struct pipe *parse_stream(char **pstring,
if (parse_redirect(, redir_fd, redir_style, input))
goto parse_error_exitcode1;
continue; /* get next char */
-#endif /* !__U_BOOT__ */
+#else /* __U_BOOT__ */
+   /*
+* In U-Boot, '<' and '>' can be used in test command 
to test if
+* a string is, alphabetically, before or after another.
+* In 2021 Busybox hush, we will keep the same behavior 
and so not treat
+* them as redirection operator.
+*
+* Indeed, in U-Boot, tests are handled by the test 
command and not by the
+* shell code.
+* So, better to give this character as input to test 
command.
+*
+* NOTE In my opinion, when you use '<' or '>' I am 
almost sure
+* you wanted to use "-gt" or "-lt" in place, so 
thinking to
+* escape these will make you should check your code 
(sh syntax
+* at this level is, for me, error prone).
+*/
+   case '>':
+   fallthrough;
+   case '<':
+   o_addQchr(, ch);
+   continue;
+#endif /* __U_BOOT__ */
case '#':
if (ctx.word.length == 0 && !ctx.word.has_quoted_part) {
/* skip "#comment" */
-- 
2.34.1



[RFC PATCH v9 14/23] cli: hush_2021: Add functions to be called from run_command()

2023-06-08 Thread Francis Laniel
run_command() is called internally by the command run and it can also be called
directly from U-Boot code, e.g. to do unit tests.
This commit adds this path to go to hush 2021.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 common/cli_hush_upstream.c | 66 --
 1 file changed, 63 insertions(+), 3 deletions(-)

diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index b806c5c653..b11445c3ac 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -1012,6 +1012,7 @@ struct globals {
 #ifdef __U_BOOT__
int flag_repeat;
int do_repeat;
+   int run_command_flags;
 #endif /* __U_BOOT__ */
char *ifs_whitespace; /* = G.ifs or malloced */
 #ifndef __U_BOOT__
@@ -3005,7 +3006,24 @@ static int i_getch(struct in_str *i)
if (i->p && *i->p != '\0') {
ch = (unsigned char)*i->p++;
goto out;
+#ifndef __U_BOOT__
}
+#else /* __U_BOOT__ */
+   /*
+* There are two ways for command to be called:
+* 1. The first one is when they are typed by the user.
+* 2. The second one is through run_command() (NOTE command run
+* internally calls run_command()).
+*
+* In the second case, we do not get input from the user, so once we
+* get a '\0', it means we need to stop.
+* NOTE G.run_command_flags is only set on run_command call stack, so
+* we use this to know if we come from user input or run_command().
+*/
+   } else if (i->p && *i->p == '\0' && G.run_command_flags){
+   return EOF;
+   }
+#endif /* __U_BOOT__ */
 #endif
 #ifndef __U_BOOT__
/* peek_buf[] is an int array, not char. Can contain EOF. */
@@ -3164,7 +3182,6 @@ static void setup_file_in_str(struct in_str *i)
 #endif /* !__U_BOOT__ */
 }
 
-#ifndef __U_BOOT__
 static void setup_string_in_str(struct in_str *i, const char *s)
 {
memset(i, 0, sizeof(*i));
@@ -3172,7 +3189,6 @@ static void setup_string_in_str(struct in_str *i, const 
char *s)
i->p = s;
 }
 
-#endif /* !__U_BOOT__ */
 
 /*
  * o_string support
@@ -7911,7 +7927,11 @@ static int run_and_free_list(struct pipe *pi);
  * NUL: parse all, execute, return
  * ';': parse till ';' or newline, execute, repeat till EOF
  */
+#ifndef __U_BOOT__
 static void parse_and_run_stream(struct in_str *inp, int end_trigger)
+#else /* __U_BOOT__ */
+static int parse_and_run_stream(struct in_str *inp, int end_trigger)
+#endif /* __U_BOOT__ */
 {
/* Why we need empty flag?
 * An obscure corner case "false; ``; echo $?":
@@ -7920,7 +7940,11 @@ static void parse_and_run_stream(struct in_str *inp, int 
end_trigger)
 * this breaks "false; echo `echo $?`" case.
 */
bool empty = 1;
+#ifndef __U_BOOT__
while (1) {
+#else /* __U_BOOT__ */
+   do {
+#endif /* __U_BOOT__ */
struct pipe *pipe_list;
 
 #if ENABLE_HUSH_INTERACTIVE
@@ -7967,21 +7991,57 @@ static void parse_and_run_stream(struct in_str *inp, 
int end_trigger)
empty = 0;
if (G_flag_return_in_progress == 1)
break;
+#ifndef __U_BOOT__
}
+#else /* __U_BOOT__ */
+   /*
+* This do/while is needed by run_command to avoid looping on a command
+* with syntax error.
+*/
+   } while (!(G.run_command_flags & FLAG_EXIT_FROM_LOOP));
+
+   return G.last_exitcode;
+#endif /* __U_BOOT__ */
 }
 
 #ifndef __U_BOOT__
 static void parse_and_run_string(const char *s)
+#else /* __U_BOOT__ */
+static int parse_and_run_string(const char *s)
+#endif /* __U_BOOT__ */
 {
struct in_str input;
//IF_HUSH_LINENO_VAR(unsigned sv = G.parse_lineno;)
 
setup_string_in_str(, s);
+#ifndef __U_BOOT__
parse_and_run_stream(, '\0');
+#else /* __U_BOOT__ */
+   return parse_and_run_stream(, '\0');
+#endif /* __U_BOOT__ */
//IF_HUSH_LINENO_VAR(G.parse_lineno = sv;)
 }
-#endif /* !__U_BOOT__ */
 
+#ifdef __U_BOOT__
+int parse_string_outer(const char *cmd, int flags)
+{
+   int ret;
+   int old_flags;
+
+   /*
+* Keep old values of run_command to be able to restore them once
+* command was executed.
+*/
+   old_flags = G.run_command_flags;
+   G.run_command_flags = flags;
+
+   ret = parse_and_run_string(cmd);
+
+   G.run_command_flags = old_flags;
+
+   return ret;
+}
+#endif /* __U_BOOT__ */
 #ifndef __U_BOOT__
 static void parse_and_run_file(HFILE *fp)
 #else /* __U_BOOT__ */
-- 
2.34.1



[RFC PATCH v9 12/23] cli: Enables using hush 2021 parser as command line parser

2023-06-08 Thread Francis Laniel
If one defines HUSH_2021_PARSER, it is then possible to use 2021 parser with:
=> cli get
old
=> cli set 2021
=> cli get
2021

Reviewed-by: Simon Glass 
Signed-off-by: Francis Laniel 
---
 cmd/Kconfig   |  8 +
 cmd/cli.c |  7 -
 common/Makefile   |  1 +
 common/cli.c  | 38 +++
 common/cli_hush_2021.c|  3 ++
 common/cli_hush_upstream.c| 46 +---
 doc/usage/cmd/cli.rst | 17 ++-
 include/asm-generic/global_data.h |  4 +++
 include/cli_hush.h| 51 +--
 9 files changed, 160 insertions(+), 15 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 4a1dad3b54..fc4ae40cc3 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -34,6 +34,14 @@ menu "Hush flavor to use"
  2005.
 
  It is actually the default U-Boot shell when decided to use 
hush as shell.
+
+   config HUSH_2021_PARSER
+   bool "Use hush 2021 parser"
+   help
+ This option enables the new flavor of hush based on hush 
Busybox from
+ 2021.
+
+ For the moment, it is highly experimental and should be used 
at own risks.
 endmenu
 
 config CMDLINE_EDITING
diff --git a/cmd/cli.c b/cmd/cli.c
index 7671785b83..d2b64da613 100644
--- a/cmd/cli.c
+++ b/cmd/cli.c
@@ -12,6 +12,8 @@ static const char *gd_flags_to_parser(void)
 {
if (gd->flags & GD_FLG_HUSH_OLD_PARSER)
return "old";
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER)
+   return "2021";
return NULL;
 }
 
@@ -34,12 +36,15 @@ static int parser_string_to_gd_flags(const char *parser)
 {
if (!strcmp(parser, "old"))
return GD_FLG_HUSH_OLD_PARSER;
+   if (!strcmp(parser, "2021"))
+   return GD_FLG_HUSH_2021_PARSER;
return -1;
 }
 
 static void reset_parser_gd_flags(void)
 {
gd->flags &= ~GD_FLG_HUSH_OLD_PARSER;
+   gd->flags &= ~GD_FLG_HUSH_2021_PARSER;
 }
 
 static int do_cli_set(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -108,7 +113,7 @@ static int do_cli(struct cmd_tbl *cmdtp, int flag, int argc,
 #if CONFIG_IS_ENABLED(SYS_LONGHELP)
 static char cli_help_text[] =
"get - print current cli\n"
-   "set - set the current cli, possible value is: old"
+   "set - set the current cli, possible value are: old, 2021"
;
 #endif
 
diff --git a/common/Makefile b/common/Makefile
index 93d0a5a309..ba8641eb9d 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -9,6 +9,7 @@ obj-y += init/
 obj-y += main.o
 obj-y += exports.o
 obj-$(CONFIG_HUSH_OLD_PARSER) += cli_hush.o
+obj-$(CONFIG_HUSH_2021_PARSER) += cli_hush_2021.o
 obj-$(CONFIG_AUTOBOOT) += autoboot.o
 
 # # boards
diff --git a/common/cli.c b/common/cli.c
index d419671e8c..e3e2bc7fe1 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -43,12 +43,15 @@ int run_command(const char *cmd, int flag)
return 1;
 
return 0;
-#else
+#elif CONFIG_IS_ENABLED(HUSH_OLD_PARSER)
int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP;
 
if (flag & CMD_FLAG_ENV)
hush_flags |= FLAG_CONT_ON_NEWLINE;
return parse_string_outer(cmd, hush_flags);
+#else /* HUSH_2021_PARSER */
+   /* Not yet implemented. */
+   return 1;
 #endif
 }
 
@@ -108,7 +111,12 @@ int run_command_list(const char *cmd, int len, int flag)
buff[len] = '\0';
}
 #ifdef CONFIG_HUSH_PARSER
+#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER)
rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON);
+#else /* HUSH_2021_PARSER */
+   /* Not yet implemented. */
+   rcode = 1;
+#endif
 #else
/*
 * This function will overwrite any \n it sees with a \0, which
@@ -254,8 +262,13 @@ err:
 void cli_loop(void)
 {
bootstage_mark(BOOTSTAGE_ID_ENTER_CLI_LOOP);
-#ifdef CONFIG_HUSH_PARSER
-   parse_file_outer();
+#if CONFIG_IS_ENABLED(HUSH_PARSER)
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER)
+   parse_and_run_file();
+   else if (gd->flags & GD_FLG_HUSH_OLD_PARSER)
+   parse_file_outer();
+
+   printf("Problem\n");
/* This point is never reached */
for (;;);
 #elif defined(CONFIG_CMDLINE)
@@ -268,10 +281,23 @@ void cli_loop(void)
 void cli_init(void)
 {
 #ifdef CONFIG_HUSH_PARSER
+   /* This if block is used to initialize hush parser gd flag. */
if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER)
-   && CONFIG_IS_ENABLED(HUSH_OLD_PARSER))
-   gd->flags |= GD_FLG_HUSH_OLD_PARSER;
-   u_boot_hush_start();
+   && !(gd->flags & GD_FLG_HUSH_2021_PARSER)) {
+   if (CONFIG_IS_ENABLED(HUSH_OLD_PARSER))
+   gd->flags |= GD_FLG_HUSH_OLD_PARSER;
+   else if (CONFIG_IS_ENABLED(HUSH_2021_PARSER))
+   gd->flags |= 

[RFC PATCH v9 11/23] cmd: Add new cli command

2023-06-08 Thread Francis Laniel
This command can be used to print the current parser with 'cli print'.
It can also be used to set the current parser with 'cli set'.
For the moment, only one value is valid for set: old.

Signed-off-by: Francis Laniel 
---
 cmd/Makefile  |   2 +
 cmd/cli.c | 120 ++
 common/cli.c  |   3 +-
 doc/usage/cmd/cli.rst |  59 +
 doc/usage/index.rst   |   1 +
 5 files changed, 184 insertions(+), 1 deletion(-)
 create mode 100644 cmd/cli.c
 create mode 100644 doc/usage/cmd/cli.rst

diff --git a/cmd/Makefile b/cmd/Makefile
index 6c37521b4e..706e934836 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -224,6 +224,8 @@ obj-$(CONFIG_CMD_AVB) += avb.o
 # Foundries.IO SCP03
 obj-$(CONFIG_CMD_SCP03) += scp03.o
 
+obj-$(CONFIG_HUSH_PARSER) += cli.o
+
 obj-$(CONFIG_ARM) += arm/
 obj-$(CONFIG_RISCV) += riscv/
 obj-$(CONFIG_SANDBOX) += sandbox/
diff --git a/cmd/cli.c b/cmd/cli.c
new file mode 100644
index 00..7671785b83
--- /dev/null
+++ b/cmd/cli.c
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const char *gd_flags_to_parser(void)
+{
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER)
+   return "old";
+   return NULL;
+}
+
+static int do_cli_get(struct cmd_tbl *cmdtp, int flag, int argc,
+char *const argv[])
+{
+   const char *current = gd_flags_to_parser();
+
+   if (!current) {
+   printf("current cli value is not valid, this should not 
happen!\n");
+   return CMD_RET_FAILURE;
+   }
+
+   printf("%s\n", current);
+
+   return CMD_RET_SUCCESS;
+}
+
+static int parser_string_to_gd_flags(const char *parser)
+{
+   if (!strcmp(parser, "old"))
+   return GD_FLG_HUSH_OLD_PARSER;
+   return -1;
+}
+
+static void reset_parser_gd_flags(void)
+{
+   gd->flags &= ~GD_FLG_HUSH_OLD_PARSER;
+}
+
+static int do_cli_set(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+   char *parser_name;
+   int parser_flag;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   parser_name = argv[1];
+
+   parser_flag = parser_string_to_gd_flags(parser_name);
+   if (parser_flag == -1) {
+   printf("Bad value for parser name: %s\n", parser_name);
+   return CMD_RET_USAGE;
+   }
+
+   if (parser_flag == GD_FLG_HUSH_OLD_PARSER &&
+   !CONFIG_IS_ENABLED(HUSH_OLD_PARSER)) {
+   printf("Want to set current parser to old, but its code was not 
compiled!\n");
+   return CMD_RET_FAILURE;
+   }
+
+   if (parser_flag == GD_FLG_HUSH_2021_PARSER &&
+   !CONFIG_IS_ENABLED(HUSH_2021_PARSER)) {
+   printf("Want to set current parser to 2021, but its code was 
not compiled!\n");
+   return CMD_RET_FAILURE;
+   }
+
+   reset_parser_gd_flags();
+   gd->flags |= parser_flag;
+
+   cli_init();
+   cli_loop();
+
+   /* cli_loop() should never return. */
+   return CMD_RET_FAILURE;
+}
+
+static struct cmd_tbl parser_sub[] = {
+   U_BOOT_CMD_MKENT(get, 1, 1, do_cli_get, "", ""),
+   U_BOOT_CMD_MKENT(set, 2, 1, do_cli_set, "", ""),
+};
+
+static int do_cli(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+   struct cmd_tbl *cp;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   /* drop initial "parser" arg */
+   argc--;
+   argv++;
+
+   cp = find_cmd_tbl(argv[0], parser_sub, ARRAY_SIZE(parser_sub));
+   if (cp)
+   return cp->cmd(cmdtp, flag, argc, argv);
+
+   return CMD_RET_USAGE;
+}
+
+#if CONFIG_IS_ENABLED(SYS_LONGHELP)
+static char cli_help_text[] =
+   "get - print current cli\n"
+   "set - set the current cli, possible value is: old"
+   ;
+#endif
+
+U_BOOT_CMD(cli, 3, 1, do_cli,
+  "cli",
+#if CONFIG_IS_ENABLED(SYS_LONGHELP)
+  cli_help_text
+#endif
+);
diff --git a/common/cli.c b/common/cli.c
index e5fe1060d0..d419671e8c 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -268,7 +268,8 @@ void cli_loop(void)
 void cli_init(void)
 {
 #ifdef CONFIG_HUSH_PARSER
-   if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER))
+   if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER)
+   && CONFIG_IS_ENABLED(HUSH_OLD_PARSER))
gd->flags |= GD_FLG_HUSH_OLD_PARSER;
u_boot_hush_start();
 #endif
diff --git a/doc/usage/cmd/cli.rst b/doc/usage/cmd/cli.rst
new file mode 100644
index 00..89ece3203d
--- /dev/null
+++ b/doc/usage/cmd/cli.rst
@@ -0,0 +1,59 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+cli command
+===
+
+Synopis
+---
+
+::
+
+cli get
+cli set cli_flavor
+
+Description
+---
+
+The cli command permits getting and changing the current parser at runtime.
+
+cli get
+~~~
+
+It shows the 

[RFC PATCH v9 09/23] cli: Add menu for hush parser

2023-06-08 Thread Francis Laniel
For the moment, the menu contains only entry: HUSH_OLD_PARSER which is the
default.
The goal is to prepare the field to add a new hush parser which guarantees
actual behavior is still correct.

Reviewed-by: Simon Glass 
Signed-off-by: Francis Laniel 
---
 cmd/Kconfig | 13 +
 common/Makefile |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 365371fb51..4a1dad3b54 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -23,6 +23,19 @@ config HUSH_PARSER
  If disabled, you get the old, much simpler behaviour with a somewhat
  smaller memory footprint.
 
+menu "Hush flavor to use"
+   depends on HUSH_PARSER
+
+   config HUSH_OLD_PARSER
+   bool "Use hush old parser"
+   default y
+   help
+ This option enables the old flavor of hush based on hush 
Busybox from
+ 2005.
+
+ It is actually the default U-Boot shell when decided to use 
hush as shell.
+endmenu
+
 config CMDLINE_EDITING
bool "Enable command line editing"
depends on CMDLINE
diff --git a/common/Makefile b/common/Makefile
index c87bb2e78b..93d0a5a309 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -8,7 +8,7 @@ ifndef CONFIG_SPL_BUILD
 obj-y += init/
 obj-y += main.o
 obj-y += exports.o
-obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
+obj-$(CONFIG_HUSH_OLD_PARSER) += cli_hush.o
 obj-$(CONFIG_AUTOBOOT) += autoboot.o
 
 # # boards
-- 
2.34.1



[RFC PATCH v9 08/23] cli: Port Busybox 2021 hush to U-Boot

2023-06-08 Thread Francis Laniel
Adds new file cli_hush_2021.c, it is a copy of Busybox hush file as it was of
time to commit 37460f5da.
This commit modifies Busybox hush to not compile some part specific to Busybox
and adds some code needed by U-Boot.
The modifications consists mainly on adding code #if(n)def guards.

For the moment, this refurbished flavor of hush only permits running command
without any keywords (i.e., if and for are not recognized) or variable expansion
(i.e., echo $foo prints foo and not value stored in variable foo).

A new file was also added to define some functions specific to U-Boot.

Signed-off-by: Francis Laniel 
Signed-off-by: Harald Seiler 
---
 common/cli_hush_2021.c | 274 
 common/cli_hush_upstream.c | 501 -
 2 files changed, 774 insertions(+), 1 deletion(-)
 create mode 100644 common/cli_hush_2021.c

diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c
new file mode 100644
index 00..6d109933b8
--- /dev/null
+++ b/common/cli_hush_2021.c
@@ -0,0 +1,274 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * This file defines the compilation unit for the new hush shell version.  The
+ * actual implementation from upstream BusyBox can be found in
+ * `cli_hush_2021_upstream.c` which is included at the end of this file.
+ *
+ * This "wrapper" technique is used to keep the changes to the upstream version
+ * as minmal as possible.  Instead, all defines and redefines necessary are 
done
+ * here, outside the upstream sources.  This will hopefully make upgrades to
+ * newer revisions much easier.
+ *
+ * Copyright (c) 2021, Harald Seiler, DENX Software Engineering, h...@denx.de
+ */
+
+#include  /* readline */
+#include 
+#include  /* malloc, free, realloc*/
+#include /* isalpha, isdigit */
+#include 
+#include 
+#include 
+#include 
+#include /* find_cmd */
+#include 
+
+/*
+ * BusyBox Version: UPDATE THIS WHEN PULLING NEW UPSTREAM REVISION!
+ */
+#define BB_VER "1.34.0.git37460f5daff9"
+
+/*
+ * Define hush features by the names used upstream.
+ */
+#define ENABLE_HUSH_INTERACTIVE1
+#define ENABLE_FEATURE_EDITING 1
+/* No MMU in U-Boot */
+#define BB_MMU 0
+#define USE_FOR_NOMMU(...) __VA_ARGS__
+#define USE_FOR_MMU(...)
+
+/*
+ * Size-saving "small" ints (arch-dependent)
+ */
+#if CONFIG_IS_ENABLED(X86) || CONFIG_IS_ENABLED(X86_64) || 
CONFIG_IS_ENABLED(MIPS)
+/* add other arches which benefit from this... */
+typedef signed char smallint;
+typedef unsigned char smalluint;
+#else
+/* for arches where byte accesses generate larger code: */
+typedef int smallint;
+typedef unsigned smalluint;
+#endif
+
+/*
+ * Alignment defines used by BusyBox.
+ */
+#define ALIGN1 __attribute__((aligned(1)))
+#define ALIGN2 __attribute__((aligned(2)))
+#define ALIGN4 __attribute__((aligned(4)))
+#define ALIGN8 __attribute__((aligned(8)))
+#define ALIGN_PTR  __attribute__((aligned(sizeof(void*
+
+/*
+ * Miscellaneous compiler/platform defines.
+ */
+#define FAST_FUNC /* not used in U-Boot */
+#define UNUSED_PARAM   __always_unused
+#define ALWAYS_INLINE  __always_inline
+#define NOINLINE   noinline
+
+/*
+ * Defines to provide equivalents to what libc/BusyBox defines.
+ */
+#define EOF(-1)
+#define EXIT_SUCCESS   0
+#define EXIT_FAILURE   1
+
+/*
+ * Stubs to provide libc/BusyBox functions based on U-Boot equivalents where it
+ * makes sense.
+ */
+#define utoa   simple_itoa
+
+static void __noreturn xfunc_die(void)
+{
+   panic("HUSH died!");
+}
+
+#define bb_error_msg_and_die(format, ...) do { \
+panic("HUSH: " format, __VA_ARGS__); \
+} while (0);
+
+#define bb_simple_error_msg_and_die(msg) do { \
+panic_str("HUSH: " msg); \
+} while (0);
+
+/* fdprintf() is used for debug output. */
+static int __maybe_unused fdprintf(int fd, const char *format, ...)
+{
+   va_list args;
+   uint i;
+
+   assert(fd == 2);
+
+   va_start(args, format);
+   i = vprintf(format, args);
+   va_end(args);
+
+   return i;
+}
+
+static void bb_verror_msg(const char *s, va_list p, const char* strerr)
+{
+   /* TODO: what to do with strerr arg? */
+   vprintf(s, p);
+}
+
+static void bb_error_msg(const char *s, ...)
+{
+   va_list p;
+
+   va_start(p, s);
+   bb_verror_msg(s, p, NULL);
+   va_end(p);
+}
+
+static void *xmalloc(size_t size)
+{
+   void *p = NULL;
+   if (!(p = malloc(size)))
+   panic("out of memory");
+   return p;
+}
+
+static void *xzalloc(size_t size)
+{
+   void *p = xmalloc(size);
+   memset(p, 0, size);
+   return p;
+}
+
+static void *xrealloc(void *ptr, size_t size)
+{
+   void *p = NULL;
+   if (!(p = realloc(ptr, size)))
+   panic("out of memory");
+   return p;
+}
+
+#define xstrdupstrdup
+#define 

[RFC PATCH v9 06/23] test: hush: Test hush loops

2023-06-08 Thread Francis Laniel
The added tests verifies correct behavior of for, while and until loops.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 test/hush/Makefile |  1 +
 test/hush/loop.c   | 65 ++
 2 files changed, 66 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..ca777e38fe
--- /dev/null
+++ b/test/hush/loop.c
@@ -0,0 +1,65 @@
+// 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 quux; do echo 
$loop_i; done", 0));
+   ut_assert_nextline("foo");
+   ut_assert_nextline("bar");
+   ut_assert_nextline("quux");
+   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.34.1



[RFC PATCH v9 05/23] test: hush: Test hush commands list

2023-06-08 Thread Francis Laniel
Verifies behavior of commands separated by ';', '&&' and '||'.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 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.34.1



[RFC PATCH v9 04/23] test: hush: Test hush variable expansion

2023-06-08 Thread Francis Laniel
Verifies shell variables are replaced by their values.

Reviewed-by: Simon Glass 
Signed-off-by: Francis Laniel 
---
 test/hush/Makefile   |   1 +
 test/hush/dollar.c   | 167 +++
 test/py/tests/test_ut.py |   8 +-
 3 files changed, 175 insertions(+), 1 deletion(-)
 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..defb2c3fd0
--- /dev/null
+++ b/test/hush/dollar.c
@@ -0,0 +1,167 @@
+// 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));
+   ut_assert_nextline_empty();
+   ut_assert_console_end();
+
+   ut_assertok(run_command("echo ${dollar_foo}", 0));
+   ut_assert_nextline_empty();
+   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();
+
+   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("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("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("dollar_foo='bar \"quux'", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   /*
+* This one is buggy.
+* ut_assert_nextline("bar \"quux");
+* ut_assert_console_end();
+*
+* So, let's reset output:
+*/
+   console_record_reset_enable();
+
+   ut_asserteq(1, run_command("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 priority 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;
+}
+HUSH_TEST(hush_test_env_dollar, 0);
+
+static int hush_test_command_dollar(struct unit_test_state *uts)
+{
+   console_record_reset_enable();
+
+   ut_assertok(run_command("dollar_bar=\"echo bar\"", 0));
+
+   ut_assertok(run_command("$dollar_bar", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("${dollar_bar}", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_bar=\"echo\nbar\"", 0));
+
+   ut_assertok(run_command("$dollar_bar", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_bar='echo bar\n'", 0));
+
+   

[RFC PATCH v9 03/23] test/py: hush_if_test: Remove the test file

2023-06-08 Thread Francis Laniel
5804ebfeb1ce ("test: hush: Test hush if/else") translated this test to a C test,
so this python file is no more needed.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 test/py/tests/test_hush_if_test.py | 197 -
 1 file changed, 197 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 3b4b6fcaf4..00
--- a/test/py/tests/test_hush_if_test.py
+++ /dev/null
@@ -1,197 +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),
-)
-
-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()
-
-@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 test_hush_z(u_boot_console):
-"""Test the -z operator"""
-u_boot_console.run_command('setenv ut_var_nonexistent')
-u_boot_console.run_command('setenv ut_var_exists 1')
-exec_hush_if(u_boot_console, 'test -z "$ut_var_nonexistent"', True)
-exec_hush_if(u_boot_console, 'test -z "$ut_var_exists"', False)
-

[RFC PATCH v9 02/23] test: hush: Test hush if/else

2023-06-08 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 
Reviewed-by: Simon Glass 
---
 test/hush/Makefile |   1 +
 test/hush/if.c | 316 +
 2 files changed, 317 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..b7200e32ec
--- /dev/null
+++ b/test/hush/if.c
@@ -0,0 +1,316 @@
+// 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");
+   

[RFC PATCH v9 01/23] test: Add framework to test hush behavior

2023-06-08 Thread Francis Laniel
Introduce 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 
Reviewed-by: Simon Glass 
---
 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 7349ce5aa6..77dc7bf62d 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -41,6 +41,7 @@ int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char 
*const argv[]);
 int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_font(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_loadm(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[]);
diff --git a/test/Makefile b/test/Makefile
index 178773647a..d6ca3e221d 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -20,6 +20,9 @@ obj-$(CONFIG_FUZZ) += fuzz/
 ifndef CONFIG_SANDBOX_VPL
 obj-$(CONFIG_UNIT_TEST) += lib/
 endif
+ifneq ($(CONFIG_HUSH_PARSER),)
+obj-$(CONFIG_$(SPL_)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 d440da833a..ba050e8aef 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -107,6 +107,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
 #ifdef CONFIG_CMD_LOADM
U_BOOT_CMD_MKENT(loadm, CONFIG_SYS_MAXARGS, 1, do_ut_loadm, "", ""),
 #endif
@@ -197,6 +200,9 @@ static char ut_help_text[] =
 #ifdef CONFIG_CONSOLE_TRUETYPE
"\nut font - font command"
 #endif
+#if CONFIG_IS_ENABLED(HUSH_PARSER)
+   "\nhush - Test hush behavior"
+#endif
 #ifdef CONFIG_CMD_LOADM
"\nloadm - loadm command parameters and loading memory blob"
 #endif
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.34.1



[RFC PATCH v9 00/23] Modernize U-Boot shell

2023-06-08 Thread Francis Laniel
Hi.


During 2021 summer, Sean Anderson wrote a contribution to add a new shell, based
on LIL, to U-Boot [1, 2].
While one of the goals of this contribution was to address the fact actual
U-Boot shell, which is based on Busybox hush, is old there was a discussion
about adding a new shell versus updating the actual one [3, 4].

So, in this series, with Harald Seiler, we updated the actual U-Boot shell to
reflect what is currently in Busybox source code.
Basically, this contribution is about taking a snapshot of Busybox shell/hush.c
file (as it exists in commit 37460f5da) and adapt it to suit U-Boot needs.

This contribution was written to be as backward-compatible as possible to avoid
breaking the existing.
So, the 2021 hush flavor offers the same as the actual, that is to say:
1. Variable expansion.
2. Instruction lists (;, && and ||).
3. If, then and else.
4. Loops (for, while and until).
No new features offered by Busybox hush were implemented (e.g. functions).

It is possible to change the parser at runtime using the "cli" command:
=> cli print
old
=> cli set 2021
=> cli print
2021
=> cli set old
The default parser is the old one.
Note that to use both parser, you would need to set both CONFIG_HUSH_2021_PARSER
and CONFIG_HUSH_OLD_PARSER.

In terms of testing, new unit tests were added to ut to ensure the new behavior
is the same as the old one and it does not add regression.
Nonetheless, if old behavior was buggy and fixed upstream, the fix is then added
to U-Boot [5].
In sandbox, all of these tests pass smoothly:
=> printenv board
board=sandbox
=> ut hush
Running 20 hush tests
...
Failures: 0
=> parser set 2021
=> ut hush
Running 20 hush tests
...
Failures: 0

Thanks to the effort of Harald Seiler, I was successful booting a board:
=> printenv fdtfile
fdtfile=amlogic/meson-gxl-s905x-libretech-cc.dtb
=> cli get
old
=> boot
...
root@lepotato:~#
root@lepotato:~# reboot
...
=> cli set 2021
=> cli get
2021
=> printenv fdtfile
fdtfile=amlogic/meson-gxl-s905x-libretech-cc.dtb
=> boot
...
root@lepotato:~#

I was able to have the CI passes but I had to not use CONFIG_HUSH_2021_PARSER
for the keymile board.
Indeed, the keymile board family is the only set of boards to call
get_local_var(), set_local_var() and unset_local_var().
Sadly, these functions are static in this contribution.
I could have change all of them to introduce code like this:
*_local_var(/*...*/)
{
if (gd->flags & GD_FLG_HUSH_OLD_PARSER)
return *_local_var_old(/*...*/);
if (gd->flags & GD_FLG_HUSH_2021_PARSER)
return *_local_var_2021(/*...*/);
}
But this would have mean renaming all old hush functions calls and I did not
want to change the old hush particularly to avoid breaking things.
Instead, I change the keymile board to use environment variable instead of local
ones.
I think this particularities can be addressed in future works.

I also had to enable CONFIG_LTO for kirkwoord sheevaplug and phytec bk4r1, so
they do not hit their limits.

For all these reasons, I marked this contribution as RFC to indeed collect your
opinions.
My goal is not to change suddenly actual shell to this one, we clearly need a
transition period to think about it.
I think it is better to see this contribution as a proof of concept which shows
it is possible to update the actual shell.

If you want to review it - your review will really be appreciated - here are
some information regarding the commits:
* commits marked as "test:" deal with unit tests.
* commit "cli: Add Busybox upstream hush.c file." copies Busybox shell/hush.c
into U-Boot tree, this explain why this commit contains around 12000 additions.
* commit "cli: Port Busybox 2021 hush to U-Boot." modifies previously added file
to permit us to use this as new shell.
The really good idea of #include'ing Busybox code into a wrapper file to define
some particular functions while minimizing modifications to upstream code comes
from Harald Seiler.
* commit "cmd: Add new parser command" adds a new command which permits
selecting parser at runtime.
I am not really satisfied with the fact it calls cli_init() and cli_loop() each
time the parser is set, so your reviews would be welcomed.
* Other commits focus on enabling features we need (e.g. if).

Changes since:
 v2:
  * Added a small fix to compile sandbox with NO_SDL=1.
  * Added a command to change parser at runtime.
  * Added 2021 parser function to all run_command*().
 v3:
  * Various bug fixes pointed by the CI.
  * Added upstream busybox hush commits until 6th February 2022.
 v4:
  * Various cleaning.
  * Modified python test to accept failure output when the test are designed to
  fail.
  * Bumped upstream busybox hush commits until 24h March 2022.
 v5:
  * Bumped upstream busybox hush commits until 30th January 2023.
  * Fix how hush interprets '<' and '>', indeed we needed to escape them but I
  removed this behavior as tests are handled by test command and not hush
  itself. This permitted to have the ut fdt 

rk3328 efuse return just 0

2023-06-08 Thread Belisko Marek
Hi,

I'm using tip of actual master and with this small patches:
--- a/configs/rock-pi-e-rk3328_defconfig
+++ b/configs/rock-pi-e-rk3328_defconfig
@@ -73,6 +73,8 @@ CONFIG_FASTBOOT_BUF_ADDR=0x800800
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
+CONFIG_MISC=y
+CONFIG_ROCKCHIP_EFUSE=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_ETH_DESIGNWARE=y

--- a/configs/rock-pi-e-rk3328_defconfig
+++ b/configs/rock-pi-e-rk3328_defconfig
@@@ -45,8 -34,6 +45,7 @@@ CONFIG_SPL_I2C=
  CONFIG_SPL_POWER=y
  CONFIG_SPL_ATF=y
  CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
 +CONFIG_TPL_SYS_MALLOC_SIMPLE=y
- CONFIG_TPL_DRIVERS_MISC=y
  CONFIG_CMD_BOOTZ=y
  CONFIG_CMD_GPT=y
  CONFIG_CMD_MMC=y

as for the following issue:
/home/marek/data/projects/u-boot/drivers/misc/rockchip-efuse.c:273:(.text.rockchip_efuse_of_to_plat+0x1c):
relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol
`dev_read_addr_ptr'

I'm trying to enable proper ethaddr handling (as in this case cpuid# is
used for ethaddr generation).

With those enabled options I'm still getting an cpuid# variable set to all
'0'. Is there some other fix necessary maybe?

Thanks and BR,

marek
-- 
as simple and primitive as possible
-
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com


Re: [PATCH v2] dt-bindings: riscv: deprecate riscv,isa

2023-06-08 Thread Conor Dooley
On Thu, Jun 08, 2023 at 11:49:08AM -0600, Rob Herring wrote:
> On Thu, 08 Jun 2023 17:54:05 +0100, Conor Dooley wrote:

> > As a result of implementing Sean's suggestion, I believe I need to add
> > riscv,isa-extensions as an exception to the rules preventing vendor
> > properties being of object type, otherwise dt_binding_check is less than
> > happy with me.

> dtschema/dtc warnings/errors:
> /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/riscv/extensions.yaml:
>  properties:riscv,isa-extensions: 'oneOf' conditional failed, one must be 
> fixed:
>   Additional properties are not allowed ('additionalProperties', 
> 'properties' were unexpected)
>   hint: A vendor boolean property can use "type: boolean"
>   
> /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/riscv/extensions.yaml:
>  properties:riscv,isa-extensions: 'oneOf' conditional failed, one must be 
> fixed:
>   'enum' is a required property
>   'const' is a required property
>   hint: A vendor string property with exact values has an 
> implicit type
>   from schema $id: 
> http://devicetree.org/meta-schemas/vendor-props.yaml#
>   Additional properties are not allowed ('additionalProperties', 
> 'properties', 'type' were unexpected)
>   hint: A vendor string property with exact values has an 
> implicit type
>   
> /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/riscv/extensions.yaml:
>  properties:riscv,isa-extensions: 'oneOf' conditional failed, one must be 
> fixed:
>   '$ref' is a required property
>   'allOf' is a required property
>   hint: A vendor property needs a $ref to types.yaml
>   from schema $id: 
> http://devicetree.org/meta-schemas/vendor-props.yaml#
>   'boolean' was expected
>   hint: A vendor boolean property can use "type: boolean"
>   hint: Vendor specific properties must have a type and description 
> unless they have a defined, common suffix.
>   from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#

Yeah, expected. I think I need an exception in vendor-props for this to
pass the checks.


signature.asc
Description: PGP signature


Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration

2023-06-08 Thread Ilias Apalodimas
Thanks Maxim,

On Thu, 8 Jun 2023 at 13:14, Maxim Uvarov  wrote:
>
> Ilias asked to make more clear results to compare the original stack and LWIP 
> stack. So the difference between the current U-boot stack and the LWIP stack 
> with 3 network commands is:
> a) 18Kb  - ls -lh size
> b) 15Kb - bloat-o-meter script total line report.
>
> BOM=linux/scripts/bloat-o-meter (script)
>
> 1. 893K - U-boot CMD_NET=n
> 2. 928K - U-boot CMD_NET=y TFTP=y PING=y WGET=y
> BOM 1-2: Total: Before=692286, After=722283, chg +4.33%
> 3. 940K - U-boot CMD_NET=n, LWIP_TFTP=y LWIP_PING=y LWIP_PING=y
> BOM 1-3: Total: Before=692286, After=738425, chg +6.66%

That's much more readable! I discussed this with Tom over IRC and the
size difference is certainly a reasonable trade-off for the extra
functionality.

Can you tidy up the series and include DHCP and PXE done through LWIP?

Thanks
/Ilias
>
> BOM 2-3:
>
> add/remove: 287/203 grow/shrink: 3/11 up/down: 43459/-27317 (16142)
> Function old new   delta
> tcp_input  -3588   +3588
> tcp_receive-2884   +2884
> ip4_reass  -1760   +1760
> tcp_output -1400   +1400
> tcp_write  -1300   +1300
> tcp_slowtmr-1172   +1172
> httpc_tcp_recv -1044   +1044
> tftp_recv  - 888+888
> ip4_input  - 700+700
> ip4_frag   - 632+632
> icmp_input - 604+604
> udp_input  - 596+596
> etharp_input   - 512+512
> tcp_split_unsent_seg   - 500+500
> ip4addr_aton   - 492+492
> tcp_alloc  - 484+484
> ip4_output_if_src  - 476+476
> tcp_close_shutdown - 448+448
> etharp_query   - 436+436
> httpc_init_connection_common.constprop - 416+416
> udp_sendto_if_src  - 408+408
> etharp_output  - 404+404
> arp_table  - 400+400
> tcp_connect- 396+396
> pbuf_alloc - 376+376
> etharp_find_entry  - 372+372
> tcp_abandon- 368+368
> tcp_zero_window_probe  - 356+356
> raw_sendto_if_src  - 328+328
> pbuf_copy_partial_pbuf - 328+328
> ip_reass_free_complete_datagram- 328+328
> tcp_create_segment - 300+300
> raw_input  - 292+292
> uboot_lwip_init- 284+284
> ethernet_input - 284+284
> etharp_raw - 284+284
> tcp_output_alloc_header_common.constprop   - 280+280
> cmds   - 280+280
> udp_bind   - 276+276
> tcp_oos_insert_segment - 276+276
> ip_reass_remove_oldest_datagram- 272+272
> icmp_send_response - 268+268
> netif_add  - 260+260
> ping_send  - 244+244
> tcp_rexmit - 232+232
> tcp_parseopt   - 220+220
> tcp_free_acked_segments.constprop  - 220+220
> send_request   - 220+220
> inet_chksum_pseudo - 216+216
> ip4addr_ntoa_r - 212+212
> do_lwip_ping   - 212+212
> tcp_enqueue_flags  - 208+208
> etharp_output_to_arp_index - 208+208
> netif_set_addr - 204+204
> tcp_fasttmr- 200+200
> tcp_rexmit_rto_prepare - 196+196
> tcp_process_refused_data   - 196+196
> send_data  - 196+196
> lwip_wget  - 192+192
> 

Re: [u-boot/next] Pull request efi-next-20230608

2023-06-08 Thread Tom Rini
On Thu, Jun 08, 2023 at 11:49:00AM +0200, Heinrich Schuchardt wrote:

> Dear Tom,
> 
> The following changes since commit ac6096fe9c4d99f1dc37db95f213e08a48b11e70:
> 
>   Merge branch '2023-06-01-assorted-platform-updates' into next (2023-06-01
> 15:43:38 -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-efi.git
> tags/efi-next-20230608
> 
> for you to fetch changes up to b6f954e5b09545d18a150e4a4431a648e41ff287:
> 
>   test/py: efi_capsule: test for FMP versioning (2023-06-08 09:20:36 +0200)
> 
> Gitlab CI showed no issues:
> https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/16516
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Pull request: u-boot-sunxi/master for 2023.07

2023-06-08 Thread Tom Rini
On Thu, Jun 08, 2023 at 01:30:36AM +0100, Andre Przywara wrote:

> Hi Tom,
> 
> a small late pull request for Allwinner. The main feature is just a DT
> update, matching the v6.4 Linux kernel DT files. This also enables a board
> (LCTech Pi F1C200s) which got its .dts file merged into Linux. Plus a tiny
> typo fix from Sam.
> 
> Gitlab CI passed, briefly tested on an H616 board and the new LCTech Pi.
> 
> Thanks,
> Andre
> 
> 
> The following changes since commit 0a8a4b86422650d6955a2382796089735453902d:
> 
>   Merge tag 'u-boot-amlogic-20230607' of 
> https://source.denx.de/u-boot/custodians/u-boot-amlogic (2023-06-07 12:17:06 
> -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-sunxi.git master
> 
> for you to fetch changes up to 9bc6f1a4d08261032d60836ea1dd6f2e98889060:
> 
>   sunxi: Fix typo in include guard (2023-06-07 22:45:02 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2] dt-bindings: riscv: deprecate riscv,isa

2023-06-08 Thread Rob Herring
sions
> =
> 
> Compared to riscv,isa, this proposed scheme promotes vendor extensions,
> oft touted as the strength of RISC-V, to first-class citizens.
> At present, extensions are defined as meaning what the RISC-V ISA
> specifications say they do. There is no realistic way of using that
> interface to provide cross-platform definitions for what vendor
> extensions mean. Vendor extensions may also have even less consistency
> than RVI do in terms of versioning, or no care about backwards
> compatibility.
> A boolean property allows us to assign explicit meanings on a per vendor
> extension basis, backed up by a description of their meanings.
> 
> fin
> ===
> 
> Create a new file to store the extension meanings, each of which are
> boolean children of a riscv,isa-extensions node and a new
> riscv,isa-base property to replace the aspect of riscv,isa that is
> not represented by booleans - the base ISA implemented by a hart.
> Originally I proposed properties in the cpu node, rather than as a child
> of the cpu node, but some concerns were raised about the size of the dtb
> for systems with dozens of cpus & dozens of extensions. Using a child
> node, and dropping the "riscv,isa-extension-" prefix saves the guts of
> 20 bytes per extension, per hart, and hopefully placates the size
> conscious.
> 
> As a starting point, add properties for extensions currently used in
> Linux.
> 
> Finally, mark riscv,isa as deprecated, as removing it is an ABI break.
> 
> CC: Palmer Dabbelt 
> CC: Paul Walmsley 
> CC: Rob Herring 
> CC: Krzysztof Kozlowski 
> CC: Alistair Francis 
> CC: Andrew Jones 
> CC: Anup Patel 
> CC: Atish Patra 
> CC: Jessica Clarke 
> CC: Rick Chen 
> CC: Leo 
> CC: Oleksii 
> CC: linux-ri...@lists.infradead.org
> CC: qemu-ri...@nongnu.org
> CC: u-boot@lists.denx.de
> CC: devicet...@vger.kernel.org
> CC: linux-ker...@vger.kernel.org
> Signed-off-by: Conor Dooley 
> ---
> Changes in v2:
> - Use Sean's suggestion of a child node to calm fears of bloat
> - Fixup a rake of wording etc issues that Drew pointed out
> 
> As a result of implementing Sean's suggestion, I believe I need to add
> riscv,isa-extensions as an exception to the rules preventing vendor
> properties being of object type, otherwise dt_binding_check is less than
> happy with me.
> 
> I've tried to CC a few folks here that would care about this, but I am
> sure there are more. I'll go cross-post it to sw-dev, if it allows me to
> post there...
> ---
>  .../devicetree/bindings/riscv/cpus.yaml   |  57 ++--
>  .../devicetree/bindings/riscv/extensions.yaml | 278 ++
>  2 files changed, 313 insertions(+), 22 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/riscv/extensions.yaml
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/riscv/extensions.yaml:
 properties:riscv,isa-extensions: 'oneOf' conditional failed, one must be fixed:
Additional properties are not allowed ('additionalProperties', 
'properties' were unexpected)
hint: A vendor boolean property can use "type: boolean"

/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/riscv/extensions.yaml:
 properties:riscv,isa-extensions: 'oneOf' conditional failed, one must be fixed:
'enum' is a required property
'const' is a required property
hint: A vendor string property with exact values has an 
implicit type
from schema $id: 
http://devicetree.org/meta-schemas/vendor-props.yaml#
Additional properties are not allowed ('additionalProperties', 
'properties', 'type' were unexpected)
hint: A vendor string property with exact values has an 
implicit type

/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/riscv/extensions.yaml:
 properties:riscv,isa-extensions: 'oneOf' conditional failed, one must be fixed:
'$ref' is a required property
'allOf' is a required property
hint: A vendor property needs a $ref to types.yaml
from schema $id: 
http://devicetree.org/meta-schemas/vendor-props.yaml#
'boolean' was expected
hint: A vendor boolean property can use "type: boolean"
hint: Vendor specific properties must have a type and description 
unless they have a defined, common suffix.
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#

doc reference errors (make refcheckdocs):

See 
https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20230608-sitting-bath-31eddc03c5a5@spud

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.



Re: [PATCH v5 4/7] board: asus: transformer: add ASUS Transformer T30 family support

2023-06-08 Thread Svyatoslav Ryhel



8 червня 2023 р. 20:09:41 GMT+03:00, Tom Rini  написав(-ла):
>On Thu, Jun 08, 2023 at 07:54:54PM +0300, Svyatoslav Ryhel wrote:
>> чт, 8 черв. 2023 р. о 19:40 Tom Rini  пише:
>> >
>> > On Thu, Jun 08, 2023 at 06:11:57PM +0300, Svyatoslav Ryhel wrote:
>> > > вт, 6 черв. 2023 р. о 22:47 Tom Rini  пише:
>> > > >
>> > > > On Tue, Jun 06, 2023 at 10:40:53PM +0300, Svyatoslav Ryhel wrote:
>> > > > >
>> > > > >
>> > > > > 6 червня 2023 р. 22:19:44 GMT+03:00, Tom Rini  
>> > > > > написав(-ла):
>> > > > > >On Tue, Jun 06, 2023 at 10:18:47AM +0300, Svyatoslav Ryhel wrote:
>> > > > > >
>> > > > > >> The ASUS Transformer T30 family are 2-in-1 detachable tablets
>> > > > > >> and AiO developed by ASUS that run the Android operating system
>> > > > > >> (TF600T runs Windows RT and P1801-T runs Android and Windows).
>> > > > > >> The T30 Transformers feature a 10.1-inch display (apart P1801-T),
>> > > > > >> an Nvidia Tegra 3 quad-core chip, 1/2 GB of RAM, and 16/32 GB of
>> > > > > >> storage. Transformers board derives from Nvidia Cardhu development
>> > > > > >> board.
>> > > > > >>
>> > > > > >> This patch brings support for 7 known Transformer devices:
>> > > > > >> - ASUS Transformer Prime TF201
>> > > > > >> - ASUS Transformer Pad TF300T/TF300TG/TF300TL
>> > > > > >> - ASUS VivoTab RT TF600T (Windows RT based)
>> > > > > >> - ASUS Transformer Infinity TF700T
>> > > > > >> - ASUS Transformer AiO P1801-T
>> > > > > >>
>> > > > > >> Tested-by: Andreas Westman Dorcsak  # all 
>> > > > > >> devices
>> > > > > >> Signed-off-by: Svyatoslav Ryhel 
>> > > > > >> ---
>> > > > > >>  arch/arm/dts/Makefile |   7 +
>> > > > > >>  arch/arm/dts/tegra30-asus-p1801-t.dts |  17 +
>> > > > > >>  arch/arm/dts/tegra30-asus-tf201.dts   |   9 +
>> > > > > >>  arch/arm/dts/tegra30-asus-tf300t.dts  |  18 +
>> > > > > >>  arch/arm/dts/tegra30-asus-tf300tg.dts |   9 +
>> > > > > >>  arch/arm/dts/tegra30-asus-tf300tl.dts |   9 +
>> > > > > >>  arch/arm/dts/tegra30-asus-tf600t.dts  |  89 +
>> > > > > >>  arch/arm/dts/tegra30-asus-tf700t.dts  |  13 +
>> > > > > >>  arch/arm/dts/tegra30-asus-transformer.dtsi| 211 ++
>> > > > > >>  arch/arm/mach-tegra/tegra30/Kconfig   |   5 +
>> > > > > >>  board/asus/transformer-t30/Kconfig|  23 ++
>> > > > > >>  board/asus/transformer-t30/MAINTAINERS|   6 +
>> > > > > >>  board/asus/transformer-t30/Makefile   |  11 +
>> > > > > >>  .../pinmux-config-transformer.h   | 365 
>> > > > > >> ++
>> > > > > >>  .../transformer-t30/transformer-t30-spl.c |  41 ++
>> > > > > >>  board/asus/transformer-t30/transformer-t30.c  | 201 ++
>> > > > > >>  configs/p1801-t.config|   2 +
>> > > > > >>  configs/tf201.config  |   2 +
>> > > > > >>  configs/tf300t.config |   2 +
>> > > > > >>  configs/tf300tg.config|   2 +
>> > > > > >>  configs/tf300tl.config|   2 +
>> > > > > >>  configs/tf600t.config |   4 +
>> > > > > >>  configs/tf700t.config |   2 +
>> > > > > >>  configs/transformer_t30_defconfig |  85 
>> > > > > >
>> > > > > >Sorry for not noticing this part sooner.  Looking in the kernel,
>> > > > > >arch/{riscv,powerpc}/Makefile both provide examples of how to 
>> > > > > >automate
>> > > > > >generating the resulting defconfigs directly. I think we really want
>> > > > > >that, and also the config fragments need to be listed in the 
>> > > > > >MAINTAINERS
>> > > > > >file.
>> > > > >
>> > > > > Not sure if adding this is a good idea, plus adding fragments into
>> > > > > MAINTAINERS may cause even more issues. Iirc buildman uses it as a
>> > > > > config source and defining multiple fragments may fail not only for
>> > > > > boards under question, but those, already existing in u-boot, as 
>> > > > > well.
>> > > >
>> > > > If this causes buildman problems then we'll need to figure out
>> > > > something, but it shouldn't.
>> > >
>> > > Adding fragments into MAINTAINERS does not cause issues but seems to
>> > > not have any effect either.
>> >
>> > Well, get_maintainers.pl will now report who owns them, which it didn't
>> > before, yes?
>> >
>> 
>> It does report me if get_maintainers.pl is used anyway, even if no
>> files are specified in MAINTAINERS
>
>As maintainer, or as git heuristics?  But all the same, the rule about
>defconfigs needing to be in MAINTAINERS entires should extend to config
>fragments.
>

Hm, not as maintainer even for main defconfig which is strange. I will add 
fragments as separate files and re-check.

>> > > > > Issue is not in the arch dir to tweak arch's makefile, fragments are
>> > > > > used by some boards and issue lays in omitting their existence by
>> > > > > system of autobuild.
>> > > >
>> > > > Yes, and I'd like to set some good 

Re: [PATCH v5 4/7] board: asus: transformer: add ASUS Transformer T30 family support

2023-06-08 Thread Tom Rini
On Thu, Jun 08, 2023 at 07:54:54PM +0300, Svyatoslav Ryhel wrote:
> чт, 8 черв. 2023 р. о 19:40 Tom Rini  пише:
> >
> > On Thu, Jun 08, 2023 at 06:11:57PM +0300, Svyatoslav Ryhel wrote:
> > > вт, 6 черв. 2023 р. о 22:47 Tom Rini  пише:
> > > >
> > > > On Tue, Jun 06, 2023 at 10:40:53PM +0300, Svyatoslav Ryhel wrote:
> > > > >
> > > > >
> > > > > 6 червня 2023 р. 22:19:44 GMT+03:00, Tom Rini  
> > > > > написав(-ла):
> > > > > >On Tue, Jun 06, 2023 at 10:18:47AM +0300, Svyatoslav Ryhel wrote:
> > > > > >
> > > > > >> The ASUS Transformer T30 family are 2-in-1 detachable tablets
> > > > > >> and AiO developed by ASUS that run the Android operating system
> > > > > >> (TF600T runs Windows RT and P1801-T runs Android and Windows).
> > > > > >> The T30 Transformers feature a 10.1-inch display (apart P1801-T),
> > > > > >> an Nvidia Tegra 3 quad-core chip, 1/2 GB of RAM, and 16/32 GB of
> > > > > >> storage. Transformers board derives from Nvidia Cardhu development
> > > > > >> board.
> > > > > >>
> > > > > >> This patch brings support for 7 known Transformer devices:
> > > > > >> - ASUS Transformer Prime TF201
> > > > > >> - ASUS Transformer Pad TF300T/TF300TG/TF300TL
> > > > > >> - ASUS VivoTab RT TF600T (Windows RT based)
> > > > > >> - ASUS Transformer Infinity TF700T
> > > > > >> - ASUS Transformer AiO P1801-T
> > > > > >>
> > > > > >> Tested-by: Andreas Westman Dorcsak  # all devices
> > > > > >> Signed-off-by: Svyatoslav Ryhel 
> > > > > >> ---
> > > > > >>  arch/arm/dts/Makefile |   7 +
> > > > > >>  arch/arm/dts/tegra30-asus-p1801-t.dts |  17 +
> > > > > >>  arch/arm/dts/tegra30-asus-tf201.dts   |   9 +
> > > > > >>  arch/arm/dts/tegra30-asus-tf300t.dts  |  18 +
> > > > > >>  arch/arm/dts/tegra30-asus-tf300tg.dts |   9 +
> > > > > >>  arch/arm/dts/tegra30-asus-tf300tl.dts |   9 +
> > > > > >>  arch/arm/dts/tegra30-asus-tf600t.dts  |  89 +
> > > > > >>  arch/arm/dts/tegra30-asus-tf700t.dts  |  13 +
> > > > > >>  arch/arm/dts/tegra30-asus-transformer.dtsi| 211 ++
> > > > > >>  arch/arm/mach-tegra/tegra30/Kconfig   |   5 +
> > > > > >>  board/asus/transformer-t30/Kconfig|  23 ++
> > > > > >>  board/asus/transformer-t30/MAINTAINERS|   6 +
> > > > > >>  board/asus/transformer-t30/Makefile   |  11 +
> > > > > >>  .../pinmux-config-transformer.h   | 365 
> > > > > >> ++
> > > > > >>  .../transformer-t30/transformer-t30-spl.c |  41 ++
> > > > > >>  board/asus/transformer-t30/transformer-t30.c  | 201 ++
> > > > > >>  configs/p1801-t.config|   2 +
> > > > > >>  configs/tf201.config  |   2 +
> > > > > >>  configs/tf300t.config |   2 +
> > > > > >>  configs/tf300tg.config|   2 +
> > > > > >>  configs/tf300tl.config|   2 +
> > > > > >>  configs/tf600t.config |   4 +
> > > > > >>  configs/tf700t.config |   2 +
> > > > > >>  configs/transformer_t30_defconfig |  85 
> > > > > >
> > > > > >Sorry for not noticing this part sooner.  Looking in the kernel,
> > > > > >arch/{riscv,powerpc}/Makefile both provide examples of how to 
> > > > > >automate
> > > > > >generating the resulting defconfigs directly. I think we really want
> > > > > >that, and also the config fragments need to be listed in the 
> > > > > >MAINTAINERS
> > > > > >file.
> > > > >
> > > > > Not sure if adding this is a good idea, plus adding fragments into
> > > > > MAINTAINERS may cause even more issues. Iirc buildman uses it as a
> > > > > config source and defining multiple fragments may fail not only for
> > > > > boards under question, but those, already existing in u-boot, as well.
> > > >
> > > > If this causes buildman problems then we'll need to figure out
> > > > something, but it shouldn't.
> > >
> > > Adding fragments into MAINTAINERS does not cause issues but seems to
> > > not have any effect either.
> >
> > Well, get_maintainers.pl will now report who owns them, which it didn't
> > before, yes?
> >
> 
> It does report me if get_maintainers.pl is used anyway, even if no
> files are specified in MAINTAINERS

As maintainer, or as git heuristics?  But all the same, the rule about
defconfigs needing to be in MAINTAINERS entires should extend to config
fragments.

> > > > > Issue is not in the arch dir to tweak arch's makefile, fragments are
> > > > > used by some boards and issue lays in omitting their existence by
> > > > > system of autobuild.
> > > >
> > > > Yes, and I'd like to set some good examples for the first config
> > > > fragments we're adding as I suspect you're the first person to notice
> > > > this works (as a feature not a happenstance) and others will make more
> > > > use if it for more than a few changes.  So I'd like to get things going
> > > > in the right direction.
> > >
> 

[PATCH v2] dt-bindings: riscv: deprecate riscv,isa

2023-06-08 Thread Conor Dooley
From: Conor Dooley 

intro
=

When the RISC-V dt-bindings were accepted upstream in Linux, the base
ISA etc had yet to be ratified. By the ratification of the base ISA,
incompatible changes had snuck into the specifications - for example the
Zicsr and Zifencei extensions were spun out of the base ISA.

Fast forward to today, and the reason for this patch.
Currently the riscv,isa dt property permits only a specific subset of
the ISA string - in particular it excludes version numbering.
With the current constraints, it is not possible to discern whether
"rv64i" means that the hart supports the fence.i instruction, for
example.
Future systems may choose to implement their own instruction fencing,
perhaps using a vendor extension, or they may not implement the optional
counter extensions. Software needs a way to determine this.

versioning schemes
==

"Use the extension versions that are described in the ISA manual" you
may say, and it's not like this has not been considered.
Firstly, software that parses the riscv,isa property at runtime will
need to contain a lookup table of some sort that maps arbitrary versions
to versions it understands. There is not a consistent application of
version number applied to extensions, with a higgledy-piggledy
collection of tags, "bare" and version documents awaiting the reader on
the "recently ratified extensions" page:
https://wiki.riscv.org/display/HOME/Recently+Ratified+Extensions

As an aside, this is reflected in the patch too, since many
extensions have yet to appear in a release of the ISA specs,
and are defined by commits in their respective "working draft"
repositories.

Secondly, there is an issue of backwards compatibility, whereby allowing
numbers in the ISA string, some parsers may be broken. This would
require an additional property to be created to even use the versions in
this manner.

boolean properties
==

If a new property is needed, the whole approach may as well be looked at
from the bottom up. A string with limited character choices etc is
hardly the best approach for communicating extension information to
software.

Switching to using boolean properties, one per extension, allows us to
define explicit meanings for the DT representation of each extension -
rather than the current situation where different operating systems or
other bits of software may impart different meanings to characters in
the string. Clearly the best source of meanings is the specifications
themselves, this just provides us the ability to choose at what point
in time the meaning is set. If an extension changes incompatibility in
the future, a new property will be required.

Off-list, some of the RVI folks have committed to shoring up the wording
in either the ISA specifications, the riscv-isa-manual or
so that in the future, modifications to and additions or removals of
features will require a new extension. Codifying that assertion
somewhere would make it quite unlikely that compatibility would be
broken, but we have the tools required to deal with it, if & when it
crops up.
It is in our collective interest, as consumers of extension meanings, to
define a scheme that enforces compatibility.

The use of boolean properties, rather than elements in a string, will
also permit validation that the strings have a meaning, as well as
potentially reject mutually exclusive combinations, or enforce
dependencies between instructions. That would not be possible with the
current dt-schema infrastructure for arbitrary strings, as we would need
to add a riscv,isa parser to dt-validate! That's not implemented in this
patch, but rather left as future work (for the brave, or the foolish).

acpi


The current ACPI ECR is based on having a string unfortunately, but
ideally ACPI will move to another method, perhaps GUIDs, that give
explicit meaning to extensions.

parser simplicity
=

Many systems that parse DT at runtime already implement an function that
can check for the presence of boolean properties, rather than having to
implement - although unfortunately for backwards compatibility with old
dtbs, existing parsers may not be removable - which may greatly simplify
dt parsing code. For example, in Linux, checking for an extension
becomes as simple as:
of_property_present(extension_node, "zicbom")

vendor extensions
=

Compared to riscv,isa, this proposed scheme promotes vendor extensions,
oft touted as the strength of RISC-V, to first-class citizens.
At present, extensions are defined as meaning what the RISC-V ISA
specifications say they do. There is no realistic way of using that
interface to provide cross-platform definitions for what vendor
extensions mean. Vendor extensions may also have even less consistency
than RVI do in terms of versioning, or no care about backwards
compatibility.
A boolean property allows us to assign explicit meanings on a per vendor
extension basis, backed 

Re: [PATCH v5 4/7] board: asus: transformer: add ASUS Transformer T30 family support

2023-06-08 Thread Svyatoslav Ryhel
чт, 8 черв. 2023 р. о 19:40 Tom Rini  пише:
>
> On Thu, Jun 08, 2023 at 06:11:57PM +0300, Svyatoslav Ryhel wrote:
> > вт, 6 черв. 2023 р. о 22:47 Tom Rini  пише:
> > >
> > > On Tue, Jun 06, 2023 at 10:40:53PM +0300, Svyatoslav Ryhel wrote:
> > > >
> > > >
> > > > 6 червня 2023 р. 22:19:44 GMT+03:00, Tom Rini  
> > > > написав(-ла):
> > > > >On Tue, Jun 06, 2023 at 10:18:47AM +0300, Svyatoslav Ryhel wrote:
> > > > >
> > > > >> The ASUS Transformer T30 family are 2-in-1 detachable tablets
> > > > >> and AiO developed by ASUS that run the Android operating system
> > > > >> (TF600T runs Windows RT and P1801-T runs Android and Windows).
> > > > >> The T30 Transformers feature a 10.1-inch display (apart P1801-T),
> > > > >> an Nvidia Tegra 3 quad-core chip, 1/2 GB of RAM, and 16/32 GB of
> > > > >> storage. Transformers board derives from Nvidia Cardhu development
> > > > >> board.
> > > > >>
> > > > >> This patch brings support for 7 known Transformer devices:
> > > > >> - ASUS Transformer Prime TF201
> > > > >> - ASUS Transformer Pad TF300T/TF300TG/TF300TL
> > > > >> - ASUS VivoTab RT TF600T (Windows RT based)
> > > > >> - ASUS Transformer Infinity TF700T
> > > > >> - ASUS Transformer AiO P1801-T
> > > > >>
> > > > >> Tested-by: Andreas Westman Dorcsak  # all devices
> > > > >> Signed-off-by: Svyatoslav Ryhel 
> > > > >> ---
> > > > >>  arch/arm/dts/Makefile |   7 +
> > > > >>  arch/arm/dts/tegra30-asus-p1801-t.dts |  17 +
> > > > >>  arch/arm/dts/tegra30-asus-tf201.dts   |   9 +
> > > > >>  arch/arm/dts/tegra30-asus-tf300t.dts  |  18 +
> > > > >>  arch/arm/dts/tegra30-asus-tf300tg.dts |   9 +
> > > > >>  arch/arm/dts/tegra30-asus-tf300tl.dts |   9 +
> > > > >>  arch/arm/dts/tegra30-asus-tf600t.dts  |  89 +
> > > > >>  arch/arm/dts/tegra30-asus-tf700t.dts  |  13 +
> > > > >>  arch/arm/dts/tegra30-asus-transformer.dtsi| 211 ++
> > > > >>  arch/arm/mach-tegra/tegra30/Kconfig   |   5 +
> > > > >>  board/asus/transformer-t30/Kconfig|  23 ++
> > > > >>  board/asus/transformer-t30/MAINTAINERS|   6 +
> > > > >>  board/asus/transformer-t30/Makefile   |  11 +
> > > > >>  .../pinmux-config-transformer.h   | 365 
> > > > >> ++
> > > > >>  .../transformer-t30/transformer-t30-spl.c |  41 ++
> > > > >>  board/asus/transformer-t30/transformer-t30.c  | 201 ++
> > > > >>  configs/p1801-t.config|   2 +
> > > > >>  configs/tf201.config  |   2 +
> > > > >>  configs/tf300t.config |   2 +
> > > > >>  configs/tf300tg.config|   2 +
> > > > >>  configs/tf300tl.config|   2 +
> > > > >>  configs/tf600t.config |   4 +
> > > > >>  configs/tf700t.config |   2 +
> > > > >>  configs/transformer_t30_defconfig |  85 
> > > > >
> > > > >Sorry for not noticing this part sooner.  Looking in the kernel,
> > > > >arch/{riscv,powerpc}/Makefile both provide examples of how to automate
> > > > >generating the resulting defconfigs directly. I think we really want
> > > > >that, and also the config fragments need to be listed in the 
> > > > >MAINTAINERS
> > > > >file.
> > > >
> > > > Not sure if adding this is a good idea, plus adding fragments into
> > > > MAINTAINERS may cause even more issues. Iirc buildman uses it as a
> > > > config source and defining multiple fragments may fail not only for
> > > > boards under question, but those, already existing in u-boot, as well.
> > >
> > > If this causes buildman problems then we'll need to figure out
> > > something, but it shouldn't.
> >
> > Adding fragments into MAINTAINERS does not cause issues but seems to
> > not have any effect either.
>
> Well, get_maintainers.pl will now report who owns them, which it didn't
> before, yes?
>

It does report me if get_maintainers.pl is used anyway, even if no
files are specified in MAINTAINERS

> > > > Issue is not in the arch dir to tweak arch's makefile, fragments are
> > > > used by some boards and issue lays in omitting their existence by
> > > > system of autobuild.
> > >
> > > Yes, and I'd like to set some good examples for the first config
> > > fragments we're adding as I suspect you're the first person to notice
> > > this works (as a feature not a happenstance) and others will make more
> > > use if it for more than a few changes.  So I'd like to get things going
> > > in the right direction.
> >
> > May you specify more, what do you exactly want from me to change.
>
> Well, as this just came up on the IRC channel as well as someone else
> noticed fragments work, it would be nice to figure out what needs to
> be added so they can live in $(BOARDDIR) if possible.  Or something that
> doesn't cause a further explosion of files in configs/ (which is already
> unwieldy).
>

I see your point but it is 

Re: [PATCH v5 4/7] board: asus: transformer: add ASUS Transformer T30 family support

2023-06-08 Thread Tom Rini
On Thu, Jun 08, 2023 at 06:11:57PM +0300, Svyatoslav Ryhel wrote:
> вт, 6 черв. 2023 р. о 22:47 Tom Rini  пише:
> >
> > On Tue, Jun 06, 2023 at 10:40:53PM +0300, Svyatoslav Ryhel wrote:
> > >
> > >
> > > 6 червня 2023 р. 22:19:44 GMT+03:00, Tom Rini  
> > > написав(-ла):
> > > >On Tue, Jun 06, 2023 at 10:18:47AM +0300, Svyatoslav Ryhel wrote:
> > > >
> > > >> The ASUS Transformer T30 family are 2-in-1 detachable tablets
> > > >> and AiO developed by ASUS that run the Android operating system
> > > >> (TF600T runs Windows RT and P1801-T runs Android and Windows).
> > > >> The T30 Transformers feature a 10.1-inch display (apart P1801-T),
> > > >> an Nvidia Tegra 3 quad-core chip, 1/2 GB of RAM, and 16/32 GB of
> > > >> storage. Transformers board derives from Nvidia Cardhu development
> > > >> board.
> > > >>
> > > >> This patch brings support for 7 known Transformer devices:
> > > >> - ASUS Transformer Prime TF201
> > > >> - ASUS Transformer Pad TF300T/TF300TG/TF300TL
> > > >> - ASUS VivoTab RT TF600T (Windows RT based)
> > > >> - ASUS Transformer Infinity TF700T
> > > >> - ASUS Transformer AiO P1801-T
> > > >>
> > > >> Tested-by: Andreas Westman Dorcsak  # all devices
> > > >> Signed-off-by: Svyatoslav Ryhel 
> > > >> ---
> > > >>  arch/arm/dts/Makefile |   7 +
> > > >>  arch/arm/dts/tegra30-asus-p1801-t.dts |  17 +
> > > >>  arch/arm/dts/tegra30-asus-tf201.dts   |   9 +
> > > >>  arch/arm/dts/tegra30-asus-tf300t.dts  |  18 +
> > > >>  arch/arm/dts/tegra30-asus-tf300tg.dts |   9 +
> > > >>  arch/arm/dts/tegra30-asus-tf300tl.dts |   9 +
> > > >>  arch/arm/dts/tegra30-asus-tf600t.dts  |  89 +
> > > >>  arch/arm/dts/tegra30-asus-tf700t.dts  |  13 +
> > > >>  arch/arm/dts/tegra30-asus-transformer.dtsi| 211 ++
> > > >>  arch/arm/mach-tegra/tegra30/Kconfig   |   5 +
> > > >>  board/asus/transformer-t30/Kconfig|  23 ++
> > > >>  board/asus/transformer-t30/MAINTAINERS|   6 +
> > > >>  board/asus/transformer-t30/Makefile   |  11 +
> > > >>  .../pinmux-config-transformer.h   | 365 ++
> > > >>  .../transformer-t30/transformer-t30-spl.c |  41 ++
> > > >>  board/asus/transformer-t30/transformer-t30.c  | 201 ++
> > > >>  configs/p1801-t.config|   2 +
> > > >>  configs/tf201.config  |   2 +
> > > >>  configs/tf300t.config |   2 +
> > > >>  configs/tf300tg.config|   2 +
> > > >>  configs/tf300tl.config|   2 +
> > > >>  configs/tf600t.config |   4 +
> > > >>  configs/tf700t.config |   2 +
> > > >>  configs/transformer_t30_defconfig |  85 
> > > >
> > > >Sorry for not noticing this part sooner.  Looking in the kernel,
> > > >arch/{riscv,powerpc}/Makefile both provide examples of how to automate
> > > >generating the resulting defconfigs directly. I think we really want
> > > >that, and also the config fragments need to be listed in the MAINTAINERS
> > > >file.
> > >
> > > Not sure if adding this is a good idea, plus adding fragments into
> > > MAINTAINERS may cause even more issues. Iirc buildman uses it as a
> > > config source and defining multiple fragments may fail not only for
> > > boards under question, but those, already existing in u-boot, as well.
> >
> > If this causes buildman problems then we'll need to figure out
> > something, but it shouldn't.
> 
> Adding fragments into MAINTAINERS does not cause issues but seems to
> not have any effect either.

Well, get_maintainers.pl will now report who owns them, which it didn't
before, yes?

> > > Issue is not in the arch dir to tweak arch's makefile, fragments are
> > > used by some boards and issue lays in omitting their existence by
> > > system of autobuild.
> >
> > Yes, and I'd like to set some good examples for the first config
> > fragments we're adding as I suspect you're the first person to notice
> > this works (as a feature not a happenstance) and others will make more
> > use if it for more than a few changes.  So I'd like to get things going
> > in the right direction.
> 
> May you specify more, what do you exactly want from me to change.

Well, as this just came up on the IRC channel as well as someone else
noticed fragments work, it would be nice to figure out what needs to
be added so they can live in $(BOARDDIR) if possible.  Or something that
doesn't cause a further explosion of files in configs/ (which is already
unwieldy).

> > > >I also worry that none of these other configs will be caught by buildmn
> > > >and so won't be in CI at all, just the base.  Which isn't a big problem,
> > > >yet, but could be as more people use config fragments. I'm just noting
> > > >this secondary part and not saying you need to fix that as well.
> > > >
> > >
> > > Buildman indeed is not catching any fragments, which 

Re: [PATCH v5 2/2] serial: zynqmp: Fetch baudrate from dtb and update

2023-06-08 Thread Tom Rini
On Thu, Jun 08, 2023 at 10:50:36AM +0200, Michal Simek wrote:
> 
> 
> On 6/7/23 21:13, Tom Rini wrote:
> > On Thu, May 25, 2023 at 09:32:59AM +0530, Venkatesh Yadav Abbarapu wrote:
> > 
> > > From: Algapally Santosh Sagar 
> > > 
> > > The baudrate configured in .config is taken by default by serial. If
> > > change of baudrate is required then the .config needs to changed and
> > > u-boot recompilation is required or the u-boot environment needs to be
> > > updated.
> > > 
> > > To avoid this, support is added to fetch the baudrate directly from the
> > > device tree file and update.
> > > The serial, prints the log with the configured baudrate in the dtb.
> > > The commit c4df0f6f315c ("arm: mvebu: Espressobin: Set default value for
> > > $fdtfile env variable") is taken as reference for changing the default
> > > environment variable.
> > > 
> > > The default environment stores the default baudrate value, When default
> > > baudrate and dtb baudrate are not same glitches are seen on the serial.
> > > So, the environment also needs to be updated with the dtb baudrate to
> > > avoid the glitches on the serial.
> > > 
> > > Signed-off-by: Algapally Santosh Sagar 
> > > Signed-off-by: Venkatesh Yadav Abbarapu 
> > > ---
> > >   doc/README.serial_dt_baud  | 41 +
> > 
> > Sorry I missed this until v5.  This needs to be in rST and under doc/
> > somewhere (and make htmldocs happy).
> 
> Any other issue with implementation?

Nope, I noticed this while preparing to apply it to -next.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 12/12] arm: dts: stm32: Add partitions in flash0 and nand node for stm32mp15xx-dhcom/dhcor

2023-06-08 Thread Patrick Delaunay
Add partitions subnode in flash0 for stm32mp157xx-dhcom/dhcor boards.

Signed-off-by: Patrick Delaunay 
---

 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi | 27 ++
 arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi | 27 ++
 configs/stm32mp15_dhcom_basic_defconfig|  3 ---
 configs/stm32mp15_dhcor_basic_defconfig|  3 ---
 4 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi 
b/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi
index bc0730cf2bd0..a808620e1219 100644
--- a/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi
@@ -92,6 +92,33 @@
 
  {
bootph-pre-ram;
+
+   partitions {
+   compatible = "fixed-partitions";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   partition@0 {
+   label = "fsbl1";
+   reg = <0x 0x0004>;
+   };
+   partition@4 {
+   label = "fsbl2";
+   reg = <0x0004 0x0004>;
+   };
+   partition@50 {
+   label = "uboot";
+   reg = <0x0008 0x0016>;
+   };
+   partition@90 {
+   label = "env1";
+   reg = <0x001E 0x0001>;
+   };
+   partition@98 {
+   label = "env2";
+   reg = <0x001F 0x0001>;
+   };
+   };
 };
 
  {
diff --git a/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi 
b/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi
index 804c66283e08..eb905ad28201 100644
--- a/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi
@@ -28,6 +28,33 @@
 
  {
bootph-pre-ram;
+
+   partitions {
+   compatible = "fixed-partitions";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   partition@0 {
+   label = "fsbl1";
+   reg = <0x 0x0004>;
+   };
+   partition@4 {
+   label = "fsbl2";
+   reg = <0x0004 0x0004>;
+   };
+   partition@50 {
+   label = "uboot";
+   reg = <0x0008 0x0016>;
+   };
+   partition@90 {
+   label = "env1";
+   reg = <0x001E 0x0001>;
+   };
+   partition@98 {
+   label = "env2";
+   reg = <0x001F 0x0001>;
+   };
+   };
 };
 
  {
diff --git a/configs/stm32mp15_dhcom_basic_defconfig 
b/configs/stm32mp15_dhcom_basic_defconfig
index 430d0bccc9a7..77f0fafc5c71 100644
--- a/configs/stm32mp15_dhcom_basic_defconfig
+++ b/configs/stm32mp15_dhcom_basic_defconfig
@@ -85,9 +85,6 @@ CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_BTRFS=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
-CONFIG_MTDIDS_DEFAULT="nor0=nor0"
-CONFIG_MTDPARTS_DEFAULT="mtdparts=nor0:256k(fsbl1),256k(fsbl2),1408k(uboot),64k(env1),64k(env2)"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_ISO_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
diff --git a/configs/stm32mp15_dhcor_basic_defconfig 
b/configs/stm32mp15_dhcor_basic_defconfig
index f23875fb84fe..4151ad64a4be 100644
--- a/configs/stm32mp15_dhcor_basic_defconfig
+++ b/configs/stm32mp15_dhcor_basic_defconfig
@@ -83,9 +83,6 @@ CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_BTRFS=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
-CONFIG_MTDIDS_DEFAULT="nor0=nor0"
-CONFIG_MTDPARTS_DEFAULT="mtdparts=nor0:256k(fsbl1),256k(fsbl2),1408k(uboot),64k(env1),64k(env2)"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_ISO_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
-- 
2.25.1



[PATCH 10/12] stm32mp: stm32prog: Remove tee_detected from stm32prog_data struct

2023-06-08 Thread Patrick Delaunay
From: Patrice Chotard 

As stm32prog_get_tee_partitions() is no more used, remove tee_detected
boolean from stm32prog_data struct and all code using it.

Signed-off-by: Patrice Chotard 
Signed-off-by: Patrick Delaunay 
---

 arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c |  9 -
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 11 ---
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h |  3 ---
 arch/arm/mach-stm32mp/include/mach/stm32prog.h  |  4 
 4 files changed, 27 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
index cfafa539aeb9..c695cc11232b 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
@@ -180,15 +180,6 @@ U_BOOT_CMD(stm32prog, 5, 0, do_stm32prog,
   "   = size of flashlayout (optional for image with STM32 
header)\n"
 );
 
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-bool stm32prog_get_tee_partitions(void)
-{
-   if (stm32prog_data)
-   return stm32prog_data->tee_detected;
-
-   return false;
-}
-#endif
 
 bool stm32prog_get_fsbl_nor(void)
 {
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 241ad40abb7c..0cdc14dd5bc8 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -995,9 +995,6 @@ static int treat_partition_list(struct stm32prog_data *data)
INIT_LIST_HEAD(>dev[j].part_list);
}
 
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-   data->tee_detected = false;
-#endif
data->fsbl_nor_detected = false;
for (i = 0; i < data->part_nb; i++) {
part = >part_array[i];
@@ -1049,14 +1046,6 @@ static int treat_partition_list(struct stm32prog_data 
*data)
!strncmp(part->name, "fsbl", 4))
data->fsbl_nor_detected = true;
/* fallthrough */
-   case STM32PROG_NAND:
-   case STM32PROG_SPI_NAND:
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-   if (!data->tee_detected &&
-   !strncmp(part->name, "tee", 3))
-   data->tee_detected = true;
-   break;
-#endif
default:
break;
}
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
index 58f4b96fa752..04a899ee1184 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
@@ -149,9 +149,6 @@ struct stm32prog_data {
struct stm32prog_dev_t  dev[STM32PROG_MAX_DEV]; /* array of device */
int part_nb;/* nb of partition */
struct stm32prog_part_t *part_array;/* array of partition */
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-   booltee_detected;
-#endif
boolfsbl_nor_detected;
 
/* command internal information */
diff --git a/arch/arm/mach-stm32mp/include/mach/stm32prog.h 
b/arch/arm/mach-stm32mp/include/mach/stm32prog.h
index 99be4e1d656b..23d1adfbad92 100644
--- a/arch/arm/mach-stm32mp/include/mach/stm32prog.h
+++ b/arch/arm/mach-stm32mp/include/mach/stm32prog.h
@@ -11,8 +11,4 @@ int stm32prog_read_medium_virt(struct dfu_entity *dfu, u64 
offset,
   void *buf, long *len);
 int stm32prog_get_medium_size_virt(struct dfu_entity *dfu, u64 *size);
 
-#ifdef CONFIG_STM32MP15x_STM32IMAGE
-bool stm32prog_get_tee_partitions(void);
-#endif
-
 bool stm32prog_get_fsbl_nor(void);
-- 
2.25.1



[PATCH 11/12] configs: stm32mp1: disable CMD_MTDPARTS

2023-06-08 Thread Patrick Delaunay
From: Patrice Chotard 

Disable CMD_MTDPARTS as it's no more needed and it is strongly
encouraged to avoid using this command anymore.
(see comments in ./cmd/Kconfig:2422).

Signed-off-by: Patrice Chotard 
Signed-off-by: Patrick Delaunay 
---

 configs/stm32mp13_defconfig | 1 -
 configs/stm32mp15_basic_defconfig   | 1 -
 configs/stm32mp15_defconfig | 1 -
 configs/stm32mp15_trusted_defconfig | 1 -
 4 files changed, 4 deletions(-)

diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig
index a9cc7e4d0353..5e9abc5e2625 100644
--- a/configs/stm32mp13_defconfig
+++ b/configs/stm32mp13_defconfig
@@ -39,7 +39,6 @@ CONFIG_CMD_RNG=y
 CONFIG_CMD_TIMER=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_LIVE=y
diff --git a/configs/stm32mp15_basic_defconfig 
b/configs/stm32mp15_basic_defconfig
index 7661159110e5..94f4dbd4c32b 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -75,7 +75,6 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 # CONFIG_SPL_DOS_PARTITION is not set
diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig
index 1ff9f73730d3..37b6d4a7b4ac 100644
--- a/configs/stm32mp15_defconfig
+++ b/configs/stm32mp15_defconfig
@@ -51,7 +51,6 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_LIVE=y
diff --git a/configs/stm32mp15_trusted_defconfig 
b/configs/stm32mp15_trusted_defconfig
index e7bf2e171ace..9c5446d6d4a2 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -52,7 +52,6 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_LIVE=y
-- 
2.25.1



[PATCH 09/12] board: st: remove board_mtdparts_default

2023-06-08 Thread Patrick Delaunay
Remove the function board_mtdparts_default and the associated file
or configs, only used by the CONFIG_SYS_MTDPARTS_RUNTIME now removed.

Signed-off-by: Patrick Delaunay 
---

 board/st/common/Kconfig|  66 ---
 board/st/common/Makefile   |   1 -
 board/st/common/stm32mp_mtdparts.c | 177 -
 3 files changed, 244 deletions(-)
 delete mode 100644 board/st/common/stm32mp_mtdparts.c

diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig
index aba3590866e0..c1c254d07354 100644
--- a/board/st/common/Kconfig
+++ b/board/st/common/Kconfig
@@ -6,72 +6,6 @@ config CMD_STBOARD
  This compile the stboard command to
  read and write the board in the OTP.
 
-config MTDPARTS_NAND0_BOOT
-   string "mtd boot partitions for nand0"
-   default "2m(fsbl),2m(ssbl1),2m(ssbl2)" if STM32MP15x_STM32IMAGE || \
- !TFABOOT
-   default "2m(fsbl),4m(fip1),4m(fip2)"
-   depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
-   help
- This define the partitions of nand0 used to build mtparts dynamically
- for boot from nand0.
- Each partition need to be aligned with the device erase block size,
- 512KB is the max size for the NAND supported by stm32mp1 platform.
- The fsbl partition support multiple copy of the same binary, one by
- erase block.
-
-config MTDPARTS_NAND0_TEE
-   string "mtd tee partitions for nand0"
-   default "512k(teeh),512k(teed),512k(teex)"
-   depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE
-   help
- This define the tee partitions added in mtparts dynamically
- when tee is supported with boot from nand0.
- Each partition need to be aligned with the device erase block size,
- 512KB is the max size for the NAND supported by stm32mp1 platform.
-
-config MTDPARTS_NOR0_BOOT
-   string "mtd boot partitions for nor0"
-   default "256k(fsbl1),256k(fsbl2),2m(ssbl),512k(u-boot-env)" if 
STM32MP15x_STM32IMAGE || \
-  !TFABOOT
-   default "256k(fsbl1),256k(fsbl2),4m(fip),512k(u-boot-env)"
-   depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
-   help
- This define the partitions of nand0 used to build mtparts dynamically
- for boot from nor0.
- Each partition need to be aligned with the device erase block size,
- with 256KB we support all the NOR.
- U-Boot env partition (512kB) use 2 erase block for redundancy.
-
-config MTDPARTS_NOR0_TEE
-   string "mtd tee partitions for nor0"
-   default "256k(teeh),512k(teed),256k(teex)"
-   depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE
-   help
- This define the tee partitions added in mtparts dynamically
- when tee is supported with boot from nor0.
-
-config MTDPARTS_SPINAND0_BOOT
-   string "mtd boot partitions for spi-nand0"
-   default "2m(fsbl),2m(ssbl1),2m(ssbl2)" if STM32MP15x_STM32IMAGE || 
!TFABOOT
-   default "2m(fsbl),4m(fip1),4m(fip2)"
-   depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
-   help
- This define the partitions of nand0 used to build mtparts dynamically
- for boot from spi-nand0,
- 512KB is the max size for the NAND supported by stm32mp1 platform.
- The fsbl partition support multiple copy of the same binary, one by
- erase block.
-
-config MTDPARTS_SPINAND0_TEE
-   string "mtd tee partitions for spi-nand0"
-   default "512k(teeh),512k(teed),512k(teex)"
-   depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP && STM32MP15x_STM32IMAGE
-   help
- This define the tee partitions added in mtparts dynamically
- when tee is supported with boot from spi-nand0,
- 512KB is the max size for the NAND supported by stm32mp1 platform.
-
 config DFU_ALT_RAM0
string "dfu for ram0"
default "uImage ram 0xc200 0x200;devicetree.dtb ram 0xc400 
0x10;uramdisk.image.gz ram 0xc440 0x1000"
diff --git a/board/st/common/Makefile b/board/st/common/Makefile
index 65bbebd6abc3..c9608297261a 100644
--- a/board/st/common/Makefile
+++ b/board/st/common/Makefile
@@ -7,7 +7,6 @@ obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o
 obj-$(CONFIG_PMIC_STPMIC1) += stpmic1.o
 
 ifeq ($(CONFIG_ARCH_STM32MP),y)
-obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += stm32mp_mtdparts.o
 obj-$(CONFIG_SET_DFU_ALT_INFO) += stm32mp_dfu.o
 endif
 
diff --git a/board/st/common/stm32mp_mtdparts.c 
b/board/st/common/stm32mp_mtdparts.c
deleted file mode 100644
index 67a56a2623a1..
--- a/board/st/common/stm32mp_mtdparts.c
+++ /dev/null
@@ -1,177 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
-/*
- * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 

[PATCH 08/12] board: stm32mp1: use fdt_copy_fixed_partitions

2023-06-08 Thread Patrick Delaunay
Copy the fixed partition nodes from U-Boot device tree to Linux kernel
device tree to dynamically configure the MTD partitions.

fdt_copy_fixed_partitions is only based on device tree
and replace the function fdt_fixup_mtdparts based on mtdparts variable;
the variable mtdid and mtdparts are not more required.

Signed-off-by: Patrick Delaunay 
---

 board/st/stm32mp1/stm32mp1.c| 16 +---
 configs/stm32mp13_defconfig |  1 -
 configs/stm32mp15_basic_defconfig   |  1 -
 configs/stm32mp15_defconfig |  1 -
 configs/stm32mp15_trusted_defconfig |  1 -
 5 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 1a1b1844c8c0..be850151e5fc 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -915,20 +914,7 @@ int mmc_get_env_dev(void)
 #if defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
-   static const struct node_info nodes[] = {
-   { "jedec,spi-nor",  MTD_DEV_TYPE_NOR,  },
-   { "spi-nand",   MTD_DEV_TYPE_SPINAND},
-   { "st,stm32mp15-fmc2",  MTD_DEV_TYPE_NAND, },
-   { "st,stm32mp1-fmc2-nfc",   MTD_DEV_TYPE_NAND, },
-   };
-   char *boot_device;
-
-   /* Check the boot-source and don't update MTD for serial or usb boot */
-   boot_device = env_get("boot_device");
-   if (!boot_device ||
-   (strcmp(boot_device, "serial") && strcmp(boot_device, "usb")))
-   if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS))
-   fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
+   fdt_copy_fixed_partitions(blob);
 
if (IS_ENABLED(CONFIG_FDT_SIMPLEFB))
fdt_simplefb_enable_and_mem_rsv(blob);
diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig
index 02a29cd9f03a..a9cc7e4d0353 100644
--- a/configs/stm32mp13_defconfig
+++ b/configs/stm32mp13_defconfig
@@ -74,7 +74,6 @@ CONFIG_TEE=y
 CONFIG_OPTEE=y
 # CONFIG_OPTEE_TA_AVB is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
diff --git a/configs/stm32mp15_basic_defconfig 
b/configs/stm32mp15_basic_defconfig
index 273b72fdaf0a..7661159110e5 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -188,7 +188,6 @@ CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
 # CONFIG_BINMAN_FDT is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig
index b1f0f2f7c784..1ff9f73730d3 100644
--- a/configs/stm32mp15_defconfig
+++ b/configs/stm32mp15_defconfig
@@ -164,7 +164,6 @@ CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
 # CONFIG_BINMAN_FDT is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
diff --git a/configs/stm32mp15_trusted_defconfig 
b/configs/stm32mp15_trusted_defconfig
index bcfd60e5a85a..e7bf2e171ace 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -164,7 +164,6 @@ CONFIG_WDT=y
 CONFIG_WDT_STM32MP=y
 # CONFIG_BINMAN_FDT is not set
 CONFIG_ERRNO_STR=y
-CONFIG_FDT_FIXUP_PARTITIONS=y
 # CONFIG_LMB_USE_MAX_REGIONS is not set
 CONFIG_LMB_MEMORY_REGIONS=2
 CONFIG_LMB_RESERVED_REGIONS=16
-- 
2.25.1



[PATCH 07/12] configs: stm32mp: Disable SYS_MTDPARTS_RUNTIME for stm32mp15 and stm32mp13

2023-06-08 Thread Patrick Delaunay
From: Patrice Chotard 

As we don't use anymore MTDPARTS_xx Kconfig variables
(MTDPARTS_NAND0_BOOT, MTDPARTS_NOR0_BOOT...),
disable SYS_MTDPARTS_RUNTIME.

Signed-off-by: Patrice Chotard 
Signed-off-by: Patrick Delaunay 
---

 configs/stm32mp13_defconfig | 1 -
 configs/stm32mp15_basic_defconfig   | 1 -
 configs/stm32mp15_defconfig | 1 -
 configs/stm32mp15_trusted_defconfig | 1 -
 4 files changed, 4 deletions(-)

diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig
index b076573c450f..02a29cd9f03a 100644
--- a/configs/stm32mp13_defconfig
+++ b/configs/stm32mp13_defconfig
@@ -59,7 +59,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_PINCONF=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
diff --git a/configs/stm32mp15_basic_defconfig 
b/configs/stm32mp15_basic_defconfig
index 13355ebb4692..273b72fdaf0a 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -125,7 +125,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_STM32_FMC2=y
 CONFIG_SYS_NAND_ONFI_DETECTION=y
diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig
index bad5c32ef808..b1f0f2f7c784 100644
--- a/configs/stm32mp15_defconfig
+++ b/configs/stm32mp15_defconfig
@@ -98,7 +98,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_STM32_FMC2=y
 CONFIG_SYS_NAND_ONFI_DETECTION=y
diff --git a/configs/stm32mp15_trusted_defconfig 
b/configs/stm32mp15_trusted_defconfig
index 5f0fb4565105..bcfd60e5a85a 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -99,7 +99,6 @@ CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
-CONFIG_SYS_MTDPARTS_RUNTIME=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_STM32_FMC2=y
 CONFIG_SYS_NAND_ONFI_DETECTION=y
-- 
2.25.1



[PATCH 06/12] arm: dts: stm32: Add partitions in flash0 and nand node for stm32mp15xx-ev1

2023-06-08 Thread Patrick Delaunay
From: Patrice Chotard 

Add partitions subnode in flash0 and nand nodes for all stm32mp157xx-ev1
boards. Update only the file stm32mp157c-ev1-*u-boot.dtsi, included by
other files  stm32mp15*-ev1-*-u-boot.dtsi.

For SCMI variant of device tree used with stm32mp15_defconfig
add partitions needed by TF-A firmware update:
- metadata to save the TF-A information: 2 copy
- fip-a / fip-b: two FIP slots, used for system A/B (seamless) update
- the previous "fsbl" partition with 2 copy of TFA is replaced
  by 2 partitions (only one copy in each MTD partition) to simplify
  the update: no need to managed this copy on update, need to update the
  two partition (skip bad block for NAND)
The offset for ENV partition are also updated in stm32mp15_defconfig

Signed-off-by: Patrick Delaunay 
Signed-off-by: Patrice Chotard 
---

 arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi | 85 
 arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi  | 98 ++-
 configs/stm32mp15_defconfig   |  4 +-
 3 files changed, 184 insertions(+), 3 deletions(-)

diff --git a/arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi 
b/arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi
index eef717946b5f..9768db8de9c9 100644
--- a/arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi
@@ -23,6 +23,91 @@
 
  {
bootph-pre-ram;
+   partitions {
+   compatible = "fixed-partitions";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   partition@0 {
+   label = "fsbl1";
+   reg = <0x 0x0004>;
+   };
+   partition@4 {
+   label = "fsbl2";
+   reg = <0x0004 0x0004>;
+   };
+   partition@8 {
+   label = "metadata1";
+   reg = <0x0008 0x0004>;
+   };
+   partition@c {
+   label = "metadata2";
+   reg = <0x000c 0x0004>;
+   };
+   partition@10 {
+   label = "fip-a";
+   reg = <0x0010 0x0040>;
+   };
+   partition@50 {
+   label = "fip-b";
+   reg = <0x0050 0x0040>;
+   };
+   partition@90 {
+   label = "u-boot-env";
+   reg = <0x0090 0x0008>;
+   };
+   partition@98 {
+   label = "nor-user";
+   reg = <0x0098 0x0368>;
+   };
+   };
+};
+
+ {
+   nand-controller@4,0 {
+   nand@0 {
+   partitions {
+   compatible = "fixed-partitions";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   partition@0 {
+   label = "fsbl1";
+   reg = <0x 0x0008>;
+   };
+   partition@8 {
+   label = "fsbl2";
+   reg = <0x0008 0x0008>;
+   };
+   partition@10 {
+   label = "metadata1";
+   reg = <0x0010 0x0008>;
+   };
+   partition@18 {
+   label = "metadata2";
+   reg = <0x0018 0x0008>;
+   };
+   partition@20 {
+   label = "fip-a1";
+   reg = <0x0020 0x0040>;
+   };
+   partition@60 {
+   label = "fip-a2";
+   reg = <0x0060 0x0040>;
+   };
+   partition@a0 {
+   label = "fip-b1";
+   reg = <0x00a0 0x0040>;
+   };
+   partition@e0 {
+   label = "fip-b2";
+   reg = <0x00e0 0x0040>;
+   };
+   partition@120 {
+   label = "UBI";
+   reg = <0x0120 0x3ee0>;
+   };
+   };
+   };
+   };
 

[PATCH 05/12] arm: dts: stm32: Align stm32mp15xx-*-scmi-u-boot.dtsi file

2023-06-08 Thread Patrick Delaunay
Update "secure" version of STM32 boards based on SCMI when RCC_TZCR.TZEN=1
stm32mp15xx-*-scmi-u-boot.dtsi with latest patches on files
stm32mp15xx-*-u-boot.dtsi.

Signed-off-by: Patrick Delaunay 
---

 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi  |  1 +
 arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi |  7 
 arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi | 40 +++
 3 files changed, 48 insertions(+)

diff --git a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi 
b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
index cff3f49948e4..2623cebf21a4 100644
--- a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
@@ -12,6 +12,7 @@
i2c3 = 
usb0 = _hs;
};
+
config {
u-boot,boot-led = "heartbeat";
u-boot,error-led = "error";
diff --git a/arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi 
b/arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi
index 5a8fc15ab2b7..ae93497cd5a8 100644
--- a/arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi
@@ -4,3 +4,10 @@
  */
 
 #include "stm32mp157a-dk1-scmi-u-boot.dtsi"
+
+/ {
+   fwu-mdata {
+   compatible = "u-boot,fwu-mdata-gpt";
+   fwu-mdata-store = <>;
+   };
+};
diff --git a/arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi 
b/arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi
index 71a94f9130a6..eef717946b5f 100644
--- a/arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi
@@ -14,4 +14,44 @@
spi0 = 
usb0 = _hs;
};
+
+   fwu-mdata {
+   compatible = "u-boot,fwu-mdata-gpt";
+   fwu-mdata-store = <>;
+   };
+};
+
+ {
+   bootph-pre-ram;
+};
+
+ {
+   bootph-pre-ram;
+};
+
+_clk_pins_a {
+   bootph-pre-ram;
+   pins {
+   bootph-pre-ram;
+   };
+};
+
+_bk1_pins_a {
+   bootph-pre-ram;
+   pins1 {
+   bootph-pre-ram;
+   };
+   pins2 {
+   bootph-pre-ram;
+   };
+};
+
+_bk2_pins_a {
+   bootph-pre-ram;
+   pins1 {
+   bootph-pre-ram;
+   };
+   pins2 {
+   bootph-pre-ram;
+   };
 };
-- 
2.25.1



[PATCH 04/12] stm32mp: stm32prog: Remove usage of "mtdparts" function

2023-06-08 Thread Patrick Delaunay
From: Patrice Chotard 

Motivation for this patch is to remove usage of function define
in cmd/mtdparts.c interface, based on env variables mtdids and mtdparts:
mtdparts_init() and find_dev_and_part().
See commit 938db6fe5da3 ("cmd: mtdparts: describe as legacy")

Now, all MTD devices are populated with their partition's information
found in DT, accessible in MTD devices. Use these information to find
the wanted partitions, no more need of find_dev_and_part() usage.

Signed-off-by: Patrice Chotard 
Signed-off-by: Patrick Delaunay 
---

 .../mach-stm32mp/cmd_stm32prog/stm32prog.c| 42 +--
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 6f3641ccf57b..241ad40abb7c 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -208,11 +208,6 @@ static int optee_ta_invoke(struct stm32prog_data *data, 
int cmd, int type,
return rc;
 }
 
-/* partition handling routines : CONFIG_CMD_MTDPARTS */
-int mtdparts_init(void);
-int find_dev_and_part(const char *id, struct mtd_device **dev,
- u8 *part_num, struct part_info **part);
-
 char *stm32prog_get_error(struct stm32prog_data *data)
 {
static const char error_msg[] = "Unspecified";
@@ -741,6 +736,7 @@ static int init_device(struct stm32prog_data *data,
struct mmc *mmc = NULL;
struct blk_desc *block_dev = NULL;
struct mtd_info *mtd = NULL;
+   struct mtd_info *partition;
char mtd_id[16];
int part_id;
int ret;
@@ -749,6 +745,7 @@ static int init_device(struct stm32prog_data *data,
u64 part_addr, part_size;
bool part_found;
const char *part_name;
+   u8 i;
 
switch (dev->target) {
case STM32PROG_MMC:
@@ -793,10 +790,11 @@ static int init_device(struct stm32prog_data *data,
stm32prog_err("unknown device type = %d", dev->target);
return -ENODEV;
}
+   /* register partitions with MTDIDS/MTDPARTS or OF fallback */
+   mtd_probe_devices();
get_mtd_by_target(mtd_id, dev->target, dev->dev_id);
log_debug("%s\n", mtd_id);
 
-   mtdparts_init();
mtd = get_mtd_device_nm(mtd_id);
if (IS_ERR(mtd)) {
stm32prog_err("MTD device %s not found", mtd_id);
@@ -943,25 +941,23 @@ static int init_device(struct stm32prog_data *data,
}
 
if (IS_ENABLED(CONFIG_MTD) && mtd) {
-   char mtd_part_id[32];
-   struct part_info *mtd_part;
-   struct mtd_device *mtd_dev;
-   u8 part_num;
-
-   sprintf(mtd_part_id, "%s,%d", mtd_id,
-   part->part_id - 1);
-   ret = find_dev_and_part(mtd_part_id, _dev,
-   _num, _part);
-   if (ret != 0) {
-   stm32prog_err("%s (0x%x): Invalid MTD partition 
%s",
- part->name, part->id,
- mtd_part_id);
+   i = 0;
+   list_for_each_entry(partition, >partitions, node) {
+   if ((part->part_id - 1) == i) {
+   part_found = true;
+   break;
+   }
+   i++;
+   }
+   if (part_found) {
+   part_addr = partition->offset;
+   part_size = partition->size;
+   part_name = partition->name;
+   } else {
+   stm32prog_err("%s (0x%x):Couldn't find part %d 
on device mtd %s",
+ part->name, part->id, 
part->part_id, mtd_id);
return -ENODEV;
}
-   part_addr = mtd_part->offset;
-   part_size = mtd_part->size;
-   part_name = mtd_part->name;
-   part_found = true;
}
 
/* no partition for this device */
-- 
2.25.1



[PATCH 00/12] stm32mp1: use U-Boot device tree to configure MTD partitions

2023-06-08 Thread Patrick Delaunay


Add the MTD partitions subnode in U-Boot device tree for all stm32mp13
and stm32mp15 boards and no more rely on mtdids and mtdparts variables
or CONFIG_SYS_MTDPARTS_RUNTIME.

When these variables are absent, the required OF fallback is performed in
mtd_probe_devices() with commit dc339bf784f0 ("mtd: add support for parsing
partitions defined in OF").

To allow dynamically configuration of MTD partitioning for Linux kernel,
the MTD partitioning is only defined in U-Boot device tree and copied
in Linux kernel device tree.

This serie also disable CMD_MTDPARTS as it is strongly encouraged to
no more use this command.

Marek, I modify the dhcom/dhcor boardd in the last patch of the serie
but if you prefer I can drop this patch.

For "stm32mp157c-ev1.dts" used by stm32mp15_trusted_defconfig

* nand0
  - type: NAND flash
  - block size: 0x4 bytes
  - min I/O: 0x1000 bytes
  - OOB size: 224 bytes
  - OOB available: 118 bytes
  - ECC strength: 8 bits
  - ECC step size: 512 bytes
  - bitflip threshold: 6 bits
  - 0x-0x4000 : "nand0"
  - 0x-0x0020 : "fsbl"
  - 0x0020-0x0060 : "fip1"
  - 0x0060-0x00a0 : "fip2"
  - 0x00a0-0x4000 : "UBI"
* nor0
  - device: flash@0
  - parent: spi@58003000
  - driver: jedec_spi_nor
  - path: /soc/spi@58003000/flash@0
  - type: NOR flash
  - block size: 0x1 bytes
  - min I/O: 0x1 bytes
  - 0x-0x0400 : "nor0"
  - 0x-0x0004 : "fsbl1"
  - 0x0004-0x0008 : "fsbl2"
  - 0x0008-0x0048 : "fip"
  - 0x0048-0x0050 : "u-boot-env"
  - 0x0050-0x0400 : "nor-user"


For "stm32mp157c-ev1-scmi.dts" the device tree file used by
stm32mp15_defconfig, with TF-A BL2 and OP-TEE including a SCMI server
for secure resources (when TZEN=1), the default STMicroelectronics
configuration.

I align the NOR and NAND layout on EV1 boards with the STMicroelectronics
recommendations used in OpenSTLinux V4.0:
with support of TF-A BL2 firmware update, required 2 "metadata" partition
for redundancy and 2 FIPs for A/B update.

* nand0
  - type: NAND flash
  - block size: 0x4 bytes
  - min I/O: 0x1000 bytes
  - OOB size: 224 bytes
  - OOB available: 118 bytes
  - ECC strength: 8 bits
  - ECC step size: 512 bytes
  - bitflip threshold: 6 bits
  - 0x-0x4000 : "nand0"
  - 0x-0x0008 : "fsbl1"
  - 0x0008-0x0010 : "fsbl2"
  - 0x0010-0x0018 : "metadata1"
  - 0x0018-0x0020 : "metadata2"
  - 0x0020-0x0060 : "fip-a1"
  - 0x0060-0x00a0 : "fip-a2"
  - 0x00a0-0x00e0 : "fip-b1"
  - 0x00e0-0x0120 : "fip-b2"
  - 0x0120-0x4000 : "UBI"
* nor0
  - device: flash@0
  - parent: spi@58003000
  - driver: jedec_spi_nor
  - path: /soc/spi@58003000/flash@0
  - type: NOR flash
  - block size: 0x1 bytes
  - min I/O: 0x1 bytes
  - 0x-0x0400 : "nor0"
  - 0x-0x0004 : "fsbl1"
  - 0x0004-0x0008 : "fsbl2"
  - 0x0008-0x000c : "metadata1"
  - 0x000c-0x0010 : "metadata2"
  - 0x0010-0x0050 : "fip-a"
  - 0x0050-0x0090 : "fip-b"
  - 0x0090-0x0098 : "u-boot-env"
  - 0x0098-0x0400 : "nor-user"



Patrice Chotard (5):
  stm32mp: stm32prog: Remove usage of "mtdparts" function
  arm: dts: stm32: Add partitions in flash0 and nand node for
stm32mp15xx-ev1
  configs: stm32mp: Disable SYS_MTDPARTS_RUNTIME for stm32mp15 and
stm32mp13
  stm32mp: stm32prog: Remove tee_detected from stm32prog_data struct
  configs: stm32mp1: disable CMD_MTDPARTS

Patrick Delaunay (7):
  fdt_support: include dm/ofnode.h
  fdt_support: add fdt_copy_fixed_partitions function
  dfu: mtd: remove direct call of mtdparts_init function
  arm: dts: stm32: Align stm32mp15xx-*-scmi-u-boot.dtsi file
  board: stm32mp1: use fdt_copy_fixed_partitions
  board: st: remove board_mtdparts_default
  arm: dts: stm32: Add partitions in flash0 and nand node for
stm32mp15xx-dhcom/dhcor

 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi  |   1 +
 arch/arm/dts/stm32mp157c-dk2-scmi-u-boot.dtsi |   7 +
 arch/arm/dts/stm32mp157c-ev1-scmi-u-boot.dtsi | 125 +
 arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi  |  98 +-
 arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi|  27 +++
 arch/arm/dts/stm32mp15xx-dhcor-u-boot.dtsi|  27 +++
 .../cmd_stm32prog/cmd_stm32prog.c |   9 -
 .../mach-stm32mp/cmd_stm32prog/stm32prog.c|  53 ++
 .../mach-stm32mp/cmd_stm32prog/stm32prog.h|   3 -
 .../arm/mach-stm32mp/include/mach/stm32prog.h |   4 -
 board/st/common/Kconfig   

[PATCH 02/12] fdt_support: add fdt_copy_fixed_partitions function

2023-06-08 Thread Patrick Delaunay
Add a new function fdt_copy_fixed_partitions to copy the fixed
partition nodes from U-Boot device tree to Linux kernel
device tree and to dynamically configure the MTD partitions.

This function fdt_copy_fixed_partitions is only based on device tree
with livetree compatible function and replace the function
fdt_fixup_mtdparts based on mtdparts variable.

Signed-off-by: Patrick Delaunay 
---

 common/fdt_support.c  | 73 +++
 include/fdt_support.h |  8 +
 2 files changed, 81 insertions(+)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index ffc59fd8b36a..5e49078f8c35 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -1051,6 +1051,79 @@ void fdt_fixup_mtdparts(void *blob, const struct 
node_info *node_info,
 }
 #endif
 
+int fdt_copy_fixed_partitions(void *blob)
+{
+   ofnode node, subnode;
+   int off, suboff, res;
+   char path[256];
+   int address_cells, size_cells;
+   u8 i, j, child_count;
+
+   node = ofnode_by_compatible(ofnode_null(), "fixed-partitions");
+   while (ofnode_valid(node)) {
+   /* copy the U-Boot fixed partition */
+   address_cells = ofnode_read_simple_addr_cells(node);
+   size_cells = ofnode_read_simple_size_cells(node);
+
+   res = ofnode_get_path(ofnode_get_parent(node), path, 
sizeof(path));
+   if (res)
+   return res;
+
+   off = fdt_path_offset(blob, path);
+   if (off < 0)
+   return -ENODEV;
+
+   off = fdt_find_or_add_subnode(blob, off, "partitions");
+   res = fdt_setprop_string(blob, off, "compatible", 
"fixed-partitions");
+   if (res)
+   return res;
+
+   res = fdt_setprop_u32(blob, off, "#address-cells", 
address_cells);
+   if (res)
+   return res;
+
+   res = fdt_setprop_u32(blob, off, "#size-cells", size_cells);
+   if (res)
+   return res;
+
+   /*
+* parse partition in reverse order as 
fdt_find_or_add_subnode() only
+* insert the new node after the parent's properties
+*/
+   child_count = ofnode_get_child_count(node);
+   for (i = child_count; i > 0 ; i--) {
+   subnode = ofnode_first_subnode(node);
+   if (!ofnode_valid(subnode))
+   break;
+
+   for (j = 0; (j < i - 1); j++)
+   subnode = ofnode_next_subnode(subnode);
+
+   if (!ofnode_valid(subnode))
+   break;
+
+   const u32 *reg;
+   int len;
+
+   suboff = fdt_find_or_add_subnode(blob, off, 
ofnode_get_name(subnode));
+   res = fdt_setprop_string(blob, suboff, "label",
+ofnode_read_string(subnode, 
"label"));
+   if (res)
+   return res;
+
+   reg = ofnode_get_property(subnode, "reg", );
+   res = fdt_setprop(blob, suboff, "reg", reg, len);
+   if (res)
+   return res;
+   }
+
+   /* go to next fixed-partitions node */
+   node = ofnode_by_compatible(node, "fixed-partitions");
+   }
+
+   return 0;
+}
+
 void fdt_del_node_and_alias(void *blob, const char *alias)
 {
int off = fdt_path_offset(blob, alias);
diff --git a/include/fdt_support.h b/include/fdt_support.h
index eeb83e6251d3..2cd836689821 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -256,6 +256,14 @@ static inline void fdt_fixup_mtdparts(void *fdt,
 }
 #endif
 
+/**
+ * copy the fixed-partition nodes from U-Boot device tree to external blob
+ *
+ * @param blob FDT blob to update
+ * Return: 0 if ok, or non-zero on error
+ */
+int fdt_copy_fixed_partitions(void *blob);
+
 void fdt_del_node_and_alias(void *blob, const char *alias);
 
 /**
-- 
2.25.1



[PATCH 03/12] dfu: mtd: remove direct call of mtdparts_init function

2023-06-08 Thread Patrick Delaunay
With MTD support in driver model, the direct call of mtdparts_init
should be avoided and replaced by mtd_probe_devices.

With the modificaton when MTDIDS/MTDPARTS are empty the OF fallback
with partition describe in device tree is correctly performed,
introduced by commit dc339bf784f0 ("mtd: add support for parsing
partitions defined in OF").
With this patch the dependency with CONFIG_CMD_MTDPARTS is removed.

Signed-off-by: Patrick Delaunay 
---

 drivers/dfu/Kconfig   |  1 -
 drivers/dfu/dfu_mtd.c | 34 +++---
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 8d7f13dcb0b5..c3a0b93b25e0 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -41,7 +41,6 @@ config DFU_MMC
 config DFU_MTD
bool "MTD back end for DFU"
depends on DM_MTD
-   depends on CMD_MTDPARTS
help
  This option enables using DFU to read and write to on any MTD device.
 
diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
index c7075f12eca9..75e2f6a42151 100644
--- a/drivers/dfu/dfu_mtd.c
+++ b/drivers/dfu/dfu_mtd.c
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -275,7 +274,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char 
*devstr, char **argv, int a
 {
char *s;
struct mtd_info *mtd;
-   int ret, part;
+   int part;
 
mtd = get_mtd_device_nm(devstr);
if (IS_ERR_OR_NULL(mtd))
@@ -299,10 +298,9 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char 
*devstr, char **argv, int a
if (*s)
return -EINVAL;
} else if ((!strcmp(argv[0], "part")) || (!strcmp(argv[0], "partubi"))) 
{
-   char mtd_id[32];
-   struct mtd_device *mtd_dev;
-   u8 part_num;
-   struct part_info *pi;
+   struct mtd_info *partition;
+   int partnum = 0;
+   bool part_found = false;
 
if (argc != 2)
return -EINVAL;
@@ -313,19 +311,25 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char 
*devstr, char **argv, int a
if (*s)
return -EINVAL;
 
-   sprintf(mtd_id, "%s,%d", devstr, part - 1);
-   printf("using id '%s'\n", mtd_id);
+   /* register partitions with MTDIDS/MTDPARTS or OF fallback */
+   mtd_probe_devices();
 
-   mtdparts_init();
-
-   ret = find_dev_and_part(mtd_id, _dev, _num, );
-   if (ret != 0) {
-   printf("Could not locate '%s'\n", mtd_id);
+   partnum = 0;
+   list_for_each_entry(partition, >partitions, node) {
+   partnum++;
+   if (partnum == part) {
+   part_found = true;
+   break;
+   }
+   }
+   if (!part_found) {
+   printf("No partition %d in %s\n", part, mtd->name);
return -1;
}
+   log_debug("partition %d:%s in %s\n", partnum, partition->name, 
mtd->name);
 
-   dfu->data.mtd.start = pi->offset;
-   dfu->data.mtd.size = pi->size;
+   dfu->data.mtd.start = partition->offset;
+   dfu->data.mtd.size = partition->size;
if (!strcmp(argv[0], "partubi"))
dfu->data.mtd.ubi = 1;
} else {
-- 
2.25.1



[PATCH 01/12] fdt_support: include dm/ofnode.h

2023-06-08 Thread Patrick Delaunay
This patch is a preliminary patch to use ofnode function
is fdt_support to read the U-Boot device tree with livetree
compatible functions.

Signed-off-by: Patrick Delaunay 
---

 common/fdt_support.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 2053fe3bad83..ffc59fd8b36a 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1065,7 +1066,6 @@ void fdt_del_node_and_alias(void *blob, const char *alias)
 
 /* Max address size we deal with */
 #define OF_MAX_ADDR_CELLS  4
-#define OF_BAD_ADDRFDT_ADDR_T_NONE
 #define OF_CHECK_COUNTS(na, ns)((na) > 0 && (na) <= OF_MAX_ADDR_CELLS 
&& \
(ns) > 0)
 
-- 
2.25.1



Re: [PATCH v5 4/7] board: asus: transformer: add ASUS Transformer T30 family support

2023-06-08 Thread Svyatoslav Ryhel
вт, 6 черв. 2023 р. о 22:47 Tom Rini  пише:
>
> On Tue, Jun 06, 2023 at 10:40:53PM +0300, Svyatoslav Ryhel wrote:
> >
> >
> > 6 червня 2023 р. 22:19:44 GMT+03:00, Tom Rini  
> > написав(-ла):
> > >On Tue, Jun 06, 2023 at 10:18:47AM +0300, Svyatoslav Ryhel wrote:
> > >
> > >> The ASUS Transformer T30 family are 2-in-1 detachable tablets
> > >> and AiO developed by ASUS that run the Android operating system
> > >> (TF600T runs Windows RT and P1801-T runs Android and Windows).
> > >> The T30 Transformers feature a 10.1-inch display (apart P1801-T),
> > >> an Nvidia Tegra 3 quad-core chip, 1/2 GB of RAM, and 16/32 GB of
> > >> storage. Transformers board derives from Nvidia Cardhu development
> > >> board.
> > >>
> > >> This patch brings support for 7 known Transformer devices:
> > >> - ASUS Transformer Prime TF201
> > >> - ASUS Transformer Pad TF300T/TF300TG/TF300TL
> > >> - ASUS VivoTab RT TF600T (Windows RT based)
> > >> - ASUS Transformer Infinity TF700T
> > >> - ASUS Transformer AiO P1801-T
> > >>
> > >> Tested-by: Andreas Westman Dorcsak  # all devices
> > >> Signed-off-by: Svyatoslav Ryhel 
> > >> ---
> > >>  arch/arm/dts/Makefile |   7 +
> > >>  arch/arm/dts/tegra30-asus-p1801-t.dts |  17 +
> > >>  arch/arm/dts/tegra30-asus-tf201.dts   |   9 +
> > >>  arch/arm/dts/tegra30-asus-tf300t.dts  |  18 +
> > >>  arch/arm/dts/tegra30-asus-tf300tg.dts |   9 +
> > >>  arch/arm/dts/tegra30-asus-tf300tl.dts |   9 +
> > >>  arch/arm/dts/tegra30-asus-tf600t.dts  |  89 +
> > >>  arch/arm/dts/tegra30-asus-tf700t.dts  |  13 +
> > >>  arch/arm/dts/tegra30-asus-transformer.dtsi| 211 ++
> > >>  arch/arm/mach-tegra/tegra30/Kconfig   |   5 +
> > >>  board/asus/transformer-t30/Kconfig|  23 ++
> > >>  board/asus/transformer-t30/MAINTAINERS|   6 +
> > >>  board/asus/transformer-t30/Makefile   |  11 +
> > >>  .../pinmux-config-transformer.h   | 365 ++
> > >>  .../transformer-t30/transformer-t30-spl.c |  41 ++
> > >>  board/asus/transformer-t30/transformer-t30.c  | 201 ++
> > >>  configs/p1801-t.config|   2 +
> > >>  configs/tf201.config  |   2 +
> > >>  configs/tf300t.config |   2 +
> > >>  configs/tf300tg.config|   2 +
> > >>  configs/tf300tl.config|   2 +
> > >>  configs/tf600t.config |   4 +
> > >>  configs/tf700t.config |   2 +
> > >>  configs/transformer_t30_defconfig |  85 
> > >
> > >Sorry for not noticing this part sooner.  Looking in the kernel,
> > >arch/{riscv,powerpc}/Makefile both provide examples of how to automate
> > >generating the resulting defconfigs directly. I think we really want
> > >that, and also the config fragments need to be listed in the MAINTAINERS
> > >file.
> >
> > Not sure if adding this is a good idea, plus adding fragments into
> > MAINTAINERS may cause even more issues. Iirc buildman uses it as a
> > config source and defining multiple fragments may fail not only for
> > boards under question, but those, already existing in u-boot, as well.
>
> If this causes buildman problems then we'll need to figure out
> something, but it shouldn't.

Adding fragments into MAINTAINERS does not cause issues but seems to
not have any effect either.

>
> > Issue is not in the arch dir to tweak arch's makefile, fragments are
> > used by some boards and issue lays in omitting their existence by
> > system of autobuild.
>
> Yes, and I'd like to set some good examples for the first config
> fragments we're adding as I suspect you're the first person to notice
> this works (as a feature not a happenstance) and others will make more
> use if it for more than a few changes.  So I'd like to get things going
> in the right direction.

May you specify more, what do you exactly want from me to change.

> >
> > >I also worry that none of these other configs will be caught by buildmn
> > >and so won't be in CI at all, just the base.  Which isn't a big problem,
> > >yet, but could be as more people use config fragments. I'm just noting
> > >this secondary part and not saying you need to fix that as well.
> > >
> >
> > Buildman indeed is not catching any fragments, which already caused me 
> > issues since defconfigs are not as generic as I would like to (since else I 
> > get a big chunk of checks failed).
> >
> > A good solution might be to tweak buildman to accept fragments if any are 
> > defined in the dedicated field of MAINTAINERS file. But that would be a 
> > major patchset to implement on the entire project scale.
>
> Yes, I'm not sure how best to deal with fragments to start with, for
> buildman.  But we don't need to solve that today for this series,
> either.
>

Does this patchset require any additional changes to be accepted? Have
in mind that most likely there 

[PATCH 3/3] stm32mp: stm32prog: Add support of FWU_MDATA partition type

2023-06-08 Thread Patrick Delaunay
Add support of "FWU_MDATA" partition type in flashlayout to select
the TF-A firmware update metadata partition type guid, associated to
U-Boot "system" partition type guid, FWU_MDATA_GUID introduced by
commit 2eaedc95164f ("FWU: Add FWU metadata structure and driver for
accessing metadata") and used in gpt_get_mdata_partitions() for
commit 554b38f7a532 ("FWU: Add FWU metadata access driver for GPT
partitioned block devices")

See also recommendation in FWU-PSA-A_DEN0118_1.0ALP3.pdf
  4.1.2 Metadata integration with GPT
  When embedded in a GPT, each metadata replica occupies a single
  partition with PartitionTypeGUID = metadata_uuid.
  UUID = 8a7a84a0-8387-40f6-ab41-a8b9a5a60d23

Signed-off-by: Patrick Delaunay 
---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 11 +++
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 07369919620e..a2ff5558a519 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -63,6 +63,12 @@ static const efi_guid_t uuid_mmc[3] = {
ROOTFS_MMC2_UUID
 };
 
+/*
+ * GUID value defined in the FWU specification for identification
+ * of the FWU metadata partition.
+ */
+#define FWU_MDATA_UUID "8a7a84a0-8387-40f6-ab41-a8b9a5a60d23"
+
 /* FIP type partition UUID used by TF-A*/
 #define FIP_TYPE_UUID "19D5DF83-11B0-457B-BE2C-7559C13142A5"
 
@@ -430,6 +436,8 @@ static int parse_type(struct stm32prog_data *data,
}
} else if (!strcmp(p, "FIP")) {
part->part_type = PART_FIP;
+   } else if (!strcmp(p, "FWU_MDATA")) {
+   part->part_type = PART_FWU_MDATA;
} else if (!strcmp(p, "ENV")) {
part->part_type = PART_ENV;
} else if (!strcmp(p, "System")) {
@@ -1140,6 +1148,9 @@ static int create_gpt_partitions(struct stm32prog_data 
*data)
case PART_FIP:
type_str = FIP_TYPE_UUID;
break;
+   case PART_FWU_MDATA:
+   type_str = FWU_MDATA_UUID;
+   break;
case PART_ESP:
/* EFI System Partition */
type_str = "system";
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
index a6fb9d5e9cc5..02b286be8182 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
@@ -105,6 +105,7 @@ struct stm32_header_v2 {
 enum stm32prog_part_type {
PART_BINARY,
PART_FIP,
+   PART_FWU_MDATA,
PART_ENV,
PART_SYSTEM,
PART_FILESYSTEM,
-- 
2.25.1



[PATCH 1/3] stm32mp: stm32prog: Add support of ENV partition type

2023-06-08 Thread Patrick Delaunay
Add support of "ENV" partition type in flashlayout to select
the "u-boot-env" GUID, with PARTITION_U_BOOT_ENVIRONMENT =
3de21764-95bd-54bd-a5c3-4abe786f38a8, that mean a partition
holding a U-Boot environment introduced by
commit c0364ce1c695 ("doc/README.gpt: define partition type
GUID for U-Boot environment")'

Signed-off-by: Patrick Delaunay 
---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 5 +
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 6f3641ccf57b..1bd86b5187da 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -430,6 +430,8 @@ static int parse_type(struct stm32prog_data *data,
}
} else if (!strcmp(p, "FIP")) {
part->part_type = PART_FIP;
+   } else if (!strcmp(p, "ENV")) {
+   part->part_type = PART_ENV;
} else if (!strcmp(p, "System")) {
part->part_type = PART_SYSTEM;
} else if (!strcmp(p, "FileSystem")) {
@@ -1130,6 +1132,9 @@ static int create_gpt_partitions(struct stm32prog_data 
*data)
case PART_BINARY:
type_str = LINUX_RESERVED_UUID;
break;
+   case PART_ENV:
+   type_str = "u-boot-env";
+   break;
case PART_FIP:
type_str = FIP_TYPE_UUID;
break;
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
index 58f4b96fa752..4c2c1314d990 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
@@ -100,6 +100,7 @@ struct stm32_header_v2 {
 enum stm32prog_part_type {
PART_BINARY,
PART_FIP,
+   PART_ENV,
PART_SYSTEM,
PART_FILESYSTEM,
RAW_IMAGE,
-- 
2.25.1



[PATCH 2/3] stm32mp: stm32prog: Add support of ESP partition type

2023-06-08 Thread Patrick Delaunay
Add support of "ESP" partition type in flashlayout to select
the "EFI System Partition", associated to U-Boot "system"
partition type  guid, PARTITION_SYSTEM_GUID =
C12A7328-F81F-11d2-BA4B-00A0C93EC93B.

This partition is the bootable partition for efi boot.

Signed-off-by: Patrick Delaunay 
---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 8 +++-
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h | 8 +++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 1bd86b5187da..07369919620e 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -434,6 +434,8 @@ static int parse_type(struct stm32prog_data *data,
part->part_type = PART_ENV;
} else if (!strcmp(p, "System")) {
part->part_type = PART_SYSTEM;
+   } else if (!strcmp(p, "ESP")) {
+   part->part_type = PART_ESP;
} else if (!strcmp(p, "FileSystem")) {
part->part_type = PART_FILESYSTEM;
} else if (!strcmp(p, "RawImage")) {
@@ -1138,7 +1140,11 @@ static int create_gpt_partitions(struct stm32prog_data 
*data)
case PART_FIP:
type_str = FIP_TYPE_UUID;
break;
-   default:
+   case PART_ESP:
+   /* EFI System Partition */
+   type_str = "system";
+   break;
+   default: /* PART_FILESYSTEM or PART_SYSTEM for distro */
type_str = "linux";
break;
}
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
index 4c2c1314d990..a6fb9d5e9cc5 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
@@ -96,13 +96,19 @@ struct stm32_header_v2 {
u8 extension_padding[376];
 };
 
-/* partition type in flashlayout file */
+/*
+ * partition type in flashlayout file
+ * SYSTEM = linux partition, bootable
+ * FILESYSTEM = linux partition
+ * ESP = EFI system partition
+ */
 enum stm32prog_part_type {
PART_BINARY,
PART_FIP,
PART_ENV,
PART_SYSTEM,
PART_FILESYSTEM,
+   PART_ESP,
RAW_IMAGE,
 };
 
-- 
2.25.1



Reading squashfs from spi nor mtd device

2023-06-08 Thread Mike Looijmans

Been banging my head most of the day, can't figure it out.

Have squashfs support compiled in, and can load files and so from MMC 
device.


What I really want is to read (kernel etc) from a QSPI NOR flash (using 
mtd I guess?)


For mmc it's easy:

Zynq> sqfsls mmc 0:2
    bin/
    boot/
    dev/
    etc/
    home/
    lib/
       linuxrc
    media/
       mnt
    proc/
    run/
    sbin/
    sys/
       tmp
    usr/
    var/
    www/

3 file(s), 14 dir(s)


For QSPI NOR, I can't find any clue as for what I should pass to sqfsls 
as "device" parameters. I have MTD set up, and I can load ubifs just 
fine from this flash, using "ubi part qspi-rootfs" when there's an ubi 
fileystem in there...


Zynq> mtd list
List of MTD devices:
* nor0
  - device: flash@0
  - parent: spi@e000d000
  - driver: jedec_spi_nor
  - path: /axi/spi@e000d000/flash@0
  - type: NOR flash
  - block size: 0x1 bytes
  - min I/O: 0x1 bytes
  - 0x-0x0200 : "nor0"
  - 0x-0x0010 : "qspi-boot-bin"
  - 0x0010-0x0200 : "qspi-rootfs"


So what are the "magic" words I need to pass to sqfsload to make it read 
the flash device?




--
Mike Looijmans
System Expert

TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: mike.looijm...@topic.nl
W: www.topic.nl





Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration

2023-06-08 Thread Maxim Uvarov
Ilias asked to make more clear results to compare the original stack and
LWIP stack. So the difference between the current U-boot stack and the LWIP
stack with 3 network commands is:
a) 18Kb  - ls -lh size
b) 15Kb - bloat-o-meter script total line report.

BOM=linux/scripts/bloat-o-meter (script)

1. 893K - U-boot CMD_NET=n
2. 928K - U-boot CMD_NET=y TFTP=y PING=y WGET=y
BOM 1-2: Total: Before=692286, After=722283, chg +4.33%
3. 940K - U-boot CMD_NET=n, LWIP_TFTP=y LWIP_PING=y LWIP_PING=y
BOM 1-3: Total: Before=692286, After=738425, chg +6.66%

BOM 2-3:

add/remove: 287/203 grow/shrink: 3/11 up/down: 43459/-27317 (16142)
Function old new   delta
tcp_input  -3588   +3588
tcp_receive-2884   +2884
ip4_reass  -1760   +1760
tcp_output -1400   +1400
tcp_write  -1300   +1300
tcp_slowtmr-1172   +1172
httpc_tcp_recv -1044   +1044
tftp_recv  - 888+888
ip4_input  - 700+700
ip4_frag   - 632+632
icmp_input - 604+604
udp_input  - 596+596
etharp_input   - 512+512
tcp_split_unsent_seg   - 500+500
ip4addr_aton   - 492+492
tcp_alloc  - 484+484
ip4_output_if_src  - 476+476
tcp_close_shutdown - 448+448
etharp_query   - 436+436
httpc_init_connection_common.constprop - 416+416
udp_sendto_if_src  - 408+408
etharp_output  - 404+404
arp_table  - 400+400
tcp_connect- 396+396
pbuf_alloc - 376+376
etharp_find_entry  - 372+372
tcp_abandon- 368+368
tcp_zero_window_probe  - 356+356
raw_sendto_if_src  - 328+328
pbuf_copy_partial_pbuf - 328+328
ip_reass_free_complete_datagram- 328+328
tcp_create_segment - 300+300
raw_input  - 292+292
uboot_lwip_init- 284+284
ethernet_input - 284+284
etharp_raw - 284+284
tcp_output_alloc_header_common.constprop   - 280+280
cmds   - 280+280
udp_bind   - 276+276
tcp_oos_insert_segment - 276+276
ip_reass_remove_oldest_datagram- 272+272
icmp_send_response - 268+268
netif_add  - 260+260
ping_send  - 244+244
tcp_rexmit - 232+232
tcp_parseopt   - 220+220
tcp_free_acked_segments.constprop  - 220+220
send_request   - 220+220
inet_chksum_pseudo - 216+216
ip4addr_ntoa_r - 212+212
do_lwip_ping   - 212+212
tcp_enqueue_flags  - 208+208
etharp_output_to_arp_index - 208+208
netif_set_addr - 204+204
tcp_fasttmr- 200+200
tcp_rexmit_rto_prepare - 196+196
tcp_process_refused_data   - 196+196
send_data  - 196+196
lwip_wget  - 192+192
ethernet_output- 192+192
ping_recv  - 188+188
pbuf_memcmp- 184+184
pbuf_copy_partial  - 184+184
httpc_free_state   - 180+180
tcp_send_fin   - 172+172
httpc_recv - 168+168

[PATCH 2/2] arm64: zynqmp: Fix lockstep mode cpu release functionality

2023-06-08 Thread Venkatesh Yadav Abbarapu
For lockstep mode, cpu_release function is expecting to execute
on R5 core 0, if there is attempt to pass other than R5 core 0,
through an error saying "Lockstep mode should run on R5 core 0 only".

Signed-off-by: Venkatesh Yadav Abbarapu 
---
 arch/arm/mach-zynqmp/mp.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-zynqmp/mp.c b/arch/arm/mach-zynqmp/mp.c
index 7a12f4b2b6..b06c867e57 100644
--- a/arch/arm/mach-zynqmp/mp.c
+++ b/arch/arm/mach-zynqmp/mp.c
@@ -326,6 +326,10 @@ int cpu_release(u32 nr, int argc, char *const argv[])
flush_dcache_all();
 
if (!strncmp(argv[1], "lockstep", 8)) {
+   if (nr != ZYNQMP_CORE_RPU0) {
+   printf("Lockstep mode should run on 
ZYNQMP_CORE_RPU0\n");
+   return 1;
+   }
printf("R5 lockstep mode\n");
set_r5_reset(nr, LOCK);
set_r5_tcm_mode(LOCK);
-- 
2.17.1



[PATCH 1/2] arm64: zynqmp: Fix tcminit mode param

2023-06-08 Thread Venkatesh Yadav Abbarapu
While invoking "zynqmp tcminit mode" command (which is invalid command)
on U-Boot, it just works. Check the mode param, if it is valid then
only initialize the TCM.

Signed-off-by: Venkatesh Yadav Abbarapu 
---
 board/xilinx/zynqmp/cmds.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/board/xilinx/zynqmp/cmds.c b/board/xilinx/zynqmp/cmds.c
index e20030ecda..fff3f37807 100644
--- a/board/xilinx/zynqmp/cmds.c
+++ b/board/xilinx/zynqmp/cmds.c
@@ -187,6 +187,11 @@ static int do_zynqmp_tcm_init(struct cmd_tbl *cmdtp, int 
flag, int argc,
if (argc != cmdtp->maxargs)
return CMD_RET_USAGE;
 
+   if (strcmp(argv[2], "lockstep") && strcmp(argv[2], "split")) {
+   printf("mode param should be lockstep or split\n");
+   return CMD_RET_FAILURE;
+   }
+
mode = hextoul(argv[2], NULL);
if (mode != TCM_LOCK && mode != TCM_SPLIT) {
printf("Mode should be either 0(lock)/1(split)\n");
-- 
2.17.1



[PATCH 0/2] Fix the tcminit command

2023-06-08 Thread Venkatesh Yadav Abbarapu
Fix the tcminit mode param and cpu release lockstep 
functionality. 


Venkatesh Yadav Abbarapu (2):
  arm64: zynqmp: Fix tcminit mode param
  arm64: zynqmp: Fix lockstep mode cpu release functionality

 arch/arm/mach-zynqmp/mp.c  | 4 
 board/xilinx/zynqmp/cmds.c | 5 +
 2 files changed, 9 insertions(+)

-- 
2.17.1



Re: [PATCH 1/2] usb: musb-new: sunxi: only perform SRAM initialization when necessary

2023-06-08 Thread Andre Przywara
On Wed,  7 Jun 2023 17:16:43 -0600
Sam Edwards  wrote:

> Only the older (ca. A10, A20) sunxis need this poke for the MUSB to
> function. Mimic the Linux kernel and add a `has_sram` flag to the config
> structure that is only set for the specific compatibles that require
> this initialization.

The patch looks alright in general, thanks for sending this! I will try to
test it on an older SoC in the next days. As an added bonus, that should
actually help the F1C100s USB(-OTG) support.

Cheers,
Andre

> Signed-off-by: Sam Edwards 
> ---
>  drivers/usb/musb-new/sunxi.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
> index ab55d68620..c05c0d5561 100644
> --- a/drivers/usb/musb-new/sunxi.c
> +++ b/drivers/usb/musb-new/sunxi.c
> @@ -85,6 +85,7 @@
>  
>  struct sunxi_musb_config {
>   struct musb_hdrc_config *config;
> + bool has_sram;
>  };
>  
>  struct sunxi_glue {
> @@ -313,7 +314,10 @@ static int sunxi_musb_init(struct musb *musb)
>  
>   musb->isr = sunxi_musb_interrupt;
>  
> - USBC_ConfigFIFO_Base();
> + if (glue->cfg->has_sram) {
> + USBC_ConfigFIFO_Base();
> + }
> +
>   USBC_EnableDpDmPullUp(musb->mregs);
>   USBC_EnableIdPullUp(musb->mregs);
>  
> @@ -525,6 +529,7 @@ static int musb_usb_remove(struct udevice *dev)
>  
>  static const struct sunxi_musb_config sun4i_a10_cfg = {
>   .config = _config,
> + .has_sram = true,
>  };
>  
>  static const struct sunxi_musb_config sun6i_a31_cfg = {



Re: [PATCH 1/8] common: spl: spl: Update stack pointer address

2023-06-08 Thread Nikhil M Jain

Hi Devarsh,

On 12/05/23 13:39, Devarsh Thakkar wrote:

Hi Nikhil, Vignesh, Tom,

Nikhil,
Thanks for the patch.

On 11/05/23 15:29, Nikhil M Jain wrote:

I think more apt subject would be "Update stack pointer after relocation"

At SPL stage when stack is relocated, the stack pointer needs to be
updated,


since
the stack pointer may point to stack in on chip memory even

though stack is relocated.

Signed-off-by: Nikhil M Jain 
---
  common/spl/spl.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 72078a8ebc..206caf4f8b 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -992,6 +992,7 @@ ulong spl_relocate_stack_gd(void)
  #endif
/* Get stack position: use 8-byte alignment for ABI compliance */
ptr = CONFIG_SPL_STACK_R_ADDR - roundup(sizeof(gd_t),16);
+   gd->start_addr_sp = ptr;
new_gd = (gd_t *)ptr;


Seems to me you are setting gd->start_addr_sp to new gd's base address, are
they both supposed to be same ?

Vignesh, Tom,

Could you please have a look at this patch and comment ? Does the caller of
this function need to set gd->start_addr_sp or it's ok to set in here only?



I looked at how the start_addr_sp was being updated in u-boot proper 
stage and it is done in the same way as I have done. Since the stack 
grows in opposite direction there won't be any issues.



Regards
Devarsh


memcpy(new_gd, (void *)gd, sizeof(gd_t));
  #if CONFIG_IS_ENABLED(DM)


Thanks,
Nikhil


Re: [PATCH] firmware: zynqmp: Extend debug message to show parameters

2023-06-08 Thread Michal Simek




On 6/1/23 13:34, Michal Simek wrote:

Also print more arguments not just ID when xilinx_pm_request is called.
It helps to decode what firmware is asked to do.

Signed-off-by: Michal Simek 
---

  drivers/firmware/firmware-zynqmp.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/firmware-zynqmp.c 
b/drivers/firmware/firmware-zynqmp.c
index ab7e0389bb4a..ea46f7b8418c 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -315,7 +315,8 @@ U_BOOT_DRIVER(zynqmp_power) = {
  int __maybe_unused xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
 u32 arg3, u32 *ret_payload)
  {
-   debug("%s at EL%d, API ID: 0x%0x\n", __func__, current_el(), api_id);
+   debug("%s at EL%d, API ID: 0x%0x, 0x%0x, 0x%0x, 0x%0x, 0x%0x\n",
+ __func__, current_el(), api_id, arg0, arg1, arg2, arg3);
  
  	if (IS_ENABLED(CONFIG_SPL_BUILD) || current_el() == 3) {

  #if defined(CONFIG_ZYNQMP_IPI)


Applied.
M


Re: [PATCH] arm64: zynqmp: Fix return code from do_zynqmp_pmufw()

2023-06-08 Thread Michal Simek




On 6/1/23 13:25, Michal Simek wrote:

zynqmp_pmufw_node() can also return values like -ENODEV which means that
NODE has been already configured that's why don't propagate this error
code.

Signed-off-by: Michal Simek 
---

The same technique was used on power domain driver by this patch
https://lore.kernel.org/r/20230523124215.30915-3-stefan.herbrechtsmeier-...@weidmueller.com

---
  board/xilinx/zynqmp/cmds.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/board/xilinx/zynqmp/cmds.c b/board/xilinx/zynqmp/cmds.c
index 9d375b075501..930592ffb5c1 100644
--- a/board/xilinx/zynqmp/cmds.c
+++ b/board/xilinx/zynqmp/cmds.c
@@ -211,6 +211,7 @@ static int do_zynqmp_pmufw(struct cmd_tbl *cmdtp, int flag, 
int argc,
  
  	if (!strncmp(argv[2], "node", 4)) {

u32 id;
+   int ret;
  
  		if (!strncmp(argv[3], "close", 5))

return zynqmp_pmufw_config_close();
@@ -223,7 +224,11 @@ static int do_zynqmp_pmufw(struct cmd_tbl *cmdtp, int 
flag, int argc,
  
  		printf("Enable permission for node ID %d\n", id);
  
-		return zynqmp_pmufw_node(id);

+   ret = zynqmp_pmufw_node(id);
+   if (ret == -ENODEV)
+   ret = 0;
+
+   return ret;
}
  
  	addr = hextoul(argv[2], NULL);


Applied.
M


[PATCH] pinctrl: rockchip: Fix Data Abort exception in SPL

2023-06-08 Thread Jonas Karlman
Using CONFIG_ARMV8_SPL_EXCEPTION_VECTORS=y and CONFIG_OF_LIVE=y triggers
a Data Abort exception from unaligned memory access when the pinctrl
driver iterate node properties, e.g. for UART2 on RK3568.

  setting mux of GPIO0-24 to 1
  setting mux of GPIO0-24 to 1
  "Synchronous Abort" handler, esr 0x9621
  elr: e554 lr : e54c
  x 0: 0a5c x 1: 0a5c
  x 2: 0007 x 3: 0065
  x 4: 0007 x 5: 00022d4e
  x 6: 0a7c x 7: 000227a4
  x 8: 00021cf0 x 9: 0a7c
  x10: 00021cf0 x11: 00021cf0
  x12: 003fda1c x13: 0007
  x14: 003fd9ec x15: 0001c0ff
  x16: 0700 x17: fdccd028
  x18: 003fde20 x19: 0018
  x20: 00020670 x21: 
  x22: 003fdb00 x23: 003fef90
  x24: 00020688 x25: 
  x26: 0001 x27: 003ffc50
  x28:  x29: 003fda60

  Code: b94083e1 97ffd508 93407c01 37f81260 (f9401038)
  Resetting CPU ...

Fix this by replacing the loop to access node properties with use of
ofnode_for_each_prop instead of the current ifdef.

Also continue to next prop instead of aborting at first sign of an
unknown property.

This fixes the Data Abort exception and also pinconf of e.g. pull and
drive in SPL, e.g. for UART2 on RK3568.

  setting mux of GPIO0-24 to 1
  setting mux of GPIO0-24 to 1
  setting pull of GPIO0-24 to 5
  setting mux of GPIO0-25 to 1
  setting mux of GPIO0-25 to 1
  setting pull of GPIO0-25 to 5

Fixes: e7ae4cf27a6d ("pinctrl: rockchip: Add common rockchip pinctrl driver")
Signed-off-by: Jonas Karlman 
---
 .../pinctrl/rockchip/pinctrl-rockchip-core.c  | 28 ---
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c 
b/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c
index d9d61fdb726a..8ef089994f46 100644
--- a/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c
+++ b/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "pinctrl-rockchip.h"
 
@@ -433,13 +432,7 @@ static int rockchip_pinctrl_set_state(struct udevice *dev,
int prop_len, param;
const u32 *data;
ofnode node;
-#ifdef CONFIG_OF_LIVE
-   const struct device_node *np;
-   struct property *pp;
-#else
-   int property_offset, pcfg_node;
-   const void *blob = gd->fdt_blob;
-#endif
+   struct ofprop prop;
data = dev_read_prop(config, "rockchip,pins", );
if (count < 0) {
debug("%s: bad array size %d\n", __func__, count);
@@ -473,24 +466,15 @@ static int rockchip_pinctrl_set_state(struct udevice *dev,
node = ofnode_get_by_phandle(conf);
if (!ofnode_valid(node))
return -ENODEV;
-#ifdef CONFIG_OF_LIVE
-   np = ofnode_to_np(node);
-   for (pp = np->properties; pp; pp = pp->next) {
-   prop_name = pp->name;
-   prop_len = pp->length;
-   value = pp->value;
-#else
-   pcfg_node = ofnode_to_offset(node);
-   fdt_for_each_property_offset(property_offset, blob, pcfg_node) {
-   value = fdt_getprop_by_offset(blob, property_offset,
- _name, _len);
+   ofnode_for_each_prop(prop, node) {
+   value = ofprop_get_property(, _name, 
_len);
if (!value)
-   return -ENOENT;
-#endif
+   continue;
+
param = rockchip_pinconf_prop_name_to_param(prop_name,

_val);
if (param < 0)
-   break;
+   continue;
 
if (prop_len >= sizeof(fdt32_t))
arg = fdt32_to_cpu(*(fdt32_t *)value);
-- 
2.40.1



[u-boot/next] Pull request efi-next-20230608

2023-06-08 Thread Heinrich Schuchardt

Dear Tom,

The following changes since commit ac6096fe9c4d99f1dc37db95f213e08a48b11e70:

  Merge branch '2023-06-01-assorted-platform-updates' into next 
(2023-06-01 15:43:38 -0400)


are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-efi.git 
tags/efi-next-20230608


for you to fetch changes up to b6f954e5b09545d18a150e4a4431a648e41ff287:

  test/py: efi_capsule: test for FMP versioning (2023-06-08 09:20:36 +0200)

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


Pull request efi-next-20230608

UEFI:

* Support for firmware versions in capsule updates


Masahisa Kojima (10):
  efi_loader: add the number of image entries in 
efi_capsule_update_info

  efi_loader: store firmware version into FmpState variable
  efi_loader: versioning support in GetImageInfo
  efi_loader: get lowest supported version from device tree
  efi_loader: check lowest supported version
  mkeficapsule: add FMP Payload Header
  doc: uefi: add firmware versioning documentation
  doc: uefi: add anti-rollback documentation
  test: efi_capsule: refactor efi_capsule test
  test/py: efi_capsule: test for FMP versioning

 arch/arm/mach-rockchip/board.c |   4 +-
 .../advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c  |   2 +-
 .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c|   2 +-
 board/emulation/qemu-arm/qemu-arm.c|   2 +-
 board/kontron/pitx_imx8m/pitx_imx8m.c  |   2 +-
 board/kontron/sl-mx8mm/sl-mx8mm.c  |   2 +-
 board/kontron/sl28/sl28.c  |   2 +-
 board/rockchip/evb_rk3399/evb-rk3399.c |   2 +-
 board/sandbox/sandbox.c|   2 +-
 board/socionext/developerbox/developerbox.c|   2 +-
 board/st/stm32mp1/stm32mp1.c   |   2 +-
 board/xilinx/common/board.c|   2 +-
 doc/develop/uefi/uefi.rst  |  66 +
 .../firmware/firmware-version.txt  |  22 ++
 doc/mkeficapsule.1 |  10 +
 include/efi_loader.h   |   3 +-
 lib/efi_loader/efi_firmware.c  | 276 
+--

 lib/fwu_updates/fwu.c  |   2 +-
 test/py/tests/test_efi_capsule/capsule_common.py   | 142 ++
 test/py/tests/test_efi_capsule/conftest.py |  82 ++
 .../test_efi_capsule/test_capsule_firmware_fit.py  | 213 +++
 .../test_efi_capsule/test_capsule_firmware_raw.py  | 301 
-
 .../test_capsule_firmware_signed_fit.py| 269 
+++---
 .../test_capsule_firmware_signed_raw.py| 276 
---

 test/py/tests/test_efi_capsule/version.dts |  24 ++
 tools/eficapsule.h |  30 ++
 tools/mkeficapsule.c   |  37 ++-
 27 files changed, 1102 insertions(+), 677 deletions(-)
 create mode 100644 doc/device-tree-bindings/firmware/firmware-version.txt
 create mode 100644 test/py/tests/test_efi_capsule/capsule_common.py
 create mode 100644 test/py/tests/test_efi_capsule/version.dts


Re: [PATCH] arm64: zynqmp: Fix command error values properly

2023-06-08 Thread Michal Simek




On 6/1/23 13:21, Michal Simek wrote:

Process errors from command via cmd_process_error() as is done on Versal.
When internal function returns different number then CMD_RET_SUCCESS(0),
CMD_RET_FAILURE(1) or CMD_RET_USAGE(-1) shell react on these errors by
throwing an error like
"exit not allowed from main input shell." that's why use
cmd_process_error() to make sure that error code is all the time correct.

Signed-off-by: Michal Simek 
---

  board/xilinx/zynqmp/cmds.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/board/xilinx/zynqmp/cmds.c b/board/xilinx/zynqmp/cmds.c
index c1224bdf821f..9d375b075501 100644
--- a/board/xilinx/zynqmp/cmds.c
+++ b/board/xilinx/zynqmp/cmds.c
@@ -394,17 +394,17 @@ static int do_zynqmp(struct cmd_tbl *cmdtp, int flag, int 
argc,
 char *const argv[])
  {
struct cmd_tbl *c;
+   int ret = CMD_RET_USAGE;
  
  	if (argc < 2)

return CMD_RET_USAGE;
  
  	c = find_cmd_tbl(argv[1], _zynqmp_sub[0],

 ARRAY_SIZE(cmd_zynqmp_sub));
-
if (c)
-   return c->cmd(c, flag, argc, argv);
-   else
-   return CMD_RET_USAGE;
+   ret = c->cmd(c, flag, argc, argv);
+
+   return cmd_process_error(c, ret);
  }
  
  /***/


Applied.
M


Re: [PATCH v2] PCI: zynqmp: Add ZynqMP NWL PCIe root port driver

2023-06-08 Thread Michal Simek




On 5/25/23 11:49, Stefan Roese wrote:

This patch adds the PCIe controller driver for the Xilinx / AMD ZynqMP
NWL PCIe Bridge as root port. The driver source is partly copied from
the Linux PCI driver and modified to enable usage in U-Boot (e.g.
simplified and interrupt support removed).

Signed-off-by: Stefan Roese 
Cc: Simon Glass 
Cc: Pali Rohár 
Cc: Bin Meng 
Cc: Michal Simek 
---
v2:
- Remove some unused members from struct nwl_pcie
- Fix usage of dev_seq() in nwl_pcie_config_address()
- Remove writing to PCI_PRIMARY_BUS reg as this is done by the
   common U-Boot PCI code later

  MAINTAINERS   |   1 +
  drivers/pci/Kconfig   |   7 +
  drivers/pci/Makefile  |   1 +
  drivers/pci/pcie-xilinx-nwl.c | 352 ++
  4 files changed, 361 insertions(+)
  create mode 100644 drivers/pci/pcie-xilinx-nwl.c

diff --git a/MAINTAINERS b/MAINTAINERS
index c8f72e9ec6a2..2bc19d9daa75 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -343,6 +343,7 @@ F:  drivers/rtc/armada38x.c
  F:drivers/spi/kirkwood_spi.c
  F:drivers/spi/mvebu_a3700_spi.c
  F:drivers/pci/pcie_dw_mvebu.c
+F: drivers/pci/pcie-xilinx-nwl.c
  F:drivers/watchdog/armada-37xx-wdt.c
  F:drivers/watchdog/orion_wdt.c
  F:include/configs/mv-common.h
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index ef328d26525b..60d98d14640d 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -374,4 +374,11 @@ config PCIE_UNIPHIER
  Say Y here if you want to enable PCIe controller support on
  UniPhier SoCs.
  
+config PCIE_XILINX_NWL

+   bool "Xilinx NWL PCIe controller"
+   depends on ARCH_ZYNQMP
+   help
+Say 'Y' here if you want support for Xilinx / AMD NWL PCIe
+controller as Root Port.
+
  endif
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 49506e7ba59b..11f60c6991d9 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -49,3 +49,4 @@ obj-$(CONFIG_PCI_OCTEONTX) += pci_octeontx.o
  obj-$(CONFIG_PCIE_OCTEON) += pcie_octeon.o
  obj-$(CONFIG_PCIE_DW_SIFIVE) += pcie_dw_sifive.o
  obj-$(CONFIG_PCIE_UNIPHIER) += pcie_uniphier.o
+obj-$(CONFIG_PCIE_XILINX_NWL) += pcie-xilinx-nwl.o
diff --git a/drivers/pci/pcie-xilinx-nwl.c b/drivers/pci/pcie-xilinx-nwl.c
new file mode 100644
index ..7ef2bdf57b56
--- /dev/null
+++ b/drivers/pci/pcie-xilinx-nwl.c
@@ -0,0 +1,352 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * PCIe host bridge driver for Xilinx / AMD ZynqMP NWL PCIe Bridge
+ *
+ * Based on the Linux driver which is:
+ * (C) Copyright 2014 - 2015, Xilinx, Inc.
+ *
+ * Author: Stefan Roese 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Bridge core config registers */
+#define BRCFG_PCIE_RX0 0x
+#define BRCFG_PCIE_RX1 0x0004
+#define BRCFG_INTERRUPT0x0010
+#define BRCFG_PCIE_RX_MSG_FILTER   0x0020
+
+/* Egress - Bridge translation registers */
+#define E_BREG_CAPABILITIES0x0200
+#define E_BREG_CONTROL 0x0208
+#define E_BREG_BASE_LO 0x0210
+#define E_BREG_BASE_HI 0x0214
+#define E_ECAM_CAPABILITIES0x0220
+#define E_ECAM_CONTROL 0x0228
+#define E_ECAM_BASE_LO 0x0230
+#define E_ECAM_BASE_HI 0x0234
+
+#define I_ISUB_CONTROL 0x03E8
+#define SET_ISUB_CONTROL   BIT(0)
+/* Rxed msg fifo  - Interrupt status registers */
+#define MSGF_MISC_STATUS   0x0400
+#define MSGF_MISC_MASK 0x0404
+#define MSGF_LEG_STATUS0x0420
+#define MSGF_LEG_MASK  0x0424
+#define MSGF_MSI_STATUS_LO 0x0440
+#define MSGF_MSI_STATUS_HI 0x0444
+#define MSGF_MSI_MASK_LO   0x0448
+#define MSGF_MSI_MASK_HI   0x044C
+
+/* Msg filter mask bits */
+#define CFG_ENABLE_PM_MSG_FWD  BIT(1)
+#define CFG_ENABLE_INT_MSG_FWD BIT(2)
+#define CFG_ENABLE_ERR_MSG_FWD BIT(3)
+#define CFG_ENABLE_MSG_FILTER_MASK (CFG_ENABLE_PM_MSG_FWD |\
+CFG_ENABLE_INT_MSG_FWD |   \
+CFG_ENABLE_ERR_MSG_FWD)
+
+/* Misc interrupt status mask bits */
+#define MSGF_MISC_SR_RXMSG_AVAIL   BIT(0)
+#define MSGF_MISC_SR_RXMSG_OVERBIT(1)
+#define MSGF_MISC_SR_SLAVE_ERR BIT(4)
+#define MSGF_MISC_SR_MASTER_ERRBIT(5)
+#define MSGF_MISC_SR_I_ADDR_ERRBIT(6)
+#define MSGF_MISC_SR_E_ADDR_ERRBIT(7)
+#define MSGF_MISC_SR_FATAL_AER BIT(16)
+#define MSGF_MISC_SR_NON_FATAL_AER BIT(17)
+#define MSGF_MISC_SR_CORR_AER  BIT(18)
+#define MSGF_MISC_SR_UR_DETECT BIT(20)
+#define MSGF_MISC_SR_NON_FATAL_DEV 

Re: [PATCH v5 2/2] serial: zynqmp: Fetch baudrate from dtb and update

2023-06-08 Thread Michal Simek




On 6/7/23 21:13, Tom Rini wrote:

On Thu, May 25, 2023 at 09:32:59AM +0530, Venkatesh Yadav Abbarapu wrote:


From: Algapally Santosh Sagar 

The baudrate configured in .config is taken by default by serial. If
change of baudrate is required then the .config needs to changed and
u-boot recompilation is required or the u-boot environment needs to be
updated.

To avoid this, support is added to fetch the baudrate directly from the
device tree file and update.
The serial, prints the log with the configured baudrate in the dtb.
The commit c4df0f6f315c ("arm: mvebu: Espressobin: Set default value for
$fdtfile env variable") is taken as reference for changing the default
environment variable.

The default environment stores the default baudrate value, When default
baudrate and dtb baudrate are not same glitches are seen on the serial.
So, the environment also needs to be updated with the dtb baudrate to
avoid the glitches on the serial.

Signed-off-by: Algapally Santosh Sagar 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
  doc/README.serial_dt_baud  | 41 +


Sorry I missed this until v5.  This needs to be in rST and under doc/
somewhere (and make htmldocs happy).


Any other issue with implementation?

M


Re: [PATCH] cmd: usb: Prevent reset in usb tree/info command

2023-06-08 Thread Xavier Drudis Ferran
El Thu, Jun 08, 2023 at 12:05:18AM +0200, Marek Vasut deia:
> On 6/5/23 17:20, Xavier Drudis Ferran wrote:
> > Add a check to avoid dommed (by null pointer dereference) recursive
> > call, not only for UCLASS_BLK.
> > 
> > When booting my Rock Pi 4B+ with a USB mass storage stick plugged
> > into one of the USB 2 ports (EHCI), when it is plugged before power
> > on, when issuing a
> > 
> > usb tree
> > 
> > or
> > 
> > usb info
> 
> I cannot reproduce the problem. Do you perform any other interaction with
> the USB stack, like e.g. 'usb start' or 'usb reset' before issuing the
> aforementioned commands ?
>

No. Well, in some tests yes and some no, but I got the error in all cases.

Btw, I was testing on the next branch. I had those two commits on top
https://patchwork.ozlabs.org/project/uboot/patch/202013db5a47ecbac4a53c360ed1ca91ca663996.1685974993.git.xdru...@tinet.cat/
https://patchwork.ozlabs.org/project/uboot/patch/464111fca83008503022e8ada5305e69ffd1afbd.1685974993.git.xdru...@tinet.cat/

And minor configuration changes (but I had bootstage active, might or might not 
be related)

U-Boot was in a microSD card. 


> What kind of USB stick is used here, please share model, VID, PID.
>

It may only happen with ext4 partitions or something...

Or it might have to do with other media not being bootable (they used
to be for some old and customized version of U-boot, but not the
current one)

This is the lsusb -v output of the same USB stick in another computer

Bus 007 Device 008: ID 0718:070a Imation Corp. TF10
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass0 
  bDeviceSubClass 0 
  bDeviceProtocol 0 
  bMaxPacketSize064
  idVendor   0x0718 Imation Corp.
  idProduct  0x070a 
  bcdDevice1.00
  iManufacturer   1 TDK LoR
  iProduct2 TF10
  iSerial 3 07032B6B1D0ACB96
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength   0x0020
bNumInterfaces  1
bConfigurationValue 1
iConfiguration  0 
bmAttributes 0x80
  (Bus Powered)
MaxPower  200mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   2
  bInterfaceClass 8 Mass Storage
  bInterfaceSubClass  6 SCSI
  bInterfaceProtocol 80 Bulk-Only
  iInterface  0 
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81  EP 1 IN
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02  EP 2 OUT
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
Device Qualifier (for other device speed):
  bLength10
  bDescriptorType 6
  bcdUSB   2.00
  bDeviceClass0 
  bDeviceSubClass 0 
  bDeviceProtocol 0 
  bMaxPacketSize064
  bNumConfigurations  1
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x
  (Bus Powered)

Partitions:

Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: TDK LoR TF10 (scsi)
Disk /dev/sda: 32,0GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End SizeFile system  Flags
 1  0,00B  32,0GB  32,0GB  ext4


The content in the ext4 partition is just data, 3 files,
lost+found and another directory

Let me get to my logs... (I added a printf here uclass_id=22 is UCLASS_BLK
uclass_id=25 is UCLASS_BOOTDEV )

U-Boot TPL 2023.07-rc2-00089-gab17b3d648-dirty (Jun 05 2023 - 10:42:52)
lpddr4_set_rate: change freq to 400MHz 0, 1
Channel 0: LPDDR4, 400MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
Channel 1: LPDDR4, 400MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
256B stride
lpddr4_set_rate: change freq to 800MHz 1, 0
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2023.07-rc2-00089-gab17b3d648-dirty (Jun 05 2023 - 10:42:52 +0200)
Trying to boot from MMC1
NOTICE:  BL31: v2.1(release):v2.1-728-ged01e0c4-dirty
NOTICE:  BL31: Built : 18:29:11, Mar 22 2022


U-Boot 2023.07-rc2-00089-gab17b3d648-dirty (Jun 05 2023 - 

Re: [PATCH v7 2/2] phy: rockchip-inno-usb2: Implement clock operations for usb2phy clock

2023-06-08 Thread Jagan Teki
On Mon, Jun 5, 2023 at 8:37 PM Xavier Drudis Ferran  wrote:
>
> This clock doesn't seem needed but appears in a phandle list used by
> ehci-generic.c to bulk enable it. The phandle list comes from linux,
> where it is needed for suspend/resume to work [1].
>
> My tests give the same results with or without this patch, but Marek
> Vasut found it weird to declare an empty clk_ops [2].
>
> So I adapted the code from linux 6.1-rc8 so that it hopefully works
> if it ever has some user. For now, without real use, it seems to
> at least not give any errors when called.
>
> Link: [1] https://lkml.kernel.org/lkml/1731551.Q6cHK6n5ZM@phil/T/
>   [2] 
> https://patchwork.ozlabs.org/project/uboot/patch/Y5IWpjYLB4aXMy9o@localhost/
>
> Cc: Simon Glass 
> Cc: Philipp Tomsich 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Sean Anderson 
> Cc: Marek Vasut 
> Cc: Christoph Fritz 
> Cc: Jagan Teki 
>
> Signed-off-by: Xavier Drudis Ferran 
> ---
>
>  v7: add clkout_ctl values for rk3568 (from linux).
>  UNTESTED (I don't have the hardware).
>
>  v6: just retested over current next branch and some corrections
>  to message and headers
>  (no changes to code).
>
>  v5: ignores the return value from property_enable() which is not
>  an error code in U-Boot (unlike in linux). This avoid a false
>  failure of rockchip_usb2phy_clk_disable() that interfered with
>  clock disable and appeared to cause hang or reset.
> ---
>  drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 80 ++-
>  1 file changed, 78 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c 
> b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> index 732d37201d..be5f79490c 100644
> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> @@ -56,6 +56,7 @@ struct rockchip_usb2phy_port_cfg {
>
>  struct rockchip_usb2phy_cfg {
> unsigned int reg;
> +   struct usb2phy_reg  clkout_ctl;
> const struct rockchip_usb2phy_port_cfg port_cfgs[USB2PHY_NUM_PORTS];
>  };
>
> @@ -77,6 +78,18 @@ static inline int property_enable(void *reg_base,
> return writel(val, reg_base + reg->offset);
>  }
>
> +static inline bool property_enabled(void *reg_base,
> +   const struct usb2phy_reg *reg)
> +{
> +   unsigned int tmp, orig;
> +   unsigned int mask = GENMASK(reg->bitend, reg->bitstart);
> +
> +   orig = readl(reg_base + reg->offset);
> +
> +   tmp = (orig & mask) >> reg->bitstart;
> +   return tmp != reg->disable;
> +}
> +
>  static const
>  struct rockchip_usb2phy_port_cfg *us2phy_get_port(struct phy *phy)
>  {
> @@ -169,7 +182,63 @@ static struct phy_ops rockchip_usb2phy_ops = {
> .of_xlate = rockchip_usb2phy_of_xlate,
>  };
>
> +/**
> + * round_rate() - Adjust a rate to the exact rate a clock can provide.
> + * @clk:   The clock to manipulate.
> + * @rate:  Desidered clock rate in Hz.
> + *
> + * Return: rounded rate in Hz, or -ve error code.
> + */

I forgot to comment, this last time. I feel these explicit comments
wouldn't be required as clk-uclass clearly documented.

> +ulong rockchip_usb2phy_clk_round_rate(struct clk *clk, ulong rate)

static

> +{
> +   return 48000;
> +}
> +
> +/**
> + * enable() - Enable a clock.
> + * @clk:   The clock to manipulate.
> + *
> + * Return: zero on success, or -ve error code.
> + */

ditto.

> +int rockchip_usb2phy_clk_enable(struct clk *clk)

ditto.

> +{
> +   struct udevice *parent = dev_get_parent(clk->dev);
> +   struct rockchip_usb2phy *priv = dev_get_priv(parent);
> +   const struct rockchip_usb2phy_cfg *phy_cfg = priv->phy_cfg;
> +
> +   /* turn on 480m clk output if it is off */
> +   if (!property_enabled(priv->reg_base, _cfg->clkout_ctl)) {
> +   property_enable(priv->reg_base, _cfg->clkout_ctl, true);
> +
> +   /* waiting for the clk become stable */
> +   usleep_range(1200, 1300);
> +   }
> +
> +   return 0;
> +}
> +
> +/**
> + * disable() - Disable a clock.
> + * @clk:   The clock to manipulate.
> + *
> + * Return: zero on success, or -ve error code.
> + */

ditto.

> +int rockchip_usb2phy_clk_disable(struct clk *clk)

ditto.

Thanks,
Jagan.


[PATCH] board_f: Relocate fdt if SKIP_RELOC and fdt is in bss

2023-06-08 Thread Kunihiko Hayashi
There are cases that the devicetree blob is placed after _end, such as
fdt_find_separate() returns _end. This is in bss area cleared before
relocation.

When GD_FLG_SKIP_RELOC is set, the blob is still in bss, but will be
cleared. As a result, the devicetree become invalid.

To avoid this issue, should relocate it to the new fdt area using the
latter condition in reloc_fdt().

Signed-off-by: Kunihiko Hayashi 
---
 common/board_f.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/board_f.c b/common/board_f.c
index 51d2f3c365e9..9a245872d190 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -622,7 +622,8 @@ static int init_post(void)
 static int reloc_fdt(void)
 {
if (!IS_ENABLED(CONFIG_OF_EMBED)) {
-   if (gd->flags & GD_FLG_SKIP_RELOC)
+   if (gd->flags & GD_FLG_SKIP_RELOC &&
+   gd->fdt_blob != &_end)
return 0;
if (gd->new_fdt) {
memcpy(gd->new_fdt, gd->fdt_blob,
-- 
2.25.1



Re: [PATCH v7 0/2] arm: dts: rockchip: rk3399: usb: ehci: Fix EHCI probe in rk3399 to access peripherals by USB 2

2023-06-08 Thread Xavier Drudis Ferran
El Wed, Jun 07, 2023 at 11:42:40PM +0200, Marek Vasut deia:
> On 6/5/23 17:04, Xavier Drudis Ferran wrote:
> > EHCI probing in Rock pi 4 currently fails.
> > 
> > Add a clock driver for usb2phy so that probing EHCI does not fail when
> > missing one of the clocks in the bundle for usb_host0_ehci, since
> > usb2phy is UCLASS_PHY but not UCLASS_CLK.
> > 
> > Xavier Drudis Ferran (2):
> >phy: rockchip-inno-usb2: Add usb2phy clock provider of 480MHz clock
> >phy: rockchip-inno-usb2: Implement clock operations for usb2phy clock
> > 
> >   drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 109 +-
> >   1 file changed, 106 insertions(+), 3 deletions(-)
> 
> Applied both to usb/master .
> 
> btw the cover letter subject should not have 'arm: dts:' tags, but rather
> 'phy:' tag , since this does not touch any DTs .


Yes, sorry. v1 did touch *-u-boot.dts. I hesitated about what was more
confusing, changing subject on different versions of a patch with the
same intent or keeping the old subject.

Thanks for merging.