Re: [RFC PATCH 01/15] DO-NOT-MERGE: dts: upstream: src: Necessary pulls from upstream dts

2024-04-04 Thread Jayesh Choudhary

Hello Sumit,

On 05/04/24 10:27, Sumit Garg wrote:

Hi Jayesh,

On Thu, 4 Apr 2024 at 14:30, Jayesh Choudhary  wrote:


j722s dts support that needs to be pulled from devicetree-rebasing
tree. The whole series depends on this support.



Which devicetree-rebasing tag does this patch depend upon? v6.8-dts
has already made its way to U-Boot mainline [1].

[1] 
https://source.denx.de/u-boot/u-boot/-/commit/bc39e06778168a34bb4e0a34fbee4edbde4414d8



These patches are on top of the next branch (same commit)
The required patches[0][2][3] are in tag v6.9-rc1-dts.

[0]: 

[2]: 

[3]: 



-Jayesh



-Sumit


Signed-off-by: Jayesh Choudhary 
---
  dts/upstream/Bindings/arm/ti/k3.yaml   |   6 +
  dts/upstream/src/arm64/ti/k3-j722s-evm.dts | 383 +
  dts/upstream/src/arm64/ti/k3-j722s.dtsi|  89 +
  dts/upstream/src/arm64/ti/k3-pinctrl.h |   3 +
  4 files changed, 481 insertions(+)
  create mode 100644 dts/upstream/src/arm64/ti/k3-j722s-evm.dts
  create mode 100644 dts/upstream/src/arm64/ti/k3-j722s.dtsi

diff --git a/dts/upstream/Bindings/arm/ti/k3.yaml 
b/dts/upstream/Bindings/arm/ti/k3.yaml
index c6506bccfe..d526723484 100644
--- a/dts/upstream/Bindings/arm/ti/k3.yaml
+++ b/dts/upstream/Bindings/arm/ti/k3.yaml
@@ -123,6 +123,12 @@ properties:
- ti,j721s2-evm
- const: ti,j721s2

+  - description: K3 J722S SoC and Boards
+items:
+  - enum:
+  - ti,j722s-evm
+  - const: ti,j722s
+
- description: K3 J784s4 SoC
  items:
- enum:


[...]


Re: [RFC PATCH 01/15] DO-NOT-MERGE: dts: upstream: src: Necessary pulls from upstream dts

2024-04-04 Thread Sumit Garg
Hi Jayesh,

On Thu, 4 Apr 2024 at 14:30, Jayesh Choudhary  wrote:
>
> j722s dts support that needs to be pulled from devicetree-rebasing
> tree. The whole series depends on this support.
>

Which devicetree-rebasing tag does this patch depend upon? v6.8-dts
has already made its way to U-Boot mainline [1].

[1] 
https://source.denx.de/u-boot/u-boot/-/commit/bc39e06778168a34bb4e0a34fbee4edbde4414d8

-Sumit

