Re: [PATCH v2] fdt: automatically add /chosen/kaslr-seed if DM_RNG is enabled

2024-05-20 Thread Michal Simek




On 5/20/24 18:37, Tim Harvey wrote:

On Mon, May 20, 2024 at 1:29 AM Michal Simek  wrote:


Hi Tim,

On 5/16/24 17:58, Tim Harvey wrote:

On Wed, May 15, 2024 at 1:50 PM Tim Harvey  wrote:


If RANDOMIZE_BASE is enabled in the Linux kernel instructing it to
randomize the virtual address at which the kernel image is loaded, it
expects entropy to be provided by the bootloader by populating
/chosen/kaslr-seed with a 64-bit value from source of entropy at boot.

If we have DM_RNG enabled populate this value automatically when
fdt_chosen is called unless ARMV8_SEC_FIRMWARE_SUPPORT is enabled as
it's implementation uses a different source of entropy.

As this fdt node is added elsewhere create a library function and
use it to deduplicate code.

Note that the kalsrseed command (CMD_KASLRSEED) is likely pointless now
but left in place in case boot scripts exist that rely on this command
existing and returning success. An informational message is printed to
alert users of this command that it is likely no longer needed.

Signed-off-by: Tim Harvey 
---
v2:
   - fix typo in commit msg
   - use stack for seed to avoid unecessary malloc/free
   - move to a library function and deduplicate code by using it elsewhere
---
   board/xilinx/common/board.c | 35 -
   boot/fdt_support.c  | 10 +
   boot/pxe_utils.c| 35 +++--
   cmd/kaslrseed.c | 45 ++---
   include/kaslrseed.h | 17 ++
   lib/Makefile|  1 +
   lib/kaslrseed.c | 34 
   7 files changed, 72 insertions(+), 105 deletions(-)
   create mode 100644 include/kaslrseed.h
   create mode 100644 lib/kaslrseed.c

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 30a81376ac41..f741e8957818 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -713,41 +713,6 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS) && 
IS_ENABLED(CONFIG_NAND_ZYNQ))
  fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));

-   if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
-   debug("No RNG device\n");
-   return 0;
-   }
-
-   if (dm_rng_read(dev, buf, n)) {
-   debug("Reading RNG failed\n");
-   return 0;
-   }
-
-   if (!blob) {
-   debug("No FDT memory address configured. Please configure\n"
- "the FDT address via \"fdt addr \" command.\n"
- "Aborting!\n");
-   return 0;
-   }
-
-   ret = fdt_check_header(blob);
-   if (ret < 0) {
-   debug("fdt_chosen: %s\n", fdt_strerror(ret));
-   return ret;
-   }
-
-   nodeoffset = fdt_find_or_add_subnode(blob, 0, "chosen");
-   if (nodeoffset < 0) {
-   debug("Reading chosen node failed\n");
-   return nodeoffset;
-   }
-
-   ret = fdt_setprop(blob, nodeoffset, "kaslr-seed", buf, sizeof(buf));
-   if (ret < 0) {
-   debug("Unable to set kaslr-seed on chosen node: %s\n", 
fdt_strerror(ret));
-   return ret;
-   }
-
  return 0;
   }
   #endif
diff --git a/boot/fdt_support.c b/boot/fdt_support.c
index 874ca4d6f5af..3455d60d69dc 100644
--- a/boot/fdt_support.c
+++ b/boot/fdt_support.c
@@ -8,6 +8,7 @@

   #include 
   #include 
+#include 
   #include 
   #include 
   #include 
@@ -300,6 +301,15 @@ int fdt_chosen(void *fdt)
  if (nodeoffset < 0)
  return nodeoffset;

