Re: [PATCH 1/2] cmd: efidebug: add uri device path

2023-08-24 Thread Masahisa Kojima
On Thu, 24 Aug 2023 at 14:37, Heinrich Schuchardt  wrote:
>
> On 8/23/23 10:37, Masahisa Kojima wrote:
> > This adds the URI device path option for 'boot add' subcommand.
> > User can add the URI load option for downloading ISO image file
> > or EFI application through network(e.g. HTTP).
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> >   cmd/efidebug.c | 39 +++
> >   1 file changed, 39 insertions(+)
> >
> > diff --git a/cmd/efidebug.c b/cmd/efidebug.c
> > index 0be3af3e76..62f867df2a 100644
> > --- a/cmd/efidebug.c
> > +++ b/cmd/efidebug.c
> > @@ -829,6 +829,44 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int 
> > flag,
> >   argc -= 1;
> >   argv += 1;
> >   break;
> > + case 'u':
> > + {
> > + char *pos;
> > + int uridp_len;
> > + struct efi_device_path_uri *uridp;
> > +
> > + if (argc <  3 || lo.label) {
> > + r = CMD_RET_USAGE;
> > + goto out;
> > + }
> > + id = (int)hextoul(argv[1], );
> > + if (*endp != '\0' || id > 0x)
> > + return CMD_RET_USAGE;
> > +
> > + efi_create_indexed_name(var_name16, 
> > sizeof(var_name16),
> > + "Boot", id);
> > +
> > + label = efi_convert_string(argv[2]);
> > + if (!label)
> > + return CMD_RET_FAILURE;
> > + lo.label = label;
> > +
> > + uridp_len = sizeof(struct efi_device_path) + 
> > strlen(argv[3]) + 1; > +   fp_free = efi_alloc(uridp_len + 
> > sizeof(END));
> > + uridp = (struct efi_device_path_uri *)fp_free;
> > + uridp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
> > + uridp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_URI;
> > + uridp->dp.length = uridp_len;
> > + strcpy(uridp->uri, argv[3]);
>
> This assumes that argv[3] is a valid URI.
>
> Would it be preferable to validate that the string is percent encoded,
> conforms to RFC 3986, and contains a supported scheme, an authority, and
> a path?
>
> As a user I would like related errors to be caught at entry and not at
> runtime.

OK, I agree. I will add input uri validation here.

Thanks,
Masahisa Kojima

>
> Best regards
>
> Heinrich
>
> > + pos = (char *)uridp + uridp_len;
> > + memcpy(pos, , sizeof(END));
> > + fp_size += uridp_len + sizeof(END);
> > + file_path = (struct efi_device_path *)uridp;
> > + argc -= 3;
> > + argv += 3;
> > + break;
> > + }
> > +
> >   default:
> >   r = CMD_RET_USAGE;
> >   goto out;
> > @@ -1492,6 +1530,7 @@ static char efidebug_help_text[] =
> >   "  -b|-B[:] \n"
> >   "  -i|-I  [:] \n"
> >   "  (-b, -i for short form device path)\n"
> > + "  -u   \n"
> >   "  -s ''\n"
> >   "efidebug boot rm  [ [ [...]]]\n"
> >   "  - delete UEFI Boot variables\n"
>


Re: [PATCH 1/2] cmd: efidebug: add uri device path

2023-08-24 Thread Masahisa Kojima
On Thu, 24 Aug 2023 at 09:11, AKASHI Takahiro
 wrote:
>
> Hi Kojima-san,
>
> On Wed, Aug 23, 2023 at 05:37:19PM +0900, Masahisa Kojima wrote:
> > This adds the URI device path option for 'boot add' subcommand.
> > User can add the URI load option for downloading ISO image file
> > or EFI application through network(e.g. HTTP).
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> >  cmd/efidebug.c | 39 +++
> >  1 file changed, 39 insertions(+)
> >
> > diff --git a/cmd/efidebug.c b/cmd/efidebug.c
> > index 0be3af3e76..62f867df2a 100644
> > --- a/cmd/efidebug.c
> > +++ b/cmd/efidebug.c
> > @@ -829,6 +829,44 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int 
> > flag,
> >   argc -= 1;
> >   argv += 1;
> >   break;
> > + case 'u':
> > + {
> > + char *pos;
> > + int uridp_len;
> > + struct efi_device_path_uri *uridp;
> > +
> > + if (argc <  3 || lo.label) {
> > + r = CMD_RET_USAGE;
> > + goto out;
> > + }
> > + id = (int)hextoul(argv[1], );
> > + if (*endp != '\0' || id > 0x)
> > + return CMD_RET_USAGE;
> > +
> > + efi_create_indexed_name(var_name16, 
> > sizeof(var_name16),
> > + "Boot", id);
> > +
> > + label = efi_convert_string(argv[2]);
> > + if (!label)
> > + return CMD_RET_FAILURE;
> > + lo.label = label;
> > +
> > + uridp_len = sizeof(struct efi_device_path) + 
> > strlen(argv[3]) + 1;
> > + fp_free = efi_alloc(uridp_len + sizeof(END));
> > + uridp = (struct efi_device_path_uri *)fp_free;
> > + uridp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
> > + uridp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_URI;
> > + uridp->dp.length = uridp_len;
> > + strcpy(uridp->uri, argv[3]);
> > + pos = (char *)uridp + uridp_len;
> > + memcpy(pos, , sizeof(END));
> > + fp_size += uridp_len + sizeof(END);
> > + file_path = (struct efi_device_path *)uridp;
> > + argc -= 3;
> > + argv += 3;
> > + break;
> > + }
> > +
> >   default:
> >   r = CMD_RET_USAGE;
> >   goto out;
> > @@ -1492,6 +1530,7 @@ static char efidebug_help_text[] =
> >   "  -b|-B[:] \n"
> >   "  -i|-I  [:] \n"
> >   "  (-b, -i for short form device path)\n"
> > + "  -u   \n"
>
> It might be a matter of personal preference, but
> since the current syntax of efidebug is already much complex,
> I don't want to add more options unless it's necessary.
> How about re-using "-B" option, say
>=> efidebug -B 3 debian-netinst uri - https://foo.com/baa

I understand your concern. OK, I will add uri in -b|B and also update
documentation.

Thanks,
Masahisa Kojima

>
> BTW, I think that  and  should have been moved out of "-b|B"
> when Ilias introduced this new syntax.
>
> -Takahiro Akashi
>
>
> >   "  -s ''\n"
> >   "efidebug boot rm  [ [ [...]]]\n"
> >   "  - delete UEFI Boot variables\n"
> > --
> > 2.34.1
> >


Re: [PATCH 1/2] net: ti: am65-cpsw-nuss: Workaround for buggy PHY/Board

2023-08-24 Thread Siddharth Vadapalli
Roger,

On 25/08/23 00:39, Roger Quadros wrote:
> 
> 
> On 24/08/2023 21:24, Tom Rini wrote:
>> On Thu, Aug 24, 2023 at 11:34:29PM +0530, Siddharth Vadapalli wrote:
>>> Hello Roger,
>>>
>>> On 22-08-2023 17:43, Roger Quadros wrote:

...

> 
> Even a single "PHY not found" print is not OK. It looks like an
> error while it should not.
> 
> The correct solution is to use the MDIO uclass framework and add
> some generic handling in the class driver. drivers/net/eth-phy-uclass.c
> 
> We could provide the delay time in the 'reset-deassert-us' property.
> Although I'm not sure if this is the correct property for this case
> as there is no RESET GPIO on the board. What we really want is delay
> from power-on-reset. Which means we might have to introduce a new property
> and use time from boot to determine if PHY is ready or not?
> 
> NOTE: PHY ready time is different for hardware reset and power-on-reset.
> 50ms vs 150ms

Another alternative could be that of implementing the for-loop within
phy_connect() along with the delay, by updating the function with a new
parameter "tries" which indicates the number of retries before finally printing
"PHY not found" in case of an error. Optionally, another parameter "delay" can
be added, which indicates the delay within the for-loop.

This implementation will require updating all drivers in drivers/net which use
phy_connect(), with the "tries" parameter set to 1 for them. The am65-cpsw-nuss
driver can set "tries" to 5 as done in the current patch.

The idea behind moving the for-loop within phy_connect() is that it will help
solve the issue for other drivers as well, if they potentially encounter such
buggy PHYs in future boards.

> 

-- 
Regards,
Siddharth.


[PATCH 2/2] Title: Add Meta OpenBMC Minerva dts in uboot.

2023-08-24 Thread peteryin
Add dts file for Meta OpenBMC Minerva.

Signed-off-by: peteryin 
---
 arch/arm/dts/Makefile|  1 +
 arch/arm/dts/ast2600-minerva.dts | 93 
 2 files changed, 94 insertions(+)
 create mode 100644 arch/arm/dts/ast2600-minerva.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0a893baf64..d3faab78b1 100755
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -684,6 +684,7 @@ dtb-$(CONFIG_ARCH_ASPEED) += \
ast2600a0-evb.dtb \
ast2600a1-evb.dtb \
ast2600-bletchley.dtb \
+   ast2600-minerva.dtb \
ast2600-evb.dtb \
ast2600-dcscm.dtb \
ast2600-fpga.dtb \
diff --git a/arch/arm/dts/ast2600-minerva.dts b/arch/arm/dts/ast2600-minerva.dts
new file mode 100644
index 00..2399525b24
--- /dev/null
+++ b/arch/arm/dts/ast2600-minerva.dts
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: GPL-2.0+
+// Copyright (c) 2022 Meta Platforms Inc.
+/dts-v1/;
+
+#include "ast2600-u-boot.dtsi"
+
+/ {
+   model = "Facebook Minerva BMC";
+   compatible = "facebook,minerva-bmc", "aspeed,ast2600";
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x4000>;
+   };
+
+   chosen {
+   stdout-path = 
+   };
+
+   aliases {
+   spi0 = 
+   ethernet3 = 
+   };
+
+   cpus {
+   cpu@0 {
+   clock-frequency = <8>;
+   };
+   cpu@1 {
+   clock-frequency = <8>;
+   };
+   };
+};
+
+ {
+   u-boot,dm-pre-reloc;
+   status = "okay";
+};
+
+ {
+   clock-frequency = <4>;
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+   phy-mode = "rgmii";
+   pinctrl-names = "default";
+   pinctrl-0 = <_rgmii4_default>;
+};
+
+ {
+   status = "okay";
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_fmcquad_default>;
+
+   flash@0 {
+   status = "okay";
+   spi-max-frequency = <5000>;
+   spi-tx-bus-width = <2>;
+   spi-rx-bus-width = <2>;
+   };
+
+   flash@1 {
+   status = "okay";
+   spi-max-frequency = <5000>;
+   spi-tx-bus-width = <2>;
+   spi-rx-bus-width = <2>;
+   };
+
+   flash@2 {
+   status = "okay";
+   spi-max-frequency = <5000>;
+   spi-tx-bus-width = <2>;
+   spi-rx-bus-width = <2>;
+   };
+};
+
+ {
+   status = "okay";
+};
-- 
2.25.1



[PATCH 1/2] Title:Add board for Meta openbmc Minerva.

2023-08-24 Thread peteryin
From: peteryin 

Create minerva initial file.

Signed-off-by: peteryin 
---
 arch/arm/mach-aspeed/ast2600/Kconfig  |   8 ++
 board/aspeed/meta_ast2600/Kconfig |  13 ++
 board/aspeed/meta_ast2600/Makefile|   1 +
 .../meta_ast2600/meta_minerva_ast2600.c   | 130 ++
 4 files changed, 152 insertions(+)
 create mode 100644 board/aspeed/meta_ast2600/Kconfig
 create mode 100644 board/aspeed/meta_ast2600/Makefile
 create mode 100644 board/aspeed/meta_ast2600/meta_minerva_ast2600.c

diff --git a/arch/arm/mach-aspeed/ast2600/Kconfig 
b/arch/arm/mach-aspeed/ast2600/Kconfig
index f5852afa77..444990e2e3 100644
--- a/arch/arm/mach-aspeed/ast2600/Kconfig
+++ b/arch/arm/mach-aspeed/ast2600/Kconfig
@@ -51,6 +51,13 @@ config TARGET_QUALCOMM_DC_SCM_V1
  QUALCOMM-DC-SCM-V1 is a Qualcomm DC-SCM V1 board which is
  equipped with AST2600.
 
+config TARGET_META_MINERVA_AST2600
+   bool "META-MINERVA-AST2600"
+   depends on ASPEED_AST2600
+   help
+ META-MINERVA-AST2600 is META openbmc minerva board for AST2600A3 chip.
+
+
 endchoice
 
 source "board/aspeed/evb_ast2600/Kconfig"
@@ -59,5 +66,6 @@ source "board/aspeed/slt_ast2600/Kconfig"
 source "board/aspeed/ast2600_ibm/Kconfig"
 source "board/aspeed/ast2600_intel/Kconfig"
 source "board/qualcomm/dc-scm-v1/Kconfig"
+source "board/aspeed/meta_ast2600/Kconfig"
 
 endif
