Re: [PATCH 13/15] rockchip: rk3328: Add support to build bootable SPI image

2024-02-08 Thread Da Xue
On Wed, Feb 7, 2024 at 10:53 PM Dragan Simic  wrote:
>
> Hello Jonas,
>
> On 2024-02-07 01:02, Jonas Karlman wrote:
> > Similar to RK35xx the BootRom in RK3328 can read all data and look for
> > idbloader at 0x8000, same as on SD and eMMC.
> >
> > Use the rksd format and modify the mkimage offset to generate a
> > bootable
> > u-boot-rockchip-spi.bin that can be written to 0x0 of SPI NOR flash.
> >
> > Signed-off-by: Jonas Karlman 
>
> Could you, please, clarify a bit why the "rkspi" format isn't used
> instead of "rksd"?

"The SPI code has a bug that means that the 2 KiB blocks in which the
bootloader is loaded have a stride of 4KiB, leaving the 2KiB inbetween
as unused padding."

RK3399 has the 2K SPI bug and necessitated the rkspi format. RK3328
came after RK3399 and resolved this bug so the SPI and MMC formats are
now the same.

I verified on a ROC-RK3328-CC-V2.

>
> > ---
> >  arch/arm/dts/rk3328-u-boot.dtsi| 11 +++
> >  arch/arm/mach-rockchip/rk3328/rk3328.c |  1 +
> >  2 files changed, 12 insertions(+)
> >
> > diff --git a/arch/arm/dts/rk3328-u-boot.dtsi
> > b/arch/arm/dts/rk3328-u-boot.dtsi
> > index b90d78878d77..2a5dca97dd4b 100644
> > --- a/arch/arm/dts/rk3328-u-boot.dtsi
> > +++ b/arch/arm/dts/rk3328-u-boot.dtsi
> > @@ -120,3 +120,14 @@
> >  _otg {
> >   hnp-srp-disable;
> >  };
> > +
> > +#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
> > + {
> > + simple-bin-spi {
> > + mkimage {
> > + args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
> > + offset = <0x8000>;
> > + };
> > + };
> > +};
> > +#endif
> > diff --git a/arch/arm/mach-rockchip/rk3328/rk3328.c
> > b/arch/arm/mach-rockchip/rk3328/rk3328.c
> > index b591d38fe412..b82b209de9e2 100644
> > --- a/arch/arm/mach-rockchip/rk3328/rk3328.c
> > +++ b/arch/arm/mach-rockchip/rk3328/rk3328.c
> > @@ -36,6 +36,7 @@
> >
> >  const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
> >   [BROM_BOOTSOURCE_EMMC] = "/mmc@ff52",
> > + [BROM_BOOTSOURCE_SPINOR] = "/spi@ff19/flash@0",
> >   [BROM_BOOTSOURCE_SD] = "/mmc@ff50",
> >  };


[PATCH v2] spi: mxc_spi: Add imx6ul-ecspi compatible string

2024-02-08 Thread Marek Vasut
Recent i.MX8MP DTs use new fsl,imx6ul-ecspi compatible string instead
of the fsl,imx51-ecspi compatible string. Add the new compatible string
to fix ECSPI operation on i.MX8MP.

For details, see Linux:
48d74376fb68 ("arm64: dts: imx8mp: update ecspi compatible and clk")
8eb1252bbedf ("spi: imx: remove ERR009165 workaround on i.mx6ul")

Fixes: 451799a6ceac ("arm: dts: imx8mp: Sync the DT with kernel 6.4-rc4")
Reviewed-by: Fabio Estevam 
Signed-off-by: Marek Vasut 
---
Cc: "NXP i.MX U-Boot Team" 
Cc: Fabio Estevam 
Cc: Jagan Teki 
Cc: Stefano Babic 
---
V2: - Update commit message
  - Specify kernel commit where this got introduced
  - Add Fixes tag
---
 drivers/spi/mxc_spi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index 33360a18329..e291092c481 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -670,6 +670,7 @@ static const struct dm_spi_ops mxc_spi_ops = {
 
 static const struct udevice_id mxc_spi_ids[] = {
{ .compatible = "fsl,imx51-ecspi" },
+   { .compatible = "fsl,imx6ul-ecspi" },
{ }
 };
 
-- 
2.43.0



Re: [PATCH 13/15] rockchip: rk3328: Add support to build bootable SPI image

2024-02-08 Thread Jonas Karlman
Hi Dragan,

On 2024-02-08 04:53, Dragan Simic wrote:
> Hello Jonas,
> 
> On 2024-02-07 01:02, Jonas Karlman wrote:
>> Similar to RK35xx the BootRom in RK3328 can read all data and look for
>> idbloader at 0x8000, same as on SD and eMMC.
>>
>> Use the rksd format and modify the mkimage offset to generate a 
>> bootable
>> u-boot-rockchip-spi.bin that can be written to 0x0 of SPI NOR flash.
>>
>> Signed-off-by: Jonas Karlman 
> 
> Could you, please, clarify a bit why the "rkspi" format isn't used
> instead of "rksd"?

Not really sure how I can clarify this.

As stated in commit message, the bootrom will read all bytes and use
same boot offset as the sd/emmc-format. The "legacy" spi-format only
read first 2kb of each 4kb of storage, see tools/rkspi.c.

A few bootrom versions:
- rk3288: 320A 20131116 V100
- rk3399: 330C 20160118 V100
- rk3328: 320C 20161117 V100
- rk3308: 330E 20180203 V100

I am not sure if the rkspi format must be used for all bootrom prior to
and including rk3399 and all versions after that should use the rksd
format. I have only ever used boot from spi flash on rk3399, rk3328 and
rk35xx. And for those that has been true.

Regards,
Jonas

> 
>> ---
>>  arch/arm/dts/rk3328-u-boot.dtsi| 11 +++
>>  arch/arm/mach-rockchip/rk3328/rk3328.c |  1 +
>>  2 files changed, 12 insertions(+)
>>
>> diff --git a/arch/arm/dts/rk3328-u-boot.dtsi 
>> b/arch/arm/dts/rk3328-u-boot.dtsi
>> index b90d78878d77..2a5dca97dd4b 100644
>> --- a/arch/arm/dts/rk3328-u-boot.dtsi
>> +++ b/arch/arm/dts/rk3328-u-boot.dtsi
>> @@ -120,3 +120,14 @@
>>  _otg {
>>  hnp-srp-disable;
>>  };
>> +
>> +#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
>> + {
>> +simple-bin-spi {
>> +mkimage {
>> +args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
>> +offset = <0x8000>;
>> +};
>> +};
>> +};
>> +#endif
>> diff --git a/arch/arm/mach-rockchip/rk3328/rk3328.c
>> b/arch/arm/mach-rockchip/rk3328/rk3328.c
>> index b591d38fe412..b82b209de9e2 100644
>> --- a/arch/arm/mach-rockchip/rk3328/rk3328.c
>> +++ b/arch/arm/mach-rockchip/rk3328/rk3328.c
>> @@ -36,6 +36,7 @@
>>
>>  const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
>>  [BROM_BOOTSOURCE_EMMC] = "/mmc@ff52",
>> +[BROM_BOOTSOURCE_SPINOR] = "/spi@ff19/flash@0",
>>  [BROM_BOOTSOURCE_SD] = "/mmc@ff50",
>>  };



Re: Bug: PDF documentation doesn't build according to instructions

2024-02-08 Thread Tom Rini
On Thu, Feb 08, 2024 at 12:17:56AM +, Patrick Walton wrote:

> When I follow the instructions for building PDF documentation (
> https://docs.u-boot.org/en/latest/build/documentation.html ) , I run
> into an error at the texi2pdf step (attached). It appears to have to
> do with the boot flow diagram of k3_current not being an acceptable
> format for the pdf compiler. I tested this on several releases and it
> appears to have appeared in the v2023.10 release and continues to the
> latest. I was able to build the documentation on the v2023.07 release.

Unfortunately PDF docs are not part of CI and it seems that we would
need a bit of work to make it automatically build as well. Patches to do
this as well as fix the problem you reported would be much appreciated.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] ARM: imx: Let SPL configure ECSPI1 clock on Data Modul i.MX8M Plus eDM SBC

2024-02-08 Thread Fabio Estevam
Hi Marek,

On Thu, Feb 8, 2024 at 2:34 PM Marek Vasut  wrote:
>
> The SPL clock code does configure the ECSPI clock frequency, which has
> to match the mxc-spi driver configuration for successful SPI NOR boot.
> Drop the assigned-clock from DT ecspi1 node on this board to let the
> SPL clock code do the configuration and keep it aligned with the driver
> expectation.
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Fabio Estevam 


Re: [PATCH] spi: mxc_spi: Add imx6ul-ecspi compatible string

2024-02-08 Thread Fabio Estevam
Hi Marek,

On Thu, Feb 8, 2024 at 2:33 PM Marek Vasut  wrote:
>
> Recent i.MX8MP DTs use new fsl,imx6ul-ecspi compatible string instead

Please specify the Linux version in which this happened.

> of the fsl,imx51-ecspi compatible string. Add the new compatible string
> to fix ECSPI operation on i.MX8MP.
>
> Signed-off-by: Marek Vasut 

I assume this goes via Jagan's spi tree.

Reviewed-by: Fabio Estevam 


Re: [PATCH 1/2] board: imx93_var_som: Probe ELE MU

2024-02-08 Thread Fabio Estevam
On Thu, Feb 8, 2024 at 6:45 AM Mathieu Othacehe  wrote:

> diff --git a/board/variscite/imx93_var_som/spl.c 
> b/board/variscite/imx93_var_som/spl.c
> index 502e599b91a..0965a2de996 100644
> --- a/board/variscite/imx93_var_som/spl.c
> +++ b/board/variscite/imx93_var_som/spl.c
> @@ -97,6 +97,7 @@ int power_init_board(void)
> return 0;
>  }
>
> +extern int imx9_probe_mu(void *ctx, struct event *event);

Please put this prototype into a header file.

Currently, it appears in 3 imx93 spl.c files.


Re: [PATCH 0/2] imx93_var_som: Enable AHAB support

2024-02-08 Thread Fabio Estevam
Hi Mathieu,

On Thu, Feb 8, 2024 at 6:45 AM Mathieu Othacehe  wrote:
>
> Hello,
>
> This enables AHAB support on the imx93_var_som.
> I was able to test that I can boot from signed images on a closed board.
>
> There is one issue that has been discovered and that is discussed here:
> https://lists.denx.de/pipermail/u-boot/2024-February/545404.html
>
> This series can still be applied in the meantime I guess.

Just wanted to make sure I understand: if someone programs the fuse to
close the board,
it will fail to boot U-Boot proper and this means that the board is
bricked. Is this correct?

Is the boot failure related to some malloc size needing to be increased?


Re: [PATCH v1 1/2] imx: imxrt1050-evk: Add support for SPI flash booting

2024-02-08 Thread Fabio Estevam
Hi Giulio,

On Wed, Jan 31, 2024 at 10:06 AM Giulio Benetti
 wrote:

> The problem is that mmu_set_region_dcache_behaviour() is not implemented
> for armv7m and mxsfb.c requires it when DCache is enabled, that's why
> I've disabled.
>
> So we can keep it as is or implement armv7m complete
> mmu_set_region_dcache_behaviour()

Ok, thanks for the clarification.


Re: Pull request: Please pull u-boot-imx-master-20240208

2024-02-08 Thread Tom Rini
On Thu, Feb 08, 2024 at 11:36:33AM -0300, Fabio Estevam wrote:

> Hi Tom,
> 
> Please pull from u-boot-imx, thanks
> 
> The following changes since commit 0101a2ffe125911ebf89172b495f5ff14f2fd058:
> 
>   Merge branch '2024-02-06-assorted-fixes' (2024-02-07 09:47:47 -0500)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git 
> tags/u-boot-imx-master-20240208
> 
> for you to fetch changes up to 8dcf1df48dff339b172d1bce2a38a965ee4aafca:
> 
>   phycore-imx8mp: add support for booting and flashing emmc via UUU 
> (2024-02-08 10:11:46 -0300)
> 
> u-boot-imx-master-20240208

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [GIT PULL] please pull fsl-qoriq-2024-2-8

2024-02-08 Thread Tom Rini
On Thu, Feb 08, 2024 at 11:59:32AM +, Peng Fan wrote:

> Hi Tom,
> 
> Please pull fsl-qoriq-2024-2-8. Sorry for not being active in the past time, 
> will try to
> catch up.
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] ti: keystone2: Imply NFS command support

2024-02-08 Thread Tom Rini
On Tue, 25 Jul 2023 10:54:15 -0500, Andrew Davis wrote:

> TI KS2 boards have the nfs command in their common environment boot
> configuration, enable this command.
> 
> 

Applied to u-boot/master, thanks!

-- 
Tom




Re: [PATCH 2/2] ti: keystone2: Move common Kconfig selections to under ARCH_KEYSTONE

2024-02-08 Thread Andrew Davis

On 7/25/23 12:41 PM, Tom Rini wrote:

On Tue, Jul 25, 2023 at 10:54:16AM -0500, Andrew Davis wrote:


These select/imply settings are common to the whole architecture not just
these boards, move these settings to the architecture config.

Signed-off-by: Andrew Davis 


Reviewed-by: Tom Rini 



ping


[PATCH] ARM: imx: Let SPL configure ECSPI1 clock on Data Modul i.MX8M Plus eDM SBC

2024-02-08 Thread Marek Vasut
The SPL clock code does configure the ECSPI clock frequency, which has
to match the mxc-spi driver configuration for successful SPI NOR boot.
Drop the assigned-clock from DT ecspi1 node on this board to let the
SPL clock code do the configuration and keep it aligned with the driver
expectation.

Signed-off-by: Marek Vasut 
---
Cc: "NXP i.MX U-Boot Team" 
Cc: Fabio Estevam 
Cc: Jagan Teki 
Cc: Stefano Babic 
---
 arch/arm/dts/imx8mp-data-modul-edm-sbc-u-boot.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/dts/imx8mp-data-modul-edm-sbc-u-boot.dtsi 
b/arch/arm/dts/imx8mp-data-modul-edm-sbc-u-boot.dtsi
index cb6ea356fd7..805b5f57955 100644
--- a/arch/arm/dts/imx8mp-data-modul-edm-sbc-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-data-modul-edm-sbc-u-boot.dtsi
@@ -45,6 +45,9 @@
 };
 
  {
+   /delete-property/ assigned-clocks;
+   /delete-property/ assigned-clock-rates;
+   /delete-property/ assigned-clock-parents;
bootph-pre-ram;
flash@0 {
bootph-pre-ram;
-- 
2.43.0



[PATCH] spi: mxc_spi: Add imx6ul-ecspi compatible string

2024-02-08 Thread Marek Vasut
Recent i.MX8MP DTs use new fsl,imx6ul-ecspi compatible string instead
of the fsl,imx51-ecspi compatible string. Add the new compatible string
to fix ECSPI operation on i.MX8MP.

Signed-off-by: Marek Vasut 
---
Cc: "NXP i.MX U-Boot Team" 
Cc: Fabio Estevam 
Cc: Jagan Teki 
Cc: Stefano Babic 
---
 drivers/spi/mxc_spi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index 33360a18329..e291092c481 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -670,6 +670,7 @@ static const struct dm_spi_ops mxc_spi_ops = {
 
 static const struct udevice_id mxc_spi_ids[] = {
{ .compatible = "fsl,imx51-ecspi" },
+   { .compatible = "fsl,imx6ul-ecspi" },
{ }
 };
 
-- 
2.43.0



[PATCH 3/3] doc: board: Add minimal documentation for Sielaff i.MX6 Solo board

2024-02-08 Thread Frieder Schrempf
From: Frieder Schrempf 

Describe how to build and boot for the Sielaff i.MX6 Solo board.

Signed-off-by: Frieder Schrempf 
---
 doc/board/sielaff/imx6dl-sielaff.rst | 32 
 doc/board/sielaff/index.rst  |  9 
 2 files changed, 41 insertions(+)
 create mode 100644 doc/board/sielaff/imx6dl-sielaff.rst
 create mode 100644 doc/board/sielaff/index.rst

diff --git a/doc/board/sielaff/imx6dl-sielaff.rst 
b/doc/board/sielaff/imx6dl-sielaff.rst
new file mode 100644
index 000..24dd67ccaef
--- /dev/null
+++ b/doc/board/sielaff/imx6dl-sielaff.rst
@@ -0,0 +1,32 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Sielaff i.MX6 Solo Board
+
+
+The Sielaff i.MX6 Solo board is a control and HMI board for vending
+machines.
+
+Quick Start
+---
+
+- Build U-Boot
+- Boot
+
+Build U-Boot
+
+
+.. code-block:: bash
+
+   $ make imx6dl_sielaff_defconfig
+   $ make CROSS_COMPILE=arm-none-linux-gnueabihf-
+
+Burn the flash.bin to SD card at an offset of 1 KiB:
+
+.. code-block:: bash
+
+   $ dd if=flash.bin of=/dev/sd[x] bs=1K seek=1 conv=notrunc
+
+Boot
+
+
+Put the SD card in the slot on the board and apply power.
diff --git a/doc/board/sielaff/index.rst b/doc/board/sielaff/index.rst
new file mode 100644
index 000..a8376484d88
--- /dev/null
+++ b/doc/board/sielaff/index.rst
@@ -0,0 +1,9 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Sielaff
+===
+
+.. toctree::
+   :maxdepth: 2
+
+   imx6dl-sielaff
-- 
2.43.0



[PATCH 2/3] board: Add support for Sielaff i.MX6 Solo board

2024-02-08 Thread Frieder Schrempf
From: Frieder Schrempf 

The Sielaff i.MX6 Solo board is a control and HMI board for vending
machines. Add support for this board.

The devicetree files are taken from pending changes in the Linux
kernel that are available from linux-next and will likely be
part of Linux v6.9.

Signed-off-by: Frieder Schrempf 
---
 arch/arm/dts/Makefile |   1 +
 arch/arm/dts/imx6dl-sielaff-u-boot.dtsi   |  33 ++
 arch/arm/dts/imx6dl-sielaff.dts   | 533 ++
 arch/arm/mach-imx/mx6/Kconfig |  10 +
 board/sielaff/imx6dl-sielaff/Kconfig  |  15 +
 board/sielaff/imx6dl-sielaff/Makefile |   8 +
 board/sielaff/imx6dl-sielaff/imx6dl-sielaff.c | 111 
 .../sielaff/imx6dl-sielaff/imx6dl-sielaff.env | 115 
 board/sielaff/imx6dl-sielaff/spl.c| 277 +
 configs/imx6dl_sielaff_defconfig  | 117 
 include/configs/imx6dl-sielaff.h  |  25 +
 11 files changed, 1245 insertions(+)
 create mode 100644 arch/arm/dts/imx6dl-sielaff-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6dl-sielaff.dts
 create mode 100644 board/sielaff/imx6dl-sielaff/Kconfig
 create mode 100644 board/sielaff/imx6dl-sielaff/Makefile
 create mode 100644 board/sielaff/imx6dl-sielaff/imx6dl-sielaff.c
 create mode 100644 board/sielaff/imx6dl-sielaff/imx6dl-sielaff.env
 create mode 100644 board/sielaff/imx6dl-sielaff/spl.c
 create mode 100644 configs/imx6dl_sielaff_defconfig
 create mode 100644 include/configs/imx6dl-sielaff.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0fcae77cefe..d60fa1179af 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -930,6 +930,7 @@ dtb-y += \
imx6dl-riotboard.dtb \
imx6dl-sabreauto.dtb \
imx6dl-sabresd.dtb \
+   imx6dl-sielaff.dtb \
imx6dl-wandboard-revd1.dtb \
imx6s-dhcom-drc02.dtb
 
diff --git a/arch/arm/dts/imx6dl-sielaff-u-boot.dtsi 
b/arch/arm/dts/imx6dl-sielaff-u-boot.dtsi
new file mode 100644
index 000..47f4c499031
--- /dev/null
+++ b/arch/arm/dts/imx6dl-sielaff-u-boot.dtsi
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+/*
+ * Copyright (C) 2022 Kontron Electronics GmbH
+ */
+
+#include "imx6qdl-u-boot.dtsi"
+
+/ {
+   binman: binman {
+   filename = "flash.bin";
+   pad-byte = <0x00>;
+
+   spl: blob-ext@1 {
+   offset = <0x0>;
+   filename = "SPL";
+   };
+
+   uboot: blob-ext@2 {
+   offset = <0x11000>;
+   filename = "u-boot.img";
+   };
+   };
+};
+
+ {
+   phy-mode = "rmii";
+   phy-reset-gpios = < 2 GPIO_ACTIVE_LOW>;
+   phy-reset-duration = <100>;
+};
+
+ {
+   fsl,legacy-bch-geometry;
+};
diff --git a/arch/arm/dts/imx6dl-sielaff.dts b/arch/arm/dts/imx6dl-sielaff.dts
new file mode 100644
index 000..7de8d5f2651
--- /dev/null
+++ b/arch/arm/dts/imx6dl-sielaff.dts
@@ -0,0 +1,533 @@
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+/*
+ * Copyright (C) 2022 Kontron Electronics GmbH
+ */
+
+/dts-v1/;
+
+#include "imx6dl.dtsi"
+#include 
+#include 
+#include 
+
+/ {
+   model = "Sielaff i.MX6 Solo";
+   compatible = "sielaff,imx6dl-board", "fsl,imx6dl";
+
+   chosen {
+   stdout-path = 
+   };
+
+   backlight: pwm-backlight {
+   compatible = "pwm-backlight";
+   pinctrl-names = "default";
+   pinctrl-0 = <_backlight>;
+   pwms = < 0 5 0>;
+   brightness-levels = <0 0 64 88 112 136 184 232 255>;
+   default-brightness-level = <4>;
+   enable-gpios = < 16 GPIO_ACTIVE_HIGH>;
+   power-supply = <_backlight>;
+   };
+
+   cec {
+   compatible = "cec-gpio";
+   pinctrl-names = "default";
+   pinctrl-0 = <_hdmi_cec>;
+   cec-gpios = < 7 GPIO_ACTIVE_HIGH>;
+   hdmi-phandle = <>;
+   };
+
+   enet_ref: clock-enet-ref {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <5000>;
+   clock-output-names = "enet-ref";
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpio_keys>;
+
+   key-0 {
+   gpios = < 16 0>;
+   debounce-interval = <10>;
+   linux,code = <1>;
+   };
+
+   key-1 {
+   gpios = < 27 0>;
+   debounce-interval = <10>;
+   linux,code = <2>;
+   };
+
+   key-2 {
+   gpios = < 4 0>;
+   debounce-interval = <10>;
+   linux,code = <3>;
+   };
+   };
+
+   leds {
+   compatible = 

[PATCH 1/3] mtd: spi-nor-ids: Add support for ESMT/EON EN25Q80B

2024-02-08 Thread Frieder Schrempf
From: Frieder Schrempf 

The datasheet can be found here:
https://www.esmt.com.tw/upload/pdf/ESMT/datasheets/EN25Q80B_Ver.E.pdf

Signed-off-by: Frieder Schrempf 
---
 drivers/mtd/spi/spi-nor-ids.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index 38a287487ed..4e83b8c94c9 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -80,6 +80,7 @@ const struct flash_info spi_nor_ids[] = {
 #endif
 #ifdef CONFIG_SPI_FLASH_EON/* EON */
/* EON -- en25xxx */
+   { INFO("en25q80b",   0x1c3014, 0, 64 * 1024,   16, SECT_4K) },
{ INFO("en25q32b",   0x1c3016, 0, 64 * 1024,   64, 0) },
{ INFO("en25q64",0x1c3017, 0, 64 * 1024,  128, SECT_4K) },
{ INFO("en25q128b",  0x1c3018, 0, 64 * 1024,  256, 0) },
-- 
2.43.0



[PATCH v2] cmd: setexpr: fix no matching string in gsub return empty value

2024-02-08 Thread Massimiliano Minella
From: Massimiliano Minella 

In gsub, when the destination string is empty, the string 't' is
provided and the regular expression doesn't match, then the final result
is an empty string.

Example:

=> echo ${foo}

=> setenv foo
=> setexpr foo gsub e a bar
=> echo ${foo}

=>

The variable ${foo} should contain "bar" and the lack of match shouldn't
be considered an error.

This patch fixes the erroneous behavior by removing the return
statement and breaking out of the loop in case of lack of match.

Also add a test for the no match case.

Signed-off-by: Massimiliano Minella 
---
Changes in V2:
 - update documentation to describe the behavior

 cmd/setexpr.c |  9 -
 doc/usage/cmd/setexpr.rst |  1 +
 test/cmd/setexpr.c| 10 ++
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/cmd/setexpr.c b/cmd/setexpr.c
index 233471f6cb..ab76824a32 100644
--- a/cmd/setexpr.c
+++ b/cmd/setexpr.c
@@ -216,14 +216,12 @@ int setexpr_regex_sub(char *data, uint data_size, char 
*nbuf, uint nbuf_size,
if (res == 0) {
if (loop == 0) {
debug("%s: No match\n", data);
-   return 1;
} else {
-   break;
+   debug("## MATCH ## %s\n", data);
}
+   break;
}
 
-   debug("## MATCH ## %s\n", data);
-
if (!s)
return 1;
 
@@ -540,7 +538,8 @@ U_BOOT_CMD(
"- For each substring matching the regular expression  in the\n"
"  string , substitute the string .  The result is\n"
"  assigned to .  If  is not supplied, use the old\n"
-   "  value of \n"
+   "  value of . If no substring matching  is found in ,\n"
+   "  assign  to .\n"
"setexpr name sub r s [t]\n"
"- Just like gsub(), but replace only the first matching substring"
 #endif
diff --git a/doc/usage/cmd/setexpr.rst b/doc/usage/cmd/setexpr.rst
index d245a13ca8..593a0ea91e 100644
--- a/doc/usage/cmd/setexpr.rst
+++ b/doc/usage/cmd/setexpr.rst
@@ -39,6 +39,7 @@ setexpr name gsub   []
  string , substitute the string .
  The result is assigned to .
  If  is not supplied, use the old value of .
+ If no substring matching  is found in , assign  to .
 
 setexpr name sub   []
  Just like gsub(), but replace only the first matching substring
diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c
index 312593e1e3..ee329e94b8 100644
--- a/test/cmd/setexpr.c
+++ b/test/cmd/setexpr.c
@@ -179,6 +179,16 @@ static int setexpr_test_regex(struct unit_test_state *uts)
val = env_get("mary");
ut_asserteq_str("this is a test", val);
 
+   /* No match */
+   ut_assertok(run_command("setenv fred 'this is a test'", 0));
+   ut_assertok(run_command("setenv mary ''", 0));
+   ut_assertok(run_command("setexpr fred gsub us is \"${fred}\"", 0));
+   ut_assertok(run_command("setexpr mary gsub us is \"${fred}\"", 0));
+   val = env_get("fred");
+   ut_asserteq_str("this is a test", val);
+   val = env_get("mary");
+   ut_asserteq_str("this is a test", val);
+
unmap_sysmem(buf);
 
return 0;
-- 
2.43.0



Pull request: Please pull u-boot-imx-master-20240208

2024-02-08 Thread Fabio Estevam
Hi Tom,

Please pull from u-boot-imx, thanks

The following changes since commit 0101a2ffe125911ebf89172b495f5ff14f2fd058:

  Merge branch '2024-02-06-assorted-fixes' (2024-02-07 09:47:47 -0500)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git 
tags/u-boot-imx-master-20240208

for you to fetch changes up to 8dcf1df48dff339b172d1bce2a38a965ee4aafca:

  phycore-imx8mp: add support for booting and flashing emmc via UUU (2024-02-08 
10:11:46 -0300)

u-boot-imx-master-20240208
--

CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/19565

- Add USB support for phycore-imx8mp
- Fix environment corruption, reset on mx6sabresd
- Print reset cause on imx8
- Extend mkimage to support generating an image for i.MXRT FlexSPI
- Add new apalis and colibri variants
- Add support for phyBOARD-Segin-i.MX93 support
- Fix when FEC is primarily used instead of EQOS on i.MX93.

Benjamin Hahn (4):
  imx8mp-phyboard-pollux-rdk: sync with kernel devicetree from v6.8-rc2
  phycore-imx8mp: add USB host support
  phycore-imx8mp: add USB mass storage support
  phycore-imx8mp: add support for booting and flashing emmc via UUU

Fabio Estevam (3):
  mx6sabresd: Fix U-Boot corruption after saving the environment
  mx6sabresd: Convert to watchdog driver model
  mx6sabresd: Remove board_phy_config()

Igor Opaniuk (2):
  imx: scu_api: add implementation of sc_pm_reset_reason
  imx: imx8: print reset cause

Jesse Taube (1):
  tools: mkimage: Add support for i.MXRT FlexSPI Header

Joao Paulo Goncalves (2):
  toradex: tdx-cfg-block: Add new apalis and colibri pid
  toradex: tdx-cfg-block: add 0086 i.mx8m mini sku

Marek Vasut (1):
  ARM: imx: Enable kaslrseed command on Data Modul i.MX8M Mini/Plus eDM SBC

Mathieu Othacehe (1):
  board: phytec: phycore-imx93: Add phyBOARD-Segin-i.MX93 support

Primoz Fiser (1):
  imx9: clock: Fix board_interface_eth_init for FEC

 arch/arm/dts/Makefile  |3 +-
 arch/arm/dts/imx6qdl-sabresd-u-boot.dtsi   |9 +
 .../arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi |4 +
 arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts|  162 +-
 arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi  |  293 
 arch/arm/dts/imx93-phyboard-segin.dts  |  117 ++
 arch/arm/dts/imx93-phycore-som.dtsi|  126 ++
 arch/arm/mach-imx/imx8/cpu.c   |   41 +
 arch/arm/mach-imx/imx9/Kconfig |6 +
 arch/arm/mach-imx/imx9/clock.c |5 +
 board/freescale/mx6sabresd/mx6sabresd.c|   34 -
 board/phytec/phycore_imx8mp/phycore-imx8mp.c   |4 +
 board/phytec/phycore_imx93/Kconfig |   13 +
 board/phytec/phycore_imx93/MAINTAINERS |   10 +
 board/phytec/phycore_imx93/Makefile|   14 +
 board/phytec/phycore_imx93/lpddr4_timing.c | 1546 
 board/phytec/phycore_imx93/phycore-imx93.c |   42 +
 board/phytec/phycore_imx93/phycore_imx93.env   |   73 +
 board/phytec/phycore_imx93/spl.c   |  148 ++
 board/toradex/common/tdx-cfg-block.c   |   10 +
 board/toradex/common/tdx-cfg-block.h   |   10 +
 configs/imx8mm_data_modul_edm_sbc_defconfig|2 +
 configs/imx8mp_data_modul_edm_sbc_defconfig|2 +
 configs/imx93-phyboard-segin_defconfig |  138 ++
 configs/mx6sabresd_defconfig   |6 +
 configs/phycore-imx8mp_defconfig   |   33 +-
 doc/board/phytec/imx93-phyboard-segin.rst  |   61 +
 doc/board/phytec/index.rst |1 +
 drivers/misc/imx8/scu_api.c|   22 +
 include/configs/phycore_imx8mp.h   |5 +
 include/configs/phycore_imx93.h|   28 +
 include/firmware/imx/sci/sci.h |6 +
 include/imximage.h |   42 +-
 tools/Kconfig  |   21 +
 tools/imx8mimage.c |   41 +-
 tools/imximage.c   |   77 +
 36 files changed, 3078 insertions(+), 77 deletions(-)
 create mode 100644 arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx93-phyboard-segin.dts
 create mode 100644 arch/arm/dts/imx93-phycore-som.dtsi
 create mode 100644 board/phytec/phycore_imx93/Kconfig
 create mode 100644 board/phytec/phycore_imx93/MAINTAINERS
 create mode 100644 board/phytec/phycore_imx93/Makefile
 create mode 100644 board/phytec/phycore_imx93/lpddr4_timing.c
 create mode 100644 board/phytec/phycore_imx93/phycore-imx93.c
 create mode 100644 board/phytec/phycore_imx93/phycore_imx93.env
 create mode 100644 board/phytec/phycore_imx93/spl.c
 create mode 100644 configs/imx93-phyboard

Re: [PATCH v3 1/4] imx8mp-phyboard-pollux-rdk: sync with kernel devicetree from v6.8-rc2

2024-02-08 Thread Fabio Estevam
On Thu, Feb 8, 2024 at 9:03 AM Benjamin Hahn  wrote:
>
> sync devicetree with kernel v6.8-rc2.
>
> New commits on kernel v6.8-rc2:
> 4a58fcdb1818 arm64: dts: imx8mp-phyboard-pollux: Add support for RS232/RS485
> 3bd7fdcc359e arm64: dts: imx8mp-phyboard-pollux: Add gpio-line-names
> f5faa633daf8 arm64: dts: imx8mp-phyboard-pollux: Enable USB support
> 27c0dc128d04 arm64: dts: imx8mp-phyboard-pollux: Add flexcan support
> fa2a1ec50456 arm64: dts: imx8mp-phyboard-pollux: Add missing usdhc clocks 
> assignment
> 055e38c76388 arm64: dts: imx8mp-phyboard-pollux-rdk: Fix led sub-node names
>
> Signed-off-by: Benjamin Hahn 

Applied all, thanks.


Re: [PATCH v2 1/3] mx6sabresd: Fix U-Boot corruption after saving the environment

2024-02-08 Thread Fabio Estevam
On Fri, Feb 2, 2024 at 1:04 PM Fabio Estevam  wrote:
>
> From: Fabio Estevam 
>
> U-Boot binary has grown in such a way that it goes beyond the reserved
> area for the environment variables.
>
> Running "saveenv" and rebooting the board causes U-Boot to hang because
> of this overlap.
>
> Fix this problem by selecting CONFIG_LTO so that the U-Boot proper
> size can be reduced.
>
> Also, to prevent this same problem to happen in the future, use
> CONFIG_BOARD_SIZE_LIMIT, which can detect the overlap in build-time.
>
> CONFIG_BOARD_SIZE_LIMIT is calculated as follows:
>
> CONFIG_BOARD_SIZE_LIMIT = CONFIG_ENV_OFFSET - u-boot-img.dtb offset
> CONFIG_BOARD_SIZE_LIMIT = 0xc000 - 69 * 1024
> CONFIG_BOARD_SIZE_LIMIT = 715766
>
> Signed-off-by: Fabio Estevam 

Applied all, thanks.


Re: [PATCH v1 2/2] imx: imx8: print reset cause

2024-02-08 Thread Fabio Estevam
On Wed, Jan 31, 2024 at 9:49 AM Igor Opaniuk  wrote:
>
> Add support for printing reset cause during boot.
>
> Signed-off-by: Igor Opaniuk 

Applied, both, thanks.


Re: [PATCH v1] tools: mkimage: Add support for i.MXRT FlexSPI Header

2024-02-08 Thread Fabio Estevam
On Tue, Jan 23, 2024 at 11:15 PM Jesse Taube  wrote:
>
> Modify imx8m Flex SPI Configuration Block to work with imxrt.
> Add more Flex SPI configuration options to Kconfig.
>
> Signed-off-by: Jesse Taube 
> ---

Applied, thanks.


Re: [PATCH] toradex: tdx-cfg-block: add 0086 i.mx8m mini sku

2024-02-08 Thread Fabio Estevam
On Wed, Jan 31, 2024 at 2:32 PM Joao Paulo Goncalves
 wrote:
>
> From: Joao Paulo Goncalves 
>
> Add new product id 0086 Verdin iMX8M Mini DualLite 2GB IT.
>
> Signed-off-by: Joao Paulo Goncalves 

Applied, thanks.


Re: [PATCH v4] board: phytec: phycore-imx93: Add phyBOARD-Segin-i.MX93 support

2024-02-08 Thread Fabio Estevam
On Tue, Jan 30, 2024 at 11:50 AM Mathieu Othacehe  wrote:
>
> Add initial support for the PHYTEC phyBOARD-Segin-i.MX93 board based on
> the PHYTEC phyCORE-i.MX93 SoM.
>
> Supported features:
> - 1GB LPDDR4 RAM
> - eMMC
> - external SD
> - FEC Ethernet
> - debug UART
> - watchdog
>
> Signed-off-by: Mathieu Othacehe 

Applied, thanks.


Re: [PATCH] imx9: clock: Fix board_interface_eth_init for FEC

2024-02-08 Thread Fabio Estevam
On Tue, Jan 30, 2024 at 9:43 AM Primoz Fiser  wrote:
>
> Commit d5eae216d833 ("net: dwc_eth_qos: Add board_interface_eth_init()
> for i.MX93") implemented board_interface_eth_init for i.MX9 platforms.
> However it only accounted for the EQOS interface while any board using
> FEC as primary Ethernet interface was left out as return value -EINVAL
> is always returned from the function in such case.
>
> Fix this by returning 0 (success) when FEC interface is primarily used
> instead of EQOS interface on i.MX93.
>
> Fixes: d5eae216d833 ("net: dwc_eth_qos: Add board_interface_eth_init() for 
> i.MX93")
> Signed-off-by: Primoz Fiser 

Applied, thanks.


Re: [FIX PATCH v1] Fix: common: usb_hub: Reset only USB3.0 hub

2024-02-08 Thread Dragan Simic

On 2024-02-08 15:10, Shantur Rathore wrote:

On Thu, Feb 8, 2024 at 1:44 PM Dragan Simic  wrote:

On 2024-02-08 14:33, Marek Vasut wrote:
> On 2/8/24 12:30, Shantur Rathore wrote:
>> On Wed, Feb 7, 2024 at 1:07 PM Marek Vasut  wrote:
>>> On 2/7/24 11:23, Shantur Rathore wrote:
 USB 3.0 spec requires hub to reset device while
 enumeration. Some USB 2.0 hubs / devices don't
 handle this well and after implementation of
 reset some USB 2.0 disks weren't detected on
 Allwinner based boards.

 Resetting only when hub is USB 3.0 fixes it.
>>>
>>> It would be good to include as many details about the faulty hardware
>>> in
>>> the commit message as possible, so that when someone else runs into
>>> this, they would have all that information available.
>>>
 Tested-by: Andre Przywara 

 Signed-off-by: Shantur Rathore 
 ---

common/usb_hub.c | 6 --
1 file changed, 4 insertions(+), 2 deletions(-)

 diff --git a/common/usb_hub.c b/common/usb_hub.c
 index 3fb7e14d10..2e054eb935 100644
 --- a/common/usb_hub.c
 +++ b/common/usb_hub.c
 @@ -174,8 +174,10 @@ static void usb_hub_power_on(struct
 usb_hub_device *hub)

debug("enabling power on all ports\n");
for (i = 0; i < dev->maxchild; i++) {
 - usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_RESET);
 - debug("Reset : port %d returns %lX\n", i + 1,
 dev->status);
 + if (usb_hub_is_superspeed(dev)) {
>>>
>>> Should this condition be "all which are lower than superspeed"
>>> instead ,
>>> so when the next generation of USB comes, this problem won't trigger
>>> ?
>>>
>>> What does Linux do btw ?
>>
>> As of now Linux checks if the hub is superspeed
>> https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.c#L2859
>>
>> which is
>>   return hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS; //
>> USB_HUB_PR_SS = 3
>>
>> This holds true for newer SuperSpeedPlus hubs as well.
>> https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.h#L155
>>
>> We can change the check to be  bDeviceProtocol > 2 but who knows if
>> things change in the newer version of spec.
>> I am open to suggestions.
>
> Please just include the ^ in the commit description. Use link to
> git.kernel.org , not some mirror . This is extremely useful
> information and, well, you already wrote the V2 commit message
> addition in this answer.

Shantur, if that would be easier or quicker for you, I can write
a quite detailed patch description for you, in exchange for a
"Helped-by" tag in the v2 patch submission. :)


That would be really kind of you Dragan.


Sure, I'll write the summary and send it over.


I am down with the flu so that would really help me as my brain is
working at 15% capacity.


Oh, I'm really sorry to hear that. :(  I hope you'll get better
soon, and I know very well what's it like;  I've also been sick
recently, as a result of some kind of flu that unfortunately found
its way into my lungs, and it took me about a month to get back
to about 90% of my usual mental capacity.  I'm still not back to
exactly 100%. :/

I really hope you'll recover much faster.


Re: [PATCH v1 7/7] doc: android: avb: add slot_suffix param details

2024-02-08 Thread Mattijs Korpershoek
Hi Igor,

Thank you for the patch.

On mar., févr. 06, 2024 at 23:31, Igor Opaniuk  
wrote:

> From: Igor Opaniuk 
>
> Add info about slot_suffix param for avb verify.
>
> Signed-off-by: Igor Opaniuk 
> ---
>
>  doc/android/avb2.rst | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/doc/android/avb2.rst b/doc/android/avb2.rst
> index a072119574f..c0b2bedb831 100644
> --- a/doc/android/avb2.rst
> +++ b/doc/android/avb2.rst
> @@ -39,15 +39,17 @@ Provides CLI interface to invoke AVB 2.0 verification + 
> misc. commands for
>  different testing purposes::
>  
>  avb init  - initialize avb 2.0 for 
> -avb verify - run verification process using hash data from vbmeta 
> structure
> +avb verify [slot_suffix] - run verification process using hash data
> +from vbmeta structure. Provide [slot_suffix] if vbmeta partition
> +is slotted

Any particular reason for this to not be exactly the wording as in cmd/avb.c?

"avb verify [slot_suffix] - run verification process using hash data\n"
"from vbmeta structure\n"
"[slot_suffix] - _a, _b, etc (if vbmeta partition is slotted)\n"

It looks good, but I think it would be better if both are the same for
consistency, since both texts are user facing.

>  avb read_rb  - read rollback index at location 
>  avb write_rb   - write rollback index  to 
>  avb is_unlocked - returns unlock status of the device
>  avb get_uuid  - read and print uuid of partition 
>  avb read_part - read  bytes from
> -partition  to buffer 
> +partition  to buffer 
>  avb write_part - write  bytes to
> - by  using data from 
> + by  using data from 
>  
>  Partitions tampering (example)
>  --
> -- 
> 2.34.1


Re: [FIX PATCH v1] Fix: common: usb_hub: Reset only USB3.0 hub

2024-02-08 Thread Shantur Rathore
On Thu, Feb 8, 2024 at 1:44 PM Dragan Simic  wrote:
>
> On 2024-02-08 14:33, Marek Vasut wrote:
> > On 2/8/24 12:30, Shantur Rathore wrote:
> >> On Wed, Feb 7, 2024 at 1:07 PM Marek Vasut  wrote:
> >>> On 2/7/24 11:23, Shantur Rathore wrote:
>  USB 3.0 spec requires hub to reset device while
>  enumeration. Some USB 2.0 hubs / devices don't
>  handle this well and after implementation of
>  reset some USB 2.0 disks weren't detected on
>  Allwinner based boards.
> 
>  Resetting only when hub is USB 3.0 fixes it.
> >>>
> >>> It would be good to include as many details about the faulty hardware
> >>> in
> >>> the commit message as possible, so that when someone else runs into
> >>> this, they would have all that information available.
> >>>
>  Tested-by: Andre Przywara 
> 
>  Signed-off-by: Shantur Rathore 
>  ---
> 
> common/usb_hub.c | 6 --
> 1 file changed, 4 insertions(+), 2 deletions(-)
> 
>  diff --git a/common/usb_hub.c b/common/usb_hub.c
>  index 3fb7e14d10..2e054eb935 100644
>  --- a/common/usb_hub.c
>  +++ b/common/usb_hub.c
>  @@ -174,8 +174,10 @@ static void usb_hub_power_on(struct
>  usb_hub_device *hub)
> 
> debug("enabling power on all ports\n");
> for (i = 0; i < dev->maxchild; i++) {
>  - usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_RESET);
>  - debug("Reset : port %d returns %lX\n", i + 1,
>  dev->status);
>  + if (usb_hub_is_superspeed(dev)) {
> >>>
> >>> Should this condition be "all which are lower than superspeed"
> >>> instead ,
> >>> so when the next generation of USB comes, this problem won't trigger
> >>> ?
> >>>
> >>> What does Linux do btw ?
> >>
> >> As of now Linux checks if the hub is superspeed
> >> https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.c#L2859
> >>
> >> which is
> >>   return hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS; //
> >> USB_HUB_PR_SS = 3
> >>
> >> This holds true for newer SuperSpeedPlus hubs as well.
> >> https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.h#L155
> >>
> >> We can change the check to be  bDeviceProtocol > 2 but who knows if
> >> things change in the newer version of spec.
> >> I am open to suggestions.
> >
> > Please just include the ^ in the commit description. Use link to
> > git.kernel.org , not some mirror . This is extremely useful
> > information and, well, you already wrote the V2 commit message
> > addition in this answer.
>
> Shantur, if that would be easier or quicker for you, I can write
> a quite detailed patch description for you, in exchange for a
> "Helped-by" tag in the v2 patch submission. :)

That would be really kind of you Dragan.
I am down with the flu so that would really help me as my brain is
working at 15% capacity.


Re: [PATCH v1 5/7] common: avb_verify: add str_avb_io_error/str_avb_slot_error

2024-02-08 Thread Mattijs Korpershoek
Hi Igor,

Thank you for the patch.

On mar., févr. 06, 2024 at 23:31, Igor Opaniuk  
wrote:

> From: Igor Opaniuk 
>
> Introduce str_avb_io_error() and str_avb_slot_error() functions,
> that provide a pointer to AVB runtime error message.
>
> Signed-off-by: Igor Opaniuk 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  common/avb_verify.c  | 49 
>  include/avb_verify.h |  3 ++-
>  2 files changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/common/avb_verify.c b/common/avb_verify.c
> index ed58239cf8a..cff9117d92f 100644
> --- a/common/avb_verify.c
> +++ b/common/avb_verify.c
> @@ -119,6 +119,55 @@ static const unsigned char avb_root_pub[1032] = {
>   0xd8, 0x7e,
>  };
>  
> +const char *str_avb_io_error(AvbIOResult res)
> +{
> + switch (res) {
> + case AVB_IO_RESULT_OK:
> + return "Requested operation was successful";
> + case AVB_IO_RESULT_ERROR_IO:
> + return "Underlying hardware encountered an I/O error";
> + case AVB_IO_RESULT_ERROR_OOM:
> + return "Unable to allocate memory";
> + case AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION:
> + return "Requested partition does not exist";
> + case AVB_IO_RESULT_ERROR_RANGE_OUTSIDE_PARTITION:
> + return "Bytes requested is outside the range of partition";
> + case AVB_IO_RESULT_ERROR_NO_SUCH_VALUE:
> + return "Named persistent value does not exist";
> + case AVB_IO_RESULT_ERROR_INVALID_VALUE_SIZE:
> + return "Named persistent value size is not supported";
> + case AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE:
> + return "Buffer is too small for the requested operation";
> + default:
> + return "Unknown AVB error";
> + }
> +}
> +
> +const char *str_avb_slot_error(AvbSlotVerifyResult res)
> +{
> + switch (res) {
> + case AVB_SLOT_VERIFY_RESULT_OK:
> + return "Verification passed successfully";
> + case AVB_SLOT_VERIFY_RESULT_ERROR_OOM:
> + return "Allocation of memory failed";
> + case AVB_SLOT_VERIFY_RESULT_ERROR_IO:
> + return "I/O error occurred while trying to load data";
> + case AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION:
> + return "Digest didn't match or signature checks failed";
> + case AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX:
> + return "Rollback index is less than its stored value";
> + case AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED:
> + return "Public keys are not accepted";
> + case AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_METADATA:
> + return "Metadata is invalid or inconsistent";
> + case AVB_SLOT_VERIFY_RESULT_ERROR_UNSUPPORTED_VERSION:
> + return "Metadata requires a newer version of libavb";
> + case AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_ARGUMENT:
> + return "Invalid arguments are used";
> + default:
> + return "Unknown AVB slot verification error";
> + }
> +}
>  /**
>   * 
> 
>   * Boot states support (GREEN, YELLOW, ORANGE, RED) and dm_verity
> diff --git a/include/avb_verify.h b/include/avb_verify.h
> index 2fb850044d9..5d998b5a302 100644
> --- a/include/avb_verify.h
> +++ b/include/avb_verify.h
> @@ -52,7 +52,8 @@ char *avb_set_enforce_verity(const char *cmdline);
>  char *avb_set_ignore_corruption(const char *cmdline);
>  
>  char *append_cmd_line(char *cmdline_orig, char *cmdline_new);
> -
> +const char *str_avb_io_error(AvbIOResult res);
> +const char *str_avb_slot_error(AvbSlotVerifyResult res);
>  /**
>   * 
> 
>   * I/O helper inline functions
> -- 
> 2.34.1


Re: [PATCH v1 4/7] cmd: avb: rework prints

2024-02-08 Thread Mattijs Korpershoek
Hi Igor,

Thank you for the patch.

On mar., févr. 06, 2024 at 23:31, Igor Opaniuk  
wrote:

> From: Igor Opaniuk 
>
> Introduce AVB_OPS_CHECK macro for checking AvbOps before using
> it to avoid code duplication.
> Simplify and add more context for prints where it's needed.
>
> Signed-off-by: Igor Opaniuk 
> ---
>
>  cmd/avb.c | 156 --
>  1 file changed, 80 insertions(+), 76 deletions(-)
>
> diff --git a/cmd/avb.c b/cmd/avb.c
> index ce8b63873f2..ae0012c0e79 100644
> --- a/cmd/avb.c
> +++ b/cmd/avb.c
> @@ -11,6 +11,14 @@
>  #include 
>  
>  #define AVB_BOOTARGS "avb_bootargs"
> +
> +#define AVB_OPS_CHECK(avb_ops) do { \
> + if (!(avb_ops)) { \
> + printf("AVB is not initialized, please run 'avb init '\n"); 
> \
> + return CMD_RET_FAILURE; \
> + } \
> +} while (false)
> +
checkpatch.pl --u-boot seems to complain about this:
WARNING: Macros with flow control statements should be avoided
#25: FILE: cmd/avb.c:15:

This seems documented in the kernel coding style as well.
https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enums-and-rtl

I'd argue that in this case, it's not better or worse in terme of
readability but i'd prefer to stick to the rules in this case.

The error handling (using ret) and the better prints seem fine though.
Could we drop the AVB_OPS_CHECK macro for v2?

>  static struct AvbOps *avb_ops;
>  
>  int do_avb_init(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
> argv[])
> @@ -28,8 +36,10 @@ int do_avb_init(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>   avb_ops = avb_ops_alloc(mmc_dev);
>   if (avb_ops)
>   return CMD_RET_SUCCESS;
> + else
> + printf("Can't allocate AvbOps");
>  
> - printf("Failed to initialize avb2\n");
> + printf("Failed to initialize AVB\n");
>  
>   return CMD_RET_FAILURE;
>  }
> @@ -41,11 +51,9 @@ int do_avb_read_part(struct cmd_tbl *cmdtp, int flag, int 
> argc,
>   s64 offset;
>   size_t bytes, bytes_read = 0;
>   void *buffer;
> + int ret;
>  
> - if (!avb_ops) {
> - printf("AVB 2.0 is not initialized, please run 'avb init'\n");
> - return CMD_RET_USAGE;
> - }
> + AVB_OPS_CHECK(avb_ops);
>  
>   if (argc != 5)
>   return CMD_RET_USAGE;
> @@ -55,14 +63,15 @@ int do_avb_read_part(struct cmd_tbl *cmdtp, int flag, int 
> argc,
>   bytes = hextoul(argv[3], NULL);
>   buffer = (void *)hextoul(argv[4], NULL);
>  
> - if (avb_ops->read_from_partition(avb_ops, part, offset, bytes,
> -  buffer, _read) ==
> -  AVB_IO_RESULT_OK) {
> + ret = avb_ops->read_from_partition(avb_ops, part, offset,
> +bytes, buffer, _read);
> + if (ret == AVB_IO_RESULT_OK) {
>   printf("Read %zu bytes\n", bytes_read);
>   return CMD_RET_SUCCESS;
>   }
>  
> - printf("Failed to read from partition\n");
> + printf("Failed to read from partition '%s', err = %d\n",
> +part, ret);
>  
>   return CMD_RET_FAILURE;
>  }
> @@ -74,11 +83,9 @@ int do_avb_read_part_hex(struct cmd_tbl *cmdtp, int flag, 
> int argc,
>   s64 offset;
>   size_t bytes, bytes_read = 0;
>   char *buffer;
> + int ret;
>  
> - if (!avb_ops) {
> - printf("AVB 2.0 is not initialized, please run 'avb init'\n");
> - return CMD_RET_USAGE;
> - }
> + AVB_OPS_CHECK(avb_ops);
>  
>   if (argc != 4)
>   return CMD_RET_USAGE;
> @@ -94,8 +101,9 @@ int do_avb_read_part_hex(struct cmd_tbl *cmdtp, int flag, 
> int argc,
>   }
>   memset(buffer, 0, bytes);
>  
> - if (avb_ops->read_from_partition(avb_ops, part, offset, bytes, buffer,
> -  _read) == AVB_IO_RESULT_OK) {
> + ret = avb_ops->read_from_partition(avb_ops, part, offset,
> +bytes, buffer, _read);
> + if (ret == AVB_IO_RESULT_OK) {
>   printf("Requested %zu, read %zu bytes\n", bytes, bytes_read);
>   printf("Data: ");
>   for (int i = 0; i < bytes_read; i++)
> @@ -107,7 +115,8 @@ int do_avb_read_part_hex(struct cmd_tbl *cmdtp, int flag, 
> int argc,
>   return CMD_RET_SUCCESS;
>   }
>  
> - printf("Failed to read from partition\n");
> + printf("Failed to read from partition '%s', err = %d\n",
> +part, ret);
>  
>   free(buffer);
>   return CMD_RET_FAILURE;
> @@ -120,11 +129,9 @@ int do_avb_write_part(struct cmd_tbl *cmdtp, int flag, 
> int argc,
>   s64 offset;
>   size_t bytes;
>   void *buffer;
> + int ret;
>  
> - if (!avb_ops) {
> - printf("AVB 2.0 is not initialized, run 'avb init' first\n");
> - return CMD_RET_FAILURE;
> - }
> + AVB_OPS_CHECK(avb_ops);
>  
>   if 

Re: [FIX PATCH v1] Fix: common: usb_hub: Reset only USB3.0 hub

2024-02-08 Thread Dragan Simic

On 2024-02-08 14:33, Marek Vasut wrote:

On 2/8/24 12:30, Shantur Rathore wrote:

On Wed, Feb 7, 2024 at 1:07 PM Marek Vasut  wrote:

On 2/7/24 11:23, Shantur Rathore wrote:

USB 3.0 spec requires hub to reset device while
enumeration. Some USB 2.0 hubs / devices don't
handle this well and after implementation of
reset some USB 2.0 disks weren't detected on
Allwinner based boards.

Resetting only when hub is USB 3.0 fixes it.


It would be good to include as many details about the faulty hardware 
in

the commit message as possible, so that when someone else runs into
this, they would have all that information available.


Tested-by: Andre Przywara 

Signed-off-by: Shantur Rathore 
---

   common/usb_hub.c | 6 --
   1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 3fb7e14d10..2e054eb935 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -174,8 +174,10 @@ static void usb_hub_power_on(struct 
usb_hub_device *hub)


   debug("enabling power on all ports\n");
   for (i = 0; i < dev->maxchild; i++) {
- usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_RESET);
- debug("Reset : port %d returns %lX\n", i + 1, 
dev->status);

+ if (usb_hub_is_superspeed(dev)) {


Should this condition be "all which are lower than superspeed" 
instead ,
so when the next generation of USB comes, this problem won't trigger 
?


What does Linux do btw ?


As of now Linux checks if the hub is superspeed
https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.c#L2859

which is
  return hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS; // 
USB_HUB_PR_SS = 3


This holds true for newer SuperSpeedPlus hubs as well.
https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.h#L155

We can change the check to be  bDeviceProtocol > 2 but who knows if
things change in the newer version of spec.
I am open to suggestions.


Please just include the ^ in the commit description. Use link to
git.kernel.org , not some mirror . This is extremely useful
information and, well, you already wrote the V2 commit message
addition in this answer.


Shantur, if that would be easier or quicker for you, I can write
a quite detailed patch description for you, in exchange for a
"Helped-by" tag in the v2 patch submission. :)


Re: [PATCH v1 3/7] common: avb_verify: rework error/debug prints

2024-02-08 Thread Mattijs Korpershoek
Hi Igor,

Thank you for the patch.

On mar., févr. 06, 2024 at 23:31, Igor Opaniuk  
wrote:

> From: Igor Opaniuk 
>
> Make error prints more verbose with additional context.
> Also s/print/debug/g for prints, which might be relevant only
> for debugging purposes.
>
> Signed-off-by: Igor Opaniuk 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  common/avb_verify.c | 31 ++-
>  1 file changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/common/avb_verify.c b/common/avb_verify.c
> index 938a5383b5d..ed58239cf8a 100644
> --- a/common/avb_verify.c
> +++ b/common/avb_verify.c
> @@ -279,9 +279,9 @@ static unsigned long mmc_read_and_flush(struct mmc_part 
> *part,
>* Reading fails on unaligned buffers, so we have to
>* use aligned temporary buffer and then copy to destination
>*/
> -
>   if (unaligned) {
> - printf("Handling unaligned read buffer..\n");
> + debug("%s: handling unaligned read buffer, addr = 0x%p\n",
> +   __func__, buffer);
>   tmp_buf = get_sector_buf();
>   buf_size = get_sector_buf_size();
>   if (sectors > buf_size / part->info.blksz)
> @@ -320,7 +320,8 @@ static unsigned long mmc_write(struct mmc_part *part, 
> lbaint_t start,
>   if (unaligned) {
>   tmp_buf = get_sector_buf();
>   buf_size = get_sector_buf_size();
> - printf("Handling unaligned wrire buffer..\n");
> + debug("%s: handling unaligned read buffer, addr = 0x%p\n",
> +   __func__, buffer);
>   if (sectors > buf_size / part->info.blksz)
>   sectors = buf_size / part->info.blksz;
>  
> @@ -348,30 +349,35 @@ static struct mmc_part *get_partition(AvbOps *ops, 
> const char *partition)
>   dev_num = get_boot_device(ops);
>   part->mmc = find_mmc_device(dev_num);
>   if (!part->mmc) {
> - printf("No MMC device at slot %x\n", dev_num);
> + printf("%s: no MMC device at slot %x\n", __func__, dev_num);
>   goto err;
>   }
>  
> - if (mmc_init(part->mmc)) {
> - printf("MMC initialization failed\n");
> + ret = mmc_init(part->mmc);
> + if (ret) {
> + printf("%s: MMC initialization failed, err = %d\n",
> +__func__, ret);
>   goto err;
>   }
>  
>   if (IS_MMC(part->mmc)) {
>   ret = mmc_switch_part(part->mmc, part_num);
> - if (ret)
> + if (ret) {
> + printf("%s: MMC part switch failed, err = %d\n",
> +__func__, ret);
>   goto err;
> + }
>   }
>  
>   mmc_blk = mmc_get_blk_desc(part->mmc);
>   if (!mmc_blk) {
> - printf("Error - failed to obtain block descriptor\n");
> + printf("%s: failed to obtain block descriptor\n", __func__);
>   goto err;
>   }
>  
>   ret = part_get_info_by_name(mmc_blk, partition, >info);
>   if (ret < 0) {
> - printf("Can't find partition '%s'\n", partition);
> + printf("%s: can't find partition '%s'\n", __func__, partition);
>   goto err;
>   }
>  
> @@ -684,7 +690,7 @@ static AvbIOResult read_rollback_index(AvbOps *ops,
>  {
>  #ifndef CONFIG_OPTEE_TA_AVB
>   /* For now we always return 0 as the stored rollback index. */
> - printf("%s not supported yet\n", __func__);
> + debug("%s: rollback protection is not implemented\n", __func__);
>  
>   if (out_rollback_index)
>   *out_rollback_index = 0;
> @@ -730,7 +736,7 @@ static AvbIOResult write_rollback_index(AvbOps *ops,
>  {
>  #ifndef CONFIG_OPTEE_TA_AVB
>   /* For now this is a no-op. */
> - printf("%s not supported yet\n", __func__);
> + debug("%s: rollback protection is not implemented\n", __func__);
>  
>   return AVB_IO_RESULT_OK;
>  #else
> @@ -766,8 +772,7 @@ static AvbIOResult read_is_device_unlocked(AvbOps *ops, 
> bool *out_is_unlocked)
>  {
>  #ifndef CONFIG_OPTEE_TA_AVB
>   /* For now we always return that the device is unlocked. */
> -
> - printf("%s not supported yet\n", __func__);
> + debug("%s: device locking is not implemented\n", __func__);
>  
>   *out_is_unlocked = true;
>  
> -- 
> 2.34.1


Re: [PATCH v1 2/7] avb: move SPDX license itdentifiers to the first line

2024-02-08 Thread Mattijs Korpershoek
Hi Igor,

Thank you for the patch.

On mar., févr. 06, 2024 at 23:31, Igor Opaniuk  
wrote:

> From: Igor Opaniuk 
>
> Move SPDX license identifiers to the first line, so it conforms
> to license placement rule [1]:
>
> Placement:
> The SPDX license identifier in kernel files shall be added at the first
> possible line in a file which can contain a comment.  For the majority
> of files this is the first line, except for scripts which require the
> '#!PATH_TO_INTERPRETER' in the first line.  For those scripts the SPDX
> identifier goes into the second line.
>
> [1] https://www.kernel.org/doc/Documentation/process/license-rules.rst
>
> Signed-off-by: Igor Opaniuk 

Reviewed-by: Mattijs Korpershoek 

Nitpick in the title: itdentifiers -> identifiers.
If no other remarks in the series, will fix when applying.

> ---
>
>  cmd/avb.c  | 4 +---
>  common/avb_verify.c| 3 +--
>  include/avb_verify.h   | 4 +---
>  test/py/tests/test_android/test_avb.py | 3 +--
>  4 files changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/cmd/avb.c b/cmd/avb.c
> index 783f51b8169..ce8b63873f2 100644
> --- a/cmd/avb.c
> +++ b/cmd/avb.c
> @@ -1,8 +1,6 @@
> -
> +// SPDX-License-Identifier: GPL-2.0+
>  /*
>   * (C) Copyright 2018, Linaro Limited
> - *
> - * SPDX-License-Identifier:  GPL-2.0+
>   */
>  
>  #include 
> diff --git a/common/avb_verify.c b/common/avb_verify.c
> index 59f2c25e0de..938a5383b5d 100644
> --- a/common/avb_verify.c
> +++ b/common/avb_verify.c
> @@ -1,7 +1,6 @@
> +// SPDX-License-Identifier: GPL-2.0+
>  /*
>   * (C) Copyright 2018, Linaro Limited
> - *
> - * SPDX-License-Identifier:  GPL-2.0+
>   */
>  
>  #include 
> diff --git a/include/avb_verify.h b/include/avb_verify.h
> index 1e787ba6668..2fb850044d9 100644
> --- a/include/avb_verify.h
> +++ b/include/avb_verify.h
> @@ -1,8 +1,6 @@
> -
> +/* SPDX-License-Identifier: GPL-2.0+ */
>  /*
>   * (C) Copyright 2018, Linaro Limited
> - *
> - * SPDX-License-Identifier:  GPL-2.0+
>   */
>  
>  #ifndef  _AVB_VERIFY_H
> diff --git a/test/py/tests/test_android/test_avb.py 
> b/test/py/tests/test_android/test_avb.py
> index 238b48c90fa..865efbca4de 100644
> --- a/test/py/tests/test_android/test_avb.py
> +++ b/test/py/tests/test_android/test_avb.py
> @@ -1,6 +1,5 @@
> -# Copyright (c) 2018, Linaro Limited
> -#
>  # SPDX-License-Identifier:  GPL-2.0+
> +# Copyright (c) 2018, Linaro Limited
>  #
>  # Android Verified Boot 2.0 Test
>  
> -- 
> 2.34.1


Re: [FIX PATCH v1] Fix: common: usb_hub: Reset only USB3.0 hub

2024-02-08 Thread Marek Vasut

On 2/8/24 12:30, Shantur Rathore wrote:

Hi Marek,

On Wed, Feb 7, 2024 at 1:07 PM Marek Vasut  wrote:


On 2/7/24 11:23, Shantur Rathore wrote:

USB 3.0 spec requires hub to reset device while
enumeration. Some USB 2.0 hubs / devices don't
handle this well and after implementation of
reset some USB 2.0 disks weren't detected on
Allwinner based boards.

Resetting only when hub is USB 3.0 fixes it.


It would be good to include as many details about the faulty hardware in
the commit message as possible, so that when someone else runs into
this, they would have all that information available.


Tested-by: Andre Przywara 

Signed-off-by: Shantur Rathore 
---

   common/usb_hub.c | 6 --
   1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 3fb7e14d10..2e054eb935 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -174,8 +174,10 @@ static void usb_hub_power_on(struct usb_hub_device *hub)

   debug("enabling power on all ports\n");
   for (i = 0; i < dev->maxchild; i++) {
- usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_RESET);
- debug("Reset : port %d returns %lX\n", i + 1, dev->status);
+ if (usb_hub_is_superspeed(dev)) {


Should this condition be "all which are lower than superspeed" instead ,
so when the next generation of USB comes, this problem won't trigger ?

What does Linux do btw ?


As of now Linux checks if the hub is superspeed
https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.c#L2859

which is
  return hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS; // USB_HUB_PR_SS = 3

This holds true for newer SuperSpeedPlus hubs as well.
https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.h#L155

We can change the check to be  bDeviceProtocol > 2 but who knows if
things change in the newer version of spec.
I am open to suggestions.


Please just include the ^ in the commit description. Use link to 
git.kernel.org , not some mirror . This is extremely useful information 
and, well, you already wrote the V2 commit message addition in this answer.


Thanks


Re: [PATCH v1 1/7] common: avb_verify: don't call mmc_switch_part for SD

2024-02-08 Thread Mattijs Korpershoek
Hi Igor,

Thank you for the patch.

On mar., févr. 06, 2024 at 23:31, Igor Opaniuk  
wrote:

> From: Igor Opaniuk 
>
> mmc_switch_part() is used for switching between hw partitions
> on eMMC (boot0, boot1, user, rpmb).
> There is no need to do that for SD card.
>
> Signed-off-by: Igor Opaniuk 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  common/avb_verify.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/common/avb_verify.c b/common/avb_verify.c
> index 48ba8db51e5..59f2c25e0de 100644
> --- a/common/avb_verify.c
> +++ b/common/avb_verify.c
> @@ -358,9 +358,11 @@ static struct mmc_part *get_partition(AvbOps *ops, const 
> char *partition)
>   goto err;
>   }
>  
> - ret = mmc_switch_part(part->mmc, part_num);
> - if (ret)
> - goto err;
> + if (IS_MMC(part->mmc)) {
> + ret = mmc_switch_part(part->mmc, part_num);
> + if (ret)
> + goto err;
> + }
>  
>   mmc_blk = mmc_get_blk_desc(part->mmc);
>   if (!mmc_blk) {
> -- 
> 2.34.1


Re: [PATCH v2 1/2] imx: imxrt1050-evk: Add support for SPI flash booting

2024-02-08 Thread Fabio Estevam
Hi Jesse,

On Tue, Feb 6, 2024 at 1:40 PM Jesse Taube  wrote:
>
> Add support for booting the imxrt1050-evk from spi.
> Add imximage config and the ability for SPL to boot from NOR.
>
> Signed-off-by: Jesse Taube 

This causes the following build failure when building imxrt1020-evk_defconfig:

arm: + imxrt1020-evk
1221+binman: Device tree 'u-boot.dtb' does not have a 'binman' node
1222+make[1]: *** [Makefile:1125: .binman_stamp] Error 1
1223+make: *** [Makefile:177: sub-make] Error 2
1224w+arch/arm/dts/imxrt1170-evk.dtb: Warning (reg_format):
/memory/ocram@2024:reg: property has invalid length (8 bytes)
(#address-cells == 2, #size-cells == 1)
1225w+arch/arm/dts/imxrt1170-evk.dtb: Warning (reg_format):
/memory/sdram@8000:reg: property has invalid length (8 bytes)
(#address-cells == 2, #size-cells == 1)
1226w+arch/arm/dts/imxrt1170-evk.dtb: Warning
(avoid_default_addr_size): /memory/ocram@2024: Relying on default
#address-cells value
1227w+arch/arm/dts/imxrt1170-evk.dtb: Warning
(avoid_default_addr_size): /memory/ocram@2024: Relying on default
#size-cells value
1228w+arch/arm/dts/imxrt1170-evk.dtb: Warning
(avoid_default_addr_size): /memory/sdram@8000: Relying on default
#address-cells value
1229w+arch/arm/dts/imxrt1170-evk.dtb: Warning
(avoid_default_addr_size): /memory/sdram@8000: Relying on default
#size-cells value
1230 arm: w+ topic_miamiplus

Please fix and resend.

Also, there was a whitespace warning when applying this series.

Please make sure to run checkpatch on the patches.


Bug: PDF documentation doesn't build according to instructions

2024-02-08 Thread Patrick Walton
When I follow the instructions for building PDF documentation ( 
https://docs.u-boot.org/en/latest/build/documentation.html ) , I run into an 
error at the texi2pdf step (attached). It appears to have to do with the boot 
flow diagram of k3_current not being an acceptable format for the pdf compiler. 
I tested this on several releases and it appears to have appeared in the 
v2023.10 release and continues to the latest. I was able to build the 
documentation on the v2023.07 release.

Take care,

Patrick Walton
Co-founder/CEO
Care Weather
801-227-4740
www.careweather.com ( http://www.careweather.com )./doc/output/texinfo/u-boot.texi:119130: Could not find image file u-boot-figur
es/boot_diagram_k3_current for pdf.
@dopdfimage ...uld not find image file #1 for pdf}
  @else @gdef @pdfimgext {JP...

@imagexxx ...t @fi @ifpdf @dopdfimage {#1}{#2}{#3}
  @else @ifx @XeTeXrevision ...

@image ...true @fi @else @imagexxx #1,@finish 
  @fi 
l.119130 ...am_k3_current,,,Boot flow diagram,svg}
  
? 
./doc/output/texinfo/u-boot.texi:119130: Emergency stop.
@dopdfimage ...uld not find image file #1 for pdf}
  @else @gdef @pdfimgext {JP...

@imagexxx ...t @fi @ifpdf @dopdfimage {#1}{#2}{#3}
  @else @ifx @XeTeXrevision ...

@image ...true @fi @else @imagexxx #1,@finish 
  @fi 
l.119130 ...am_k3_current,,,Boot flow diagram,svg}
  
@Texinfo supports .png, .jpg, .jpeg, and .pdf images with PDF output, and none 
of those formats could be found. (.eps cannot be supported due to the design of
 the PDF format; use regular TeX (DVI output) for that.) 

./doc/output/texinfo/u-boot.texi:119130:  ==> Fatal error occurred, no output P
DF file produced!


[PATCH 2/2] configs: imx93_var_som: Enable AHAB support

2024-02-08 Thread Mathieu Othacehe
Enable AHAB support in the imx93_var_som configuration.

Signed-off-by: Mathieu Othacehe 
---
 configs/imx93_var_som_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/imx93_var_som_defconfig b/configs/imx93_var_som_defconfig
index cc0c5a79bc1..14922f2a3e2 100644
--- a/configs/imx93_var_som_defconfig
+++ b/configs/imx93_var_som_defconfig
@@ -12,6 +12,7 @@ CONFIG_IMX_CONFIG="arch/arm/mach-imx/imx9/imximage.cfg"
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx93-var-som-symphony"
 CONFIG_SPL_TEXT_BASE=0x2049A000
+CONFIG_AHAB_BOOT=y
 CONFIG_TARGET_IMX93_VAR_SOM=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_SPL_SERIAL=y
-- 
2.41.0



[PATCH 1/2] board: imx93_var_som: Probe ELE MU

2024-02-08 Thread Mathieu Othacehe
Probing the MU is needed to prevent this error in the SPL:

ele dev is not initialized
Authenticate container hdr failed, return -19, resp 0x0
IND = INVALID

ele dev is not initialized
Error: release container failed, resp 0x0!
IND = INVALID

SPL: failed to boot from all boot devices

Signed-off-by: Mathieu Othacehe 
---
 board/variscite/imx93_var_som/spl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/board/variscite/imx93_var_som/spl.c 
b/board/variscite/imx93_var_som/spl.c
index 502e599b91a..0965a2de996 100644
--- a/board/variscite/imx93_var_som/spl.c
+++ b/board/variscite/imx93_var_som/spl.c
@@ -97,6 +97,7 @@ int power_init_board(void)
return 0;
 }
 
+extern int imx9_probe_mu(void *ctx, struct event *event);
 void board_init_f(ulong dummy)
 {
int ret;
@@ -114,9 +115,9 @@ void board_init_f(ulong dummy)
 
preloader_console_init();
 
-   ret = arch_cpu_init();
+   ret = imx9_probe_mu(NULL, NULL);
if (ret) {
-   printf("Fail to init Sentinel API\n");
+   printf("Fail to init ELE API\n");
} else {
printf("SOC: 0x%x\n", gd->arch.soc_rev);
printf("LC: 0x%x\n", gd->arch.lifecycle);
-- 
2.41.0



[PATCH 0/2] imx93_var_som: Enable AHAB support

2024-02-08 Thread Mathieu Othacehe
Hello,

This enables AHAB support on the imx93_var_som.
I was able to test that I can boot from signed images on a closed board.

There is one issue that has been discovered and that is discussed here:
https://lists.denx.de/pipermail/u-boot/2024-February/545404.html

This series can still be applied in the meantime I guess.

Thanks,

Mathieu

Mathieu Othacehe (2):
  board: imx93_var_som: Probe ELE MU
  configs: imx93_var_som: Enable AHAB support

 board/variscite/imx93_var_som/spl.c | 5 +++--
 configs/imx93_var_som_defconfig | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

-- 
2.41.0



Re: [PATCH v1] vexpress_ca9x4: Enable DM_SERIAL

2024-02-08 Thread Ole Orhagen
On Thu, Feb 8, 2024 at 9:27 AM Linus Walleij 
wrote:

> On Mon, Feb 5, 2024 at 9:18 AM Ole Orhagen 
> wrote:
>
>>
>> But I will try to dust it off and test it again.
>>>
>>
>> Did you get any results from the tests?
>>
>
>
> Yes!
>
> It works fine both before and after the patch. Latest log from
> the actual hardware:
>
> Cmd> usb_on
> Enabling debug USB...
>
> (here I copy over the binary to the internal SD-card which is
> presented over USB mass storage)
>
> Cmd> reboot
>
> Powering up system...
> Daughterboard fitted to site 1.
>
> Switching on ATXPSU...
> ATX3V3: ON
> VIOset: 1.8V
> MBtemp: 29 degC
>
> Configuring motherboard (rev D, var A)...
> IOFPGA  config: PASSED
> MUXFPGA config: PASSED
> OSC CLK config: PASSED
> Programming image \SOFTWARE\boot-a9.bin
> Erasing Flash image boot.bin
> ...
> Erasing Flash
> ...
> Writing Flash
> .
> Updating eeprom with image boot.bin
> Image: boot.bin UPDATED from \SOFTWARE\boot-a9.bin
>
> Testing SMC devices (FPGA build 8)...
> SRAM 32MB test: PASSED
> VRAM  8MB test: PASSED
> LAN9118   test: PASSED
> USB & OTG test: PASSED
> KMI1/KMI2 test: PASSED
> MMC & SD  test: PASSED
> DVI image test: PASSED
> AACI AC97 test: PASSED
> CF card   test: PASSED
> UART port test: PASSED
> MAC addrs test: PASSED
>
> Reading Site 1 Board File \SITE1\HBI0191B\board.txt
> DB1 JTAG configuration complete.
> Setting DB1 OSCCLKS...
> DB1.0 DCC 0 SPI configuration complete.
>
> Writing SCC 0x4061 with 0xBB8A802A
> Writing SCC 0x40610001 with 0x1F09
> Writing SCC 0x40610002 with 0x
> DB1.0 DCC 0 SCC configuration complete.
>
> DB SMB clock enabled.
> Waiting for SITE1 CB_READY...
> Testing SMB clock...
> Configuring MUXFPGA for DB1.
> Setting DVI mode for XGA.
> Releasing Daughterboard resets.
> Switching MCC log to UART1.
>
> ARM Versatile Express Boot Monitor
> Version:V5.2.1
> Build Date: Apr  4 2013
> Daughterboard Site 1: V2P-CA9 Cortex A9
> Daughterboard Site 2: Not Used
> Running boot script from flash - BOOTSCRIPT
>
>
> U-Boot 2024.04-rc1-00101-g0101a2ffe125 (Feb 08 2024 - 09:21:31 +0100)
>
> DRAM:  512 MiB (effective 1 GiB)
> WARNING: Caches not enabled
> Core:  22 devices, 11 uclasses, devicetree: embed
> Flash: 128 MiB
> MMC:   mmci@5000: 0
> Loading Environment from Flash... OK
> In:uart@9000
> Out:   uart@9000
> Err:   uart@9000
> Net:   eth0: ethernet@3,0200
> Hit any key to stop autoboot:  0
> smc911x: detected LAN9118 controller
> smc911x: phy initialized
> smc911x: MAC 00:02:f7:00:3c:9d
> Using ethernet@3,0200 device
> TFTP from server 192.168.1.140; our IP address is 192.168.1.35
> Filename 'zImage'.
> Load address: 0x6200
> Loading: smc911x: MAC 00:02:f7:00:3c:9d
>
> Yours,
> Linus Walleij
>


Great :)

Thanks for taking the time!

-- 
*Ole P. Orhagen*
Software Engineer | Mender 
Oslo, Norway

  Northern.tech
 | Securing the world's connected devices


Re: [PATCH v1] vexpress_ca9x4: Enable DM_SERIAL

2024-02-08 Thread Ole Orhagen
Awesome, thanks!

:)

On Wed, Feb 7, 2024 at 4:45 PM Tom Rini  wrote:

> On Fri, Jan 26, 2024 at 01:47:50PM +0100, Ole P. Orhagen wrote:
>
> > This commit enables support for DM_SERIAL in the vexpress_ca9x4 boards.
> >
> > When running the board with the DM_SERIAL driver, the board ran out of
> > memory in SPL when initialising the DM serial driver.
> >
> > Thus this required an increase in the pre-allocated SRAM memory. I did
> > increase it to 0x800, and it now works graciously.
> >
> > It could probably be set lower, but I do not see any reason not to use
> the
> > available SRAM at this point.
> >
> > Also adds stdout-path to the 'chosen' node in the device tree.
> >
> > Signed-off-by: Ole P. Orhagen 
> > Reviewed-by: Linus Walleij 
>
> Applied to u-boot/master, thanks!
>
> --
> Tom
>


-- 
*Ole P. Orhagen*
Software Engineer | Mender 
Oslo, Norway

  Northern.tech
 | Securing the world's connected devices


Re: [PATCH 00/10] ECC Series

2024-02-08 Thread Santhosh Kumar K




On 31/01/24 11:32, Santhosh Kumar K wrote:

This series is to:
1. Enable ECC priming with BIST engine (Patch 1)
2. Add a function to store base address and size of RAM's banks
in a 64 bit device private data (Patch 2)
3. Setup the ECC region start and range (Patch 3)
4. Enable ECC 1 bit error, 2 bit error and multiple bit
error interrupts (Patch 4)
5. Add CONFIG_K3_INLINE_ECC (Patch 5)
6. Pull the redundant DDR functions to a common location (Patch 6)
7. Remove redundant DDR functions (Patch 7, 8)
8. Fixup DDR size when ECC is enabled (Patch 9)
9. Add ss_cfg reg entry (Patch 10)

Tested on AM62X and AM62A, results:
AM62X: https://gist.github.com/santhosh21/c5f07cd921bd2b12d12385f22c698ee6
AM62A: https://gist.github.com/santhosh21/e5fa684d890d65b4034346435213ec8b

Things to look in the test log:
1. Time-taken for priming
2. Fixed up DDR size (RAM size =- ECC reserved space).

Thanks and Regards,
Santhosh.

Georgi Vlaev (1):
   ram: k3-ddrss: Use the DDR controller BIST engine for ECC priming

Neha Malcom Francis (1):
   drivers: ram: Kconfig: Add CONFIG_K3_INLINE_ECC

Santhosh Kumar K (8):
   ram: k3-ddrss: Add k3_ddrss_ddr_bank_base_size_calc() to solve
 'calculations restricted to 32 bits' issue
   ram: k3-ddrss: Setup ECC region start and range
   ram: k3-ddrss: Enable ECC interrupts
   board: ti: common: k3-ddr-init: Pull redundant DDR functions to a
 common location



This patch seems to break compilation on J7* platforms, I'll post a v2.
Please don't merge the series.



   board: ti: am64x: evm: Remove redundant DDR functions
   board: ti: am62x: evm: Remove redundant DDR functions
   board: ti: am62ax: evm: Fixup DDR size when ECC is enabled
   arm: dts: k3-am62a-ddr: Add ss_cfg reg entry

  arch/arm/dts/k3-am62a-ddr.dtsi  |   7 +-
  board/ti/am62ax/evm.c   |  16 +--
  board/ti/am62x/evm.c|  61 +-
  board/ti/am64x/evm.c|  71 +--
  board/ti/common/k3-ddr-init.c   |  75 
  board/ti/common/k3-ddr-init.h   |  15 +++
  drivers/ram/Kconfig |  11 ++
  drivers/ram/k3-ddrss/k3-ddrss.c | 209 +++-
  8 files changed, 307 insertions(+), 158 deletions(-)
  create mode 100644 board/ti/common/k3-ddr-init.c
  create mode 100644 board/ti/common/k3-ddr-init.h



Thanks and Regards,
Santhosh.


[PATCH v3 4/4] phycore-imx8mp: add support for booting and flashing emmc via UUU

2024-02-08 Thread Benjamin Hahn
add support for Serial Downloader Boot via UUU as well as flashing emmc
via UUU on USB0 Port of phyBOARD Pollux.

Reviewed-by: Fabio Estevam 
Signed-off-by: Benjamin Hahn 
---
 board/phytec/phycore_imx8mp/phycore-imx8mp.c |  4 
 configs/phycore-imx8mp_defconfig | 18 --
 include/configs/phycore_imx8mp.h |  5 +
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/board/phytec/phycore_imx8mp/phycore-imx8mp.c 
b/board/phytec/phycore_imx8mp/phycore-imx8mp.c
index a8f0821437..dbdd6bb793 100644
--- a/board/phytec/phycore_imx8mp/phycore-imx8mp.c
+++ b/board/phytec/phycore_imx8mp/phycore-imx8mp.c
@@ -46,6 +46,10 @@ int board_late_init(void)
case MMC3_BOOT:
env_set_ulong("mmcdev", 2);
break;
+   case USB_BOOT:
+   printf("Detect USB boot. Will enter fastboot mode!\n");
+   env_set_ulong("dofastboot", 1);
+   break;
default:
break;
}
diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig
index e3fe4ed94e..0f37286d5d 100644
--- a/configs/phycore-imx8mp_defconfig
+++ b/configs/phycore-imx8mp_defconfig
@@ -27,7 +27,7 @@ CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="mmc dev ${mmcdev}; if mmc rescan; then if run loadimage; 
then run mmcboot; else run netboot; fi; fi;"
+CONFIG_BOOTCOMMAND="if test ${dofastboot} = 1; then fastboot 0; fi; mmc dev 
${mmcdev}; if mmc rescan; then if run loadimage; then run mmcboot; else run 
netboot; fi; fi;"
 CONFIG_DEFAULT_FDT_FILE="oftree"
 CONFIG_SYS_CBSIZE=2048
 CONFIG_SYS_PBSIZE=2074
@@ -66,6 +66,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
+CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -87,6 +88,17 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_DM=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_IMX8MP=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x4280
+CONFIG_FASTBOOT_BUF_SIZE=0x1300
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_UUU_SUPPORT=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=2
+CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y
+CONFIG_FASTBOOT_MMC_BOOT1_NAME="mmc2boot0"
+CONFIG_FASTBOOT_MMC_BOOT2_NAME="mmc2boot1"
+CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
+CONFIG_FASTBOOT_MMC_USER_NAME="mmc2"
 CONFIG_MXC_GPIO=y
 CONFIG_DM_I2C=y
 # CONFIG_SPL_DM_I2C is not set
@@ -111,6 +123,9 @@ CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
 CONFIG_SPL_POWER_LEGACY=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_IMX8M_POWER_DOMAIN=y
+CONFIG_IMX8MP_HSIOMIX_BLKCTRL=y
 CONFIG_POWER_PCA9450=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
@@ -136,5 +151,4 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="FSL"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
-CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_IMX_WATCHDOG=y
diff --git a/include/configs/phycore_imx8mp.h b/include/configs/phycore_imx8mp.h
index d79d364c8e..11a17be7fe 100644
--- a/include/configs/phycore_imx8mp.h
+++ b/include/configs/phycore_imx8mp.h
@@ -19,6 +19,11 @@
"fdt_addr=0x4800\0" \
"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
"ip_dyn=yes\0" \
+   "dofastboot=0\0" \
+   "fastboot_raw_partition_bootloader=64 8128\0" \
+   "fastboot_raw_partition_all=0 4194304\0" \
+   "emmc_dev=2\0" \
+   "sd_dev=1\0" \
"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
"mmcpart=1\0" \
"mmcroot=2\0" \

-- 
2.34.1



[PATCH v3 3/4] phycore-imx8mp: add USB mass storage support

2024-02-08 Thread Benjamin Hahn
add support for USB mass storage to USB0 port of phyBOARD Pollux.

tested with "ums 0 mmc 2"

Signed-off-by: Benjamin Hahn 
---
 arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi | 4 
 configs/phycore-imx8mp_defconfig| 7 +++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi 
b/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi
index 1c7b250549..b4efff27a7 100644
--- a/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi
@@ -70,6 +70,10 @@
bootph-pre-ram;
 };
 
+_dwc3_0 {
+   dr_mode = "peripheral";
+};
+
  {
bootph-pre-ram;
 };
diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig
index 74450b957b..e3fe4ed94e 100644
--- a/configs/phycore-imx8mp_defconfig
+++ b/configs/phycore-imx8mp_defconfig
@@ -66,6 +66,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
@@ -123,6 +124,7 @@ CONFIG_SYSRESET_PSCI=y
 CONFIG_SYSRESET_WATCHDOG=y
 CONFIG_DM_THERMAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y
@@ -130,4 +132,9 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_STORAGE=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_IMX_WATCHDOG=y

-- 
2.34.1



[PATCH v3 1/4] imx8mp-phyboard-pollux-rdk: sync with kernel devicetree from v6.8-rc2

2024-02-08 Thread Benjamin Hahn
sync devicetree with kernel v6.8-rc2.

New commits on kernel v6.8-rc2:
4a58fcdb1818 arm64: dts: imx8mp-phyboard-pollux: Add support for RS232/RS485
3bd7fdcc359e arm64: dts: imx8mp-phyboard-pollux: Add gpio-line-names
f5faa633daf8 arm64: dts: imx8mp-phyboard-pollux: Enable USB support
27c0dc128d04 arm64: dts: imx8mp-phyboard-pollux: Add flexcan support
fa2a1ec50456 arm64: dts: imx8mp-phyboard-pollux: Add missing usdhc clocks 
assignment
055e38c76388 arm64: dts: imx8mp-phyboard-pollux-rdk: Fix led sub-node names

Signed-off-by: Benjamin Hahn 
---
 arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts | 162 +++-
 1 file changed, 159 insertions(+), 3 deletions(-)

diff --git a/arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts 
b/arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts
index 6aa720bafe..c8640cac3e 100644
--- a/arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts
+++ b/arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts
@@ -19,6 +19,36 @@
stdout-path = 
};
 
+   reg_can1_stby: regulator-can1-stby {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_flexcan1_reg>;
+   gpio = < 20 GPIO_ACTIVE_LOW>;
+   regulator-max-microvolt = <330>;
+   regulator-min-microvolt = <330>;
+   regulator-name = "can1-stby";
+   };
+
+   reg_can2_stby: regulator-can2-stby {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_flexcan2_reg>;
+   gpio = < 21 GPIO_ACTIVE_LOW>;
+   regulator-max-microvolt = <330>;
+   regulator-min-microvolt = <330>;
+   regulator-name = "can2-stby";
+   };
+
+   reg_usb1_vbus: regulator-usb1-vbus {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_usb1_vbus>;
+   gpio = < 12 GPIO_ACTIVE_LOW>;
+   regulator-max-microvolt = <500>;
+   regulator-min-microvolt = <500>;
+   regulator-name = "usb1_host_vbus";
+   };
+
reg_usdhc2_vmmc: regulator-usdhc2 {
compatible = "regulator-fixed";
pinctrl-names = "default";
@@ -57,6 +87,21 @@
};
 };
 
+/* CAN FD */
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_flexcan1>;
+   xceiver-supply = <_can1_stby>;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_flexcan2>;
+   xceiver-supply = <_can2_stby>;
+   status = "okay";
+};
+
  {
clock-frequency = <40>;
pinctrl-names = "default", "gpio";
@@ -76,15 +121,15 @@
compatible = "nxp,pca9533";
reg = <0x62>;
 
-   led1 {
+   led-1 {
type = ;
};
 
-   led2 {
+   led-2 {
type = ;
};
 
-   led3 {
+   led-3 {
type = ;
};
};
@@ -101,8 +146,51 @@
status = "okay";
 };
 
+/* USB1 Host mode Type-A */
+_phy0 {
+   vbus-supply = <_usb1_vbus>;
+   status = "okay";
+};
+
+_0 {
+   status = "okay";
+};
+
+_dwc3_0 {
+   dr_mode = "host";
+   status = "okay";
+};
+
+/* USB2 4-port USB3.0 HUB */
+_phy1 {
+   status = "okay";
+};
+
+_1 {
+   fsl,permanently-attached;
+   fsl,disable-port-power-control;
+   status = "okay";
+};
+
+_dwc3_1 {
+   dr_mode = "host";
+   status = "okay";
+};
+
+/* RS232/RS485 */
+ {
+   assigned-clocks = < IMX8MP_CLK_UART2>;
+   assigned-clock-parents = < IMX8MP_SYS_PLL1_80M>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart2>;
+   uart-has-rtscts;
+   status = "okay";
+};
+
 /* SD-Card */
  {
+   assigned-clocks = < IMX8MP_CLK_USDHC2>;
+   assigned-clock-rates = <2>;
pinctrl-names = "default", "state_100mhz", "state_200mhz";
pinctrl-0 = <_usdhc2>, <_usdhc2_pins>;
pinctrl-1 = <_usdhc2_100mhz>, <_usdhc2_pins>;
@@ -113,6 +201,33 @@
status = "okay";
 };
 
+ {
+   gpio-line-names = "", "", "X_PMIC_WDOG_B", "",
+   "PMIC_SD_VSEL", "", "", "", "", "",
+   "", "", "USB1_OTG_PWR", "", "", "X_nETHPHY_INT";
+};
+
+ {
+   gpio-line-names = "", "", "", "",
+   "", "", "", "", "", "",
+   "", "", "X_SD2_CD_B", "", "", "",
+   "", "", "", "SD2_RESET_B";
+};
+
+ {
+   gpio-line-names = "", "", "", "",
+   "", "", "", "", "", "",
+   "", "", "", "", "", "",
+   "", "", "", "", "nCAN1_EN", "nCAN2_EN";
+};
+
+ {
+   gpio-line-names = "", "", "", "",
+   "", "", "", "", "", "",
+   "", "", "", "", "", "",
+   "", "", "X_PMIC_IRQ_B", "", "nENET0_INT_PWDN";
+};
+
  {
pinctrl_eqos: eqosgrp 

[PATCH v3 2/4] phycore-imx8mp: add USB host support

2024-02-08 Thread Benjamin Hahn
The phyBOARD Pollux has two USB ports. Add support for USB host and USB
storage for the USB1 port.

Signed-off-by: Benjamin Hahn 
---
 configs/phycore-imx8mp_defconfig | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig
index 519e0cfb3d..74450b957b 100644
--- a/configs/phycore-imx8mp_defconfig
+++ b/configs/phycore-imx8mp_defconfig
@@ -65,6 +65,7 @@ CONFIG_CMD_FUSE=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
@@ -104,6 +105,7 @@ CONFIG_DM_ETH_PHY=y
 CONFIG_FEC_MXC=y
 CONFIG_RGMII=y
 CONFIG_MII=y
+CONFIG_PHY_IMX8MQ_USB=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
@@ -120,4 +122,12 @@ CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_SYSRESET_WATCHDOG=y
 CONFIG_DM_THERMAL=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_XHCI_DWC3_OF_SIMPLE=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_USB_STORAGE=y
 CONFIG_IMX_WATCHDOG=y

-- 
2.34.1



[PATCH v3 0/4] phycore-imx8mp: Add USB support

2024-02-08 Thread Benjamin Hahn
add support for various USB features like USB storage, USB mass storage
as well as booting and flashing emmc via UUU.

Signed-off-by: Benjamin Hahn 
---
Changes in v3:
- add patch description for the sync with kernel devicetree commit
- Link to v2: 
https://lore.kernel.org/r/20240131-usb_support-v2-0-7521c554b...@phytec.de

Changes in v2:
- sync kernel devicetree before making changes
- Link to v1: 
https://lore.kernel.org/r/20240129-usb_support-v1-0-8bd2fe840...@phytec.de

---
Benjamin Hahn (4):
  imx8mp-phyboard-pollux-rdk: sync with kernel devicetree from v6.8-rc2
  phycore-imx8mp: add USB host support
  phycore-imx8mp: add USB mass storage support
  phycore-imx8mp: add support for booting and flashing emmc via UUU

 .../arm/dts/imx8mp-phyboard-pollux-rdk-u-boot.dtsi |   4 +
 arch/arm/dts/imx8mp-phyboard-pollux-rdk.dts| 162 -
 board/phytec/phycore_imx8mp/phycore-imx8mp.c   |   4 +
 configs/phycore-imx8mp_defconfig   |  33 -
 include/configs/phycore_imx8mp.h   |   5 +
 5 files changed, 204 insertions(+), 4 deletions(-)
---
base-commit: 0101a2ffe125911ebf89172b495f5ff14f2fd058
change-id: 20240126-usb_support-403f47d71ac1

Best regards,
-- 
Benjamin Hahn 



[GIT PULL] please pull fsl-qoriq-2024-2-8

2024-02-08 Thread Peng Fan
Hi Tom,

Please pull fsl-qoriq-2024-2-8. Sorry for not being active in the past time, 
will try to
catch up.

---
Add TJA1120 driver support
fsl-layerscape/soc.c: do not destroy bootcmd environment
---
CI: https://source.denx.de/u-boot/custodians/u-boot-fsl-qoriq/-/pipelines/19562

Thanks,
Peng.

The following changes since commit 0101a2ffe125911ebf89172b495f5ff14f2fd058:

  Merge branch '2024-02-06-assorted-fixes' (2024-02-07 09:47:47 -0500)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-fsl-qoriq.git 
tags/fsl-qoriq-2024-2-8

for you to fetch changes up to 121696c957d741d17125f5416d1210b11ef8afdd:

  fsl-layerscape/soc.c: do not destroy bootcmd environment (2024-02-08 10:45:32 
+0800)


Mike Looijmans (1):
  fsl-layerscape/soc.c: do not destroy bootcmd environment

Radu Pirea (NXP OSS) (4):
  net: phy: nxp-c45-tja11xx: use local definion of features
  net: phy: nxp-c45-tja11xx: read PHY the speed from hardware
  net: phy: nxp-c45-tja11xx: rename nxp_c45_tja11xx structure
  net: phy: nxp-c45-tja11xx: add tja1120 support

 arch/arm/cpu/armv8/fsl-layerscape/soc.c |  5 +
 drivers/net/phy/nxp-c45-tja11xx.c   | 43 
---
 include/phy.h   |  4 
 3 files changed, 45 insertions(+), 7 deletions(-)


Re: [PATCH v4] misc: fs-loader: Use fw_storage_interface instead of storage_interface

2024-02-08 Thread Roger Quadros



On 08/02/2024 07:19, MD Danish Anwar wrote:
> Hi Sean,
> 
> On 07/02/24 11:14 pm, Sean Anderson wrote:
>> On 1/30/24 01:26, MD Danish Anwar wrote:
>>> The fs-loader driver reads env storage_interface and uses it to load
>>> firmware file into memory using the medium set by env. Update the driver
>>> to use env fw_storage_interface as this variable is only used to load
>>> firmwares. The env storage_interface will act as fallback so that the
>>> existing implementations do not break.
>>>
>>> Also update the FS Loader documentation accordingly.
>>
>> So why do you want to do this? I don't see what the point of renaming the
>> variable is, since you are not e.g. adding any new functionality, and we
>> have to pay for the rename in code size.
>>
> 
> I am upstreaming TI's ICSSG driver for u-boot and during code review
> Roger Quadros  commented asking to rename this
> variable [1]. I think the motive here was to keep all variables used by
> fs-loader driver with 'fw_' prefix. All other variables had 'fw_' prefix
> except for storage_interface.

Can you please mention this motive in the Commit message?

> 
> [1]
> https://lore.kernel.org/all/4721f3b9-f823-47f3-b4f3-ed40002af...@kernel.org/
> 
>> --Sean
> 

-- 
cheers,
-roger


Re: [RFC] Drop md5sum, crc32 and sha1 cmds in favor of hash cmd

2024-02-08 Thread Igor Opaniuk
Hello Tom, Peter,

On Wed, Feb 7, 2024 at 3:16 PM Peter Robinson  wrote:
>
> On Wed, 7 Feb 2024 at 13:48, Tom Rini  wrote:
> >
> > On Wed, Feb 07, 2024 at 02:00:16PM +0100, Igor Opaniuk wrote:
> > > Hello,
> > >
> > > I was playing a bit with different hash functions recently, and
> > > it turned out that md5sum, crc32, sha1 cmds just duplicate
> > > what is already covered by generic `hash` cmd.
> > >
> > > => sha1 0x6000 0x200
> > > sha1 for 6000 ... 61ff ==> 
> > > 4ff5ffc91d00a95155518b920f46e2483d0e1437
> > > => hash sha1 0x6000 0x200
> > > sha1 for 6000 ... 61ff ==> 
> > > 4ff5ffc91d00a95155518b920f46e2483d0e1437
> > >
> > > => crc32 0x6000 0x200
> > > crc32 for 6000 ... 61ff ==> 6fe352e8
> > > => hash crc32 0x6000 0x200
> > > crc32 for 6000 ... 61ff ==> 6fe352e8
> > >
> > > => md5sum 0x6000 0x200
> > > md5 for 6000 ... 61ff ==> e6bbbe95f5b41996f4a9b9af7bbd4050
> > > => hash md5 0x6000 0x200
> > > md5 for 6000 ... 61ff ==> e6bbbe95f5b41996f4a9b9af7bbd4050
> > >
> > > Considering that most of them (besides md5sum) are using the same
> > > int hash_command() function under the hood, but have a lot of duplicated
> > > code for handling params, does it make sense to do some cleanup and
> > > drop all them in favour  `hash`?
> > >
> > > I also plan to extend usage info for `hash` by adding a list
> > > compiled-in algos based on hash related compiled flags
> > > (CONFIG_SHA1, CONFIG_CRC32 etc), so it's clear what algos
> > > are available for hash calculation.
> > >
> > > Comments/objections are welcome!
> >
> > It would be good, implementation wise, if each of those commands was
> > just a redirect to hash ..., similar to how "load " will call the
> > right filesystem calls. Does that make sense? Thanks.
>
> Yes, I actually have that one my todo list to basically alias the
> individual commands to the hash command to remove those commands. My
> intention there was a first step to allow us to eventually minimise or
> even remove the use of obsolete hashes etc.

Thank you for your comments. I'll re-factor as discussed and send a patch
series when it's ready (plan to do that before the next merge window opens).

Regards,
Igor

-- 
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: igor.opan...@gmail.com
skype: igor.opanyuk
http://ua.linkedin.com/in/iopaniuk


Re: [FIX PATCH v1] Fix: common: usb_hub: Reset only USB3.0 hub

2024-02-08 Thread Shantur Rathore
Hi Marek,

On Wed, Feb 7, 2024 at 1:07 PM Marek Vasut  wrote:
>
> On 2/7/24 11:23, Shantur Rathore wrote:
> > USB 3.0 spec requires hub to reset device while
> > enumeration. Some USB 2.0 hubs / devices don't
> > handle this well and after implementation of
> > reset some USB 2.0 disks weren't detected on
> > Allwinner based boards.
> >
> > Resetting only when hub is USB 3.0 fixes it.
>
> It would be good to include as many details about the faulty hardware in
> the commit message as possible, so that when someone else runs into
> this, they would have all that information available.
>
> > Tested-by: Andre Przywara 
> >
> > Signed-off-by: Shantur Rathore 
> > ---
> >
> >   common/usb_hub.c | 6 --
> >   1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/common/usb_hub.c b/common/usb_hub.c
> > index 3fb7e14d10..2e054eb935 100644
> > --- a/common/usb_hub.c
> > +++ b/common/usb_hub.c
> > @@ -174,8 +174,10 @@ static void usb_hub_power_on(struct usb_hub_device 
> > *hub)
> >
> >   debug("enabling power on all ports\n");
> >   for (i = 0; i < dev->maxchild; i++) {
> > - usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_RESET);
> > - debug("Reset : port %d returns %lX\n", i + 1, dev->status);
> > + if (usb_hub_is_superspeed(dev)) {
>
> Should this condition be "all which are lower than superspeed" instead ,
> so when the next generation of USB comes, this problem won't trigger ?
>
> What does Linux do btw ?

As of now Linux checks if the hub is superspeed
https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.c#L2859

which is
 return hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS; // USB_HUB_PR_SS = 3

This holds true for newer SuperSpeedPlus hubs as well.
https://github.com/torvalds/linux/blob/master/drivers/usb/core/hub.h#L155

We can change the check to be  bDeviceProtocol > 2 but who knows if
things change in the newer version of spec.
I am open to suggestions.

Kind regards,
Shantur


Re: [PATCH 0/2] smbios: fill wake-up type

2024-02-08 Thread Mark Kettenis
> From: Heinrich Schuchardt 
> Date: Thu,  8 Feb 2024 11:49:50 +0100
> 
> We should not use the reserved value 0x00 for the wake up type but
> use 0x06 (Power Switch).

Well, if I look at my collection of boards, many don't even have a
power switch.  So I think the only sensible default value is 0x02
(Unknown).

If there is a compelling use-case for providing a more accurate value,
that should probably be done by the various PMIC drivers.

> Correctly display wake-up type in smbios command.
> 
> Display SMBIOS type 1 field family in smbios command.
> 
> Heinrich Schuchardt (2):
>   cmd: smbios: type 1 wake-up time, family
>   smbios: fill wake-up type
> 
>  cmd/smbios.c | 25 +++--
>  include/smbios.h |  2 ++
>  lib/smbios.c |  1 +
>  3 files changed, 26 insertions(+), 2 deletions(-)
> 
> -- 
> 2.43.0
> 
> 


[PATCH 2/2] smbios: fill wake-up type

2024-02-08 Thread Heinrich Schuchardt
We should not use the reserved value 0x00 for the wake up type but
use 0x06 (Power Switch).

Signed-off-by: Heinrich Schuchardt 
---
 include/smbios.h | 2 ++
 lib/smbios.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/include/smbios.h b/include/smbios.h
index 3df8827b60d..704d7e5dc86 100644
--- a/include/smbios.h
+++ b/include/smbios.h
@@ -108,6 +108,8 @@ struct __packed smbios_type0 {
char eos[SMBIOS_STRUCT_EOS_BYTES];
 };
 
+#define SMBIOS_WAKEUP_TYPE_POWER_SWITCH 0x06
+
 struct __packed smbios_type1 {
u8 type;
u8 length;
diff --git a/lib/smbios.c b/lib/smbios.c
index c83af730a91..8599743738a 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -394,6 +394,7 @@ static int smbios_write_type1(ulong *current, int handle,
} else {
t->serial_number = smbios_add_prop(ctx, "serial", NULL);
}
+   t->wakeup_type = SMBIOS_WAKEUP_TYPE_POWER_SWITCH;
t->sku_number = smbios_add_prop(ctx, "sku", NULL);
t->family = smbios_add_prop(ctx, "family", NULL);
 
-- 
2.43.0



[PATCH 1/2] cmd: smbios: type 1 wake-up time, family

2024-02-08 Thread Heinrich Schuchardt
Correct type 1 output

* render wake up time as string
* print family string
* remove duplicate serial number output

Signed-off-by: Heinrich Schuchardt 
---
 cmd/smbios.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/cmd/smbios.c b/cmd/smbios.c
index 66f6b761378..f79619c1f0b 100644
--- a/cmd/smbios.c
+++ b/cmd/smbios.c
@@ -14,6 +14,18 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static const char * const wakeup_type_strings[] = {
+   "Reserved", /* 0x00 */
+   "Other",/* 0x01 */
+   "Unknown",  /* 0x02 */
+   "APM Timer",/* 0x03 */
+   "Modem Ring",   /* 0x04 */
+   "Lan Remote",   /* 0x05 */
+   "Power Switch", /* 0x06 */
+   "PCI PME#", /* 0x07 */
+   "AC Power Restored",/* 0x08 */
+};
+
 /**
  * smbios_get_string() - get SMBIOS string from table
  *
@@ -72,6 +84,14 @@ void smbios_print_str(const char *label, void *table, u8 
index)
printf("\t%s: %s\n", label, smbios_get_string(table, index));
 }
 
+const char *smbios_wakeup_type_str(u8 wakeup_type)
+{
+   if (wakeup_type >= ARRAY_SIZE(wakeup_type_strings))
+   /* Values over 0x08 are reserved. */
+   wakeup_type = 0;
+   return wakeup_type_strings[wakeup_type];
+}
+
 static void smbios_print_type1(struct smbios_type1 *table)
 {
printf("System Information\n");
@@ -81,11 +101,12 @@ static void smbios_print_type1(struct smbios_type1 *table)
smbios_print_str("Serial Number", table, table->serial_number);
if (table->length >= 0x19) {
printf("\tUUID: %pUl\n", table->uuid);
-   smbios_print_str("Wake Up Type", table, table->serial_number);
+   printf("\tWake-up Type: %s\n",
+  smbios_wakeup_type_str(table->wakeup_type));
}
if (table->length >= 0x1b) {
-   smbios_print_str("Serial Number", table, table->serial_number);
smbios_print_str("SKU Number", table, table->sku_number);
+   smbios_print_str("Family", table, table->family);
}
 }
 
-- 
2.43.0



[PATCH 0/2] smbios: fill wake-up type

2024-02-08 Thread Heinrich Schuchardt
We should not use the reserved value 0x00 for the wake up type but
use 0x06 (Power Switch).

Correctly display wake-up type in smbios command.

Display SMBIOS type 1 field family in smbios command.

Heinrich Schuchardt (2):
  cmd: smbios: type 1 wake-up time, family
  smbios: fill wake-up type

 cmd/smbios.c | 25 +++--
 include/smbios.h |  2 ++
 lib/smbios.c |  1 +
 3 files changed, 26 insertions(+), 2 deletions(-)

-- 
2.43.0



Re: [PATCH v4 5/7] configs: am62x_evm_*: Enable USB and DFU support

2024-02-08 Thread Mattijs Korpershoek
Hi Sjoerd,

Thank you for the patch.

On ven., janv. 12, 2024 at 09:52, 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 config fragment for DFU
> supports which disables support for persistent storage to free up space
> for USB support
>
> Signed-off-by: Sjoerd Simons 

I know this will be reworked in v5 (to use defconfig fragments) as
discussed in [1] but i'd still like to give some feedback on my testing.

Applying this series seems to break eMMC booting for me on AM62x SK EVM:

U-Boot SPL 2024.04-rc1-00106-g7c3798e43744 (Feb 08 2024 - 10:41:17 +0100)
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.1.8--v09.01.08 (Kool Koala)')
SPL initial stack usage: 13368 bytes
Trying to boot from MMC1
alloc space exhausted
spl_load_image_fat: error reading image tispl.bin, err - -22
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

It seems that the size of tispl.bin gets too big because of this commit.

Before series:
~/work/ti/src/bootloaders-upstream/out/ $ du -s tispl.bin_unsigned
796 tispl.bin_unsigned

After series:
~/work/ti/src/bootloaders-upstream/out/ $ du -s tispl.bin_unsigned
876 tispl.bin_unsigned

Per my understanding, this change increases the size of the a53 U-Boot
SPL, which is why we can no longer boot from eMMC.

Here is are other depending project refs:
- optee_os: 439c5ecbb68b ("core: arm: fix integer overflow in 
generic_timer_{handler,start}()")
- ti-linux-firmware: 0350c2edecab ("ti-dm: Update firmware for J722S device")
- trustef-firmware-a: 17bef2248d45 ("Merge "feat(fvp): delegate FFH RAS 
handling to SP" into integration")

Reverting just this commit makes it boot to eMMC for me again.

I also tried this downstream change[2] to increase the alloc space in
the SPL. That did not fix the booting problem.

To fix it, I had to remove:
CONFIG_SPL_ENV_SUPPORT=y
CONFIG_SPL_DFU=y

Which bring down the tispl to:
~/work/ti/src/bootloaders-upstream/out/ $ du -s tispl.bin_unsigned
820 tispl.bin_unsigned

Of course, removing both config options is not an acceptable solution since
it defeats the purpose of this patch.

Did you test booting from eMMC when developping this series, or did you
just tested booting from DFU ?

[1] 
https://lore.kernel.org/all/b587fcaebed8b61285a901b468e3ccbddf7d06f2.ca...@collabora.com/
[2] 
https://git.ti.com/cgit/ti-u-boot/ti-u-boot/commit/?h=ti-u-boot-2023.04=28c1b1ec8ba89b7c7b2cd43483054a432552008f

>
> ---
>
> Changes in v4:
> - Move R5 dfu config to a config fragment rather then a full defconfig
> - Don't enable XHCI for the R5 SPL, unneeded
>
> Changes in v3:
> - Run savedefconfig to adjust to more recent u-boot
>
> Changes in v2:
> - Create a seperate defconfig for R5
>
>  configs/am62x_evm_a53_defconfig | 30 ++
>  configs/am62x_r5_usbdfu.config  | 28 
>  2 files changed, 58 insertions(+)
>  create mode 100644 configs/am62x_r5_usbdfu.config
>
> diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
> index aa96c1b3125..f335eb11e63 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
> @@ -41,16 +42,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_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
> @@ -61,10 +69,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
> @@ -103,4 +118,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
> +CONFIG_USB_DWC3=y
> +CONFIG_USB_DWC3_GENERIC=y
> +CONFIG_SPL_USB_DWC3_GENERIC=y
> +CONFIG_SPL_USB_DWC3_AM62=y
> 

[PATCH] mmc: arm_pl180_mmci: Rely on DM

2024-02-08 Thread Linus Walleij
The PL180/MMCI driver is implied to use CONFIG_DM and the ARM
defconfigs such as configs/vexpress_ca9x4_defconfig will get it
as well.

With a simple oneline to default to not being the v2 variant,
the original ARM MMCI variant works fine with the driver as well.
The IP version actually needs to be read out from a register on
the ARM versions, but we will simply assume we are running on the
original hardware if arm,primecell-periphid is not explicitly
specified in the device tree.

Drop the !CONFIG_DM code and depend on DM_MMC.

Tested on the Versatile Express CA9x4 board.

Signed-off-by: Linus Walleij 
---
 drivers/mmc/Kconfig  |  1 +
 drivers/mmc/arm_pl180_mmci.c | 66 ++--
 2 files changed, 3 insertions(+), 64 deletions(-)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 17618c3bdcc1..59716c3966e5 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -79,6 +79,7 @@ config MMC_SPI_CRC_ON
 
 config ARM_PL180_MMCI
bool "ARM AMBA Multimedia Card Interface and compatible support"
+   depends on DM_MMC
help
  This selects the ARM(R) AMBA(R) PrimeCell Multimedia Card
  Interface (PL180, PL181 and compatible) support.
diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c
index 5cf5502ed545..2666b65362bc 100644
--- a/drivers/mmc/arm_pl180_mmci.c
+++ b/drivers/mmc/arm_pl180_mmci.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -25,8 +26,6 @@
 #include "arm_pl180_mmci.h"
 #include 
 
-#ifdef CONFIG_DM_MMC
-#include 
 #define MMC_CLOCK_MAX  4800
 #define MMC_CLOCK_MIN  40
 
@@ -34,7 +33,6 @@ struct arm_pl180_mmc_plat {
struct mmc_config cfg;
struct mmc mmc;
 };
-#endif
 
 static int wait_for_command_end(struct mmc *dev, struct mmc_cmd *cmd)
 {
@@ -358,65 +356,6 @@ static int  host_set_ios(struct mmc *dev)
return 0;
 }
 
-#ifndef CONFIG_DM_MMC
-/* MMC uses open drain drivers in the enumeration phase */
-static int mmc_host_reset(struct mmc *dev)
-{
-   struct pl180_mmc_host *host = dev->priv;
-
-   writel(host->pwr_init, >base->power);
-
-   return 0;
-}
-
-static const struct mmc_ops arm_pl180_mmci_ops = {
-   .send_cmd = host_request,
-   .set_ios = host_set_ios,
-   .init = mmc_host_reset,
-};
-
-/*
- * mmc_host_init - initialize the mmc controller.
- * Set initial clock and power for mmc slot.
- * Initialize mmc struct and register with mmc framework.
- */
-
-int arm_pl180_mmci_init(struct pl180_mmc_host *host, struct mmc **mmc)
-{
-   u32 sdi_u32;
-
-   writel(host->pwr_init, >base->power);
-   writel(host->clkdiv_init, >base->clock);
-   udelay(CLK_CHANGE_DELAY);
-
-   /* Disable mmc interrupts */
-   sdi_u32 = readl(>base->mask0) & ~SDI_MASK0_MASK;
-   writel(sdi_u32, >base->mask0);
-
-   host->cfg.name = host->name;
-   host->cfg.ops = _pl180_mmci_ops;
-
-   /* TODO remove the duplicates */
-   host->cfg.host_caps = host->caps;
-   host->cfg.voltages = host->voltages;
-   host->cfg.f_min = host->clock_min;
-   host->cfg.f_max = host->clock_max;
-   if (host->b_max != 0)
-   host->cfg.b_max = host->b_max;
-   else
-   host->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
-
-   *mmc = mmc_create(>cfg, host);
-   if (!*mmc)
-   return -1;
-   debug("registered mmc interface number is:%d\n",
- (*mmc)->block_dev.devnum);
-
-   return 0;
-}
-#endif
-
-#ifdef CONFIG_DM_MMC
 static void arm_pl180_mmc_init(struct pl180_mmc_host *host)
 {
u32 sdi_u32;
@@ -477,7 +416,7 @@ static int arm_pl180_mmc_probe(struct udevice *dev)
host->version2 = true;
break;
default:
-   host->version2 = true;
+   host->version2 = false; /* ARM variant */
}
 
gpio_request_by_name(dev, "cd-gpios", 0, >cd_gpio, GPIOD_IS_IN);
@@ -561,4 +500,3 @@ U_BOOT_DRIVER(arm_pl180_mmc) = {
.priv_auto  = sizeof(struct pl180_mmc_host),
    .plat_auto  = sizeof(struct arm_pl180_mmc_plat),
 };
-#endif

---
base-commit: 0101a2ffe125911ebf89172b495f5ff14f2fd058
change-id: 20240208-uboot-vexpress-ca9-127bd6b163df

Best regards,
-- 
Linus Walleij 



[PATCH v1 2/2] arm: mach-k3: am62: Fixup thermal zone critical points

2024-02-08 Thread Francesco Dolcini
From: Joao Paulo Goncalves 

Read the max temperature for the SoC temperature grade from the hardware
and change the critical trip nodes on each thermal zone of FDT at
runtime so they are correct with the hardware value for its grade.

Signed-off-by: Joao Paulo Goncalves 
Signed-off-by: Francesco Dolcini 
---
 arch/arm/mach-k3/am625_fdt.c | 37 
 1 file changed, 37 insertions(+)

diff --git a/arch/arm/mach-k3/am625_fdt.c b/arch/arm/mach-k3/am625_fdt.c
index 970dd3447dec..3c46d1028fd0 100644
--- a/arch/arm/mach-k3/am625_fdt.c
+++ b/arch/arm/mach-k3/am625_fdt.c
@@ -38,11 +38,48 @@ static void fdt_fixup_pru_node_am625(void *blob, int 
has_pru)
fdt_del_node_path(blob, "/bus@f/pruss@3004");
 }
 
+static int fdt_fixup_trips_node(void *blob, int zoneoffset, int maxc)
+{
+   int node, trip;
+
+   node = fdt_subnode_offset(blob, zoneoffset, "trips");
+   if (node < 0)
+   return -1;
+
+   fdt_for_each_subnode(trip, blob, node) {
+   const char *type = fdt_getprop(blob, trip, "type", NULL);
+
+   if (!type || (strncmp(type, "critical", 8) != 0))
+   continue;
+
+   if (fdt_setprop_u32(blob, trip, "temperature", 1000 * maxc) < 0)
+   return -1;
+   }
+
+   return 0;
+}
+
+static void fdt_fixup_thermal_zone_nodes_am625(void *blob, int maxc)
+{
+   int node, zone;
+
+   node = fdt_path_offset(blob, "/thermal-zones");
+   if (node < 0)
+   return;
+
+   fdt_for_each_subnode(zone, blob, node) {
+   if (fdt_fixup_trips_node(blob, zone, maxc) < 0)
+   printf("Failed to set temperature in %s critical 
trips\n",
+  fdt_get_name(blob, zone, NULL));
+   }
+}
+
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
fdt_fixup_cores_nodes_am625(blob, k3_get_core_nr());
fdt_fixup_gpu_nodes_am625(blob, k3_has_gpu());
fdt_fixup_pru_node_am625(blob, k3_has_pru());
+   fdt_fixup_thermal_zone_nodes_am625(blob, k3_get_max_temp());
 
return 0;
 }
-- 
2.39.2



[PATCH v1 1/2] arm: mach-k3: am62: Get soc max temperature by grade

2024-02-08 Thread Francesco Dolcini
From: Joao Paulo Goncalves 

AM62x SoC is available in multiple temperature grade:
- Commercial: 0° to 95° C
- Industrial: -40° to 105° C
- Automotive: -40° to 125° C

Add a new function that returns the am62 max temperature value
accordingly to its temperature grade in Celsius.

Signed-off-by: Joao Paulo Goncalves 
Signed-off-by: Francesco Dolcini 
---
 arch/arm/mach-k3/include/mach/am62_hardware.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/arch/arm/mach-k3/include/mach/am62_hardware.h 
b/arch/arm/mach-k3/include/mach/am62_hardware.h
index 54380f36e161..9c4c6c542b63 100644
--- a/arch/arm/mach-k3/include/mach/am62_hardware.h
+++ b/arch/arm/mach-k3/include/mach/am62_hardware.h
@@ -42,6 +42,10 @@
 
 #define JTAG_DEV_FEATURE_NO_PRU0x4
 
+#define JTAG_DEV_TEMP_COMMERCIAL   0x3
+#define JTAG_DEV_TEMP_INDUSTRIAL   0x4
+#define JTAG_DEV_TEMP_AUTOMOTIVE   0x5
+
 #define CTRLMMR_MAIN_DEVSTAT   (WKUP_CTRL_MMR0_BASE + 0x30)
 #define MAIN_DEVSTAT_PRIMARY_BOOTMODE_MASK GENMASK(6, 3)
 #define MAIN_DEVSTAT_PRIMARY_BOOTMODE_SHIFT3
@@ -102,6 +106,19 @@ static inline int k3_get_temp_grade(void)
return (full_devid & JTAG_DEV_TEMP_MASK) >> JTAG_DEV_TEMP_SHIFT;
 }
 
+static inline int k3_get_max_temp(void)
+{
+   switch (k3_get_temp_grade()) {
+   case JTAG_DEV_TEMP_INDUSTRIAL:
+   return 105;
+   case JTAG_DEV_TEMP_AUTOMOTIVE:
+   return 125;
+   case JTAG_DEV_TEMP_COMMERCIAL:
+   default:
+   return 95;
+   }
+}
+
 static inline int k3_has_pru(void)
 {
u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
-- 
2.39.2



[PATCH v1 0/2] arm: mach-k3: am62: Fixup thermal zone critical points

2024-02-08 Thread Francesco Dolcini
From: Francesco Dolcini 

This series adds support to dynamically fixup the DT the critical thermal trip
point of TI AM62 depending on the SoC temperature grade.

Joao Paulo Goncalves (2):
  arm: mach-k3: am62: Get soc max temperature by grade
  arm: mach-k3: am62: Fixup thermal zone critical points

 arch/arm/mach-k3/am625_fdt.c  | 37 +++
 arch/arm/mach-k3/include/mach/am62_hardware.h | 17 +
 2 files changed, 54 insertions(+)

-- 
2.39.2



Re: [PATCH v1] vexpress_ca9x4: Enable DM_SERIAL

2024-02-08 Thread Linus Walleij
On Mon, Feb 5, 2024 at 9:18 AM Ole Orhagen 
wrote:

>
> But I will try to dust it off and test it again.
>>
>
> Did you get any results from the tests?
>


Yes!

It works fine both before and after the patch. Latest log from
the actual hardware:

Cmd> usb_on
Enabling debug USB...

(here I copy over the binary to the internal SD-card which is
presented over USB mass storage)

Cmd> reboot

Powering up system...
Daughterboard fitted to site 1.

Switching on ATXPSU...
ATX3V3: ON
VIOset: 1.8V
MBtemp: 29 degC

Configuring motherboard (rev D, var A)...
IOFPGA  config: PASSED
MUXFPGA config: PASSED
OSC CLK config: PASSED
Programming image \SOFTWARE\boot-a9.bin
Erasing Flash image boot.bin
...
Erasing Flash
...
Writing Flash
.
Updating eeprom with image boot.bin
Image: boot.bin UPDATED from \SOFTWARE\boot-a9.bin

Testing SMC devices (FPGA build 8)...
SRAM 32MB test: PASSED
VRAM  8MB test: PASSED
LAN9118   test: PASSED
USB & OTG test: PASSED
KMI1/KMI2 test: PASSED
MMC & SD  test: PASSED
DVI image test: PASSED
AACI AC97 test: PASSED
CF card   test: PASSED
UART port test: PASSED
MAC addrs test: PASSED

Reading Site 1 Board File \SITE1\HBI0191B\board.txt
DB1 JTAG configuration complete.
Setting DB1 OSCCLKS...
DB1.0 DCC 0 SPI configuration complete.

Writing SCC 0x4061 with 0xBB8A802A
Writing SCC 0x40610001 with 0x1F09
Writing SCC 0x40610002 with 0x
DB1.0 DCC 0 SCC configuration complete.

DB SMB clock enabled.
Waiting for SITE1 CB_READY...
Testing SMB clock...
Configuring MUXFPGA for DB1.
Setting DVI mode for XGA.
Releasing Daughterboard resets.
Switching MCC log to UART1.

ARM Versatile Express Boot Monitor
Version:V5.2.1
Build Date: Apr  4 2013
Daughterboard Site 1: V2P-CA9 Cortex A9
Daughterboard Site 2: Not Used
Running boot script from flash - BOOTSCRIPT


U-Boot 2024.04-rc1-00101-g0101a2ffe125 (Feb 08 2024 - 09:21:31 +0100)

DRAM:  512 MiB (effective 1 GiB)
WARNING: Caches not enabled
Core:  22 devices, 11 uclasses, devicetree: embed
Flash: 128 MiB
MMC:   mmci@5000: 0
Loading Environment from Flash... OK
In:uart@9000
Out:   uart@9000
Err:   uart@9000
Net:   eth0: ethernet@3,0200
Hit any key to stop autoboot:  0
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 00:02:f7:00:3c:9d
Using ethernet@3,0200 device
TFTP from server 192.168.1.140; our IP address is 192.168.1.35
Filename 'zImage'.
Load address: 0x6200
Loading: smc911x: MAC 00:02:f7:00:3c:9d

Yours,
Linus Walleij