+   if (IS_ENABLED(CONFIG_DM_RNG) && 
!IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT)) {
+   err = fdt_kaslrseed(fdt);
+   if (err) {
+   printf("WARNING: could not set kaslr-seed %s.\n",
+  fdt_strerror(err));
+   return err;
+   }
+   }
+
  if (IS_ENABLED(CONFIG_BOARD_RNG_SEED) && !board_rng_seed(&buf)) {
  err = fdt_setprop(fdt, nodeoffset, "rng-seed",
abuf_data(&buf), abuf_size(&buf));
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 4b22bb6f525a..8d70233fc08d 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -8,6 +8,7 @@
   #include 
   #include 
   #include 
+#include 
   #include 
   #include 
   #include 
@@ -323,10 +324,6 @@ static void label_boot_kaslrseed(void)
   #if CONFIG_IS_ENABLED(DM_RNG)
  ulong fdt_addr;
  struct fdt_header *working_fdt;
-   size_t n = 0x8;
-   struct udevice *dev;
-   u64 *buf;
-   int nodeoffset;
  int err;

  /* Get the main fdt and map it */
@@ -342,35 +339,9 @@ static void label_boot_kaslrseed(void)
  if (err <= 0)
  return;

-   if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
-   printf("No RNG device\n

Re: [PATCH v2 3/3] cyclic: make clients embed a struct cyclic_info in their own data structure

2024-05-20 Thread Stefan Roese

On 5/19/24 21:44, Rasmus Villemoes wrote:

On 18/05/2024 09.34, Stefan Roese wrote:


This introduces some problems when compiling e.g. sandbox:

In file included from test/common/cyclic.c:10:
test/common/cyclic.c: In function ‘dm_test_cyclic_running’:
test/common/cyclic.c:25:42: warning: passing argument 1 of
‘cyclic_register’ from incompatible pointer type
[-Wincompatible-pointer-types]
    25 | ut_assertnonnull(cyclic_register(cyclic_test, 10 * 1000,
"cyclic_demo",
   |  ^~~
   |  |
   |  void (*)(void *)
include/test/ut.h:298:29: note: in definition of macro ‘ut_assertnonnull’

[...]


Could you please also change the test file accordingly? I'll then
try to get this upstream shortly.


Whoops, I don't know how I managed to miss that when grepping for users.
Sorry about that. Updated version coming shortly.


Thanks. Still the new version also fails in the CI build. I'm using
MS Azure for this, here the link to the failing build:

https://dev.azure.com/sr0718/u-boot/_build/results?buildId=355&view=results

Could you please make sure that CI fully builds?

BTW: Not sure if I still can pull this (updated version) in, since I'm
leaving for a 2 week vacation tomorrow morning.

Thanks,
Stefan


[PATCH v2] arm: dts: k3-j7200: Move to OF_UPSTREAM

2024-05-20 Thread Aniket Limaye
Move to using OF_UPSTREAM config and thus using the devicetree-rebasing
subtree.

Signed-off-by: Aniket Limaye 
---

Boot logs:
https://gist.github.com/aniket-l/aab91bb12d2495c54da094fca49c369f

Changes in v2:
- Rebased to next
- Removed dependency on binman templating series [1] as per [2]

[1]: https://lore.kernel.org/all/20240322131011.1029620-1-n-fran...@ti.com/
[2]: https://lore.kernel.org/u-boot/20240520095916.1809962-1-n-fran...@ti.com/

---
 arch/arm/dts/Makefile |1 -
 arch/arm/dts/k3-j7200-binman.dtsi |2 +-
 .../k3-j7200-common-proc-board-u-boot.dtsi|   14 +-
 arch/arm/dts/k3-j7200-common-proc-board.dts   |  396 -
 arch/arm/dts/k3-j7200-main.dtsi   | 1284 -
 arch/arm/dts/k3-j7200-mcu-wakeup.dtsi |  647 -
 arch/arm/dts/k3-j7200-som-p0.dtsi |  327 -
 arch/arm/dts/k3-j7200-thermal.dtsi|   47 -
 arch/arm/dts/k3-j7200.dtsi|  164 ---
 configs/j7200_evm_a72_defconfig   |3 +-
 10 files changed, 8 insertions(+), 2877 deletions(-)
 delete mode 100644 arch/arm/dts/k3-j7200-common-proc-board.dts
 delete mode 100644 arch/arm/dts/k3-j7200-main.dtsi
 delete mode 100644 arch/arm/dts/k3-j7200-mcu-wakeup.dtsi
 delete mode 100644 arch/arm/dts/k3-j7200-som-p0.dtsi
 delete mode 100644 arch/arm/dts/k3-j7200-thermal.dtsi
 delete mode 100644 arch/arm/dts/k3-j7200.dtsi

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index f7032f1e175..ea8fee8e25c 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1194,7 +1194,6 @@ dtb-$(CONFIG_SOC_K3_AM654) += \
 
 dtb-$(CONFIG_SOC_K3_J721E) += k3-j721e-common-proc-board.dtb \
  k3-j721e-r5-common-proc-board.dtb \
- k3-j7200-common-proc-board.dtb \
  k3-j7200-r5-common-proc-board.dtb \
  k3-j721e-sk.dtb \
  k3-j721e-r5-sk.dtb \
diff --git a/arch/arm/dts/k3-j7200-binman.dtsi 
b/arch/arm/dts/k3-j7200-binman.dtsi
index 06db8659876..b6e0aa37971 100644
--- a/arch/arm/dts/k3-j7200-binman.dtsi
+++ b/arch/arm/dts/k3-j7200-binman.dtsi
@@ -180,7 +180,7 @@
 
 #ifdef CONFIG_TARGET_J7200_A72_EVM
 
-#define SPL_J7200_EVM_DTB "spl/dts/k3-j7200-common-proc-board.dtb"
+#define SPL_J7200_EVM_DTB "spl/dts/ti/k3-j7200-common-proc-board.dtb"
 #define J7200_EVM_DTB "u-boot.dtb"
 
 &binman {
diff --git a/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi 
b/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi
index 485f17c5f06..045ef170e17 100644
--- a/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi
+++ b/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi
@@ -26,8 +26,12 @@
 &cbass_mcu_wakeup {
bootph-all;
 
-   chipid@4314 {
+   wkup_conf: bus@4300 {
bootph-all;
+
+   chipid: chipid@14 {
+   bootph-all;
+   };
};
 };
 
@@ -40,14 +44,6 @@
 };
 
 &mcu_udmap {
-   reg = <0x0 0x285c 0x0 0x100>,
-   <0x0 0x284c 0x0 0x4000>,
-   <0x0 0x2a80 0x0 0x4>,
-   <0x0 0x284a 0x0 0x4000>,
-   <0x0 0x2aa0 0x0 0x4>,
-   <0x0 0x2840 0x0 0x2000>;
-   reg-names = "gcfg", "rchan", "rchanrt", "tchan",
-   "tchanrt", "rflow";
bootph-all;
 };
 
diff --git a/arch/arm/dts/k3-j7200-common-proc-board.dts 
b/arch/arm/dts/k3-j7200-common-proc-board.dts
deleted file mode 100644
index cee2b4b0eb8..000
--- a/arch/arm/dts/k3-j7200-common-proc-board.dts
+++ /dev/null
@@ -1,396 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2020 Texas Instruments Incorporated - https://www.ti.com/
- */
-
-/dts-v1/;
-
-#include "k3-j7200-som-p0.dtsi"
-#include 
-#include 
-#include 
-
-#include "k3-serdes.h"
-
-/ {
-   compatible = "ti,j7200-evm", "ti,j7200";
-   model = "Texas Instruments J7200 EVM";
-
-   aliases {
-   serial0 = &wkup_uart0;
-   serial1 = &mcu_uart0;
-   serial2 = &main_uart0;
-   serial3 = &main_uart1;
-   serial5 = &main_uart3;
-   mmc0 = &main_sdhci0;
-   mmc1 = &main_sdhci1;
-   };
-
-   chosen {
-   stdout-path = "serial2:115200n8";
-   };
-
-   evm_12v0: fixedregulator-evm12v0 {
-   /* main supply */
-   compatible = "regulator-fixed";
-   regulator-name = "evm_12v0";
-   regulator-min-microvolt = <1200>;
-   regulator-max-microvolt = <1200>;
-   regulator-always-on;
-   regulator-boot-on;
-   };
-
-   vsys_3v3: fixedregulator-vsys3v3 {
-   /* Output of LM5140 */
-   compatible = "regulator-fixed";
-   regulator-name = "vsys_3v3";
-   regulator-min-microvolt = <330>;
-   regulator-ma

Re: [PATCH v2 10/10] arch: arm: dts: k3-am62-sk-u-boot: Add missing "bootph-all" property to phy_gmii_sel node

2024-05-20 Thread Chintan Vankar




On 20/05/24 17:43, Roger Quadros wrote:



On 20/05/2024 09:04, Chintan Vankar wrote:



On 25/04/24 18:06, Chintan Vankar wrote:



On 25/04/24 18:01, Roger Quadros wrote:



On 25/04/2024 15:08, Chintan Vankar wrote:

Add "bootph-all" property to CPSW MAC's PHY node phy_gmii_sel.

Signed-off-by: Chintan Vankar 
---

Changes from v1 to v2:
- This patch is newly added in this series to enable CPSW MAC's PHY
    node "phy_gmii_sel". As per discussion at here:
    https://lore.kernel.org/r/20240112130127.rvvrhz7p4vmlyalh@smother/
    changes made by this patch can be dropped in the future when the
    DT-Sync is performed with am62-main.dtsi containing this change in
    the Linux DT which will match U-Boot's DT.


I don't think bootph-all exists in am62-main.dtsi. It should come from
board.dts



Yes, I am having the same discussion at here:
https://lore.kernel.org/all/c13ac165-7cbd-4e53-914e-8c6bc2825...@ti.com/



Since I have posted patch which adds bootph-all property to
"k3-am62x-sk-common.dtsi" at here:
https://lore.kernel.org/r/20240430085048.3143665-1-c-van...@ti.com/
and it has no open comments and this series
also does not have any open comments, so can it be merged ?


Since bootph-all is being added to k3-am62x-sk-common.dtsi don't you have to 
drop patch 10
from this series?



Yes you are correct, but that patch is not merged yet.





   arch/arm/dts/k3-am625-sk-u-boot.dtsi | 4 
   1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
index fa778b0ff4..e9a1afde95 100644
--- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
@@ -46,3 +46,7 @@
   &cpsw_port2 {
   status = "disabled";
   };
+
+&phy_gmii_sel {
+    bootph-all;
+};






Re: [PATCH v2 06/10] arm: mach-k3: am625_init: Probe AM65 CPSW NUSS

2024-05-20 Thread Chintan Vankar




On 20/05/24 17:42, Roger Quadros wrote:



On 25/04/2024 15:59, Chintan Vankar wrote:



On 25/04/24 17:57, Roger Quadros wrote:



On 25/04/2024 15:08, Chintan Vankar wrote:

From: Kishon Vijay Abraham I 

In order to support Ethernet boot on AM62x, probe AM65 CPSW NUSS
driver in board_init_f().

Signed-off-by: Kishon Vijay Abraham I 
Signed-off-by: Siddharth Vadapalli 
Signed-off-by: Chintan Vankar 
---

Link to v1:
https://lore.kernel.org/r/20240112064759.1801600-8-s-vadapa...@ti.com/

Changes from v1 to v2:
- No changes.

   arch/arm/mach-k3/am625_init.c | 10 ++
   1 file changed, 10 insertions(+)

diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c
index 668f9a51ef..9bf61b1e83 100644
--- a/arch/arm/mach-k3/am625_init.c
+++ b/arch/arm/mach-k3/am625_init.c
@@ -277,6 +277,16 @@ void board_init_f(ulong dummy)
   if (ret)
   panic("DRAM init failed: %d\n", ret);
   }
+
+    if (IS_ENABLED(CONFIG_SPL_ETH) && IS_ENABLED(CONFIG_TI_AM65_CPSW_NUSS) &&
+    spl_boot_device() == BOOT_DEVICE_ETHERNET) {
+    struct udevice *cpswdev;
+
+    if (uclass_get_device_by_driver(UCLASS_MISC, 
DM_DRIVER_GET(am65_cpsw_nuss),
+    &cpswdev))
+    printf("Failed to probe am65_cpsw_nuss driver\n");
+    }
+


This looks like a HACK.
The network driver should be probed only when the networking feature is 
actually required.



Driver is probed only when the condition above
"spl_boot_device() == BOOT_DEVICE_ETHERNET" is true, which says Boot
device is Ethernet, and here we are booting with Ethernet so driver is
getting probed.


I think you misunderstood what I was saying as am625_init.c is not using
any Ethernet function it should not cause the Ethernet driver to probe.

Instead it should be probed by the networking use case.

What happens if you don't use this patch? Where is it failing?



You are correct that it should be probed by the networking use case and
we are using networking functionality of "Booting via Ethernet".
Regarding its probing, I already had discussion that why do I have to
probe it explicitly at here:
https://lore.kernel.org/r/ee1d16fd-b99b-4b07-97bb-a896e1791...@ti.com/

Now if I don't use this patch then Ethernet will not get initialized at
SPL stage, and in "spl_net_load_image()" function, there will be an
error saying "No Ethernet Found", and since we selected booting via
Ethernet it will fail to boot.




   spl_enable_cache();
     fixup_a53_cpu_freq_by_speed_grade();






Re: [PATCH 2/2 v4] board: starfive: support Pine64 Star64 board

2024-05-20 Thread E Shattow
Hi,

On Sun, May 19, 2024 at 9:43 PM H Bell  wrote:
>
> Add documentation files
>
> Signed-off-by: Henry Bell 
> Cc: ycli...@andestech.com
> Cc: heinrich.schucha...@canonical.com
> ---
>
> Changes since v1
>
> - New patch
>
> Changes since v2
>
> - Remove extra params to
> - Clarification on boot section
> - Add entry on MAC adresses and how to correct them
>
> Changes since v3
>
> - Rebase against d678a59d2d
> ---
>  doc/board/starfive/index.rst |   1 +
>  doc/board/starfive/pine64_star64.rst | 136 +++
>  2 files changed, 137 insertions(+)
>  create mode 100644 doc/board/starfive/pine64_star64.rst
>
> diff --git a/doc/board/starfive/index.rst b/doc/board/starfive/index.rst
> index d369b986cc..72ab6ddfbf 100644
> --- a/doc/board/starfive/index.rst
> +++ b/doc/board/starfive/index.rst
> @@ -8,4 +8,5 @@ StarFive
>
> milk-v_mars
> milk-v_mars_cm
> +   pine64_star64
> visionfive2
> diff --git a/doc/board/starfive/pine64_star64.rst 
> b/doc/board/starfive/pine64_star64.rst
> new file mode 100644
> index 00..567d1207ba
> --- /dev/null
> +++ b/doc/board/starfive/pine64_star64.rst
> @@ -0,0 +1,136 @@
> +.. SPDX-License-Identifier: GPL-2.0+
> +
> +Pine64 Star64
> +===
> +
> +U-Boot for the Star64 uses the same U-Boot binaries as the VisionFive 2 
> board.
> +In U-Boot SPL the actual board is detected and the device-tree patched
> +accordingly.
> +
> +Building
> +
> +
> +1. Add the RISC-V toolchain to your PATH.
> +2. Setup ARCH & cross compilation environment variable:
> +
> +.. code-block:: none
> +
> +   export CROSS_COMPILE=
> +
> +The M-mode software OpenSBI provides the supervisor binary interface (SBI) 
> and
> +is responsible for the switch to S-Mode. It is a prerequisite to build 
> U-Boot.
> +Support for the JH7110 was introduced in OpenSBI 1.2. It is recommended to 
> use
> +a current release.
> +
> +.. code-block:: console
> +
> +   git clone https://github.com/riscv/opensbi.git
> +   cd opensbi
> +   make PLATFORM=generic FW_TEXT_START=0x4000
> +
> +Now build the U-Boot SPL and U-Boot proper.
> +
> +.. code-block:: console
> +
> +   cd 
> +   make starfive_visionfive2_defconfig
> +   make 
> OPENSBI=$(opensbi_dir)/build/platform/generic/firmware/fw_dynamic.bin
> +
> +This will generate the U-Boot SPL image (spl/u-boot-spl.bin.normal.out) as 
> well
> +as the FIT image (u-boot.itb) with OpenSBI and U-Boot.
> +
> +Device-tree selection
> +~
> +
> +U-Boot will set variable $fdtfile to starfive/jh7110-pine64-star64.dtb.
> +
> +To overrule this selection the variable can be set manually and saved in the
> +environment
> +
> +::
> +
> +setenv fdtfile my_device-tree.dtb
> +env save

Nit: prefer consistent sub-command as:
env set fdtfile my_device-tree.dtb

> +
> +or the configuration variable CONFIG_DEFAULT_FDT_FILE can be used to set to
> +provide a default value.
> +
> +Boot source selection
> +~
> +

> +The board provides the DIP switches (marked S1804) adjacent to the 40pin GPIO
> +Bus for boot selection. The ``L`` (0) and ``H`` (1) silk screening to the 
> side
> +of the should be used to determine state (not the ``ON/ONKE`` markings
> +physically on the component). ``GPIO_0`` is channel 2 on the switch, while
> +``GPIO_1`` is channel 1.

Suggested: "Boot mode is selected by an MSEL-DIP marked S1804 and GPIO_0
position adjacent to the 40pin GPIO header. ON/ONKE and number markings of the
MSEL-DIP are misleading; Instead refer to the ``L`` (0) and ``H`` (1)
silkscreen for
accurate selection."

> +
> ++ (QSPI) Flash: 00 ``??``
> ++ SD: 01 ``??``
> ++ EMMC: 10 ``??``
> ++ UART: 11 ``??``
> +
> +Preparing the SD-Card
> +~
> +
> +The device firmware loads U-Boot SPL (u-boot-spl.bin.normal.out) from the
> +partition with type GUID 2E54B353-1271-4842-806F-E436D6AF6985. You are free
> +to choose any partition number.
> +
> +With the default configuration U-Boot SPL loads the U-Boot FIT image
> +(u-boot.itb) from partition 2 
> (CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x2).
> +When formatting it is recommended to use GUID
> +BC13C2FF-59E6-4262-A352-B275FD6F7172 for this partition.
> +
> +The FIT image (u-boot.itb) is a combination of OpenSBI's fw_dynamic.bin,
> +u-boot-nodtb.bin and the device tree blob.
> +
> +Format the SD card (make sure the disk has GPT, otherwise use gdisk to 
> switch)
> +
> +.. code-block:: bash
> +
> +   sudo sgdisk --clear \
> + --set-alignment=2 \
> + --new=1:4096:8191 --change-name=1:spl 
> --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985\
> + --new=2:8192:16383 --change-name=2:uboot 
> --typecode=2:BC13C2FF-59E6-4262-A352-B275FD6F7172  \
> + --new=3:16384:1654784 --change-name=3:system 
> --typecode=3:EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 \
> + /dev/sdb
> +
> +Copy U-Boot to the SD card
> +
> +.. code-block:: bash
> +
> +   sudo dd if=u-boot-spl.bin.normal.out of=/dev/sdb1
>

Re: [PATCH 06/10] drivers: serial: Add xtensa semihosting driver

2024-05-20 Thread Max Filippov
On Sun, May 19, 2024 at 1:53 PM Jiaxun Yang  wrote:
>
> Add xtensa semihosting driver.
>
> It can't use regular semihosting driver as Xtensa's has it's own
> semihosting ABI.
>
> Note that semihosting supports puts in serial but I never managed to
> get it work, so it's putc only for now.

I wonder, what were the issues that you experienced?

> Signed-off-by: Jiaxun Yang 
> ---
>  drivers/serial/Kconfig | 18 ++-
>  drivers/serial/Makefile|  1 +
>  drivers/serial/serial_xtensa_semihosting.c | 79 
> ++
>  3 files changed, 97 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index 1fe4607598eb..3a1e5a6f2877 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -501,6 +501,15 @@ config DEBUG_UART_MT7620
>   driver will be available until the real driver model serial is
>   running.
>
> +config DEBUG_UART_XTENSA_SEMIHOSTING
> +   bool "Xtensa semihosting"
> +   depends on XTENSA_SEMIHOSTING_SERIAL
> +   help
> + Select this to enable the debug UART using the Xtensa semihosting 
> driver.
> + This provides basic serial output from the console without needing 
> to
> + start up driver model. The driver will be available until the real
> + driver model serial is running.
> +
>  endchoice
>
>  config DEBUG_UART_BASE
> @@ -936,7 +945,6 @@ config SH_SCIF_CLK_FREQ
>  config SEMIHOSTING_SERIAL
> bool "Semihosting UART support"
> depends on SEMIHOSTING && !SERIAL_RX_BUFFER
> -   imply SERIAL_PUTS
> help
>   Select this to enable a serial UART using semihosting. Special halt
>   instructions will be issued which an external debugger (such as a
> @@ -1115,6 +1123,14 @@ config XEN_SERIAL
>   If built without DM support, then requires Xen
>   to be built with CONFIG_VERBOSE_DEBUG.
>
> +config XTENSA_SEMIHOSTING_SERIAL
> +   bool "Xtensa Semihosting UART support"
> +   depends on DM_SERIAL
> +   depends on XTENSA_SEMIHOSTING
> +   imply SERIAL_PUTS
> +   help
> + Select this to enable a serial UART using Xtensa semihosting.
> +
>  choice
> prompt "Console port"
> default 8xx_CONS_SMC1
> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> index dbe598b74064..78810f98367c 100644
> --- a/drivers/serial/Makefile
> +++ b/drivers/serial/Makefile
> @@ -60,6 +60,7 @@ obj-$(CONFIG_MT7620_SERIAL) += serial_mt7620.o
>  obj-$(CONFIG_HTIF_CONSOLE) += serial_htif.o
>  obj-$(CONFIG_SIFIVE_SERIAL) += serial_sifive.o
>  obj-$(CONFIG_XEN_SERIAL) += serial_xen.o
> +obj-$(CONFIG_XTENSA_SEMIHOSTING_SERIAL) += serial_xtensa_semihosting.o
>  obj-$(CONFIG_S5P4418_PL011_SERIAL) += serial_s5p4418_pl011.o
>
>  ifndef CONFIG_SPL_BUILD
> diff --git a/drivers/serial/serial_xtensa_semihosting.c 
> b/drivers/serial/serial_xtensa_semihosting.c
> new file mode 100644
> index ..1bf3c18537e7
> --- /dev/null
> +++ b/drivers/serial/serial_xtensa_semihosting.c
> @@ -0,0 +1,79 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2024 Jiaxun Yang 
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +/**
> + * struct simc_serial_priv - Semihosting serial private data
> + * @counter: Counter used to fake pending every other call
> + */
> +struct simc_serial_priv {
> +   unsigned int counter;
> +};
> +
> +static int simc_serial_getc(struct udevice *dev)
> +{
> +   char ch = 0;
> +
> +   simc_read(0, &ch, sizeof(ch));
> +
> +   return ch;
> +}
> +
> +static int simc_serial_putc(struct udevice *dev, const char ch)
> +{
> +   char str[2] = {0};

Why does it need to be an array if only the first element is ever used?

> +
> +   str[0] = ch;
> +   simc_write(1, str, 1);
> +
> +   return 0;
> +}
> +
> +static int simc_serial_pending(struct udevice *dev, bool input)
> +{
> +   struct simc_serial_priv *priv = dev_get_priv(dev);
> +
> +   if (input)
> +   return priv->counter++ & 1;

This can result in blocking the whole CPU thread of the emulator when
used with simcall-based semihosting and there's no input actually available.
Not sure how it would behave with the gdbio. I think something like
the following:

if (input) {
int res = simc_poll(0);
return res < 0 ? priv->counter++ & 1 : res;
}

could be used here to avoid that.

> +   return false;
> +}
> +
> +static const struct dm_serial_ops simc_serial_ops = {
> +   .putc = simc_serial_putc,
> +   .getc = simc_serial_getc,
> +   .pending = simc_serial_pending,
> +};
> +
> +U_BOOT_DRIVER(simc_serial) = {
> +   .name   = "serial_xtensa_semihosting",
> +   .id = UCLASS_SERIAL,
> +   .priv_auto = sizeof(struct simc_serial_priv),
> +   .ops= &simc_serial_ops,
> +   .flags  = DM_FLAG_PRE_RELOC,
> +};
> +
> +U_BOOT_DRVINFO(simc_serial) = {
> +   .name = "serial_xtensa_s

Re: [PATCH 05/10] xtensa: Bring in semihosting headers and config options

2024-05-20 Thread Max Filippov
On Sun, May 19, 2024 at 1:53 PM Jiaxun Yang  wrote:
>
> They are all directly imported from Linux kernel.
>
> Signed-off-by: Jiaxun Yang 
> ---
>  arch/xtensa/Kconfig  |  27 ++
>  arch/xtensa/include/asm/platform/simcall-gdbio.h |  34 +++
>  arch/xtensa/include/asm/platform/simcall-iss.h   |  73 +++
>  arch/xtensa/include/asm/platform/simcall.h   | 110 
> +++
>  4 files changed, 244 insertions(+)

Reviewed-by: Max Filippov 

-- 
Thanks.
-- Max


Re: [PATCH RFC 3/4] pwm: sunxi: Add support Allwinner D1 PWM

2024-05-20 Thread John Watts
On Sat, May 18, 2024 at 01:54:45PM +1000, John Watts wrote:
> This driver documents and handles setting up PWM on the D1.
> 
> Signed-off-by: John Watts 
> ---
>  drivers/pwm/Kconfig|   6 +
>  drivers/pwm/Makefile   |   1 +
>  drivers/pwm/sunxi_pwm_d1.c | 542 
> +
>  3 files changed, 549 insertions(+)

Patch v9 of the kernel uses apb now instead of apb0, so this should be changed
to fit once the kernel driver is merged.

> 
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index 6e79868d0e..8c4c910ea7 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -112,6 +112,12 @@ config PWM_SUNXI
> This PWM is found on H3, A64 and other Allwinner SoCs. It supports a
> programmable period and duty cycle. A 16-bit counter is used.
>  
> +config PWM_SUNXI_D1
> + bool "Enable support for the Allwinner D1 Sunxi PWM"
> + depends on DM_PWM
> + help
> +   This PWM is found on D1, T113-S3 and R329 SoCs.
> +
>  config PWM_TI_EHRPWM
>   bool "Enable support for EHRPWM PWM"
>   depends on DM_PWM && ARCH_OMAP2PLUS
> diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
> index e4d10c8dc3..ea96e7159b 100644
> --- a/drivers/pwm/Makefile
> +++ b/drivers/pwm/Makefile
> @@ -23,4 +23,5 @@ obj-$(CONFIG_PWM_SANDBOX)   += sandbox_pwm.o
>  obj-$(CONFIG_PWM_SIFIVE) += pwm-sifive.o
>  obj-$(CONFIG_PWM_TEGRA)  += tegra_pwm.o
>  obj-$(CONFIG_PWM_SUNXI)  += sunxi_pwm.o
> +obj-$(CONFIG_PWM_SUNXI_D1)   += sunxi_pwm_d1.o
>  obj-$(CONFIG_PWM_TI_EHRPWM)  += pwm-ti-ehrpwm.o
> diff --git a/drivers/pwm/sunxi_pwm_d1.c b/drivers/pwm/sunxi_pwm_d1.c
> new file mode 100644
> index 00..6c57bc6e85
> --- /dev/null
> +++ b/drivers/pwm/sunxi_pwm_d1.c
> @@ -0,0 +1,542 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright 2022 Jookia 
> +/*
> + * The Allwinner D1's PWM channels are 16-bit counters with up to
> + * 65537 cycles (yes, you read that correctly).
> + *
> + * Each channel must be programmed using three variables:
> + * - The entire cycle count (used for the period)
> + * - The active cycle count (the count of inactive cycles)
> + * - The polarity (specifies if the signal is active high or low)
> + * The cycle counts are at minimum 1 and at maximum 65536.
> + *
> + * The controller will output the number of entire cycles plus one
> + * extra, with any cycles after the active cycle output as active.
> + *
> + * Consider a PWM period of 128 nanoseconds and a cycle period of 32.
> + * Setting the entire cycle count to 3 and active cycle count to 4
> + * gives an output like so:
> + *
> + * - Cycle 1 runs 0 to 32 nanoseconds, inactive
> + * - Cycle 2 runs 32 to 64 nanoseconds, inactive
> + * - Cycle 3 runs 64 to 96 nanoseconds, inactive
> + * - Cycle 4 runs 96 to 128 nanoseconds, inactive
> + * - Cycle 5 is skipped but would run 128 to 160 nanoseconds, active
> + *
> + * If we set the entire count to 4, cycle 5 would run and we wouldn't be
> + * able to specify it as inactive as the active count only goes up to 4.
> + *
> + * In practice this means we want to set the entire cycle to be one less
> + * then the actual number of cycles we want, so we can set the number of
> + * active cycles to be up to maximum for a fully inactive signal.
> + *
> + * The PWM channels are paired and clocked together, resulting in a
> + * cycle time found using the following formula:
> + *
> + * PWM0_CYCLE_NS = 10 / (BUS_CLOCK / COMMON_DIV / PWM0_PRESCALER_K)
> + * PWM1_CYCLE_NS = 10 / (BUS_CLOCK / COMMON_DIV / PWM1_PRESCALER_K)
> + *
> + * This means both clocks should ideally be set at the same time and not
> + * impact each other too much.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* PWM channel information */
> +struct pwm_channel {
> + uint period_ns;
> + uint duty_ns;
> + bool polarity;
> + bool enable;
> + bool updated;
> +};
> +
> +/* Timings found for a PWM channel */
> +struct pwm_timings {
> + uint cycle_ns;
> + uint period_ns;
> + uint duty_ns;
> + uint clock_id;
> + uint common_div;
> + uint prescale_k;
> + uint entire_cycles;
> + uint active_cycles;
> + uint polarity;
> +};
> +
> +/* Driver state */
> +struct sunxi_pwm_d1_priv {
> + void *base;
> + struct clk *clk_bus;
> + struct clk *clk_srcs[3]; /* Last value must be NULL */
> + struct reset_ctl *reset;
> + int npwm;
> + struct pwm_channel *channels;
> +};
> +
> +/* Divides a nanosecond value, rounding up for very low values */
> +uint div_ns(uint ns, uint div)
> +{
> + uint result = (ns / div);
> +
> + /* If the number is less than 1000, round it to the nearest digit */
> + if (result < 1000)
> + result = (ns + (div - 1)) / div;
> +
> + if (result < 1)
> + result = 1;
> +
> + return result;
> +}
> +
> +/* Checks if an error is relatively too large

Re: [PATCH FOR TESTING ONLY RFC 4/4] sunxi-d1s-t113: Add D1 and T113 PWM node

2024-05-20 Thread John Watts
On Mon, May 20, 2024 at 03:58:12PM +0530, Sumit Garg wrote:
> This change shouldn't be needed for your testing purposes too. It only
> comes into picture once you enable OF_UPSTREAM. BTW, DT source files
> in dts/upstream are strictly following/syncing against Linux kernel DT
> sources. So all the custom U-Boot specific DT stuff belongs to
> arch/${ARCH}/dts/.
> 
> -Sumit

Hi,

I use OF_UPSTREAM.

John.


Re: [PATCH v2] fdt: automatically add /chosen/kaslr-seed if DM_RNG is enabled

2024-05-20 Thread Tim Harvey
On Mon, May 20, 2024 at 1:29 AM Michal Simek  wrote:
>
> Hi Tim,
>
> On 5/16/24 17:58, Tim Harvey wrote:
> > On Wed, May 15, 2024 at 1:50 PM Tim Harvey  wrote:
> >>
> >> If RANDOMIZE_BASE is enabled in the Linux kernel instructing it to
> >> randomize the virtual address at which the kernel image is loaded, it
> >> expects entropy to be provided by the bootloader by populating
> >> /chosen/kaslr-seed with a 64-bit value from source of entropy at boot.
> >>
> >> If we have DM_RNG enabled populate this value automatically when
> >> fdt_chosen is called unless ARMV8_SEC_FIRMWARE_SUPPORT is enabled as
> >> it's implementation uses a different source of entropy.
> >>
> >> As this fdt node is added elsewhere create a library function and
> >> use it to deduplicate code.
> >>
> >> Note that the kalsrseed command (CMD_KASLRSEED) is likely pointless now
> >> but left in place in case boot scripts exist that rely on this command
> >> existing and returning success. An informational message is printed to
> >> alert users of this command that it is likely no longer needed.
> >>
> >> Signed-off-by: Tim Harvey 
> >> ---
> >> v2:
> >>   - fix typo in commit msg
> >>   - use stack for seed to avoid unecessary malloc/free
> >>   - move to a library function and deduplicate code by using it elsewhere
> >> ---
> >>   board/xilinx/common/board.c | 35 -
> >>   boot/fdt_support.c  | 10 +
> >>   boot/pxe_utils.c| 35 +++--
> >>   cmd/kaslrseed.c | 45 ++---
> >>   include/kaslrseed.h | 17 ++
> >>   lib/Makefile|  1 +
> >>   lib/kaslrseed.c | 34 
> >>   7 files changed, 72 insertions(+), 105 deletions(-)
> >>   create mode 100644 include/kaslrseed.h
> >>   create mode 100644 lib/kaslrseed.c
> >>
> >> diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
> >> index 30a81376ac41..f741e8957818 100644
> >> --- a/board/xilinx/common/board.c
> >> +++ b/board/xilinx/common/board.c
> >> @@ -713,41 +713,6 @@ int ft_board_setup(void *blob, struct bd_info *bd)
> >>  if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS) && 
> >> IS_ENABLED(CONFIG_NAND_ZYNQ))
> >>  fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
> >>
> >> -   if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
> >> -   debug("No RNG device\n");
> >> -   return 0;
> >> -   }
> >> -
> >> -   if (dm_rng_read(dev, buf, n)) {
> >> -   debug("Reading RNG failed\n");
> >> -   return 0;
> >> -   }
> >> -
> >> -   if (!blob) {
> >> -   debug("No FDT memory address configured. Please 
> >> configure\n"
> >> - "the FDT address via \"fdt addr \" 
> >> command.\n"
> >> - "Aborting!\n");
> >> -   return 0;
> >> -   }
> >> -
> >> -   ret = fdt_check_header(blob);
> >> -   if (ret < 0) {
> >> -   debug("fdt_chosen: %s\n", fdt_strerror(ret));
> >> -   return ret;
> >> -   }
> >> -
> >> -   nodeoffset = fdt_find_or_add_subnode(blob, 0, "chosen");
> >> -   if (nodeoffset < 0) {
> >> -   debug("Reading chosen node failed\n");
> >> -   return nodeoffset;
> >> -   }
> >> -
> >> -   ret = fdt_setprop(blob, nodeoffset, "kaslr-seed", buf, 
> >> sizeof(buf));
> >> -   if (ret < 0) {
> >> -   debug("Unable to set kaslr-seed on chosen node: %s\n", 
> >> fdt_strerror(ret));
> >> -   return ret;
> >> -   }
> >> -
> >>  return 0;
> >>   }
> >>   #endif
> >> diff --git a/boot/fdt_support.c b/boot/fdt_support.c
> >> index 874ca4d6f5af..3455d60d69dc 100644
> >> --- a/boot/fdt_support.c
> >> +++ b/boot/fdt_support.c
> >> @@ -8,6 +8,7 @@
> >>
> >>   #include 
> >>   #include 
> >> +#include 
> >>   #include 
> >>   #include 
> >>   #include 
> >> @@ -300,6 +301,15 @@ int fdt_chosen(void *fdt)
> >>  if (nodeoffset < 0)
> >>  return nodeoffset;
> >>
> >> +   if (IS_ENABLED(CONFIG_DM_RNG) && 
> >> !IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT)) {
> >> +   err = fdt_kaslrseed(fdt);
> >> +   if (err) {
> >> +   printf("WARNING: could not set kaslr-seed %s.\n",
> >> +  fdt_strerror(err));
> >> +   return err;
> >> +   }
> >> +   }
> >> +
> >>  if (IS_ENABLED(CONFIG_BOARD_RNG_SEED) && !board_rng_seed(&buf)) {
> >>  err = fdt_setprop(fdt, nodeoffset, "rng-seed",
> >>abuf_data(&buf), abuf_size(&buf));
> >> diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
> >> index 4b22bb6f525a..8d70233fc08d 100644
> >> --- a/boot/pxe_utils.c
> >> +++ b/boot/pxe_utils.c
> >> @@ -8,6 +8,7 @@
> >>   #include 
> >>   #include 
> >>   #include 
> >> +#include 
> >>   #include 

Re: [PATCH 0/6] power: pmic: sunxi: consolidate AXP SPL drivers

2024-05-20 Thread Peter Robinson
On Mon, 20 May 2024 at 15:18, Andre Przywara  wrote:
>
> On Mon, 20 May 2024 13:48:41 +0100
> Peter Robinson  wrote:
>
> Hi Peter,
>
> thanks for having a look!
>
> > Hi Andre,
> >
> > > this is the first series in an attempt to clean up the X-Powers AXP PMIC
> > > drivers used by the SPL for sunxi boards. So far we have a separate
> > > driver file for each AXP variant, but the code was largely the same,
> > > just differing by the regulator ranges.
> > >
> > > This adds a new generic driver, which reads the regulator description
> > > from an array of structs. This is similar to how the DM AXP driver used
> > > for U-Boot proper works, but is simplified, since we won't need the full
> > > feature set for the SPL, and we want to keep the code size small.
> >
> > Overall seems a reasonable approach, would it make sense to put the
> > regulator descriptions in a file that could be shared between this and
> > the DM driver so the information isn't duplicated and hence may
> > diverge over time with things like copy/paste errors?
>
> Yes, I thought about it, but it gets nasty:
> - The SPL should only have the regulator descriptions for the *one*
> selected AXP chip, whereas the DM driver can afford to describe all
> regulators and select the right ones via the compatible at runtime. This
> is to conserve memory for the SPL.
> - The SPL should only be interested in the DC/DC buck converters, we don't
> really need any LDOs. Again saves memory.
> - Each regulator entry for the SPL should be as small as possible, we don't
> want and need the regulator name, for instance, or the table pointer.
> Again to save memory.
>
> Currently the array for the three AXP313 regulators in the SPL is exactly
> 30 bytes long; in the DM driver, just for the small AXP313: 192 bytes. The
> difference is even more pronounced for the larger AXPs.
>
> I am hopeful there might be some macro magic to express this, like:
> static const struct axp_regulator_plat axp313_regulators[] = {
>SPL( "dcdc1", 0x10, BIT(0), 0x13, 0x7f,  500, 1540,  10, 70 )
>SPL( "dcdc2", 0x10, BIT(1), 0x14, 0x7f,  500, 1540,  10, 70 )
>SPL( "dcdc3", 0x10, BIT(2), 0x15, 0x7f,  500, 1840,  10, 70 )
> PROPER( "aldo1", 0x10, BIT(3), 0x16, 0x1f,  500, 3500, 100, NA )
> PROPER( "dldo1", 0x10, BIT(4), 0x17, 0x1f,  500, 3500, 100, NA )
> {}
> };
> But we still need something to avoid the array altogether when another AXP
> is selected, which might require #ifdefs.
> So it might be possible, but the devil is probably in the details.
>
> For now I just wanted to avoid adding more AXP driver files to
> the drivers/power directory, so I consider this a future optimisation.

That all makes sense, thanks for the great explanation!

> Happy to take patches :-D
>
> Cheers,
> Andre
>
> > Peter
> >
> > > To help bisect-ability, and to simplify review, each of the simpler AXP
> > > drivers covered by this approach is handled in a separate patch.
> > > We just convert the AXP313, AXP305, AXP717 for now, and on the way add
> > > support for the AXP707, just because it's now very easy, and we will
> > > need it soon enough.
> > > The other AXP SPL drivers are more complex, and support more regulators,
> > > but my hunch is that we really just need the DC/DC converters in the
> > > SPL. However I need to prove and test this, so I will convert the other
> > > AXP chips later.
> > >
> > > Please have a look and comment whether the approach in general is a good
> > > idea.
> > >
> > > Cheers,
> > > Andre
> > >
> > > Andre Przywara (6):
> > >   power: pmic: sunxi: only build AXP drivers for SPL
> > >   power: pmic: sunxi: introduce generic SPL AXP DC/DC driver
> > >   power: pmic: sunxi: replace AXP717 SPL driver
> > >   power: pmic: sunxi: use generic AXP SPL driver for AXP313
> > >   power: pmic: sunxi: use generic AXP SPL driver for AXP305
> > >   power: pmic: sunxi: add AXP707 support
> > >
> > >  drivers/power/Makefile  |   8 +-
> > >  drivers/power/axp305.c  |  82 --
> > >  drivers/power/axp313.c  | 133 -
> > >  drivers/power/axp717.c  |  92 
> > >  drivers/power/axp_spl.c | 184 
> > >  5 files changed, 189 insertions(+), 310 deletions(-)
> > >  delete mode 100644 drivers/power/axp305.c
> > >  delete mode 100644 drivers/power/axp313.c
> > >  delete mode 100644 drivers/power/axp717.c
> > >  create mode 100644 drivers/power/axp_spl.c
> > >
> > > --
> > > 2.35.8
> > >
>


[ANN] U-Boot v2024.07-rc3 released

2024-05-20 Thread Tom Rini
Hey all,

It's release day and here is -rc3. At this point, I think we're firmly
on "bug fix and documentation" ground moving forward for changes to
v2024.07 and the next branch is open and ready for use and pull
requests.

In terms of a changelog, 
git log --merges v2024.07-rc2..v2024.07-rc3
contains what I've pulled but as always, better PR messages and tags
will provide better results here.

I hope to remain on schedule and that means the rest of the rcs every
other Monday, and with final release on Monday, July 1st, 2024. Thanks
all!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 04/10] xtensa: Define PLATFORM_ELFFLAGS

2024-05-20 Thread Jiaxun Yang



在2024年5月20日五月 下午4:18,Max Filippov写道:
> On Sun, May 19, 2024 at 1:53 PM Jiaxun Yang  wrote:
>>
>> u-boot.elf target requiures it to work.
>
> Typo.
>
>> Signed-off-by: Jiaxun Yang 
>> ---
>>  arch/xtensa/config.mk | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/xtensa/config.mk b/arch/xtensa/config.mk
>> index b080e403..3ec936272f25 100644
>> --- a/arch/xtensa/config.mk
>> +++ b/arch/xtensa/config.mk
>> @@ -7,3 +7,6 @@ PLATFORM_CPPFLAGS += -D__XTENSA__ -mlongcalls -mforce-no-pic 
>> \
>>  -ffunction-sections -fdata-sections
>>
>>  LDFLAGS_FINAL += --gc-sections
>> +
>> +PLATFORM_ELFFLAGS += -B xtensa -O elf32-xtensa-le
>> +
>
> This fixes endianness as little for the whole architecture, but xtensa cores
> may be either little or big endian.

Hi Max,

Thanks for reviewing, I can just add a branch with ifdef CONFIG_SYS_BIG_EDNIAN
if you wish, but I think all CPUs U-Boot support are little endian only?

I have an ongoing series[1] fixing endian selection options, please let me know 
if
U-Boot do work with big endian Xtensa.

Thanks.

[1]: 
https://patchwork.ozlabs.org/project/uboot/patch/20240519-aarch64-be-v1-11-75cc328ed...@flygoat.com/

>
> -- 
> Thanks.
> -- Max

-- 
- Jiaxun


Re: [PATCH v2 0/3] arm: dts: am62-beagleplay: Fix Beagleplay Ethernet

2024-05-20 Thread Tom Rini
On Mon, 13 May 2024 15:13:53 +0300, Roger Quadros wrote:

> Sync AM62 device tree files with Linux v6.9 and
> add in the missing bits in -u-boot.dtsi to get CPSW
> Ethernet working.
> 
> CI testing
> https://github.com/u-boot/u-boot/pull/534
> 
> [...]

Applied to u-boot/next, thanks!

-- 
Tom




Re: [PATCH] ARM: dts: renesas: Remove leftovers after OF_UPSTREAM conversion

2024-05-20 Thread Adam Ford
On Sun, May 19, 2024 at 3:40 PM Marek Vasut
 wrote:
>
> Remove leftover DTSI files after OF_UPSTREAM conversion.
> Those are no longer used and no longer necessary, remove them.
> No functional change.
>

This seems like the right thing to do.

> Signed-off-by: Marek Vasut 

Acked-by: Adam Ford 

> ---
> Cc: Adam Ford 
> Cc: Tom Rini 
> ---
>  arch/arm/dts/salvator-common.dtsi| 1104 --
>  arch/arm/dts/salvator-x.dtsi |   29 -
>  arch/arm/dts/salvator-xs.dtsi|   85 --
>  arch/arm/dts/ulcb-audio-graph-card.dtsi  |   85 --
>  arch/arm/dts/ulcb-audio-graph-card2.dtsi |   26 -
>  arch/arm/dts/ulcb.dtsi   |  509 --
>  6 files changed, 1838 deletions(-)
>  delete mode 100644 arch/arm/dts/salvator-common.dtsi
>  delete mode 100644 arch/arm/dts/salvator-x.dtsi
>  delete mode 100644 arch/arm/dts/salvator-xs.dtsi
>  delete mode 100644 arch/arm/dts/ulcb-audio-graph-card.dtsi
>  delete mode 100644 arch/arm/dts/ulcb-audio-graph-card2.dtsi
>  delete mode 100644 arch/arm/dts/ulcb.dtsi
>
> diff --git a/arch/arm/dts/salvator-common.dtsi 
> b/arch/arm/dts/salvator-common.dtsi
> deleted file mode 100644
> index 4a3d5037821..000
> --- a/arch/arm/dts/salvator-common.dtsi
> +++ /dev/null
> @@ -1,1104 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * Device Tree Source for common parts of Salvator-X board variants
> - *
> - * Copyright (C) 2015-2016 Renesas Electronics Corp.
> - */
> -
> -/*
> - * SSI-AK4613
> - *
> - * This command is required when Playback/Capture
> - *
> - * amixer set "DVC Out" 100%
> - * amixer set "DVC In" 100%
> - *
> - * You can use Mute
> - *
> - * amixer set "DVC Out Mute" on
> - * amixer set "DVC In Mute" on
> - *
> - * You can use Volume Ramp
> - *
> - * amixer set "DVC Out Ramp Up Rate"   "0.125 dB/64 steps"
> - * amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps"
> - * amixer set "DVC Out Ramp" on
> - * aplay xxx.wav &
> - * amixer set "DVC Out"  80%  // Volume Down
> - * amixer set "DVC Out" 100%  // Volume Up
> - */
> -
> -#include 
> -#include 
> -
> -/ {
> -   aliases {
> -   i2c0 = &i2c0;
> -   i2c1 = &i2c1;
> -   i2c2 = &i2c2;
> -   i2c3 = &i2c3;
> -   i2c4 = &i2c4;
> -   i2c5 = &i2c5;
> -   i2c6 = &i2c6;
> -   i2c7 = &i2c_dvfs;
> -   serial0 = &scif2;
> -   serial1 = &hscif1;
> -   ethernet0 = &avb;
> -   mmc0 = &sdhi2;
> -   mmc1 = &sdhi0;
> -   mmc2 = &sdhi3;
> -   };
> -
> -   chosen {
> -   bootargs = "ignore_loglevel rw root=/dev/nfs ip=on";
> -   stdout-path = "serial0:115200n8";
> -   };
> -
> -   audio_clkout: audio-clkout {
> -   /*
> -* This is same as <&rcar_sound 0>
> -* but needed to avoid cs2000/rcar_sound probe dead-lock
> -*/
> -   compatible = "fixed-clock";
> -   #clock-cells = <0>;
> -   clock-frequency = <12288000>;
> -   };
> -
> -   backlight: backlight {
> -   compatible = "pwm-backlight";
> -   pwms = <&pwm1 0 5>;
> -
> -   brightness-levels = <256 128 64 16 8 4 0>;
> -   default-brightness-level = <6>;
> -
> -   power-supply = <®_12v>;
> -   enable-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
> -   };
> -
> -   cvbs-in {
> -   compatible = "composite-video-connector";
> -   label = "CVBS IN";
> -
> -   port {
> -   cvbs_con: endpoint {
> -   remote-endpoint = <&adv7482_ain7>;
> -   };
> -   };
> -   };
> -
> -   hdmi-in {
> -   compatible = "hdmi-connector";
> -   label = "HDMI IN";
> -   type = "a";
> -
> -   port {
> -   hdmi_in_con: endpoint {
> -   remote-endpoint = <&adv7482_hdmi>;
> -   };
> -   };
> -   };
> -
> -   hdmi0-out {
> -   compatible = "hdmi-connector";
> -   label = "HDMI0 OUT";
> -   type = "a";
> -
> -   port {
> -   hdmi0_con: endpoint {
> -   remote-endpoint = <&rcar_dw_hdmi0_out>;
> -   };
> -   };
> -   };
> -
> -   hdmi1-out {
> -   compatible = "hdmi-connector";
> -   label = "HDMI1 OUT";
> -   type = "a";
> -
> -   port {
> -   hdmi1_con: endpoint {
> -   };
> -   };
> -   };
> -
> -   keys {
> -   compatible = "gpio-keys";
> -
> -   pinctrl-0 = <&keys_pins>;
> -   pinctrl-names = "default"

Re: [PATCH 04/10] xtensa: Define PLATFORM_ELFFLAGS

2024-05-20 Thread Max Filippov
On Sun, May 19, 2024 at 1:53 PM Jiaxun Yang  wrote:
>
> u-boot.elf target requiures it to work.

Typo.

> Signed-off-by: Jiaxun Yang 
> ---
>  arch/xtensa/config.mk | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/xtensa/config.mk b/arch/xtensa/config.mk
> index b080e403..3ec936272f25 100644
> --- a/arch/xtensa/config.mk
> +++ b/arch/xtensa/config.mk
> @@ -7,3 +7,6 @@ PLATFORM_CPPFLAGS += -D__XTENSA__ -mlongcalls -mforce-no-pic \
>  -ffunction-sections -fdata-sections
>
>  LDFLAGS_FINAL += --gc-sections
> +
> +PLATFORM_ELFFLAGS += -B xtensa -O elf32-xtensa-le
> +

This fixes endianness as little for the whole architecture, but xtensa cores
may be either little or big endian.

-- 
Thanks.
-- Max


Re: [PATCH v2] sysreset: add Qualcomm PSHOLD reset driver

2024-05-20 Thread Caleb Connolly




On 24/04/2024 14:44, Robert Marko wrote:

Number of Qualcomm ARMv7 SoC-s did not use PSCI but rather used PSHOLD
(Qualcomm Power Supply Hold Reset) bit to trigger reset or poweroff.


Applied, thanks!

b4 missed this one...

https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/19d175b1ff7a2e1272d4ad41415d2421fcb0adf0

// Caleb (they/them)


Re: [PATCH 1/4] MAINTAINERS: IPQ40XX: remove Luka Kovacic as maintainer

2024-05-20 Thread Caleb Connolly


On Wed, 24 Apr 2024 11:46:22 +0200, Robert Marko wrote:
> Luka Kovacic is no longer at Sartura, so remove him as one of IPQ40xx
> maintainers.
> 
> 

Applied, thanks!

[1/4] MAINTAINERS: IPQ40XX: remove Luka Kovacic as maintainer
  
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/db1d3404d82e
[2/4] MAINTAINERS: IPQ40XX: update GCC dt-bindings
  
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/dfa2645af1b6
[3/4] MAINTAINERS: IPQ40XX: add clock-ipq4019 instead of reset driver
  
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/28ad78df7a2b
[4/4] MAINTAINERS: IPQ40XX: add pinctrl driver
  
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/c4191505216d

Best regards,
-- 
Caleb Connolly 



Re: [PATCH v2 1/3] mach-ipq40xx: add CPU specific code

2024-05-20 Thread Caleb Connolly


On Tue, 14 May 2024 12:17:50 +0200, Robert Marko wrote:
> Provide basic DRAM info population from DT, cache setting and the
> board_init stub.
> 
> 

Applied, thanks!

[1/3] mach-ipq40xx: add CPU specific code
  
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/31718ccb900d
[2/3] mach-ipq40xx: use OF_UPSTREAM
  
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/6eb2efafc33a
[3/3] arm: dts: drop downstream IPQ4019 DTSI
  
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/d8903c0f94ee

Best regards,
-- 
Caleb Connolly 



Re: [PATCH 0/6] power: pmic: sunxi: consolidate AXP SPL drivers

2024-05-20 Thread Andre Przywara
On Mon, 20 May 2024 13:48:41 +0100
Peter Robinson  wrote:

Hi Peter,

thanks for having a look!

> Hi Andre,
> 
> > this is the first series in an attempt to clean up the X-Powers AXP PMIC
> > drivers used by the SPL for sunxi boards. So far we have a separate
> > driver file for each AXP variant, but the code was largely the same,
> > just differing by the regulator ranges.
> >
> > This adds a new generic driver, which reads the regulator description
> > from an array of structs. This is similar to how the DM AXP driver used
> > for U-Boot proper works, but is simplified, since we won't need the full
> > feature set for the SPL, and we want to keep the code size small.  
> 
> Overall seems a reasonable approach, would it make sense to put the
> regulator descriptions in a file that could be shared between this and
> the DM driver so the information isn't duplicated and hence may
> diverge over time with things like copy/paste errors?

Yes, I thought about it, but it gets nasty:
- The SPL should only have the regulator descriptions for the *one*
selected AXP chip, whereas the DM driver can afford to describe all
regulators and select the right ones via the compatible at runtime. This
is to conserve memory for the SPL.
- The SPL should only be interested in the DC/DC buck converters, we don't
really need any LDOs. Again saves memory.
- Each regulator entry for the SPL should be as small as possible, we don't
want and need the regulator name, for instance, or the table pointer.
Again to save memory.

Currently the array for the three AXP313 regulators in the SPL is exactly
30 bytes long; in the DM driver, just for the small AXP313: 192 bytes. The
difference is even more pronounced for the larger AXPs.

I am hopeful there might be some macro magic to express this, like:
static const struct axp_regulator_plat axp313_regulators[] = {
   SPL( "dcdc1", 0x10, BIT(0), 0x13, 0x7f,  500, 1540,  10, 70 )
   SPL( "dcdc2", 0x10, BIT(1), 0x14, 0x7f,  500, 1540,  10, 70 )
   SPL( "dcdc3", 0x10, BIT(2), 0x15, 0x7f,  500, 1840,  10, 70 )
PROPER( "aldo1", 0x10, BIT(3), 0x16, 0x1f,  500, 3500, 100, NA )
PROPER( "dldo1", 0x10, BIT(4), 0x17, 0x1f,  500, 3500, 100, NA )
{}
};
But we still need something to avoid the array altogether when another AXP
is selected, which might require #ifdefs.
So it might be possible, but the devil is probably in the details.

For now I just wanted to avoid adding more AXP driver files to
the drivers/power directory, so I consider this a future optimisation.
Happy to take patches :-D

Cheers,
Andre

> Peter
> 
> > To help bisect-ability, and to simplify review, each of the simpler AXP
> > drivers covered by this approach is handled in a separate patch.
> > We just convert the AXP313, AXP305, AXP717 for now, and on the way add
> > support for the AXP707, just because it's now very easy, and we will
> > need it soon enough.
> > The other AXP SPL drivers are more complex, and support more regulators,
> > but my hunch is that we really just need the DC/DC converters in the
> > SPL. However I need to prove and test this, so I will convert the other
> > AXP chips later.
> >
> > Please have a look and comment whether the approach in general is a good
> > idea.
> >
> > Cheers,
> > Andre
> >
> > Andre Przywara (6):
> >   power: pmic: sunxi: only build AXP drivers for SPL
> >   power: pmic: sunxi: introduce generic SPL AXP DC/DC driver
> >   power: pmic: sunxi: replace AXP717 SPL driver
> >   power: pmic: sunxi: use generic AXP SPL driver for AXP313
> >   power: pmic: sunxi: use generic AXP SPL driver for AXP305
> >   power: pmic: sunxi: add AXP707 support
> >
> >  drivers/power/Makefile  |   8 +-
> >  drivers/power/axp305.c  |  82 --
> >  drivers/power/axp313.c  | 133 -
> >  drivers/power/axp717.c  |  92 
> >  drivers/power/axp_spl.c | 184 
> >  5 files changed, 189 insertions(+), 310 deletions(-)
> >  delete mode 100644 drivers/power/axp305.c
> >  delete mode 100644 drivers/power/axp313.c
> >  delete mode 100644 drivers/power/axp717.c
> >  create mode 100644 drivers/power/axp_spl.c
> >
> > --
> > 2.35.8
> >  



Re: [PATCH] env: Invert gd->env_valid for env_mmc_save

2024-05-20 Thread Jasper Orschulko
Hi Tom,

you are right. If this patch is to be merged, we should change all the 
occurrences. That was an oversight on my part, sorry about that. I'll send an 
updated patch to the mailing list later this week.

My colleague Michael can give more technical background on this than I can, so 
I'll let him do explaining here ;)

Best,
Jasper

On 17 May 2024 20:51:44 CEST, Tom Rini  wrote:
>On Fri, May 10, 2024 at 01:38:34PM +0200, jas...@fancydomain.eu wrote:
>
>> From: Jasper Orschulko 
>> 
>> The A/B update strategy of the env's has a gap in the first 2 calls of 
>> saveenv.
>> The env's are stored twice on the first memory area if:
>> gd->env_valid == ENV_INVALID.
>> 
>> u-boot=> saveenv
>> Saving Environment to MMC... Writing to MMC(1)... OK
>> u-boot=> saveenv
>> Saving Environment to MMC... Writing to MMC(1)... OK  <-- !!!
>> u-boot=> saveenv
>> Saving Environment to MMC... Writing to redundant MMC(1)... OK
>> u-boot=> saveenv
>> Saving Environment to MMC... Writing to MMC(1)... OK
>> 
>> Signed-off-by: Michael Glembotzki 
>> Signed-off-by: Jasper Orschulko 
>> ---
>>  env/mmc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/env/mmc.c b/env/mmc.c
>> index 7afb733e890..2bef30c973c 100644
>> --- a/env/mmc.c
>> +++ b/env/mmc.c
>> @@ -299,7 +299,7 @@ static int env_mmc_save(void)
>>  ret = 0;
>>  
>>  if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT))
>> -gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : 
>> ENV_REDUND;
>> +gd->env_valid = gd->env_valid == ENV_VALID ? ENV_REDUND : 
>> ENV_VALID;
>>  
>>  fini:
>>  fini_mmc_for_env(mmc);
>
>Can you please explain a little more on how you get to this problem? The
>same code / test exists in env/fat.c, env/sf.c and env/ubi.c. In the
>case of env/mmc.c it's been that way since introduction in:
>commit d196bd880347373237d73e0d115b4d51c68cf2ad
>Author: Michael Heimpold 
>Date:   Wed Apr 10 10:36:19 2013 +
>
>env_mmc: add support for redundant environment
>
>This patch add support for storing the environment redundant on
>mmc devices. Substantially it re-uses the logic from the NAND 
> implementation,
>that means using an incremental counter for marking newer data.
>
>Signed-off-by: Michael Heimpold 
>
>as well. Thanks!
>
>-- 
>Tom


RE: [Agilex7 M-series Platform Enablement v1 16/16] configs: Add defconfig for Agilex7 M-series

2024-05-20 Thread Meng, Tingting


> -Original Message-
> From: Tom Rini 
> Sent: Friday, May 17, 2024 11:16 PM
> To: Meng, Tingting 
> Cc: u-boot@lists.denx.de; Lukasz Majewski ; Sean
> Anderson ; Rayagonda Kokatanur
> ; Marek ; Simon
> ; Chee, Tien Fong
> ; Hea, Kok Kiang ;
> Maniyam, Dinesh ; Ng, Boon Khai
> ; Yuslaimi, Alif Zakuan
> ; Chong, Teik Heng
> ; Zamri, Muhammad Hazim Izzat
> ; Lim, Jit Loon
> ; Tang, Sieu Mun ; Lau,
> Wan Yee 
> Subject: Re: [Agilex7 M-series Platform Enablement v1 16/16] configs: Add
> defconfig for Agilex7 M-series
> 
> On Fri, May 17, 2024 at 01:27:01PM +0800, tingting.m...@intel.com wrote:
> > From: Wan Yee Lau 
> >
> > Add defconfig for Agilex7 M-series.
> >
> > Signed-off-by: Wan Yee Lau 
> > Signed-off-by: Teik Heng Chong 
> > Signed-off-by: Tingting Meng 
> > ---
> >  ...onfig => socfpga_agilex7m_sdmmc_defconfig} | 110
> > +-
> >  1 file changed, 54 insertions(+), 56 deletions(-)  copy
> > configs/{socfpga_agilex5_defconfig =>
> > socfpga_agilex7m_sdmmc_defconfig} (56%)
> 
> You need to put this in a MAINTAINERS file.
> 
> --
> Tom

Will add it. Thanks so much.


RE: [Agilex7 M-series Platform Enablement v1 01/16] arch: arm: dts: Add dts and dtsi for new platform Agilex7 M-series

2024-05-20 Thread Meng, Tingting


> -Original Message-
> From: Tom Rini 
> Sent: Friday, May 17, 2024 11:08 PM
> To: Meng, Tingting 
> Cc: u-boot@lists.denx.de; Lukasz Majewski ; Sean
> Anderson ; Rayagonda Kokatanur
> ; Marek ; Simon
> ; Chee, Tien Fong
> ; Hea, Kok Kiang ;
> Maniyam, Dinesh ; Ng, Boon Khai
> ; Yuslaimi, Alif Zakuan
> ; Chong, Teik Heng
> ; Zamri, Muhammad Hazim Izzat
> ; Lim, Jit Loon
> ; Tang, Sieu Mun ; Lau,
> Wan Yee 
> Subject: Re: [Agilex7 M-series Platform Enablement v1 01/16] arch: arm: dts:
> Add dts and dtsi for new platform Agilex7 M-series
> 
> On Fri, May 17, 2024 at 01:26:46PM +0800, tingting.m...@intel.com wrote:
> 
> > From: Wan Yee Lau 
> >
> > Add Agilex7 M-series dtsi and dts for new platform Agilex7 M-series.
> >
> > Signed-off-by: Wan Yee Lau 
> > Signed-off-by: Teik Heng Chong 
> > Signed-off-by: Tingting Meng 
> > ---
> >  ...tsi => socfpga_agilex7m_socdk-u-boot.dtsi} |  37 -
> > ...x_socdk.dts => socfpga_agilex7m_socdk.dts} |  66 +++--
> >  arch/arm/dts/socfpga_soc64_u-boot.dtsi| 127 ++
> >  3 files changed, 213 insertions(+), 17 deletions(-)  copy
> > arch/arm/dts/{socfpga_agilex_socdk-u-boot.dtsi =>
> > socfpga_agilex7m_socdk-u-boot.dtsi} (50%)  copy
> > arch/arm/dts/{socfpga_agilex_socdk.dts => socfpga_agilex7m_socdk.dts}
> > (63%)  create mode 100644 arch/arm/dts/socfpga_soc64_u-boot.dtsi
> 
> Why can't we use OF_UPSTREAM on these platforms?
> 
> --
> Tom
ok, Tom, will convert to OF_UPSTREAM







Re: [PATCH 0/6] power: pmic: sunxi: consolidate AXP SPL drivers

2024-05-20 Thread Peter Robinson
Hi Andre,

> this is the first series in an attempt to clean up the X-Powers AXP PMIC
> drivers used by the SPL for sunxi boards. So far we have a separate
> driver file for each AXP variant, but the code was largely the same,
> just differing by the regulator ranges.
>
> This adds a new generic driver, which reads the regulator description
> from an array of structs. This is similar to how the DM AXP driver used
> for U-Boot proper works, but is simplified, since we won't need the full
> feature set for the SPL, and we want to keep the code size small.

Overall seems a reasonable approach, would it make sense to put the
regulator descriptions in a file that could be shared between this and
the DM driver so the information isn't duplicated and hence may
diverge over time with things like copy/paste errors?

Peter

> To help bisect-ability, and to simplify review, each of the simpler AXP
> drivers covered by this approach is handled in a separate patch.
> We just convert the AXP313, AXP305, AXP717 for now, and on the way add
> support for the AXP707, just because it's now very easy, and we will
> need it soon enough.
> The other AXP SPL drivers are more complex, and support more regulators,
> but my hunch is that we really just need the DC/DC converters in the
> SPL. However I need to prove and test this, so I will convert the other
> AXP chips later.
>
> Please have a look and comment whether the approach in general is a good
> idea.
>
> Cheers,
> Andre
>
> Andre Przywara (6):
>   power: pmic: sunxi: only build AXP drivers for SPL
>   power: pmic: sunxi: introduce generic SPL AXP DC/DC driver
>   power: pmic: sunxi: replace AXP717 SPL driver
>   power: pmic: sunxi: use generic AXP SPL driver for AXP313
>   power: pmic: sunxi: use generic AXP SPL driver for AXP305
>   power: pmic: sunxi: add AXP707 support
>
>  drivers/power/Makefile  |   8 +-
>  drivers/power/axp305.c  |  82 --
>  drivers/power/axp313.c  | 133 -
>  drivers/power/axp717.c  |  92 
>  drivers/power/axp_spl.c | 184 
>  5 files changed, 189 insertions(+), 310 deletions(-)
>  delete mode 100644 drivers/power/axp305.c
>  delete mode 100644 drivers/power/axp313.c
>  delete mode 100644 drivers/power/axp717.c
>  create mode 100644 drivers/power/axp_spl.c
>
> --
> 2.35.8
>


[PATCH v4] cmd: move ELF load and boot to lib/elf.c

2024-05-20 Thread Maxim Moskalets
From: Maxim Moskalets 

Loading and running the ELF image is the responsibility of the
library and should not be associated with the command line interface.

It is also required to run ELF images from FIT with the bootm command
so as not to depend on the command line interface.

Signed-off-by: Maxim Moskalets 
---
 cmd/elf.c | 58 +++
 include/elf.h | 10 +
 lib/elf.c | 54 +++
 3 files changed, 86 insertions(+), 36 deletions(-)

diff --git a/cmd/elf.c b/cmd/elf.c
index a02361f9f5..32b7462f92 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -19,21 +19,6 @@
 #include 
 #endif
 
-/* Allow ports to override the default behavior */
-static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),
-int argc, char *const argv[])
-{
-   unsigned long ret;
-
-   /*
-* pass address parameter as argv[0] (aka command name),
-* and all remaining args
-*/
-   ret = entry(argc, argv);
-
-   return ret;
-}
-
 /* Interpreter command to boot an arbitrary ELF image from memory */
 int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
@@ -43,8 +28,8 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
 #endif
unsigned long addr; /* Address of the ELF image */
unsigned long rc; /* Return value from user code */
-   char *sload = NULL;
-   int rcode = 0;
+   int rcode = CMD_RET_SUCCESS;
+   Bootelf_flags flags = {0};
 
/* Consume 'bootelf' */
argc--; argv++;
@@ -52,7 +37,10 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
/* Check for [-p|-s] flag. */
if (argc >= 1 && (argv[0][0] == '-' && \
(argv[0][1] == 'p' || argv[0][1] == 's'))) {
-   sload = argv[0];
+   if (argv[0][1] == 'p')
+   flags.phdr = 1;
+   log_debug("Using ELF header format %s\n",
+   flags.phdr ? "phdr" : "shdr");
/* Consume flag. */
argc--; argv++;
}
@@ -75,17 +63,9 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
} else
addr = image_load_addr;
 
-   if (!valid_elf_image(addr))
-   return 1;
-
-   if (sload && sload[1] == 'p')
-   addr = load_elf_image_phdr(addr);
-   else
-   addr = load_elf_image_shdr(addr);
-
 #if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP)
if (fdt_addr) {
-   printf("## Setting up FDT at 0x%08lx ...\n", fdt_addr);
+   log_debug("Setting up FDT at 0x%08lx ...\n", fdt_addr);
flush();
 
if (image_setup_libfdt(&img, (void *)fdt_addr, NULL))
@@ -93,21 +73,27 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
}
 #endif
 
-   if (!env_get_autostart())
-   return rcode;
-
-   printf("## Starting application at 0x%08lx ...\n", addr);
-   flush();
+   if (env_get_autostart()) {
+   flags.autostart = 1;
+   log_debug("Starting application at 0x%08lx ...\n", addr);
+   flush();
+   }
 
/*
 * pass address parameter as argv[0] (aka command name),
-* and all remaining args
+* and all remaining arguments
 */
-   rc = do_bootelf_exec((void *)addr, argc, argv);
+   rc = bootelf(addr, flags, argc, argv);
if (rc != 0)
-   rcode = 1;
+   rcode = CMD_RET_FAILURE;
 
-   printf("## Application terminated, rc = 0x%lx\n", rc);
+   if (flags.autostart)
+   {
+   if (ENOEXEC == errno)
+   log_err("Invalid ELF image\n");
+   else
+   log_debug("## Application terminated, rc = 0x%lx\n", 
rc);
+   }
 
return rcode;
 }
diff --git a/include/elf.h b/include/elf.h
index a4ba74d8ab..b88e6cf403 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -12,6 +12,12 @@
 #ifndef __ASSEMBLY__
 #include "compiler.h"
 
+/* Flag param bits for bootelf() function */
+typedef struct {
+   unsigned phdr  : 1; /* load via program (not section) headers */
+   unsigned autostart : 1; /* Start ELF after loading */
+} Bootelf_flags;
+
 /* This version doesn't work for 64-bit ABIs - Erik */
 
 /* These typedefs need to be handled better */
@@ -700,6 +706,10 @@ unsigned long elf_hash(const unsigned char *name);
 #define R_RISCV_RELATIVE   3
 
 #ifndef __ASSEMBLY__
+unsigned long bootelf_exec(ulong (*entry)(int, char * const[]),
+  int argc, char *const argv[]);
+unsigned long bootelf(unsigned long addr, Bootelf_flags flags,
+ int argc, char *const argv[]);
 int valid_elf_image(unsigned long addr);
 unsigned long load_elf64_image

Re: [PATCH v2 10/10] arch: arm: dts: k3-am62-sk-u-boot: Add missing "bootph-all" property to phy_gmii_sel node

2024-05-20 Thread Roger Quadros



On 20/05/2024 09:04, Chintan Vankar wrote:
> 
> 
> On 25/04/24 18:06, Chintan Vankar wrote:
>>
>>
>> On 25/04/24 18:01, Roger Quadros wrote:
>>>
>>>
>>> On 25/04/2024 15:08, Chintan Vankar wrote:
 Add "bootph-all" property to CPSW MAC's PHY node phy_gmii_sel.

 Signed-off-by: Chintan Vankar 
 ---

 Changes from v1 to v2:
 - This patch is newly added in this series to enable CPSW MAC's PHY
    node "phy_gmii_sel". As per discussion at here:
    https://lore.kernel.org/r/20240112130127.rvvrhz7p4vmlyalh@smother/
    changes made by this patch can be dropped in the future when the
    DT-Sync is performed with am62-main.dtsi containing this change in
    the Linux DT which will match U-Boot's DT.
>>>
>>> I don't think bootph-all exists in am62-main.dtsi. It should come from
>>> board.dts
>>>
>>
>> Yes, I am having the same discussion at here:
>> https://lore.kernel.org/all/c13ac165-7cbd-4e53-914e-8c6bc2825...@ti.com/
>>
> 
> Since I have posted patch which adds bootph-all property to
> "k3-am62x-sk-common.dtsi" at here:
> https://lore.kernel.org/r/20240430085048.3143665-1-c-van...@ti.com/
> and it has no open comments and this series
> also does not have any open comments, so can it be merged ?

Since bootph-all is being added to k3-am62x-sk-common.dtsi don't you have to 
drop patch 10
from this series?

> 

   arch/arm/dts/k3-am625-sk-u-boot.dtsi | 4 
   1 file changed, 4 insertions(+)

 diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
 b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
 index fa778b0ff4..e9a1afde95 100644
 --- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
 +++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
 @@ -46,3 +46,7 @@
   &cpsw_port2 {
   status = "disabled";
   };
 +
 +&phy_gmii_sel {
 +    bootph-all;
 +};
>>>

-- 
cheers,
-roger


Re: [PATCH v2 06/10] arm: mach-k3: am625_init: Probe AM65 CPSW NUSS

2024-05-20 Thread Roger Quadros



On 25/04/2024 15:59, Chintan Vankar wrote:
> 
> 
> On 25/04/24 17:57, Roger Quadros wrote:
>>
>>
>> On 25/04/2024 15:08, Chintan Vankar wrote:
>>> From: Kishon Vijay Abraham I 
>>>
>>> In order to support Ethernet boot on AM62x, probe AM65 CPSW NUSS
>>> driver in board_init_f().
>>>
>>> Signed-off-by: Kishon Vijay Abraham I 
>>> Signed-off-by: Siddharth Vadapalli 
>>> Signed-off-by: Chintan Vankar 
>>> ---
>>>
>>> Link to v1:
>>> https://lore.kernel.org/r/20240112064759.1801600-8-s-vadapa...@ti.com/
>>>
>>> Changes from v1 to v2:
>>> - No changes.
>>>
>>>   arch/arm/mach-k3/am625_init.c | 10 ++
>>>   1 file changed, 10 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c
>>> index 668f9a51ef..9bf61b1e83 100644
>>> --- a/arch/arm/mach-k3/am625_init.c
>>> +++ b/arch/arm/mach-k3/am625_init.c
>>> @@ -277,6 +277,16 @@ void board_init_f(ulong dummy)
>>>   if (ret)
>>>   panic("DRAM init failed: %d\n", ret);
>>>   }
>>> +
>>> +    if (IS_ENABLED(CONFIG_SPL_ETH) && IS_ENABLED(CONFIG_TI_AM65_CPSW_NUSS) 
>>> &&
>>> +    spl_boot_device() == BOOT_DEVICE_ETHERNET) {
>>> +    struct udevice *cpswdev;
>>> +
>>> +    if (uclass_get_device_by_driver(UCLASS_MISC, 
>>> DM_DRIVER_GET(am65_cpsw_nuss),
>>> +    &cpswdev))
>>> +    printf("Failed to probe am65_cpsw_nuss driver\n");
>>> +    }
>>> +
>>
>> This looks like a HACK.
>> The network driver should be probed only when the networking feature is 
>> actually required.
>>
> 
> Driver is probed only when the condition above
> "spl_boot_device() == BOOT_DEVICE_ETHERNET" is true, which says Boot
> device is Ethernet, and here we are booting with Ethernet so driver is
> getting probed.

