Re: [RFC PATCH 10/17] clk: sunxi: Add support for the D1 CCU

2023-05-23 Thread Andre Przywara
On Sun, 21 May 2023 21:57:57 -0600
Sam Edwards  wrote:

Hi Sam,

> On 12/5/22 17:45, Andre Przywara wrote:
> > From: Samuel Holland 
> > 
> > Since the D1 CCU binding is defined, we can add support for its
> > gates/resets, following the pattern of the existing drivers.
> > 
> > Signed-off-by: Samuel Holland 
> > Reviewed-by: Andre Przywara 
> > Acked-by: Sean Anderson   
> 
> Hi Andre,
> 
> So far so good! This patchset seems pretty functional. I'm still trying 
> to get various peripherals on my board up and running; there are a 
> couple of rough edges I'm encountering. I'll report back when I have a 
> build I like.
> 
> In particular, I had to update this patch in your series to be 
> consistent with 46fa23f9ee. My own patch follows.

Ah, yeah, Samuel's rework. Thanks for the heads up, I somehow missed
that when updating the series!

> I'd also suggest adding to `mangopi_mq_r_defconfig`:
> CONFIG_CLK_SUN20I_D1=y
> ...or, better yet, an appropriate `select` in Kconfig?

I think this is related to the rework, I just added a "default
MACH_SUN8I_R528" line to the clock's Kconfig, similar to what we
already do for the pinctrl driver.

I merged the changes into the respective patch.

Please note that I also found a build bug for 64-bit SoCs, and that the
new DRAM driver's Kconfig symbols conflict with the already used
symbols for other DRAM drivers (like the A64 one). This broke the A64
DRAM init routine, for instance.

If the tests work well, I will try to post some proper version ASAP. If
not, I will probably just push some updated WIP version to my Github.

Thanks,
Andre


> --
> 
> diff --git a/drivers/clk/sunxi/clk_d1.c b/drivers/clk/sunxi/clk_d1.c
> index 9412b77a54..f4ff682566 100644
> --- a/drivers/clk/sunxi/clk_d1.c
> +++ b/drivers/clk/sunxi/clk_d1.c
> @@ -74,28 +74,9 @@ static struct ccu_reset d1_resets[] = {
>   [RST_BUS_LRADC] = RESET(0xa9c, BIT(16)),
>   };
> 
> -static const struct ccu_desc d1_ccu_desc = {
> +const struct ccu_desc d1_ccu_desc = {
>   .gates  = d1_gates,
>   .resets = d1_resets,
> -};
> -
> -static int d1_clk_bind(struct udevice *dev)
> -{
> - return sunxi_reset_bind(dev, ARRAY_SIZE(d1_resets));
> -}
> -
> -static const struct udevice_id d1_ccu_ids[] = {
> - { .compatible = "allwinner,sun20i-d1-ccu",
> -   .data = (ulong)_ccu_desc },
> - { }
> -};
> -
> -U_BOOT_DRIVER(clk_sun20i_d1) = {
> - .name   = "sun20i_d1_ccu",
> - .id = UCLASS_CLK,
> - .of_match   = d1_ccu_ids,
> - .priv_auto  = sizeof(struct ccu_priv),
> - .ops= _clk_ops,
> - .probe  = sunxi_clk_probe,
> - .bind   = d1_clk_bind,
> + .num_gates  = ARRAY_SIZE(d1_gates),
> + .num_resets = ARRAY_SIZE(d1_resets),
>   };
> diff --git a/drivers/clk/sunxi/clk_sunxi.c
> b/drivers/clk/sunxi/clk_sunxi.c index ec02a2d037..176d3cbc28 100644
> --- a/drivers/clk/sunxi/clk_sunxi.c
> +++ b/drivers/clk/sunxi/clk_sunxi.c
> @@ -125,6 +125,7 @@ extern const struct ccu_desc h616_ccu_desc;
>   extern const struct ccu_desc h6_r_ccu_desc;
>   extern const struct ccu_desc r40_ccu_desc;
>   extern const struct ccu_desc v3s_ccu_desc;
> +extern const struct ccu_desc d1_ccu_desc;
> 
>   static const struct udevice_id sunxi_clk_ids[] = {
>   #ifdef CONFIG_CLK_SUN4I_A10
> @@ -214,6 +215,10 @@ static const struct udevice_id sunxi_clk_ids[] =
> { #ifdef CONFIG_CLK_SUNIV_F1C100S
>   { .compatible = "allwinner,suniv-f1c100s-ccu",
> .data = (ulong)_ccu_desc },
> +#endif
> +#ifdef CONFIG_CLK_SUN20I_D1
> + { .compatible = "allwinner,sun20i-d1-ccu",
> +   .data = (ulong)_ccu_desc },
>   #endif
>   { }
>   };



Re: [RFC PATCH v1 2/3] spi: sunxi: Add support for R329/D1/R528/T113 SPI controller

2023-05-23 Thread Sam Edwards

Hi Maxim,

By any chance do you happen to know when in sunxi history the SPI 
controller grew QuadSPI/DualSPI support? It'd probably be feature creep 
to have in this patch series, but since they don't look too hard to 
implement, I might be interested in taking a stab at supporting them.


On 5/19/23 07:40, Maxim Kiselev wrote:

These SoCs have two SPI controllers that are quite similar to the SPI
on previous Allwinner SoCs. The main difference is that new SoCs
don't have a clock divider (SPI_CCR register) inside SPI IP.

Instead SPI sample mode should be configured depending on the input clock.

For now SPI input clock source selection is not supported by this driver,
and only HOSC@24MHz can be used as input clock. Therefore, according to
the, manual we could change the SPI sample mode from delay half
cycle(default) to normal.

This patch adds a quirk for this kind of SPI controllers

Signed-off-by: Maxim Kiselev 


Tested-by: Sam Edwards 

Cheers,
Sam


Re: [RFC PATCH v1 3/3] riscv: dts: allwinner: d1: Add SPI controllers node

2023-05-23 Thread Sam Edwards

Hi Maxim,

I've been using this series for a little bit. Things seem pretty good! 
Thank you for your work on it. :)


On 5/19/23 07:40, Maxim Kiselev wrote:

Some boards form the MangoPi family (MQ\MQ-Dual\MQ-R) may have


Typo; replace: "form" -> "from"


an optional SPI flash that connects to the SPI0 controller.

This controller is the same for R329/D1/R528/T113s SoCs and
should be supported by the sun50i-r329-spi driver.

So let's add its DT nodes.

Signed-off-by: Maxim Kiselev 


Reviewed-by: Sam Edwards 

Cheers,
Sam


[PATCH v4 3/3] Load option with short device path for boot vars

2023-05-23 Thread Raymond Mao
The boot variables automatically generated for removable medias
should be with short form of device path without device nodes.
This is a requirement for the case that a removable media is
plugged into a different port but is still able to work with the
existing boot variables.

Signed-off-by: Raymond Mao 
---
Changes in v2
- Ignore EFI_NOT_FOUND returned from
  efi_bootmgr_update_media_device_boot_option which means no boot
  options scanned.
Changes in v3
- Split the patch into moving and renaming functions and
  individual patches for each changed functionality
Changes in v4
- Revert the change of introducing a bool parameter when updating
  the boot option. Use short-form of device path by default

 lib/efi_loader/efi_bootmgr.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index c329428973..336b9d2d8f 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -387,6 +387,11 @@ static efi_status_t 
efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo
p = dev_name;
utf8_utf16_strncpy(, buf, strlen(buf));
 
+   /* use short form device path */
+   device_path = efi_dp_shorten(device_path);
+   if (!device_path)
+   continue;
+
lo.label = dev_name;
lo.attributes = LOAD_OPTION_ACTIVE;
lo.file_path = device_path;
-- 
2.25.1



[PATCH v4 2/3] Boot var automatic management for removable medias

2023-05-23 Thread Raymond Mao
Changes for complying to EFI spec §3.5.1.1
'Removable Media Boot Behavior'.
Boot variables can be automatically generated during a removable
media is probed. At the same time, unused boot variables will be
detected and removed.

Signed-off-by: Raymond Mao 
---
Changes in v2
- Ignore EFI_NOT_FOUND returned from
  efi_bootmgr_update_media_device_boot_option which means no boot
  options scanned.
Changes in v3
- Split the patch into moving and renaming functions and
  individual patches for each changed functionality
Changes in v4
- Revert the change of introducing a bool parameter when updating
  the boot option. Use short-form of device path by default

 lib/efi_loader/efi_disk.c |  7 +++
 lib/efi_loader/efi_variable.c | 10 +-
 lib/efi_loader/efi_variable_tee.c |  5 +
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index d2256713a8..ca5f07f2ec 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -687,6 +687,13 @@ int efi_disk_probe(void *ctx, struct event *event)
return -1;
}
 
+   /* only do the boot option management when UEFI sub-system is 
initialized */
+   if (efi_obj_list_initialized == EFI_SUCCESS) {
+   ret = efi_bootmgr_update_media_device_boot_option();
+   if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
+   return -1;
+   }
+
return 0;
 }
 
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index be95ed44e6..fe71144358 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -476,6 +476,14 @@ efi_status_t efi_init_variables(void)
log_err("Invalid EFI variable seed\n");
}
 
+   ret = efi_init_secure_state();
+   if (ret != EFI_SUCCESS)
+   return ret;
 
-   return efi_init_secure_state();
+   /* update boot option management after variable service initialized */
+   ret = efi_bootmgr_update_media_device_boot_option();
+   if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
+   return ret;
+
+   return EFI_SUCCESS;
 }
diff --git a/lib/efi_loader/efi_variable_tee.c 
b/lib/efi_loader/efi_variable_tee.c
index dfef18435d..2995d4a583 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -748,5 +748,10 @@ efi_status_t efi_init_variables(void)
if (ret != EFI_SUCCESS)
return ret;
 
+   /* update boot option management after variable service initialized */
+   ret = efi_bootmgr_update_media_device_boot_option();
+   if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
+   return ret;
+
return EFI_SUCCESS;
 }
-- 
2.25.1



[PATCH v4 1/3] Move bootorder and bootoption apis to lib

2023-05-23 Thread Raymond Mao
Rename and move bootorder and bootoption apis from cmd to lib
for re-use between eficonfig and bootmgr

Signed-off-by: Raymond Mao 
---
Changes in v2
- Ignore EFI_NOT_FOUND returned from
  efi_bootmgr_update_media_device_boot_option which means no boot
  options scanned.
Changes in v3
- Split the patch into moving and renaming functions and
  individual patches for each changed functionality
Changes in v4
- Revert the change of introducing a bool parameter when updating
  the boot option. Use short-form of device path by default

 cmd/bootmenu.c   |   2 +-
 cmd/eficonfig.c  | 408 +--
 include/efi_config.h |   5 -
 include/efi_loader.h |  11 +
 lib/efi_loader/efi_bootmgr.c | 380 
 lib/efi_loader/efi_helper.c  |  25 +++
 6 files changed, 423 insertions(+), 408 deletions(-)

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 6baeedc69f..01daddca7b 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -351,7 +351,7 @@ static struct bootmenu_data *bootmenu_create(int delay)
 * UEFI specification requires booting from removal media using
 * a architecture-specific default image name such as 
BOOTAA64.EFI.
 */
-   efi_ret = eficonfig_generate_media_device_boot_option();
+   efi_ret = efi_bootmgr_update_media_device_boot_option();
if (efi_ret != EFI_SUCCESS && efi_ret != EFI_NOT_FOUND)
goto cleanup;
 
diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index 720f52b48b..82a80306f4 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -1134,43 +1134,6 @@ out:
return ret;
 }
 
