Re: [PATCH 1/6] include: env: phytec: overlays: Add extension command

2024-07-09 Thread Yannic Moog
On Tue, 2024-07-09 at 15:47 +0200, Wadim Egorov wrote:
> 
> 
> Am 09.07.24 um 15:31 schrieb Daniel Schultz:
> > Hi Yannic,
> > 
> > On 09.07.24 08:49, Yannic Moog wrote:
> > > Hello Daniel,
> > > 
> > > On Sun, 2024-07-07 at 23:07 -0700, Daniel Schultz wrote:
> > > > Add a new environment routine to apply extensions. Our SOM detection
> > > > adds overlays via the extension framework to alter the kernel
> > > > device-tree according to the flashed EEPROM image.
> > > > 
> > > > Signed-off-by: Daniel Schultz 
> > > > ---
> > > >   include/env/phytec/overlays.env | 20 
> > > >   1 file changed, 20 insertions(+)
> > > > 
> > > > diff --git a/include/env/phytec/overlays.env 
> > > > b/include/env/phytec/overlays.env
> > > > index 78721cde654..50110e731bd 100644
> > > > --- a/include/env/phytec/overlays.env
> > > > +++ b/include/env/phytec/overlays.env
> > > > @@ -23,6 +23,16 @@ mmc_apply_overlays=
> > > >   fi;
> > > >   done;
> > > >   fi;
> > > > +#ifdef CONFIG_CMD_EXTENSION
> > > > +mmc_apply_extensions=
> > > > +    setenv extension_overlay_addr ${fdtoverlay_addr_r};
> > > > +    setenv extension_overlay_cmd 'load mmc ${mmcdev}:${mmcpart}
> > > > +      ${fdtoverlay_addr_r} ${extension_overlay_name}';
> > > > +    extension scan;
> > > > +    extension apply all;
> > > > +#else
> > > > +mmc_apply_extensions=echo "no extension command"
> > > Do you think it makes sense to make this fail? I would think 
> > > "apply_extensions" would be
> > > unsuccessful if extensions are not working.
> > 
> > Technically, you don't need our SOM detection overlays. They just make 
> > the boot nicer and you don't have any probe errors or other error 
> > messages. So, in my opinion, it's better not apply them instead of 
> > stopping the entire boot.
> 
> My recommendation is to embed all SoM variant related overlays into 
> u-boot.img's FIT using binman.

Didn't think binman would be used for that, but I share your opinion regarding 
overlay packaging.

Yannic

> 
> This makes the extension command obsolete, and especially the handling 
> for loading of overlays from different boot sources / storage devices.
> 
> Having them available directly in the u-boot binary resolves the issue 
> of not found overlays.
> 
> We do not know how users will proceed after u-boot booted and if the 
> overlays will be available to the "extension setup". Better to have 
> everything in place and fixup to the best we know using our SoM data 
> stored in the EEPROM.
> 
> This kind of overlays should be applied regardless of the boot device.
> 
> > 
> > Regards,
> > Daniel
> > 
> > > 
> > > Yannic
> > > 
> > > > +#endif
> > > >   net_load_bootenv=${get_cmd} ${bootenv_addr_r} ${bootenv}
> > > >   net_load_overlay=${get_cmd} ${fdtoverlay_addr_r} ${overlay}
> > > >   net_apply_overlays=
> > > > @@ -36,3 +46,13 @@ net_apply_overlays=
> > > >   fi;
> > > >   done;
> > > >   fi;
> > > > +#ifdef CONFIG_CMD_EXTENSION
> > > > +net_apply_extensions=
> > > > +    setenv extension_overlay_addr ${fdtoverlay_addr_r};
> > > > +    setenv extension_overlay_cmd '${get_cmd} ${fdtoverlay_addr_r}
> > > > + ${extension_overlay_name}';
> > > > +    extension scan;
> > > > +    extension apply all;
> > > > +#else
> > > > +net_apply_extensions=echo "no extension command"
> > > > +#endif



[PATCH] mtd: nand: raw: atmel: Use ONFI ECC params if available

2024-07-09 Thread Zixun Li
When ECC parameters are not specified in DT, first try ONFI ECC parameters
before fallback to maximum strength. To be inline with kernel driver behavior.

Signed-off-by: Zixun LI 
---
 drivers/mtd/nand/raw/atmel/nand-controller.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c 
b/drivers/mtd/nand/raw/atmel/nand-controller.c
index 9873d11254..d29a9c6f10 100644
--- a/drivers/mtd/nand/raw/atmel/nand-controller.c
+++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
@@ -1064,11 +1064,15 @@ static int atmel_nand_pmecc_init(struct nand_chip *chip)
req.ecc.strength = ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH;
else if (chip->ecc.strength)
req.ecc.strength = chip->ecc.strength;
+   else if(chip->ecc_strength_ds)
+   req.ecc.strength = chip->ecc_strength_ds;
else
req.ecc.strength = ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH;
 
if (chip->ecc.size)
req.ecc.sectorsize = chip->ecc.size;
+   else if(chip->ecc_step_ds)
+   req.ecc.sectorsize = chip->ecc_step_ds;
else
req.ecc.sectorsize = ATMEL_PMECC_SECTOR_SIZE_AUTO;
 
-- 
2.45.1



Re: [PATCH] gpt: allow spaces in partition list

2024-07-09 Thread Sam Protsenko
On Thu, Jun 27, 2024 at 6:29 AM Mikhail Kshevetskiy
 wrote:
>
> This allows spliting partition list to several lines in environment file
>
> ex:
> 
> gpt_partition_list=
> name=boot1,size=5MiB,start=0x10;
> name=boot2,size=5MiB;
> name=rootfs1,size=70MiB;
> name=rootfs2,size=70MiB;
> name=overlay1,size=20MiB;
> name=overlay2,size=20MiB;
> name=art,size=4MiB;
>
> Signed-off-by: Mikhail Kshevetskiy 
> ---

Feel free to add:

Reviewed-by: Sam Protsenko 
Tested-by: Sam Protsenko 

With this patch the next command succeeds, when having $partitions
described in multi-line variable in .env file:

=> gpt verify mmc 0 "$partitions"

I wonder if it makes sense to also change cmd_gen_envp command in
Makefile to avoid adding spaces in place of newlines, in the first
place? It would allow us to specify unbroken multi-line variables in
.env, though I'm not sure if anyone actually relies on that behavior
in their .env files.