I think you misunderstood what I was saying as am625_init.c is not using
any Ethernet function it should not cause the Ethernet driver to probe.

Instead it should be probed by the networking use case.

What happens if you don't use this patch? Where is it failing?

> 
>>>   spl_enable_cache();
>>>     fixup_a53_cpu_freq_by_speed_grade();
>>

-- 
cheers,
-roger


[PATCH v3] cmd: move ELF load and boot to lib/elf.c

2024-05-20 Thread Maxim Moskalets
From: Maxim Moskalets 

Loading and running the ELF image is the responsibility of the
library and should not be associated with the command line interface.

It is also required to run ELF images from FIT with the bootm command
so as not to depend on the command line interface.

Signed-off-by: Maxim Moskalets 
---
 cmd/elf.c | 53 --
 include/elf.h | 10 ++
 lib/elf.c | 54 +++
 3 files changed, 81 insertions(+), 36 deletions(-)

diff --git a/cmd/elf.c b/cmd/elf.c
index a02361f9f5..9e1df73aff 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -19,21 +19,6 @@
 #include 
 #endif
 
-/* Allow ports to override the default behavior */
-static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),
-int argc, char *const argv[])
-{
-   unsigned long ret;
-
-   /*
-* pass address parameter as argv[0] (aka command name),
-* and all remaining args
-*/
-   ret = entry(argc, argv);
-
-   return ret;
-}
-
 /* Interpreter command to boot an arbitrary ELF image from memory */
 int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