-/**
- * eficonfig_get_unused_bootoption() - get unused "Boot" index
- *
- * @buf:   pointer to the buffer to store boot option variable name
- * @buf_size:  buffer size
- * @index: pointer to store the index in the BootOrder variable
- * Return: status code
- */
-efi_status_t eficonfig_get_unused_bootoption(u16 *buf, efi_uintn_t buf_size,
-unsigned int *index)
-{
-   u32 i;
-   efi_status_t ret;
-   efi_uintn_t size;
-
-   if (buf_size < u16_strsize(u"Boot"))
-   return EFI_BUFFER_TOO_SMALL;
-
-   for (i = 0; i <= 0x; i++) {
-   size = 0;
-   efi_create_indexed_name(buf, buf_size, "Boot", i);
-   ret = efi_get_variable_int(buf, _global_variable_guid,
-  NULL, , NULL, NULL);
-   if (ret == EFI_BUFFER_TOO_SMALL)
-   continue;
-   else
-   break;
-   }
-
-   if (i > 0x)
-   return EFI_OUT_OF_RESOURCES;
-
-   *index = i;
-
-   return EFI_SUCCESS;
-}
-
 /**
  * eficonfig_set_boot_option() - set boot option
  *
@@ -1208,46 +1171,6 @@ static efi_status_t eficonfig_set_boot_option(u16 
*varname, struct efi_device_pa
return ret;
 }
 
-/**
- * eficonfig_append_bootorder() - append new boot option in BootOrder variable
- *
- * @index: "Boot" index to append to BootOrder variable
- * Return: status code
- */
-efi_status_t eficonfig_append_bootorder(u16 index)
-{
-   u16 *bootorder;
-   efi_status_t ret;
-   u16 *new_bootorder = NULL;
-   efi_uintn_t last, size, new_size;
-
-   /* append new boot option */
-   bootorder = efi_get_var(u"BootOrder", _global_variable_guid, );
-   last = size / sizeof(u16);
-   new_size = size + sizeof(u16);
-   new_bootorder = calloc(1, new_size);
-   if (!new_bootorder) {
-   ret = EFI_OUT_OF_RESOURCES;
-   goto out;
-   }
-   memcpy(new_bootorder, bootorder, size);
-   new_bootorder[last] = index;
-
-   ret = efi_set_variable_int(u"BootOrder", _global_variable_guid,
-  EFI_VARIABLE_NON_VOLATILE |
-  EFI_VARIABLE_BOOTSERVICE_ACCESS |
-  EFI_VARIABLE_RUNTIME_ACCESS,
-  new_size, new_bootorder, false);
-   if (ret != EFI_SUCCESS)
-   goto out;
-
-out:
-   free(bootorder);
-   free(new_bootorder);
-
-   return ret;
-}
-
 /**
  * create_boot_option_entry() - create boot option entry
  *
@@ -1619,7 +1542,7 @@ static efi_status_t 
eficonfig_process_add_boot_option(void *data)
if (!bo)
return EFI_OUT_OF_RESOURCES;
 
-   ret = eficonfig_get_unused_bootoption(varname, sizeof(varname), 
>boot_index);
+   ret = efi_bootmgr_get_unused_bootoption(varname, sizeof(varname), 
>boot_index);
if (ret != EFI_SUCCESS)
return ret;
 
@@ -1627,7 +1550,7 @@ static efi_status_t 
eficonfig_process_add_boot_option(void *data)
if (ret != EFI_SUCCESS)
goto out;
 
-   ret = eficonfig_append_bootorder((u16)bo->boot_index);
+   ret = 

Re: [PATCH] arm: dts: k3-j721e: Remove ti,strobe-sel

2023-05-23 Thread Nishanth Menon
On 11:49-20230523, Tom Rini wrote:
> On Tue, May 23, 2023 at 04:48:53PM +0530, Neha Malcom Francis wrote:
> 
> > HS400 speed mode is not supported for sdhci0 (eMMC) for J721E (errata of
> > J721E: (i2024) 'MMCSD: Peripherals Do Not Support HS400'[1]). Thus,
> > remove ti,strobe-sel property which is needed only for HS400 speed mode.
> > This also helps sync kernel dts with u-boot dts.
> > 
> > [1] https://www.ti.com/lit/er/sprz455/sprz455.pdf
> > 
> > Fixes: e64665fa727e ("arm: dts: k3-j721e-main: Update the speed modes
> > supported and their itap delay values for MMCSD subsystems")
> > Signed-off-by: Bhavya Kapoor 
> > Signed-off-by: Neha Malcom Francis 
> > ---
> >  arch/arm/dts/k3-j721e-main.dtsi | 1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/arch/arm/dts/k3-j721e-main.dtsi 
> > b/arch/arm/dts/k3-j721e-main.dtsi
> > index cf3482376c..7dc6f923d1 100644
> > --- a/arch/arm/dts/k3-j721e-main.dtsi
> > +++ b/arch/arm/dts/k3-j721e-main.dtsi
> > @@ -1049,7 +1049,6 @@
> > ti,itap-del-sel-mmc-hs = <0xa>;
> > ti,itap-del-sel-ddr52 = <0x3>;
> > ti,trm-icp = <0x8>;
> > -   ti,strobe-sel = <0x77>;
> > dma-coherent;
> > };
> 
> Nishanth?


NAK. not because this is wrong - but what is the reason we have to
re-emphasise over and over and over again -> Please send to upstream
kernel.org master branch AND then pick patches in backport to
kernel.org.

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


Re: [PATCH 0/4] ESM support for J721E and J7200

2023-05-23 Thread Nishanth Menon
On 09:56-20230523, Tom Rini wrote:
> On Tue, May 23, 2023 at 01:19:47PM +0530, Neha Malcom Francis wrote:
> 
> > Add support for ESM (Error Signalling Module) in J721E and J7200. The
> > ESM error pin output is routed to the PMIC (Power Management IC) which
> > can reset the board. The dts nodes for SoC ESM modules are added (if
> > not already) to enable them.
> > 
> > Gowtham Tammana (2):
> >   arm: dts: k3-j7200: Add Main domain ESM support
> >   board: ti: j721e: initialize ESM support for J7200 SOM
> > 
> > Neha Malcom Francis (2):
> >   arm: dts: k3-j721e: Refine MAIN domain ESM support
> >   configs: j7200_evm_r5: Add ESM config for J7200
> > 
> >  arch/arm/dts/k3-j7200-main.dtsi| 7 +++
> >  arch/arm/dts/k3-j7200.dtsi | 1 +
> >  arch/arm/dts/k3-j721e-main.dtsi| 7 +++
> >  arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 9 -
> >  arch/arm/dts/k3-j721e.dtsi | 1 +
> >  board/ti/j721e/evm.c   | 3 ++-
> >  configs/j7200_evm_r5_defconfig | 1 +
> >  7 files changed, 19 insertions(+), 10 deletions(-)
> 
> Since we're touching the dts files, adding Nishanth.

Easy NAK ;) -> K.org master first please. and then sync back and we dont
need to do these piecemeal fixups.


-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


[PATCH v2] imx: imx8mp: Add support for Polyhex Debix Model A SBC

2023-05-23 Thread Gilles Talis
Add support for the Polyhex Debix Model A SBC board.
It is an industrial grade single board computer based on
NXP's i.MX 8M Plus.
Currently supported interfaces are:
- Serial console
- Micro SD
- eQOS and FEC Ethernet

imx8mp-debix-model-a.dts is taken from Linux 6.3.

Signed-off-by: Gilles Talis 
---
Changes in v2:
- Updated Copyright time and author in files needing correction
---
 arch/arm/dts/Makefile |1 +
 arch/arm/dts/imx8mp-debix-model-a-u-boot.dtsi |  141 ++
 arch/arm/dts/imx8mp-debix-model-a.dts |  507 +
 arch/arm/mach-imx/imx8m/Kconfig   |8 +
 board/polyhex/imx8mp_debix_model_a/Kconfig|   15 +
 .../polyhex/imx8mp_debix_model_a/MAINTAINERS  |8 +
 board/polyhex/imx8mp_debix_model_a/Makefile   |   13 +
 .../imx8mp_debix_model_a.c|   55 +
 .../imximage-8mp-lpddr4.cfg   |9 +
 .../imx8mp_debix_model_a/lpddr4_timing.c  | 1843 +
 board/polyhex/imx8mp_debix_model_a/spl.c  |  128 ++
 configs/imx8mp_debix_model_a_defconfig|  110 +
 include/configs/imx8mp_debix_model_a.h|   54 +
 13 files changed, 2892 insertions(+)
 create mode 100644 arch/arm/dts/imx8mp-debix-model-a-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mp-debix-model-a.dts
 create mode 100644 board/polyhex/imx8mp_debix_model_a/Kconfig
 create mode 100644 board/polyhex/imx8mp_debix_model_a/MAINTAINERS
 create mode 100644 board/polyhex/imx8mp_debix_model_a/Makefile
 create mode 100644 board/polyhex/imx8mp_debix_model_a/imx8mp_debix_model_a.c
 create mode 100644 board/polyhex/imx8mp_debix_model_a/imximage-8mp-lpddr4.cfg
 create mode 100644 board/polyhex/imx8mp_debix_model_a/lpddr4_timing.c
 create mode 100644 board/polyhex/imx8mp_debix_model_a/spl.c
 create mode 100644 configs/imx8mp_debix_model_a_defconfig
 create mode 100644 include/configs/imx8mp_debix_model_a.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 480269fa60..1c53e357db 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1008,6 +1008,7 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
imx8mq-phanbell.dtb \
imx8mp-beacon-kit.dtb \
imx8mp-data-modul-edm-sbc.dtb \
+   imx8mp-debix-model-a.dtb \
imx8mp-dhcom-pdk2.dtb \
imx8mp-dhcom-pdk3.dtb \
imx8mp-evk.dtb \
diff --git a/arch/arm/dts/imx8mp-debix-model-a-u-boot.dtsi 
b/arch/arm/dts/imx8mp-debix-model-a-u-boot.dtsi
new file mode 100644
index 00..33bd89a843
--- /dev/null
+++ b/arch/arm/dts/imx8mp-debix-model-a-u-boot.dtsi
@@ -0,0 +1,141 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2019, 2021 NXP
+ * Copyright 2023 Gilles Talis 
+ */
+
+#include "imx8mp-u-boot.dtsi"
+
+/ {
+   wdt-reboot {
+   compatible = "wdt-reboot";
+   wdt = <>;
+   bootph-pre-ram;
+   };
+   firmware {
+   optee {
+   compatible = "linaro,optee-tz";
+   method = "smc";
+   };
+   };
+};
+
+ {
+   bootph-pre-ram;
+};
+
+ {
+   reset-gpios = < 18 GPIO_ACTIVE_LOW>;
+   reset-delay-us = <15000>;
+   reset-post-delay-us = <10>;
+};
+
+ {
+   phy-reset-gpios = < 19 GPIO_ACTIVE_LOW>;
+   phy-reset-duration = <15>;
+   phy-reset-post-delay = <100>;
+};
+
+ {
+   bootph-pre-ram;
+};
+
+ {
+   bootph-pre-ram;
+};
+
+ {
+   bootph-pre-ram;
+};
+
+ {
+   bootph-pre-ram;
+};
+
+ {
+   bootph-pre-ram;
+};
+
+ {
+   bootph-pre-ram;
+};
+
+_i2c1 {
+   bootph-pre-ram;
+};
+
+_pmic {
+   bootph-pre-ram;
+};
+
+_uart2 {
+   bootph-pre-ram;
+};
+
+_usdhc2_gpio {
+   bootph-pre-ram;
+};
+
+_usdhc2 {
+   bootph-pre-ram;
+};
+
+_usdhc3 {
+   bootph-pre-ram;
+};
+
+_wdog {
+   bootph-pre-ram;
+};
+
+ {
+   bootph-pre-ram;
+
+   regulators {
+   bootph-pre-ram;
+   };
+};
+
+_usdhc2_vmmc {
+   u-boot,off-on-delay-us = <2>;
+};
+
+_usdhc2_vmmc {
+   bootph-pre-ram;
+};
+
+ {
+   bootph-pre-ram;
+};
+
+_jr0 {
+   bootph-pre-ram;
+};
+
+_jr1 {
+   bootph-pre-ram;
+};
+
+_jr2 {
+   bootph-pre-ram;
+};
+
+ {
+   bootph-pre-ram;
+};
+
+ {
+   bootph-pre-ram;
+   sd-uhs-sdr104;
+   sd-uhs-ddr50;
+};
+
+ {
+   bootph-pre-ram;
+   mmc-hs400-1_8v;
+   mmc-hs400-enhanced-strobe;
+};
+
+ {
+   bootph-pre-ram;
+};
diff --git a/arch/arm/dts/imx8mp-debix-model-a.dts 
b/arch/arm/dts/imx8mp-debix-model-a.dts
new file mode 100644
index 00..58dae612b4
--- /dev/null
+++ b/arch/arm/dts/imx8mp-debix-model-a.dts
@@ -0,0 +1,507 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2019 NXP
+ * Copyright 2022 Ideas on Board Oy
+ */
+
+/dts-v1/;
+
+#include 
+#include 
+#include 
+
+#include "imx8mp.dtsi"
+
+/ {
+   model = "Polyhex Debix Model A i.MX8MPlus board";
+   compatible = "polyhex,imx8mp-debix-model-a", "polyhex,imx8mp-debix", 
"fsl,imx8mp";
+
+   chosen {
+  

Re: [PATCH 0/8] Cleanup unaligned access macros

2023-05-23 Thread Tom Rini
On Mon, May 22, 2023 at 11:34:36PM +0300, Ilias Apalodimas wrote:
> Hi Jens
> 
> On Mon, May 22, 2023 at 02:22:30PM +0200, Jens Wiklander wrote:
> > Hi,
> >
> > There are two versions of get/set_unaligned, get_unaligned_be64,
> > put_unaligned_le64 etc in U-Boot causing confusion (and bugs).
> >
> > In this patch-set, I'm trying to fix that with a single unified version of
> > the access macros to be used across all archs. This work is inspired by
> > similar changes in this Linux kernel by Arnd Bergman,
> > https://lore.kernel.org/lkml/20210514100106.3404011-1-a...@kernel.org/
> >
> > Thanks,
> > Jens
> 
> Thanks for the cleanup.
> 
> For the series
> Reviewed-by: Ilias Apalodimas 
> Although I'd like to hear from arch maintainers as well.
> 
> Tom, This did pass all the CI successfully, but regardless I think it
> should be pulled into -next.  If you want me to pick it up via the TPM tree
> please let me know.

I'll pick this up for -next after it's been around a little bit longer,
to let people test / ack it, thanks.

-- 
Tom


signature.asc
Description: PGP signature


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

2023-05-23 Thread Pali Rohár
Hello! I have looked at this change and below are my comments.

On Tuesday 23 May 2023 14:57:38 Stefan Roese wrote:
> This patch adds the PCIe controller driver for the Xilinx / AMD ZynqMP
> NWL PCIe Bridge as root port. The driver source is partly copied from
> the Linux PCI driver and modified to enable usage in U-Boot (e.g.
> simplified and interrupt support removed).
> 
> Signed-off-by: Stefan Roese 
> Cc: Simon Glass 
> Cc: Pali Rohár 
> Cc: Bin Meng 
> Cc: Michal Simek 
> ---
>  MAINTAINERS   |   1 +
>  drivers/pci/Kconfig   |   7 +
>  drivers/pci/Makefile  |   1 +
>  drivers/pci/pcie-xilinx-nwl.c | 374 ++
>  4 files changed, 383 insertions(+)
>  create mode 100644 drivers/pci/pcie-xilinx-nwl.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index c8f72e9ec6a2..2bc19d9daa75 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -343,6 +343,7 @@ F:drivers/rtc/armada38x.c
>  F:   drivers/spi/kirkwood_spi.c
>  F:   drivers/spi/mvebu_a3700_spi.c
>  F:   drivers/pci/pcie_dw_mvebu.c
> +F:   drivers/pci/pcie-xilinx-nwl.c
>  F:   drivers/watchdog/armada-37xx-wdt.c
>  F:   drivers/watchdog/orion_wdt.c
>  F:   include/configs/mv-common.h
> diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
> index ef328d26525b..60d98d14640d 100644
> --- a/drivers/pci/Kconfig
> +++ b/drivers/pci/Kconfig
> @@ -374,4 +374,11 @@ config PCIE_UNIPHIER
> Say Y here if you want to enable PCIe controller support on
> UniPhier SoCs.
>  
> +config PCIE_XILINX_NWL
> + bool "Xilinx NWL PCIe controller"
> + depends on ARCH_ZYNQMP
> + help
> +  Say 'Y' here if you want support for Xilinx / AMD NWL PCIe
> +  controller as Root Port.
> +
>  endif
> diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
> index 49506e7ba59b..11f60c6991d9 100644
> --- a/drivers/pci/Makefile
> +++ b/drivers/pci/Makefile
> @@ -49,3 +49,4 @@ obj-$(CONFIG_PCI_OCTEONTX) += pci_octeontx.o
>  obj-$(CONFIG_PCIE_OCTEON) += pcie_octeon.o
>  obj-$(CONFIG_PCIE_DW_SIFIVE) += pcie_dw_sifive.o
>  obj-$(CONFIG_PCIE_UNIPHIER) += pcie_uniphier.o
> +obj-$(CONFIG_PCIE_XILINX_NWL) += pcie-xilinx-nwl.o
> diff --git a/drivers/pci/pcie-xilinx-nwl.c b/drivers/pci/pcie-xilinx-nwl.c
> new file mode 100644
> index ..3d64a0e3b961
> --- /dev/null
> +++ b/drivers/pci/pcie-xilinx-nwl.c
> @@ -0,0 +1,374 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * PCIe host bridge driver for Xilinx / AMD ZynqMP NWL PCIe Bridge
> + *
> + * Based on the Linux driver which is:
> + * (C) Copyright 2014 - 2015, Xilinx, Inc.
> + *
> + * Author: Stefan Roese 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* Bridge core config registers */
> +#define BRCFG_PCIE_RX0   0x
> +#define BRCFG_PCIE_RX1   0x0004
> +#define BRCFG_INTERRUPT  0x0010
> +#define BRCFG_PCIE_RX_MSG_FILTER 0x0020
> +
> +/* Egress - Bridge translation registers */
> +#define E_BREG_CAPABILITIES  0x0200
> +#define E_BREG_CONTROL   0x0208
> +#define E_BREG_BASE_LO   0x0210
> +#define E_BREG_BASE_HI   0x0214
> +#define E_ECAM_CAPABILITIES  0x0220
> +#define E_ECAM_CONTROL   0x0228
> +#define E_ECAM_BASE_LO   0x0230
> +#define E_ECAM_BASE_HI   0x0234
> +
> +#define I_ISUB_CONTROL   0x03E8
> +#define SET_ISUB_CONTROL BIT(0)
> +/* Rxed msg fifo  - Interrupt status registers */
> +#define MSGF_MISC_STATUS 0x0400
> +#define MSGF_MISC_MASK   0x0404
> +#define MSGF_LEG_STATUS  0x0420
> +#define MSGF_LEG_MASK0x0424
> +#define MSGF_MSI_STATUS_LO   0x0440
> +#define MSGF_MSI_STATUS_HI   0x0444
> +#define MSGF_MSI_MASK_LO 0x0448
> +#define MSGF_MSI_MASK_HI 0x044C
> +
> +/* Msg filter mask bits */
> +#define CFG_ENABLE_PM_MSG_FWDBIT(1)
> +#define CFG_ENABLE_INT_MSG_FWD   BIT(2)
> +#define CFG_ENABLE_ERR_MSG_FWD   BIT(3)
> +#define CFG_ENABLE_MSG_FILTER_MASK   (CFG_ENABLE_PM_MSG_FWD |\
> +  CFG_ENABLE_INT_MSG_FWD |   \
> +  CFG_ENABLE_ERR_MSG_FWD)
> +
> +/* Misc interrupt status mask bits */
> +#define MSGF_MISC_SR_RXMSG_AVAIL BIT(0)
> +#define MSGF_MISC_SR_RXMSG_OVER  BIT(1)
> +#define MSGF_MISC_SR_SLAVE_ERR   BIT(4)
> +#define MSGF_MISC_SR_MASTER_ERR  BIT(5)
> +#define MSGF_MISC_SR_I_ADDR_ERR  BIT(6)
> +#define MSGF_MISC_SR_E_ADDR_ERR  BIT(7)
> +#define MSGF_MISC_SR_FATAL_AER   BIT(16)
> +#define MSGF_MISC_SR_NON_FATAL_AER   

Re: [PATCH] arm: dts: k3-j721e: Remove ti,strobe-sel

2023-05-23 Thread Tom Rini
On Tue, May 23, 2023 at 04:48:53PM +0530, Neha Malcom Francis wrote:

> HS400 speed mode is not supported for sdhci0 (eMMC) for J721E (errata of
> J721E: (i2024) 'MMCSD: Peripherals Do Not Support HS400'[1]). Thus,
> remove ti,strobe-sel property which is needed only for HS400 speed mode.
> This also helps sync kernel dts with u-boot dts.
> 
> [1] https://www.ti.com/lit/er/sprz455/sprz455.pdf
> 
> Fixes: e64665fa727e ("arm: dts: k3-j721e-main: Update the speed modes
> supported and their itap delay values for MMCSD subsystems")
> Signed-off-by: Bhavya Kapoor 
> Signed-off-by: Neha Malcom Francis 
> ---
>  arch/arm/dts/k3-j721e-main.dtsi | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/arm/dts/k3-j721e-main.dtsi b/arch/arm/dts/k3-j721e-main.dtsi
> index cf3482376c..7dc6f923d1 100644
> --- a/arch/arm/dts/k3-j721e-main.dtsi
> +++ b/arch/arm/dts/k3-j721e-main.dtsi
> @@ -1049,7 +1049,6 @@
>   ti,itap-del-sel-mmc-hs = <0xa>;
>   ti,itap-del-sel-ddr52 = <0x3>;
>   ti,trm-icp = <0x8>;
> - ti,strobe-sel = <0x77>;
>   dma-coherent;
>   };

Nishanth?

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 0/4] ESM support for J721E and J7200