diff --git a/board/aspeed/meta_ast2600/Kconfig 
b/board/aspeed/meta_ast2600/Kconfig
new file mode 100644
index 00..adc5b58733
--- /dev/null
+++ b/board/aspeed/meta_ast2600/Kconfig
@@ -0,0 +1,13 @@
+if TARGET_META_MINERVA_AST2600
+
+config SYS_BOARD
+   default "meta_ast2600"
+
+config SYS_VENDOR
+   default "aspeed"
+
+config SYS_CONFIG_NAME
+   string "board configuration name"
+   default "meta_minerva_ast2600"
+
+endif
diff --git a/board/aspeed/meta_ast2600/Makefile 
b/board/aspeed/meta_ast2600/Makefile
new file mode 100644
index 00..b5a526efa5
--- /dev/null
+++ b/board/aspeed/meta_ast2600/Makefile
@@ -0,0 +1 @@
+obj-y += meta_minerva_ast2600.o
diff --git a/board/aspeed/meta_ast2600/meta_minerva_ast2600.c 
b/board/aspeed/meta_ast2600/meta_minerva_ast2600.c
new file mode 100644
index 00..d0b3720da3
--- /dev/null
+++ b/board/aspeed/meta_ast2600/meta_minerva_ast2600.c
@@ -0,0 +1,130 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) ASPEED Technology Inc.
+ */
+#include 
+#include 
+
+#define SCU_BASE   (0x1e6e2000)
+#define ESPI_BASE  (0x1e6ee000)
+#define LPC_BASE   (0x1e789000)
+#define LPC_HICR5  (LPC_BASE + 0x80)
+#define LPC_HICR6  (LPC_BASE + 0x84)
+#define LPC_SNPWADR(LPC_BASE + 0x90)
+#define LPC_HICRB  (LPC_BASE + 0x100)
+#define LPC_PCCR0  (LPC_BASE | 0x130)
+
+#define SCU_MUTI_FN_PIN_CTRL5  (SCU_BASE | 0x414)
+#define SCU_MUTI_FN_PIN_CTRL7  (SCU_BASE | 0x41C)
+#define SCU_MUTI_FN_PIN_CTRL9  (SCU_BASE | 0x434)
+#define SCU_MUTI_FN_PIN_CTRL15 (SCU_BASE | 0x454)
+#define SCU_PIN_CONTROL8_REG   (SCU_BASE | 0x430)
+#define SCU_HW_STRAP2_SET_REG  (SCU_BASE | 0x510)
+#define SCU_HW_STRAP2_CLR_REG  (SCU_BASE | 0x514)
+#define SCU_HW_STRAP3_REG  (SCU_BASE | 0x51C)
+
+#define ENABLE_GPIO_PASSTHROUGHBIT(9)
+#define GPIO_BASE  (0x1e78)
+#define GPIO_ABCD_BASE_REG (GPIO_BASE | 0x000)
+#define GPIO_ABCD_DATA_REG (GPIO_ABCD_BASE_REG)
+#define GPIO_ABCD_DIR_REG  (GPIO_BASE | 0x004)
+
+#define GPIO_EFGH_BASE_REG (GPIO_BASE | 0x020)
+#define GPIO_EFGH_DATA_REG (GPIO_EFGH_BASE_REG)
+#define GPIO_EFGH_DIR_REG  (GPIO_BASE | 0x024)
+
+#define GPIO_IJKL_BASE_REG (GPIO_BASE | 0x070)
+#define GPIO_IJKL_DATA_REG (GPIO_IJKL_BASE_REG)
+#define GPIO_IJKL_DIR_REG  (GPIO_BASE | 0x074)
+
+#define GPIO_MNOP_BASE_REG (GPIO_BASE | 0x078)
+#define GPIO_MNOP_DATA_REG (GPIO_MNOP_BASE_REG)
+#define GPIO_MNOP_DIR_REG  (GPIO_BASE | 0x07C)
+#define GPIO_MNOP_CMD_SOURCE0  (GPIO_BASE | 0x0E0)
+#define GPIO_MNOP_CMD_SOURCE1  (GPIO_BASE | 0x0E4)
+
+#define GPIO_QRST_BASE_REG (GPIO_BASE | 0x080)
+#define GPIO_QRST_DATA_REG (GPIO_QRST_BASE_REG)
+#define GPIO_QRST_DIR_REG  (GPIO_BASE | 0x084)
+
+#define GPIO_UVWX_BASE_REG (GPIO_BASE | 0x088)
+#define GPIO_UVWX_DATA_REG (GPIO_UVWX_BASE_REG)
+#define GPIO_UVWX_DIR_REG  (GPIO_BASE | 0x08C)
+
+#define GPIO_NAME(base, pin)   (1 << (pin + (base - 'A') % 4 * 8))
+#define GPIO_GROUP(base, val)  (val << ((base - 'A') % 4 * 8))
+#define SIO_ADDR_4E(0x4E)
+#define SIO_ADDR_2E(0x2E)
+
+static void __maybe_unused el_espi_init(void)
+{
+   u32 value = 0;
+
+   //SCU514: SCU514: Hardware Strap2 Clear Register (default)
+   //SCU510 [6]:0 eSPI mode
+   setbits_le32(SCU_HW_STRAP2_CLR_REG, 

[PATCH v2] Convert CFG_SYS_UBOOT_START to Kconfig

2023-08-24 Thread Jesse Taube
Commit 65cc0e2a65d2 ("global: Move remaining CONFIG_SYS_* to CFG_SYS_*")
renamed CONFIG_SYS_UBOOT_START to CFG_SYS_UBOOT_START. Unfortunately,
this meant that the value was no longer available to the Makefile. This
caused imxrt to fail to boot. All the other boards that used this
variable were unaffected because they were using the default value
which is CONFIG_TEXT_BASE.

This commit converts CFG_SYS_UBOOT_START to Kconfig and sets the default
value to CONFIG_TEXT_BASE.

Suggested-by: Marek Vasut 
Suggested-by: Tom Rini 
Signed-off-by: Jesse Taube 
---
V1->V2:
 - Add "and executed" to TEXT_BASE
 - Reword SYS_UBOOT_START
 - Reword HAVE_SYS_UBOOT_START
 - Use bool as prompt
---
 Makefile  | 16 
 arch/arm/mach-k3/config_secure.mk |  2 +-
 arch/arm/mach-omap2/config_secure.mk  |  2 +-
 boot/Kconfig  | 19 ++-
 common/spl/spl.c  |  6 +-
 common/spl/spl_fit.c  |  2 +-
 configs/imxrt1020-evk_defconfig   |  2 ++
 configs/imxrt1050-evk_defconfig   |  2 ++
 configs/imxrt1170-evk_defconfig   |  2 ++
 .../configs/gardena-smart-gateway-mt7688.h|  4 
 include/configs/imxrt1020-evk.h   |  6 --
 include/configs/imxrt1050-evk.h   |  6 --
 include/configs/imxrt1170-evk.h   |  3 ---
 include/configs/linkit-smart-7688.h   |  4 
 include/configs/mt7620.h  |  3 ---
 include/configs/mt7628.h  |  3 ---
 include/configs/mt8512.h  |  2 --
 include/configs/vocore2.h |  4 
 include/spl.h |  2 +-
 19 files changed, 33 insertions(+), 57 deletions(-)

diff --git a/Makefile b/Makefile
index 9b90204bfe..13d4c63439 100644
--- a/Makefile
+++ b/Makefile
@@ -1364,14 +1364,6 @@ OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec
 u-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE
$(call if_changed,objcopy)
 
-#
-# U-Boot entry point, needed for booting of full-blown U-Boot
-# from the SPL U-Boot version.
-#
-ifndef CFG_SYS_UBOOT_START
-CFG_SYS_UBOOT_START := $(CONFIG_TEXT_BASE)
-endif
-
 # Boards with more complex image requirements can provide an .its source file
 # or a generator script
 # NOTE: Please do not use this. We are migrating away from Makefile rules to 
use
@@ -1391,7 +1383,7 @@ endif
 
 ifdef CONFIG_SPL_LOAD_FIT
 MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
-   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
+   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
-p $(CONFIG_FIT_EXTERNAL_OFFSET) \
-n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
$(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(DEVICE_TREE))) \
@@ -1399,10 +1391,10 @@ MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T 
firmware -C none -O u-boot \
$(patsubst %,-b arch/$(ARCH)/dts/%.dtbo,$(subst 
",,$(CONFIG_OF_OVERLAY_LIST)))
 else
 MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
-   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
+   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
-n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
 MKIMAGEFLAGS_u-boot-ivt.img = -A $(ARCH) -T firmware_ivt -C none -O u-boot \
-   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
+   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
-n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
 u-boot-ivt.img: MKIMAGEOUTPUT = u-boot-ivt.img.log
 endif
@@ -1433,7 +1425,7 @@ MKIMAGEFLAGS_u-boot.pbl = -n 
$(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
 UBOOT_BIN := u-boot.bin
 
 MKIMAGEFLAGS_u-boot-lzma.img = -A $(ARCH) -T standalone -C lzma -O u-boot \
-   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
+   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
-n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
 
 u-boot.bin.lzma: u-boot.bin FORCE
diff --git a/arch/arm/mach-k3/config_secure.mk 
b/arch/arm/mach-k3/config_secure.mk
index 7bc8af813a..9cc1f9eb24 100644
--- a/arch/arm/mach-k3/config_secure.mk
+++ b/arch/arm/mach-k3/config_secure.mk
@@ -30,7 +30,7 @@ tispl.bin_HS: $(obj)/u-boot-spl-nodtb.bin_HS $(patsubst 
%,$(obj)/dts/%.dtb_HS,$(
$(call if_changed,mkfitimage)
 
 MKIMAGEFLAGS_u-boot.img_HS = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
-   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
+   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
-n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
$(patsubst %,-b arch/$(ARCH)/dts/%.dtb_HS,$(subst ",,$(CONFIG_OF_LIST)))
 
diff --git a/arch/arm/mach-omap2/config_secure.mk 
b/arch/arm/mach-omap2/config_secure.mk
index 24ddcdb961..f76262bb0c 100644
--- a/arch/arm/mach-omap2/config_secure.mk
+++ b/arch/arm/mach-omap2/config_secure.mk
@@ -102,7 +102,7 @@ 

Re: [PATCH V4 8/8] doc: board: ti: Add BeaglePlay documentation

2023-08-24 Thread Nishanth Menon
On 19:31-20230824, Simon Glass wrote:
> > >
> > > Also I tried the mmc instructions and managed to brick the board. Is
> > Hmm.. This is just documenting what Robert has in his scripts[1]
> >
> > > there a recovery procedure?
> >
> > Oopsie.. Sorry you had to hit that..
> >
> > >
> > > I suppose I should have tries it on an SD card first. I thought that
> > > was what I was doing, but I didn't know about the internal mmc...
> >
> > Recovery currently involves booting off sd and flashing the emmc up :(
> > unfortunately.. USB DFU etc are still work in progress.
> 
> Hmm so does that mean I need an ARM machine do to the SD
> boot-partition magic, or can I use a USB reader on an x86 box

I just have x86box with SDcard reader - and I use Balena etcher app
image to keep my head straight.

> 
> >
> > A ready to go image such as [2] emmc flasher image might help speed
> > things up.
> >
> > [1] 
> > https://git.beagleboard.org/beagleboard/repos-arm64/-/blob/main/bb-u-boot-beagleplay-mainline/suite/bookworm/debian/install-emmc.sh
> > [2] 
> > https://rcn-ee.net/rootfs/debian-arm64-12-bookworm-xfce-v5.10-ti/2023-08-24/

I realized I just pointed you to Robert's in-work space.. rather not do
that. Sorry.

> > emmc flasher image
> 
> OK thanks. I am not sure how to use those yet, but will make a note.

Just https://etcher.balena.io/ and flash an SD card with the official
image here: https://www.beagleboard.org/distros/beagleplay-debian-11-flasher

https://files.beagle.cc/file/beagleboard-public-2021/images/am625x-emmc-flasher-debian-11.6-xfce-arm64-2023-02-04-10gb.img.xz


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


[PATCH] bootstd: Drop some TODOs

2023-08-24 Thread Simon Glass
The existing TODOs are done, so remove them. Add another that came up
today.

Signed-off-by: Simon Glass 
---

 doc/develop/bootstd.rst | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst
index ec3136535783..3e566e994d6c 100644
--- a/doc/develop/bootstd.rst
+++ b/doc/develop/bootstd.rst
@@ -752,9 +752,7 @@ To do
 
 Some things that need to be done to completely replace the distro-boot scripts:
 
-- add bootdev drivers for dhcp, sata, scsi, ide, virtio
-- PXE boot for EFI
-- support for loading U-Boot scripts
+- implement extensions (devicetree overlays with add-on boards)
 
 Other ideas:
 
-- 
2.42.0.rc1.204.g551eb34607-goog



Re: [PATCH V4 8/8] doc: board: ti: Add BeaglePlay documentation

2023-08-24 Thread Simon Glass
Hi Nishanth,

On Thu, 24 Aug 2023 at 19:22, Nishanth Menon  wrote:
>
> On 19:04-20230824, Simon Glass wrote:
> > Hi Nishanth,
> >
> > On Tue, 22 Aug 2023 at 12:43, Nishanth Menon  wrote:
> > >
> > > Add base documentation for BeaglePlay
> > >
> > > Signed-off-by: Nishanth Menon 
> > > ---
> > > Cc: Heinrich Schuchardt 
> > >
> > > Changes Since V3:
> > > * Updated documentation to give a more clear overview of MMC partitions
> > >   and flashing information.
> > > * Added OpenOCD debug documentation
> > > * Added LED status information and indication of various boot stages
> > >
> > > V3: https://lore.kernel.org/all/20230815164440.2713726-5...@ti.com/
> > > V2: https://lore.kernel.org/u-boot/20230727234446.3651836-5...@ti.com/
> > > V1: https://lore.kernel.org/all/20230725185253.2123433-7...@ti.com/
> > >
> > >  doc/board/ti/am62x_beagleplay.rst| 256 ++
> > >  doc/board/ti/img/beagleplay_emmc.svg | 697 +++
> > >  doc/board/ti/k3.rst  |   1 +
> > >  3 files changed, 954 insertions(+)
> > >  create mode 100644 doc/board/ti/am62x_beagleplay.rst
> > >  create mode 100644 doc/board/ti/img/beagleplay_emmc.svg
> > >
> > > diff --git a/doc/board/ti/am62x_beagleplay.rst 
> > > b/doc/board/ti/am62x_beagleplay.rst
> > > new file mode 100644
> > > index ..5adb7b4c9ace
> > > --- /dev/null
> > > +++ b/doc/board/ti/am62x_beagleplay.rst
> > > @@ -0,0 +1,256 @@
> > > +.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
> > > +.. sectionauthor:: Nishanth Menon 
> > > +
> > > +AM62x Beagleboard.org Beagleplay
> > > +
> > > +
> > > +Introduction:
> > > +-
> > > +
> > > +BeagleBoard.org BeaglePlay is an easy to use, affordable open source
> > > +hardware single board computer based on the Texas Instruments AM625
> > > +SoC that allows you to create connected devices that work even at long
> > > +distances using IEEE 802.15.4g LR-WPAN and IEEE 802.3cg 10Base-T1L.
> > > +Expansion is provided over open standards based mikroBUS, Grove and
> > > +QWIIC headers among other interfaces.
> > > +
> > > +Further information can be found at:
> > > +
> > > +* Product Page: https://beagleplay.org/
> > > +* Hardware documentation: 
> > > https://git.beagleboard.org/beagleplay/beagleplay
> > > +
> > > +Boot Flow:
> > > +--
> > > +Below is the pictorial representation of boot flow:
> > > +
> > > +.. image:: img/boot_diagram_k3_current.svg
> > > +  :alt: Boot flow diagram
> > > +
> > > +- On this platform, 'TI Foundational Security' (TIFS) functions as the
> > > +  security enclave master while 'Device Manager' (DM), also known as the
> > > +  'TISCI server' in "TI terminology", offers all the essential services.
> > > +  The A53/M4F (Aux core) sends requests to TIFS/DM to accomplish these
> > > +  services, as illustrated in the diagram above.
> > > +
> > > +Sources:
> > > +
> > > +.. include::  k3.rst
> > > +:start-after: .. k3_rst_include_start_boot_sources
> > > +:end-before: .. k3_rst_include_end_boot_sources
> > > +
> > > +Build procedure:
> > > +
> > > +0. Setup the environment variables:
> > > +
> > > +.. include::  k3.rst
> > > +:start-after: .. k3_rst_include_start_common_env_vars_desc
> > > +:end-before: .. k3_rst_include_end_common_env_vars_desc
> > > +
> > > +.. include::  k3.rst
> > > +:start-after: .. k3_rst_include_start_board_env_vars_desc
> > > +:end-before: .. k3_rst_include_end_board_env_vars_desc
> > > +
> > > +Set the variables corresponding to this platform:
> > > +
> > > +.. include::  k3.rst
> > > +:start-after: .. k3_rst_include_start_common_env_vars_defn
> > > +:end-before: .. k3_rst_include_end_common_env_vars_defn
> > > +.. code-block:: bash
> > > +
> > > + $ export UBOOT_CFG_CORTEXR="am62x_evm_r5_defconfig beagleplay_r5.config"
> > > + $ export UBOOT_CFG_CORTEXA="am62x_evm_a53_defconfig 
> > > beagleplay_a53.config"
> > > + $ export TFA_BOARD=lite
> > > + $ # we dont use any extra TFA parameters
> > > + $ unset TFA_EXTRA_ARGS
> &g

Re: [PATCH V4 8/8] doc: board: ti: Add BeaglePlay documentation

2023-08-24 Thread Nishanth Menon
On 19:04-20230824, Simon Glass wrote:
> Hi Nishanth,
> 
> On Tue, 22 Aug 2023 at 12:43, Nishanth Menon  wrote:
> >
> > Add base documentation for BeaglePlay
> >
> > Signed-off-by: Nishanth Menon 
> > ---
> > Cc: Heinrich Schuchardt 
> >
> > Changes Since V3:
> > * Updated documentation to give a more clear overview of MMC partitions
> >   and flashing information.
> > * Added OpenOCD debug documentation
> > * Added LED status information and indication of various boot stages
> >
> > V3: https://lore.kernel.org/all/20230815164440.2713726-5...@ti.com/
> > V2: https://lore.kernel.org/u-boot/20230727234446.3651836-5...@ti.com/
> > V1: https://lore.kernel.org/all/20230725185253.2123433-7...@ti.com/
> >
> >  doc/board/ti/am62x_beagleplay.rst| 256 ++
> >  doc/board/ti/img/beagleplay_emmc.svg | 697 +++
> >  doc/board/ti/k3.rst  |   1 +
> >  3 files changed, 954 insertions(+)
> >  create mode 100644 doc/board/ti/am62x_beagleplay.rst
> >  create mode 100644 doc/board/ti/img/beagleplay_emmc.svg
> >
> > diff --git a/doc/board/ti/am62x_beagleplay.rst 
> > b/doc/board/ti/am62x_beagleplay.rst
> > new file mode 100644
> > index ..5adb7b4c9ace
> > --- /dev/null
> > +++ b/doc/board/ti/am62x_beagleplay.rst
> > @@ -0,0 +1,256 @@
> > +.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
> > +.. sectionauthor:: Nishanth Menon 
> > +
> > +AM62x Beagleboard.org Beagleplay
> > +
> > +
> > +Introduction:
> > +-
> > +
> > +BeagleBoard.org BeaglePlay is an easy to use, affordable open source
> > +hardware single board computer based on the Texas Instruments AM625
> > +SoC that allows you to create connected devices that work even at long
> > +distances using IEEE 802.15.4g LR-WPAN and IEEE 802.3cg 10Base-T1L.
> > +Expansion is provided over open standards based mikroBUS, Grove and
> > +QWIIC headers among other interfaces.
> > +
> > +Further information can be found at:
> > +
> > +* Product Page: https://beagleplay.org/
> > +* Hardware documentation: https://git.beagleboard.org/beagleplay/beagleplay
> > +
> > +Boot Flow:
> > +--
> > +Below is the pictorial representation of boot flow:
> > +
> > +.. image:: img/boot_diagram_k3_current.svg
> > +  :alt: Boot flow diagram
> > +
> > +- On this platform, 'TI Foundational Security' (TIFS) functions as the
> > +  security enclave master while 'Device Manager' (DM), also known as the
> > +  'TISCI server' in "TI terminology", offers all the essential services.
> > +  The A53/M4F (Aux core) sends requests to TIFS/DM to accomplish these
> > +  services, as illustrated in the diagram above.
> > +
> > +Sources:
> > +
> > +.. include::  k3.rst
> > +:start-after: .. k3_rst_include_start_boot_sources
> > +:end-before: .. k3_rst_include_end_boot_sources
> > +
> > +Build procedure:
> > +
> > +0. Setup the environment variables:
> > +
> > +.. include::  k3.rst
> > +:start-after: .. k3_rst_include_start_common_env_vars_desc
> > +:end-before: .. k3_rst_include_end_common_env_vars_desc
> > +
> > +.. include::  k3.rst
> > +:start-after: .. k3_rst_include_start_board_env_vars_desc
> > +:end-before: .. k3_rst_include_end_board_env_vars_desc
> > +
> > +Set the variables corresponding to this platform:
> > +
> > +.. include::  k3.rst
> > +:start-after: .. k3_rst_include_start_common_env_vars_defn
> > +:end-before: .. k3_rst_include_end_common_env_vars_defn
> > +.. code-block:: bash
> > +
> > + $ export UBOOT_CFG_CORTEXR="am62x_evm_r5_defconfig beagleplay_r5.config"
> > + $ export UBOOT_CFG_CORTEXA="am62x_evm_a53_defconfig beagleplay_a53.config"
> > + $ export TFA_BOARD=lite
> > + $ # we dont use any extra TFA parameters
> > + $ unset TFA_EXTRA_ARGS
> > + $ export OPTEE_PLATFORM=k3-am62x
> > + $ export OPTEE_EXTRA_ARGS="CFG_WITH_SOFTWARE_PRNG=y"
> > +
> > +.. include::  am62x_sk.rst
> > +:start-after: .. am62x_evm_rst_include_start_build_steps
> > +:end-before: .. am62x_evm_rst_include_end_build_steps
> > +
> > +Target Images
> > +--
> > +Copy the below images to an SD card and boot:
> > +
> > +* tiboot3-am62x-gp-evm.bin from R5 build as tiboot3.bin
> > +* tispl.bin_unsigned from Cortex-A build as tispl.bin
> > +* u-

Re: [PATCH] board: ti: am62x: beagleplay: Disable semi-functional PSCI reset support

2023-08-24 Thread Nishanth Menon
On 17:58-20230824, Tom Rini wrote:
> On Thu, Aug 24, 2023 at 11:53:17PM +0200, Jan Kiszka wrote:
> > From: Jan Kiszka 
> > 
> > At this point, system shutdown is not supported by the DM firmware that
> > TF-A calls. As we can't de-select only this feature, declare complete
> > PSCI reset support as non-functional so that we don't signal incomplete
> > support to the OS via EFI runtime services. This makes power-off under
> > Linux work again when booting via EFI.
> > 
> > Signed-off-by: Jan Kiszka 
> > ---
> >  board/ti/am62x/beagleplay_a53.config | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/board/ti/am62x/beagleplay_a53.config 
> > b/board/ti/am62x/beagleplay_a53.config
> > index 967f794446d..8b0f671bc9e 100644
> > --- a/board/ti/am62x/beagleplay_a53.config
> > +++ b/board/ti/am62x/beagleplay_a53.config
> > @@ -53,3 +53,5 @@ CONFIG_SPI=n
> >  CONFIG_SPI_FLASH=n
> >  CONFIG_SPL_DM_SPI_FLASH=n
> >  CONFIG_SPL_SPI_FLASH_SUPPORT=n
> > +# DM firmware lacks support for shutdown
> > +# CONFIG_PSCI_RESET is not set
> 
> Is this lack of feature for just the beagleplay part of the firmware
> stack or more generically to the TI am62x platforms?

Thanks a ton Jan for digging deep into this and finding this. So much
appreciated.

This is all K3 platforms with the exception of j7200-evm.

PSCI SYSTEM_OFF function is routed by TFA to DM, there is no implementation
on DM side since involved PMIC and team is trying to lock in a manner in
which it is easier for people to describe things.

PSCI SYSTEM_RESET on the other hand is handled correctly by DM.

Even though CONFIG_POWEROFF is disabled, apparently enabling PSCI_RESET
results in EFI runtime services gets to think that poweroff is also
supported. Looking at drivers/firmware/psci.c[1] efi request for
poweroff is via EFI_RESET_SHUTDOWN[2] - so the specification itself
mandates that both reset AND poweroff should be implemented.

Luckily for us we have a broken u-boot reset implementation, which last
I looked was not following the h/w specifications and the intent was to
move to PSCI -> DM for reset so that system can properly reset and not
get randomly hung during reset under certain circumstances.

But, given the circumstances, I can pick this up and do it at am62_evm
level rather than at just beagle level. I will pick this patch up and
roll it up into v6 of the beagleplay series - but will modify am62x_evm
config instead.

[1] https://github.com/u-boot/u-boot/blob/master/drivers/firmware/psci.c#L246
[2] 
https://uefi.org/specs/UEFI/2.9_A/08_Services_Runtime_Services.html?highlight=efiresetshutdown#resetsystem
-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


Re: [PATCH V4 8/8] doc: board: ti: Add BeaglePlay documentation

2023-08-24 Thread Simon Glass
Hi Nishanth,

On Tue, 22 Aug 2023 at 12:43, Nishanth Menon  wrote:
>
> Add base documentation for BeaglePlay
>
> Signed-off-by: Nishanth Menon 
> ---
> Cc: Heinrich Schuchardt 
>
> Changes Since V3:
> * Updated documentation to give a more clear overview of MMC partitions
>   and flashing information.
> * Added OpenOCD debug documentation
> * Added LED status information and indication of various boot stages
>
> V3: https://lore.kernel.org/all/20230815164440.2713726-5...@ti.com/
> V2: https://lore.kernel.org/u-boot/20230727234446.3651836-5...@ti.com/
> V1: https://lore.kernel.org/all/20230725185253.2123433-7...@ti.com/
>
>  doc/board/ti/am62x_beagleplay.rst| 256 ++
>  doc/board/ti/img/beagleplay_emmc.svg | 697 +++
>  doc/board/ti/k3.rst  |   1 +
>  3 files changed, 954 insertions(+)
>  create mode 100644 doc/board/ti/am62x_beagleplay.rst
>  create mode 100644 doc/board/ti/img/beagleplay_emmc.svg
>
> diff --git a/doc/board/ti/am62x_beagleplay.rst 
> b/doc/board/ti/am62x_beagleplay.rst
> new file mode 100644
> index ..5adb7b4c9ace
> --- /dev/null
> +++ b/doc/board/ti/am62x_beagleplay.rst
> @@ -0,0 +1,256 @@
> +.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
> +.. sectionauthor:: Nishanth Menon 
> +
> +AM62x Beagleboard.org Beagleplay
> +
> +
> +Introduction:
> +-
> +
> +BeagleBoard.org BeaglePlay is an easy to use, affordable open source
> +hardware single board computer based on the Texas Instruments AM625
> +SoC that allows you to create connected devices that work even at long
> +distances using IEEE 802.15.4g LR-WPAN and IEEE 802.3cg 10Base-T1L.
> +Expansion is provided over open standards based mikroBUS, Grove and
> +QWIIC headers among other interfaces.
> +
> +Further information can be found at:
> +
> +* Product Page: https://beagleplay.org/
> +* Hardware documentation: https://git.beagleboard.org/beagleplay/beagleplay
> +
> +Boot Flow:
> +--
> +Below is the pictorial representation of boot flow:
> +
> +.. image:: img/boot_diagram_k3_current.svg
> +  :alt: Boot flow diagram
> +
> +- On this platform, 'TI Foundational Security' (TIFS) functions as the
> +  security enclave master while 'Device Manager' (DM), also known as the
> +  'TISCI server' in "TI terminology", offers all the essential services.
> +  The A53/M4F (Aux core) sends requests to TIFS/DM to accomplish these
> +  services, as illustrated in the diagram above.
> +
> +Sources:
> +
> +.. include::  k3.rst
> +:start-after: .. k3_rst_include_start_boot_sources
> +:end-before: .. k3_rst_include_end_boot_sources
> +
> +Build procedure:
> +
> +0. Setup the environment variables:
> +
> +.. include::  k3.rst
> +:start-after: .. k3_rst_include_start_common_env_vars_desc
> +:end-before: .. k3_rst_include_end_common_env_vars_desc
> +
> +.. include::  k3.rst
> +:start-after: .. k3_rst_include_start_board_env_vars_desc
> +:end-before: .. k3_rst_include_end_board_env_vars_desc
> +
> +Set the variables corresponding to this platform:
> +
> +.. include::  k3.rst
> +:start-after: .. k3_rst_include_start_common_env_vars_defn
> +:end-before: .. k3_rst_include_end_common_env_vars_defn
> +.. code-block:: bash
> +
> + $ export UBOOT_CFG_CORTEXR="am62x_evm_r5_defconfig beagleplay_r5.config"
> + $ export UBOOT_CFG_CORTEXA="am62x_evm_a53_defconfig beagleplay_a53.config"
> + $ export TFA_BOARD=lite
> + $ # we dont use any extra TFA parameters
> + $ unset TFA_EXTRA_ARGS
> + $ export OPTEE_PLATFORM=k3-am62x
> + $ export OPTEE_EXTRA_ARGS="CFG_WITH_SOFTWARE_PRNG=y"
> +
> +.. include::  am62x_sk.rst
> +:start-after: .. am62x_evm_rst_include_start_build_steps
> +:end-before: .. am62x_evm_rst_include_end_build_steps
> +
> +Target Images
> +--
> +Copy the below images to an SD card and boot:
> +
> +* tiboot3-am62x-gp-evm.bin from R5 build as tiboot3.bin
> +* tispl.bin_unsigned from Cortex-A build as tispl.bin
> +* u-boot.img_unsigned from Cortex-A build as uboot.img

I just noticed - I think this should be u-boot.img

Also I tried the mmc instructions and managed to brick the board. Is
there a recovery procedure?

I suppose I should have tries it on an SD card first. I thought that
was what I was doing, but I didn't know about the internal mmc...

Regards,
Simon


Re: [PATCH v7 2/2] phy: phy-imx8mq-usb: clean up clock code

2023-08-24 Thread Marek Vasut

On 8/24/23 20:05, Tim Harvey wrote:

On Thu, Jul 13, 2023 at 12:17 PM Marek Vasut  wrote:


On 7/13/23 20:56, Tim Harvey wrote:

use CONFIG_IS_ENABLED for clock enable/disable and change printf's
to dev_err. Additionlly remove the comment that does not make sense.

Signed-off-by: Tim Harvey 


Reviewed-by: Marek Vasut 

Thanks!


Hi Marek,

Who's tree do the phy patches go through?


It is assigned to me in PW, so I'll pick it up via usb/master , applied 
, thanks.


That said, if you see something stuck for a month, that's too long, just 
let me know sooner please.


Re: [PATCH 1/1] doc: describe TPL/VPL/SPL boot

2023-08-24 Thread Pali Rohár
On Thursday 24 August 2023 15:06:44 Marek Vasut wrote:
> On 8/23/23 22:55, Pali Rohár wrote:
> > On Wednesday 23 August 2023 22:46:13 Marek Vasut wrote:
> > > On 8/23/23 22:35, Pali Rohár wrote:
> > > > On Wednesday 23 August 2023 22:32:18 Heinrich Schuchardt wrote:
> > > > > Looking at the MAINTAINER file it seems that POWERPC should be set to
> > > > > orphaned.
> > > > 
> > > > And this is only just because of your fault folks here, as you have been
> > > > completely ignoring any my patches for improving this situation here and
> > > > finally after more than year of my reminders more of you wrote me
> > > > officially that would ignore any changes from me.
> > > > So go and complain to somebody else, not me.
> > > 
> > > Why not pick up the PPC maintainership yourself ? You are qualified 
> > > enough I
> > > think.
> > 
> > I'm not sure if you cannot read or understand above written text, but I
> > will repeat it once again and the last time specially for you: I'm not
> > going to send any changes, improvements or fixes to any people anymore
> > who either implicitly or explicitly wrote that will ignore me or my
> > contributions.
> 
> So pick up the PPC maintainership, apply the outstanding patches, send a PR
> to Tom and problem with stuck patches is solved. Why not do it this way?

As you have proved that you are either troll or continuously trying to
make me a fool, you have been added to the black list of idiots. Do not
contact me again.

> > > There is a whole thread on frustration about getting patches reviewed and
> > > upstream here too:
> > > 
> > > https://lore.kernel.org/all/20230816180808.GB2919664@perftesting/


Re: [PATCH v7 1/2] phy: phy-imx8mq-usb: add vbus regulator support

2023-08-24 Thread Marcel Ziswiler
Hi Tim

Thanks!

On Thu, 2023-07-13 at 11:56 -0700, Tim Harvey wrote:
> Add support for enabling and disabling vbus-supply regulator found
> on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.
> 
> Signed-off-by: Tim Harvey 
> Reviewed-by: Adam Ford 
> Reviewed-by: Marek Vasut 

Tested-by: Marcel Ziswiler 

> ---
> v7:
>  - add #ifdef protection around clk_disable error path
> 
> v6:
>  - move changes to clk to separate patch
>  - sort new vars in reverse christmas tree style
> 
> v5:
>  - remove #if CONFIG_IS_ENABLED around struct members
>    (you can not conditionally include if using if (CONFIG_IS_ENABLED(foo)) )
>  - replace clk '#if CONFIG_IS_ENABLED(CLK)' with 'if (CONFIG_IS_ENABLED(CLK))'
> 
> v4:
>  - use regulator_set_enable_if_allowed to handle regulator reference
> counting
>    errors
>  - added Marek's rb tag
> 
> v3:
>  - change pr_err to dev_err
>  - add #if CONFIG_IS_ENABLED around vbus_supply in struct
>  - add fail path to disable clock if regulator enable failed
> 
> v2:
>  - protect ret with __maybe_unused in case CONFIG_CLK and
>    CONFIG_DM_REGULATOR not defined
>  - add error prints on failures
>  - add Adam's rb tag
> Signed-off-by: Tim Harvey 
> ---
>  drivers/phy/phy-imx8mq-usb.c | 39 +---
>  1 file changed, 36 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/phy/phy-imx8mq-usb.c b/drivers/phy/phy-imx8mq-usb.c
> index 69f01de55538..9fa78ef4da3d 100644
> --- a/drivers/phy/phy-imx8mq-usb.c
> +++ b/drivers/phy/phy-imx8mq-usb.c
> @@ -14,6 +14,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  
>  #define PHY_CTRL0  0x0
>  #define PHY_CTRL0_REF_SSP_EN   BIT(2)
> @@ -81,6 +83,7 @@ struct imx8mq_usb_phy {
>  #endif
> void __iomem *base;
> enum imx8mpq_phy_type type;
> +   struct udevice *vbus_supply;
>  };
>  
>  static const struct udevice_id imx8mq_usb_phy_of_match[] = {
> @@ -173,9 +176,9 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
> struct udevice *dev = usb_phy->dev;
> struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> u32 value;
> +   int ret;
>  
>  #if CONFIG_IS_ENABLED(CLK)
> -   int ret;
> ret = clk_enable(_phy->phy_clk);
> if (ret) {
> printf("Failed to enable usb phy clock\n");
> @@ -183,12 +186,26 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
> }
>  #endif
>  
> +   if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> +   ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, 
> true);
> +   if (ret && ret != -ENOSYS) {
> +   dev_err(dev, "Failed to enable VBUS regulator: %d\n", 
> ret);
> +   goto err;
> +   }
> +   }
> +
> /* Disable rx term override */
> value = readl(imx_phy->base + PHY_CTRL6);
> value &= ~PHY_CTRL6_RXTERM_OVERRIDE_SEL;
> writel(value, imx_phy->base + PHY_CTRL6);
>  
> return 0;
> +
> +err:
> +#if CONFIG_IS_ENABLED(CLK)
> +   clk_disable(_phy->phy_clk);
> +#endif
> +   return ret;
>  }
>  
>  static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
> @@ -196,6 +213,7 @@ static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
> struct udevice *dev = usb_phy->dev;
> struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> u32 value;
> +   int ret;
>  
> /* Override rx term to be 0 */
> value = readl(imx_phy->base + PHY_CTRL6);
> @@ -206,6 +224,14 @@ static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
> clk_disable(_phy->phy_clk);
>  #endif
>  
> +   if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> +   ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, 
> false);
> +   if (ret && ret != -ENOSYS) {
> +   dev_err(dev, "Failed to disable VBUS regulator: 
> %d\n", ret);
> +   return ret;
> +   }
> +   }
> +
> return 0;
>  }
>  
> @@ -224,6 +250,7 @@ struct phy_ops imx8mq_usb_phy_ops = {
>  int imx8mq_usb_phy_probe(struct udevice *dev)
>  {
> struct imx8mq_usb_phy *priv = dev_get_priv(dev);
> +   int ret;
>  
> priv->type = dev_get_driver_data(dev);
> priv->base = dev_read_addr_ptr(dev);
> @@ -232,8 +259,6 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
> return -EINVAL;
>  
>  #if CONFIG_IS_ENABLED(CLK)
> -   int ret;
> -
> /* Assigned clock already set clock */
> ret = clk_get_by_name(dev, "phy", >phy_clk);
> if (ret) {
> @@ -241,6 +266,14 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
> return ret;
> }
>  #endif
> +   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
> +   ret = device_get_supply_regulator(dev, "vbus-supply",
> + >vbus_supply);
> +   if (ret && 

Re: [PATCH] Convert CFG_SYS_UBOOT_START to Kconfig

2023-08-24 Thread Tom Rini
On Thu, Aug 24, 2023 at 06:40:09PM -0400, Jesse T wrote:
> On Thu, Aug 24, 2023 at 4:01 PM Simon Glass  wrote:
> >
> > Hi Jesse,
> >
> > On Wed, 23 Aug 2023 at 20:30, Jesse Taube  wrote:
> > >
> > > Commit 65cc0e2a65d2 ("global: Move remaining CONFIG_SYS_* to CFG_SYS_*")
> > > renamed CONFIG_SYS_UBOOT_START to CFG_SYS_UBOOT_START. Unfortunately,
> > > this meant that the value was no longer available to the Makefile. This
> > > caused imxrt to fail to boot. All the other boards that used this
> > > variable were unaffected because they were using the default value
> > > which is CONFIG_TEXT_BASE.
> > >
> > > This commit converts CFG_SYS_UBOOT_START to Kconfig and sets the default
> > > value to CONFIG_TEXT_BASE.
> > >
> > > Suggested-by: Marek Vasut 
> > > Suggested-by: Tom Rini 
> > > Signed-off-by: Jesse Taube 
> > > ---
> > >  Makefile   | 16 
> > >  arch/arm/mach-k3/config_secure.mk  |  2 +-
> > >  arch/arm/mach-omap2/config_secure.mk   |  2 +-
> > >  boot/Kconfig   | 16 
> > >  common/spl/spl.c   |  6 +-
> > >  common/spl/spl_fit.c   |  2 +-
> > >  configs/imxrt1020-evk_defconfig|  2 ++
> > >  configs/imxrt1050-evk_defconfig|  2 ++
> > >  configs/imxrt1170-evk_defconfig|  2 ++
> > >  include/configs/gardena-smart-gateway-mt7688.h |  4 
> > >  include/configs/imxrt1020-evk.h|  6 --
> > >  include/configs/imxrt1050-evk.h|  6 --
> > >  include/configs/imxrt1170-evk.h|  3 ---
> > >  include/configs/linkit-smart-7688.h|  4 
> > >  include/configs/mt7620.h   |  3 ---
> > >  include/configs/mt7628.h   |  3 ---
> > >  include/configs/mt8512.h   |  2 --
> > >  include/configs/vocore2.h  |  4 
> > >  include/spl.h  |  2 +-
> > >  19 files changed, 31 insertions(+), 56 deletions(-)
> > >
> > > diff --git a/Makefile b/Makefile
> > > index 9b90204bfe..13d4c63439 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -1364,14 +1364,6 @@ OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec
> > >  u-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE
> > > $(call if_changed,objcopy)
> > >
> > > -#
> > > -# U-Boot entry point, needed for booting of full-blown U-Boot
> > > -# from the SPL U-Boot version.
> > > -#
> > > -ifndef CFG_SYS_UBOOT_START
> > > -CFG_SYS_UBOOT_START := $(CONFIG_TEXT_BASE)
> > > -endif
> > > -
> > >  # Boards with more complex image requirements can provide an .its source 
> > > file
> > >  # or a generator script
> > >  # NOTE: Please do not use this. We are migrating away from Makefile 
> > > rules to use
> > > @@ -1391,7 +1383,7 @@ endif
> > >
> > >  ifdef CONFIG_SPL_LOAD_FIT
> > >  MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O 
> > > u-boot \
> > > -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> > > +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> > > -p $(CONFIG_FIT_EXTERNAL_OFFSET) \
> > > -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
> > > $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst 
> > > ",,$(DEVICE_TREE))) \
> > > @@ -1399,10 +1391,10 @@ MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T 
> > > firmware -C none -O u-boot \
> > > $(patsubst %,-b arch/$(ARCH)/dts/%.dtbo,$(subst 
> > > ",,$(CONFIG_OF_OVERLAY_LIST)))
> > >  else
> > >  MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
> > > -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> > > +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> > > -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
> > >  MKIMAGEFLAGS_u-boot-ivt.img = -A $(ARCH) -T firmware_ivt -C none -O 
> > > u-boot \
> > > -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> > > +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> > > -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
> > >  u-boot-ivt.img: MKIMAGEOUTPUT = u-boot-ivt.img.log
> > >  endif
> > > @@ -1433,7 +1425,7 @@ MKIMAGEFLAGS_u-boot.pbl = -n 
> > > $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
> > >  UBOOT_BIN := u-boot.bin
> > >
> > >  MKIMAGEFLAGS_u-boot-lzma.img = -A $(ARCH) -T standalone -C lzma -O 
> > > u-boot \
> > > -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> > > +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> > > -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
> > >
> > >  u-boot.bin.lzma: u-boot.bin FORCE
> > > diff --git a/arch/arm/mach-k3/config_secure.mk 
> > > b/arch/arm/mach-k3/config_secure.mk
> > > index 7bc8af813a..9cc1f9eb24 100644
> > > --- a/arch/arm/mach-k3/config_secure.mk
> > > +++ b/arch/arm/mach-k3/config_secure.mk
> > > @@ -30,7 +30,7 @@ tispl.bin_HS: 

Re: [PATCH] Convert CFG_SYS_UBOOT_START to Kconfig

2023-08-24 Thread Jesse T
On Thu, Aug 24, 2023 at 4:01 PM Simon Glass  wrote:
>
> Hi Jesse,
>
> On Wed, 23 Aug 2023 at 20:30, Jesse Taube  wrote:
> >
> > Commit 65cc0e2a65d2 ("global: Move remaining CONFIG_SYS_* to CFG_SYS_*")
> > renamed CONFIG_SYS_UBOOT_START to CFG_SYS_UBOOT_START. Unfortunately,
> > this meant that the value was no longer available to the Makefile. This
> > caused imxrt to fail to boot. All the other boards that used this
> > variable were unaffected because they were using the default value
> > which is CONFIG_TEXT_BASE.
> >
> > This commit converts CFG_SYS_UBOOT_START to Kconfig and sets the default
> > value to CONFIG_TEXT_BASE.
> >
> > Suggested-by: Marek Vasut 
> > Suggested-by: Tom Rini 
> > Signed-off-by: Jesse Taube 
> > ---
> >  Makefile   | 16 
> >  arch/arm/mach-k3/config_secure.mk  |  2 +-
> >  arch/arm/mach-omap2/config_secure.mk   |  2 +-
> >  boot/Kconfig   | 16 
> >  common/spl/spl.c   |  6 +-
> >  common/spl/spl_fit.c   |  2 +-
> >  configs/imxrt1020-evk_defconfig|  2 ++
> >  configs/imxrt1050-evk_defconfig|  2 ++
> >  configs/imxrt1170-evk_defconfig|  2 ++
> >  include/configs/gardena-smart-gateway-mt7688.h |  4 
> >  include/configs/imxrt1020-evk.h|  6 --
> >  include/configs/imxrt1050-evk.h|  6 --
> >  include/configs/imxrt1170-evk.h|  3 ---
> >  include/configs/linkit-smart-7688.h|  4 
> >  include/configs/mt7620.h   |  3 ---
> >  include/configs/mt7628.h   |  3 ---
> >  include/configs/mt8512.h   |  2 --
> >  include/configs/vocore2.h  |  4 
> >  include/spl.h  |  2 +-
> >  19 files changed, 31 insertions(+), 56 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 9b90204bfe..13d4c63439 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1364,14 +1364,6 @@ OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec
> >  u-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE
> > $(call if_changed,objcopy)
> >
> > -#
> > -# U-Boot entry point, needed for booting of full-blown U-Boot
> > -# from the SPL U-Boot version.
> > -#
> > -ifndef CFG_SYS_UBOOT_START
> > -CFG_SYS_UBOOT_START := $(CONFIG_TEXT_BASE)
> > -endif
> > -
> >  # Boards with more complex image requirements can provide an .its source 
> > file
> >  # or a generator script
> >  # NOTE: Please do not use this. We are migrating away from Makefile rules 
> > to use
> > @@ -1391,7 +1383,7 @@ endif
> >
> >  ifdef CONFIG_SPL_LOAD_FIT
> >  MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot 
> > \
> > -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> > +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> > -p $(CONFIG_FIT_EXTERNAL_OFFSET) \
> > -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
> > $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(DEVICE_TREE))) \
> > @@ -1399,10 +1391,10 @@ MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T 
> > firmware -C none -O u-boot \
> > $(patsubst %,-b arch/$(ARCH)/dts/%.dtbo,$(subst 
> > ",,$(CONFIG_OF_OVERLAY_LIST)))
> >  else
> >  MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
> > -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> > +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> > -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
> >  MKIMAGEFLAGS_u-boot-ivt.img = -A $(ARCH) -T firmware_ivt -C none -O u-boot 
> > \
> > -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> > +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> > -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
> >  u-boot-ivt.img: MKIMAGEOUTPUT = u-boot-ivt.img.log
> >  endif
> > @@ -1433,7 +1425,7 @@ MKIMAGEFLAGS_u-boot.pbl = -n 
> > $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
> >  UBOOT_BIN := u-boot.bin
> >
> >  MKIMAGEFLAGS_u-boot-lzma.img = -A $(ARCH) -T standalone -C lzma -O u-boot \
> > -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> > +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> > -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
> >
> >  u-boot.bin.lzma: u-boot.bin FORCE
> > diff --git a/arch/arm/mach-k3/config_secure.mk 
> > b/arch/arm/mach-k3/config_secure.mk
> > index 7bc8af813a..9cc1f9eb24 100644
> > --- a/arch/arm/mach-k3/config_secure.mk
> > +++ b/arch/arm/mach-k3/config_secure.mk
> > @@ -30,7 +30,7 @@ tispl.bin_HS: $(obj)/u-boot-spl-nodtb.bin_HS $(patsubst 
> > %,$(obj)/dts/%.dtb_HS,$(
> > $(call if_changed,mkfitimage)
> >
> >  MKIMAGEFLAGS_u-boot.img_HS = -f auto -A $(ARCH) -T firmware -C none -O 
> > u-boot \
> > -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> > +   -a 

Re: [PATCH] board: ti: am62x: beagleplay: Disable semi-functional PSCI reset support

2023-08-24 Thread Tom Rini
On Thu, Aug 24, 2023 at 11:53:17PM +0200, Jan Kiszka wrote:
> From: Jan Kiszka 
> 
> At this point, system shutdown is not supported by the DM firmware that
> TF-A calls. As we can't de-select only this feature, declare complete
> PSCI reset support as non-functional so that we don't signal incomplete
> support to the OS via EFI runtime services. This makes power-off under
> Linux work again when booting via EFI.
> 
> Signed-off-by: Jan Kiszka 
> ---
>  board/ti/am62x/beagleplay_a53.config | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/board/ti/am62x/beagleplay_a53.config 
> b/board/ti/am62x/beagleplay_a53.config
> index 967f794446d..8b0f671bc9e 100644
> --- a/board/ti/am62x/beagleplay_a53.config
> +++ b/board/ti/am62x/beagleplay_a53.config
> @@ -53,3 +53,5 @@ CONFIG_SPI=n
>  CONFIG_SPI_FLASH=n
>  CONFIG_SPL_DM_SPI_FLASH=n
>  CONFIG_SPL_SPI_FLASH_SUPPORT=n
> +# DM firmware lacks support for shutdown
> +# CONFIG_PSCI_RESET is not set

Is this lack of feature for just the beagleplay part of the firmware
stack or more generically to the TI am62x platforms?

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] board: ti: am62x: beagleplay: Disable semi-functional PSCI reset support

2023-08-24 Thread Jan Kiszka
From: Jan Kiszka 

At this point, system shutdown is not supported by the DM firmware that
TF-A calls. As we can't de-select only this feature, declare complete
PSCI reset support as non-functional so that we don't signal incomplete
support to the OS via EFI runtime services. This makes power-off under
Linux work again when booting via EFI.

Signed-off-by: Jan Kiszka 
---
 board/ti/am62x/beagleplay_a53.config | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/board/ti/am62x/beagleplay_a53.config 
b/board/ti/am62x/beagleplay_a53.config
index 967f794446d..8b0f671bc9e 100644
--- a/board/ti/am62x/beagleplay_a53.config
+++ b/board/ti/am62x/beagleplay_a53.config
@@ -53,3 +53,5 @@ CONFIG_SPI=n
 CONFIG_SPI_FLASH=n
 CONFIG_SPL_DM_SPI_FLASH=n
 CONFIG_SPL_SPI_FLASH_SUPPORT=n
+# DM firmware lacks support for shutdown
+# CONFIG_PSCI_RESET is not set
--
2.35.3


Re: [PATCH v2 0/4] arm: qemu: Enable Bochs, console buffering, USB keyboard

2023-08-24 Thread Tom Rini
On Mon, Aug 14, 2023 at 08:39:40PM +0300, Alper Nebi Yasak wrote:

> Now that the driver for the Bochs VGA card emulated by QEMU is no longer
> limited to x86 architectures [1], this series enables it on arm and
> arm64 virtual machines to provide a graphical interface. In line with
> that series this also enables console buffering and USB keyboard.
> 
> Tested with the Debian 12 installer using GRUB EFI:
> 
>   $ tools/buildman/buildman -o build/qemu_arm64 --boards=qemu_arm64 -w
>   $ cd build/qemu_arm64
>   $ curl -L -o debian.img \
>   
> https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-12.0.0-arm64-netinst.iso
>   $ qemu-system-aarch64 \
>   -machine virt -cpu cortex-a53 -m 4G -smp 4 \
>   -bios u-boot.bin \
>   -serial stdio -device VGA \
>   -nic user,model=virtio-net-pci \
>   -device virtio-rng-pci \
>   -device qemu-xhci,id=xhci -device usb-kbd -device usb-tablet \
>   -drive if=virtio,file=debian.img,format=raw,readonly=on,media=cdrom
> 
> And with one using extlinux.conf:
> 
> $ [...]
> $ curl -L -o head.img.gz \
> 
> https://deb.debian.org/debian/dists/bookworm/main/installer-arm64/current/images/netboot/SD-card-images/gtk/firmware.none.img.gz
> $ curl -L -o partition.img.gz \
> 
> https://deb.debian.org/debian/dists/bookworm/main/installer-arm64/current/images/netboot/SD-card-images/gtk/partition.img.gz
> $ zcat head.img.gz partition.img.gz >debian.img
> $ [...]
> 
> Both can get to a graphical installer just fine, in addition to U-Boot
> video console showing up in a GTK window.
> 
> [1] video: bochs: Remove the x86 limitation
> https://lore.kernel.org/u-boot/20230723044041.1089804-1-bm...@tinylab.org/

For the series, applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] Convert CFG_SYS_UBOOT_START to Kconfig

2023-08-24 Thread Simon Glass
Hi Jesse,

On Wed, 23 Aug 2023 at 20:30, Jesse Taube  wrote:
>
> Commit 65cc0e2a65d2 ("global: Move remaining CONFIG_SYS_* to CFG_SYS_*")
> renamed CONFIG_SYS_UBOOT_START to CFG_SYS_UBOOT_START. Unfortunately,
> this meant that the value was no longer available to the Makefile. This
> caused imxrt to fail to boot. All the other boards that used this
> variable were unaffected because they were using the default value
> which is CONFIG_TEXT_BASE.
>
> This commit converts CFG_SYS_UBOOT_START to Kconfig and sets the default
> value to CONFIG_TEXT_BASE.
>
> Suggested-by: Marek Vasut 
> Suggested-by: Tom Rini 
> Signed-off-by: Jesse Taube 
> ---
>  Makefile   | 16 
>  arch/arm/mach-k3/config_secure.mk  |  2 +-
>  arch/arm/mach-omap2/config_secure.mk   |  2 +-
>  boot/Kconfig   | 16 
>  common/spl/spl.c   |  6 +-
>  common/spl/spl_fit.c   |  2 +-
>  configs/imxrt1020-evk_defconfig|  2 ++
>  configs/imxrt1050-evk_defconfig|  2 ++
>  configs/imxrt1170-evk_defconfig|  2 ++
>  include/configs/gardena-smart-gateway-mt7688.h |  4 
>  include/configs/imxrt1020-evk.h|  6 --
>  include/configs/imxrt1050-evk.h|  6 --
>  include/configs/imxrt1170-evk.h|  3 ---
>  include/configs/linkit-smart-7688.h|  4 
>  include/configs/mt7620.h   |  3 ---
>  include/configs/mt7628.h   |  3 ---
>  include/configs/mt8512.h   |  2 --
>  include/configs/vocore2.h  |  4 
>  include/spl.h  |  2 +-
>  19 files changed, 31 insertions(+), 56 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 9b90204bfe..13d4c63439 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1364,14 +1364,6 @@ OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec
>  u-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE
> $(call if_changed,objcopy)
>
> -#
> -# U-Boot entry point, needed for booting of full-blown U-Boot
> -# from the SPL U-Boot version.
> -#
> -ifndef CFG_SYS_UBOOT_START
> -CFG_SYS_UBOOT_START := $(CONFIG_TEXT_BASE)
> -endif
> -
>  # Boards with more complex image requirements can provide an .its source file
>  # or a generator script
>  # NOTE: Please do not use this. We are migrating away from Makefile rules to 
> use
> @@ -1391,7 +1383,7 @@ endif
>
>  ifdef CONFIG_SPL_LOAD_FIT
>  MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
> -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -p $(CONFIG_FIT_EXTERNAL_OFFSET) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
> $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(DEVICE_TREE))) \
> @@ -1399,10 +1391,10 @@ MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T 
> firmware -C none -O u-boot \
> $(patsubst %,-b arch/$(ARCH)/dts/%.dtbo,$(subst 
> ",,$(CONFIG_OF_OVERLAY_LIST)))
>  else
>  MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
> -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
>  MKIMAGEFLAGS_u-boot-ivt.img = -A $(ARCH) -T firmware_ivt -C none -O u-boot \
> -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
>  u-boot-ivt.img: MKIMAGEOUTPUT = u-boot-ivt.img.log
>  endif
> @@ -1433,7 +1425,7 @@ MKIMAGEFLAGS_u-boot.pbl = -n 
> $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
>  UBOOT_BIN := u-boot.bin
>
>  MKIMAGEFLAGS_u-boot-lzma.img = -A $(ARCH) -T standalone -C lzma -O u-boot \
> -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
>
>  u-boot.bin.lzma: u-boot.bin FORCE
> diff --git a/arch/arm/mach-k3/config_secure.mk 
> b/arch/arm/mach-k3/config_secure.mk
> index 7bc8af813a..9cc1f9eb24 100644
> --- a/arch/arm/mach-k3/config_secure.mk
> +++ b/arch/arm/mach-k3/config_secure.mk
> @@ -30,7 +30,7 @@ tispl.bin_HS: $(obj)/u-boot-spl-nodtb.bin_HS $(patsubst 
> %,$(obj)/dts/%.dtb_HS,$(
> $(call if_changed,mkfitimage)
>
>  MKIMAGEFLAGS_u-boot.img_HS = -f auto -A $(ARCH) -T firmware -C none -O 
> u-boot \
> -   -a $(CONFIG_TEXT_BASE) -e $(CFG_SYS_UBOOT_START) \
> +   -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
> $(patsubst %,-b arch/$(ARCH)/dts/%.dtb_HS,$(subst 
> ",,$(CONFIG_OF_LIST)))
>
> diff --git a/arch/arm/mach-omap2/config_secure.mk 
> 

[PATCH 19/19] boot: Join ARCH_FIXUP_FDT_MEMORY with related options

2023-08-24 Thread Simon Glass
Move this to be with the other devicetree-fixup options.

Signed-off-by: Simon Glass 
---

 boot/Kconfig | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 32d3a7306139..d9cb67945716 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -690,14 +690,6 @@ config SUPPORT_RAW_INITRD
  address of the initrd must be augmented by it's size, in the following
  format: ":".
 
-config ARCH_FIXUP_FDT_MEMORY
-   bool "Enable arch_fixup_memory_banks() call"
-   default y
-   help
- Enable FDT memory map syncup before OS boot. This feature can be
- used for booting OS with different memory setup where the part of
- the memory location should be used for different purpose.
-
 config CHROMEOS
bool "Support booting Chrome OS"
help
@@ -1489,6 +1481,14 @@ config FDT_SIMPLEFB
  the presence of the simple frame buffer with associated reserved
  memory
 
+config ARCH_FIXUP_FDT_MEMORY
+   bool "Enable arch_fixup_memory_banks() call"
+   default y
+   help
+ Enable FDT memory map syncup before OS boot. This feature can be
+ used for booting OS with different memory setup where the part of
+ the memory location should be used for different purpose.
+
 endmenu
 
 endif # OF_LIBFDT
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 18/19] boot: Join FDT_FIXUP_PARTITIONS with related options

2023-08-24 Thread Simon Glass
Move this to be with the other devicetree-fixup options.

Signed-off-by: Simon Glass 
---

 boot/Kconfig | 8 
 lib/Kconfig  | 9 -
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 4742ee2027bd..32d3a7306139 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1473,6 +1473,14 @@ config OF_STDOUT_VIA_ALIAS
  incorrect when used with device tree as this option does not
  exist / should not be used.
 
+config FDT_FIXUP_PARTITIONS
+   bool "overwrite MTD partitions in DTS through defined in 'mtdparts'"
+   depends on CMD_MTDPARTS
+   help
+ Allow overwriting defined partitions in the device tree blob
+ using partition info defined in the 'mtdparts' environment
+ variable.
+
 config FDT_SIMPLEFB
bool "FDT tools for simplefb support"
help
diff --git a/lib/Kconfig b/lib/Kconfig
index bfab2f3165a7..eb2b10161824 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -953,15 +953,6 @@ config VPL_OF_LIBFDT_ASSUME_MASK
  0xff means all assumptions are made and any invalid data may cause
  unsafe execution. See FDT_ASSUME_PERFECT, etc. in libfdt_internal.h
 
-config FDT_FIXUP_PARTITIONS
-   bool "overwrite MTD partitions in DTS through defined in 'mtdparts'"
-   depends on OF_LIBFDT
-   depends on CMD_MTDPARTS
-   help
- Allow overwriting defined partitions in the device tree blob
- using partition info defined in the 'mtdparts' environment
- variable.
-
 menu "System tables"
depends on (!EFI && !SYS_COREBOOT) || (ARM && EFI_LOADER)
 
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 17/19] Make DISTRO_DEFAULTS as deprecated

2023-08-24 Thread Simon Glass
Encourage people to move to distro boot. Add a short migration guide.

Signed-off-by: Simon Glass 
---

 boot/Kconfig|  7 ++-
 doc/develop/bootstd.rst | 23 +++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 02b33323d726..4742ee2027bd 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -781,7 +781,7 @@ config SYS_BOOT_RAMDISK_HIGH
 endmenu# Boot images
 
 config DISTRO_DEFAULTS
-   bool "Select defaults suitable for booting general purpose Linux 
distributions"
+   bool "(deprecated) 'Defaults suitable for booting general purpose Linux 
distributions"
select BOOT_DEFAULTS
select AUTO_COMPLETE
select CMDLINE_EDITING
@@ -789,6 +789,11 @@ config DISTRO_DEFAULTS
select HUSH_PARSER
select SYS_LONGHELP
help
+ Note: These scripts have been replaced by Standard Boot. Do not use
+ them on new boards. See 'Migrating from distro_boot' at
+ doc/develop/bootstd.rst
+
+
  Select this to enable various options and commands which are suitable
  for building u-boot for booting general purpose Linux distributions.
 
diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst
index ec3136535783..8b2f0849a1c0 100644
--- a/doc/develop/bootstd.rst
+++ b/doc/develop/bootstd.rst
@@ -458,6 +458,28 @@ readyFile was loaded and is ready for use. In this 
state the bootflow is
 ===  
===
 
 
+Migrating from distro_boot
+--
+
+To migrate from distro_boot:
+
+#. Update your board header files to remove the BOOTENV and BOOT_TARGET_xxx
+   defines. Standard boot finds available boot devices automatically.
+
+#. Remove the "boot_targets" variable unless you need it. Standard boot uses a
+   default order from fastest to slowest, which generally matches the order 
used
+   by boards.
+
+#. Make sure that CONFIG_BOOTSTD_DEFAULTS is enabled by your board, so it can
+   boot common Linux distributions.
+
+An example patch is at migrate_patch_.
+
+If you are using custom boot scripts for your board, consider creating your
+own bootmeth to hold the logic. There are various examples at
+`boot/bootmeth_...`.
+
+
 Theory of operation
 ---
 
@@ -768,3 +790,4 @@ Other ideas:
 .. _BootLoaderSpec: 
http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/
 .. _distro_boot: https://github.com/u-boot/u-boot/blob/master/boot/distro.c
 .. _bootflow_h: https://github.com/u-boot/u-boot/blob/master/include/bootflow.h
+.. _migrate_patch: 
https://patchwork.ozlabs.org/project/uboot/patch/20230727215433.578830-2-...@chromium.org/
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 16/19] Kconfig: Move TEXT_BASE et al under general setup

2023-08-24 Thread Simon Glass
These don't relate to booting. Move them out of there and into the same
place as the other related settings.

Signed-off-by: Simon Glass 
---

 Kconfig  | 65 
 boot/Kconfig | 65 
 2 files changed, 65 insertions(+), 65 deletions(-)

diff --git a/Kconfig b/Kconfig
index 0a2e97578dfc..2d4b82149860 100644
--- a/Kconfig
+++ b/Kconfig
@@ -585,6 +585,71 @@ config MP
  This provides an option to bringup different processors
  in multiprocessor cases.
 
+config HAVE_TEXT_BASE
+   bool
+   depends on !NIOS2 && !XTENSA
+   depends on !EFI_APP
+   default y
+
+config TEXT_BASE
+   depends on HAVE_TEXT_BASE
+   default 0x0 if POSITION_INDEPENDENT
+   default 0x8080 if ARCH_OMAP2PLUS || ARCH_K3
+   default 0x8170 if MACH_SUNIV
+   default 0x2a00 if MACH_SUN9I
+   default 0x4a00 if SUNXI_MINIMUM_DRAM_MB >= 256
+   default 0x42e0 if SUNXI_MINIMUM_DRAM_MB >= 64
+   hex "Text Base"
+   help
+ The address in memory that U-Boot will be running from, initially.
+
+config HAVE_SYS_MONITOR_BASE
+   bool
+   depends on ARC || MIPS || M68K || NIOS2 || PPC || XTENSA || X86 \
+   || ENV_IS_IN_FLASH || MTD_NOR_FLASH
+   depends on !EFI_APP
+   default y
+
+config SYS_MONITOR_BASE
+   depends on HAVE_SYS_MONITOR_BASE
+   hex "Physical start address of boot monitor code"
+   default TEXT_BASE
+   help
+ The physical start address of boot monitor code (which is the same as
+ CONFIG_TEXT_BASE when linking) and the same as CFG_SYS_FLASH_BASE
+ when booting from flash.
+
+config SPL_SYS_MONITOR_BASE
+   depends on MPC85xx && SPL && HAVE_SYS_MONITOR_BASE
+   hex "Physical start address of SPL monitor code"
+   default SPL_TEXT_BASE
+
+config TPL_SYS_MONITOR_BASE
+   depends on MPC85xx && TPL && HAVE_SYS_MONITOR_BASE
+   hex "Physical start address of TPL monitor code"
+
+config DYNAMIC_SYS_CLK_FREQ
+   bool "Determine CPU clock frequency at run-time"
+   help
+ Implement a get_board_sys_clk function that will determine the CPU
+ clock frequency at run time, rather than define it statically.
+
+config SYS_CLK_FREQ
+   depends on !DYNAMIC_SYS_CLK_FREQ
+   int "CPU clock frequency"
+   default 12500 if ARCH_LS1012A
+   default 1 if ARCH_P2020 || ARCH_T1024 || ARCH_T1042 || \
+ARCH_LS1021A || FSL_LSCH2 || FSL_LSCH3
+   default  if ARCH_P1010 || ARCH_P1020 || ARCH_T4240
+   default  if ARCH_T2080
+   default  if RCAR_GEN3
+   default 2400 if ARCH_EXYNOS
+   default 2000 if RCAR_GEN2
+   default 0
+   help
+ A static value for the CPU frequency.  Note that if not required
+ for a given SoC, this can be left at 0.
+
 source "api/Kconfig"
 
 endmenu# General setup
diff --git a/boot/Kconfig b/boot/Kconfig
index 8343eba10531..02b33323d726 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -690,71 +690,6 @@ config SUPPORT_RAW_INITRD
  address of the initrd must be augmented by it's size, in the following
  format: ":".
 
-config HAVE_TEXT_BASE
-   bool
-   depends on !NIOS2 && !XTENSA
-   depends on !EFI_APP
-   default y
-
-config TEXT_BASE
-   depends on HAVE_TEXT_BASE
-   default 0x0 if POSITION_INDEPENDENT
-   default 0x8080 if ARCH_OMAP2PLUS || ARCH_K3
-   default 0x8170 if MACH_SUNIV
-   default 0x2a00 if MACH_SUN9I
-   default 0x4a00 if SUNXI_MINIMUM_DRAM_MB >= 256
-   default 0x42e0 if SUNXI_MINIMUM_DRAM_MB >= 64
-   hex "Text Base"
-   help
- The address in memory that U-Boot will be running from, initially.
-
-config HAVE_SYS_MONITOR_BASE
-   bool
-   depends on ARC || MIPS || M68K || NIOS2 || PPC || XTENSA || X86 \
-   || ENV_IS_IN_FLASH || MTD_NOR_FLASH
-   depends on !EFI_APP
-   default y
-
-config SYS_MONITOR_BASE
-   depends on HAVE_SYS_MONITOR_BASE
-   hex "Physical start address of boot monitor code"
-   default TEXT_BASE
-   help
- The physical start address of boot monitor code (which is the same as
- CONFIG_TEXT_BASE when linking) and the same as CFG_SYS_FLASH_BASE
- when booting from flash.
-
-config SPL_SYS_MONITOR_BASE
-   depends on MPC85xx && SPL && HAVE_SYS_MONITOR_BASE
-   hex "Physical start address of SPL monitor code"
-   default SPL_TEXT_BASE
-
-config TPL_SYS_MONITOR_BASE
-   depends on MPC85xx && TPL && HAVE_SYS_MONITOR_BASE
-   hex "Physical start address of TPL monitor code"
-
-config DYNAMIC_SYS_CLK_FREQ
-   bool "Determine CPU clock frequency at run-time"
-   help
- Implement a get_board_sys_clk function that will determine the CPU
- clock frequency at run 

[PATCH 15/19] boot: Make standard boot a menu

2023-08-24 Thread Simon Glass
Collect these options into a menu for easier viewing.

Signed-off-by: Simon Glass 
---

 boot/Kconfig | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index af08703ea1e5..8343eba10531 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -372,8 +372,8 @@ config BOOT_DEFAULTS
  of U-Boot to boot various images. Currently much functionality is
  tied to enabling the command that exercises it.
 
-config BOOTSTD
-   bool "Standard boot support"
+menuconfig BOOTSTD
+   bool "Standard boot"
default y
depends on DM && OF_CONTROL && BLK
help
@@ -393,6 +393,8 @@ config BOOTSTD
U-Boot)
- bootflow - a description of how to boot (owned by the distro)
 
+if BOOTSTD
+
 config SPL_BOOTSTD
bool "Standard boot support in SPL"
depends on SPL && SPL_DM && SPL_OF_CONTROL && SPL_BLK
@@ -413,8 +415,6 @@ config VPL_BOOTSTD
  boot. It is enabled by default since the main purpose of VPL is to
  handle the firmware part of VBE.
 
-if BOOTSTD
-
 config BOOTSTD_FULL
bool "Enhanced features for standard boot"
default y if SANDBOX
@@ -670,7 +670,7 @@ config BOOTMETH_SCRIPT
  This provides a way to try out standard boot on an existing boot flow.
  It is not enabled by default to save space.
 
-endif
+endif # BOOTSTD
 
 config LEGACY_IMAGE_FORMAT
bool "Enable support for the legacy image format"
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 14/19] spl: Tidy up load address in spl_ram

2023-08-24 Thread Simon Glass
This CONFIG is used but is not given a value by some boards. Use
a default value of 0 explicitly, rather than relying on the 0 value
provided by CONFIG_SPL_LOAD_FIT_ADDRESS

This will allow us to make SPL_LOAD_FIT_ADDRESS depend on SPL_LOAD_FIT
as it should.

Signed-off-by: Simon Glass 
---

 common/spl/spl_ram.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index 93cf420d810a..4158ed1c32d7 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -20,12 +20,16 @@
 static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
   ulong count, void *buf)
 {
-   ulong addr;
+   ulong addr = 0;
 
debug("%s: sector %lx, count %lx, buf %lx\n",
  __func__, sector, count, (ulong)buf);
 
-   addr = (ulong)CONFIG_SPL_LOAD_FIT_ADDRESS + sector;
+   if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+   addr = IF_ENABLED_INT(CONFIG_SPL_LOAD_FIT,
+ CONFIG_SPL_LOAD_FIT_ADDRESS);
+   }
+   addr += sector;
if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD))
addr += image_load_offset;
 
@@ -38,20 +42,23 @@ static int spl_ram_load_image(struct spl_image_info 
*spl_image,
  struct spl_boot_device *bootdev)
 {
struct legacy_img_hdr *header;
+   ulong addr = 0;
int ret;
 
-   header = (struct legacy_img_hdr *)CONFIG_SPL_LOAD_FIT_ADDRESS;
+   if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+   addr = IF_ENABLED_INT(CONFIG_SPL_LOAD_FIT,
+ CONFIG_SPL_LOAD_FIT_ADDRESS);
+   }
 
if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD)) {
-   unsigned long addr = (unsigned long)header;
ret = image_pre_load(addr);
 
if (ret)
return ret;
 
addr += image_load_offset;
-   header = (struct legacy_img_hdr *)addr;
}
+   header = map_sysmem(addr, 0);
 
 #if CONFIG_IS_ENABLED(DFU)
if (bootdev->boot_device == BOOT_DEVICE_DFU)
@@ -84,7 +91,7 @@ static int spl_ram_load_image(struct spl_image_info 
*spl_image,
u_boot_pos = 
(ulong)spl_get_load_buffer(-sizeof(*header),

sizeof(*header));
}
-   header = (struct legacy_img_hdr *)map_sysmem(u_boot_pos, 0);
+   header = map_sysmem(u_boot_pos, 0);
 
ret = spl_parse_image_header(spl_image, bootdev, header);
}
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 12/19] Kconfig: Create a menu for FIT

2023-08-24 Thread Simon Glass
This is a major feature with a lot of options. Give it its own menu to
tidy up the 'make menuconfig' display. Drop the 'depends on FIT' pieces
which are now unnecessary, since they are now bracketed by an 'if FIT'.

Signed-off-by: Simon Glass 
---

 boot/Kconfig | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index e378d9cdb4ff..bc3a68402a15 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -9,8 +9,8 @@ config ANDROID_BOOT_IMAGE
  This enables support for booting images which use the Android
  image format header.
 
-config FIT
-   bool "Support Flattened Image Tree"
+menuconfig FIT
+   bool "Flattened Image Tree (FIT)"
select HASH
select MD5
select SHA1
@@ -25,6 +25,8 @@ config FIT
  multiple configurations, verification through hashing and also
  verified boot (secure boot using RSA).
 
+if FIT
+
 config TIMESTAMP
bool "Show image date and time when displaying image information"
default y if CMD_DATE
@@ -38,7 +40,6 @@ config TIMESTAMP
 
 config FIT_EXTERNAL_OFFSET
hex "FIT external data offset"
-   depends on FIT
default 0x0
help
  This specifies a data offset in fit image.
@@ -49,7 +50,6 @@ config FIT_EXTERNAL_OFFSET
 
 config FIT_FULL_CHECK
bool "Do a full check of the FIT before using it"
-   depends on FIT
default y
help
  Enable this do a full check of the FIT to make sure it is valid. This
@@ -59,7 +59,7 @@ config FIT_FULL_CHECK
 
 config FIT_SIGNATURE
bool "Enable signature verification of FIT uImages"
-   depends on DM && FIT
+   depends on DM
select HASH
imply RSA
imply RSA_VERIFY
@@ -97,7 +97,7 @@ config FIT_RSASSA_PSS
 
 config FIT_CIPHER
bool "Enable ciphering data in a FIT uImages"
-   depends on DM && FIT
+   depends on DM
select AES
help
  Enable the feature of data ciphering/unciphering in the tool mkimage
@@ -105,7 +105,6 @@ config FIT_CIPHER
 
 config FIT_VERBOSE
bool "Show verbose messages when FIT images fail"
-   depends on FIT
help
  Generally a system will have valid FIT images so debug messages
  are a waste of code space. If you are debugging your images then
@@ -114,7 +113,6 @@ config FIT_VERBOSE
 
 config FIT_BEST_MATCH
bool "Select the best match for the kernel device tree"
-   depends on FIT
help
  When no configuration is explicitly selected, default to the
  one whose fdt's compatibility field best matches that of
@@ -124,7 +122,6 @@ config FIT_BEST_MATCH
 
 config FIT_IMAGE_POST_PROCESS
bool "Enable post-processing of FIT artifacts after loading by U-Boot"
-   depends on FIT
depends on SOCFPGA_SECURE_VAB_AUTH
help
  Allows doing any sort of manipulation to blobs after they got 
extracted
@@ -139,11 +136,12 @@ config FIT_IMAGE_POST_PROCESS
 
 config FIT_PRINT
 bool "Support FIT printing"
-   depends on FIT
 default y
 help
   Support printing the content of the fitImage in a verbose manner.
 
+endif # FIT
+
 config SPL_FIT
bool "Support Flattened Image Tree within SPL"
depends on SPL && FIT
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 13/19] Kconfig: Move SPL_FIT under FIT

2023-08-24 Thread Simon Glass
This option already depends on FIT, so put it under the same umbrella, so
that it appears in the FIT menu.

Signed-off-by: Simon Glass 
---

 boot/Kconfig | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index bc3a68402a15..af08703ea1e5 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -140,11 +140,9 @@ config FIT_PRINT
 help
   Support printing the content of the fitImage in a verbose manner.
 
-endif # FIT
-
 config SPL_FIT
bool "Support Flattened Image Tree within SPL"
-   depends on SPL && FIT
+   depends on SPL
select SPL_HASH
select SPL_OF_LIBFDT
 
@@ -195,7 +193,7 @@ config SPL_FIT_RSASSA_PSS
 
 config SPL_LOAD_FIT
bool "Enable SPL loading U-Boot as a FIT (basic fitImage features)"
-   depends on SPL && FIT
+   depends on SPL
select SPL_FIT
help
  Normally with the SPL framework a legacy image is generated as part
@@ -243,7 +241,6 @@ config SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ
 
 config SPL_LOAD_FIT_FULL
bool "Enable SPL loading U-Boot as a FIT (full fitImage features)"
-   depends on FIT
select SPL_FIT
help
  Normally with the SPL framework a legacy image is generated as part
@@ -341,6 +338,8 @@ config VPL_FIT_SIGNATURE_MAX_SIZE
 
 endif # VPL
 
+endif # FIT
+
 config PXE_UTILS
bool
select MENU
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 11/19] boot: Rename Android-boot text