@@ -43,8 +28,8 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
 #endif
unsigned long addr; /* Address of the ELF image */
unsigned long rc; /* Return value from user code */
-   char *sload = NULL;
-   int rcode = 0;
+   int rcode = CMD_RET_SUCCESS;
+   Bootelf_flags flags = {0};
 
/* Consume 'bootelf' */
argc--; argv++;
@@ -52,7 +37,10 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
/* Check for [-p|-s] flag. */
if (argc >= 1 && (argv[0][0] == '-' && \
(argv[0][1] == 'p' || argv[0][1] == 's'))) {
-   sload = argv[0];
+   if (argv[0][1] == 'p')
+   flags.phdr = 1;
+   log_debug("Using ELF header format %s\n",
+   flags.phdr ? "phdr" : "shdr");
/* Consume flag. */
argc--; argv++;
}
@@ -75,17 +63,9 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
} else
addr = image_load_addr;
 
-   if (!valid_elf_image(addr))
-   return 1;
-
-   if (sload && sload[1] == 'p')
-   addr = load_elf_image_phdr(addr);
-   else
-   addr = load_elf_image_shdr(addr);
-
 #if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP)
if (fdt_addr) {
-   printf("## Setting up FDT at 0x%08lx ...\n", fdt_addr);
+   log_debug("Setting up FDT at 0x%08lx ...\n", fdt_addr);
flush();
 
if (image_setup_libfdt(&img, (void *)fdt_addr, NULL))
@@ -93,21 +73,22 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
}
 #endif
 