2023-05-23 Thread Tom Rini
On Tue, May 23, 2023 at 01:19:47PM +0530, Neha Malcom Francis wrote:

> Add support for ESM (Error Signalling Module) in J721E and J7200. The
> ESM error pin output is routed to the PMIC (Power Management IC) which
> can reset the board. The dts nodes for SoC ESM modules are added (if
> not already) to enable them.
> 
> Gowtham Tammana (2):
>   arm: dts: k3-j7200: Add Main domain ESM support
>   board: ti: j721e: initialize ESM support for J7200 SOM
> 
> Neha Malcom Francis (2):
>   arm: dts: k3-j721e: Refine MAIN domain ESM support
>   configs: j7200_evm_r5: Add ESM config for J7200
> 
>  arch/arm/dts/k3-j7200-main.dtsi| 7 +++
>  arch/arm/dts/k3-j7200.dtsi | 1 +
>  arch/arm/dts/k3-j721e-main.dtsi| 7 +++
>  arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 9 -
>  arch/arm/dts/k3-j721e.dtsi | 1 +
>  board/ti/j721e/evm.c   | 3 ++-
>  configs/j7200_evm_r5_defconfig | 1 +
>  7 files changed, 19 insertions(+), 10 deletions(-)

Since we're touching the dts files, adding Nishanth.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 6/6] net: ldpaa_eth: export DPNI and DPMAC counters through 'net stats'

2023-05-23 Thread Ioana Ciornei
Export the already existing DPNI and DPMAC counters through the newly
added callbacks.

Signed-off-by: Ioana Ciornei 
---
 drivers/net/ldpaa_eth/ldpaa_eth.c | 44 ---
 1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c 
b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 53c5b8ba2b1d..8c0b5a3b6fd2 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -998,11 +998,47 @@ static int ldpaa_eth_of_to_plat(struct udevice *dev)
return 0;
 }
 