> Signed-off-by: Jayesh Choudhary 
> ---
>  dts/upstream/Bindings/arm/ti/k3.yaml   |   6 +
>  dts/upstream/src/arm64/ti/k3-j722s-evm.dts | 383 +
>  dts/upstream/src/arm64/ti/k3-j722s.dtsi|  89 +
>  dts/upstream/src/arm64/ti/k3-pinctrl.h |   3 +
>  4 files changed, 481 insertions(+)
>  create mode 100644 dts/upstream/src/arm64/ti/k3-j722s-evm.dts
>  create mode 100644 dts/upstream/src/arm64/ti/k3-j722s.dtsi
>
> diff --git a/dts/upstream/Bindings/arm/ti/k3.yaml 
> b/dts/upstream/Bindings/arm/ti/k3.yaml
> index c6506bccfe..d526723484 100644
> --- a/dts/upstream/Bindings/arm/ti/k3.yaml
> +++ b/dts/upstream/Bindings/arm/ti/k3.yaml
> @@ -123,6 +123,12 @@ properties:
>- ti,j721s2-evm
>- const: ti,j721s2
>
> +  - description: K3 J722S SoC and Boards
> +items:
> +  - enum:
> +  - ti,j722s-evm
> +  - const: ti,j722s
> +
>- description: K3 J784s4 SoC
>  items:
>- enum:
> diff --git a/dts/upstream/src/arm64/ti/k3-j722s-evm.dts 
> b/dts/upstream/src/arm64/ti/k3-j722s-evm.dts
> new file mode 100644
> index 00..cee3a8661d
> --- /dev/null
> +++ b/dts/upstream/src/arm64/ti/k3-j722s-evm.dts
> @@ -0,0 +1,383 @@
> +// SPDX-License-Identifier: GPL-2.0-only OR MIT
> +/*
> + * Device Tree file for the J722S EVM
> + * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
> + *
> + * Schematics: https://www.ti.com/lit/zip/sprr495
> + */
> +
> +/dts-v1/;
> +
> +#include 
> +#include "k3-j722s.dtsi"
> +
> +/ {
> +   compatible = "ti,j722s-evm", "ti,j722s";
> +   model = "Texas Instruments J722S EVM";
> +
> +   aliases {
> +   serial0 = _uart0;
> +   serial2 = _uart0;
> +   mmc0 = 
> +   mmc1 = 
> +   };
> +
> +   chosen {
> +   stdout-path = _uart0;
> +   };
> +
> +   memory@8000 {
> +   /* 8G RAM */
> +   reg = <0x 0x8000 0x 0x8000>,
> + <0x0008 0x8000 0x0001 0x8000>;
> +   device_type = "memory";
> +   bootph-pre-ram;
> +   };
> +
> +   reserved_memory: reserved-memory {
> +   #address-cells = <2>;
> +   #size-cells = <2>;
> +   ranges;
> +
> +   secure_tfa_ddr: tfa@9e78 {
> +   reg = <0x00 0x9e78 0x00 0x8>;
> +   no-map;
> +   };
> +
> +   secure_ddr: optee@9e80 {
> +   reg = <0x00 0x9e80 0x00 0x0180>;
> +   no-map;
> +   };
> +
> +   wkup_r5fss0_core0_memory_region: r5f-memory@a010 {
> +   compatible = "shared-dma-pool";
> +   reg = <0x00 0xa010 0x00 0xf0>;
> +   no-map;
> +   };
> +
> +   };
> +
> +   vmain_pd: regulator-0 {
> +   /* TPS65988 PD CONTROLLER OUTPUT */
> +   compatible = "regulator-fixed";
> +   regulator-name = "vmain_pd";
> +   regulator-min-microvolt = <500>;
> +   regulator-max-microvolt = <500>;
> +   regulator-always-on;
> +   regulator-boot-on;
> +   bootph-all;
> +   };
> +
> +   vsys_5v0: regulator-vsys5v0 {
> +   /* Output of LM5140 */
> +   compatible = "regulator-fixed";
> +   regulator-name = "vsys_5v0";
> +   regulator-min-microvolt = <500>;
> +   regulator-max-microvolt = <500>;
> +   vin-supply = <_pd>;
> +   regulator-always-on;
> +   regulator-boot-on;
> +   };
> +
> +   vdd_mmc1: regulator-mmc1 {
> +   /* TPS22918DBVR */
> +   compatible = "regulator-fixed";
> +   regulator-name = "vdd_mmc1";
> +   regulator-min-microvolt = <330>;
> +   regulator-max-microvolt = <330>;
> +   regulator-boot-on;
> +   enable-active-high;
> +   gpio = < 15 GPIO_ACTIVE_HIGH>;
> +   bootph-all;
> +   };
> +
> +   vdd_sd_dv: regulator-TLV71033 {
> +   compatible = "regulator-gpio";
> +   regulator-name = "tlv71033";
> +   pinctrl-names = "default";
> +   pinctrl-0 = <_sd_dv_pins_default>;
> +   regulator-min-microvolt = <180>;
> +   

Re: [PATCH v2 6/6] spinand: bind UBI block

2024-04-04 Thread Chuanhong Guo
Hi!

On Thu, Apr 4, 2024 at 4:02 PM Alexey Romanov
 wrote:
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -1182,8 +1183,13 @@ static int spinand_bind(struct udevice *dev)
> > >  {
> > > if (blk_enabled()) {
> > > struct spinand_plat *plat = dev_get_plat(dev);
> > > +   int ret;
> > > +
> > > +   ret = mtd_bind(dev, >mtd);
> > > +   if (ret)
> > > +   return ret;
> > >
> > > -   return mtd_bind(dev, >mtd);
> > > +   return ubi_bind(dev);
> >
> > Is this expecting the entire SPI-NAND covered by a single UBI partition?
>
> Why? Nah.

I can't find the code it's patching in my outdated local tree and
made a wrong guess. Sorry for my ignorance.

> ubi_bind() just create block device and bind it to SPI-NAND device.
> When working with this block device user must specify, which SPI-NAND
> partition UBI is located on.
>

And thanks for the explanation!

-- 
Regards,
Chuanhong Guo


Re: [PATCH] spi: dw: Use controller clock rate as maximum frequency

2024-04-04 Thread Kunihiko Hayashi

Hi Jagan,

On 2023/12/18 20:40, Jagan Teki wrote:

On Wed, Oct 25, 2023 at 1:20 PM Kunihiko Hayashi
 wrote:


Currently the controller driver has maximum frequency in plat->frequency
that is specified by "spi-max-frequency" DT property in the controller
node. This is special to U-Boot and doesn't exist to Linux.

 spi {
 spi-max-frequency = ;
 };

Usually the frequency should be specified by "spi-max-frequency" at the
slave device node.

 spi {
 slave {
 spi-max-frequency = ;
 };
 };

The final maximum frequency is set to the smaller value of the controller
node (A) and the slave device node (B).

Currently, if the property in the controller node is omitted, the default
frequency is fixed at 500kHz. Even if the controller and the slave device
allow the higher frequency than 500kHz, the maximum frequency can't exceed
500kHz.

The upper limit of the maximum frequency should be determined by the clock
rate of the controller clock. And this patch determines the maximum
frequency based on the clock rate if the controller node property isn't
specified.

Signed-off-by: Kunihiko Hayashi 
---


Applied to u-boot-spi/master


Sorry for the old response,
I couldn't see this patch in the current master branch.
Could you please apply this if it is missing?

Thank you,

---
Best Regards
Kunihiko Hayashi


[PATCH v3] tpm-v2: allow algoirthm name to be configured for pcr_read and pcr_extend

2024-04-04 Thread Tim Harvey
For pcr_read and pcr_extend commands allow the digest algorithm to be
specified by an additional argument. If not specified it will default to
SHA256 for backwards compatibility.

A follow-on to this could be to extend all PCR banks with the detected
algo when the  argument is 'auto'.

Signed-off-by: Tim Harvey 
---
v3:
 - replace tpm2_supported_algorithms with struct and use this to relate hash 
algoirthm
   details
v2:
 - use tpm2_algorithm_to_len
 - use enum tpm2_algorithms
 - make function names and parameter names more consistent with existing
   tpm-v2 functions
 - fix various spelling errors
---
 cmd/tpm-v2.c  | 49 
 include/tpm-v2.h  | 67 ++-
 lib/efi_loader/efi_tcg2.c |  4 +--
 lib/tpm-v2.c  | 62 +++-
 4 files changed, 143 insertions(+), 39 deletions(-)

diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c
index 7e479b9dfe36..2343b4d9cb9e 100644
--- a/cmd/tpm-v2.c
+++ b/cmd/tpm-v2.c
@@ -99,11 +99,19 @@ static int do_tpm2_pcr_extend(struct cmd_tbl *cmdtp, int 
flag, int argc,
struct tpm_chip_priv *priv;
u32 index = simple_strtoul(argv[1], NULL, 0);
void *digest = map_sysmem(simple_strtoul(argv[2], NULL, 0), 0);
+   int algo = TPM2_ALG_SHA256;
+   int algo_len;
int ret;
u32 rc;
 
-   if (argc != 3)
+   if (argc < 3 || argc > 4)
return CMD_RET_USAGE;
+   if (argc == 4) {
+   algo = tpm2_name_to_algorithm(argv[3]);
+   if (algo < 0)
+   return CMD_RET_FAILURE;
+   }
+   algo_len = tpm2_algorithm_to_len(algo);
 
ret = get_tpm();
if (ret)
@@ -116,8 +124,12 @@ static int do_tpm2_pcr_extend(struct cmd_tbl *cmdtp, int 
flag, int argc,
if (index >= priv->pcr_count)
return -EINVAL;
 
-   rc = tpm2_pcr_extend(dev, index, TPM2_ALG_SHA256, digest,
-TPM2_DIGEST_LEN);
+   rc = tpm2_pcr_extend(dev, index, algo, digest, algo_len);
+   if (!rc) {
+   printf("PCR #%u extended with %d byte %s digest\n", index,
+  algo_len, tpm2_algorithm_name(algo));
+   print_byte_string(digest, algo_len);
+   }
 
unmap_sysmem(digest);
 
@@ -127,15 +139,23 @@ static int do_tpm2_pcr_extend(struct cmd_tbl *cmdtp, int 
flag, int argc,
 static int do_tpm_pcr_read(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[])
 {
+   enum tpm2_algorithms algo = TPM2_ALG_SHA256;
struct udevice *dev;
struct tpm_chip_priv *priv;
u32 index, rc;
+   int algo_len;
unsigned int updates;
void *data;
int ret;
 
-   if (argc != 3)
+   if (argc < 3 || argc > 4)
return CMD_RET_USAGE;
+   if (argc == 4) {
+   algo = tpm2_name_to_algorithm(argv[3]);
+   if (algo < 0)
+   return CMD_RET_FAILURE;
+   }
+   algo_len = tpm2_algorithm_to_len(algo);
 
ret = get_tpm();
if (ret)
@@ -151,11 +171,12 @@ static int do_tpm_pcr_read(struct cmd_tbl *cmdtp, int 
flag, int argc,
 
data = map_sysmem(simple_strtoul(argv[2], NULL, 0), 0);
 
-   rc = tpm2_pcr_read(dev, index, priv->pcr_select_min, TPM2_ALG_SHA256,
-  data, TPM2_DIGEST_LEN, );
+   rc = tpm2_pcr_read(dev, index, priv->pcr_select_min, algo,
+  data, algo_len, );
if (!rc) {
-   printf("PCR #%u content (%u known updates):\n", index, updates);
-   print_byte_string(data, TPM2_DIGEST_LEN);
+   printf("PCR #%u %s %d byte content (%u known updates):\n", 
index,
+  tpm2_algorithm_name(algo), algo_len, updates);
+   print_byte_string(data, algo_len);
}
 
unmap_sysmem(data);
@@ -415,14 +436,14 @@ U_BOOT_CMD(tpm2, CONFIG_SYS_MAXARGS, 1, do_tpm, "Issue a 
TPMv2.x command",
 " is one of:\n"
 "* TPM2_RH_LOCKOUT\n"
 "* TPM2_RH_PLATFORM\n"
-"pcr_extend  \n"
-"Extend PCR # with digest at .\n"
+"pcr_extend   []\n"
+"Extend PCR # with digest at  with digest_algo.\n"
 ": index of the PCR\n"
-": address of a 32-byte SHA256 digest\n"
-"pcr_read  \n"
-"Read PCR # to memory address .\n"
+": address of digest of digest_algo type (defaults to 
SHA256)\n"
+"pcr_read   []\n"
+"Read PCR # to memory address  with .\n"
 ": index of the PCR\n"
-": address to store the a 32-byte SHA256 digest\n"
+": address of digest of digest_algo type (defaults to 
SHA256)\n"
 "get_capability\n"
 "Read and display  entries indexed by /.\n"
 "Values are 4 bytes long and are written at .\n"
diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index 33dd103767c4..263f9529e55d 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -386,7 +386,54 @@ enum tpm2_algorithms {

Re: [V1 PATCH 1/2] rockchip: sdram: Support getting banks from TPL for rk3568 and rk3588

2024-04-04 Thread Chris Morgan
On Tue, Apr 02, 2024 at 06:38:59PM +0200, Quentin Schulz wrote:
> Hi Chris,
> 
> On 4/1/24 20:14, Chris Morgan wrote:
> > From: Chris Morgan 
> > 
> > Allow RK3568 and RK3588 based boards to get the RAM bank configuration
> > from the ROCKCHIP_TPL stage instead of the current logic. This fixes
> > both an issue where 256MB of RAM is blocked for devices with >= 4GB
> > of RAM and where memory holes need to be defined for devices with
> > > = 16GB of RAM. In the event that neither SOC is used and the
> > ROCKCHIP_TPL stage is not used, fall back to existing logic.
> > 
> > Signed-off-by: Chris Morgan 
> > ---
> >   arch/arm/mach-rockchip/sdram.c | 100 +
> >   1 file changed, 100 insertions(+)
> > 
> > diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c
> > index 0d9a0aef6f..e02fb03c5f 100644
> > --- a/arch/arm/mach-rockchip/sdram.c
> > +++ b/arch/arm/mach-rockchip/sdram.c
> > @@ -12,6 +12,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   DECLARE_GLOBAL_DATA_PTR;
> > @@ -35,11 +36,110 @@ struct tos_parameter_t {
> > s64 reserve[8];
> >   };
> > +/* Tag magic */
> > +#define ATAGS_CORE_MAGIC   0x54410001
> > +#define ATAGS_DDR_MEM_MAGIC0x54410052
> > +
> > +/* Tag size and offset */
> > +#define ATAGS_SIZE SZ_8K
> > +#define ATAGS_OFFSET   (SZ_2M - ATAGS_SIZE)
> > +#define ATAGS_PHYS_BASE(CFG_SYS_SDRAM_BASE + ATAGS_OFFSET)
> > +
> > +/* ATAGS memory structure. */
> > +struct tag_ddr_mem {
> > +   u32 count;
> > +   u32 version;
> > +   u64 bank[20];
> > +   u32 flags;
> > +   u32 data[2];
> > +   u32 hash;
> > +} __packed;
> > +
> > +/**
> > + * rockchip_dram_init_banksize() - Get RAM banks from Rockchip TPL
> > + *
> > + * Iterate through the defined ATAGS memory location to first find a
> > + * valid core header, then find a valid ddr_info header. Sanity check
> > + * the number of banks found. Then, iterate through the data to add
> > + * each individual memory bank. Perform fixups on memory banks that
> > + * overlap with a reserved space. If an error condition is received,
> > + * it is expected that memory bank setup will fall back on existing
> > + * logic. If ROCKCHIP_EXTERNAL_TPL is false then immediately return,
> > + * and if neither ROCKCHIP_RK3588 or ROCKCHIP_RK3568 is enabled
> > + * immediately return.
> > + *
> > + * Return number of banks found on success or negative on error.
> > + */
> > +__weak int rockchip_dram_init_banksize(void)
> > +{
> > +   struct tag_ddr_mem *ddr_info;
> > +   size_t val;
> > +   size_t addr = ATAGS_PHYS_BASE;
> 
> I think this should be phys_addr_t instead of size_t?
> 
> size_t is an unsigned long on aarch64 and phys_addr_t is an unsigned long
> long so 4B vs 8B.
> 
> This however would likely prevent us from reusing this code on aarch32
> machines, but maybe it's a problem for the people who'll look into
> supporting this :) (also, aarch32 and >= 3.75GiB may be a bit optimistic :)
> ).

Could I just specify a size and not worry about it? A u32 should be more
than enough to hold the maximum RAM address of an RK3588 board (32GB).
That would allow this to work on both 32 and 64 right? Otherwise I could
further restrict this code to the AARCH64 ifdef.

> 
> > +   int i;
> > +
> 
> u8 is plenty enough here :)

I use it as a return value where there are negative numbers (though
obviously this should never be negative since it's an increment
counter). Does that matter?

> 
> > +   if (!IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL))
> > +   return 0;
> > +   if (!IS_ENABLED(CONFIG_ROCKCHIP_RK3588) &&
> > +   !IS_ENABLED(CONFIG_ROCKCHIP_RK3568))
> > +   return 0;
> > +
> > +   if (!IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL))
> > +   return -EPERM;
> > +
> 
> I think testing once is enough :)
> 
> Also, you probably want to use -ENOTSUPP instead?

Acknowledged.

> 
> > +   while (addr < (ATAGS_PHYS_BASE + ATAGS_SIZE)) {
> > +   val = readl(addr);
> > +   if (val == ATAGS_CORE_MAGIC)
> 
> Save a variable by not saving the result of readl and just check against
> ATAGS_CORE_MAGIC.

Acknowledged.

> 
> > +   break;
> > +   addr += 4;
> 
> This is an incorrect step size, addr is 4B, so this will result in 16B
> increments, which may be too much. Additionally, we shouldn't read every 4B
> as the tag is only ever guaranteed to be 4B aligned, not that we would have
> a tag every 4B. This also means that it's possible somehow the content of a
> tag at a 4B-aligned offset has the CORE_MAGIC for some reason, but we
> shouldn't match on it.
> 

I'm not quite sure I follow. Are you saying I need to increment every
4 * the value of size in the tag_header? The value I show is 0x5 in
my header meaning increment every 0x14?

> I recommend to follow what Rockchip does downstream:
> 
> """
> struct tag_header {
> u32 size; /* size in units of 4B */
> u32 magic;
> };
> """
> 
> if magic != CORE_MAGIC, 

[PATCH v2] arm: imx: fix signature_block_hdr struct fields order

2024-04-04 Thread Javier Viguera
According to the documentation (for example NXP's AN13994 on encrypted
boot on AHAB-enabled devices), the format of the signature block is:

  +--+--+--+-+
  | Tag  | Length - msb | Length - lsb | Version |
  +--+--+--+-+
  | SRK Table offset| Certificate offset |
  +-++
  | Blob offset | Signature offset   |
  +-++

There is no runtime error in the current u-boot code. The only user of
struct signature_block_hdr is the "get_container_size" function in the
"arch/arm/mach-imx/image-container.c" file, and it's only using the very
first fields of the struct (which are in the correct position) and thus
there is no runtime failure.

On the other hand, extending the code to get the data encryption key
blob offset on the signature header gives a wrong value as the field is
in the wrong order.

Signed-off-by: Javier Viguera 
---

Notes:
v2:
  - Improve commit log

 include/imx_container.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/imx_container.h b/include/imx_container.h
index 54cd684e35d5..691c764b3e5b 100644
--- a/include/imx_container.h
+++ b/include/imx_container.h
@@ -50,10 +50,10 @@ struct signature_block_hdr {
u8 length_lsb;
u8 length_msb;
u8 tag;
-   u16 srk_table_offset;
u16 cert_offset;
-   u16 blob_offset;
+   u16 srk_table_offset;
u16 signature_offset;
+   u16 blob_offset;
u32 reserved;
 } __packed;
 


[PULL] Please pull qcom-next-2024Apr04 (attempt 2)

2024-04-04 Thread Caleb Connolly
Hi Tom,

Sorry for the noise, totally fluffed that PR... Please ignore the previous
email.

Some new Qualcomm features for you:

* Ethernet, i2c, and USB support are now enabled by default
* The clock driver gets some bug fixes and cleanup
* Invalid FDTs are now properly detected in board_fdt_blob_setup().
* The pinctrl driver gains preparatory support for per-pin function muxes.
* Support is added for two generations of Qualcomm HighSpeed USB PHY
* A power domain driver is added for the Globall Distributed Switch Controllers
  on the GCC hardware block.
* SDM845 gains USB host mode support.
* OF_LIVE is enabled by default for Qualcomm platforms
* Some U-Boot devicetree compatibility fixups are added during init to improve
  compatbility with upstream DT.

The following changes since commit cdfcc37428e06f4730ab9a17cc084eeb7676ea1a:

  Merge tag 'u-boot-dfu-next-20240402' of 
https://source.denx.de/u-boot/custodians/u-boot-dfu (2024-04-02 22:37:23 -0400)

are available in the Git repository at:

  g...@source.denx.de:u-boot/custodians/u-boot-snapdragon.git 
tags/qcom-next-2024Apr04

for you to fetch changes up to b2511143fba4c0631446c968fb4c0d962b01d850:

  qcom_defconfig: enable USB (2024-04-04 17:46:48 +0200)


Bhupesh Sharma (2):
  phy: qcom: add Qualcomm QUSB2 USB PHY driver
  phy: qcom: Add SNPS femto v2 USB HS phy

Caleb Connolly (13):
  mailmap: update Bhupesh's email address
  mach-snapdragon: disable power-domains for pre-reloc drivers
  clk/qcom: use offsets for RCG registers
  clk/qcom: sdm845: add gdscs
  clk/qcom: sdm845: add USB clocks
  gpio: msm_gpio: add .set_flags op
  serial: msm-geni: support livetree
  mach-snapdragon: fixup USB nodes
  mach-snapdragon: fixup power-domains
  mach-snapdragon: call regulators_enable_boot_on()
  dts: sdm845-db845c: add u-boot fixups
  qcom_defconfig: enable livetree
  qcom_defconfig: enable USB

Sumit Garg (1):
  qcom_defconfig: Enable ethernet and I2C support

Volodymyr Babchuk (4):
  qcom: board: validate fdt before trying to use it
  clk: qcom: clear div mask before assigning a new divider
  clk: qcom: add support for power domains uclass
  pinctrl: qcom: pass pin number to get_function_mux callback

 .mailmap  |   1 +
 arch/arm/Kconfig  |   1 +
 arch/arm/dts/sdm845-db845c-u-boot.dtsi|   9 +
 arch/arm/mach-snapdragon/Makefile |   1 +
 arch/arm/mach-snapdragon/board.c  |  10 +-
 arch/arm/mach-snapdragon/of_fixup.c   | 155 +++
 arch/arm/mach-snapdragon/qcom-priv.h  |  20 ++
 configs/qcom_defconfig|  31 ++-
 drivers/clk/qcom/Kconfig  |   2 +-
 drivers/clk/qcom/clock-apq8016.c  |  39 +--
 drivers/clk/qcom/clock-apq8096.c  |  28 +-
 drivers/clk/qcom/clock-qcom.c | 159 +--
 drivers/clk/qcom/clock-qcom.h |  22 +-
 drivers/clk/qcom/clock-qcs404.c   | 122 ++---
 drivers/clk/qcom/clock-sdm845.c   |  61 +++--
 drivers/gpio/msm_gpio.c   |  27 +-
 drivers/phy/qcom/Kconfig  |  15 ++
 drivers/phy/qcom/Makefile |   2 +
 drivers/phy/qcom/phy-qcom-qusb2.c | 429 ++
 drivers/phy/qcom/phy-qcom-snps-femto-v2.c | 216 +++
 drivers/pinctrl/qcom/pinctrl-apq8016.c|   3 +-
 drivers/pinctrl/qcom/pinctrl-apq8096.c|   3 +-
 drivers/pinctrl/qcom/pinctrl-ipq4019.c|   3 +-
 drivers/pinctrl/qcom/pinctrl-qcom.c   |   4 +-
 drivers/pinctrl/qcom/pinctrl-qcom.h   |   3 +-
 drivers/pinctrl/qcom/pinctrl-qcs404.c |   3 +-
 drivers/pinctrl/qcom/pinctrl-sdm845.c |   3 +-
 drivers/serial/serial_msm_geni.c  |  15 +-
 28 files changed, 1150 insertions(+), 237 deletions(-)
 create mode 100644 arch/arm/dts/sdm845-db845c-u-boot.dtsi
 create mode 100644 arch/arm/mach-snapdragon/of_fixup.c
 create mode 100644 arch/arm/mach-snapdragon/qcom-priv.h
 create mode 100644 drivers/phy/qcom/phy-qcom-qusb2.c
 create mode 100644 drivers/phy/qcom/phy-qcom-snps-femto-v2.c


[PULL] Please pull qcom-next-2024Apr04

2024-04-04 Thread Caleb Connolly
Hi Tom,

Some new Qualcomm features for you:

* Ethernet, i2c, and USB support are now enabled by default
* The clock driver gets some bug fixes and cleanup
* Invalid FDTs are now properly detected in board_fdt_blob_setup().
* The pinctrl driver gains preparatory support for per-pin function muxes.
* Support is added for two generations of Qualcomm HighSpeed USB PHY
* A power domain driver is added for the Globall Distributed Switch Controllers
  on the GCC hardware block.
* SDM845 gains USB host mode support.
* OF_LIVE is enabled by default for Qualcomm platforms
* Some U-Boot devicetree compatibility fixups are added during init to improve
  compatbility with upstream DT.

The following changes since commit b2511143fba4c0631446c968fb4c0d962b01d850:

  qcom_defconfig: enable USB (2024-04-04 17:46:48 +0200)

are available in the Git repository at:

  g...@source.denx.de:u-boot/custodians/u-boot-snapdragon.git 
tags/qcom-next-2024Apr04

for you to fetch changes up to b2511143fba4c0631446c968fb4c0d962b01d850:

  qcom_defconfig: enable USB (2024-04-04 17:46:48 +0200)




Re: [PATCH 1/1] net: nfs: fix file handle length in NFSv3

2024-04-04 Thread Andrew Davis

On 3/26/24 4:34 AM, Sébastien Szymanski wrote:

The NFS protocol uses file handles to refer to file or directory.
In NFSv2 file handles have a fixed size of 32 bytes.
In NFSv3 file handles have a variable length up to 64 bytes. This is
also true for the MOUNT protocol. [1]
When the NFSv3 server replies with a file handle length > 32 bytes, U-Boot
only copies 32 bytes of that file handle and the next LOOKUP Call fails:

BIOS> nfs ${loadaddr} 192.168.1.51:/nfsroot/opos93dev-br/boot/Image
Using ethernet@428a device
File transfer via NFS from server 192.168.1.51; our IP address is 192.168.1.133
Filename '/nfsroot/opos93dev-br/boot/Image'.
Load address: 0x8040
Loading: *** ERROR: File lookup fail

done
BIOS>

Looking at this transfer in Wireshark, we can see that the server
replies with the following file handle:

 length: 36
 [hash (CRC-32): 0x230ac67b]
 FileHandle: 
0100070101005e0091763911f87c449fa73c298552db19ba0c9f60002980cfd2

and U-Boot sends the following file handle in the next LOOKUP Call:

 length: 32
 [hash (CRC-32): 0x6314131b]
 FileHandle: 
00240100070101005e0091763911f87c449fa73c298552db19ba

Fix this by using a variable length file handle for dirfh.

[1] https://www.rfc-editor.org/rfc/rfc1813.html#page-106

Fixes: b0baca982048 ("net: NFS: Add NFSv3 support")
Signed-off-by: Sébastien Szymanski 
---


Fixes NFS boot for me, thanks!

Tested-by: Andrew Davis 


  net/nfs.c | 18 +-
  1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/net/nfs.c b/net/nfs.c
index 7a8887ef2368..c18282448ccd 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -57,7 +57,8 @@ static int nfs_offset = -1;
  static int nfs_len;
  static const ulong nfs_timeout = CONFIG_NFS_TIMEOUT;
  
-static char dirfh[NFS_FHSIZE];	/* NFSv2 / NFSv3 file handle of directory */

+static char dirfh[NFS3_FHSIZE]; /* NFSv2 / NFSv3 file handle of directory */
+static unsigned int dirfh3_length; /* (variable) length of dirfh when NFSv3 */
  static char filefh[NFS3_FHSIZE]; /* NFSv2 / NFSv3 file handle */
  static unsigned int filefh3_length;   /* (variable) length of filefh when 
NFSv3 */
  
@@ -377,9 +378,9 @@ static void nfs_lookup_req(char *fname)
  
  		rpc_req(PROG_NFS, NFS_LOOKUP, data, len);

} else {  /* NFS_V3 */
-   *p++ = htonl(NFS_FHSIZE);   /* Dir handle length */
-   memcpy(p, dirfh, NFS_FHSIZE);
-   p += (NFS_FHSIZE / 4);
+   *p++ = htonl(dirfh3_length);/* Dir handle length */
+   memcpy(p, dirfh, dirfh3_length);
+   p += (dirfh3_length / 4);
*p++ = htonl(fnamelen);
if (fnamelen & 3)
*(p + fnamelen / 4) = 0;
@@ -565,7 +566,14 @@ static int nfs_mount_reply(uchar *pkt, unsigned len)
  
  	fs_mounted = 1;

/*  NFSv2 and NFSv3 use same structure */
-   memcpy(dirfh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
+   if (choosen_nfs_version != NFS_V3) {
+   memcpy(dirfh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
+   } else {
+   dirfh3_length = ntohl(rpc_pkt.u.reply.data[1]);
+   if (dirfh3_length > NFS3_FHSIZE)
+   dirfh3_length  = NFS3_FHSIZE;
+   memcpy(dirfh, rpc_pkt.u.reply.data + 2, dirfh3_length);
+   }
  
  	return 0;

  }


[GIT PULL] Please pull u-boot-amlogic-next-20240404

2024-04-04 Thread Neil Armstrong

Hi Tom,

Please pull this migration to OF_UPSTREAM for all Amlogic SoCs family
except the newer A1 family.
In Addition, there's a few fixes & updates for the jethubj100 board.

Thanks,
Neil

The following changes since commit cdfcc37428e06f4730ab9a17cc084eeb7676ea1a:

  Merge tag 'u-boot-dfu-next-20240402' of 
https://source.denx.de/u-boot/custodians/u-boot-dfu (2024-04-02 22:37:23 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-amlogic.git 
tags/u-boot-amlogic-20240404

for you to fetch changes up to 114df8b5339e503b50b6ac1a61bf1daac57c2e11:

  dts: meson: Drop redundant G12A, G12B & SM1 devicetree files (2024-04-04 
18:48:46 +0200)


- jethubj100: fix config, MAINTAINERS & update docs
- Switch GXL, GXM, AXG, G12A, G12B & SM1 to using upstream DT


Neil Armstrong (5):
  configs: meson64: remove amlogic prefix in fdtfile when 
CONFIG_OF_UPSTREAM is selected
  dts: meson: Switch GXL, GXM & AXG to using upstream DT
  dts: meson: Drop redundant GXL, GXM & AXG devicetree files
  dts: meson-g12a: Switch to using upstream DT
  dts: meson: Drop redundant G12A, G12B & SM1 devicetree files

Viacheslav Bocharov (3):
  board: amlogic: jethubj100: fix common config header
  board: amlogic: jethubj100: update MAINTAINERS
  board: amlogic: jethubj100: update docs

 arch/arm/dts/Makefile  |   36 +-
 arch/arm/dts/meson-axg-jethome-jethub-j100.dts |  361 ---
 arch/arm/dts/meson-axg-s400.dts|  602 -
 arch/arm/dts/meson-axg.dtsi| 1957 ---
 arch/arm/dts/meson-g12-common.dtsi | 2493 
 arch/arm/dts/meson-g12.dtsi|  385 ---
 arch/arm/dts/meson-g12a-radxa-zero.dts |  405 
 arch/arm/dts/meson-g12a-sei510.dts |  566 -
 arch/arm/dts/meson-g12a-u200.dts   |  308 ---
 arch/arm/dts/meson-g12a.dtsi   |  140 --
 arch/arm/dts/meson-g12b-a311d-bananapi-m2s.dts |   33 -
 arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts  |   41 -
 arch/arm/dts/meson-g12b-a311d.dtsi |  149 --
 arch/arm/dts/meson-g12b-bananapi-cm4-cm4io.dts |  165 --
 arch/arm/dts/meson-g12b-bananapi-cm4.dtsi  |  388 ---
 arch/arm/dts/meson-g12b-bananapi.dtsi  |  521 
 arch/arm/dts/meson-g12b-gsking-x.dts   |  133 --
 arch/arm/dts/meson-g12b-gtking-pro.dts |  142 --
 arch/arm/dts/meson-g12b-gtking.dts |  163 --
 arch/arm/dts/meson-g12b-khadas-vim3.dtsi   |  107 -
 arch/arm/dts/meson-g12b-odroid-go-ultra.dts|  722 --
 arch/arm/dts/meson-g12b-odroid-n2-plus.dts |   31 -
 arch/arm/dts/meson-g12b-odroid-n2.dts  |   15 -
 arch/arm/dts/meson-g12b-odroid-n2.dtsi |  303 ---
 arch/arm/dts/meson-g12b-odroid-n2l.dts |  125 -
 arch/arm/dts/meson-g12b-odroid.dtsi|  445 
 arch/arm/dts/meson-g12b-radxa-zero2.dts|  489 
 arch/arm/dts/meson-g12b-s922x-bananapi-m2s.dts |   14 -
 arch/arm/dts/meson-g12b-s922x.dtsi |  139 --
 arch/arm/dts/meson-g12b-w400.dtsi  |  425 
 arch/arm/dts/meson-g12b.dtsi   |  146 --
 arch/arm/dts/meson-gx-libretech-pc.dtsi|  447 
 arch/arm/dts/meson-gx-mali450.dtsi |   61 -
 arch/arm/dts/meson-gx-p23x-q20x.dtsi   |  324 ---
 arch/arm/dts/meson-gx.dtsi |  675 --
 arch/arm/dts/meson-gxl-mali.dtsi   |   17 -
 arch/arm/dts/meson-gxl-s805x-libretech-ac.dts  |  319 ---
 arch/arm/dts/meson-gxl-s805x.dtsi  |   23 -
 arch/arm/dts/meson-gxl-s905d-libretech-pc.dts  |   16 -
 arch/arm/dts/meson-gxl-s905d.dtsi  |   12 -
 .../arm/dts/meson-gxl-s905w-jethome-jethub-j80.dts |  247 --
 arch/arm/dts/meson-gxl-s905x-khadas-vim.dts|  237 --
 arch/arm/dts/meson-gxl-s905x-libretech-cc-v2.dts   |  313 ---
 arch/arm/dts/meson-gxl-s905x-libretech-cc.dts  |  356 ---
 arch/arm/dts/meson-gxl-s905x-p212.dts  |  134 --
 arch/arm/dts/meson-gxl-s905x-p212.dtsi |  213 --
 arch/arm/dts/meson-gxl-s905x.dtsi  |   18 -
 arch/arm/dts/meson-gxl.dtsi|  940 
 arch/arm/dts/meson-gxm-gt1-ultimate.dts|   91 -
 arch/arm/dts/meson-gxm-khadas-vim2.dts |  424 
 arch/arm/dts/meson-gxm-s912-libretech-pc.dts   |   62 -
 arch/arm/dts/meson-gxm-wetek-core2.dts |   85 -
 arch/arm/dts/meson-gxm.dtsi|  216 --
 arch/arm/dts/meson-khadas-vim3.dtsi|  534 -
 arch/arm/dts/meson-sm1-bananapi-m2-pro.dts |   97 -
 arch/arm/d

[PATCH 3/3] qcom_defconfig: enable SM8550 & SM8650 clock driver

2024-04-04 Thread Neil Armstrong
Enable the SM8550 & SM8650 clock driver in the Qualcomm defconfig.

Signed-off-by: Neil Armstrong 
---
 configs/qcom_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig
index 1abb57345ff..993c2d25f07 100644
--- a/configs/qcom_defconfig
+++ b/configs/qcom_defconfig
@@ -37,6 +37,8 @@ CONFIG_BUTTON_QCOM_PMIC=y
 CONFIG_CLK=y
 CONFIG_CLK_QCOM_QCS404=y
 CONFIG_CLK_QCOM_SDM845=y
+CONFIG_CLK_QCOM_SM8550=y
+CONFIG_CLK_QCOM_SM8650=y
 CONFIG_MSM_GPIO=y
 CONFIG_QCOM_PMIC_GPIO=y
 CONFIG_DM_I2C=y

-- 
2.34.1



[PATCH 2/3] clk: qcom: Add SM8650 clock driver

2024-04-04 Thread Neil Armstrong
Add the GCC and TCSRCC clock driver for the SM8650 SoC.

The GCC driver uses the clk-qcom infrastructure to support GDSCs,
Resets and gates. While the TCSRCC is a simpler clock driver which
only supports gates.

The GCC enable and set_rate callbacks contains some tweaks to
setup clocks for Debug UART, SDCard controller and USB.

The TCSRCC gates returns the XO frequency, which is used by the
Synopsys eUSB2 driver to determine the PHY configuration.

Signed-off-by: Neil Armstrong 
---
 drivers/clk/qcom/Kconfig|   8 +
 drivers/clk/qcom/Makefile   |   1 +
 drivers/clk/qcom/clock-sm8650.c | 332 
 3 files changed, 341 insertions(+)

diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index c908a3d19c9..a9216ea30d4 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -55,6 +55,14 @@ config CLK_QCOM_SM8550
  on the Snapdragon SM8550 SoC. This driver supports the clocks
  and resets exposed by the GCC hardware block.
 
+config CLK_QCOM_SM8650
+   bool "Qualcomm SM8650 GCC"
+   select CLK_QCOM
+   help
+ Say Y here to enable support for the Global Clock Controller
+ on the Snapdragon SM8650 SoC. This driver supports the clocks
+ and resets exposed by the GCC hardware block.
+
 endmenu
 
 endif
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index d9ac5719f49..3ccb4ffae76 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_CLK_QCOM_APQ8096) += clock-apq8096.o
 obj-$(CONFIG_CLK_QCOM_IPQ4019) += clock-ipq4019.o
 obj-$(CONFIG_CLK_QCOM_QCS404) += clock-qcs404.o
 obj-$(CONFIG_CLK_QCOM_SM8550) += clock-sm8550.o
+obj-$(CONFIG_CLK_QCOM_SM8650) += clock-sm8650.o
diff --git a/drivers/clk/qcom/clock-sm8650.c b/drivers/clk/qcom/clock-sm8650.c
new file mode 100644
index 000..0ce83e9b243
--- /dev/null
+++ b/drivers/clk/qcom/clock-sm8650.c
@@ -0,0 +1,332 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Clock drivers for Qualcomm sm8650
+ *
+ * (C) Copyright 2024 Linaro Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "clock-qcom.h"
+
+/* On-board TCXO, TOFIX get from DT */
+#define TCXO_RATE  3840
+
+/* bi_tcxo_div2 divided after RPMh output */
+#define TCXO_DIV2_RATE (TCXO_RATE / 2)
+
+static const struct freq_tbl ftbl_gcc_qupv3_wrap1_s3_clk_src[] = {
+   F(7372800, CFG_CLK_SRC_GPLL0_EVEN, 1, 384, 15625),
+   F(14745600, CFG_CLK_SRC_GPLL0_EVEN, 1, 768, 15625),
+   F(1920, CFG_CLK_SRC_CXO, 1, 0, 0),
+   F(29491200, CFG_CLK_SRC_GPLL0_EVEN, 1, 1536, 15625),
+   F(3200, CFG_CLK_SRC_GPLL0_EVEN, 1, 8, 75),
+   F(4800, CFG_CLK_SRC_GPLL0_EVEN, 1, 4, 25),
+   F(6400, CFG_CLK_SRC_GPLL0_EVEN, 1, 16, 75),
+   F(7500, CFG_CLK_SRC_GPLL0_EVEN, 4, 0, 0),
+   F(8000, CFG_CLK_SRC_GPLL0_EVEN, 1, 4, 15),
+   F(9600, CFG_CLK_SRC_GPLL0_EVEN, 1, 8, 25),
+   F(1, CFG_CLK_SRC_GPLL0, 6, 0, 0),
+   { }
+};
+
+static const struct freq_tbl ftbl_gcc_sdcc2_apps_clk_src[] = {
+   F(40, CFG_CLK_SRC_CXO, 12, 1, 4),
+   F(2500, CFG_CLK_SRC_GPLL0_EVEN, 12, 0, 0),
+   F(1, CFG_CLK_SRC_GPLL0_EVEN, 3, 0, 0),
+   /* TOFIX F(20200, CFG_CLK_SRC_GPLL9, 4, 0, 0), */
+   { }
+};
+
+static const struct freq_tbl ftbl_gcc_usb30_prim_master_clk_src[] = {
+   F(6667, CFG_CLK_SRC_GPLL0_EVEN, 4.5, 0, 0),
+   F(1, CFG_CLK_SRC_GPLL0, 4.5, 0, 0),
+   F(2, CFG_CLK_SRC_GPLL0, 3, 0, 0),
+   F(24000, CFG_CLK_SRC_GPLL0, 2.5, 0, 0),
+   { }
+};
+
+static ulong sm8650_set_rate(struct clk *clk, ulong rate)
+{
+   struct msm_clk_priv *priv = dev_get_priv(clk->dev);
+   const struct freq_tbl *freq;
+
+   switch (clk->id) {
+   case GCC_QUPV3_WRAP2_S7_CLK: /* UART15 */
+   freq = qcom_find_freq(ftbl_gcc_qupv3_wrap1_s3_clk_src, rate);
+   clk_rcg_set_rate_mnd(priv->base, 0x1e898,
+freq->pre_div, freq->m, freq->n, 
freq->src, 16);
+   return freq->freq;
+   case GCC_SDCC2_APPS_CLK:
+   freq = qcom_find_freq(ftbl_gcc_sdcc2_apps_clk_src, rate);
+   clk_rcg_set_rate_mnd(priv->base, 0x14018,
+freq->pre_div, freq->m, freq->n, 
freq->src, 8);
+   return freq->freq;
+   case GCC_USB30_PRIM_MASTER_CLK:
+   freq = qcom_find_freq(ftbl_gcc_usb30_prim_master_clk_src, rate);
+   clk_rcg_set_rate_mnd(priv->base, 0x3902c,
+freq->pre_div, freq->m, freq->n, 
freq->src, 8);
+   return freq->freq;
+   case GCC_USB30_PRIM_MOCK_UTMI_CLK:
+   clk_rcg_set_rate(priv->base, 0x39044, 0, 0);
+   return TCXO_DIV2_RATE;
+   case GCC_USB3_PRIM_PHY_AUX_CLK_SRC:
+   

[PATCH 1/3] clk: qcom: Add SM8550 clock driver

2024-04-04 Thread Neil Armstrong
Add the GCC and TCSRCC clock driver for the SM8550 SoC.

The GCC driver uses the clk-qcom infrastructure to support GDSCs,
Resets and gates. While the TCSRCC is a simpler clock driver which
only supports gates.

The GCC enable and set_rate callbacks contains some tweaks to
setup clocks for Debug UART, SDCard controller and USB.

The TCSRCC gates returns the XO frequency, which is used by the
Synopsys eUSB2 driver to determine the PHY configuration.

Signed-off-by: Neil Armstrong 
---
 drivers/clk/qcom/Kconfig|   8 +
 drivers/clk/qcom/Makefile   |   1 +
 drivers/clk/qcom/clock-sm8550.c | 335 
 3 files changed, 344 insertions(+)

diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index 8dae635ac2c..c908a3d19c9 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -47,6 +47,14 @@ config CLK_QCOM_SDM845
  on the Snapdragon 845 SoC. This driver supports the clocks
  and resets exposed by the GCC hardware block.
 
+config CLK_QCOM_SM8550
+   bool "Qualcomm SM8550 GCC"
+   select CLK_QCOM
+   help
+ Say Y here to enable support for the Global Clock Controller
+ on the Snapdragon SM8550 SoC. This driver supports the clocks
+ and resets exposed by the GCC hardware block.
+
 endmenu
 
 endif
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index cb179fdac58..d9ac5719f49 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_CLK_QCOM_APQ8016) += clock-apq8016.o
 obj-$(CONFIG_CLK_QCOM_APQ8096) += clock-apq8096.o
 obj-$(CONFIG_CLK_QCOM_IPQ4019) += clock-ipq4019.o
 obj-$(CONFIG_CLK_QCOM_QCS404) += clock-qcs404.o
+obj-$(CONFIG_CLK_QCOM_SM8550) += clock-sm8550.o
diff --git a/drivers/clk/qcom/clock-sm8550.c b/drivers/clk/qcom/clock-sm8550.c
new file mode 100644
index 000..c0249925cc7
--- /dev/null
+++ b/drivers/clk/qcom/clock-sm8550.c
@@ -0,0 +1,335 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Clock drivers for Qualcomm sm8550
+ *
+ * (C) Copyright 2024 Linaro Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "clock-qcom.h"
+
+/* On-board TCXO, TOFIX get from DT */
+#define TCXO_RATE  3840
+
+/* bi_tcxo_div2 divided after RPMh output */
+#define TCXO_DIV2_RATE (TCXO_RATE / 2)
+
+static const struct freq_tbl ftbl_gcc_qupv3_wrap1_s2_clk_src[] = {
+   F(7372800, CFG_CLK_SRC_GPLL0_EVEN, 1, 384, 15625),
+   F(14745600, CFG_CLK_SRC_GPLL0_EVEN, 1, 768, 15625),
+   F(1920, CFG_CLK_SRC_CXO, 1, 0, 0),
+   F(29491200, CFG_CLK_SRC_GPLL0_EVEN, 1, 1536, 15625),
+   F(3200, CFG_CLK_SRC_GPLL0_EVEN, 1, 8, 75),
+   F(4800, CFG_CLK_SRC_GPLL0_EVEN, 1, 4, 25),
+   F(5120, CFG_CLK_SRC_GPLL0_EVEN, 1, 64, 375),
+   F(6400, CFG_CLK_SRC_GPLL0_EVEN, 1, 16, 75),
+   F(7500, CFG_CLK_SRC_GPLL0_EVEN, 4, 0, 0),
+   F(8000, CFG_CLK_SRC_GPLL0_EVEN, 1, 4, 15),
+   F(9600, CFG_CLK_SRC_GPLL0_EVEN, 1, 8, 25),
+   F(1, CFG_CLK_SRC_GPLL0, 6, 0, 0),
+   { }
+};
+
+static const struct freq_tbl ftbl_gcc_sdcc2_apps_clk_src[] = {
+   F(40, CFG_CLK_SRC_CXO, 12, 1, 4),
+   F(2500, CFG_CLK_SRC_GPLL0_EVEN, 12, 0, 0),
+   F(3750, CFG_CLK_SRC_GPLL0_EVEN, 8, 0, 0),
+   F(5000, CFG_CLK_SRC_GPLL0_EVEN, 6, 0, 0),
+   F(1, CFG_CLK_SRC_GPLL0_EVEN, 3, 0, 0),
+   /* TOFIX F(20200, CFG_CLK_SRC_GPLL9, 4, 0, 0), */
+   { }
+};
+
+static const struct freq_tbl ftbl_gcc_usb30_prim_master_clk_src[] = {
+   F(6667, CFG_CLK_SRC_GPLL0_EVEN, 4.5, 0, 0),
+   F(1, CFG_CLK_SRC_GPLL0, 4.5, 0, 0),
+   F(2, CFG_CLK_SRC_GPLL0, 3, 0, 0),
+   F(24000, CFG_CLK_SRC_GPLL0, 2.5, 0, 0),
+   { }
+};
+
+static ulong sm8550_set_rate(struct clk *clk, ulong rate)
+{
+   struct msm_clk_priv *priv = dev_get_priv(clk->dev);
+   const struct freq_tbl *freq;
+
+   switch (clk->id) {
+   case GCC_QUPV3_WRAP1_S7_CLK: /* UART7 */
+   freq = qcom_find_freq(ftbl_gcc_qupv3_wrap1_s2_clk_src, rate);
+   clk_rcg_set_rate_mnd(priv->base, 0x18898,
+freq->pre_div, freq->m, freq->n, 
freq->src, 16);
+   return freq->freq;
+   case GCC_SDCC2_APPS_CLK:
+   freq = qcom_find_freq(ftbl_gcc_sdcc2_apps_clk_src, rate);
+   clk_rcg_set_rate_mnd(priv->base, 0x14018,
+freq->pre_div, freq->m, freq->n, 
freq->src, 8);
+   return freq->freq;
+   case GCC_USB30_PRIM_MASTER_CLK:
+   freq = qcom_find_freq(ftbl_gcc_usb30_prim_master_clk_src, rate);
+   clk_rcg_set_rate_mnd(priv->base, 0x3902c,
+freq->pre_div, freq->m, freq->n, 
freq->src, 8);
+   return freq->freq;
+   case GCC_USB30_PRIM_MOCK_UTMI_CLK:
+   

[PATCH 0/3] qcom: add clock driver support for SM8550 and SM8650 SoCc

2024-04-04 Thread Neil Armstrong
Add the GCC and TCSRCC clock driver for the SM8550 & SM8650 SoCs.

The GCC driver uses the clk-qcom infrastructure to support GDSCs,
Resets and gates. While the TCSRCC is a simpler clock driver which
only supports gates.

The GCC enable and set_rate callbacks contains some tweaks to
setup clocks for Debug UART, SDCard controller and USB.

The TCSRCC gates returns the XO frequency, which is used by the
Synopsys eUSB2 driver to determine the PHY configuration.

In addition, the drivers are enabled in the Qualcomm defconfig.

Signed-off-by: Neil Armstrong 
---
Neil Armstrong (3):
  clk: qcom: Add SM8550 clock driver
  clk: qcom: Add SM8650 clock driver
  qcom_defconfig: enable SM8550 & SM8650 clock driver

 configs/qcom_defconfig  |   2 +
 drivers/clk/qcom/Kconfig|  16 ++
 drivers/clk/qcom/Makefile   |   2 +
 drivers/clk/qcom/clock-sm8550.c | 335 
 drivers/clk/qcom/clock-sm8650.c | 332 +++
 5 files changed, 687 insertions(+)
---
base-commit: f0e6aba1218bca578605697eed8aa94582bf57bb
change-id: 20240404-topic-sm8x50-clock-a76f8359b5fb

Best regards,
-- 
Neil Armstrong 



Re: [PATCH v2] tools: open FIT image read-only

2024-04-04 Thread Dragan Simic

Hello all,

Just a brief reminder about merging this patch.  It looks fine to me.


On 2024-03-21 19:31, Ahelenia Ziemiańska wrote:

Open for reading as O_RDONLY instead of O_RDWR:
the only usage of the fd is for the single read() below;
this prevented
mkimage -f auto -A arm64 \
-T kernel -C lz4 -d Image-6.6.15.lz4 \
-b mt8173-elm-hana-6.6.15.dtb outf
when the inputs were unwritable.

Link: https://bugs.debian.org/1063097
Signed-off-by: Ahelenia Ziemiańska 
Reviewed-by: Dragan Simic 
---
 tools/fit_image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/fit_image.c b/tools/fit_image.c
index beef1fa8..0fccfbb4 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -137,7 +137,7 @@ static int fdt_property_file(struct
image_tool_params *params,
int ret;
int fd;

-   fd = open(fname, O_RDWR | O_BINARY);
+   fd = open(fname, O_RDONLY | O_BINARY);
if (fd < 0) {
fprintf(stderr, "%s: Can't open %s: %s\n",
params->cmdname, fname, strerror(errno));


Re: [PATCH v3] tools: copyfile: use 64k instead of 512 buffer

2024-04-04 Thread Dragan Simic

Hello Ahelenia,

Just checking, have you forgotten about this patch?


On 2024-03-21 21:50, Dragan Simic wrote:

On 2024-03-21 21:37, Ahelenia Ziemiańska wrote:

This is a trivial but significant optimization:
mkimage took >200ms (and 49489 writes (of which 49456 512)),
now it takes  110ms (and   419 writes (of which   386 64k)).

sendfile is much more appropriate for this and is done in one syscall,
but doesn't bring any significant speedups over 64k r/w
at the 13M size ranges, so there's no need to introduce
#if __linux__
while((size = sendfile(fd_dst, fd_src, NULL, 128 * 1024 * 1024)) > 0)
;
if(size != -1) {
ret = 0;
goto out;
}
#endif

Also extract the buffer size to a constant.

Signed-off-by: Ahelenia Ziemiańska 
Reviewed-by: Dragan Simic 


Please, remove my Reviewed-by tag from this version of the patch,
because it no longer applies.


---
On Thu, Mar 21, 2024 at 08:49:52PM +0100, Dragan Simic wrote:

On 2024-03-21 19:29, Ahelenia Ziemiańska wrote:
> This is a trivial but significant optimisation:
s/optimisation/optimization/

This seems to run counter to precedent of not doing americans'
imperialism for them for free
(I see -ise/-ize in free variation even in my 100-deep checkout).


Well, that's politics, which I have no interest about.


> +#define copyfile_bufsize (64 * 1024)
This is not the right place for such a preprocessor directive.
Instead, it should be placed at the start of the file.

Also, it should use all uppercase letters.

FTR, neither of these points seem to be universal;
I modelled this after tools/mtk_image.c (also cf. 
scripts/kconfig/expr.c),

but there are at least 25 other function-local macros
(as in git grep -B1 '^#define' | grep -c -A1 -e '-{' returns 27).


AFAICT, scripts/kconfig/expr.c could use come cleanups.


Also kinda weird to explicitly request a macro
only to review it back to a constant, but whatever.


Well, it isn't weird.  See, the instances of a preprocessor #define
directive are replaced with its definition before the source code
reaches the compiler, making it, in this case, a bit easier for the
compiler to do its job.

The way you wrote it below, the compiler will almost surely optimize
out the constant variable and replace it with the literal number in
the generated object code, but that puts unnecessary burden on the
compiler, which can be avoided by feeding it with the literal number,
using a preprocessor directive.


 tools/fit_common.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/fit_common.c b/tools/fit_common.c
index 2d417d47..37066203 100644
--- a/tools/fit_common.c
+++ b/tools/fit_common.c
@@ -129,6 +129,7 @@ int copyfile(const char *src, const char *dst)
 {
int fd_src = -1, fd_dst = -1;
void *buf = NULL;
+   const size_t bufsize = 64 * 1024;
ssize_t size;
size_t count;
int ret = -1;
@@ -145,14 +146,14 @@ int copyfile(const char *src, const char *dst)
goto out;
}

-   buf = calloc(1, 512);
+   buf = calloc(1, bufsize);
if (!buf) {
printf("Can't allocate buffer to copy file\n");
goto out;
}

while (1) {
-   size = read(fd_src, buf, 512);
+   size = read(fd_src, buf, bufsize);
if (size < 0) {
printf("Can't read file %s\n", src);
goto out;


Re: [RFC PATCH 08/15] arm: mach-k3: j722s: introduce clock and device files for wkup spl

2024-04-04 Thread Bryan Brattlof
On April  4, 2024 thus sayeth Jayesh Choudhary:
> Include the clock and lpsc tree files needed for the wkup spl to
> initialize the proper PLLs and power domains to boot the SoC.
> 
> Signed-off-by: Vaishnav Achath 
> Signed-off-by: Jayesh Choudhary 
> ---
>  arch/arm/mach-k3/r5/Makefile   |   1 +
>  arch/arm/mach-k3/r5/j722s/Makefile |   6 +
>  arch/arm/mach-k3/r5/j722s/clk-data.c   | 312 +
>  arch/arm/mach-k3/r5/j722s/dev-data.c   |  69 ++
>  drivers/clk/ti/clk-k3.c|   6 +
>  drivers/power/domain/ti-power-domain.c |   6 +
>  include/k3-clk.h   |   1 +
>  include/k3-dev.h   |   1 +
>  8 files changed, 402 insertions(+)
>  create mode 100644 arch/arm/mach-k3/r5/j722s/Makefile
>  create mode 100644 arch/arm/mach-k3/r5/j722s/clk-data.c
>  create mode 100644 arch/arm/mach-k3/r5/j722s/dev-data.c
> 

Reviewed-by: Bryan Brattlof 

~Bryan


Re: [RFC PATCH 05/15] clk: ti: clk-k3: use IS_ENABLED macro and fix the clock-data order

2024-04-04 Thread Bryan Brattlof
On April  4, 2024 thus sayeth Jayesh Choudhary:
> Use IS_ENABLED macro for the platform clock-data list and add them
> in alphabetical order.
> 
> Signed-off-by: Jayesh Choudhary 
> ---
>  drivers/clk/ti/clk-k3.c | 41 +
>  1 file changed, 21 insertions(+), 20 deletions(-)
> 

Reviewed-by: Bryan Brattlof 

~Bryan



Re: [PATCH v2 4/4] boot: correct finding the default EFI binary

2024-04-04 Thread Heinrich Schuchardt

On 04.04.24 16:46, Ilias Apalodimas wrote:

Hi Heinrich,

FWIW reading at this, I don't see a point of having it overall. It has
a nice feature of trying to load external DTBs from a path though.
I think in the future we can move the dtb selection in
bootmeth_efi_mgr.c and delete this one


efi_mgr method should only scan removable drives for 
EFI/BOOT/BOOT.EFI to be UEFI compliant.


The efi method also scans non-removable drives for these files.

I agree that this behavior could be integrated into the EFI boot manager 
itself (with a corresponding configuration switch) to replace the efi 
boot method.


Best regards

Heinrich



On Thu, 4 Apr 2024 at 14:49, Heinrich Schuchardt
 wrote:


* The sandbox must not use an arbitrary file name bootsbox.efi but the
   file name matching the host architecture to properly boot the respective
   file. We already have an include which provides a macro with the name of
   the EFI binary. Use it.

* The path to the EFI binary should be absolute.

* The path and the file name must be capitalized to conform to the UEFI
   specification. This is important when reading from case sensitive
   file systems.

Signed-off-by: Heinrich Schuchardt 
---
v2:
 new patch
---
  boot/bootmeth_efi.c  | 44 +++-
  test/boot/bootflow.c |  4 +++-
  2 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index a46b6c9c805..aebc5207fc0 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -14,6 +14,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -23,43 +24,7 @@
  #include 
  #include 

-#define EFI_DIRNAME"efi/boot/"
-
-/**
- * get_efi_leafname() - Get the leaf name for the EFI file we expect
- *
- * @str: Place to put leaf name for this architecture, e.g. "bootaa64.efi".
- * Must have at least 16 bytes of space
- * @max_len: Length of @str, must be >=16
- */
-static int get_efi_leafname(char *str, int max_len)
-{
-   const char *base;
-
-   if (max_len < 16)
-   return log_msg_ret("spc", -ENOSPC);
-   if (IS_ENABLED(CONFIG_ARM64))
-   base = "bootaa64";
-   else if (IS_ENABLED(CONFIG_ARM))
-   base = "bootarm";
-   else if (IS_ENABLED(CONFIG_X86_RUN_32BIT))
-   base = "bootia32";
-   else if (IS_ENABLED(CONFIG_X86_RUN_64BIT))
-   base = "bootx64";
-   else if (IS_ENABLED(CONFIG_ARCH_RV32I))
-   base = "bootriscv32";
-   else if (IS_ENABLED(CONFIG_ARCH_RV64I))
-   base = "bootriscv64";
-   else if (IS_ENABLED(CONFIG_SANDBOX))
-   base = "bootsbox";
-   else
-   return -EINVAL;
-
-   strcpy(str, base);
-   strcat(str, ".efi");
-
-   return 0;
-}
+#define EFI_DIRNAME"/EFI/BOOT/"

  static int get_efi_pxe_arch(void)
  {
@@ -259,10 +224,7 @@ static int distro_efi_try_bootflow_files(struct udevice 
*dev,
 return -ENOENT;

 strcpy(fname, EFI_DIRNAME);
-   ret = get_efi_leafname(fname + strlen(fname),
-  sizeof(fname) - strlen(fname));
-   if (ret)
-   return log_msg_ret("leaf", ret);
+   strcat(fname, BOOTEFI_NAME);

 if (bflow->blk)
  desc = dev_get_uclass_plat(bflow->blk);
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index e60e9309fa9..674d4c05f83 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -13,6 +13,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #ifdef CONFIG_SANDBOX
  #include 
@@ -179,7 +180,8 @@ static int bootflow_cmd_scan_e(struct unit_test_state *uts)
 ut_assert_nextline("  3  efi  media   mmc  0  
mmc1.bootdev.whole");
 ut_assert_nextline(" ** No partition found, err=-2: No such file or 
directory");
 ut_assert_nextline("  4  extlinux ready   mmc  1  
mmc1.bootdev.part_1   /extlinux/extlinux.conf");
-   ut_assert_nextline("  5  efi  fs  mmc  1  
mmc1.bootdev.part_1   efi/boot/bootsbox.efi");
+   ut_assert_nextline("  5  efi  fs  mmc  1  
mmc1.bootdev.part_1   /EFI/BOOT/"
+  BOOTEFI_NAME);

 ut_assert_skip_to_line("Scanning bootdev 'mmc0.bootdev':");
 ut_assert_skip_to_line(
--
2.43.0



Reviewed-by: Ilias Apalodimas 
Tested-by: Ilias Apalodimas 




Re: [RFC PATCH 15/15] doc: board: ti: Add J722S-EVM documentation

2024-04-04 Thread Andrew Davis

On 4/4/24 4:00 AM, Jayesh Choudhary wrote:

Introduce basic documentation for the J722S-EVM.

Signed-off-by: Jayesh Choudhary 
---
  doc/board/ti/j722s_evm.rst | 262 +
  doc/board/ti/k3.rst|   1 +
  2 files changed, 263 insertions(+)
  create mode 100644 doc/board/ti/j722s_evm.rst

diff --git a/doc/board/ti/j722s_evm.rst b/doc/board/ti/j722s_evm.rst
new file mode 100644
index 00..150330f637
--- /dev/null
+++ b/doc/board/ti/j722s_evm.rst
@@ -0,0 +1,262 @@
+.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+.. sectionauthor:: Jayesh Choudhary 
+
+J722S-EVM Platform
+==
+
+The J722S is a family of  application processors built for Automotive and
+Linux Application development. J722S family of SoCs is a superset of the
+AM62P SoC family and shares similar memory map, thus the nodes are being
+reused from AM62P includes instead of duplicating the definitions.
+
+Some highlights of J722S SoC (in addition to AM62P SoC features) are:
+
+* Two Cortex-R5F for Functional Safety or general-purpose usage and
+  two C7x floating point vector DSP with Matrix Multiply Accelerator
+  for deep learning.
+
+* Vision Processing Accelerator (VPAC) with image signal processor
+  and Depth and Motion Processing Accelerator (DMPAC).
+
+* 7xUARTs, 3xSPI, 5xI2C, 2xUSB2, 2xCAN-FD, 3xMMC and SD, GPMC for
+  NAND/FPGA connection, OSPI memory controller, 5xMcASP for audio,
+  4xCSI-RX for Camera, 1 PCIe Gen3 controller, USB3.0 eCAP/eQEP,
+  ePWM, among other peripherals.
+
+For those interested, more details about this SoC can be found in the
+Technical Reference Manual here: https://www.ti.com/lit/zip/sprujb3
+
+Boot Flow:
+--
+
+The bootflow is exactly the same as all SoCs in the am62xxx extended SoC
+family. Below is the pictorial representation:
+
+.. image:: img/boot_diagram_k3_current.svg
+  :alt: Boot flow diagram
+
+- Here TIFS acts as master and provides all the critical services. R5/A53
+  requests TIFS to get these services done as shown in the above diagram.
+
+Sources:
+
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_boot_sources
+:end-before: .. k3_rst_include_end_boot_sources
+
+Build procedure:
+
+
+0. Setup the environment variables:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_common_env_vars_desc
+:end-before: .. k3_rst_include_end_common_env_vars_desc
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_board_env_vars_desc
+:end-before: .. k3_rst_include_end_board_env_vars_desc
+
+Set the variables corresponding to this platform:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_common_env_vars_defn
+:end-before: .. k3_rst_include_end_common_env_vars_defn
+
+.. code-block:: bash
+
+ $ export UBOOT_CFG_CORTEXR=j722s_evm_r5_defconfig
+ $ export UBOOT_CFG_CORTEXA=j722s_evm_a53_defconfig
+ $ export TFA_BOARD=lite
+ $ # we dont use any extra TFA parameters
+ $ unset TFA_EXTRA_ARGS


Why unset, who is setting in the first place?


+ $ export OPTEE_PLATFORM=k3-am62x


None of the addresses OPTEE cares about changed from AM62?


+ $ export OPTEE_EXTRA_ARGS="CFG_WITH_SOFTWARE_PRNG=y"


Do you still need this, the HW RNG should work now.

Andrew


+
+.. j722s_evm_rst_include_start_build_steps
+
+1. Trusted Firmware-A:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_build_steps_tfa
+:end-before: .. k3_rst_include_end_build_steps_tfa
+
+
+2. OP-TEE:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_build_steps_optee
+:end-before: .. k3_rst_include_end_build_steps_optee
+
+3. U-Boot:
+
+* 3.1 R5:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_build_steps_spl_r5
+:end-before: .. k3_rst_include_end_build_steps_spl_r5
+
+* 3.2 A53:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_build_steps_uboot
+:end-before: .. k3_rst_include_end_build_steps_uboot
+.. j722s_evm_rst_include_end_build_steps
+
+Target Images
+--
+
+In order to boot we need tiboot3.bin, tispl.bin and u-boot.img.  Each SoC
+variant (HS-FS, HS-SE) requires a different source for these files.
+
+ - HS-FS
+
+* tiboot3-j722s-hs-fs-evm.bin from step 3.1
+* tispl.bin, u-boot.img from step 3.2
+
+ - HS-SE
+
+* tiboot3-j722s-hs-evm.bin from step 3.1
+* tispl.bin, u-boot.img from step 3.2
+
+Image formats:
+--
+
+- tiboot3.bin
+
+.. image:: img/multi_cert_tiboot3.bin.svg
+  :alt: tiboot3.bin image format
+
+- tispl.bin
+
+.. image:: img/dm_tispl.bin.svg
+  :alt: tispl.bin image format
+
+A53 SPL DDR Memory Layout
+-
+
+.. j722s_evm_rst_include_start_ddr_mem_layout
+
+This provides an overview memory usage in A53 SPL stage.
+
+.. list-table::
+   :widths: 16 16 16
+   :header-rows: 1
+
+   * - Region
+ - Start Address
+ - End Address
+
+   * - EMPTY
+ - 

Re: [PATCH v2 1/4] boot: correct the default sequence of boot methods

2024-04-04 Thread Heinrich Schuchardt

On 04.04.24 17:18, Mark Kettenis wrote:

From: Heinrich Schuchardt 
Date: Thu,  4 Apr 2024 13:47:39 +0200

The default sequence of boot methods is determined by alphabetical sorting
during linkage.

* efi_mgr must run before efi to be UEFI compliant
* pxe should run as last resort

Signed-off-by: Heinrich Schuchardt 


This sound very much like you're working around a standard boot design
flaw.

Who does the alphabetical sorting here?  Is that just a result of how
the toolchain behaves?  If so, that sounds fragile to me and I think
it would be better to make the order explicit in the code.


Thanks for reviewing.

Please, observe the SORT command in our linker script lines

KEEP(*(SORT(__u_boot_list*)));

This ensures that linker generated lists are always alphabetically 
sorted. We rely on this in other places too. See 
part_driver_lookup_type() where GPT must be tested before FAT (commit 
96e5b03c8ab7 ("dm: part: Convert partition API use to linker lists").


Best regards

Heinrich



Cheers,

Mark


---
v2:
no change
---
  boot/bootmeth_efi.c | 2 +-
  boot/bootmeth_efi_mgr.c | 2 +-
  boot/bootmeth_pxe.c | 2 +-
  test/boot/bootflow.c| 2 +-
  4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index c4eb331d69e..a46b6c9c805 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -489,7 +489,7 @@ static const struct udevice_id distro_efi_bootmeth_ids[] = {
{ }
  };
  
-U_BOOT_DRIVER(bootmeth_efi) = {

+U_BOOT_DRIVER(bootmeth_4efi) = {
.name   = "bootmeth_efi",
.id = UCLASS_BOOTMETH,
.of_match   = distro_efi_bootmeth_ids,
diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
index ed29d7ef021..b7d429f2c3d 100644
--- a/boot/bootmeth_efi_mgr.c
+++ b/boot/bootmeth_efi_mgr.c
@@ -114,7 +114,7 @@ static const struct udevice_id efi_mgr_bootmeth_ids[] = {
{ }
  };
  
-U_BOOT_DRIVER(bootmeth_efi_mgr) = {

+U_BOOT_DRIVER(bootmeth_3efi_mgr) = {
.name   = "bootmeth_efi_mgr",
.id = UCLASS_BOOTMETH,
.of_match   = efi_mgr_bootmeth_ids,
diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c
index 8d489a11aa4..70f693aa239 100644
--- a/boot/bootmeth_pxe.c
+++ b/boot/bootmeth_pxe.c
@@ -184,7 +184,7 @@ static const struct udevice_id extlinux_bootmeth_pxe_ids[] 
= {
{ }
  };
  
-U_BOOT_DRIVER(bootmeth_pxe) = {

+U_BOOT_DRIVER(bootmeth_zpxe) = {
.name   = "bootmeth_pxe",
.id = UCLASS_BOOTMETH,
.of_match   = extlinux_bootmeth_pxe_ids,
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 4845b7121c8..e60e9309fa9 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -377,7 +377,7 @@ static int bootflow_system(struct unit_test_state *uts)
if (!IS_ENABLED(CONFIG_EFI_BOOTMGR))
return -EAGAIN;
ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, ));
-   ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_efi_mgr),
+   ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_3efi_mgr),
"efi_mgr", 0, ofnode_null(), ));
ut_assertok(device_probe(dev));
sandbox_set_fake_efi_mgr_dev(dev, true);
--
2.43.0






Re: [RFC PATCH 13/15] arm: dts: Introduce J722S U-Boot dts files

2024-04-04 Thread Andrew Davis

On 4/4/24 4:00 AM, Jayesh Choudhary wrote:

Include the uboot device tree files needed to boot the board.

Co-developed-by: Vaishnav Achath 
Signed-off-by: Vaishnav Achath 
Signed-off-by: Jayesh Choudhary 
---
  arch/arm/dts/Makefile  |2 +
  arch/arm/dts/k3-j722s-binman.dtsi  |  171 ++
  arch/arm/dts/k3-j722s-ddr-lp4-50-3733.dtsi | 2795 
  arch/arm/dts/k3-j722s-evm-u-boot.dtsi  |   36 +
  arch/arm/dts/k3-j722s-r5-evm.dts   |   82 +
  5 files changed, 3086 insertions(+)
  create mode 100644 arch/arm/dts/k3-j722s-binman.dtsi
  create mode 100644 arch/arm/dts/k3-j722s-ddr-lp4-50-3733.dtsi
  create mode 100644 arch/arm/dts/k3-j722s-evm-u-boot.dtsi
  create mode 100644 arch/arm/dts/k3-j722s-r5-evm.dts



[...]


diff --git a/arch/arm/dts/k3-j722s-evm-u-boot.dtsi 
b/arch/arm/dts/k3-j722s-evm-u-boot.dtsi
new file mode 100644
index 00..056ef08455
--- /dev/null
+++ b/arch/arm/dts/k3-j722s-evm-u-boot.dtsi
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Common J722S EVM dts file for SPLs
+ * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include "k3-j722s-binman.dtsi"
+
+/ {
+   chosen {
+   stdout-path = "serial2:115200n8";
+   tick-timer = _timer0;
+   };
+};
+
+_pktdma {
+   reg = <0x00 0x485c 0x00 0x000100>,
+ <0x00 0x4a80 0x00 0x02>,
+ <0x00 0x4aa0 0x00 0x04>,
+ <0x00 0x4b80 0x00 0x40>,
+ <0x00 0x485e 0x00 0x02>,
+ <0x00 0x484a 0x00 0x004000>,
+ <0x00 0x484c 0x00 0x002000>,
+ <0x00 0x4843 0x00 0x004000>;
+   reg-names = "gcfg", "rchanrt", "tchanrt", "ringrt",
+   "cfg", "tchan", "rchan", "rflow";


Is this needed? Do we still not have the correct regs in
upstream kernel?


+};
+
+ {
+   bootph-pre-ram;
+
+   k3_sysreset: sysreset-controller {
+   compatible = "ti,sci-sysreset";
+   bootph-pre-ram;


This node won't be needed soon either[0]. Should mean an
almost empty -u-boot.dtsi file, which should be the goal.

Andrew

[0] https://lore.kernel.org/all/20240402160908.508974-1-...@ti.com/


+   };
+};
diff --git a/arch/arm/dts/k3-j722s-r5-evm.dts b/arch/arm/dts/k3-j722s-r5-evm.dts
new file mode 100644
index 00..aff83cd5d9
--- /dev/null
+++ b/arch/arm/dts/k3-j722s-r5-evm.dts
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * J722S EVM dts file for R5 SPL
+ * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include "k3-j722s-evm.dts"
+#include "k3-j722s-evm-u-boot.dtsi"
+
+#include "k3-j722s-ddr-lp4-50-3733.dtsi"
+#include "k3-am62a-ddr.dtsi"
+
+/ {
+   aliases {
+   remoteproc0 = 
+   remoteproc1 = _0;
+   serial0 = _uart0;
+   serial2 = _uart0;
+   };
+
+   a53_0: a53@0 {
+   compatible = "ti,am654-rproc";
+   reg = <0x00 0x00a9 0x00 0x10>;
+   power-domains = <_pds 61 TI_SCI_PD_EXCLUSIVE>,
+   <_pds 135 TI_SCI_PD_EXCLUSIVE>,
+   <_pds 166 TI_SCI_PD_EXCLUSIVE>;
+   resets = <_reset 135 0>;
+   clocks = <_clks 61 0>;
+   assigned-clocks = <_clks 61 0>, <_clks 135 0>;
+   assigned-clock-parents = <_clks 61 2>;
+   assigned-clock-rates = <2>, <12>;
+   ti,sci = <>;
+   ti,sci-proc-id = <32>;
+   ti,sci-host-id = <10>;
+   bootph-all;
+   };
+
+   dm_tifs: dm-tifs {
+   compatible = "ti,j721e-dm-sci";
+   ti,host-id = <36>;
+   ti,secure-host;
+   mbox-names = "rx", "tx";
+   mboxes= <_proxy_main 22>,
+   <_proxy_main 23>;
+   bootph-all;
+   };
+};
+
+ {
+   mboxes= <_proxy_main 0>,
+   <_proxy_main 1>,
+   <_proxy_main 0>;
+   mbox-names = "rx", "tx", "notify";
+   ti,host-id = <35>;
+   ti,secure-host;
+};
+
+_main {
+   sa3_secproxy: secproxy@4488 {
+   compatible = "ti,am654-secure-proxy";
+   #mbox-cells = <1>;
+   reg = <0x00 0x4488 0x00 0x2>,
+ <0x00 0x4486 0x00 0x2>,
+ <0x00 0x4360 0x00 0x1>;
+   reg-names = "rt", "scfg", "target_data";
+   bootph-all;
+   };
+
+   sysctrler: sysctrler {
+   compatible = "ti,am654-system-controller";
+   mboxes= <_proxy_main 1>,
+   <_proxy_main 0>,
+   <_secproxy 0>;
+   mbox-names = "tx", "rx", "boot_notify";
+   bootph-all;
+   };
+};
+
+/* WKUP UART0 is used for DM firmware logs */
+_uart0 {
+   status = "okay";
+};


Re: [PATCH v2 1/4] boot: correct the default sequence of boot methods

2024-04-04 Thread Mark Kettenis
> From: Heinrich Schuchardt 
> Date: Thu,  4 Apr 2024 13:47:39 +0200
> 
> The default sequence of boot methods is determined by alphabetical sorting
> during linkage.
> 
> * efi_mgr must run before efi to be UEFI compliant
> * pxe should run as last resort
> 
> Signed-off-by: Heinrich Schuchardt 

This sound very much like you're working around a standard boot design
flaw.

Who does the alphabetical sorting here?  Is that just a result of how
the toolchain behaves?  If so, that sounds fragile to me and I think
it would be better to make the order explicit in the code.

Cheers,

Mark

> ---
> v2:
>   no change
> ---
>  boot/bootmeth_efi.c | 2 +-
>  boot/bootmeth_efi_mgr.c | 2 +-
>  boot/bootmeth_pxe.c | 2 +-
>  test/boot/bootflow.c| 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
> index c4eb331d69e..a46b6c9c805 100644
> --- a/boot/bootmeth_efi.c
> +++ b/boot/bootmeth_efi.c
> @@ -489,7 +489,7 @@ static const struct udevice_id distro_efi_bootmeth_ids[] 
> = {
>   { }
>  };
>  
> -U_BOOT_DRIVER(bootmeth_efi) = {
> +U_BOOT_DRIVER(bootmeth_4efi) = {
>   .name   = "bootmeth_efi",
>   .id = UCLASS_BOOTMETH,
>   .of_match   = distro_efi_bootmeth_ids,
> diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
> index ed29d7ef021..b7d429f2c3d 100644
> --- a/boot/bootmeth_efi_mgr.c
> +++ b/boot/bootmeth_efi_mgr.c
> @@ -114,7 +114,7 @@ static const struct udevice_id efi_mgr_bootmeth_ids[] = {
>   { }
>  };
>  
> -U_BOOT_DRIVER(bootmeth_efi_mgr) = {
> +U_BOOT_DRIVER(bootmeth_3efi_mgr) = {
>   .name   = "bootmeth_efi_mgr",
>   .id = UCLASS_BOOTMETH,
>   .of_match   = efi_mgr_bootmeth_ids,
> diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c
> index 8d489a11aa4..70f693aa239 100644
> --- a/boot/bootmeth_pxe.c
> +++ b/boot/bootmeth_pxe.c
> @@ -184,7 +184,7 @@ static const struct udevice_id 
> extlinux_bootmeth_pxe_ids[] = {
>   { }
>  };
>  
> -U_BOOT_DRIVER(bootmeth_pxe) = {
> +U_BOOT_DRIVER(bootmeth_zpxe) = {
>   .name   = "bootmeth_pxe",
>   .id = UCLASS_BOOTMETH,
>   .of_match   = extlinux_bootmeth_pxe_ids,
> diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
> index 4845b7121c8..e60e9309fa9 100644
> --- a/test/boot/bootflow.c
> +++ b/test/boot/bootflow.c
> @@ -377,7 +377,7 @@ static int bootflow_system(struct unit_test_state *uts)
>   if (!IS_ENABLED(CONFIG_EFI_BOOTMGR))
>   return -EAGAIN;
>   ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, ));
> - ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_efi_mgr),
> + ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_3efi_mgr),
>   "efi_mgr", 0, ofnode_null(), ));
>   ut_assertok(device_probe(dev));
>   sandbox_set_fake_efi_mgr_dev(dev, true);
> -- 
> 2.43.0
> 
> 


Re: [PATCH v2 4/4] boot: correct finding the default EFI binary

2024-04-04 Thread Ilias Apalodimas
Hi Heinrich,

FWIW reading at this, I don't see a point of having it overall. It has
a nice feature of trying to load external DTBs from a path though.
I think in the future we can move the dtb selection in
bootmeth_efi_mgr.c and delete this one

On Thu, 4 Apr 2024 at 14:49, Heinrich Schuchardt
 wrote:
>
> * The sandbox must not use an arbitrary file name bootsbox.efi but the
>   file name matching the host architecture to properly boot the respective
>   file. We already have an include which provides a macro with the name of
>   the EFI binary. Use it.
>
> * The path to the EFI binary should be absolute.
>
> * The path and the file name must be capitalized to conform to the UEFI
>   specification. This is important when reading from case sensitive
>   file systems.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
> v2:
> new patch
> ---
>  boot/bootmeth_efi.c  | 44 +++-
>  test/boot/bootflow.c |  4 +++-
>  2 files changed, 6 insertions(+), 42 deletions(-)
>
> diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
> index a46b6c9c805..aebc5207fc0 100644
> --- a/boot/bootmeth_efi.c
> +++ b/boot/bootmeth_efi.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -23,43 +24,7 @@
>  #include 
>  #include 
>
> -#define EFI_DIRNAME"efi/boot/"
> -
> -/**
> - * get_efi_leafname() - Get the leaf name for the EFI file we expect
> - *
> - * @str: Place to put leaf name for this architecture, e.g. "bootaa64.efi".
> - * Must have at least 16 bytes of space
> - * @max_len: Length of @str, must be >=16
> - */
> -static int get_efi_leafname(char *str, int max_len)
> -{
> -   const char *base;
> -
> -   if (max_len < 16)
> -   return log_msg_ret("spc", -ENOSPC);
> -   if (IS_ENABLED(CONFIG_ARM64))
> -   base = "bootaa64";
> -   else if (IS_ENABLED(CONFIG_ARM))
> -   base = "bootarm";
> -   else if (IS_ENABLED(CONFIG_X86_RUN_32BIT))
> -   base = "bootia32";
> -   else if (IS_ENABLED(CONFIG_X86_RUN_64BIT))
> -   base = "bootx64";
> -   else if (IS_ENABLED(CONFIG_ARCH_RV32I))
> -   base = "bootriscv32";
> -   else if (IS_ENABLED(CONFIG_ARCH_RV64I))
> -   base = "bootriscv64";
> -   else if (IS_ENABLED(CONFIG_SANDBOX))
> -   base = "bootsbox";
> -   else
> -   return -EINVAL;
> -
> -   strcpy(str, base);
> -   strcat(str, ".efi");
> -
> -   return 0;
> -}
> +#define EFI_DIRNAME"/EFI/BOOT/"
>
>  static int get_efi_pxe_arch(void)
>  {
> @@ -259,10 +224,7 @@ static int distro_efi_try_bootflow_files(struct udevice 
> *dev,
> return -ENOENT;
>
> strcpy(fname, EFI_DIRNAME);
> -   ret = get_efi_leafname(fname + strlen(fname),
> -  sizeof(fname) - strlen(fname));
> -   if (ret)
> -   return log_msg_ret("leaf", ret);
> +   strcat(fname, BOOTEFI_NAME);
>
> if (bflow->blk)
>  desc = dev_get_uclass_plat(bflow->blk);
> diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
> index e60e9309fa9..674d4c05f83 100644
> --- a/test/boot/bootflow.c
> +++ b/test/boot/bootflow.c
> @@ -13,6 +13,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #ifdef CONFIG_SANDBOX
>  #include 
> @@ -179,7 +180,8 @@ static int bootflow_cmd_scan_e(struct unit_test_state 
> *uts)
> ut_assert_nextline("  3  efi  media   mmc  0  
> mmc1.bootdev.whole");
> ut_assert_nextline(" ** No partition found, err=-2: No such file 
> or directory");
> ut_assert_nextline("  4  extlinux ready   mmc  1  
> mmc1.bootdev.part_1   /extlinux/extlinux.conf");
> -   ut_assert_nextline("  5  efi  fs  mmc  1  
> mmc1.bootdev.part_1   efi/boot/bootsbox.efi");
> +   ut_assert_nextline("  5  efi  fs  mmc  1  
> mmc1.bootdev.part_1   /EFI/BOOT/"
> +  BOOTEFI_NAME);
>
> ut_assert_skip_to_line("Scanning bootdev 'mmc0.bootdev':");
> ut_assert_skip_to_line(
> --
> 2.43.0
>

Reviewed-by: Ilias Apalodimas 
Tested-by: Ilias Apalodimas 


Re: [PATCH v2 3/4] efi_loader: move HOST_ARCH to version_autogenerated.h

2024-04-04 Thread Ilias Apalodimas
On Thu, 4 Apr 2024 at 14:50, Heinrich Schuchardt
 wrote:
>
> efi_default_filename.h requires HOST_ARCH to be defined. Up to now we
> defined it via a CFLAGS. This does not scale. Add the symbol to
> version_autogenerated.h instead.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
> v2:
> new patch
> ---
>  Makefile| 1 +
>  arch/sandbox/config.mk  | 2 --
>  include/host_arch.h | 2 ++
>  lib/efi_loader/Makefile | 3 +--
>  4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index ba660976547..1069adca91e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1963,6 +1963,7 @@ define filechk_version.h
> echo \#define U_BOOT_VERSION_NUM $(VERSION); \
> echo \#define U_BOOT_VERSION_NUM_PATCH $$(echo $(PATCHLEVEL) | \
> sed -e "s/^0*//"); \
> +   echo \#define HOST_ARCH $(HOST_ARCH); \
> echo \#define CC_VERSION_STRING \"$$(LC_ALL=C $(CC) --version | head 
> -n 1)\"; \
> echo \#define LD_VERSION_STRING \"$$(LC_ALL=C $(LD) --version | head 
> -n 1)\"; )
>  endef
> diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
> index 1d50991f8d2..405843800e9 100644
> --- a/arch/sandbox/config.mk
> +++ b/arch/sandbox/config.mk
> @@ -69,5 +69,3 @@ EFI_LDS := 
> ${SRCDIR}/../../../arch/riscv/lib/elf_riscv64_efi.lds
>  endif
>  EFI_CRT0 := crt0_sandbox_efi.o
>  EFI_RELOC := reloc_sandbox_efi.o
> -AFLAGS_crt0_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"
> -CFLAGS_reloc_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"
> diff --git a/include/host_arch.h b/include/host_arch.h
> index 169d4945136..261194bd7c6 100644
> --- a/include/host_arch.h
> +++ b/include/host_arch.h
> @@ -16,6 +16,8 @@ export HOST_ARCH_X86=0x0386
>  export HOST_ARCH_X86_64=0x8664
>  #endif
>
> +#include 
> +
>  #define HOST_ARCH_AARCH64 0xaa64
>  #define HOST_ARCH_ARM 0x00a7
>  #define HOST_ARCH_RISCV32 0x5032
> diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
> index fcb0af7e7d6..086521fb287 100644
> --- a/lib/efi_loader/Makefile
> +++ b/lib/efi_loader/Makefile
> @@ -6,8 +6,7 @@
>  # This file only gets included with CONFIG_EFI_LOADER set, so all
>  # object inclusion implicitly depends on it
>
> -asflags-y += -DHOST_ARCH="$(HOST_ARCH)" -I.
> -ccflags-y += -DHOST_ARCH="$(HOST_ARCH)"
> +asflags-y += -I.
>
>  CFLAGS_efi_boottime.o += \
>-DFW_VERSION="0x$(VERSION)" \
> --
> 2.43.0
>

Acked-by: Ilias Apalodimas 


Re: [PATCH v2 2/4] boot: enable booting via EFI boot manager by default

2024-04-04 Thread Ilias Apalodimas
On Thu, 4 Apr 2024 at 14:49, Heinrich Schuchardt
 wrote:
>
> If UEFI is enabled in U-Boot, we want it to conform to the UEFI
> specification. This requires enabling the boot manager boot method.
>
> Reported-by: E Shattow 
> Signed-off-by: Heinrich Schuchardt 
> ---
> v2:
> fix building with EFI_BOOT_MGR but w/o BOOTSTD
> ---
>  boot/Kconfig   | 10 ++
>  boot/Makefile  |  2 +-
>  lib/efi_loader/Kconfig |  1 -
>  3 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/boot/Kconfig b/boot/Kconfig
> index 3d7aabd27d6..d9a6c270059 100644
> --- a/boot/Kconfig
> +++ b/boot/Kconfig
> @@ -558,6 +558,16 @@ config BOOTMETH_EFILOADER
>
>   This provides a way to try out standard boot on an existing boot 
> flow.
>
> +config BOOTMETH_EFI_BOOTMGR
> +   bool "Bootdev support for EFI boot manager"
> +   depends on EFI_BOOTMGR
> +   select BOOTMETH_GLOBAL
> +   default y
> +   help
> + Enable booting via the UEFI boot manager. Based on the EFI variables
> + the EFI binary to be launched is determined. To set the EFI 
> variables
> + use the eficonfig command.
> +
>  config BOOTMETH_VBE
> bool "Bootdev support for Verified Boot for Embedded"
> depends on FIT
> diff --git a/boot/Makefile b/boot/Makefile
> index f0a279cde16..84ccfeaecec 100644
> --- a/boot/Makefile
> +++ b/boot/Makefile
> @@ -34,8 +34,8 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_CROS) += bootm.o 
> bootm_os.o bootmeth_cros.o
>  obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o
>  obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o
>  obj-$(CONFIG_$(SPL_TPL_)CEDIT) += cedit.o
> +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFI_BOOTMGR) += bootmeth_efi_mgr.o
>  ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL
> -obj-$(CONFIG_EFI_BOOTMGR) += bootmeth_efi_mgr.o
>  obj-$(CONFIG_$(SPL_TPL_)EXPO) += bootflow_menu.o
>  obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow_menu.o
>  endif
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index a7c3e05c13a..e13a6f9f4c3 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -44,7 +44,6 @@ config EFI_BINARY_EXEC
>  config EFI_BOOTMGR
> bool "UEFI Boot Manager"
> default y
> -   select BOOTMETH_GLOBAL if BOOTSTD
> help
>   Select this option if you want to select the UEFI binary to be 
> booted
>   via UEFI variables Boot, BootOrder, and BootNext. You should 
> also
> --
> 2.43.0
>

Reviewed-by: Ilias Apalodimas 


Re: [PATCH v2 1/4] boot: correct the default sequence of boot methods

2024-04-04 Thread Ilias Apalodimas
On Thu, 4 Apr 2024 at 14:49, Heinrich Schuchardt
 wrote:
>
> The default sequence of boot methods is determined by alphabetical sorting
> during linkage.
>
> * efi_mgr must run before efi to be UEFI compliant
> * pxe should run as last resort
>
> Signed-off-by: Heinrich Schuchardt 
> ---
> v2:
> no change
> ---
>  boot/bootmeth_efi.c | 2 +-
>  boot/bootmeth_efi_mgr.c | 2 +-
>  boot/bootmeth_pxe.c | 2 +-
>  test/boot/bootflow.c| 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
> index c4eb331d69e..a46b6c9c805 100644
> --- a/boot/bootmeth_efi.c
> +++ b/boot/bootmeth_efi.c
> @@ -489,7 +489,7 @@ static const struct udevice_id distro_efi_bootmeth_ids[] 
> = {
> { }
>  };
>
> -U_BOOT_DRIVER(bootmeth_efi) = {
> +U_BOOT_DRIVER(bootmeth_4efi) = {
> .name   = "bootmeth_efi",
> .id = UCLASS_BOOTMETH,
> .of_match   = distro_efi_bootmeth_ids,
> diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
> index ed29d7ef021..b7d429f2c3d 100644
> --- a/boot/bootmeth_efi_mgr.c
> +++ b/boot/bootmeth_efi_mgr.c
> @@ -114,7 +114,7 @@ static const struct udevice_id efi_mgr_bootmeth_ids[] = {
> { }
>  };
>
> -U_BOOT_DRIVER(bootmeth_efi_mgr) = {
> +U_BOOT_DRIVER(bootmeth_3efi_mgr) = {
> .name   = "bootmeth_efi_mgr",
> .id = UCLASS_BOOTMETH,
> .of_match   = efi_mgr_bootmeth_ids,
> diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c
> index 8d489a11aa4..70f693aa239 100644
> --- a/boot/bootmeth_pxe.c
> +++ b/boot/bootmeth_pxe.c
> @@ -184,7 +184,7 @@ static const struct udevice_id 
> extlinux_bootmeth_pxe_ids[] = {
> { }
>  };
>
> -U_BOOT_DRIVER(bootmeth_pxe) = {
> +U_BOOT_DRIVER(bootmeth_zpxe) = {
> .name   = "bootmeth_pxe",
> .id = UCLASS_BOOTMETH,
> .of_match   = extlinux_bootmeth_pxe_ids,
> diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
> index 4845b7121c8..e60e9309fa9 100644
> --- a/test/boot/bootflow.c
> +++ b/test/boot/bootflow.c
> @@ -377,7 +377,7 @@ static int bootflow_system(struct unit_test_state *uts)
> if (!IS_ENABLED(CONFIG_EFI_BOOTMGR))
> return -EAGAIN;
> ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, ));
> -   ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_efi_mgr),
> +   ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_3efi_mgr),
> "efi_mgr", 0, ofnode_null(), ));
> ut_assertok(device_probe(dev));
> sandbox_set_fake_efi_mgr_dev(dev, true);
> --
> 2.43.0
>

Reviewed-by: Ilias Apalodimas 


[PATCH v5 5/5] tee: remove common.h inclusion

2024-04-04 Thread Igor Opaniuk
The usage of the common.h include file is deprecated [1], and has already
been removed from several files.
Get rid of all inclusions in the "drivers/tee" directory, and replace it
with required include files directly where needed.

[1] doc/develop/codingstyle.rst

Reviewed-by: Ilias Apalodimas 
Signed-off-by: Igor Opaniuk 
---

Changes in v5:
- Extended commit message for "cmd: optee_rpmb: close tee session"
- Added R-b tag

Changes in v4:
- Rebased on the latest master and excluded "tee: sandbox: fix spelling errors",
  as it was merged already by Heinrich Schuchardt

Changes in v3:
- Added calls for closing tee session after every read/write operation
- Added calls for closing tee session after every read/write operation

Changes in v2:
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
- Applied R-b and T-b tags
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'

 drivers/tee/broadcom/chimp_optee.c | 3 ++-
 drivers/tee/optee/core.c   | 1 -
 drivers/tee/optee/i2c.c| 1 -
 drivers/tee/optee/rpmb.c   | 1 -
 drivers/tee/optee/supplicant.c | 2 +-
 drivers/tee/sandbox.c  | 2 +-
 drivers/tee/tee-uclass.c   | 1 -
 7 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/tee/broadcom/chimp_optee.c 
b/drivers/tee/broadcom/chimp_optee.c
index 37f9b094f76..bd146ef2899 100644
--- a/drivers/tee/broadcom/chimp_optee.c
+++ b/drivers/tee/broadcom/chimp_optee.c
@@ -3,9 +3,10 @@
  * Copyright 2020 Broadcom.
  */
 
-#include 
 #include 
 #include 
+#include 
+#include 
 
 #ifdef CONFIG_CHIMP_OPTEE
 
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 47f845cffe3..5fc0505c788 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -3,7 +3,6 @@
  * Copyright (c) 2018-2020 Linaro Limited
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/tee/optee/i2c.c b/drivers/tee/optee/i2c.c
index ef4e10f9912..e3fb99897c5 100644
--- a/drivers/tee/optee/i2c.c
+++ b/drivers/tee/optee/i2c.c
@@ -3,7 +3,6 @@
  * Copyright (c) 2020 Foundries.io Ltd
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c
index 5bc13757ea8..bacced6af6c 100644
--- a/drivers/tee/optee/rpmb.c
+++ b/drivers/tee/optee/rpmb.c
@@ -3,7 +3,6 @@
  * Copyright (c) 2018 Linaro Limited
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/tee/optee/supplicant.c b/drivers/tee/optee/supplicant.c
index f9dd874b594..8a426f53ba8 100644
--- a/drivers/tee/optee/supplicant.c
+++ b/drivers/tee/optee/supplicant.c
@@ -3,10 +3,10 @@
  * Copyright (c) 2018, Linaro Limited
  */
 
-#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "optee_msg.h"
diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c
index ec66401878c..8ad7c09efdd 100644
--- a/drivers/tee/sandbox.c
+++ b/drivers/tee/sandbox.c
@@ -2,7 +2,7 @@
 /*
  * Copyright (C) 2018 Linaro Limited
  */
-#include 
+
 #include 
 #include 
 #include 
diff --git a/drivers/tee/tee-uclass.c b/drivers/tee/tee-uclass.c
index 52412a4098e..0194d732193 100644
--- a/drivers/tee/tee-uclass.c
+++ b/drivers/tee/tee-uclass.c
@@ -5,7 +5,6 @@
 
 #define LOG_CATEGORY UCLASS_TEE
 
-#include 
 #include 
 #include 
 #include 
-- 
2.34.1



[PATCH v5 4/5] test: py: add optee_rpmb tests

2024-04-04 Thread Igor Opaniuk
Add read/write tests for optee_rpmb cmd.

Signed-off-by: Igor Opaniuk 
---

(no changes since v1)

 test/py/tests/test_optee_rpmb.py | 20 
 1 file changed, 20 insertions(+)
 create mode 100644 test/py/tests/test_optee_rpmb.py

diff --git a/test/py/tests/test_optee_rpmb.py b/test/py/tests/test_optee_rpmb.py
new file mode 100644
index 000..8a081b5c494
--- /dev/null
+++ b/test/py/tests/test_optee_rpmb.py
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier:  GPL-2.0+
+#
+# Tests for OP-TEE RPMB read/write support
+
+"""
+This tests optee_rpmb cmd in U-Boot
+"""
+
+import pytest
+import u_boot_utils as util
+
+@pytest.mark.buildconfigspec('cmd_optee_rpmb')
+def test_optee_rpmb_read_write(u_boot_console):
+"""Test OP-TEE RPMB cmd read/write
+"""
+response = u_boot_console.run_command('optee_rpmb write_pvalue 
test_variable test_value')
+assert response == 'Wrote 11 bytes'
+
+response = u_boot_console.run_command('optee_rpmb read_pvalue 
test_variable 11')
+assert response == 'Read 11 bytes, value = test_value'
\ No newline at end of file
-- 
2.34.1



[PATCH v5 3/5] cmd: optee_rpmb: build cmd for sandbox

2024-04-04 Thread Igor Opaniuk
Support CMD_OPTEE_RPMB for SANDBOX configurations.
Test:

$ ./u-boot -d arch/sandbox/dts/test.dtb
...
=> optee_rpmb write_pvalue test_variable test_value
Wrote 11 bytes
=> optee_rpmb read_pvalue test_variable 11
Read 11 bytes, value = test_value

Reviewed-by: Mattijs Korpershoek 
Tested-by: Mattijs Korpershoek 
Signed-off-by: Igor Opaniuk 
---

(no changes since v2)

Changes in v2:
- Applied R-b and T-b tags

 cmd/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 61e280fb1a4..227d66a7eea 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1394,7 +1394,9 @@ config CMD_CLONE
 
 config CMD_OPTEE_RPMB
bool "Enable read/write support on RPMB via OPTEE"
-   depends on SUPPORT_EMMC_RPMB && OPTEE
+   depends on (SUPPORT_EMMC_RPMB && OPTEE) || SANDBOX_TEE
+   default y if SANDBOX_TEE
+   select OPTEE_TA_AVB if SANDBOX_TEE
help
  Enable the commands for reading, writing persistent named values
  in the Replay Protection Memory Block partition in eMMC by
-- 
2.34.1



[PATCH v5 2/5] cmd: optee_rpmb: close tee session

2024-04-04 Thread Igor Opaniuk
Close tee session after each optee_rpmb invocation, as there is no
reason to keep it open, considering the absence of any available mechanism
to clean up all open sessions automatically before handing over control
to the Linux kernel. Without proper clean-up we might end up with orphaned
sessions registered in OP-TEE OS core (obvious resource leak).

Signed-off-by: Igor Opaniuk 
---

Changes in v5:
- Extended commit message, added more details about the reasons why the
  change was needed

 cmd/optee_rpmb.c | 23 +--
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
index e0e44bbed04..b3cafd92410 100644
--- a/cmd/optee_rpmb.c
+++ b/cmd/optee_rpmb.c
@@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
 
rc = tee_shm_alloc(tee, name_size,
   TEE_SHM_ALLOC, _name);
-   if (rc)
-   return -ENOMEM;
+   if (rc) {
+   rc = -ENOMEM;
+   goto close_session;
+   }
 
rc = tee_shm_alloc(tee, buffer_size,
   TEE_SHM_ALLOC, _buf);
@@ -125,6 +127,9 @@ out:
tee_shm_free(shm_buf);
 free_name:
tee_shm_free(shm_name);
+close_session:
+   tee_close_session(tee, session);
+   tee = NULL;
 
return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
struct tee_param param[2];
size_t name_size = strlen(name) + 1;
 
+   if (!value_size)
+   return -EINVAL;
+
if (!tee) {
if (avb_ta_open_session())
return -ENODEV;
}
-   if (!value_size)
-   return -EINVAL;
 
rc = tee_shm_alloc(tee, name_size,
   TEE_SHM_ALLOC, _name);
-   if (rc)
-   return -ENOMEM;
+   if (rc) {
+   rc = -ENOMEM;
+   goto close_session;
+   }
 
rc = tee_shm_alloc(tee, value_size,
   TEE_SHM_ALLOC, _buf);
@@ -178,6 +186,9 @@ out:
tee_shm_free(shm_buf);
 free_name:
tee_shm_free(shm_name);
+close_session:
+   tee_close_session(tee, session);
+   tee = NULL;
 
return rc;
 }
-- 
2.34.1



[PATCH v5 1/5] tee: optee: fix description in Kconfig

2024-04-04 Thread Igor Opaniuk
Fix OPTEE_TA_AVB symbol description in Kconfig:
s/"write"rb"/"write_rb"/g

Reviewed-by: Heinrich Schuchardt 
Reviewed-by: Ilias Apalodimas 
Signed-off-by: Igor Opaniuk 
---

(no changes since v2)

Changes in v2:
- Applied R-b tags

 drivers/tee/optee/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig
index 9dc65b0501e..db0bcfa6f15 100644
--- a/drivers/tee/optee/Kconfig
+++ b/drivers/tee/optee/Kconfig
@@ -19,7 +19,7 @@ config OPTEE_TA_AVB
default y
help
  Enables support for the AVB Trusted Application (TA) in OP-TEE.
- The TA can support the "avb" subcommands "read_rb", "write"rb"
+ The TA can support the "avb" subcommands "read_rb", "write_rb"
  and "is_unlocked".
 
 config OPTEE_TA_RPC_TEST
-- 
2.34.1



[PATCH v5 0/5] TEE: minor cleanup

2024-04-04 Thread Igor Opaniuk
- Address some spelling errors and typos
- Support CMD_OPTEE_RPMB for SANDBOX configurations and add python tests
- Remove common.h inclusion for drivers/tee
- Add calls for closing tee session after every read/write operation.

CI build:
[1] 
https://dev.azure.com/igoropaniuk/u-boot/_build/results?buildId=33=results

Changes in v5:
- Extended commit message for "cmd: optee_rpmb: close tee session"
- Added R-b tag

Changes in v4:
- Rebased on the latest master and excluded "tee: sandbox: fix spelling errors",
  as it was merged already by Heinrich Schuchardt

Changes in v3:
- Added calls for closing tee session after every read/write operation

Changes in v2:
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
- Applied R-b and T-b tags

Igor Opaniuk (5):
  tee: optee: fix description in Kconfig
  cmd: optee_rpmb: close tee session
  cmd: optee_rpmb: build cmd for sandbox
  test: py: add optee_rpmb tests
  tee: remove common.h inclusion

 cmd/Kconfig|  4 +++-
 cmd/optee_rpmb.c   | 23 +--
 drivers/tee/broadcom/chimp_optee.c |  3 ++-
 drivers/tee/optee/Kconfig  |  2 +-
 drivers/tee/optee/core.c   |  1 -
 drivers/tee/optee/i2c.c|  1 -
 drivers/tee/optee/rpmb.c   |  1 -
 drivers/tee/optee/supplicant.c |  2 +-
 drivers/tee/sandbox.c  |  2 +-
 drivers/tee/tee-uclass.c   |  1 -
 test/py/tests/test_optee_rpmb.py   | 20 
 11 files changed, 45 insertions(+), 15 deletions(-)
 create mode 100644 test/py/tests/test_optee_rpmb.py

-- 
2.34.1



Re: [PATCH] arm: dts: kirkwood: Remove DTS files for Kirkwood boards

2024-04-04 Thread Stefan Roese

On 3/26/24 22:12, Tony Dinh wrote:

Remove DTS and DTSI files for Kirkwood boards that have upstream supports.

This patch depends on
"arm: dts: kirkwood: Enable upstream DT on Kirkwood boards"
https://patchwork.ozlabs.org/project/uboot/patch/20240322021747.14873-1-mibo...@gmail.com/

Signed-off-by: Tony Dinh 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

  arch/arm/dts/Makefile |  28 +-
  arch/arm/dts/kirkwood-6192.dtsi   |  88 --
  arch/arm/dts/kirkwood-6281.dtsi   |  90 --
  arch/arm/dts/kirkwood-6282.dtsi   | 161 
  arch/arm/dts/kirkwood-98dx4122.dtsi   |  53 --
  arch/arm/dts/kirkwood-blackarmor-nas220.dts   | 172 
  arch/arm/dts/kirkwood-d2net.dts   |  45 -
  arch/arm/dts/kirkwood-dns325.dts  |  63 --
  arch/arm/dts/kirkwood-dnskw.dtsi  | 235 -
  arch/arm/dts/kirkwood-dockstar.dts| 110 ---
  arch/arm/dts/kirkwood-dreamplug.dts   | 131 ---
  arch/arm/dts/kirkwood-ds109.dts   |  40 -
  arch/arm/dts/kirkwood-goflexnet.dts   | 190 
  .../arm/dts/kirkwood-guruplug-server-plus.dts | 133 ---
  arch/arm/dts/kirkwood-ib62x0.dts  | 146 ---
  arch/arm/dts/kirkwood-iconnect.dts| 195 
  arch/arm/dts/kirkwood-is2.dts |  40 -
  arch/arm/dts/kirkwood-lschlv2.dts |  20 -
  arch/arm/dts/kirkwood-lsxhl.dts   |  20 -
  arch/arm/dts/kirkwood-lsxl.dtsi   | 241 -
  arch/arm/dts/kirkwood-net2big.dts |  63 --
  arch/arm/dts/kirkwood-netxbig.dtsi| 232 -
  arch/arm/dts/kirkwood-ns2-common.dtsi |  97 --
  arch/arm/dts/kirkwood-ns2.dts |  40 -
  arch/arm/dts/kirkwood-ns2lite.dts |  35 -
  arch/arm/dts/kirkwood-ns2max.dts  |  59 --
  arch/arm/dts/kirkwood-ns2mini.dts |  60 --
  arch/arm/dts/kirkwood-nsa310s.dts | 319 ---
  arch/arm/dts/kirkwood-nsa325.dts  | 231 -
  arch/arm/dts/kirkwood-nsa3x0-common.dtsi  | 157 
  arch/arm/dts/kirkwood-openrd-base.dts |  39 -
  arch/arm/dts/kirkwood-openrd-client.dts   |  73 --
  arch/arm/dts/kirkwood-openrd-ultimate.dts |  55 --
  arch/arm/dts/kirkwood-openrd.dtsi | 122 ---
  arch/arm/dts/kirkwood-pogo_e02.dts| 132 ---
  arch/arm/dts/kirkwood-pogoplug-series-4.dts   | 180 
  arch/arm/dts/kirkwood-sheevaplug-common.dtsi  | 104 ---
  arch/arm/dts/kirkwood-sheevaplug.dts  |  42 -
  arch/arm/dts/kirkwood-synology.dtsi   | 855 --
  arch/arm/dts/kirkwood.dtsi| 393 
  40 files changed, 1 insertion(+), 5488 deletions(-)
  delete mode 100644 arch/arm/dts/kirkwood-6192.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-6281.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-6282.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-98dx4122.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-blackarmor-nas220.dts
  delete mode 100644 arch/arm/dts/kirkwood-d2net.dts
  delete mode 100644 arch/arm/dts/kirkwood-dns325.dts
  delete mode 100644 arch/arm/dts/kirkwood-dnskw.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-dockstar.dts
  delete mode 100644 arch/arm/dts/kirkwood-dreamplug.dts
  delete mode 100644 arch/arm/dts/kirkwood-ds109.dts
  delete mode 100644 arch/arm/dts/kirkwood-goflexnet.dts
  delete mode 100644 arch/arm/dts/kirkwood-guruplug-server-plus.dts
  delete mode 100644 arch/arm/dts/kirkwood-ib62x0.dts
  delete mode 100644 arch/arm/dts/kirkwood-iconnect.dts
  delete mode 100644 arch/arm/dts/kirkwood-is2.dts
  delete mode 100644 arch/arm/dts/kirkwood-lschlv2.dts
  delete mode 100644 arch/arm/dts/kirkwood-lsxhl.dts
  delete mode 100644 arch/arm/dts/kirkwood-lsxl.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-net2big.dts
  delete mode 100644 arch/arm/dts/kirkwood-netxbig.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-ns2-common.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-ns2.dts
  delete mode 100644 arch/arm/dts/kirkwood-ns2lite.dts
  delete mode 100644 arch/arm/dts/kirkwood-ns2max.dts
  delete mode 100644 arch/arm/dts/kirkwood-ns2mini.dts
  delete mode 100644 arch/arm/dts/kirkwood-nsa310s.dts
  delete mode 100644 arch/arm/dts/kirkwood-nsa325.dts
  delete mode 100644 arch/arm/dts/kirkwood-nsa3x0-common.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-openrd-base.dts
  delete mode 100644 arch/arm/dts/kirkwood-openrd-client.dts
  delete mode 100644 arch/arm/dts/kirkwood-openrd-ultimate.dts
  delete mode 100644 arch/arm/dts/kirkwood-openrd.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-pogo_e02.dts
  delete mode 100644 arch/arm/dts/kirkwood-pogoplug-series-4.dts
  delete mode 100644 arch/arm/dts/kirkwood-sheevaplug-common.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-sheevaplug.dts
  delete mode 100644 arch/arm/dts/kirkwood-synology.dtsi
  delete mode 100644 arch/arm/dts/kirkwood.dtsi

diff --git a/arch/arm/dts/Makefile 

RE: [PATCH] arm: imx: fix signature_block_hdr struct fields order

2024-04-04 Thread Viguera, Javier
Hi Fabio,

First, sorry for the delay. I was out of the office (Easter).

-Original Message-
From: Fabio Estevam  
Could you elaborate more about this and share more details?
Have you seen a run-time error or did you catch it by code inspection?

The struct has the fields in the wrong order according to other documentation 
from NXP (see for example the AN13994 - Encrypted Boot on AHAB-enabled devices).

In the current upstream u-boot code there is NO runtime error, as those fields 
are not being used. Only ' get_container_size`on  
`arch/arm/mach-imx/image-container.c`  defines a variable of that type. But 
then it only uses the "length_lsb" and "length_msb" fiels, which are at the 
beginning of the struct and thus in the correct position.

On the other hand, we were hit by this problem in some bootloader encryption 
related code we do in our (as of Digi) BSP. We get the blob offset from the 
signature block header to read the data encryption key blob and due to the 
wrong order this patch fixes, we were getting a wrong position of the DEK blob.

Hope this clears it up a bit.

--
Javier Viguera
Software Engineer at Digi International.





[PATCH] xilinx: common: Fix MAC address read from EEPROM

2024-04-04 Thread Petr Zejdl
The upper-to-lowercase character conversion now avoids altering the
MAC address field. In the previous version, this alteration corrupted
the MAC address.

Signed-off-by: Petr Zejdl 
---
 board/xilinx/common/board.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 66edf857f1..49dc5d10cc 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -101,10 +101,14 @@ static void xilinx_eeprom_legacy_cleanup(char *eeprom, 
int size)
for (i = 0; i < size; i++) {
byte = eeprom[i];
 
-   /* Remove all non printable chars but ignore MAC address */
-   if ((i < offsetof(struct xilinx_legacy_format, eth_mac) ||
-i >= offsetof(struct xilinx_legacy_format, unused1)) &&
-(byte < '!' || byte > '~')) {
+   /* Ignore MAC address */
+   if (i >= offsetof(struct xilinx_legacy_format, eth_mac) &&
+   i < offsetof(struct xilinx_legacy_format, unused1)) {
+   continue;
+   }
+
+   /* Remove all non printable chars */
+   if (byte < '!' || byte > '~') {
eeprom[i] = 0;
continue;
}
-- 
2.31.1



[PATCH v3 3/3] spinand: bind mtdblock

2024-04-04 Thread Alexey Romanov
Bind SPI-NAND driver to MTD block driver.

Reviewed-by: Frieder Schrempf 
Signed-off-by: Alexey Romanov 
---
 drivers/mtd/nand/spi/core.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 2a3dbcfcb4..dd880adf31 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -36,6 +36,10 @@
 #include 
 #endif
 
+struct spinand_plat {
+   struct mtd_info *mtd;
+};
+
 /* SPI NAND index visible in MTD names */
 static int spi_nand_idx;
 
@@ -1174,12 +1178,24 @@ static void spinand_cleanup(struct spinand_device 
*spinand)
kfree(spinand->scratchbuf);
 }
 
+static int spinand_bind(struct udevice *dev)
+{
+   if (blk_enabled()) {
+   struct spinand_plat *plat = dev_get_plat(dev);
+
+   return mtd_bind(dev, >mtd);
+   }
+
+   return 0;
+}
+
 static int spinand_probe(struct udevice *dev)
 {
struct spinand_device *spinand = dev_get_priv(dev);
struct spi_slave *slave = dev_get_parent_priv(dev);
struct mtd_info *mtd = dev_get_uclass_priv(dev);
struct nand_device *nand = spinand_to_nand(spinand);
+   struct spinand_plat *plat = dev_get_plat(dev);
int ret;
 
 #ifndef __UBOOT__
@@ -1219,6 +1235,8 @@ static int spinand_probe(struct udevice *dev)
if (ret)
goto err_spinand_cleanup;
 
+   plat->mtd = mtd;
+
return 0;
 
 err_spinand_cleanup:
@@ -1288,6 +1306,8 @@ U_BOOT_DRIVER(spinand) = {
.of_match = spinand_ids,
.priv_auto  = sizeof(struct spinand_device),
.probe = spinand_probe,
+   .bind = spinand_bind,
+   .plat_auto = sizeof(struct spinand_plat),
 };
 
 void board_nand_init(void)
-- 
2.34.1



[PATCH v3 2/3] drivers: introduce mtdblock abstraction

2024-04-04 Thread Alexey Romanov
MTD block - abstraction over MTD subsystem, allowing
to read and write in blocks using BLK UCLASS.

Signed-off-by: Alexey Romanov 
---
 drivers/block/blk-uclass.c |   1 +
 drivers/mtd/Makefile   |   1 +
 drivers/mtd/mtdblock.c | 227 +
 include/linux/mtd/mtd.h|  12 ++
 4 files changed, 241 insertions(+)
 create mode 100644 drivers/mtd/mtdblock.c

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 77066da352..ab0a9105c9 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -37,6 +37,7 @@ static struct {
{ UCLASS_PVBLOCK, "pvblock" },
{ UCLASS_BLKMAP, "blkmap" },
{ UCLASS_RKMTD, "rkmtd" },
+   { UCLASS_MTD, "mtd" },
 };
 
 static enum uclass_id uclass_name_to_iftype(const char *uclass_idname)
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index c638980ea2..993b122ac4 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -26,6 +26,7 @@ obj-y += onenand/
 obj-y += spi/
 obj-$(CONFIG_MTD_UBI) += ubi/
 obj-$(CONFIG_NVMXIP) += nvmxip/
+obj-$(CONFIG_BLK) += mtdblock.o
 
 #SPL/TPL build
 else
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
new file mode 100644
index 00..e56fa49064
--- /dev/null
+++ b/drivers/mtd/mtdblock.c
@@ -0,0 +1,227 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * MTD block - abstraction over MTD subsystem, allowing
+ * to read and write in blocks using BLK UCLASS.
+ *
+ * - Read algorithm:
+ *
+ *   1. Convert start block number to start address.
+ *   2. Read block_dev->blksz bytes using mtd_read() and
+ *  add to start address pointer block_dev->blksz bytes,
+ *  until the requested number of blocks have been read.
+ *
+ * - Write algorithm:
+ *
+ *   1. Convert start block number to start address.
+ *   2. Round this address down by mtd->erasesize.
+ *
+ *   Erase addr  Start addr
+ *  ||
+ *  vv
+ *  ++++
+ *  | blksz  |  blksz |  blksz |
+ *  ++++
+ *
+ *   3. Calculate offset between this two addresses.
+ *   4. Read mtd->erasesize bytes using mtd_read() into
+ *  temporary buffer from erase address.
+ *
+ *   Erase addr  Start addr
+ *  ||
+ *  vv
+ *  ++++
+ *  | blksz  |  blksz |  blksz |
+ *  ++++
+ *  ^
+ *  |
+ *  |
+ *   mtd_read()
+ *   from here
+ *
+ *   5. Copy data from user buffer to temporary buffer with offset,
+ *  calculated at step 3.
+ *   6. Erase and write mtd->erasesize bytes at erase address
+ *  pointer using mtd_erase/mtd_write().
+ *   7. Add to erase address pointer mtd->erasesize bytes.
+ *   8. goto 1 until the requested number of blocks have
+ *  been written.
+ *
+ * (C) Copyright 2024 SaluteDevices, Inc.
+ *
+ * Author: Alexey Romanov 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int mtd_bind(struct udevice *dev, struct mtd_info **mtd)
+{
+   struct blk_desc *bdesc;
+   struct udevice *bdev;
+   int ret;
+
+   ret = blk_create_devicef(dev, "mtd_blk", "blk", UCLASS_MTD,
+dev_seq(dev), 512, 0, );
+   if (ret) {
+   pr_err("Cannot create block device\n");
+   return ret;
+   }
+
+   bdesc = dev_get_uclass_plat(bdev);
+   dev_set_priv(bdev, mtd);
+   bdesc->bdev = bdev;
+   bdesc->part_type = PART_TYPE_MTD;
+
+   return 0;
+}
+
+static ulong mtd_blk_read(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
+ void *dst)
+{
+   struct blk_desc *block_dev = dev_get_uclass_plat(dev);
+   struct mtd_info *mtd = blk_desc_to_mtd(block_dev);
+   unsigned int sect_size = block_dev->blksz;
+   lbaint_t cur = start;
+   ulong read_cnt = 0;
+
+   while (read_cnt < blkcnt) {
+   int ret;
+   loff_t sect_start = cur * sect_size;
+   size_t retlen;
+
+   ret = mtd_read(mtd, sect_start, sect_size, , dst);
+   if (ret)
+   return ret;
+
+   if (retlen != sect_size) {
+   pr_err("mtdblock: failed to read block 0x%lx\n", cur);
+   return -EIO;
+   }
+
+   cur++;
+   dst += sect_size;
+   read_cnt++;
+   }
+
+   return read_cnt;
+}
+
+static int mtd_erase_write(struct mtd_info *mtd, uint64_t start, const void 
*src)
+{
+   int ret;
+   size_t retlen;
+   struct erase_info erase = { 0 };
+
+   erase.mtd = mtd;
+   erase.addr = start;
+   erase.len = mtd->erasesize;
+
+   ret = mtd_erase(mtd, );
+   if (ret)
+   return ret;
+
+   ret = 

[PATCH v3 1/3] disk: support MTD partitions

2024-04-04 Thread Alexey Romanov
Add new MTD partition driver, which can be useful with
mtdblock driver combination.

Signed-off-by: Alexey Romanov 
---
 disk/part.c   |  3 +-
 drivers/mtd/Kconfig   |  1 +
 drivers/mtd/mtdpart.c | 69 +++
 include/part.h|  3 ++
 4 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/disk/part.c b/disk/part.c
index b6b485a637..5ed7dee6fa 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -304,7 +304,8 @@ static void print_part_header(const char *type, struct 
blk_desc *desc)
CONFIG_IS_ENABLED(DOS_PARTITION) || \
CONFIG_IS_ENABLED(ISO_PARTITION) || \
CONFIG_IS_ENABLED(AMIGA_PARTITION) || \
-   CONFIG_IS_ENABLED(EFI_PARTITION)
+   CONFIG_IS_ENABLED(EFI_PARTITION) || \
+   CONFIG_IS_ENABLED(MTD_PARTITIONS)
printf("\nPartition Map for %s device %d  --   Partition Type: %s\n\n",
   uclass_get_name(desc->uclass_id), desc->devnum, type);
 #endif /* any CONFIG_..._PARTITION */
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 1902351719..40272f7e50 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -2,6 +2,7 @@ menu "MTD Support"
 
 config MTD_PARTITIONS
bool
+   select PARTITIONS
 
 config MTD
bool "Enable MTD layer"
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 4886392a1c..67244869f2 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -21,6 +21,8 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -1055,3 +1057,70 @@ uint64_t mtd_get_device_size(const struct mtd_info *mtd)
return mtd->size;
 }
 EXPORT_SYMBOL_GPL(mtd_get_device_size);
+
+static struct mtd_info *mtd_get_partition_by_index(struct mtd_info *mtd, int 
index)
+{
+   struct mtd_info *part;
+   int i = 0;
+
+   list_for_each_entry(part, >partitions, node)
+   if (i++ == index)
+   return part;
+
+   debug("Partition with idx=%d not found on MTD device %s\n", index, 
mtd->name);
+   return NULL;
+}
+
+static int part_get_info_mtd(struct blk_desc *dev_desc, int part_idx,
+struct disk_partition *info)
+{
+   struct mtd_info *master = blk_desc_to_mtd(dev_desc);
+   struct mtd_info *part;
+
+   if (!master) {
+   pr_err("MTD device is NULL\n");
+   return -EINVAL;
+   }
+
+   part = mtd_get_partition_by_index(master, part_idx);
+   if (!part) {
+   debug("Failed to find partition with idx=%d\n", part_idx);
+   return -EINVAL;
+   }
+
+   snprintf(info->name, PART_NAME_LEN, part->name);
+   info->start = part->offset / dev_desc->blksz;
+   info->size = part->size / dev_desc->blksz;
+   info->blksz = dev_desc->blksz;
+
+   return 0;
+}
+
+static void part_print_mtd(struct blk_desc *dev_desc)
+{
+   struct mtd_info *master = blk_desc_to_mtd(dev_desc);
+   struct mtd_info *part;
+
+   list_for_each_entry(part, >partitions, node)
+   printf("- 0x%012llx-0x%012llx : \"%s\"\n",
+  part->offset, part->offset + part->size, part->name);
+}
+
+static int part_test_mtd(struct blk_desc *dev_desc)
+{
+   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
+
+   if (blk_dread(dev_desc, 0, 1, (ulong *)buffer) != 1)
+   return -1;
+
+   return 0;
+}
+
+U_BOOT_PART_TYPE(mtd) = {
+   .name   = "MTD",
+   .part_type  = PART_TYPE_MTD,
+   .max_entries= MTD_ENTRY_NUMBERS,
+   .get_info   = part_get_info_ptr(part_get_info_mtd),
+   .print  = part_print_ptr(part_print_mtd),
+   .test   = part_test_mtd,
+};
diff --git a/include/part.h b/include/part.h
index db34bc6bb7..85c1b881b9 100644
--- a/include/part.h
+++ b/include/part.h
@@ -30,12 +30,15 @@ struct block_drvr {
 #define PART_TYPE_ISO  0x03
 #define PART_TYPE_AMIGA0x04
 #define PART_TYPE_EFI  0x05
+#define PART_TYPE_MTD  0x06
 
 /* maximum number of partition entries supported by search */
 #define DOS_ENTRY_NUMBERS  8
 #define ISO_ENTRY_NUMBERS  64
 #define MAC_ENTRY_NUMBERS  64
 #define AMIGA_ENTRY_NUMBERS8
+#define MTD_ENTRY_NUMBERS  64
+
 /*
  * Type string for U-Boot bootable partitions
  */
-- 
2.34.1



[PATCH v3 0/3] Introduce mtdblock device

2024-04-04 Thread Alexey Romanov
Hello!

This series adds support for the mtdblock device, which
allows to read/write data block by block. For example,
it can now be used for BCB or Android AB command:

  $ bcb load mtd 0 part_name

Tested only on SPI NAND, so bind is made only for
SPI NAND drivers.

---

Changes V1 -> V2 [1]:

  - Drop patch [2].
  - Add warning if bind NAND mtdblock device.
  - Move documentation of mtdblock implementation
from commit message to the source code.
  - Remove __maybe_unused from mtd partition functions
description.
  - Use blk_enabled() instead of #ifdefs.

Changes V2 -> V3 [2]:

  - Rebased over [3].
  - Rename mtd_bread/bwrite -> mtd_blk_read/write.
  - Fix GPL-2.0 license short name definiton in headers.
  - Add empty line after MTD_ENTRY_NUMBERS define.

Links:

  - [1] 
https://lore.kernel.org/all/20240227100441.1811047-1-avroma...@salutedevices.com/
  - [2] 
https://lore.kernel.org/all/20240227100441.1811047-5-avroma...@salutedevices.com/
  - [3] 
https://lore.kernel.org/u-boot/20240403114047.84030-1-heinrich.schucha...@canonical.com/T/#u

Alexey Romanov (3):
  disk: support MTD partitions
  drivers: introduce mtdblock abstraction
  spinand: bind mtdblock

 disk/part.c |   3 +-
 drivers/block/blk-uclass.c  |   1 +
 drivers/mtd/Kconfig |   1 +
 drivers/mtd/Makefile|   1 +
 drivers/mtd/mtdblock.c  | 227 
 drivers/mtd/mtdpart.c   |  69 +++
 drivers/mtd/nand/spi/core.c |  20 
 include/linux/mtd/mtd.h |  12 ++
 include/part.h  |   3 +
 9 files changed, 336 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c

-- 
2.34.1



Please pull u-boot-marvell/master

2024-04-04 Thread Stefan Roese

Hi Tom,

please pull the first batch of mostly Marvell related patches:


- kirkwood: Switch to using upstream dts/dtsi files (Tony)
- mvebu: Turris Omnia - New board revision support (Marek)


Here the Azure build, without any issues:

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

Thanks,
Stefan

The following changes since commit cdfcc37428e06f4730ab9a17cc084eeb7676ea1a:

  Merge tag 'u-boot-dfu-next-20240402' of 
https://source.denx.de/u-boot/custodians/u-boot-dfu (2024-04-02 22:37:23 
-0400)


are available in the Git repository at:

  g...@source.denx.de:u-boot/custodians/u-boot-marvell.git

for you to fetch changes up to 53bdcd1e9eacd6992d990b288fd6d48f43d94a0b:

  arm: mvebu: turris_omnia: Enable rng command in defconfig (2024-04-04 
10:45:27 +0200)



Marek Behún (18):
  arm: mvebu: turris_omnia: Enable LTO by default on Turris Omnia
  arm: mvebu: turris_omnia: Add header containing MCU command 
interface and use it

  arm: mvebu: turris_{omnia, mox}: Don't print model two times
  arm: mvebu: turris_omnia: Update MCU status and features reading
  arm: mvebu: turris_omnia: Implement getting board information 
from MCU

  arm: mvebu: turris_omnia: Print board ECDSA public key if available
  arm: mvebu: turris_omnia: Disable Atmel SHA node if not present
  arm: mvebu: spl: Do not build mvebu-reset in SPL
  arm: mvebu: system-controller: Rework to use UCLASS_SYSCON
  arm: mvebu: system-controller: Select mvebu-reset if DM_RESET && 
PCI_MVEBU

  arm: mvebu: system-controller: Add support for SYSRESET
  gpio: turris_omnia_mcu: Use byteorder conversion functions
  gpio: turris_omnia_mcu: Update firmware features reading
  gpio: turris_omnia_mcu: Add support for system power off via sysreset
  arm: mvebu: turris_omnia: Enable poweroff command via sysreset in 
defconfig

  cmd: rng: Print "Abort" on -EINTR
  misc: turris_omnia_mcu: Add support for rng provided by MCU
  arm: mvebu: turris_omnia: Enable rng command in defconfig

Tony Dinh (2):
  arm: dts: kirkwood: Enable upstream DT on Kirkwood boards
  arm: dts: kirkwood: Remove DTS files for Kirkwood boards

 arch/arm/dts/Makefile  |  28 +-
 arch/arm/dts/kirkwood-6192.dtsi|  88 ---
 arch/arm/dts/kirkwood-6281.dtsi|  90 ---
 arch/arm/dts/kirkwood-6282.dtsi| 161 -
 arch/arm/dts/kirkwood-98dx4122.dtsi|  53 --
 arch/arm/dts/kirkwood-blackarmor-nas220.dts| 172 -
 arch/arm/dts/kirkwood-d2net.dts|  45 --
 arch/arm/dts/kirkwood-dns325.dts   |  63 --
 arch/arm/dts/kirkwood-dnskw.dtsi   | 235 ---
 arch/arm/dts/kirkwood-dockstar.dts | 110 
 arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi|   7 +
 arch/arm/dts/kirkwood-dreamplug.dts| 131 
 arch/arm/dts/kirkwood-ds109.dts|  40 --
 arch/arm/dts/kirkwood-goflexnet.dts| 190 --
 arch/arm/dts/kirkwood-guruplug-server-plus.dts | 133 
 arch/arm/dts/kirkwood-ib62x0.dts   | 146 -
 arch/arm/dts/kirkwood-iconnect.dts | 195 --
 arch/arm/dts/kirkwood-is2.dts  |  40 --
 arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi  |   6 +-
 arch/arm/dts/kirkwood-lschlv2.dts  |  20 -
 arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi|   6 +-
 arch/arm/dts/kirkwood-lsxhl.dts|  20 -
 arch/arm/dts/kirkwood-lsxl.dtsi| 241 ---
 arch/arm/dts/kirkwood-net2big.dts  |  63 --
 arch/arm/dts/kirkwood-netxbig.dtsi | 232 ---
 arch/arm/dts/kirkwood-ns2-common.dtsi  |  97 ---
 arch/arm/dts/kirkwood-ns2.dts  |  40 --
 arch/arm/dts/kirkwood-ns2lite.dts  |  35 -
 arch/arm/dts/kirkwood-ns2max.dts   |  59 --
 arch/arm/dts/kirkwood-ns2mini.dts  |  60 --
 arch/arm/dts/kirkwood-nsa310s.dts  | 319 -
 arch/arm/dts/kirkwood-nsa325-u-boot.dtsi   |   7 +
 arch/arm/dts/kirkwood-nsa325.dts   | 231 ---
 arch/arm/dts/kirkwood-nsa3x0-common.dtsi   | 157 -
 arch/arm/dts/kirkwood-openrd-base.dts  |  39 --
 arch/arm/dts/kirkwood-openrd-client.dts|  73 ---
 arch/arm/dts/kirkwood-openrd-ultimate.dts  |  55 --
 arch/arm/dts/kirkwood-openrd.dtsi  | 122 
 arch/arm/dts/kirkwood-pogo_e02.dts | 132 
 arch/arm/dts/kirkwood-pogoplug-series-4.dts| 180 --
 arch/arm/dts/kirkwood-sheevaplug-common.dtsi   | 104 ---
 arch/arm/dts/kirkwood-sheevaplug.dts   |  42 --
 arch/arm/dts/kirkwood-synology.dtsi| 855 
-

 arch/arm/dts/kirkwood.dtsi | 393 
 

Re: [PATCH] arm: imx: fix signature_block_hdr struct fields order

2024-04-04 Thread Fabio Estevam
Hi Javier,

On Thu, Apr 4, 2024 at 8:58 AM Viguera, Javier  wrote:

> The struct has the fields in the wrong order according to other documentation 
> from NXP (see for example the AN13994 - Encrypted Boot on AHAB-enabled 
> devices).
>
> In the current upstream u-boot code there is NO runtime error, as those 
> fields are not being used. Only ' get_container_size`on  
> `arch/arm/mach-imx/image-container.c`  defines a variable of that type. But 
> then it only uses the "length_lsb" and "length_msb" fiels, which are at the 
> beginning of the struct and thus in the correct position.
>
> On the other hand, we were hit by this problem in some bootloader encryption 
> related code we do in our (as of Digi) BSP. We get the blob offset from the 
> signature block header to read the data encryption key blob and due to the 
> wrong order this patch fixes, we were getting a wrong position of the DEK 
> blob.
>
> Hope this clears it up a bit.

Thanks for the clarification.

Please put all this explanation into the commit log and send a v2.

Thanks


Re: [PATCH v3] arm: dts: kirkwood: Enable upstream DT on Kirkwood boards

2024-04-04 Thread Stefan Roese

On 4/2/24 00:08, Tony Dinh wrote:

Enable OF_UPSTREAM to use upstream DT and add marvell/ prefix to the
DEFAULT_DEVICE_TREE for Kirkwood boards. And so we can directly build
DTBs from dts/upstream/src/arm/marvell, and including *-u-boot.dtsi
files from arch/arm/dts/ directory.

Background:

The following 2 commands and filters were used in the analysis to determine
which upstream DTS and DTSI files can be used as they are, or need to have
modified/created *-u-boot.dtsi for u-boot specific implementation, and
which board should be opt-out from OF_UPSTREAM.

"git grep -li arch_kirkwood configs | xargs grep DEVICE_TREE | cut -d '"' -f2 | 
xargs -n1 sh -c 'diff -qs  arch/arm/dts/$1.dts dts/upstream/src/arm/marvell/$1.dts' sh | grep 
differ"
"diff -qrbu arch/arm/dts/ dts/upstream/src/arm/marvell/ | grep kirkwood | grep ".dtsi 
""

More detailed information can be found at:
https://lore.kernel.org/u-boot/20240328021825.17935-1-mibo...@gmail.com/T/#u

I've regression tested this patch with the Zyxel NSA325 (Kirkwood 88F6282)
and Zyxel NSA310S (Kirkwood 88F6281). The Zyxel NSA325 board has a
USB 3.0 controller attached to the PCIe bus. And the Zyxel NSA310S
has an extensive overhaul in bindings and styles in upstream DTS version.

Tested-by: Michael Walle  # on lschv2
Acked-by: Sumit Garg 
Reviewed-by: Stefan Roese 

Signed-off-by: Tony Dinh 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

Changes in v3:
- Collect Reviewed/Tested/Acked-by tags.
- Trim the commit description and point to lore.kernel.org for detailed 
information.
- No change from the V2 patch.

Changes in v2:
Remove unnecessary redefined OF_UPSTREAM and use "imply OF_UPSTREAM" for
KW88F6281 and KW88F6192 SoCs.

  arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi | 7 +++
  arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi   | 6 --
  arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi | 6 --
  arch/arm/dts/kirkwood-nsa325-u-boot.dtsi| 7 +++
  arch/arm/mach-kirkwood/Kconfig  | 2 ++
  configs/SBx81LIFKW_defconfig| 1 +
  configs/SBx81LIFXCAT_defconfig  | 1 +
  configs/d2net_v2_defconfig  | 2 +-
  configs/dns325_defconfig| 2 +-
  configs/dockstar_defconfig  | 2 +-
  configs/dreamplug_defconfig | 2 +-
  configs/ds109_defconfig | 2 +-
  configs/goflexhome_defconfig| 2 +-
  configs/guruplug_defconfig  | 2 +-
  configs/ib62x0_defconfig| 2 +-
  configs/iconnect_defconfig  | 2 +-
  configs/inetspace_v2_defconfig  | 2 +-
  configs/lschlv2_defconfig   | 2 +-
  configs/lsxhl_defconfig | 2 +-
  configs/nas220_defconfig| 2 +-
  configs/net2big_v2_defconfig| 2 +-
  configs/netspace_lite_v2_defconfig  | 2 +-
  configs/netspace_max_v2_defconfig   | 2 +-
  configs/netspace_mini_v2_defconfig  | 2 +-
  configs/netspace_v2_defconfig   | 2 +-
  configs/nsa310s_defconfig   | 2 +-
  configs/nsa325_defconfig| 2 +-
  configs/openrd_base_defconfig   | 2 +-
  configs/openrd_client_defconfig | 2 +-
  configs/openrd_ultimate_defconfig   | 2 +-
  configs/pogo_e02_defconfig  | 2 +-
  configs/pogo_v4_defconfig   | 2 +-
  configs/sheevaplug_defconfig| 2 +-
  33 files changed, 52 insertions(+), 30 deletions(-)
  create mode 100644 arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi
  create mode 100644 arch/arm/dts/kirkwood-nsa325-u-boot.dtsi

diff --git a/arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi 
b/arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi
new file mode 100644
index 00..59f19a211f
--- /dev/null
+++ b/arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/ {
+   aliases {
+   spi0 = 
+   };
+};
diff --git a/arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi 
b/arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi
index 7fc2d7d3b4..cf33ff822e 100644
--- a/arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi
+++ b/arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi
@@ -1,7 +1,9 @@
  // SPDX-License-Identifier: GPL-2.0+
  
- {

-   status = "disabled";
+/ {
+   aliases {
+   spi0 = 
+   };
  };
  
  _power {

diff --git a/arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi 
b/arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi
index 7fc2d7d3b4..cf33ff822e 100644
--- a/arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi
+++ b/arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi
@@ -1,7 +1,9 @@
  // SPDX-License-Identifier: GPL-2.0+
  
- {

-   status = "disabled";
+/ {
+   aliases {
+   spi0 = 
+   };
  };
  
  _power {

diff --git a/arch/arm/dts/kirkwood-nsa325-u-boot.dtsi 
b/arch/arm/dts/kirkwood-nsa325-u-boot.dtsi
new file mode 100644
index 00..dec27b2a87
--- /dev/null
+++ b/arch/arm/dts/kirkwood-nsa325-u-boot.dtsi

Re: [PATCH u-boot-mvebu v4 00/18] Turris Omnia - New board revision support

2024-04-04 Thread Stefan Roese

On 4/4/24 09:50, Marek Behún wrote:

changes since v3:
- added missing files turris_common.c and turris_common.h to patch 05/18
- added comment to patch 11/18 before while (1); as discussed in v3

v1, v2 and v3 at:
   
https://patchwork.ozlabs.org/project/uboot/cover/20240304152148.3847-1-ka...@kernel.org/
   
https://patchwork.ozlabs.org/project/uboot/cover/20240323180711.5498-1-ka...@kernel.org/
   
https://patchwork.ozlabs.org/project/uboot/cover/20240327162355.24584-1-ka...@kernel.org/

Marek Behún (18):
   arm: mvebu: turris_omnia: Enable LTO by default on Turris Omnia
   arm: mvebu: turris_omnia: Add header containing MCU command interface
 and use it
   arm: mvebu: turris_{omnia, mox}: Don't print model two times
   arm: mvebu: turris_omnia: Update MCU status and features reading
   arm: mvebu: turris_omnia: Implement getting board information from MCU
   arm: mvebu: turris_omnia: Print board ECDSA public key if available
   arm: mvebu: turris_omnia: Disable Atmel SHA node if not present
   arm: mvebu: spl: Do not build mvebu-reset in SPL
   arm: mvebu: system-controller: Rework to use UCLASS_SYSCON
   arm: mvebu: system-controller: Select mvebu-reset if DM_RESET &&
 PCI_MVEBU
   arm: mvebu: system-controller: Add support for SYSRESET
   gpio: turris_omnia_mcu: Use byteorder conversion functions
   gpio: turris_omnia_mcu: Update firmware features reading
   gpio: turris_omnia_mcu: Add support for system power off via sysreset
   arm: mvebu: turris_omnia: Enable poweroff command via sysreset in
 defconfig
   cmd: rng: Print "Abort" on -EINTR
   misc: turris_omnia_mcu: Add support for rng provided by MCU
   arm: mvebu: turris_omnia: Enable rng command in defconfig

  arch/arm/mach-mvebu/Kconfig  |  25 ++
  arch/arm/mach-mvebu/Makefile |   3 +-
  arch/arm/mach-mvebu/cpu.c|   2 +
  arch/arm/mach-mvebu/system-controller.c  | 145 ++--
  board/CZ.NIC/turris_atsha_otp.c  |  27 +-
  board/CZ.NIC/turris_common.c |  42 +++
  board/CZ.NIC/turris_common.h |  10 +
  board/CZ.NIC/turris_mox/turris_mox.c |   5 +-
  board/CZ.NIC/turris_omnia/Makefile   |   2 +-
  board/CZ.NIC/turris_omnia/turris_omnia.c | 310 -
  cmd/rng.c|   7 +-
  configs/turris_omnia_defconfig   |   6 +
  drivers/gpio/Kconfig |   7 -
  drivers/gpio/Makefile|   1 -
  drivers/gpio/turris_omnia_mcu.c  | 316 -
  drivers/misc/Kconfig |  11 +
  drivers/misc/Makefile|   1 +
  drivers/misc/turris_omnia_mcu.c  | 411 +++
  include/turris-omnia-mcu-interface.h | 248 ++
  19 files changed, 1097 insertions(+), 482 deletions(-)
  create mode 100644 board/CZ.NIC/turris_common.c
  create mode 100644 board/CZ.NIC/turris_common.h
  delete mode 100644 drivers/gpio/turris_omnia_mcu.c
  create mode 100644 drivers/misc/turris_omnia_mcu.c
  create mode 100644 include/turris-omnia-mcu-interface.h


Applied to u-boot-marvell/master

Thanks,
Stefan


Re: [PATCH v1] MAINTAINERS: add entries for tee-related orphaned files

2024-04-04 Thread Mattijs Korpershoek
Hi Igor,

Thank you for the patch.

On jeu., avril 04, 2024 at 12:52, Igor Opaniuk  wrote:

> Add orphaned TEE/OP-TEE-related files to TEE subsystem entry in
> MAINTAINERS. This includes:
> - optee_rpmb cmd and test for it
> - Misc. OP-TEE tests
> - OP-TEE SCMI agent implementation
> - Documentation, including device tree bindings
>
> Signed-off-by: Igor Opaniuk 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  MAINTAINERS | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0462ade4ac6..0f7325d6045 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1642,9 +1642,18 @@ M: Jens Wiklander 
>  M:   Ilias Apalodimas 
>  T:   git https://source.denx.de/u-boot/custodians/u-boot-tpm.git
>  S:   Maintained
> +F:   cmd/optee*
> +F:   doc/README.tee
> +F:   doc/device-tree-bindings/firmware/linaro,optee-tz.txt
> +F:   drivers/firmware/scmi/optee_agent.c
>  F:   drivers/tee/
> +F:   include/sandboxtee.h
>  F:   include/tee.h
>  F:   include/tee/
> +F:   include/test/optee.h
> +F:   test/dm/tee.c
> +F:   test/optee/
> +F:   test/py/tests/test_optee_rpmb.py
>  
>  TEE-lib
>  M:   Bryan O'Donoghue 
> -- 
> 2.34.1


[PATCH v2 3/4] efi_loader: move HOST_ARCH to version_autogenerated.h

2024-04-04 Thread Heinrich Schuchardt
efi_default_filename.h requires HOST_ARCH to be defined. Up to now we
defined it via a CFLAGS. This does not scale. Add the symbol to
version_autogenerated.h instead.

Signed-off-by: Heinrich Schuchardt 
---
v2:
new patch
---
 Makefile| 1 +
 arch/sandbox/config.mk  | 2 --
 include/host_arch.h | 2 ++
 lib/efi_loader/Makefile | 3 +--
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index ba660976547..1069adca91e 100644
--- a/Makefile
+++ b/Makefile
@@ -1963,6 +1963,7 @@ define filechk_version.h
echo \#define U_BOOT_VERSION_NUM $(VERSION); \
echo \#define U_BOOT_VERSION_NUM_PATCH $$(echo $(PATCHLEVEL) | \
sed -e "s/^0*//"); \
+   echo \#define HOST_ARCH $(HOST_ARCH); \
echo \#define CC_VERSION_STRING \"$$(LC_ALL=C $(CC) --version | head -n 
1)\"; \
echo \#define LD_VERSION_STRING \"$$(LC_ALL=C $(LD) --version | head -n 
1)\"; )
 endef
diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 1d50991f8d2..405843800e9 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -69,5 +69,3 @@ EFI_LDS := 
${SRCDIR}/../../../arch/riscv/lib/elf_riscv64_efi.lds
 endif
 EFI_CRT0 := crt0_sandbox_efi.o
 EFI_RELOC := reloc_sandbox_efi.o
-AFLAGS_crt0_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"
-CFLAGS_reloc_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"
diff --git a/include/host_arch.h b/include/host_arch.h
index 169d4945136..261194bd7c6 100644
--- a/include/host_arch.h
+++ b/include/host_arch.h
@@ -16,6 +16,8 @@ export HOST_ARCH_X86=0x0386
 export HOST_ARCH_X86_64=0x8664
 #endif
 
+#include 
+
 #define HOST_ARCH_AARCH64 0xaa64
 #define HOST_ARCH_ARM 0x00a7
 #define HOST_ARCH_RISCV32 0x5032
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index fcb0af7e7d6..086521fb287 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -6,8 +6,7 @@
 # This file only gets included with CONFIG_EFI_LOADER set, so all
 # object inclusion implicitly depends on it
 
-asflags-y += -DHOST_ARCH="$(HOST_ARCH)" -I.
-ccflags-y += -DHOST_ARCH="$(HOST_ARCH)"
+asflags-y += -I.
 
 CFLAGS_efi_boottime.o += \
   -DFW_VERSION="0x$(VERSION)" \
-- 
2.43.0



[PATCH v2 4/4] boot: correct finding the default EFI binary

2024-04-04 Thread Heinrich Schuchardt
* The sandbox must not use an arbitrary file name bootsbox.efi but the
  file name matching the host architecture to properly boot the respective
  file. We already have an include which provides a macro with the name of
  the EFI binary. Use it.

* The path to the EFI binary should be absolute.

* The path and the file name must be capitalized to conform to the UEFI
  specification. This is important when reading from case sensitive
  file systems.

Signed-off-by: Heinrich Schuchardt 
---
v2:
new patch
---
 boot/bootmeth_efi.c  | 44 +++-
 test/boot/bootflow.c |  4 +++-
 2 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index a46b6c9c805..aebc5207fc0 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -23,43 +24,7 @@
 #include 
 #include 
 
-#define EFI_DIRNAME"efi/boot/"
-
-/**
- * get_efi_leafname() - Get the leaf name for the EFI file we expect
- *
- * @str: Place to put leaf name for this architecture, e.g. "bootaa64.efi".
- * Must have at least 16 bytes of space
- * @max_len: Length of @str, must be >=16
- */
-static int get_efi_leafname(char *str, int max_len)
-{
-   const char *base;
-
-   if (max_len < 16)
-   return log_msg_ret("spc", -ENOSPC);
-   if (IS_ENABLED(CONFIG_ARM64))
-   base = "bootaa64";
-   else if (IS_ENABLED(CONFIG_ARM))
-   base = "bootarm";
-   else if (IS_ENABLED(CONFIG_X86_RUN_32BIT))
-   base = "bootia32";
-   else if (IS_ENABLED(CONFIG_X86_RUN_64BIT))
-   base = "bootx64";
-   else if (IS_ENABLED(CONFIG_ARCH_RV32I))
-   base = "bootriscv32";
-   else if (IS_ENABLED(CONFIG_ARCH_RV64I))
-   base = "bootriscv64";
-   else if (IS_ENABLED(CONFIG_SANDBOX))
-   base = "bootsbox";
-   else
-   return -EINVAL;
-
-   strcpy(str, base);
-   strcat(str, ".efi");
-
-   return 0;
-}
+#define EFI_DIRNAME"/EFI/BOOT/"
 
 static int get_efi_pxe_arch(void)
 {
@@ -259,10 +224,7 @@ static int distro_efi_try_bootflow_files(struct udevice 
*dev,
return -ENOENT;
 
strcpy(fname, EFI_DIRNAME);
-   ret = get_efi_leafname(fname + strlen(fname),
-  sizeof(fname) - strlen(fname));
-   if (ret)
-   return log_msg_ret("leaf", ret);
+   strcat(fname, BOOTEFI_NAME);
 
if (bflow->blk)
 desc = dev_get_uclass_plat(bflow->blk);
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index e60e9309fa9..674d4c05f83 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #ifdef CONFIG_SANDBOX
 #include 
@@ -179,7 +180,8 @@ static int bootflow_cmd_scan_e(struct unit_test_state *uts)
ut_assert_nextline("  3  efi  media   mmc  0  
mmc1.bootdev.whole");
ut_assert_nextline(" ** No partition found, err=-2: No such file or 
directory");
ut_assert_nextline("  4  extlinux ready   mmc  1  
mmc1.bootdev.part_1   /extlinux/extlinux.conf");
-   ut_assert_nextline("  5  efi  fs  mmc  1  
mmc1.bootdev.part_1   efi/boot/bootsbox.efi");
+   ut_assert_nextline("  5  efi  fs  mmc  1  
mmc1.bootdev.part_1   /EFI/BOOT/"
+  BOOTEFI_NAME);
 
ut_assert_skip_to_line("Scanning bootdev 'mmc0.bootdev':");
ut_assert_skip_to_line(
-- 
2.43.0



[PATCH v2 2/4] boot: enable booting via EFI boot manager by default

2024-04-04 Thread Heinrich Schuchardt
If UEFI is enabled in U-Boot, we want it to conform to the UEFI
specification. This requires enabling the boot manager boot method.

Reported-by: E Shattow 
Signed-off-by: Heinrich Schuchardt 
---
v2:
fix building with EFI_BOOT_MGR but w/o BOOTSTD
---
 boot/Kconfig   | 10 ++
 boot/Makefile  |  2 +-
 lib/efi_loader/Kconfig |  1 -
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 3d7aabd27d6..d9a6c270059 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -558,6 +558,16 @@ config BOOTMETH_EFILOADER
 
  This provides a way to try out standard boot on an existing boot flow.
 
+config BOOTMETH_EFI_BOOTMGR
+   bool "Bootdev support for EFI boot manager"
+   depends on EFI_BOOTMGR
+   select BOOTMETH_GLOBAL
+   default y
+   help
+ Enable booting via the UEFI boot manager. Based on the EFI variables
+ the EFI binary to be launched is determined. To set the EFI variables
+ use the eficonfig command.
+
 config BOOTMETH_VBE
bool "Bootdev support for Verified Boot for Embedded"
depends on FIT
diff --git a/boot/Makefile b/boot/Makefile
index f0a279cde16..84ccfeaecec 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -34,8 +34,8 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_CROS) += bootm.o bootm_os.o 
bootmeth_cros.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o
 obj-$(CONFIG_$(SPL_TPL_)CEDIT) += cedit.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFI_BOOTMGR) += bootmeth_efi_mgr.o
 ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL
-obj-$(CONFIG_EFI_BOOTMGR) += bootmeth_efi_mgr.o
 obj-$(CONFIG_$(SPL_TPL_)EXPO) += bootflow_menu.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow_menu.o
 endif
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index a7c3e05c13a..e13a6f9f4c3 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -44,7 +44,6 @@ config EFI_BINARY_EXEC
 config EFI_BOOTMGR
bool "UEFI Boot Manager"
default y
-   select BOOTMETH_GLOBAL if BOOTSTD
help
  Select this option if you want to select the UEFI binary to be booted
  via UEFI variables Boot, BootOrder, and BootNext. You should also
-- 
2.43.0



[PATCH v2 1/4] boot: correct the default sequence of boot methods

2024-04-04 Thread Heinrich Schuchardt
The default sequence of boot methods is determined by alphabetical sorting
during linkage.

* efi_mgr must run before efi to be UEFI compliant
* pxe should run as last resort

Signed-off-by: Heinrich Schuchardt 
---
v2:
no change
---
 boot/bootmeth_efi.c | 2 +-
 boot/bootmeth_efi_mgr.c | 2 +-
 boot/bootmeth_pxe.c | 2 +-
 test/boot/bootflow.c| 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index c4eb331d69e..a46b6c9c805 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -489,7 +489,7 @@ static const struct udevice_id distro_efi_bootmeth_ids[] = {
{ }
 };
 
-U_BOOT_DRIVER(bootmeth_efi) = {
+U_BOOT_DRIVER(bootmeth_4efi) = {
.name   = "bootmeth_efi",
.id = UCLASS_BOOTMETH,
.of_match   = distro_efi_bootmeth_ids,
diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
index ed29d7ef021..b7d429f2c3d 100644
--- a/boot/bootmeth_efi_mgr.c
+++ b/boot/bootmeth_efi_mgr.c
@@ -114,7 +114,7 @@ static const struct udevice_id efi_mgr_bootmeth_ids[] = {
{ }
 };
 
-U_BOOT_DRIVER(bootmeth_efi_mgr) = {
+U_BOOT_DRIVER(bootmeth_3efi_mgr) = {
.name   = "bootmeth_efi_mgr",
.id = UCLASS_BOOTMETH,
.of_match   = efi_mgr_bootmeth_ids,
diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c
index 8d489a11aa4..70f693aa239 100644
--- a/boot/bootmeth_pxe.c
+++ b/boot/bootmeth_pxe.c
@@ -184,7 +184,7 @@ static const struct udevice_id extlinux_bootmeth_pxe_ids[] 
= {
{ }
 };
 
-U_BOOT_DRIVER(bootmeth_pxe) = {
+U_BOOT_DRIVER(bootmeth_zpxe) = {
.name   = "bootmeth_pxe",
.id = UCLASS_BOOTMETH,
.of_match   = extlinux_bootmeth_pxe_ids,
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 4845b7121c8..e60e9309fa9 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -377,7 +377,7 @@ static int bootflow_system(struct unit_test_state *uts)
if (!IS_ENABLED(CONFIG_EFI_BOOTMGR))
return -EAGAIN;
ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, ));
-   ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_efi_mgr),
+   ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_3efi_mgr),
"efi_mgr", 0, ofnode_null(), ));
ut_assertok(device_probe(dev));
sandbox_set_fake_efi_mgr_dev(dev, true);
-- 
2.43.0



[PATCH v2 0/4] boot: fix EFI boot methods

2024-04-04 Thread Heinrich Schuchardt
The default sequence of boot methods is determined by alphabetical sorting
during linkage.

* efi_mgr must run before efi to be UEFI compliant
* pxe should run as last resort

If UEFI is enabled in U-Boot, we want it to conform to the UEFI
specification. This requires enabling the boot manager boot method.

The sandbox must not use an arbitrary file name bootsbox.efi but the
file name matching the host architecture to properly boot the respective
file. We already have an include which provides a macro with the name of
the EFI binary. Use it.

The path to the EFI binary should be absolute.

The path and the file name must be capitalized to conform to the UEFI
specification. This is important when reading from case sensitive
file systems.

v2:
fix building with EFI_BOOT_MGR but w/o BOOTSTD
correct finding the default EFI binary

Heinrich Schuchardt (4):
  boot: correct the default sequence of boot methods
  boot: enable booting via EFI boot manager by default
  efi_loader: move HOST_ARCH to version_autogenerated.h
  boot: correct finding the default EFI binary

 Makefile|  1 +
 arch/sandbox/config.mk  |  2 --
 boot/Kconfig| 10 +
 boot/Makefile   |  2 +-
 boot/bootmeth_efi.c | 46 -
 boot/bootmeth_efi_mgr.c |  2 +-
 boot/bootmeth_pxe.c |  2 +-
 include/host_arch.h |  2 ++
 lib/efi_loader/Kconfig  |  1 -
 lib/efi_loader/Makefile |  3 +--
 test/boot/bootflow.c|  6 --
 11 files changed, 25 insertions(+), 52 deletions(-)

-- 
2.43.0



Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

2024-04-04 Thread Ilias Apalodimas
Hi Igor,


On Thu, 4 Apr 2024 at 14:40, Igor Opaniuk  wrote:
>
> Ilias,
>
> On Thu, Apr 4, 2024 at 1:00 PM Ilias Apalodimas  
> wrote:
>>
>> Hi Igor,
>>
>> On Thu, 4 Apr 2024 at 13:18, Igor Opaniuk  wrote:
>> >
>> > Hi Ilias,
>> >
>> > On Thu, Apr 4, 2024 at 10:54 AM Ilias Apalodimas 
>> >  wrote:
>> >>
>> >> Hi Igor,
>> >>
>> >> On Thu, 4 Apr 2024 at 11:40, Ilias Apalodimas
>> >>  wrote:
>> >> >
>> >> > Hi Igor,
>> >> >
>> >> > I was about to apply the series, but noticed neither me or Jens were 
>> >> > cc'ed
>> >> > on this. Adding Jens to the party
>> >> >
>> >> > On Thu, Apr 04, 2024 at 10:13:49AM +0200, Igor Opaniuk wrote:
>> >> > > Add calls for closing tee session after every read/write operation.
>> >> >
>> >> > What the patch is pretty obvious, but I am missing an explanation of why
>> >> > this is needed
>> >> >
>> >> > >
>> >> > > Signed-off-by: Igor Opaniuk 
>> >> > > ---
>> >> > >
>> >> > > (no changes since v1)
>> >> > >
>> >> > >  cmd/optee_rpmb.c | 23 +--
>> >> > >  1 file changed, 17 insertions(+), 6 deletions(-)
>> >> > >
>> >> > > diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
>> >> > > index e0e44bbed04..b3cafd92410 100644
>> >> > > --- a/cmd/optee_rpmb.c
>> >> > > +++ b/cmd/optee_rpmb.c
>> >> > > @@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
>> >> > >
>> >> > >   rc = tee_shm_alloc(tee, name_size,
>> >> > >  TEE_SHM_ALLOC, _name);
>> >> > > - if (rc)
>> >> > > - return -ENOMEM;
>> >> > > + if (rc) {
>> >> > > + rc = -ENOMEM;
>> >> > > + goto close_session;
>> >> > > + }
>> >> >
>> >> > I don't think you need the session to be opened to allocate memory.
>> >> > So instead of of doing this, why don't we just move the alloc call 
>> >> > before
>> >> > opening the session?
>> >>
>> >> Looking at it again, we do need tee != NULL, but I think it's cleaner
>> >> to add something like
>> >> if (!dev)
>> >> return -ENODEV
>> >> to __tee_shm_add() instead.
>> >
>> > Do you mind if I address that in a separate patch series, as tbh I
>> > don't want to add additional patches to the existing series?
>>
>> We still completely change the functionality. So, the patchset is not
>> a 'tiny cleanup', it instead closes the session every time instead of
>> keeping it open.
>> There are a few things going on, that aren't explained clearly in the
>> commit message
>> - Why is this needed? Looking at the code it is an actual problem
>> since sessions tied to the AVB uuid will remain open
>> - Is there any side effect by always closing the session?
>> I don't mind merging it as is with a proper commit message, but I
>> think the alternative is just easier.
>
> I'll provide a bit more context here. The problem initially was in the TEE 
> sandbox
> driver implementation(drivers/tee/sandbox.c) and it's limitations, which 
> doesn't
> permit to have multiple simultaneous sessions with different TAs.
> This is what actually happened in this CI run [1], firstly "optee_rpmb"
> cmd was executed (and after execution we had one session open), and
> then "scp03", which also makes calls to OP-TEE, however it fails
> in sandbox_tee_open_session() because of this check:
>
> if (state->ta) {
> printf("A session is already open\n");
> return -EBUSY;
> }
>
> So basically I had two ways in mind to address that:
> 1. Close a session on each optee_rpmb cmd invocation.
> I don't see any reason to keep this session open, as obviously
> there is no other mechanism (tbh, I don't know if DM calls ".remove" for 
> active
> devices) to close it automatically before handing over control to
> Linux kernel. As a result we might end up with some orphaned sessions
> registered in OP-TEE OS core (obvious resource leak).
> 2. Extend TEE sandbox driver, add support for multiple
> simultaneous sessions just to handle the case.
>
> I've chosen the first approach, as IMO it was "kill two birds with one stone",
> I could address resource leak in OP-TEE and bypass limitations of
> TEE sandbox driver.

Thanks, this helps.
All this needs to be in the commit message, instead of a mail thread.
Can you send a new revision with the commit message amended?

Thanks
/Ilias
>
> [1] https://source.denx.de/u-boot/custodians/u-boot-tpm/-/jobs/792216
>
>>
>>
>> Thanks
>> /Ilias
>>
>> >
>> >>
>> >>
>> >> Cheers
>> >> /Ilias
>> >> >
>> >> > >
>> >> > >   rc = tee_shm_alloc(tee, buffer_size,
>> >> > >  TEE_SHM_ALLOC, _buf);
>> >> > > @@ -125,6 +127,9 @@ out:
>> >> > >   tee_shm_free(shm_buf);
>> >> > >  free_name:
>> >> > >   tee_shm_free(shm_name);
>> >> > > +close_session:
>> >> > > + tee_close_session(tee, session);
>> >> > > + tee = NULL;
>> >> > >
>> >> > >   return rc;
>> >> > >  }
>> >> > > @@ -139,17 +144,20 @@ static int write_persistent_value(const char 
>> >> > > *name,
>> >> > >   struct tee_param param[2];
>> >> > >   size_t name_size = strlen(name) + 1;
>> >> > >

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

2024-04-04 Thread Igor Opaniuk
Ilias,

On Thu, Apr 4, 2024 at 1:00 PM Ilias Apalodimas 
wrote:

> Hi Igor,
>
> On Thu, 4 Apr 2024 at 13:18, Igor Opaniuk  wrote:
> >
> > Hi Ilias,
> >
> > On Thu, Apr 4, 2024 at 10:54 AM Ilias Apalodimas <
> ilias.apalodi...@linaro.org> wrote:
> >>
> >> Hi Igor,
> >>
> >> On Thu, 4 Apr 2024 at 11:40, Ilias Apalodimas
> >>  wrote:
> >> >
> >> > Hi Igor,
> >> >
> >> > I was about to apply the series, but noticed neither me or Jens were
> cc'ed
> >> > on this. Adding Jens to the party
> >> >
> >> > On Thu, Apr 04, 2024 at 10:13:49AM +0200, Igor Opaniuk wrote:
> >> > > Add calls for closing tee session after every read/write operation.
> >> >
> >> > What the patch is pretty obvious, but I am missing an explanation of
> why
> >> > this is needed
> >> >
> >> > >
> >> > > Signed-off-by: Igor Opaniuk 
> >> > > ---
> >> > >
> >> > > (no changes since v1)
> >> > >
> >> > >  cmd/optee_rpmb.c | 23 +--
> >> > >  1 file changed, 17 insertions(+), 6 deletions(-)
> >> > >
> >> > > diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
> >> > > index e0e44bbed04..b3cafd92410 100644
> >> > > --- a/cmd/optee_rpmb.c
> >> > > +++ b/cmd/optee_rpmb.c
> >> > > @@ -87,8 +87,10 @@ static int read_persistent_value(const char
> *name,
> >> > >
> >> > >   rc = tee_shm_alloc(tee, name_size,
> >> > >  TEE_SHM_ALLOC, _name);
> >> > > - if (rc)
> >> > > - return -ENOMEM;
> >> > > + if (rc) {
> >> > > + rc = -ENOMEM;
> >> > > + goto close_session;
> >> > > + }
> >> >
> >> > I don't think you need the session to be opened to allocate memory.
> >> > So instead of of doing this, why don't we just move the alloc call
> before
> >> > opening the session?
> >>
> >> Looking at it again, we do need tee != NULL, but I think it's cleaner
> >> to add something like
> >> if (!dev)
> >> return -ENODEV
> >> to __tee_shm_add() instead.
> >
> > Do you mind if I address that in a separate patch series, as tbh I
> > don't want to add additional patches to the existing series?
>
> We still completely change the functionality. So, the patchset is not
> a 'tiny cleanup', it instead closes the session every time instead of
> keeping it open.
> There are a few things going on, that aren't explained clearly in the
> commit message
> - Why is this needed? Looking at the code it is an actual problem
> since sessions tied to the AVB uuid will remain open
> - Is there any side effect by always closing the session?
> I don't mind merging it as is with a proper commit message, but I
> think the alternative is just easier.
>
I'll provide a bit more context here. The problem initially was in the TEE
sandbox
driver implementation(drivers/tee/sandbox.c) and it's limitations, which
doesn't
permit to have multiple simultaneous sessions with different TAs.
This is what actually happened in this CI run [1], firstly "optee_rpmb"
cmd was executed (and after execution we had one session open), and
then "scp03", which also makes calls to OP-TEE, however it fails
in sandbox_tee_open_session() because of this check:

if (state->ta) {
printf("A session is already open\n");
return -EBUSY;
}

So basically I had two ways in mind to address that:
1. Close a session on each optee_rpmb cmd invocation.
I don't see any reason to keep this session open, as obviously
there is no other mechanism (tbh, I don't know if DM calls ".remove" for
active
devices) to close it automatically before handing over control to
Linux kernel. As a result we might end up with some orphaned sessions
registered in OP-TEE OS core (obvious resource leak).
2. Extend TEE sandbox driver, add support for multiple
simultaneous sessions just to handle the case.

I've chosen the first approach, as IMO it was "kill two birds with one
stone",
I could address resource leak in OP-TEE and bypass limitations of
TEE sandbox driver.

[1] https://source.denx.de/u-boot/custodians/u-boot-tpm/-/jobs/792216


>
> Thanks
> /Ilias
>
> >
> >>
> >>
> >> Cheers
> >> /Ilias
> >> >
> >> > >
> >> > >   rc = tee_shm_alloc(tee, buffer_size,
> >> > >  TEE_SHM_ALLOC, _buf);
> >> > > @@ -125,6 +127,9 @@ out:
> >> > >   tee_shm_free(shm_buf);
> >> > >  free_name:
> >> > >   tee_shm_free(shm_name);
> >> > > +close_session:
> >> > > + tee_close_session(tee, session);
> >> > > + tee = NULL;
> >> > >
> >> > >   return rc;
> >> > >  }
> >> > > @@ -139,17 +144,20 @@ static int write_persistent_value(const char
> *name,
> >> > >   struct tee_param param[2];
> >> > >   size_t name_size = strlen(name) + 1;
> >> > >
> >> > > + if (!value_size)
> >> > > + return -EINVAL;
> >> > > +
> >> > >   if (!tee) {
> >> > >   if (avb_ta_open_session())
> >> > >   return -ENODEV;
> >> > >   }
> >> > > - if (!value_size)
> >> > > - return -EINVAL;
> >> > >
> >> > >   rc = tee_shm_alloc(tee, name_size,
> >> > >  

Re: [PATCH v1] MAINTAINERS: add entries for tee-related orphaned files

2024-04-04 Thread Ilias Apalodimas
Thanks!


On Thu, 4 Apr 2024 at 13:52, Igor Opaniuk  wrote:
>
> Add orphaned TEE/OP-TEE-related files to TEE subsystem entry in
> MAINTAINERS. This includes:
> - optee_rpmb cmd and test for it
> - Misc. OP-TEE tests
> - OP-TEE SCMI agent implementation
> - Documentation, including device tree bindings
>
> Signed-off-by: Igor Opaniuk 
> ---
>
>  MAINTAINERS | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0462ade4ac6..0f7325d6045 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1642,9 +1642,18 @@ M:   Jens Wiklander 
>  M: Ilias Apalodimas 
>  T: git https://source.denx.de/u-boot/custodians/u-boot-tpm.git
>  S: Maintained
> +F: cmd/optee*
> +F: doc/README.tee
> +F: doc/device-tree-bindings/firmware/linaro,optee-tz.txt
> +F: drivers/firmware/scmi/optee_agent.c
>  F: drivers/tee/
> +F: include/sandboxtee.h
>  F: include/tee.h
>  F: include/tee/
> +F: include/test/optee.h
> +F: test/dm/tee.c
> +F: test/optee/
> +F: test/py/tests/test_optee_rpmb.py
>
>  TEE-lib
>  M: Bryan O'Donoghue 
> --
> 2.34.1
>

Reviewed-by: Ilias Apalodimas 


Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

2024-04-04 Thread Ilias Apalodimas
Hi Igor,

On Thu, 4 Apr 2024 at 13:18, Igor Opaniuk  wrote:
>
> Hi Ilias,
>
> On Thu, Apr 4, 2024 at 10:54 AM Ilias Apalodimas 
>  wrote:
>>
>> Hi Igor,
>>
>> On Thu, 4 Apr 2024 at 11:40, Ilias Apalodimas
>>  wrote:
>> >
>> > Hi Igor,
>> >
>> > I was about to apply the series, but noticed neither me or Jens were cc'ed
>> > on this. Adding Jens to the party
>> >
>> > On Thu, Apr 04, 2024 at 10:13:49AM +0200, Igor Opaniuk wrote:
>> > > Add calls for closing tee session after every read/write operation.
>> >
>> > What the patch is pretty obvious, but I am missing an explanation of why
>> > this is needed
>> >
>> > >
>> > > Signed-off-by: Igor Opaniuk 
>> > > ---
>> > >
>> > > (no changes since v1)
>> > >
>> > >  cmd/optee_rpmb.c | 23 +--
>> > >  1 file changed, 17 insertions(+), 6 deletions(-)
>> > >
>> > > diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
>> > > index e0e44bbed04..b3cafd92410 100644
>> > > --- a/cmd/optee_rpmb.c
>> > > +++ b/cmd/optee_rpmb.c
>> > > @@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
>> > >
>> > >   rc = tee_shm_alloc(tee, name_size,
>> > >  TEE_SHM_ALLOC, _name);
>> > > - if (rc)
>> > > - return -ENOMEM;
>> > > + if (rc) {
>> > > + rc = -ENOMEM;
>> > > + goto close_session;
>> > > + }
>> >
>> > I don't think you need the session to be opened to allocate memory.
>> > So instead of of doing this, why don't we just move the alloc call before
>> > opening the session?
>>
>> Looking at it again, we do need tee != NULL, but I think it's cleaner
>> to add something like
>> if (!dev)
>> return -ENODEV
>> to __tee_shm_add() instead.
>
> Do you mind if I address that in a separate patch series, as tbh I
> don't want to add additional patches to the existing series?

We still completely change the functionality. So, the patchset is not
a 'tiny cleanup', it instead closes the session every time instead of
keeping it open.
There are a few things going on, that aren't explained clearly in the
commit message
- Why is this needed? Looking at the code it is an actual problem
since sessions tied to the AVB uuid will remain open
- Is there any side effect by always closing the session?
I don't mind merging it as is with a proper commit message, but I
think the alternative is just easier.

Thanks
/Ilias

>
>>
>>
>> Cheers
>> /Ilias
>> >
>> > >
>> > >   rc = tee_shm_alloc(tee, buffer_size,
>> > >  TEE_SHM_ALLOC, _buf);
>> > > @@ -125,6 +127,9 @@ out:
>> > >   tee_shm_free(shm_buf);
>> > >  free_name:
>> > >   tee_shm_free(shm_name);
>> > > +close_session:
>> > > + tee_close_session(tee, session);
>> > > + tee = NULL;
>> > >
>> > >   return rc;
>> > >  }
>> > > @@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
>> > >   struct tee_param param[2];
>> > >   size_t name_size = strlen(name) + 1;
>> > >
>> > > + if (!value_size)
>> > > + return -EINVAL;
>> > > +
>> > >   if (!tee) {
>> > >   if (avb_ta_open_session())
>> > >   return -ENODEV;
>> > >   }
>> > > - if (!value_size)
>> > > - return -EINVAL;
>> > >
>> > >   rc = tee_shm_alloc(tee, name_size,
>> > >  TEE_SHM_ALLOC, _name);
>> > > - if (rc)
>> > > - return -ENOMEM;
>> > > + if (rc) {
>> > > + rc = -ENOMEM;
>> > > + goto close_session;
>> > > + }
>> >
>> > ditto
>> >
>> > >
>> > >   rc = tee_shm_alloc(tee, value_size,
>> > >  TEE_SHM_ALLOC, _buf);
>> > > @@ -178,6 +186,9 @@ out:
>> > >   tee_shm_free(shm_buf);
>> > >  free_name:
>> > >   tee_shm_free(shm_name);
>> > > +close_session:
>> > > + tee_close_session(tee, session);
>> > > + tee = NULL;
>> > >
>> > >   return rc;
>> > >  }
>> > > --
>> > > 2.34.1
>> > >
>> >
>> > Thanks
>> > /Ilias
>
>
>
>
> --
> Best regards - Atentamente - Meilleures salutations
>
> Igor Opaniuk
>
> mailto: igor.opan...@gmail.com
> skype: igor.opanyuk
> https://www.linkedin.com/in/iopaniuk


Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

2024-04-04 Thread Igor Opaniuk
HI Ilias

On Thu, Apr 4, 2024 at 12:15 PM Igor Opaniuk  wrote:

> Hi Ilias,
>
> On Thu, Apr 4, 2024 at 10:40 AM Ilias Apalodimas <
> ilias.apalodi...@linaro.org> wrote:
>
>> Hi Igor,
>>
>> I was about to apply the series, but noticed neither me or Jens were cc'ed
>> on this. Adding Jens to the party
>>
> I usually rely on automatic CC-list creation by patman. Looks like there
> is no
> entry in MAINTAINERS for this specific file, that's why only Tom was added.
> I'll send a patch for that if you don't mind.
>

I've added all orphaned tee-related files to MAINTAINERS in [1], so I patman
should  generate the CC list correctly next time.

[1]
https://lore.kernel.org/u-boot/20240404105248.3241506-1-igor.opan...@gmail.com/T/#u


>
>
>> On Thu, Apr 04, 2024 at 10:13:49AM +0200, Igor Opaniuk wrote:
>> > Add calls for closing tee session after every read/write operation.
>>
>> What the patch is pretty obvious, but I am missing an explanation of why
>> this is needed
>>
>> >
>> > Signed-off-by: Igor Opaniuk 
>> > ---
>> >
>> > (no changes since v1)
>> >
>> >  cmd/optee_rpmb.c | 23 +--
>> >  1 file changed, 17 insertions(+), 6 deletions(-)
>> >
>> > diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
>> > index e0e44bbed04..b3cafd92410 100644
>> > --- a/cmd/optee_rpmb.c
>> > +++ b/cmd/optee_rpmb.c
>> > @@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
>> >
>> >   rc = tee_shm_alloc(tee, name_size,
>> >  TEE_SHM_ALLOC, _name);
>> > - if (rc)
>> > - return -ENOMEM;
>> > + if (rc) {
>> > + rc = -ENOMEM;
>> > + goto close_session;
>> > + }
>>
>> I don't think you need the session to be opened to allocate memory.
>> So instead of of doing this, why don't we just move the alloc call before
>> opening the session?
>>
> That's correct, but avb_ta_open_session() wrapper calls
> both tee_find_device()/
> tee_open_session(), and tee_shm_alloc() expects valid tee device as param,
> which
> is initialized by tee_find_device(). My intention was to address the only
> one particular issue
> that was catched by CI and explained in [1] instead of doing overhaul of
> the whole optee_rpmb cmd implementation.
>
>
>> >
>> >   rc = tee_shm_alloc(tee, buffer_size,
>> >  TEE_SHM_ALLOC, _buf);
>> > @@ -125,6 +127,9 @@ out:
>> >   tee_shm_free(shm_buf);
>> >  free_name:
>> >   tee_shm_free(shm_name);
>> > +close_session:
>> > + tee_close_session(tee, session);
>> > + tee = NULL;
>> >
>> >   return rc;
>> >  }
>> > @@ -139,17 +144,20 @@ static int write_persistent_value(const char
>> *name,
>> >   struct tee_param param[2];
>> >   size_t name_size = strlen(name) + 1;
>> >
>> > + if (!value_size)
>> > + return -EINVAL;
>> > +
>> >   if (!tee) {
>> >   if (avb_ta_open_session())
>> >   return -ENODEV;
>> >   }
>> > - if (!value_size)
>> > - return -EINVAL;
>> >
>> >   rc = tee_shm_alloc(tee, name_size,
>> >  TEE_SHM_ALLOC, _name);
>> > - if (rc)
>> > - return -ENOMEM;
>> > + if (rc) {
>> > + rc = -ENOMEM;
>> > + goto close_session;
>> > + }
>>
>> ditto
>>
>> >
>> >   rc = tee_shm_alloc(tee, value_size,
>> >  TEE_SHM_ALLOC, _buf);
>> > @@ -178,6 +186,9 @@ out:
>> >   tee_shm_free(shm_buf);
>> >  free_name:
>> >   tee_shm_free(shm_name);
>> > +close_session:
>> > + tee_close_session(tee, session);
>> > + tee = NULL;
>> >
>> >   return rc;
>> >  }
>> > --
>> > 2.34.1
>> >
>>
>> Thanks
>> /Ilias
>>
>
> [1]
> https://lore.kernel.org/all/20240302220108.720637-5-igor.opan...@gmail.com/T/
>
> --
> Best regards - Atentamente - Meilleures salutations
>
> Igor Opaniuk
>
> mailto: igor.opan...@gmail.com
> skype: igor.opanyuk
> https://www.linkedin.com/in/iopaniuk 
>


-- 
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: igor.opan...@gmail.com
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk 


[PATCH v1] MAINTAINERS: add entries for tee-related orphaned files

2024-04-04 Thread Igor Opaniuk
Add orphaned TEE/OP-TEE-related files to TEE subsystem entry in
MAINTAINERS. This includes:
- optee_rpmb cmd and test for it
- Misc. OP-TEE tests
- OP-TEE SCMI agent implementation
- Documentation, including device tree bindings

Signed-off-by: Igor Opaniuk 
---

 MAINTAINERS | 9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0462ade4ac6..0f7325d6045 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1642,9 +1642,18 @@ M:   Jens Wiklander 
 M: Ilias Apalodimas 
 T: git https://source.denx.de/u-boot/custodians/u-boot-tpm.git
 S: Maintained
+F: cmd/optee*
+F: doc/README.tee
+F: doc/device-tree-bindings/firmware/linaro,optee-tz.txt
+F: drivers/firmware/scmi/optee_agent.c
 F: drivers/tee/
+F: include/sandboxtee.h
 F: include/tee.h
 F: include/tee/
+F: include/test/optee.h
+F: test/dm/tee.c
+F: test/optee/
+F: test/py/tests/test_optee_rpmb.py
 
 TEE-lib
 M: Bryan O'Donoghue 
-- 
2.34.1



[RFC PATCH 13/15] arm: dts: Introduce J722S U-Boot dts files

2024-04-04 Thread Jayesh Choudhary
Include the uboot device tree files needed to boot the board.

Co-developed-by: Vaishnav Achath 
Signed-off-by: Vaishnav Achath 
Signed-off-by: Jayesh Choudhary 
---
 arch/arm/dts/Makefile  |2 +
 arch/arm/dts/k3-j722s-binman.dtsi  |  171 ++
 arch/arm/dts/k3-j722s-ddr-lp4-50-3733.dtsi | 2795 
 arch/arm/dts/k3-j722s-evm-u-boot.dtsi  |   36 +
 arch/arm/dts/k3-j722s-r5-evm.dts   |   82 +
 5 files changed, 3086 insertions(+)
 create mode 100644 arch/arm/dts/k3-j722s-binman.dtsi
 create mode 100644 arch/arm/dts/k3-j722s-ddr-lp4-50-3733.dtsi
 create mode 100644 arch/arm/dts/k3-j722s-evm-u-boot.dtsi
 create mode 100644 arch/arm/dts/k3-j722s-r5-evm.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 7b7788f755..83b1f267cb 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1407,6 +1407,8 @@ dtb-$(CONFIG_SOC_K3_J721S2) += k3-am68-sk-base-board.dtb\
 dtb-$(CONFIG_SOC_K3_J784S4) += k3-am69-r5-sk.dtb \
   k3-j784s4-r5-evm.dtb
 
+dtb-$(CONFIG_SOC_K3_J722S) += k3-j722s-r5-evm.dtb
+
 dtb-$(CONFIG_SOC_K3_AM642) += k3-am642-r5-evm.dtb \
  k3-am642-r5-sk.dtb \
  k3-am642-phyboard-electra-rdk.dtb \
diff --git a/arch/arm/dts/k3-j722s-binman.dtsi 
b/arch/arm/dts/k3-j722s-binman.dtsi
new file mode 100644
index 00..fa9a16bc98
--- /dev/null
+++ b/arch/arm/dts/k3-j722s-binman.dtsi
@@ -0,0 +1,171 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include "k3-binman.dtsi"
+
+#if IS_ENABLED(CONFIG_TARGET_J722S_R5_EVM)
+
+ {
+   tiboot3-j722s-hs-fs-evm.bin {
+   filename = "tiboot3-j722s-hs-fs-evm.bin";
+   symlink = "tiboot3.bin";
+
+   ti-secure-rom {
+   content = <_boot_spl_fs>, <_fs_enc_fs>, 
<_tifs_cfg_fs>,
+ <_dm_cfg_fs>, <_inner_cert_fs>;
+   combined;
+   dm-data;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl_fs>;
+   content-sysfw = <_fs_enc_fs>;
+   content-sysfw-data = <_tifs_cfg_fs>;
+   content-sysfw-inner-cert = <_inner_cert_fs>;
+   content-dm-data = <_dm_cfg_fs>;
+   load = <0x43c0>;
+   load-sysfw = <0x4>;
+   load-sysfw-data = <0x67000>;
+   load-dm-data = <0x43c7a800>;
+   };
+
+   u_boot_spl_fs: u-boot-spl {
+   no-expanded;
+   };
+
+   ti_fs_enc_fs: ti-fs-enc.bin {
+   filename = 
"ti-sysfw/ti-fs-firmware-j722s-hs-fs-enc.bin";
+   type = "blob-ext";
+   optional;
+   };
+
+   combined_tifs_cfg_fs: combined-tifs-cfg.bin {
+   filename = "combined-tifs-cfg.bin";
+   type = "blob-ext";
+   };
+
+   sysfw_inner_cert_fs: sysfw-inner-cert {
+   filename = 
"ti-sysfw/ti-fs-firmware-j722s-hs-fs-cert.bin";
+   type = "blob-ext";
+   optional;
+   };
+
+   combined_dm_cfg_fs: combined-dm-cfg.bin {
+   filename = "combined-dm-cfg.bin";
+   type = "blob-ext";
+   };
+   };
+};
+#endif /*CONFIG_TARGET_J722S_R5_EVM*/
+
+#if IS_ENABLED(CONFIG_TARGET_J722S_A53_EVM)
+
+#define SPL_J722S_EVM_DTB "spl/dts/ti/k3-j722s-evm.dtb"
+#define J722S_EVM_DTB "u-boot.dtb"
+
+ {
+   ti-dm {
+   filename = "ti-dm.bin";
+
+   blob-ext {
+   filename = 
"ti-dm/j722s/ipc_echo_testb_mcu1_0_release_strip.xer5f";
+   };
+   };
+
+   ti-spl {
+   insert-template = <_spl_template>;
+
+   fit {
+   images {
+   dm {
+   ti-secure {
+   content = <>;
+   keyfile = "custMpk.pem";
+   };
+
+   dm: ti-dm {
+   filename = "ti-dm.bin";
+   };
+   };
+
+   fdt-0 {
+   description = "k3-j722s-evm";
+   type = "flat_dt";
+   arch = "arm";
+   compression = "none";
+
+   ti-secure {
+ 

Re: [PATCH v2 6/6] spinand: bind UBI block

2024-04-04 Thread Alexey Romanov
Hi,

On Thu, Apr 04, 2024 at 11:23:47AM +0800, Chuanhong Guo wrote:
> Hello!
> 
> On Mon, Mar 25, 2024 at 10:46 PM Alexey Romanov
>  wrote:
> >
> > UBI block is virtual block device, which is an abstraction
> > over MTD layer. Therefore it is logical to use it in combination
> > with MTD drivers.
> >
> > Signed-off-by: Alexey Romanov 
> > ---
> >  drivers/mtd/nand/spi/core.c | 8 +++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> > index dd880adf31..c47f6c1b46 100644
> > --- a/drivers/mtd/nand/spi/core.c
> > +++ b/drivers/mtd/nand/spi/core.c
> > @@ -27,6 +27,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -1182,8 +1183,13 @@ static int spinand_bind(struct udevice *dev)
> >  {
> > if (blk_enabled()) {
> > struct spinand_plat *plat = dev_get_plat(dev);
> > +   int ret;
> > +
> > +   ret = mtd_bind(dev, >mtd);
> > +   if (ret)
> > +   return ret;
> >
> > -   return mtd_bind(dev, >mtd);
> > +   return ubi_bind(dev);
> 
> Is this expecting the entire SPI-NAND covered by a single UBI partition?

Why? Nah.

ubi_bind() just create block device and bind it to SPI-NAND device.
When working with this block device user must specify, which SPI-NAND
partition UBI is located on.

> It's almost never this case on real hardware. For SPI-NAND booted
> SoCs, the first few blocks always store the first stage bootloader
> raw, because bootrom knows nothing about UBI.
> 
> > }
> >
> > return 0;
> > --
> > 2.34.1
> >
> 
> 
> -- 
> Regards,
> Chuanhong Guo

-- 
Thank you,
Alexey

Re: [PATCH v1] verdin-imx8mm/verdin-imx8mp: move imx verdins to OF_UPSTREAM

2024-04-04 Thread Sumit Garg
On Wed, 3 Apr 2024 at 12:51, Marcel Ziswiler  wrote:
>
> From: Marcel Ziswiler 
>
> Move verdin-imx8mm and verdin-imx8mp to OF_UPSTREAM:
> - handle the fact that dtbs now have a 'freescale/' prefix
> - imply OF_UPSTREAM
> - remove redundant files from arch/arm/dts leaving only the
>   *-u-boot.dtsi files
> - update MAINTAINERS files
>
> Signed-off-by: Marcel Ziswiler 
>
> ---
>
>  arch/arm/dts/Makefile   |2 -
>  arch/arm/dts/imx8mm-verdin-dev.dtsi |  160 ---
>  arch/arm/dts/imx8mm-verdin-wifi-dev.dts |   18 -
>  arch/arm/dts/imx8mm-verdin-wifi.dtsi|   94 --
>  arch/arm/dts/imx8mm-verdin.dtsi | 1319 -
>  arch/arm/dts/imx8mp-verdin-dev.dtsi |  165 ---
>  arch/arm/dts/imx8mp-verdin-wifi-dev.dts |   18 -
>  arch/arm/dts/imx8mp-verdin-wifi.dtsi|   87 --
>  arch/arm/dts/imx8mp-verdin.dtsi | 1438 ---
>  arch/arm/mach-imx/imx8m/Kconfig |2 +
>  board/toradex/verdin-imx8mm/MAINTAINERS |4 -
>  board/toradex/verdin-imx8mp/MAINTAINERS |4 -
>  configs/verdin-imx8mm_defconfig |2 +-
>  configs/verdin-imx8mp_defconfig |2 +-
>  14 files changed, 4 insertions(+), 3311 deletions(-)
>  delete mode 100644 arch/arm/dts/imx8mm-verdin-dev.dtsi
>  delete mode 100644 arch/arm/dts/imx8mm-verdin-wifi-dev.dts
>  delete mode 100644 arch/arm/dts/imx8mm-verdin-wifi.dtsi
>  delete mode 100644 arch/arm/dts/imx8mm-verdin.dtsi
>  delete mode 100644 arch/arm/dts/imx8mp-verdin-dev.dtsi
>  delete mode 100644 arch/arm/dts/imx8mp-verdin-wifi-dev.dts
>  delete mode 100644 arch/arm/dts/imx8mp-verdin-wifi.dtsi
>  delete mode 100644 arch/arm/dts/imx8mp-verdin.dtsi
>

Reviewed-by: Sumit Garg 

-Sumit

> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index 18fedc16740..cd8aa0b4143 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -1082,7 +1082,6 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
> imx8mm-phg.dtb \
> imx8mm-phyboard-polis-rdk.dtb \
> imx8mm-phygate-tauri-l.dtb \
> -   imx8mm-verdin-wifi-dev.dtb \
> imx8mn-bsh-smm-s2.dtb \
> imx8mn-bsh-smm-s2pro.dtb \
> imx8mq-cm.dtb \
> @@ -1104,7 +1103,6 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
> imx8mp-icore-mx8mp-edimm2.2.dtb \
> imx8mp-msc-sm2s.dtb \
> imx8mp-phyboard-pollux-rdk.dtb \
> -   imx8mp-verdin-wifi-dev.dtb \
> imx8mq-pico-pi.dtb \
> imx8mq-kontron-pitx-imx8m.dtb \
> imx8mq-librem5-r4.dtb
> diff --git a/arch/arm/dts/imx8mm-verdin-dev.dtsi 
> b/arch/arm/dts/imx8mm-verdin-dev.dtsi
> deleted file mode 100644
> index 3c4b8ca125e..000
> --- a/arch/arm/dts/imx8mm-verdin-dev.dtsi
> +++ /dev/null
> @@ -1,160 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
> -/*
> - * Copyright 2022 Toradex
> - */
> -
> -/ {
> -   sound_card: sound-card {
> -   compatible = "simple-audio-card";
> -   simple-audio-card,bitclock-master = <_master>;
> -   simple-audio-card,format = "i2s";
> -   simple-audio-card,frame-master = <_master>;
> -   simple-audio-card,mclk-fs = <256>;
> -   simple-audio-card,name = "imx8mm-nau8822";
> -   simple-audio-card,routing =
> -   "Headphones", "LHP",
> -   "Headphones", "RHP",
> -   "Speaker", "LSPK",
> -   "Speaker", "RSPK",
> -   "Line Out", "AUXOUT1",
> -   "Line Out", "AUXOUT2",
> -   "LAUX", "Line In",
> -   "RAUX", "Line In",
> -   "LMICP", "Mic In",
> -   "RMICP", "Mic In";
> -   simple-audio-card,widgets =
> -   "Headphones", "Headphones",
> -   "Line Out", "Line Out",
> -   "Speaker", "Speaker",
> -   "Microphone", "Mic In",
> -   "Line", "Line In";
> -
> -   dailink_master: simple-audio-card,codec {
> -   clocks = < IMX8MM_CLK_SAI2_ROOT>;
> -   sound-dai = <_1a>;
> -   };
> -
> -   simple-audio-card,cpu {
> -   sound-dai = <>;
> -   };
> -   };
> -};
> -
> -/* Verdin SPI_1 */
> - {
> -   status = "okay";
> -};
> -
> -/* EEPROM on display adapter boards */
> -_display_adapter {
> -   status = "okay";
> -};
> -
> -/* EEPROM on Verdin Development board */
> -_carrier_board {
> -   status = "okay";
> -};
> -
> - {
> -   status = "okay";
> -};
> -
> -/* Verdin QSPI_1 */
> - {
> -   status = "okay";
> -};
> -
> -/* Current measurement into module VCC */
> - {
> -   status = "okay";
> -};
> -
> -_temp {
> -   vs-supply = <_1p8v>;
> -   status = "okay";
> -};
> -
> - {
> -   status = "okay";
> -};
> -
> -_expander_21 {
> -   status = "okay";
> -};
> -
> -/* Verdin I2C_1 

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

2024-04-04 Thread Igor Opaniuk
Hi Ilias,

On Thu, Apr 4, 2024 at 10:54 AM Ilias Apalodimas <
ilias.apalodi...@linaro.org> wrote:

> Hi Igor,
>
> On Thu, 4 Apr 2024 at 11:40, Ilias Apalodimas
>  wrote:
> >
> > Hi Igor,
> >
> > I was about to apply the series, but noticed neither me or Jens were
> cc'ed
> > on this. Adding Jens to the party
> >
> > On Thu, Apr 04, 2024 at 10:13:49AM +0200, Igor Opaniuk wrote:
> > > Add calls for closing tee session after every read/write operation.
> >
> > What the patch is pretty obvious, but I am missing an explanation of why
> > this is needed
> >
> > >
> > > Signed-off-by: Igor Opaniuk 
> > > ---
> > >
> > > (no changes since v1)
> > >
> > >  cmd/optee_rpmb.c | 23 +--
> > >  1 file changed, 17 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
> > > index e0e44bbed04..b3cafd92410 100644
> > > --- a/cmd/optee_rpmb.c
> > > +++ b/cmd/optee_rpmb.c
> > > @@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
> > >
> > >   rc = tee_shm_alloc(tee, name_size,
> > >  TEE_SHM_ALLOC, _name);
> > > - if (rc)
> > > - return -ENOMEM;
> > > + if (rc) {
> > > + rc = -ENOMEM;
> > > + goto close_session;
> > > + }
> >
> > I don't think you need the session to be opened to allocate memory.
> > So instead of of doing this, why don't we just move the alloc call before
> > opening the session?
>
> Looking at it again, we do need tee != NULL, but I think it's cleaner
> to add something like
> if (!dev)
> return -ENODEV
> to __tee_shm_add() instead.
>
Do you mind if I address that in a separate patch series, as tbh I
don't want to add additional patches to the existing series?


>
> Cheers
> /Ilias
> >
> > >
> > >   rc = tee_shm_alloc(tee, buffer_size,
> > >  TEE_SHM_ALLOC, _buf);
> > > @@ -125,6 +127,9 @@ out:
> > >   tee_shm_free(shm_buf);
> > >  free_name:
> > >   tee_shm_free(shm_name);
> > > +close_session:
> > > + tee_close_session(tee, session);
> > > + tee = NULL;
> > >
> > >   return rc;
> > >  }
> > > @@ -139,17 +144,20 @@ static int write_persistent_value(const char
> *name,
> > >   struct tee_param param[2];
> > >   size_t name_size = strlen(name) + 1;
> > >
> > > + if (!value_size)
> > > + return -EINVAL;
> > > +
> > >   if (!tee) {
> > >   if (avb_ta_open_session())
> > >   return -ENODEV;
> > >   }
> > > - if (!value_size)
> > > - return -EINVAL;
> > >
> > >   rc = tee_shm_alloc(tee, name_size,
> > >  TEE_SHM_ALLOC, _name);
> > > - if (rc)
> > > - return -ENOMEM;
> > > + if (rc) {
> > > + rc = -ENOMEM;
> > > + goto close_session;
> > > + }
> >
> > ditto
> >
> > >
> > >   rc = tee_shm_alloc(tee, value_size,
> > >  TEE_SHM_ALLOC, _buf);
> > > @@ -178,6 +186,9 @@ out:
> > >   tee_shm_free(shm_buf);
> > >  free_name:
> > >   tee_shm_free(shm_name);
> > > +close_session:
> > > + tee_close_session(tee, session);
> > > + tee = NULL;
> > >
> > >   return rc;
> > >  }
> > > --
> > > 2.34.1
> > >
> >
> > Thanks
> > /Ilias
>



-- 
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: igor.opan...@gmail.com
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk 


Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

2024-04-04 Thread Igor Opaniuk
Hi Ilias,

On Thu, Apr 4, 2024 at 10:40 AM Ilias Apalodimas <
ilias.apalodi...@linaro.org> wrote:

> Hi Igor,
>
> I was about to apply the series, but noticed neither me or Jens were cc'ed
> on this. Adding Jens to the party
>
I usually rely on automatic CC-list creation by patman. Looks like there is
no
entry in MAINTAINERS for this specific file, that's why only Tom was added.
I'll send a patch for that if you don't mind.


> On Thu, Apr 04, 2024 at 10:13:49AM +0200, Igor Opaniuk wrote:
> > Add calls for closing tee session after every read/write operation.
>
> What the patch is pretty obvious, but I am missing an explanation of why
> this is needed
>
> >
> > Signed-off-by: Igor Opaniuk 
> > ---
> >
> > (no changes since v1)
> >
> >  cmd/optee_rpmb.c | 23 +--
> >  1 file changed, 17 insertions(+), 6 deletions(-)
> >
> > diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
> > index e0e44bbed04..b3cafd92410 100644
> > --- a/cmd/optee_rpmb.c
> > +++ b/cmd/optee_rpmb.c
> > @@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
> >
> >   rc = tee_shm_alloc(tee, name_size,
> >  TEE_SHM_ALLOC, _name);
> > - if (rc)
> > - return -ENOMEM;
> > + if (rc) {
> > + rc = -ENOMEM;
> > + goto close_session;
> > + }
>
> I don't think you need the session to be opened to allocate memory.
> So instead of of doing this, why don't we just move the alloc call before
> opening the session?
>
That's correct, but avb_ta_open_session() wrapper calls
both tee_find_device()/
tee_open_session(), and tee_shm_alloc() expects valid tee device as param,
which
is initialized by tee_find_device(). My intention was to address the only
one particular issue
that was catched by CI and explained in [1] instead of doing overhaul of
the whole optee_rpmb cmd implementation.


> >
> >   rc = tee_shm_alloc(tee, buffer_size,
> >  TEE_SHM_ALLOC, _buf);
> > @@ -125,6 +127,9 @@ out:
> >   tee_shm_free(shm_buf);
> >  free_name:
> >   tee_shm_free(shm_name);
> > +close_session:
> > + tee_close_session(tee, session);
> > + tee = NULL;
> >
> >   return rc;
> >  }
> > @@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
> >   struct tee_param param[2];
> >   size_t name_size = strlen(name) + 1;
> >
> > + if (!value_size)
> > + return -EINVAL;
> > +
> >   if (!tee) {
> >   if (avb_ta_open_session())
> >   return -ENODEV;
> >   }
> > - if (!value_size)
> > - return -EINVAL;
> >
> >   rc = tee_shm_alloc(tee, name_size,
> >  TEE_SHM_ALLOC, _name);
> > - if (rc)
> > - return -ENOMEM;
> > + if (rc) {
> > + rc = -ENOMEM;
> > + goto close_session;
> > + }
>
> ditto
>
> >
> >   rc = tee_shm_alloc(tee, value_size,
> >  TEE_SHM_ALLOC, _buf);
> > @@ -178,6 +186,9 @@ out:
> >   tee_shm_free(shm_buf);
> >  free_name:
> >   tee_shm_free(shm_name);
> > +close_session:
> > + tee_close_session(tee, session);
> > + tee = NULL;
> >
> >   return rc;
> >  }
> > --
> > 2.34.1
> >
>
> Thanks
> /Ilias
>

[1]
https://lore.kernel.org/all/20240302220108.720637-5-igor.opan...@gmail.com/T/

-- 
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: igor.opan...@gmail.com
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk 


Re: [PATCH 3/4] arm: dts: k3-*-binman.dtsi: Clean up and templatize boot binaries

2024-04-04 Thread Neha Malcom Francis

Hi Matthias

On 04/04/24 13:34, Matthias Schiffer wrote:

On Wed, 2024-04-03 at 17:51 +0200, Michael Walle wrote:

Hi,


And on top of that, it will just be a base board and there will
likely be some carrier device trees (overlay? I'm not sure yet).

As far as I can tell, you've put the memory configuration into the
device tree, so I'll probably need to switch between them somehow.


The "k3--ddr.dtsi" file will be present in your k3-r5.dts
which makes sense, the memory configuration depends on the board.




k3--ddr.dtsi* (e.g J721E EVM vs. SK boards consume different memory
configurations.


Right.


And one board might have multiple configuration depending on the
variant of the board. Typically, one board is available with
different memory options. i.e. 1GiB, 4GiB and so on. The actual RAM
chips can come from different manufacturers. So all all, I presume
there will be different RAM settings, i.e. different
k3--ddr.dtsi. But I have to switch between the setting during
runtime because there will be only one boot image for that board.


This is a runtime dynamic DDR configuration support you are describing
correct? This means you would be including all the supported memory option
DTSIs in your k3--r5.dts correct and probably do some board magic
code in the SPL DDR driver to choose the DTB. How is this affecting the
packing of the final bootloader which will anyways pack the whole R5 DTB?


Correct, the DDR configuration should be chosen at runtime after
reading some board strappings. Unless, it will work with with the
same configuration which seems unlikely to me. But it is not an
unusual configuration I'd say.

I haven't looked into this in detail, but to me it seems not that
obvious how to do that in a generic/upstreamable way. Multiple
device nodes sounds wrong. Thus, I'd likely need different device
trees for the different memory configurations for the R5 SPL. Not
sure that is yet possible with u-boot, though. If you have any
better idea, I'm all ears.


Also, regarding the board variants, I'll probably need to choose
between multiple device trees. That is invisible to the user,
because u-boot will choose the correct DTB according a board
strapping, which btw. works really fine, see for example
(boards/kontron/sl28/spl.c:board_fit_config_name_match).


Again, this is assuming that there is some HW blown register available
for the board to use (or in our earlier K3 case, the EEPROM) but that is
not necessarily true every time.


No, that is of course board dependent. It is just an example that
there are boards with more than one DTB.

Let's step back a bit. Right now, there is
k3---binman.dtsi
which is fine. But it seems, that TI is heading towards a common
k3--binman.dtsi
which is intended to be used by all the boards that are using that
particular SoC, correct me if I'm wrong here. Now the problem with
that is that you hardcode the FIT configuations which are really
board dependent and assume that there will be exactly one DTB per
board, i.e. your "#define SPL_BOARD_DTB" etc.



Correct, but as I mentioned in the earlier message, if your board supports
more than 1 FIT configuration, you can easily extend the image and add more
configurations.


Thus, what I was trying to say is that you should split all the
board independent configuration (dt fragments) from the board
specific configuration.

And again, of course I could just ignore the k3--binman.dtsi
and just use a suitable copy "k3---binman.dtsi" for my
board. But as I said, I'm not sure, this is the way to go and I have
a slight feeling I will be asked to reuse the "k3--binman.dtsi"
when I submit my board support.



I don't think it makes much sense to hardcode your generic
*-binman.dtsi to just one FIT configuration. I'd rather see a split
between generic things which are shared across all boards and board
specifics, like the FIT configuration. I mean I could just copy all


Correct me if I'm wrong, but my understanding is that you would want to
add more FDT blobs in the *-binman.dtsi correct? That is still possible,
adding another "fdt-1" and "conf-1" in the

Something like this in your -u-boot.dtsi,

tispl {
insert-template = <_spl>;
fit {
images {
fdt-1 {
...
};
};
configurations {
conf-1 {
...
};
};
};
};


Then you have the information at two places. One being the "#define
SPL_BOARD_DTB" stuff and the other one being in this additional DT
fragment. That is really confusing.



Hm... maybe. I personally don't see it as confusing. Even when picking
between multiple DTBs, you will have a default DTB in any case, marking that
as a macro wouldn't be confusing right? We'll need to get a third opinion on
here then, I had seen your ping on IRC [1], putting it here for the others
as well.



As 

[RFC PATCH 15/15] doc: board: ti: Add J722S-EVM documentation

2024-04-04 Thread Jayesh Choudhary
Introduce basic documentation for the J722S-EVM.

Signed-off-by: Jayesh Choudhary 
---
 doc/board/ti/j722s_evm.rst | 262 +
 doc/board/ti/k3.rst|   1 +
 2 files changed, 263 insertions(+)
 create mode 100644 doc/board/ti/j722s_evm.rst

diff --git a/doc/board/ti/j722s_evm.rst b/doc/board/ti/j722s_evm.rst
new file mode 100644
index 00..150330f637
--- /dev/null
+++ b/doc/board/ti/j722s_evm.rst
@@ -0,0 +1,262 @@
+.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+.. sectionauthor:: Jayesh Choudhary 
+
+J722S-EVM Platform
+==
+
+The J722S is a family of  application processors built for Automotive and
+Linux Application development. J722S family of SoCs is a superset of the
+AM62P SoC family and shares similar memory map, thus the nodes are being
+reused from AM62P includes instead of duplicating the definitions.
+
+Some highlights of J722S SoC (in addition to AM62P SoC features) are:
+
+* Two Cortex-R5F for Functional Safety or general-purpose usage and
+  two C7x floating point vector DSP with Matrix Multiply Accelerator
+  for deep learning.
+
+* Vision Processing Accelerator (VPAC) with image signal processor
+  and Depth and Motion Processing Accelerator (DMPAC).
+
+* 7xUARTs, 3xSPI, 5xI2C, 2xUSB2, 2xCAN-FD, 3xMMC and SD, GPMC for
+  NAND/FPGA connection, OSPI memory controller, 5xMcASP for audio,
+  4xCSI-RX for Camera, 1 PCIe Gen3 controller, USB3.0 eCAP/eQEP,
+  ePWM, among other peripherals.
+
+For those interested, more details about this SoC can be found in the
+Technical Reference Manual here: https://www.ti.com/lit/zip/sprujb3
+
+Boot Flow:
+--
+
+The bootflow is exactly the same as all SoCs in the am62xxx extended SoC
+family. Below is the pictorial representation:
+
+.. image:: img/boot_diagram_k3_current.svg
+  :alt: Boot flow diagram
+
+- Here TIFS acts as master and provides all the critical services. R5/A53
+  requests TIFS to get these services done as shown in the above diagram.
+
+Sources:
+
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_boot_sources
+:end-before: .. k3_rst_include_end_boot_sources
+
+Build procedure:
+
+
+0. Setup the environment variables:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_common_env_vars_desc
+:end-before: .. k3_rst_include_end_common_env_vars_desc
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_board_env_vars_desc
+:end-before: .. k3_rst_include_end_board_env_vars_desc
+
+Set the variables corresponding to this platform:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_common_env_vars_defn
+:end-before: .. k3_rst_include_end_common_env_vars_defn
+
+.. code-block:: bash
+
+ $ export UBOOT_CFG_CORTEXR=j722s_evm_r5_defconfig
+ $ export UBOOT_CFG_CORTEXA=j722s_evm_a53_defconfig
+ $ export TFA_BOARD=lite
+ $ # we dont use any extra TFA parameters
+ $ unset TFA_EXTRA_ARGS
+ $ export OPTEE_PLATFORM=k3-am62x
+ $ export OPTEE_EXTRA_ARGS="CFG_WITH_SOFTWARE_PRNG=y"
+
+.. j722s_evm_rst_include_start_build_steps
+
+1. Trusted Firmware-A:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_build_steps_tfa
+:end-before: .. k3_rst_include_end_build_steps_tfa
+
+
+2. OP-TEE:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_build_steps_optee
+:end-before: .. k3_rst_include_end_build_steps_optee
+
+3. U-Boot:
+
+* 3.1 R5:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_build_steps_spl_r5
+:end-before: .. k3_rst_include_end_build_steps_spl_r5
+
+* 3.2 A53:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_build_steps_uboot
+:end-before: .. k3_rst_include_end_build_steps_uboot
+.. j722s_evm_rst_include_end_build_steps
+
+Target Images
+--
+
+In order to boot we need tiboot3.bin, tispl.bin and u-boot.img.  Each SoC
+variant (HS-FS, HS-SE) requires a different source for these files.
+
+ - HS-FS
+
+* tiboot3-j722s-hs-fs-evm.bin from step 3.1
+* tispl.bin, u-boot.img from step 3.2
+
+ - HS-SE
+
+* tiboot3-j722s-hs-evm.bin from step 3.1
+* tispl.bin, u-boot.img from step 3.2
+
+Image formats:
+--
+
+- tiboot3.bin
+
+.. image:: img/multi_cert_tiboot3.bin.svg
+  :alt: tiboot3.bin image format
+
+- tispl.bin
+
+.. image:: img/dm_tispl.bin.svg
+  :alt: tispl.bin image format
+
+A53 SPL DDR Memory Layout
+-
+
+.. j722s_evm_rst_include_start_ddr_mem_layout
+
+This provides an overview memory usage in A53 SPL stage.
+
+.. list-table::
+   :widths: 16 16 16
+   :header-rows: 1
+
+   * - Region
+ - Start Address
+ - End Address
+
+   * - EMPTY
+ - 0x8000
+ - 0x8008
+
+   * - TEXT BASE
+ - 0x8008
+ - 0x800d8000
+
+   * - EMPTY
+ - 0x800d8000
+ - 0x80477660
+
+   * - STACK
+ - 0x80477660
+ - 0x80477e60
+
+   * - GD
+ - 0x80477e60
+ 

[RFC PATCH 14/15] configs: introduce configs needed for the J722S

2024-04-04 Thread Jayesh Choudhary
Introduce the initial configs needed to support the J722S SoC family.

Signed-off-by: Vaishnav Achath 
Signed-off-by: Jayesh Choudhary 
---
 configs/j722s_evm_a53_defconfig | 177 
 configs/j722s_evm_r5_defconfig  | 137 
 include/configs/j722s_evm.h |  14 +++
 3 files changed, 328 insertions(+)
 create mode 100644 configs/j722s_evm_a53_defconfig
 create mode 100644 configs/j722s_evm_r5_defconfig
 create mode 100644 include/configs/j722s_evm.h

diff --git a/configs/j722s_evm_a53_defconfig b/configs/j722s_evm_a53_defconfig
new file mode 100644
index 00..8d29c9601b
--- /dev/null
+++ b/configs/j722s_evm_a53_defconfig
@@ -0,0 +1,177 @@
+CONFIG_ARM=y
+CONFIG_ARCH_K3=y
+CONFIG_TI_SECURE_DEVICE=y
+CONFIG_SYS_MALLOC_F_LEN=0x8000
+CONFIG_SPL_GPIO=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_SOC_K3_J722S=y
+CONFIG_TARGET_J722S_A53_EVM=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8048
+CONFIG_SF_DEFAULT_SPEED=2500
+CONFIG_ENV_SIZE=0x4
+CONFIG_DM_GPIO=y
+CONFIG_SPL_DM_SPI=y
+CONFIG_OF_UPSTREAM=y
+CONFIG_DEFAULT_DEVICE_TREE="ti/k3-j722s-evm"
+CONFIG_SPL_TEXT_BASE=0x8008
+CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_DM_RESET=y
+CONFIG_SPL_MMC=y
+CONFIG_SPL_SERIAL=y
+CONFIG_SPL_STACK_R_ADDR=0x8200
+CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_SPI=y
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
+CONFIG_BOOTSTD_FULL=y
+CONFIG_BOOTSTD_DEFAULTS=y
+CONFIG_BOOTCOMMAND="run envboot; bootflow scan -lb"
+CONFIG_SPL_MAX_SIZE=0x58000
+CONFIG_SPL_PAD_TO=0x0
+CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
+CONFIG_SPL_BSS_START_ADDR=0x80a0
+CONFIG_SPL_BSS_MAX_SIZE=0x8
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_STACK_R=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
+CONFIG_SPL_DMA=y
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
+CONFIG_SPL_I2C=y
+CONFIG_SPL_DM_MAILBOX=y
+CONFIG_SPL_MTD_SUPPORT=y
+CONFIG_SPL_DM_SPI_FLASH=y
+CONFIG_SPL_POWER_DOMAIN=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
+# CONFIG_SPL_SPI_FLASH_TINY is not set
+CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
+CONFIG_SPL_THERMAL=y
+CONFIG_SPL_YMODEM_SUPPORT=y
+CONFIG_SYS_MAXARGS=64
+CONFIG_CMD_CLK=y
+CONFIG_CMD_DFU=y
+CONFIG_CMD_DM=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
+CONFIG_CMD_REMOTEPROC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_UBI=y
+CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_MULTI_DTB_FIT=y
+CONFIG_SPL_MULTI_DTB_FIT=y
+CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_DEVICE_REMOVE=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_REGMAP=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SPL_SYSCON=y
+CONFIG_SPL_OF_TRANSLATE=y
+CONFIG_CLK=y
+CONFIG_SPL_CLK=y
+CONFIG_CLK_TI_SCI=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_MTD=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_SF=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x4
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x80
+CONFIG_DMA_CHANNELS=y
+CONFIG_TI_K3_NAVSS_UDMA=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0xC000
+CONFIG_FASTBOOT_BUF_SIZE=0x2F00
+CONFIG_TI_SCI_PROTOCOL=y
+CONFIG_SPL_DM_GPIO_LOOKUP_LABEL=y
+CONFIG_DA8XX_GPIO=y
+CONFIG_DM_PCA953X=y
+CONFIG_SPL_DM_PCA953X=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_OMAP24XX=y
+CONFIG_DM_MAILBOX=y
+CONFIG_K3_SEC_PROXY=y
+CONFIG_I2C_EEPROM=y
+CONFIG_SPL_I2C_EEPROM=y
+CONFIG_FS_LOADER=y
+CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_MMC_IO_VOLTAGE=y
+CONFIG_SPL_MMC_IO_VOLTAGE=y
+CONFIG_MMC_HS400_SUPPORT=y
+CONFIG_SPL_MMC_HS400_SUPPORT=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_ADMA=y
+CONFIG_SPL_MMC_SDHCI_ADMA=y
+CONFIG_MMC_SDHCI_AM654=y
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_MTD_SPI_NAND=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH_SFDP_SUPPORT=y
+CONFIG_SPI_FLASH_SOFT_RESET=y
+CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_S28HX_T=y
+CONFIG_PHY_TI_DP83867=y
+CONFIG_TI_AM65_CPSW_NUSS=y
+CONFIG_PINCTRL=y
+CONFIG_SPL_PINCTRL=y
+CONFIG_PINCTRL_SINGLE=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_TI_SCI_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_SPL_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_SPL_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_SPL_DM_REGULATOR_GPIO=y
+CONFIG_K3_SYSTEM_CONTROLLER=y
+CONFIG_REMOTEPROC_TI_K3_ARM64=y
+CONFIG_REMOTEPROC_TI_K3_DSP=y
+CONFIG_REMOTEPROC_TI_K3_R5F=y
+CONFIG_RESET_TI_SCI=y
+CONFIG_DM_SERIAL=y
+CONFIG_SOC_DEVICE=y
+CONFIG_SOC_DEVICE_TI_K3=y
+CONFIG_SOC_TI=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_CADENCE_QSPI=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_TI_SCI=y
+CONFIG_DM_THERMAL=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y

[RFC PATCH 11/15] board: ti: Introduce basic board files for the J722S family

2024-04-04 Thread Jayesh Choudhary
Introduce the basic files needed to support the TI J722S family of SoCs.

Co-developed-by: Vaishnav Achath 
Signed-off-by: Vaishnav Achath 
Signed-off-by: Jayesh Choudhary 
---
 board/ti/j722s/Kconfig  |   26 +
 board/ti/j722s/MAINTAINERS  |9 +
 board/ti/j722s/Makefile |7 +
 board/ti/j722s/board-cfg.yaml   |   36 +
 board/ti/j722s/evm.c|   29 +
 board/ti/j722s/j722s.env|   15 +
 board/ti/j722s/pm-cfg.yaml  |   12 +
 board/ti/j722s/rm-cfg.yaml  | 1119 +++
 board/ti/j722s/sec-cfg.yaml |  379 +++
 board/ti/j722s/tifs-rm-cfg.yaml |  981 +++
 10 files changed, 2613 insertions(+)
 create mode 100644 board/ti/j722s/Kconfig
 create mode 100644 board/ti/j722s/MAINTAINERS
 create mode 100644 board/ti/j722s/Makefile
 create mode 100644 board/ti/j722s/board-cfg.yaml
 create mode 100644 board/ti/j722s/evm.c
 create mode 100644 board/ti/j722s/j722s.env
 create mode 100644 board/ti/j722s/pm-cfg.yaml
 create mode 100644 board/ti/j722s/rm-cfg.yaml
 create mode 100644 board/ti/j722s/sec-cfg.yaml
 create mode 100644 board/ti/j722s/tifs-rm-cfg.yaml

diff --git a/board/ti/j722s/Kconfig b/board/ti/j722s/Kconfig
new file mode 100644
index 00..68c214e473
--- /dev/null
+++ b/board/ti/j722s/Kconfig
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+#
+
+if TARGET_J722S_R5_EVM || TARGET_J722S_A53_EVM
+
+config SYS_BOARD
+   default "j722s"
+
+config SYS_VENDOR
+   default "ti"
+
+config SYS_CONFIG_NAME
+   default "j722s_evm"
+
+source "board/ti/common/Kconfig"
+
+endif
+
+if TARGET_J722S_R5_EVM
+
+config SPL_LDSCRIPT
+   default "arch/arm/mach-omap2/u-boot-spl.lds"
+
+endif
diff --git a/board/ti/j722s/MAINTAINERS b/board/ti/j722s/MAINTAINERS
new file mode 100644
index 00..7908c30def
--- /dev/null
+++ b/board/ti/j722s/MAINTAINERS
@@ -0,0 +1,9 @@
+J722S BOARD
+M: Vaishnav Achath 
+M: Jayesh Choudhary 
+M: Tom Rini 
+S: Maintained
+F: board/ti/j722s/
+F: include/configs/j722s_evm.h
+F: configs/j722s_evm_r5_defconfig
+F: configs/j722s_evm_a53_defconfig
diff --git a/board/ti/j722s/Makefile b/board/ti/j722s/Makefile
new file mode 100644
index 00..20d2ec934b
--- /dev/null
+++ b/board/ti/j722s/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-y  += evm.o
diff --git a/board/ti/j722s/board-cfg.yaml b/board/ti/j722s/board-cfg.yaml
new file mode 100644
index 00..f9a4c438ca
--- /dev/null
+++ b/board/ti/j722s/board-cfg.yaml
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Board configuration for J722S
+#
+
+---
+
+board-cfg:
+rev:
+boardcfg_abi_maj: 0x0
+boardcfg_abi_min: 0x1
+control:
+subhdr:
+magic: 0xC1D3
+size: 7
+main_isolation_enable: 0x5A
+main_isolation_hostid: 0x2
+secproxy:
+subhdr:
+magic: 0x1207
+size: 7
+scaling_factor: 0x1
+scaling_profile: 0x1
+disable_main_nav_secure_proxy: 0
+msmc:
+subhdr:
+magic: 0xA5C3
+size: 5
+msmc_cache_size: 0x0
+debug_cfg:
+subhdr:
+magic: 0x020C
+size: 8
+trace_dst_enables: 0x00
+trace_src_enables: 0x00
diff --git a/board/ti/j722s/evm.c b/board/ti/j722s/evm.c
new file mode 100644
index 00..515aaa8187
--- /dev/null
+++ b/board/ti/j722s/evm.c
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Board specific initialization for J722S platforms
+ *
+ * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int board_init(void)
+{
+   return 0;
+}
+
+int dram_init(void)
+{
+   return fdtdec_setup_mem_size_base();
+}
+
+int dram_init_banksize(void)
+{
+   return fdtdec_setup_memory_banksize();
+}
diff --git a/board/ti/j722s/j722s.env b/board/ti/j722s/j722s.env
new file mode 100644
index 00..f8b6aff2c2
--- /dev/null
+++ b/board/ti/j722s/j722s.env
@@ -0,0 +1,15 @@
+#include 
+#include 
+
+name_kern=Image
+console=ttyS2,115200n8
+args_all=setenv optargs ${optargs} earlycon=ns16550a,mmio32,0x0280
+   ${mtdparts}
+run_kern=booti ${loadaddr} ${rd_spec} ${fdtaddr}
+
+boot_targets=mmc1 mmc0 pxe dhcp
+boot=mmc
+mmcdev=1
+bootpart=1:2
+bootdir=/boot
+rd_spec=-
diff --git a/board/ti/j722s/pm-cfg.yaml b/board/ti/j722s/pm-cfg.yaml
new file mode 100644
index 00..46b3ad2010
--- /dev/null
+++ b/board/ti/j722s/pm-cfg.yaml
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Power management configuration 

[RFC PATCH 12/15] firmware: ti_sci_static_data: Add static DMA channel

2024-04-04 Thread Jayesh Choudhary
Include the static DMA channel data for using DMA at SPL stage
for J722S SoC family.

Signed-off-by: Vaishnav Achath 
Signed-off-by: Jayesh Choudhary 
---
 drivers/firmware/ti_sci_static_data.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/ti_sci_static_data.h 
b/drivers/firmware/ti_sci_static_data.h
index 9662bd95f2..3370f80231 100644
--- a/drivers/firmware/ti_sci_static_data.h
+++ b/drivers/firmware/ti_sci_static_data.h
@@ -85,7 +85,7 @@ static struct ti_sci_resource_static_data rm_static_data[] = {
 #endif /* CONFIG_SOC_K3_J721S2 */
 
 #if IS_ENABLED(CONFIG_SOC_K3_AM625) || IS_ENABLED(CONFIG_SOC_K3_AM62A7) || \
-   IS_ENABLED(CONFIG_SOC_K3_AM62P5)
+   IS_ENABLED(CONFIG_SOC_K3_AM62P5) || IS_ENABLED(CONFIG_SOC_K3_J722S)
 static struct ti_sci_resource_static_data rm_static_data[] = {
/* BC channels */
{
-- 
2.25.1



[RFC PATCH 10/15] arch: mach-k3: Introduce basic files to support J722S SoC family

2024-04-04 Thread Jayesh Choudhary
Introduce the basic functions and definitions needed to properly
initialize TI J722S family of SoCs.

Co-developed-by: Vaishnav Achath 
Signed-off-by: Vaishnav Achath 
Signed-off-by: Jayesh Choudhary 
---
 arch/arm/mach-k3/Kconfig  |   7 +-
 arch/arm/mach-k3/Makefile |   1 +
 arch/arm/mach-k3/include/mach/hardware.h  |   4 +
 .../arm/mach-k3/include/mach/j722s_hardware.h |  83 ++
 arch/arm/mach-k3/include/mach/j722s_spl.h |  49 
 arch/arm/mach-k3/include/mach/spl.h   |   4 +
 arch/arm/mach-k3/j722s/Kconfig|  32 ++
 arch/arm/mach-k3/j722s_init.c | 276 ++
 8 files changed, 455 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-k3/include/mach/j722s_hardware.h
 create mode 100644 arch/arm/mach-k3/include/mach/j722s_spl.h
 create mode 100644 arch/arm/mach-k3/j722s/Kconfig
 create mode 100644 arch/arm/mach-k3/j722s_init.c

diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig
index 2bb970c2d4..f3f42b3921 100644
--- a/arch/arm/mach-k3/Kconfig
+++ b/arch/arm/mach-k3/Kconfig
@@ -25,6 +25,9 @@ config SOC_K3_J721E
 config SOC_K3_J721S2
bool "TI's K3 based J721S2 SoC Family Support"
 
+config SOC_K3_J722S
+   bool "TI's K3 based J722S SoC Family Support"
+
 config SOC_K3_J784S4
bool "TI's K3 based J784S4 SoC Family Support"
 
@@ -84,6 +87,7 @@ config SYS_K3_BOOT_PARAM_TABLE_INDEX
default 0x43c3f290 if SOC_K3_AM62A7 && CPU_V7R
default 0x7000f290 if SOC_K3_AM62A7 && ARM64
default 0x43c4f290 if SOC_K3_AM62P5
+   default 0x43c7f290 if SOC_K3_J722S
help
  Address at which ROM stores the value which determines if SPL
  is booted up by primary boot media or secondary boot media.
@@ -122,7 +126,7 @@ config K3_EARLY_CONS_IDX
 
 config K3_ATF_LOAD_ADDR
hex "Load address of ATF image"
-   default 0x8000 if (SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_AM62P5)
+   default 0x8000 if (SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_AM62P5 
|| SOC_K3_J722S)
default 0x7000
help
  The load address for the ATF image. This value is used to build the
@@ -163,6 +167,7 @@ source "arch/arm/mach-k3/am62ax/Kconfig"
 source "arch/arm/mach-k3/am62px/Kconfig"
 source "arch/arm/mach-k3/j721e/Kconfig"
 source "arch/arm/mach-k3/j721s2/Kconfig"
+source "arch/arm/mach-k3/j722s/Kconfig"
 source "arch/arm/mach-k3/j784s4/Kconfig"
 
 endif
diff --git a/arch/arm/mach-k3/Makefile b/arch/arm/mach-k3/Makefile
index 6ee9864c72..87baa6f313 100644
--- a/arch/arm/mach-k3/Makefile
+++ b/arch/arm/mach-k3/Makefile
@@ -23,5 +23,6 @@ obj-$(CONFIG_SOC_K3_AM625) += am625_init.o
 obj-$(CONFIG_SOC_K3_AM62A7) += am62a7_init.o
 obj-$(CONFIG_SOC_K3_J784S4) += j784s4_init.o
 obj-$(CONFIG_SOC_K3_AM62P5) += am62p5_init.o
+obj-$(CONFIG_SOC_K3_J722S) += j722s_init.o
 endif
 obj-y += common.o security.o
diff --git a/arch/arm/mach-k3/include/mach/hardware.h 
b/arch/arm/mach-k3/include/mach/hardware.h
index b4bc121cbf..e8abe01137 100644
--- a/arch/arm/mach-k3/include/mach/hardware.h
+++ b/arch/arm/mach-k3/include/mach/hardware.h
@@ -36,6 +36,10 @@
 #include "j721s2_hardware.h"
 #endif
 
+#ifdef CONFIG_SOC_K3_J722S
+#include "j722s_hardware.h"
+#endif
+
 #ifdef CONFIG_SOC_K3_J784S4
 #include "j784s4_hardware.h"
 #endif
diff --git a/arch/arm/mach-k3/include/mach/j722s_hardware.h 
b/arch/arm/mach-k3/include/mach/j722s_hardware.h
new file mode 100644
index 00..8d0bec2206
--- /dev/null
+++ b/arch/arm/mach-k3/include/mach/j722s_hardware.h
@@ -0,0 +1,83 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * K3: J722S SoC definitions, structures etc.
+ *
+ * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#ifndef __ASM_ARCH_J722S_HARDWARE_H
+#define __ASM_ARCH_J722S_HARDWARE_H
+
+#include 
+#ifndef __ASSEMBLY__
+#include 
+#endif
+
+#define PADCFG_MMR0_BASE   0x0408
+#define PADCFG_MMR1_BASE   0x000f
+#define CTRL_MMR0_BASE 0x0010
+#define MCU_CTRL_MMR0_BASE 0x0450
+#define WKUP_CTRL_MMR0_BASE0x4300
+
+#define CTRLMMR_MAIN_DEVSTAT   (WKUP_CTRL_MMR0_BASE + 0x30)
+#define MAIN_DEVSTAT_PRIMARY_BOOTMODE_MASK GENMASK(6, 3)
+#define MAIN_DEVSTAT_PRIMARY_BOOTMODE_SHIFT3
+#define MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK GENMASK(9, 7)
+#define MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT7
+#define MAIN_DEVSTAT_BACKUP_BOOTMODE_MASK  GENMASK(12, 10)
+#define MAIN_DEVSTAT_BACKUP_BOOTMODE_SHIFT 10
+#define MAIN_DEVSTAT_BACKUP_BOOTMODE_CFG_MASK  BIT(13)
+#define MAIN_DEVSTAT_BACKUP_BOOTMODE_CFG_SHIFT 13
+
+/* Primary Bootmode MMC Config macros */
+#define MAIN_DEVSTAT_PRIMARY_MMC_PORT_MASK 0x4
+#define MAIN_DEVSTAT_PRIMARY_MMC_PORT_SHIFT2
+#define MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK   0x1
+#define MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_SHIFT  0
+
+/* Primary Bootmode 

[RFC PATCH 08/15] arm: mach-k3: j722s: introduce clock and device files for wkup spl

2024-04-04 Thread Jayesh Choudhary
Include the clock and lpsc tree files needed for the wkup spl to
initialize the proper PLLs and power domains to boot the SoC.

Signed-off-by: Vaishnav Achath 
Signed-off-by: Jayesh Choudhary 
---
 arch/arm/mach-k3/r5/Makefile   |   1 +
 arch/arm/mach-k3/r5/j722s/Makefile |   6 +
 arch/arm/mach-k3/r5/j722s/clk-data.c   | 312 +
 arch/arm/mach-k3/r5/j722s/dev-data.c   |  69 ++
 drivers/clk/ti/clk-k3.c|   6 +
 drivers/power/domain/ti-power-domain.c |   6 +
 include/k3-clk.h   |   1 +
 include/k3-dev.h   |   1 +
 8 files changed, 402 insertions(+)
 create mode 100644 arch/arm/mach-k3/r5/j722s/Makefile
 create mode 100644 arch/arm/mach-k3/r5/j722s/clk-data.c
 create mode 100644 arch/arm/mach-k3/r5/j722s/dev-data.c

diff --git a/arch/arm/mach-k3/r5/Makefile b/arch/arm/mach-k3/r5/Makefile
index f1e61c8548..d3886caa06 100644
--- a/arch/arm/mach-k3/r5/Makefile
+++ b/arch/arm/mach-k3/r5/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_SOC_K3_AM62P5) += am62px/
 obj-$(CONFIG_SOC_K3_J721E) += j721e/
 obj-$(CONFIG_SOC_K3_J721E) += j7200/
 obj-$(CONFIG_SOC_K3_J721S2) += j721s2/
+obj-$(CONFIG_SOC_K3_J722S) += j722s/
 obj-$(CONFIG_SOC_K3_J784S4) += j784s4/
 
 obj-y += common.o
diff --git a/arch/arm/mach-k3/r5/j722s/Makefile 
b/arch/arm/mach-k3/r5/j722s/Makefile
new file mode 100644
index 00..2a0dbf5f5a
--- /dev/null
+++ b/arch/arm/mach-k3/r5/j722s/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+
+obj-y += clk-data.o
+obj-y += dev-data.o
diff --git a/arch/arm/mach-k3/r5/j722s/clk-data.c 
b/arch/arm/mach-k3/r5/j722s/clk-data.c
new file mode 100644
index 00..b4f27af333
--- /dev/null
+++ b/arch/arm/mach-k3/r5/j722s/clk-data.c
@@ -0,0 +1,312 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * J722S specific clock platform data
+ *
+ * This file is auto generated. Please do not hand edit and report any issues
+ * to Bryan Brattlof .
+ *
+ * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include 
+#include "k3-clk.h"
+
+static const char * const gluelogic_hfosc0_clkout_parents[] = {
+   NULL,
+   NULL,
+   "osc_24_mhz",
+   "osc_25_mhz",
+   "osc_26_mhz",
+   NULL,
+};
+
+static const char * const clk_32k_rc_sel_out0_parents[] = {
+   "gluelogic_rcosc_clk_1p0v_97p65k",
+   "gluelogic_hfosc0_clkout",
+   "gluelogic_rcosc_clk_1p0v_97p65k",
+   "gluelogic_lfosc0_clkout",
+};
+
+static const char * const main_emmcsd1_io_clklb_sel_out0_parents[] = {
+   "board_0_mmc1_clklb_out",
+   "board_0_mmc1_clk_out",
+};
+
+static const char * const main_ospi_loopback_clk_sel_out0_parents[] = {
+   "board_0_ospi0_dqs_out",
+   "board_0_ospi0_lbclko_out",
+};
+
+static const char * const main_usb0_refclk_sel_out0_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "postdiv4_16ff_main_0_hsdivout8_clk",
+};
+
+static const char * const sam62_pll_ctrl_wrap_main_0_sysclkout_clk_parents[] = 
{
+   "gluelogic_hfosc0_clkout",
+   "hsdiv4_16fft_main_0_hsdivout0_clk",
+};
+
+static const char * const sam62_pll_ctrl_wrap_mcu_0_sysclkout_clk_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "hsdiv4_16fft_mcu_0_hsdivout0_clk",
+};
+
+static const char * const clkout0_ctrl_out0_parents[] = {
+   "hsdiv4_16fft_main_2_hsdivout1_clk",
+   "hsdiv4_16fft_main_2_hsdivout1_clk",
+};
+
+static const char * const main_emmcsd0_refclk_sel_out0_parents[] = {
+   "postdiv4_16ff_main_0_hsdivout5_clk",
+   "hsdiv4_16fft_main_2_hsdivout2_clk",
+};
+
+static const char * const main_emmcsd1_refclk_sel_out0_parents[] = {
+   "postdiv4_16ff_main_0_hsdivout5_clk",
+   "hsdiv4_16fft_main_2_hsdivout2_clk",
+};
+
+static const char * const main_gtcclk_sel_out0_parents[] = {
+   "postdiv4_16ff_main_2_hsdivout5_clk",
+   "postdiv4_16ff_main_0_hsdivout6_clk",
+   "board_0_cp_gemac_cpts0_rft_clk_out",
+   NULL,
+   "board_0_mcu_ext_refclk0_out",
+   "board_0_ext_refclk1_out",
+   "sam62_pll_ctrl_wrap_mcu_0_chip_div1_clk_clk",
+   "sam62_pll_ctrl_wrap_main_0_chip_div1_clk_clk",
+};
+
+static const char * const main_ospi_ref_clk_sel_out0_parents[] = {
+   "hsdiv4_16fft_main_0_hsdivout1_clk",
+   "postdiv1_16fft_main_1_hsdivout5_clk",
+};
+
+static const char * const main_timerclkn_sel_out0_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "clk_32k_rc_sel_out0",
+   "postdiv4_16ff_main_0_hsdivout7_clk",
+   "gluelogic_rcosc_clkout",
+   "board_0_mcu_ext_refclk0_out",
+   "board_0_ext_refclk1_out",
+   NULL,
+   "board_0_cp_gemac_cpts0_rft_clk_out",
+   "hsdiv4_16fft_main_1_hsdivout3_clk",
+   "postdiv4_16ff_main_2_hsdivout6_clk",
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+};
+
+static const char * const wkup_clkout_sel_out0_parents[] = {
+   

[RFC PATCH 09/15] ram: k3-ddrss: Enable the am62ax's DDR controller for J722S

2024-04-04 Thread Jayesh Choudhary
The J722S family of SoCs uses the same DDR controller as found on the
AM62A family. Enable this option when building for the J722S family.

Signed-off-by: Vaishnav Achath 
Signed-off-by: Jayesh Choudhary 
---
 drivers/ram/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ram/Kconfig b/drivers/ram/Kconfig
index 9838a2798f..a64d2dff68 100644
--- a/drivers/ram/Kconfig
+++ b/drivers/ram/Kconfig
@@ -65,7 +65,7 @@ choice
default K3_J721E_DDRSS if SOC_K3_J721E || SOC_K3_J721S2 || SOC_K3_J784S4
default K3_AM64_DDRSS if SOC_K3_AM642
default K3_AM64_DDRSS if SOC_K3_AM625
-   default K3_AM62A_DDRSS if SOC_K3_AM62A7 || SOC_K3_AM62P5
+   default K3_AM62A_DDRSS if SOC_K3_AM62A7 || SOC_K3_AM62P5 || SOC_K3_J722S
 
 config K3_J721E_DDRSS
bool "Enable J721E DDRSS support"
-- 
2.25.1



[RFC PATCH 01/15] DO-NOT-MERGE: dts: upstream: src: Necessary pulls from upstream dts

2024-04-04 Thread Jayesh Choudhary
j722s dts support that needs to be pulled from devicetree-rebasing
tree. The whole series depends on this support.

Signed-off-by: Jayesh Choudhary 
---
 dts/upstream/Bindings/arm/ti/k3.yaml   |   6 +
 dts/upstream/src/arm64/ti/k3-j722s-evm.dts | 383 +
 dts/upstream/src/arm64/ti/k3-j722s.dtsi|  89 +
 dts/upstream/src/arm64/ti/k3-pinctrl.h |   3 +
 4 files changed, 481 insertions(+)
 create mode 100644 dts/upstream/src/arm64/ti/k3-j722s-evm.dts
 create mode 100644 dts/upstream/src/arm64/ti/k3-j722s.dtsi

diff --git a/dts/upstream/Bindings/arm/ti/k3.yaml 
b/dts/upstream/Bindings/arm/ti/k3.yaml
index c6506bccfe..d526723484 100644
--- a/dts/upstream/Bindings/arm/ti/k3.yaml
+++ b/dts/upstream/Bindings/arm/ti/k3.yaml
@@ -123,6 +123,12 @@ properties:
   - ti,j721s2-evm
   - const: ti,j721s2
 
+  - description: K3 J722S SoC and Boards
+items:
+  - enum:
+  - ti,j722s-evm
+  - const: ti,j722s
+
   - description: K3 J784s4 SoC
 items:
   - enum:
diff --git a/dts/upstream/src/arm64/ti/k3-j722s-evm.dts 
b/dts/upstream/src/arm64/ti/k3-j722s-evm.dts
new file mode 100644
index 00..cee3a8661d
--- /dev/null
+++ b/dts/upstream/src/arm64/ti/k3-j722s-evm.dts
@@ -0,0 +1,383 @@
+// SPDX-License-Identifier: GPL-2.0-only OR MIT
+/*
+ * Device Tree file for the J722S EVM
+ * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
+ *
+ * Schematics: https://www.ti.com/lit/zip/sprr495
+ */
+
+/dts-v1/;
+
+#include 
+#include "k3-j722s.dtsi"
+
+/ {
+   compatible = "ti,j722s-evm", "ti,j722s";
+   model = "Texas Instruments J722S EVM";
+
+   aliases {
+   serial0 = _uart0;
+   serial2 = _uart0;
+   mmc0 = 
+   mmc1 = 
+   };
+
+   chosen {
+   stdout-path = _uart0;
+   };
+
+   memory@8000 {
+   /* 8G RAM */
+   reg = <0x 0x8000 0x 0x8000>,
+ <0x0008 0x8000 0x0001 0x8000>;
+   device_type = "memory";
+   bootph-pre-ram;
+   };
+
+   reserved_memory: reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secure_tfa_ddr: tfa@9e78 {
+   reg = <0x00 0x9e78 0x00 0x8>;
+   no-map;
+   };
+
+   secure_ddr: optee@9e80 {
+   reg = <0x00 0x9e80 0x00 0x0180>;
+   no-map;
+   };
+
+   wkup_r5fss0_core0_memory_region: r5f-memory@a010 {
+   compatible = "shared-dma-pool";
+   reg = <0x00 0xa010 0x00 0xf0>;
+   no-map;
+   };
+
+   };
+
+   vmain_pd: regulator-0 {
+   /* TPS65988 PD CONTROLLER OUTPUT */
+   compatible = "regulator-fixed";
+   regulator-name = "vmain_pd";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-always-on;
+   regulator-boot-on;
+   bootph-all;
+   };
+
+   vsys_5v0: regulator-vsys5v0 {
+   /* Output of LM5140 */
+   compatible = "regulator-fixed";
+   regulator-name = "vsys_5v0";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_pd>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   vdd_mmc1: regulator-mmc1 {
+   /* TPS22918DBVR */
+   compatible = "regulator-fixed";
+   regulator-name = "vdd_mmc1";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   enable-active-high;
+   gpio = < 15 GPIO_ACTIVE_HIGH>;
+   bootph-all;
+   };
+
+   vdd_sd_dv: regulator-TLV71033 {
+   compatible = "regulator-gpio";
+   regulator-name = "tlv71033";
+   pinctrl-names = "default";
+   pinctrl-0 = <_sd_dv_pins_default>;
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   vin-supply = <_5v0>;
+   gpios = <_gpio0 70 GPIO_ACTIVE_HIGH>;
+   states = <180 0x0>,
+<330 0x1>;
+   };
+
+   vsys_io_1v8: regulator-vsys-io-1v8 {
+   compatible = "regulator-fixed";
+   regulator-name = "vsys_io_1v8";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-always-on;
+   regulator-boot-on;
+   

[RFC PATCH 02/15] arm: mach-k3: Sort CONFIG_SOC* and K3_SOC_ID entries

2024-04-04 Thread Jayesh Choudhary
Sort CONFIG_SOC* and K3_SOC_ID alphabetically.

Signed-off-by: Jayesh Choudhary 
---
 arch/arm/mach-k3/include/mach/hardware.h | 37 
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-k3/include/mach/hardware.h 
b/arch/arm/mach-k3/include/mach/hardware.h
index af982e70d1..bbe1fe5c80 100644
--- a/arch/arm/mach-k3/include/mach/hardware.h
+++ b/arch/arm/mach-k3/include/mach/hardware.h
@@ -8,37 +8,38 @@
 
 #include 
 
-#ifdef CONFIG_SOC_K3_AM654
-#include "am6_hardware.h"
+#ifdef CONFIG_SOC_K3_AM625
+#include "am62_hardware.h"
 #endif
 
-#ifdef CONFIG_SOC_K3_J721E
-#include "j721e_hardware.h"
+#ifdef CONFIG_SOC_K3_AM62A7
+#include "am62a_hardware.h"
 #endif
 
-#ifdef CONFIG_SOC_K3_J721S2
-#include "j721s2_hardware.h"
+#ifdef CONFIG_SOC_K3_AM62P5
+#include "am62p_hardware.h"
 #endif
 
 #ifdef CONFIG_SOC_K3_AM642
 #include "am64_hardware.h"
 #endif
 
-#ifdef CONFIG_SOC_K3_AM625
-#include "am62_hardware.h"
+#ifdef CONFIG_SOC_K3_AM654
+#include "am6_hardware.h"
 #endif
 
-#ifdef CONFIG_SOC_K3_AM62A7
-#include "am62a_hardware.h"
+#ifdef CONFIG_SOC_K3_J721E
+#include "j721e_hardware.h"
+#endif
+
+#ifdef CONFIG_SOC_K3_J721S2
+#include "j721s2_hardware.h"
 #endif
 
 #ifdef CONFIG_SOC_K3_J784S4
 #include "j784s4_hardware.h"
 #endif
 
-#ifdef CONFIG_SOC_K3_AM62P5
-#include "am62p_hardware.h"
-#endif
 
 /* Assuming these addresses and definitions stay common across K3 devices */
 #define CTRLMMR_WKUP_JTAG_ID   (WKUP_CTRL_MMR0_BASE + 0x14)
@@ -63,14 +64,14 @@ static inline bool soc_is_##id(void) \
JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT; \
return soc == JTAG_ID_PARTNO_##ID; \
 }
-K3_SOC_ID(am65x, AM65X)
-K3_SOC_ID(j721e, J721E)
-K3_SOC_ID(j7200, J7200)
-K3_SOC_ID(am64x, AM64X)
-K3_SOC_ID(j721s2, J721S2)
 K3_SOC_ID(am62x, AM62X)
 K3_SOC_ID(am62ax, AM62AX)
 K3_SOC_ID(am62px, AM62PX)
+K3_SOC_ID(am64x, AM64X)
+K3_SOC_ID(am65x, AM65X)
+K3_SOC_ID(j7200, J7200)
+K3_SOC_ID(j721e, J721E)
+K3_SOC_ID(j721s2, J721S2)
 
 #define K3_SEC_MGR_SYS_STATUS  0x44234100
 #define SYS_STATUS_DEV_TYPE_SHIFT  0
-- 
2.25.1



[RFC PATCH 07/15] arm: mach-k3: r5: Makefile: Fix the order for entries

2024-04-04 Thread Jayesh Choudhary
Add the entries in alphabetical order.

Signed-off-by: Jayesh Choudhary 
---
 arch/arm/mach-k3/r5/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-k3/r5/Makefile b/arch/arm/mach-k3/r5/Makefile
index 1cfc8e3ade..f1e61c8548 100644
--- a/arch/arm/mach-k3/r5/Makefile
+++ b/arch/arm/mach-k3/r5/Makefile
@@ -3,13 +3,13 @@
 # Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/
 #  Andrew Davis 
 
+obj-$(CONFIG_SOC_K3_AM625) += am62x/
+obj-$(CONFIG_SOC_K3_AM62A7) += am62ax/
+obj-$(CONFIG_SOC_K3_AM62P5) += am62px/
 obj-$(CONFIG_SOC_K3_J721E) += j721e/
 obj-$(CONFIG_SOC_K3_J721E) += j7200/
 obj-$(CONFIG_SOC_K3_J721S2) += j721s2/
-obj-$(CONFIG_SOC_K3_AM625) += am62x/
-obj-$(CONFIG_SOC_K3_AM62A7) += am62ax/
 obj-$(CONFIG_SOC_K3_J784S4) += j784s4/
-obj-$(CONFIG_SOC_K3_AM62P5) += am62px/
 
 obj-y += common.o
 obj-y += lowlevel_init.o
-- 
2.25.1



[RFC PATCH 05/15] clk: ti: clk-k3: use IS_ENABLED macro and fix the clock-data order

2024-04-04 Thread Jayesh Choudhary
Use IS_ENABLED macro for the platform clock-data list and add them
in alphabetical order.

Signed-off-by: Jayesh Choudhary 
---
 drivers/clk/ti/clk-k3.c | 41 +
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/clk/ti/clk-k3.c b/drivers/clk/ti/clk-k3.c
index 7aa162c2f7..a3c6e79db7 100644
--- a/drivers/clk/ti/clk-k3.c
+++ b/drivers/clk/ti/clk-k3.c
@@ -60,6 +60,24 @@ static void clk_add_map(struct ti_clk_data *data, struct clk 
*clk,
 }
 
 static const struct soc_attr ti_k3_soc_clk_data[] = {
+#if IS_ENABLED(CONFIG_SOC_K3_AM625)
+   {
+   .family = "AM62X",
+   .data = _clk_platdata,
+   },
+#endif
+#if IS_ENABLED(CONFIG_SOC_K3_AM62A7)
+   {
+   .family = "AM62AX",
+   .data = _clk_platdata,
+   },
+#endif
+#if IS_ENABLED(CONFIG_SOC_K3_AM62P5)
+   {
+   .family = "AM62PX",
+   .data = _clk_platdata,
+   },
+#endif
 #if IS_ENABLED(CONFIG_SOC_K3_J721E)
{
.family = "J721E",
@@ -69,35 +87,18 @@ static const struct soc_attr ti_k3_soc_clk_data[] = {
.family = "J7200",
.data = _clk_platdata,
},
-#elif CONFIG_SOC_K3_J721S2
+#endif
+#if IS_ENABLED(CONFIG_SOC_K3_J721S2)
{
.family = "J721S2",
.data = _clk_platdata,
},
 #endif
-#ifdef CONFIG_SOC_K3_AM625
-   {
-   .family = "AM62X",
-   .data = _clk_platdata,
-   },
-#endif
-#ifdef CONFIG_SOC_K3_AM62A7
-   {
-   .family = "AM62AX",
-   .data = _clk_platdata,
-   },
-#endif
-#ifdef CONFIG_SOC_K3_J784S4
+#if IS_ENABLED(CONFIG_SOC_K3_J784S4)
{
.family = "J784S4",
.data = _clk_platdata,
},
-#endif
-#ifdef CONFIG_SOC_K3_AM62P5
-   {
-   .family = "AM62PX",
-   .data = _clk_platdata,
-   },
 #endif
{ /* sentinel */ }
 };
-- 
2.25.1



[RFC PATCH 03/15] soc: ti: k3-socinfo: Fix SOC JTAG entry order

2024-04-04 Thread Jayesh Choudhary
Add JTAG_ID_PARTNO_* in alphabetical order.

Signed-off-by: Jayesh Choudhary 
---
 drivers/soc/soc_ti_k3.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/soc/soc_ti_k3.c b/drivers/soc/soc_ti_k3.c
index 3a4e58bba6..bcc11e6bff 100644
--- a/drivers/soc/soc_ti_k3.c
+++ b/drivers/soc/soc_ti_k3.c
@@ -24,33 +24,33 @@ static const char *get_family_string(u32 idreg)
soc = (idreg & JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
 
switch (soc) {
+   case JTAG_ID_PARTNO_AM62X:
+   family = "AM62X";
+   break;
+   case JTAG_ID_PARTNO_AM62AX:
+   family = "AM62AX";
+   break;
+   case JTAG_ID_PARTNO_AM62PX:
+   family = "AM62PX";
+   break;
+   case JTAG_ID_PARTNO_AM64X:
+   family = "AM64X";
+   break;
case JTAG_ID_PARTNO_AM65X:
family = "AM65X";
break;
-   case JTAG_ID_PARTNO_J721E:
-   family = "J721E";
-   break;
case JTAG_ID_PARTNO_J7200:
family = "J7200";
break;
-   case JTAG_ID_PARTNO_AM64X:
-   family = "AM64X";
+   case JTAG_ID_PARTNO_J721E:
+   family = "J721E";
break;
case JTAG_ID_PARTNO_J721S2:
family = "J721S2";
break;
-   case JTAG_ID_PARTNO_AM62X:
-   family = "AM62X";
-   break;
-   case JTAG_ID_PARTNO_AM62AX:
-   family = "AM62AX";
-   break;
case JTAG_ID_PARTNO_J784S4:
family = "J784S4";
break;
-   case JTAG_ID_PARTNO_AM62PX:
-   family = "AM62PX";
-   break;
default:
family = "Unknown Silicon";
};
-- 
2.25.1



[RFC PATCH 06/15] power: domain: ti: Fix the order for platform data entries

2024-04-04 Thread Jayesh Choudhary
Add the power domain platform data entries in alphabetical order.

Signed-off-by: Jayesh Choudhary 
---
 drivers/power/domain/ti-power-domain.c | 36 +-
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/power/domain/ti-power-domain.c 
b/drivers/power/domain/ti-power-domain.c
index 8996c40ddc..a280859aa5 100644
--- a/drivers/power/domain/ti-power-domain.c
+++ b/drivers/power/domain/ti-power-domain.c
@@ -72,6 +72,24 @@ static void lpsc_write(u32 val, struct ti_lpsc *lpsc, u32 
reg)
 }
 
 static const struct soc_attr ti_k3_soc_pd_data[] = {
+#if IS_ENABLED(CONFIG_SOC_K3_AM625)
+   {
+   .family = "AM62X",
+   .data = _pd_platdata,
+   },
+#endif
+#if IS_ENABLED(CONFIG_SOC_K3_AM62A7)
+   {
+   .family = "AM62AX",
+   .data = _pd_platdata,
+   },
+#endif
+#if IS_ENABLED(CONFIG_SOC_K3_AM62P5)
+   {
+   .family = "AM62PX",
+   .data = _pd_platdata,
+   },
+#endif
 #if IS_ENABLED(CONFIG_SOC_K3_J721E)
{
.family = "J721E",
@@ -88,29 +106,11 @@ static const struct soc_attr ti_k3_soc_pd_data[] = {
.data = _pd_platdata,
},
 #endif
-#if IS_ENABLED(CONFIG_SOC_K3_AM625)
-   {
-   .family = "AM62X",
-   .data = _pd_platdata,
-   },
-#endif
-#if IS_ENABLED(CONFIG_SOC_K3_AM62A7)
-   {
-   .family = "AM62AX",
-   .data = _pd_platdata,
-   },
-#endif
 #if IS_ENABLED(CONFIG_SOC_K3_J784S4)
{
.family = "J784S4",
.data = _pd_platdata,
},
-#endif
-#if IS_ENABLED(CONFIG_SOC_K3_AM62P5)
-   {
-   .family = "AM62PX",
-   .data = _pd_platdata,
-   },
 #endif
{ /* sentinel */ }
 };
-- 
2.25.1



[RFC PATCH 04/15] soc: add info to identify the J722S SoC family

2024-04-04 Thread Jayesh Choudhary
Include the part number for TI's j722s family of SoC
to identify it during boot.

Signed-off-by: Vaishnav Achath 
Signed-off-by: Jayesh Choudhary 
---
 arch/arm/mach-k3/include/mach/hardware.h | 2 ++
 drivers/soc/soc_ti_k3.c  | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/arch/arm/mach-k3/include/mach/hardware.h 
b/arch/arm/mach-k3/include/mach/hardware.h
index bbe1fe5c80..b4bc121cbf 100644
--- a/arch/arm/mach-k3/include/mach/hardware.h
+++ b/arch/arm/mach-k3/include/mach/hardware.h
@@ -55,6 +55,7 @@
 #define JTAG_ID_PARTNO_J7200   0xbb6d
 #define JTAG_ID_PARTNO_J721E   0xbb64
 #define JTAG_ID_PARTNO_J721S2  0xbb75
+#define JTAG_ID_PARTNO_J722S0xbba0
 #define JTAG_ID_PARTNO_J784S4  0xbb80
 
 #define K3_SOC_ID(id, ID) \
@@ -72,6 +73,7 @@ K3_SOC_ID(am65x, AM65X)
 K3_SOC_ID(j7200, J7200)
 K3_SOC_ID(j721e, J721E)
 K3_SOC_ID(j721s2, J721S2)
+K3_SOC_ID(j722s, J722S)
 
 #define K3_SEC_MGR_SYS_STATUS  0x44234100
 #define SYS_STATUS_DEV_TYPE_SHIFT  0
diff --git a/drivers/soc/soc_ti_k3.c b/drivers/soc/soc_ti_k3.c
index bcc11e6bff..92a99ec8db 100644
--- a/drivers/soc/soc_ti_k3.c
+++ b/drivers/soc/soc_ti_k3.c
@@ -48,6 +48,9 @@ static const char *get_family_string(u32 idreg)
case JTAG_ID_PARTNO_J721S2:
family = "J721S2";
break;
+   case JTAG_ID_PARTNO_J722S:
+   family = "J722S";
+   break;
case JTAG_ID_PARTNO_J784S4:
family = "J784S4";
break;
-- 
2.25.1



[RFC PATCH 00/15] Add basic U-Boot Support for J722S-EVM

2024-04-04 Thread Jayesh Choudhary
Hello there,

This series add the U-Boot support for our new platform of K3-SOC
family - J722S-EVM which is a superset of AM62P. It shares the same
memory map and thus the nodes are being reused from AM62P includes
instead of duplicating the definitions.

Some highlights of J722S SoC (in addition to AM62P SoC features) are:

- Two Cortex-R5F for Functional Safety or general-purpose usage and
  two C7x floating point vector DSP with Matrix Multiply Accelerator
  for deep learning.
  
- Vision Processing Accelerator (VPAC) with image signal processor
  and Depth and Motion Processing Accelerator (DMPAC).

- 7xUARTs, 3xSPI, 5xI2C, 2xUSB2, 2xCAN-FD, 3xMMC and SD, GPMC for
  NAND/FPGA connection, OSPI memory controller, 5xMcASP for audio,
  4xCSI-RX for Camera, 1 PCIe Gen3 controller, USB3.0 eCAP/eQEP,
  ePWM, among other peripherals.
  
TRM: 
Schematics: 

Bootlog test:


NOTE: This series depends on the latest dts pull form upstream that will
add the dts changes for J722S-EVM. So the first patch adds the relavent
dts updates which is *NOT SUPPOSED TO BE MERGED*

Jayesh Choudhary (15):
  DO-NOT-MERGE: dts: upstream: src: Necessary pulls from upstream dts
  arm: mach-k3: Sort CONFIG_SOC* and K3_SOC_ID entries
  soc: ti: k3-socinfo: Fix SOC JTAG entry order
  soc: add info to identify the J722S SoC family
  clk: ti: clk-k3: use IS_ENABLED macro and fix the clock-data order
  power: domain: ti: Fix the order for platform data entries
  arm: mach-k3: r5: Makefile: Fix the order for entries
  arm: mach-k3: j722s: introduce clock and device files for wkup spl
  ram: k3-ddrss: Enable the am62ax's DDR controller for J722S
  arch: mach-k3: Introduce basic files to support J722S SoC family
  board: ti: Introduce basic board files for the J722S family
  firmware: ti_sci_static_data: Add static DMA channel
  arm: dts: Introduce J722S U-Boot dts files
  configs: introduce configs needed for the J722S
  doc: board: ti: Add J722S-EVM documentation

 arch/arm/dts/Makefile |2 +
 arch/arm/dts/k3-j722s-binman.dtsi |  171 +
 arch/arm/dts/k3-j722s-ddr-lp4-50-3733.dtsi| 2795 +
 arch/arm/dts/k3-j722s-evm-u-boot.dtsi |   36 +
 arch/arm/dts/k3-j722s-r5-evm.dts  |   82 +
 arch/arm/mach-k3/Kconfig  |7 +-
 arch/arm/mach-k3/Makefile |1 +
 arch/arm/mach-k3/include/mach/hardware.h  |   43 +-
 .../arm/mach-k3/include/mach/j722s_hardware.h |   83 +
 arch/arm/mach-k3/include/mach/j722s_spl.h |   49 +
 arch/arm/mach-k3/include/mach/spl.h   |4 +
 arch/arm/mach-k3/j722s/Kconfig|   32 +
 arch/arm/mach-k3/j722s_init.c |  276 ++
 arch/arm/mach-k3/r5/Makefile  |7 +-
 arch/arm/mach-k3/r5/j722s/Makefile|6 +
 arch/arm/mach-k3/r5/j722s/clk-data.c  |  312 ++
 arch/arm/mach-k3/r5/j722s/dev-data.c  |   69 +
 board/ti/j722s/Kconfig|   26 +
 board/ti/j722s/MAINTAINERS|9 +
 board/ti/j722s/Makefile   |7 +
 board/ti/j722s/board-cfg.yaml |   36 +
 board/ti/j722s/evm.c  |   29 +
 board/ti/j722s/j722s.env  |   15 +
 board/ti/j722s/pm-cfg.yaml|   12 +
 board/ti/j722s/rm-cfg.yaml| 1119 +++
 board/ti/j722s/sec-cfg.yaml   |  379 +++
 board/ti/j722s/tifs-rm-cfg.yaml   |  981 ++
 configs/j722s_evm_a53_defconfig   |  177 ++
 configs/j722s_evm_r5_defconfig|  137 +
 doc/board/ti/j722s_evm.rst|  262 ++
 doc/board/ti/k3.rst   |1 +
 drivers/clk/ti/clk-k3.c   |   41 +-
 drivers/firmware/ti_sci_static_data.h |2 +-
 drivers/power/domain/ti-power-domain.c|   36 +-
 drivers/ram/Kconfig   |2 +-
 drivers/soc/soc_ti_k3.c   |   29 +-
 dts/upstream/Bindings/arm/ti/k3.yaml  |6 +
 dts/upstream/src/arm64/ti/k3-j722s-evm.dts|  383 +++
 dts/upstream/src/arm64/ti/k3-j722s.dtsi   |   89 +
 dts/upstream/src/arm64/ti/k3-pinctrl.h|3 +
 include/configs/j722s_evm.h   |   14 +
 include/k3-clk.h  |1 +
 include/k3-dev.h  |1 +
 43 files changed, 7703 insertions(+), 69 deletions(-)
 create mode 100644 arch/arm/dts/k3-j722s-binman.dtsi
 create mode 100644 arch/arm/dts/k3-j722s-ddr-lp4-50-3733.dtsi
 create mode 100644 arch/arm/dts/k3-j722s-evm-u-boot.dtsi
 create mode 100644 arch/arm/dts/k3-j722s-r5-evm.dts
 create mode 100644 arch/arm/mach-k3/include/mach/j722s_hardware.h
 create mode 100644 arch/arm/mach-k3/include/mach/j722s_spl.h
 create mode 100644 

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

2024-04-04 Thread Ilias Apalodimas
Hi Igor,

On Thu, 4 Apr 2024 at 11:40, Ilias Apalodimas
 wrote:
>
> Hi Igor,
>
> I was about to apply the series, but noticed neither me or Jens were cc'ed
> on this. Adding Jens to the party
>
> On Thu, Apr 04, 2024 at 10:13:49AM +0200, Igor Opaniuk wrote:
> > Add calls for closing tee session after every read/write operation.
>
> What the patch is pretty obvious, but I am missing an explanation of why
> this is needed
>
> >
> > Signed-off-by: Igor Opaniuk 
> > ---
> >
> > (no changes since v1)
> >
> >  cmd/optee_rpmb.c | 23 +--
> >  1 file changed, 17 insertions(+), 6 deletions(-)
> >
> > diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
> > index e0e44bbed04..b3cafd92410 100644
> > --- a/cmd/optee_rpmb.c
> > +++ b/cmd/optee_rpmb.c
> > @@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
> >
> >   rc = tee_shm_alloc(tee, name_size,
> >  TEE_SHM_ALLOC, _name);
> > - if (rc)
> > - return -ENOMEM;
> > + if (rc) {
> > + rc = -ENOMEM;
> > + goto close_session;
> > + }
>
> I don't think you need the session to be opened to allocate memory.
> So instead of of doing this, why don't we just move the alloc call before
> opening the session?

Looking at it again, we do need tee != NULL, but I think it's cleaner
to add something like
if (!dev)
return -ENODEV
to __tee_shm_add() instead.

Cheers
/Ilias
>
> >
> >   rc = tee_shm_alloc(tee, buffer_size,
> >  TEE_SHM_ALLOC, _buf);
> > @@ -125,6 +127,9 @@ out:
> >   tee_shm_free(shm_buf);
> >  free_name:
> >   tee_shm_free(shm_name);
> > +close_session:
> > + tee_close_session(tee, session);
> > + tee = NULL;
> >
> >   return rc;
> >  }
> > @@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
> >   struct tee_param param[2];
> >   size_t name_size = strlen(name) + 1;
> >
> > + if (!value_size)
> > + return -EINVAL;
> > +
> >   if (!tee) {
> >   if (avb_ta_open_session())
> >   return -ENODEV;
> >   }
> > - if (!value_size)
> > - return -EINVAL;
> >
> >   rc = tee_shm_alloc(tee, name_size,
> >  TEE_SHM_ALLOC, _name);
> > - if (rc)
> > - return -ENOMEM;
> > + if (rc) {
> > + rc = -ENOMEM;
> > + goto close_session;
> > + }
>
> ditto
>
> >
> >   rc = tee_shm_alloc(tee, value_size,
> >  TEE_SHM_ALLOC, _buf);
> > @@ -178,6 +186,9 @@ out:
> >   tee_shm_free(shm_buf);
> >  free_name:
> >   tee_shm_free(shm_name);
> > +close_session:
> > + tee_close_session(tee, session);
> > + tee = NULL;
> >
> >   return rc;
> >  }
> > --
> > 2.34.1
> >
>
> Thanks
> /Ilias


Please pull u-boot-samsung master

2024-04-04 Thread Minkyu Kang
Dear Tom,

The following changes since commit dde373bde392c38649c8c4420e0c98ef8d38d9dc:

  Prepare v2024.04-rc5 (2024-03-25 21:56:50 -0400)

are available in the git repository at:

  g...@source.denx.de:u-boot/custodians/u-boot-samsung.git master

for you to fetch changes up to 1751ba9a3b79ea5083ff5c4de58fe3bd9588f32a:

  clk: exynos: Add CMU_CORE and CMU_HSI for Exynos850 (2024-03-26 18:56:55
+0900)


Sam Protsenko (4):
  clk: exynos: Re-arrange clocks in Exynos850 CMU_TOP
  clk: exynos: Don't expose prototypes for not used functions
  clk: exynos: Fix incorrect clock lookup for non-top CMUs
  clk: exynos: Add CMU_CORE and CMU_HSI for Exynos850

 drivers/clk/exynos/clk-exynos850.c | 326
++---
 drivers/clk/exynos/clk-pll.c   |   6 +-
 drivers/clk/exynos/clk-pll.h   |   6 ++
 drivers/clk/exynos/clk.c   |  47 ++
 drivers/clk/exynos/clk.h   |  70 ++-
 5 files changed, 384 insertions(+), 71 deletions(-)

Thanks,
Minkyu Kang.




Re: [PATCH] soc: zynqmp: Add the IDcode for TEG variant

2024-04-04 Thread Michal Simek




On 4/2/24 16:23, Venkatesh Yadav Abbarapu wrote:

ID code is added for zu3teg variant.

Signed-off-by: Venkatesh Yadav Abbarapu 
---
  drivers/soc/soc_xilinx_zynqmp.c | 8 
  1 file changed, 8 insertions(+)

diff --git a/drivers/soc/soc_xilinx_zynqmp.c b/drivers/soc/soc_xilinx_zynqmp.c
index 786825d920..d8b4f172a3 100644
--- a/drivers/soc/soc_xilinx_zynqmp.c
+++ b/drivers/soc/soc_xilinx_zynqmp.c
@@ -44,6 +44,7 @@ enum {
ZYNQMP_VARIANT_DR = BIT(3),
ZYNQMP_VARIANT_DR_SE = BIT(4),
ZYNQMP_VARIANT_EG_SE = BIT(5),
+   ZYNQMP_VARIANT_TEG = BIT(6),
  };
  
  struct zynqmp_device {

@@ -74,6 +75,11 @@ static const struct zynqmp_device zynqmp_devices[] = {
.device = 3,
.variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG,
},
+   {
+   .id = 0x04718093,
+   .device = 3,
+   .variants = ZYNQMP_VARIANT_TEG,
+   },
{
.id = 0x04721093,
.device = 4,
@@ -299,6 +305,8 @@ static int soc_xilinx_zynqmp_detect_machine(struct udevice 
*dev, u32 idcode,
strlcat(priv->machine, "dr", sizeof(priv->machine));
} else if (device->variants & ZYNQMP_VARIANT_DR_SE) {
strlcat(priv->machine, "dr_SE", sizeof(priv->machine));
+   } else if (device->variants & ZYNQMP_VARIANT_TEG) {
+   strlcat(priv->machine, "teg", sizeof(priv->machine));
}
  
  	return 0;


Applied.
M


Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

2024-04-04 Thread Ilias Apalodimas
Hi Igor,

I was about to apply the series, but noticed neither me or Jens were cc'ed
on this. Adding Jens to the party

On Thu, Apr 04, 2024 at 10:13:49AM +0200, Igor Opaniuk wrote:
> Add calls for closing tee session after every read/write operation.

What the patch is pretty obvious, but I am missing an explanation of why
this is needed

>
> Signed-off-by: Igor Opaniuk 
> ---
>
> (no changes since v1)
>
>  cmd/optee_rpmb.c | 23 +--
>  1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
> index e0e44bbed04..b3cafd92410 100644
> --- a/cmd/optee_rpmb.c
> +++ b/cmd/optee_rpmb.c
> @@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
>
>   rc = tee_shm_alloc(tee, name_size,
>  TEE_SHM_ALLOC, _name);
> - if (rc)
> - return -ENOMEM;
> + if (rc) {
> + rc = -ENOMEM;
> + goto close_session;
> + }

I don't think you need the session to be opened to allocate memory.
So instead of of doing this, why don't we just move the alloc call before
opening the session?

>
>   rc = tee_shm_alloc(tee, buffer_size,
>  TEE_SHM_ALLOC, _buf);
> @@ -125,6 +127,9 @@ out:
>   tee_shm_free(shm_buf);
>  free_name:
>   tee_shm_free(shm_name);
> +close_session:
> + tee_close_session(tee, session);
> + tee = NULL;
>
>   return rc;
>  }
> @@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
>   struct tee_param param[2];
>   size_t name_size = strlen(name) + 1;
>
> + if (!value_size)
> + return -EINVAL;
> +
>   if (!tee) {
>   if (avb_ta_open_session())
>   return -ENODEV;
>   }
> - if (!value_size)
> - return -EINVAL;
>
>   rc = tee_shm_alloc(tee, name_size,
>  TEE_SHM_ALLOC, _name);
> - if (rc)
> - return -ENOMEM;
> + if (rc) {
> + rc = -ENOMEM;
> + goto close_session;
> + }

ditto

>
>   rc = tee_shm_alloc(tee, value_size,
>  TEE_SHM_ALLOC, _buf);
> @@ -178,6 +186,9 @@ out:
>   tee_shm_free(shm_buf);
>  free_name:
>   tee_shm_free(shm_name);
> +close_session:
> + tee_close_session(tee, session);
> + tee = NULL;
>
>   return rc;
>  }
> --
> 2.34.1
>

Thanks
/Ilias


Re: [PATCH v4 5/5] tee: remove common.h inclusion

2024-04-04 Thread Ilias Apalodimas
I've already reviewed this one. [0]
I'll add my tag

[0] 
https://lore.kernel.org/u-boot/CAC_iWjLZcKEo6-0P_gkz5UOe7VanuNv1+=i3xcutkvo5b1t...@mail.gmail.com/
Cheers
/Ilias
On Thu, 4 Apr 2024 at 11:14, Igor Opaniuk  wrote:
>
> The usage of the common.h include file is deprecated [1], and has already
> been removed from several files.
> Get rid of all inclusions in the "drivers/tee" directory, and replace it
> with required include files directly where needed.
>
> [1] doc/develop/codingstyle.rst
>
> Signed-off-by: Igor Opaniuk 
> ---
>
> (no changes since v3)
>
> Changes in v3:
> - Added calls for closing tee session after every read/write operation
> - Added calls for closing tee session after every read/write operation
>
> Changes in v2:
> - Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
> - Applied R-b and T-b tags
> - Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
>
>  drivers/tee/broadcom/chimp_optee.c | 3 ++-
>  drivers/tee/optee/core.c   | 1 -
>  drivers/tee/optee/i2c.c| 1 -
>  drivers/tee/optee/rpmb.c   | 1 -
>  drivers/tee/optee/supplicant.c | 2 +-
>  drivers/tee/sandbox.c  | 2 +-
>  drivers/tee/tee-uclass.c   | 1 -
>  7 files changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/tee/broadcom/chimp_optee.c 
> b/drivers/tee/broadcom/chimp_optee.c
> index 37f9b094f76..bd146ef2899 100644
> --- a/drivers/tee/broadcom/chimp_optee.c
> +++ b/drivers/tee/broadcom/chimp_optee.c
> @@ -3,9 +3,10 @@
>   * Copyright 2020 Broadcom.
>   */
>
> -#include 
>  #include 
>  #include 
> +#include 
> +#include 
>
>  #ifdef CONFIG_CHIMP_OPTEE
>
> diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> index 47f845cffe3..5fc0505c788 100644
> --- a/drivers/tee/optee/core.c
> +++ b/drivers/tee/optee/core.c
> @@ -3,7 +3,6 @@
>   * Copyright (c) 2018-2020 Linaro Limited
>   */
>
> -#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/tee/optee/i2c.c b/drivers/tee/optee/i2c.c
> index ef4e10f9912..e3fb99897c5 100644
> --- a/drivers/tee/optee/i2c.c
> +++ b/drivers/tee/optee/i2c.c
> @@ -3,7 +3,6 @@
>   * Copyright (c) 2020 Foundries.io Ltd
>   */
>
> -#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c
> index 5bc13757ea8..bacced6af6c 100644
> --- a/drivers/tee/optee/rpmb.c
> +++ b/drivers/tee/optee/rpmb.c
> @@ -3,7 +3,6 @@
>   * Copyright (c) 2018 Linaro Limited
>   */
>
> -#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/tee/optee/supplicant.c b/drivers/tee/optee/supplicant.c
> index f9dd874b594..8a426f53ba8 100644
> --- a/drivers/tee/optee/supplicant.c
> +++ b/drivers/tee/optee/supplicant.c
> @@ -3,10 +3,10 @@
>   * Copyright (c) 2018, Linaro Limited
>   */
>
> -#include 
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  #include "optee_msg.h"
> diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c
> index ec66401878c..8ad7c09efdd 100644
> --- a/drivers/tee/sandbox.c
> +++ b/drivers/tee/sandbox.c
> @@ -2,7 +2,7 @@
>  /*
>   * Copyright (C) 2018 Linaro Limited
>   */
> -#include 
> +
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/tee/tee-uclass.c b/drivers/tee/tee-uclass.c
> index 52412a4098e..0194d732193 100644
> --- a/drivers/tee/tee-uclass.c
> +++ b/drivers/tee/tee-uclass.c
> @@ -5,7 +5,6 @@
>
>  #define LOG_CATEGORY UCLASS_TEE
>
> -#include 
>  #include 
>  #include 
>  #include 
> --
> 2.34.1
>


Re: [PATCH 2/2] arm: dts: k3: binman: am625: add support for signing TIFSSTUB Images

2024-04-04 Thread Dhruva Gole
Hi Neha!

On Apr 04, 2024 at 10:20:21 +0530, Neha Malcom Francis wrote:
> Hi Dhruva
> 
> On 03/04/24 17:33, Dhruva Gole wrote:
> > From: Kamlesh Gurudasani 
> > 
> > Add support for signing of TIFSSTUB images for HSSE, HSFS and GP devices
> > and include them in tispl.bin and tispl.bin_unsigned.
> > 
> > Signed-off-by: Kamlesh Gurudasani 
> > Signed-off-by: Dhruva Gole 
> > ---
> >   arch/arm/dts/k3-am625-sk-binman.dtsi | 141 ++-
> >   1 file changed, 139 insertions(+), 2 deletions(-)
> > 
[...]
> > dm {
> > ti-dm {
> > filename = "ti-dm.bin";
> > @@ -270,7 +406,8 @@
> > conf-0 {
> > description = "k3-am625-sk";
> > firmware = "atf";
> > -   loadables = "tee", "dm", "spl";
> > +   loadables = "tee", "tifsstub-hs", 
> > "tifsstub-fs",
> > + "tifsstub-gp", "dm", "spl";
> > fdt = "fdt-0";
> > };
> > };
> 
> 
> If there are multiple boards that will support TIFSSTUB in future, I would
> prefer templating these out and putting them in k3-binman.dtsi. However

That's a great idea. From the next set of boards for which also need
binman TIFS Stub support we will keep in mind as you said below.
Currently amidst all the movement and cleanup I don't want to push out
too many changes at once.

I also have cleanup and OF_UPSTREAM changes for am62x pending which I
plan on posting sometime soon..

> considering there's a lot of movement currently (cleanup and OF_STREAM) in
> that file, you can maybe take this up when adding support for the next
> board.
> 
> Reviewed-by: Neha Malcom Francis 

Thanks!

-- 
Best regards,
Dhruva Gole 


Re: [PATCH v4 0/5] TEE: minor cleanup

2024-04-04 Thread Ilias Apalodimas
Thanks Igor

I'll pick this up

On Thu, 4 Apr 2024 at 11:13, Igor Opaniuk  wrote:
>
> - Address some spelling errors and typos
> - Support CMD_OPTEE_RPMB for SANDBOX configurations and add python tests
> - Remove common.h inclusion for drivers/tee
> - Add calls for closing tee session after every read/write operation.
>
> CI build:
> [1] 
> https://dev.azure.com/igoropaniuk/u-boot/_build/results?buildId=31=results
>
> Changes in v4:
> - Rebased on the latest master and excluded "tee: sandbox: fix spelling 
> errors",
>   as it was merged already by Heinrich Schuchardt
>
> Changes in v3:
> - Added calls for closing tee session after every read/write operation
>
> Changes in v2:
> - Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
> - Applied R-b and T-b tags
>
> Igor Opaniuk (5):
>   tee: optee: fix description in Kconfig
>   cmd: optee_rpmb: close tee session
>   cmd: optee_rpmb: build cmd for sandbox
>   test: py: add optee_rpmb tests
>   tee: remove common.h inclusion
>
>  cmd/Kconfig|  4 +++-
>  cmd/optee_rpmb.c   | 23 +--
>  drivers/tee/broadcom/chimp_optee.c |  3 ++-
>  drivers/tee/optee/Kconfig  |  2 +-
>  drivers/tee/optee/core.c   |  1 -
>  drivers/tee/optee/i2c.c|  1 -
>  drivers/tee/optee/rpmb.c   |  1 -
>  drivers/tee/optee/supplicant.c |  2 +-
>  drivers/tee/sandbox.c  |  2 +-
>  drivers/tee/tee-uclass.c   |  1 -
>  test/py/tests/test_optee_rpmb.py   | 20 
>  11 files changed, 45 insertions(+), 15 deletions(-)
>  create mode 100644 test/py/tests/test_optee_rpmb.py
>
> --
> 2.34.1
>


[PATCH v4 5/5] tee: remove common.h inclusion

2024-04-04 Thread Igor Opaniuk
The usage of the common.h include file is deprecated [1], and has already
been removed from several files.
Get rid of all inclusions in the "drivers/tee" directory, and replace it
with required include files directly where needed.

[1] doc/develop/codingstyle.rst

Signed-off-by: Igor Opaniuk 
---

(no changes since v3)

Changes in v3:
- Added calls for closing tee session after every read/write operation
- Added calls for closing tee session after every read/write operation

Changes in v2:
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
- Applied R-b and T-b tags
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'

 drivers/tee/broadcom/chimp_optee.c | 3 ++-
 drivers/tee/optee/core.c   | 1 -
 drivers/tee/optee/i2c.c| 1 -
 drivers/tee/optee/rpmb.c   | 1 -
 drivers/tee/optee/supplicant.c | 2 +-
 drivers/tee/sandbox.c  | 2 +-
 drivers/tee/tee-uclass.c   | 1 -
 7 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/tee/broadcom/chimp_optee.c 
b/drivers/tee/broadcom/chimp_optee.c
index 37f9b094f76..bd146ef2899 100644
--- a/drivers/tee/broadcom/chimp_optee.c
+++ b/drivers/tee/broadcom/chimp_optee.c
@@ -3,9 +3,10 @@
  * Copyright 2020 Broadcom.
  */
 
-#include 
 #include 
 #include 
+#include 
+#include 
 
 #ifdef CONFIG_CHIMP_OPTEE
 
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 47f845cffe3..5fc0505c788 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -3,7 +3,6 @@
  * Copyright (c) 2018-2020 Linaro Limited
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/tee/optee/i2c.c b/drivers/tee/optee/i2c.c
index ef4e10f9912..e3fb99897c5 100644
--- a/drivers/tee/optee/i2c.c
+++ b/drivers/tee/optee/i2c.c
@@ -3,7 +3,6 @@
  * Copyright (c) 2020 Foundries.io Ltd
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c
index 5bc13757ea8..bacced6af6c 100644
--- a/drivers/tee/optee/rpmb.c
+++ b/drivers/tee/optee/rpmb.c
@@ -3,7 +3,6 @@
  * Copyright (c) 2018 Linaro Limited
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/tee/optee/supplicant.c b/drivers/tee/optee/supplicant.c
index f9dd874b594..8a426f53ba8 100644
--- a/drivers/tee/optee/supplicant.c
+++ b/drivers/tee/optee/supplicant.c
@@ -3,10 +3,10 @@
  * Copyright (c) 2018, Linaro Limited
  */
 
-#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "optee_msg.h"
diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c
index ec66401878c..8ad7c09efdd 100644
--- a/drivers/tee/sandbox.c
+++ b/drivers/tee/sandbox.c
@@ -2,7 +2,7 @@
 /*
  * Copyright (C) 2018 Linaro Limited
  */
-#include 
+
 #include 
 #include 
 #include 
diff --git a/drivers/tee/tee-uclass.c b/drivers/tee/tee-uclass.c
index 52412a4098e..0194d732193 100644
--- a/drivers/tee/tee-uclass.c
+++ b/drivers/tee/tee-uclass.c
@@ -5,7 +5,6 @@
 
 #define LOG_CATEGORY UCLASS_TEE
 
-#include 
 #include 
 #include 
 #include 
-- 
2.34.1



[PATCH v4 4/5] test: py: add optee_rpmb tests

2024-04-04 Thread Igor Opaniuk
Add read/write tests for optee_rpmb cmd.

Signed-off-by: Igor Opaniuk 
---

(no changes since v1)

 test/py/tests/test_optee_rpmb.py | 20 
 1 file changed, 20 insertions(+)
 create mode 100644 test/py/tests/test_optee_rpmb.py

diff --git a/test/py/tests/test_optee_rpmb.py b/test/py/tests/test_optee_rpmb.py
new file mode 100644
index 000..8a081b5c494
--- /dev/null
+++ b/test/py/tests/test_optee_rpmb.py
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier:  GPL-2.0+
+#
+# Tests for OP-TEE RPMB read/write support
+
+"""
+This tests optee_rpmb cmd in U-Boot
+"""
+
+import pytest
+import u_boot_utils as util
+
+@pytest.mark.buildconfigspec('cmd_optee_rpmb')
+def test_optee_rpmb_read_write(u_boot_console):
+"""Test OP-TEE RPMB cmd read/write
+"""
+response = u_boot_console.run_command('optee_rpmb write_pvalue 
test_variable test_value')
+assert response == 'Wrote 11 bytes'
+
+response = u_boot_console.run_command('optee_rpmb read_pvalue 
test_variable 11')
+assert response == 'Read 11 bytes, value = test_value'
\ No newline at end of file
-- 
2.34.1



[PATCH v4 3/5] cmd: optee_rpmb: build cmd for sandbox

2024-04-04 Thread Igor Opaniuk
Support CMD_OPTEE_RPMB for SANDBOX configurations.
Test:

$ ./u-boot -d arch/sandbox/dts/test.dtb
...
=> optee_rpmb write_pvalue test_variable test_value
Wrote 11 bytes
=> optee_rpmb read_pvalue test_variable 11
Read 11 bytes, value = test_value

Reviewed-by: Mattijs Korpershoek 
Tested-by: Mattijs Korpershoek 
Signed-off-by: Igor Opaniuk 
---

(no changes since v2)

Changes in v2:
- Applied R-b and T-b tags

 cmd/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 61e280fb1a4..227d66a7eea 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1394,7 +1394,9 @@ config CMD_CLONE
 
 config CMD_OPTEE_RPMB
bool "Enable read/write support on RPMB via OPTEE"
-   depends on SUPPORT_EMMC_RPMB && OPTEE
+   depends on (SUPPORT_EMMC_RPMB && OPTEE) || SANDBOX_TEE
+   default y if SANDBOX_TEE
+   select OPTEE_TA_AVB if SANDBOX_TEE
help
  Enable the commands for reading, writing persistent named values
  in the Replay Protection Memory Block partition in eMMC by
-- 
2.34.1



[PATCH v4 2/5] cmd: optee_rpmb: close tee session

2024-04-04 Thread Igor Opaniuk
Add calls for closing tee session after every read/write operation.

Signed-off-by: Igor Opaniuk 
---

(no changes since v1)

 cmd/optee_rpmb.c | 23 +--
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
index e0e44bbed04..b3cafd92410 100644
--- a/cmd/optee_rpmb.c
+++ b/cmd/optee_rpmb.c
@@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
 
rc = tee_shm_alloc(tee, name_size,
   TEE_SHM_ALLOC, _name);
-   if (rc)
-   return -ENOMEM;
+   if (rc) {
+   rc = -ENOMEM;
+   goto close_session;
+   }
 
rc = tee_shm_alloc(tee, buffer_size,
   TEE_SHM_ALLOC, _buf);
@@ -125,6 +127,9 @@ out:
tee_shm_free(shm_buf);
 free_name:
tee_shm_free(shm_name);
+close_session:
+   tee_close_session(tee, session);
+   tee = NULL;
 
return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
struct tee_param param[2];
size_t name_size = strlen(name) + 1;
 
+   if (!value_size)
+   return -EINVAL;
+
if (!tee) {
if (avb_ta_open_session())
return -ENODEV;
}
-   if (!value_size)
-   return -EINVAL;
 
rc = tee_shm_alloc(tee, name_size,
   TEE_SHM_ALLOC, _name);
-   if (rc)
-   return -ENOMEM;
+   if (rc) {
+   rc = -ENOMEM;
+   goto close_session;
+   }
 
rc = tee_shm_alloc(tee, value_size,
   TEE_SHM_ALLOC, _buf);
@@ -178,6 +186,9 @@ out:
tee_shm_free(shm_buf);
 free_name:
tee_shm_free(shm_name);
+close_session:
+   tee_close_session(tee, session);
+   tee = NULL;
 
return rc;
 }
-- 
2.34.1



[PATCH v4 1/5] tee: optee: fix description in Kconfig

2024-04-04 Thread Igor Opaniuk
Fix OPTEE_TA_AVB symbol description in Kconfig:
s/"write"rb"/"write_rb"/g

Reviewed-by: Heinrich Schuchardt 
Reviewed-by: Ilias Apalodimas 
Signed-off-by: Igor Opaniuk 
---

(no changes since v2)

Changes in v2:
- Applied R-b tags

 drivers/tee/optee/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig
index 9dc65b0501e..db0bcfa6f15 100644
--- a/drivers/tee/optee/Kconfig
+++ b/drivers/tee/optee/Kconfig
@@ -19,7 +19,7 @@ config OPTEE_TA_AVB
default y
help
  Enables support for the AVB Trusted Application (TA) in OP-TEE.
- The TA can support the "avb" subcommands "read_rb", "write"rb"
+ The TA can support the "avb" subcommands "read_rb", "write_rb"
  and "is_unlocked".
 
 config OPTEE_TA_RPC_TEST
-- 
2.34.1



[PATCH v4 0/5] TEE: minor cleanup

2024-04-04 Thread Igor Opaniuk
- Address some spelling errors and typos
- Support CMD_OPTEE_RPMB for SANDBOX configurations and add python tests
- Remove common.h inclusion for drivers/tee
- Add calls for closing tee session after every read/write operation.

CI build:
[1] 
https://dev.azure.com/igoropaniuk/u-boot/_build/results?buildId=31=results

Changes in v4:
- Rebased on the latest master and excluded "tee: sandbox: fix spelling errors",
  as it was merged already by Heinrich Schuchardt

Changes in v3:
- Added calls for closing tee session after every read/write operation

Changes in v2:
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
- Applied R-b and T-b tags

Igor Opaniuk (5):
  tee: optee: fix description in Kconfig
  cmd: optee_rpmb: close tee session
  cmd: optee_rpmb: build cmd for sandbox
  test: py: add optee_rpmb tests
  tee: remove common.h inclusion

 cmd/Kconfig|  4 +++-
 cmd/optee_rpmb.c   | 23 +--
 drivers/tee/broadcom/chimp_optee.c |  3 ++-
 drivers/tee/optee/Kconfig  |  2 +-
 drivers/tee/optee/core.c   |  1 -
 drivers/tee/optee/i2c.c|  1 -
 drivers/tee/optee/rpmb.c   |  1 -
 drivers/tee/optee/supplicant.c |  2 +-
 drivers/tee/sandbox.c  |  2 +-
 drivers/tee/tee-uclass.c   |  1 -
 test/py/tests/test_optee_rpmb.py   | 20 
 11 files changed, 45 insertions(+), 15 deletions(-)
 create mode 100644 test/py/tests/test_optee_rpmb.py

-- 
2.34.1



Re: [PATCH 2/2] arm: dts: k3: binman: am625: add support for signing TIFSSTUB Images

2024-04-04 Thread Francesco Dolcini
On Thu, Apr 04, 2024 at 10:20:21AM +0530, Neha Malcom Francis wrote:
> On 03/04/24 17:33, Dhruva Gole wrote:
> > From: Kamlesh Gurudasani 
> > 
> > Add support for signing of TIFSSTUB images for HSSE, HSFS and GP devices
> > and include them in tispl.bin and tispl.bin_unsigned.
> > 
> > Signed-off-by: Kamlesh Gurudasani 
> > Signed-off-by: Dhruva Gole 

[...]

> > @@ -270,7 +406,8 @@
> > conf-0 {
> > description = "k3-am625-sk";
> > firmware = "atf";
> > -   loadables = "tee", "dm", "spl";
> > +   loadables = "tee", "tifsstub-hs", 
> > "tifsstub-fs",
> > + "tifsstub-gp", "dm", "spl";
> > fdt = "fdt-0";
> > };
> > };
> 
> 
> If there are multiple boards that will support TIFSSTUB in future, I would

I would assume that this will be the case. Verdin AM62 would need the
same, for example.

Francesco



Re: [PATCH 3/4] arm: dts: k3-*-binman.dtsi: Clean up and templatize boot binaries

2024-04-04 Thread Matthias Schiffer
On Wed, 2024-04-03 at 17:51 +0200, Michael Walle wrote:
> Hi,
> 
> > > > > > And on top of that, it will just be a base board and there will
> > > > > > likely be some carrier device trees (overlay? I'm not sure yet).
> > > > > > 
> > > > > > As far as I can tell, you've put the memory configuration into the
> > > > > > device tree, so I'll probably need to switch between them somehow.
> > > > > 
> > > > > The "k3--ddr.dtsi" file will be present in your k3-r5.dts
> > > > > which makes sense, the memory configuration depends on the board.
> > > > 
> > > 
> > > k3--ddr.dtsi* (e.g J721E EVM vs. SK boards consume different memory
> > > configurations.
> 
> Right.
> 
> > > > And one board might have multiple configuration depending on the
> > > > variant of the board. Typically, one board is available with
> > > > different memory options. i.e. 1GiB, 4GiB and so on. The actual RAM
> > > > chips can come from different manufacturers. So all all, I presume
> > > > there will be different RAM settings, i.e. different
> > > > k3--ddr.dtsi. But I have to switch between the setting during
> > > > runtime because there will be only one boot image for that board.
> > > 
> > > This is a runtime dynamic DDR configuration support you are describing
> > > correct? This means you would be including all the supported memory option
> > > DTSIs in your k3--r5.dts correct and probably do some board magic
> > > code in the SPL DDR driver to choose the DTB. How is this affecting the
> > > packing of the final bootloader which will anyways pack the whole R5 DTB?
> 
> Correct, the DDR configuration should be chosen at runtime after
> reading some board strappings. Unless, it will work with with the
> same configuration which seems unlikely to me. But it is not an
> unusual configuration I'd say.
> 
> I haven't looked into this in detail, but to me it seems not that
> obvious how to do that in a generic/upstreamable way. Multiple
> device nodes sounds wrong. Thus, I'd likely need different device
> trees for the different memory configurations for the R5 SPL. Not
> sure that is yet possible with u-boot, though. If you have any
> better idea, I'm all ears.
> 
> > > > > > Also, regarding the board variants, I'll probably need to choose
> > > > > > between multiple device trees. That is invisible to the user,
> > > > > > because u-boot will choose the correct DTB according a board
> > > > > > strapping, which btw. works really fine, see for example
> > > > > > (boards/kontron/sl28/spl.c:board_fit_config_name_match).
> > > > > 
> > > > > Again, this is assuming that there is some HW blown register available
> > > > > for the board to use (or in our earlier K3 case, the EEPROM) but that 
> > > > > is
> > > > > not necessarily true every time.
> > > > 
> > > > No, that is of course board dependent. It is just an example that
> > > > there are boards with more than one DTB.
> > > > 
> > > > Let's step back a bit. Right now, there is
> > > >k3---binman.dtsi
> > > > which is fine. But it seems, that TI is heading towards a common
> > > >k3--binman.dtsi
> > > > which is intended to be used by all the boards that are using that
> > > > particular SoC, correct me if I'm wrong here. Now the problem with
> > > > that is that you hardcode the FIT configuations which are really
> > > > board dependent and assume that there will be exactly one DTB per
> > > > board, i.e. your "#define SPL_BOARD_DTB" etc.
> > > > 
> > > 
> > > Correct, but as I mentioned in the earlier message, if your board supports
> > > more than 1 FIT configuration, you can easily extend the image and add 
> > > more
> > > configurations.
> > > 
> > > > Thus, what I was trying to say is that you should split all the
> > > > board independent configuration (dt fragments) from the board
> > > > specific configuration.
> > > > 
> > > > And again, of course I could just ignore the k3--binman.dtsi
> > > > and just use a suitable copy "k3---binman.dtsi" for my
> > > > board. But as I said, I'm not sure, this is the way to go and I have
> > > > a slight feeling I will be asked to reuse the "k3--binman.dtsi"
> > > > when I submit my board support.
> > > > 
> > > > > > 
> > > > > > I don't think it makes much sense to hardcode your generic
> > > > > > *-binman.dtsi to just one FIT configuration. I'd rather see a split
> > > > > > between generic things which are shared across all boards and board
> > > > > > specifics, like the FIT configuration. I mean I could just copy all
> > > > > 
> > > > > Correct me if I'm wrong, but my understanding is that you would want 
> > > > > to
> > > > > add more FDT blobs in the *-binman.dtsi correct? That is still 
> > > > > possible,
> > > > > adding another "fdt-1" and "conf-1" in the
> > > > > 
> > > > > Something like this in your -u-boot.dtsi,
> > > > > 
> > > > > tispl {
> > > > >   insert-template = <_spl>;
> > > > >   fit {
> > > > >   images {
> > > > >   fdt-1 {
> > > > >  

[PATCH u-boot-mvebu v4 18/18] arm: mvebu: turris_omnia: Enable rng command in defconfig

2024-04-04 Thread Marek Behún
Now that Turris Omnia has a rng driver provided in the MCU driver,
enable the rng command in defconfig.

Signed-off-by: Marek Behún 
Reviewed-by: Stefan Roese 
---
 configs/turris_omnia_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 4c21635ec9..f2b39115fe 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -73,6 +73,7 @@ CONFIG_CMD_WDT=y
 CONFIG_CMD_TFTPPUT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_RNG=y
 CONFIG_CMD_AES=y
 CONFIG_CMD_HASH=y
 CONFIG_CMD_BTRFS=y
-- 
2.43.2



[PATCH u-boot-mvebu v4 17/18] misc: turris_omnia_mcu: Add support for rng provided by MCU

2024-04-04 Thread Marek Behún
Add support for true random number generator provided by the MCU on
Turris Omnia. The MCU firmware supports TRNG if the FEAT_TRNG bit is set
in features. In that case we bind the rng driver.

Signed-off-by: Marek Behún 
Reviewed-by: Stefan Roese 
---
 configs/turris_omnia_defconfig  |  1 +
 drivers/misc/Kconfig|  1 +
 drivers/misc/turris_omnia_mcu.c | 57 +
 3 files changed, 59 insertions(+)

diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 0df0f3c90b..4c21635ec9 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -107,6 +107,7 @@ CONFIG_NVME_PCI=y
 CONFIG_PCI_MVEBU=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_ARMADA_38X=y
+CONFIG_DM_RNG=y
 CONFIG_DM_RTC=y
 CONFIG_RTC_ARMADA38X=y
 CONFIG_SERIAL_PROBE_ALL=y
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 041de538fa..6b06888454 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -509,6 +509,7 @@ config TURRIS_OMNIA_MCU
bool "Enable Turris Omnia MCU driver"
depends on DM_I2C
depends on DM_GPIO
+   depends on DM_RNG
depends on SYSRESET
default y if TARGET_TURRIS_OMNIA
help
diff --git a/drivers/misc/turris_omnia_mcu.c b/drivers/misc/turris_omnia_mcu.c
index 77a0424d61..6b2f17c000 100644
--- a/drivers/misc/turris_omnia_mcu.c
+++ b/drivers/misc/turris_omnia_mcu.c
@@ -5,15 +5,20 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
+#define CMD_TRNG_MAX_ENTROPY_LEN   64
+
 struct turris_omnia_mcu_info {
u32 features;
 };
@@ -282,6 +287,49 @@ U_BOOT_DRIVER(turris_omnia_mcu_sysreset) = {
.ops= _sysreset_ops,
 };
 
+static int omnia_rng_read(struct udevice *dev, void *data, size_t count)
+{
+   u8 buf[1 + CMD_TRNG_MAX_ENTROPY_LEN];
+   size_t len;
+   int ret;
+
+   while (count) {
+   ret = dm_i2c_read(dev->parent, CMD_TRNG_COLLECT_ENTROPY, buf,
+ sizeof(buf));
+   if (ret)
+   return ret;
+
+   len = min_t(size_t, buf[0],
+   min_t(size_t, CMD_TRNG_MAX_ENTROPY_LEN, count));
+
+   if (!len) {
+   /* wait 500ms (fail if interrupted), then try again */
+   for (int i = 0; i < 5; ++i) {
+   mdelay(100);
+   if (ctrlc())
+   return -EINTR;
+   }
+   continue;
+   }
+
+   memcpy(data, [1], len);
+   data += len;
+   count -= len;
+   }
+
+   return 0;
+}
+
+static const struct dm_rng_ops omnia_rng_ops = {
+   .read   = omnia_rng_read,
+};
+
+U_BOOT_DRIVER(turris_omnia_mcu_trng) = {
+   .name   = "turris-omnia-mcu-trng",
+   .id = UCLASS_RNG,
+   .ops= _rng_ops,
+};
+
 static int turris_omnia_mcu_bind(struct udevice *dev)
 {
/* bind MCU GPIOs as a child device */
@@ -336,6 +384,15 @@ static int turris_omnia_mcu_probe(struct udevice *dev)
return ret;
}
 
+   /* bind rng if trng is supported */
+   if (info->features & FEAT_TRNG) {
+   ret = device_bind_driver_to_node(dev, "turris-omnia-mcu-trng",
+"turris-omnia-mcu-trng",
+dev_ofnode(dev), NULL);
+   if (ret < 0)
+   return ret;
+   }
+
return 0;
 }
 
-- 
2.43.2



[PATCH u-boot-mvebu v4 16/18] cmd: rng: Print "Abort" on -EINTR

2024-04-04 Thread Marek Behún
In the rng command, print
  Abort
instead of
  Reading RNG failed
if the error number is -EINTR, which can happen if the user pressed
CTRL-C.

Signed-off-by: Marek Behún 
Reviewed-by: Stefan Roese 
---
 cmd/rng.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/cmd/rng.c b/cmd/rng.c
index b073a6c849..e5ab868112 100644
--- a/cmd/rng.c
+++ b/cmd/rng.c
@@ -17,7 +17,7 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
u8 buf[64];
int devnum;
struct udevice *dev;
-   int ret = CMD_RET_SUCCESS;
+   int ret = CMD_RET_SUCCESS, err;
 
if (argc == 2 && !strcmp(argv[1], "list")) {
int idx = 0;
@@ -62,8 +62,9 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
 
n = min(n, sizeof(buf));
 
-   if (dm_rng_read(dev, buf, n)) {
-   printf("Reading RNG failed\n");
+   err = dm_rng_read(dev, buf, n);
+   if (err) {
+   puts(err == -EINTR ? "Abort\n" : "Reading RNG failed\n");
ret = CMD_RET_FAILURE;
} else {
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, n);
-- 
2.43.2



[PATCH u-boot-mvebu v4 15/18] arm: mvebu: turris_omnia: Enable poweroff command via sysreset in defconfig

2024-04-04 Thread Marek Behún
Enable support for the poweroff command via sysreset for Turris Omnia.

Signed-off-by: Marek Behún 
Reviewed-by: Stefan Roese 
---
 configs/turris_omnia_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 9d5171c6a8..0df0f3c90b 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -65,6 +65,7 @@ CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_MTD=y
 CONFIG_CMD_PCI=y
+CONFIG_CMD_POWEROFF=y
 CONFIG_CMD_SATA=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
@@ -114,6 +115,7 @@ CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYS_NS16550=y
 CONFIG_KIRKWOOD_SPI=y
 CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_POWEROFF=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
-- 
2.43.2



[PATCH u-boot-mvebu v4 14/18] gpio: turris_omnia_mcu: Add support for system power off via sysreset

2024-04-04 Thread Marek Behún
Add support for system power off via UCLASS_SYSRESET. Newer versions of
Turris Omnia MCU firmware can power off the board (MCU will disable
almost all voltage regulators and go into low power mode).

Move the MCU driver into drivers/misc and register it under UCLASS_MISC.
The sysreset and gpio device are bound as child devices of the MCU device.

Signed-off-by: Marek Behún 
Reviewed-by: Stefan Roese 
---
 configs/turris_omnia_defconfig|   1 +
 drivers/gpio/Kconfig  |   7 -
 drivers/gpio/Makefile |   1 -
 drivers/misc/Kconfig  |  10 ++
 drivers/misc/Makefile |   1 +
 drivers/{gpio => misc}/turris_omnia_mcu.c | 150 --
 6 files changed, 120 insertions(+), 50 deletions(-)
 rename drivers/{gpio => misc}/turris_omnia_mcu.c (60%)

diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 39e15043df..9d5171c6a8 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -113,6 +113,7 @@ CONFIG_SPL_DEBUG_UART_BASE=0xd0012000
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYS_NS16550=y
 CONFIG_KIRKWOOD_SPI=y
+CONFIG_SYSRESET=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index a7fb1eb3f4..b050585389 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -665,13 +665,6 @@ config SLG7XL45106_I2C_GPO
   8-bit gpo expander, all gpo lines are controlled by writing
   value into data register.
 
-config TURRIS_OMNIA_MCU
-   bool "Turris Omnia MCU GPIO driver"
-   depends on DM_GPIO
-   default y if TARGET_TURRIS_OMNIA
-   help
-  Support for GPIOs on MCU connected to Turris Omnia via i2c.
-
 config FTGPIO010
bool "Faraday Technology FTGPIO010 driver"
depends on DM_GPIO
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 90711702a6..4a29315435 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -73,7 +73,6 @@ obj-$(CONFIG_$(SPL_)MAX77663_GPIO)+= max77663_gpio.o
 obj-$(CONFIG_SL28CPLD_GPIO)+= sl28cpld-gpio.o
 obj-$(CONFIG_ZYNQMP_GPIO_MODEPIN)  += zynqmp_gpio_modepin.o
 obj-$(CONFIG_SLG7XL45106_I2C_GPO)  += gpio_slg7xl45106.o
-obj-$(CONFIG_$(SPL_TPL_)TURRIS_OMNIA_MCU)  += turris_omnia_mcu.o
 obj-$(CONFIG_FTGPIO010)+= ftgpio010.o
 obj-$(CONFIG_ADP5585_GPIO) += adp5585_gpio.o
 obj-$(CONFIG_RZG2L_GPIO)   += rzg2l-gpio.o
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 98043fc2ff..041de538fa 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -505,6 +505,16 @@ config TEST_DRV
  model. This should only be enabled for testing as it is not useful for
  anything else.
 
+config TURRIS_OMNIA_MCU
+   bool "Enable Turris Omnia MCU driver"
+   depends on DM_I2C
+   depends on DM_GPIO
+   depends on SYSRESET
+   default y if TARGET_TURRIS_OMNIA
+   help
+ This enables support for Turris Omnia MCU connected GPIOs and
+ board power off.
+
 config USB_HUB_USB251XB
tristate "USB251XB Hub Controller Configuration Driver"
depends on I2C
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 1522f6c3b7..9e829905f1 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -81,6 +81,7 @@ obj-$(CONFIG_SYS_DPAA_QBMAN) += fsl_portals.o
 obj-$(CONFIG_TEGRA186_BPMP) += tegra186_bpmp.o
 obj-$(CONFIG_TEGRA_CAR) += tegra_car.o
 obj-$(CONFIG_TEST_DRV) += test_drv.o
+obj-$(CONFIG_$(SPL_TPL_)TURRIS_OMNIA_MCU) += turris_omnia_mcu.o
 obj-$(CONFIG_TWL4030_LED) += twl4030_led.o
 obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress_config.o
 obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
diff --git a/drivers/gpio/turris_omnia_mcu.c b/drivers/misc/turris_omnia_mcu.c
similarity index 60%
rename from drivers/gpio/turris_omnia_mcu.c
rename to drivers/misc/turris_omnia_mcu.c
index 40ced261e3..77a0424d61 100644
--- a/drivers/gpio/turris_omnia_mcu.c
+++ b/drivers/misc/turris_omnia_mcu.c
@@ -1,9 +1,14 @@
 // SPDX-License-Identifier: GPL-2.0+
-// (C) 2022 Pali Rohár 
+/*
+ * Copyright (C) 2022 Pali Rohár 
+ * Copyright (C) 2024 Marek Behún 
+ */
 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -13,9 +18,9 @@ struct turris_omnia_mcu_info {
u32 features;
 };
 
-static int turris_omnia_mcu_get_function(struct udevice *dev, uint offset)
+static int omnia_gpio_get_function(struct udevice *dev, uint offset)
 {
-   struct turris_omnia_mcu_info *info = dev_get_plat(dev);
+   struct turris_omnia_mcu_info *info = dev_get_priv(dev->parent);
 
switch (offset) {
/* bank 0 */
@@ -49,9 +54,9 @@ static int turris_omnia_mcu_get_function(struct udevice *dev, 
uint offset)
}
 }
 
-static int turris_omnia_mcu_get_value(struct udevice *dev, uint offset)
+static int omnia_gpio_get_value(struct udevice *dev, uint offset)
 {
-   struct 

[PATCH u-boot-mvebu v4 13/18] gpio: turris_omnia_mcu: Update firmware features reading

2024-04-04 Thread Marek Behún
Update firmware features reading to try reading 32 bits of features and
fallback to reading 16 bits.

Signed-off-by: Marek Behún 
Reviewed-by: Stefan Roese 
---
 drivers/gpio/turris_omnia_mcu.c | 32 ++--
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/turris_omnia_mcu.c b/drivers/gpio/turris_omnia_mcu.c
index c441d07d69..40ced261e3 100644
--- a/drivers/gpio/turris_omnia_mcu.c
+++ b/drivers/gpio/turris_omnia_mcu.c
@@ -10,7 +10,7 @@
 #include 
 
 struct turris_omnia_mcu_info {
-   u16 features;
+   u32 features;
 };
 
 static int turris_omnia_mcu_get_function(struct udevice *dev, uint offset)
@@ -228,25 +228,37 @@ static int turris_omnia_mcu_probe(struct udevice *dev)
 {
struct turris_omnia_mcu_info *info = dev_get_plat(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
-   u16 val;
+   u32 dword;
+   u16 word;
int ret;
 
-   ret = dm_i2c_read(dev, CMD_GET_STATUS_WORD, (void *), sizeof(val));
+   ret = dm_i2c_read(dev, CMD_GET_STATUS_WORD, (void *), 
sizeof(word));
if (ret < 0) {
printf("Error: turris_omnia_mcu CMD_GET_STATUS_WORD failed: 
%d\n",
   ret);
return ret;
}
 
-   if (le16_to_cpu(val) & STS_FEATURES_SUPPORTED) {
-   ret = dm_i2c_read(dev, CMD_GET_FEATURES, (void *),
- sizeof(val));
+   if (le16_to_cpu(word) & STS_FEATURES_SUPPORTED) {
+   /* try read 32-bit features */
+   ret = dm_i2c_read(dev, CMD_GET_FEATURES, (void *),
+ sizeof(dword));
if (ret < 0) {
-   printf("Error: turris_omnia_mcu CMD_GET_FEATURES 
failed: %d\n",
-  ret);
-   return ret;
+   /* try read 16-bit features */
+   ret = dm_i2c_read(dev, CMD_GET_FEATURES, (void *),
+ sizeof(word));
+   if (ret < 0) {
+   printf("Error: turris_omnia_mcu 
CMD_GET_FEATURES failed: %d\n",
+  ret);
+   return ret;
+   }
+
+   info->features = le16_to_cpu(word);
+   } else {
+   info->features = le32_to_cpu(dword);
+   if (info->features & FEAT_FROM_BIT_16_INVALID)
+   info->features &= GENMASK(15, 0);
}
-   info->features = le16_to_cpu(val);
}
 
uc_priv->bank_name = "mcu_";
-- 
2.43.2



[PATCH u-boot-mvebu v4 12/18] gpio: turris_omnia_mcu: Use byteorder conversion functions

2024-04-04 Thread Marek Behún
Use byteorder conversion function instead of manually assembling data
from/to MCU.

Signed-off-by: Marek Behún 
Reviewed-by: Stefan Roese 
---
 drivers/gpio/turris_omnia_mcu.c | 80 +++--
 1 file changed, 46 insertions(+), 34 deletions(-)

diff --git a/drivers/gpio/turris_omnia_mcu.c b/drivers/gpio/turris_omnia_mcu.c
index da9a6efe6d..c441d07d69 100644
--- a/drivers/gpio/turris_omnia_mcu.c
+++ b/drivers/gpio/turris_omnia_mcu.c
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -51,27 +52,31 @@ static int turris_omnia_mcu_get_function(struct udevice 
*dev, uint offset)
 static int turris_omnia_mcu_get_value(struct udevice *dev, uint offset)
 {
struct turris_omnia_mcu_info *info = dev_get_plat(dev);
-   u8 val16[2];
-   u8 val32[4];
+   u32 val32;
+   u16 val16;
int ret;
 
switch (offset) {
/* bank 0 */
case 0 ... 15:
-   ret = dm_i2c_read(dev, CMD_GET_STATUS_WORD, val16, 2);
+   ret = dm_i2c_read(dev, CMD_GET_STATUS_WORD, (void *),
+ sizeof(val16));
if (ret)
return ret;
-   return u16)val16[1] << 8) | val16[0]) >> offset) & 0x1;
+
+   return !!(le16_to_cpu(val16) & BIT(offset));
 
/* bank 1 - supported only when FEAT_EXT_CMDS is set */
case (16 + 0) ... (16 + 31):
if (!(info->features & FEAT_EXT_CMDS))
return -EINVAL;
-   ret = dm_i2c_read(dev, CMD_GET_EXT_STATUS_DWORD, val32, 4);
+
+   ret = dm_i2c_read(dev, CMD_GET_EXT_STATUS_DWORD, (void *),
+ sizeof(val32));
if (ret)
return ret;
-   return u32)val32[3] << 24) | ((u32)val32[2] << 16) |
-((u32)val32[1] << 8) | val32[0]) >> (offset - 16)) & 
0x1;
+
+   return !!(le32_to_cpu(val32) & BIT(offset - 16));
 
/* bank 2 - supported only when FEAT_EXT_CMDS and FEAT_PERIPH_MCU is 
set */
case (16 + 32 + 0) ... (16 + 32 + 15):
@@ -79,10 +84,13 @@ static int turris_omnia_mcu_get_value(struct udevice *dev, 
uint offset)
return -EINVAL;
if (!(info->features & FEAT_PERIPH_MCU))
return -EINVAL;
-   ret = dm_i2c_read(dev, CMD_GET_EXT_CONTROL_STATUS, val16, 2);
+
+   ret = dm_i2c_read(dev, CMD_GET_EXT_CONTROL_STATUS,
+ (void *), sizeof(val16));
if (ret)
return ret;
-   return u16)val16[1] << 8) | val16[0]) >> (offset - 16 - 
32)) & 0x1;
+
+   return !!(le16_to_cpu(val16) & BIT(offset - 16 - 32));
 
default:
return -EINVAL;
@@ -92,30 +100,33 @@ static int turris_omnia_mcu_get_value(struct udevice *dev, 
uint offset)
 static int turris_omnia_mcu_set_value(struct udevice *dev, uint offset, int 
value)
 {
struct turris_omnia_mcu_info *info = dev_get_plat(dev);
-   u8 val16[2];
-   u8 val32[4];
+   u16 valmask16[2];
+   u8 valmask8[2];
 
switch (offset) {
/* bank 0 */
case 0 ... 15:
switch (offset) {
case ilog2(STS_USB30_PWRON):
-   val16[1] = CTL_USB30_PWRON;
+   valmask8[1] = CTL_USB30_PWRON;
break;
case ilog2(STS_USB31_PWRON):
-   val16[1] = CTL_USB31_PWRON;
+   valmask8[1] = CTL_USB31_PWRON;
break;
case ilog2(STS_ENABLE_4V5):
-   val16[1] = CTL_ENABLE_4V5;
+   valmask8[1] = CTL_ENABLE_4V5;
break;
case ilog2(STS_BUTTON_MODE):
-   val16[1] = CTL_BUTTON_MODE;
+   valmask8[1] = CTL_BUTTON_MODE;
break;
default:
return -EINVAL;
}
-   val16[0] = value ? val16[1] : 0;
-   return dm_i2c_write(dev, CMD_GENERAL_CONTROL, val16, 
sizeof(val16));
+
+   valmask8[0] = value ? valmask8[1] : 0;
+
+   return dm_i2c_write(dev, CMD_GENERAL_CONTROL, valmask8,
+   sizeof(valmask8));
 
/* bank 2 - supported only when FEAT_EXT_CMDS and FEAT_PERIPH_MCU is 
set */
case (16 + 32 + 0) ... (16 + 32 + 15):
@@ -123,11 +134,12 @@ static int turris_omnia_mcu_set_value(struct udevice 
*dev, uint offset, int valu
return -EINVAL;
if (!(info->features & FEAT_PERIPH_MCU))
return -EINVAL;
-   val32[3] = BIT(offset - 16 - 32) >> 8;
-   val32[2] = BIT(offset - 16 - 32) & 0xff;
-   val32[1] = value ? val32[3] : 0;
-   

  1   2   >