-   if (!env_get_autostart())
-   return rcode;
-
-   printf("## Starting application at 0x%08lx ...\n", addr);
-   flush();
+   if (env_get_autostart()) {
+   flags.autostart = 1;
+   log_debug("Starting application at 0x%08lx ...\n", addr);
+   flush();
+   }
 
/*
 * pass address parameter as argv[0] (aka command name),
-* and all remaining args
+* and all remaining arguments
 */
-   rc = do_bootelf_exec((void *)addr, argc, argv);
+   rc = bootelf(addr, flags, argc, argv);
if (rc != 0)
-   rcode = 1;
+   rcode = CMD_RET_FAILURE;
 
-   printf("## Application terminated, rc = 0x%lx\n", rc);
+   if (flags.autostart && rc && (ENOEXEC == errno))
+   log_err("Invalid ELF image\n");
 
return rcode;
 }
diff --git a/include/elf.h b/include/elf.h
index a4ba74d8ab..b88e6cf403 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -12,6 +12,12 @@
 #ifndef __ASSEMBLY__
 #include "compiler.h"
 
+/* Flag param bits for bootelf() function */
+typedef struct {
+   unsigned phdr  : 1; /* load via program (not section) headers */
+   unsigned autostart : 1; /* Start ELF after loading */
+} Bootelf_flags;
+
 /* This version doesn't work for 64-bit ABIs - Erik */
 
 /* These typedefs need to be handled better */