+static int ldpaa_eth_get_sset_count(struct udevice *dev)
+{
+   return LDPAA_ETH_DPNI_NUM_STATS + LDPAA_ETH_DPMAC_NUM_STATS;
+}
+
+static void ldpaa_eth_get_strings(struct udevice *dev, u8 *data)
+{
+   u8 *p = data;
+   int i;
+
+   for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++) {
+   strlcpy(p, ldpaa_eth_dpni_stat_strings[i], ETH_GSTRING_LEN);
+   p += ETH_GSTRING_LEN;
+   }
+
+   for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++) {
+   strlcpy(p, ldpaa_eth_dpmac_stat_strings[i], ETH_GSTRING_LEN);
+   p += ETH_GSTRING_LEN;
+   }
+}
+
+static void ldpaa_eth_get_stats(struct udevice *dev, u64 *data)
+{
+   struct ldpaa_eth_priv *priv = dev_get_priv(dev);
+   int i, j = 0;
+
+   for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++)
+   *(data + j++) = priv->dpni_stats[i];
+
+   for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++)
+   *(data + j++) = priv->dpmac_stats[i];
+}
+
 static const struct eth_ops ldpaa_eth_ops = {
-   .start  = ldpaa_eth_open,
-   .send   = ldpaa_eth_tx,
-   .recv   = ldpaa_eth_pull_dequeue_rx,
-   .stop   = ldpaa_eth_stop,
+   .start = ldpaa_eth_open,
+   .send = ldpaa_eth_tx,
+   .recv = ldpaa_eth_pull_dequeue_rx,
+   .stop = ldpaa_eth_stop,
+   .get_sset_count = ldpaa_eth_get_sset_count,
+   .get_strings = ldpaa_eth_get_strings,
+   .get_stats = ldpaa_eth_get_stats,
 };
 
 static const struct udevice_id ldpaa_eth_of_ids[] = {
-- 
2.25.1



[PATCH 5/6] cmd: net: add a 'net stats' command to dump network statistics

2023-05-23 Thread Ioana Ciornei
Add a new option to the 'net' command which can be used to dump network
statistics.

To do this, 3 new callbacks are added to the eth_ops structure:
.get_sset_count(), .get_strings(), .get_stats(). These callbacks
have the same functions as in Linux: to return the number of counters,
the strings which describe those counters and the actual values.

Signed-off-by: Ioana Ciornei 
---
 cmd/net.c | 54 ++-
 include/net.h |  6 ++
 2 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/cmd/net.c b/cmd/net.c
index 68d406291ef1..dfe811f41acf 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -691,8 +692,58 @@ static int do_net_list(struct cmd_tbl *cmdtp, int flag, 
int argc, char *const ar
return CMD_RET_SUCCESS;
 }
 
+static int do_net_stats(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
+{
+   int nstats, err, i, off;
+   struct udevice *dev;
+   u64 *values;
+   u8 *strings;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   err = uclass_get_device_by_name(UCLASS_ETH, argv[1], );
+   if (err) {
+   printf("Could not find device %s\n", argv[1]);
+   return CMD_RET_FAILURE;
+   }
+
+   if (!eth_get_ops(dev)->get_sset_count ||
+   !eth_get_ops(dev)->get_strings ||
+   !eth_get_ops(dev)->get_stats) {
+   printf("Driver does not implement stats dump!\n");
+   return CMD_RET_FAILURE;
+   }
+
+   nstats = eth_get_ops(dev)->get_sset_count(dev);
+   strings = kcalloc(nstats, ETH_GSTRING_LEN, GFP_KERNEL);
+   if (!strings)
+   return CMD_RET_FAILURE;
+
+   values = kcalloc(nstats, sizeof(u64), GFP_KERNEL);
+   if (!values)
+   goto err_free_strings;
+
+   eth_get_ops(dev)->get_strings(dev, strings);
+   eth_get_ops(dev)->get_stats(dev, values);
+
+   off = 0;
+   for (i = 0; i < nstats; i++) {
+   printf("  %s: %llu\n", [off], values[i]);
+   off += ETH_GSTRING_LEN;
+   };
+
+   return CMD_RET_SUCCESS;
+
+err_free_strings:
+   kfree(strings);
+
+   return CMD_RET_FAILURE;
+}
+
 static struct cmd_tbl cmd_net[] = {
U_BOOT_CMD_MKENT(list, 1, 0, do_net_list, "", ""),
+   U_BOOT_CMD_MKENT(stats, 2, 0, do_net_stats, "", ""),
 };
 
 static int do_net(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
@@ -714,9 +765,10 @@ static int do_net(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
 }
 
 U_BOOT_CMD(
-   net, 2, 1, do_net,
+   net, 3, 1, do_net,
"NET sub-system",
"list - list available devices\n"
+   "stats  - dump statistics for specified device\n"
 );
 
 #if defined(CONFIG_CMD_NCSI)
diff --git a/include/net.h b/include/net.h
index 785cb1059ef9..e254df7d7f43 100644
--- a/include/net.h
+++ b/include/net.h
@@ -167,6 +167,9 @@ enum eth_recv_flags {
  * to the network stack. This function should fill in the
  * eth_pdata::enetaddr field - optional
  * set_promisc: Enable or Disable promiscuous mode
+ * get_sset_count: Number of statistics counters
+ * get_string: Names of the statistic counters
+ * get_stats: The values of the statistic counters
  */
 struct eth_ops {
int (*start)(struct udevice *dev);
@@ -178,6 +181,9 @@ struct eth_ops {
int (*write_hwaddr)(struct udevice *dev);
int (*read_rom_hwaddr)(struct udevice *dev);
int (*set_promisc)(struct udevice *dev, bool enable);
+   int (*get_sset_count)(struct udevice *dev);
+   void (*get_strings)(struct udevice *dev, u8 *data);
+   void (*get_stats)(struct udevice *dev, u64 *data);
 };
 
 #define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops)
-- 
2.25.1



[PATCH 4/6] net: ldpaa_eth: extend debug capabilities with DPMAC statistics

2023-05-23 Thread Ioana Ciornei
The ldpaa_eth driver already had a DPMAC statistics dump, this patch
extends the list of stats and adds a bit more structure to the code.

For a bit more context, the DPAA2 u-boot software architecture uses a
default network interface object - a DPNI - which, at runtime, will get
connected to the currently used DPMAC object.
Each time the .stop() eth callback is called, the DPMAC is destroyed
thus any previous counters will get lost.

As a preparation for the next patches, we add a software kept set of
DPMAC counters which will get updated before each destroy operation
takes place.

Signed-off-by: Ioana Ciornei 
---
 drivers/net/ldpaa_eth/ldpaa_eth.c | 114 ++
 drivers/net/ldpaa_eth/ldpaa_eth.h |  34 +
 include/fsl-mc/fsl_dpmac.h|   5 +-
 3 files changed, 76 insertions(+), 77 deletions(-)

diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c 
b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 907e51da6e1e..53c5b8ba2b1d 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -79,8 +79,33 @@ static void ldpaa_eth_add_dpni_stats(struct udevice *dev, 
u64 *data)
priv->dpni_stats[i] += data[i];
 }
 
-#ifdef DEBUG
+static void ldpaa_eth_collect_dpmac_stats(struct udevice *dev, u64 *data)
+{
+   struct ldpaa_eth_priv *priv = dev_get_priv(dev);
+   int err, i;
+   u64 value;
 
+   for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++) {
+   err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
+   priv->dpmac_handle, i,
+   );
+   if (err)
+   printf("dpmac_get_counter(%d) failed\n", i);
+
+   *(data + i) = value;
+   }
+}
+
+static void ldpaa_eth_add_dpmac_stats(struct udevice *dev, u64 *data)
+{
+   struct ldpaa_eth_priv *priv = dev_get_priv(dev);
+   int i;
+
+   for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++)
+   priv->dpmac_stats[i] += data[i];
+}
+
+#ifdef DEBUG
 static void ldpaa_eth_dump_dpni_stats(struct udevice *dev, u64 *data)
 {
int i;
@@ -90,82 +115,13 @@ static void ldpaa_eth_dump_dpni_stats(struct udevice *dev, 
u64 *data)
printf("  %s: %llu\n", ldpaa_eth_dpni_stat_strings[i], data[i]);
 }
 
-static void ldpaa_eth_get_dpmac_counter(struct udevice *dev)
+static void ldpaa_eth_dump_dpmac_stats(struct udevice *dev, u64 *data)
 {
-   struct ldpaa_eth_priv *priv = dev_get_priv(dev);
-   int err = 0;
-   u64 value;
-
-   err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
-priv->dpmac_handle,
-DPMAC_CNT_ING_BYTE,
-);
-   if (err < 0) {
-   printf("dpmac_get_counter: DPMAC_CNT_ING_BYTE failed\n");
-   return;
-   }
-   printf("\nDPMAC counters ..\n");
-   printf("DPMAC_CNT_ING_BYTE=%lld\n", value);
-
-   err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
-priv->dpmac_handle,
-DPMAC_CNT_ING_FRAME_DISCARD,
-);
-   if (err < 0) {
-   printf("dpmac_get_counter: DPMAC_CNT_ING_FRAME_DISCARD 
failed\n");
-   return;
-   }
-   printf("DPMAC_CNT_ING_FRAME_DISCARD=%lld\n", value);
-
-   err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
-priv->dpmac_handle,
-DPMAC_CNT_ING_ALIGN_ERR,
-);
-   if (err < 0) {
-   printf("dpmac_get_counter: DPMAC_CNT_ING_ALIGN_ERR failed\n");
-   return;
-   }
-   printf("DPMAC_CNT_ING_ALIGN_ERR =%lld\n", value);
-
-   err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
-priv->dpmac_handle,
-DPMAC_CNT_ING_BYTE,
-);
-   if (err < 0) {
-   printf("dpmac_get_counter: DPMAC_CNT_ING_BYTE failed\n");
-   return;
-   }
-   printf("DPMAC_CNT_ING_BYTE=%lld\n", value);
-
-   err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
-priv->dpmac_handle,
-DPMAC_CNT_ING_ERR_FRAME,
-);
-   if (err < 0) {
-   printf("dpmac_get_counter: DPMAC_CNT_ING_ERR_FRAME failed\n");
-   return;
-   }
-   printf("DPMAC_CNT_ING_ERR_FRAME=%lld\n", value);
-
-   err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
-priv->dpmac_handle,
-DPMAC_CNT_EGR_BYTE ,
-);
-   if (err < 0) {
-   printf("dpmac_get_counter: DPMAC_CNT_EGR_BYTE failed\n");
-   return;
-   }
-   printf("DPMAC_CNT_EGR_BYTE =%lld\n", value);
+   int i;
 
-   err = dpmac_get_counter(dflt_mc_io, MC_CMD_NO_FLAGS,
-priv->dpmac_handle,
-DPMAC_CNT_EGR_ERR_FRAME ,
-);
-   if (err < 0) {
-   

[PATCH 3/6] net: ldpaa_eth: extend debug capabilities with DPNI statistics

2023-05-23 Thread Ioana Ciornei
The ldpaa_eth driver already had a DPNI statistics dump, this patch
extends the list of stats and adds a bit more structure to the code.

For a bit more context, the DPAA2 u-boot software architecture uses a
default network interface object - a DPNI - which, at runtime, will get
connected to the currently used DPMAC object.
Each time the .stop() eth callback is called, the DPNI is reset to its
original state, including its counters.

As a preparation for the next patches, we add a software kept set of
DPNI counters which will get updated before each reset operation takes
place.

Signed-off-by: Ioana Ciornei 
---
 drivers/net/ldpaa_eth/ldpaa_eth.c | 106 +++---
 drivers/net/ldpaa_eth/ldpaa_eth.h |  30 +
 2 files changed, 82 insertions(+), 54 deletions(-)

diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c 
b/drivers/net/ldpaa_eth/ldpaa_eth.c
index fe901baf5a4e..907e51da6e1e 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -38,68 +38,56 @@ static void init_phy(struct udevice *dev)
 }
 #endif
 