2023-08-24 Thread Simon Glass
Phrases like 'Enable support for' are pointless since this is an option
which enables things. Drop that part so it is easier to follow.

Signed-off-by: Simon Glass 
---

 boot/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index daec68034c72..e378d9cdb4ff 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -3,7 +3,7 @@ menu "Boot options"
 menu "Boot images"
 
 config ANDROID_BOOT_IMAGE
-   bool "Enable support for Android Boot Images"
+   bool "Android Boot Images"
default y if FASTBOOT
help
  This enables support for booting images which use the Android
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 10/19] boot: Move some other fdt-fixup options to the same menu

2023-08-24 Thread Simon Glass
Move more options relating to fixing up a device tree into the new
devicetree-fixup menu.

Signed-off-by: Simon Glass 
---

 boot/Kconfig | 55 +---
 1 file changed, 26 insertions(+), 29 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 1b2ac7451a61..daec68034c72 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -693,35 +693,6 @@ config SUPPORT_RAW_INITRD
  address of the initrd must be augmented by it's size, in the following
  format: ":".
 
-config OF_BOARD_SETUP
-   bool "Set up board-specific details in device tree before boot"
-   depends on OF_LIBFDT
-   help
- This causes U-Boot to call ft_board_setup() before booting into
- the Operating System. This function can set up various
- board-specific information in the device tree for use by the OS.
- The device tree is then passed to the OS.
-
-config OF_SYSTEM_SETUP
-   bool "Set up system-specific details in device tree before boot"
-   depends on OF_LIBFDT
-   help
- This causes U-Boot to call ft_system_setup() before booting into
- the Operating System. This function can set up various
- system-specific information in the device tree for use by the OS.
- The device tree is then passed to the OS.
-
-config OF_STDOUT_VIA_ALIAS
-   bool "Update the device-tree stdout alias from U-Boot"
-   depends on OF_LIBFDT
-   help
- This uses U-Boot's serial alias from the aliases node to update
- the device tree passed to the OS. The "linux,stdout-path" property
- in the chosen node is set to point to the correct serial node.
- This option currently references CONFIG_CONS_INDEX, which is
- incorrect when used with device tree as this option does not
- exist / should not be used.
-
 config HAVE_TEXT_BASE
bool
depends on !NIOS2 && !XTENSA
@@ -1539,6 +1510,32 @@ if OF_LIBFDT
 
 menu "Devicetree fixup"
 
+config OF_BOARD_SETUP
+   bool "Set up board-specific details in device tree before boot"
+   help
+ This causes U-Boot to call ft_board_setup() before booting into
+ the Operating System. This function can set up various
+ board-specific information in the device tree for use by the OS.
+ The device tree is then passed to the OS.
+
+config OF_SYSTEM_SETUP
+   bool "Set up system-specific details in device tree before boot"
+   help
+ This causes U-Boot to call ft_system_setup() before booting into
+ the Operating System. This function can set up various
+ system-specific information in the device tree for use by the OS.
+ The device tree is then passed to the OS.
+
+config OF_STDOUT_VIA_ALIAS
+   bool "Update the device-tree stdout alias from U-Boot"
+   help
+ This uses U-Boot's serial alias from the aliases node to update
+ the device tree passed to the OS. The "linux,stdout-path" property
+ in the chosen node is set to point to the correct serial node.
+ This option currently references CONFIG_CONS_INDEX, which is
+ incorrect when used with device tree as this option does not
+ exist / should not be used.
+
 config FDT_SIMPLEFB
bool "FDT tools for simplefb support"
help
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 09/19] Move fdt_simplefb to boot/

2023-08-24 Thread Simon Glass
This relates to booting, so move it there. Create a new Kconfig menu for
things related to devicetree fixup.

Signed-off-by: Simon Glass 
---

 boot/Kconfig| 16 
 boot/Makefile   |  1 +
 {common => boot}/fdt_simplefb.c |  0
 common/Kconfig  |  9 -
 common/Makefile |  1 -
 5 files changed, 17 insertions(+), 10 deletions(-)
 rename {common => boot}/fdt_simplefb.c (100%)

diff --git a/boot/Kconfig b/boot/Kconfig
index 5e2d4286aeaa..1b2ac7451a61 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1535,6 +1535,22 @@ config SPL_IMAGE_PRE_LOAD_SIG
 
 endmenu
 
+if OF_LIBFDT
+
+menu "Devicetree fixup"
+
+config FDT_SIMPLEFB
+   bool "FDT tools for simplefb support"
+   help
+ Enable the fdt tools to manage the simple fb nodes in device tree.
+ These functions can be used by board to indicate to the OS
+ the presence of the simple frame buffer with associated reserved
+ memory
+
+endmenu
+
+endif # OF_LIBFDT
+
 config USE_BOOTARGS
bool "Enable boot arguments"
help
diff --git a/boot/Makefile b/boot/Makefile
index f15a161614ff..6ce983b83fa4 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_$(SPL_TPL_)CEDIT) += cedit.o
 endif
 
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
+obj-$(CONFIG_$(SPL_TPL_)FDT_SIMPLEFB) += fdt_simplefb.o
 
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
 obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
diff --git a/common/fdt_simplefb.c b/boot/fdt_simplefb.c
similarity index 100%
rename from common/fdt_simplefb.c
rename to boot/fdt_simplefb.c
diff --git a/common/Kconfig b/common/Kconfig
index 2f46fdb3f62c..9693c0ac426f 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1156,14 +1156,5 @@ config VPL_IMAGE_SIGN_INFO
 
 endif
 
-config FDT_SIMPLEFB
-   bool "FDT tools for simplefb support"
-   depends on OF_LIBFDT
-   help
- Enable the fdt tools to manage the simple fb nodes in device tree.
- These functions can be used by board to indicate to the OS
- the presence of the simple frame buffer with associated reserved
- memory
-
 config IO_TRACE
bool
diff --git a/common/Makefile b/common/Makefile
index 0948721d0b47..5c1617206f07 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -17,7 +17,6 @@ obj-y += board_r.o
 obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
 obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
 
-obj-$(CONFIG_FDT_SIMPLEFB) += fdt_simplefb.o
 obj-$(CONFIG_MII) += miiphyutil.o
 obj-$(CONFIG_CMD_MII) += miiphyutil.o
 obj-$(CONFIG_PHYLIB) += miiphyutil.o
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 08/19] boot: Move fdt_support to boot/

2023-08-24 Thread Simon Glass
This relates to booting since it fixes up the devicetree for the OS. Move
it into the boot/ directory.

Signed-off-by: Simon Glass 
---

 boot/Makefile  | 3 +++
 {common => boot}/fdt_support.c | 0
 common/Makefile| 2 --
 3 files changed, 3 insertions(+), 2 deletions(-)
 rename {common => boot}/fdt_support.c (100%)

diff --git a/boot/Makefile b/boot/Makefile
index 10f015722378..f15a161614ff 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_QFW) += bootmeth_qfw.o
 endif
 
 obj-y += image.o image-board.o
+
 obj-$(CONFIG_ANDROID_AB) += android_ab.o
 obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o
 
@@ -37,6 +38,8 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow_menu.o
 obj-$(CONFIG_$(SPL_TPL_)CEDIT) += cedit.o
 endif
 
+obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
+
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
 obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
 obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o
diff --git a/common/fdt_support.c b/boot/fdt_support.c
similarity index 100%
rename from common/fdt_support.c
rename to boot/fdt_support.c
diff --git a/common/Makefile b/common/Makefile
index 0a3f75f2f1c8..0948721d0b47 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -18,7 +18,6 @@ obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
 obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
 
 obj-$(CONFIG_FDT_SIMPLEFB) += fdt_simplefb.o
-obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
 obj-$(CONFIG_MII) += miiphyutil.o
 obj-$(CONFIG_CMD_MII) += miiphyutil.o
 obj-$(CONFIG_PHYLIB) += miiphyutil.o
@@ -51,7 +50,6 @@ ifdef CONFIG_SPL_DFU
 obj-$(CONFIG_DFU_OVER_USB) += dfu.o
 endif
 obj-$(CONFIG_SPL_NET) += miiphyutil.o
-obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
 
 obj-$(CONFIG_SPL_USB_HOST) += usb.o usb_hub.o
 obj-$(CONFIG_SPL_USB_STORAGE) += usb_storage.o
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 07/19] test: Move POST under a renamed Testing section

2023-08-24 Thread Simon Glass
Rename Unit tests to Testing, since it is a stretch to describe some of
the tests as unit tests. Move POST there as well, so it doesn't show up
by itself in the top-level menu.

Signed-off-by: Simon Glass 
---

 test/Kconfig | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/test/Kconfig b/test/Kconfig
index 6e859fb7d0db..830245b6f9a9 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -1,9 +1,4 @@
-config POST
-   bool "Power On Self Test support"
-   help
- See doc/README.POST for more details
-
-menu "Unit tests"
+menu "Testing"
 
 config UNIT_TEST
bool "Unit tests"
@@ -110,4 +105,9 @@ source "test/lib/Kconfig"
 source "test/optee/Kconfig"
 source "test/overlay/Kconfig"
 
+config POST
+   bool "Power On Self Test support"
+   help
+ See doc/README.POST for more details
+
 endmenu
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 06/19] FMU: Avoid showing an unselectable menu option

2023-08-24 Thread Simon Glass
Use a menuconfig to avoid showing a menu which cannot be selected in many
cases.

This option should really go with the other 'Update support'.

Perhaps we should even consider a top-level update/ directory?

Signed-off-by: Simon Glass 
---

 lib/Kconfig | 4 
 lib/fwu_updates/Kconfig | 6 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 9addcfab3734..bfab2f3165a7 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1118,8 +1118,4 @@ config PHANDLE_CHECK_SEQ
 
 endmenu
 
-menu "FWU Multi Bank Updates"
-
 source lib/fwu_updates/Kconfig
-
-endmenu
diff --git a/lib/fwu_updates/Kconfig b/lib/fwu_updates/Kconfig
index 71f34793d926..be35ad29fa32 100644
--- a/lib/fwu_updates/Kconfig
+++ b/lib/fwu_updates/Kconfig
@@ -1,4 +1,4 @@
-config FWU_MULTI_BANK_UPDATE
+menuconfig FWU_MULTI_BANK_UPDATE
bool "Enable FWU Multi Bank Update Feature"
depends on EFI_CAPSULE_ON_DISK
select PARTITION_TYPE_GUID
@@ -10,6 +10,8 @@ config FWU_MULTI_BANK_UPDATE
  multiple banks(copies) of the firmware images. One of the
  bank is selected for updating all the firmware components
 
+if FWU_MULTI_BANK_UPDATE
+
 config FWU_NUM_BANKS
int "Number of Banks defined by the platform"
depends on FWU_MULTI_BANK_UPDATE
@@ -31,3 +33,5 @@ config FWU_TRIAL_STATE_CNT
  With FWU Multi Bank Update feature enabled, number of times
  the platform is allowed to boot in Trial State after an
  update.
+
+endif
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 05/19] net: Move SYS_RX_ETH_BUFFER into the network menu

2023-08-24 Thread Simon Glass
Move this Kconfig option into the correct place, so it doesn't show up
in the top-level menu.

Unfortunately this makes the CONFIG undefined on some boards which don't
enable CONFIG_NET but do include the net.h header file. In fact that
header is included from a lot of common places. So use a fallback in the
header file.

Signed-off-by: Simon Glass 
---

 include/net.h | 9 ++---
 net/Kconfig   | 4 ++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/net.h b/include/net.h
index e254df7d7f43..f70396c74ba5 100644
--- a/include/net.h
+++ b/include/net.h
@@ -31,11 +31,14 @@ struct udevice;
 #define DEBUG_INT_STATE 0  /* Internal network state changes */
 
 /*
- * The number of receive packet buffers, and the required packet buffer
- * alignment in memory.
- *
+ * The number of receive packet buffers, and the required packet buffer
+ * alignment in memory.
  */
+#ifdef CONFIG_SYS_RX_ETH_BUFFER
 #define PKTBUFSRX  CONFIG_SYS_RX_ETH_BUFFER
+#else
+#define PKTBUFSRX  4
+#endif
 #define PKTALIGN   ARCH_DMA_MINALIGN
 
 /* Number of packets processed together */
diff --git a/net/Kconfig b/net/Kconfig
index 4215889127c9..a13ab1d80a0d 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -252,8 +252,6 @@ config IPV6
  ip6addr, serverip6. If a u-boot command is capable to parse an IPv6
  address and find it, it will force using IPv6 in the network stack.
 
-endif   # if NET
-
 config SYS_RX_ETH_BUFFER
int "Number of receive packet buffers"
default 4
@@ -262,3 +260,5 @@ config SYS_RX_ETH_BUFFER
  controllers it is recommended to set this value to 8 or even higher,
  since all buffers can be full shortly after enabling the interface on
  high Ethernet traffic.
+
+endif   # if NET
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 04/19] video: Move BMP options and code to video directory

2023-08-24 Thread Simon Glass
Put the options and the common BMP code with the other related Kconfig
options in the drivers/video directory.

Signed-off-by: Simon Glass 
---

 common/Kconfig  | 11 ---
 common/Makefile |  1 -
 drivers/video/Kconfig   | 11 +++
 drivers/video/Makefile  |  2 ++
 {common => drivers/video}/bmp.c |  0
 5 files changed, 13 insertions(+), 12 deletions(-)
 rename {common => drivers/video}/bmp.c (100%)

diff --git a/common/Kconfig b/common/Kconfig
index 844531a59eda..2f46fdb3f62c 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1167,14 +1167,3 @@ config FDT_SIMPLEFB
 
 config IO_TRACE
bool
-
-config BMP
-   bool # Enable bmp image display
-   help
- Enable bmp functions to display bmp image and get bmp info.
-
-config SPL_BMP
-   bool # Enable bmp image display at SPL
-   depends on SPL_VIDEO
-   help
- Enable bmp functions to display bmp image and get bmp info at SPL.
diff --git a/common/Makefile b/common/Makefile
index f5c3d90f0675..0a3f75f2f1c8 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -45,7 +45,6 @@ endif # !CONFIG_SPL_BUILD
 
 obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o
 obj-$(CONFIG_$(SPL_TPL_)BLOBLIST) += bloblist.o
-obj-$(CONFIG_$(SPL_)BMP) += bmp.o
 
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_SPL_DFU
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 09f2cb1a7321..a4befd6b655c 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -682,6 +682,11 @@ config BACKLIGHT_LM3533
  LM3533 Lighting Power chip. Only Bank A is supported as for now.
  Supported backlight level range is from 2 to 255 with step of 1.
 
+config BMP
+   bool # Enable bmp image display
+   help
+ Enable bmp functions to display bmp image and get bmp info.
+
 source "drivers/video/ti/Kconfig"
 
 source "drivers/video/exynos/Kconfig"
@@ -1117,6 +1122,12 @@ config SPL_VIDEO_REMOVE
  if this  option is enabled video driver will be removed at the end of
  SPL stage, before loading the next stage.
 
+config SPL_BMP
+   bool # Enable bmp image display at SPL
+   depends on SPL_VIDEO
+   help
+ Enable bmp functions to display bmp image and get bmp info at SPL.
+
 if SPL_SPLASH_SCREEN
 
 config SPL_SPLASH_SCREEN_ALIGN
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index d13af9f3b19b..a3182dca734b 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -3,6 +3,8 @@
 # (C) Copyright 2000-2007
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 
+obj-$(CONFIG_$(SPL_)BMP) += bmp.o
+
 ifdef CONFIG_DM
 obj-$(CONFIG_$(SPL_TPL_)BACKLIGHT) += backlight-uclass.o
 obj-$(CONFIG_BACKLIGHT_GPIO) += backlight_gpio.o
diff --git a/common/bmp.c b/drivers/video/bmp.c
similarity index 100%
rename from common/bmp.c
rename to drivers/video/bmp.c
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 03/19] video: Hide the BMP options

2023-08-24 Thread Simon Glass
These appear prominently in the main menu at present. However they are
selected when needed so do not need to be visible.

Make them hidden.

Signed-off-by: Simon Glass 
---

 common/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 0b09bd68bd13..844531a59eda 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1169,12 +1169,12 @@ config IO_TRACE
bool
 
 config BMP
-   bool "Enable bmp image display"
+   bool # Enable bmp image display
help
  Enable bmp functions to display bmp image and get bmp info.
 
 config SPL_BMP
-   bool "Enable bmp image display at SPL"
+   bool # Enable bmp image display at SPL
depends on SPL_VIDEO
help
  Enable bmp functions to display bmp image and get bmp info at SPL.
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 02/19] Kconfig: Move API into general setup

2023-08-24 Thread Simon Glass
This is perhaps not a commonly used feature so should not have its own
option in the main menu. Move it under general setup.

Signed-off-by: Simon Glass 
---

 Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Kconfig b/Kconfig
index 91170bf8d223..0a2e97578dfc 100644
--- a/Kconfig
+++ b/Kconfig
@@ -585,10 +585,10 @@ config MP
  This provides an option to bringup different processors
  in multiprocessor cases.
 
-endmenu# General setup
-
 source "api/Kconfig"
 
+endmenu# General setup
+
 source "boot/Kconfig"
 
 source "common/Kconfig"
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 01/19] lib: rational: Move the Kconfigs into the correct place

2023-08-24 Thread Simon Glass
These should not be part of the 'system tables' menu. Move them outside
on their own.

Signed-off-by: Simon Glass 
Fixes: 7d0f3fbb93c ("lib: rational: copy the rational fraction lib...")
---

 lib/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 42e559ad0b51..9addcfab3734 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -989,6 +989,8 @@ config GENERATE_SMBIOS_TABLE
  See also SMBIOS_SYSINFO which allows SMBIOS values to be provided in
  the devicetree.
 
+endmenu
+
 config LIB_RATIONAL
bool "enable continued fraction calculation routines"
 
@@ -996,8 +998,6 @@ config SPL_LIB_RATIONAL
bool "enable continued fraction calculation routines for SPL"
depends on SPL
 
-endmenu
-
 config ASN1_COMPILER
bool
help
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 00/19] Kconfig: Tidy up some options

2023-08-24 Thread Simon Glass
The view from 'make menuconfig' is confusing in places. This series aims
to improve the top-level menu and also the boot menu.

It also groups FDT-fixup options tegether, at least the ones I could fine.

Finally this series marks the distro scripts as deprecated, so people have
a pointer to standard boot.


Simon Glass (19):
  lib: rational: Move the Kconfigs into the correct place
  Kconfig: Move API into general setup
  video: Hide the BMP options
  video: Move BMP options and code to video directory
  net: Move SYS_RX_ETH_BUFFER into the network menu
  FMU: Avoid showing an unselectable menu option
  test: Move POST under a renamed Testing section
  boot: Move fdt_support to boot/
  Move fdt_simplefb to boot/
  boot: Move some other fdt-fixup options to the same menu
  boot: Rename Android-boot text
  Kconfig: Create a menu for FIT
  Kconfig: Move SPL_FIT under FIT
  spl: Tidy up load address in spl_ram
  boot: Make standard boot a menu
  Kconfig: Move TEXT_BASE et al under general setup
  Make DISTRO_DEFAULTS as deprecated
  boot: Join FDT_FIXUP_PARTITIONS with related options
  boot: Join ARCH_FIXUP_FDT_MEMORY with related options

 Kconfig |  67 ++-
 boot/Kconfig| 202 +---
 boot/Makefile   |   4 +
 {common => boot}/fdt_simplefb.c |   0
 {common => boot}/fdt_support.c  |   0
 common/Kconfig  |  20 
 common/Makefile |   4 -
 common/spl/spl_ram.c|  19 ++-
 doc/develop/bootstd.rst |  23 
 drivers/video/Kconfig   |  11 ++
 drivers/video/Makefile  |   2 +
 {common => drivers/video}/bmp.c |   0
 include/net.h   |   9 +-
 lib/Kconfig |  17 +--
 lib/fwu_updates/Kconfig |   6 +-
 net/Kconfig |   4 +-
 test/Kconfig|  12 +-
 17 files changed, 220 insertions(+), 180 deletions(-)
 rename {common => boot}/fdt_simplefb.c (100%)
 rename {common => boot}/fdt_support.c (100%)
 rename {common => drivers/video}/bmp.c (100%)

-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 23/23] CI: Add ChromiumOS utilities