@@ -700,6 +706,10 @@ unsigned long elf_hash(const unsigned char *name);
 #define R_RISCV_RELATIVE   3
 
 #ifndef __ASSEMBLY__
+unsigned long bootelf_exec(ulong (*entry)(int, char * const[]),
+  int argc, char *const argv[]);
+unsigned long bootelf(unsigned long addr, Bootelf_flags flags,
+ int argc, char *const argv[]);
 int valid_elf_image(unsigned long addr);
 unsigned long load_elf64_image_phdr(unsigned long addr);
 unsigned long load_elf64_image_shdr(unsigned long addr);
diff --git a/lib/elf.c b/lib/elf.c
index 9a794f9cba..

[PATCH v3] cmd: move ELF load and boot to lib/elf.c

2024-05-20 Thread Maxim Moskalets
From: Maxim Moskalets 

Loading and running the ELF image is the responsibility of the
library and should not be associated with the command line interface.

It is also required to run ELF images from FIT with the bootm command
so as not to depend on the command line interface.

Signed-off-by: Maxim Moskalets 
---
 cmd/elf.c | 53 --
 include/elf.h | 10 ++
 lib/elf.c | 54 +++
 3 files changed, 81 insertions(+), 36 deletions(-)

diff --git a/cmd/elf.c b/cmd/elf.c
index a02361f9f5..9e1df73aff 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -19,21 +19,6 @@
 #include 
 #endif
 
-/* Allow ports to override the default behavior */
-static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),
-int argc, char *const argv[])
-{
-   unsigned long ret;
-
-   /*
-* pass address parameter as argv[0] (aka command name),
-* and all remaining args
-*/
-   ret = entry(argc, argv);
-
-   return ret;
-}
-
 /* Interpreter command to boot an arbitrary ELF image from memory */
 int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
@@ -43,8 +28,8 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
 #endif
unsigned long addr; /* Address of the ELF image */
unsigned long rc; /* Return value from user code */
-   char *sload = NULL;
-   int rcode = 0;
+   int rcode = CMD_RET_SUCCESS;
+   Bootelf_flags flags = {0};
 
/* Consume 'bootelf' */
argc--; argv++;
@@ -52,7 +37,10 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
/* Check for [-p|-s] flag. */
if (argc >= 1 && (argv[0][0] == '-' && \
(argv[0][1] == 'p' || argv[0][1] == 's'))) {
-   sload = argv[0];
+   if (argv[0][1] == 'p')
+   flags.phdr = 1;
+   log_debug("Using ELF header format %s\n",
+   flags.phdr ? "phdr" : "shdr");
/* Consume flag. */
argc--; argv++;
}
@@ -75,17 +63,9 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
} else
addr = image_load_addr;
 
-   if (!valid_elf_image(addr))
-   return 1;
-
-   if (sload && sload[1] == 'p')
-   addr = load_elf_image_phdr(addr);
-   else
-   addr = load_elf_image_shdr(addr);
-
 #if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP)
if (fdt_addr) {
-   printf("## Setting up FDT at 0x%08lx ...\n", fdt_addr);
+   log_debug("Setting up FDT at 0x%08lx ...\n", fdt_addr);
flush();
 
if (image_setup_libfdt(&img, (void *)fdt_addr, NULL))
@@ -93,21 +73,22 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
}
 #endif
 
-   if (!env_get_autostart())
-   return rcode;
-
-   printf("## Starting application at 0x%08lx ...\n", addr);
-   flush();
+   if (env_get_autostart()) {
+   flags.autostart = 1;
+   log_debug("Starting application at 0x%08lx ...\n", addr);
+   flush();
+   }
 
/*
 * pass address parameter as argv[0] (aka command name),
-* and all remaining args
+* and all remaining arguments
 */
-   rc = do_bootelf_exec((void *)addr, argc, argv);
+   rc = bootelf(addr, flags, argc, argv);
if (rc != 0)
-   rcode = 1;
+   rcode = CMD_RET_FAILURE;
 
-   printf("## Application terminated, rc = 0x%lx\n", rc);
+   if (flags.autostart && rc && (ENOEXEC == errno))
+   log_err("Invalid ELF image\n");
 
return rcode;
 }
diff --git a/include/elf.h b/include/elf.h
index a4ba74d8ab..b88e6cf403 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -12,6 +12,12 @@
 #ifndef __ASSEMBLY__
 #include "compiler.h"
 
+/* Flag param bits for bootelf() function */
+typedef struct {
+   unsigned phdr  : 1; /* load via program (not section) headers */
+   unsigned autostart : 1; /* Start ELF after loading */
+} Bootelf_flags;
+
 /* This version doesn't work for 64-bit ABIs - Erik */
 
 /* These typedefs need to be handled better */
@@ -700,6 +706,10 @@ unsigned long elf_hash(const unsigned char *name);
 #define R_RISCV_RELATIVE   3
 
 #ifndef __ASSEMBLY__
+unsigned long bootelf_exec(ulong (*entry)(int, char * const[]),
+  int argc, char *const argv[]);
+unsigned long bootelf(unsigned long addr, Bootelf_flags flags,
+ int argc, char *const argv[]);
 int valid_elf_image(unsigned long addr);
 unsigned long load_elf64_image_phdr(unsigned long addr);
 unsigned long load_elf64_image_shdr(unsigned long addr);
diff --git a/lib/elf.c b/lib/elf.c
index 9a794f9cba..

Fwd: [PATCH v2] cmd: move ELF load and boot to lib/elf.c

2024-05-20 Thread Максим Москалец
On 18.05.2024 12:40, Heinrich Schuchardt wrote:
> On 5/13/24 20:17, Maxim Moskalets wrote:
>> From: Maxim Moskalets 
>>
>> Loading and running the ELF image is the responsibility of the
>> library and should not be associated with the command line interface.
>>
>> It is also required to run ELF images from FIT with the bootm command
>> so as not to depend on the command line interface.
>>
>> Signed-off-by: Maxim Moskalets 
>> ---
>>   cmd/elf.c | 49 +
>>   include/elf.h | 10 ++
>>   lib/elf.c | 38 ++
>>   3 files changed, 65 insertions(+), 32 deletions(-)
>>
>> diff --git a/cmd/elf.c b/cmd/elf.c
>> index a02361f9f5..1fb955ae41 100644
>> --- a/cmd/elf.c
>> +++ b/cmd/elf.c
>> @@ -19,21 +19,6 @@
>>   #include 
>>   #endif
>>
>> -/* Allow ports to override the default behavior */
>> -static unsigned long do_bootelf_exec(ulong (*entry)(int, char *
>> const[]),
>> - int argc, char *const argv[])
>> -{
>> -unsigned long ret;
>> -
>> -/*
>> - * pass address parameter as argv[0] (aka command name),
>> - * and all remaining args
>
> Carving out the library function is a good idea.
>
> Nits
>
> %s/args/arguments/
>
>> - */
>> -ret = entry(argc, argv);
>> -
>> -return ret;
>> -}
>> -
>>   /* Interpreter command to boot an arbitrary ELF image from memory */
>
> Please, document functions fully:
>
>
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
>
>
> The preferred place for documenting exported functions is in the header
> file.
>

Not my code, but okay.