-#ifdef DEBUG
+static void ldpaa_eth_collect_dpni_stats(struct udevice *dev, u64 *data)
+{
+   union dpni_statistics dpni_stats;
+   int dpni_stats_page_size[DPNI_STATISTICS_CNT] = {
+   sizeof(dpni_stats.page_0),
+   sizeof(dpni_stats.page_1),
+   sizeof(dpni_stats.page_2),
+   sizeof(dpni_stats.page_3),
+   sizeof(dpni_stats.page_4),
+   sizeof(dpni_stats.page_5),
+   sizeof(dpni_stats.page_6),
+   };
+   int j, k, num_cnt, err, i = 0;
 
-#define DPNI_STATS_PER_PAGE 6
-
-static const char *dpni_statistics[][DPNI_STATS_PER_PAGE] = {
-   {
-   "DPNI_CNT_ING_ALL_FRAMES",
-   "DPNI_CNT_ING_ALL_BYTES",
-   "DPNI_CNT_ING_MCAST_FRAMES",
-   "DPNI_CNT_ING_MCAST_BYTES",
-   "DPNI_CNT_ING_BCAST_FRAMES",
-   "DPNI_CNT_ING_BCAST_BYTES",
-   }, {
-   "DPNI_CNT_EGR_ALL_FRAMES",
-   "DPNI_CNT_EGR_ALL_BYTES",
-   "DPNI_CNT_EGR_MCAST_FRAMES",
-   "DPNI_CNT_EGR_MCAST_BYTES",
-   "DPNI_CNT_EGR_BCAST_FRAMES",
-   "DPNI_CNT_EGR_BCAST_BYTES",
-   }, {
-   "DPNI_CNT_ING_FILTERED_FRAMES",
-   "DPNI_CNT_ING_DISCARDED_FRAMES",
-   "DPNI_CNT_ING_NOBUFFER_DISCARDS",
-   "DPNI_CNT_EGR_DISCARDED_FRAMES",
-   "DPNI_CNT_EGR_CNF_FRAMES",
-   ""
-   },
-};
+   for (j = 0; j <= 6; j++) {
+   /* We're not interested in pages 4 & 5 for now */
+   if (j == 4 || j == 5)
+   continue;
+   err = dpni_get_statistics(dflt_mc_io, MC_CMD_NO_FLAGS,
+ dflt_dpni->dpni_handle,
+ j, _stats);
+   if (err) {
+   memset(_stats, 0, sizeof(dpni_stats));
+   printf("dpni_get_stats(%d) failed\n", j);
+   }
+
+   num_cnt = dpni_stats_page_size[j] / sizeof(u64);
+   for (k = 0; k < num_cnt; k++)
+   *(data + i++) = dpni_stats.raw.counter[k];
+   }
+}
 
-static void print_dpni_stats(const char *strings[],
-union dpni_statistics dpni_stats)
+static void ldpaa_eth_add_dpni_stats(struct udevice *dev, u64 *data)
 {
-   uint64_t *stat;
+   struct ldpaa_eth_priv *priv = dev_get_priv(dev);
int i;
 
-   stat = (uint64_t *)_stats;
-   for (i = 0; i < DPNI_STATS_PER_PAGE; i++) {
-   if (strcmp(strings[i], "\0") == 0)
-   break;
-   printf("%s= %llu\n", strings[i], *stat);
-   stat++;
-   }
+   for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++)
+   priv->dpni_stats[i] += data[i];
 }
 
-static void ldpaa_eth_get_dpni_counter(void)
+#ifdef DEBUG
+
+static void ldpaa_eth_dump_dpni_stats(struct udevice *dev, u64 *data)
 {
-   int err = 0;
-   unsigned int page = 0;
-   union dpni_statistics dpni_stats;
+   int i;
 
-   printf("DPNI counters ..\n");
-   for (page = 0; page < 3; page++) {
-   err = dpni_get_statistics(dflt_mc_io, MC_CMD_NO_FLAGS,
- dflt_dpni->dpni_handle, page,
- _stats);
-   if (err < 0) {
-   printf("dpni_get_statistics: failed:");
-   printf("%d for page[%d]\n", err, page);
-   return;
-   }
-   print_dpni_stats(dpni_statistics[page], dpni_stats);
-   }
+   printf("DPNI counters:\n");
+   for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++)
+   printf("  %s: %llu\n", ldpaa_eth_dpni_stat_strings[i], data[i]);
 }
 
 static void ldpaa_eth_get_dpmac_counter(struct udevice *dev)
@@ -556,12 +544,22 @@ static void ldpaa_eth_stop(struct udevice *dev)
struct ldpaa_eth_priv *priv = dev_get_priv(dev);
struct phy_device 

[PATCH 2/6] net: ldpaa_eth: transform dpni_statistics from a struct to a union

2023-05-23 Thread Ioana Ciornei
In order to simplify code, dpni_statistics can be written as a union.
Using the raw accessors we can just loop through all the statistics from
a page without trying to access each an every one independently.
Make this change to a union.

Signed-off-by: Ioana Ciornei 
---
 drivers/net/fsl-mc/dpni.c |   2 +-
 drivers/net/ldpaa_eth/ldpaa_eth.c |   4 +-
 include/fsl-mc/fsl_dpni.h | 143 +-
 3 files changed, 105 insertions(+), 44 deletions(-)