2023-08-24 Thread Simon Glass
We need cgpt and futility for building test images. Add them.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/docker/Dockerfile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 3d2b64a355f3..6e6ae9ebed40 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -39,6 +39,7 @@ RUN apt-get update && apt-get install -y \
binutils-dev \
bison \
build-essential \
+   cgpt \
clang-16 \
coreutils \
cpio \
@@ -115,6 +116,8 @@ RUN apt-get update && apt-get install -y \
util-linux \
uuid-dev \
virtualenv \
+   vboot-kernel-utils \
+   vboot-utils \
xxd \
zip \
&& rm -rf /var/lib/apt/lists/*
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 22/23] bootstd: cros: Allow detection of any kernel partition

2023-08-24 Thread Simon Glass
The existing ChromiumOS bootmeth only supports reading a single kernel
partition, either 2 or 4. In fact there are normally two options
available.

Use the GUID to detect kernel partitions, with the BOOTMETHF_ANY_PART
flag, so that bootstd does not require a valid filesystem before calling
the bootmeth.

Tidy up and improve the logging while we are here.

Signed-off-by: Simon Glass 
Suggested-by: Alper Nebi Yasak 
---

Changes in v2:
- Rebase to -next

 boot/Kconfig |  2 ++
 boot/bootmeth_cros.c | 48 +++-
 test/boot/bootflow.c |  5 +++--
 3 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 5e2d4286aeaa..b385902b53fe 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -466,6 +466,8 @@ config BOOTMETH_CROS
bool "Bootdev support for Chromium OS"
depends on X86 || ARM || SANDBOX
default y if !ARM
+   select PARTITION_TYPE_GUID
+   select PARTITION_UUIDS
help
  Enables support for booting Chromium OS using bootdevs. This uses the
  kernel A slot and obtains the kernel command line from the parameters
diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c
index 1776fb1838c6..20e0b1e89c36 100644
--- a/boot/bootmeth_cros.c
+++ b/boot/bootmeth_cros.c
@@ -16,16 +16,19 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include "bootmeth_cros.h"
 
+static const efi_guid_t cros_kern_type = PARTITION_CROS_KERNEL;
+
 /*
  * Layout of the ChromeOS kernel
  *
- * Partitions 2 and 4 contain kernels
+ * Partitions 2 and 4 contain kernels with type GUID_CROS_KERNEL
  *
  * Contents are:
  *
@@ -145,13 +148,25 @@ static int scan_part(struct udevice *blk, int partnum,
 {
struct blk_desc *desc = dev_get_uclass_plat(blk);
struct vb2_keyblock *hdr;
+   struct uuid type;
ulong num_blks;
int ret;
 
+   if (!partnum)
+   return log_msg_ret("efi", -ENOENT);
+
ret = part_get_info(desc, partnum, info);
if (ret)
return log_msg_ret("part", ret);
 
+   /* Check for kernel partition type */
+   log_debug("part %x: type=%s\n", partnum, info->type_guid);
+   if (uuid_str_to_bin(info->type_guid, (u8 *), UUID_STR_FORMAT_GUID))
+   return log_msg_ret("typ", -EINVAL);
+
+   if (memcmp(_kern_type, , sizeof(type)))
+   return log_msg_ret("typ", -ENOEXEC);
+
/* Make a buffer for the header information */
num_blks = PROBE_SIZE >> desc->log2blksz;
log_debug("Reading header, blk=%s, start=%lx, blocks=%lx\n",
@@ -167,6 +182,7 @@ static int scan_part(struct udevice *blk, int partnum,
 
if (memcmp(VB2_KEYBLOCK_MAGIC, hdr->magic, VB2_KEYBLOCK_MAGIC_SIZE)) {
free(hdr);
+   log_debug("no magic\n");
return -ENOENT;
}
 
@@ -340,24 +356,16 @@ static int cros_read_bootflow(struct udevice *dev, struct 
bootflow *bflow)
struct vb2_keyblock *hdr;
const char *uuid = NULL;
struct cros_priv *priv;
-   int part, ret;
-
-   log_debug("starting, part=%d\n", bflow->part);
+   int ret;
 
-   /* We consider the whole disk, not any one partition */
-   if (bflow->part)
-   return log_msg_ret("max", -ENOENT);
+   log_debug("starting, part=%x\n", bflow->part);
 
-   /* Check partition 2 then 4 */
-   part = 2;
-   ret = scan_part(bflow->blk, part, , );
+   /* Check for kernel partitions */
+   ret = scan_part(bflow->blk, bflow->part, , );
if (ret) {
-   part = 4;
-   ret = scan_part(bflow->blk, part, , );
-   if (ret)
-   return log_msg_ret("scan", ret);
+   log_debug("- scan failed: err=%d\n", ret);
+   return log_msg_ret("scan", ret);
}
-   bflow->part = part;
 
priv = malloc(sizeof(struct cros_priv));
if (!priv) {
@@ -366,8 +374,8 @@ static int cros_read_bootflow(struct udevice *dev, struct 
bootflow *bflow)
}
bflow->bootmeth_priv = priv;
 
-   log_info("Selected partition %d, header at %lx\n", bflow->part,
-(ulong)map_to_sysmem(hdr));
+   log_debug("Selected partition %d, header at %lx\n", bflow->part,
+ (ulong)map_to_sysmem(hdr));
 
/* Grab a few things from the preamble */
preamble = (void *)hdr + hdr->keyblock_size;
@@ -381,8 +389,11 @@ static int cros_read_bootflow(struct udevice *dev, struct 
bootflow *bflow)
ret = cros_read_info(bflow, uuid, preamble);
preamble = NULL;
free(hdr);
-   if (ret)
+   if (ret) {
+   free(priv->info_buf);
+   free(priv);
return log_msg_ret("inf", ret);
+   }
bflow->size = priv->body_size;
bflow->state = BOOTFLOWST_READY;
 
@@ -437,6 +448,7 @@ static int cros_bootmeth_bind(struct udevice *dev)
  

[PATCH v2 21/23] uuid: Add ChromiumOS partition types

2023-08-24 Thread Simon Glass
Add some GUIDs for ChromiumOS so we can detect the partitions.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/part_efi.h | 14 ++
 lib/uuid.c |  7 +++
 2 files changed, 21 insertions(+)

diff --git a/include/part_efi.h b/include/part_efi.h
index c68529b4dafe..59b7895b8a23 100644
--- a/include/part_efi.h
+++ b/include/part_efi.h
@@ -60,6 +60,20 @@
EFI_GUID( 0x3de21764, 0x95bd, 0x54bd, \
0xa5, 0xc3, 0x4a, 0xbe, 0x78, 0x6f, 0x38, 0xa8)
 
+/* Special ChromiumOS things */
+#define PARTITION_CROS_KERNEL \
+   EFI_GUID(0xfe3a2a5d, 0x4f32, 0x41a7, \
+0xb7, 0x25, 0xac, 0xcc, 0x32, 0x85, 0xa3, 0x09)
+#define PARTITION_CROS_ROOT \
+   EFI_GUID(0x3cb8e202, 0x3b7e, 0x47dd, \
+0x8a, 0x3c, 0x7f, 0xf2, 0xa1, 0x3c, 0xfc, 0xec)
+#define PARTITION_CROS_FIRMWARE \
+   EFI_GUID(0xcab6e88e, 0xabf3, 0x4102, \
+0xa0, 0x7a, 0xd4, 0xbb, 0x9b, 0xe3, 0xc1, 0xd3)
+#define PARTITION_CROS_RESERVED \
+   EFI_GUID(0x2e0a753d, 0x9e48, 0x43b0, \
+0x83, 0x37, 0xb1, 0x51, 0x92, 0xcb, 0x1b, 0x5e)
+
 /* linux/include/efi.h */
 typedef u16 efi_char16_t;
 
diff --git a/lib/uuid.c b/lib/uuid.c
index 3bdb20b0e5b6..afb40bff507a 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -7,6 +7,8 @@
  *   Abdellatif El Khlifi 
  */
 
+#define LOG_CATEGOT LOGC_CORE
+
 #include 
 #include 
 #include 
@@ -61,6 +63,10 @@ static const struct {
{"swap",PARTITION_LINUX_SWAP_GUID},
{"lvm", PARTITION_LINUX_LVM_GUID},
{"u-boot-env",  PARTITION_U_BOOT_ENVIRONMENT},
+   {"cros-kern",   PARTITION_CROS_KERNEL},
+   {"cros-root",   PARTITION_CROS_ROOT},
+   {"cros-fw", PARTITION_CROS_FIRMWARE},
+   {"cros-rsrv",   PARTITION_CROS_RESERVED},
 #endif
 #if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI)
{
@@ -258,6 +264,7 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char 
*uuid_bin,
uint64_t tmp64;
 
if (!uuid_str_valid(uuid_str)) {
+   log_debug("not valid\n");
 #ifdef CONFIG_PARTITION_TYPE_GUID
if (!uuid_guid_get_bin(uuid_str, uuid_bin))
return 0;
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 19/23] part: Add a fallback for part_get_bootable()

2023-08-24 Thread Simon Glass
This function can be called when partition support is disabled. Add a
static inline to handle this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/part.h | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/part.h b/include/part.h
index 16ba8c102535..f321479a5e91 100644
--- a/include/part.h
+++ b/include/part.h
@@ -372,14 +372,6 @@ part_get_info_by_dev_and_name_or_num(const char *dev_iface,
 }
 #endif
 
-/**
- * part_get_bootable() - Find the first bootable partition
- *
- * @desc: Block-device descriptor
- * @return first bootable partition, or 0 if there is none
- */
-int part_get_bootable(struct blk_desc *desc);
-
 struct udevice;
 /**
  * disk_blk_read() - read blocks from a disk partition
@@ -670,12 +662,24 @@ static inline struct part_driver 
*part_driver_get_first(void)
  */
 int part_get_type_by_name(const char *name);
 
+/**
+ * part_get_bootable() - Find the first bootable partition
+ *
+ * @desc: Block-device descriptor
+ * @return first bootable partition, or 0 if there is none
+ */
+int part_get_bootable(struct blk_desc *desc);
+
 #else
 static inline int part_driver_get_count(void)
 { return 0; }
 
 static inline struct part_driver *part_driver_get_first(void)
 { return NULL; }
+
+static inline bool part_get_bootable(struct blk_desc *desc)
+{ return false; }
+
 #endif /* CONFIG_PARTITIONS */
 
 #endif /* _PART_H */
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 20/23] bootstd: Support bootmeths which can scan any partition

2023-08-24 Thread Simon Glass
Some bootmeths support scanning a partition without a filesystem on it.
Add a flag to support this.

This will allow the ChromiumOS bootmeth to find kernel partition, which
are stored in a special format, without a filesystem.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootdev-uclass.c   | 17 ++---
 doc/develop/bootstd.rst | 11 ++-
 include/bootmeth.h  |  3 +++
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index c4044d87dc3e..69506e3865fc 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -111,6 +111,8 @@ int bootdev_bind(struct udevice *parent, const char 
*drv_name, const char *name,
 int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
struct bootflow_iter *iter, struct bootflow *bflow)
 {
+   struct bootmeth_uc_plat *plat = dev_get_uclass_plat(bflow->method);
+   bool allow_any_part = plat->flags & BOOTMETHF_ANY_PART;
struct blk_desc *desc = dev_get_uclass_plat(blk);
struct disk_partition info;
char partstr[20];
@@ -142,6 +144,7 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice 
*blk,
 * us whether there is valid media there
 */
ret = part_get_info(desc, iter->part, );
+   log_debug("part_get_info() returned %d\n", ret);
if (!iter->part && ret == -ENOENT)
ret = 0;
 
@@ -154,7 +157,7 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice 
*blk,
ret = -ESHUTDOWN;
else
bflow->state = BOOTFLOWST_MEDIA;
-   if (ret) {
+   if (ret && !allow_any_part) {
/* allow partition 1 to be missing */
if (iter->part == 1) {
iter->max_part = 3;
@@ -174,9 +177,15 @@ int bootdev_find_in_blk(struct udevice *dev, struct 
udevice *blk,
if (!iter->part) {
iter->first_bootable = part_get_bootable(desc);
log_debug("checking bootable=%d\n", iter->first_bootable);
+   } else if (allow_any_part) {
+   /*
+* allow any partition to be scanned, by skipping any checks
+* for filesystems or partition contents on this disk
+*/
 
/* if there are bootable partitions, scan only those */
-   } else if (iter->first_bootable ? !info.bootable : iter->part != 1) {
+   } else if (iter->first_bootable >= 0 &&
+  (iter->first_bootable ? !info.bootable : iter->part != 1)) {
return log_msg_ret("boot", -EINVAL);
} else {
ret = fs_set_blk_dev_with_part(desc, bflow->part);
@@ -193,6 +202,7 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice 
*blk,
bflow->state = BOOTFLOWST_FS;
}
 
+   log_debug("method %s\n", bflow->method->name);
ret = bootmeth_read_bootflow(bflow->method, bflow);
if (ret)
return log_msg_ret("method", ret);
@@ -559,7 +569,8 @@ int bootdev_get_bootflow(struct udevice *dev, struct 
bootflow_iter *iter,
 {
const struct bootdev_ops *ops = bootdev_get_ops(dev);
 
-   log_debug("->get_bootflow %s=%p\n", dev->name, ops->get_bootflow);
+   log_debug("->get_bootflow %s,%x=%p\n", dev->name, iter->part,
+ ops->get_bootflow);
bootflow_init(bflow, dev, iter->method);
if (!ops->get_bootflow)
return default_get_bootflow(dev, iter, bflow);
diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst
index ec3136535783..c01e0971dc84 100644
--- a/doc/develop/bootstd.rst
+++ b/doc/develop/bootstd.rst
@@ -677,11 +677,12 @@ Assuming the bootmeth is happy, or at least indicates 
that it is willing to try
 partition. If that works it tries to detect a file system. If that works then 
it
 calls the bootmeth device once more, this time to read the bootflow.
 
-Note: At present a filesystem is needed for the bootmeth to be called on block
-devices, simply because we don't have any examples where this is not the case.
-This feature can be added as needed. Note that sandbox is a special case, since
-in that case the host filesystem can be accessed even though the block device
-is NULL.
+Note: Normally a filesystem is needed for the bootmeth to be called on block
+devices, but bootmeths which don't need that can set the BOOTMETHF_ANY_PART
+flag to indicate that they can scan any partition. An example is the ChromiumOS
+bootmeth which can store a kernel in a raw partition. Note also that sandbox is
+a special case, since in that case the host filesystem can be accessed even
+though the block device is NULL.
 
 If we take the example of the `bootmeth_extlinux` driver, this call ends up at
 `extlinux_read_bootflow()`. It has the filesystem ready, so tries various
diff --git a/include/bootmeth.h b/include/bootmeth.h
index d3d8d608cd78..0fc36104ece0 100644
--- a/include/bootmeth.h
+++ 

[PATCH v2 18/23] bootstd: Add a test for bootmeth_cros

2023-08-24 Thread Simon Glass
The ChromiumOS bootmeth has no tests at present. Before adding more
features. add a basic test.

This creates a disk which can be scanned by the bootmeth, so make sure
things work. It is quite rudimentary, since the kernel is faked, the root
disk is missing and there is no cmdline stored.

Enable the bootmeth for snow so it can build the unit test.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/sandbox/dts/test.dts |   9 +++
 configs/snow_defconfig|   1 +
 test/boot/bootflow.c  |  33 -
 test/py/tests/test_ut.py  | 142 ++
 4 files changed, 183 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index f351d5cb84b0..49cc94882229 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -39,6 +39,8 @@
mmc1 = "/mmc1";
mmc2 = "/mmc2";
mmc3 = "/mmc3";
+   mmc4 = "/mmc4";
+   mmc5 = "/mmc5";
pci0 = 
pci1 = 
pci2 = 
@@ -1055,6 +1057,13 @@
filename = "mmc4.img";
};
 
+   /* This is used for ChromiumOS tests */
+   mmc5 {
+   status = "disabled";
+   compatible = "sandbox,mmc";
+   filename = "mmc5.img";
+   };
+
pch {
compatible = "sandbox,pch";
};
diff --git a/configs/snow_defconfig b/configs/snow_defconfig
index bb066a645991..22ec8e5141f6 100644
--- a/configs/snow_defconfig
+++ b/configs/snow_defconfig
@@ -29,6 +29,7 @@ CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 CONFIG_FIT_BEST_MATCH=y
 CONFIG_BOOTSTD_FULL=y
+CONFIG_BOOTMETH_CROS=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SILENT_CONSOLE=y
 CONFIG_BLOBLIST=y
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 54a878c4bd5d..ae34370981cb 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -27,6 +27,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+extern U_BOOT_DRIVER(bootmeth_cros);
 extern U_BOOT_DRIVER(bootmeth_script);
 
 static int inject_response(struct unit_test_state *uts)
@@ -514,7 +515,8 @@ BOOTSTD_TEST(bootflow_cmd_boot, UT_TESTF_DM | 
UT_TESTF_SCAN_FDT);
  * @mmc_dev: MMC device to use, e.g. "mmc4"
  * Returns 0 on success, -ve on failure
  */
-static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev)
+static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
+   bool bind_cros)
 {
const char *order[] = {"mmc2", "mmc1", mmc_dev, NULL};
struct udevice *dev, *bootstd;
@@ -533,6 +535,13 @@ static int prep_mmc_bootdev(struct unit_test_state *uts, 
const char *mmc_dev)
ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_script),
"bootmeth_script", 0, ofnode_null(), ));
 
+   /* Enable the cros bootmeth if needed */
+   if (bind_cros) {
+   ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, ));
+   ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_cros),
+   "cros", 0, ofnode_null(), ));
+   }
+
/* Change the order to include the device */
std = dev_get_priv(bootstd);
old_order = std->bootdev_order;
@@ -556,7 +565,7 @@ static int prep_mmc_bootdev(struct unit_test_state *uts, 
const char *mmc_dev)
  */
 static int prep_mmc4_bootdev(struct unit_test_state *uts)
 {
-   ut_assertok(prep_mmc_bootdev(uts, "mmc4"));
+   ut_assertok(prep_mmc_bootdev(uts, "mmc4", false));
 
return 0;
 }
@@ -963,3 +972,23 @@ static int bootflow_cmdline(struct unit_test_state *uts)
return 0;
 }
 BOOTSTD_TEST(bootflow_cmdline, 0);
+
+/* Test ChromiumOS bootmeth */
+static int bootflow_cros(struct unit_test_state *uts)
+{
+   ut_assertok(prep_mmc_bootdev(uts, "mmc5", true));
+   ut_assertok(run_command("bootflow list", 0));
+
+   ut_assert_nextlinen("Showing all");
+   ut_assert_nextlinen("Seq");
+   ut_assert_nextlinen("---");
+   ut_assert_nextlinen("  0  extlinux");
+   ut_assert_nextlinen("  1  cros ready   mmc  2  
mmc5.bootdev.whole   ");
+   ut_assert_nextlinen("---");
+   ut_assert_skip_to_line("(2 bootflows, 2 valid)");
+
+   ut_assert_console_end();
+
+   return 0;
+}
+BOOTSTD_TEST(bootflow_cros, 0);
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index 3cc41c2ffb13..856eaf1b7f22 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
 
+import collections
 import getpass
 import gzip
 import os
@@ -282,6 +283,146 @@ label Fedora-Workstation-armhfp-31-1.9 
(5.3.7-301.fc31.armv7hl)
 copy_prepared_image(cons, mmc_dev, fname)
 
 
+def setup_cros_image(cons):
+"""Create a 20MB disk image with ChromiumOS partitions"""
+Partition = collections.namedtuple('part', 

[PATCH v2 17/23] bootstd: test: Allow binding and using any mmc device

2023-08-24 Thread Simon Glass
We currently use mmc4 for tests. Update the function which sets this up
so that it can handle any device.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 test/boot/bootflow.c | 28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 649237a9e229..54a878c4bd5d 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -508,21 +508,24 @@ static int bootflow_cmd_boot(struct unit_test_state *uts)
 BOOTSTD_TEST(bootflow_cmd_boot, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
 
 /**
- * prep_mmc4_bootdev() - Set up the mmc4 bootdev so we can access a fake 
Armbian
+ * prep_mmc_bootdev() - Set up an mmc bootdev so we can access other distros
  *
  * @uts: Unit test state
+ * @mmc_dev: MMC device to use, e.g. "mmc4"
  * Returns 0 on success, -ve on failure
  */
-static int prep_mmc4_bootdev(struct unit_test_state *uts)
+static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev)
 {
-   static const char *order[] = {"mmc2", "mmc1", "mmc4", NULL};
+   const char *order[] = {"mmc2", "mmc1", mmc_dev, NULL};
struct udevice *dev, *bootstd;
struct bootstd_priv *std;
const char **old_order;
-   ofnode node;
+   ofnode root, node;
 
/* Enable the mmc4 node since we need a second bootflow */
-   node = ofnode_path("/mmc4");
+   root = oftree_root(oftree_default());
+   node = ofnode_find_subnode(root, mmc_dev);
+   ut_assert(ofnode_valid(node));
ut_assertok(lists_bind_fdt(gd->dm_root, node, , NULL, false));
 
/* Enable the script bootmeth too */
@@ -530,7 +533,7 @@ static int prep_mmc4_bootdev(struct unit_test_state *uts)
ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_script),
"bootmeth_script", 0, ofnode_null(), ));
 
-   /* Change the order to include mmc4 */
+   /* Change the order to include the device */
std = dev_get_priv(bootstd);
old_order = std->bootdev_order;
std->bootdev_order = order;
@@ -545,6 +548,19 @@ static int prep_mmc4_bootdev(struct unit_test_state *uts)
return 0;
 }
 
+/**
+ * prep_mmc4_bootdev() - Set up the mmc4 bootdev so we can access a fake 
Armbian
+ *
+ * @uts: Unit test state
+ * Returns 0 on success, -ve on failure
+ */
+static int prep_mmc4_bootdev(struct unit_test_state *uts)
+{
+   ut_assertok(prep_mmc_bootdev(uts, "mmc4"));
+
+   return 0;
+}
+
 /* Check 'bootflow menu' to select a bootflow */
 static int bootflow_cmd_menu(struct unit_test_state *uts)
 {
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 16/23] bootflow: Show an empty filename when there is none