>>   int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char
>> *const argv[])
>>   {
>> @@ -43,8 +28,8 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int
>> argc, char *const argv[])
>>   #endif
>>   unsigned long addr; /* Address of the ELF image */
>>   unsigned long rc; /* Return value from user code */
>> -char *sload = NULL;
>>   int rcode = 0;
>
> Maybe
>
> %s/0/CMD_RET_SUCCESS/
>
>> +Bootelf_flags flags = {0};
>>
>>   /* Consume 'bootelf' */
>>   argc--; argv++;
>> @@ -52,7 +37,10 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag,
>> int argc, char *const argv[])
>>   /* Check for [-p|-s] flag. */
>>   if (argc >= 1 && (argv[0][0] == '-' && \
>>   (argv[0][1] == 'p' || argv[0][1] == 's'))) {
>> -sload = argv[0];
>> +if (argv[0][1] == 'p')
>> +flags.phdr = 1;
>> +printf("## Try to elf hdr format %s\n",
>> +flags.phdr ? "phdr" : "shdr");
>
> Please, use log_debug() for debug messages and avoid the '## ' noise.
>
> Do you mean:
>
> log_debug("Using ELF header format %s\n",
>

It was in original implementation, but i can fix.

>>   /* Consume flag. */
>>   argc--; argv++;
>>   }
>> @@ -75,14 +63,6 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag,
>> int argc, char *const argv[])
>>   } else
>>   addr = image_load_addr;
>>
>> -if (!valid_elf_image(addr))
>> -return 1;
>> -
>> -if (sload && sload[1] == 'p')
>> -addr = load_elf_image_phdr(addr);
>> -else
>> -addr = load_elf_image_shdr(addr);
>> -
>>   #if CONFIG_IS_ENABLED(CMD_ELF_FDT_SETUP)
>>   if (fdt_addr) {
>>   printf("## Setting up FDT at 0x%08lx ...\n", fdt_addr);
>
> This looks like a debug message too.
>
>> @@ -93,21 +73,26 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag,
>> int argc, char *const argv[])
>>   }
>>   #endif
>>
>> -if (!env_get_autostart())
>> -return rcode;
>> -
>> -printf("## Starting application at 0x%08lx ...\n", addr);
>> -flush();
>> +if (env_get_autostart()) {
>> +flags.autostart = 1;
>> +printf("## Starting application at 0x%08lx ...\n", addr);
>
> log_debug("Starting application at 0x%08lx ...\n", addr);
>
>> +flush();
>> +}
>>
>>   /*
>>* pass address parameter as argv[0] (aka command name),
>>* and all remaining args
>>*/
>> -rc = do_bootelf_exec((void *)addr, argc, argv);
>> +rc = bootelf(addr, flags, argc, argv);
>>   if (rc != 0)
>>   rcode = 1;
>
> %s/1/CMD_RET_FAILURE/
>
>>
>> -printf("## Application terminated, rc = 0x%lx\n", rc);
>> +if (flags.autostart) {
>> +if (ENOEXEC == errno)
>
> if (rc && ENOEXEC == errno)
>
>> +printf("## Invalid ELF image\n");
>
> log_err("Invalid ELF image\n");
>
>> +else
>> +printf("## Application terminated, rc = 0x%lx\n", rc);
>
> This message is only relevant if the application failed:
>
> else if (rc)
> log_err("Application failed, rc = 0x%lx\n", rc);
>
>> +}
>>
>>   return rcode;
>>   }
>> diff --git a/include/elf.h b/include/elf.h
>> index a4ba74d8ab..b88e6cf403 100644
>> --- a/include/elf.h
>> +++ b/include/elf.h
>> @@ -12,6 +12,12 @@
>>   #ifndef __ASSEMBLY__
>>   #include "compiler.h"
>>
>> +/* Fla

Re: [PATCH FOR TESTING ONLY RFC 4/4] sunxi-d1s-t113: Add D1 and T113 PWM node

2024-05-20 Thread Sumit Garg
On Sat, 18 May 2024 at 09:25, John Watts  wrote:
>
> This is based on the binding from the as yet unmerged kernel series:
>
> https://lore.kernel.org/linux-kernel/20240131125920.2879433-2-privates...@gmail.com/
>
> Signed-off-by: John Watts 
> ---
>  arch/riscv/dts/sunxi-d1s-t113.dtsi   | 12 
>  dts/upstream/src/riscv/allwinner/sunxi-d1s-t113.dtsi | 12 
>  2 files changed, 24 insertions(+)
>
> diff --git a/arch/riscv/dts/sunxi-d1s-t113.dtsi 
> b/arch/riscv/dts/sunxi-d1s-t113.dtsi
> index 822f022eec..92b6432f77 100644
> --- a/arch/riscv/dts/sunxi-d1s-t113.dtsi
> +++ b/arch/riscv/dts/sunxi-d1s-t113.dtsi
> @@ -145,6 +145,18 @@
> };
> };
>
> +   pwm: pwm@2000c00 {
> +   compatible = "allwinner,sun20i-d1-pwm";
> +   reg = <0x02000c00 0x400>;
> +   clocks = <&ccu CLK_BUS_PWM>,
> +<&dcxo>,
> +<&ccu CLK_APB0>;
> +   clock-names = "bus", "hosc", "apb0";
> +   resets = <&ccu RST_BUS_PWM>;
> +   status = "disabled";
> +   #pwm-cells = <0x3>;
> +   };
> +
> ccu: clock-controller@2001000 {
> compatible = "allwinner,sun20i-d1-ccu";
> reg = <0x2001000 0x1000>;
> diff --git a/dts/upstream/src/riscv/allwinner/sunxi-d1s-t113.dtsi 
> b/dts/upstream/src/riscv/allwinner/sunxi-d1s-t113.dtsi
> index 5a9d7f5a75..435a1e66aa 100644
> --- a/dts/upstream/src/riscv/allwinner/sunxi-d1s-t113.dtsi
> +++ b/dts/upstream/src/riscv/allwinner/sunxi-d1s-t113.dtsi
> @@ -145,6 +145,18 @@
> };
> };
>
> +   pwm: pwm@2000c00 {
> +   compatible = "allwinner,sun20i-d1-pwm";
> +   reg = <0x02000c00 0x400>;
> +   clocks = <&ccu CLK_BUS_PWM>,
> +<&dcxo>,
> +<&ccu CLK_APB0>;
> +   clock-names = "bus", "hosc", "apb0";
> +   resets = <&ccu RST_BUS_PWM>;
> +   status = "disabled";
> +   #pwm-cells = <0x3>;
> +   };
> +

This change shouldn't be needed for your testing purposes too. It only
comes into picture once you enable OF_UPSTREAM. BTW, DT source files
in dts/upstream are strictly following/syncing against Linux kernel DT
sources. So all the custom U-Boot specific DT stuff belongs to
arch/${ARCH}/dts/.

-Sumit

> ccu: clock-controller@2001000 {
> compatible = "allwinner,sun20i-d1-ccu";
> reg = <0x2001000 0x1000>;
>
> --
> 2.45.1
>


Re: [RESEND PATCH 4/4] omap3: igep0x00: Migrate to use upstream DT

2024-05-20 Thread Sumit Garg
On Sat, 18 May 2024 at 18:36, Javier Martinez Canillas
 wrote:
>
> From: Javier Martinez Canillas 
>
> Enable OF_UPSTREAM to use upstream DT and add a ti/omap/ prefix to the
> DEFAULT_DEVICE_TREE config option.
>
> That way, a DTS from the upstream dts/upstream/src/ directory is used
> instead of the arch/$(ARCH)/dts/ directory. These in turn are removed.
>
> Signed-off-by: Javier Martinez Canillas 
> ---
>
>  arch/arm/dts/Makefile   |   3 -
>  arch/arm/dts/omap3-igep.dtsi| 247 --
>  arch/arm/dts/omap3-igep0020-common.dtsi | 261 
>  arch/arm/dts/omap3-igep0020.dts |  47 -
>  configs/igep00x0_defconfig  |   3 +-
>  5 files changed, 2 insertions(+), 559 deletions(-)
>  delete mode 100644 arch/arm/dts/omap3-igep.dtsi
>  delete mode 100644 arch/arm/dts/omap3-igep0020-common.dtsi
>  delete mode 100644 arch/arm/dts/omap3-igep0020.dts
>

Acked-by: Sumit Garg 

-Sumit

> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index a5c82ebf7a5f..a9bd4921718e 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -1030,9 +1030,6 @@ dtb-$(CONFIG_TARGET_OMAP3_BEAGLE) += \
>
>  dtb-$(CONFIG_TARGET_DEVKIT8000) += omap3-devkit8000.dtb
>
> -dtb-$(CONFIG_TARGET_OMAP3_IGEP00X0) += \
> -   omap3-igep0020.dtb
> -
>  dtb-$(CONFIG_TARGET_OMAP4_PANDA) += \
> omap4-panda.dtb \
> omap4-panda-es.dtb
> diff --git a/arch/arm/dts/omap3-igep.dtsi b/arch/arm/dts/omap3-igep.dtsi
> deleted file mode 100644
> index 219202610463..
> --- a/arch/arm/dts/omap3-igep.dtsi
> +++ /dev/null
> @@ -1,247 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * Common device tree for IGEP boards based on AM/DM37x
> - *
> - * Copyright (C) 2012 Javier Martinez Canillas 
> - * Copyright (C) 2012 Enric Balletbo i Serra 
> - */
> -/dts-v1/;
> -
> -#include "omap36xx.dtsi"
> -
> -/ {
> -   memory@8000 {
> -   device_type = "memory";
> -   reg = <0x8000 0x2000>; /* 512 MB */
> -   };
> -
> -   chosen {
> -   stdout-path = &uart3;
> -   };
> -
> -   sound {
> -   compatible = "ti,omap-twl4030";
> -   ti,model = "igep2";
> -   ti,mcbsp = <&mcbsp2>;
> -   };
> -
> -   vdd33: regulator-vdd33 {
> -   compatible = "regulator-fixed";
> -   regulator-name = "vdd33";
> -   regulator-always-on;
> -   };
> -
> -};
> -
> -&omap3_pmx_core {
> -   gpmc_pins: pinmux_gpmc_pins {
> -   pinctrl-single,pins = <
> -   /* OneNAND seems to require PIN_INPUT on clock. */
> -OMAP3_CORE1_IOPAD(0x20be, PIN_INPUT | MUX_MODE0) 
>/* gpmc_clk.gpmc_clk */
> -   >;
> -   };
> -
> -   uart1_pins: pinmux_uart1_pins {
> -   pinctrl-single,pins = <
> -   OMAP3_CORE1_IOPAD(0x2182, PIN_INPUT | MUX_MODE0)  
>   /* uart1_rx.uart1_rx */
> -   OMAP3_CORE1_IOPAD(0x217c, PIN_OUTPUT | MUX_MODE0) 
>   /* uart1_tx.uart1_tx */
> -   >;
> -   };
> -
> -   uart3_pins: pinmux_uart3_pins {
> -   pinctrl-single,pins = <
> -   OMAP3_CORE1_IOPAD(0x219e, PIN_INPUT | MUX_MODE0)  
>   /* uart3_rx.uart3_rx */
> -   OMAP3_CORE1_IOPAD(0x21a0, PIN_OUTPUT | MUX_MODE0) 
>   /* uart3_tx.uart3_tx */
> -   >;
> -   };
> -
> -   mcbsp2_pins: pinmux_mcbsp2_pins {
> -   pinctrl-single,pins = <
> -   OMAP3_CORE1_IOPAD(0x213c, PIN_INPUT | MUX_MODE0)  
>   /* mcbsp2_fsx.mcbsp2_fsx */
> -   OMAP3_CORE1_IOPAD(0x213e, PIN_INPUT | MUX_MODE0)  
>   /* mcbsp2_clkx.mcbsp2_clkx */
> -   OMAP3_CORE1_IOPAD(0x2140, PIN_INPUT | MUX_MODE0)  
>   /* mcbsp2_dr.mcbsp2.dr */
> -   OMAP3_CORE1_IOPAD(0x2142, PIN_OUTPUT | MUX_MODE0) 
>   /* mcbsp2_dx.mcbsp2_dx */
> -   >;
> -   };
> -
> -   mmc1_pins: pinmux_mmc1_pins {
> -   pinctrl-single,pins = <
> -   OMAP3_CORE1_IOPAD(0x2144, PIN_INPUT_PULLUP | 
> MUX_MODE0) /* sdmmc1_clk.sdmmc1_clk */
> -   OMAP3_CORE1_IOPAD(0x2146, PIN_INPUT_PULLUP | 
> MUX_MODE0) /* sdmmc1_cmd.sdmmc1_cmd */
> -   OMAP3_CORE1_IOPAD(0x2148, PIN_INPUT_PULLUP | 
> MUX_MODE0) /* sdmmc1_dat0.sdmmc1_dat0 */
> -   OMAP3_CORE1_IOPAD(0x214a, PIN_INPUT_PULLUP | 
> MUX_MODE0) /* sdmmc1_dat1.sdmmc1_dat1 */
> -   OMAP3_CORE1_IOPAD(0x214c, PIN_INPUT_PULLUP | 
> MUX_MODE0) /* sdmmc1_dat2.sdmmc1_dat2 */
> -   OMAP3_CORE1_IOPAD(0x214e, PIN_INPUT_PULLUP | 
> MUX_MODE0) /* sdmmc1_dat3.sdmmc1_dat3 */
> -   >;
> -   };
> -
> -   mmc2_pins: pinmux_mmc2_pins {
> -   pinctrl-single,pins = <
> - 

Re: [PATCH 08/10] dts/upsteam: Add Makefile for xtensa

2024-05-20 Thread Sumit Garg
On Mon, 20 May 2024 at 02:24, Jiaxun Yang  wrote:
>
> It is required to get it xtensa OF_UPSTREAM work.
>
> Signed-off-by: Jiaxun Yang 
> ---
>  dts/upstream/src/xtensa/Makefile | 14 ++
>  1 file changed, 14 insertions(+)
>

Reviewed-by: Sumit Garg 

-Sumit

> diff --git a/dts/upstream/src/xtensa/Makefile 
> b/dts/upstream/src/xtensa/Makefile
> new file mode 100644
> index ..2a81acb32bc3
> --- /dev/null
> +++ b/dts/upstream/src/xtensa/Makefile
> @@ -0,0 +1,14 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +
> +include $(srctree)/scripts/Makefile.dts
> +
> +targets += $(dtb-y)
> +
> +# Add any required device tree compiler flags here
> +DTC_FLAGS += -a 0x8
> +
> +PHONY += dtbs
> +dtbs: $(addprefix $(obj)/, $(dtb-y))
> +   @:
> +
> +clean-files := *.dtb *.dtbo */*.dtb */*.dtbo
>
> --
> 2.43.0
>


[PATCH 2/3] configs: j721e_sk: Move to separate defconfig for J721E SK board

2024-05-20 Thread Neha Malcom Francis
Add defconfig for J721E SK R5 and A72 configuration.

This includes and modifies the J721E EVM defconfigs:
j721e_evm_r5_defconfig -> j721e_sk_r5_defconfig
j721e_evm_a72_defconfig -> j721e_sk_a72_defconfig

Signed-off-by: Neha Malcom Francis 
---
 arch/arm/dts/k3-j721e-binman.dtsi| 99 ++--
 arch/arm/dts/k3-j721e-sk-u-boot.dtsi | 23 +++
 board/ti/j721e/MAINTAINERS   |  2 +
 configs/j721e_evm_a72_defconfig  |  2 +-
 configs/j721e_evm_r5_defconfig   |  2 +-
 configs/j721e_sk_a72_defconfig   |  9 +++
 configs/j721e_sk_r5_defconfig| 10 +++
 7 files changed, 52 insertions(+), 95 deletions(-)
 create mode 100644 configs/j721e_sk_a72_defconfig
 create mode 100644 configs/j721e_sk_r5_defconfig

diff --git a/arch/arm/dts/k3-j721e-binman.dtsi 
b/arch/arm/dts/k3-j721e-binman.dtsi
index 75a6e9599b9..2867d264664 100644
--- a/arch/arm/dts/k3-j721e-binman.dtsi
+++ b/arch/arm/dts/k3-j721e-binman.dtsi
@@ -212,10 +212,7 @@
 #ifdef CONFIG_TARGET_J721E_A72_EVM
 
 #define SPL_J721E_EVM_DTB "spl/dts/k3-j721e-common-proc-board.dtb"
-#define SPL_J721E_SK_DTB "spl/dts/k3-j721e-sk.dtb"
-
 #define J721E_EVM_DTB "u-boot.dtb"
-#define J721E_SK_DTB "arch/arm/dts/k3-j721e-sk.dtb"
 
 &binman {
ti-dm {
@@ -361,28 +358,13 @@
arch = "arm";
compression = "none";
ti-secure {
-   content = <&spl_j721e_evm_dtb>;
+   content = <&spl_j721e_dtb>;
keyfile = "custMpk.pem";
};
-   spl_j721e_evm_dtb: blob-ext {
+   spl_j721e_dtb: blob-ext {
filename = SPL_J721E_EVM_DTB;
};
};
-
-   fdt-1 {
-   description = "k3-j721e-sk";
-   type = "flat_dt";
-   arch = "arm";
-   compression = "none";
-   ti-secure {
-   content = <&spl_j721e_sk_dtb>;
-   keyfile = "custMpk.pem";
-
-   };
-   spl_j721e_sk_dtb: blob-ext {
-   filename = SPL_J721E_SK_DTB;
-   };
-   };
};
 
configurations {
@@ -394,13 +376,6 @@
loadables = "tee", "dm", "spl";
fdt = "fdt-0";
};
-
-   conf-1 {
-   description = "k3-j721e-sk";
-   firmware = "atf";
-   loadables = "tee", "dm", "spl";
-   fdt = "fdt-1";
-   };
};
};
};
@@ -422,35 +397,17 @@
arch = "arm";
compression = "none";
ti-secure {
-   content = <&j721e_evm_dtb>;
+   content = <&j721e_dtb>;
keyfile = "custMpk.pem";
 
};
-   j721e_evm_dtb: blob-ext {
+   j721e_dtb: blob-ext {
filename = J721E_EVM_DTB;
};
hash {
algo = "crc32";
};
};
-
-   fdt-1 {
-   description = "k3-j721e-sk";
-   type = "flat_dt";
-   arch = "arm";
-   compression = "none";
-   ti-secure {
-   content = <&j721e_sk_dtb>;
-   keyfile = "custMpk.pem";
-
-   };
-   j721e_sk_dtb: blob-ext {
-   filename = J721E_SK_DTB;
-   

[PATCH 1/3] arm: dts: k3-j721e-r5*: Introduce k3-j721e-r5.dtsi

2024-05-20 Thread Neha Malcom Francis
Introduce k3-j721e-r5.dtsi to be used by board R5 DTS files. This
helps sync SoC changes across boards.

Signed-off-by: Neha Malcom Francis 
---
 arch/arm/dts/k3-j721e-r5-beagleboneai64.dts   | 78 +-
 .../arm/dts/k3-j721e-r5-common-proc-board.dts | 75 +
 arch/arm/dts/k3-j721e-r5-sk.dts   | 75 +
 arch/arm/dts/k3-j721e-r5.dtsi | 80 +++
 4 files changed, 83 insertions(+), 225 deletions(-)
 create mode 100644 arch/arm/dts/k3-j721e-r5.dtsi

diff --git a/arch/arm/dts/k3-j721e-r5-beagleboneai64.dts 
b/arch/arm/dts/k3-j721e-r5-beagleboneai64.dts
index 43da4dafba8..4f97af4fd94 100644
--- a/arch/arm/dts/k3-j721e-r5-beagleboneai64.dts
+++ b/arch/arm/dts/k3-j721e-r5-beagleboneai64.dts
@@ -12,84 +12,8 @@
 #include "k3-j721e-ddr.dtsi"
 
 #include "k3-j721e-beagleboneai64-u-boot.dtsi"
+#include "k3-j721e-r5.dtsi"
 
-/ {
-   aliases {
-   remoteproc0 = &sysctrler;
-   remoteproc1 = &a72_0;
-   };
-
-   chosen {
-   tick-timer = &mcu_timer0;
-   };
-
-   a72_0: a72@0 {
-   compatible = "ti,am654-rproc";
-   reg = <0x0 0x00a9 0x0 0x10>;
-   power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>,
-   <&k3_pds 202 TI_SCI_PD_EXCLUSIVE>,
-   <&k3_pds 4 TI_SCI_PD_EXCLUSIVE>;
-   resets = <&k3_reset 202 0>;
-   clocks = <&k3_clks 61 1>;
-   assigned-clocks = <&k3_clks 202 2>, <&k3_clks 61 1>;
-   assigned-clock-rates = <20>, <2>;
-   ti,sci = <&dmsc>;
-   ti,sci-proc-id = <32>;
-   ti,sci-host-id = <10>;
-   bootph-pre-ram;
-   };
-
-   dm_tifs: dm-tifs {
-   compatible = "ti,j721e-dm-sci";
-   ti,host-id = <3>;
-   ti,secure-host;
-   mbox-names = "rx", "tx";
-   mboxes= <&secure_proxy_mcu 21>,
-   <&secure_proxy_mcu 23>;
-   bootph-pre-ram;
-   };
-};
-
-&dmsc {
-   mboxes= <&secure_proxy_mcu 6>,
-   <&secure_proxy_mcu 8>,
-   <&secure_proxy_mcu 5>;
-   mbox-names = "rx", "tx", "notify";
-   ti,host-id = <4>;
-   ti,secure-host;
-};
-
-&mcu_timer0 {
-   status = "okay";
-   bootph-pre-ram;
-};
-
-&secure_proxy_mcu {
-   bootph-pre-ram;
-   /* We require this for boot handshake */
-   status = "okay";
-};
-
-&cbass_mcu_wakeup {
-   sysctrler: sysctrler {
-   compatible = "ti,am654-system-controller";
-   mboxes= <&secure_proxy_mcu 4>, <&secure_proxy_mcu 5>;
-   mbox-names = "tx", "rx";
-   bootph-pre-ram;
-   };
-};
-
-&mcu_ringacc {
-   ti,sci = <&dm_tifs>;
-};
-
-&mcu_udmap {
-   ti,sci = <&dm_tifs>;
-};
-
-&wkup_uart0_pins_default {
-   bootph-pre-ram;
-};
 
 &wkup_i2c0 {
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 9655ca21d02..c7e344350c8 100644
--- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts
+++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts
@@ -10,76 +10,7 @@
 #include "k3-j721e-ddr.dtsi"
 #include "k3-j721e-common-proc-board-u-boot.dtsi"
 
-/ {
-   chosen {
-   tick-timer = &mcu_timer0;
-   };
-
-   aliases {
-   remoteproc0 = &sysctrler;
-   remoteproc1 = &a72_0;
-   };
-
-   a72_0: a72@0 {
-   compatible = "ti,am654-rproc";
-   reg = <0x0 0x00a9 0x0 0x10>;
-   power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>,
-   <&k3_pds 202 TI_SCI_PD_EXCLUSIVE>,
-   <&k3_pds 4 TI_SCI_PD_EXCLUSIVE>;
-   resets = <&k3_reset 202 0>;
-   clocks = <&k3_clks 61 1>;
-   assigned-clocks = <&k3_clks 202 2>, <&k3_clks 61 1>;
-   assigned-clock-rates = <20>, <2>;
-   ti,sci = <&dmsc>;
-   ti,sci-proc-id = <32>;
-   ti,sci-host-id = <10>;
-   bootph-pre-ram;
-   };
-
-   dm_tifs: dm-tifs {
-   compatible = "ti,j721e-dm-sci";
-   ti,host-id = <3>;
-   ti,secure-host;
-   mbox-names = "rx", "tx";
-   mboxes= <&secure_proxy_mcu 21>,
-   <&secure_proxy_mcu 23>;
-   bootph-pre-ram;
-   };
-};
-
-&mcu_timer0 {
-   status = "okay";
-   bootph-pre-ram;
-};
-
-&dmsc {
-   mboxes= <&secure_proxy_mcu 8>, <&secure_proxy_mcu 6>, 
<&secure_proxy_mcu 5>;
-   mbox-names = "tx", "rx", "notify";
-   ti,host-id = <4>;
-   ti,secure-host;
-};
-
-&secure_proxy_mcu {
-   bootph-pre-ram;
-   status = "okay";
-};
-
-&cbass_mcu_wakeup {
-   sysctrler: sysctrler {
-   bootph-pre-ram;

[PATCH 0/3] k3-j721e: Enable OF_UPSTREAM for J721E

2024-05-20 Thread Neha Malcom Francis
This series was plucked out from the larger series [1] that did some
templating reformatting and also enabled OF_UPSTREAM for J721E. The
former has been kept aside till all the platforms affected have moved to
using OF_UPSTREAM to have less conflicts while merging.

Patches split J721E EVM and J721E SK to using separate builds, as well
as enable OF_UPSTREAM for both the platforms.

Boot logs:
https://gist.github.com/nehamalcom/8f326376b6c6b1196084721405159bb9

[1] https://lore.kernel.org/all/20240322131011.1029620-1-n-fran...@ti.com/

Neha Malcom Francis (3):
  arm: dts: k3-j721e-r5*: Introduce k3-j721e-r5.dtsi
  configs: j721e_sk: Move to separate defconfig for J721E SK board
  arm: dts: k3-j721e: Move to OF_UPSTREAM

 arch/arm/dts/Makefile |4 +-
 arch/arm/dts/k3-j721e-binman.dtsi |  101 +-
 .../k3-j721e-common-proc-board-u-boot.dtsi|   14 +-
 arch/arm/dts/k3-j721e-common-proc-board.dts   |  976 --
 arch/arm/dts/k3-j721e-main.dtsi   | 2741 -
 arch/arm/dts/k3-j721e-mcu-wakeup.dtsi |  681 
 arch/arm/dts/k3-j721e-r5-beagleboneai64.dts   |   78 +-
 .../arm/dts/k3-j721e-r5-common-proc-board.dts |   75 +-
 arch/arm/dts/k3-j721e-r5-sk.dts   |   75 +-
 arch/arm/dts/k3-j721e-r5.dtsi |   80 +
 arch/arm/dts/k3-j721e-sk-u-boot.dtsi  |   41 +-
 arch/arm/dts/k3-j721e-sk.dts  | 1074 ---
 arch/arm/dts/k3-j721e-som-p0.dtsi |  446 ---
 arch/arm/dts/k3-j721e-thermal.dtsi|   75 -
 arch/arm/dts/k3-j721e.dtsi|  176 --
 board/ti/j721e/MAINTAINERS|2 +
 configs/j721e_evm_a72_defconfig   |5 +-
 configs/j721e_evm_r5_defconfig|2 +-
 configs/j721e_sk_a72_defconfig|9 +
 configs/j721e_sk_r5_defconfig |   10 +
 20 files changed, 147 insertions(+), 6518 deletions(-)
 delete mode 100644 arch/arm/dts/k3-j721e-common-proc-board.dts
 delete mode 100644 arch/arm/dts/k3-j721e-main.dtsi
 delete mode 100644 arch/arm/dts/k3-j721e-mcu-wakeup.dtsi
 create mode 100644 arch/arm/dts/k3-j721e-r5.dtsi
 delete mode 100644 arch/arm/dts/k3-j721e-sk.dts
 delete mode 100644 arch/arm/dts/k3-j721e-som-p0.dtsi
 delete mode 100644 arch/arm/dts/k3-j721e-thermal.dtsi
 delete mode 100644 arch/arm/dts/k3-j721e.dtsi
 create mode 100644 configs/j721e_sk_a72_defconfig
 create mode 100644 configs/j721e_sk_r5_defconfig

-- 
2.34.1



Re: [PATCH] ARM: dts: renesas: Reserve space in 64bit R-Car DTs

2024-05-20 Thread Sumit Garg
On Mon, 20 May 2024 at 02:11, Marek Vasut
 wrote:
>
> Reserve 4 kiB of space in 64bit R-Car DTs when those DTs are compiled
> to permit patching in OpTee-OS /firmware node, /reserved-memory node,
> possibly also additional /memory@ nodes and RPC node by TFA.
>
> This duplicates behavior in arch/arm/dts/Makefile with OF_UPSTREAM.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Sumit Garg 
> Cc: Tom Rini 
> ---
>  dts/upstream/src/arm64/Makefile | 4 
>  1 file changed, 4 insertions(+)
>

Reviewed-by: Sumit Garg 

-Sumit

> diff --git a/dts/upstream/src/arm64/Makefile b/dts/upstream/src/arm64/Makefile
> index 9a8f6aa3584..26a83d3d29d 100644
> --- a/dts/upstream/src/arm64/Makefile
> +++ b/dts/upstream/src/arm64/Makefile
> @@ -7,6 +7,10 @@ targets += $(dtb-y)
>  # Add any required device tree compiler flags here
>  DTC_FLAGS += -a 0x8
>
> +ifdef CONFIG_RCAR_64
> +DTC_FLAGS += -R 4 -p 0x1000
> +endif
> +
>  PHONY += dtbs
>  dtbs: $(addprefix $(obj)/, $(dtb-y))
> @:
> --
> 2.43.0
>


Re: [PATCH v3 11/12] MIPS: boston: Migrate to OF_UPSTREAM

2024-05-20 Thread Sumit Garg
On Mon, 20 May 2024 at 04:17, Tom Rini  wrote:
>
> On Sun, May 19, 2024 at 09:57:03PM +0100, Jiaxun Yang wrote:
> >
> >
> > 在2024年5月19日五月 下午7:20,Daniel Schwierzeck写道:
> > >
> > > Reviewed-by: Daniel Schwierzeck 
> > >
> > Hi Daniel,
> >
> > Thanks for reviewing the series.
> > >
> > [...]
> > >
> > > should be 'select' because the switch to upstream DTS is permanent and
> > > it does not make sense for the user to be able to deselect this option
> > >
> >
> > Do you want me to send another version or are you going to fix
> > it as you apply the patch?
>
> So, in the case of OF_UPTREAM, it's "imply OF_UPSTREAM" everywhere else
> and while there's a case to be made it should be select instead, that's
> probably a future clean-up for all users.

I think it depends on whether OF_UPSTREAM is enabled for a SoC (with
multiple board variants) or a single target board (I suppose that's
the case here). For the former case, "imply" would be preferred since
we can't enforce a policy at SoC level where new boards are coming up
which have to opt out of OF_UPSTREAM. For the latter case, "select"
would be preferred. However, I agree that it can be a future cleanup
patch.

-Sumit

>
> --
> Tom


Re: [PATCH v2] fdt: automatically add /chosen/kaslr-seed if DM_RNG is enabled

2024-05-20 Thread Michal Simek

Hi Tim,

On 5/16/24 17:58, Tim Harvey wrote:

On Wed, May 15, 2024 at 1:50 PM Tim Harvey  wrote:


If RANDOMIZE_BASE is enabled in the Linux kernel instructing it to
randomize the virtual address at which the kernel image is loaded, it
expects entropy to be provided by the bootloader by populating
/chosen/kaslr-seed with a 64-bit value from source of entropy at boot.

If we have DM_RNG enabled populate this value automatically when
fdt_chosen is called unless ARMV8_SEC_FIRMWARE_SUPPORT is enabled as
it's implementation uses a different source of entropy.

As this fdt node is added elsewhere create a library function and
use it to deduplicate code.

Note that the kalsrseed command (CMD_KASLRSEED) is likely pointless now
but left in place in case boot scripts exist that rely on this command
existing and returning success. An informational message is printed to
alert users of this command that it is likely no longer needed.

Signed-off-by: Tim Harvey 
---
v2:
  - fix typo in commit msg
  - use stack for seed to avoid unecessary malloc/free
  - move to a library function and deduplicate code by using it elsewhere
---
  board/xilinx/common/board.c | 35 -
  boot/fdt_support.c  | 10 +
  boot/pxe_utils.c| 35 +++--
  cmd/kaslrseed.c | 45 ++---
  include/kaslrseed.h | 17 ++
  lib/Makefile|  1 +
  lib/kaslrseed.c | 34 
  7 files changed, 72 insertions(+), 105 deletions(-)
  create mode 100644 include/kaslrseed.h
  create mode 100644 lib/kaslrseed.c

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 30a81376ac41..f741e8957818 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -713,41 +713,6 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS) && 
IS_ENABLED(CONFIG_NAND_ZYNQ))
 fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));

-   if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
-   debug("No RNG device\n");
-   return 0;
-   }
-
-   if (dm_rng_read(dev, buf, n)) {
-   debug("Reading RNG failed\n");
-   return 0;
-   }
-
-   if (!blob) {
-   debug("No FDT memory address configured. Please configure\n"
- "the FDT address via \"fdt addr \" command.\n"
- "Aborting!\n");
-   return 0;
-   }
-
-   ret = fdt_check_header(blob);
-   if (ret < 0) {
-   debug("fdt_chosen: %s\n", fdt_strerror(ret));
-   return ret;
-   }
-
-   nodeoffset = fdt_find_or_add_subnode(blob, 0, "chosen");
-   if (nodeoffset < 0) {
-   debug("Reading chosen node failed\n");
-   return nodeoffset;
-   }
-
-   ret = fdt_setprop(blob, nodeoffset, "kaslr-seed", buf, sizeof(buf));
-   if (ret < 0) {
-   debug("Unable to set kaslr-seed on chosen node: %s\n", 
fdt_strerror(ret));
-   return ret;
-   }
-
 return 0;
  }
  #endif