diff --git a/drivers/net/fsl-mc/dpni.c b/drivers/net/fsl-mc/dpni.c
index 5290be20c85e..a31abbff71b9 100644
--- a/drivers/net/fsl-mc/dpni.c
+++ b/drivers/net/fsl-mc/dpni.c
@@ -491,7 +491,7 @@ int dpni_get_statistics(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
uint8_t  page,
-   struct dpni_statistics *stat)
+   union dpni_statistics *stat)
 {
struct mc_command cmd = { 0 };
int err;
diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c 
b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 2cb6e9b7d705..fe901baf5a4e 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -68,7 +68,7 @@ static const char *dpni_statistics[][DPNI_STATS_PER_PAGE] = {
 };
 
 static void print_dpni_stats(const char *strings[],
-struct dpni_statistics dpni_stats)
+union dpni_statistics dpni_stats)
 {
uint64_t *stat;
int i;
@@ -86,7 +86,7 @@ static void ldpaa_eth_get_dpni_counter(void)
 {
int err = 0;
unsigned int page = 0;
-   struct dpni_statistics dpni_stats;
+   union dpni_statistics dpni_stats;
 
printf("DPNI counters ..\n");
for (page = 0; page < 3; page++) {
diff --git a/include/fsl-mc/fsl_dpni.h b/include/fsl-mc/fsl_dpni.h
index e5e7338192f6..fc57c375ac14 100644
--- a/include/fsl-mc/fsl_dpni.h
+++ b/include/fsl-mc/fsl_dpni.h
@@ -258,13 +258,13 @@ do { \
 /*cmd, param, offset, width, type, arg_name */
 #define DPNI_RSP_GET_STATISTICS(cmd, stat) \
 do { \
-   MC_RSP_OP(cmd, 0, 0, 64, uint64_t, (stat)->counter0); \
-   MC_RSP_OP(cmd, 1, 0, 64, uint64_t, (stat)->counter1); \
-   MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (stat)->counter2); \
-   MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (stat)->counter3); \
-   MC_RSP_OP(cmd, 4, 0, 64, uint64_t, (stat)->counter4); \
-   MC_RSP_OP(cmd, 5, 0, 64, uint64_t, (stat)->counter5); \
-   MC_RSP_OP(cmd, 6, 0, 64, uint64_t, (stat)->counter6); \
+   MC_RSP_OP(cmd, 0, 0, 64, uint64_t, (stat)->raw.counter[0]); \
+   MC_RSP_OP(cmd, 1, 0, 64, uint64_t, (stat)->raw.counter[1]); \
+   MC_RSP_OP(cmd, 2, 0, 64, uint64_t, (stat)->raw.counter[2]); \
+   MC_RSP_OP(cmd, 3, 0, 64, uint64_t, (stat)->raw.counter[3]); \
+   MC_RSP_OP(cmd, 4, 0, 64, uint64_t, (stat)->raw.counter[4]); \
+   MC_RSP_OP(cmd, 5, 0, 64, uint64_t, (stat)->raw.counter[5]); \
+   MC_RSP_OP(cmd, 6, 0, 64, uint64_t, (stat)->raw.counter[6]); \
 } while (0)
 
 enum net_prot {
@@ -1257,40 +1257,101 @@ int dpni_set_tx_confirmation_mode(struct fsl_mc_io 
*mc_io,
  uint32_t  cmd_flags,
  uint16_t  token,
  enum dpni_confirmation_mode mode);
-struct dpni_statistics {
-   /**
-* Page_0 statistics structure
-* @ingress_all_frames: Ingress frame count
-* @ingress_all_bytes: Ingress byte count
-* @ingress_multicast_frames: Ingress multicast frame count
-* @ingress_multicast_bytes: Ingress multicast byte count
-* @ingress_broadcast_frames: Ingress broadcast frame count
-* @ingress_broadcast_bytes: Ingress broadcast byte count
-*
-* Page_1 statistics structure
-* @egress_all_frames: Egress frame count
-* @egress_all_bytes: Egress byte count
-* @egress_multicast_frames: Egress multicast frame count
-* @egress_multicast_bytes: Egress multicast byte count
-* @egress_broadcast_frames: Egress broadcast frame count
-* @egress_broadcast_bytes: Egress broadcast byte count
-*
-* Page_2 statistics structure
-* @ingress_filtered_frames: Ingress filtered frame count
-* @ingress_discarded_frames: Ingress discarded frame count
-* @ingress_nobuffer_discards: Ingress discarded frame count due to
-*  lack of buffers.
-* @egress_discarded_frames: Egress discarded frame count
-* @egress_confirmed_frames: Egress confirmed frame count
-*/
 
-   uint64_t counter0;
-   uint64_t counter1;
-   uint64_t counter2;
-   uint64_t counter3;
-   uint64_t counter4;
-   uint64_t counter5;
-   uint64_t counter6;
+#define DPNI_STATISTICS_CNT7
+
+/**
+ * union dpni_statistics - Union describing the DPNI statistics
+ * @page_0: 

[PATCH 1/6] net: ldpaa_eth: fix the memory layout of the dpmac_get_counters() API

2023-05-23 Thread Ioana Ciornei
Each MC commands has a specific predefined memory layout that gets
interpreted by the firmware. The dpmac_get_counters() API memory layout
is wrong, thus the results returned by the command are incorrect.

Fix this by updating the offset of the counter field.

Signed-off-by: Ioana Ciornei 
---
 include/fsl-mc/fsl_dpmac.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/fsl-mc/fsl_dpmac.h b/include/fsl-mc/fsl_dpmac.h
index 1cea123a3164..8f5e17fe222a 100644
--- a/include/fsl-mc/fsl_dpmac.h
+++ b/include/fsl-mc/fsl_dpmac.h
@@ -84,7 +84,7 @@ do { \
 
 /*cmd, param, offset, width, type, arg_name */
 #define DPMAC_CMD_GET_COUNTER(cmd, type) \
-   MC_CMD_OP(cmd, 1, 0,  64, enum dpmac_counter, type)
+   MC_CMD_OP(cmd, 0, 0,  8, enum dpmac_counter, type)
 
 /*cmd, param, offset, width, type, arg_name */
 #define DPMAC_RSP_GET_COUNTER(cmd, counter) \
-- 
2.25.1



[PATCH 0/6] Add the 'net stats' command to dump network statistics

2023-05-23 Thread Ioana Ciornei
This patch set extends the 'net' command so that it can be used to dump
network statistics on the available devices. The first user of this new
API is the ldpaa_eth driver which, in the last patch, implements the 3
new callbacks added.

Since the ldpaa_eth driver already had some debug printing of counters,
the first 4 patches are there to extend the existing list of counters
and to reorganize the code so that it fits better with the new eth_ops
callbacks.

Ioana Ciornei (6):
  net: ldpaa_eth: fix the memory layout of the dpmac_get_counters() API
  net: ldpaa_eth: transform dpni_statistics from a struct to a union
  net: ldpaa_eth: extend debug capabilities with DPNI statistics
  net: ldpaa_eth: extend debug capabilities with DPMAC statistics
  cmd: net: add a 'net stats' command to dump network statistics
  net: ldpaa_eth: export DPNI and DPMAC counters through 'net stats'

 cmd/net.c |  54 ++-
 drivers/net/fsl-mc/dpni.c |   2 +-
 drivers/net/ldpaa_eth/ldpaa_eth.c | 248 +++---
 drivers/net/ldpaa_eth/ldpaa_eth.h |  64 
 include/fsl-mc/fsl_dpmac.h|   7 +-
 include/fsl-mc/fsl_dpni.h | 143 -
 include/net.h |   6 +
 7 files changed, 353 insertions(+), 171 deletions(-)

-- 
2.25.1



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

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

Signed-off-by: Stefan Roese 
Cc: Simon Glass 
Cc: Pali Rohár 
Cc: Bin Meng 
Cc: Michal Simek 
---
 MAINTAINERS   |   1 +
 drivers/pci/Kconfig   |   7 +
 drivers/pci/Makefile  |   1 +
 drivers/pci/pcie-xilinx-nwl.c | 374 ++
 4 files changed, 383 insertions(+)
 create mode 100644 drivers/pci/pcie-xilinx-nwl.c

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

[PATCH v5 4/5] firmware: zynqmp: Move permission to change config object message

2023-05-23 Thread Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier 

Move the permission to change a config object message from
zynqmp_pmufw_load_config_object function to zynqmp_pmufw_node function
to simplify the code and check the permission only if required.

Signed-off-by: Stefan Herbrechtsmeier 

---

Changes in v5:
- Return 0 in case of no permission to change config object in
  zynqmp_pmufw_node to keep old behavior.
- Reword and unify static variable names.
- Initialize static variables with 'true' to store them in data section
  to make them usable before relocation.

Changes in v4:
- Reword
- Move the check back to zynqmp_pmufw_node because the check need to be
  run after the config object load.
- Return error in zynqmp_pmufw_config_close and zynqmp_pmufw_node.

Changes in v3:
- Added

 drivers/firmware/firmware-zynqmp.c | 34 ++
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/firmware/firmware-zynqmp.c 
b/drivers/firmware/firmware-zynqmp.c
index ca3a0b55c9..e1abfb4cec 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -63,29 +63,32 @@ static unsigned int xpm_configobject_close[] = {
 
 int zynqmp_pmufw_config_close(void)
 {
-   zynqmp_pmufw_load_config_object(xpm_configobject_close,
-   sizeof(xpm_configobject_close));
-   return 0;
+   return zynqmp_pmufw_load_config_object(xpm_configobject_close,
+  sizeof(xpm_configobject_close));
 }
 
 int zynqmp_pmufw_node(u32 id)
 {
-   static bool skip_config;
-   int ret;
+   static bool check = true;
+   static bool permission = true;
+
+   if (check) {
+   check = false;
+
+   if (zynqmp_pmufw_node(NODE_OCM_BANK_0) == -EACCES) {
+   printf("PMUFW:  No permission to change config 
object\n");
+   permission = false;
+   }
+   }
 
-   if (skip_config)
+   if (!permission)
return 0;
 
/* Record power domain id */
xpm_configobject[NODE_ID_LOCATION] = id;
 
-   ret = zynqmp_pmufw_load_config_object(xpm_configobject,
- sizeof(xpm_configobject));
-
-   if (ret == -EACCES && id == NODE_OCM_BANK_0)
-   skip_config = true;
-
-   return 0;
+   return zynqmp_pmufw_load_config_object(xpm_configobject,
+  sizeof(xpm_configobject));
 }
 
 static int do_pm_probe(void)
@@ -250,8 +253,6 @@ int zynqmp_pmufw_load_config_object(const void *cfg_obj, 
size_t size)
err = xilinx_pm_request(PM_SET_CONFIGURATION, (u32)(u64)cfg_obj, 0, 0,
0, ret_payload);
if (err == XST_PM_NO_ACCESS) {
-   if (((u32 *)cfg_obj)[NODE_ID_LOCATION] == NODE_OCM_BANK_0)
-   printf("PMUFW:  No permission to change config 
object\n");
return -EACCES;
}
 
@@ -295,9 +296,6 @@ static int zynqmp_power_probe(struct udevice *dev)
   ret >> ZYNQMP_PM_VERSION_MAJOR_SHIFT,
   ret & ZYNQMP_PM_VERSION_MINOR_MASK);
 
-   if (IS_ENABLED(CONFIG_ARCH_ZYNQMP))
-   zynqmp_pmufw_node(NODE_OCM_BANK_0);
-
return 0;
 };
 
-- 
2.30.2



[PATCH v5 5/5] firmware: zynqmp: Store driver data in data section

2023-05-23 Thread Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier 

Store the driver data in the data section to make the data usable before
relocation. Additionally mark the driver data static to restrict the
access.

Signed-off-by: Stefan Herbrechtsmeier 
---

Changes in v5:
- Added

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

diff --git a/drivers/firmware/firmware-zynqmp.c 
b/drivers/firmware/firmware-zynqmp.c
index e1abfb4cec..74d1b67541 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -23,10 +23,10 @@
 #define XST_PM_NO_ACCESS   2002L
 #define XST_PM_ALREADY_CONFIGURED  2009L
 
-struct zynqmp_power {
+static struct zynqmp_power {
struct mbox_chan tx_chan;
struct mbox_chan rx_chan;
-} zynqmp_power = {};
+} zynqmp_power __section(".data");
 
 #define NODE_ID_LOCATION   5
 
-- 
2.30.2



[PATCH v5 1/5] firmware: zynqmp: Remove extraordinary return value

2023-05-23 Thread Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier 

Return a common -EACCES error value instead of a positive private error
value XST_PM_NO_ACCESS (2002) in zynqmp_pmufw_load_config_object
function if the config object is not loadable to simplify the error
checking.

Signed-off-by: Stefan Herbrechtsmeier 
---

(no changes since v3)

Changes in v3:
- Rebase

Changes in v2:
- Use macro for node id

 drivers/firmware/firmware-zynqmp.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/firmware-zynqmp.c 
b/drivers/firmware/firmware-zynqmp.c
index dc8e3ad2b9..2b1ad5d2c3 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -82,7 +82,7 @@ int zynqmp_pmufw_node(u32 id)
ret = zynqmp_pmufw_load_config_object(xpm_configobject,
  sizeof(xpm_configobject));
 
-   if (ret == XST_PM_NO_ACCESS && id == NODE_OCM_BANK_0)
+   if (ret == -EACCES && id == NODE_OCM_BANK_0)
skip_config = true;
 
return 0;
@@ -235,8 +235,7 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const 
u32 id)
  *
  * @cfg_obj: Pointer to the configuration object
  * @size:Size of @cfg_obj in bytes
- * Return:   0 on success otherwise negative errno. If the config object
- *   is not loadable returns positive errno XST_PM_NO_ACCESS(2002)
+ * Return:   0 on success otherwise negative errno.
  */
 int zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size)
 {
@@ -251,10 +250,8 @@ int zynqmp_pmufw_load_config_object(const void *cfg_obj, 
size_t size)
err = xilinx_pm_request(PM_SET_CONFIGURATION, (u32)(u64)cfg_obj, 0, 0,
0, ret_payload);
if (err == XST_PM_NO_ACCESS) {
-   if (((u32 *)cfg_obj)[NODE_ID_LOCATION] == NODE_OCM_BANK_0) {
+   if (((u32 *)cfg_obj)[NODE_ID_LOCATION] == NODE_OCM_BANK_0)
printf("PMUFW:  No permission to change config 
object\n");
-   return err;
-   }
return -EACCES;
}
 
-- 
2.30.2



[PATCH v5 3/5] power: zynqmp: Mask node already configured error

2023-05-23 Thread Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier 

Do not return an error (ENODEV) from the request function if the node is
already configured.

Signed-off-by: Stefan Herbrechtsmeier 

---

Changes in v5:
- Added

 drivers/power/domain/zynqmp-power-domain.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/power/domain/zynqmp-power-domain.c 
b/drivers/power/domain/zynqmp-power-domain.c
index adbbb5fdd9..5ee9e020fb 100644
--- a/drivers/power/domain/zynqmp-power-domain.c
+++ b/drivers/power/domain/zynqmp-power-domain.c
@@ -23,12 +23,17 @@ static int zynqmp_pm_request_node(const u32 node, const u32 
capabilities,
 
 static int zynqmp_power_domain_request(struct power_domain *power_domain)
 {
+   int ret = 0;
+
dev_dbg(power_domain->dev, "Request for id: %ld\n", power_domain->id);
 
-   if (IS_ENABLED(CONFIG_ARCH_ZYNQMP))
-   return zynqmp_pmufw_node(power_domain->id);
+   if (IS_ENABLED(CONFIG_ARCH_ZYNQMP)) {
+   ret = zynqmp_pmufw_node(power_domain->id);
+   if (ret == -ENODEV)
+   ret = 0;
+   }
 
-   return 0;
+   return ret;
 }
 
 static int zynqmp_power_domain_free(struct power_domain *power_domain)
-- 
2.30.2



[PATCH v5 2/5] firmware: zynqmp: Remove redundant child device bind

2023-05-23 Thread Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier 

Remove the redundant child device bind from the driver bind function and
rely on the post_bind of the class which calls the same function.

Signed-off-by: Stefan Herbrechtsmeier 

---

Changes in v5:
- Added

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

diff --git a/drivers/firmware/firmware-zynqmp.c 
b/drivers/firmware/firmware-zynqmp.c
index 2b1ad5d2c3..ca3a0b55c9 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -395,7 +395,7 @@ static int zynqmp_firmware_bind(struct udevice *dev)
}
}
 
-   return dm_scan_fdt_dev(dev);
+   return 0;
 }
 
 U_BOOT_DRIVER(zynqmp_firmware) = {
-- 
2.30.2



Re: Issues with bcm2835-host: let firmware manage the clock divisor

2023-05-23 Thread Stefan Wahren

Hi Nuno,

Am 15.05.23 um 10:13 schrieb Nuno Gonçalves:
On Sun, May 14, 2023 at 7:54 PM Stefan Wahren > wrote:


Yes, this is very likely. But how can U-Boot assume that at least Linux
is booting afterwards. How about the other OSes with devicetree support?


I don't know what other OSes the patch author have tested it and if 
there was any good argument for breaking Linux Mainline.


sorry, the question wasn't actually for you, since you just reported the 
issue. There is never a good argument to break Linux Mainline, 
especially the Raspberry Pi folks don't support for U-Boot.


Because we stuck in this discussion, can you please provide more 
information to reproduce this issue?


What is the exact behavior based on debug UART and LED when Linux fails 
to start from eMMC (timeout, SoC lockup, ...)?


Does your boot setup (U-Boot) based on Device tree (Mainline or RPF) or EFI?

Which Raspberry firmware version are you using?

What settings of config.txt do you use?

Are you able to reproduce this issue on other RPi variants?

Best regards



Thanks,
Nuno


[PATCH 1/2] imx: spl_imx_romapi: avoid tricky use of spl_load_simple_fit() to get full FIT size

2023-05-23 Thread Rasmus Villemoes
Currently, spl_imx_romapi uses a somewhat tricky workaround for the
fact that a FIT image with external data doesn't directly allow one to
know the full size of the file: It does a dummy spl_load_simple_fit(),
having the ->read callback remember the largest offset requested, and
then does a last call to rom_api_download_image() to fetch the
remaining part of the full FIT image.

We can avoid that by just keeping track of how much we have downloaded
already, and if the ->read() requests something outside the current
valid buffer, fetch up to the end of the current request.

The current method also suffers from not working when CONFIG_IMX_HAB
is enabled, because the first call of spl_load_simple_fit() will have
written garbage to the various locations, so the
board_spl_fit_post_load() call panics. The downstream NXP kernel
carries a workaround for this, but that workaround should not be
necessary with this, since we only ever memcpy() valid image data.

This only affects the CONFIG_SPL_LOAD_FIT case - I don't have any
hardware or experience with the CONFIG_SPL_LOAD_IMX_CONTAINER case, so
I leave that alone for now.

Signed-off-by: Rasmus Villemoes 
---
 arch/arm/mach-imx/spl_imx_romapi.c | 50 ++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/mach-imx/spl_imx_romapi.c 
b/arch/arm/mach-imx/spl_imx_romapi.c
index 830d5d12c2..e4e2297ac0 100644
--- a/arch/arm/mach-imx/spl_imx_romapi.c
+++ b/arch/arm/mach-imx/spl_imx_romapi.c
@@ -126,6 +126,41 @@ static int spl_romapi_load_image_seekable(struct 
spl_image_info *spl_image,
return 0;
 }
 
+struct stream_state {
+   u8 *base;
+   u8 *end;
+   u32 pagesize;
+};
+
+static ulong spl_romapi_read_stream(struct spl_load_info *load, ulong sector,
+  ulong count, void *buf)
+{
+   struct stream_state *ss = load->priv;
+   u8 *end = (u8*)(sector + count);
+   u32 bytes;
+   int ret;
+
+   if (end > ss->end) {
+   bytes = end - ss->end;
+   bytes += ss->pagesize - 1;
+   bytes /= ss->pagesize;
+   bytes *= ss->pagesize;
+
+   debug("downloading another 0x%x bytes\n", bytes);
+   ret = rom_api_download_image(ss->end, 0, bytes);
+
+   if (ret != ROM_API_OKAY) {
+   printf("Failure download %d\n", bytes);
+   return 0;
+   }
+
+   ss->end = end;
+   }
+
+   memcpy(buf, (void *)(sector), count);
+   return count;
+}
+
 static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
   ulong count, void *buf)
 {
@@ -309,6 +344,21 @@ static int spl_romapi_load_image_stream(struct 
spl_image_info *spl_image,
}
}
 
+   if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+   struct stream_state ss;
+
+   ss.base = phdr;
+   ss.end = p;
+   ss.pagesize = pagesize;
+
+   memset(, 0, sizeof(load));
+   load.bl_len = 1;
+   load.read = spl_romapi_read_stream;
+   load.priv = 
+
+   return spl_load_simple_fit(spl_image, , (ulong)phdr, phdr);
+   }
+
total = img_total_size(phdr);
total += 3;
total &= ~0x3;
-- 
2.37.2



[PATCH 2/2] imx: spl_imx_romapi.c: remove dead code

2023-05-23 Thread Rasmus Villemoes
These IS_ENABLED(CONFIG_SPL_LOAD_FIT) cases can no longer be reached,
and thus get_fit_image_size() is also redundant.

Signed-off-by: Rasmus Villemoes 
---
 arch/arm/mach-imx/spl_imx_romapi.c | 25 ++---
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/arch/arm/mach-imx/spl_imx_romapi.c 
b/arch/arm/mach-imx/spl_imx_romapi.c
index e4e2297ac0..d34102990f 100644
--- a/arch/arm/mach-imx/spl_imx_romapi.c
+++ b/arch/arm/mach-imx/spl_imx_romapi.c
@@ -177,23 +177,6 @@ static ulong spl_ram_load_read(struct spl_load_info *load, 
ulong sector,
return count;
 }
 
-static ulong get_fit_image_size(void *fit)
-{
-   struct spl_image_info spl_image;
-   struct spl_load_info spl_load_info;
-   ulong last = (ulong)fit;
-
-   memset(_load_info, 0, sizeof(spl_load_info));
-   spl_load_info.bl_len = 1;
-   spl_load_info.read = spl_ram_load_read;
-   spl_load_info.priv = 
-
-   spl_load_simple_fit(_image, _load_info,
-   (uintptr_t)fit, fit);
-
-   return last - (ulong)fit;
-}
-
 static u8 *search_fit_header(u8 *p, int size)
 {
int i;
@@ -254,9 +237,7 @@ static int img_info_size(void *img_hdr)
 
 static int img_total_size(void *img_hdr)
 {
-   if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
-   return get_fit_image_size(img_hdr);
-   } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) {
+   if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) {
int total = get_container_size((ulong)img_hdr, NULL);
 
if (total < 0) {
@@ -379,9 +360,7 @@ static int spl_romapi_load_image_stream(struct 
spl_image_info *spl_image,
load.bl_len = 1;
load.read = spl_ram_load_read;
 
-   if (IS_ENABLED(CONFIG_SPL_LOAD_FIT))
-   return spl_load_simple_fit(spl_image, , (ulong)phdr, phdr);
-   else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER))
+   if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER))
return spl_load_imx_container(spl_image, , (ulong)phdr);
 
return -1;
-- 
2.37.2



Re: [PATCH v4 1/7] dt-bindings: clock: Add StarFive JH7110 PLL clock generator

2023-05-23 Thread Conor Dooley
On Tue, May 23, 2023 at 01:10:06PM +0200, Torsten Duwe wrote:
> On Tue, 23 May 2023 09:28:39 +0100
> Conor Dooley  wrote:
> 
> > On Tue, May 23, 2023 at 10:56:43AM +0800, Xingyu Wu wrote:
> > > On 2023/5/19 22:16, Conor Dooley wrote:
> > > > On Fri, May 19, 2023 at 03:57:33PM +0200, Torsten Duwe wrote:
> > > >> On Fri, May 12, 2023 at 10:20:30AM +0800, Xingyu Wu wrote:
> > > >> [...]
> 
> > > >> > +/* PLL clocks */
> > > >> > +#define JH7110_CLK_PLL0_OUT 0
> > > >> > +#define JH7110_CLK_PLL1_OUT 1
> > > >> > +#define JH7110_CLK_PLL2_OUT 2
> > > >> 
> > > >> In U-Boot commit 58c9c60b Yanhong Wang added:
> > > >> 
> > > >> +
> > > >> +#define JH7110_SYSCLK_PLL0_OUT   190
> > > >> +#define JH7110_SYSCLK_PLL1_OUT   191
> > > >> +#define JH7110_SYSCLK_PLL2_OUT   192
> > > >> +
> > > >> +#define JH7110_SYSCLK_END193
> [...]
> > > > Ohh, that's not good.. If you pass the U-Boot dtb to Linux it
> > > > won't understand the numbering. The headers are part of the
> > > > dt-binding :/
> 
> In fact, the clock index >= 190 makes linux hang on boot, waiting with
> EPROBE_DEFER for every device's clock, because the sysclk driver errors
> out with EINVAL (jh7110_sysclk_get()).

Yup, that's about what I expected to happen.

> > > Because PLL driver is separated from SYSCRG drivers in Linux, the
> > > numbering starts from 0. But in Uboot, the PLL driver is included
> > > in the SYSCRG driver, and the number follows the SYSCRG.
> > 
> > Unfortunately, how you choose to construct your drivers has nothing to
> > do with this.
> > These defines/numbers appear in the dts and are part of the DT ABI.
> > The same dts is supposed to work for Linux & U-Boot.
> 
> The JH7110 has 6 blocks of 64k iomem in that functional area:
> {SYS,STG,AON} x {CRG,SYSCON}. None of these has 190 clocks.
> The good news: the current DTS, as proposed here and in U-Boot master,
> provides nodes for all 6 entities. The bad news is that the clock
> assignments to those nodes and their numbering is messed up.
> 
> AFAICT PLL{0,1,2} _are_ generated in SYS_SYSCON and thus U-Boot gets it
> wrong, in addition to the erroneous DTS.

The numbers are kinda hocus-pocus anyway, they are just made up since the
clock numbering usually isn't something with a nice TRM to go and
reference (unlike interrupts which usually are documented in that way).
It is very helpful to make them aligned some register/bit positions or,
but that is not required.
IOW U-Boot is not wrong per se to use 190 instead of 0, but it is wrong
to have different numbers in both places.

It sounds like you're saying that (and I have not looked) the U-Boot dts
actually has structural difference w.r.t. what provides which clock?
If so, that'll need to be fixed independently of the numbering problem.

Otherwise Xingyu & Yanhong should coordinate on which is the "correct"
way of doing things & do it in both places.

Thanks,
Conor.


signature.asc
Description: PGP signature


[PATCH] arm: dts: k3-j721e: Remove ti,strobe-sel

2023-05-23 Thread Neha Malcom Francis
HS400 speed mode is not supported for sdhci0 (eMMC) for J721E (errata of
J721E: (i2024) 'MMCSD: Peripherals Do Not Support HS400'[1]). Thus,
remove ti,strobe-sel property which is needed only for HS400 speed mode.
This also helps sync kernel dts with u-boot dts.

[1] https://www.ti.com/lit/er/sprz455/sprz455.pdf

Fixes: e64665fa727e ("arm: dts: k3-j721e-main: Update the speed modes
supported and their itap delay values for MMCSD subsystems")
Signed-off-by: Bhavya Kapoor 
Signed-off-by: Neha Malcom Francis 
---
 arch/arm/dts/k3-j721e-main.dtsi | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/dts/k3-j721e-main.dtsi b/arch/arm/dts/k3-j721e-main.dtsi
index cf3482376c..7dc6f923d1 100644
--- a/arch/arm/dts/k3-j721e-main.dtsi
+++ b/arch/arm/dts/k3-j721e-main.dtsi
@@ -1049,7 +1049,6 @@
ti,itap-del-sel-mmc-hs = <0xa>;
ti,itap-del-sel-ddr52 = <0x3>;
ti,trm-icp = <0x8>;
-   ti,strobe-sel = <0x77>;
dma-coherent;
};
 
-- 
2.34.1



[PATCH 4/4] configs: j7200_evm_r5: Add ESM config for J7200

2023-05-23 Thread Neha Malcom Francis
Add CONFIG_ESM_K3 to enable ESM initialization in J7200.

Signed-off-by: Neha Malcom Francis 
---
 configs/j7200_evm_r5_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/j7200_evm_r5_defconfig b/configs/j7200_evm_r5_defconfig
index e149ccb9a4..b846f830c5 100644
--- a/configs/j7200_evm_r5_defconfig
+++ b/configs/j7200_evm_r5_defconfig
@@ -168,3 +168,4 @@ CONFIG_FS_EXT4=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
 CONFIG_LIB_RATIONAL=y
 CONFIG_SPL_LIB_RATIONAL=y
+CONFIG_ESM_K3=y
-- 
2.34.1



[PATCH 3/4] board: ti: j721e: initialize ESM support for J7200 SOM

2023-05-23 Thread Neha Malcom Francis
From: Gowtham Tammana 

ESM support is available for J7200X-PM2-SOM board, as such enable
support for it.

Signed-off-by: Gowtham Tammana 
Signed-off-by: Neha Malcom Francis 
---
 board/ti/j721e/evm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
index 2398bead78..90c339fcad 100644
--- a/board/ti/j721e/evm.c
+++ b/board/ti/j721e/evm.c
@@ -543,7 +543,8 @@ void spl_board_init(void)
}
 
 #ifdef CONFIG_ESM_K3