>  cmd/gpt.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/cmd/gpt.c b/cmd/gpt.c
> index 7aaf1889a5a..2b29ab98ccc 100644
> --- a/cmd/gpt.c
> +++ b/cmd/gpt.c
> @@ -117,6 +117,7 @@ static char *extract_val(const char *str, const char *key)
> k = strsep(, "=");
> if (!k)
> break;
> +   k += strspn(k, " \t");
> if  (strcmp(k, key) == 0) {
> new = strdup(v);
> break;
> @@ -151,6 +152,7 @@ static bool found_key(const char *str, const char *key)
> k = strsep(, ",");
> if (!k)
> break;
> +   k += strspn(k, " \t");
> if  (strcmp(k, key) == 0) {
> result = true;
> break;
> --
> 2.43.0
>


[PATCH] test/py/requirements.txt: Bump zipp to current release

2024-07-09 Thread Tom Rini
A security issue exists with zipp before v3.19.1, and the current
release is now v3.19.2. While the change in versions numbers is large, a
manual inspection of the changelog shows that it's not as big as might
be implied.

Reported-by: GitHub dependabot
Signed-off-by: Tom Rini 
---
 test/py/requirements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/py/requirements.txt b/test/py/requirements.txt
index c1dd636931f7..6d3030cf90cd 100644
--- a/test/py/requirements.txt
+++ b/test/py/requirements.txt
@@ -27,4 +27,4 @@ testtools==2.3.0
 traceback2==1.4.0
 unittest2==1.1.0
 wcwidth==0.1.7
-zipp==0.6.0
+zipp==3.19.2
-- 
2.34.1



[PATCH v3 1/1] bloblist: Fix bloblist convention checking.

2024-07-09 Thread Levi Yun
According to recently firmware handsoff spec [1]'s "Register usage at handoff
boundary", Transfer List's signature value was changed from 0x40_b10b
(3 bytes) to 4a0f_b10b (4 bytes).

As updating of TL's signature, register value of x1/r1 should be:

In aarch32's r1 value should be
R1[23:0]: set to the TL signature (4a0f_b10b -> masked range value: 0f_b10b)
R1[31:24]: version of the register convention ==  1

and

In aarch64's x1 value should be
X1[31:0]: set to the TL signature (4a0f_b10b)
X1[39:32]: version of the register convention ==  1
X1[63:40]: MBZ
(See the [2] and [3]).

This patch fix problems:
   1. breaking X1 value with updated specification in aarch64
- change of length of signature field.

   2. previous error value set in R1 in arm32.
- length of signature should be 24, but it uses 32bit signature.

[1] https://github.com/FirmwareHandoff/firmware_handoff
[2] https://github.com/FirmwareHandoff/firmware_handoff/issues/32
[3] 
https://github.com/FirmwareHandoff/firmware_handoff/commit/5aa7aa1d3a1db75213e458d392b751f0707de027

Signed-off-by: Levi Yun 
---
v3:
  - Restore arch/arm/lib/xferlist.c.

v2:
  - Modify commit message.
  - Remove wrong swaping check in xferlist_from_boot_arg().

 common/bloblist.c  | 11 ++-
 include/bloblist.h |  5 -
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index 11d6422b69..2008ab4d25 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -576,7 +576,16 @@ int bloblist_maybe_init(void)

 int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig)
 {
-   if (rzero || rsig != (BLOBLIST_MAGIC | BLOBLIST_REGCONV_VER) ||
+   ulong version = BLOBLIST_REGCONV_VER;
+   ulong sigval;
+
+   sigval = (IS_ENABLED(CONFIG_64BIT)) ?
+   ((BLOBLIST_MAGIC & ((1UL << BLOBLIST_REGCONV_SHIFT_64) 
- 1)) |
+((version  & BLOBLIST_REGCONV_MASK) << 
BLOBLIST_REGCONV_SHIFT_64)) :
+   ((BLOBLIST_MAGIC & ((1UL << BLOBLIST_REGCONV_SHIFT_32) 
- 1)) |
+((version  & BLOBLIST_REGCONV_MASK) << 
BLOBLIST_REGCONV_SHIFT_32));
+
+   if (rzero || rsig != sigval ||
rfdt != (ulong)bloblist_find(BLOBLISTT_CONTROL_FDT, 0)) {
gd->bloblist = NULL;  /* Reset the gd bloblist pointer */
return -EIO;
diff --git a/include/bloblist.h b/include/bloblist.h
index 7fbdd622bc..f4849f22a0 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -83,7 +83,10 @@ enum {
 * Register convention version should be placed into a higher byte
 * https://github.com/FirmwareHandoff/firmware_handoff/issues/32
 */
-   BLOBLIST_REGCONV_VER= 1 << 24,
+   BLOBLIST_REGCONV_SHIFT_64 = 32,
+   BLOBLIST_REGCONV_SHIFT_32 = 24,
+   BLOBLIST_REGCONV_MASK = 0xff,
+   BLOBLIST_REGCONV_VER = 1,

BLOBLIST_BLOB_ALIGN_LOG2 = 3,
BLOBLIST_BLOB_ALIGN  = 1 << BLOBLIST_BLOB_ALIGN_LOG2,
--
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}



Re: [PATCH] bloblist: Fix bloblist convention checking.

2024-07-09 Thread Yeo Reum Yun
Hi. Raymond.

> I think you don't even need to change the order.
> The FW handoff must fulfill two conditions at the same time (A valid TL plus 
> and proper register
> conventions).
> Both conditions are essential with the same priority and which one should be 
> proceeded first
> is fully arbitrary.

okay. then I'll restore xferlist.c.

and send patch v3.
Please ignore patch v2.

Thanks!


From: Raymond Mao 
Sent: 09 July 2024 20:26
To: Yeo Reum Yun
Cc: tr...@konsulko.com; s...@chromium.org; ilias.apalodimas; n-ja...@ti.com; 
bmeng...@gmail.com; u-boot@lists.denx.de
Subject: Re: [PATCH] bloblist: Fix bloblist convention checking.

Hi Levi,

On Tue, 9 Jul 2024 at 13:16, Yeo Reum Yun 
mailto:yeoreum@arm.com>> wrote:
Hi Raymond!


> The handoff of armv7 will break if you swap arg[0] and arg[2] here.
> The args are already aligned in the correct order via the assembly code.
> Please see the 'save_boot_params' function in start.S of armv7.

Thanks to let me know. I couldn't see that code.
But I think before checking transfer_list, It would be good to check convention 
first.

So, I'll change order only.

I think you don't even need to change the order.
The FW handoff must fulfill two conditions at the same time (A valid TL plus 
and proper register
conventions).
Both conditions are essential with the same priority and which one should be 
proceeded first
is fully arbitrary.

Regards,
Raymond
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


Re: [PATCH] arm: dts: mvebu: Migrate to upstream DT for Synology DS116 (Armada 385) board

2024-07-09 Thread Tony Dinh
Hi Stefan,

On Thu, May 23, 2024 at 12:27 AM Sumit Garg  wrote:
>
> On Thu, 23 May 2024 at 03:22, Tony Dinh  wrote:
> >
> > Enable OF_UPSTREAM to use upstream DT and add marvell/ prefix to the
> > DEFAULT_DEVICE_TREE in DS116 defconfig. Remove current DTS in
> > arch/arm/dts/ directory.
> >
> > Signed-off-by: Tony Dinh 
> > ---
> >
> >  arch/arm/dts/Makefile  |   1 -
> >  arch/arm/dts/armada-385-synology-ds116.dts | 291 -
> >  configs/ds116_defconfig|   3 +-
> >  3 files changed, 2 insertions(+), 293 deletions(-)
> >  delete mode 100644 arch/arm/dts/armada-385-synology-ds116.dts
> >
>
> Acked-by: Sumit Garg 
>
> -Sumit

Is this OK to be merged to next?

All the best,
Tony

>
> > diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> > index a5c82ebf7a..75f7e616b4 100644
> > --- a/arch/arm/dts/Makefile
> > +++ b/arch/arm/dts/Makefile
> > @@ -155,7 +155,6 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
> > armada-385-atl-x530.dtb \
> > armada-385-atl-x530DP.dtb   \
> > armada-385-db-88f6820-amc.dtb   \
> > -   armada-385-synology-ds116.dtb   \
> > armada-385-thecus-n2350.dtb \
> > armada-385-turris-omnia.dtb \
> > armada-388-clearfog.dtb \
> > diff --git a/arch/arm/dts/armada-385-synology-ds116.dts 
> > b/arch/arm/dts/armada-385-synology-ds116.dts
> > deleted file mode 100644
> > index 82a0373f7f..00
> > --- a/arch/arm/dts/armada-385-synology-ds116.dts
> > +++ /dev/null
> > @@ -1,291 +0,0 @@
> > -// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> > -/*
> > - * Device Tree file for Synology DS116 NAS
> > - *
> > - * Copyright (C) 2017 Willy Tarreau 
> > - */
> > -
> > -/dts-v1/;
> > -#include "armada-385.dtsi"
> > -#include 
> > -
> > -/ {
> > -   model = "Synology DS116";
> > -   compatible = "marvell,a385-gp", "marvell,armada385", 
> > "marvell,armada380";
> > -
> > -   chosen {
> > -   stdout-path = "serial0:115200n8";
> > -   };
> > -
> > -   memory {
> > -   device_type = "memory";
> > -   reg = <0x 0x4000>; /* 1 GB */
> > -   };
> > -
> > -   soc {
> > -   ranges =  > - MBUS_ID(0x01, 0x1d) 0 0xfff0 0x10
> > - MBUS_ID(0x09, 0x19) 0 0xf110 0x1
> > - MBUS_ID(0x09, 0x15) 0 0xf111 0x1
> > - MBUS_ID(0x0c, 0x04) 0 0xf120 0x10>;
> > -
> > -   internal-regs {
> > -   i2c@11000 {
> > -   pinctrl-names = "default";
> > -   pinctrl-0 = <_pins>;
> > -   status = "okay";
> > -   clock-frequency = <10>;
> > -
> > -   eeprom@57 {
> > -   compatible = "atmel,24c64";
> > -   reg = <0x57>;
> > -   };
> > -   };
> > -
> > -   serial@12000 {
> > -   pinctrl-names = "default";
> > -   pinctrl-0 = <_pins>;
> > -   status = "okay";
> > -   };
> > -
> > -   serial@12100 {
> > -   /* A PIC16F1829 is connected to uart1 at 
> > 9600 bps,
> > -* and takes single-character orders :
> > -*   "1" : power off // already handled by 
> > the poweroff node
> > -*   "2" : short beep
> > -*   "3" : long beep
> > -*   "4" : turn the power LED ON
> > -*   "5" : flash the power LED
> > -*   "6" : turn the power LED OFF
> > -*   "7" : turn the status LED OFF
> > -*   "8" : turn the status LED ON
> > -*   "9" : flash the status LED
> > -*   "A" : flash the motherboard LED (D8)
> > -*   "B" : turn the motherboard LED OFF
> > -*   "C" : hard reset
> > -*/
> > -   pinctrl-names = "default";
> > -   pinctrl-0 = <_pins>;
> > -   status = "okay";
> > -   };
> > -
> > -   poweroff@12100 {
> > -   compatible = "synology,power-off";
> > -   reg = <0x12100 0x100>;
> > -   clocks = < 0>;
> > -   };
> > -
> > -  

Re: [PATCH] bloblist: Fix bloblist convention checking.

2024-07-09 Thread Raymond Mao
Hi Levi,

On Tue, 9 Jul 2024 at 13:16, Yeo Reum Yun  wrote:

> Hi Raymond!
>
>
> > The handoff of armv7 will break if you swap arg[0] and arg[2] here.
> > The args are already aligned in the correct order via the assembly code.
> > Please see the 'save_boot_params' function in start.S of armv7.
>
> Thanks to let me know. I couldn't see that code.
> But I think before checking transfer_list, It would be good to check
> convention first.
>
> So, I'll change order only.
>
> I think you don't even need to change the order.
The FW handoff must fulfill two conditions at the same time (A valid TL
plus and proper register
conventions).
Both conditions are essential with the same priority and which one should
be proceeded first
is fully arbitrary.

Regards,
Raymond


[PATCH v2] bloblist: Fix bloblist convention checking.

2024-07-09 Thread Levi Yun
According to recently firmware handsoff spec [1]'s "Register usage at handoff
boundary", Transfer List's signature value was changed from 0x40_b10b
(3 bytes) to 4a0f_b10b (4 bytes).

As updating of TL's signature, register value of x1/r1 should be:

In aarch32's r1 value should be
R1[23:0]: set to the TL signature (4a0f_b10b -> masked range value: 0f_b10b)
R1[31:24]: version of the register convention ==  1

and

In aarch64's x1 value should be
X1[31:0]: set to the TL signature (4a0f_b10b)
X1[39:32]: version of the register convention ==  1
X1[63:40]: MBZ
(See the [2] and [3]).

This patch fix problems:
   1. breaking X1 value with updated specification in aarch64
- change of length of signature field.

   2. previous error value set in R1 in arm32.
- length of signature should be 24, but it uses 32bit signature.

[1] https://github.com/FirmwareHandoff/firmware_handoff
[2] https://github.com/FirmwareHandoff/firmware_handoff/issues/32
[3] 
https://github.com/FirmwareHandoff/firmware_handoff/commit/5aa7aa1d3a1db75213e458d392b751f0707de027

Signed-off-by: Levi Yun 
---
v2:
  - Modify commit message.
  - Remove wrong swaping check in xferlist_from_boot_arg().

 arch/arm/lib/xferlist.c |  5 ++---
 common/bloblist.c   | 11 ++-
 include/bloblist.h  |  5 -
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/arch/arm/lib/xferlist.c b/arch/arm/lib/xferlist.c
index f9c5d88bd4..c0b1e33f96 100644
--- a/arch/arm/lib/xferlist.c
+++ b/arch/arm/lib/xferlist.c
@@ -12,12 +12,11 @@ int xferlist_from_boot_arg(ulong addr, ulong size)
 {
int ret;

-   ret = bloblist_check(saved_args[3], size);
+   ret = bloblist_check_reg_conv(saved_args[0], saved_args[2], 
saved_args[1]);
if (ret)
return ret;

-   ret = bloblist_check_reg_conv(saved_args[0], saved_args[2],
- saved_args[1]);
+   ret = bloblist_check(saved_args[3], size);
if (ret)
return ret;

diff --git a/common/bloblist.c b/common/bloblist.c
index 11d6422b69..2008ab4d25 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -576,7 +576,16 @@ int bloblist_maybe_init(void)

 int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig)
 {
-   if (rzero || rsig != (BLOBLIST_MAGIC | BLOBLIST_REGCONV_VER) ||
+   ulong version = BLOBLIST_REGCONV_VER;
+   ulong sigval;
+
+   sigval = (IS_ENABLED(CONFIG_64BIT)) ?
+   ((BLOBLIST_MAGIC & ((1UL << BLOBLIST_REGCONV_SHIFT_64) 
- 1)) |
+((version  & BLOBLIST_REGCONV_MASK) << 
BLOBLIST_REGCONV_SHIFT_64)) :
+   ((BLOBLIST_MAGIC & ((1UL << BLOBLIST_REGCONV_SHIFT_32) 
- 1)) |
+((version  & BLOBLIST_REGCONV_MASK) << 
BLOBLIST_REGCONV_SHIFT_32));
+
+   if (rzero || rsig != sigval ||
rfdt != (ulong)bloblist_find(BLOBLISTT_CONTROL_FDT, 0)) {
gd->bloblist = NULL;  /* Reset the gd bloblist pointer */
return -EIO;
diff --git a/include/bloblist.h b/include/bloblist.h
index 7fbdd622bc..f4849f22a0 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -83,7 +83,10 @@ enum {
 * Register convention version should be placed into a higher byte
 * https://github.com/FirmwareHandoff/firmware_handoff/issues/32
 */
-   BLOBLIST_REGCONV_VER= 1 << 24,
+   BLOBLIST_REGCONV_SHIFT_64 = 32,
+   BLOBLIST_REGCONV_SHIFT_32 = 24,
+   BLOBLIST_REGCONV_MASK = 0xff,
+   BLOBLIST_REGCONV_VER = 1,

BLOBLIST_BLOB_ALIGN_LOG2 = 3,
BLOBLIST_BLOB_ALIGN  = 1 << BLOBLIST_BLOB_ALIGN_LOG2,
--
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}



Re: [PATCH] bloblist: Fix bloblist convention checking.

2024-07-09 Thread Yeo Reum Yun
Hi Raymond!


> The handoff of armv7 will break if you swap arg[0] and arg[2] here.
> The args are already aligned in the correct order via the assembly code.
> Please see the 'save_boot_params' function in start.S of armv7.

Thanks to let me know. I couldn't see that code.
But I think before checking transfer_list, It would be good to check convention 
first.

So, I'll change order only.

Thanks!
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


Re: [PATCH v4 01/21] linux/bitmap.h: add bitmap_empty helper

2024-07-09 Thread Tom Rini
On Tue, Jul 09, 2024 at 11:34:29AM +0200, Caleb Connolly wrote:

> Import this function from Linux as of 6.10-rc6
> 
> Signed-off-by: Caleb Connolly 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] driver: rng: Do not check ARM_SMCCC_TRNG_VERSION

2024-07-09 Thread Leo Yan
As described in the document SMC Calling Convention (ARM DEN 0028 1.5 F),
section 7 "Arm Architecture Calls", the SMC call SMCCC_ARCH_FEATURES is
not expected to support the function ID ARM_SMCCC_TRNG_VERSION. Trusted
Firmware-A follows up the specification in its implementation.

This commit removes the invocation to avoid the failure - which is a
wrong calling in U-boot. The later code invokes ARM_SMCCC_TRNG_VERSION
for retrieving the TRNG version, except it can read back the version
number, it also can be used to detect whether the TRNG is supported or
not.

Signed-off-by: Leo Yan 
---
 drivers/rng/smccc_trng.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/rng/smccc_trng.c b/drivers/rng/smccc_trng.c
index f59b80666b..1da1affd8e 100644
--- a/drivers/rng/smccc_trng.c
+++ b/drivers/rng/smccc_trng.c
@@ -135,10 +135,6 @@ static bool smccc_trng_is_supported(void 
(*invoke_fn)(unsigned long a0, unsigned
 {
struct arm_smccc_res res;
 
-   (*invoke_fn)(ARM_SMCCC_ARCH_FEATURES, ARM_SMCCC_TRNG_VERSION, 0, 0, 0, 
0, 0, 0, );
-   if (res.a0 == ARM_SMCCC_RET_NOT_SUPPORTED)
-   return false;
-
(*invoke_fn)(ARM_SMCCC_TRNG_VERSION, 0, 0, 0, 0, 0, 0, 0, );
if (res.a0 & BIT(31))
return false;
-- 
2.34.1



[PATCH] bloblist: Fix bloblist convention checking.

2024-07-09 Thread Levi Yun
According to recently firmware handsoff spec [1]'s
"Register usage at handoff boundary",
Transfer List's signature value was changed from 0x40_b10b
(3 bytes) to 4a0f_b10b (4 bytes).

As updating of TL's signature, register value of x1/r1 should be:

In aarch32's r1 value should be
R1[23:0]: TL signature (4a0f_b10b->masked range value: 0f_b10b)
R1[31:24]: version of the register convention ==  1

and

In aarch64's x1 value should be
X1[31:0]: TL signature (4a0f_b10b)
X1[39:32]: version of the register convention ==  1
X1[63:40]: MBZ
(See the [2] and [3]).

Also, according to architecture, the convention is slight different:

In aarch32:
R0: MBZ
R1: see above
R2: Compatibility location for passing a platform description devicetree
R3: tl_base_pa

In aarch64:
X0: Compatibility location for passing a platform description devicetree
X1: see above
X2: MBZ
X3: tl_base_pa

This patch fix problems:
   1. breaking X1 value with updated specification in aarch64
- change of length of signature field.

   2. previous error value set in R1 in arm32.
- length of signature should be 24, but it uses 32bit signature.

   3. according to architecture, check register convetion differently.

[1] https://github.com/FirmwareHandoff/firmware_handoff
[2] https://github.com/FirmwareHandoff/firmware_handoff/issues/32
[3] 
https://github.com/FirmwareHandoff/firmware_handoff/commit/5aa7aa1d3a1db75213e458d392b751f0707de027

Signed-off-by: Levi Yun 
---
 arch/arm/lib/xferlist.c |  8 +---
 common/bloblist.c   | 11 ++-
 include/bloblist.h  |  5 -
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/arch/arm/lib/xferlist.c b/arch/arm/lib/xferlist.c
index f9c5d88bd4..a6349293bd 100644
--- a/arch/arm/lib/xferlist.c
+++ b/arch/arm/lib/xferlist.c
@@ -12,12 +12,14 @@ int xferlist_from_boot_arg(ulong addr, ulong size)
 {
int ret;

-   ret = bloblist_check(saved_args[3], size);
+   if (IS_ENABLED(CONFIG_64BIT))
+   ret = bloblist_check_reg_conv(saved_args[0], saved_args[2], 
saved_args[1]);
+   else
+   ret = bloblist_check_reg_conv(saved_args[2], saved_args[0], 
saved_args[1]);
if (ret)
return ret;

-   ret = bloblist_check_reg_conv(saved_args[0], saved_args[2],
- saved_args[1]);
+   ret = bloblist_check(saved_args[3], size);
if (ret)
return ret;

diff --git a/common/bloblist.c b/common/bloblist.c
index 11d6422b69..2008ab4d25 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -576,7 +576,16 @@ int bloblist_maybe_init(void)

 int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig)
 {
-   if (rzero || rsig != (BLOBLIST_MAGIC | BLOBLIST_REGCONV_VER) ||
+   ulong version = BLOBLIST_REGCONV_VER;
+   ulong sigval;
+
+   sigval = (IS_ENABLED(CONFIG_64BIT)) ?
+   ((BLOBLIST_MAGIC & ((1UL << BLOBLIST_REGCONV_SHIFT_64) 
- 1)) |
+((version  & BLOBLIST_REGCONV_MASK) << 
BLOBLIST_REGCONV_SHIFT_64)) :
+   ((BLOBLIST_MAGIC & ((1UL << BLOBLIST_REGCONV_SHIFT_32) 
- 1)) |
+((version  & BLOBLIST_REGCONV_MASK) << 
BLOBLIST_REGCONV_SHIFT_32));
+
+   if (rzero || rsig != sigval ||
rfdt != (ulong)bloblist_find(BLOBLISTT_CONTROL_FDT, 0)) {
gd->bloblist = NULL;  /* Reset the gd bloblist pointer */
return -EIO;
diff --git a/include/bloblist.h b/include/bloblist.h
index 7fbdd622bc..f4849f22a0 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -83,7 +83,10 @@ enum {
 * Register convention version should be placed into a higher byte
 * https://github.com/FirmwareHandoff/firmware_handoff/issues/32
 */
-   BLOBLIST_REGCONV_VER= 1 << 24,
+   BLOBLIST_REGCONV_SHIFT_64 = 32,
+   BLOBLIST_REGCONV_SHIFT_32 = 24,
+   BLOBLIST_REGCONV_MASK = 0xff,
+   BLOBLIST_REGCONV_VER = 1,

BLOBLIST_BLOB_ALIGN_LOG2 = 3,
BLOBLIST_BLOB_ALIGN  = 1 << BLOBLIST_BLOB_ALIGN_LOG2,
--
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}



Re: [EXTERNAL] Re: [PATCH 1/6] sound: ti: Add sound support for am625 board in Uboot

2024-07-09 Thread Tom Rini
On Tue, Jul 09, 2024 at 04:56:45PM +0530, Scaria Kochidanadu wrote:
> 
> 
> On 08/07/24 21:16, Tom Rini wrote:
> > On Mon, Jul 08, 2024 at 01:22:02PM +0530, Scaria Kochidanadu wrote:
> > 
> >> Add a UCLASS_SOUND driver for Texas Instruments SoCs which ties together
> >> the tlv320aic3106 audio codec and MCASP I2S controller. Enable audio
> >> playback functionality by taking a data pointer and data size as the
> >> sound data. The uboot sound play command takes time and frequency as
> >> input and creates the data for a beep sound with the given parameters,
> >> which is then passed to the sound play function.
> > [snip]
> >> +++ b/drivers/sound/ti_sound.c
> >> @@ -0,0 +1,119 @@
> >> +// SPDX-License-Identifier: GPL-2.0+
> >> +/*
> >> + * (C) Copyright 2024 Texas Instruments Incorporated - https://www.ti.com/
> >> + * Scaria M Kochidanadu, s-kochidan...@ti.com
> >> + *
> >> + * based on the uboot samsung sound driver, which is
> >> + *
> >> + * Copyright 2018 Google, LLC
> >> + * Written by Simon Glass 
> >> + */
> >> +
> >> +#include  /* boot information for Linux kernel */
> >> +/* Pull in stuff for the build system */
> >> +#ifdef DO_DEPS_ONLY
> >> +#include 
> >> +#endif
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> > 
> > Please audit this list. I really am confused by .
> > 
> 
> I will be removing this in v2 as it is not required.
> 
> >> +static int ti_sound_stop_play(struct udevice *dev)
> >> +{
> >> +  /* This function is necassary to satisfy the function calls
> >> +   * in the Uboot command: sound play
> >> +   */
> >> +  return 0;
> > 
> > /*
> >  * Like this...
> >  */
> > 
> > [snip]
> >> +static const struct udevice_id ti_sound_ids[] = {
> >> +  { .compatible = "simple-audio-card" },
> >> +  { }
> >> +};
> > 
> > Adding an actual simple-audio-card framework for U-Boot would be great.
> > This driver implies (and is?) TI-centric, instead. So lets rework this
> > to be split appropriately? Thanks.
> > 
> 
> I wanted to reuse the sound card DT node in the upstream kernel
> device-tree. The U-boot upstrem repo does not have the node as it is
> using an older version of DT.

When was the node upstreamed? Use the cherry-pick option to 
dts/update-dts-subtree.sh if needed.

> But if using the simple-audio-card node is not preferred, then can we
> create TI specific compatible and a separate DT node?

No, I would like to see the start of simple-audio-card support be worked
on, so that other platforms can leverage on top of this. Thanks.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v3 07/10] configs: am62: Add configs for enabling ETHBOOT in R5SPL

2024-07-09 Thread Tom Rini
On Tue, Jul 09, 2024 at 12:29:15PM +0530, Chintan Vankar wrote:
> 
> 
> On 05/07/24 21:07, Tom Rini wrote:
> > On Fri, Jul 05, 2024 at 10:20:27AM +0530, Chintan Vankar wrote:
> > 
> > > From: Kishon Vijay Abraham I 
> > > 
> > > Add configs for enabling ETHBOOT in R5SPL.
> > > 
> > > Signed-off-by: Kishon Vijay Abraham I 
> > > Signed-off-by: Andreas Dannenberg 
> > > Signed-off-by: Siddharth Vadapalli 
> > > Signed-off-by: Chintan Vankar 
> > > ---
> > > 
> > > Link to v2:
> > > https://lore.kernel.org/r/20240425120822.2048012-8-c-van...@ti.com/
> > > 
> > > Changes from v2 to v3:
> > > - No changes.
> > > 
> > >   configs/am62x_evm_r5_ethboot_defconfig | 20 
> > >   1 file changed, 20 insertions(+)
> > >   create mode 100644 configs/am62x_evm_r5_ethboot_defconfig
> > > 
> > > diff --git a/configs/am62x_evm_r5_ethboot_defconfig 
> > > b/configs/am62x_evm_r5_ethboot_defconfig
> > > new file mode 100644
> > > index 00..7b1932b215
> > > --- /dev/null
> > > +++ b/configs/am62x_evm_r5_ethboot_defconfig
> > > @@ -0,0 +1,20 @@
> > > +#include
> > > +
> > > +CONFIG_SPL_GPIO=y
> > 
> > You need a few other options set in order for buildman to work in this
> > case, please look at the other #include users.
> > 
> 
> Are you referring to include "configs/k3_efi_capsule.config" ?

No, I'm referring to:
$ grep -l '#include' configs
configs/am62px_evm_a53_defconfig
configs/am62x_beagleplay_a53_defconfig
configs/am62x_evm_a53_defconfig
configs/am62x_lpsk_a53_defconfig
configs/am62x_lpsk_r5_defconfig
configs/am64x_evm_a53_defconfig
configs/am68_sk_a72_defconfig
configs/am68_sk_r5_defconfig
configs/am69_sk_a72_defconfig
configs/am69_sk_r5_defconfig
configs/j721e_beagleboneai64_a72_defconfig
configs/j721e_evm_a72_defconfig
configs/j721e_sk_a72_defconfig
configs/j721e_sk_r5_defconfig
configs/j784s4_evm_a72_defconfig

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] bloblist: Fix bloblist convention checking.

2024-07-09 Thread Raymond Mao
Hi Levi,

On Tue, 9 Jul 2024 at 09:25, Levi Yun  wrote:

> According to recently firmware handsoff spec [1]'s
> "Register usage at handoff boundary",
> Transfer List's signature value was changed from 0x40_b10b
> (3 bytes) to 4a0f_b10b (4 bytes).
>
> As updating of TL's signature, register value of x1/r1 should be:
>
> In aarch32's r1 value should be
> R1[23:0]: TL signature (4a0f_b10b->masked range value: 0f_b10b)
> R1[31:24]: version of the register convention ==  1
>
> and
>
> In aarch64's x1 value should be
> X1[31:0]: TL signature (4a0f_b10b)
> X1[39:32]: version of the register convention ==  1
> X1[63:40]: MBZ
> (See the [2] and [3]).
>
> Also, according to architecture, the convention is slight different:
>
> In aarch32:
> R0: MBZ
> R1: see above
> R2: Compatibility location for passing a platform description
> devicetree
> R3: tl_base_pa
>
> In aarch64:
> X0: Compatibility location for passing a platform description
> devicetree
> X1: see above
> X2: MBZ
> X3: tl_base_pa
>
> This patch fix problems:
>1. breaking X1 value with updated specification in aarch64
> - change of length of signature field.
>
>2. previous error value set in R1 in arm32.
> - length of signature should be 24, but it uses 32bit signature.
>
>3. according to architecture, check register convetion differently.
>
> [1] https://github.com/FirmwareHandoff/firmware_handoff
> [2] https://github.com/FirmwareHandoff/firmware_handoff/issues/32
> [3]
> https://github.com/FirmwareHandoff/firmware_handoff/commit/5aa7aa1d3a1db75213e458d392b751f0707de027
>
> Signed-off-by: Levi Yun 
> ---
>  arch/arm/lib/xferlist.c |  8 +---
>  common/bloblist.c   | 11 ++-
>  include/bloblist.h  |  5 -
>  3 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/lib/xferlist.c b/arch/arm/lib/xferlist.c
> index f9c5d88bd4..a6349293bd 100644
> --- a/arch/arm/lib/xferlist.c
> +++ b/arch/arm/lib/xferlist.c
> @@ -12,12 +12,14 @@ int xferlist_from_boot_arg(ulong addr, ulong size)
>  {
> int ret;
>
> -   ret = bloblist_check(saved_args[3], size);
> +   if (IS_ENABLED(CONFIG_64BIT))
> +   ret = bloblist_check_reg_conv(saved_args[0],
> saved_args[2], saved_args[1]);
> +   else
> +   ret = bloblist_check_reg_conv(saved_args[2],
> saved_args[0], saved_args[1]);
>

The handoff of armv7 will break if you swap arg[0] and arg[2] here.
The args are already aligned in the correct order via the assembly code.
Please see the 'save_boot_params' function in start.S of armv7.

Regards,
Raymond


Re: [PATCH 1/6] include: env: phytec: overlays: Add extension command

2024-07-09 Thread Wadim Egorov




Am 09.07.24 um 15:31 schrieb Daniel Schultz:

Hi Yannic,

On 09.07.24 08:49, Yannic Moog wrote:

Hello Daniel,

On Sun, 2024-07-07 at 23:07 -0700, Daniel Schultz wrote:

Add a new environment routine to apply extensions. Our SOM detection
adds overlays via the extension framework to alter the kernel
device-tree according to the flashed EEPROM image.

Signed-off-by: Daniel Schultz 
---
  include/env/phytec/overlays.env | 20 
  1 file changed, 20 insertions(+)

diff --git a/include/env/phytec/overlays.env 
b/include/env/phytec/overlays.env

index 78721cde654..50110e731bd 100644
--- a/include/env/phytec/overlays.env
+++ b/include/env/phytec/overlays.env
@@ -23,6 +23,16 @@ mmc_apply_overlays=
  fi;
  done;
  fi;
+#ifdef CONFIG_CMD_EXTENSION
+mmc_apply_extensions=
+    setenv extension_overlay_addr ${fdtoverlay_addr_r};
+    setenv extension_overlay_cmd 'load mmc ${mmcdev}:${mmcpart}
+      ${fdtoverlay_addr_r} ${extension_overlay_name}';
+    extension scan;
+    extension apply all;
+#else
+mmc_apply_extensions=echo "no extension command"
Do you think it makes sense to make this fail? I would think 
"apply_extensions" would be

unsuccessful if extensions are not working.


Technically, you don't need our SOM detection overlays. They just make 
the boot nicer and you don't have any probe errors or other error 
messages. So, in my opinion, it's better not apply them instead of 
stopping the entire boot.


My recommendation is to embed all SoM variant related overlays into 
u-boot.img's FIT using binman.


This makes the extension command obsolete, and especially the handling 
for loading of overlays from different boot sources / storage devices.


Having them available directly in the u-boot binary resolves the issue 
of not found overlays.


We do not know how users will proceed after u-boot booted and if the 
overlays will be available to the "extension setup". Better to have 
everything in place and fixup to the best we know using our SoM data 
stored in the EEPROM.


This kind of overlays should be applied regardless of the boot device.



Regards,
Daniel



Yannic


+#endif
  net_load_bootenv=${get_cmd} ${bootenv_addr_r} ${bootenv}
  net_load_overlay=${get_cmd} ${fdtoverlay_addr_r} ${overlay}
  net_apply_overlays=
@@ -36,3 +46,13 @@ net_apply_overlays=
  fi;
  done;
  fi;
+#ifdef CONFIG_CMD_EXTENSION
+net_apply_extensions=
+    setenv extension_overlay_addr ${fdtoverlay_addr_r};
+    setenv extension_overlay_cmd '${get_cmd} ${fdtoverlay_addr_r}
+ ${extension_overlay_name}';
+    extension scan;
+    extension apply all;
+#else
+net_apply_extensions=echo "no extension command"
+#endif


Re: [PATCH 1/6] include: env: phytec: overlays: Add extension command

2024-07-09 Thread Daniel Schultz

Hi Yannic,

On 09.07.24 08:49, Yannic Moog wrote:

Hello Daniel,

On Sun, 2024-07-07 at 23:07 -0700, Daniel Schultz wrote:

Add a new environment routine to apply extensions. Our SOM detection
adds overlays via the extension framework to alter the kernel
device-tree according to the flashed EEPROM image.

Signed-off-by: Daniel Schultz 
---
  include/env/phytec/overlays.env | 20 
  1 file changed, 20 insertions(+)

diff --git a/include/env/phytec/overlays.env b/include/env/phytec/overlays.env
index 78721cde654..50110e731bd 100644
--- a/include/env/phytec/overlays.env
+++ b/include/env/phytec/overlays.env
@@ -23,6 +23,16 @@ mmc_apply_overlays=
    fi;
    done;
    fi;
+#ifdef CONFIG_CMD_EXTENSION
+mmc_apply_extensions=
+   setenv extension_overlay_addr ${fdtoverlay_addr_r};
+   setenv extension_overlay_cmd 'load mmc ${mmcdev}:${mmcpart}
+     ${fdtoverlay_addr_r} ${extension_overlay_name}';
+   extension scan;
+   extension apply all;
+#else
+mmc_apply_extensions=echo "no extension command"

Do you think it makes sense to make this fail? I would think "apply_extensions" 
would be
unsuccessful if extensions are not working.


Technically, you don't need our SOM detection overlays. They just make 
the boot nicer and you don't have any probe errors or other error 
messages. So, in my opinion, it's better not apply them instead of 
stopping the entire boot.


Regards,
Daniel



Yannic


+#endif
  net_load_bootenv=${get_cmd} ${bootenv_addr_r} ${bootenv}
  net_load_overlay=${get_cmd} ${fdtoverlay_addr_r} ${overlay}
  net_apply_overlays=
@@ -36,3 +46,13 @@ net_apply_overlays=
    fi;
    done;
    fi;
+#ifdef CONFIG_CMD_EXTENSION
+net_apply_extensions=
+   setenv extension_overlay_addr ${fdtoverlay_addr_r};
+   setenv extension_overlay_cmd '${get_cmd} ${fdtoverlay_addr_r}
+${extension_overlay_name}';
+   extension scan;
+   extension apply all;
+#else
+net_apply_extensions=echo "no extension command"
+#endif


[PATCH] board: raspberrypi: Fix format specifier for printing rev_scheme

2024-07-09 Thread Francois Berder
rev_scheme is an unsigned integer and must not be printed
as a signed integer.

Signed-off-by: Francois Berder 
---
 board/raspberrypi/rpi/rpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index d996eb0cf6..caa4483117 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -381,7 +381,7 @@ static void set_board_info(void)
 
snprintf(s, sizeof(s), "0x%X", revision);
env_set("board_revision", s);
-   snprintf(s, sizeof(s), "%d", rev_scheme);
+   snprintf(s, sizeof(s), "%u", rev_scheme);
env_set("board_rev_scheme", s);
/* Can't rename this to board_rev_type since it's an ABI for scripts */
snprintf(s, sizeof(s), "0x%X", rev_type);
-- 
2.34.1



Re: [EXTERNAL] Re: [PATCH 1/6] sound: ti: Add sound support for am625 board in Uboot

2024-07-09 Thread Scaria Kochidanadu



On 08/07/24 21:16, Tom Rini wrote:
> On Mon, Jul 08, 2024 at 01:22:02PM +0530, Scaria Kochidanadu wrote:
> 
>> Add a UCLASS_SOUND driver for Texas Instruments SoCs which ties together
>> the tlv320aic3106 audio codec and MCASP I2S controller. Enable audio
>> playback functionality by taking a data pointer and data size as the
>> sound data. The uboot sound play command takes time and frequency as
>> input and creates the data for a beep sound with the given parameters,
>> which is then passed to the sound play function.
> [snip]
>> +++ b/drivers/sound/ti_sound.c
>> @@ -0,0 +1,119 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * (C) Copyright 2024 Texas Instruments Incorporated - https://www.ti.com/
>> + * Scaria M Kochidanadu, s-kochidan...@ti.com
>> + *
>> + * based on the uboot samsung sound driver, which is
>> + *
>> + * Copyright 2018 Google, LLC
>> + * Written by Simon Glass 
>> + */
>> +
>> +#include  /* boot information for Linux kernel */
>> +/* Pull in stuff for the build system */
>> +#ifdef DO_DEPS_ONLY
>> +#include 
>> +#endif
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
> 
> Please audit this list. I really am confused by .
> 

I will be removing this in v2 as it is not required.

>> +static int ti_sound_stop_play(struct udevice *dev)
>> +{
>> +/* This function is necassary to satisfy the function calls
>> + * in the Uboot command: sound play
>> + */
>> +return 0;
> 
> /*
>  * Like this...
>  */
> 
> [snip]
>> +static const struct udevice_id ti_sound_ids[] = {
>> +{ .compatible = "simple-audio-card" },
>> +{ }
>> +};
> 
> Adding an actual simple-audio-card framework for U-Boot would be great.
> This driver implies (and is?) TI-centric, instead. So lets rework this
> to be split appropriately? Thanks.
> 

I wanted to reuse the sound card DT node in the upstream kernel
device-tree. The U-boot upstrem repo does not have the node as it is
using an older version of DT.
But if using the simple-audio-card node is not preferred, then can we
create TI specific compatible and a separate DT node?


[PATCH] regulator: fixed: fix regulator-fixed-clock

2024-07-09 Thread John Keeping
For regulator-fixed-clock, the device's private data is never set so in
fixed_clock_regulator_set_enable() is null and the function cannot
complete successfully.

Rename the _plat structure to _priv to better represent its role and set
this as the private data.  As shown by the set_enable() function and by
using the same .of_to_plat hook as regulator-fixed, the platform data is
regulator_common_plat so also set .plat_auto correctly.

Finally, set up the private data by adding a .probe function to look up
the clock and set the member variable.

Fixes: f3b5100aff3 ("regulator: fixed: add possibility to enable by clock")
Signed-off-by: John Keeping 
---
 drivers/power/regulator/fixed.c | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c
index 98c89bf2aff..996da41546a 100644
--- a/drivers/power/regulator/fixed.c
+++ b/drivers/power/regulator/fixed.c
@@ -17,7 +17,7 @@
 
 #include "regulator_common.h"
 
-struct fixed_clock_regulator_plat {
+struct fixed_clock_regulator_priv {
struct clk *enable_clock;
unsigned int clk_enable_counter;
 };
@@ -83,14 +83,14 @@ static int fixed_regulator_set_enable(struct udevice *dev, 
bool enable)
 
 static int fixed_clock_regulator_get_enable(struct udevice *dev)
 {
-   struct fixed_clock_regulator_plat *priv = dev_get_priv(dev);
+   struct fixed_clock_regulator_priv *priv = dev_get_priv(dev);
 
return priv->clk_enable_counter > 0;
 }
 
 static int fixed_clock_regulator_set_enable(struct udevice *dev, bool enable)
 {
-   struct fixed_clock_regulator_plat *priv = dev_get_priv(dev);
+   struct fixed_clock_regulator_priv *priv = dev_get_priv(dev);
struct regulator_common_plat *plat = dev_get_plat(dev);
int ret = 0;
 
@@ -113,6 +113,17 @@ static int fixed_clock_regulator_set_enable(struct udevice 
*dev, bool enable)
return ret;
 }
 
+static int fixed_clock_regulator_probe(struct udevice *dev)
+{
+   struct fixed_clock_regulator_priv *priv = dev_get_priv(dev);
+
+   priv->enable_clock = devm_clk_get(dev, NULL);
+   if (IS_ERR(priv->enable_clock))
+   return PTR_ERR(priv->enable_clock);
+
+   return 0;
+}
+
 static const struct dm_regulator_ops fixed_regulator_ops = {
.get_value  = fixed_regulator_get_value,
.get_current= fixed_regulator_get_current,
@@ -149,6 +160,8 @@ U_BOOT_DRIVER(regulator_fixed_clock) = {
.id = UCLASS_REGULATOR,
.ops = _clock_regulator_ops,
.of_match = fixed_clock_regulator_ids,
+   .probe = fixed_clock_regulator_probe,
.of_to_plat = fixed_regulator_of_to_plat,
-   .plat_auto = sizeof(struct fixed_clock_regulator_plat),
+   .plat_auto = sizeof(struct regulator_common_plat),
+   .priv_auto = sizeof(struct fixed_clock_regulator_priv),
 };
-- 
2.45.2



Re: [PATCH] eth: asix88179: reset during probe

2024-07-09 Thread Mattijs Korpershoek
Hi Marek,

On mar., juil. 09, 2024 at 13:13, Marek Vasut  wrote:

> On 7/9/24 10:39 AM, Mattijs Korpershoek wrote:
>> Hi Caleb,
>
> Hi,
>
>> Thank you for the patch.
>> 
>> On mar., juin 18, 2024 at 16:57, Caleb Connolly  
>> wrote:
>> 
>>> In some cases (consistently in my case with an embedded board) the
>>> ethernet controller will time out on the first init but always succeed
>>> after reset.
>>>
>>> Let's reset the controller during probe so we always start with it in a
>>> known state, and don't have wait for the first asix_wait_link() to
>>> time out.
>>>
>>> Signed-off-by: Caleb Connolly 
>> 
>> Reviewed-by: Mattijs Korpershoek 
>> 
>>> ---
>>> I see this behaviour consistently across three Qualcomm platforms that use 
>>> this
>>> controller.
>>> ---
>>>   drivers/usb/eth/asix88179.c | 6 ++
>>>   1 file changed, 6 insertions(+)
>
> Do you want to pick it via usb-gadget tree or shall I pick it via usb tree ?

According to get_maintainer.pl, it should be you :)

./scripts/get_maintainer.pl -- drivers/usb/eth/asix88179.c
Marek Vasut  (maintainer:USB)
Tom Rini  (maintainer:THE 
REST,authored:3/3=100%,added_lines:1/1=100%,removed_lines:2/2=100%)
Mattijs Korpershoek  (commit_signer:1/3=33%)
u-boot@lists.denx.de (open list)

If you are okay with that, please pick it up.

Thanks!
Mattijs


[PATCH] amd: Enable the NFS command for Versal2

2024-07-09 Thread Prasad Kummari
Enabled the default utilization of the NFS command on Versal2
platform to facilitate booting images through the network using
the NFS protocol

Signed-off-by: Prasad Kummari 
---
 configs/amd_versal2_virt_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/amd_versal2_virt_defconfig 
b/configs/amd_versal2_virt_defconfig
index 2d611f84cd..bbe7db4fb3 100644
--- a/configs/amd_versal2_virt_defconfig
+++ b/configs/amd_versal2_virt_defconfig
@@ -46,6 +46,7 @@ CONFIG_CMD_USB=y
 CONFIG_BOOTP_MAY_FAIL=y
 CONFIG_BOOTP_BOOTFILESIZE=y
 CONFIG_CMD_TFTPPUT=y
+CONFIG_CMD_NFS=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EFIDEBUG=y
 CONFIG_CMD_TIME=y
-- 
2.25.1



Re: [PATCH] eth: asix88179: reset during probe

2024-07-09 Thread Marek Vasut

On 7/9/24 10:39 AM, Mattijs Korpershoek wrote:

Hi Caleb,


Hi,


Thank you for the patch.

On mar., juin 18, 2024 at 16:57, Caleb Connolly  
wrote:


In some cases (consistently in my case with an embedded board) the
ethernet controller will time out on the first init but always succeed
after reset.

Let's reset the controller during probe so we always start with it in a
known state, and don't have wait for the first asix_wait_link() to
time out.

Signed-off-by: Caleb Connolly 


Reviewed-by: Mattijs Korpershoek 


---
I see this behaviour consistently across three Qualcomm platforms that use this
controller.
---
  drivers/usb/eth/asix88179.c | 6 ++
  1 file changed, 6 insertions(+)


Do you want to pick it via usb-gadget tree or shall I pick it via usb tree ?


[PATCH 6/6] zlib: Remove incorrect ZLIB_VERSION

2024-07-09 Thread Christophe Leroy
From: Michal Simek 

Get rid of zlib version which is not correct because of U-Boot related
changes and various CVE backports.

The change in inspired by Linux kernel commit 4f3865fb57a0 ("[PATCH]
zlib_inflate: Upgrade library code to a recent version") which described
ZLIB_VERSION removal as

"This patch also removes ZLIB_VERSION as it no longer has a correct value.
We don't need version checks anyway as the kernel's module handling will
take care of that for us.  This removal is also more in keeping with the
zlib author's wishes (http://www.zlib.net/zlib_faq.html#faq24) and I've
added something to the zlib.h header to note its a modified version."

Author describes wish to follow this guidance at
https://www.zlib.net/zlib_faq.html#faq24:
"The license says that altered source versions must be "plainly marked". So
what exactly do I need to do to meet that requirement?

You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
particular, the final version number needs to be changed to f, and an
identification string should be appended to ZLIB_VERSION. Version numbers
x.x.x.f are reserved for modifications to zlib by others than the zlib
maintainers. For example, if the version of the base zlib you are altering
is 1.2.3.4, then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
ZLIB_VERSION to something like 1.2.3.f-zachary-mods-v3. You can also update
the version strings in deflate.c and inftrees.c."

But U-Boot is not exact version that's why following the same style which
has been used by Linux kernel where ZLIB_VERSION is completely removed.

Signed-off-by: Michal Simek 
Signed-off-by: Christophe Leroy 
---
 include/u-boot/zlib.h | 16 ++--
 lib/gzip.c|  2 +-
 lib/zlib/deflate.c| 13 +++--
 lib/zlib/inflate.c|  9 +++--
 lib/zlib/zutil.c  |  1 -
 5 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/include/u-boot/zlib.h b/include/u-boot/zlib.h
index a33cc8780d..ee19f46095 100644
--- a/include/u-boot/zlib.h
+++ b/include/u-boot/zlib.h
@@ -49,9 +49,6 @@
 extern "C" {
 #endif
 
-#define ZLIB_VERSION "1.2.3"
-#define ZLIB_VERNUM 0x1230
-
 /* #include "zconf.h" *//* included directly here */
 /* zconf.h -- configuration of the zlib compression library
  * Copyright (C) 1995-2005 Jean-loup Gailly.
@@ -484,7 +481,6 @@ typedef gz_header FAR *gz_headerp;
 #define Z_DATA_ERROR   (-3)
 #define Z_MEM_ERROR(-4)
 #define Z_BUF_ERROR(-5)
-#define Z_VERSION_ERROR (-6)
 /* Return codes for the compression/decompression functions. Negative
  * values are errors, positive values are used for special but normal events.
  */
@@ -523,11 +519,11 @@ typedef gz_header FAR *gz_headerp;
 
 ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
 ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
-   const char *version, int stream_size));
+   int stream_size));
 ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
 ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
int windowBits, int memLevel,
-   int strategy, const char *version,
+   int strategy,
int stream_size));
 ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
 ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
@@ -553,7 +549,7 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
 
 
 ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
-   const char *version, int stream_size));
+   int stream_size));
 ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
 /*
 inflate decompresses as much data as possible, and stops when the input
@@ -743,11 +739,11 @@ ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf 
*destLen,
 */
 
 ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
-  const char *version, int stream_size));
+  int stream_size));
 #define inflateInit(strm) \
-   inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
+   inflateInit_((strm), sizeof(z_stream))
 #define inflateInit2(strm, windowBits) \
-   inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
+   inflateInit2_((strm), (windowBits), sizeof(z_stream))
 
 #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
struct internal_state {int dummy;}; /* hack for buggy compilers */
diff --git a/lib/gzip.c b/lib/gzip.c
index 5d9c19598d..a9a3df524d 100644
--- a/lib/gzip.c
+++ b/lib/gzip.c
@@ -67,7 +67,7 @@ int zzip(void *dst, unsigned long *lenp, unsigned char *src,
 
r = deflateInit2_(, Z_BEST_SPEED, Z_DEFLATED, window,
DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
-   ZLIB_VERSION, sizeof(z_stream));
+   sizeof(z_stream));
if (r != Z_OK) {
printf ("Error: deflateInit2_() 

[PATCH 5/6] zlib: Misc unrelated updates

2024-07-09 Thread Christophe Leroy
From: Michal Simek 

This patch adds misc updates to better match zlib original code.

It is split out of a previous version of
patch ("zlib: Port fix for CVE-2016-9841 to U-Boot)
as those changes were unrelated.

Signed-off-by: Michal Simek 
[chleroy: Split out of patch ("zlib: Port fix for CVE-2016-9841 to U-Boot)]
Signed-off-by: Christophe Leroy 
---
 lib/zlib/inffast.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/zlib/inffast.c b/lib/zlib/inffast.c
index 19236f1e23..b5a0adcce6 100644
--- a/lib/zlib/inffast.c
+++ b/lib/zlib/inffast.c
@@ -1,5 +1,5 @@
 /* inffast.c -- fast decoding
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2008, 2010, 2013 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -47,12 +47,13 @@
   requires strm->avail_out >= 258 for each loop to avoid checking for
   output space.
  */
-void inflate_fast(z_streamp strm, unsigned start)
-/* start: inflate()'s starting value for strm->avail_out */
+void ZLIB_INTERNAL inflate_fast(strm, start)
+z_streamp strm;
+unsigned start; /* inflate()'s starting value for strm->avail_out */
 {
 struct inflate_state FAR *state;
-unsigned char FAR *in;  /* local strm->next_in */
-unsigned char FAR *last;/* while in < last, enough input available */
+z_const unsigned char FAR *in;  /* local strm->next_in */
+z_const unsigned char FAR *last;/* have enough input while in < last */
 unsigned char FAR *out; /* local strm->next_out */
 unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
 unsigned char FAR *end; /* while out < end, enough space available */
@@ -177,7 +178,8 @@ void inflate_fast(z_streamp strm, unsigned start)
 if (dist > op) {/* see if copy from window */
 op = dist - op; /* distance back in window */
 if (op > whave) {
-strm->msg = (char *)"invalid distance too far back";
+strm->msg =
+(char *)"invalid distance too far back";
 state->mode = BAD;
 break;
 }
-- 
2.44.0



[PATCH 4/6] zlib: Port fix for CVE-2016-9841 to U-Boot

2024-07-09 Thread Christophe Leroy
From: Michal Simek 

The patch corresponds to zlib commit at
https://github.com/madler/zlib/commit/9aaec95e82117c1cb0f9624264c3618fc380cecb
which declares that it is fixing CVE-2016-9841.
Here is c description from zlib:
"Use post-increment only in inffast.c.

An old inffast.c optimization turns out to not be optimal anymore
with modern compilers, and furthermore was not compliant with the
C standard, for which decrementing a pointer before its allocated
memory is undefined. Per the recommendation of a security audit of
the zlib code by Trail of Bits and TrustInSoft, in support of the
Mozilla Foundation, this "optimization" was removed, in order to
avoid the possibility of undefined behavior."

Origin patch also updates the code when
INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR is present but this code is not
the part of U-Boot hence it is ignored.
Also do not deal with state->sane variable which requires other changes
which are also not the part of zlib.

Commit 92faa8b10918 ("zlib: handle overflow while calculating available
stream input size") is kept in inffast.c too not to break described case.

Commit cd514aeb996e ("zlib: Optimize decompression") is also kept,
otherwise linux kernel decompression is 40% longer on powerpc 8xx
platform and it leads to watchdog resets.

Signed-off-by: Michal Simek 
[chleroy: Restore optimisation from commit cd514aeb996e ("zlib: Optimize 
decompression") and fix zlib.h]
Signed-off-by: Christophe Leroy 
---
 lib/zlib/inffast.c | 89 ++
 lib/zlib/zlib.h|  1 -
 2 files changed, 34 insertions(+), 56 deletions(-)

diff --git a/lib/zlib/inffast.c b/lib/zlib/inffast.c
index 29ec72fce5..19236f1e23 100644
--- a/lib/zlib/inffast.c
+++ b/lib/zlib/inffast.c
@@ -12,27 +12,6 @@
 
 #ifndef ASMINF
 
-/* Allow machine dependent optimization for post-increment or pre-increment.
-   Based on testing to date,
-   Pre-increment preferred for:
-   - PowerPC G3 (Adler)
-   - MIPS R5000 (Randers-Pehrson)
-   Post-increment preferred for:
-   - none
-   No measurable difference:
-   - Pentium III (Anderson)
-   - M68060 (Nikl)
- */
-#ifdef POSTINC
-#  define OFF 0
-#  define PUP(a) *(a)++
-#  define UP_UNALIGNED(a) get_unaligned((a)++)
-#else
-#  define OFF 1
-#  define PUP(a) *++(a)
-#  define UP_UNALIGNED(a) get_unaligned(++(a))
-#endif
-
 /*
Decode literal, length, and distance codes and write out the resulting
literal and match bytes until either not enough input or output is
@@ -99,7 +78,7 @@ void inflate_fast(z_streamp strm, unsigned start)
 
 /* copy state to local variables */
 state = (struct inflate_state FAR *)strm->state;
-in = strm->next_in - OFF;
+in = strm->next_in;
 last = in + (strm->avail_in - 5);
 if (in > last && strm->avail_in > 5) {
 /*
@@ -109,7 +88,7 @@ void inflate_fast(z_streamp strm, unsigned start)
strm->avail_in = 0x - (uintptr_t)in;
 last = in + (strm->avail_in - 5);
 }
-out = strm->next_out - OFF;
+out = strm->next_out;
 beg = out - (start - strm->avail_out);
 end = out + (strm->avail_out - 257);
 #ifdef INFLATE_STRICT
@@ -130,9 +109,9 @@ void inflate_fast(z_streamp strm, unsigned start)
input data or output space */
 do {
 if (bits < 15) {
-hold += (unsigned long)(PUP(in)) << bits;
+hold += (unsigned long)(*in++) << bits;
 bits += 8;
-hold += (unsigned long)(PUP(in)) << bits;
+hold += (unsigned long)(*in++) << bits;
 bits += 8;
 }
 here = lcode[hold & lmask];
@@ -145,14 +124,14 @@ void inflate_fast(z_streamp strm, unsigned start)
 Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
 "inflate: literal '%c'\n" :
 "inflate: literal 0x%02x\n", here.val));
-PUP(out) = (unsigned char)(here.val);
+*out++ = (unsigned char)(here.val);
 }
 else if (op & 16) { /* length base */
 len = (unsigned)(here.val);
 op &= 15;   /* number of extra bits */
 if (op) {
 if (bits < op) {
-hold += (unsigned long)(PUP(in)) << bits;
+hold += (unsigned long)(*in++) << bits;
 bits += 8;
 }
 len += (unsigned)hold & ((1U << op) - 1);
@@ -161,9 +140,9 @@ void inflate_fast(z_streamp strm, unsigned start)
 }
 Tracevv((stderr, "inflate: length %u\n", len));
 if (bits < 15) {
-hold += (unsigned long)(PUP(in)) << bits;
+hold += (unsigned long)(*in++) << bits;
 bits += 8;
-hold += (unsigned long)(PUP(in)) << bits;
+hold += (unsigned long)(*in++) << bits;
 bits += 8;
 }
 here = dcode[hold & dmask];
@@ -176,10 

[PATCH 3/6] zlib: Fix inflate_fast() when POSTINC macro is set

2024-07-09 Thread Christophe Leroy
inflate_fast() implements possibility to be build with
POSTINC set or unset. That POSTINC macro was introduced by
commit e89516f031db ("zlib: split up to match original source tree")
but forced to #undef in zlib.h.

However, in the meantime that commit removed UP_UNALIGNED() macro
introduced by commit cd514aeb996e ("zlib: Optimize decompression")
that was meant to implement proper behaviour depending on POSTINC.

In addition, commit cd514aeb996e ("zlib: Optimize decompression") has
a bug for when POSTINC is set in the following pointer arithmetic:

pat16 = *(sout-2+2*OFF)

The intension is to remove 2 bytes when OFF is 0, but sout being a
short, this leads to removing 4 bytes instead of 2. The bug in not
visible when OFF is set to 1 which has always been the case until now.

In preparation for followup patch that will activate POSTINC, add back
UP_UNALIGNED() macro and fix the above pointer calculation.

Fixes: cd514aeb996e ("zlib: Optimize decompression")
Cc: Michal Simek 
Signed-off-by: Christophe Leroy 
---
 lib/zlib/inffast.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/zlib/inffast.c b/lib/zlib/inffast.c
index bdaa6d0dc5..29ec72fce5 100644
--- a/lib/zlib/inffast.c
+++ b/lib/zlib/inffast.c
@@ -26,9 +26,11 @@
 #ifdef POSTINC
 #  define OFF 0
 #  define PUP(a) *(a)++
+#  define UP_UNALIGNED(a) get_unaligned((a)++)
 #else
 #  define OFF 1
 #  define PUP(a) *++(a)
+#  define UP_UNALIGNED(a) get_unaligned(++(a))
 #endif
 
 /*
@@ -270,14 +272,14 @@ void inflate_fast(z_streamp strm, unsigned start)
sfrom = (unsigned short *)(from - OFF);
loops = len >> 1;
do
-   PUP(sout) = get_unaligned(++sfrom);
+   PUP(sout) = UP_UNALIGNED(sfrom);
while (--loops);
out = (unsigned char *)sout + OFF;
from = (unsigned char *)sfrom + OFF;
} else { /* dist == 1 or dist == 2 */
unsigned short pat16;
 
-   pat16 = *(sout-2+2*OFF);
+   pat16 = *(sout - 1 + OFF);
if (dist == 1)
 #if defined(__BIG_ENDIAN)
pat16 = (pat16 & 0xff) | ((pat16 & 0xff ) << 8);
-- 
2.44.0



[PATCH 2/6] zlib: Rename write variable to wnext (window write index)

2024-07-09 Thread Christophe Leroy
From: Michal Simek 

There is no particular patch/description which described the reason for
this change but it was done as the part of zlib 1.2.3.5 release done by
zlib commit d004b047838a ("zlib 1.2.3.5"). It is preparation for followup
patch.

Signed-off-by: Michal Simek 
Signed-off-by: Christophe Leroy 
---
 lib/zlib/inffast.c | 20 ++--
 lib/zlib/inflate.c | 22 +++---
 lib/zlib/inflate.h |  2 +-
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/lib/zlib/inffast.c b/lib/zlib/inffast.c
index d61cf0e72a..bdaa6d0dc5 100644
--- a/lib/zlib/inffast.c
+++ b/lib/zlib/inffast.c
@@ -80,7 +80,7 @@ void inflate_fast(z_streamp strm, unsigned start)
 #endif
 unsigned wsize; /* window size or zero if not using window */
 unsigned whave; /* valid bytes in the window */
-unsigned write; /* window write index */
+unsigned wnext; /* window write index */
 unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */
 unsigned long hold; /* local strm->hold */
 unsigned bits;  /* local strm->bits */
@@ -115,7 +115,7 @@ void inflate_fast(z_streamp strm, unsigned start)
 #endif
 wsize = state->wsize;
 whave = state->whave;
-write = state->write;
+wnext = state->wnext;
 window = state->window;
 hold = state->hold;
 bits = state->bits;
@@ -201,7 +201,7 @@ void inflate_fast(z_streamp strm, unsigned start)
 break;
 }
 from = window - OFF;
-if (write == 0) {   /* very common case */
+if (wnext == 0) {   /* very common case */
 from += wsize - op;
 if (op < len) { /* some from window */
 len -= op;
@@ -211,17 +211,17 @@ void inflate_fast(z_streamp strm, unsigned start)
 from = out - dist;  /* rest from output */
 }
 }
-else if (write < op) {  /* wrap around window */
-from += wsize + write - op;
-op -= write;
+else if (wnext < op) {  /* wrap around window */
+from += wsize + wnext - op;
+op -= wnext;
 if (op < len) { /* some from end of window */
 len -= op;
 do {
 PUP(out) = PUP(from);
 } while (--op);
 from = window - OFF;
-if (write < len) {  /* some from start of window */
-op = write;
+if (wnext < len) {  /* some from start of window */
+op = wnext;
 len -= op;
 do {
 PUP(out) = PUP(from);
@@ -231,7 +231,7 @@ void inflate_fast(z_streamp strm, unsigned start)
 }
 }
 else {  /* contiguous in window */
-from += write - op;
+from += wnext - op;
 if (op < len) { /* some from window */
 len -= op;
 do {
@@ -343,7 +343,7 @@ void inflate_fast(z_streamp strm, unsigned start)
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- Using bit fields for code structure
- Different op definition to avoid & for extra bits (do & for table bits)
-   - Three separate decoding do-loops for direct, window, and write == 0
+   - Three separate decoding do-loops for direct, window, and wnext == 0
- Special case for distance > 1 copies to do overlapped load and store copy
- Explicit branch predictions (based on measured branch probabilities)
- Deferring match copy and interspersed it with decoding subsequent codes
diff --git a/lib/zlib/inflate.c b/lib/zlib/inflate.c
index 8f767b7b9d..79c9e991aa 100644
--- a/lib/zlib/inflate.c
+++ b/lib/zlib/inflate.c
@@ -21,7 +21,7 @@ int ZEXPORT inflateReset(z_streamp strm)
 state->head = Z_NULL;
 state->wsize = 0;
 state->whave = 0;
-state->write = 0;
+state->wnext = 0;
 state->hold = 0;
 state->bits = 0;
 state->lencode = state->distcode = state->next = state->codes;
@@ -115,7 +115,7 @@ local int updatewindow(z_streamp strm, unsigned out)
 /* if window not in use yet, initialize */
 if (state->wsize == 0) {
 state->wsize = 1U << state->wbits;
-state->write = 0;
+state->wnext = 0;
 state->whave = 0;
 }
 
@@ -123,22 +123,22 @@ local int updatewindow(z_streamp strm, unsigned out)
 copy = out - 

[PATCH 1/6] zlib: Rename this variable to here (current decoding table entry)

2024-07-09 Thread Christophe Leroy
From: Michal Simek 

There is no particular patch/description which described the reason for
this change but it was done as the part of zlib 1.2.3.5 release done by
zlib commit 639be997883d ("zlib 1.2.3.3") It is preparation for followup
patch.

Signed-off-by: Michal Simek 
Signed-off-by: Christophe Leroy 
---
 lib/zlib/inffast.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/lib/zlib/inffast.c b/lib/zlib/inffast.c
index e3c7f3b892..d61cf0e72a 100644
--- a/lib/zlib/inffast.c
+++ b/lib/zlib/inffast.c
@@ -88,7 +88,7 @@ void inflate_fast(z_streamp strm, unsigned start)
 code const FAR *dcode;  /* local strm->distcode */
 unsigned lmask; /* mask for first level of length codes */
 unsigned dmask; /* mask for first level of distance codes */
-code this;  /* retrieved table entry */
+code here;  /* retrieved table entry */
 unsigned op;/* code bits, operation, extra bits, or */
 /*  window position, window bytes to copy */
 unsigned len;   /* match length, unused bytes */
@@ -133,20 +133,20 @@ void inflate_fast(z_streamp strm, unsigned start)
 hold += (unsigned long)(PUP(in)) << bits;
 bits += 8;
 }
-this = lcode[hold & lmask];
+here = lcode[hold & lmask];
   dolen:
-op = (unsigned)(this.bits);
+op = (unsigned)(here.bits);
 hold >>= op;
 bits -= op;
-op = (unsigned)(this.op);
+op = (unsigned)(here.op);
 if (op == 0) {  /* literal */
-Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
 "inflate: literal '%c'\n" :
-"inflate: literal 0x%02x\n", this.val));
-PUP(out) = (unsigned char)(this.val);
+"inflate: literal 0x%02x\n", here.val));
+PUP(out) = (unsigned char)(here.val);
 }
 else if (op & 16) { /* length base */
-len = (unsigned)(this.val);
+len = (unsigned)(here.val);
 op &= 15;   /* number of extra bits */
 if (op) {
 if (bits < op) {
@@ -164,14 +164,14 @@ void inflate_fast(z_streamp strm, unsigned start)
 hold += (unsigned long)(PUP(in)) << bits;
 bits += 8;
 }
-this = dcode[hold & dmask];
+here = dcode[hold & dmask];
   dodist:
-op = (unsigned)(this.bits);
+op = (unsigned)(here.bits);
 hold >>= op;
 bits -= op;
-op = (unsigned)(this.op);
+op = (unsigned)(here.op);
 if (op & 16) {  /* distance base */
-dist = (unsigned)(this.val);
+dist = (unsigned)(here.val);
 op &= 15;   /* number of extra bits */
 if (bits < op) {
 hold += (unsigned long)(PUP(in)) << bits;
@@ -297,7 +297,7 @@ void inflate_fast(z_streamp strm, unsigned start)
 }
 }
 else if ((op & 64) == 0) {  /* 2nd level distance code */
-this = dcode[this.val + (hold & ((1U << op) - 1))];
+here = dcode[here.val + (hold & ((1U << op) - 1))];
 goto dodist;
 }
 else {
@@ -307,7 +307,7 @@ void inflate_fast(z_streamp strm, unsigned start)
 }
 }
 else if ((op & 64) == 0) {  /* 2nd level length code */
-this = lcode[this.val + (hold & ((1U << op) - 1))];
+here = lcode[here.val + (hold & ((1U << op) - 1))];
 goto dolen;
 }
 else if (op & 32) { /* end-of-block */
-- 
2.44.0



[PATCH 0/6] Resubmit series "zlib: Address CVE-2016-9841"

2024-07-09 Thread Christophe Leroy
This series reapplies the series that was merged by commit 4914263c9a14
("Merge patch series "zlib: Address CVE-2016-9841"") but then reverted
by commit bbacdd3ef776 ("Revert "Merge patch series "zlib: Address
CVE-2016-9841""") due to boot failure on powerpc/8xx platform induced
by the removal of the necessary optimatisation brought by
commit cd514aeb996e ("zlib: Optimize decompression").

In addition to the previous version, this series adds patch 3 to fix
inflate_fast() with post incremendation and removes the deletion of
commit cd514aeb996e ("zlib: Optimize decompression") by patch 4.
It also adds patch 5 which contains changes split out of patch 4 because
they are unrelated to the description of the patch.

CI passed on 
https://source.denx.de/u-boot/custodians/u-boot-mpc8xx/-/pipelines/21518

Christophe Leroy (1):
  zlib: Fix inflate_fast() when POSTINC macro is set

Michal Simek (5):
  zlib: Rename this variable to here (current decoding table entry)
  zlib: Rename write variable to wnext (window write index)
  zlib: Port fix for CVE-2016-9841 to U-Boot
  zlib: Misc unrelated updates
  zlib: Remove incorrect ZLIB_VERSION

 include/u-boot/zlib.h |  16 ++---
 lib/gzip.c|   2 +-
 lib/zlib/deflate.c|  13 +---
 lib/zlib/inffast.c| 147 +++---
 lib/zlib/inflate.c|  31 -
 lib/zlib/inflate.h|   2 +-
 lib/zlib/zlib.h   |   1 -
 lib/zlib/zutil.c  |   1 -
 8 files changed, 90 insertions(+), 123 deletions(-)

-- 
2.44.0



[PATCH v4 10/21] soc: qcom: rpmh-rsc: remaining U-Boot API changes

2024-07-09 Thread Caleb Connolly
Minor adjustments to fix building with U-Boot and work correctly as a
synchronous driver without interrupts. RPMh is fast enough that we can
get away with just firing off requests and assuming they complete.

U-Boot behaviour changes are annotated with a "U-Boot:" comment.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/rpmh-rsc.c | 78 +
 1 file changed, 29 insertions(+), 49 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index d4ef88dda184..566fa16baba9 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -134,16 +134,8 @@ enum {
  *  |  ..   |
  *  +---+
  */
 
-#define USECS_TO_CYCLES(time_usecs)\
-   xloops_to_cycles((time_usecs) * 0x10C7UL)
-
-static inline unsigned long xloops_to_cycles(u64 xloops)
-{
-   return (xloops * loops_per_jiffy * HZ) >> 32;
-}
-
 static u32 rpmh_rsc_reg_offset_ver_2_7[] = {
[RSC_DRV_TCS_OFFSET]= 672,
[RSC_DRV_CMD_OFFSET]= 20,
[DRV_SOLVER_CONFIG] = 0x04,
@@ -248,37 +240,18 @@ static void write_tcs_reg_sync(const struct rsc_drv *drv, 
int reg, int tcs_id,
  */
 static struct tcs_group *get_tcs_for_msg(struct rsc_drv *drv,
 const struct tcs_request *msg)
 {
-   int type;
-   struct tcs_group *tcs;
-
-   switch (msg->state) {
-   case RPMH_ACTIVE_ONLY_STATE:
-   type = ACTIVE_TCS;
-   break;
-   case RPMH_WAKE_ONLY_STATE:
-   type = WAKE_TCS;
-   break;
-   case RPMH_SLEEP_STATE:
-   type = SLEEP_TCS;
-   break;
-   default:
+   /*
+* U-Boot: since we're single threaded and running synchronously we can
+* just always used the first active TCS.
+*/
+   if (msg->state != RPMH_ACTIVE_ONLY_STATE) {
+   log_err("WARN: only ACTIVE_ONLY state supported\n");
return ERR_PTR(-EINVAL);
}
 
-   /*
-* If we are making an active request on a RSC that does not have a
-* dedicated TCS for active state use, then re-purpose a wake TCS to
-* send active votes. This is safe because we ensure any active-only
-* transfers have finished before we use it (maybe by running from
-* the last CPU in PM code).
-*/
-   tcs = >tcs[type];
-   if (msg->state == RPMH_ACTIVE_ONLY_STATE && !tcs->num_tcs)
-   tcs = >tcs[WAKE_TCS];
-
-   return tcs;
+   return >tcs[ACTIVE_TCS];
 }
 
 /**
  * __tcs_buffer_write() - Write to TCS hardware from a request; don't trigger.
@@ -298,11 +271,8 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int 
tcs_id, int cmd_id,
u32 cmd_enable = 0;
struct tcs_cmd *cmd;
int i, j;
 
-   /* Convert all commands to RR when the request has wait_for_compl set */
-   cmd_msgid |= msg->wait_for_compl ? CMD_MSGID_RESP_REQ : 0;
-
for (i = 0, j = cmd_id; i < msg->num_cmds; i++, j++) {
cmd = >cmds[i];
cmd_enable |= BIT(j);
msgid = cmd_msgid;
@@ -314,9 +284,11 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int 
tcs_id, int cmd_id,
 
write_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_MSGID], tcs_id, j, 
msgid);
write_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_ADDR], tcs_id, j, 
cmd->addr);
write_tcs_cmd(drv, drv->regs[RSC_DRV_CMD_DATA], tcs_id, j, 
cmd->data);
-   trace_rpmh_send_msg(drv, tcs_id, msg->state, j, msgid, cmd);
+   debug("tcs(m): %d [%s] cmd(n): %d msgid: %#x addr: %#x data: 
%#x complete: %d\n",
+ tcs_id, msg->state == RPMH_ACTIVE_ONLY_STATE ? "active" : 
"?", j, msgid,
+ cmd->addr, cmd->data, cmd->wait);
}
 
cmd_enable |= read_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id);
write_tcs_reg(drv, drv->regs[RSC_DRV_CMD_ENABLE], tcs_id, cmd_enable);
@@ -346,34 +318,28 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int 
tcs_id, int cmd_id,
  */
 int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg)
 {
struct tcs_group *tcs;
-   int tcs_id;
-
-   might_sleep();
+   int tcs_id, i;
+   u32 addr;
 
tcs = get_tcs_for_msg(drv, msg);
if (IS_ERR(tcs))
return PTR_ERR(tcs);
 
-   spin_lock_irq(>lock);
-
-   /* Wait forever for a free tcs. It better be there eventually! */
-   wait_event_lock_irq(drv->tcs_wait,
-   (tcs_id = claim_tcs_for_req(drv, tcs, msg)) >= 0,
-   drv->lock);
+   /* u-boot is single-threaded, always use the first TCS as we'll never 
conflict */
+   tcs_id = tcs->offset;
 
tcs->req[tcs_id - tcs->offset] = msg;
-   set_bit(tcs_id, 

[PATCH v4 21/21] qcom_defconfig: enable rpmh regulators

2024-07-09 Thread Caleb Connolly
Enable RPMh, cmd-db, and RPMh regulators. Additionally enable
CMD_REGULATOR for debugging.

Signed-off-by: Caleb Connolly 
---
 configs/qcom_defconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig
index 60a8e38cc6bb..8a55bb9af708 100644
--- a/configs/qcom_defconfig
+++ b/configs/qcom_defconfig
@@ -35,8 +35,9 @@ CONFIG_CMD_UFS=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_CAT=y
 CONFIG_CMD_BMP=y
 CONFIG_CMD_EFIDEBUG=y
+CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_LOG=y
 CONFIG_OF_LIVE=y
 CONFIG_BUTTON_QCOM_PMIC=y
 CONFIG_CLK=y
@@ -90,11 +91,15 @@ CONFIG_PINCTRL_QCOM_SM8650=y
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_QCOM=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_QCOM_RPMH=y
 CONFIG_SCSI=y
 CONFIG_MSM_SERIAL=y
 CONFIG_MSM_GENI_SERIAL=y
+CONFIG_SOC_QCOM=y
+CONFIG_QCOM_COMMAND_DB=y
+CONFIG_QCOM_RPMH=y
 CONFIG_SPMI_MSM=y
 CONFIG_SYSINFO=y
 CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y

-- 
2.45.2



[PATCH v4 18/21] power: regulator: qcom-rpmh-regulator: remove unused regulators

2024-07-09 Thread Caleb Connolly
Initially just include the few regulators needed for the RB5 board.
Others can be added back as-needed.

Signed-off-by: Caleb Connolly 
---
 drivers/power/regulator/qcom-rpmh-regulator.c | 1281 -
 1 file changed, 1281 deletions(-)

diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c 
b/drivers/power/regulator/qcom-rpmh-regulator.c
index 089623f3a2b9..2a8e8f9ac444 100644
--- a/drivers/power/regulator/qcom-rpmh-regulator.c
+++ b/drivers/power/regulator/qcom-rpmh-regulator.c
@@ -338,68 +338,8 @@ static unsigned int rpmh_regulator_vrm_get_mode(struct 
regulator_dev *rdev)
 
return vreg->mode;
 }
 
-/**
- * rpmh_regulator_vrm_get_optimum_mode() - get the mode based on the  load
- * @rdev:  Regulator device pointer for the rpmh-regulator
- * @input_uV:  Input voltage
- * @output_uV: Output voltage
- * @load_uA:   Aggregated load current in microamps
- *
- * This function is used in the regulator_ops for VRM type RPMh regulator
- * devices.
- *
- * Return: 0 on success, errno on failure
- */
-static unsigned int rpmh_regulator_vrm_get_optimum_mode(
-   struct regulator_dev *rdev, int input_uV, int output_uV, int load_uA)
-{
-   struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
-
-   if (load_uA >= vreg->hw_data->hpm_min_load_uA)
-   return REGULATOR_MODE_NORMAL;
-   else
-   return REGULATOR_MODE_IDLE;
-}
-
-static int rpmh_regulator_vrm_set_bypass(struct regulator_dev *rdev,
-   bool enable)
-{
-   struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
-   int ret;
-
-   if (vreg->bypassed == enable)
-   return 0;
-
-   ret = rpmh_regulator_vrm_set_mode_bypass(vreg, vreg->mode, enable);
-   if (!ret)
-   vreg->bypassed = enable;
-
-   return ret;
-}
-
-static int rpmh_regulator_vrm_get_bypass(struct regulator_dev *rdev,
-   bool *enable)
-{
-   struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
-
-   *enable = vreg->bypassed;
-
-   return 0;
-}
-
-static const struct regulator_ops rpmh_regulator_vrm_ops = {
-   .enable = rpmh_regulator_enable,
-   .disable= rpmh_regulator_disable,
-   .is_enabled = rpmh_regulator_is_enabled,
-   .set_voltage_sel= rpmh_regulator_vrm_set_voltage_sel,
-   .get_voltage_sel= rpmh_regulator_vrm_get_voltage_sel,
-   .list_voltage   = regulator_list_voltage_linear_range,
-   .set_mode   = rpmh_regulator_vrm_set_mode,
-   .get_mode   = rpmh_regulator_vrm_get_mode,
-};
-
 static const struct regulator_ops rpmh_regulator_vrm_drms_ops = {
.enable = rpmh_regulator_enable,
.disable= rpmh_regulator_disable,
.is_enabled = rpmh_regulator_is_enabled,
@@ -410,331 +350,8 @@ static const struct regulator_ops 
rpmh_regulator_vrm_drms_ops = {
.get_mode   = rpmh_regulator_vrm_get_mode,
.get_optimum_mode   = rpmh_regulator_vrm_get_optimum_mode,
 };
 
-static const struct regulator_ops rpmh_regulator_vrm_bypass_ops = {
-   .enable = rpmh_regulator_enable,
-   .disable= rpmh_regulator_disable,
-   .is_enabled = rpmh_regulator_is_enabled,
-   .set_voltage_sel= rpmh_regulator_vrm_set_voltage_sel,
-   .get_voltage_sel= rpmh_regulator_vrm_get_voltage_sel,
-   .list_voltage   = regulator_list_voltage_linear_range,
-   .set_mode   = rpmh_regulator_vrm_set_mode,
-   .get_mode   = rpmh_regulator_vrm_get_mode,
-   .set_bypass = rpmh_regulator_vrm_set_bypass,
-   .get_bypass = rpmh_regulator_vrm_get_bypass,
-};
-
-static const struct regulator_ops rpmh_regulator_xob_ops = {
-   .enable = rpmh_regulator_enable,
-   .disable= rpmh_regulator_disable,
-   .is_enabled = rpmh_regulator_is_enabled,
-};
-
-/**
- * rpmh_regulator_init_vreg() - initialize all attributes of an rpmh-regulator
- * @vreg:  Pointer to the individual rpmh-regulator resource
- * @dev:   Pointer to the top level rpmh-regulator PMIC 
device
- * @node:  Pointer to the individual rpmh-regulator resource
- * device node
- * @pmic_id:   String used to identify the top level rpmh-regulator
- * PMIC device on the board
- * @pmic_rpmh_data:Pointer to a null-terminated array of rpmh-regulator
- * resources defined for the top level PMIC device
- *
- * Return: 0 on success, errno on failure
- */
-static int rpmh_regulator_init_vreg(struct rpmh_vreg *vreg, struct device *dev,
-   struct device_node *node, const char *pmic_id,
-   const struct 

[PATCH v4 20/21] power: regulator: qcom-rpmh-regulator: adjust probe for U-Boot

2024-07-09 Thread Caleb Connolly
Refactor initialization to use U-Boot's driver model and API.

Signed-off-by: Caleb Connolly 
---
 drivers/power/regulator/qcom-rpmh-regulator.c | 136 +++---
 1 file changed, 102 insertions(+), 34 deletions(-)

diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c 
b/drivers/power/regulator/qcom-rpmh-regulator.c
index b716b380c148..06fd3f31956f 100644
--- a/drivers/power/regulator/qcom-rpmh-regulator.c
+++ b/drivers/power/regulator/qcom-rpmh-regulator.c
@@ -411,66 +411,134 @@ static const struct rpmh_vreg_init_data 
pm8150l_vreg_data[] = {
RPMH_VREG("ldo11",  "ldo%s11", _pldo,  "vdd-l7-l11"),
{}
 };
 
-static int rpmh_regulator_probe(struct platform_device *pdev)
+/* probe an individual regulator */
+static int rpmh_regulator_probe(struct udevice *dev)
 {
-   struct device *dev = >dev;
-   const struct rpmh_vreg_init_data *vreg_data;
-   struct device_node *node;
-   struct rpmh_vreg *vreg;
-   const char *pmic_id;
-   int ret;
+   const struct rpmh_vreg_init_data *init_data;
+   struct rpmh_vreg *priv;
+   struct dm_regulator_uclass_plat *plat_data;
 
-   vreg_data = of_device_get_match_data(dev);
-   if (!vreg_data)
+   init_data = (const struct rpmh_vreg_init_data 
*)dev_get_driver_data(dev);
+   priv = dev_get_priv(dev);
+   plat_data = dev_get_uclass_plat(dev);
+
+   priv->dev = dev;
+   priv->addr = cmd_db_read_addr(dev->name);
+   if (!priv->addr) {
+   dev_err(dev, "Failed to read RPMh address for %s\n", dev->name);
return -ENODEV;
-
-   ret = of_property_read_string(dev->of_node, "qcom,pmic-id", _id);
-   if (ret < 0) {
-   dev_err(dev, "qcom,pmic-id missing in DT node\n");
-   return ret;
}
 
-   for_each_available_child_of_node(dev->of_node, node) {
-   vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL);
-   if (!vreg) {
-   of_node_put(node);
+   priv->hw_data = init_data->hw_data;
+   priv->enabled = -EINVAL;
+   priv->uv = -ENOTRECOVERABLE;
+   if (ofnode_read_u32(dev_ofnode(dev), "regulator-initial-mode", 
>mode))
+   priv->mode = -EINVAL;
+
+   plat_data->mode = priv->hw_data->pmic_mode_map;
+   plat_data->mode_count = priv->hw_data->n_modes;
+
+   return 0;
+}
+
+/* for non-drm, xob, or bypass regulators add additional driver definitions */
+U_BOOT_DRIVER(rpmh_regulator_drm) = {
+   .name = "rpmh_regulator_drm",
+   .id = UCLASS_REGULATOR,
+   .probe = rpmh_regulator_probe,
+   .priv_auto = sizeof(struct rpmh_vreg),
+   .ops = _regulator_vrm_drms_ops,
+};
+
+/* This driver intentionally only supports a subset of the available 
regulators.
+ * This function checks to see if a given regulator node in DT matches a 
regulator
+ * defined in the driver.
+ */
+static const struct rpmh_vreg_init_data *
+vreg_get_init_data(const struct rpmh_vreg_init_data *init_data, ofnode node)
+{
+   const struct rpmh_vreg_init_data *data;
+
+   for (data = init_data; data->name; data++) {
+   if (!strcmp(data->name, ofnode_get_name(node)))
+   return data;
+   }
+
+   return NULL;
+}
+
+static int rpmh_regulators_bind(struct udevice *dev)
+{
+   const struct rpmh_vreg_init_data *init_data, *data;
+   const char *pmic_id;
+   char *name;
+   struct driver *drv;
+   ofnode node;
+   int ret;
+   size_t namelen;
+
+   init_data = (const struct rpmh_vreg_init_data 
*)dev_get_driver_data(dev);
+   if (!init_data) {
+   dev_err(dev, "No RPMh regulator init data\n");
+   return -ENODEV;
+   }
+
+   pmic_id = ofnode_read_string(dev_ofnode(dev), "qcom,pmic-id");
+   if (!pmic_id) {
+   dev_err(dev, "No PMIC ID\n");
+   return -ENODEV;
+   }
+
+   drv = lists_driver_lookup_name("rpmh_regulator_drm");
+
+   ofnode_for_each_subnode(node, dev_ofnode(dev)) {
+   data = vreg_get_init_data(init_data, node);
+   if (!data)
+   continue;
+
+   /* %s is replaced with pmic_id, so subtract 2, then add 1 for 
the null terminator */
+   namelen = strlen(data->resource_name) + strlen(pmic_id) - 1;
+   name = devm_kzalloc(dev, namelen, GFP_KERNEL);
+   ret = snprintf(name, namelen, data->resource_name, pmic_id);
+   if (ret < 0 || ret >= namelen) {
+   dev_err(dev, "Failed to create RPMh regulator name\n");
return -ENOMEM;
}
 
-   ret = rpmh_regulator_init_vreg(vreg, dev, node, pmic_id,
-   vreg_data);
+   ret = device_bind_with_driver_data(dev, drv, name, (ulong)data,
+  node, NULL);
if (ret < 0) {
-  

[PATCH v4 19/21] power: regulator: qcom-rpmh-regulator: port ops to U-Boot

2024-07-09 Thread Caleb Connolly
Port over the regulator ops to U-Boot's regulator API. Add back the
pmic5 mode map using U-Boot dm_regulator_mode API and adjust the
pmic5_pldo and pmic5_pldo_lv definitions. No functional changes.

Signed-off-by: Caleb Connolly 
---
 drivers/power/regulator/qcom-rpmh-regulator.c | 158 ++
 1 file changed, 87 insertions(+), 71 deletions(-)

diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c 
b/drivers/power/regulator/qcom-rpmh-regulator.c
index 2a8e8f9ac444..b716b380c148 100644
--- a/drivers/power/regulator/qcom-rpmh-regulator.c
+++ b/drivers/power/regulator/qcom-rpmh-regulator.c
@@ -192,87 +192,96 @@ struct rpmh_vreg_init_data {
  *
  * Return: 0 on success, errno on failure
  */
 static int rpmh_regulator_send_request(struct rpmh_vreg *vreg,
-   struct tcs_cmd *cmd, bool wait_for_ack)
+  const struct tcs_cmd *cmd, bool 
wait_for_ack)
 {
int ret;
 
if (wait_for_ack || vreg->always_wait_for_ack)
-   ret = rpmh_write(vreg->dev, RPMH_ACTIVE_ONLY_STATE, cmd, 1);
+   ret = rpmh_write(vreg->dev->parent, RPMH_ACTIVE_ONLY_STATE, 
cmd, 1);
else
-   ret = rpmh_write_async(vreg->dev, RPMH_ACTIVE_ONLY_STATE, cmd,
-   1);
+   ret = rpmh_write_async(vreg->dev->parent, 
RPMH_ACTIVE_ONLY_STATE, cmd, 1);
 
return ret;
 }
 
-static int _rpmh_regulator_vrm_set_voltage_sel(struct regulator_dev *rdev,
-   unsigned int selector, bool wait_for_ack)
+static int _rpmh_regulator_vrm_set_value(struct udevice *rdev,
+int uv, bool wait_for_ack)
 {
-   struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
+   struct rpmh_vreg *vreg = dev_get_priv(rdev);
struct tcs_cmd cmd = {
.addr = vreg->addr + RPMH_REGULATOR_REG_VRM_VOLTAGE,
};
int ret;
+   unsigned int selector;
 
-   /* VRM voltage control register is set with voltage in millivolts. */
-   cmd.data = DIV_ROUND_UP(regulator_list_voltage_linear_range(rdev,
-   selector), 1000);
+   selector = (uv - vreg->hw_data->voltage_range.min) / 
vreg->hw_data->voltage_range.step;
+   cmd.data = DIV_ROUND_UP(vreg->hw_data->voltage_range.min +
+   selector * vreg->hw_data->voltage_range.step, 
1000);
 
ret = rpmh_regulator_send_request(vreg, , wait_for_ack);
if (!ret)
-   vreg->voltage_selector = selector;
+   vreg->uv = cmd.data * 1000;
 
return ret;
 }
 
-static int rpmh_regulator_vrm_set_voltage_sel(struct regulator_dev *rdev,
-   unsigned int selector)
+static int rpmh_regulator_vrm_set_value(struct udevice *rdev,
+   int uv)
 {
-   struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
+   struct rpmh_vreg *vreg = dev_get_priv(rdev);
+
+   debug("%s: set_value %d (current %d)\n", rdev->name, uv, vreg->uv);
 
if (vreg->enabled == -EINVAL) {
/*
 * Cache the voltage and send it later when the regulator is
 * enabled or disabled.
 */
-   vreg->voltage_selector = selector;
+   vreg->uv = uv;
return 0;
}
 
-   return _rpmh_regulator_vrm_set_voltage_sel(rdev, selector,
-   selector > vreg->voltage_selector);
+   return _rpmh_regulator_vrm_set_value(rdev, uv,
+   uv > vreg->uv);
 }
 
-static int rpmh_regulator_vrm_get_voltage_sel(struct regulator_dev *rdev)
+static int rpmh_regulator_vrm_get_value(struct udevice *rdev)
 {
-   struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
+   struct rpmh_vreg *vreg = dev_get_priv(rdev);
 
-   return vreg->voltage_selector;
+   debug("%s: get_value %d\n", rdev->name, vreg->uv);
+
+   return vreg->uv;
 }
 
-static int rpmh_regulator_is_enabled(struct regulator_dev *rdev)
+static int rpmh_regulator_is_enabled(struct udevice *rdev)
 {
-   struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
+   struct rpmh_vreg *vreg = dev_get_priv(rdev);
 
-   return vreg->enabled;
+   debug("%s: is_enabled %d\n", rdev->name, vreg->enabled);
+
+   return vreg->enabled > 0;
 }
 
-static int rpmh_regulator_set_enable_state(struct regulator_dev *rdev,
-   bool enable)
+static int rpmh_regulator_set_enable_state(struct udevice *rdev,
+  bool enable)
 {
-   struct rpmh_vreg *vreg = rdev_get_drvdata(rdev);
+   struct rpmh_vreg *vreg = dev_get_priv(rdev);
struct tcs_cmd cmd = {
.addr = vreg->addr + RPMH_REGULATOR_REG_ENABLE,
.data = enable,
};
int ret;
 
+   debug("%s: set_enable %d 

[PATCH v4 17/21] power: regulator: adjust structs for U-Boot

2024-07-09 Thread Caleb Connolly
Switch to our linear_range helpers and remove unused/unsupported
linux-isms.

Signed-off-by: Caleb Connolly 
---
 drivers/power/regulator/qcom-rpmh-regulator.c | 28 +--
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c 
b/drivers/power/regulator/qcom-rpmh-regulator.c
index d0acee9f558e..089623f3a2b9 100644
--- a/drivers/power/regulator/qcom-rpmh-regulator.c
+++ b/drivers/power/regulator/qcom-rpmh-regulator.c
@@ -102,13 +102,12 @@ struct linear_range {
  * struct rpmh_vreg_hw_data - RPMh regulator hardware configurations
  * @regulator_type:RPMh accelerator type used to manage this
  * regulator
  * @ops:   Pointer to regulator ops callback structure
- * @voltage_ranges:The possible ranges of voltages supported by 
this
- * PMIC regulator type
- * @n_linear_ranges:   Number of entries in voltage_ranges
+ * @voltage_range: The single range of voltages supported by this
+ * PMIC regulator type
  * @n_voltages:The number of unique voltage set points 
defined
- * by voltage_ranges
+ * by voltage_range
  * @hpm_min_load_uA:   Minimum load current in microamps that requires
  * high power mode (HPM) operation.  This is used
  * for LDO hardware type regulators only.
  * @pmic_mode_map: Array indexed by regulator framework mode
@@ -119,15 +118,15 @@ struct linear_range {
  * in device tree to a regulator framework mode
  */
 struct rpmh_vreg_hw_data {
enum rpmh_regulator_typeregulator_type;
-   const struct regulator_ops  *ops;
-   const struct linear_range   *voltage_ranges;
-   int n_linear_ranges;
+   const struct dm_regulator_ops   *ops;
+   struct linear_range voltage_range;
int n_voltages;
int hpm_min_load_uA;
-   const int   *pmic_mode_map;
-   unsigned int  (*of_map_mode)(unsigned int mode);
+   struct dm_regulator_mode*pmic_mode_map;
+   int n_modes;
+   unsigned int(*of_map_mode)(unsigned int 
mode);
 };
 
 /**
  * struct rpmh_vreg - individual RPMh regulator data structure encapsulating a
@@ -148,23 +147,22 @@ struct rpmh_vreg_hw_data {
  * not
  * @bypassed:  Boolean indicating if the regulator is in
  * bypass (pass-through) mode or not.  This is
  * only used by BOB rpmh-regulator resources.
- * @voltage_selector:  Selector used for get_voltage_sel() and
- * set_voltage_sel() callbacks
+ * @uv:Selector used for get_voltage_sel() and
+ * set_value() callbacks
  * @mode:  RPMh VRM regulator current framework mode
  */
 struct rpmh_vreg {
-   struct device   *dev;
+   struct udevice  *dev;
u32 addr;
-   struct regulator_desc   rdesc;
const struct rpmh_vreg_hw_data  *hw_data;
boolalways_wait_for_ack;
 
int enabled;
boolbypassed;
-   int voltage_selector;
-   unsigned intmode;
+   int uv;
+   int mode;
 };
 
 /**
  * struct rpmh_vreg_init_data - initialization data for an RPMh regulator

-- 
2.45.2



[PATCH v4 14/21] power: regulator: import qcom-rpmh-regulator from Linux

2024-07-09 Thread Caleb Connolly
Import the driver from Linux 6.10-rc6.

Signed-off-by: Caleb Connolly 
---
 drivers/power/regulator/Kconfig   |8 +
 drivers/power/regulator/Makefile  |1 +
 drivers/power/regulator/qcom-rpmh-regulator.c | 1709 +
 3 files changed, 1718 insertions(+)

diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
index 102ec7bc5f89..bc061c20d75e 100644
--- a/drivers/power/regulator/Kconfig
+++ b/drivers/power/regulator/Kconfig
@@ -215,8 +215,16 @@ config DM_REGULATOR_GPIO
This config enables implementation of driver-model regulator uclass
features for gpio regulators. The driver implements get/set for
voltage value.
 
+config DM_REGULATOR_QCOM_RPMH
+   bool "Enable driver model for Qualcomm RPMh regulator"
+   depends on DM_REGULATOR && QCOM_RPMH
+   ---help---
+ Enable support for the Qualcomm RPMh regulator. The driver
+ implements get/set api for a limited set of regulators used
+ by u-boot.
+
 config SPL_DM_REGULATOR_GPIO
bool "Enable Driver Model for GPIO REGULATOR in SPL"
depends on DM_REGULATOR_GPIO && SPL_GPIO
select SPL_DM_REGULATOR_COMMON
diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile
index f79932d83307..56a527612b74 100644
--- a/drivers/power/regulator/Makefile
+++ b/drivers/power/regulator/Makefile
@@ -20,8 +20,9 @@ obj-$(CONFIG_$(SPL_)REGULATOR_PWM) += pwm_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_FAN53555) += fan53555.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_COMMON) += regulator_common.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_FIXED) += fixed.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_GPIO) += gpio-regulator.o
+obj-$(CONFIG_DM_REGULATOR_QCOM_RPMH) += qcom-rpmh-regulator.o
 obj-$(CONFIG_$(SPL_TPL_)REGULATOR_RK8XX) += rk8xx.o
 obj-$(CONFIG_DM_REGULATOR_S2MPS11) += s2mps11_regulator.o
 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
 obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c 
b/drivers/power/regulator/qcom-rpmh-regulator.c
new file mode 100644
index ..80e304711345
--- /dev/null
+++ b/drivers/power/regulator/qcom-rpmh-regulator.c
@@ -0,0 +1,1709 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+// Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+
+#define pr_fmt(fmt) "%s: " fmt, __func__
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+/**
+ * enum rpmh_regulator_type - supported RPMh accelerator types
+ * @VRM:   RPMh VRM accelerator which supports voting on enable, voltage,
+ * and mode of LDO, SMPS, and BOB type PMIC regulators.
+ * @XOB:   RPMh XOB accelerator which supports voting on the enable state
+ * of PMIC regulators.
+ */
+enum rpmh_regulator_type {
+   VRM,
+   XOB,
+};
+
+#define RPMH_REGULATOR_REG_VRM_VOLTAGE 0x0
+#define RPMH_REGULATOR_REG_ENABLE  0x4
+#define RPMH_REGULATOR_REG_VRM_MODE0x8
+
+#define PMIC4_LDO_MODE_RETENTION   4
+#define PMIC4_LDO_MODE_LPM 5
+#define PMIC4_LDO_MODE_HPM 7
+
+#define PMIC4_SMPS_MODE_RETENTION  4
+#define PMIC4_SMPS_MODE_PFM5
+#define PMIC4_SMPS_MODE_AUTO   6
+#define PMIC4_SMPS_MODE_PWM7
+
+#define PMIC4_BOB_MODE_PASS0
+#define PMIC4_BOB_MODE_PFM 1
+#define PMIC4_BOB_MODE_AUTO2
+#define PMIC4_BOB_MODE_PWM 3
+
+#define PMIC5_LDO_MODE_RETENTION   3
+#define PMIC5_LDO_MODE_LPM 4
+#define PMIC5_LDO_MODE_HPM 7
+
+#define PMIC5_SMPS_MODE_RETENTION  3
+#define PMIC5_SMPS_MODE_PFM4
+#define PMIC5_SMPS_MODE_AUTO   6
+#define PMIC5_SMPS_MODE_PWM7
+
+#define PMIC5_BOB_MODE_PASS2
+#define PMIC5_BOB_MODE_PFM 4
+#define PMIC5_BOB_MODE_AUTO6
+#define PMIC5_BOB_MODE_PWM 7
+
+/**
+ * struct rpmh_vreg_hw_data - RPMh regulator hardware configurations
+ * @regulator_type:RPMh accelerator type used to manage this
+ * regulator
+ * @ops:   Pointer to regulator ops callback structure
+ * @voltage_ranges:The possible ranges of voltages supported by 
this
+ * PMIC regulator type
+ * @n_linear_ranges:   Number of entries in voltage_ranges
+ * @n_voltages:The number of unique voltage set points 
defined
+ * by voltage_ranges
+ * @hpm_min_load_uA:   Minimum load current in microamps that requires
+ *   

[PATCH v4 16/21] power: regulator: qcom-rpmh-regulator: port over lineage_range helpers

2024-07-09 Thread Caleb Connolly
Import struct linear_range() and builder macro from Linux regulator
core.

Signed-off-by: Caleb Connolly 
---
 drivers/power/regulator/qcom-rpmh-regulator.c | 37 +++
 1 file changed, 37 insertions(+)

diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c 
b/drivers/power/regulator/qcom-rpmh-regulator.c
index 5f522de44734..d0acee9f558e 100644
--- a/drivers/power/regulator/qcom-rpmh-regulator.c
+++ b/drivers/power/regulator/qcom-rpmh-regulator.c
@@ -28,8 +28,15 @@ enum rpmh_regulator_type {
VRM,
XOB,
 };
 
+enum rpmh_regulator_mode {
+   REGULATOR_MODE_RETENTION,
+   REGULATOR_MODE_LPM,
+   REGULATOR_MODE_AUTO,
+   REGULATOR_MODE_HPM,
+};
+
 #define RPMH_REGULATOR_REG_VRM_VOLTAGE 0x0
 #define RPMH_REGULATOR_REG_ENABLE  0x4
 #define RPMH_REGULATOR_REG_VRM_MODE0x8
 
@@ -60,8 +67,38 @@ enum rpmh_regulator_type {
 #define PMIC5_BOB_MODE_PFM 4
 #define PMIC5_BOB_MODE_AUTO6
 #define PMIC5_BOB_MODE_PWM 7
 
+
+/**
+ * struct linear_range - table of selector - value pairs
+ *
+ * Define a lookup-table for range of values. Intended to help when looking
+ * for a register value matching certaing physical measure (like voltage).
+ * Usable when increment of one in register always results a constant increment
+ * of the physical measure (like voltage).
+ *
+ * @min:  Lowest value in range
+ * @min_sel: Lowest selector for range
+ * @max_sel: Highest selector for range
+ * @step: Value step size
+ */
+struct linear_range {
+   unsigned int min;
+   unsigned int min_sel;
+   unsigned int max_sel;
+   unsigned int step;
+};
+
+/* Initialize struct linear_range for regulators */
+#define REGULATOR_LINEAR_RANGE(_min_uV, _min_sel, _max_sel, _step_uV)  \
+{  \
+   .min= _min_uV,  \
+   .min_sel= _min_sel, \
+   .max_sel= _max_sel, \
+   .step   = _step_uV, \
+}
+
 /**
  * struct rpmh_vreg_hw_data - RPMh regulator hardware configurations
  * @regulator_type:RPMh accelerator type used to manage this
  * regulator

-- 
2.45.2



[PATCH v4 15/21] power: regulator: adjust headers for U-Boot

2024-07-09 Thread Caleb Connolly
Remove unused/unsupported Linux headers and add necessary U-Boot ones.

Signed-off-by: Caleb Connolly 
---
 drivers/power/regulator/qcom-rpmh-regulator.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c 
b/drivers/power/regulator/qcom-rpmh-regulator.c
index 80e304711345..5f522de44734 100644
--- a/drivers/power/regulator/qcom-rpmh-regulator.c
+++ b/drivers/power/regulator/qcom-rpmh-regulator.c
@@ -4,17 +4,14 @@
 
 #define pr_fmt(fmt) "%s: " fmt, __func__
 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
 

-- 
2.45.2



[PATCH v4 07/21] soc: qcom: rpmh-rsc: drop unused multi-threading and non-active TCS support

2024-07-09 Thread Caleb Connolly
Since U-Boot is single threaded, we can avoid most of the complexity
that comes with handling more than one in-flight TCS. Drop all the rpmh
code associated with multi-threading as we'll instead wait for a
response on each TCS.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/rpmh-internal.h |   4 -
 drivers/soc/qcom/rpmh-rsc.c  | 562 ---
 2 files changed, 566 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index e3cf1beff803..12c5b8d9cf86 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -139,10 +139,6 @@ struct rsc_drv {
 int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg);
 int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv,
 const struct tcs_request *msg);
 void rpmh_rsc_invalidate(struct rsc_drv *drv);
-void rpmh_rsc_write_next_wakeup(struct rsc_drv *drv);
-
-void rpmh_tx_done(const struct tcs_request *msg);
-int rpmh_flush(struct rpmh_ctrlr *ctrlr);
 
 #endif /* __RPM_INTERNAL_H__ */
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index de86009ecd91..fc8321bf208f 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -246,49 +246,8 @@ static void write_tcs_reg_sync(const struct rsc_drv *drv, 
int reg, int tcs_id,
pr_err("%s: error writing %#x to %d:%#x\n", drv->name,
   data, tcs_id, reg);
 }
 
-/**
- * tcs_invalidate() - Invalidate all TCSes of the given type (sleep or wake).
- * @drv:  The RSC controller.
- * @type: SLEEP_TCS or WAKE_TCS
- *
- * This will clear the "slots" variable of the given tcs_group and also
- * tell the hardware to forget about all entries.
- *
- * The caller must ensure that no other RPMH actions are happening when this
- * function is called, since otherwise the device may immediately become
- * used again even before this function exits.
- */
-static void tcs_invalidate(struct rsc_drv *drv, int type)
-{
-   int m;
-   struct tcs_group *tcs = >tcs[type];
-
-   /* Caller ensures nobody else is running so no lock */
-   if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS))
-   return;
-
-   for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++)
-   write_tcs_reg_sync(drv, drv->regs[RSC_DRV_CMD_ENABLE], m, 0);
-
-   bitmap_zero(tcs->slots, MAX_TCS_SLOTS);
-}
-
-/**
- * rpmh_rsc_invalidate() - Invalidate sleep and wake TCSes.
- * @drv: The RSC controller.
- *
- * The caller must ensure that no other RPMH actions are happening when this
- * function is called, since otherwise the device may immediately become
- * used again even before this function exits.
- */
-void rpmh_rsc_invalidate(struct rsc_drv *drv)
-{
-   tcs_invalidate(drv, SLEEP_TCS);
-   tcs_invalidate(drv, WAKE_TCS);
-}
-
 /**
  * get_tcs_for_msg() - Get the tcs_group used to send the given message.
  * @drv: The RSC controller.
  * @msg: The message we want to send.
@@ -331,158 +290,8 @@ static struct tcs_group *get_tcs_for_msg(struct rsc_drv 
*drv,
 
return tcs;
 }
 
-/**
- * get_req_from_tcs() - Get a stashed request that was xfering on the given 
TCS.
- * @drv:The RSC controller.
- * @tcs_id: The global ID of this TCS.
- *
- * For ACTIVE_ONLY transfers we want to call back into the client when the
- * transfer finishes. To do this we need the "request" that the client
- * originally provided us. This function grabs the request that we stashed
- * when we started the transfer.
- *
- * This only makes sense for ACTIVE_ONLY transfers since those are the only
- * ones we track sending (the only ones we enable interrupts for and the only
- * ones we call back to the client for).
- *
- * Return: The stashed request.
- */
-static const struct tcs_request *get_req_from_tcs(struct rsc_drv *drv,
- int tcs_id)
-{
-   struct tcs_group *tcs;
-   int i;
-
-   for (i = 0; i < TCS_TYPE_NR; i++) {
-   tcs = >tcs[i];
-   if (tcs->mask & BIT(tcs_id))
-   return tcs->req[tcs_id - tcs->offset];
-   }
-
-   return NULL;
-}
-
-/**
- * __tcs_set_trigger() - Start xfer on a TCS or unset trigger on a borrowed TCS
- * @drv: The controller.
- * @tcs_id:  The global ID of this TCS.
- * @trigger: If true then untrigger/retrigger. If false then just untrigger.
- *
- * In the normal case we only ever call with "trigger=true" to start a
- * transfer. That will un-trigger/disable the TCS from the last transfer
- * then trigger/enable for this transfer.
- *
- * If we borrowed a wake TCS for an active-only transfer we'll also call
- * this function with "trigger=false" to just do the un-trigger/disable
- * before using the TCS for wake purposes again.
- *
- * Note that the AP is only in charge of triggering active-only transfers.
- * The AP never triggers sleep/wake values using this function.
- */
-static void 

[PATCH v4 13/21] soc: qcom: rpmh: U-Boot API changes

2024-07-09 Thread Caleb Connolly
Fix build errors, add some debug logging.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/rpmh.c | 53 +++--
 include/soc/qcom/rpmh.h |  4 ++--
 2 files changed, 22 insertions(+), 35 deletions(-)

diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 22605e0291a1..96f14a9afdf2 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -15,27 +15,30 @@
 #include "rpmh-internal.h"
 
 #define RPMH_TIMEOUT_MSmsecs_to_jiffies(1)
 
-#define DEFINE_RPMH_MSG_ONSTACK(device, s, q, name)\
+#define DEFINE_RPMH_MSG_ONSTACK(device, s, name)   \
struct rpmh_request name = {\
.msg = {\
.state = s, \
.cmds = name.cmd,   \
.num_cmds = 0,  \
-   .wait_for_compl = true, \
},  \
.cmd = { { 0 } },   \
-   .completion = q,\
.dev = device,  \
-   .needs_free = false,\
+   .needs_free = false,\
}
 
 #define ctrlr_to_drv(ctrlr) container_of(ctrlr, struct rsc_drv, client)
 
-static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev)
+static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct udevice *dev)
 {
-   struct rsc_drv *drv = dev_get_drvdata(dev->parent);
+   struct rsc_drv *drv = (struct rsc_drv *)dev_get_priv(dev->parent);
+
+   if (!drv) {
+   log_err("BUG: no RPMh driver for %s (parent %s)\n", dev->name, 
dev->parent->name);
+   BUG();
+   }
 
return >client;
 }
 
@@ -49,36 +52,23 @@ static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct 
device *dev)
  * Cache the RPMH request and send if the state is ACTIVE_ONLY.
  * SLEEP/WAKE_ONLY requests are not sent to the controller at
  * this time. Use rpmh_flush() to send them to the controller.
  */
-static int __rpmh_write(const struct device *dev, enum rpmh_state state,
+static int __rpmh_write(const struct udevice *dev, enum rpmh_state state,
struct rpmh_request *rpm_msg)
 {
struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev);
-   int ret = -EINVAL;
-   struct cache_req *req;
-   int i;
 
-   /* Cache the request in our store and link the payload */
-   for (i = 0; i < rpm_msg->msg.num_cmds; i++) {
-   req = cache_rpm_request(ctrlr, state, _msg->msg.cmds[i]);
-   if (IS_ERR(req))
-   return PTR_ERR(req);
+   if (state != RPMH_ACTIVE_ONLY_STATE) {
+   log_err("only ACTIVE_ONLY state supported\n");
+   return -EINVAL;
}
 
-   if (state == RPMH_ACTIVE_ONLY_STATE) {
-   ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), _msg->msg);
-   } else {
-   /* Clean up our call by spoofing tx_done */
-   ret = 0;
-   rpmh_tx_done(_msg->msg);
-   }
-
-   return ret;
+   return rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), _msg->msg);
 }
 
 static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state,
-   const struct tcs_cmd *cmd, u32 n)
+  const struct tcs_cmd *cmd, u32 n)
 {
if (!cmd || !n || n > MAX_RPMH_PAYLOAD)
return -EINVAL;
 
@@ -87,8 +77,10 @@ static int __fill_rpmh_msg(struct rpmh_request *req, enum 
rpmh_state state,
req->msg.state = state;
req->msg.cmds = req->cmd;
req->msg.num_cmds = n;
 
+   debug("rpmh_msg: %d, %d cmds [first %#x/%#x]\n", state, n, cmd->addr, 
cmd->data);
+
return 0;
 }
 
 /**
@@ -100,24 +92,19 @@ static int __fill_rpmh_msg(struct rpmh_request *req, enum 
rpmh_state state,
  * @n: The number of elements in @cmd
  *
  * May sleep. Do not call from atomic contexts.
  */
-int rpmh_write(const struct device *dev, enum rpmh_state state,
+int rpmh_write(const struct udevice *dev, enum rpmh_state state,
   const struct tcs_cmd *cmd, u32 n)
 {
-   DECLARE_COMPLETION_ONSTACK(compl);
-   DEFINE_RPMH_MSG_ONSTACK(dev, state, , rpm_msg);
+   DEFINE_RPMH_MSG_ONSTACK(dev, state, rpm_msg);
int ret;
 
ret = __fill_rpmh_msg(_msg, state, cmd, n);
if (ret)
return ret;
 
ret = __rpmh_write(dev, state, _msg);
-   if (ret)
-   return ret;
 
-   ret = wait_for_completion_timeout(, RPMH_TIMEOUT_MS);
-   WARN_ON(!ret);
-   return (ret > 0) ? 0 : -ETIMEDOUT;
+   return ret;
 }
 EXPORT_SYMBOL_GPL(rpmh_write);
diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h
index 9a5c5d992e04..3421fbf1ee3e 100644
--- a/include/soc/qcom/rpmh.h
+++ b/include/soc/qcom/rpmh.h
@@ 

[PATCH v4 12/21] soc: qcom: rpmh: drop unused functions

2024-07-09 Thread Caleb Connolly
A lot of the features in here are only relevant when running
multi-threaded with interrupts. Drop everything except what we need to
run single-threaded with a single TCS (which is all the rpmh-rsc
framework in U-Boot supports).

Keep rpmh_write_async() for simplicity and make it wrap the regular
rpmh_write().

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/rpmh.c | 371 
 include/soc/qcom/rpmh.h |  25 +---
 2 files changed, 3 insertions(+), 393 deletions(-)

diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 03ef4106c9a6..22605e0291a1 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -31,124 +31,15 @@
}
 
 #define ctrlr_to_drv(ctrlr) container_of(ctrlr, struct rsc_drv, client)
 
-/**
- * struct cache_req: the request object for caching
- *
- * @addr: the address of the resource
- * @sleep_val: the sleep vote
- * @wake_val: the wake vote
- * @list: linked list obj
- */
-struct cache_req {
-   u32 addr;
-   u32 sleep_val;
-   u32 wake_val;
-   struct list_head list;
-};
-
-/**
- * struct batch_cache_req - An entry in our batch catch
- *
- * @list: linked list obj
- * @count: number of messages
- * @rpm_msgs: the messages
- */
-
-struct batch_cache_req {
-   struct list_head list;
-   int count;
-   struct rpmh_request rpm_msgs[];
-};
-
 static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev)
 {
struct rsc_drv *drv = dev_get_drvdata(dev->parent);
 
return >client;
 }
 
-void rpmh_tx_done(const struct tcs_request *msg)
-{
-   struct rpmh_request *rpm_msg = container_of(msg, struct rpmh_request,
-   msg);
-   struct completion *compl = rpm_msg->completion;
-   bool free = rpm_msg->needs_free;
-
-   if (!compl)
-   goto exit;
-
-   /* Signal the blocking thread we are done */
-   complete(compl);
-
-exit:
-   if (free)
-   kfree(rpm_msg);
-}
-
-static struct cache_req *__find_req(struct rpmh_ctrlr *ctrlr, u32 addr)
-{
-   struct cache_req *p, *req = NULL;
-
-   list_for_each_entry(p, >cache, list) {
-   if (p->addr == addr) {
-   req = p;
-   break;
-   }
-   }
-
-   return req;
-}
-
-static struct cache_req *cache_rpm_request(struct rpmh_ctrlr *ctrlr,
-  enum rpmh_state state,
-  struct tcs_cmd *cmd)
-{
-   struct cache_req *req;
-   unsigned long flags;
-   u32 old_sleep_val, old_wake_val;
-
-   spin_lock_irqsave(>cache_lock, flags);
-   req = __find_req(ctrlr, cmd->addr);
-   if (req)
-   goto existing;
-
-   req = kzalloc(sizeof(*req), GFP_ATOMIC);
-   if (!req) {
-   req = ERR_PTR(-ENOMEM);
-   goto unlock;
-   }
-
-   req->addr = cmd->addr;
-   req->sleep_val = req->wake_val = UINT_MAX;
-   list_add_tail(>list, >cache);
-
-existing:
-   old_sleep_val = req->sleep_val;
-   old_wake_val = req->wake_val;
-
-   switch (state) {
-   case RPMH_ACTIVE_ONLY_STATE:
-   case RPMH_WAKE_ONLY_STATE:
-   req->wake_val = cmd->data;
-   break;
-   case RPMH_SLEEP_STATE:
-   req->sleep_val = cmd->data;
-   break;
-   }
-
-   ctrlr->dirty |= (req->sleep_val != old_sleep_val ||
-req->wake_val != old_wake_val) &&
-req->sleep_val != UINT_MAX &&
-req->wake_val != UINT_MAX;
-
-unlock:
-   spin_unlock_irqrestore(>cache_lock, flags);
-
-   return req;
-}
-
 /**
  * __rpmh_write: Cache and send the RPMH request
  *
  * @dev: The device making the request
@@ -199,40 +90,8 @@ static int __fill_rpmh_msg(struct rpmh_request *req, enum 
rpmh_state state,
 
return 0;
 }
 
-/**
- * rpmh_write_async: Write a set of RPMH commands
- *
- * @dev: The device making the request
- * @state: Active/sleep set
- * @cmd: The payload data
- * @n: The number of elements in payload
- *
- * Write a set of RPMH commands, the order of commands is maintained
- * and will be sent as a single shot.
- */
-int rpmh_write_async(const struct device *dev, enum rpmh_state state,
-const struct tcs_cmd *cmd, u32 n)
-{
-   struct rpmh_request *rpm_msg;
-   int ret;
-
-   rpm_msg = kzalloc(sizeof(*rpm_msg), GFP_ATOMIC);
-   if (!rpm_msg)
-   return -ENOMEM;
-   rpm_msg->needs_free = true;
-
-   ret = __fill_rpmh_msg(rpm_msg, state, cmd, n);
-   if (ret) {
-   kfree(rpm_msg);
-   return ret;
-   }
-
-   return __rpmh_write(dev, state, rpm_msg);
-}
-EXPORT_SYMBOL_GPL(rpmh_write_async);
-
 /**
  * rpmh_write: Write a set of RPMH commands and block until response
  *
  * @dev: The device making the request
@@ -261,234 +120,4 @@ 

[PATCH v4 11/21] soc: qcom: rpmh: adjust headers for U-Boot

2024-07-09 Thread Caleb Connolly
Drop unused/unsupported Linux headers and add dm/device.h for U-Boot.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/rpmh.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 8903ed956312..03ef4106c9a6 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -2,22 +2,14 @@
 /*
  * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
  */
 
-#include 
+#include 
+#include 
 #include 
-#include 
-#include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 
 #include 
 
 #include "rpmh-internal.h"

-- 
2.45.2



[PATCH v4 09/21] soc: qcom: rpmh-rsc: adjust probe for U-Boot

2024-07-09 Thread Caleb Connolly
Rework the rpmh-rsc initialization to use U-Boot's driver model and
initialize cmd-db.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/rpmh-internal.h |  14 ++--
 drivers/soc/qcom/rpmh-rsc.c  | 143 +--
 2 files changed, 50 insertions(+), 107 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index 12c5b8d9cf86..ac8f6c35a7a4 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -7,17 +7,18 @@
 #ifndef __RPM_INTERNAL_H__
 #define __RPM_INTERNAL_H__
 
 #include 
-#include 
 #include 
 
 #define TCS_TYPE_NR4
 #define MAX_CMDS_PER_TCS   16
 #define MAX_TCS_PER_TYPE   3
 #define MAX_TCS_NR (MAX_TCS_PER_TYPE * TCS_TYPE_NR)
 #define MAX_TCS_SLOTS  (MAX_CMDS_PER_TCS * MAX_TCS_PER_TYPE)
 
+#define USEC_PER_SEC   100UL
+
 struct rsc_drv;
 
 /**
  * struct tcs_group: group of Trigger Command Sets (TCS) to send state requests
@@ -63,10 +64,9 @@ struct tcs_group {
  */
 struct rpmh_request {
struct tcs_request msg;
struct tcs_cmd cmd[MAX_RPMH_PAYLOAD];
-   struct completion *completion;
-   const struct device *dev;
+   const struct udevice *dev;
bool needs_free;
 };
 
 /**
@@ -78,9 +78,8 @@ struct rpmh_request {
  * @batch_cache: Cache sleep and wake requests sent as batch
  */
 struct rpmh_ctrlr {
struct list_head cache;
-   spinlock_t cache_lock;
bool dirty;
struct list_head batch_cache;
 };
 
@@ -122,17 +121,12 @@ struct rsc_drv {
void __iomem *base;
void __iomem *tcs_base;
int id;
int num_tcs;
-   struct notifier_block rsc_pm;
-   struct notifier_block genpd_nb;
-   atomic_t cpus_in_pm;
struct tcs_group tcs[TCS_TYPE_NR];
DECLARE_BITMAP(tcs_in_use, MAX_TCS_NR);
-   spinlock_t lock;
-   wait_queue_head_t tcs_wait;
struct rpmh_ctrlr client;
-   struct device *dev;
+   struct udevice *dev;
struct rsc_ver ver;
u32 *regs;
 };
 
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index c09214552cfb..d4ef88dda184 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -386,20 +386,20 @@ int rpmh_rsc_send_data(struct rsc_drv *drv, const struct 
tcs_request *msg)
 
return 0;
 }
 
-static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv 
*drv)
+static int rpmh_probe_tcs_config(struct udevice *dev, struct rsc_drv *drv)
 {
struct tcs_type_config {
u32 type;
u32 n;
} tcs_cfg[TCS_TYPE_NR] = { { 0 } };
-   struct device_node *dn = pdev->dev.of_node;
+   ofnode dn = dev_ofnode(dev);
u32 config, max_tcs, ncpt, offset;
int i, ret, n, st = 0;
struct tcs_group *tcs;
 
-   ret = of_property_read_u32(dn, "qcom,tcs-offset", );
+   ret = ofnode_read_u32(dn, "qcom,tcs-offset", );
if (ret)
return ret;
drv->tcs_base = drv->base + offset;
 
@@ -411,24 +411,15 @@ static int rpmh_probe_tcs_config(struct platform_device 
*pdev, struct rsc_drv *d
 
ncpt = config & (DRV_NCPT_MASK << DRV_NCPT_SHIFT);
ncpt = ncpt >> DRV_NCPT_SHIFT;
 
-   n = of_property_count_u32_elems(dn, "qcom,tcs-config");
-   if (n != 2 * TCS_TYPE_NR)
-   return -EINVAL;
+   n = ofnode_read_u32_array(dn, "qcom,tcs-config", (u32 *)tcs_cfg, 2 * 
TCS_TYPE_NR);
+   if (n < 0) {
+   log_err("RPMh: %s: error reading qcom,tcs-config %d\n", 
dev->name, n);
+   return n;
+   }
 
for (i = 0; i < TCS_TYPE_NR; i++) {
-   ret = of_property_read_u32_index(dn, "qcom,tcs-config",
-i * 2, _cfg[i].type);
-   if (ret)
-   return ret;
-   if (tcs_cfg[i].type >= TCS_TYPE_NR)
-   return -EINVAL;
-
-   ret = of_property_read_u32_index(dn, "qcom,tcs-config",
-i * 2 + 1, _cfg[i].n);
-   if (ret)
-   return ret;
if (tcs_cfg[i].n > MAX_TCS_PER_TYPE)
return -EINVAL;
}
 
@@ -457,43 +448,39 @@ static int rpmh_probe_tcs_config(struct platform_device 
*pdev, struct rsc_drv *d
 
return 0;
 }
 
-static int rpmh_rsc_probe(struct platform_device *pdev)
+static int rpmh_rsc_bind(struct udevice *dev)
 {
-   struct device_node *dn = pdev->dev.of_node;
-   struct rsc_drv *drv;
-   char drv_id[10] = {0};
-   int ret, irq;
-   u32 solver_config;
-   u32 rsc_id;
+   int ret;
 
-   /*
-* Even though RPMh doesn't directly use cmd-db, all of its children
-* do. To avoid adding this check to our children we'll do it now.
-*/
-   ret = cmd_db_ready();
-  

[PATCH v4 08/21] soc: qcom: rpmh-rsc: adjust headers for U-Boot

2024-07-09 Thread Caleb Connolly
Remove unsupported / unused Linux headers and add those needed for
U-Boot.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/rpmh-rsc.c | 35 ---
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index fc8321bf208f..c09214552cfb 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -5,39 +5,28 @@
  */
 
 #define pr_fmt(fmt) "%s " fmt, KBUILD_MODNAME
 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
 
-#include 
 #include 
 #include 
 #include 
 
 #include "rpmh-internal.h"
 
-#define CREATE_TRACE_POINTS
-#include "trace-rpmh.h"
-
 
 #define RSC_DRV_ID 0
 
 #define MAJOR_VER_MASK 0xFF

-- 
2.45.2



[PATCH v4 06/21] soc: qcom: cmd-db: adjust for U-Boot API

2024-07-09 Thread Caleb Connolly
Keep the header pointer in the .data section so we don't initialize it
again after relocation, adjust cmd_db_get_header() to work with the
U-Boot API, and skip validating the header since all cmd-db users are
children of the rpmh-rsc and those children will only probe if cmd-db
initializes successfully.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/cmd-db.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index 4d3fd4db8852..b852a269ae12 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -104,9 +104,9 @@ static bool cmd_db_magic_matches(const struct cmd_db_header 
*header)
 
return memcmp(magic, CMD_DB_MAGIC, ARRAY_SIZE(CMD_DB_MAGIC)) == 0;
 }
 
-static struct cmd_db_header *cmd_db_header;
+static struct cmd_db_header *cmd_db_header __section(".data") = NULL;
 
 static inline const void *rsc_to_entry_header(const struct rsc_hdr *hdr)
 {
u16 offset = le16_to_cpu(hdr->header_offset);
@@ -127,16 +127,12 @@ static int cmd_db_get_header(const char *id, const struct 
entry_header **eh,
 const struct rsc_hdr **rh)
 {
const struct rsc_hdr *rsc_hdr;
const struct entry_header *ent;
-   int ret, i, j;
+   int i, j;
u8 query[sizeof(ent->id)] __nonstring;
 
-   ret = cmd_db_ready();
-   if (ret)
-   return ret;
-
-   strtomem_pad(query, id, 0);
+   strncpy(query, id, sizeof(query));
 
for (i = 0; i < MAX_SLV_ID; i++) {
rsc_hdr = _db_header->header[i];
if (!rsc_hdr->slv_id)

-- 
2.45.2



[PATCH v4 05/21] soc: qcom: cmd-db: replace cmd_db_ready() with cmd_db_init()

2024-07-09 Thread Caleb Connolly
Using the driver model for cmd-db is fine, but it's unnecessary
complexity which we can just avoid in U-Boot. Instead let's just have a
function to initialize it and call said function when initializing rpmh.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/cmd-db.c | 74 ++-
 include/soc/qcom/cmd-db.h |  4 +--
 2 files changed, 24 insertions(+), 54 deletions(-)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index b6426ac3cafc..4d3fd4db8852 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -122,24 +122,8 @@ rsc_offset(const struct rsc_hdr *hdr, const struct 
entry_header *ent)
 
return cmd_db_header->data + offset + loffset;
 }
 
-/**
- * cmd_db_ready - Indicates if command DB is available
- *
- * Return: 0 on success, errno otherwise
- */
-int cmd_db_ready(void)
-{
-   if (cmd_db_header == NULL)
-   return -EPROBE_DEFER;
-   else if (!cmd_db_magic_matches(cmd_db_header))
-   return -EINVAL;
-
-   return 0;
-}
-EXPORT_SYMBOL_GPL(cmd_db_ready);
-
 static int cmd_db_get_header(const char *id, const struct entry_header **eh,
 const struct rsc_hdr **rh)
 {
const struct rsc_hdr *rsc_hdr;
@@ -193,55 +177,41 @@ u32 cmd_db_read_addr(const char *id)
return ret < 0 ? 0 : le32_to_cpu(ent->addr);
 }
 EXPORT_SYMBOL_GPL(cmd_db_read_addr);
 
-static int cmd_db_dev_probe(struct platform_device *pdev)
+int cmd_db_init(void)
 {
-   struct reserved_mem *rmem;
-   int ret = 0;
+   void __iomem *base;
+   ofnode rmem, node;
 
-   rmem = of_reserved_mem_lookup(pdev->dev.of_node);
-   if (!rmem) {
-   dev_err(>dev, "failed to acquire memory region\n");
-   return -EINVAL;
+   if (cmd_db_header)
+   return 0;
+
+   rmem = ofnode_path("/reserved-memory");
+   ofnode_for_each_subnode(node, rmem) {
+   if (ofnode_device_is_compatible(node, "qcom,cmd-db"))
+   goto found;
}
 
-   cmd_db_header = memremap(rmem->base, rmem->size, MEMREMAP_WB);
-   if (!cmd_db_header) {
-   ret = -ENOMEM;
-   cmd_db_header = NULL;
-   return ret;
+   log_err("%s: Failed to find cmd-db node\n", __func__);
+   return -ENOENT;
+found:
+   debug("%s(%s)\n", __func__, ofnode_get_name(node));
+
+   base = (void __iomem *)ofnode_get_addr(node);
+   if ((fdt_addr_t)base == FDT_ADDR_T_NONE) {
+   log_err("%s: Failed to read base address\n", __func__);
+   return -ENOENT;
}
 
+   cmd_db_header = base;
if (!cmd_db_magic_matches(cmd_db_header)) {
-   dev_err(>dev, "Invalid Command DB Magic\n");
+   log_err("%s: Invalid Command DB Magic\n", __func__);
return -EINVAL;
}
 
-   device_set_pm_not_required(>dev);
-
return 0;
 }
-
-static const struct of_device_id cmd_db_match_table[] = {
-   { .compatible = "qcom,cmd-db" },
-   { }
-};
-MODULE_DEVICE_TABLE(of, cmd_db_match_table);
-
-static struct platform_driver cmd_db_dev_driver = {
-   .probe  = cmd_db_dev_probe,
-   .driver = {
-  .name = "cmd-db",
-  .of_match_table = cmd_db_match_table,
-  .suppress_bind_attrs = true,
-   },
-};
-
-static int __init cmd_db_device_init(void)
-{
-   return platform_driver_register(_db_dev_driver);
-}
-core_initcall(cmd_db_device_init);
+EXPORT_SYMBOL(cmd_db_init);
 
 MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Command DB Driver");
 MODULE_LICENSE("GPL v2");
diff --git a/include/soc/qcom/cmd-db.h b/include/soc/qcom/cmd-db.h
index 753c7923f8e5..535164cc7fb0 100644
--- a/include/soc/qcom/cmd-db.h
+++ b/include/soc/qcom/cmd-db.h
@@ -21,13 +21,13 @@ enum cmd_db_hw_type {
 
 #if IS_ENABLED(CONFIG_QCOM_COMMAND_DB)
 u32 cmd_db_read_addr(const char *resource_id);
 
-int cmd_db_ready(void);
+int cmd_db_init(void);
 #else
 static inline u32 cmd_db_read_addr(const char *resource_id)
 { return 0; }
 
-static inline int cmd_db_ready(void)
+static inline int cmd_db_init(void)
 { return -ENODEV; }
 #endif /* CONFIG_QCOM_COMMAND_DB */
 #endif /* __QCOM_COMMAND_DB_H__ */

-- 
2.45.2



[PATCH v4 04/21] soc: qcom: cmd-db: drop unused functions

2024-07-09 Thread Caleb Connolly
Due to our simpler rpmh-rsc driver and lack of debugfs, we don't need
quite a few cmd-db functions, just drop them.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/cmd-db.c | 144 --
 include/soc/qcom/cmd-db.h |  15 -
 2 files changed, 159 deletions(-)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index 685b6d530136..b6426ac3cafc 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -193,150 +193,8 @@ u32 cmd_db_read_addr(const char *id)
return ret < 0 ? 0 : le32_to_cpu(ent->addr);
 }
 EXPORT_SYMBOL_GPL(cmd_db_read_addr);
 
-/**
- * cmd_db_read_aux_data() - Query command db for aux data.
- *
- *  @id: Resource to retrieve AUX Data on
- *  @len: size of data buffer returned
- *
- *  Return: pointer to data on success, error pointer otherwise
- */
-const void *cmd_db_read_aux_data(const char *id, size_t *len)
-{
-   int ret;
-   const struct entry_header *ent;
-   const struct rsc_hdr *rsc_hdr;
-
-   ret = cmd_db_get_header(id, , _hdr);
-   if (ret)
-   return ERR_PTR(ret);
-
-   if (len)
-   *len = le16_to_cpu(ent->len);
-
-   return rsc_offset(rsc_hdr, ent);
-}
-EXPORT_SYMBOL_GPL(cmd_db_read_aux_data);
-
-/**
- * cmd_db_match_resource_addr() - Compare if both Resource addresses are same
- *
- * @addr1: Resource address to compare
- * @addr2: Resource address to compare
- *
- * Return: true if two addresses refer to the same resource, false otherwise
- */
-bool cmd_db_match_resource_addr(u32 addr1, u32 addr2)
-{
-   /*
-* Each RPMh VRM accelerator resource has 3 or 4 contiguous 4-byte
-* aligned addresses associated with it. Ignore the offset to check
-* for VRM requests.
-*/
-   if (addr1 == addr2)
-   return true;
-   else if (SLAVE_ID(addr1) == CMD_DB_HW_VRM && VRM_ADDR(addr1) == 
VRM_ADDR(addr2))
-   return true;
-
-   return false;
-}
-EXPORT_SYMBOL_GPL(cmd_db_match_resource_addr);
-
-/**
- * cmd_db_read_slave_id - Get the slave ID for a given resource address
- *
- * @id: Resource id to query the DB for version
- *
- * Return: cmd_db_hw_type enum on success, CMD_DB_HW_INVALID on error
- */
-enum cmd_db_hw_type cmd_db_read_slave_id(const char *id)
-{
-   int ret;
-   const struct entry_header *ent;
-   u32 addr;
-
-   ret = cmd_db_get_header(id, , NULL);
-   if (ret < 0)
-   return CMD_DB_HW_INVALID;
-
-   addr = le32_to_cpu(ent->addr);
-   return (addr >> SLAVE_ID_SHIFT) & SLAVE_ID_MASK;
-}
-EXPORT_SYMBOL_GPL(cmd_db_read_slave_id);
-
-#ifdef CONFIG_DEBUG_FS
-static int cmd_db_debugfs_dump(struct seq_file *seq, void *p)
-{
-   int i, j;
-   const struct rsc_hdr *rsc;
-   const struct entry_header *ent;
-   const char *name;
-   u16 len, version;
-   u8 major, minor;
-
-   seq_puts(seq, "Command DB DUMP\n");
-
-   for (i = 0; i < MAX_SLV_ID; i++) {
-   rsc = _db_header->header[i];
-   if (!rsc->slv_id)
-   break;
-
-   switch (le16_to_cpu(rsc->slv_id)) {
-   case CMD_DB_HW_ARC:
-   name = "ARC";
-   break;
-   case CMD_DB_HW_VRM:
-   name = "VRM";
-   break;
-   case CMD_DB_HW_BCM:
-   name = "BCM";
-   break;
-   default:
-   name = "Unknown";
-   break;
-   }
-
-   version = le16_to_cpu(rsc->version);
-   major = version >> 8;
-   minor = version;
-
-   seq_printf(seq, "Slave %s (v%u.%u)\n", name, major, minor);
-   seq_puts(seq, "-\n");
-
-   ent = rsc_to_entry_header(rsc);
-   for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) {
-   seq_printf(seq, "0x%05x: %*pEp", le32_to_cpu(ent->addr),
-  (int)strnlen(ent->id, sizeof(ent->id)), 
ent->id);
-
-   len = le16_to_cpu(ent->len);
-   if (len) {
-   seq_printf(seq, " [%*ph]",
-  len, rsc_offset(rsc, ent));
-   }
-   seq_putc(seq, '\n');
-   }
-   }
-
-   return 0;
-}
-
-static int open_cmd_db_debugfs(struct inode *inode, struct file *file)
-{
-   return single_open(file, cmd_db_debugfs_dump, inode->i_private);
-}
-#endif
-
-static const struct file_operations cmd_db_debugfs_ops = {
-#ifdef CONFIG_DEBUG_FS
-   .open = open_cmd_db_debugfs,
-#endif
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
-
 static int cmd_db_dev_probe(struct platform_device *pdev)
 {
struct reserved_mem *rmem;
int ret = 0;
@@ 

[PATCH v4 02/21] soc: qcom: import rpmh and cmd-db drivers from Linux

2024-07-09 Thread Caleb Connolly
Import RPMh and cmd-db framework from Linux 6.10-rc6.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/Kconfig  |1 +
 drivers/soc/Makefile |1 +
 drivers/soc/qcom/Kconfig |   27 +
 drivers/soc/qcom/Makefile|4 +
 drivers/soc/qcom/cmd-db.c|  393 +
 drivers/soc/qcom/rpmh-internal.h |  148 +
 drivers/soc/qcom/rpmh-rsc.c  | 1162 ++
 drivers/soc/qcom/rpmh.c  |  502 
 include/soc/qcom/cmd-db.h|   48 ++
 include/soc/qcom/rpmh.h  |   47 ++
 include/soc/qcom/tcs.h   |   81 +++
 11 files changed, 2414 insertions(+)

diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index cee506fe4747..8ef408d9ba1b 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -47,8 +47,9 @@ config SOC_XILINX_VERSAL_NET
  Enable this option to select SoC device id driver for Xilinx Versal 
NET.
  This allows other drivers to verify the SoC familiy & revision using
  matching SoC attributes.
 
+source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/samsung/Kconfig"
 source "drivers/soc/ti/Kconfig"
 
 endmenu
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 5ec89a053165..00e6a5ac8e2b 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -2,8 +2,9 @@
 #
 # Makefile for the U-Boot SOC specific device drivers.
 
 obj-$(CONFIG_SOC_AMD_VERSAL2) += soc_amd_versal2.o
+obj-$(CONFIG_SOC_QCOM) += qcom/
 obj-$(CONFIG_SOC_SAMSUNG) += samsung/
 obj-$(CONFIG_SOC_TI) += ti/
 obj-$(CONFIG_SOC_DEVICE) += soc-uclass.o
 obj-$(CONFIG_SOC_DEVICE_TI_K3) += soc_ti_k3.o
diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
new file mode 100644
index ..4aa7833930c7
--- /dev/null
+++ b/drivers/soc/qcom/Kconfig
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# QCOM Soc drivers
+#
+menuconfig SOC_QCOM
+   bool "Qualcomm SOC drivers support"
+   help
+ Say Y here if you want to enable Qualcomm SOC drivers support.
+
+if SOC_QCOM
+
+config QCOM_COMMAND_DB
+   bool "Qualcomm Command DB"
+   help
+ Command DB queries shared memory by key string for shared system
+ resources. Platform drivers that require to set state of a shared
+ resource on a RPM-hardened platform must use this database to get
+ SoC specific identifier and information for the shared resources.
+
+config QCOM_RPMH
+   bool "Qualcomm RPMh support"
+   depends on QCOM_COMMAND_DB
+   help
+ Say y here to support the Qualcomm RPMh (resource peripheral manager)
+ if you need to control regulators on Qualcomm platforms, say y here.
+
+endif # SOC_QCOM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
new file mode 100644
index ..78fae8bbfa16
--- /dev/null
+++ b/drivers/soc/qcom/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o
+obj-$(CONFIG_QCOM_RPMH) += rpmh-rsc.o rpmh.o
diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
new file mode 100644
index ..d84572662017
--- /dev/null
+++ b/drivers/soc/qcom/cmd-db.c
@@ -0,0 +1,393 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2016-2018, 2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define NUM_PRIORITY   2
+#define MAX_SLV_ID 8
+#define SLAVE_ID_MASK  0x7
+#define SLAVE_ID_SHIFT 16
+#define SLAVE_ID(addr) FIELD_GET(GENMASK(19, 16), addr)
+#define VRM_ADDR(addr) FIELD_GET(GENMASK(19, 4), addr)
+
+/**
+ * struct entry_header: header for each entry in cmddb
+ *
+ * @id: resource's identifier
+ * @priority: unused
+ * @addr: the address of the resource
+ * @len: length of the data
+ * @offset: offset from :@data_offset, start of the data
+ */
+struct entry_header {
+   u8 id[8];
+   __le32 priority[NUM_PRIORITY];
+   __le32 addr;
+   __le16 len;
+   __le16 offset;
+};
+
+/**
+ * struct rsc_hdr: resource header information
+ *
+ * @slv_id: id for the resource
+ * @header_offset: entry's header at offset from the end of the cmd_db_header
+ * @data_offset: entry's data at offset from the end of the cmd_db_header
+ * @cnt: number of entries for HW type
+ * @version: MSB is major, LSB is minor
+ * @reserved: reserved for future use.
+ */
+struct rsc_hdr {
+   __le16 slv_id;
+   __le16 header_offset;
+   __le16 data_offset;
+   __le16 cnt;
+   __le16 version;
+   __le16 reserved[3];
+};
+
+/**
+ * struct cmd_db_header: The DB header information
+ *
+ * @version: The cmd db version
+ * @magic: constant expected in the database
+ * @header: array of resources
+ * @checksum: checksum for the header. Unused.
+ * 

[PATCH v4 03/21] soc: qcom: cmd-db: adjust headers for U-Boot

2024-07-09 Thread Caleb Connolly
Replace unused/unsupported Linux headers with appropriate U-Boot
alternatives.

Signed-off-by: Caleb Connolly 
---
 drivers/soc/qcom/cmd-db.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index d84572662017..685b6d530136 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -3,18 +3,16 @@
  * Copyright (c) 2016-2018, 2020, The Linux Foundation. All rights reserved.
  * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
-#include 
-#include 
+#define pr_fmt(fmt) "cmd-db: " fmt
+
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
+#include 
+#include 
 
 #include 
 
 #define NUM_PRIORITY   2

-- 
2.45.2



[PATCH v4 01/21] linux/bitmap.h: add bitmap_empty helper

2024-07-09 Thread Caleb Connolly
Import this function from Linux as of 6.10-rc6

Signed-off-by: Caleb Connolly 
---
 include/linux/bitmap.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 0a8503af9f14..40ca2212cb40 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -195,8 +195,16 @@ static inline void bitmap_fill(unsigned long *dst, 
unsigned int nbits)
memset(dst, 0xff, len);
}
 }
 
+static inline bool bitmap_empty(const unsigned long *src, unsigned int nbits)
+{
+   if (small_const_nbits(nbits))
+   return !(*src & BITMAP_LAST_WORD_MASK(nbits));
+
+   return find_first_bit(src, nbits) == nbits;
+}
+
 static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
 const unsigned long *src2, unsigned int nbits)
 {
if (small_const_nbits(nbits))

-- 
2.45.2



[PATCH v4 00/21] qcom: rpmh core and regulator support

2024-07-09 Thread Caleb Connolly
This series introduces support for the RPMh (Resource Power Manager
(hardened)) co-processor and associated regulator driver found on most
modern Qualcomm platforms (since ~2017).

Even though most regulators are controlled via SPMI, the specific
regions on the PMICs for controlling the regulators are restricted and
can't be accessed by the Applications Processor (AP/HLOS). Instead,
these resources are proxied via the RPMh where they can be voted on by
multiple subsystems (Linux, the modem, and the other DSPs). This is done
for security (to protect clocks, power domains, and regulators that are
specifically relevant for the trustzone) as well as to simplify the
management of shared peripherals and to allow for handover of
peripherals like the USB controller.

For U-Boot, our main concern is the regulators. Since all regulators on
the system are controlled via the RPMh, it is necessary to support it to
enable USB VBUS on some platforms, and may be needed for other
peripherals in the future.

Communicating with the RPMh additional requires accessing the cmd-db
shared memory region, this contains key/value maps to determine the
address of specific resources on the RPMh.

Introduce support for the cmd-db, the RPMh framework, and some of the
regulators that are necessary to enable USB VBUS on the RB5 development
board.

These drivers are taken from Linux, then modified and simplified for
U-Boot. The original Linux drivers contain heavy optimisations related
to multithreading and asynchronous probing, as well as support for idle
and suspend states which we don't need to deal with here. This unused
code is removed before finally adjusting the drivers to properly build
for U-Boot and use its device model.

The U-Boot version of the driver supports a single ACTIVE_ONLY TCS and
waits for it to be cleared after use. We don't support programming
low power states.

---
Changes in v4:
- Denote original Linux version in bitmap.h patch
- Rebased on Linux 6.10-rc6 and re-apply U-Boot changes preserving git
  history. Allowing for future changes to the Linux drivers to be ported
  over more easily.
- Add missing check to wait for the TCS to be cleared after use (seems
  we were just racing the RPMh before, oops!).
- Fix missing n_modes in pmic5_pldo regulator.
- Link to v3: 
https://lore.kernel.org/r/20240708-b4-qcom-rpmh-v3-0-846cc6c5b...@linaro.org

Changes in v3:
- Don't call dm_scan_fdt_dev(), since DM core will scan.
- Link to v2: 
https://lore.kernel.org/r/20240708-b4-qcom-rpmh-v2-0-8bc765606...@linaro.org

Changes in v2:
- Implement Neil's suggestions and fixes for SM8[56]50
- Slightly refactor cmd_db_init() for better abstraction.
- Improve logging (printf -> log_err/dev_err)
- Add missing error check in rpmh_regulators_bind()
- Link to v1: 
https://lore.kernel.org/r/20240617-b4-qcom-rpmh-v1-0-bd2336923...@linaro.org

---
Caleb Connolly (21):
  linux/bitmap.h: add bitmap_empty helper
  soc: qcom: import rpmh and cmd-db drivers from Linux
  soc: qcom: cmd-db: adjust headers for U-Boot
  soc: qcom: cmd-db: drop unused functions
  soc: qcom: cmd-db: replace cmd_db_ready() with cmd_db_init()
  soc: qcom: cmd-db: adjust for U-Boot API
  soc: qcom: rpmh-rsc: drop unused multi-threading and non-active TCS 
support
  soc: qcom: rpmh-rsc: adjust headers for U-Boot
  soc: qcom: rpmh-rsc: adjust probe for U-Boot
  soc: qcom: rpmh-rsc: remaining U-Boot API changes
  soc: qcom: rpmh: adjust headers for U-Boot
  soc: qcom: rpmh: drop unused functions
  soc: qcom: rpmh: U-Boot API changes
  power: regulator: import qcom-rpmh-regulator from Linux
  power: regulator: adjust headers for U-Boot
  power: regulator: qcom-rpmh-regulator: port over lineage_range helpers
  power: regulator: adjust structs for U-Boot
  power: regulator: qcom-rpmh-regulator: remove unused regulators
  power: regulator: qcom-rpmh-regulator: port ops to U-Boot
  power: regulator: qcom-rpmh-regulator: adjust probe for U-Boot
  qcom_defconfig: enable rpmh regulators

 configs/qcom_defconfig|   5 +
 drivers/power/regulator/Kconfig   |   8 +
 drivers/power/regulator/Makefile  |   1 +
 drivers/power/regulator/qcom-rpmh-regulator.c | 544 ++
 drivers/soc/Kconfig   |   1 +
 drivers/soc/Makefile  |   1 +
 drivers/soc/qcom/Kconfig  |  27 ++
 drivers/soc/qcom/Makefile |   4 +
 drivers/soc/qcom/cmd-db.c | 213 ++
 drivers/soc/qcom/rpmh-internal.h  | 138 +++
 drivers/soc/qcom/rpmh-rsc.c   | 518 
 drivers/soc/qcom/rpmh.c   | 110 ++
 include/linux/bitmap.h|   8 +
 include/soc/qcom/cmd-db.h |  33 ++
 include/soc/qcom/rpmh.h   |  28 ++
 include/soc/qcom/tcs.h   

Re: [PATCH v2 3/3] phy: test: Implement sandbox PHY .set_mode and DM test

2024-07-09 Thread Mattijs Korpershoek
Hi Marek,

Thank you for the patch.

On lun., juin 17, 2024 at 19:36, Marek Vasut  
wrote:

> Implement trivial extension to the sandbox PHY, which makes it pretend
> to support selecting USB Host mode and nothing else. Any other mode is
> rejected with -EINVAL. Any submode except for default submode 0 is
> rejected with -EOPNOTSUPP . The implementation behaves in this trivial
> way to permit easy unit testing using test which is also added in this
> commit.
>
> To run the test, use e.g. sandbox64_defconfig and run U-Boot as follows:
> $ ./u-boot -Tc 'ut dm phy_setup'
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Caleb Connolly 
> Cc: Fabio Estevam 
> Cc: Fabrice Gasnier 
> Cc: Jonas Karlman 
> Cc: Mathieu Othacehe 
> Cc: Mattijs Korpershoek 
> Cc: Neil Armstrong 
> Cc: Nishanth Menon 
> Cc: Nobuhiro Iwamatsu 
> Cc: Sean Anderson 
> Cc: Simon Glass 
> Cc: Sumit Garg 
> Cc: Tim Harvey 
> Cc: Tom Rini 
> Cc: Xavier Drudis Ferran 
> Cc: u-boot-q...@groups.io
> Cc: u-boot@lists.denx.de
> ---
> V2: New patch
> ---
>  drivers/phy/sandbox-phy.c | 13 +
>  test/dm/phy.c |  7 +++
>  2 files changed, 20 insertions(+)
>
> diff --git a/drivers/phy/sandbox-phy.c b/drivers/phy/sandbox-phy.c
> index b159147a765..e70d20432e0 100644
> --- a/drivers/phy/sandbox-phy.c
> +++ b/drivers/phy/sandbox-phy.c
> @@ -72,6 +72,18 @@ static int sandbox_phy_exit(struct phy *phy)
>   return 0;
>  }
>  
> +static int
> +sandbox_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
> +{
> + if (submode)
> + return -EOPNOTSUPP;
> +
> + if (mode != PHY_MODE_USB_HOST)
> + return -EINVAL;
> +
> + return 0;
> +}
> +
>  static int sandbox_phy_bind(struct udevice *dev)
>  {
>   if (dev_get_driver_data(dev) != DRIVER_DATA)
> @@ -96,6 +108,7 @@ static struct phy_ops sandbox_phy_ops = {
>   .power_off = sandbox_phy_power_off,
>   .init = sandbox_phy_init,
>   .exit = sandbox_phy_exit,
> + .set_mode = sandbox_phy_set_mode,
>  };
>  
>  static const struct udevice_id sandbox_phy_ids[] = {
> diff --git a/test/dm/phy.c b/test/dm/phy.c
> index a90881b12ab..a93aa83ab10 100644
> --- a/test/dm/phy.c
> +++ b/test/dm/phy.c
> @@ -246,6 +246,13 @@ static int dm_test_phy_setup(struct unit_test_state *uts)
>   ut_assertok(generic_setup_phy(parent, , 0, PHY_MODE_USB_HOST, 0));
>   ut_assertok(generic_shutdown_phy());
>  
> + /* set_mode as USB Host passes, anything else is not supported */
> + ut_assertok(generic_setup_phy(parent, , 0, PHY_MODE_USB_HOST, 0));
> + ut_assertok(generic_phy_set_mode(, PHY_MODE_USB_HOST, 0));
> + ut_asserteq(-EOPNOTSUPP, generic_phy_set_mode(, PHY_MODE_USB_HOST, 
> 1));
> + ut_asserteq(-EINVAL, generic_phy_set_mode(, PHY_MODE_USB_DEVICE, 
> 0));
> + ut_assertok(generic_shutdown_phy());
> +
>   /* power_off fail with -EIO */
>   ut_assertok(generic_setup_phy(parent, , 1, PHY_MODE_USB_HOST, 0));
>   ut_asserteq(-EIO, generic_shutdown_phy());
> -- 
> 2.43.0


Re: [PATCH v4 1/4] binman: Add nxp_imx8mcst etype for i.MX8M flash.bin signing

2024-07-09 Thread Simon Glass
Hi Marek,

On Sun, 7 Jul 2024 at 01:55, Marek Vasut  wrote:
>
> On 6/27/24 10:19 AM, Simon Glass wrote:
> > Hi Marek,
>
> Hi,
>
> >> Add new binman etype which allows signing both the SPL and fitImage 
> >> sections
> >> of i.MX8M flash.bin using CST. There are multiple DT properties which 
> >> govern
> >> the signing process, nxp,loader-address is the only mandatory one 
> >> which sets
> >> the SPL signature start address without the imx8mimage header, this 
> >> should be
> >> SPL text base. The key material can be configured using optional DT 
> >> properties
> >> nxp,srk-table, nxp,csf-crt, nxp,img-crt, all of which default the key 
> >> material
> >> names generated by CST tool scripts. The nxp,unlock property can be 
> >> used to
> >> unlock CAAM access in SPL section.
> >>
> >> Reviewed-by: Tim Harvey 
> >> Signed-off-by: Marek Vasut 
> >
> > Applied the series, thanks.
> 
>  This lacks tests - can you please add sufficient tests in ftest.py to
>  get the cover coverage back to 100%? Please try 'binman test -T' to
>  see this.
> >>>
> >>> Any thoughts on this, please? At present -master is broken for one
> >>> file and -next has three problems.
> >>
> >> It is in the pipeline.
> >>
> >> What exactly is the error you observe ?
> >>
> >> When I run binman test -T , I get a lot of output, but no error reports?
> >
> > Sorry I somehow missed this email.
> >
> > The tests are in ftest.py - there are lots of examples, e.g.
> > testXilinxBootgenSigning() - commit d8a2d3b29
>
> This seems to be testing some out-of-tree tool , not binman ?

It is testing the etype, which needs the tool to be present, yes, You
can use 'binman tool -f' to fetch tools if you want to try that one.

>
> > Basically you need to create a test .dts file that uses your entry
> > type, then use it in the test code. You can check error handling as
> > well, e.g. by having an invalid dts too if needed.
> >
> > If you run 'binman test -T' you will see the code-coverage problem.
> > You may need to fetch tools with 'binman tool -f missing' to get all
> > the tools*:
> >
> > Coverage error: 96%, but should be 100%
> > ValueError: Test coverage failure
> >
> > It is normally much easier to add an etype using a test than to test
> > it by using it 'for real', since you don't need to worry about the
> > U-Boot integration.
>
> Huh ...

Regards,
Simon


Re: [PATCH v2 2/3] phy: rcar: Split init and set_mode operations

2024-07-09 Thread Mattijs Korpershoek
Hi Marek,

Thank you for the patch.

On lun., juin 17, 2024 at 19:36, Marek Vasut  
wrote:

> The current init operation also sets the PHY into USB host mode.
> Split the mode configuration into set_mode callback instead and
> implement support for device and OTG modes as well.
>
> The OTG mode performs auto-detection and selects either host or
> device mode. In case the OTG mode is configured, submode field
> can be used to select full PHY (re)initialization or only mode
> auto-detection. The full (re)initialization is only necessary
> once, on start up.
>
> Since the OTG mode may enable IRQ generation in the PHY, disable
> that IRQ generation in the exit callback again.
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Caleb Connolly 
> Cc: Fabio Estevam 
> Cc: Fabrice Gasnier 
> Cc: Jonas Karlman 
> Cc: Mathieu Othacehe 
> Cc: Mattijs Korpershoek 
> Cc: Neil Armstrong 
> Cc: Nishanth Menon 
> Cc: Nobuhiro Iwamatsu 
> Cc: Sean Anderson 
> Cc: Simon Glass 
> Cc: Sumit Garg 
> Cc: Tim Harvey 
> Cc: Tom Rini 
> Cc: Xavier Drudis Ferran 
> Cc: u-boot-q...@groups.io
> Cc: u-boot@lists.denx.de
> ---
> V2: No change
> ---
>  drivers/phy/phy-rcar-gen3.c | 90 ++---
>  1 file changed, 85 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/phy/phy-rcar-gen3.c b/drivers/phy/phy-rcar-gen3.c
> index 7c292cae0e2..b278f995f37 100644
> --- a/drivers/phy/phy-rcar-gen3.c
> +++ b/drivers/phy/phy-rcar-gen3.c
> @@ -8,6 +8,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -31,8 +32,13 @@
>  #define USB2_LINECTRL1   0x610
>  #define USB2_ADPCTRL 0x630
>  
> +/* INT_ENABLE */
> +#define USB2_INT_ENABLE_UCOM_INTEN   BIT(3)
> +#define USB2_INT_ENABLE_USBH_INTB_EN BIT(2)
> +#define USB2_INT_ENABLE_USBH_INTA_EN BIT(1)
> +
>  /* USBCTR */
> -#define USB2_USBCTR_PLL_RST  BIT(1)
> +#define USB2_USBCTR_PLL_RST  BIT(1)
>  
>  /* SPD_RSM_TIMSET */
>  #define USB2_SPD_RSM_TIMSET_INIT 0x014e029b
> @@ -43,11 +49,23 @@
>  /* COMMCTRL */
>  #define USB2_COMMCTRL_OTG_PERI   BIT(31) /* 1 = Peripheral mode 
> */
>  
> +/* OBINTSTA and OBINTEN */
> +#define USB2_OBINT_SESSVLDCHGBIT(12)
> +#define USB2_OBINT_IDDIGCHG  BIT(11)
> +
> +/* VBCTRL */
> +#define USB2_VBCTRL_DRVVBUSSEL   BIT(8)
> +
>  /* LINECTRL1 */
> +#define USB2_LINECTRL1_DPRPD_EN  BIT(19)
>  #define USB2_LINECTRL1_DP_RPDBIT(18)
> +#define USB2_LINECTRL1_DMRPD_EN  BIT(17)
>  #define USB2_LINECTRL1_DM_RPDBIT(16)
>  
>  /* ADPCTRL */
> +#define USB2_ADPCTRL_OTGSESSVLD  BIT(20)
> +#define USB2_ADPCTRL_IDDIG   BIT(19)
> +#define USB2_ADPCTRL_IDPULLUPBIT(5)  /* 1 = ID sampling is 
> enabled */
>  #define USB2_ADPCTRL_DRVVBUS BIT(4)
>  
>  struct rcar_gen3_phy {
> @@ -65,12 +83,14 @@ static int rcar_gen3_phy_phy_init(struct phy *phy)
>   writel(USB2_SPD_RSM_TIMSET_INIT, priv->regs + USB2_SPD_RSM_TIMSET);
>   writel(USB2_OC_TIMSET_INIT, priv->regs + USB2_OC_TIMSET);
>  
> - setbits_le32(priv->regs + USB2_LINECTRL1,
> -  USB2_LINECTRL1_DP_RPD | USB2_LINECTRL1_DM_RPD);
> + return 0;
> +}
>  
> - clrbits_le32(priv->regs + USB2_COMMCTRL, USB2_COMMCTRL_OTG_PERI);
> +static int rcar_gen3_phy_phy_exit(struct phy *phy)
> +{
> + struct rcar_gen3_phy *priv = dev_get_priv(phy->dev);
>  
> - setbits_le32(priv->regs + USB2_ADPCTRL, USB2_ADPCTRL_DRVVBUS);
> + writel(0, priv->regs + USB2_INT_ENABLE);
>  
>   return 0;
>  }
> @@ -102,10 +122,70 @@ static int rcar_gen3_phy_phy_power_off(struct phy *phy)
>   return regulator_set_enable(priv->vbus_supply, false);
>  }
>  
> +static int rcar_gen3_phy_phy_set_mode(struct phy *phy, enum phy_mode mode,
> +   int submode)
> +{
> + const u32 adpdevmask = USB2_ADPCTRL_IDDIG | USB2_ADPCTRL_OTGSESSVLD;
> + struct rcar_gen3_phy *priv = dev_get_priv(phy->dev);
> + u32 adpctrl;
> +
> + if (mode == PHY_MODE_USB_OTG) {
> + if (submode) {
> + /* OTG submode is used as initialization indicator */
> + writel(USB2_INT_ENABLE_UCOM_INTEN |
> +USB2_INT_ENABLE_USBH_INTB_EN |
> +USB2_INT_ENABLE_USBH_INTA_EN,
> +priv->regs + USB2_INT_ENABLE);
> + setbits_le32(priv->regs + USB2_VBCTRL,
> +  USB2_VBCTRL_DRVVBUSSEL);
> + writel(USB2_OBINT_SESSVLDCHG | USB2_OBINT_IDDIGCHG,
> +priv->regs + USB2_OBINTSTA);
> + setbits_le32(priv->regs + USB2_OBINTEN,
> +  USB2_OBINT_SESSVLDCHG |
> +  USB2_OBINT_IDDIGCHG);
> + setbits_le32(priv->regs + USB2_ADPCTRL,
> + 

Re: [PATCH v2 1/3] phy: Extend generic_setup_phy() with PHY mode and submode

2024-07-09 Thread Mattijs Korpershoek
Hi Marek,

Thank you for the patch.

On lun., juin 17, 2024 at 19:36, Marek Vasut  
wrote:

> Extend generic_setup_phy() parameter list with PHY mode and submode and
> call generic_phy_set_mode() in generic_setup_phy(), so the generic PHY
> setup function can configure the PHY into correct mode before powering
> the PHY up.
>
> Update all call sites of generic_setup_phy() as well, all of which are
> USB host related, except for DM test which now behaves as a USB host
> test.
>
> Note that if the PHY driver does not implement the .set_mode callback,
> generic_phy_set_mode() call returns 0 and does not error out, so this
> should not break any existing systems.
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Caleb Connolly 
> Cc: Fabio Estevam 
> Cc: Fabrice Gasnier 
> Cc: Jonas Karlman 
> Cc: Mathieu Othacehe 
> Cc: Mattijs Korpershoek 
> Cc: Neil Armstrong 
> Cc: Nishanth Menon 
> Cc: Nobuhiro Iwamatsu 
> Cc: Sean Anderson 
> Cc: Simon Glass 
> Cc: Sumit Garg 
> Cc: Tim Harvey 
> Cc: Tom Rini 
> Cc: Xavier Drudis Ferran 
> Cc: u-boot-q...@groups.io
> Cc: u-boot@lists.denx.de
> ---
> V2: Add failpath to return errno from generic_phy_set_mode()
> ---
>  drivers/phy/phy-uclass.c| 13 +++--
>  drivers/usb/host/ehci-generic.c |  2 +-
>  drivers/usb/host/ehci-msm.c |  2 +-
>  drivers/usb/host/ehci-mx6.c |  2 +-
>  drivers/usb/host/ehci-pci.c |  2 +-
>  drivers/usb/host/ohci-generic.c |  2 +-
>  include/generic-phy.h   |  5 -
>  test/dm/phy.c   |  8 
>  8 files changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
> index acdcda15b5b..777d952b041 100644
> --- a/drivers/phy/phy-uclass.c
> +++ b/drivers/phy/phy-uclass.c
> @@ -508,7 +508,8 @@ int generic_phy_power_off_bulk(struct phy_bulk *bulk)
>   return ret;
>  }
>  
> -int generic_setup_phy(struct udevice *dev, struct phy *phy, int index)
> +int generic_setup_phy(struct udevice *dev, struct phy *phy, int index,
> +   enum phy_mode mode, int submode)
>  {
>   int ret;
>  
> @@ -520,10 +521,18 @@ int generic_setup_phy(struct udevice *dev, struct phy 
> *phy, int index)
>   if (ret)
>   return ret;
>  
> + ret = generic_phy_set_mode(phy, mode, submode);
> + if (ret)
> + goto phys_mode_err;
> +
>   ret = generic_phy_power_on(phy);
>   if (ret)
> - generic_phy_exit(phy);
> + goto phys_mode_err;
> +
> + return 0;
>  
> +phys_mode_err:
> + generic_phy_exit(phy);
>   return ret;
>  }
>  
> diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
> index 23c3ed25554..1ae3619ce25 100644
> --- a/drivers/usb/host/ehci-generic.c
> +++ b/drivers/usb/host/ehci-generic.c
> @@ -94,7 +94,7 @@ static int ehci_usb_probe(struct udevice *dev)
>   if (err)
>   goto reset_err;
>  
> - err = generic_setup_phy(dev, >phy, 0);
> + err = generic_setup_phy(dev, >phy, 0, PHY_MODE_USB_HOST, 0);
>   if (err)
>   goto regulator_err;
>  
> diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
> index a081f71b187..b0c060b8173 100644
> --- a/drivers/usb/host/ehci-msm.c
> +++ b/drivers/usb/host/ehci-msm.c
> @@ -56,7 +56,7 @@ static int ehci_usb_probe(struct udevice *dev)
>   hcor = (struct ehci_hcor *)((phys_addr_t)hccr +
>   HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
>  
> - ret = generic_setup_phy(dev, >phy, 0);
> + ret = generic_setup_phy(dev, >phy, 0, PHY_MODE_USB_HOST, 0);
>   if (ret)
>   return ret;
>  
> diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> index 31cd8a50f4a..a93fa5d5455 100644
> --- a/drivers/usb/host/ehci-mx6.c
> +++ b/drivers/usb/host/ehci-mx6.c
> @@ -703,7 +703,7 @@ static int ehci_usb_probe(struct udevice *dev)
>   usb_phy_enable(ehci, priv->phy_addr);
>  #endif
>  #else
> - ret = generic_setup_phy(dev, >phy, 0);
> + ret = generic_setup_phy(dev, >phy, 0, PHY_MODE_USB_HOST, 0);
>   if (ret)
>   goto err_regulator;
>  #endif
> diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
> index 572686580cd..8d05b14e898 100644
> --- a/drivers/usb/host/ehci-pci.c
> +++ b/drivers/usb/host/ehci-pci.c
> @@ -30,7 +30,7 @@ static int ehci_pci_init(struct udevice *dev, struct 
> ehci_hccr **ret_hccr,
>   int ret;
>   u32 cmd;
>  
> - ret = generic_setup_phy(dev, >phy, 0);
> + ret = generic_setup_phy(dev, >phy, 0, PHY_MODE_USB_HOST, 0);
>   if (ret)
>   return ret;
>  
> diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
> index f1325cd4953..cc44226f5e0 100644
> --- a/drivers/usb/host/ohci-generic.c
> +++ b/drivers/usb/host/ohci-generic.c
> @@ -50,7 +50,7 @@ static int ohci_usb_probe(struct udevice *dev)
>   goto reset_err;
>   }
>  
> - err = generic_setup_phy(dev, 

Re: [PATCH] eth: asix88179: reset during probe

2024-07-09 Thread Mattijs Korpershoek
Hi Caleb,

Thank you for the patch.

On mar., juin 18, 2024 at 16:57, Caleb Connolly  
wrote:

> In some cases (consistently in my case with an embedded board) the
> ethernet controller will time out on the first init but always succeed
> after reset.
>
> Let's reset the controller during probe so we always start with it in a
> known state, and don't have wait for the first asix_wait_link() to
> time out.
>
> Signed-off-by: Caleb Connolly 

Reviewed-by: Mattijs Korpershoek 

> ---
> I see this behaviour consistently across three Qualcomm platforms that use 
> this
> controller.
> ---
>  drivers/usb/eth/asix88179.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c
> index 7bfd285b3aa4..a0aa5c25e428 100644
> --- a/drivers/usb/eth/asix88179.c
> +++ b/drivers/usb/eth/asix88179.c
> @@ -628,8 +628,14 @@ static int ax88179_eth_probe(struct udevice *dev)
>  
>   usb_dev = priv->ueth.pusb_dev;
>   priv->maxpacketsize = usb_dev->epmaxpacketout[AX_ENDPOINT_OUT];
>  
> + ret = asix_basic_reset(>ueth, priv);
> + if (ret) {
> + printf("Failed to reset ethernet device\n");
> + return ret;
> + }
> +
>   /* Get the MAC address */
>   ret = asix_read_mac(>ueth, pdata->enetaddr);
>   if (ret)
>   return ret;
> -- 
> 2.45.0


Re: [PATCH 1/4] configs: phycore_am62x_a53: Add more commands

2024-07-09 Thread Wadim Egorov




Am 01.07.24 um 08:20 schrieb Daniel Schultz:

Add i2c and rtc commands with all dependencies which are
required for testing.

Additionally, add smc and cache commands to boot Zephyr on the A53.

Signed-off-by: Daniel Schultz 


For this series,

Reviewed-by: Wadim Egorov 


---
  configs/phycore_am62x_a53_defconfig | 7 +++
  1 file changed, 7 insertions(+)

diff --git a/configs/phycore_am62x_a53_defconfig 
b/configs/phycore_am62x_a53_defconfig
index 56302383c0f..06b8834e074 100644
--- a/configs/phycore_am62x_a53_defconfig
+++ b/configs/phycore_am62x_a53_defconfig
@@ -1,4 +1,5 @@
  CONFIG_ARM=y
+CONFIG_ARM_SMCCC=y
  CONFIG_ARCH_K3=y
  CONFIG_SYS_MALLOC_LEN=0x200
  CONFIG_SYS_MALLOC_F_LEN=0x8000
@@ -63,9 +64,13 @@ CONFIG_SPL_SPI_LOAD=y
  CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
  CONFIG_SPL_YMODEM_SUPPORT=y
  CONFIG_CMD_DFU=y
+CONFIG_CMD_I2C=y
  CONFIG_CMD_MMC=y
  CONFIG_CMD_MTD=y
  CONFIG_CMD_USB=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_RTC=y
+CONFIG_CMD_SMC=y
  CONFIG_OF_CONTROL=y
  CONFIG_SPL_OF_CONTROL=y
  CONFIG_MULTI_DTB_FIT=y
@@ -123,6 +128,8 @@ CONFIG_TI_SCI_POWER_DOMAIN=y
  CONFIG_K3_SYSTEM_CONTROLLER=y
  CONFIG_REMOTEPROC_TI_K3_ARM64=y
  CONFIG_RESET_TI_SCI=y
+CONFIG_DM_RTC=y
+CONFIG_RTC_RV3028=y
  CONFIG_DM_SERIAL=y
  CONFIG_SOC_DEVICE=y
  CONFIG_SOC_DEVICE_TI_K3=y


Re: [PATCH] include/fastboot.h: add missing types.h include

2024-07-09 Thread Mattijs Korpershoek
Hi,

On Fri, 21 Jun 2024 03:51:02 +0200, Caleb Connolly wrote:
> Fixes a compile error when building with only the TCP fastboot implementation.
> 
> 

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu 
(u-boot-dfu)

[1/1] include/fastboot.h: add missing types.h include
  
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/b091d3872833a4b8d088ee41348a2d4ff48067cc

--
Mattijs


Re: [PATCH 0/6] Extend SOM detection

2024-07-09 Thread Daniel Schultz

Hey,

please don't apply these patches. We just found an issue while working 
on another task. Sorry!


Best Regards,
Daniel

On 08.07.24 08:07, Daniel Schultz wrote:

This patchset extends PHYTEC's SOM detection for the
K3 platforms.

It adds generic support to apply overlays via the
extension framework inside the overlays.env file. Additionally,
the K3 mmc boot environment applies these overlays now.

It also adds the 'extension_board_scan' hook to the K3 board
code and adds all missing configs in the phyCORE-AM62x and
-AM64x A53 defconfigs.

Daniel Schultz (6):
   include: env: phytec: overlays: Add extension command
   include: env: phytec: k3_mmc: Apply extension overlays
   board: phytec: common: k3: Add SOM detection overlays
   board: phytec: common: Kconfig: Enable SUPPORT_EXTENSION_SCAN
   configs: phytec_am62x_a53_defconfig: Set CONFIG_CMD_EXTENSION
   configs: phycore_am64x_a53_defconfig: Enable SOM detection

  board/phytec/common/Kconfig |  2 ++
  board/phytec/common/k3/board.c  | 45 +
  configs/phycore_am62x_a53_defconfig |  1 +
  configs/phycore_am64x_a53_defconfig |  2 ++
  include/env/phytec/k3_mmc.env   |  1 +
  include/env/phytec/overlays.env | 20 +
  6 files changed, 71 insertions(+)



Re: [PATCH] configs: am62x_evm_a53_defconfig: Remove CONFIG_SYS_BOOTM_LEN

2024-07-09 Thread Kamlesh Gurudasani
Manorit Chawdhry  writes:

> Hi Kamlesh,
>
> On 17:20-20240708, Kamlesh Gurudasani wrote:
>> Increase the maximum size of the buffer that is used to decompress
>> the OS image in to.
>> 
>> If image size is greater than the buffer, boot
>> will fail with following error,
>> "Error: inflate() returned -5"
>> "gzip compressed: uncompress error -1"
>> 
>> Default limit for ARM64 platforms is 0x400, remove
>> CONFIG_SYS_BOOTM_LEN=0x800, so that it follows default limit.
>
> Why were we failing with a larger buffer size..?

Thanks for reviewing, Manorit. Typo in the commit msg, extra zero.
It should be 0x80 as in actual diff. Will fix in v2.

Kamlesh
>
> Regards,
> Manorit
>
>> 
>> Signed-off-by: Kamlesh Gurudasani 
>> ---
>>  configs/am62x_evm_a53_defconfig | 1 -
>>  1 file changed, 1 deletion(-)
>> 
>> diff --git a/configs/am62x_evm_a53_defconfig 
>> b/configs/am62x_evm_a53_defconfig
>> index ca993b427b..dfa5ecc847 100644
>> --- a/configs/am62x_evm_a53_defconfig
>> +++ b/configs/am62x_evm_a53_defconfig
>> @@ -32,7 +32,6 @@ CONFIG_SPL_SPI=y
>>  CONFIG_SPL_LOAD_FIT=y
>>  CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
>>  CONFIG_BOOTSTD_FULL=y
>> -CONFIG_SYS_BOOTM_LEN=0x80
>>  CONFIG_BOOTCOMMAND="run findfdt; run envboot; bootflow scan -lb"
>>  CONFIG_BOARD_LATE_INIT=y
>>  CONFIG_SPL_MAX_SIZE=0x58000
>> 
>> ---
>> base-commit: fd46ea0e701920eb205c2bce9d527bf0dec10b59
>> change-id: 20240708-remove-bootm-len-ab4e46039656
>> 
>> Best regards,
>> -- 
>> Kamlesh Gurudasani 
>> 


Re: [PATCH v3 07/10] configs: am62: Add configs for enabling ETHBOOT in R5SPL

2024-07-09 Thread Chintan Vankar




On 05/07/24 21:07, Tom Rini wrote:

On Fri, Jul 05, 2024 at 10:20:27AM +0530, Chintan Vankar wrote:


From: Kishon Vijay Abraham I 

Add configs for enabling ETHBOOT in R5SPL.

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

Link to v2:
https://lore.kernel.org/r/20240425120822.2048012-8-c-van...@ti.com/

Changes from v2 to v3:
- No changes.

  configs/am62x_evm_r5_ethboot_defconfig | 20 
  1 file changed, 20 insertions(+)
  create mode 100644 configs/am62x_evm_r5_ethboot_defconfig

diff --git a/configs/am62x_evm_r5_ethboot_defconfig 
b/configs/am62x_evm_r5_ethboot_defconfig
new file mode 100644
index 00..7b1932b215
--- /dev/null
+++ b/configs/am62x_evm_r5_ethboot_defconfig
@@ -0,0 +1,20 @@
+#include
+
+CONFIG_SPL_GPIO=y


You need a few other options set in order for buildman to work in this
case, please look at the other #include users.



Are you referring to include "configs/k3_efi_capsule.config" ?


Re: [PATCH 1/6] include: env: phytec: overlays: Add extension command

2024-07-09 Thread Yannic Moog
Hello Daniel,

On Sun, 2024-07-07 at 23:07 -0700, Daniel Schultz wrote:
> Add a new environment routine to apply extensions. Our SOM detection
> adds overlays via the extension framework to alter the kernel
> device-tree according to the flashed EEPROM image.
> 
> Signed-off-by: Daniel Schultz 
> ---
>  include/env/phytec/overlays.env | 20 
>  1 file changed, 20 insertions(+)
> 
> diff --git a/include/env/phytec/overlays.env b/include/env/phytec/overlays.env
> index 78721cde654..50110e731bd 100644
> --- a/include/env/phytec/overlays.env
> +++ b/include/env/phytec/overlays.env
> @@ -23,6 +23,16 @@ mmc_apply_overlays=
>   fi;
>   done;
>   fi;
> +#ifdef CONFIG_CMD_EXTENSION
> +mmc_apply_extensions=
> + setenv extension_overlay_addr ${fdtoverlay_addr_r};
> + setenv extension_overlay_cmd 'load mmc ${mmcdev}:${mmcpart}
> +   ${fdtoverlay_addr_r} ${extension_overlay_name}';
> + extension scan;
> + extension apply all;
> +#else
> +mmc_apply_extensions=echo "no extension command"

Do you think it makes sense to make this fail? I would think "apply_extensions" 
would be
unsuccessful if extensions are not working.

Yannic

> +#endif
>  net_load_bootenv=${get_cmd} ${bootenv_addr_r} ${bootenv}
>  net_load_overlay=${get_cmd} ${fdtoverlay_addr_r} ${overlay}
>  net_apply_overlays=
> @@ -36,3 +46,13 @@ net_apply_overlays=
>   fi;
>   done;
>   fi;
> +#ifdef CONFIG_CMD_EXTENSION
> +net_apply_extensions=
> + setenv extension_overlay_addr ${fdtoverlay_addr_r};
> + setenv extension_overlay_cmd '${get_cmd} ${fdtoverlay_addr_r}
> +  ${extension_overlay_name}';
> + extension scan;
> + extension apply all;
> +#else
> +net_apply_extensions=echo "no extension command"
> +#endif



Re: [PATCH] xilinx: Enable the NFS command for zynqmp_kria

2024-07-09 Thread Michal Simek




On 7/9/24 06:22, Prasad Kummari wrote:

Enabled the default utilization of the NFS command on ZynqMP Kria
platforms to facilitate booting images through the network using
the NFS protocol.

Signed-off-by: Prasad Kummari 
---
  configs/xilinx_zynqmp_kria_defconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/configs/xilinx_zynqmp_kria_defconfig 
b/configs/xilinx_zynqmp_kria_defconfig
index 58e88b25fd..4c66c536d0 100644
--- a/configs/xilinx_zynqmp_kria_defconfig
+++ b/configs/xilinx_zynqmp_kria_defconfig
@@ -81,6 +81,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
  CONFIG_BOOTP_MAY_FAIL=y
  CONFIG_BOOTP_BOOTFILESIZE=y
  CONFIG_CMD_TFTPPUT=y
+CONFIG_CMD_NFS=y
  CONFIG_CMD_BMP=y
  CONFIG_CMD_CACHE=y
  CONFIG_CMD_EFIDEBUG=y


please also add it to amd_versal2_virt_defconfig

Thanks,
Michal


[PATCH] clk: clk-uclass: Print clk name in clk_enable/clk_disable

2024-07-09 Thread Michael Trimarchi
Print clk name in clk_enable and clk_disable. Make sense to know
what clock get disabled/enabled before a system crash or system
hang.

Signed-off-by: Michael Trimarchi 
---
 drivers/clk/clk-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index d768e5ad2e..76f1026164 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -630,7 +630,7 @@ int clk_enable(struct clk *clk)
struct clk *clkp = NULL;
int ret;
 
-   debug("%s(clk=%p)\n", __func__, clk);
+   debug("%s(clk=%p name=%s)\n", __func__, clk, clk->dev->name);
if (!clk_valid(clk))
return 0;
ops = clk_dev_ops(clk->dev);
@@ -691,7 +691,7 @@ int clk_disable(struct clk *clk)
struct clk *clkp = NULL;
int ret;
 
-   debug("%s(clk=%p)\n", __func__, clk);
+   debug("%s(clk=%p name=%s)\n", __func__, clk, clk->dev->name);
if (!clk_valid(clk))
return 0;
ops = clk_dev_ops(clk->dev);
-- 
2.43.0