diff --git a/boot/fdt_support.c b/boot/fdt_support.c
index 874ca4d6f5af..3455d60d69dc 100644
--- a/boot/fdt_support.c
+++ b/boot/fdt_support.c
@@ -8,6 +8,7 @@

  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -300,6 +301,15 @@ int fdt_chosen(void *fdt)
 if (nodeoffset < 0)
 return nodeoffset;

+   if (IS_ENABLED(CONFIG_DM_RNG) && 
!IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT)) {
+   err = fdt_kaslrseed(fdt);
+   if (err) {
+   printf("WARNING: could not set kaslr-seed %s.\n",
+  fdt_strerror(err));
+   return err;
+   }
+   }
+
 if (IS_ENABLED(CONFIG_BOARD_RNG_SEED) && !board_rng_seed(&buf)) {
 err = fdt_setprop(fdt, nodeoffset, "rng-seed",
   abuf_data(&buf), abuf_size(&buf));
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 4b22bb6f525a..8d70233fc08d 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -8,6 +8,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -323,10 +324,6 @@ static void label_boot_kaslrseed(void)
  #if CONFIG_IS_ENABLED(DM_RNG)
 ulong fdt_addr;
 struct fdt_header *working_fdt;
-   size_t n = 0x8;
-   struct udevice *dev;
-   u64 *buf;
-   int nodeoffset;
 int err;

 /* Get the main fdt and map it */
@@ -342,35 +339,9 @@ static void label_boot_kaslrseed(void)
 if (err <= 0)
 return;

-   if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
-   printf("No RNG device\n");
-   return;
-   }
-
-   nodeoffset = fdt_find_or_add_subnode(working_fdt, 0, "chosen");
-   if (nodeoffset <