-   if (board_ti_k3_is("J721EX-PM2-SOM")) {
+   if (board_ti_k3_is("J721EX-PM2-SOM") ||
+   board_ti_k3_is("J7200X-PM2-SOM")) {
ret = uclass_get_device_by_driver(UCLASS_MISC,
  DM_DRIVER_GET(k3_esm), );
if (ret)
-- 
2.34.1



[PATCH 2/4] arm: dts: k3-j7200: Add Main domain ESM support

2023-05-23 Thread Neha Malcom Francis
From: Gowtham Tammana 

Main domain ESM support is needed to configure main domain watchdog
interrupts to generate ESM pin events. On J7200 boards ESM error pin
output is propagated to PMIC to generate reset.

Signed-off-by: Gowtham Tammana 
Signed-off-by: Neha Malcom Francis 
---
 arch/arm/dts/k3-j7200-main.dtsi | 7 +++
 arch/arm/dts/k3-j7200.dtsi  | 1 +
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/dts/k3-j7200-main.dtsi b/arch/arm/dts/k3-j7200-main.dtsi
index e8a41d09b4..d8db2d2d01 100644
--- a/arch/arm/dts/k3-j7200-main.dtsi
+++ b/arch/arm/dts/k3-j7200-main.dtsi
@@ -774,4 +774,11 @@
ti,loczrama = <1>;
};
};
+
+   main_esm: esm@70 {
+   compatible = "ti,j721e-esm";
+   reg = <0x0 0x70 0x0 0x1000>;
+   ti,esm-pins = <656>, <657>;
+   bootph-pre-ram;
+   };
 };
diff --git a/arch/arm/dts/k3-j7200.dtsi b/arch/arm/dts/k3-j7200.dtsi
index b7005b8031..9252d97399 100644
--- a/arch/arm/dts/k3-j7200.dtsi
+++ b/arch/arm/dts/k3-j7200.dtsi
@@ -124,6 +124,7 @@
#size-cells = <2>;
ranges = <0x00 0x0010 0x00 0x0010 0x00 0x0002>, /* 
ctrl mmr */
 <0x00 0x0060 0x00 0x0060 0x00 0x00031100>, /* 
GPIO */
+<0x00 0x0070 0x00 0x0070 0x00 0x1000>, /* 
ESM */
 <0x00 0x00a4 0x00 0x00a4 0x00 0x0800>, /* 
timesync router */
 <0x00 0x0100 0x00 0x0100 0x00 0x0d00>, /* 
Most peripherals */
 <0x00 0x3000 0x00 0x3000 0x00 0x0c40>, /* 
MAIN NAVSS */
-- 
2.34.1



[PATCH 1/4] arm: dts: k3-j721e: Refine MAIN domain ESM support

2023-05-23 Thread Neha Malcom Francis
MAIN domain ESM support was already added for J721E to configure main
domain watchdog interrupts to generate ESM pin events. Move the main_esm
node to be in sync with kernel dts. Also add register mapping for ESM in
J721E.

