[PATCH 1/1] imx: imx9: fixup thermal trips from fuses

2024-01-11 Thread Primoz Fiser
Read i.MX9 CPU temp grade from fuses and fixup thermal trips in Linux
device-tree accordingly.

Based on commit 0543a1ed2787 ("imx8m: fixup thermal trips")

Signed-off-by: Primoz Fiser 
---
 arch/arm/mach-imx/imx9/soc.c | 45 
 1 file changed, 45 insertions(+)

diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-imx/imx9/soc.c
index 86b45be3d804..f06339f13880 100644
--- a/arch/arm/mach-imx/imx9/soc.c
+++ b/arch/arm/mach-imx/imx9/soc.c
@@ -507,8 +507,53 @@ int print_cpuinfo(void)
return 0;
 }
 
+static int fixup_thermal_trips(void *blob, const char *name)
+{
+   int minc, maxc;
+   int node, trip;
+
+   node = fdt_path_offset(blob, "/thermal-zones");
+   if (node < 0)
+   return node;
+
+   node = fdt_subnode_offset(blob, node, name);
+   if (node < 0)
+   return node;
+
+   node = fdt_subnode_offset(blob, node, "trips");
+   if (node < 0)
+   return node;
+
+   get_cpu_temp_grade(&minc, &maxc);
+
+   fdt_for_each_subnode(trip, blob, node) {
+   const char *type;
+   int temp, ret;
+
+   type = fdt_getprop(blob, trip, "type", NULL);
+   if (!type)
+   continue;
+
+   temp = 0;
+   if (!strcmp(type, "critical"))
+   temp = 1000 * (maxc - 5);
+   else if (!strcmp(type, "passive"))
+   temp = 1000 * (maxc - 10);
+   if (temp) {
+   ret = fdt_setprop_u32(blob, trip, "temperature", temp);
+   if (ret)
+   return ret;
+   }
+   }
+
+   return 0;
+}
+
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
+   if (fixup_thermal_trips(blob, "cpu-thermal"))
+   printf("Failed to update cpu-thermal trip(s)");
+
return 0;
 }
 
-- 
2.25.1



[PATCH 0/1] i.MX9 thermal trip fixups

2024-01-11 Thread Primoz Fiser
With recent introduction of i.MX93 silicone revision A1, the thermal
grade fuses are properly set for the different CPU temperature grades
(e.g. Industrial or Automotive grade).

Thus read thermal trips from fuses and fixup Linux device-tree temp
trips accordingly to the CPU temp grade.

BR,
Primoz

Primoz Fiser (1):
  imx: imx9: fixup thermal trips from fuses

 arch/arm/mach-imx/imx9/soc.c | 45 
 1 file changed, 45 insertions(+)

-- 
2.25.1



Re: [PATCH] Add Phytec i.MX93 support

2024-01-18 Thread Primoz Fiser
Hi Mathieu,

I already gave my review on the kernel mailing list.

As first step, naming scheme is not compatible with PHYTEC naming
convention. Please fix it across the entire patch. Maybe reference
downstream u-boot for that?

Please also use "phyBOARD-Segin-i.MX93" when referencing the board as
this is the official board name.

On 17. 01. 24 08:52, Mathieu Othacehe wrote:
> Add support for the Phytec i.MX93 Segin evaluation kit. The SoM consists
> of an NXP i.MX93 dual A55 CPU. The SoM is mounted on a Phytec Segin SBC.
> 
> Signed-off-by: Mathieu Othacehe 
> ---
>  arch/arm/dts/Makefile |3 +-
>  arch/arm/dts/imx93-phycore-segin-u-boot.dtsi  |  274 +++
>  arch/arm/dts/imx93-phycore-segin.dts  |   95 +>  
> arch/arm/dts/imx93-phycore-som.dtsi   |   64 +
>  arch/arm/mach-imx/imx9/Kconfig|6 +
>  board/phytec/common/mmc.c |   49 +
>  board/phytec/imx93_phycore/Kconfig|   21 +
>  board/phytec/imx93_phycore/MAINTAINERS|   10 +
>  board/phytec/imx93_phycore/Makefile   |   16 +
>  board/phytec/imx93_phycore/imx93_phycore.c|   89 +
>  board/phytec/imx93_phycore/imx93_phycore.env  |   96 +

s/imx93_phycore/phycore_imx93

To fit into existing PHYTEC boards already in tree.


>  .../phytec/imx93_phycore/lpddr4_timing_1GB.c  | 1546 +

Remove _1GB suffix.

PHYTEC DRAM auto-detection will follow later.


>  board/phytec/imx93_phycore/spl.c  |  181 ++
>  configs/imx93_phycore_defconfig   |  147 ++

should be phycore-imx93_defconfig


>  doc/board/phytec/imx93_phycore.rst|   68 +
>  doc/board/phytec/index.rst|1 +
>  include/configs/imx93_phycore.h   |   47 +
>  17 files changed, 2712 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/dts/imx93-phycore-segin-u-boot.dtsi
>  create mode 100644 arch/arm/dts/imx93-phycore-segin.dts
>  create mode 100644 arch/arm/dts/imx93-phycore-som.dtsi
>  create mode 100644 board/phytec/common/mmc.c
>  create mode 100644 board/phytec/imx93_phycore/Kconfig
>  create mode 100644 board/phytec/imx93_phycore/MAINTAINERS
>  create mode 100644 board/phytec/imx93_phycore/Makefile
>  create mode 100644 board/phytec/imx93_phycore/imx93_phycore.c
>  create mode 100644 board/phytec/imx93_phycore/imx93_phycore.env
>  create mode 100644 board/phytec/imx93_phycore/lpddr4_timing_1GB.c
>  create mode 100644 board/phytec/imx93_phycore/spl.c
>  create mode 100644 configs/imx93_phycore_defconfig
>  create mode 100644 doc/board/phytec/imx93_phycore.rst
>  create mode 100644 include/configs/imx93_phycore.h
> 
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index d456a524b36..4a23e2a2f49 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -1127,7 +1127,8 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
>  
>  dtb-$(CONFIG_ARCH_IMX9) += \
>   imx93-11x11-evk.dtb \
> - imx93-var-som-symphony.dtb
> + imx93-var-som-symphony.dtb \
> + imx93-phycore-segin.dtb

s/imx93-phycore-segin/imx93-phyboard-segin

>  
>  dtb-$(CONFIG_ARCH_IMXRT) += imxrt1050-evk.dtb \
>   imxrt1020-evk.dtb \
> diff --git a/arch/arm/dts/imx93-phycore-segin-u-boot.dtsi 
> b/arch/arm/dts/imx93-phycore-segin-u-boot.dtsi
> new file mode 100644
> index 000..6d75f1985aa
> --- /dev/null
> +++ b/arch/arm/dts/imx93-phycore-segin-u-boot.dtsi
> @@ -0,0 +1,274 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +/*
> + * Copyright (C) 2023 PHYTEC Messtechnik GmbH
> + * Christoph Stoidner 
> + *
> + * Product homepage:
> + * phyBOARD-Segin carrier board is reused for the i.MX93 design.
> + * 
> https://www.phytec.de/produkte/single-board-computer/phyboard-segin-imx6ul/
> + */
> +

Please sync header with what you have sent to linux mailing lists.

> +#include "imx93-u-boot.dtsi"
> +
> +/ {
> + wdt-reboot {
> + compatible = "wdt-reboot";
> + wdt = <&wdog3>;
> + bootph-pre-ram;
> + bootph-some-ram;
> + };
> +
> + aliases {
> + ethernet0 = &eqos;> +   ethernet1 = &fec;
> + };
> +
> + firmware {
> + optee {
> + compatible = "linaro,optee-tz";
> + method = "smc";
> + };
> + };
> +};
> +
> +&{/soc@0} {
> + bootph-all;
> + bootph-pre-ram;
> +};
> +
> +&aips1 {
> + bootph-pre-ram;
> + bootph-all;
> +};
> +
> +&aips2 {
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
> +&aips3 {
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
> +&iomuxc {
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
> +®_usdhc2_vmmc {
> + u-boot,off-on-delay-us = <2>;
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
> +&pinctrl_reg_usdhc2_vmmc {
> + bootph-pre-ram;
> +};
> +
> +&pinctrl_uart1 {
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
> +&pinctrl_usdhc2 {
> + bootph-pre-ram;
> + bootph-some-ram

Re: [PATCH v2] Add Phytec i.MX93 support

2024-01-25 Thread Primoz Fiser
Hi Mathieu,

First of all, thank you for the v2.

I was able quickly build & test on the actual board.

Here are my findings:

- FEC ethernet doesn't work
- distroboot doesn't work

Did you expirience the same?

Nonetheless, here are my comments for v2:


On 24. 01. 24 14:42, Mathieu Othacehe wrote:
> Add support for the Phytec i.MX93 Segin evaluation kit. The SoM consists
> of an NXP i.MX93 dual A55 CPU. The SoM is mounted on a Phytec Segin SBC.

Can you rework you commit msg + title please?

Something like this would be more appropriate:

title:

"board: phytec: phycore-imx93: Add phyBOARD-Segin-i.MX93 support"

msg:

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
- debug UART
- watchdog



Thanks!


> 
> Signed-off-by: Mathieu Othacehe 
> ---
> Hello,
> 
> This new revision takes Yannic and Primoz comments into account.  I went
> for a configuration file that is named imx93-phyboard-segin_defconfig,
> which is inline with the imx8mm-phygate-tauri-l_defconfig, as discussed
> with Yannic.>
> This way, the device tree and the configuration files are matching. I
> restored the original phycore_imx93 directory in board/phytec/. The
> documentation is updated accordingly.>
> I aligned the device trees with the v5 revision of the matching kernel
> patch.
> 
> I removed the initialization of fec and eqos Ethernet ports that is not
> tested yet.
> 
> Thanks,
> 
> Mathieu>
> v1: https://lists.denx.de/pipermail/u-boot/2024-January/543599.html
> 
>  arch/arm/dts/Makefile |3 +-
>  arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi |  287 +++
>  arch/arm/dts/imx93-phyboard-segin.dts |  117 ++
>  arch/arm/dts/imx93-phycore-som.dtsi   |  126 ++
>  arch/arm/mach-imx/imx9/Kconfig|6 +
>  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|   61 +
>  board/phytec/phycore_imx93/phycore_imx93.env  |   96 +
>  board/phytec/phycore_imx93/spl.c  |  182 ++
>  configs/imx93-phyboard-segin_defconfig|  147 ++
>  doc/board/phytec/imx93-phyboard-segin.rst |   61 +
>  doc/board/phytec/index.rst|1 +
>  include/configs/phycore_imx93.h   |   47 +
>  16 files changed, 2716 insertions(+), 1 deletion(-)
>  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

board file is named phycore-imx93.c in downstream.

Also other PHYTEC products in upstream use the same:

$ ls board/phytec/phycore_*/phycore*.c
board/phytec/phycore_am62x/phycore-am62x.c
board/phytec/phycore_imx93/phycore_imx93.c
board/phytec/phycore_imx8mm/phycore-imx8mm.c
board/phytec/phycore_rk3288/phycore-rk3288.c
board/phytec/phycore_imx8mp/phycore-imx8mp.c

Can you rename to match other?

>  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-segin_defconfig
>  create mode 100644 doc/board/phytec/imx93-phyboard-segin.rst
>  create mode 100644 include/configs/phycore_imx93.h
> 
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index d456a524b36..e7687a1b57d 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -1127,7 +1127,8 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
>  
>  dtb-$(CONFIG_ARCH_IMX9) += \
>   imx93-11x11-evk.dtb \
> - imx93-var-som-symphony.dtb
> + imx93-var-som-symphony.dtb \
> + imx93-phyboard-segin.dtb
>  
>  dtb-$(CONFIG_ARCH_IMXRT) += imxrt1050-evk.dtb \
>   imxrt1020-evk.dtb \
> diff --git a/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi 
> b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> new file mode 100644
> index 000..3d4c851b0d0
> --- /dev/null
> +++ b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> @@ -0,0 +1,287 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +/*
> + * Copyright (C) 2023 PHYTEC Messtechnik GmbH
> + * Christoph Stoidner 
> + *
> + * Product homepage:
> + * phyBOARD-Segin carrier board is reused for the i.MX93 design.
> + * 
> https://www.phytec.eu/en/produkte/single-board-computer/phyboard-segin-imx6ul/
> + */
> +
> +#include "imx93-u-boot.dtsi"
> +
> +/ {
> + wdt-reboot {
> + compatible = "wdt-reboot";
> + wdt = <&wdog3>;
> + bootph-pre-

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

2024-01-29 Thread Primoz Fiser


Hi Mathieu,

thanks for fixing my remarks.

Here are just a few left for v4.


On 25. 01. 24 17:45, 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
> - debug UART
> - watchdog
> 
> Signed-off-by: Mathieu Othacehe 
> ---
> Hello,
> 
> This new revision fixes the remarks of Primoz. It uses configuration and an
> environment files closer to what's inside the downstream project.
> 
> Thanks,
> 
> Mathieu
> 
> v2: https://lists.denx.de/pipermail/u-boot/2024-January/544396.html
> 
>  arch/arm/dts/Makefile |3 +-
>  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/imx9/Kconfig|6 +
>  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  |   85 +
>  board/phytec/phycore_imx93/spl.c  |  150 ++
>  configs/imx93-phyboard-segin_defconfig|  149 ++
>  doc/board/phytec/imx93-phyboard-segin.rst |   61 +
>  doc/board/phytec/index.rst|1 +
>  include/configs/phycore_imx93.h   |   28 +
>  16 files changed, 2643 insertions(+), 1 deletion(-)
>  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-segin_defconfig
>  create mode 100644 doc/board/phytec/imx93-phyboard-segin.rst
>  create mode 100644 include/configs/phycore_imx93.h
> 
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index d456a524b36..e7687a1b57d 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -1127,7 +1127,8 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
>  
>  dtb-$(CONFIG_ARCH_IMX9) += \
>   imx93-11x11-evk.dtb \
> - imx93-var-som-symphony.dtb
> + imx93-var-som-symphony.dtb \
> + imx93-phyboard-segin.dtb
>  
>  dtb-$(CONFIG_ARCH_IMXRT) += imxrt1050-evk.dtb \
>   imxrt1020-evk.dtb \
> diff --git a/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi 
> b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> new file mode 100644
> index 000..c194b009274
> --- /dev/null
> +++ b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> @@ -0,0 +1,293 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +/*
> + * Copyright (C) 2023 PHYTEC Messtechnik GmbH
> + * Christoph Stoidner 
> + *
> + * Product homepage:
> + * phyBOARD-Segin carrier board is reused for the i.MX93 design.
> + * 
> https://www.phytec.eu/en/produkte/single-board-computer/phyboard-segin-imx6ul/
> + */
> +
> +#include "imx93-u-boot.dtsi"
> +
> +/ {
> + wdt-reboot {
> + compatible = "wdt-reboot";
> + wdt = <&wdog3>;
> + bootph-pre-ram;
> + bootph-some-ram;
> + };
> +
> + aliases {
> + ethernet0 = &eqos;
> + ethernet1 = &fec;

Please make "fec" the primary eth interface here, like so:

aliases {
ethernet0 = &fec;
ethernet1 = &eqos;
};

Reason: FEC's phy is on the SoM while EQOS' phy is on the base-board. To
reuse phycore-imx93 code between multiple base-boards PHYTEC prefers to
make the SoM's eth interface the primary one.


> + };
> +
> + firmware {
> + optee {
> + compatible = "linaro,optee-tz";
> + method = "smc";
> + };
> + };
> +};
> +
> +&{/soc@0} {
> + bootph-all;
> + bootph-pre-ram;
> +};
> +
> +&aips1 {
> + bootph-pre-ram;
> + bootph-all;
> +};
> +
> +&aips2 {
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
> +&aips3 {
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
> +&iomuxc {
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
> +®_usdhc2_vmmc {
> + u-boot,off-on-delay-us = <2>;
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
> +&pinctrl_reg_usdhc2_vmmc {
> + bootph-pre-ram;
> +};
> +
> +&pinctrl_uart1 {
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
> +&pinctrl_usdhc1 {
> + bootph-pre-ram

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

2024-01-30 Thread Primoz Fiser
Hi Mathieu,

On 30. 01. 24 10:43, Mathieu Othacehe wrote:
> 
> Hello,
> 
>> Please remove findfdt script.
>>
>> Not needed when you set fdt_file to CONFIG_DEFAULT_FDT_FILE above.
> 
> The reason I used findfdt is that CONFIG_DEFAULT_FDT_FILE is a string
> so, we end up with:
> 
> --8<---cut here---start->8---
> fdt_file="oftree"
> --8<---cut here---end--->8---
> 
> which gives:
> 
> --8<---cut here---start->8---
> u-boot=> run loadfdt
> Failed to load '"oftree"'
> --8<---cut here---end--->8---
> 
> whereas, if I set:
> 
> --8<---cut here---start->8---
> u-boot=> setenv fdt_file oftree
> u-boot=> run loadfdt   
> 24579 bytes read in 5 ms (4.7 MiB/s)
> --8<---cut here---end--->8---
> 
> I then see three options: introduce an unstrigify macro, hardcode
> fdt_file=oftree in the env file, or use the findfdt hack.

On my side there is no problem, see my output here:

U-Boot 2024.04-rc1-4-g686cb1ca1391-dirty (Jan 30 2024 - 10:58:24 +0100)

CPU:   i.MX93 rev1.1
Model: PHYTEC phyBOARD-Segin-i.MX93
DRAM:  1 GiB
Core:  184 devices, 22 uclasses, devicetree: separate
WDT:   Started wdog@4249 with servicing every 1000ms (40s timeout)
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... OK
In:serial@4438
Out:   serial@4438
Err:   serial@4438
Net:   eth0: ethernet@4289
Hit any key to stop autoboot:  0
u-boot=>
u-boot=> env default -a
## Resetting to default environment
u-boot=> saveenv; saveenv
Saving Environment to MMC... Writing to redundant MMC(1)... OK
Saving Environment to MMC... Writing to MMC(1)... OK
u-boot=> printenv fdt_file
fdt_file="oftree"
u-boot=> run loadfdt
48532 bytes read in 5 ms (9.3 MiB/s)
u-boot=> boot
switch to partitions #0, OK
mmc1 is current device
32688640 bytes read in 411 ms (75.8 MiB/s)
Booting from mmc ...
83 bytes read in 1 ms (81.1 KiB/s)
48532 bytes read in 4 ms (11.6 MiB/s)
Working FDT set to 8300
3615 bytes read in 3 ms (1.1 MiB/s)
1209 bytes read in 2 ms (589.8 KiB/s)
## Flattened Device Tree blob at 8300
   Booting using the fdt blob at 0x8300
Working FDT set to 8300
   Loading Device Tree to bcf0a000, end bcf19fff ... OK
Working FDT set to bcf0a000

Starting kernel ...



Here is my diff compared to your v3:

--- a/board/phytec/phycore_imx93/phycore_imx93.env
+++ b/board/phytec/phycore_imx93/phycore_imx93.env
@@ -5,7 +5,7 @@ console=ttyLP0
 fdt_addr=0x8300
 fdto_addr=0x830c
 bootenv_addr=0x8350
-fdt_file=undefined
+fdt_file=CONFIG_DEFAULT_FDT_FILE
 ipaddr=192.168.3.11
 serverip=192.168.3.10
 netmask=255.255.255.0
@@ -22,11 +22,7 @@ mmcautodetect=yes
 mmcargs=setenv bootargs ${mcore_clk} console=${console},${baudrate}
earlycon
root=/dev/mmcblk${mmcdev}p${mmcroot} ${raucargs} rootwait rw
 loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
-findfdt=if test $fdt_file = undefined; then
-setenv fdt_file CONFIG_DEFAULT_FDT_FILE ;
-fi;
-echo fdt_file=${fdt_file};
-loadfdt=run findfdt;fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr}
${fdt_file}
+loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
 mmc_load_overlay=fatload mmc ${mmcdev}:${mmcpart} ${fdto_addr} ${overlay}
 mmc_apply_overlays=



So this should work. We have the same in the downstream u-boot-imx.

Also, in-tree, phycore_am62x.env has the same:

fdtfile=CONFIG_DEFAULT_FDT_FILE
loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdtaddr} ${fdtfile}

Can you re-check, please?

Maybe check your include/generated/environment.h?

> 
> I'm not sure which one is the better?
> 
> I will fix all the other remarks in the v4.

OK, thanks.

I spotted additional remark that was not fixed in v3:

In file doc/board/phytec/imx93-phyboard-segin.rst, can you please change
title from:

phyCORE-i.MX 93 on a phyBOARD-Segin
===

to:

phyBOARD-Segin-i.MX93
=

and this text from:

U-Boot for the phyCORE-i.MX 93 on a phyBOARD-Segin.

to:

U-Boot for the phyBOARD-Segin-i.MX93.


Last but not least, please remove:

#define EEPROM_ADDR0x50

from board/phytec/phycore_imx93/spl.c

As support for PHYTEC_EEPROM will come later and that define will be
part of that series.

Thanks and best regards,
Primoz

> 
> Thanks,
> 
> Mathieu





[PATCH] imx9: clock: Fix board_interface_eth_init for FEC

2024-01-30 Thread Primoz Fiser
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 
---
 arch/arm/mach-imx/imx9/clock.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-imx/imx9/clock.c b/arch/arm/mach-imx/imx9/clock.c
index 92c41e9a67bf..75d92af036a1 100644
--- a/arch/arm/mach-imx/imx9/clock.c
+++ b/arch/arm/mach-imx/imx9/clock.c
@@ -882,6 +882,11 @@ int board_interface_eth_init(struct udevice *dev, 
phy_interface_t interface_type
device_is_compatible(dev, "nxp,imx93-dwmac-eqos"))
return imx93_eqos_interface_init(dev, interface_type);
 
+   if (IS_ENABLED(CONFIG_IMX93) &&
+   IS_ENABLED(CONFIG_FEC_MXC) &&
+   device_is_compatible(dev, "fsl,imx93-fec"))
+   return 0;
+
return -EINVAL;
 }
 
-- 
2.25.1



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

2024-01-30 Thread Primoz Fiser
Hi Mathieu,

On 30. 01. 24 13:49, Mathieu Othacehe wrote:
> 
> Hey,
> 
>> Can you re-check, please?
>>
>> Maybe check your include/generated/environment.h?
> 
> Thanks for checking. It is strange that you do not reproduce that one.
> 
> My include/generated/environment.h looks like:
> 
> --8<---cut here---start->8---
> #define CONFIG_EXTRA_ENV_TEXT 
> "bootenv=bootenv.txt\0bootenv_addr=0x8350\0console=ttyLP0\0fdt_addr=0x8300\0fdt_file=\"oftree\"\0fdto_addr=0x830c\0image=Image\0ip_dyn=yes\0loadfdt=fatload
>  mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0loadimage=fatload mmc 
> ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0mmc_apply_overlays=fdt address 
> ${fdt_addr}; for overlay in ${overlays}; do; if run mmc_load_overlay; then 
> fdt resize ${filesize}; fdt apply ${fdto_addr}; fi; 
> done;\0mmc_load_bootenv=fatload mmc ${mmcdev}:${mmcpart} ${bootenv_addr} 
> ${bootenv}\0mmc_load_overlay=fatload mmc ${mmcdev}:${mmcpart} ${fdto_addr} 
> ${overlay}\0mmcargs=setenv bootargs console=${console},${baudrate} earlycon 
> root=/dev/mmcblk${mmcdev}p${mmcroot} ${raucargs} rootwait 
> rw\0mmcautodetect=yes\0mmcboot=echo Booting from mmc ...; if run 
> mmc_load_bootenv; then env import -t ${bootenv_addr} ${filesize}; fi; run 
> mmcargs; if run loadfdt; then run mmc_apply_overlays; booti ${loadaddr} - 
> ${fdt_addr}; else echo WARN: Cannot load the DT; 
> fi;\0mmcdev=1\0mmcpart=1\0mmcroot=2\0net_apply_overlays=fdt address 
> ${fdt_addr}; for overlay in ${overlays}; do; if run net_load_overlay; then 
> fdt resize ${filesize}; fdt apply ${fdto_addr}; fi; 
> done;\0net_load_bootenv=${get_cmd} ${bootenv_addr} 
> ${bootenv}\0net_load_overlay=${get_cmd} ${fdto_addr} 
> ${overlay}\0netargs=setenv bootargs console=${console},${baudrate} earlycon 
> root=/dev/nfs ip=${nfsip} nfsroot=${serverip}:${nfsroot},v3,tcp\0netboot=echo 
> Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv 
> get_cmd dhcp; else setenv get_cmd tftp; fi; if run net_load_bootenv; then env 
> import -t ${bootenv_addr} ${filesize}; fi; ${get_cmd} ${loadaddr} ${image}; 
> if ${get_cmd} ${fdt_addr} ${fdt_file}; then run net_apply_overlays; booti 
> ${loadaddr} - ${fdt_addr}; else echo WARN: Cannot load the DT; 
> fi;\0nfsroot=/nfs\0"
> --8<---cut here---end--->8---
> 
> Note that fdt_file=\"oftree\" which explains the issue on my side. Do
> you have a similar environment.h?

I have the same.

> 
> What u-boot commit are you based on?

I am based on latest master 6faba41927bd (tag: v2024.04-rc1)

> 
> Mathieu


To Tom:

> And what awk do you both have? environment.h is generated via
> scripts/env2string.awk

Using Ubuntu 20.04 LTS

$ awk --version
GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0)
Copyright (C) 1989, 1991-2019 Free Software Foundation.

BR,
Primoz


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

2024-01-30 Thread Primoz Fiser
Hi Mathieu,

On 30. 01. 24 14:37, Mathieu Othacehe wrote:
> 
>> I am based on latest master 6faba41927bd (tag: v2024.04-rc1)
> 
> That was it. I rebased from 043ca8c8a9b to 6faba41927bd and I now have
> the same behaviour as you. I cannot find which commit fixed the
> situation in that interval though.
> 
> Preparing the v4,

OK, great.

Can you maybe test my patch:

https://patchwork.ozlabs.org/project/uboot/patch/20240130124337.497748-1-primoz.fi...@norik.com/

And see if it fixes Ethernet on the board?

BR,
Primoz



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

2024-01-31 Thread Primoz Fiser
Hi Mathieu,

Thanks for v4. I have no more remarks.

Also tested your v4 on the board.

Everything works, even eMMC booting which you were not able to test.

With that my Tested-by: can be applied.

Tested-by: Primoz Fiser 

BR,
Primoz

On 30. 01. 24 15:50, 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 
> ---
> Hello,
> 
> This new revision fixes the remarks of Primoz. The configuration is now
> aligned on the savedefconfig output. The FEC Ethernet is also tested to be
> working if this patch is in:
> 
> https://patchwork.ozlabs.org/project/uboot/patch/20240130124337.497748-1-primoz.fi...@norik.com/
> 
> The proposed patch has been rebased on top of 6faba41.
> 
> Thanks,
> 
> Mathieu
> 
> v3: https://lists.denx.de/pipermail/u-boot/2024-January/544493.html
> 
>  arch/arm/dts/Makefile |3 +-
>  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/imx9/Kconfig|6 +
>  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 ++
>  configs/imx93-phyboard-segin_defconfig|  138 ++
>  doc/board/phytec/imx93-phyboard-segin.rst |   61 +
>  doc/board/phytec/index.rst|1 +
>  include/configs/phycore_imx93.h   |   28 +
>  16 files changed, 2618 insertions(+), 1 deletion(-)
>  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-segin_defconfig
>  create mode 100644 doc/board/phytec/imx93-phyboard-segin.rst
>  create mode 100644 include/configs/phycore_imx93.h
> 




Re: [PATCH 2/3] configs: imx93-phyboard-segin: Add USB support.

2024-03-19 Thread Primoz Fiser
Hi Mathieu,

On 18. 03. 24 18:16, Mathieu Othacehe wrote:
> Enable the `usb` command and some USB drivers.
> 

I would rephrase commit msg to something like this:

Add USB support by enabling `usb` command and required USB drivers.


> Signed-off-by: Mathieu Othacehe 
> ---
>  configs/imx93-phyboard-segin_defconfig | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/configs/imx93-phyboard-segin_defconfig 
> b/configs/imx93-phyboard-segin_defconfig
> index 24f9bd553aa..5acb987b817 100644
> --- a/configs/imx93-phyboard-segin_defconfig
> +++ b/configs/imx93-phyboard-segin_defconfig
> @@ -23,6 +23,7 @@ CONFIG_SPL_STACK=0x20519dd0
>  CONFIG_SPL=y
>  CONFIG_ENV_OFFSET_REDUND=0x72
>  CONFIG_CMD_DEKBLOB=y
> +CONFIG_CMD_USB=y

Can you run

$ make savedefconfig && cp defconfig configs/imx93-phyboard-segin_defconfig

to re-order CONFIG_CMD_USB please?


>  CONFIG_SPL_IMX_ROMAPI_LOADADDR=0x8800
>  CONFIG_SYS_LOAD_ADDR=0x8040
>  CONFIG_SYS_MEMTEST_START=0x8000
> @@ -132,6 +133,13 @@ CONFIG_SPL_SYSRESET=y
>  CONFIG_SYSRESET_WATCHDOG=y
>  CONFIG_DM_THERMAL=y
>  CONFIG_IMX_TMU=y
> +CONFIG_USB=y
> +CONFIG_USB_EHCI_HCD=y
> +CONFIG_USB_GADGET=y
> +CONFIG_USB_GADGET_MANUFACTURER="FSL"
> +CONFIG_USB_GADGET_VENDOR_NUM=0x1fc9
> +CONFIG_USB_GADGET_PRODUCT_NUM=0x0152
> +CONFIG_CI_UDC=y
>  CONFIG_ULP_WATCHDOG=y
>  CONFIG_LZO=y
>  CONFIG_BZIP2=y


-- 
Primoz Fiser| phone: +386-41-540-545
 |
-|
Norik systems d.o.o.| https://www.norik.com
<https://www.norik.com>  |
Your embedded software partner  | email: i...@norik.com
<mailto:i...@norik.com> |
Slovenia, EU| phone: +386-41-540-545
 |



Re: [PATCH 1/3] arm: dts: imx93-phyboard-segin: Add USB support.

2024-03-19 Thread Primoz Fiser
Hi Marek,

On 18. 03. 24 22:48, Marek Vasut wrote:
> On 3/18/24 6:16 PM, Mathieu Othacehe wrote:
>> Enable both usbotg1 and usbotg2 ports.
> 
> Drop fullstop from $subject end.
> 
>> Signed-off-by: Mathieu Othacehe 
>> ---
>>   arch/arm/dts/imx93-phyboard-segin.dts | 13 +
>>   1 file changed, 13 insertions(+)
>>
>> diff --git a/arch/arm/dts/imx93-phyboard-segin.dts
>> b/arch/arm/dts/imx93-phyboard-segin.dts
>> index 85fb188b057..acf307a3192 100644
>> --- a/arch/arm/dts/imx93-phyboard-segin.dts
>> +++ b/arch/arm/dts/imx93-phyboard-segin.dts
>> @@ -40,6 +40,19 @@
>>   status = "okay";
>>   };
>>   +/* USB  */
>> +&usbotg1 {
>> +    disable-over-current;
> 
> Why is this needed ?

OC pins are not connected to the SoC thus disable OC to avoid warnings
(c/p from kernel dts).

BR,
Primoz




[PATCH] imx: imx9: Set correct critical temperature

2024-08-13 Thread Primoz Fiser
Commit 3233349fa6e2 ("imx: imx9: fixup thermal trips from fuses")
wrongly set critical temperature to (maxc - 5) instead of maxc.

Fixes: 3233349fa6e2 ("imx: imx9: fixup thermal trips from fuses")
Signed-off-by: Primoz Fiser 
---
 arch/arm/mach-imx/imx9/soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-imx/imx9/soc.c
index 32208220b207..f88e7a222dd4 100644
--- a/arch/arm/mach-imx/imx9/soc.c
+++ b/arch/arm/mach-imx/imx9/soc.c
@@ -536,7 +536,7 @@ static int fixup_thermal_trips(void *blob, const char *name)
 
temp = 0;
if (!strcmp(type, "critical"))
-   temp = 1000 * (maxc - 5);
+   temp = 1000 * maxc;
else if (!strcmp(type, "passive"))
temp = 1000 * (maxc - 10);
if (temp) {
-- 
2.34.1



Re: [PATCH 1/2] net: fec_mxc: Fix clk_ref rate on iMX93

2024-09-23 Thread Primoz Fiser
Hi,

On 23. 09. 24 15:14, Peng Fan (OSS) wrote:
> From: Ye Li 
> 
> Because iMX93 has a internal 1/2 divider before clock input to
> network controller, so have to set twice frequency rate
> 
> Fixes: 09de565f76b ("net: fec_mxc: support i.MX93")
> Signed-off-by: Ye Li 
> Signed-off-by: Peng Fan 
> ---
>  drivers/net/fec_mxc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 0a0d92bc2cd..e5d7f0f3e1e 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1215,6 +1215,9 @@ static int fecmxc_set_ref_clk(struct clk *clk_ref, 
> phy_interface_t interface)
>   else
>   return -EINVAL;
>  
> + if (is_imx93())
> + freq = freq << 1;

Humm, but how did it work so far?

On phyboard-segin-imx93, this change breaks fec ethernet.

I had to revert this already in NXP downstream u-boot.

BR,
Primoz


> +
>   ret = clk_set_rate(clk_ref, freq);
>   if (ret < 0)
>   return ret;

-- 
Primoz Fiser| phone: +386-41-390-545
 |
-|
Norik systems d.o.o.| https://www.norik.com
<https://www.norik.com>  |
Your embedded software partner  | email: i...@norik.com
<mailto:i...@norik.com> |
Slovenia, EU| phone: +386-41-540-545
 |



Re: [PATCH v3 1/3] board: phytec: phycore-imx93: Add 2GB LPDDR4X RAM timings

2024-11-20 Thread Primoz Fiser
Tested on phyBOARD-Nash-i.MX93 with phyCORE-i.MX93 2GiB SOM

Link: https://gist.github.com/pfiser/d5766c95f5639e6a9852c94412f39eb5

Tested-by: Primoz Fiser 


On 19. 11. 24 17:29, Christoph Stoidner wrote:
> The phyCORE-i.MX 93 is available with a 1GB ram chip or a 2GB ram chip.
> Add the ram timings for the 2GB chip, in form of a diff compared
> to the existing LPDDR4X 1GB timings. With that, the SPL can select the
> appropriate timings at startup.
> Update also the 1GB ram timings with new version of the DDR Tool.
> 
> Signed-off-by: Christoph Stoidner 
> ---
> Cc: Mathieu Othacehe 
> Cc: Christoph Stoidner 
> Cc: Tom Rini 
> Cc: Yannic Moog 
> Cc: Primoz Fiser 
> Cc: Andrej Picej 
> Cc: Wadim Egorov 
> ---
> No changes in v3
> 
> Changes in v2:
> - remove multiple blank lines
> - add update of 1GB ram timings to commit message
> 
>  board/phytec/phycore_imx93/lpddr4_timing.c | 793 +++--
>  1 file changed, 732 insertions(+), 61 deletions(-)
> 
> diff --git a/board/phytec/phycore_imx93/lpddr4_timing.c 
> b/board/phytec/phycore_imx93/lpddr4_timing.c
> index 2111972a40..f1261f6a92 100644
> --- a/board/phytec/phycore_imx93/lpddr4_timing.c
> +++ b/board/phytec/phycore_imx93/lpddr4_timing.c
> @@ -1,24 +1,24 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
> - * Copyright 2023 NXP
> - * Copyright (C) 2023 PHYTEC Messtechnik GmbH
> + * Copyright 2024 NXP
> + * Copyright (C) 2024 PHYTEC Messtechnik GmbH
>   * Christoph Stoidner 
>   *
> - * Code generated with DDR Tool v1.0.0.
> + * Code generated with DDR Tool v3.1.0_7.4.
>   */
>  
>  #include 
>  #include 
>  
> +/* Initialize DDRC registers */
>  static struct dram_cfg_param ddr_ddrc_cfg[] = {
> - /** Initialize DDRC registers **/
>   {0x4e300110, 0x4411},
>   {0x4e30, 0x8000bf},
>   {0x4e38, 0x0},
>   {0x4e300080, 0x8412},
>   {0x4e300084, 0x0},
>   {0x4e300114, 0x1002},
> - {0x4e300260, 0x4080},
> + {0x4e300260, 0x80},
>   {0x4e300f04, 0x80},
>   {0x4e300800, 0x43b30002},
>   {0x4e300804, 0x1f1f1f1f},
> @@ -31,18 +31,17 @@ static struct dram_cfg_param ddr_ddrc_cfg[] = {
>   {0x4e301254, 0x0},
>   {0x4e301258, 0x0},
>   {0x4e30125c, 0x0},
> -
>  };
>  
>  /* dram fsp cfg */
>  static struct dram_fsp_cfg ddr_dram_fsp_cfg[] = {
>   {
>   {
> - {0x4e300100, 0x24A0421B},
> + {0x4e300100, 0x24A0321B},
>   {0x4e300104, 0xF8EE001B},
> - {0x4e300108, 0x2F263233},
> - {0x4e30010C, 0x0005E18B},
> - {0x4e300124, 0x1C77},
> + {0x4e300108, 0x2F2E3233},
> + {0x4e30010C, 0x0005C18B},
> + {0x4e300124, 0x1C79},
>   {0x4e300160, 0x9102},
>   {0x4e30016C, 0x35F0},
>   {0x4e300170, 0x8B0B0608},
> @@ -50,21 +49,73 @@ static struct dram_fsp_cfg ddr_dram_fsp_cfg[] = {
>   {0x4e300254, 0x00FE00FE},
>   {0x4e300258, 0x0008},
>   {0x4e30025C, 0x0400},
> - {0x4e300300, 0x224F2215},
> + {0x4e300300, 0x224F2213},
>   {0x4e300304, 0x00FE2213},
> - {0x4e300308, 0x0A3C0E3C},
> + {0x4e300308, 0x0A380E3D},
>   },
>   {
>   {0x01, 0xE4},
>   {0x02, 0x36},
> - {0x03, 0xF2},
> - {0x0b, 0x46},
> - {0x0c, 0x11},
> - {0x0e, 0x11},
> + {0x03, 0x22},
> + {0x0b, 0x44},
> + {0x0c, 0x1E},
> + {0x0e, 0x12},
> + {0x16, 0x04},
> + },
> + 0,
> + },
> + {
> + {
> + {0x4e300100, 0x124F2100},
> + {0x4e300104, 0xF877000E},
> + {0x4e300108, 0x1816E4AA},
> + {0x4e30010C, 0x005101E6},
> + {0x4e300124, 0x0E3C},
> + {0x4e300160, 0x9101},
> + {0x4e30016C, 0x3090},
> + {0x4e300170, 0x8A0A0508},
> + {0x4e300250, 0x0014},
> + {0x4e300254, 0x007B007B},
> + {0x4e300258, 0x0008},
> + {0x4e30025C, 0x0400},
> + },
> + {
> +

Re: [PATCH v3 2/3] board: phytec: imx93: Add eeprom-based hardware introspection

2024-11-20 Thread Primoz Fiser
Hi Christoph,

I get the following runtime error for eMMC:

> U-Boot SPL 2025.01-rc2-00132-gef3b6c6bc869 (Nov 20 2024 - 09:45:19 +0100)
> SoM: PCL-077-23231211I000.1 PCB rev: 1 
> M33 prepare ok
> WDT:   Started wdog@4249 with servicing every 1000ms (40s timeout)
> Normal Boot
> Trying to boot from BOOTROM
> Boot Stage: Primary boot
> image offset 0x8000, pagesize 0x200, ivt offset 0x0
> Load image from 0x49800 by ROM_API
> NOTICE:  BL31: v2.8(release):lf-6.1.36-2.1.0-0-g1a3beeab6484
> NOTICE:  BL31: Built : 11:39:38, Aug  7 2023
> 
> 
> U-Boot 2025.01-rc2-00132-gef3b6c6bc869 (Nov 20 2024 - 09:45:19 +0100)
> 
> CPU:   i.MX93 rev1.1
> Model: PHYTEC phyCORE-i.MX93
> DRAM:  2 GiB
> Core:  190 devices, 25 uclasses, devicetree: separate
> WDT:   Started wdog@4249 with servicing every 1000ms (40s timeout)
> MMC:   FSL_SDHC: 0, FSL_SDHC: 1
> Loading Environment from MMC... Reading from redundant MMC(1)... OK
> In:serial@4438
> Out:   serial@4438
> Err:   serial@4438
> Net:   eth0: ethernet@4289
> Hit any key to stop autoboot:  0 
> u-boot=> mmc info
> esdhc_change_pinstate 12 error
> esdhc_set_timing error -38
> Select HS400ES failed -38
> unable to select a mode: -5
> u-boot=> 

This means, HS400 is properly selected but I guess you forgot to add
ushdc1 pinctrl settings for 100 and 200MHz modes (HS400).

BR,
Primoz


On 19. 11. 24 17:29, Christoph Stoidner wrote:
> The phyCORE-i.MX 93 is available in various variants. Relevant variant
> options for the spl/u-boot are:
> - with or without HS400 support for the eMMC
> - with 1GB ram chip, or 2GB ram chip
> 
> The phyCORE's eeprom contains all information about the existing variant
> options. Add evaluation of the eeprom data to the spl/u-boot to
> enable/disable HS400 and to select the appropriate ram configuration at
> startup.
> 
> Signed-off-by: Christoph Stoidner 
> Reviewed-by: Wadim Egorov 
> ---
> Cc: Mathieu Othacehe 
> Cc: Christoph Stoidner 
> Cc: Stefano Babic 
> Cc: Fabio Estevam 
> Cc: "NXP i.MX U-Boot Team" 
> Cc: Tom Rini 
> Cc: Yannic Moog 
> Cc: Primoz Fiser 
> Cc: Andrej Picej 
> Cc: Wadim Egorov 
> ---
> Changes in v3:
> - remove unwanted dts node eepromid
> - correct typo in doc (PHYTEC_IMX93_VOLTAGE_3V3)
> - improve enum code-style (phytec_imx93_option_index)
> 
> Changes in v2:
> - encapsulate handling of feature flag VOLTAGE into own function
> - move definition of enum phytec_imx93_ddr_eeprom_code into header file
> 
>  arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi |   9 ++
>  arch/arm/mach-imx/imx9/Kconfig|   2 +
>  arch/arm/mach-imx/imx9/soc.c  |   2 +-
>  board/phytec/common/Kconfig   |   8 ++
>  board/phytec/common/Makefile  |   1 +
>  board/phytec/common/imx93_som_detection.c | 111 ++
>  board/phytec/common/imx93_som_detection.h |  51 
>  board/phytec/phycore_imx93/Kconfig|  28 +
>  board/phytec/phycore_imx93/MAINTAINERS|   5 +-
>  board/phytec/phycore_imx93/phycore-imx93.c|  51 
>  board/phytec/phycore_imx93/spl.c  |  48 
>  11 files changed, 314 insertions(+), 2 deletions(-)
>  create mode 100644 board/phytec/common/imx93_som_detection.c
>  create mode 100644 board/phytec/common/imx93_som_detection.h
> 
> diff --git a/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi 
> b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> index 6897c91f4d..e001ee3288 100644
> --- a/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> +++ b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> @@ -305,4 +305,13 @@
>   };
>   };
>   };
> +
> + eeprom@50 {
> + bootph-pre-ram;
> + bootph-some-ram;
> + compatible = "atmel,24c32";
> + reg = <0x50>;
> + pagesize = <32>;
> + vcc-supply = <&buck4>;
> + };
>  };
> diff --git a/arch/arm/mach-imx/imx9/Kconfig b/arch/arm/mach-imx/imx9/Kconfig
> index 5c1054138f..2465e31d73 100644
> --- a/arch/arm/mach-imx/imx9/Kconfig
> +++ b/arch/arm/mach-imx/imx9/Kconfig
> @@ -45,6 +45,8 @@ config TARGET_PHYCORE_IMX93
>   bool "phycore_imx93"
>   select IMX93
>   select IMX9_LPDDR4X
> + select OF_BOARD_FIXUP
> + select OF_BOARD_SETUP
>  
>  endchoice
>  
> diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-imx/imx9/soc.c
> index 21e0e7dd1e..6837ac82b0 100644
> --- a/arch/arm/mach-imx/imx9/soc.c
> +++ b/arch/arm/mach-imx/imx9/soc.c
> @@ -634,7 +634,7 @@ static int low_drive_freq_update(void *bl

Re: [PATCH v4 2/3] board: phytec: imx93: Add eeprom-based hardware introspection

2024-11-21 Thread Primoz Fiser
Tested on phyBOARD-Nash-i.MX93 with 1.8V IO_VOLTAGE capable of HS400ES
eMMC mode.

Link: https://gist.github.com/pfiser/964617af99e43fb5cc6fec6b65070f21

Tested-by: Primoz Fiser 

On 20. 11. 24 17:31, Christoph Stoidner wrote:
> The phyCORE-i.MX 93 is available in various variants. Relevant variant
> options for the spl/u-boot are:
> - with or without HS400 support for the eMMC
> - with 1GB ram chip, or 2GB ram chip
> 
> The phyCORE's eeprom contains all information about the existing variant
> options. Add evaluation of the eeprom data to the spl/u-boot to
> enable/disable HS400 and to select the appropriate ram configuration at
> startup.
> 
> Signed-off-by: Christoph Stoidner 
> Reviewed-by: Wadim Egorov 
> Reviewed-by: Yannic Moog 
> ---
> Cc: Mathieu Othacehe 
> Cc: Christoph Stoidner 
> Cc: Stefano Babic 
> Cc: Fabio Estevam 
> Cc: "NXP i.MX U-Boot Team" 
> Cc: Tom Rini 
> Cc: Yannic Moog 
> Cc: Primoz Fiser 
> Cc: Andrej Picej 
> Cc: Wadim Egorov 
> ---
> Changes in v4:
> - add missing pinctrls for eMMC 100mhz and 200mhz
> 
> Changes in v3:
> - remove unwanted dts node eepromid
> - correct typo in doc (PHYTEC_IMX93_VOLTAGE_3V3)
> - improve enum code-style (phytec_imx93_option_index)
> 
> Changes in v2:
> - encapsulate handling of feature flag VOLTAGE into own function
> - move definition of enum phytec_imx93_ddr_eeprom_code into header file
> 
>  arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi |  58 +
>  arch/arm/mach-imx/imx9/Kconfig|   2 +
>  arch/arm/mach-imx/imx9/soc.c  |   2 +-
>  board/phytec/common/Kconfig   |   8 ++
>  board/phytec/common/Makefile  |   1 +
>  board/phytec/common/imx93_som_detection.c | 111 ++
>  board/phytec/common/imx93_som_detection.h |  51 
>  board/phytec/phycore_imx93/Kconfig|  28 +
>  board/phytec/phycore_imx93/MAINTAINERS|   5 +-
>  board/phytec/phycore_imx93/phycore-imx93.c|  51 
>  board/phytec/phycore_imx93/spl.c  |  48 
>  11 files changed, 363 insertions(+), 2 deletions(-)
>  create mode 100644 board/phytec/common/imx93_som_detection.c
>  create mode 100644 board/phytec/common/imx93_som_detection.h
> 
> diff --git a/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi 
> b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> index 6897c91f4d..702d86f4e0 100644
> --- a/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> +++ b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> @@ -139,6 +139,13 @@
>  &usdhc1 {
>   bootph-pre-ram;
>   bootph-some-ram;
> + /*
> +  * Remove pinctrl assignments once they are added to 
> imx93-phycore-som.dtsi
> +  */
> + pinctrl-names = "default", "state_100mhz", "state_200mhz";
> + pinctrl-0 = <&pinctrl_usdhc1>;
> + pinctrl-1 = <&pinctrl_usdhc1_100mhz>;
> + pinctrl-2 = <&pinctrl_usdhc1_200mhz>;
>  };
>  
>  &usdhc2 {
> @@ -215,6 +222,48 @@
>   MX93_PAD_ENET2_RD3__GPIO4_IO27  0x31e
>   >;
>   };
> +
> + /*
> +  * Remove pinctrl_usdhc1_100mhz and pinctrl_usdhc1_200mhz once they
> +  * are added to imx93-phycore-som.dtsi
> +  */
> + /* need to config the SION for data and cmd pad, refer to ERR052021 */
> + pinctrl_usdhc1_100mhz: usdhc1-100mhzgrp {
> + bootph-pre-ram;
> + bootph-some-ram;
> + fsl,pins = <
> + MX93_PAD_SD1_CLK__USDHC1_CLK0x17be
> + MX93_PAD_SD1_CMD__USDHC1_CMD0x4000139e
> + MX93_PAD_SD1_DATA0__USDHC1_DATA00x4000138e
> + MX93_PAD_SD1_DATA1__USDHC1_DATA10x4000139e
> + MX93_PAD_SD1_DATA2__USDHC1_DATA20x400013be
> + MX93_PAD_SD1_DATA3__USDHC1_DATA30x4000139e
> + MX93_PAD_SD1_DATA4__USDHC1_DATA40x4000139e
> + MX93_PAD_SD1_DATA5__USDHC1_DATA50x4000139e
> + MX93_PAD_SD1_DATA6__USDHC1_DATA60x4000139e
> + MX93_PAD_SD1_DATA7__USDHC1_DATA70x4000139e
> + MX93_PAD_SD1_STROBE__USDHC1_STROBE  0x179e
> + >;
> + };
> +
> + /* need to config the SION for data and cmd pad, refer to ERR052021 */
> + pinctrl_usdhc1_200mhz: usdhc1-200mhzgrp {
> + bootph-pre-ram;
> + bootph-some-ram;
> + fsl,pins = <
> + MX93_PAD_SD1_CLK__USDHC1_CLK0x17be
> +

Re: [PATCH v2 3/3] board: phytec: imx93: Add phyCORE-i.MX 93 support for all SOM variants

2024-11-14 Thread Primoz Fiser
Hi Christoph,

this patch doesn't apply anymore on latest master.

Can you please rebase for v3?

Then I can test it on the board.

Thanks,
BR,
Primoz

On 13. 11. 24 17:00, Christoph Stoidner wrote:
> The phyCORE-i.MX 93 is available in various variants (e.g. different ram
> sizes, eMMC HS400 yes/no). Enable hardware introspection for the
> imx93-phyboard-segin_defconfig, so that during startup the SOM module
> variant can be detected, and the hardware can be configured accordingly.
> The resulting SPL and u-boot binary shall able to boot each
> phyCORE-i.MX 93 module variant on each carrier board. Finally rename
> imx93-phyboard-segin_defconfig to imx93-phycore_defconfig, to highlight
> its SOM scope.
> 
> Signed-off-by: Christoph Stoidner 
> ---
> Cc: Mathieu Othacehe 
> Cc: Christoph Stoidner 
> Cc: Stefano Babic 
> Cc: Fabio Estevam 
> Cc: "NXP i.MX U-Boot Team" 
> Cc: Tom Rini 
> Cc: Yannic Moog 
> Cc: Primoz Fiser 
> Cc: Andrej Picej 
> Cc: Wadim Egorov 
> ---
> Changes in v2:
> - just rename imx93-phyboard-segin_defconfig and add needed CONFIGs,
>   instead of creating an entirely new second defconfig
> - remove wrong comment from imx93-phyboard-segin-u-boot.dtsi
> - improve commit message
> 
>  arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi   | 6 --
>  board/phytec/phycore_imx93/MAINTAINERS  | 2 +-
>  ...x93-phyboard-segin_defconfig => imx93-phycore_defconfig} | 4 +++-
>  3 files changed, 8 insertions(+), 4 deletions(-)
>  rename configs/{imx93-phyboard-segin_defconfig => imx93-phycore_defconfig} 
> (98%)
> 
> diff --git a/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi 
> b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> index 25c778bb07..2245461032 100644
> --- a/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> +++ b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> @@ -2,15 +2,17 @@
>  /*
>   * Copyright (C) 2023 PHYTEC Messtechnik GmbH
>   * Christoph Stoidner 
> + * Copyright (C) 2024 PHYTEC Messtechnik GmbH
>   *
>   * Product homepage:
> - * phyBOARD-Segin carrier board is reused for the i.MX93 design.
> - * 
> https://www.phytec.eu/en/produkte/single-board-computer/phyboard-segin-imx6ul/
> +   https://www.phytec.de/produkte/system-on-modules/phycore-imx-91-93/
>   */
>  
>  #include "imx93-u-boot.dtsi"
>  
>  / {
> + model = "PHYTEC phyCORE-i.MX93";
> +
>   wdt-reboot {
>   compatible = "wdt-reboot";
>   wdt = <&wdog3>;
> diff --git a/board/phytec/phycore_imx93/MAINTAINERS 
> b/board/phytec/phycore_imx93/MAINTAINERS
> index cea817ffdc..718f89a084 100644
> --- a/board/phytec/phycore_imx93/MAINTAINERS
> +++ b/board/phytec/phycore_imx93/MAINTAINERS
> @@ -9,5 +9,5 @@ F:  arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
>  F:  board/phytec/phycore_imx93/
>  F:  board/phytec/common/imx93_som_detection.c
>  F:  board/phytec/common/imx93_som_detection.h
> -F:  configs/imx93-phyboard-segin_defconfig
> +F:  configs/imx93-phycore_defconfig
>  F:  include/configs/phycore_imx93.h
> diff --git a/configs/imx93-phyboard-segin_defconfig 
> b/configs/imx93-phycore_defconfig
> similarity index 98%
> rename from configs/imx93-phyboard-segin_defconfig
> rename to configs/imx93-phycore_defconfig
> index 18a4087e4b..cf9800118a 100644
> --- a/configs/imx93-phyboard-segin_defconfig
> +++ b/configs/imx93-phycore_defconfig
> @@ -6,13 +6,13 @@ CONFIG_SYS_MALLOC_F_LEN=0x2
>  CONFIG_SPL_LIBCOMMON_SUPPORT=y
>  CONFIG_SPL_LIBGENERIC_SUPPORT=y
>  CONFIG_NR_DRAM_BANKS=2
> +CONFIG_PHYTEC_SOM_DETECTION=y
>  CONFIG_ENV_SOURCE_FILE="phycore_imx93"
>  CONFIG_ENV_SIZE=0x1
>  CONFIG_ENV_OFFSET=0x70
>  CONFIG_IMX_CONFIG="arch/arm/mach-imx/imx9/imximage.cfg"
>  CONFIG_DM_GPIO=y
>  CONFIG_DEFAULT_DEVICE_TREE="imx93-phyboard-segin"
> -CONFIG_SPL_TEXT_BASE=0x2049A000
>  CONFIG_AHAB_BOOT=y
>  CONFIG_TARGET_PHYCORE_IMX93=y
>  CONFIG_OF_LIBFDT_OVERLAY=y
> @@ -20,6 +20,7 @@ CONFIG_SYS_MONITOR_LEN=524288
>  CONFIG_SPL_SERIAL=y
>  CONFIG_SPL_DRIVERS_MISC=y
>  CONFIG_SPL_STACK=0x20519dd0
> +CONFIG_SPL_TEXT_BASE=0x2049A000
>  CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
>  CONFIG_SPL_BSS_START_ADDR=0x2051a000
>  CONFIG_SPL_BSS_MAX_SIZE=0x2000
> @@ -31,6 +32,7 @@ CONFIG_SPL_IMX_ROMAPI_LOADADDR=0x8800
>  CONFIG_SYS_MEMTEST_START=0x8000
>  CONFIG_SYS_MEMTEST_END=0x9000
>  CONFIG_REMAKE_ELF=y
> +# CONFIG_ANDROID_BOOT_IMAGE is not set
>  CONFIG_DISTRO_DEFAULTS=y
>  CONFIG_OF_SYSTEM_SETUP=y
>  CONFIG_BOOTCOMMAND="mmc dev ${mmcdev}; if mmc rescan; then if run loadimage; 
> then run mmcboot; else run netboot; fi; fi;"

-- 
Primoz Fiser| phone: +386-41-390-545
 |
-|
Norik systems d.o.o.| https://www.norik.com
<https://www.norik.com>  |
Your embedded software partner  | email: i...@norik.com
<mailto:i...@norik.com> |
Slovenia, EU| phone: +386-41-540-545
 |



Re: [PATCH v2 2/3] board: phytec: imx93: Add eeprom-based hardware introspection

2024-11-14 Thread Primoz Fiser
Hi Christoph,

On 13. 11. 24 17:00, Christoph Stoidner wrote:
> The phyCORE-i.MX 93 is available in various variants. Relevant variant
> options for the spl/u-boot are:
> - with or without HS400 support for the eMMC
> - with 1GB ram chip, or 2GB ram chip
> 
> The phyCORE's eeprom contains all information about the existing variant
> options. Add evaluation of the eeprom data to the spl/u-boot to
> enable/disable HS400 and to select the appropriate ram configuration at
> startup.
> 
> Signed-off-by: Christoph Stoidner 
> ---
> Cc: Mathieu Othacehe 
> Cc: Christoph Stoidner 
> Cc: Stefano Babic 
> Cc: Fabio Estevam 
> Cc: "NXP i.MX U-Boot Team" 
> Cc: Tom Rini 
> Cc: Yannic Moog 
> Cc: Primoz Fiser 
> Cc: Andrej Picej 
> Cc: Wadim Egorov 
> ---
> Changes in v2:
> - encapsulate handling of feature flag VOLTAGE into own function
> - move definition of enum phytec_imx93_ddr_eeprom_code into header file
> 
>  arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi |  19 +++
>  arch/arm/mach-imx/imx9/Kconfig|   2 +
>  arch/arm/mach-imx/imx9/soc.c  |   2 +-
>  board/phytec/common/Kconfig   |   8 ++
>  board/phytec/common/Makefile  |   1 +
>  board/phytec/common/imx93_som_detection.c | 111 ++
>  board/phytec/common/imx93_som_detection.h |  51 
>  board/phytec/phycore_imx93/Kconfig|  28 +
>  board/phytec/phycore_imx93/MAINTAINERS|   5 +-
>  board/phytec/phycore_imx93/phycore-imx93.c|  51 
>  board/phytec/phycore_imx93/spl.c  |  48 
>  11 files changed, 324 insertions(+), 2 deletions(-)
>  create mode 100644 board/phytec/common/imx93_som_detection.c
>  create mode 100644 board/phytec/common/imx93_som_detection.h
> 
> diff --git a/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi 
> b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> index 6897c91f4d..25c778bb07 100644
> --- a/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> +++ b/arch/arm/dts/imx93-phyboard-segin-u-boot.dtsi
> @@ -305,4 +305,23 @@
>   };
>   };
>   };
> +
> + eeprom@50 {
> + bootph-pre-ram;
> + bootph-some-ram;
> + compatible = "atmel,24c32";
> + reg = <0x50>;
> + pagesize = <32>;
> + vcc-supply = <&buck4>;
> + };
> +
> + eepromid@58 {
> + bootph-pre-ram;
> + bootph-some-ram;
> + compatible = "atmel,24c32";
> + pagesize = <32>;
> + reg = <0x58>;
> + size = <32>;
> + vcc-supply = <&buck4>;
> + };
>  };
> diff --git a/arch/arm/mach-imx/imx9/Kconfig b/arch/arm/mach-imx/imx9/Kconfig
> index 5c1054138f..2465e31d73 100644
> --- a/arch/arm/mach-imx/imx9/Kconfig
> +++ b/arch/arm/mach-imx/imx9/Kconfig
> @@ -45,6 +45,8 @@ config TARGET_PHYCORE_IMX93
>   bool "phycore_imx93"
>   select IMX93
>   select IMX9_LPDDR4X
> + select OF_BOARD_FIXUP
> + select OF_BOARD_SETUP
>  
>  endchoice
>  
> diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-imx/imx9/soc.c
> index 7c28fa39e1..237354f507 100644
> --- a/arch/arm/mach-imx/imx9/soc.c
> +++ b/arch/arm/mach-imx/imx9/soc.c
> @@ -628,7 +628,7 @@ static int low_drive_freq_update(void *blob)
>   return 0;
>  }
>  
> -#ifdef CONFIG_OF_BOARD_FIXUP
> +#if defined(CONFIG_OF_BOARD_FIXUP) && !defined(CONFIG_TARGET_PHYCORE_IMX93)
>  #ifndef CONFIG_XPL_BUILD
>  int board_fix_fdt(void *fdt)
>  {
> diff --git a/board/phytec/common/Kconfig b/board/phytec/common/Kconfig
> index f394ace786..bc5511707a 100644
> --- a/board/phytec/common/Kconfig
> +++ b/board/phytec/common/Kconfig
> @@ -19,6 +19,14 @@ config PHYTEC_IMX8M_SOM_DETECTION
> Support of I2C EEPROM based SoM detection. Supported
> for PHYTEC i.MX8MM/i.MX8MP boards
>  
> +config PHYTEC_IMX93_SOM_DETECTION
> + bool "Support SoM detection for i.MX93 PHYTEC platforms"
> + depends on ARCH_IMX9 && PHYTEC_SOM_DETECTION
> + default y
> + help
> +   Support of I2C EEPROM based SoM detection. Supported
> +   for PHYTEC i.MX93 based boards
> +
>  config PHYTEC_AM62_SOM_DETECTION
>   bool "Support SoM detection for AM62x PHYTEC platforms"
>   depends on (TARGET_PHYCORE_AM62X_A53 || TARGET_PHYCORE_AM62X_R5) && \
> diff --git a/board/phytec/common/Makefile b/board/phytec/common/Makefile
> index cd78f7686f..8126f7356e 100644
> --- a/board/phytec/common/Makefile
> +++ b/board/phytec/commo