2023-08-24 Thread Simon Glass
At present 'bootflow list' shows  for the filename when it is not
present. Show an empty string instead, since that is more user-friendly.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/bootflow.c   |  2 +-
 test/boot/bootflow.c | 22 --
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 3c3abaf8a3b2..300ad3aaa760 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -71,7 +71,7 @@ static void show_bootflow(int index, struct bootflow *bflow, 
bool errors)
printf("%3x  %-11s  %-6s  %-9.9s %4x  %-25.25s %s\n", index,
   bflow->method->name, bootflow_state_get_name(bflow->state),
   bflow->dev ? dev_get_uclass_name(dev_get_parent(bflow->dev)) :
-  "(none)", bflow->part, bflow->name, bflow->fname);
+  "(none)", bflow->part, bflow->name, bflow->fname ?: "");
if (errors)
report_bootflow_err(bflow, bflow->err);
 }
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 8a4e090e9bcf..649237a9e229 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -167,21 +167,22 @@ static int bootflow_cmd_scan_e(struct unit_test_state 
*uts)
ut_assert_nextline("Seq  Method   State   UclassPart  Name  
Filename");
ut_assert_nextlinen("---");
ut_assert_nextline("Scanning bootdev 'mmc2.bootdev':");
-   ut_assert_nextline("  0  extlinux media   mmc  0  
mmc2.bootdev.whole");
+   ut_assert_nextline("  0  extlinux media   mmc  0  
mmc2.bootdev.whole");
ut_assert_nextline(" ** No partition found, err=-93: Protocol not 
supported");
-   ut_assert_nextline("  1  efi  media   mmc  0  
mmc2.bootdev.whole");
+   ut_assert_nextline("  1  efi  media   mmc  0  
mmc2.bootdev.whole");
ut_assert_nextline(" ** No partition found, err=-93: Protocol not 
supported");
 
ut_assert_nextline("Scanning bootdev 'mmc1.bootdev':");
-   ut_assert_nextline("  2  extlinux media   mmc  0  
mmc1.bootdev.whole");
+   ut_assert_nextline("  2  extlinux media   mmc  0  
mmc1.bootdev.whole");
ut_assert_nextline(" ** No partition found, err=-2: No such file or 
directory");
-   ut_assert_nextline("  3  efi  media   mmc  0  
mmc1.bootdev.whole");
+   ut_assert_nextline("  3  efi  media   mmc  0  
mmc1.bootdev.whole");
ut_assert_nextline(" ** No partition found, err=-2: No such file or 
directory");
ut_assert_nextline("  4  extlinux ready   mmc  1  
mmc1.bootdev.part_1   /extlinux/extlinux.conf");
ut_assert_nextline("  5  efi  fs  mmc  1  
mmc1.bootdev.part_1   efi/boot/bootsbox.efi");
 
ut_assert_skip_to_line("Scanning bootdev 'mmc0.bootdev':");
-   ut_assert_skip_to_line(" 3f  efi  media   mmc  0  
mmc0.bootdev.whole");
+   ut_assert_skip_to_line(
+   " 3f  efi  media   mmc  0  mmc0.bootdev.whole   
 ");
ut_assert_nextline(" ** No partition found, err=-93: Protocol not 
supported");
ut_assert_nextline("No more bootdevs");
ut_assert_nextlinen("---");
@@ -192,10 +193,11 @@ static int bootflow_cmd_scan_e(struct unit_test_state 
*uts)
ut_assert_nextline("Showing all bootflows");
ut_assert_nextline("Seq  Method   State   UclassPart  Name  
Filename");
ut_assert_nextlinen("---");
-   ut_assert_nextline("  0  extlinux media   mmc  0  
mmc2.bootdev.whole");
-   ut_assert_nextline("  1  efi  media   mmc  0  
mmc2.bootdev.whole");
-   ut_assert_skip_to_line("  4  extlinux ready   mmc  1  
mmc1.bootdev.part_1   /extlinux/extlinux.conf");
-   ut_assert_skip_to_line(" 3f  efi  media   mmc  0  
mmc0.bootdev.whole");
+   ut_assert_nextline("  0  extlinux media   mmc  0  
mmc2.bootdev.whole");
+   ut_assert_nextline("  1  efi  media   mmc  0  
mmc2.bootdev.whole");
+   ut_assert_skip_to_line(
+   "  4  extlinux ready   mmc  1  mmc1.bootdev.part_1  
 /extlinux/extlinux.conf");
+   ut_assert_skip_to_line(" 3f  efi  media   mmc  0  
mmc0.bootdev.whole");
ut_assert_nextlinen("---");
ut_assert_nextline("(64 bootflows, 1 valid)");
ut_assert_console_end();
@@ -384,7 +386,7 @@ static int bootflow_system(struct unit_test_state *uts)
console_record_reset_enable();
ut_assertok(run_command("bootflow scan -lH", 0));
ut_assert_skip_to_line(
-   "  0  efi_mgr  ready   (none)   0 
 ");
+   "  0  

[PATCH v2 13/23] uuid: Move function comments to header file

2023-08-24 Thread Simon Glass
These should be in the header file for easy browsing, not in the source
code. Move them and add a missing Return on one of the functions.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Rebase to -next

 include/uuid.h | 103 +
 lib/uuid.c | 103 -
 2 files changed, 103 insertions(+), 103 deletions(-)

diff --git a/include/uuid.h b/include/uuid.h
index 89b93e642b73..f5a941250f48 100644
--- a/include/uuid.h
+++ b/include/uuid.h
@@ -12,6 +12,51 @@
 
 #include 
 
+/*
+ * UUID - Universally Unique IDentifier - 128 bits unique number.
+ *There are 5 versions and one variant of UUID defined by RFC4122
+ *specification. A UUID contains a set of fields. The set varies
+ *depending on the version of the UUID, as shown below:
+ *- time, MAC address(v1),
+ *- user ID(v2),
+ *- MD5 of name or URL(v3),
+ *- random data(v4),
+ *- SHA-1 of name or URL(v5),
+ *
+ * Layout of UUID:
+ * timestamp - 60-bit: time_low, time_mid, time_hi_and_version
+ * version   - 4 bit (bit 4 through 7 of the time_hi_and_version)
+ * clock seq - 14 bit: clock_seq_hi_and_reserved, clock_seq_low
+ * variant:  - bit 6 and 7 of clock_seq_hi_and_reserved
+ * node  - 48 bit
+ *
+ * source: https://www.ietf.org/rfc/rfc4122.txt
+ *
+ * UUID binary format (16 bytes):
+ *
+ * 4B-2B-2B-2B-6B (big endian - network byte order)
+ *
+ * UUID string is 36 length of characters (36 bytes):
+ *
+ * 0914   19   24
+ * ----
+ *be be   be   be   be
+ *
+ * where x is a hexadecimal character. Fields are separated by '-'s.
+ * When converting to a binary UUID, le means the field should be converted
+ * to little endian and be means it should be converted to big endian.
+ *
+ * UUID is also used as GUID (Globally Unique Identifier) with the same binary
+ * format but it differs in string format like below.
+ *
+ * GUID:
+ * 0914   19   24
+ * ----
+ *le le   le   be   be
+ *
+ * GUID is used e.g. in GPT (GUID Partition Table) as a partiions unique id.
+ */
+
 /* This is structure is in big-endian */
 struct uuid {
unsigned int time_low;
@@ -40,20 +85,78 @@ struct uuid {
 #define UUID_VARIANT   0x1
 
 int uuid_str_valid(const char *uuid);
+
+/*
+ * uuid_str_to_bin() - convert string UUID or GUID to big endian binary data.
+ *
+ * @param uuid_str - pointer to UUID or GUID string [37B] or GUID shorcut
+ * @param uuid_bin - pointer to allocated array for big endian output [16B]
+ * @str_format - UUID string format: 0 - UUID; 1 - GUID
+ * Return: 0 if OK, -EINVAL if the string is not a valid UUID
+ */
 int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
int str_format);
+
+/*
+ * uuid_bin_to_str() - convert big endian binary data to string UUID or GUID.
+ *
+ * @param uuid_bin:pointer to binary data of UUID (big endian) [16B]
+ * @param uuid_str:pointer to allocated array for output string [37B]
+ * @str_format:bit 0: 0 - UUID; 1 - GUID
+ * bit 1: 0 - lower case; 2 - upper case
+ */
 void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str,
 int str_format);
+
+/*
+ * uuid_guid_get_bin() - this function get GUID bin for string
+ *
+ * @param guid_str - pointer to partition type string
+ * @param guid_bin - pointer to allocated array for big endian output [16B]
+ */
 int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
+
+/*
+ * uuid_guid_get_str() - this function get string for GUID.
+ *
+ * @param guid_bin - pointer to string with partition type guid [16B]
+ *
+ * Returns NULL if the type GUID is not known.
+ */
 const char *uuid_guid_get_str(const unsigned char *guid_bin);
+
+/*
+ * gen_rand_uuid() - this function generates a random binary UUID version 4.
+ *   In this version all fields beside 4 bits of version and
+ *   2 bits of variant are randomly generated.
+ *
+ * @param uuid_bin - pointer to allocated array [16B]. Output is in big endian.
+ */
 void gen_rand_uuid(unsigned char *uuid_bin);
+
+/*
+ * gen_rand_uuid_str() - this function generates UUID v4 (random) in two string
+ *   formats UUID or GUID.
+ *
+ * @param uuid_str - pointer to allocated array [37B].
+ * @param  - uuid output type: UUID - 0, GUID - 1
+ */
 void gen_rand_uuid_str(char *uuid_str, int str_format);
 
 /**
  * uuid_str_to_le_bin() - Convert string UUID to little endian binary data.
  * @uuid_str:  pointer to UUID string
  * @uuid_bin:  pointer to allocated array for little endian output [16B]
+ *
+ * UUID string is 36 characters (36 bytes):
+ *
+ * ----
+ *
+ * where x is a hexadecimal character. Fields are separated by '-'s.
+ * When converting to a little endian binary UUID, the 

[PATCH v2 15/23] test: Move 1MB.fat32.img and 2MB.ext2.img

2023-08-24 Thread Simon Glass
These are currently created in the source directory, which is not ideal.
Move them to the persistent-data directory instead. Update the test so
skip validating the filename, since it now includes a full path.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 test/dm/host.c | 44 ++
 test/py/tests/fs_helper.py |  6 ++
 test/py/tests/test_ut.py   |  6 ++
 3 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/test/dm/host.c b/test/dm/host.c
index 355ba7770afa..85f21f9839e2 100644
--- a/test/dm/host.c
+++ b/test/dm/host.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -15,9 +16,6 @@
 #include 
 #include 
 
-static const char filename[] = "2MB.ext2.img";
-static const char filename2[] = "1MB.fat32.img";
-
 /* Basic test of host interface */
 static int dm_test_host(struct unit_test_state *uts)
 {
@@ -25,6 +23,7 @@ static int dm_test_host(struct unit_test_state *uts)
struct udevice *dev, *part, *chk, *blk;
struct host_sb_plat *plat;
struct blk_desc *desc;
+   char fname[256];
ulong mem_start;
loff_t actwrite;
 
@@ -40,13 +39,15 @@ static int dm_test_host(struct unit_test_state *uts)
ut_assert(label != plat->label);
ut_asserteq(0, plat->fd);
 
-   /* Attach a file created in test_host.py */
-   ut_assertok(host_attach_file(dev, filename));
+   /* Attach a file created in test_ut_dm_init */
+   ut_assertok(os_persistent_file(fname, sizeof(fname), "2MB.ext2.img"));
+
+   ut_assertok(host_attach_file(dev, fname));
ut_assertok(uclass_first_device_err(UCLASS_HOST, ));
ut_asserteq_ptr(chk, dev);
 
-   ut_asserteq_str(filename, plat->filename);
-   ut_assert(filename != plat->filename);
+   ut_asserteq_str(fname, plat->filename);
+   ut_assert(fname != plat->filename);
ut_assert(plat->fd != 0);
 
/* Get the block device */
@@ -79,12 +80,14 @@ static int dm_test_host_dup(struct unit_test_state *uts)
 {
static char label[] = "test";
struct udevice *dev, *chk;
+   char fname[256];
 
ut_asserteq(0, uclass_id_count(UCLASS_HOST));
ut_assertok(host_create_device(label, true, ));
 
-   /* Attach a file created in test_host.py */
-   ut_assertok(host_attach_file(dev, filename));
+   /* Attach a file created in test_ut_dm_init */
+   ut_assertok(os_persistent_file(fname, sizeof(fname), "2MB.ext2.img"));
+   ut_assertok(host_attach_file(dev, fname));
ut_assertok(uclass_first_device_err(UCLASS_HOST, ));
ut_asserteq_ptr(chk, dev);
ut_asserteq(1, uclass_id_count(UCLASS_HOST));
@@ -92,8 +95,10 @@ static int dm_test_host_dup(struct unit_test_state *uts)
/* Create another device with the same label (should remove old one) */
ut_assertok(host_create_device(label, true, ));
 
-   /* Attach a different file created in test_host.py */
-   ut_assertok(host_attach_file(dev, filename2));
+   /* Attach a different file created in test_ut_dm_init */
+   ut_assertok(os_persistent_file(fname, sizeof(fname), "1MB.fat32.img"));
+   ut_assertok(host_attach_file(dev, fname));
+
ut_assertok(uclass_first_device_err(UCLASS_HOST, ));
ut_asserteq_ptr(chk, dev);
 
@@ -109,6 +114,7 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
 {
struct udevice *dev, *blk;
struct blk_desc *desc;
+   char fname[256];
 
console_record_reset();
 
@@ -117,7 +123,8 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
ut_assert_nextline("dev   blocks label   path");
ut_assert_console_end();
 
-   ut_assertok(run_commandf("host bind -r test2 %s", filename));
+   ut_assertok(os_persistent_file(fname, sizeof(fname), "2MB.ext2.img"));
+   ut_assertok(run_commandf("host bind -r test2 %s", fname));
 
/* Check the -r flag worked */
ut_assertok(uclass_first_device_err(UCLASS_HOST, ));
@@ -127,10 +134,11 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
 
ut_assertok(run_command("host info", 0));
ut_assert_nextline("dev   blocks label   path");
-   ut_assert_nextline("  0 4096 test2   2MB.ext2.img");
+   ut_assert_nextlinen("  0 4096 test2");
ut_assert_console_end();
 
-   ut_assertok(run_commandf("host bind fat %s", filename2));
+   ut_assertok(os_persistent_file(fname, sizeof(fname), "1MB.fat32.img"));
+   ut_assertok(run_commandf("host bind fat %s", fname));
 
/* Check it is not removable (no '-r') */
ut_assertok(uclass_next_device_err());
@@ -140,8 +148,8 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
 
ut_assertok(run_command("host info", 0));
ut_assert_nextline("dev   blocks label   path");
-   ut_assert_nextline("  0 4096 test2   

[PATCH v2 14/23] sandbox: Add a way to access persistent test files

2023-08-24 Thread Simon Glass
Some pytests create files in the persistent-data directory. It is useful
to be able to access these files in C tests. Add a function which can
locate a file given its leaf name, using the environment variable set
up in test/py/conftest.py

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/sandbox/cpu/os.c | 24 
 include/os.h  | 10 ++
 2 files changed, 34 insertions(+)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 9e93a0fa571f..85d0d6a17035 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -258,6 +258,30 @@ int os_unmap(void *buf, int size)
return 0;
 }
 
+int os_persistent_file(char *buf, int maxsize, const char *fname)
+{
+   const char *dirname = getenv("U_BOOT_PERSISTENT_DATA_DIR");
+   char *ptr;
+   int len;
+
+   len = strlen(fname) + (dirname ? strlen(dirname) + 1 : 0) + 1;
+   if (len > maxsize)
+   return -ENOSPC;
+
+   ptr = buf;
+   if (dirname) {
+   strcpy(ptr, dirname);
+   ptr += strlen(dirname);
+   *ptr++ = '/';
+   }
+   strcpy(ptr, fname);
+
+   if (access(buf, F_OK) == -1)
+   return -ENOENT;
+
+   return 0;
+}
+
 /* Restore tty state when we exit */
 static struct termios orig_term;
 static bool term_setup;
diff --git a/include/os.h b/include/os.h
index 968412b0a822..fc8a1b15cbf0 100644
--- a/include/os.h
+++ b/include/os.h
@@ -98,6 +98,16 @@ int os_close(int fd);
  */
 int os_unlink(const char *pathname);
 
+/** os_persistent_fname() - Find the path to a test file
+ *
+ * @buf: Buffer to hold path
+ * @maxsize: Maximum size of buffer
+ * @fname: Leaf filename to find
+ * Returns: 0 on success, -ENOENT if file is not found, -ENOSPC if the buffer 
is
+ * too small
+ */
+int os_persistent_file(char *buf, int maxsize, const char *fname);
+
 /**
  * os_exit() - access to the OS exit() system call
  *
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 12/23] dm: core: Correct error handling when event fails

2023-08-24 Thread Simon Glass
Follow the correct path in device_probe() when and event handler fails.
This avoids getting into a strange state where the device appears to be
activated but is not.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/core/device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 6e26b64fb812..60f8d6700ad4 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -598,9 +598,10 @@ int device_probe(struct udevice *dev)
 
ret = device_notify(dev, EVT_DM_POST_PROBE);
if (ret)
-   return ret;
+   goto fail_event;
 
return 0;
+fail_event:
 fail_uclass:
if (device_remove(dev, DM_REMOVE_NORMAL)) {
dm_warn("%s: Device '%s' failed to remove on error path\n",
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 11/23] part: efi: Add debugging for the signature check

2023-08-24 Thread Simon Glass
Add a little more debugging for the initial signature check. Drop the
pointless check for NULL. Also set a log category while we are here.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part_efi.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 208675213822..39382c5faee0 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -9,6 +9,9 @@
  *   when CONFIG_SYS_64BIT_LBA is not defined, lbaint_t is 32 bits; this
  *   limits the maximum size of addressable storage to < 2 tebibytes
  */
+
+#define LOG_CATEGORY LOGC_FS
+
 #include 
 #include 
 #include 
@@ -976,17 +979,23 @@ static int pmbr_part_valid(struct partition *part)
 /*
  * is_pmbr_valid(): test Protective MBR for validity
  *
+ * @mbr: Pointer to Master Boot-Record data
+ *
  * Returns: 1 if PMBR is valid, 0 otherwise.
  * Validity depends on two things:
  *  1) MSDOS signature is in the last two bytes of the MBR
  *  2) One partition of type 0xEE is found, checked by pmbr_part_valid()
  */
-static int is_pmbr_valid(legacy_mbr * mbr)
+static int is_pmbr_valid(legacy_mbr *mbr)
 {
+   uint sig = le16_to_cpu(mbr->signature);
int i = 0;
 
-   if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE)
+   if (sig != MSDOS_MBR_SIGNATURE) {
+   log_debug("Invalid signature %x\n", sig);
return 0;
+   }
+   log_debug("Signature %x valid\n", sig);
 
for (i = 0; i < 4; i++) {
if (pmbr_part_valid(>partition_record[i])) {
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 10/23] part: Add an accessor for struct disk_partition sys_ind

2023-08-24 Thread Simon Glass
This field is only present when a CONFIG is set. To avoid annoying #ifdefs
in the source code, add an accessor. Update the only usage.

Note that the accessor is optional. It can be omitted if it is known that
the option is enabled.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootdev-uclass.c |  7 +++
 include/part.h| 12 
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index fa52bc3a9c4e..c4044d87dc3e 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -184,12 +184,11 @@ int bootdev_find_in_blk(struct udevice *dev, struct 
udevice *blk,
if (ret)
return log_msg_ret("fs", ret);
 
-   /* Use an #ifdef due to info.sys_ind */
-#ifdef CONFIG_DOS_PARTITION
log_debug("%s: Found partition %x type %x fstype %d\n",
- blk->name, bflow->part, info.sys_ind,
+ blk->name, bflow->part,
+ IS_ENABLED(CONFIG_DOS_PARTITION) ?
+ disk_partition_sys_ind() : 0,
  ret ? -1 : fs_get_type());
-#endif
bflow->blk = blk;
bflow->state = BOOTFLOWST_FS;
}
diff --git a/include/part.h b/include/part.h
index 5cf1c5ec96f0..16ba8c102535 100644
--- a/include/part.h
+++ b/include/part.h
@@ -135,6 +135,18 @@ static inline void disk_partition_clr_type_guid(struct 
disk_partition *info)
 #endif
 }
 
+/* Accessors for struct disk_partition field ->sys_ind */
+extern int __invalid_use_of_disk_partition_sys_ind;
+
+static inline uint disk_partition_sys_ind(const struct disk_partition *info)
+{
+#ifdef CONFIG_DOS_PARTITION
+   return info->sys_ind;
+#else
+   return __invalid_use_of_disk_partition_sys_ind;
+#endif
+}
+
 struct disk_part {
int partnum;
struct disk_partition gpt_part_info;
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 09/23] part: Add accessors for struct disk_partition type_uuid

2023-08-24 Thread Simon Glass
This field is only present when a CONFIG is set. To avoid annoying #ifdefs
in the source code, add accessors. Update all code to use it.

Note that the accessor is optional. It can be omitted if it is known that
the option is enabled.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part.c |  8 ++--
 disk/part_efi.c |  9 +
 include/part.h  | 28 
 3 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 91c6ac42cc83..72241b7b232c 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -370,9 +370,7 @@ int part_get_info_by_type(struct blk_desc *desc, int part, 
int part_type,
if (blk_enabled()) {
/* The common case is no UUID support */
disk_partition_clr_uuid(info);
-#ifdef CONFIG_PARTITION_TYPE_GUID
-   info->type_guid[0] = 0;
-#endif
+   disk_partition_clr_type_guid(info);
 
if (part_type == PART_TYPE_UNKNOWN) {
drv = part_driver_lookup_type(desc);
@@ -415,9 +413,7 @@ int part_get_info_whole_disk(struct blk_desc *desc,
strcpy((char *)info->type, BOOT_PART_TYPE);
strcpy((char *)info->name, "Whole Disk");
disk_partition_clr_uuid(info);
-#ifdef CONFIG_PARTITION_TYPE_GUID
-   info->type_guid[0] = 0;
-#endif
+   disk_partition_clr_type_guid(info);
 
return 0;
 }
diff --git a/disk/part_efi.c b/disk/part_efi.c
index a6f7375cd38a..208675213822 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -294,10 +294,11 @@ int part_get_info_efi(struct blk_desc *desc, int part,
(char *)disk_partition_uuid(info),
UUID_STR_FORMAT_GUID);
}
-#ifdef CONFIG_PARTITION_TYPE_GUID
-   uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b,
-   info->type_guid, UUID_STR_FORMAT_GUID);
-#endif
+   if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) {
+   uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b,
+   (char *)disk_partition_type_uuid(info),
+   UUID_STR_FORMAT_GUID);
+   }
 
log_debug("start 0x" LBAF ", size 0x" LBAF ", name %s\n", info->start,
  info->size, info->name);
diff --git a/include/part.h b/include/part.h
index 8e5e543c56ec..5cf1c5ec96f0 100644
--- a/include/part.h
+++ b/include/part.h
@@ -107,6 +107,34 @@ static inline void disk_partition_clr_uuid(struct 
disk_partition *info)
 #endif
 }
 
+/* Accessors for struct disk_partition field ->type_guid */
+extern char *__invalid_use_of_disk_partition_type_uuid;
+
+static inline const
+char *disk_partition_type_uuid(const struct disk_partition *info)
+{
+#ifdef CONFIG_PARTITION_TYPE_GUID
+   return info->type_guid;
+#else
+   return __invalid_use_of_disk_partition_type_uuid;
+#endif
+}
+
+static inline void disk_partition_set_type_guid(struct disk_partition *info,
+   const char *val)
+{
+#ifdef CONFIG_PARTITION_TYPE_GUID
+   strlcpy(info->type_guid, val, UUID_STR_LEN + 1);
+#endif
+}
+
+static inline void disk_partition_clr_type_guid(struct disk_partition *info)
+{
+#ifdef CONFIG_PARTITION_TYPE_GUID
+   *info->type_guid = '\0';
+#endif
+}
+
 struct disk_part {
int partnum;
struct disk_partition gpt_part_info;
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 08/23] part: Add accessors for struct disk_partition uuid

2023-08-24 Thread Simon Glass
This field is only present when a CONFIG is set. To avoid annoying #ifdefs
in the source code, add accessors. Update all code to use it.

Note that the accessor is optional. It can be omitted if it is known that
the option is enabled.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/gpt.c   | 10 --
 disk/part.c |  8 ++--
 disk/part_dos.c | 17 -
 disk/part_efi.c | 31 ---
 fs/fat/fat.c|  4 +---
 include/part.h  | 27 +++
 6 files changed, 58 insertions(+), 39 deletions(-)

diff --git a/cmd/gpt.c b/cmd/gpt.c
index 007a68eaa72a..8969efba8c80 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -211,12 +211,10 @@ static struct disk_part *allocate_disk_part(struct 
disk_partition *info,
PART_TYPE_LEN);
newpart->gpt_part_info.type[PART_TYPE_LEN - 1] = '\0';
newpart->gpt_part_info.bootable = info->bootable;
-#ifdef CONFIG_PARTITION_UUIDS
-   strncpy(newpart->gpt_part_info.uuid, (const char *)info->uuid,
-   UUID_STR_LEN);
-   /* UUID_STR_LEN is correct, as uuid[]'s length is UUID_STR_LEN+1 chars 
*/
-   newpart->gpt_part_info.uuid[UUID_STR_LEN] = '\0';
-#endif
+   if (IS_ENABLED(CONFIG_PARTITION_UUIDS)) {
+   strlcpy(newpart->gpt_part_info.uuid, disk_partition_uuid(info),
+   UUID_STR_LEN + 1);
+   }
newpart->partnum = partnum;
 
return newpart;
diff --git a/disk/part.c b/disk/part.c
index 9190e8806187..91c6ac42cc83 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -368,10 +368,8 @@ int part_get_info_by_type(struct blk_desc *desc, int part, 
int part_type,
struct part_driver *drv;
 
if (blk_enabled()) {
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
/* The common case is no UUID support */
-   info->uuid[0] = 0;
-#endif
+   disk_partition_clr_uuid(info);
 #ifdef CONFIG_PARTITION_TYPE_GUID
info->type_guid[0] = 0;
 #endif
@@ -416,9 +414,7 @@ int part_get_info_whole_disk(struct blk_desc *desc,
info->bootable = 0;
strcpy((char *)info->type, BOOT_PART_TYPE);
strcpy((char *)info->name, "Whole Disk");
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
-   info->uuid[0] = 0;
-#endif
+   disk_partition_clr_uuid(info);
 #ifdef CONFIG_PARTITION_TYPE_GUID
info->type_guid[0] = 0;
 #endif
diff --git a/disk/part_dos.c b/disk/part_dos.c
index cc050ca8c49f..33374384373a 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -231,10 +231,8 @@ static int part_get_info_extended(struct blk_desc *desc,
return -1;
}
 
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
-   if (!ext_part_sector)
+   if (CONFIG_IS_ENABLED(PARTITION_UUIDS) && !ext_part_sector)
disksig = get_unaligned_le32([DOS_PART_DISKSIG_OFFSET]);
-#endif
 
ret = part_get_info_whole_disk(desc, );
if (ret)
@@ -263,9 +261,12 @@ static int part_get_info_extended(struct blk_desc *desc,
/* sprintf(info->type, "%d, pt->sys_ind); */
strcpy((char *)info->type, "U-Boot");
info->bootable = get_bootable(pt);
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
-   sprintf(info->uuid, "%08x-%02x", disksig, part_num);
-#endif
+   if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) {
+   char str[12];
+
+   sprintf(str, "%08x-%02x", disksig, part_num);
+   disk_partition_set_uuid(info, str);
+   }
info->sys_ind = pt->sys_ind;
return 0;
}
@@ -302,9 +303,7 @@ static int part_get_info_extended(struct blk_desc *desc,
info->blksz = DOS_PART_DEFAULT_SECTOR;
info->bootable = 0;
strcpy((char *)info->type, "U-Boot");
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
-   info->uuid[0] = 0;
-#endif
+   disk_partition_clr_uuid(info);
return 0;
}
 
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 4ac21868d088..a6f7375cd38a 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -289,10 +289,11 @@ int part_get_info_efi(struct blk_desc *desc, int part,
 print_efiname(_pte[part - 1]));
strcpy((char *)info->type, "U-Boot");
info->bootable = get_bootable(_pte[part - 1]);
-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
-   uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b, info->uuid,
-   UUID_STR_FORMAT_GUID);
-#endif
+   if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) {
+   uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b,
+   (char *)disk_partition_uuid(info),
+   UUID_STR_FORMAT_GUID);
+   }
 #ifdef CONFIG_PARTITION_TYPE_GUID
uuid_bin_to_str(gpt_pte[part - 

[PATCH v2 07/23] part: Add comments for static functions

2023-08-24 Thread Simon Glass
Some internal functions could do with a few comments, to explain what they
do. Add these, to make the code easier to follow.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/disk/part.c b/disk/part.c
index 8035dcb8a429..9190e8806187 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -26,6 +26,12 @@
 /* Check all partition types */
 #define PART_TYPE_ALL  -1
 
+/**
+ * part_driver_get_type() - Get a driver given its type
+ *
+ * @part_type: Partition type to find the driver for
+ * Return: Driver for that type, or NULL if none
+ */
 static struct part_driver *part_driver_get_type(int part_type)
 {
struct part_driver *drv =
@@ -42,6 +48,22 @@ static struct part_driver *part_driver_get_type(int 
part_type)
return NULL;
 }
 
+/**
+ * part_driver_lookup_type() - Look up the partition driver for a blk device
+ *
+ * If @desc->part_type is PART_TYPE_UNKNOWN, this checks each parition driver
+ * against the blk device to see if there is a valid partition table acceptable
+ * to that driver.
+ *
+ * If @desc->part_type is already set, it just returns the driver for that
+ * type, without testing if the driver can find a valid partition on the
+ * descriptor.
+ *
+ * On success it updates @desc->part_type if set to PART_TYPE_UNKNOWN on entry
+ *
+ * @dev_desc: Device descriptor
+ * Return: Driver found, or NULL if none
+ */
 static struct part_driver *part_driver_lookup_type(struct blk_desc *desc)
 {
struct part_driver *drv =
@@ -83,6 +105,16 @@ int part_get_type_by_name(const char *name)
return PART_TYPE_UNKNOWN;
 }
 
+/**
+ * get_dev_hwpart() - Get the descriptor for a device with hardware partitions
+ *
+ * @ifname:Interface name (e.g. "ide", "scsi")
+ * @dev:   Device number (0 for first device on that interface, 1 for
+ * second, etc.
+ * @hwpart: Hardware partition, or 0 if none (used for MMC)
+ * Return: pointer to the block device, or NULL if not available, or an
+ *error occurred.
+ */
 static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
 {
struct blk_desc *desc;
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH v2 04/23] part: efi: Use desc instead of dev_desc

2023-08-24 Thread Simon Glass
The dev_ prefix is a hangover from the pre-driver model days. The device
is now a different thing, with driver model. Update the efi code to
just use 'desc'.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part_efi.c | 228 
 1 file changed, 112 insertions(+), 116 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 80a44dc9f072..4ac21868d088 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -51,12 +51,12 @@ static inline u32 efi_crc32(const void *buf, u32 len)
 
 static int pmbr_part_valid(struct partition *part);
 static int is_pmbr_valid(legacy_mbr * mbr);
-static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
-   gpt_header *pgpt_head, gpt_entry **pgpt_pte);
-static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
+static int is_gpt_valid(struct blk_desc *desc, u64 lba, gpt_header *pgpt_head,
+   gpt_entry **pgpt_pte);
+static gpt_entry *alloc_read_gpt_entries(struct blk_desc *desc,
 gpt_header *pgpt_head);
 static int is_pte_valid(gpt_entry * pte);
-static int find_valid_gpt(struct blk_desc *dev_desc, gpt_header *gpt_head,
+static int find_valid_gpt(struct blk_desc *desc, gpt_header *gpt_head,
  gpt_entry **pgpt_pte);
 
 static char *print_efiname(gpt_entry *pte)
@@ -195,14 +195,14 @@ static void prepare_backup_gpt_header(gpt_header *gpt_h)
  * UUID is displayed as 32 hexadecimal digits, in 5 groups,
  * separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters
  */
-int get_disk_guid(struct blk_desc * dev_desc, char *guid)
+int get_disk_guid(struct blk_desc *desc, char *guid)
 {
-   ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
+   ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, desc->blksz);
gpt_entry *gpt_pte = NULL;
unsigned char *guid_bin;
 
/* This function validates AND fills in the GPT header and PTE */
-   if (find_valid_gpt(dev_desc, gpt_head, _pte) != 1)
+   if (find_valid_gpt(desc, gpt_head, _pte) != 1)
return -EINVAL;
 
guid_bin = gpt_head->disk_guid.b;
@@ -213,15 +213,15 @@ int get_disk_guid(struct blk_desc * dev_desc, char *guid)
return 0;
 }
 
-void part_print_efi(struct blk_desc *dev_desc)
+void part_print_efi(struct blk_desc *desc)
 {
-   ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
+   ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, desc->blksz);
gpt_entry *gpt_pte = NULL;
int i = 0;
unsigned char *uuid;
 
/* This function validates AND fills in the GPT header and PTE */
-   if (find_valid_gpt(dev_desc, gpt_head, _pte) != 1)
+   if (find_valid_gpt(desc, gpt_head, _pte) != 1)
return;
 
debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
@@ -255,10 +255,10 @@ void part_print_efi(struct blk_desc *dev_desc)
return;
 }
 
-int part_get_info_efi(struct blk_desc *dev_desc, int part,
+int part_get_info_efi(struct blk_desc *desc, int part,
  struct disk_partition *info)
 {
-   ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
+   ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, desc->blksz);
gpt_entry *gpt_pte = NULL;
 
/* "part" argument must be at least 1 */
@@ -268,7 +268,7 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
}
 
/* This function validates AND fills in the GPT header and PTE */
-   if (find_valid_gpt(dev_desc, gpt_head, _pte) != 1)
+   if (find_valid_gpt(desc, gpt_head, _pte) != 1)
return -EINVAL;
 
if (part > le32_to_cpu(gpt_head->num_partition_entries) ||
@@ -283,7 +283,7 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
/* The ending LBA is inclusive, to calculate size, add 1 to it */
info->size = (lbaint_t)le64_to_cpu(gpt_pte[part - 1].ending_lba) + 1
 - info->start;
-   info->blksz = dev_desc->blksz;
+   info->blksz = desc->blksz;
 
snprintf((char *)info->name, sizeof(info->name), "%s",
 print_efiname(_pte[part - 1]));
@@ -306,12 +306,12 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
return 0;
 }
 
-static int part_test_efi(struct blk_desc *dev_desc)
+static int part_test_efi(struct blk_desc *desc)
 {
-   ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc->blksz);
+   ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, desc->blksz);
 
/* Read legacy MBR from block 0 and validate it */
-   if ((blk_dread(dev_desc, 0, 1, (ulong *)legacymbr) != 1)
+   if ((blk_dread(desc, 0, 1, (ulong *)legacymbr) != 1)
|| (is_pmbr_valid(legacymbr) != 1)) {
return -1;
}
@@ -320,23 +320,23 @@ static int part_test_efi(struct blk_desc *dev_desc)
 
 

[PATCH v2 05/23] part: iso: Use desc instead of dev_desc

2023-08-24 Thread Simon Glass
The dev_ prefix is a hangover from the pre-driver model days. The device
is now a different thing, with driver model. Update the iso code to
just use 'desc'.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part_iso.c | 52 -
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/disk/part_iso.c b/disk/part_iso.c
index 4cd619bf46d3..6ac6d95be921 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -46,7 +46,7 @@ unsigned long iso_dread(struct blk_desc *block_dev, lbaint_t 
start,
 }
 
 /* only boot records will be listed as valid partitions */
-int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
+int part_get_info_iso_verb(struct blk_desc *desc, int part_num,
   struct disk_partition *info, int verb)
 {
int i,offset,entry_num;
@@ -58,23 +58,23 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int 
part_num,
iso_val_entry_t *pve = (iso_val_entry_t *)tmpbuf;
iso_init_def_entry_t *pide;
 
-   if ((dev_desc->blksz != CD_SECTSIZE) && (dev_desc->blksz != 512))
+   if (desc->blksz != CD_SECTSIZE && desc->blksz != 512)
return -1;
 
/* the first sector (sector 0x10) must be a primary volume desc */
blkaddr=PVD_OFFSET;
-   if (iso_dread(dev_desc, PVD_OFFSET, 1, (ulong *)tmpbuf) != 1)
+   if (iso_dread(desc, PVD_OFFSET, 1, (ulong *)tmpbuf) != 1)
return -1;
if(ppr->desctype!=0x01) {
if(verb)
printf ("** First descriptor is NOT a primary desc on 
%d:%d **\n",
-   dev_desc->devnum, part_num);
+   desc->devnum, part_num);
return (-1);
}
if(strncmp((char *)ppr->stand_ident,"CD001",5)!=0) {
if(verb)
printf ("** Wrong ISO Ident: %s on %d:%d **\n",
-   ppr->stand_ident, dev_desc->devnum, part_num);
+   ppr->stand_ident, desc->devnum, part_num);
return (-1);
}
lastsect = le32_to_cpu(ppr->firstsek_LEpathtab1_LE);
@@ -83,14 +83,14 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int 
part_num,
PRINTF(" Lastsect:%08lx\n",lastsect);
for(i=blkaddr;idesctype==0x00)
break; /* boot entry found */
if(ppr->desctype==0xff) {
if(verb)
printf ("** No valid boot catalog found on 
%d:%d **\n",
-   dev_desc->devnum, part_num);
+   desc->devnum, part_num);
return (-1);
}
}
@@ -98,15 +98,15 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int 
part_num,
if(strncmp(pbr->ident_str,"EL TORITO SPECIFICATION",23)!=0) {
if(verb)
printf ("** Wrong El Torito ident: %s on %d:%d **\n",
-   pbr->ident_str, dev_desc->devnum, part_num);
+   pbr->ident_str, desc->devnum, part_num);
return (-1);
}
bootaddr = get_unaligned_le32(pbr->pointer);
PRINTF(" Boot Entry at: %08lX\n",bootaddr);
-   if (iso_dread(dev_desc, bootaddr, 1, (ulong *)tmpbuf) != 1) {
+   if (iso_dread(desc, bootaddr, 1, (ulong *)tmpbuf) != 1) {
if(verb)
printf ("** Can't read Boot Entry at %lX on %d:%d **\n",
-   bootaddr, dev_desc->devnum, part_num);
+   bootaddr, desc->devnum, part_num);
return (-1);
}
chksum=0;
@@ -116,20 +116,20 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int 
part_num,
if(chksum!=0) {
if(verb)
printf("** Checksum Error in booting catalog validation 
entry on %d:%d **\n",
-  dev_desc->devnum, part_num);
+  desc->devnum, part_num);
return (-1);
}
if((pve->key[0]!=0x55)||(pve->key[1]!=0xAA)) {
if(verb)
printf ("** Key 0x55 0xAA error on %d:%d **\n",
-   dev_desc->devnum, part_num);
+   desc->devnum, part_num);
return(-1);
}
 #ifdef CHECK_FOR_POWERPC_PLATTFORM
if(pve->platform!=0x01) {
if(verb)
printf ("** No PowerPC platform CD on %d:%d **\n",
-   dev_desc->devnum, part_num);
+   desc->devnum, part_num);
return(-1);
}
 #endif
@@ -137,7 +137,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int 
part_num,
entry_num=1;
offset=0x20;
strcpy((char *)info->type, "U-Boot");
-

[PATCH v2 06/23] part: nac: Use desc instead of dev_desc

2023-08-24 Thread Simon Glass
The dev_ prefix is a hangover from the pre-driver model days. The device
is now a different thing, with driver model. Update the mac code to
just use 'desc'.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part_mac.c | 59 ++---
 1 file changed, 27 insertions(+), 32 deletions(-)

diff --git a/disk/part_mac.c b/disk/part_mac.c
index ae8263f755ae..db5e203be592 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -31,21 +31,20 @@ extern ldiv_t ldiv (long int __numer, long int __denom);
 #endif
 
 
-static int part_mac_read_ddb(struct blk_desc *dev_desc,
-mac_driver_desc_t *ddb_p);
-static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
+static int part_mac_read_ddb(struct blk_desc *desc, mac_driver_desc_t *ddb_p);
+static int part_mac_read_pdb(struct blk_desc *desc, int part,
 mac_partition_t *pdb_p);
 
 /*
  * Test for a valid MAC partition
  */
-static int part_test_mac(struct blk_desc *dev_desc)
+static int part_test_mac(struct blk_desc *desc)
 {
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1);
ulong i, n;
 
-   if (part_mac_read_ddb (dev_desc, ddesc)) {
+   if (part_mac_read_ddb(desc, ddesc)) {
/*
 * error reading Driver Descriptor Block,
 * or no valid Signature
@@ -55,8 +54,8 @@ static int part_test_mac(struct blk_desc *dev_desc)
 
n = 1;  /* assuming at least one partition */
for (i=1; i<=n; ++i) {
-   if ((blk_dread(dev_desc, i, 1, (ulong *)mpart) != 1) ||
-   (mpart->signature != MAC_PARTITION_MAGIC) ) {
+   if ((blk_dread(desc, i, 1, (ulong *)mpart) != 1) ||
+   mpart->signature != MAC_PARTITION_MAGIC) {
return (-1);
}
/* update partition count */
@@ -65,14 +64,14 @@ static int part_test_mac(struct blk_desc *dev_desc)
return (0);
 }
 
-static void part_print_mac(struct blk_desc *dev_desc)
+static void part_print_mac(struct blk_desc *desc)
 {
ulong i, n;
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1);
ldiv_t mb, gb;
 
-   if (part_mac_read_ddb (dev_desc, ddesc)) {
+   if (part_mac_read_ddb(desc, ddesc)) {
/*
 * error reading Driver Descriptor Block,
 * or no valid Signature
@@ -110,15 +109,15 @@ static void part_print_mac(struct blk_desc *dev_desc)
char c;
 
printf ("%4ld: ", i);
-   if (blk_dread(dev_desc, i, 1, (ulong *)mpart) != 1) {
+   if (blk_dread(desc, i, 1, (ulong *)mpart) != 1) {
printf ("** Can't read Partition Map on %d:%ld **\n",
-   dev_desc->devnum, i);
+   desc->devnum, i);
return;
}
 
if (mpart->signature != MAC_PARTITION_MAGIC) {
printf("** Bad Signature on %d:%ld - expected 0x%04x, 
got 0x%04x\n",
-  dev_desc->devnum, i, MAC_PARTITION_MAGIC,
+  desc->devnum, i, MAC_PARTITION_MAGIC,
   mpart->signature);
return;
}
@@ -154,10 +153,9 @@ static void part_print_mac(struct blk_desc *dev_desc)
 /*
  * Read Device Descriptor Block
  */
-static int part_mac_read_ddb(struct blk_desc *dev_desc,
-mac_driver_desc_t *ddb_p)
+static int part_mac_read_ddb(struct blk_desc *desc, mac_driver_desc_t *ddb_p)
 {
-   if (blk_dread(dev_desc, 0, 1, (ulong *)ddb_p) != 1) {
+   if (blk_dread(desc, 0, 1, (ulong *)ddb_p) != 1) {
debug("** Can't read Driver Descriptor Block **\n");
return (-1);
}
@@ -171,7 +169,7 @@ static int part_mac_read_ddb(struct blk_desc *dev_desc,
 /*
  * Read Partition Descriptor Block
  */
-static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
+static int part_mac_read_pdb(struct blk_desc *desc, int part,
 mac_partition_t *pdb_p)
 {
int n = 1;
@@ -182,15 +180,15 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, 
int part,
 * partition 1 first since this is the only way to
 * know how many partitions we have.
 */
-   if (blk_dread(dev_desc, n, 1, (ulong *)pdb_p) != 1) {
-   printf ("** Can't read Partition Map on %d:%d **\n",
-   dev_desc->devnum, n);
+   if (blk_dread(desc, n, 1, (ulong *)pdb_p) != 1) {
+   printf("** Can't read Partition Map on %d:%d **\n",
+  desc->devnum, n);
return (-1);
   

[PATCH v2 03/23] part: dos: Use desc instead of dev_desc

2023-08-24 Thread Simon Glass
The dev_ prefix is a hangover from the pre-driver model days. The device
is now a different thing, with driver model. Update the dos code to
just use 'desc'.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Rebase to -next

 disk/part_dos.c | 63 -
 1 file changed, 31 insertions(+), 32 deletions(-)

diff --git a/disk/part_dos.c b/disk/part_dos.c
index 1b81297d967f..cc050ca8c49f 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -98,27 +98,26 @@ static int test_block_type(unsigned char *buffer)
return -1;
 }
 
-static int part_test_dos(struct blk_desc *dev_desc)
+static int part_test_dos(struct blk_desc *desc)
 {
 #ifndef CONFIG_SPL_BUILD
ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr,
-   DIV_ROUND_UP(dev_desc->blksz, sizeof(legacy_mbr)));
+   DIV_ROUND_UP(desc->blksz, sizeof(legacy_mbr)));
 
-   if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1)
+   if (blk_dread(desc, 0, 1, (ulong *)mbr) != 1)
return -1;
 
if (test_block_type((unsigned char *)mbr) != DOS_MBR)
return -1;
 
-   if (dev_desc->sig_type == SIG_TYPE_NONE &&
-   mbr->unique_mbr_signature != 0) {
-   dev_desc->sig_type = SIG_TYPE_MBR;
-   dev_desc->mbr_sig = mbr->unique_mbr_signature;
+   if (desc->sig_type == SIG_TYPE_NONE && mbr->unique_mbr_signature) {
+   desc->sig_type = SIG_TYPE_MBR;
+   desc->mbr_sig = mbr->unique_mbr_signature;
}
 #else
-   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
+   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, desc->blksz);
 
-   if (blk_dread(dev_desc, 0, 1, (ulong *)buffer) != 1)
+   if (blk_dread(desc, 0, 1, (ulong *)buffer) != 1)
return -1;
 
if (test_block_type(buffer) != DOS_MBR)
@@ -130,12 +129,12 @@ static int part_test_dos(struct blk_desc *dev_desc)
 
 /*  Print a partition that is relative to its Extended partition table
  */
-static void print_partition_extended(struct blk_desc *dev_desc,
+static void print_partition_extended(struct blk_desc *desc,
 lbaint_t ext_part_sector,
 lbaint_t relative,
 int part_num, unsigned int disksig)
 {
-   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
+   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, desc->blksz);
dos_partition_t *pt;
int i;
 
@@ -146,9 +145,9 @@ static void print_partition_extended(struct blk_desc 
*dev_desc,
return;
 }
 
-   if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
+   if (blk_dread(desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
printf ("** Can't read partition table on %d:" LBAFU " **\n",
-   dev_desc->devnum, ext_part_sector);
+   desc->devnum, ext_part_sector);
return;
}
i=test_block_type(buffer);
@@ -189,9 +188,9 @@ static void print_partition_extended(struct blk_desc 
*dev_desc,
lbaint_t lba_start
= get_unaligned_le32 (pt->start4) + relative;
 
-   print_partition_extended(dev_desc, lba_start,
-   ext_part_sector == 0  ? lba_start : relative,
-   part_num, disksig);
+   print_partition_extended(desc, lba_start,
+!ext_part_sector ? lba_start :
+relative, part_num, disksig);
}
}
 
@@ -201,12 +200,12 @@ static void print_partition_extended(struct blk_desc 
*dev_desc,
 
 /*  Print a partition that is relative to its Extended partition table
  */
-static int part_get_info_extended(struct blk_desc *dev_desc,
+static int part_get_info_extended(struct blk_desc *desc,
  lbaint_t ext_part_sector, lbaint_t relative,
  int part_num, int which_part,
  struct disk_partition *info, uint disksig)
 {
-   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
+   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, desc->blksz);
struct disk_partition wdinfo = { 0 };
dos_partition_t *pt;
int i, ret;
@@ -219,9 +218,9 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
return -1;
 }
 
-   if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
+   if (blk_dread(desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
printf ("** Can't read partition table on %d:" LBAFU " **\n",
-   dev_desc->devnum, ext_part_sector);
+   desc->devnum, ext_part_sector);
return -1;
}
  

[PATCH v2 01/23] part: Use desc instead of dev_desc

2023-08-24 Thread Simon Glass
The dev_ prefix is a hangover from the pre-driver model days. The device
is now a different thing, with driver model. Update the partition code to
just use 'desc', as is done with driver model.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Rebase on -next

 disk/part.c| 178 -
 include/part.h | 125 +-
 2 files changed, 147 insertions(+), 156 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index eec02f58988d..8035dcb8a429 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -42,25 +42,25 @@ static struct part_driver *part_driver_get_type(int 
part_type)
return NULL;
 }
 
-static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc)
+static struct part_driver *part_driver_lookup_type(struct blk_desc *desc)
 {
struct part_driver *drv =
ll_entry_start(struct part_driver, part_driver);
const int n_ents = ll_entry_count(struct part_driver, part_driver);
struct part_driver *entry;
 
-   if (dev_desc->part_type == PART_TYPE_UNKNOWN) {
+   if (desc->part_type == PART_TYPE_UNKNOWN) {
for (entry = drv; entry != drv + n_ents; entry++) {
int ret;
 
-   ret = entry->test(dev_desc);
+   ret = entry->test(desc);
if (!ret) {
-   dev_desc->part_type = entry->part_type;
+   desc->part_type = entry->part_type;
return entry;
}
}
} else {
-   return part_driver_get_type(dev_desc->part_type);
+   return part_driver_get_type(desc->part_type);
}
 
/* Not found */
@@ -85,25 +85,25 @@ int part_get_type_by_name(const char *name)
 
 static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
 {
-   struct blk_desc *dev_desc;
+   struct blk_desc *desc;
int ret;
 
if (!blk_enabled())
return NULL;
-   dev_desc = blk_get_devnum_by_uclass_idname(ifname, dev);
-   if (!dev_desc) {
+   desc = blk_get_devnum_by_uclass_idname(ifname, dev);
+   if (!desc) {
debug("%s: No device for iface '%s', dev %d\n", __func__,
  ifname, dev);
return NULL;
}
-   ret = blk_dselect_hwpart(dev_desc, hwpart);
+   ret = blk_dselect_hwpart(desc, hwpart);
if (ret) {
debug("%s: Failed to select h/w partition: err-%d\n", __func__,
  ret);
return NULL;
}
 
-   return dev_desc;
+   return desc;
 }
 
 struct blk_desc *blk_get_dev(const char *ifname, int dev)
@@ -140,29 +140,24 @@ static lba512_t lba512_muldiv(lba512_t block_count, 
lba512_t mul_by,
return bc_quot * mul_by + ((bc_rem * mul_by) >> right_shift);
 }
 
-void dev_print(struct blk_desc *dev_desc)
+void dev_print(struct blk_desc *desc)
 {
lba512_t lba512; /* number of blocks if 512bytes block size */
 
-   if (dev_desc->type == DEV_TYPE_UNKNOWN) {
+   if (desc->type == DEV_TYPE_UNKNOWN) {
puts ("not available\n");
return;
}
 
-   switch (dev_desc->uclass_id) {
+   switch (desc->uclass_id) {
case UCLASS_SCSI:
-   printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n",
-   dev_desc->target,dev_desc->lun,
-   dev_desc->vendor,
-   dev_desc->product,
-   dev_desc->revision);
+   printf("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n", desc->target,
+  desc->lun, desc->vendor, desc->product, desc->revision);
break;
case UCLASS_IDE:
case UCLASS_AHCI:
-   printf ("Model: %s Firm: %s Ser#: %s\n",
-   dev_desc->vendor,
-   dev_desc->revision,
-   dev_desc->product);
+   printf("Model: %s Firm: %s Ser#: %s\n", desc->vendor,
+  desc->revision, desc->product);
break;
case UCLASS_MMC:
case UCLASS_USB:
@@ -171,27 +166,27 @@ void dev_print(struct blk_desc *dev_desc)
case UCLASS_HOST:
case UCLASS_BLKMAP:
printf ("Vendor: %s Rev: %s Prod: %s\n",
-   dev_desc->vendor,
-   dev_desc->revision,
-   dev_desc->product);
+   desc->vendor,
+   desc->revision,
+   desc->product);
break;
case UCLASS_VIRTIO:
-   printf("%s VirtIO Block Device\n", dev_desc->vendor);
+   printf("%s VirtIO Block Device\n", desc->vendor);
break;
case UCLASS_EFI_MEDIA:
-   printf("EFI media Block Device %d\n", dev_desc->devnum);
+ 

[PATCH v2 02/23] part: amiga: Use desc instead of dev_desc

2023-08-24 Thread Simon Glass
The dev_ prefix is a hangover from the pre-driver model days. The device
is now a different thing, with driver model. Update the amiga code to
just use 'desc'.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/part_amiga.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index 45d3a7048669..65e30fea558d 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -125,7 +125,7 @@ static void print_part_info(struct partition_block *p)
  * the ID AMIGA_ID_RDISK ('RDSK') and needs to have a valid
  * sum-to-zero checksum
  */
-struct rigid_disk_block *get_rdisk(struct blk_desc *dev_desc)
+struct rigid_disk_block *get_rdisk(struct blk_desc *desc)
 {
 int i;
 int limit;
@@ -139,7 +139,7 @@ struct rigid_disk_block *get_rdisk(struct blk_desc 
*dev_desc)
 
 for (i=0; i

[PATCH v2 00/23] bootstd: Support ChromiumOS better

2023-08-24 Thread Simon Glass
This updates the ChromiumOS bootmeth to detect multiple kernel partitions
on a disk.

It also includes minor code improvements to the partition drivers,
including accessors for the optional fields.

This series also includes some other related tweaks in testing.

It is available at u-boot-dm/methb-working

Changes in v2:
- Rebase on -next
- Rebase to -next
- Rebase to -next
- Rebase to -next

Simon Glass (23):
  part: Use desc instead of dev_desc
  part: amiga: Use desc instead of dev_desc
  part: dos: Use desc instead of dev_desc
  part: efi: Use desc instead of dev_desc
  part: iso: Use desc instead of dev_desc
  part: nac: Use desc instead of dev_desc
  part: Add comments for static functions
  part: Add accessors for struct disk_partition uuid
  part: Add accessors for struct disk_partition type_uuid
  part: Add an accessor for struct disk_partition sys_ind
  part: efi: Add debugging for the signature check
  dm: core: Correct error handling when event fails
  uuid: Move function comments to header file
  sandbox: Add a way to access persistent test files
  test: Move 1MB.fat32.img and 2MB.ext2.img
  bootflow: Show an empty filename when there is none
  bootstd: test: Allow binding and using any mmc device
  bootstd: Add a test for bootmeth_cros
  part: Add a fallback for part_get_bootable()
  bootstd: Support bootmeths which can scan any partition
  uuid: Add ChromiumOS partition types
  bootstd: cros: Allow detection of any kernel partition
  CI: Add ChromiumOS utilities

 arch/sandbox/cpu/os.c  |  24 
 arch/sandbox/dts/test.dts  |   9 ++
 boot/Kconfig   |   2 +
 boot/bootdev-uclass.c  |  24 +++-
 boot/bootmeth_cros.c   |  48 ---
 cmd/bootflow.c |   2 +-
 cmd/gpt.c  |  10 +-
 configs/snow_defconfig |   1 +
 disk/part.c| 226 +++--
 disk/part_amiga.c  |  34 ++---
 disk/part_dos.c|  80 +--
 disk/part_efi.c| 281 +++--
 disk/part_iso.c|  52 +++
 disk/part_mac.c|  59 
 doc/develop/bootstd.rst|  11 +-
 drivers/core/device.c  |   3 +-
 fs/fat/fat.c   |   4 +-
 include/bootmeth.h |   3 +
 include/os.h   |  10 ++
 include/part.h | 212 ++--
 include/part_efi.h |  14 ++
 include/uuid.h | 103 ++
 lib/uuid.c | 110 +--
 test/boot/bootflow.c   |  80 ---
 test/dm/host.c |  44 +++---
 test/py/tests/fs_helper.py |   6 +-
 test/py/tests/test_ut.py   | 148 ++-
 tools/docker/Dockerfile|   3 +
 28 files changed, 988 insertions(+), 615 deletions(-)

-- 
2.42.0.rc1.204.g551eb34607-goog



Re: [PATCH v2 1/7] ufs: Convert quirks to BIT() macro

2023-08-24 Thread Tom Rini
On Wed, 16 Aug 2023 17:05:49 +0200, Marek Vasut wrote:

> Use BIT() macro for quirks, no functional change.
> 
> 

Applied to u-boot/next, thanks!

-- 
Tom



[PATCH v2 16/16] board: asus: lg: move config fragments into device boards

2023-08-24 Thread Svyatoslav Ryhel
Move ASUS Transformers, Grouper, P895 and P880 config fragments into
their respective device directory in /board/../configs/

Signed-off-by: Svyatoslav Ryhel 
---
 board/asus/grouper/MAINTAINERS | 3 ---
 .../asus/grouper/configs}/grouper_E1565.config | 0
 .../asus/grouper/configs}/grouper_PM269.config | 0
 {configs => board/asus/grouper/configs}/tilapia.config | 0
 board/asus/transformer-t30/MAINTAINERS | 7 ---
 .../asus/transformer-t30/configs}/p1801-t.config   | 0
 .../asus/transformer-t30/configs}/tf201.config | 0
 .../asus/transformer-t30/configs}/tf300t.config| 0
 .../asus/transformer-t30/configs}/tf300tg.config   | 0
 .../asus/transformer-t30/configs}/tf300tl.config   | 0
 .../asus/transformer-t30/configs}/tf600t.config| 0
 .../asus/transformer-t30/configs}/tf700t.config| 0
 board/lg/x3-t30/MAINTAINERS| 2 --
 {configs => board/lg/x3-t30/configs}/p880.config   | 0
 {configs => board/lg/x3-t30/configs}/p895.config   | 0
 15 files changed, 12 deletions(-)
 rename {configs => board/asus/grouper/configs}/grouper_E1565.config (100%)
 rename {configs => board/asus/grouper/configs}/grouper_PM269.config (100%)
 rename {configs => board/asus/grouper/configs}/tilapia.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/p1801-t.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf201.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf300t.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf300tg.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf300tl.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf600t.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf700t.config (100%)
 rename {configs => board/lg/x3-t30/configs}/p880.config (100%)
 rename {configs => board/lg/x3-t30/configs}/p895.config (100%)

diff --git a/board/asus/grouper/MAINTAINERS b/board/asus/grouper/MAINTAINERS
index 18b4f0641f..f4068d8562 100644
--- a/board/asus/grouper/MAINTAINERS
+++ b/board/asus/grouper/MAINTAINERS
@@ -2,9 +2,6 @@ GROUPER BOARD
 M: Svyatoslav Ryhel 
 S: Maintained
 F: board/asus/grouper/
-F: configs/grouper_E1565.config
-F: configs/grouper_PM269.config
-F: configs/tilapia.config
 F: configs/grouper_common_defconfig
 F: doc/board/asus/grouper_common.rst
 F: include/configs/grouper.h
diff --git a/configs/grouper_E1565.config 
b/board/asus/grouper/configs/grouper_E1565.config
similarity index 100%
rename from configs/grouper_E1565.config
rename to board/asus/grouper/configs/grouper_E1565.config
diff --git a/configs/grouper_PM269.config 
b/board/asus/grouper/configs/grouper_PM269.config
similarity index 100%
rename from configs/grouper_PM269.config
rename to board/asus/grouper/configs/grouper_PM269.config
diff --git a/configs/tilapia.config b/board/asus/grouper/configs/tilapia.config
similarity index 100%
rename from configs/tilapia.config
rename to board/asus/grouper/configs/tilapia.config
diff --git a/board/asus/transformer-t30/MAINTAINERS 
b/board/asus/transformer-t30/MAINTAINERS
index c6c15323b2..071a9c04b8 100644
--- a/board/asus/transformer-t30/MAINTAINERS
+++ b/board/asus/transformer-t30/MAINTAINERS
@@ -2,13 +2,6 @@ TRANSFORMER BOARD
 M: Svyatoslav Ryhel 
 S: Maintained
 F: board/asus/transformer-t30/
-F: configs/p1801-t.config
-F: configs/tf201.config
-F: configs/tf300t.config
-F: configs/tf300tg.config
-F: configs/tf300tl.config
-F: configs/tf600t.config
-F: configs/tf700t.config
 F: configs/transformer_t30_defconfig
 F: doc/board/asus/transformer_t30.rst
 F: include/configs/transformer-common.h
diff --git a/configs/p1801-t.config 
b/board/asus/transformer-t30/configs/p1801-t.config
similarity index 100%
rename from configs/p1801-t.config
rename to board/asus/transformer-t30/configs/p1801-t.config
diff --git a/configs/tf201.config 
b/board/asus/transformer-t30/configs/tf201.config
similarity index 100%
rename from configs/tf201.config
rename to board/asus/transformer-t30/configs/tf201.config
diff --git a/configs/tf300t.config 
b/board/asus/transformer-t30/configs/tf300t.config
similarity index 100%
rename from configs/tf300t.config
rename to board/asus/transformer-t30/configs/tf300t.config
diff --git a/configs/tf300tg.config 
b/board/asus/transformer-t30/configs/tf300tg.config
similarity index 100%
rename from configs/tf300tg.config
rename to board/asus/transformer-t30/configs/tf300tg.config
diff --git a/configs/tf300tl.config 
b/board/asus/transformer-t30/configs/tf300tl.config
similarity index 100%
rename from configs/tf300tl.config
rename to board/asus/transformer-t30/configs/tf300tl.config
diff --git a/configs/tf600t.config 
b/board/asus/transformer-t30/configs/tf600t.config
similarity index 100%

[PATCH v2 15/16] board: tegra30: remove nvidia_board_late_init calls

2023-08-24 Thread Svyatoslav Ryhel
Remove nvidia_board_late_init calls from board since this setup is
performed in board2 of mach-tegra. Call of nvidia_board_late_init
from within the board does not provide any additional data.

Tested-by: Andreas Westman Dorcsak  # ASUS Transformer T30
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Svyatoslav Ryhel 
---
 board/asus/grouper/grouper.c | 12 
 board/asus/transformer-t30/transformer-t30.c | 12 
 board/htc/endeavoru/endeavoru.c  | 12 
 board/lg/x3-t30/x3-t30.c | 11 ---
 4 files changed, 47 deletions(-)

diff --git a/board/asus/grouper/grouper.c b/board/asus/grouper/grouper.c
index 2769313e68..5398ec8b9f 100644
--- a/board/asus/grouper/grouper.c
+++ b/board/asus/grouper/grouper.c
@@ -9,14 +9,12 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include "pinmux-config-grouper.h"
@@ -190,13 +188,3 @@ int ft_board_setup(void *blob, struct bd_info *bd)
return 0;
 }
 #endif
-
-void nvidia_board_late_init(void)
-{
-   char serialno_str[17];
-
-   /* Set chip id as serialno */
-   sprintf(serialno_str, "%016llx", tegra_chip_uid());
-   env_set("serial#", serialno_str);
-   env_set("platform", "Tegra 3 T30");
-}
diff --git a/board/asus/transformer-t30/transformer-t30.c 
b/board/asus/transformer-t30/transformer-t30.c
index 5c1bac004f..ba795a802e 100644
--- a/board/asus/transformer-t30/transformer-t30.c
+++ b/board/asus/transformer-t30/transformer-t30.c
@@ -11,14 +11,12 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include "pinmux-config-transformer.h"
@@ -164,13 +162,3 @@ int ft_board_setup(void *blob, struct bd_info *bd)
return 0;
 }
 #endif
-
-void nvidia_board_late_init(void)
-{
-   char serialno_str[17];
-
-   /* Set chip id as serialno */
-   sprintf(serialno_str, "%016llx", tegra_chip_uid());
-   env_set("serial#", serialno_str);
-   env_set("platform", "Tegra 3 T30");
-}
diff --git a/board/htc/endeavoru/endeavoru.c b/board/htc/endeavoru/endeavoru.c
index 1d92870f91..e1a0b242e2 100644
--- a/board/htc/endeavoru/endeavoru.c
+++ b/board/htc/endeavoru/endeavoru.c
@@ -9,14 +9,12 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include "pinmux-config-endeavoru.h"
@@ -104,13 +102,3 @@ int ft_board_setup(void *blob, struct bd_info *bd)
return 0;
 }
 #endif
-
-void nvidia_board_late_init(void)
-{
-   char serialno_str[17];
-
-   /* Set chip id as serialno */
-   sprintf(serialno_str, "%016llx", tegra_chip_uid());
-   env_set("serial#", serialno_str);
-   env_set("platform", "Tegra 3 T30");
-}
diff --git a/board/lg/x3-t30/x3-t30.c b/board/lg/x3-t30/x3-t30.c
index 594563cf52..a08e00dd87 100644
--- a/board/lg/x3-t30/x3-t30.c
+++ b/board/lg/x3-t30/x3-t30.c
@@ -9,7 +9,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -164,13 +163,3 @@ int ft_board_setup(void *blob, struct bd_info *bd)
return 0;
 }
 #endif
-
-void nvidia_board_late_init(void)
-{
-   char serialno_str[17];
-
-   /* Set chip id as serialno */
-   sprintf(serialno_str, "%016llx", tegra_chip_uid());
-   env_set("serial#", serialno_str);
-   env_set("platform", "Tegra 3 T30");
-}
-- 
2.39.2



[PATCH v2 14/16] ARM: tegra: board2: add generic late init

2023-08-24 Thread Svyatoslav Ryhel
Board specific late init allows vendors to set up different device
or board specific env variables (like serial number, platform name).
In case this information is missing, u-boot will lack info regards
serial or platform.

To avoid this prior nvidia_board_late_init internal generic function
is called which fills required data. In this case platform name is
obtained from get_chip and serialno is filled with SoC id.

Though SoC id is not dedicated to be devices serial but it fits well
in case of restriction of data about device and since SoC is basically
a main chip of the device.

Tested-by: Andreas Westman Dorcsak  # ASUS Transformers
Tested-by: Svyatoslav Ryhel  # Nvidia Tegratab
Signed-off-by: Svyatoslav Ryhel 
Reviewed-by: Simon Glass 
---
 arch/arm/mach-tegra/board2.c | 43 
 1 file changed, 43 insertions(+)

diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c
index 981768bb0e..cd405874d3 100644
--- a/arch/arm/mach-tegra/board2.c
+++ b/arch/arm/mach-tegra/board2.c
@@ -26,6 +26,10 @@
 #include 
 #include 
 #include 
+#ifndef CONFIG_TEGRA186
+#include 
+#include 
+#endif
 #if IS_ENABLED(CONFIG_TEGRA_CLKRST)
 #include 
 #endif
@@ -256,6 +260,37 @@ int board_early_init_f(void)
 }
 #endif /* EARLY_INIT */
 
+#ifndef CONFIG_TEGRA186
+static void nvidia_board_late_init_generic(void)
+{
+   char serialno_str[17];
+
+   /* Set chip id as serialno */
+   sprintf(serialno_str, "%016llx", tegra_chip_uid());
+   env_set("serial#", serialno_str);
+
+   switch (tegra_get_chip()) {
+   case CHIPID_TEGRA20:
+   env_set("platform", "tegra20");
+   break;
+   case CHIPID_TEGRA30:
+   env_set("platform", "tegra30");
+   break;
+   case CHIPID_TEGRA114:
+   env_set("platform", "tegra114");
+   break;
+   case CHIPID_TEGRA124:
+   env_set("platform", "tegra124");
+   break;
+   case CHIPID_TEGRA210:
+   env_set("platform", "tegra210");
+   break;
+   default:
+   return;
+   }
+}
+#endif
+
 int board_late_init(void)
 {
 #if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE)
@@ -268,6 +303,14 @@ int board_late_init(void)
 #endif
start_cpu_fan();
cboot_late_init();
+
+   /*
+* Perform generic env setup in case
+* vendor does not provide it.
+*/
+#ifndef CONFIG_TEGRA186
+   nvidia_board_late_init_generic();
+#endif
nvidia_board_late_init();
 
return 0;
-- 
2.39.2



[PATCH v2 13/16] ARM: tegra20: tegra30: support EBTUPDATE on non-encrypted devices

2023-08-24 Thread Svyatoslav Ryhel
Re-crypt support was extended to devices without burnt SBK. In case
SBK is not set, place from where it is read is filled with zeroes.
This patch adds support for ebtupdate function to detect nosbk device
and avoid crypto operations for it.

Tested-by: Maksim Kurnosenko 
Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/mach-tegra/tegra20/bct.c | 30 --
 arch/arm/mach-tegra/tegra30/bct.c | 30 --
 2 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-tegra/tegra20/bct.c 
b/arch/arm/mach-tegra/tegra20/bct.c
index 5eb48990b6..b2c44f3d23 100644
--- a/arch/arm/mach-tegra/tegra20/bct.c
+++ b/arch/arm/mach-tegra/tegra20/bct.c
@@ -11,6 +11,9 @@
 #include "bct.h"
 #include "uboot_aes.h"
 
+/* Device with "sbk burned: false" will expose zero key */
+const u8 nosbk[AES128_KEY_LENGTH] = { 0 };
+
 /*
  * @param  bct boot config table start in RAM
  * @param  ect bootloader start in RAM
@@ -23,22 +26,27 @@ static int bct_patch(u8 *bct, u8 *ebt, u32 ebt_size)
u8 ebt_hash[AES128_KEY_LENGTH] = { 0 };
u8 sbk[AES128_KEY_LENGTH] = { 0 };
u8 *bct_hash = bct;
+   bool encrypted;
int ret;
 
bct += BCT_HASH;
 
+   ebt_size = roundup(ebt_size, EBT_ALIGNMENT);
+
memcpy(sbk, (u8 *)(bct + BCT_LENGTH),
   NVBOOT_CMAC_AES_HASH_LENGTH * 4);
 
-   ret = decrypt_data_block(bct, BCT_LENGTH, sbk);
-   if (ret)
-   return 1;
+   encrypted = memcmp(, , AES128_KEY_LENGTH);
 
-   ebt_size = roundup(ebt_size, EBT_ALIGNMENT);
+   if (encrypted) {
+   ret = decrypt_data_block(bct, BCT_LENGTH, sbk);
+   if (ret)
+   return 1;
 
-   ret = encrypt_data_block(ebt, ebt_size, sbk);
-   if (ret)
-   return 1;
+   ret = encrypt_data_block(ebt, ebt_size, sbk);
+   if (ret)
+   return 1;
+   }
 
ret = sign_enc_data_block(ebt, ebt_size, ebt_hash, sbk);
if (ret)
@@ -52,9 +60,11 @@ static int bct_patch(u8 *bct, u8 *ebt, u32 ebt_size)
bct_tbl->bootloader[0].load_addr = CONFIG_SPL_TEXT_BASE;
bct_tbl->bootloader[0].length = ebt_size;
 
-   ret = encrypt_data_block(bct, BCT_LENGTH, sbk);
-   if (ret)
-   return 1;
+   if (encrypted) {
+   ret = encrypt_data_block(bct, BCT_LENGTH, sbk);
+   if (ret)
+   return 1;
+   }
 
ret = sign_enc_data_block(bct, BCT_LENGTH, bct_hash, sbk);
if (ret)
diff --git a/arch/arm/mach-tegra/tegra30/bct.c 
b/arch/arm/mach-tegra/tegra30/bct.c
index c56958da69..cff1a3e98d 100644
--- a/arch/arm/mach-tegra/tegra30/bct.c
+++ b/arch/arm/mach-tegra/tegra30/bct.c
@@ -11,6 +11,9 @@
 #include "bct.h"
 #include "uboot_aes.h"
 
+/* Device with "sbk burned: false" will expose zero key */
+const u8 nosbk[AES128_KEY_LENGTH] = { 0 };
+
 /*
  * @param  bct boot config table start in RAM
  * @param  ect bootloader start in RAM
@@ -23,22 +26,27 @@ static int bct_patch(u8 *bct, u8 *ebt, u32 ebt_size)
u8 ebt_hash[AES128_KEY_LENGTH] = { 0 };
u8 sbk[AES128_KEY_LENGTH] = { 0 };
u8 *bct_hash = bct;
+   bool encrypted;
int ret;
 
bct += BCT_HASH;
 
+   ebt_size = roundup(ebt_size, EBT_ALIGNMENT);
+
memcpy(sbk, (u8 *)(bct + BCT_LENGTH),
   NVBOOT_CMAC_AES_HASH_LENGTH * 4);
 
-   ret = decrypt_data_block(bct, BCT_LENGTH, sbk);
-   if (ret)
-   return 1;
+   encrypted = memcmp(, , AES128_KEY_LENGTH);
 
-   ebt_size = roundup(ebt_size, EBT_ALIGNMENT);
+   if (encrypted) {
+   ret = decrypt_data_block(bct, BCT_LENGTH, sbk);
+   if (ret)
+   return 1;
 
-   ret = encrypt_data_block(ebt, ebt_size, sbk);
-   if (ret)
-   return 1;
+   ret = encrypt_data_block(ebt, ebt_size, sbk);
+   if (ret)
+   return 1;
+   }
 
ret = sign_enc_data_block(ebt, ebt_size, ebt_hash, sbk);
if (ret)
@@ -52,9 +60,11 @@ static int bct_patch(u8 *bct, u8 *ebt, u32 ebt_size)
bct_tbl->bootloader[0].load_addr = CONFIG_SPL_TEXT_BASE;
bct_tbl->bootloader[0].length = ebt_size;
 
-   ret = encrypt_data_block(bct, BCT_LENGTH, sbk);
-   if (ret)
-   return 1;
+   if (encrypted) {
+   ret = encrypt_data_block(bct, BCT_LENGTH, sbk);
+   if (ret)
+   return 1;
+   }
 
ret = sign_enc_data_block(bct, BCT_LENGTH, bct_hash, sbk);
if (ret)
-- 
2.39.2



[PATCH v2 12/16] ARM: tegra114: enable base voltages setup from board

2023-08-24 Thread Svyatoslav Ryhel
Tegra 4, same as Tegra 3, requires configuration of CPU and CORE
voltages in the SPL stage to boot properly. Expose function to be
able perform this configuration in the SPL section of the device
board.

Tested-by: Svyatoslav Ryhel  # ASUS TF701T
Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/mach-tegra/tegra114/cpu.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-tegra/tegra114/cpu.c 
b/arch/arm/mach-tegra/tegra114/cpu.c
index 62c1053630..7d8f080c31 100644
--- a/arch/arm/mach-tegra/tegra114/cpu.c
+++ b/arch/arm/mach-tegra/tegra114/cpu.c
@@ -13,9 +13,13 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "../cpu.h"
 
+/* In case this function is not defined */
+__weak void pmic_enable_cpu_vdd(void) {}
+
 /* Tegra114-specific CPU init code */
 static void enable_cpu_power_rail(void)
 {
@@ -254,6 +258,7 @@ void start_cpu(u32 reset_vector)
 
/* Enable VDD_CPU */
enable_cpu_power_rail();
+   pmic_enable_cpu_vdd();
 
/* Get the CPU(s) running */
enable_cpu_clocks();
-- 
2.39.2



[PATCH v2 11/16] configs: transformer_t30: grouper: lg-x3: endeavoru: sync defconfigs

2023-08-24 Thread Svyatoslav Ryhel
Signed-off-by: Svyatoslav Ryhel 
---
 configs/endeavoru_defconfig   | 2 --
 configs/grouper_common_defconfig  | 4 
 configs/tf600t.config | 1 +
 configs/transformer_t30_defconfig | 2 --
 configs/x3_t30_defconfig  | 2 --
 5 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/configs/endeavoru_defconfig b/configs/endeavoru_defconfig
index 38f26f2dcc..feb481170a 100644
--- a/configs/endeavoru_defconfig
+++ b/configs/endeavoru_defconfig
@@ -21,7 +21,6 @@ CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=0
 CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_KEYED_CTRLC=y
-CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="if run check_button; then bootmenu; fi; run bootcmd_mmc0; 
poweroff;"
 CONFIG_SPL_FOOTPRINT_LIMIT=y
 CONFIG_SPL_MAX_FOOTPRINT=0x8000
@@ -44,7 +43,6 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_UMS_ABORT_KEYED=y
 # CONFIG_CMD_SETEXPR is not set
-# CONFIG_CMD_NFS is not set
 CONFIG_CMD_PAUSE=y
 CONFIG_CMD_EXT4_WRITE=y
 # CONFIG_SPL_DOS_PARTITION is not set
diff --git a/configs/grouper_common_defconfig b/configs/grouper_common_defconfig
index 8dc88851f5..36ad0980e7 100644
--- a/configs/grouper_common_defconfig
+++ b/configs/grouper_common_defconfig
@@ -21,7 +21,6 @@ CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=0
 CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_KEYED_CTRLC=y
-CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="if run check_button; then bootmenu; fi; run bootcmd_mmc0; 
poweroff;"
 CONFIG_SPL_FOOTPRINT_LIMIT=y
 CONFIG_SPL_MAX_FOOTPRINT=0x8000
@@ -43,7 +42,6 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_UMS_ABORT_KEYED=y
 # CONFIG_CMD_SETEXPR is not set
-# CONFIG_CMD_NFS is not set
 CONFIG_CMD_PAUSE=y
 CONFIG_CMD_EXT4_WRITE=y
 # CONFIG_SPL_DOS_PARTITION is not set
@@ -61,8 +59,6 @@ CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_GPIO_HOG=y
 CONFIG_SYS_I2C_TEGRA=y
-CONFIG_I2C_MUX=y
-CONFIG_I2C_MUX_GPIO=y
 CONFIG_BUTTON_KEYBOARD=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_REGULATOR=y
diff --git a/configs/tf600t.config b/configs/tf600t.config
index 18ab4fbd87..ee1b827bea 100644
--- a/configs/tf600t.config
+++ b/configs/tf600t.config
@@ -2,3 +2,4 @@ CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-tf600t"
 CONFIG_TRANSFORMER_SPI_BOOT=y
 CONFIG_BOOTCOMMAND="setenv gpio_button 222; if run check_button; then 
poweroff; fi; setenv gpio_button 132; if run check_button; then echo Starting 
SPI flash update ...; run update_spi; fi; run bootcmd_usb0; run bootcmd_mmc1; 
run bootcmd_mmc0; poweroff;"
 CONFIG_USB_GADGET_PRODUCT_NUM=0x4d00
+CONFIG_VIDEO_DSI_TEGRA30=y
diff --git a/configs/transformer_t30_defconfig 
b/configs/transformer_t30_defconfig
index 802dcb1786..eaff0697bb 100644
--- a/configs/transformer_t30_defconfig
+++ b/configs/transformer_t30_defconfig
@@ -21,7 +21,6 @@ CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=0
 CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_KEYED_CTRLC=y
-CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="setenv skip_boot 0; setenv gpio_button 150; if run 
check_button; then poweroff; fi; setenv gpio_button 131; if run check_button; 
then bootmenu; fi; if test ${skip_boot} -eq 1; then; else run bootcmd_usb0; run 
bootcmd_mmc1; run bootcmd_mmc0; poweroff; fi"
 CONFIG_SPL_FOOTPRINT_LIMIT=y
 CONFIG_SPL_MAX_FOOTPRINT=0x8000
@@ -45,7 +44,6 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_UMS_ABORT_KEYED=y
 # CONFIG_CMD_SETEXPR is not set
-# CONFIG_CMD_NFS is not set
 CONFIG_CMD_PAUSE=y
 CONFIG_CMD_EXT4_WRITE=y
 # CONFIG_SPL_DOS_PARTITION is not set
diff --git a/configs/x3_t30_defconfig b/configs/x3_t30_defconfig
index 540c43096d..98744ec89d 100644
--- a/configs/x3_t30_defconfig
+++ b/configs/x3_t30_defconfig
@@ -22,7 +22,6 @@ CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=0
 CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_KEYED_CTRLC=y
-CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="if run check_button; then bootmenu; fi; run bootcmd_mmc1; 
run bootcmd_mmc0; poweroff;"
 CONFIG_SPL_FOOTPRINT_LIMIT=y
 CONFIG_SPL_MAX_FOOTPRINT=0x8000
@@ -45,7 +44,6 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_UMS_ABORT_KEYED=y
 # CONFIG_CMD_SETEXPR is not set
-# CONFIG_CMD_NFS is not set
 CONFIG_CMD_PAUSE=y
 CONFIG_CMD_EXT4_WRITE=y
 # CONFIG_SPL_DOS_PARTITION is not set
-- 
2.39.2



[PATCH v2 10/16] ARM: dts: grouper: complete missing bindings

2023-08-24 Thread Svyatoslav Ryhel
Clean up the tree and prepare for DM PMIC migration.

Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/tegra30-asus-grouper-common.dtsi  |  5 +++--
 arch/arm/dts/tegra30-asus-nexus7-grouper-E1565.dts |  5 ++---
 arch/arm/dts/tegra30-asus-nexus7-grouper-PM269.dts | 11 +--
 arch/arm/dts/tegra30-asus-nexus7-tilapia-E1565.dts |  5 ++---
 4 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/arch/arm/dts/tegra30-asus-grouper-common.dtsi 
b/arch/arm/dts/tegra30-asus-grouper-common.dtsi
index 4fa980f24f..fcf31e2dd0 100644
--- a/arch/arm/dts/tegra30-asus-grouper-common.dtsi
+++ b/arch/arm/dts/tegra30-asus-grouper-common.dtsi
@@ -1,7 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
 #include 
-
 #include "tegra30.dtsi"
 
 / {
@@ -62,6 +61,9 @@
status = "okay";
bus-width = <8>;
non-removable;
+
+   vmmc-supply = <_emmc>;
+   vqmmc-supply = <_1v8_vio>;
};
 
usb1: usb@7d00 {
@@ -150,7 +152,6 @@
regulator-name = "vdd_5v0_bl";
regulator-min-microvolt = <500>;
regulator-max-microvolt = <500>;
-   regulator-boot-on;
gpio = < TEGRA_GPIO(H, 3) GPIO_ACTIVE_HIGH>;
enable-active-high;
};
diff --git a/arch/arm/dts/tegra30-asus-nexus7-grouper-E1565.dts 
b/arch/arm/dts/tegra30-asus-nexus7-grouper-E1565.dts
index a98d3e2145..945ae404ac 100644
--- a/arch/arm/dts/tegra30-asus-nexus7-grouper-E1565.dts
+++ b/arch/arm/dts/tegra30-asus-nexus7-grouper-E1565.dts
@@ -22,7 +22,7 @@
gpio-controller;
 
regulators {
-   vdd_1v8: sd2 {
+   vdd_1v8_vio: sd2 {
regulator-name = "vdd_1v8_gen";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <180>;
@@ -34,8 +34,7 @@
vcore_emmc: ldo3 {
regulator-name = "vcore_emmc";
regulator-min-microvolt = <285>;
-   regulator-max-microvolt = <310>;
-   regulator-always-on;
+   regulator-max-microvolt = <285>;
};
};
};
diff --git a/arch/arm/dts/tegra30-asus-nexus7-grouper-PM269.dts 
b/arch/arm/dts/tegra30-asus-nexus7-grouper-PM269.dts
index 44ea218a47..4363bfc87d 100644
--- a/arch/arm/dts/tegra30-asus-nexus7-grouper-PM269.dts
+++ b/arch/arm/dts/tegra30-asus-nexus7-grouper-PM269.dts
@@ -23,12 +23,19 @@
gpio-controller;
 
regulators {
+   vdd_1v8_vio: vddio {
+   regulator-name = "vdd_1v8_gen";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
/* eMMC VDD */
vcore_emmc: ldo1 {
regulator-name = "vdd_emmc_core";
-   regulator-min-microvolt = <100>;
+   regulator-min-microvolt = <330>;
regulator-max-microvolt = <330>;
-   regulator-always-on;
};
};
};
diff --git a/arch/arm/dts/tegra30-asus-nexus7-tilapia-E1565.dts 
b/arch/arm/dts/tegra30-asus-nexus7-tilapia-E1565.dts
index 812d5a1ba7..89348fde13 100644
--- a/arch/arm/dts/tegra30-asus-nexus7-tilapia-E1565.dts
+++ b/arch/arm/dts/tegra30-asus-nexus7-tilapia-E1565.dts
@@ -22,7 +22,7 @@
gpio-controller;
 
regulators {
-   vdd_1v8: sd2 {
+   vdd_1v8_vio: sd2 {
regulator-name = "vdd_1v8_gen";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <180>;
@@ -34,8 +34,7 @@
vcore_emmc: ldo3 {
regulator-name = "vcore_emmc";
regulator-min-microvolt = <285>;
-   regulator-max-microvolt = <310>;
-   regulator-always-on;
+   regulator-max-microvolt = <285>;
  

[PATCH v2 09/16] ARM: dts: lg-x3: complete missing bindings

2023-08-24 Thread Svyatoslav Ryhel
Clean up the tree and prepare for DM PMIC migration.

Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/tegra30-lg-x3.dtsi | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/dts/tegra30-lg-x3.dtsi b/arch/arm/dts/tegra30-lg-x3.dtsi
index 922e39915e..6e52fc5a53 100644
--- a/arch/arm/dts/tegra30-lg-x3.dtsi
+++ b/arch/arm/dts/tegra30-lg-x3.dtsi
@@ -1,7 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
 #include 
-
 #include "tegra30.dtsi"
 
 / {
@@ -91,6 +90,14 @@
regulator-boot-on;
};
 
+   avdd_3v3_periph: ldo2 {
+   regulator-name = "avdd_usb";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
vdd_usd: ldo3 {
regulator-name = "vdd_sdmmc3";
regulator-min-microvolt = <300>;
@@ -103,8 +110,6 @@
regulator-name = "vdd_ddr_rx";
regulator-min-microvolt = <285>;
regulator-max-microvolt = <285>;
-   regulator-always-on;
-   regulator-boot-on;
};
};
};
-- 
2.39.2



[PATCH v2 08/16] ARM: dts: endeavoru: complete missing bindings

2023-08-24 Thread Svyatoslav Ryhel
Clean up the tree and prepare for DM PMIC migration.

Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/tegra30-htc-endeavoru.dts | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/tegra30-htc-endeavoru.dts 
b/arch/arm/dts/tegra30-htc-endeavoru.dts
index c55e193d1d..5c7b2deae5 100644
--- a/arch/arm/dts/tegra30-htc-endeavoru.dts
+++ b/arch/arm/dts/tegra30-htc-endeavoru.dts
@@ -5,7 +5,6 @@
 /* CPU Speedo ID 4, Soc Speedo ID 1, CPU Process: 1, Core Process: 0 */
 
 #include 
-
 #include "tegra30.dtsi"
 
 / {
@@ -66,13 +65,22 @@
compatible = "ti,tps80032";
reg = <0x48>;
 
+   ti,system-power-controller;
+
regulators {
+   vdd_1v8_vio: smps5 {
+   regulator-name = "vdd_1v8_gen";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
/* DSI VDD */
avdd_dsi_csi: ldo1 {
regulator-name = "avdd_dsi_csi";
regulator-min-microvolt = <120>;
regulator-max-microvolt = <120>;
-   regulator-always-on;
};
};
};
@@ -82,6 +90,9 @@
status = "okay";
bus-width = <8>;
non-removable;
+
+   vmmc-supply = <_emmc>;
+   vqmmc-supply = <_1v8_vio>;
};
 
micro_usb: usb@7d00 {
-- 
2.39.2



[PATCH v2 07/16] ARM: dts: transformer-t30: complete missing bindings

2023-08-24 Thread Svyatoslav Ryhel
Clean up the tree and prepare for DM PMIC migration.

Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/tegra30-asus-transformer.dtsi | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/arm/dts/tegra30-asus-transformer.dtsi 
b/arch/arm/dts/tegra30-asus-transformer.dtsi
index d144a56445..888f9ca74e 100644
--- a/arch/arm/dts/tegra30-asus-transformer.dtsi
+++ b/arch/arm/dts/tegra30-asus-transformer.dtsi
@@ -1,7 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
 #include 
-
 #include "tegra30.dtsi"
 
 / {
@@ -70,12 +69,19 @@
gpio-controller;
 
regulators {
+   vdd_1v8_vio: vddio {
+   regulator-name = "vdd_1v8_gen";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
/* eMMC VDD */
vcore_emmc: ldo1 {
regulator-name = "vdd_emmc_core";
-   regulator-min-microvolt = <100>;
+   regulator-min-microvolt = <330>;
regulator-max-microvolt = <330>;
-   regulator-always-on;
};
 
/* uSD slot VDD */
@@ -88,8 +94,10 @@
/* uSD slot VDDIO */
vddio_usd: ldo3 {
regulator-name = "vddio_usd";
-   regulator-min-microvolt = <180>;
+   regulator-min-microvolt = <310>;
regulator-max-microvolt = <310>;
+   regulator-always-on;
+   regulator-boot-on;
};
};
};
@@ -110,6 +118,9 @@
status = "okay";
bus-width = <8>;
non-removable;
+
+   vmmc-supply = <_emmc>;
+   vqmmc-supply = <_1v8_vio>;
};
 
/* USB via ASUS connector */
@@ -208,7 +219,6 @@
regulator-name = "vdd_5v0_bl";
regulator-min-microvolt = <500>;
regulator-max-microvolt = <500>;
-   regulator-boot-on;
gpio = < TEGRA_GPIO(H, 3) GPIO_ACTIVE_HIGH>;
enable-active-high;
};
-- 
2.39.2



[PATCH v2 06/16] configs: transformer_t30: convert bootmenu option

2023-08-24 Thread Svyatoslav Ryhel
Convert refresh USB to enter console. Transformers have full size
USB and a dock keyboard so access to U-Boot console would be handy.

Signed-off-by: Svyatoslav Ryhel 
---
 configs/transformer_t30_defconfig| 2 +-
 include/configs/transformer-common.h | 7 +--
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/configs/transformer_t30_defconfig 
b/configs/transformer_t30_defconfig
index 840431ff38..802dcb1786 100644
--- a/configs/transformer_t30_defconfig
+++ b/configs/transformer_t30_defconfig
@@ -22,7 +22,7 @@ CONFIG_BOOTDELAY=0
 CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_KEYED_CTRLC=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="setenv gpio_button 150; if run check_button; then 
poweroff; fi; setenv gpio_button 131; if run check_button; then bootmenu; fi; 
run bootcmd_usb0; run bootcmd_mmc1; run bootcmd_mmc0; poweroff;"
+CONFIG_BOOTCOMMAND="setenv skip_boot 0; setenv gpio_button 150; if run 
check_button; then poweroff; fi; setenv gpio_button 131; if run check_button; 
then bootmenu; fi; if test ${skip_boot} -eq 1; then; else run bootcmd_usb0; run 
bootcmd_mmc1; run bootcmd_mmc0; poweroff; fi"
 CONFIG_SPL_FOOTPRINT_LIMIT=y
 CONFIG_SPL_MAX_FOOTPRINT=0x8000
 # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
diff --git a/include/configs/transformer-common.h 
b/include/configs/transformer-common.h
index dcdda1ec5b..3b7db0ab14 100644
--- a/include/configs/transformer-common.h
+++ b/include/configs/transformer-common.h
@@ -64,19 +64,14 @@
"else echo SPI flash backup FAILED! Aborting ...;" \
"poweroff; fi\0"
 
-#define TRANSFORMER_REFRESH_USB \
-   "refresh_usb=usb start; usb reset; usb tree; usb info;" \
-   "pause 'Press ANY key to return to bootmenu...'; bootmenu\0"
-
 #define TRANSFORMER_BOOTMENU \
TRANSFORMER_FLASH_UBOOT \
TRANSFORMER_FLASH_SPI \
-   TRANSFORMER_REFRESH_USB \
"bootmenu_0=mount internal storage=usb start && ums 0 mmc 0; 
bootmenu\0" \
"bootmenu_1=mount external storage=usb start && ums 0 mmc 1; 
bootmenu\0" \
"bootmenu_2=fastboot=echo Starting Fastboot protocol ...; fastboot usb 
0; bootmenu\0" \
"bootmenu_3=update bootloader=run flash_uboot\0" \
-   "bootmenu_4=refresh USB=run refresh_usb\0" \
+   "bootmenu_4=enter console=usb start; setenv skip_boot 1; exit\0" \
"bootmenu_5=reboot RCM=enterrcm\0" \
"bootmenu_6=reboot=reset\0" \
"bootmenu_7=power off=poweroff\0" \
-- 
2.39.2



[PATCH v2 05/16] board: asus: transformer-t30: remove PMIC GPIOs configuration

2023-08-24 Thread Svyatoslav Ryhel
Default configuration matches values which are set in the board
so this configuration is not required.

Signed-off-by: Svyatoslav Ryhel 
---
 board/asus/transformer-t30/transformer-t30.c | 25 
 1 file changed, 25 deletions(-)

diff --git a/board/asus/transformer-t30/transformer-t30.c 
b/board/asus/transformer-t30/transformer-t30.c
index b6fd19d28e..5c1bac004f 100644
--- a/board/asus/transformer-t30/transformer-t30.c
+++ b/board/asus/transformer-t30/transformer-t30.c
@@ -33,11 +33,6 @@
 #define TPS65911_LDO5  0x32
 #define TPS65911_LDO6  0x35
 
-#define TPS65911_GPIO0 0x60
-#define TPS65911_GPIO6 0x66
-#define TPS65911_GPIO7 0x67
-#define TPS65911_GPIO8 0x68
-
 #define TPS65911_DEVCTRL   0x3F
 #define   DEVCTRL_PWR_OFF_MASK BIT(7)
 #define   DEVCTRL_DEV_ON_MASK  BIT(2)
@@ -146,26 +141,6 @@ static void tps65911_voltage_init(void)
if (ret)
log_debug("vddio_usd set failed: %d\n", ret);
}
-
-   /* TPS659110: GPIO0_REG output high to VDD_5V0_SBY */
-   ret = dm_i2c_reg_write(dev, TPS65911_GPIO0, 0x07);
-   if (ret)
-   log_debug("vdd_5v0_sby set failed: %d\n", ret);
-
-   /* TPS659110: GPIO6_REG output high to VDD_3V3_SYS */
-   ret = dm_i2c_reg_write(dev, TPS65911_GPIO6, 0x07);
-   if (ret)
-   log_debug("vdd_3v3_sys set failed: %d\n", ret);
-
-   /* TPS659110: GPIO7_REG output high to VDD_1V5_DDR */
-   ret = dm_i2c_reg_write(dev, TPS65911_GPIO7, 0x07);
-   if (ret)
-   log_debug("vdd_1v5_ddr set failed: %d\n", ret);
-
-   /* TPS659110: GPIO8_REG pull_down output high to VDD_5V0_SYS */
-   ret = dm_i2c_reg_write(dev, TPS65911_GPIO8, 0x0f);
-   if (ret)
-   log_debug("vdd_5v0_sys set failed: %d\n", ret);
 }
 
 /*
-- 
2.39.2



[PATCH v2 04/16] ARM: dts: tf201: configure dock USB phy

2023-08-24 Thread Svyatoslav Ryhel
TF201 unlike other transformers uses non-fused xcvr value for
its dock USB port. With out it dock USB and SD reader will not
work.

Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/tegra30-asus-tf201.dts| 5 +
 arch/arm/dts/tegra30-asus-transformer.dtsi | 4 
 2 files changed, 9 insertions(+)

diff --git a/arch/arm/dts/tegra30-asus-tf201.dts 
b/arch/arm/dts/tegra30-asus-tf201.dts
index 54f359ef96..59e19f9766 100644
--- a/arch/arm/dts/tegra30-asus-tf201.dts
+++ b/arch/arm/dts/tegra30-asus-tf201.dts
@@ -6,4 +6,9 @@
 / {
model = "ASUS Transformer Prime TF201";
compatible = "asus,tf201", "nvidia,tegra30";
+
+   usb-phy@7d008000 {
+   /delete-property/ nvidia,xcvr-setup-use-fuses;
+   nvidia,xcvr-setup = <5>;  /* Based on TF201 fuse value - 48 
*/
+   };
 };
diff --git a/arch/arm/dts/tegra30-asus-transformer.dtsi 
b/arch/arm/dts/tegra30-asus-transformer.dtsi
index 4eee1df084..d144a56445 100644
--- a/arch/arm/dts/tegra30-asus-transformer.dtsi
+++ b/arch/arm/dts/tegra30-asus-transformer.dtsi
@@ -123,6 +123,10 @@
status = "okay";
};
 
+   usb-phy@7d008000 {
+   status = "okay";
+   };
+
backlight: backlight {
compatible = "pwm-backlight";
 
-- 
2.39.2



[PATCH v2 03/16] configs: transformer_t30: support booting from USB

2023-08-24 Thread Svyatoslav Ryhel
Change boot logic to primary try to boot from USB in dock, then
from microSD and lastly from eMMC.

Signed-off-by: Svyatoslav Ryhel 
---
 configs/tf600t.config | 2 +-
 configs/transformer_t30_defconfig | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configs/tf600t.config b/configs/tf600t.config
index 89d8db4eb1..18ab4fbd87 100644
--- a/configs/tf600t.config
+++ b/configs/tf600t.config
@@ -1,4 +1,4 @@
 CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-tf600t"
 CONFIG_TRANSFORMER_SPI_BOOT=y
-CONFIG_BOOTCOMMAND="setenv gpio_button 222; if run check_button; then 
poweroff; fi; setenv gpio_button 132; if run check_button; then echo Starting 
SPI flash update ...; run update_spi; fi; run bootcmd_mmc1; run bootcmd_mmc0; 
poweroff;"
+CONFIG_BOOTCOMMAND="setenv gpio_button 222; if run check_button; then 
poweroff; fi; setenv gpio_button 132; if run check_button; then echo Starting 
SPI flash update ...; run update_spi; fi; run bootcmd_usb0; run bootcmd_mmc1; 
run bootcmd_mmc0; poweroff;"
 CONFIG_USB_GADGET_PRODUCT_NUM=0x4d00
diff --git a/configs/transformer_t30_defconfig 
b/configs/transformer_t30_defconfig
index 6fe6f2548d..840431ff38 100644
--- a/configs/transformer_t30_defconfig
+++ b/configs/transformer_t30_defconfig
@@ -22,7 +22,7 @@ CONFIG_BOOTDELAY=0
 CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_KEYED_CTRLC=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="setenv gpio_button 150; if run check_button; then 
poweroff; fi; setenv gpio_button 131; if run check_button; then bootmenu; fi; 
run bootcmd_mmc1; run bootcmd_mmc0; poweroff;"
+CONFIG_BOOTCOMMAND="setenv gpio_button 150; if run check_button; then 
poweroff; fi; setenv gpio_button 131; if run check_button; then bootmenu; fi; 
run bootcmd_usb0; run bootcmd_mmc1; run bootcmd_mmc0; poweroff;"
 CONFIG_SPL_FOOTPRINT_LIMIT=y
 CONFIG_SPL_MAX_FOOTPRINT=0x8000
 # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
-- 
2.39.2



[PATCH v2 02/16] ARM: dts: tf600t: separate from common transformers tree

2023-08-24 Thread Svyatoslav Ryhel
TF600T has significant differences (Tegra DSI and DSI panel,
own power supply system) which makes use of common transformer
device tree complicated.

Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/tegra30-asus-tf600t.dts | 160 +--
 1 file changed, 148 insertions(+), 12 deletions(-)

diff --git a/arch/arm/dts/tegra30-asus-tf600t.dts 
b/arch/arm/dts/tegra30-asus-tf600t.dts
index c9b8f4fa14..fd9d11ca19 100644
--- a/arch/arm/dts/tegra30-asus-tf600t.dts
+++ b/arch/arm/dts/tegra30-asus-tf600t.dts
@@ -1,38 +1,116 @@
 // SPDX-License-Identifier: GPL-2.0
 /dts-v1/;
 
-#include "tegra30-asus-transformer.dtsi"
+#include 
+#include "tegra30.dtsi"
 
 / {
model = "ASUS VivoTab RT TF600T";
compatible = "asus,tf600t", "nvidia,tegra30";
 
+   chosen {
+   stdout-path = 
+   };
+
aliases {
+   i2c0 = _i2c;
+
+   mmc0 =  /* eMMC */
+   mmc1 =  /* uSD slot */
+
+   rtc0 = 
+   rtc1 = "/rtc@7000e000";
+
spi0 = 
+
+   usb0 = 
+   usb1 =  /* Dock USB */
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x8000>;
+   };
+
+   host1x@5000 {
+   dc@5420 {
+   clocks = <_car TEGRA30_CLK_DISP1>,
+<_car TEGRA30_CLK_PLL_D_OUT0>;
+
+   rgb {
+   status = "okay";
+
+   nvidia,panel = <>;
+   };
+   };
+
+   dsia: dsi@5430 {
+   status = "okay";
+
+   avdd-dsi-csi-supply = <_dsi_csi>;
+
+   panel = <>;
+   };
+   };
+
+   uarta: serial@70006000 {
+   status = "okay";
+   };
+
+   pwm: pwm@7000a000 {
+   status = "okay";
};
 
-   /delete-node/ host1x@5000;
+   pwr_i2c: i2c@7000d000 {
+   status = "okay";
+   clock-frequency = <40>;
 
-   pmic_i2c: i2c@7000d000 {
/* Texas Instruments TPS659110 PMIC */
pmic: tps65911@2d {
+   compatible = "ti,tps65911";
+   reg = <0x2d>;
+
+   interrupts = ;
+   #interrupt-cells = <2>;
+   interrupt-controller;
+
+   ti,system-power-controller;
+
+   #gpio-cells = <2>;
+   gpio-controller;
+
regulators {
vdd_1v2_bl: vdd1 {
regulator-name = "vdd_1v2_backlight";
regulator-min-microvolt = <120>;
regulator-max-microvolt = <120>;
+   };
+
+   vcore_lcd: vdd2 {
+   regulator-name = "vcore_lcd";
+   regulator-min-microvolt = <150>;
+   regulator-max-microvolt = <150>;
+   };
+
+   vdd_1v8_vio: vddio {
+   regulator-name = "vdd_1v8_gen";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
regulator-always-on;
regulator-boot-on;
-   ti,regulator-ext-sleep-control = <8>;
};
 
-   /delete-node/ ldo2;
-   /delete-node/ ldo3;
+   /* eMMC VDD */
+   vcore_emmc: ldo1 {
+   regulator-name = "vdd_emmc_core";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
 
/* uSD slot VDDIO */
vddio_usd: ldo5 {
regulator-name = "vddio_sdmmc";
-   regulator-min-microvolt = <180>;
+   regulator-min-microvolt = <330>;
regulator-max-microvolt = <330>;
regulator-always-on;
};
@@ -57,11 +135,65 @@
};
};
 
-   backlight {
+   sdmmc1: sdhci@7800 {
+   status = "okay";
+   bus-width = <4>;
+
+   cd-gpios = < TEGRA_GPIO(I, 5) GPIO_ACTIVE_LOW>;

[PATCH v2 01/16] ARM: dts: p1801-t: separate from common transformers tree

2023-08-24 Thread Svyatoslav Ryhel
P1801-T has significant differences (hdmi panel and backlight,
own power supply system) which makes use of common transformer
device tree complicated.

Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/tegra30-asus-p1801-t.dts | 205 +-
 1 file changed, 198 insertions(+), 7 deletions(-)

diff --git a/arch/arm/dts/tegra30-asus-p1801-t.dts 
b/arch/arm/dts/tegra30-asus-p1801-t.dts
index 4b2dc61713..39f7caf8d0 100644
--- a/arch/arm/dts/tegra30-asus-p1801-t.dts
+++ b/arch/arm/dts/tegra30-asus-p1801-t.dts
@@ -1,18 +1,209 @@
 // SPDX-License-Identifier: GPL-2.0
 /dts-v1/;
 
-#include "tegra30-asus-transformer.dtsi"
+#include 
+#include "tegra30.dtsi"
 
 / {
model = "ASUS Portable AiO P1801-T";
compatible = "asus,p1801-t", "nvidia,tegra30";
 
-   /delete-node/ host1x@5000;
-   /delete-node/ pwm@7000a000;
+   chosen {
+   stdout-path = 
+   };
 
-   /delete-node/ backlight;
-   /delete-node/ panel;
+   aliases {
+   i2c0 = _i2c;
+   i2c1 = _ddc;
 
-   /delete-node/ regulator-pnl;
-   /delete-node/ regulator-bl;
+   mmc0 =  /* eMMC */
+   mmc1 =  /* uSD slot */
+
+   rtc0 = 
+   rtc1 = "/rtc@7000e000";
+
+   usb0 = 
+   usb1 =  /* Mini USB */
+   usb2 =  /* Dock USB */
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x8000>;
+   };
+
+   host1x@5000 {
+   dc@5420 {
+   clocks = <_car TEGRA30_CLK_DISP1>,
+<_car TEGRA30_CLK_PLL_D_OUT0>;
+
+   rgb {
+   status = "okay";
+
+   nvidia,panel = <>;
+   };
+   };
+
+   hdmi: hdmi@5428 {
+   clocks = <_car TEGRA30_CLK_HDMI>,
+<_car TEGRA30_CLK_PLL_D_OUT0>;
+
+   status = "okay";
+
+   hdmi-supply = <_5v0_sys>;
+   pll-supply = <_1v8_vio>;
+   vdd-supply = <_3v3_vdd>;
+
+   /* low: tablet, high: dock */
+   nvidia,hpd-gpio = < TEGRA_GPIO(H, 4) 
GPIO_ACTIVE_LOW>;
+   nvidia,ddc-i2c-bus = <_ddc>;
+   };
+   };
+
+   uarta: serial@70006000 {
+   status = "okay";
+   };
+
+   hdmi_ddc: i2c@7000c700 {
+   status = "okay";
+   clock-frequency = <33000>;
+   };
+
+   pwr_i2c: i2c@7000d000 {
+   status = "okay";
+   clock-frequency = <40>;
+
+   /* Texas Instruments TPS659110 PMIC */
+   pmic: tps65911@2d {
+   compatible = "ti,tps65911";
+   reg = <0x2d>;
+
+   interrupts = ;
+   #interrupt-cells = <2>;
+   interrupt-controller;
+
+   ti,system-power-controller;
+
+   #gpio-cells = <2>;
+   gpio-controller;
+
+   regulators {
+   vdd_1v8_vio: vddio {
+   regulator-name = "vdd_1v8_gen";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   /* eMMC VDD */
+   vcore_emmc: ldo1 {
+   regulator-name = "vdd_emmc_core";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+
+   /* uSD slot VDD */
+   vdd_usd: ldo2 {
+   regulator-name = "vdd_usd";
+   regulator-min-microvolt = <310>;
+   regulator-max-microvolt = <310>;
+   };
+
+   /* uSD slot VDDIO */
+   vddio_usd: ldo3 {
+   regulator-name = "vddio_usd";
+   regulator-min-microvolt = <310>;
+   regulator-max-microvolt = <310>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+   };
+   };
+   };
+
+   sdmmc1: sdhci@7800 {
+   

[PATCH v2 00/16] General tegra and board improvements

2023-08-24 Thread Svyatoslav Ryhel
This patchset follows Transformers, Grouper, LG X3 and Endeavoru
bringup and contains changes from v9 of previous patchset and
some new improvenets.

List of changes:
- separated tf600t and p1801-t device trees since they use
  different video path bindings
- enabled booting from usb devices (USB > SD > eMMC)
- fixed tf201 dock usb line binding
- removed transformer board pmic gpios setup
- refresh USB option converted into enter console for transformers
- updated device trees for future DM PMIC migration
- re-synced defconfigs
- added base voltages setup from board for t114 same as on t30
- adjusted ebtupdate to work with non-encrypted re-crypted devices
- attempt to move setup of some env values to arch
- config fragments moved to board/vendor/device/configs/ dir
  (requires pending u-boot patch)

./tools/buildman/buildman tegra
Building current source for 30 boards (12 threads, 1 job per thread)
   3000 /30 colibri_t30
Completed: 30 total built, 30 newly), duration 0:05:15, rate 0.10

---
Changes from v1
- tap and trim values for t210 commit moved to dedicated patchset
- TZ manipulations dropped for now
- switched platform name inline with linux look: tegraXYZ
---

Svyatoslav Ryhel (16):
  ARM: dts: p1801-t: separate from common transformers tree
  ARM: dts: tf600t: separate from common transformers tree
  configs: transformer_t30: support booting from USB
  ARM: dts: tf201: configure dock USB phy
  board: asus: transformer-t30: remove PMIC GPIOs configuration
  configs: transformer_t30: convert bootmenu option
  ARM: dts: transformer-t30: complete missing bindings
  ARM: dts: endeavoru: complete missing bindings
  ARM: dts: lg-x3: complete missing bindings
  ARM: dts: grouper: complete missing bindings
  configs: transformer_t30: grouper: lg-x3: endeavoru: sync defconfigs
  ARM: tegra114: enable base voltages setup from board
  ARM: tegra20: tegra30: support EBTUPDATE on non-encrypted devices
  ARM: tegra: board2: add generic late init
  board: tegra30: remove nvidia_board_late_init calls
  board: asus: lg: move config fragments into device boards

 arch/arm/dts/tegra30-asus-grouper-common.dtsi |   5 +-
 .../dts/tegra30-asus-nexus7-grouper-E1565.dts |   5 +-
 .../dts/tegra30-asus-nexus7-grouper-PM269.dts |  11 +-
 .../dts/tegra30-asus-nexus7-tilapia-E1565.dts |   5 +-
 arch/arm/dts/tegra30-asus-p1801-t.dts | 205 +-
 arch/arm/dts/tegra30-asus-tf201.dts   |   5 +
 arch/arm/dts/tegra30-asus-tf600t.dts  | 160 +-
 arch/arm/dts/tegra30-asus-transformer.dtsi|  24 +-
 arch/arm/dts/tegra30-htc-endeavoru.dts|  15 +-
 arch/arm/dts/tegra30-lg-x3.dtsi   |  11 +-
 arch/arm/mach-tegra/board2.c  |  43 
 arch/arm/mach-tegra/tegra114/cpu.c|   5 +
 arch/arm/mach-tegra/tegra20/bct.c |  30 ++-
 arch/arm/mach-tegra/tegra30/bct.c |  30 ++-
 board/asus/grouper/MAINTAINERS|   3 -
 .../grouper/configs}/grouper_E1565.config |   0
 .../grouper/configs}/grouper_PM269.config |   0
 .../asus/grouper/configs}/tilapia.config  |   0
 board/asus/grouper/grouper.c  |  12 -
 board/asus/transformer-t30/MAINTAINERS|   7 -
 .../transformer-t30/configs}/p1801-t.config   |   0
 .../transformer-t30/configs}/tf201.config |   0
 .../transformer-t30/configs}/tf300t.config|   0
 .../transformer-t30/configs}/tf300tg.config   |   0
 .../transformer-t30/configs}/tf300tl.config   |   0
 .../transformer-t30/configs}/tf600t.config|   3 +-
 .../transformer-t30/configs}/tf700t.config|   0
 board/asus/transformer-t30/transformer-t30.c  |  37 
 board/htc/endeavoru/endeavoru.c   |  12 -
 board/lg/x3-t30/MAINTAINERS   |   2 -
 .../lg/x3-t30/configs}/p880.config|   0
 .../lg/x3-t30/configs}/p895.config|   0
 board/lg/x3-t30/x3-t30.c  |  11 -
 configs/endeavoru_defconfig   |   2 -
 configs/grouper_common_defconfig  |   4 -
 configs/transformer_t30_defconfig |   4 +-
 configs/x3_t30_defconfig  |   2 -
 include/configs/transformer-common.h  |   7 +-
 38 files changed, 499 insertions(+), 161 deletions(-)
 rename {configs => board/asus/grouper/configs}/grouper_E1565.config (100%)
 rename {configs => board/asus/grouper/configs}/grouper_PM269.config (100%)
 rename {configs => board/asus/grouper/configs}/tilapia.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/p1801-t.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf201.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf300t.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf300tg.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf300tl.config (100%)
 rename {configs => board/asus/transformer-t30/configs}/tf600t.config (77%)
 rename {configs => 

Re: [PATCH 1/2] net: ti: am65-cpsw-nuss: Workaround for buggy PHY/Board

2023-08-24 Thread Roger Quadros



On 24/08/2023 21:24, Tom Rini wrote:
> On Thu, Aug 24, 2023 at 11:34:29PM +0530, Siddharth Vadapalli wrote:
>> Hello Roger,
>>
>> On 22-08-2023 17:43, Roger Quadros wrote:
>>> Beagleplay has a buggy Ethernet PHY implementation for the Gigabit
>>> PHY in the sense that it is non responsive over MDIO immediately
>>> after power-up/reset.
>>>
>>> We need to either try multiple times or wait sufficiently long enough
>>> (couple of 10s of ms?) before the PHY begins to respond correctly.
>>>
>>> One theory is that the PHY is configured to operate on MDIO address 0
>>> which it treats as a special broadcast address.
>>>
>>> Datasheet states:
>>> "PHYAD (config pins) sets the PHY address for the device.
>>> The RTL8211F(I)/RTL8211FD(I) supports PHY addresses from 0x01 to 0x07.
>>> Note 1: An MDIO command with PHY address=0 is a broadcast from the MAC;
>>> each PHY device should respond."
>>>
>>> This issue is not seen with the other PHY (different make) on the board
>>> which is configured for address 0x1.
>>>
>>> As a woraround we try to probe the PHY multiple times instead of giving
>>> up on the first attempt.
>>>
>>> Signed-off-by: Roger Quadros 
>>> ---
>>>  drivers/net/ti/am65-cpsw-nuss.c | 19 ++-
>>>  1 file changed, 14 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/net/ti/am65-cpsw-nuss.c 
>>> b/drivers/net/ti/am65-cpsw-nuss.c
>>> index 51a8167d14..4f8a2f9b93 100644
>>> --- a/drivers/net/ti/am65-cpsw-nuss.c
>>> +++ b/drivers/net/ti/am65-cpsw-nuss.c
>>> @@ -27,6 +27,7 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
>>>  
>>>  #include "cpsw_mdio.h"
>>>  
>>> @@ -678,14 +679,22 @@ static int am65_cpsw_phy_init(struct udevice *dev)
>>> struct am65_cpsw_priv *priv = dev_get_priv(dev);
>>> struct am65_cpsw_common *cpsw_common = priv->cpsw_common;
>>> struct eth_pdata *pdata = dev_get_plat(dev);
>>> -   struct phy_device *phydev;
>>> u32 supported = PHY_GBIT_FEATURES;
>>> +   struct phy_device *phydev;
>>> +   int tries;
>>> int ret;
>>>  
>>> -   phydev = phy_connect(cpsw_common->bus,
>>> -priv->phy_addr,
>>> -priv->dev,
>>> -pdata->phy_interface);
>>> +   /* Some boards (e.g. beagleplay) don't work on first go */
>>> +   for (tries = 1; tries <= 5; tries++) {
>>> +   phydev = phy_connect(cpsw_common->bus,
>>> +priv->phy_addr,
>>> +priv->dev,
>>> +pdata->phy_interface);
>>> +   if (phydev)
>>> +   break;
>>> +
>>> +   mdelay(10);
>>> +   }
>>
>> After rethinking about the above implementation and the second patch of
>> this series, the second patch could be dropped altogether if the
>> following implementation is acceptable:
>>
>> phydev = phy_connect(cpsw_common->bus,
>>   priv->phy_addr,
>>   priv->dev,
>>   pdata->phy_interface);
>>
>> if (!phydev) {
>>  /* Some boards (e.g. beagleplay) don't work on first go */
>>  mdelay(50);
>>  phydev = phy_connect(cpsw_common->bus,
>>   priv->phy_addr,
>>   priv->dev,
>>   pdata->phy_interface);
>> }
>>
>> if (!phydev) {
>>  dev_err(dev, "phy_connect() failed\n");
>> ...
>>
>> With this, there would be at most one "PHY not found" print, which
>> should be fine. The mdelay value of 50 could be replaced with a
>> sufficiently large value which guarantees success for Beagleplay.
> 
> Ramon, thoughts?
> 

Even a single "PHY not found" print is not OK. It looks like an
error while it should not.

The correct solution is to use the MDIO uclass framework and add
some generic handling in the class driver. drivers/net/eth-phy-uclass.c

We could provide the delay time in the 'reset-deassert-us' property.
Although I'm not sure if this is the correct property for this case
as there is no RESET GPIO on the board. What we really want is delay
from power-on-reset. Which means we might have to introduce a new property
and use time from boot to determine if PHY is ready or not?

NOTE: PHY ready time is different for hardware reset and power-on-reset.
50ms vs 150ms

-- 
cheers,
-roger


[PATCH] arm: kirkwood: Pogo v4: Enable LTO

2023-08-24 Thread Tony Dinh
Enable building Pogo V4 u-boot image with LTO, which results in about 30K
reduction in size.

Signed-off-by: Tony Dinh 
---

 configs/pogo_v4_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/pogo_v4_defconfig b/configs/pogo_v4_defconfig
index 3e3e811543..ad36da712b 100644
--- a/configs/pogo_v4_defconfig
+++ b/configs/pogo_v4_defconfig
@@ -16,6 +16,7 @@ CONFIG_DEFAULT_DEVICE_TREE="kirkwood-pogoplug-series-4"
 CONFIG_SYS_PROMPT="Pogo_V4> "
 CONFIG_IDENT_STRING="\nPogoplug V4"
 CONFIG_SYS_LOAD_ADDR=0x80
+CONFIG_LTO=y
 CONFIG_PCI=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTSTAGE=y
-- 
2.39.2



[PATCH v2] arm: imx: imx8m: add optee configuration to ft_system_setup

2023-08-24 Thread Tim Harvey
If optee is detected configure it in the Linux device-tree:
 - add /firmware/optee node
 - add /reserved-memory nodes for optee_core and optee_shm

Signed-off-by: Tim Harvey 
Reviewed-by: Peng Fan 
---
v2: add rb tag for Peng
---
 arch/arm/mach-imx/imx8m/soc.c | 78 ++-
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index d5254886bed9..5d92d9c982a4 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -1245,6 +1245,82 @@ static int fixup_thermal_trips(void *blob, const char 
*name)
return 0;
 }
 
+#define OPTEE_SHM_SIZE 0x0040
+static int ft_add_optee_node(void *fdt, struct bd_info *bd)
+{
+   struct fdt_memory carveout;
+   const char *path, *subpath;
+   phys_addr_t optee_start;
+   size_t optee_size;
+   int offs;
+   int ret;
+
+   /*
+* No TEE space allocated indicating no TEE running, so no
+* need to add optee node in dts
+*/
+   if (!rom_pointer[1])
+   return 0;
+
+   optee_start = (phys_addr_t)rom_pointer[0];
+   optee_size = rom_pointer[1] - OPTEE_SHM_SIZE;
+
+   offs = fdt_increase_size(fdt, 512);
+   if (offs) {
+   printf("No Space for dtb\n");
+   return 1;
+   }
+
+   path = "/firmware";
+   offs = fdt_path_offset(fdt, path);
+   if (offs < 0) {
+   path = "/";
+   offs = fdt_path_offset(fdt, path);
+
+   if (offs < 0) {
+   printf("Could not find root node.\n");
+   return offs;
+   }
+
+   subpath = "firmware";
+   offs = fdt_add_subnode(fdt, offs, subpath);
+   if (offs < 0) {
+   printf("Could not create %s node.\n", subpath);
+   return offs;
+   }
+   }
+
+   subpath = "optee";
+   offs = fdt_add_subnode(fdt, offs, subpath);
+   if (offs < 0) {
+   printf("Could not create %s node.\n", subpath);
+   return offs;
+   }
+
+   fdt_setprop_string(fdt, offs, "compatible", "linaro,optee-tz");
+   fdt_setprop_string(fdt, offs, "method", "smc");
+
+   carveout.start = optee_start,
+   carveout.end = optee_start + optee_size - 1,
+   ret = fdtdec_add_reserved_memory(fdt, "optee_core", , NULL, 0,
+NULL, FDTDEC_RESERVED_MEMORY_NO_MAP);
+   if (ret < 0) {
+   printf("Could not create optee_core node.\n");
+   return ret;
+   }
+
+   carveout.start = optee_start + optee_size;
+   carveout.end = optee_start + optee_size + OPTEE_SHM_SIZE - 1;
+   ret = fdtdec_add_reserved_memory(fdt, "optee_shm", , NULL, 0,
+NULL, FDTDEC_RESERVED_MEMORY_NO_MAP);
+   if (ret < 0) {
+   printf("Could not create optee_shm node.\n");
+   return ret;
+   }
+
+   return 0;
+}
+
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
 #ifdef CONFIG_IMX8MQ
@@ -1394,7 +1470,7 @@ usb_modify_speed:
fixup_thermal_trips(blob, "soc-thermal"))
printf("Failed to update soc-thermal trip(s)");
 
-   return 0;
+   return ft_add_optee_node(blob, bd);
 }
 #endif
 
-- 
2.25.1



[PATCH v2] arm: dts: imx8m: move CAAM nodes into common u-boot.dtsi

2023-08-24 Thread Tim Harvey
Move the crypto and sec_jr* nodes from board-specific
u-boot.dtsi files into the common files. Additionally protect the
nodes with ifdef CONFIG_FSL_CAAM as they don't serve any purpose if
that is not enabled.

Signed-off-by: Tim Harvey 
---
v2:
 - fix invalid ifdef
 - add rb tags from Fabio and Peng
---
 arch/arm/dts/imx8mm-evk-u-boot.dtsi   | 16 ---
 .../dts/imx8mm-kontron-bl-common-u-boot.dtsi  | 16 ---
 arch/arm/dts/imx8mm-u-boot.dtsi   | 20 +++
 arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi  | 16 ---
 arch/arm/dts/imx8mn-u-boot.dtsi   | 20 +++
 arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi| 16 ---
 arch/arm/dts/imx8mp-evk-u-boot.dtsi   | 16 ---
 .../imx8mp-icore-mx8mp-edimm2.2-u-boot.dtsi   | 16 ---
 arch/arm/dts/imx8mp-u-boot.dtsi   | 20 +++
 .../dts/imx8mp-verdin-wifi-dev-u-boot.dtsi| 16 ---
 10 files changed, 60 insertions(+), 112 deletions(-)

diff --git a/arch/arm/dts/imx8mm-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mm-evk-u-boot.dtsi
index 155670da18d1..9a5b0795133b 100644
--- a/arch/arm/dts/imx8mm-evk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-evk-u-boot.dtsi
@@ -65,22 +65,6 @@
bootph-pre-ram;
 };
 
- {
-   bootph-pre-ram;
-};
-
-_jr0 {
-   bootph-pre-ram;
-};
-
-_jr1 {
-   bootph-pre-ram;
-};
-
-_jr2 {
-   bootph-pre-ram;
-};
-
  {
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi 
b/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
index 1ad9d49a1118..ae542fdcffad 100644
--- a/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
@@ -18,22 +18,6 @@
};
 };
 
- {
-   bootph-pre-ram;
-};
-
-_jr0 {
-   bootph-pre-ram;
-};
-
-_jr1 {
-   bootph-pre-ram;
-};
-
-_jr2 {
-   bootph-pre-ram;
-};
-
  {
bootph-pre-ram;
bootph-all;
diff --git a/arch/arm/dts/imx8mm-u-boot.dtsi b/arch/arm/dts/imx8mm-u-boot.dtsi
index a843bb851eaf..0bd7ad980b66 100644
--- a/arch/arm/dts/imx8mm-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-u-boot.dtsi
@@ -18,6 +18,12 @@
 #endif
 };
 
+#ifdef CONFIG_FSL_CAAM
+ {
+   bootph-pre-ram;
+};
+#endif
+
  {
bootph-all;
bootph-pre-ram;
@@ -216,6 +222,20 @@
bootph-pre-ram;
 };
 
+#ifdef CONFIG_FSL_CAAM
+_jr0 {
+   bootph-pre-ram;
+};
+
+_jr1 {
+   bootph-pre-ram;
+};
+
+_jr2 {
+   bootph-pre-ram;
+};
+#endif
+
  {
bootph-all;
bootph-pre-ram;
diff --git a/arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi
index 315714f39848..c31f3dec3de4 100644
--- a/arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi
@@ -57,22 +57,6 @@
bootph-pre-ram;
 };
 
- {
-   bootph-pre-ram;
-};
-
-_jr0 {
-   bootph-pre-ram;
-};
-
-_jr1 {
-   bootph-pre-ram;
-};
-
-_jr2 {
-   bootph-pre-ram;
-};
-
  {
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi
index 86c9a6cd67f0..3a9e4c16281e 100644
--- a/arch/arm/dts/imx8mn-u-boot.dtsi
+++ b/arch/arm/dts/imx8mn-u-boot.dtsi
@@ -54,6 +54,12 @@
/delete-property/ assigned-clock-rates;
 };
 
+#ifdef CONFIG_FSL_CAAM
+ {
+   bootph-pre-ram;
+};
+#endif
+
  {
bootph-pre-ram;
 };
@@ -63,6 +69,20 @@
bootph-all;
 };
 
+#ifdef CONFIG_FSL_CAAM
+_jr0 {
+   bootph-pre-ram;
+};
+
+_jr1 {
+   bootph-pre-ram;
+};
+
+_jr2 {
+   bootph-pre-ram;
+};
+#endif
+
  {
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi 
b/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
index c69f7c9c32c0..393fd8ec2e5b 100644
--- a/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
@@ -21,10 +21,6 @@
bootph-pre-ram;
 };
 
- {
-   bootph-pre-ram;
-};
-
  {
/delete-property/ assigned-clocks;
/delete-property/ assigned-clock-parents;
@@ -131,18 +127,6 @@
u-boot,off-on-delay-us = <2>;
 };
 
-_jr0 {
-   bootph-pre-ram;
-};
-
-_jr1 {
-   bootph-pre-ram;
-};
-
-_jr2 {
-   bootph-pre-ram;
-};
-
  {
compatible = "tcg,tpm_tis-spi";
 };
diff --git a/arch/arm/dts/imx8mp-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
index 17965c58ba10..6d9b229989ac 100644
--- a/arch/arm/dts/imx8mp-evk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
@@ -65,22 +65,6 @@
bootph-pre-ram;
 };
 
- {
-   bootph-pre-ram;
-};
-
-_jr0 {
-   bootph-pre-ram;
-};
-
-_jr1 {
-   bootph-pre-ram;
-};
-
-_jr2 {
-   bootph-pre-ram;
-};
-
  {
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/imx8mp-icore-mx8mp-edimm2.2-u-boot.dtsi 
b/arch/arm/dts/imx8mp-icore-mx8mp-edimm2.2-u-boot.dtsi
index fe20938af536..cf2a87a9b903 100644
--- a/arch/arm/dts/imx8mp-icore-mx8mp-edimm2.2-u-boot.dtsi
+++ 

[PATCH v2 3/3] arm: dts: imx8mn: protect the firmware/optee node with ifdef

2023-08-24 Thread Tim Harvey
There is no need to include the firmware/optee node if the optee
driver is not enabled.

Signed-off-by: Tim Harvey 
Reviewed-by: Fabio Estevam 
---
v2: added Fabio's rb tag
---
 arch/arm/dts/imx8mn-u-boot.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi
index 5046b38e4e29..86c9a6cd67f0 100644
--- a/arch/arm/dts/imx8mn-u-boot.dtsi
+++ b/arch/arm/dts/imx8mn-u-boot.dtsi
@@ -8,12 +8,14 @@
multiple-images;
};
 
+#ifdef CONFIG_OPTEE
firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
+#endif
 
wdt-reboot {
compatible = "wdt-reboot";
-- 
2.25.1



[PATCH v2 2/3] arm: dts: imx8mp: move firmware/optee node to common imx8mp-u-boot.dtsi

2023-08-24 Thread Tim Harvey
Move the firmware/optee node to the common imx8mp-u-boot.dtsi and
protect it with an ifdef CONFIG_OPTEE as it is a meaningless node
without the optee driver enabled.

Signed-off-by: Tim Harvey 
Reviewed-by: Fabio Estevam 
---
v2: added Fabio's rb tag
---
 arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi   | 7 ---
 arch/arm/dts/imx8mp-evk-u-boot.dtsi  | 6 --
 arch/arm/dts/imx8mp-icore-mx8mp-edimm2.2-u-boot.dtsi | 7 ---
 arch/arm/dts/imx8mp-rsb3720-a1-u-boot.dtsi   | 7 ---
 arch/arm/dts/imx8mp-u-boot.dtsi  | 9 +
 arch/arm/dts/imx8mp-venice-gw74xx-u-boot.dtsi| 7 ---
 arch/arm/dts/imx8mp-verdin-wifi-dev-u-boot.dtsi  | 7 ---
 7 files changed, 9 insertions(+), 41 deletions(-)

diff --git a/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi 
b/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
index b56f3a2bd2e1..c69f7c9c32c0 100644
--- a/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
@@ -11,13 +11,6 @@
wdt = <>;
bootph-pre-ram;
};
-
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
 };
 
 &{/soc@0/bus@3080/i2c@30a2/pmic@25} {
diff --git a/arch/arm/dts/imx8mp-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
index 6784ed2e7c92..17965c58ba10 100644
--- a/arch/arm/dts/imx8mp-evk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
@@ -11,12 +11,6 @@
wdt = <>;
bootph-pre-ram;
};
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
 };
 
 _usdhc2_vmmc {
diff --git a/arch/arm/dts/imx8mp-icore-mx8mp-edimm2.2-u-boot.dtsi 
b/arch/arm/dts/imx8mp-icore-mx8mp-edimm2.2-u-boot.dtsi
index d411cf79e85d..fe20938af536 100644
--- a/arch/arm/dts/imx8mp-icore-mx8mp-edimm2.2-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-icore-mx8mp-edimm2.2-u-boot.dtsi
@@ -12,13 +12,6 @@
wdt = <>;
bootph-pre-ram;
};
-
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
 };
 
 _usdhc2_vmmc {
diff --git a/arch/arm/dts/imx8mp-rsb3720-a1-u-boot.dtsi 
b/arch/arm/dts/imx8mp-rsb3720-a1-u-boot.dtsi
index f3fb44046d5c..8f1df232b1b7 100644
--- a/arch/arm/dts/imx8mp-rsb3720-a1-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-rsb3720-a1-u-boot.dtsi
@@ -12,13 +12,6 @@
wdt = <>;
bootph-pre-ram;
};
-
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
 };
 
  {
diff --git a/arch/arm/dts/imx8mp-u-boot.dtsi b/arch/arm/dts/imx8mp-u-boot.dtsi
index 36e7444a627b..b2f213e3e706 100644
--- a/arch/arm/dts/imx8mp-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-u-boot.dtsi
@@ -8,6 +8,15 @@
binman: binman {
multiple-images;
};
+
+#ifdef CONFIG_OPTEE
+   firmware {
+   optee {
+   compatible = "linaro,optee-tz";
+   method = "smc";
+   };
+   };
+#endif
 };
 
  {
diff --git a/arch/arm/dts/imx8mp-venice-gw74xx-u-boot.dtsi 
b/arch/arm/dts/imx8mp-venice-gw74xx-u-boot.dtsi
index 501bc0ce200e..240fbc1b568f 100644
--- a/arch/arm/dts/imx8mp-venice-gw74xx-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-venice-gw74xx-u-boot.dtsi
@@ -6,13 +6,6 @@
 #include "imx8mp-u-boot.dtsi"
 
 / {
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
-
wdt-reboot {
compatible = "wdt-reboot";
bootph-pre-ram;
diff --git a/arch/arm/dts/imx8mp-verdin-wifi-dev-u-boot.dtsi 
b/arch/arm/dts/imx8mp-verdin-wifi-dev-u-boot.dtsi
index 0162f9b2da37..fc87d3f4035b 100644
--- a/arch/arm/dts/imx8mp-verdin-wifi-dev-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-verdin-wifi-dev-u-boot.dtsi
@@ -6,13 +6,6 @@
 #include "imx8mp-u-boot.dtsi"
 
 / {
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
-
wdt-reboot {
compatible = "wdt-reboot";
bootph-pre-ram;
-- 
2.25.1



[PATCH v2 1/3] arm: dts: imx8mm: move firmware/optee node to common imx8mm-u-boot.dtsi

2023-08-24 Thread Tim Harvey
Move the firmware/optee node to the common imx8mm-u-boot.dtsi and
protect it with an ifdef CONFIG_OPTEE as it is a meaningless node
without the optee driver enabled.

Signed-off-by: Tim Harvey 
Reviewed-by: Fabio Estevam 
---
v2: added Fabio's rb tag
---
 arch/arm/dts/imx8mm-cl-iot-gate-optee-u-boot.dtsi | 7 ---
 arch/arm/dts/imx8mm-cl-iot-gate-u-boot.dtsi   | 7 ---
 arch/arm/dts/imx8mm-evk-u-boot.dtsi   | 7 ---
 arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi | 7 ---
 arch/arm/dts/imx8mm-phg-u-boot.dtsi   | 7 ---
 arch/arm/dts/imx8mm-u-boot.dtsi   | 9 +
 arch/arm/dts/imx8mm-verdin-wifi-dev-u-boot.dtsi   | 7 ---
 7 files changed, 9 insertions(+), 42 deletions(-)

diff --git a/arch/arm/dts/imx8mm-cl-iot-gate-optee-u-boot.dtsi 
b/arch/arm/dts/imx8mm-cl-iot-gate-optee-u-boot.dtsi
index 484e31824b85..d12ce6069cc7 100644
--- a/arch/arm/dts/imx8mm-cl-iot-gate-optee-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-cl-iot-gate-optee-u-boot.dtsi
@@ -6,13 +6,6 @@
 #include "imx8mm-u-boot.dtsi"
 
 / {
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
-
wdt-reboot {
compatible = "wdt-reboot";
bootph-pre-ram;
diff --git a/arch/arm/dts/imx8mm-cl-iot-gate-u-boot.dtsi 
b/arch/arm/dts/imx8mm-cl-iot-gate-u-boot.dtsi
index 1878c4e13fbe..219504f61105 100644
--- a/arch/arm/dts/imx8mm-cl-iot-gate-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-cl-iot-gate-u-boot.dtsi
@@ -6,13 +6,6 @@
 #include "imx8mm-u-boot.dtsi"
 
 / {
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
-
wdt-reboot {
compatible = "wdt-reboot";
bootph-pre-ram;
diff --git a/arch/arm/dts/imx8mm-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mm-evk-u-boot.dtsi
index 13688ec0d0f2..155670da18d1 100644
--- a/arch/arm/dts/imx8mm-evk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-evk-u-boot.dtsi
@@ -11,13 +11,6 @@
wdt = <>;
bootph-pre-ram;
};
-
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
 };
 
  {
diff --git a/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi 
b/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
index 65dfd33725ee..1ad9d49a1118 100644
--- a/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
@@ -16,13 +16,6 @@
wdt = <>;
bootph-pre-ram;
};
-
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
 };
 
  {
diff --git a/arch/arm/dts/imx8mm-phg-u-boot.dtsi 
b/arch/arm/dts/imx8mm-phg-u-boot.dtsi
index 3ced97cfaafa..c9e0b4420500 100644
--- a/arch/arm/dts/imx8mm-phg-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-phg-u-boot.dtsi
@@ -11,13 +11,6 @@
wdt = <>;
bootph-pre-ram;
};
-
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
 };
 
  {
diff --git a/arch/arm/dts/imx8mm-u-boot.dtsi b/arch/arm/dts/imx8mm-u-boot.dtsi
index 035282bf0b00..a843bb851eaf 100644
--- a/arch/arm/dts/imx8mm-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-u-boot.dtsi
@@ -7,6 +7,15 @@
binman: binman {
multiple-images;
};
+
+#ifdef CONFIG_OPTEE
+   firmware {
+   optee {
+   compatible = "linaro,optee-tz";
+   method = "smc";
+   };
+   };
+#endif
 };
 
  {
diff --git a/arch/arm/dts/imx8mm-verdin-wifi-dev-u-boot.dtsi 
b/arch/arm/dts/imx8mm-verdin-wifi-dev-u-boot.dtsi
index 2b268f55cb95..24e565a06c2f 100644
--- a/arch/arm/dts/imx8mm-verdin-wifi-dev-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-verdin-wifi-dev-u-boot.dtsi
@@ -6,13 +6,6 @@
 #include "imx8mm-u-boot.dtsi"
 
 / {
-   firmware {
-   optee {
-   compatible = "linaro,optee-tz";
-   method = "smc";
-   };
-   };
-
wdt-reboot {
compatible = "wdt-reboot";
bootph-pre-ram;
-- 
2.25.1



[PATCH v2 2/2] mmc: tegra: get default-tap and default-trim from device tree

2023-08-24 Thread Svyatoslav Ryhel
Default-tap and default-trim values are used for eMMC setup
mostly on T114+ devices. As for now, those values are hardcoded
for T210 and ignored for all other Tegra generations. Fix this
by passing tap and trim values from dts.

Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/include/asm/arch-tegra/tegra_mmc.h | 17 +++
 drivers/mmc/tegra_mmc.c | 52 +++--
 2 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/arch/arm/include/asm/arch-tegra/tegra_mmc.h 
b/arch/arm/include/asm/arch-tegra/tegra_mmc.h
index d6a55764ba..750c7d809e 100644
--- a/arch/arm/include/asm/arch-tegra/tegra_mmc.h
+++ b/arch/arm/include/asm/arch-tegra/tegra_mmc.h
@@ -128,21 +128,22 @@ struct tegra_mmc {
 
 /* SDMMC1/3 settings from SDMMCx Initialization Sequence of TRM */
 #define MEMCOMP_PADCTRL_VREF   7
-#define AUTO_CAL_ENABLE(1 << 29)
-#define AUTO_CAL_ACTIVE(1 << 31)
-#define AUTO_CAL_START (1 << 31)
+#define AUTO_CAL_ENABLEBIT(29)
+#define AUTO_CAL_ACTIVEBIT(31)
+#define AUTO_CAL_START BIT(31)
+
 #if defined(CONFIG_TEGRA210)
 #define AUTO_CAL_PD_OFFSET (0x7D << 8)
 #define AUTO_CAL_PU_OFFSET (0 << 0)
-#define IO_TRIM_BYPASS_MASK(1 << 2)
-#define TRIM_VAL_SHIFT 24
-#define TRIM_VAL_MASK  (0x1F << TRIM_VAL_SHIFT)
-#define TAP_VAL_SHIFT  16
-#define TAP_VAL_MASK   (0xFF << TAP_VAL_SHIFT)
 #else
 #define AUTO_CAL_PD_OFFSET (0x70 << 8)
 #define AUTO_CAL_PU_OFFSET (0x62 << 0)
 #endif
 
+#define TRIM_VAL_SHIFT 24
+#define TRIM_VAL_MASK  (0x1F << TRIM_VAL_SHIFT)
+#define TAP_VAL_SHIFT  16
+#define TAP_VAL_MASK   (0xFF << TAP_VAL_SHIFT)
+
 #endif /* __ASSEMBLY__ */
 #endif /* __TEGRA_MMC_H_ */
diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c
index f76fee3ea0..d507adbb36 100644
--- a/drivers/mmc/tegra_mmc.c
+++ b/drivers/mmc/tegra_mmc.c
@@ -37,6 +37,9 @@ struct tegra_mmc_priv {
unsigned int version;   /* SDHCI spec. version */
unsigned int clock; /* Current clock (MHz) */
int mmc_id; /* peripheral id */
+
+   int tap_value;
+   int trim_value;
 };
 
 static void tegra_mmc_set_power(struct tegra_mmc_priv *priv,
@@ -526,31 +529,6 @@ static void tegra_mmc_pad_init(struct tegra_mmc_priv *priv)
printf("%s: Warning: Autocal timed out!\n", __func__);
/* TBD: Set CFG2TMC_SDMMC1_PAD_CAL_DRV* regs here */
}
-
-#if defined(CONFIG_TEGRA210)
-   u32 tap_value, trim_value;
-
-   /* Set tap/trim values for SDMMC1/3 @ <48MHz here */
-   val = readl(>reg->venspictl); /* aka VENDOR_SYS_SW_CNTL */
-   val &= IO_TRIM_BYPASS_MASK;
-   if (id == PERIPH_ID_SDMMC1) {
-   tap_value = 4;  /* default */
-   if (val)
-   tap_value = 3;
-   trim_value = 2;
-   } else {/* SDMMC3 */
-   tap_value = 3;
-   trim_value = 3;
-   }
-
-   val = readl(>reg->venclkctl);
-   val &= ~TRIM_VAL_MASK;
-   val |= (trim_value << TRIM_VAL_SHIFT);
-   val &= ~TAP_VAL_MASK;
-   val |= (tap_value << TAP_VAL_SHIFT);
-   writel(val, >reg->venclkctl);
-   debug("%s: VENDOR_CLOCK_CNTRL = 0x%08X\n", __func__, val);
-#endif /* T210 */
 #endif /* T30/T210 */
 }
 
@@ -588,6 +566,22 @@ static void tegra_mmc_reset(struct tegra_mmc_priv *priv, 
struct mmc *mmc)
 
/* Make sure SDIO pads are set up */
tegra_mmc_pad_init(priv);
+
+   if (!IS_ERR_VALUE(priv->tap_value) ||
+   !IS_ERR_VALUE(priv->trim_value)) {
+   u32 val;
+
+   val = readl(>reg->venclkctl);
+
+   val &= ~TRIM_VAL_MASK;
+   val |= (priv->trim_value << TRIM_VAL_SHIFT);
+
+   val &= ~TAP_VAL_MASK;
+   val |= (priv->tap_value << TAP_VAL_SHIFT);
+
+   writel(val, >reg->venclkctl);
+   debug("%s: VENDOR_CLOCK_CNTRL = 0x%08X\n", __func__, val);
+   }
 }
 
 static int tegra_mmc_init(struct udevice *dev)
@@ -742,6 +736,14 @@ static int tegra_mmc_probe(struct udevice *dev)
if (dm_gpio_is_valid(>pwr_gpio))
dm_gpio_set_value(>pwr_gpio, 1);
 
+   ret = dev_read_u32(dev, "nvidia,default-tap", >tap_value);
+   if (ret)
+   priv->tap_value = ret;
+
+   ret = dev_read_u32(dev, "nvidia,default-trim", >trim_value);
+   if (ret)
+   priv->trim_value = ret;
+
upriv->mmc = >mmc;
 
return tegra_mmc_init(dev);
-- 
2.39.2



[PATCH v2 1/2] ARM: tegra210: set default-tap and default-trim values in sdhci nodes

2023-08-24 Thread Svyatoslav Ryhel
Tegra MMC driver has hardcoded tap and trim values as for now.
Set default-tap and default-trim values in sdhci nodes to avoid
regressions in case Tegra MMC driver is upated to use dts values.

Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/dts/tegra210.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/tegra210.dtsi b/arch/arm/dts/tegra210.dtsi
index a521a43d6c..28ecd2b467 100644
--- a/arch/arm/dts/tegra210.dtsi
+++ b/arch/arm/dts/tegra210.dtsi
@@ -704,6 +704,8 @@
clock-names = "sdhci";
resets = <_car 14>;
reset-names = "sdhci";
+   nvidia,default-tap = <0x2>;
+   nvidia,default-trim = <0x4>;
status = "disabled";
};
 
@@ -715,6 +717,8 @@
clock-names = "sdhci";
resets = <_car 9>;
reset-names = "sdhci";
+   nvidia,default-tap = <0x8>;
+   nvidia,default-trim = <0x0>;
status = "disabled";
};
 
@@ -726,6 +730,8 @@
clock-names = "sdhci";
resets = <_car 69>;
reset-names = "sdhci";
+   nvidia,default-tap = <0x3>;
+   nvidia,default-trim = <0x3>;
status = "disabled";
};
 
@@ -737,6 +743,8 @@
clock-names = "sdhci";
resets = <_car 15>;
reset-names = "sdhci";
+   nvidia,default-tap = <0x8>;
+   nvidia,default-trim = <0x0>;
status = "disabled";
};
 
-- 
2.39.2



[PATCH v2 0/2] tegra_mmc: get tap and trim from dts

2023-08-24 Thread Svyatoslav Ryhel
Default-tap and default-trim values are used for eMMC setup
mostly on T114+ devices. As for now, those values are hardcoded
for T210 and ignored for all other Tegra generations. Fix this
by passing tap and trim values from dts.

---
Changes from v1
- move t210 device tree fix into this series
- switch dev_read_u32_default > dev_read_u32
- if reading of device tree tap/trim values returns error
  store error in entries of driver structure
- apply tap and trim only if they pass error check
---

Svyatoslav Ryhel (2):
  ARM: tegra210: set default-tap and default-trim values in sdhci nodes
  mmc: tegra: get default-tap and default-trim from device tree

 arch/arm/dts/tegra210.dtsi  |  8 
 arch/arm/include/asm/arch-tegra/tegra_mmc.h | 17 +++
 drivers/mmc/tegra_mmc.c | 52 +++--
 3 files changed, 44 insertions(+), 33 deletions(-)

-- 
2.39.2



Re: [PATCH RESEND 0/5] clk: A few bugfixes/enhancements for CCF

2023-08-24 Thread Yang Xiwen
Why is this patchset completely ignored for more than half a month 
already? I have some other patches pending because of this one. Please 
tell me what's wrong with this patchset so that i can fix them.


--
Regards,
Yang Xiwen



Re: [PATCH 1/2] net: ti: am65-cpsw-nuss: Workaround for buggy PHY/Board

2023-08-24 Thread Tom Rini
On Thu, Aug 24, 2023 at 11:34:29PM +0530, Siddharth Vadapalli wrote:
> Hello Roger,
> 
> On 22-08-2023 17:43, Roger Quadros wrote:
> > Beagleplay has a buggy Ethernet PHY implementation for the Gigabit
> > PHY in the sense that it is non responsive over MDIO immediately
> > after power-up/reset.
> > 
> > We need to either try multiple times or wait sufficiently long enough
> > (couple of 10s of ms?) before the PHY begins to respond correctly.
> > 
> > One theory is that the PHY is configured to operate on MDIO address 0
> > which it treats as a special broadcast address.
> > 
> > Datasheet states:
> > "PHYAD (config pins) sets the PHY address for the device.
> > The RTL8211F(I)/RTL8211FD(I) supports PHY addresses from 0x01 to 0x07.
> > Note 1: An MDIO command with PHY address=0 is a broadcast from the MAC;
> > each PHY device should respond."
> > 
> > This issue is not seen with the other PHY (different make) on the board
> > which is configured for address 0x1.
> > 
> > As a woraround we try to probe the PHY multiple times instead of giving
> > up on the first attempt.
> > 
> > Signed-off-by: Roger Quadros 
> > ---
> >  drivers/net/ti/am65-cpsw-nuss.c | 19 ++-
> >  1 file changed, 14 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/net/ti/am65-cpsw-nuss.c 
> > b/drivers/net/ti/am65-cpsw-nuss.c
> > index 51a8167d14..4f8a2f9b93 100644
> > --- a/drivers/net/ti/am65-cpsw-nuss.c
> > +++ b/drivers/net/ti/am65-cpsw-nuss.c
> > @@ -27,6 +27,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  
> >  #include "cpsw_mdio.h"
> >  
> > @@ -678,14 +679,22 @@ static int am65_cpsw_phy_init(struct udevice *dev)
> > struct am65_cpsw_priv *priv = dev_get_priv(dev);
> > struct am65_cpsw_common *cpsw_common = priv->cpsw_common;
> > struct eth_pdata *pdata = dev_get_plat(dev);
> > -   struct phy_device *phydev;
> > u32 supported = PHY_GBIT_FEATURES;
> > +   struct phy_device *phydev;
> > +   int tries;
> > int ret;
> >  
> > -   phydev = phy_connect(cpsw_common->bus,
> > -priv->phy_addr,
> > -priv->dev,
> > -pdata->phy_interface);
> > +   /* Some boards (e.g. beagleplay) don't work on first go */
> > +   for (tries = 1; tries <= 5; tries++) {
> > +   phydev = phy_connect(cpsw_common->bus,
> > +priv->phy_addr,
> > +priv->dev,
> > +pdata->phy_interface);
> > +   if (phydev)
> > +   break;
> > +
> > +   mdelay(10);
> > +   }
> 
> After rethinking about the above implementation and the second patch of
> this series, the second patch could be dropped altogether if the
> following implementation is acceptable:
> 
> phydev = phy_connect(cpsw_common->bus,
>priv->phy_addr,
>priv->dev,
>pdata->phy_interface);
> 
> if (!phydev) {
>   /* Some boards (e.g. beagleplay) don't work on first go */
>   mdelay(50);
>   phydev = phy_connect(cpsw_common->bus,
>priv->phy_addr,
>priv->dev,
>pdata->phy_interface);
> }
> 
> if (!phydev) {
>   dev_err(dev, "phy_connect() failed\n");
> ...
> 
> With this, there would be at most one "PHY not found" print, which
> should be fine. The mdelay value of 50 could be replaced with a
> sufficiently large value which guarantees success for Beagleplay.

Ramon, thoughts?

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 2/2] RFC: x86: acpi: Add some debugging

2023-08-24 Thread Simon Glass
Enable some debugging to help see what is going on.

Signed-off-by: Simon Glass 
---

 arch/x86/lib/tables.c  | 1 +
 lib/acpi/acpi_writer.c | 9 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
index 67bc0a72aebc..7c6b32e6e335 100644
--- a/arch/x86/lib/tables.c
+++ b/arch/x86/lib/tables.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2015, Bin Meng 
  */
 
+#define LOG_DEBUG
 #define LOG_CATEGORY LOGC_ACPI
 
 #include 
diff --git a/lib/acpi/acpi_writer.c b/lib/acpi/acpi_writer.c
index 946f90e8e7b1..b1118b602069 100644
--- a/lib/acpi/acpi_writer.c
+++ b/lib/acpi/acpi_writer.c
@@ -5,6 +5,7 @@
  * Copyright 2021 Google LLC
  */
 
+#define LOG_DEBUG
 #define LOG_CATEGORY LOGC_ACPI
 
 #include 
@@ -21,8 +22,8 @@ int acpi_write_one(struct acpi_ctx *ctx, const struct 
acpi_writer *entry)
 {
int ret;
 
-   log_debug("%s: writing table '%s'\n", entry->name,
- entry->table);
+   log_debug("%s: writing table '%s' at %p\n", entry->name,
+ entry->table, ctx->current);
ctx->tab_start = ctx->current;
ret = entry->h_write(ctx, entry);
if (ret == -ENOENT) {
@@ -57,11 +58,15 @@ static int acpi_write_all(struct acpi_ctx *ctx)
const struct acpi_writer *entry;
int ret;
 
+   log_debug("writing acpi tables\n");
+
for (entry = writer; entry != writer + n_ents; entry++) {
ret = acpi_write_one(ctx, entry);
+   log_debug("- return code %d\n", ret);
if (ret && ret != -ENOENT)
return log_msg_ret("one", ret);
}
+   log_debug("writing acpi tables done ok\n");
 
return 0;
 }
-- 
2.42.0.rc1.204.g551eb34607-goog



[PATCH 1/2] Reland "x86: Move FACP table into separate functions""

2023-08-24 Thread Simon Glass
Each board has its own way of creating this table. Rather than calling the
acpi_create_fadt() function for each one from a common acpi_write_fadt()
function, just move the writer into the board-specific code.

Signed-off-by: Simon Glass 
---
Make another attempt to land this. It apparently breaks Edison but I
cannot test that board, nor can I work out what is wrong with the code.

Previous test report is here:

   https://lore.kernel.org/all/yga9z7sbfaev6...@smile.fi.intel.com/

Looking at the image, the method is definitely present:

   $ nm /tmp/b/edison/u-boot |grep acpi_writer
   0115fde0 D _u_boot_list_2_acpi_writer_2_0base
   0115fdf0 D _u_boot_list_2_acpi_writer_2_1facs
   0115fe00 D _u_boot_list_2_acpi_writer_2_3dsdt
   0115fe10 D _u_boot_list_2_acpi_writer_2_4gnvs
   0115fe20 D _u_boot_list_2_acpi_writer_2_5csrt
   0115fe30 D _u_boot_list_2_acpi_writer_2_5fadt
   0115fe40 D _u_boot_list_2_acpi_writer_2_5mcfg
   0115fe50 D _u_boot_list_2_acpi_writer_2_5spcr
   0115fe60 D _u_boot_list_2_acpi_writer_2_5tcpa
   0115fe70 D _u_boot_list_2_acpi_writer_2_5tpm2
   0115fe80 D _u_boot_list_2_acpi_writer_2_5x86
   0115fe90 D _u_boot_list_2_acpi_writer_2_6ssdt
   0115fea0 D _u_boot_list_2_acpi_writer_2_8dev

I wonder if the code in quark_write_fadt() is not being called?

'acpi list' shows what tables are installed. On minnowmax there is no
difference with or without this patch. Perhaps someone with sharper eyes
than me can figure this out?

The mechanism is that the functions to be called are put in a linker list,
each element being declared using ACPI_WRITER(function_name).

Then acpi_write_all() is called to write each one. Debugging could be
added to that function, perhaps?

 arch/x86/cpu/apollolake/acpi.c| 17 +
 arch/x86/cpu/baytrail/acpi.c  | 27 +++
 arch/x86/cpu/quark/acpi.c | 27 +++
 arch/x86/cpu/tangier/acpi.c   | 25 +
 arch/x86/include/asm/acpi_table.h |  2 --
 arch/x86/lib/acpi_table.c | 15 ---
 6 files changed, 68 insertions(+), 45 deletions(-)

diff --git a/arch/x86/cpu/apollolake/acpi.c b/arch/x86/cpu/apollolake/acpi.c
index fd21c0b49684..16aaed7238ab 100644
--- a/arch/x86/cpu/apollolake/acpi.c
+++ b/arch/x86/cpu/apollolake/acpi.c
@@ -146,16 +146,25 @@ void fill_fadt(struct acpi_fadt *fadt)
fadt->x_pm_tmr_blk.addrl = IOMAP_ACPI_BASE + PM1_TMR;
 }
 
-void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs,
- void *dsdt)
+static int apl_write_fadt(struct acpi_ctx *ctx, const struct acpi_writer 
*entry)
 {
-   struct acpi_table_header *header = >header;
+   struct acpi_table_header *header;
+   struct acpi_fadt *fadt;
 
-   acpi_fadt_common(fadt, facs, dsdt);
+   fadt = ctx->current;
+   acpi_fadt_common(fadt, ctx->facs, ctx->dsdt);
intel_acpi_fill_fadt(fadt);
fill_fadt(fadt);
+   header = >header;
header->checksum = table_compute_checksum(fadt, header->length);
+
+   acpi_add_table(ctx, fadt);
+
+   acpi_inc(ctx, sizeof(struct acpi_fadt));
+
+   return 0;
 }
+ACPI_WRITER(5fadt, "FADT", apl_write_fadt, 0);
 
 int apl_acpi_fill_dmar(struct acpi_ctx *ctx)
 {
diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c
index 07757b88a305..4c526ff27310 100644
--- a/arch/x86/cpu/baytrail/acpi.c
+++ b/arch/x86/cpu/baytrail/acpi.c
@@ -15,20 +15,24 @@
 #include 
 #include 
 
-void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs,
- void *dsdt)
+static int baytrail_write_fadt(struct acpi_ctx *ctx,
+  const struct acpi_writer *entry)
 {
-   struct acpi_table_header *header = &(fadt->header);
+   struct acpi_table_header *header;
+   struct acpi_fadt *fadt;
+
+   fadt = ctx->current;
+   header = >header;
u16 pmbase = ACPI_BASE_ADDRESS;
 
-   memset((void *)fadt, 0, sizeof(struct acpi_fadt));
+   memset(fadt, '\0', sizeof(struct acpi_fadt));
 
acpi_fill_header(header, "FACP");
header->length = sizeof(struct acpi_fadt);
header->revision = 4;
 
-   fadt->firmware_ctrl = (u32)facs;
-   fadt->dsdt = (u32)dsdt;
+   fadt->firmware_ctrl = (u32)ctx->facs;
+   fadt->dsdt = (u32)ctx->dsdt;
fadt->preferred_pm_profile = ACPI_PM_MOBILE;
fadt->sci_int = 9;
fadt->smi_cmd = 0;
@@ -75,9 +79,9 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct 
acpi_facs *facs,
fadt->reset_reg.addrh = 0;
fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
 
-   fadt->x_firmware_ctl_l = (u32)facs;
+   fadt->x_firmware_ctl_l = (u32)ctx->facs;
fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (u32)dsdt;
+   fadt->x_dsdt_l = (u32)ctx->dsdt;
fadt->x_dsdt_h = 0;
 
fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
@@ -137,7 +141,14 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct 

Re: [PATCH] arm: Use builtins for ffs/fls

2023-08-24 Thread Tony Dinh
Hi Sean,

On Mon, Jul 31, 2023 at 2:28 PM Sean Anderson  wrote:
>
> Since ARMv5, the clz instruction allows for efficient implementation of
> ffs/fls with builtins. Until ARMv7 (with Thumb-2), this instruction is
> only available in ARM mode. LTO makes it difficult to force specific
> functions to be in ARM mode, as it is effectively a form of very
> aggressive inlining. To work around this, fls/ffs are implemented in
> assembly for ARMv5 and ARMv6 when compiling U-Boot in Thumb mode.
> Overall, this saves around 75 bytes per call.
>
> Signed-off-by: Sean Anderson 
> ---
> I only tested this on ARMv8. If someone has an ARMv5 or ARMv6 board,
> please test this.

Thanks for the patch! I've tested it with the Pogo V4 board (Kirkwood
88F6192, ARMv5) with LTO and SYS_THUMB_BUILD.

Also nice size reduction:
Before: 502K
After: 499K

So for ARMv5,
Tested-by: Tony Dinh 

All the best,
Tony

>
>  arch/arm/include/asm/bitops.h  | 27 -
>  arch/arm/lib/Makefile  |  5 +++
>  arch/arm/lib/bitops.S  | 45 ++
>  include/asm-generic/bitops/builtin-__ffs.h | 16 
>  include/asm-generic/bitops/builtin-__fls.h | 16 
>  include/asm-generic/bitops/builtin-ffs.h   | 15 
>  include/asm-generic/bitops/builtin-fls.h   | 17 
>  7 files changed, 140 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/lib/bitops.S
>  create mode 100644 include/asm-generic/bitops/builtin-__ffs.h
>  create mode 100644 include/asm-generic/bitops/builtin-__fls.h
>  create mode 100644 include/asm-generic/bitops/builtin-ffs.h
>  create mode 100644 include/asm-generic/bitops/builtin-fls.h
>
> diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
> index fa8548624a..8e897833bb 100644
> --- a/arch/arm/include/asm/bitops.h
> +++ b/arch/arm/include/asm/bitops.h
> @@ -15,9 +15,34 @@
>  #ifndef __ASM_ARM_BITOPS_H
>  #define __ASM_ARM_BITOPS_H
>
> +#if __LINUX_ARM_ARCH__ < 5
> +
>  #include 
>  #include 
>  #include 
> +
> +#else
> +
> +#define PLATFORM_FFS
> +#define PLATFORM_FLS
> +
> +#if !IS_ENABLED(CONFIG_HAS_THUMB2) && CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
> +
> +unsigned long __fls(unsigned long word);
> +unsigned long __ffs(unsigned long word);
> +int fls(unsigned int x);
> +int ffs(int x);
> +
> +#else
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#endif
> +#endif
> +
>  #include 
>
>  #ifdef __KERNEL__
> @@ -113,7 +138,7 @@ static inline int test_bit(int nr, const void * addr)
>
>  static inline int __ilog2(unsigned int x)
>  {
> -   return generic_fls(x) - 1;
> +   return fls(x) - 1;
>  }
>
>  #define ffz(x)  __ffs(~(x))
> diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
> index 62cf80f373..b1bcd37466 100644
> --- a/arch/arm/lib/Makefile
> +++ b/arch/arm/lib/Makefile
> @@ -113,6 +113,11 @@ AFLAGS_REMOVE_memset.o := -mthumb -mthumb-interwork
>  AFLAGS_REMOVE_memcpy.o := -mthumb -mthumb-interwork
>  AFLAGS_memset.o := -DMEMSET_NO_THUMB_BUILD
>  AFLAGS_memcpy.o := -DMEMCPY_NO_THUMB_BUILD
> +
> +# This is only necessary to force ARM mode on THUMB1 targets.
> +ifneq ($(CONFIG_SYS_ARM_ARCH),4)
> +obj-y   += bitops.o
> +endif
>  endif
>  endif
>
> diff --git a/arch/arm/lib/bitops.S b/arch/arm/lib/bitops.S
> new file mode 100644
> index 00..29d1524634
> --- /dev/null
> +++ b/arch/arm/lib/bitops.S
> @@ -0,0 +1,45 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (C) 2023 Sean Anderson 
> + *
> + * ARM bitops to call when using THUMB1, which doesn't have these 
> instructions.
> + */
> +#include 
> +#include 
> +
> +.pushsection .text.__fls
> +ENTRY(__fls)
> +   clz r0, r0
> +   rsb r0, r0, #31
> +   ret lr
> +ENDPROC(__fls)
> +.popsection
> +
> +.pushsection .text.__ffs
> +ENTRY(__ffs)
> +   rsb r3, r0, #0
> +   and r0, r0, r3
> +   clz r0, r0
> +   rsb r0, r0, #31
> +   ret lr
> +ENDPROC(__ffs)
> +.popsection
> +
> +.pushsection .text.fls
> +ENTRY(fls)
> +   cmp r0, #0
> +   clzne   r0, r0
> +   rsbne   r0, r0, #32
> +   ret lr
> +ENDPROC(fls)
> +.popsection
> +
> +.pushsection .text.ffs
> +ENTRY(ffs)
> +   rsb r3, r0, #0
> +   and r0, r0, r3
> +   clz r0, r0
> +   rsb r0, r0, #32
> +   ret lr
> +ENDPROC(ffs)
> +.popsection
> diff --git a/include/asm-generic/bitops/builtin-__ffs.h 
> b/include/asm-generic/bitops/builtin-__ffs.h
> new file mode 100644
> index 00..87024da44d
> --- /dev/null
> +++ b/include/asm-generic/bitops/builtin-__ffs.h
> @@ -0,0 +1,16 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_GENERIC_BITOPS_BUILTIN___FFS_H_
> +#define _ASM_GENERIC_BITOPS_BUILTIN___FFS_H_
> +
> +/**
> + * __ffs - find first bit in word.
> + * @word: The word to search
> + *
> + * Undefined if no bit exists, so code should check against 0 first.
> + */
> +static __always_inline unsigned long __ffs(unsigned long word)
> +{
> +

Re: [PATCH v7 2/2] phy: phy-imx8mq-usb: clean up clock code

2023-08-24 Thread Tim Harvey
On Thu, Jul 13, 2023 at 12:17 PM Marek Vasut  wrote:
>
> On 7/13/23 20:56, Tim Harvey wrote:
> > use CONFIG_IS_ENABLED for clock enable/disable and change printf's
> > to dev_err. Additionlly remove the comment that does not make sense.
> >
> > Signed-off-by: Tim Harvey 
>
> Reviewed-by: Marek Vasut 
>
> Thanks!

Hi Marek,

Who's tree do the phy patches go through?

Best regards,

Tim


Re: [PATCH 1/2] net: ti: am65-cpsw-nuss: Workaround for buggy PHY/Board

2023-08-24 Thread Siddharth Vadapalli
Hello Roger,

On 22-08-2023 17:43, Roger Quadros wrote:
> Beagleplay has a buggy Ethernet PHY implementation for the Gigabit
> PHY in the sense that it is non responsive over MDIO immediately
> after power-up/reset.
> 
> We need to either try multiple times or wait sufficiently long enough
> (couple of 10s of ms?) before the PHY begins to respond correctly.
> 
> One theory is that the PHY is configured to operate on MDIO address 0
> which it treats as a special broadcast address.
> 
> Datasheet states:
> "PHYAD (config pins) sets the PHY address for the device.
> The RTL8211F(I)/RTL8211FD(I) supports PHY addresses from 0x01 to 0x07.
> Note 1: An MDIO command with PHY address=0 is a broadcast from the MAC;
> each PHY device should respond."
> 
> This issue is not seen with the other PHY (different make) on the board
> which is configured for address 0x1.
> 
> As a woraround we try to probe the PHY multiple times instead of giving
> up on the first attempt.
> 
> Signed-off-by: Roger Quadros 
> ---
>  drivers/net/ti/am65-cpsw-nuss.c | 19 ++-
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c
> index 51a8167d14..4f8a2f9b93 100644
> --- a/drivers/net/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ti/am65-cpsw-nuss.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "cpsw_mdio.h"
>  
> @@ -678,14 +679,22 @@ static int am65_cpsw_phy_init(struct udevice *dev)
>   struct am65_cpsw_priv *priv = dev_get_priv(dev);
>   struct am65_cpsw_common *cpsw_common = priv->cpsw_common;
>   struct eth_pdata *pdata = dev_get_plat(dev);
> - struct phy_device *phydev;
>   u32 supported = PHY_GBIT_FEATURES;
> + struct phy_device *phydev;
> + int tries;
>   int ret;
>  
> - phydev = phy_connect(cpsw_common->bus,
> -  priv->phy_addr,
> -  priv->dev,
> -  pdata->phy_interface);
> + /* Some boards (e.g. beagleplay) don't work on first go */
> + for (tries = 1; tries <= 5; tries++) {
> + phydev = phy_connect(cpsw_common->bus,
> +  priv->phy_addr,
> +  priv->dev,
> +  pdata->phy_interface);
> + if (phydev)
> + break;
> +
> + mdelay(10);
> + }

After rethinking about the above implementation and the second patch of
this series, the second patch could be dropped altogether if the
following implementation is acceptable:

phydev = phy_connect(cpsw_common->bus,
 priv->phy_addr,
 priv->dev,
 pdata->phy_interface);

if (!phydev) {
/* Some boards (e.g. beagleplay) don't work on first go */
mdelay(50);
phydev = phy_connect(cpsw_common->bus,
 priv->phy_addr,
 priv->dev,
 pdata->phy_interface);
}

if (!phydev) {
dev_err(dev, "phy_connect() failed\n");
...

With this, there would be at most one "PHY not found" print, which
should be fine. The mdelay value of 50 could be replaced with a
sufficiently large value which guarantees success for Beagleplay.

-- 
Regards,
Siddharth.


  1   2   3   >