Signed-off-by: Neha Malcom Francis 
---
 arch/arm/dts/k3-j721e-main.dtsi| 7 +++
 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 9 -
 arch/arm/dts/k3-j721e.dtsi | 1 +
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/arm/dts/k3-j721e-main.dtsi b/arch/arm/dts/k3-j721e-main.dtsi
index cf3482376c..2142f9c163 100644
--- a/arch/arm/dts/k3-j721e-main.dtsi
+++ b/arch/arm/dts/k3-j721e-main.dtsi
@@ -1940,4 +1940,11 @@
bus_freq = <100>;
};
};
+
+   main_esm: esm@70 {
+   compatible = "ti,j721e-esm";
+   reg = <0x0 0x70 0x0 0x1000>;
+   ti,esm-pins = <344>, <345>;
+   bootph-pre-ram;
+   };
 };
diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts 
b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts
index 1b40cf2580..376d511446 100644
--- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts
+++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts
@@ -88,15 +88,6 @@
};
 };
 
-_main {
-   main_esm: esm@70 {
-   compatible = "ti,j721e-esm";
-   reg = <0x0 0x70 0x0 0x1000>;
-   ti,esm-pins = <344>, <345>;
-   bootph-pre-ram;
-   };
-};
-
  {
mboxes= <_secproxy 8>, <_secproxy 6>, <_secproxy 5>;
mbox-names = "tx", "rx", "notify";
diff --git a/arch/arm/dts/k3-j721e.dtsi b/arch/arm/dts/k3-j721e.dtsi
index f0587fde14..d7f73f61db 100644
--- a/arch/arm/dts/k3-j721e.dtsi
+++ b/arch/arm/dts/k3-j721e.dtsi
@@ -126,6 +126,7 @@
#size-cells = <2>;
ranges = <0x00 0x0010 0x00 0x0010 0x00 0x0002>, /* 
ctrl mmr */
 <0x00 0x0060 0x00 0x0060 0x00 0x00031100>, /* 
GPIO */
+<0x00 0x0070 0x00 0x0070 0x00 0x1000>, /* 
ESM */
 <0x00 0x0090 0x00 0x0090 0x00 0x00012000>, /* 
serdes */
 <0x00 0x00a4 0x00 0x00a4 0x00 0x0800>, /* 
timesync router */
 <0x00 0x0600 0x00 0x0600 0x00 0x0040>, /* 
USBSS0 */
-- 
2.34.1



[PATCH 0/4] ESM support for J721E and J7200

2023-05-23 Thread Neha Malcom Francis
Add support for ESM (Error Signalling Module) in J721E and J7200. The
ESM error pin output is routed to the PMIC (Power Management IC) which
can reset the board. The dts nodes for SoC ESM modules are added (if
not already) to enable them.

Gowtham Tammana (2):
  arm: dts: k3-j7200: Add Main domain ESM support
  board: ti: j721e: initialize ESM support for J7200 SOM

Neha Malcom Francis (2):
  arm: dts: k3-j721e: Refine MAIN domain ESM support
  configs: j7200_evm_r5: Add ESM config for J7200

 arch/arm/dts/k3-j7200-main.dtsi| 7 +++
 arch/arm/dts/k3-j7200.dtsi | 1 +
 arch/arm/dts/k3-j721e-main.dtsi| 7 +++
 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 9 -
 arch/arm/dts/k3-j721e.dtsi | 1 +
 board/ti/j721e/evm.c   | 3 ++-
 configs/j7200_evm_r5_defconfig | 1 +
 7 files changed, 19 insertions(+), 10 deletions(-)

-- 
2.34.1



Re: [RFC PATCH 10/10] arm: migrate away from sections.c

2023-05-23 Thread Ilias Apalodimas
On Sat, May 20, 2023 at 02:55:47PM -0600, Sam Edwards wrote:
> This patch effectively reverts 3ebd1cbc49f0005092d69cf0d9a6e64d7a1c300b.

Also 47bd65ef057fb71b02b32741d5cfcaf03e2f0918 ?

>
> The approach taken in that commit was to have the section-marking
> symbols generated into empty sections by the compiler, for the linker
> script to include at the correct location. The rationale was that at
> the time, the linker considered linker-assigned symbols to be dynamic
> when they were in PIC (PIEs or shared libraries), which meant they were
> represented at runtime by a R_ARM_ABS32 relocation (by symbol name)
> rather than by M_ARM_RELATIVE.
>
> That commit landed in March 2013, but GNU ld later changed its behavior
> on 2016-02-23 to default linker-assigned symbols to dynamic only in
> shared libraries (not PIE), so this approach is unnecessary.
>
> I am removing it, because:
> 1) It required keeping sections.c in sync with multiple linker scripts.
> 2) It added complexity to the linker scripts, making them less readable.
> 3) It added unnecessary sections to the output, which can't be merged
>because the sections are sometimes of different types.
> 4) The linker may insert sections not explicitly named in the script
>somewhere between explicit sections; having the marker symbols
>outside of the sections they were marking meant the markers could
>end up with an unintended section inserted within that region.
>
> Signed-off-by: Sam Edwards 
> Cc: Albert ARIBAUD 
>

 Thanks
 /Ilias


Re: [RFC PATCH 00/10] Improve ARM target's support for LLVM toolchain

2023-05-23 Thread Ilias Apalodimas
On Mon, May 22, 2023 at 01:37:26PM -0600, Sam Edwards wrote:
> Hi Ilias,
>
> On 5/22/23 00:52, Ilias Apalodimas wrote:
> > I can help clean up the arm architecture even further.  I was toying
> > with the idea of having page-aligned sections and eventually map
> > u-boot with proper permissions per section.  Right now (at least for
> > the majority of arm platforms) we are doing RWX for all the memory,
> > apart from devices that are mapped as RW. I do have an awfully hacky
> > PoC around, but the linker script cleanup is more than welcome.
>
> Glad to hear it (and excited by the idea of proper W^X)!

Yes that's my end goal here.  Looking around the code we have in U-Boot
regarding the mmu configuration, it's a lot easier (and cleaner) to fix
the linker script, add symbols for ro_start, rw_start etc and layout the
binary in a way we can easily map it, instead of leaving it as is and try
to fix the mapping in c code.

> The linker script
> cleanup (i.e. deleting those pesky `sections.c` files and going back to
> linker-assigned symbols) can really happen whenever; it won't cause a
> problem on any version of GNU ld from <7 years ago. Perhaps a series of
> patches (one per arch) doing that should be landed first?

Yes probably, because I specifically remember digging through the history
of why the sections were defined like that in the first place.

>
> > It's probably not a mailing list issue.  I only got the efi related
> > patches on my mailbox.  The recipients were generated with
> > get_maintainers.pl?  Heinirch and I only received the efi* portions as
> > we maintain that subsystem
>
> Well, it's true that you and Heinrich weren't Cc: on every email in the
> series. I just went with patman's default behavior.
>
> But every patch was sent To: the u-boot list, and I do see the whole series
> showing up on the archive. Did you not even receive the other patches in the
> series via the list?
>
> Cheers,
> Sam

Cheers
/Ilias


Re: [PATCH v3 2/3] Boot var automatic management for removable medias

2023-05-23 Thread Ilias Apalodimas
On Tue, May 16, 2023 at 10:17:14AM -0400, Raymond Mao wrote:
> Hi Ilias,
>
> On Tue, 16 May 2023 at 01:59, Ilias Apalodimas 
> wrote:
>
> > On Tue, May 02, 2023 at 12:12:19PM -0700, Raymond Mao wrote:
> > > Changes for complying to EFI spec §3.5.1.1
> > > 'Removable Media Boot Behavior'.
> > > Boot variables can be automatically generated during a removable
> > > media is probed. At the same time, unused boot variables will be
> > > detected and removed.
> > >
> > > Signed-off-by: Raymond Mao 
> > > ---
> > > Changes in v2
> > > - Ignore EFI_NOT_FOUND returned from
> > >   efi_bootmgr_update_media_device_boot_option which means no boot
> > >   options scanned.
> > > Changes in v3
> > > - Split the patch into moving and renaming functions and
> > >   individual patches for each changed functionality
> > >
> > >  lib/efi_loader/efi_disk.c |  7 +++
> > >  lib/efi_loader/efi_variable.c | 10 +-
> > >  lib/efi_loader/efi_variable_tee.c |  5 +
> > >  3 files changed, 21 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> > > index d2256713a8..ca5f07f2ec 100644
> > > --- a/lib/efi_loader/efi_disk.c
> > > +++ b/lib/efi_loader/efi_disk.c
> > > @@ -687,6 +687,13 @@ int efi_disk_probe(void *ctx, struct event *event)
> > >   return -1;
> > >   }
> > >
> > > + /* only do the boot option management when UEFI sub-system is
> > initialized */
> > > + if (efi_obj_list_initialized == EFI_SUCCESS) {
> > > + ret = efi_bootmgr_update_media_device_boot_option();
> > > + if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
> > > + return -1;
> > > + }
> > > +
> > >   return 0;
> > >  }
> > >
> > > diff --git a/lib/efi_loader/efi_variable.c
> > b/lib/efi_loader/efi_variable.c
> > > index be95ed44e6..fe71144358 100644
> > > --- a/lib/efi_loader/efi_variable.c
> > > +++ b/lib/efi_loader/efi_variable.c
> > > @@ -476,6 +476,14 @@ efi_status_t efi_init_variables(void)
> > >   log_err("Invalid EFI variable seed\n");
> > >   }
> > >
> > > + ret = efi_init_secure_state();
> > > + if (ret != EFI_SUCCESS)
> > > + return ret;
> > >
> > > - return efi_init_secure_state();
> > > + /* update boot option management after variable service
> > initialized */
> > > + ret = efi_bootmgr_update_media_device_boot_option();
> > > + if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
> > > + return ret;
> > > +
> > > + return EFI_SUCCESS;
> > >  }
> > > diff --git a/lib/efi_loader/efi_variable_tee.c
> > b/lib/efi_loader/efi_variable_tee.c
> > > index dfef18435d..2995d4a583 100644
> > > --- a/lib/efi_loader/efi_variable_tee.c
> > > +++ b/lib/efi_loader/efi_variable_tee.c
> > > @@ -748,5 +748,10 @@ efi_status_t efi_init_variables(void)
> > >   if (ret != EFI_SUCCESS)
> > >   return ret;
> > >
> > > + /* update boot option management after variable service
> > initialized */
> > > + ret = efi_bootmgr_update_media_device_boot_option();
> > > + if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
> > > + return ret;
> >
> > You don't need this if, just return ret
> >
> We have to differentiate EFI_NOT_FOUND here for no removable medias are
> detected, otherwise efi_init_obj_list() will return failure if the return
> code of efi_init_variables() is not EFI_SUCCESS.
>

Ah fair enough.  This seems fine then, please resend the series with the
changes in patch #3

Thanks
/Ilias
> >
> > > +
> > >   return EFI_SUCCESS;
> > >  }
> > > --
> > > 2.25.1
> > >
> >
> > Regards
> > /Ilias
> >



Re: [PATCH] imx8m: soc.c: demote some printfs to debug

2023-05-23 Thread Peng Fan




On 5/22/2023 5:27 PM, Rasmus Villemoes wrote:

Getting

   Found /vpu_g1@3830 node
   Modify /vpu_g1@3830:status disabled
   Found /vpu_g2@3831 node
   Modify /vpu_g2@3831:status disabled

etc. on the console on every boot is needlessly verbose. Demote the
"Found ..." lines to debug(), which is consistent with other instances
in soc.c.

Signed-off-by: Rasmus Villemoes 


Reviewed-by: Peng Fan 


---
  arch/arm/mach-imx/imx8m/soc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index 5a4f8358c9..f5c82dff35 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -736,7 +736,7 @@ static int disable_fdt_nodes(void *blob, const char *const 
nodes_path[], int siz
if (nodeoff < 0)
continue; /* Not found, skip it */
  
-		printf("Found %s node\n", nodes_path[i]);

+   debug("Found %s node\n", nodes_path[i]);
  
  add_status:

rc = fdt_setprop(blob, nodeoff, "status", status, 
strlen(status) + 1);
@@ -1265,7 +1265,7 @@ int ft_system_setup(void *blob, struct bd_info *bd)
if (nodeoff >= 0) {
const char *speed = "high-speed";
  
-			printf("Found %s node\n", usb_dwc3_path[v]);

+   debug("Found %s node\n", usb_dwc3_path[v]);
  
  usb_modify_speed: