RE: [PATCH 1/2] dt-bindings: i2c: i2c-cdns.txt: Add description for an optional parameter, fifo-depth

2023-02-12 Thread PeiYue Ho


> -Original Message-
> From: Heiko Schocher 
> Sent: Monday, February 13, 2023 1:44 PM
> To: PeiYue Ho ; u-boot@lists.denx.de
> Cc: EngLee Teh ; WeiLiang Lim
> 
> Subject: Re: [PATCH 1/2] dt-bindings: i2c: i2c-cdns.txt: Add description for 
> an
> optional parameter, fifo-depth
> 
> Hello Pei Yue Ho
> 
> On 04.01.23 08:20, Pei Yue Ho wrote:
> > Add description for fifo-depth parameter that can be used in the
> > device tree.
> >
> > Signed-off-by: Pei Yue Ho 
> > Reviewed-by: Wei Liang Lim 
> > Reviewed-by: Eng Lee Teh 
> > ---
> >  doc/device-tree-bindings/i2c/i2c-cdns.txt | 4 
> >  1 file changed, 4 insertions(+)
> 
> Reviewed-by: Heiko Schocher 
> 
> Do you plan to submit this to linux too?

Yes, we do plan to submit it to linux in the future
> 
> bye,
> Heiko
> --
> DENX Software Engineering GmbH,  Managing Director: Erika Unter
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH v4 10/11] dm: Add support for handling old u-boot, dm- tags

2023-02-12 Thread Michal Simek




On 2/12/23 18:44, Tom Rini wrote:

On Fri, Feb 10, 2023 at 08:28:56AM -0700, Simon Glass wrote:


Add a CONFIG option to deal with this automatically, printing a warning
when U-Boot starts up. This can be useful if the device tree comes from
another project.

We will maintain this through the 2023.07 release, providing 6 months
for people to notice.

Signed-off-by: Simon Glass 


Adding Michal since he got lost by accident on this iteration. Does that
sound like enough time to get the tooling you know of updated?



This patch makes sense to me and provide good migration path. Thanks!

In connection to have tree working all the time for bisecting reasons I think 
the whole series should be a little bit rearranged and this shouldn't be the 
patch 10/11 but very early.

But I will let Tom to decide if this should be rearranged or not.

Acked-by: Michal Simek 

Thanks,
Michal



Re: [PATCH] doc: board: bcm7xxx: Convert to reStructuredText format

2023-02-12 Thread Heinrich Schuchardt

On 2/11/23 01:24, Thomas Fitzsimmons wrote:

Convert the documentation for the Broadcom BCM7445 and BCM7260 boards
to reStructuredText format and add the new filename to
doc/board/broadcom/index.rst.
---
  doc/README.bcm7xxx | 156 ---
  doc/board/broadcom/bcm7xxx.rst | 186 +
  doc/board/broadcom/index.rst   |   1 +
  3 files changed, 187 insertions(+), 156 deletions(-)
  delete mode 100644 doc/README.bcm7xxx
  create mode 100644 doc/board/broadcom/bcm7xxx.rst

diff --git a/doc/README.bcm7xxx b/doc/README.bcm7xxx
deleted file mode 100644
index 6839da5f97..00
--- a/doc/README.bcm7xxx
+++ /dev/null
@@ -1,156 +0,0 @@
-Summary
-===
-
-This document describes how to use U-Boot on the Broadcom 7445 SoC, as
-a third stage bootloader loaded by Broadcom's BOLT bootloader.
-
-BOLT loads U-Boot as a generic ELF binary.  Some U-Boot features such
-as networking are not yet available but other important features are,
-including:
-
-   - ext4 file system traversal
-
-   - support for loading FIT images
-
-   - advanced scripting
-
-   - support for FIT-provided DTBs instead of relying on the
- BOLT-provided DTB
-
-A customized version of this port has been used in production.  The
-same approach may work on other BCM7xxx boards, with some
-configuration adjustments and memory layout experimentation.
-
-Build
-=
-
-make bcm7445_defconfig
-make
-${CROSS_COMPILE}strip u-boot
-
-Run
-===
-
-To tell U-Boot which serial port to use for its console, set the
-"stdout-path" property in the "/chosen" node of the BOLT-generated
-device tree.  For example:
-
-BOLT> dt add prop chosen stdout-path s serial0:115200n8
-
-Flash the u-boot binary into board storage, then invoke it from BOLT.
-For example:
-
-BOLT> boot -bsu -elf flash0.u-boot1
-
-This port assumes that I-cache and D-cache are already enabled when
-U-Boot is entered.
-
-Flattened Image Tree Support
-
-
-What follows is an example FIT image source file.  Build it with:
-
-mkimage -f image.its image.itb
-
-Booting the resulting image.itb was tested on BOLT v1.20, with the
-following kernels:
-
-https://github.com/Broadcom/stblinux-3.14
-https://github.com/Broadcom/stblinux-4.1
-https://github.com/Broadcom/stblinux-4.9
-
-and with a generic ARMv7 root file system.
-
-image.its:
-/dts-v1/;
-/ {
-   description = "BCM7445 FIT";
-   images {
-   kernel@1 {
-   description = "Linux kernel";
-   /*
-* This kernel image output format can be
-* generated with:
-*
-* make vmlinux
-* ${CROSS_COMPILE}objcopy -O binary -S vmlinux 
vmlinux.bin
-* gzip -9 vmlinux.bin
-*
-* For stblinux-3.14, the specific Broadcom
-* board type should be configured in the
-* kernel, for example CONFIG_BCM7445D0=y.
-*/
-   data = /incbin/("");
-   type = "kernel";
-   arch = "arm";
-   os = "linux";
-   compression = "gzip";
-   load = <0x8000>;
-   entry = <0x8000>;
-   hash@1 {
-   algo = "sha256";
-   };
-   };
-   ramdisk@1 {
-   description = "Initramfs root file system";
-   data = /incbin/("");
-   type = "ramdisk";
-   arch = "arm";
-   os = "linux";
-   compression = "gzip";
-   /*
-* Set the environment variable initrd_high to
-* 0x, and set "load" and "entry" here
-* to 0x0 to keep initramfs in-place and to
-* accommodate stblinux bmem/CMA reservations.
-*/
-   load = <0x0>;
-   entry = <0x0>;
-   hash@1 {
-   algo = "sha256";
-   };
-   };
-   fdt@1 {
-   description = "Device tree dumped from BOLT";
-   /*
-* This DTB should be similar to the
-* BOLT-generated device tree, after BOLT has
-* done its runtime modifications to it.  For
-* example, it can be dumped from within
-* U-Boot (at ${fdtcontroladdr}), after BOLT
-* has loaded U-Boot.  The result can be added
-* to the Linux source tree as a .dts file.
-*
-

Re: [PATCH 4/5] eficonfig: include EFI_STATUS string in error message

2023-02-12 Thread Heinrich Schuchardt

On 2/13/23 06:50, Masahisa Kojima wrote:

On Fri, 10 Feb 2023 at 20:57, Heinrich Schuchardt  wrote:


On 2/2/23 10:24, Masahisa Kojima wrote:

Current eficonfig_print_msg() does not show the return
value of EFI Boot/Runtime Services when the service call fails.
With this commit, user can know EFI_STATUS in the error message.


Why do we need function eficonfig_print_msg()?

I cannot see why the printing only parameter msg with log_err() should
not be good enough.


ANSI_CLEAR_CONSOLE is sent before drawing the menu. I think it is
difficult for user
to know some error occurs by the user operation, user needs scroll up
to see the error message
when we use log_err(

Understood. But why do we need the status value (or with this patch the
long text for the status value)?

Best regards

Heinrich



Regards,
Masahisa Kojima



Best regards

Heinrich



Signed-off-by: Masahisa Kojima 
---
   cmd/eficonfig.c   | 95 +--
   cmd/eficonfig_sbkey.c | 16 
   include/efi_config.h  |  2 +-
   3 files changed, 93 insertions(+), 20 deletions(-)

diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index 0a17b8cf34..b0c8637676 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -151,19 +151,90 @@ static void eficonfig_menu_adjust(struct efimenu 
*efi_menu, bool add)
   #define eficonfig_menu_up(_a) eficonfig_menu_adjust(_a, false)
   #define eficonfig_menu_down(_a) eficonfig_menu_adjust(_a, true)

+struct efi_status_str {
+ efi_status_t status;
+ char *str;
+};
+
+static const struct efi_status_str status_str_table[] = {
+ {EFI_LOAD_ERROR,"Load Error"},
+ {EFI_INVALID_PARAMETER, "Invalid Parameter"},
+ {EFI_UNSUPPORTED,   "Unsupported"},
+ {EFI_BAD_BUFFER_SIZE,   "Bad Buffer Size"},
+ {EFI_BUFFER_TOO_SMALL,  "Buffer Too Small"},
+ {EFI_NOT_READY, "Not Ready"},
+ {EFI_DEVICE_ERROR,  "Device Error"},
+ {EFI_WRITE_PROTECTED,   "Write Protected"},
+ {EFI_OUT_OF_RESOURCES,  "Out of Resources"},
+ {EFI_VOLUME_CORRUPTED,  "Volume Corrupted"},
+ {EFI_VOLUME_FULL,   "Volume Full"},
+ {EFI_NO_MEDIA,  "No Media"},
+ {EFI_MEDIA_CHANGED, "Media Changed"},
+ {EFI_NOT_FOUND, "Not Found"},
+ {EFI_ACCESS_DENIED, "Access Denied"},
+ {EFI_NO_RESPONSE,   "No Response"},
+ {EFI_NO_MAPPING,"No Mapping"},
+ {EFI_TIMEOUT,   "Timeout"},
+ {EFI_NOT_STARTED,   "Not Started"},
+ {EFI_ALREADY_STARTED,   "Already Started"},
+ {EFI_ABORTED,   "Aborted"},
+ {EFI_ICMP_ERROR,"ICMP Error"},
+ {EFI_TFTP_ERROR,"TFTP Error"},
+ {EFI_PROTOCOL_ERROR,"Protocol Error"},
+ {EFI_INCOMPATIBLE_VERSION,  "Incompatible Version"},
+ {EFI_SECURITY_VIOLATION,"Security Violation"},
+ {EFI_CRC_ERROR, "CRC Error"},
+ {EFI_END_OF_MEDIA,  "End of Media"},
+ {EFI_END_OF_FILE,   "End of File"},
+ {EFI_INVALID_LANGUAGE,  "Invalid Language"},
+ {EFI_COMPROMISED_DATA,  "Compromised Data"},
+ {EFI_IP_ADDRESS_CONFLICT,   "IP Address Conflict"},
+ {EFI_HTTP_ERROR,"HTTP Error"},
+ {EFI_WARN_UNKNOWN_GLYPH,"Warn Unknown Glyph"},
+ {EFI_WARN_DELETE_FAILURE,   "Warn Delete Failure"},
+ {EFI_WARN_WRITE_FAILURE,"Warn Write Failure"},
+ {EFI_WARN_BUFFER_TOO_SMALL, "Warn Buffer Too Small"},
+ {EFI_WARN_STALE_DATA,   "Warn Stale Data"},
+ {EFI_WARN_FILE_SYSTEM,  "Warn File System"},
+ {EFI_WARN_RESET_REQUIRED,   "Warn Reset Required"},
+ {0, ""},
+};
+
+/**
+ * struct get_status_str - get status string
+ *
+ * @status:  efi_status_t value to covert to string
+ * Return:   pointer to the string
+ */
+static char *get_error_str(efi_status_t status)
+{
+ u32 i;
+
+ for (i = 0; status_str_table[i].status != 0; i++) {
+ if (status == status_str_table[i].status)
+ return status_str_table[i].str;
+ }
+ return status_str_table[i].str;
+}
+
   /**
* eficonfig_print_msg() - print message
*
* display the message to the user, user proceeds the screen
* with any key press.
*
- * @items:   pointer to the structure of each menu entry
- * @count:   the number of menu entry
- * @menu_header: pointer to the menu header string
- * Return:   status code
+ * @msg: pointer to the error message
+ * @status:  efi status code, set 0 if no status string output
*/
-void eficonfig_print_msg(char *msg)
+void eficonfig_print_msg(const char *msg, efi_status_t status)
   {
+ char str[128];
+
+ if (status == 0)
+ snprintf(str, sizeof(str), "%s", msg);
+ else
+ 

Re: [PATCH] doc: devicetree: dt_qemu.rst: Fix the typo and space

2023-02-12 Thread Heinrich Schuchardt

On 2/12/23 08:09, Yu Chien Peter Lin wrote:

Fix typo and whitespace in the document.

Signed-off-by: Yu Chien Peter Lin 


Reviewed-by: Heinrich Schuchardt 


---
  doc/develop/devicetree/dt_qemu.rst | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/develop/devicetree/dt_qemu.rst 
b/doc/develop/devicetree/dt_qemu.rst
index c25c4fb053..8ba2b22559 100644
--- a/doc/develop/devicetree/dt_qemu.rst
+++ b/doc/develop/devicetree/dt_qemu.rst
@@ -13,7 +13,7 @@ When `CONFIG_OF_BOARD` is enabled
  Obtaining the QEMU devicetree
  -

-Where QEMU generates its own devicetree to pass to U-Boot tou can use
+Where QEMU generates its own devicetree to pass to U-Boot you can use
  `-dtb u-boot.dtb` to force QEMU to use U-Boot's in-tree version.

  To obtain the devicetree that qemu generates, add `-machine dumpdtb=qemu.dtb`,
@@ -38,7 +38,7 @@ to produce a text file. It drops the duplicate header on the 
qemu one. Then it
  joins them up and runs them through dtc to compile the output::

  qemu-system-arm -machine virt -machine dumpdtb=qemu.dtb
-cat  <(dtc -I dtb qemu.dtb) <(dtc -I dtb  u-boot.dtb |grep -v /dts-v1/) 
|dtc - -o merged.dtb
+cat  <(dtc -I dtb qemu.dtb) <(dtc -I dtb u-boot.dtb | grep -v /dts-v1/) | 
dtc - -o merged.dtb

  You can then run qemu with the merged devicetree, e.g.::





Re: [RFC PATCH] doc: arch: Add document for RISC-V architecture

2023-02-12 Thread Heinrich Schuchardt

On 2/12/23 08:00, Yu Chien Peter Lin wrote:

This patch adds a brief introduction to the RISC-V architecture and
the typical boot process used on a variety of RISC-V platforms.

Signed-off-by: Yu Chien Peter Lin 
---
Hi RISC-V community,

Please leave a comment if there is anything I've missed that should
be mentioned in the document. Thanks.
---
  doc/arch/index.rst |  1 +
  doc/arch/riscv.rst | 43 +++
  2 files changed, 44 insertions(+)
  create mode 100644 doc/arch/riscv.rst

diff --git a/doc/arch/index.rst b/doc/arch/index.rst
index b3e85f9bf3..b8da4b8c8e 100644
--- a/doc/arch/index.rst
+++ b/doc/arch/index.rst
@@ -11,6 +11,7 @@ Architecture-specific doc
 m68k
 mips
 nios2
+   riscv
 sandbox/index
 sh
 x86
diff --git a/doc/arch/riscv.rst b/doc/arch/riscv.rst
new file mode 100644
index 00..243e7e7e2e
--- /dev/null
+++ b/doc/arch/riscv.rst
@@ -0,0 +1,43 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2023, Yu Chien Peter Lin 
+
+RISC-V
+==
+
+Overview
+
+
+This document outlines the U-Boot boot process for the RISC-V architecture.
+RISC-V is an open-source instruction set architecture (ISA) based on the
+principles of reduced instruction set computing (RISC). It has been designed
+to be flexible and customizable, allowing it to be adapted to different use
+cases, from embedded systems to high performance servers.
+
+Typical Boot Process
+
+
+RISC-V production boot images typically include a U-Boot SPL for 
platform-specific


%s/typically include/may include/

Many boards don't use SPL:

ae350_rv32_defconfig
ae350_rv64_defconfig
sipeed_maix_bitm_defconfig
sipeed_maix_smode_defconfig
openpiton_riscv64_defconfig
qemu-riscv64_defconfig

Please provide a description of those boot processes too.


+initialization. The U-Boot SPL then loads a FIT image (u-boot.itb), which 
contains
+an SBI (Supervisor Binary Interface) firmware such as `OpenSBI 
`_, as well as a regular


Please, try to stay within 80 columns.

%s/an SBI (Supervisor Binary Interface) firmware/a firmware providing
the SBI (Supervisor Binary Interface)/


+U-Boot (or U-Boot proper) running in S-mode. Finally, the S-mode Operating 
System
+is loaded.
+
+In between the boot stages, the hartid is passed through the a0 register, and 
the
+start address of the devicetree is passed through the a1 register.
+
+The following diagram illustrates the boot process::
+
+   <--( M-mode )><---( S-mode )-->
+   ++   +-+++   ++
+   | U-Boot SPL |-->|   SBI   |--->| U-Boot |-->|   OS   |
+   ++   +-+++   ++


SBI (Supervisory Binary Interface) is an interface not a software. So it
does not fit into this diagram.

Best regards

Heinrich


+
+To examine the boot process with the QEMU virt machine, you can follow the 
steps
+in the following document:
+:doc:`../board/emulation/qemu-riscv.rst`
+
+Toolchain
+-
+
+You can build the `RISC-V GNU toolchain 
`_ from scratch, or 
download a
+pre-built toolchain from the `releases page 
`_.




Re: [PATCH 1/2] Revert "mmc: s5p_sdhci: unset the SDHCI_QUIRK_BROKEN_R1B"

2023-02-12 Thread Henrik Grimler
Hi Jaehoon,

On Fri, 2023-02-10 at 09:00 +0900, Jaehoon Chung wrote:
> Hi,
> 
> > -Original Message-
> > From: U-Boot  On Behalf Of Henrik
> > Grimler
> > Sent: Thursday, February 9, 2023 4:04 AM
> > To: jo...@diskos.nl; jh80.ch...@gmail.com; andy...@sony.com; 
> > s...@chromium.org;
> > m.szyprow...@samsung.com; u-boot@lists.denx.de; 
> > ~postmarketos/upstream...@lists.sr.ht
> > Cc: Henrik Grimler 
> > Subject: [PATCH 1/2] Revert "mmc: s5p_sdhci: unset the
> > SDHCI_QUIRK_BROKEN_R1B"
> > 
> > This reverts commit a034ec06ff1d558bbe11d5ee05edbb4de3ee2215.
> > 
> > Commit 4a3ea75de4c5 ("Revert "mmc: sdhci: set to INT_DATA_END when
> > there are data"") reverted the alternative fix that was added for
> > Exynos 4 devices, causing an error when trying to boot from an
> > sdcard:
> > 
> >     <...>
> >     Loading Environment from MMC... sdhci_send_command: Timeout for
> > status update!
> >     mmc fail to send stop cmd
> >     <...>
> 
> Thanks for sharing issue. 
> 
> I will check this on Exynos Board. Frankly, I hope not to re-add
> QUIRK.
> Because it was verified that it was working fine without
> SDHCI_QUIKR_BROKEN_RIB.

Thanks for looking into it! It could be that issue happens only on
odroid-u2 devices, since both me and Joost have that model.

> Best Regards,
> Jaehoon Chung

Best regards,
Henrik Grimler



Re: [PATCH v2 07/10] mtd: rawnand: brcmnand: fix CS0 layout

2023-02-12 Thread Michael Nazzareno Trimarchi
On Sat, Feb 11, 2023 at 4:29 PM Linus Walleij  wrote:
>
> From: Álvaro Fernández Rojas 
>
> Only v3.3-v5.0 have a different CS0 layout.
> Controllers before v3.3 use the same layout for every CS.
>
> Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB 
> NAND controller")
> Signed-off-by: Álvaro Fernández Rojas 
> Acked-by: Florian Fainelli 
> Signed-off-by: Miquel Raynal 
> Link: 
> https://lore.kernel.org/linux-mtd/20200522121524.4161539-3-nolt...@gmail.com
> [Ported to U-Boot from the Linux kernel]
> Signed-off-by: Linus Walleij 
> ---
>  drivers/mtd/nand/raw/brcmnand/brcmnand.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c 
> b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index ee7c3a21602e..1ea9091e6497 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -561,8 +561,9 @@ static int brcmnand_revision_init(struct 
> brcmnand_controller *ctrl)
> } else {
> ctrl->cs_offsets = brcmnand_cs_offsets;
>
> -   /* v5.0 and earlier has a different CS0 offset layout */
> -   if (ctrl->nand_version <= 0x0500)
> +   /* v3.3-5.0 have a different CS0 offset layout */
> +   if (ctrl->nand_version >= 0x0303 &&
> +   ctrl->nand_version <= 0x0500)
> ctrl->cs0_offsets = brcmnand_cs_offsets_cs0;
> }
>
Reviewed-by: Michael Trimarchi 

> --
> 2.39.1
>


-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
mich...@amarulasolutions.com
__

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
i...@amarulasolutions.com
www.amarulasolutions.com


Re: [PATCH 2/2] samsung: common: only load CROS_EC if enabled in config

2023-02-12 Thread Henrik Grimler
Hi Simon,

On Wed, 2023-02-08 at 18:08 -0700, Simon Glass wrote:
> On Wed, 8 Feb 2023 at 12:04, Henrik Grimler 
> wrote:
> > 
> > Otherwise non-ChromeOS samsung devices, like the odroid boards, are
> > stuck in a bootloop if CONFIG_CROS_EC is not enabled:
> > 
> >     <...>
> >     MMC: SAMSUNG SDHCI: 2, EXYNOS DWMMC: 0
> >     Loading Environment from MMC... *** Warning - bad CRC, using
> > default environment
> > 
> >     cros-ec communications failure -96
> > 
> >     Please reset with Power+Refresh
> > 
> >     Cannot init cros-ec device
> >     resetting ...
> > 
> > Issue started after commit e44d7e73fe0d ("dm: core: Switch
> > uclass_*_device_err to use uclass_*_device_check").
> > 
> > Signed-off-by: Henrik Grimler 
> > ---
> >  board/samsung/common/board.c | 27 ++-
> >  1 file changed, 14 insertions(+), 13 deletions(-)
> > 
> > diff --git a/board/samsung/common/board.c
> > b/board/samsung/common/board.c
> > index 16ce5cb89253..78161b807bac 100644
> > --- a/board/samsung/common/board.c
> > +++ b/board/samsung/common/board.c
> > @@ -217,26 +217,27 @@ int checkboard(void)
> >  #ifdef CONFIG_BOARD_LATE_INIT
> >  int board_late_init(void)
> >  {
> > -   struct udevice *dev;
> > -   int ret;
> >     int mmcbootdev = get_boot_mmc_dev();
> >     char mmcbootdev_str[16];
> > 
> > -   ret = uclass_first_device_err(UCLASS_CROS_EC, );
> > -   if (ret && ret != -ENODEV) {
> > -   /* Force console on */
> > -   gd->flags &= ~GD_FLG_SILENT;
> > -
> > -   printf("cros-ec communications failure %d\n", ret);
> > -   puts("\nPlease reset with Power+Refresh\n\n");
> > -   panic("Cannot init cros-ec device");
> > -   return -1;
> > -   }
> > -
> >     printf("Boot device: MMC(%u)\n", mmcbootdev);
> >     sprintf(mmcbootdev_str, "%u", mmcbootdev);
> >     env_set("mmcbootdev", mmcbootdev_str);
> > 
> > +   if (IS_ENABLED(CONFIG_CROS_EC)) {
> > +   struct udevice *dev;
> > +   int ret = uclass_first_device_err(UCLASS_CROS_EC,
> > );
> > +   if (ret && ret != -ENODEV) {
> > +   /* Force console on */
> > +   gd->flags &= ~GD_FLG_SILENT;
> > +
> > +   printf("cros-ec communications failure
> > %d\n", ret);
> > +   puts("\nPlease reset with
> > Power+Refresh\n\n");
> > +   panic("Cannot init cros-ec device");
> > +   return -1;
> > +   }
> > +   }
> > +
> >     return 0;
> >  }
> >  #endif
> > --
> > 2.30.2
> > 
> 
> Reviewed-by: Simon Glass 
> 
> Another option would be to change the check for -ENODEV to also check
> for -EEPFNOSUPPORT (missing uclass).

Thanks for reviewing! Checking for that return code works as well, and
would require a smaller patch, I will send a v2 and use that suggestion
instead.

Best regards,
Henrik Grimler



Re: [PATCH v2 06/10] mtd: rawnand: brcmnand: rename v4 registers

2023-02-12 Thread Michael Nazzareno Trimarchi
Hi

On Sat, Feb 11, 2023 at 4:29 PM Linus Walleij  wrote:
>
> From: Álvaro Fernández Rojas 
>
> These registers are also used on v3.3.
>
> Signed-off-by: Álvaro Fernández Rojas 
> Reviewed-by: Miquel Raynal 
> Acked-by: Florian Fainelli 
> Signed-off-by: Miquel Raynal 
> Link: 
> https://lore.kernel.org/linux-mtd/20200522121524.4161539-2-nolt...@gmail.com
> [Ported to U-Boot from the Linux kernel]
> Signed-off-by: Linus Walleij 
> ---
>  drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c 
> b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index 5d3fb460d89a..ee7c3a21602e 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -293,8 +293,8 @@ enum brcmnand_reg {
> BRCMNAND_FC_BASE,
>  };
>
> -/* BRCMNAND v4.0 */
> -static const u16 brcmnand_regs_v40[] = {
> +/* BRCMNAND v3.3-v4.0 */
> +static const u16 brcmnand_regs_v33[] = {
> [BRCMNAND_CMD_START]=  0x04,
> [BRCMNAND_CMD_EXT_ADDRESS]  =  0x08,
> [BRCMNAND_CMD_ADDRESS]  =  0x0c,
> @@ -546,8 +546,8 @@ static int brcmnand_revision_init(struct 
> brcmnand_controller *ctrl)
> ctrl->reg_offsets = brcmnand_regs_v60;
> else if (ctrl->nand_version >= 0x0500)
> ctrl->reg_offsets = brcmnand_regs_v50;
> -   else if (ctrl->nand_version >= 0x0400)
> -   ctrl->reg_offsets = brcmnand_regs_v40;
> +   else if (ctrl->nand_version >= 0x0303)
> +   ctrl->reg_offsets = brcmnand_regs_v33;
>
> /* Chip-select stride */
> if (ctrl->nand_version >= 0x0701)
> --
> 2.39.1
>

Reviewed-by: Michael Trimarchi 


-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
mich...@amarulasolutions.com
__

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
i...@amarulasolutions.com
www.amarulasolutions.com


Re: [PATCH v2 01/10] mtd: rawnand: brcmnand: Refactored code to introduce helper functions

2023-02-12 Thread Michael Nazzareno Trimarchi
Hi

On Sat, Feb 11, 2023 at 4:29 PM Linus Walleij  wrote:
>
> From: Kamal Dasu 
>
> Refactored NAND ECC and CMD address configuration code to use helper
> functions.
>
> Signed-off-by: Kamal Dasu 
> Signed-off-by: Miquel Raynal 
> [Ported to U-Boot from the Linux kernel]
> Signed-off-by: Linus Walleij 
> ---
>  drivers/mtd/nand/raw/brcmnand/brcmnand.c | 100 ++-
>  1 file changed, 62 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c 
> b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index 74c9348f7fc4..571f1c795da0 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -595,6 +595,54 @@ static inline void brcmnand_write_fc(struct 
> brcmnand_controller *ctrl,
> __raw_writel(val, ctrl->nand_fc + word * 4);
>  }
>
> +static void brcmnand_clear_ecc_addr(struct brcmnand_controller *ctrl)
> +{
> +
> +   /* Clear error addresses */
> +   brcmnand_write_reg(ctrl, BRCMNAND_UNCORR_ADDR, 0);
> +   brcmnand_write_reg(ctrl, BRCMNAND_CORR_ADDR, 0);
> +   brcmnand_write_reg(ctrl, BRCMNAND_UNCORR_EXT_ADDR, 0);
> +   brcmnand_write_reg(ctrl, BRCMNAND_CORR_EXT_ADDR, 0);
> +}
> +
> +static u64 brcmnand_get_uncorrecc_addr(struct brcmnand_controller *ctrl)
> +{
> +   u64 err_addr;
> +
> +   err_addr = brcmnand_read_reg(ctrl, BRCMNAND_UNCORR_ADDR);
> +   err_addr |= ((u64)(brcmnand_read_reg(ctrl,
> +BRCMNAND_UNCORR_EXT_ADDR)
> +& 0x) << 32);
> +
> +   return err_addr;
> +}
> +
> +static u64 brcmnand_get_correcc_addr(struct brcmnand_controller *ctrl)
> +{
> +   u64 err_addr;
> +
> +   err_addr = brcmnand_read_reg(ctrl, BRCMNAND_CORR_ADDR);
> +   err_addr |= ((u64)(brcmnand_read_reg(ctrl,
> +BRCMNAND_CORR_EXT_ADDR)
> +& 0x) << 32);
> +
> +   return err_addr;
> +}
> +
> +static void brcmnand_set_cmd_addr(struct mtd_info *mtd, u64 addr)
> +{
> +   struct nand_chip *chip =  mtd_to_nand(mtd);
> +   struct brcmnand_host *host = nand_get_controller_data(chip);
> +   struct brcmnand_controller *ctrl = host->ctrl;
> +
> +   brcmnand_write_reg(ctrl, BRCMNAND_CMD_EXT_ADDRESS,
> +  (host->cs << 16) | ((addr >> 32) & 0x));
> +   (void)brcmnand_read_reg(ctrl, BRCMNAND_CMD_EXT_ADDRESS);
> +   brcmnand_write_reg(ctrl, BRCMNAND_CMD_ADDRESS,
> +  lower_32_bits(addr));
> +   (void)brcmnand_read_reg(ctrl, BRCMNAND_CMD_ADDRESS);
> +}
> +
>  static inline u16 brcmnand_cs_offset(struct brcmnand_controller *ctrl, int 
> cs,
>  enum brcmnand_cs_reg reg)
>  {
> @@ -1190,9 +1238,12 @@ static void brcmnand_send_cmd(struct brcmnand_host 
> *host, int cmd)
>  {
> struct brcmnand_controller *ctrl = host->ctrl;
> int ret;
> +   u64 cmd_addr;
> +
> +   cmd_addr = brcmnand_read_reg(ctrl, BRCMNAND_CMD_ADDRESS);
> +
> +   dev_dbg(ctrl->dev, "send native cmd %d addr 0x%llx\n", cmd, cmd_addr);
>
> -   dev_dbg(ctrl->dev, "send native cmd %d addr_lo 0x%x\n", cmd,
> -   brcmnand_read_reg(ctrl, BRCMNAND_CMD_ADDRESS));
> BUG_ON(ctrl->cmd_pending != 0);
> ctrl->cmd_pending = cmd;
>
> @@ -1365,12 +1416,7 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, 
> unsigned command,
> if (!native_cmd)
> return;
>
> -   brcmnand_write_reg(ctrl, BRCMNAND_CMD_EXT_ADDRESS,
> -   (host->cs << 16) | ((addr >> 32) & 0x));
> -   (void)brcmnand_read_reg(ctrl, BRCMNAND_CMD_EXT_ADDRESS);
> -   brcmnand_write_reg(ctrl, BRCMNAND_CMD_ADDRESS, lower_32_bits(addr));
> -   (void)brcmnand_read_reg(ctrl, BRCMNAND_CMD_ADDRESS);
> -
> +   brcmnand_set_cmd_addr(mtd, addr);
> brcmnand_send_cmd(host, native_cmd);
> brcmnand_waitfunc(mtd, chip);
>
> @@ -1600,20 +1646,10 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, 
> struct nand_chip *chip,
> struct brcmnand_controller *ctrl = host->ctrl;
> int i, j, ret = 0;
>
> -   /* Clear error addresses */
> -   brcmnand_write_reg(ctrl, BRCMNAND_UNCORR_ADDR, 0);
> -   brcmnand_write_reg(ctrl, BRCMNAND_CORR_ADDR, 0);
> -   brcmnand_write_reg(ctrl, BRCMNAND_UNCORR_EXT_ADDR, 0);
> -   brcmnand_write_reg(ctrl, BRCMNAND_CORR_EXT_ADDR, 0);
> -
> -   brcmnand_write_reg(ctrl, BRCMNAND_CMD_EXT_ADDRESS,
> -   (host->cs << 16) | ((addr >> 32) & 0x));
> -   (void)brcmnand_read_reg(ctrl, BRCMNAND_CMD_EXT_ADDRESS);
> +   brcmnand_clear_ecc_addr(ctrl);
>
> for (i = 0; i < trans; i++, addr += FC_BYTES) {
> -   brcmnand_write_reg(ctrl, BRCMNAND_CMD_ADDRESS,
> -  lower_32_bits(addr));
> -   (void)brcmnand_read_reg(ctrl, 

[PATCH 8/9] mtd: spi-nor-core: Rework spi_nor_cypress_octal_dtr_enable()

2023-02-12 Thread tkuw584924
From: Takahiro Kuwano 

Enabling Octal DTR mode in multi-die package parts requires reister setup
for each die. That can be done by simple for-loop. write_enable() takes
effect to all die at once so we can call it before the loop. Besides we
can replace spi_mem_exec_op() calls with spansion_read/write_any_reg().
And finally, we must mask CFR2V[7:4] when changing dummy cycles, as
CFR2V[7] indicates current addressing mode and that should be 1 (4-byte
address mode) for multi-die package parts.

Signed-off-by: Takahiro Kuwano 
---
 drivers/mtd/spi/spi-nor-core.c | 54 +-
 include/linux/mtd/spi-nor.h|  1 +
 2 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index d9b6bdc23892..4b0485b54668 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3418,48 +3418,48 @@ static struct spi_nor_fixups s25fl256l_fixups = {
  */
 static int spi_nor_cypress_octal_dtr_enable(struct spi_nor *nor)
 {
-   struct spi_mem_op op;
+   u32 addr;
u8 buf;
-   u8 addr_width = 3;
int ret;
 
-   /* Use 24 dummy cycles for memory array reads. */
ret = write_enable(nor);
if (ret)
return ret;
 
-   buf = SPINOR_REG_CYPRESS_CFR2_MEMLAT_11_24;
-   op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WR_ANY_REG, 
1),
-   SPI_MEM_OP_ADDR(addr_width, SPINOR_REG_CYPRESS_CFR2V, 
1),
-   SPI_MEM_OP_NO_DUMMY,
-   SPI_MEM_OP_DATA_OUT(1, , 1));
-   ret = spi_mem_exec_op(nor->spi, );
-   if (ret) {
-   dev_warn(nor->dev,
-"failed to set default memory latency value: %d\n",
-ret);
-   return ret;
-   }
-   ret = spi_nor_wait_till_ready(nor);
-   if (ret)
-   return ret;
+   /* Use 24 dummy cycles for memory array reads. */
+   for (addr = 0; addr < nor->mtd.size; addr += SZ_128M) {
+   ret = spansion_read_any_reg(nor,
+   addr + SPINOR_REG_CYPRESS_CFR2V, 0,
+   );
+   if (ret)
+   return ret;
 
+   buf &= ~SPINOR_REG_CYPRESS_CFR2_MEMLAT_MASK;
+   buf |= SPINOR_REG_CYPRESS_CFR2_MEMLAT_11_24;
+   ret = spansion_write_any_reg(nor,
+addr + SPINOR_REG_CYPRESS_CFR2V,
+buf);
+   if (ret) {
+   dev_warn(nor->dev, "failed to set default memory 
latency value: %d\n", ret);
+   return ret;
+   }
+   }
nor->read_dummy = 24;
 
-   /* Set the octal and DTR enable bits. */
ret = write_enable(nor);
if (ret)
return ret;
 
+   /* Set the octal and DTR enable bits. */
buf = SPINOR_REG_CYPRESS_CFR5_OCT_DTR_EN;
-   op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WR_ANY_REG, 
1),
-   SPI_MEM_OP_ADDR(addr_width, SPINOR_REG_CYPRESS_CFR5V, 
1),
-   SPI_MEM_OP_NO_DUMMY,
-   SPI_MEM_OP_DATA_OUT(1, , 1));
-   ret = spi_mem_exec_op(nor->spi, );
-   if (ret) {
-   dev_warn(nor->dev, "Failed to enable octal DTR mode\n");
-   return ret;
+   for (addr = 0; addr < nor->mtd.size; addr += SZ_128M) {
+   ret = spansion_write_any_reg(nor,
+addr + SPINOR_REG_CYPRESS_CFR5V,
+buf);
+   if (ret) {
+   dev_warn(nor->dev, "Failed to enable octal DTR mode\n");
+   return ret;
+   }
}
 
return 0;
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 8a94e1203724..d1dbf3eadbf7 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -185,6 +185,7 @@
 #define SPINOR_REG_CYPRESS_STR1V   0x0080
 #define SPINOR_REG_CYPRESS_CFR1V   0x0082
 #define SPINOR_REG_CYPRESS_CFR2V   0x0083
+#define SPINOR_REG_CYPRESS_CFR2_MEMLAT_MASKGENMASK(3, 0)
 #define SPINOR_REG_CYPRESS_CFR2_MEMLAT_11_24   0xb
 #define SPINOR_REG_CYPRESS_CFR3V   0x0084
 #define SPINOR_REG_CYPRESS_CFR3_PGSZ   BIT(4) /* Page size. */
-- 
2.25.1



[PATCH 9/9] mtd: spi-nor-ids: Add Infineon(Cypress) s28hs02gt ID

2023-02-12 Thread tkuw584924
From: Takahiro Kuwano 

Infineon(Cypress) S28HS02GT is 1.8V, 2Gb (256MB) NOR Flash memory with
Octal interface. It is a dual-die package parts and has same features
with existing S28 series.

Signed-off-by: Takahiro Kuwano 
---
 drivers/mtd/spi/spi-nor-ids.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index a862fbd707b3..7ad2a9306c31 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -301,6 +301,7 @@ const struct flash_info spi_nor_ids[] = {
{ INFO("s28hl01gt",  0x345a1b,  0, 256 * 1024, 512, 
SPI_NOR_OCTAL_DTR_READ) },
{ INFO("s28hs512t",  0x345b1a,  0, 256 * 1024, 256, 
SPI_NOR_OCTAL_DTR_READ) },
{ INFO("s28hs01gt",  0x345b1b,  0, 256 * 1024, 512, 
SPI_NOR_OCTAL_DTR_READ) },
+   { INFO("s28hs02gt",  0x345b1c,  0, 256 * 1024, 1024, 
SPI_NOR_OCTAL_DTR_READ) },
 #endif
 #endif
 #ifdef CONFIG_SPI_FLASH_SST/* SST */
-- 
2.25.1



[PATCH 7/9] mtd: spi-nor-core: Consolidate post_bfpt_fixup() for Infineon(Cypress) S25 and S28

2023-02-12 Thread tkuw584924
From: Takahiro Kuwano 

s28hx_t_post_bfpt_fixup() fixes erase opcode, erase size, and page size.
s25_post_bfpt_fixup() is doing same thing including multi-die support.
We can consolidate s28hx_t_post_bfpt_fixup() and s25_post_bfpt_fixup()
into one named s25_s28_post_bfpt_fixup().

In s25_s28_post_bfpt_fixup(), set_4byte() is called to force the device to
be 4-byte addressing mode. In S28HS02GT datasheet, the B7 opcode is missing
but it works actually (confirmed).

Signed-off-by: Takahiro Kuwano 
---
 drivers/mtd/spi/spi-nor-core.c | 52 --
 1 file changed, 6 insertions(+), 46 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 06cd2ff4d62b..d9b6bdc23892 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3309,10 +3309,10 @@ static void s25_default_init(struct spi_nor *nor)
nor->setup = s25_s28_setup;
 }
 
-static int s25_post_bfpt_fixup(struct spi_nor *nor,
-  const struct sfdp_parameter_header *header,
-  const struct sfdp_bfpt *bfpt,
-  struct spi_nor_flash_parameter *params)
+static int s25_s28_post_bfpt_fixup(struct spi_nor *nor,
+  const struct sfdp_parameter_header *header,
+  const struct sfdp_bfpt *bfpt,
+  struct spi_nor_flash_parameter *params)
 {
int ret;
u32 addr;
@@ -3386,7 +3386,7 @@ static void s25_post_sfdp_fixup(struct spi_nor *nor,
 
 static struct spi_nor_fixups s25_fixups = {
.default_init = s25_default_init,
-   .post_bfpt = s25_post_bfpt_fixup,
+   .post_bfpt = s25_s28_post_bfpt_fixup,
.post_sfdp = s25_post_sfdp_fixup,
 };
 
@@ -3502,50 +3502,10 @@ static void s28hx_t_post_sfdp_fixup(struct spi_nor *nor,
params->rdsr_addr_nbytes = 4;
 }
 
-static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor,
-  const struct sfdp_parameter_header 
*bfpt_header,
-  const struct sfdp_bfpt *bfpt,
-  struct spi_nor_flash_parameter *params)
-{
-   struct spi_mem_op op;
-   u8 buf;
-   u8 addr_width = 3;
-   int ret;
-
-   /*
-* The BFPT table advertises a 512B page size but the page size is
-* actually configurable (with the default being 256B). Read from
-* CFR3V[4] and set the correct size.
-*/
-   op = (struct spi_mem_op)
-   SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 1),
-  SPI_MEM_OP_ADDR(addr_width, 
SPINOR_REG_CYPRESS_CFR3V, 1),
-  SPI_MEM_OP_NO_DUMMY,
-  SPI_MEM_OP_DATA_IN(1, , 1));
-   ret = spi_mem_exec_op(nor->spi, );
-   if (ret)
-   return ret;
-
-   if (buf & SPINOR_REG_CYPRESS_CFR3_PGSZ)
-   params->page_size = 512;
-   else
-   params->page_size = 256;
-
-   /*
-* The BFPT advertises that it supports 4k erases, and the datasheet
-* says the same. But 4k erases did not work when testing. So, use 256k
-* erases for now.
-*/
-   nor->erase_opcode = SPINOR_OP_SE_4B;
-   nor->mtd.erasesize = 0x4;
-
-   return 0;
-}
-
 static struct spi_nor_fixups s28hx_t_fixups = {
.default_init = s28hx_t_default_init,
.post_sfdp = s28hx_t_post_sfdp_fixup,
-   .post_bfpt = s28hx_t_post_bfpt_fixup,
+   .post_bfpt = s25_s28_post_bfpt_fixup,
 };
 #endif /* CONFIG_SPI_FLASH_S28HX_T */
 
-- 
2.25.1



[PATCH 6/9] mtd: spi-nor-core: Consolidate setup() hook for Infineon(Cypress) S25 and S28

2023-02-12 Thread tkuw584924
From: Takahiro Kuwano 

s28hx_t_setup() only checks sector layout setting. To support multi-die
package parts like S28HS02GT, it needs to check device size and assign
ready() hook for multi-die package parts. These are covered in s25_setup()
so we can consolidate s28hx_t_setup() and s25_setup() into one named
s25_s28_setup().

spi_nor_wait_till_ready() at the beginning of s28hx_t_setup() can be
removed since there is no op that makes device busy state before setup.

Signed-off-by: Takahiro Kuwano 
---
 drivers/mtd/spi/spi-nor-core.c | 41 --
 1 file changed, 4 insertions(+), 37 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 3e347a3be38b..06cd2ff4d62b 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3258,8 +3258,8 @@ static int s25_s28_erase_non_uniform(struct spi_nor *nor, 
loff_t addr)
  SZ_128K);
 }
 
-static int s25_setup(struct spi_nor *nor, const struct flash_info *info,
-const struct spi_nor_flash_parameter *params)
+static int s25_s28_setup(struct spi_nor *nor, const struct flash_info *info,
+const struct spi_nor_flash_parameter *params)
 {
int ret;
u8 cr;
@@ -3306,7 +3306,7 @@ static int s25_setup(struct spi_nor *nor, const struct 
flash_info *info,
 
 static void s25_default_init(struct spi_nor *nor)
 {
-   nor->setup = s25_setup;
+   nor->setup = s25_s28_setup;
 }
 
 static int s25_post_bfpt_fixup(struct spi_nor *nor,
@@ -3465,43 +3465,10 @@ static int spi_nor_cypress_octal_dtr_enable(struct 
spi_nor *nor)
return 0;
 }
 
-static int s28hx_t_setup(struct spi_nor *nor, const struct flash_info *info,
-const struct spi_nor_flash_parameter *params)
-{
-   struct spi_mem_op op;
-   u8 buf;
-   u8 addr_width = 3;
-   int ret;
-
-   ret = spi_nor_wait_till_ready(nor);
-   if (ret)
-   return ret;
-
-   /*
-* Check CFR3V to check if non-uniform sector mode is selected. If it
-* is, set the erase hook to the non-uniform erase procedure.
-*/
-   op = (struct spi_mem_op)
-   SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 1),
-  SPI_MEM_OP_ADDR(addr_width,
-  SPINOR_REG_CYPRESS_CFR3V, 1),
-  SPI_MEM_OP_NO_DUMMY,
-  SPI_MEM_OP_DATA_IN(1, , 1));
-
-   ret = spi_mem_exec_op(nor->spi, );
-   if (ret)
-   return ret;
-
-   if (!(buf & SPINOR_REG_CYPRESS_CFR3_UNISECT))
-   nor->erase = s25_s28_erase_non_uniform;
-
-   return spi_nor_default_setup(nor, info, params);
-}
-
 static void s28hx_t_default_init(struct spi_nor *nor)
 {
nor->octal_dtr_enable = spi_nor_cypress_octal_dtr_enable;
-   nor->setup = s28hx_t_setup;
+   nor->setup = s25_s28_setup;
 }
 
 static void s28hx_t_post_sfdp_fixup(struct spi_nor *nor,
-- 
2.25.1



[PATCH 5/9] mtd: spi-nor-core: Rework s25_mdp_ready() to support Octal DTR mode

2023-02-12 Thread tkuw584924
From: Takahiro Kuwano 

s25_mdp_ready() handles status polling for multi-die package parts that
requires to read and check status register for each die. To support
S28HS02GT(dual-die package with Octal DTR support), rename function and
use nor->rdsr_dummy in octal DTR mode.

Signed-off-by: Takahiro Kuwano 
---
 drivers/mtd/spi/spi-nor-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 0e4498d6f59e..3e347a3be38b 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3223,13 +3223,13 @@ static int spi_nor_setup(struct spi_nor *nor, const 
struct flash_info *info,
 /* Use ID byte 4 to distinguish S25FS256T and S25Hx-T */
 #define S25FS256T_ID4  (0x08)
 
-static int s25_mdp_ready(struct spi_nor *nor)
+static int s25_s28_mdp_ready(struct spi_nor *nor)
 {
u32 addr;
int ret;
 
for (addr = 0; addr < nor->mtd.size; addr += SZ_128M) {
-   ret = spansion_sr_ready(nor, addr, 0);
+   ret = spansion_sr_ready(nor, addr, nor->rdsr_dummy);
if (!ret)
return ret;
}
@@ -3299,7 +3299,7 @@ static int s25_setup(struct spi_nor *nor, const struct 
flash_info *info,
 * all dies' status via read any register.
 */
if (nor->mtd.size > SZ_128M)
-   nor->ready = s25_mdp_ready;
+   nor->ready = s25_s28_mdp_ready;
 
return spi_nor_default_setup(nor, info, params);
 }
-- 
2.25.1



[PATCH 4/9] mtd: spi-nor-core: Use CLPEF(0x82) as alternative to CLSR(0x30) for S25 and S28

2023-02-12 Thread tkuw584924
From: Takahiro Kuwano 

Infineon(Cypress) S28Hx-T family does not support legacy CLSR(0x30) opcode.
Instead, it supports CLPEF(0x82) which has the same functionality as CLSR.
spansion_sr_ready() is for multi-die package parts including S28HS02GT, so
we need to use CLPEF instead of CLSR.

This change does not affect to S25x02GT which uses spansion_sr_ready() as
S25Hx-T family also supports CLPEF(0x82) as well as CLSR(0x30).

Signed-off-by: Takahiro Kuwano 
---
 drivers/mtd/spi/spi-nor-core.c | 2 +-
 include/linux/mtd/spi-nor.h| 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index b7f0f3343dd4..0e4498d6f59e 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -750,7 +750,7 @@ static int spansion_sr_ready(struct spi_nor *nor, u32 
addr_base, u8 dummy)
else
dev_dbg(nor->dev, "Programming Error occurred\n");
 
-   nor->write_reg(nor, SPINOR_OP_CLSR, NULL, 0);
+   nor->write_reg(nor, SPINOR_OP_CYPRESS_CLPEF, NULL, 0);
return -EIO;
}
 
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index ebe38306a1d2..8a94e1203724 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -180,6 +180,7 @@
 /* For Cypress flash. */
 #define SPINOR_OP_RD_ANY_REG   0x65/* Read any register */
 #define SPINOR_OP_WR_ANY_REG   0x71/* Write any register */
+#define SPINOR_OP_CYPRESS_CLPEF0x82/* Clear P/E 
err flag */
 #define SPINOR_REG_CYPRESS_ARCFN   0x0006
 #define SPINOR_REG_CYPRESS_STR1V   0x0080
 #define SPINOR_REG_CYPRESS_CFR1V   0x0082
-- 
2.25.1



[PATCH 3/9] mtd: spi-nor-core: Rework spansion_read_any_reg() to support Octal DTR mode

2023-02-12 Thread tkuw584924
From: Takahiro Kuwano 

In Infineon multi-die package parts, we need to use Read Any Register op
to read status register in 2nd or further die. Infineon S28HS02GT is
dual-die package and supports Octal DTR interface. To support this,
spansion_read_any_reg() needs to be reworked. Implementation is similar
to existing read_sr() that already supports Octal DTR mode.

Signed-off-by: Takahiro Kuwano 
---
 drivers/mtd/spi/spi-nor-core.c | 34 +-
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 2f0f24a41ee9..b7f0f3343dd4 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -330,12 +330,36 @@ static int spansion_read_any_reg(struct spi_nor *nor, u32 
addr, u8 dummy,
 u8 *val)
 {
struct spi_mem_op op =
-   SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 1),
-  SPI_MEM_OP_ADDR(nor->addr_mode_nbytes, addr, 1),
-  SPI_MEM_OP_DUMMY(dummy / 8, 1),
-  SPI_MEM_OP_DATA_IN(1, NULL, 1));
+   SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 0),
+  SPI_MEM_OP_ADDR(nor->addr_mode_nbytes, addr, 0),
+  SPI_MEM_OP_DUMMY(dummy, 0),
+  SPI_MEM_OP_DATA_IN(1, NULL, 0));
+   u8 buf[2];
+   int ret;
+
+   spi_nor_setup_op(nor, , nor->reg_proto);
+
+   /*
+* In Octal DTR mode, the number of address bytes is always 4 regardless
+* of addressing mode setting.
+*/
+   if (nor->reg_proto == SNOR_PROTO_8_8_8_DTR)
+   op.addr.nbytes = 4;
+
+   /*
+* We don't want to read only one byte in DTR mode. So, read 2 and then
+* discard the second byte.
+*/
+   if (spi_nor_protocol_is_dtr(nor->reg_proto))
+   op.data.nbytes = 2;
 
-   return spi_nor_read_write_reg(nor, , val);
+   ret = spi_nor_read_write_reg(nor, , buf);
+   if (ret)
+   return ret;
+
+   *val = buf[0];
+
+   return 0;
 }
 
 static int spansion_write_any_reg(struct spi_nor *nor, u32 addr, u8 val)
-- 
2.25.1



[PATCH 2/9] mtd: spi-nor-core: Consolidate non-uniform erase helpers for S25 and S28

2023-02-12 Thread tkuw584924
From: Takahiro Kuwano 

s25_erase_non_uniform() and s28hx_t_erase_uniform() support hybrid sector
layout (32 x 4KB sectors overlaid at bottom address) and doing same thing.
Consolidate them into single helper named s25_s28_erase_non_uniform().

Signed-off-by: Takahiro Kuwano 
---
 drivers/mtd/spi/spi-nor-core.c | 13 +++--
 include/linux/mtd/spi-nor.h|  1 -
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 74ac1fc8c41a..2f0f24a41ee9 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3227,7 +3227,7 @@ static int s25_quad_enable(struct spi_nor *nor)
return 0;
 }
 
-static int s25_erase_non_uniform(struct spi_nor *nor, loff_t addr)
+static int s25_s28_erase_non_uniform(struct spi_nor *nor, loff_t addr)
 {
/* Support 32 x 4KB sectors at bottom */
return spansion_erase_non_uniform(nor, addr, SPINOR_OP_BE_4K_4B, 0,
@@ -3268,7 +3268,7 @@ static int s25_setup(struct spi_nor *nor, const struct 
flash_info *info,
if (ret)
return ret;
if (!(cr & SPINOR_REG_CYPRESS_CFR3_UNISECT))
-   nor->erase = s25_erase_non_uniform;
+   nor->erase = s25_s28_erase_non_uniform;
 
/*
 * For the multi-die package parts, the ready() hook is needed to check
@@ -3441,13 +3441,6 @@ static int spi_nor_cypress_octal_dtr_enable(struct 
spi_nor *nor)
return 0;
 }
 
-static int s28hx_t_erase_non_uniform(struct spi_nor *nor, loff_t addr)
-{
-   /* Factory default configuration: 32 x 4 KiB sectors at bottom. */
-   return spansion_erase_non_uniform(nor, addr, SPINOR_OP_S28_SE_4K,
- 0, SZ_128K);
-}
-
 static int s28hx_t_setup(struct spi_nor *nor, const struct flash_info *info,
 const struct spi_nor_flash_parameter *params)
 {
@@ -3476,7 +3469,7 @@ static int s28hx_t_setup(struct spi_nor *nor, const 
struct flash_info *info,
return ret;
 
if (!(buf & SPINOR_REG_CYPRESS_CFR3_UNISECT))
-   nor->erase = s28hx_t_erase_non_uniform;
+   nor->erase = s25_s28_erase_non_uniform;
 
return spi_nor_default_setup(nor, info, params);
 }
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index f9a55c8e740c..ebe38306a1d2 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -180,7 +180,6 @@
 /* For Cypress flash. */
 #define SPINOR_OP_RD_ANY_REG   0x65/* Read any register */
 #define SPINOR_OP_WR_ANY_REG   0x71/* Write any register */
-#define SPINOR_OP_S28_SE_4K0x21
 #define SPINOR_REG_CYPRESS_ARCFN   0x0006
 #define SPINOR_REG_CYPRESS_STR1V   0x0080
 #define SPINOR_REG_CYPRESS_CFR1V   0x0082
-- 
2.25.1



[PATCH 1/9] mtd: spi-nor-core: Clean up macros for Infineon(Cypress) S25 and S28

2023-02-12 Thread tkuw584924
From: Takahiro Kuwano 

Some macro definitions used in Infineon(Cypress) S25 and S28 series are
redundant and some have inconsistent prefix. This patch removes redundant
ones and renames some to have same prefix as others.

Signed-off-by: Takahiro Kuwano 
---
 drivers/mtd/spi/spi-nor-core.c | 22 --
 include/linux/mtd/spi-nor.h| 11 +++
 2 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 2c3116ee5300..74ac1fc8c41a 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -330,7 +330,7 @@ static int spansion_read_any_reg(struct spi_nor *nor, u32 
addr, u8 dummy,
 u8 *val)
 {
struct spi_mem_op op =
-   SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDAR, 1),
+   SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 1),
   SPI_MEM_OP_ADDR(nor->addr_mode_nbytes, addr, 1),
   SPI_MEM_OP_DUMMY(dummy / 8, 1),
   SPI_MEM_OP_DATA_IN(1, NULL, 1));
@@ -341,7 +341,7 @@ static int spansion_read_any_reg(struct spi_nor *nor, u32 
addr, u8 dummy,
 static int spansion_write_any_reg(struct spi_nor *nor, u32 addr, u8 val)
 {
struct spi_mem_op op =
-   SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRAR, 1),
+   SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WR_ANY_REG, 1),
   SPI_MEM_OP_ADDR(nor->addr_mode_nbytes, addr, 1),
   SPI_MEM_OP_NO_DUMMY,
   SPI_MEM_OP_DATA_OUT(1, NULL, 1));
@@ -712,7 +712,7 @@ static int set_4byte(struct spi_nor *nor, const struct 
flash_info *info,
  */
 static int spansion_sr_ready(struct spi_nor *nor, u32 addr_base, u8 dummy)
 {
-   u32 reg_addr = addr_base + SPINOR_REG_ADDR_STR1V;
+   u32 reg_addr = addr_base + SPINOR_REG_CYPRESS_STR1V;
u8 sr;
int ret;
 
@@ -1820,7 +1820,7 @@ static int macronix_quad_enable(struct spi_nor *nor)
 static int spansion_quad_enable_volatile(struct spi_nor *nor, u32 addr_base,
 u8 dummy)
 {
-   u32 addr = addr_base + SPINOR_REG_ADDR_CFR1V;
+   u32 addr = addr_base + SPINOR_REG_CYPRESS_CFR1V;
 
u8 cr;
int ret;
@@ -3249,7 +3249,8 @@ static int s25_setup(struct spi_nor *nor, const struct 
flash_info *info,
 * uniform 128KB only due to complexity of non-uniform layout.
 */
if (nor->info->id[4] == S25FS256T_ID4) {
-   ret = spansion_read_any_reg(nor, SPINOR_REG_ADDR_ARCFN, 8, );
+   ret = spansion_read_any_reg(nor, SPINOR_REG_CYPRESS_ARCFN, 8,
+   );
if (ret)
return ret;
 
@@ -3263,10 +3264,10 @@ static int s25_setup(struct spi_nor *nor, const struct 
flash_info *info,
 * Read CFR3V to check if uniform sector is selected. If not, assign an
 * erase hook that supports non-uniform erase.
 */
-   ret = spansion_read_any_reg(nor, SPINOR_REG_ADDR_CFR3V, 0, );
+   ret = spansion_read_any_reg(nor, SPINOR_REG_CYPRESS_CFR3V, 0, );
if (ret)
return ret;
-   if (!(cr & CFR3V_UNHYSA))
+   if (!(cr & SPINOR_REG_CYPRESS_CFR3_UNISECT))
nor->erase = s25_erase_non_uniform;
 
/*
@@ -3327,12 +3328,13 @@ static int s25_post_bfpt_fixup(struct spi_nor *nor,
 * dies are configured to 512B buffer.
 */
for (addr = 0; addr < params->size; addr += SZ_128M) {
-   ret = spansion_read_any_reg(nor, addr + SPINOR_REG_ADDR_CFR3V,
-   0, );
+   ret = spansion_read_any_reg(nor,
+   addr + SPINOR_REG_CYPRESS_CFR3V, 0,
+   );
if (ret)
return ret;
 
-   if (!(cfr3v & CFR3V_PGMBUF)) {
+   if (!(cfr3v & SPINOR_REG_CYPRESS_CFR3_PGSZ)) {
params->page_size = 256;
return 0;
}
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 2861b73edbce..f9a55c8e740c 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -136,14 +136,6 @@
 #define SPINOR_OP_BRRD 0x16/* Bank register read */
 #define SPINOR_OP_CLSR 0x30/* Clear status register 1 */
 #define SPINOR_OP_EX4B_CYPRESS 0xB8/* Exit 4-byte mode */
-#define SPINOR_OP_RDAR 0x65/* Read any register */
-#define SPINOR_OP_WRAR 0x71/* Write any register */
-#define SPINOR_REG_ADDR_STR1V  0x0080
-#define SPINOR_REG_ADDR_CFR1V  0x0082
-#define SPINOR_REG_ADDR_CFR3V  0x0084
-#define SPINOR_REG_ADDR_ARCFN  0x0006
-#define CFR3V_UNHYSA   BIT(3)  /* Uniform sectors or not */
-#define CFR3V_PGMBUF   BIT(4)  /* Program buffer size 

[PATCH 0/9] mtd: spi-nor: Add support for Infineon S28HS02GT

2023-02-12 Thread tkuw584924
From: Takahiro Kuwano 

Infineon S28HS02GT is 1.8V, 2Gb (256MB) NOR Flash memory with Octal
interface. It is a dual-die package parts and has same features with
existing S28 series.

The goal of this series of patches is to add S28HS02GT support. Before
adding device ID to the table, some reworks are done to simplify the
support structure for all other S25Hx-T and S28Hx-T families.

Tested newly added S28HS02GT and other S25Hx-T and S28Hx-T devices on
Zynq-7000 platform with Infineon SPI controller.

Only summary datasheet is available on web.
https://www.infineon.com/dgdl/Infineon-S28HS02GT_S28HS04GT_S28HL02GT_S28HL04GT_2Gb_4Gb_SEMPER_Flash_Octal_interface_1.8V_3.0V-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7e7124d1017f0631e33714d9

Please send an email to me for full version of the datasheet.

Takahiro Kuwano (9):
  mtd: spi-nor-core: Clean up macros for Infineon(Cypress) S25 and S28
  mtd: spi-nor-core: Consolidate non-uniform erase helpers for S25 and
S28
  mtd: spi-nor-core: Rework spansion_read_any_reg() to support Octal DTR
mode
  mtd: spi-nor-core: Use CLPEF(0x82) as alternative to CLSR(0x30) for
S25 and S28
  mtd: spi-nor-core: Rework s25_mdp_ready() to support Octal DTR mode
  mtd: spi-nor-core: Consolidate setup() hook for Infineon(Cypress) S25
and S28
  mtd: spi-nor-core: Consolidate post_bfpt_fixup() for Infineon(Cypress)
S25 and S28
  mtd: spi-nor-core: Rework spi_nor_cypress_octal_dtr_enable()
  mtd: spi-nor-ids: Add Infineon(Cypress) s28hs02gt ID

 drivers/mtd/spi/spi-nor-core.c | 220 +
 drivers/mtd/spi/spi-nor-ids.c  |   1 +
 include/linux/mtd/spi-nor.h|  14 +--
 3 files changed, 89 insertions(+), 146 deletions(-)

-- 
2.25.1



Re: [PATCH] rockchip: dts: rk3328: fix sdram params

2023-02-12 Thread Kever Yang



On 2023/2/11 02:30, Jonas Karlman wrote:

The rk3328 sdram driver read sdram parameters from the devicetree into a
struct rk3328_sdram_params using dev_read_u32_array.

After commit 5ab30c3176bf ("ram: rockchip: Update ddr pctl regs for px30")
changed the size of struct ddr_pctl_regs, a member of struct
rk3328_sdram_params, U-Boot TPL can no longer initialize DRAM on RK3328.

Add ten u32 to the sdram parameter array in devicetree to align with
this size change. This fixes DRAM initialization on RK3328.

Fixes: 5ab30c3176bf ("ram: rockchip: Update ddr pctl regs for px30")
Signed-off-by: Jonas Karlman 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  arch/arm/dts/rk3328-sdram-ddr3-666.dtsi| 10 ++
  arch/arm/dts/rk3328-sdram-ddr4-666.dtsi| 10 ++
  arch/arm/dts/rk3328-sdram-lpddr3-1600.dtsi | 10 ++
  arch/arm/dts/rk3328-sdram-lpddr3-666.dtsi  | 10 ++
  4 files changed, 40 insertions(+)

diff --git a/arch/arm/dts/rk3328-sdram-ddr3-666.dtsi 
b/arch/arm/dts/rk3328-sdram-ddr3-666.dtsi
index 3e88ed443ba0..c5acfe4ac2a0 100644
--- a/arch/arm/dts/rk3328-sdram-ddr3-666.dtsi
+++ b/arch/arm/dts/rk3328-sdram-ddr3-666.dtsi
@@ -92,6 +92,16 @@
0x
0x
0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
  
  		0x0004

0x000a
diff --git a/arch/arm/dts/rk3328-sdram-ddr4-666.dtsi 
b/arch/arm/dts/rk3328-sdram-ddr4-666.dtsi
index 0859649a6905..c5fa2903c5c1 100644
--- a/arch/arm/dts/rk3328-sdram-ddr4-666.dtsi
+++ b/arch/arm/dts/rk3328-sdram-ddr4-666.dtsi
@@ -89,6 +89,16 @@
0x
0x
0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
  
  		0x0004

0x000c
diff --git a/arch/arm/dts/rk3328-sdram-lpddr3-1600.dtsi 
b/arch/arm/dts/rk3328-sdram-lpddr3-1600.dtsi
index d63c761a0283..07f27b2b7bab 100644
--- a/arch/arm/dts/rk3328-sdram-lpddr3-1600.dtsi
+++ b/arch/arm/dts/rk3328-sdram-lpddr3-1600.dtsi
@@ -92,6 +92,16 @@
0x
0x
0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
  
  		0x0004

0x000b
diff --git a/arch/arm/dts/rk3328-sdram-lpddr3-666.dtsi 
b/arch/arm/dts/rk3328-sdram-lpddr3-666.dtsi
index df42bb29ce88..d53d3a0fdfb2 100644
--- a/arch/arm/dts/rk3328-sdram-lpddr3-666.dtsi
+++ b/arch/arm/dts/rk3328-sdram-lpddr3-666.dtsi
@@ -92,6 +92,16 @@
0x
0x
0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
+   0x
  
  		0x0004

0x000b


Re: [PATCH 2/2] i2c: i2c-cdns.c: Update driver to read fifo-depth from device tree

2023-02-12 Thread Heiko Schocher
Hello Pei Yue Ho,

On 13.02.23 06:47, Heiko Schocher wrote:
> Hello Pei Yue Ho,
> 
> On 04.01.23 08:20, Pei Yue Ho wrote:
>> Enable driver to fetch the optional parameter (fifo-depth)
>> from device tree. If the parameter is not found in the device
>> tree, it will use the default value declared in the driver.
>>
>> Signed-off-by: Pei Yue Ho 
>> Reviewed-by: Wei Liang Lim 
>> Reviewed-by: Eng Lee Teh 
>> ---
>>  drivers/i2c/i2c-cdns.c | 26 --
>>  1 file changed, 16 insertions(+), 10 deletions(-)
> 
> Reviewed-by: Heiko Schocher 

I am sorry, your patch drops error in gitlab Ci, see:

https://dev.azure.com/hs0298/110c3e42-44d5-4db4-9bd5-8a8bbead15f3/_apis/build/builds/100/logs/310

"""
2023-02-13T06:30:04.2539867Zarm:  +   xilinx_zynq_virt
2023-02-13T06:30:04.2540416Z +drivers/i2c/i2c-cdns.c: In function 
'cdns_i2c_read_data':
2023-02-13T06:30:04.2541494Z +drivers/i2c/i2c-cdns.c:363:48: error: passing 
argument 1 of
'cdns_is_hold_quirk' makes pointer from integer without a cast 
[-Werror=int-conversion]
2023-02-13T06:30:04.2542415Z +  363 | if 
(cdns_is_hold_quirk(hold_quirk,
curr_recv_count))
2023-02-13T06:30:04.2542799Z +  |   
 ^~
2023-02-13T06:30:04.2543066Z +  |   
 |
2023-02-13T06:30:04.2579584Z +  |   
 int
2023-02-13T06:30:04.2580260Z +drivers/i2c/i2c-cdns.c:314:60: note: expected 
'struct i2c_cdns_bus *'
but argument is of type 'int'
2023-02-13T06:30:04.2580754Z +  314 | static inline bool 
cdns_is_hold_quirk(struct i2c_cdns_bus
*i2c_bus, int hold_quirk,
2023-02-13T06:30:04.2581135Z +  |   
~^~~
2023-02-13T06:30:04.2581604Z +drivers/i2c/i2c-cdns.c:363:29: error: too few 
arguments to function
'cdns_is_hold_quirk'
2023-02-13T06:30:04.2581973Z +  | 
^~
2023-02-13T06:30:04.2582352Z +drivers/i2c/i2c-cdns.c:314:20: note: declared here
2023-02-13T06:30:04.2582649Z +  |^~
2023-02-13T06:30:04.2583415Z +drivers/i2c/i2c-cdns.c:367:40: error: passing 
argument 1 of
'cdns_is_hold_quirk' makes pointer from integer without a cast 
[-Werror=int-conversion]
2023-02-13T06:30:04.2583944Z +  367 | if 
(cdns_is_hold_quirk(hold_quirk,
curr_recv_count)) {
2023-02-13T06:30:04.2584262Z +  |
^~
2023-02-13T06:30:04.2584510Z +  ||
2023-02-13T06:30:04.2584743Z +  |int
2023-02-13T06:30:04.2585511Z +drivers/i2c/i2c-cdns.c:367:21: error: too few 
arguments to function
'cdns_is_hold_quirk'
2023-02-13T06:30:04.2585984Z +  | ^~
2023-02-13T06:30:04.2586267Z +cc1: all warnings being treated as errors
2023-02-13T06:30:04.2586703Z +make[3]: *** [scripts/Makefile.build:257: 
drivers/i2c/i2c-cdns.o] Error 1
2023-02-13T06:30:04.2587106Z +make[2]: *** [scripts/Makefile.build:397: 
drivers/i2c] Error 2
2023-02-13T06:30:04.2587457Z +make[1]: *** [Makefile:1845: drivers] Error 2
2023-02-13T06:30:04.2587832Z +make: *** [Makefile:177: sub-make] Error 2
2023-02-13T06:30:04.2587979Z
2023-02-13T06:30:04.2588213Z 001 /1  xilinx_zynq_virt
"""

Please fix!

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH V5 08/12] iot2050: Add script for signing artifacts

2023-02-12 Thread Jan Kiszka
On 13.02.23 05:26, Simon Glass wrote:
> Hi Jan,
> 
> On Tue, 7 Feb 2023 at 11:39, Simon Glass  wrote:
>>
>> Hi Jan,
>>
>> On Tue, 7 Feb 2023 at 09:45, Jan Kiszka  wrote:
>>>
>>> On 07.02.23 16:28, Simon Glass wrote:
 Hi Jan,

 On Mon, 6 Feb 2023 at 04:57, Jan Kiszka  wrote:
>
> On 06.02.23 11:47, Jan Kiszka wrote:
>> On 04.02.23 23:26, Simon Glass wrote:
>>> Hi Jan,
>>>
>>> On Fri, 3 Feb 2023 at 23:35, Jan Kiszka  wrote:

 On 03.02.23 19:51, Tom Rini wrote:
> On Fri, Feb 03, 2023 at 01:26:37PM +0100, Jan Kiszka wrote:
>
>> From: Jan Kiszka 
>>
>> There are many ways to get a signed firmware for the IOT2050 devices,
>> namely for the parts under user-control. This script documents one 
>> way
>> of doing it, given a signing key. Augment the board documentation 
>> with
>> the required procedure around it.
>>
>> Signed-off-by: Jan Kiszka 
> [snip]
>> +# currently broken in upstream
>> +#source/tools/binman/binman replace -i flash.bin -f 
>> f...@0x38.fit fit@0x38
>> +dd if=f...@0x38.fit of=flash.bin bs=$((0x1000)) 
>> seek=$((0x38/0x1000)) conv=notrunc
>
> Is that still a true comment?
>

 binman: Node '/fit@0x38/images/u-boot': Offset 0x0 (0) size 0xb8870
 (755824) is outside the section '/fit@0x38' starting at 0x0 (0) of
 size 0x400 (1024)

 And for the second call:

 binman: Node '/fit@0x38': Replacing sections is not implemented yet
>>>
>>> I sent a patch to implement that.
>>>
>>> I'm not quite sure if this resolves the first problem, too. If not,
>>> can you please provide a binman test for the case you need, or
>>> instructions on how to cause the failure?
>>
>> Instructions to reproduce are basically
>>  - apply this series
>>  - build flash.bin according to doc/board/siemens/iot2050.rst
>>  - drop the dd calls and activate binman in this signing script
>>  - run it
>>
>> But I'll try your patch ASAP on my setup.
>
> Still left with
>
> binman: Node '/fit@0x38/images/u-boot': Offset 0x0 (0) size 0xb8928
> (756008) is outside the section '/fit@0x38' starting at 0x0 (0) of
> size 0x400 (1024)
>
> and
>
> binman: 'NoneType' object has no attribute 'props'
>
> That was for the second call of binman (source/tools/binman/binman
> replace -i flash.bin -f f...@0x38.fit fit@0x38). The "not
> implemented messages is gone.
>
> I've switched back to dd for the first call, but that did not work yet.
> So the message above indicates a relevant error.
>
> Jan

 I thought I was able to follow all the steps (gosh, so many blobs) but
 I got something different from the first 'binman' call in your script.

 binman: Error 1 running 'mkimage -t -F
 /tmp/binman.l_xl69mi/f...@0x38.fit': mkimage: verify_header failed
 for FIT Image support with exit code 1

 I will take a look at that...it is trying to rebuild the FIT and it
 should not. It is another case of rebuilding sections that I didn't
 think of.

 But actually, you need to create a new entry type for your signing
 scheme. It looks like the signature is created by openssl and (rather
 than putting it in a separate file) it creates a new file containing
 both the signature and the file contents. That is a bit of a pain, but
 can be made to work.

 Basically you need a new entry type (of which the FIT is a child) that
 gets the contents of its child, signs it and returns that as the
 contents. You can see vblock for an example, and
 collection_contents_to_file(). Let me know if you want me to create an
 example.

 The way it should work is that you run binman once (as part of the
 U-Boot build) and it produces a final image. No messing about with
 scripts, etc. In this case it looks like the key.pem file should be an
 input to your new entry type.

 Using binman replace to sign something later is fine, but it is not
 the intended use. Binman is supposed to be a single-pass image
 builder.
>>>
>>> I strongly suspect we will need split build/sign also in the future
>>> because those steps are generally separate in corporate production envs.
>>> Maybe even 3 steps: assemble, extract hashes that should be signed and
>>> embed signatures of those in the end.
>>
>> Yes I'm sure you are right, that's what I would expect. There is a
>> 'binman sign' command coming[1] so I hope we can use that to make it
>> easier, too.
>>
>> Still, we must have a single-step build in U-Boot, so we do need a new
>> entry type. Let me know if you want me to hack up something as a
>> starting point.
> 
> Please see 

Re: [PATCH v3 2/2] arm: aspeed: dtsi: add reg for i2c

2023-02-12 Thread Heiko Schocher
Hello Ryan,

On 30.01.23 07:19, Ryan Chen wrote:
> The i2c driver have global register that i2c bus use
> ofnode_get_parent to get parent register address.
> 
> Signed-off-by: Ryan Chen 
> ---
>  arch/arm/dts/ast2600.dtsi | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Heiko Schocher 

bye,
Heiko
-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH 4/5] eficonfig: include EFI_STATUS string in error message

2023-02-12 Thread Masahisa Kojima
On Fri, 10 Feb 2023 at 20:57, Heinrich Schuchardt  wrote:
>
> On 2/2/23 10:24, Masahisa Kojima wrote:
> > Current eficonfig_print_msg() does not show the return
> > value of EFI Boot/Runtime Services when the service call fails.
> > With this commit, user can know EFI_STATUS in the error message.
>
> Why do we need function eficonfig_print_msg()?
>
> I cannot see why the printing only parameter msg with log_err() should
> not be good enough.

ANSI_CLEAR_CONSOLE is sent before drawing the menu. I think it is
difficult for user
to know some error occurs by the user operation, user needs scroll up
to see the error message
when we use log_err().

Regards,
Masahisa Kojima

>
> Best regards
>
> Heinrich
>
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> >   cmd/eficonfig.c   | 95 +--
> >   cmd/eficonfig_sbkey.c | 16 
> >   include/efi_config.h  |  2 +-
> >   3 files changed, 93 insertions(+), 20 deletions(-)
> >
> > diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> > index 0a17b8cf34..b0c8637676 100644
> > --- a/cmd/eficonfig.c
> > +++ b/cmd/eficonfig.c
> > @@ -151,19 +151,90 @@ static void eficonfig_menu_adjust(struct efimenu 
> > *efi_menu, bool add)
> >   #define eficonfig_menu_up(_a) eficonfig_menu_adjust(_a, false)
> >   #define eficonfig_menu_down(_a) eficonfig_menu_adjust(_a, true)
> >
> > +struct efi_status_str {
> > + efi_status_t status;
> > + char *str;
> > +};
> > +
> > +static const struct efi_status_str status_str_table[] = {
> > + {EFI_LOAD_ERROR,"Load Error"},
> > + {EFI_INVALID_PARAMETER, "Invalid Parameter"},
> > + {EFI_UNSUPPORTED,   "Unsupported"},
> > + {EFI_BAD_BUFFER_SIZE,   "Bad Buffer Size"},
> > + {EFI_BUFFER_TOO_SMALL,  "Buffer Too Small"},
> > + {EFI_NOT_READY, "Not Ready"},
> > + {EFI_DEVICE_ERROR,  "Device Error"},
> > + {EFI_WRITE_PROTECTED,   "Write Protected"},
> > + {EFI_OUT_OF_RESOURCES,  "Out of Resources"},
> > + {EFI_VOLUME_CORRUPTED,  "Volume Corrupted"},
> > + {EFI_VOLUME_FULL,   "Volume Full"},
> > + {EFI_NO_MEDIA,  "No Media"},
> > + {EFI_MEDIA_CHANGED, "Media Changed"},
> > + {EFI_NOT_FOUND, "Not Found"},
> > + {EFI_ACCESS_DENIED, "Access Denied"},
> > + {EFI_NO_RESPONSE,   "No Response"},
> > + {EFI_NO_MAPPING,"No Mapping"},
> > + {EFI_TIMEOUT,   "Timeout"},
> > + {EFI_NOT_STARTED,   "Not Started"},
> > + {EFI_ALREADY_STARTED,   "Already Started"},
> > + {EFI_ABORTED,   "Aborted"},
> > + {EFI_ICMP_ERROR,"ICMP Error"},
> > + {EFI_TFTP_ERROR,"TFTP Error"},
> > + {EFI_PROTOCOL_ERROR,"Protocol Error"},
> > + {EFI_INCOMPATIBLE_VERSION,  "Incompatible Version"},
> > + {EFI_SECURITY_VIOLATION,"Security Violation"},
> > + {EFI_CRC_ERROR, "CRC Error"},
> > + {EFI_END_OF_MEDIA,  "End of Media"},
> > + {EFI_END_OF_FILE,   "End of File"},
> > + {EFI_INVALID_LANGUAGE,  "Invalid Language"},
> > + {EFI_COMPROMISED_DATA,  "Compromised Data"},
> > + {EFI_IP_ADDRESS_CONFLICT,   "IP Address Conflict"},
> > + {EFI_HTTP_ERROR,"HTTP Error"},
> > + {EFI_WARN_UNKNOWN_GLYPH,"Warn Unknown Glyph"},
> > + {EFI_WARN_DELETE_FAILURE,   "Warn Delete Failure"},
> > + {EFI_WARN_WRITE_FAILURE,"Warn Write Failure"},
> > + {EFI_WARN_BUFFER_TOO_SMALL, "Warn Buffer Too Small"},
> > + {EFI_WARN_STALE_DATA,   "Warn Stale Data"},
> > + {EFI_WARN_FILE_SYSTEM,  "Warn File System"},
> > + {EFI_WARN_RESET_REQUIRED,   "Warn Reset Required"},
> > + {0, ""},
> > +};
> > +
> > +/**
> > + * struct get_status_str - get status string
> > + *
> > + * @status:  efi_status_t value to covert to string
> > + * Return:   pointer to the string
> > + */
> > +static char *get_error_str(efi_status_t status)
> > +{
> > + u32 i;
> > +
> > + for (i = 0; status_str_table[i].status != 0; i++) {
> > + if (status == status_str_table[i].status)
> > + return status_str_table[i].str;
> > + }
> > + return status_str_table[i].str;
> > +}
> > +
> >   /**
> >* eficonfig_print_msg() - print message
> >*
> >* display the message to the user, user proceeds the screen
> >* with any key press.
> >*
> > - * @items:   pointer to the structure of each menu entry
> > - * @count:   the number of menu entry
> > - * @menu_header: pointer to the menu header string
> > - * Return:   status code
> > + * @msg: pointer to the error message
> > + * @status:  efi status code, set 0 if no status string output
> >*/
> > -void 

Re: [PATCH v3 1/2] i2c:aspeed:support ast2600 i2c new register mode driver

2023-02-12 Thread Heiko Schocher
Hello Ryan,

On 30.01.23 07:19, Ryan Chen wrote:
> Add i2c new register mode driver to support AST2600 i2c
> new register mode. AST2600 i2c controller have legacy and
> new register mode. The new register mode have global register
> support 4 base clock for scl clock selection, and new clock
> divider mode.
> 
> Signed-off-by: Ryan Chen 
> Reviewed-by: Simon Glass 
> ---
>  MAINTAINERS   |   6 +
>  drivers/i2c/Kconfig   |  10 ++
>  drivers/i2c/Makefile  |   1 +
>  drivers/i2c/ast2600_i2c.c | 367 ++
>  drivers/i2c/ast2600_i2c.h | 120 +
>  5 files changed, 504 insertions(+)
>  create mode 100644 drivers/i2c/ast2600_i2c.c
>  create mode 100644 drivers/i2c/ast2600_i2c.h

Reviewed-by: Heiko Schocher 

bye,
Heiko

-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH 2/2] i2c: i2c-cdns.c: Update driver to read fifo-depth from device tree

2023-02-12 Thread Heiko Schocher
Hello Pei Yue Ho,

On 04.01.23 08:20, Pei Yue Ho wrote:
> Enable driver to fetch the optional parameter (fifo-depth)
> from device tree. If the parameter is not found in the device
> tree, it will use the default value declared in the driver.
> 
> Signed-off-by: Pei Yue Ho 
> Reviewed-by: Wei Liang Lim 
> Reviewed-by: Eng Lee Teh 
> ---
>  drivers/i2c/i2c-cdns.c | 26 --
>  1 file changed, 16 insertions(+), 10 deletions(-)

Reviewed-by: Heiko Schocher 

bye,
Heiko

-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH 1/2] dt-bindings: i2c: i2c-cdns.txt: Add description for an optional parameter, fifo-depth

2023-02-12 Thread Heiko Schocher
Hello Pei Yue Ho

On 04.01.23 08:20, Pei Yue Ho wrote:
> Add description for fifo-depth parameter that can be used
> in the device tree.
> 
> Signed-off-by: Pei Yue Ho 
> Reviewed-by: Wei Liang Lim 
> Reviewed-by: Eng Lee Teh 
> ---
>  doc/device-tree-bindings/i2c/i2c-cdns.txt | 4 
>  1 file changed, 4 insertions(+)

Reviewed-by: Heiko Schocher 

Do you plan to submit this to linux too?

bye,
Heiko
-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH 1/5] menu: remove CTRL+C to quit

2023-02-12 Thread Masahisa Kojima
On Fri, 10 Feb 2023 at 20:49, Heinrich Schuchardt  wrote:
>
> On 2/2/23 10:24, Masahisa Kojima wrote:
> > On the sandbox called without "--terminal raw" CTRL+C leaves U-Boot,
> > "ESC/CTRL+C to quit" is misleading.
> >
> > Let's remove CTRL+C to quit key handling from bootmenu and eficonfig menu.
>
> I guess my review was misleading.
>
> CTRL+C on the sandbox leaves the u-boot program. Therefore advising its
> use in the GUI is not a good idea. Reacting on the CTRL+C on other
> systems does no harm.
>
> I will just take the text changes and leave the code as is.

I misunderstand your review comment.
Thank you for the update.

Regards,
Masahisa Kojima

>
> Best regards
>
> Heinrich
>
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> >   cmd/bootmenu.c   | 2 +-
> >   cmd/eficonfig.c  | 6 +++---
> >   common/menu.c| 1 -
> >   doc/usage/cmd/bootmenu.rst   | 2 +-
> >   lib/efi_loader/efi_console.c | 2 +-
> >   5 files changed, 6 insertions(+), 7 deletions(-)
> >
> > diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
> > index 3236ca5d79..8dc133c236 100644
> > --- a/cmd/bootmenu.c
> > +++ b/cmd/bootmenu.c
> > @@ -437,7 +437,7 @@ static void menu_display_statusline(struct menu *m)
> >   printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
> >   puts(ANSI_CLEAR_LINE);
> >   printf(ANSI_CURSOR_POSITION, menu->count + 6, 3);
> > - puts("Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit");
> > + puts("Press UP/DOWN to move, ENTER to select, ESC to quit");
> >   puts(ANSI_CLEAR_LINE_TO_END);
> >   printf(ANSI_CURSOR_POSITION, menu->count + 7, 1);
> >   puts(ANSI_CLEAR_LINE);
> > diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> > index 47c04cf536..f365a988d4 100644
> > --- a/cmd/eficonfig.c
> > +++ b/cmd/eficonfig.c
> > @@ -23,12 +23,12 @@
> >
> >   static struct efi_simple_text_input_protocol *cin;
> >   const char *eficonfig_menu_desc =
> > - "  Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit";
> > + "  Press UP/DOWN to move, ENTER to select, ESC to quit";
> >
> >   static const char *eficonfig_change_boot_order_desc =
> >   "  Press UP/DOWN to move, +/- to change orde\n"
> >   "  Press SPACE to activate or deactivate the entry\n"
> > - "  Select [Save] to complete, ESC/CTRL+C to quit";
> > + "  Select [Save] to complete, ESC to quit";
> >
> >   static struct efi_simple_text_output_protocol *cout;
> >   static int avail_row;
> > @@ -927,7 +927,7 @@ static efi_status_t handle_user_input(u16 *buf, int 
> > buf_size,
> >  ANSI_CURSOR_POSITION
> >  "%s"
> >  ANSI_CURSOR_POSITION
> > -"  Press ENTER to complete, ESC/CTRL+C to quit",
> > +"  Press ENTER to complete, ESC to quit",
> >  0, 1, msg, 8, 1);
> >
> >   /* tmp is used to accept user cancel */
> > diff --git a/common/menu.c b/common/menu.c
> > index cdcdbb2a18..56401695de 100644
> > --- a/common/menu.c
> > +++ b/common/menu.c
> > @@ -492,7 +492,6 @@ enum bootmenu_key bootmenu_conv_key(int ichar)
> >   /* enter key was pressed */
> >   key = BKEY_SELECT;
> >   break;
> > - case CTL_CH('c'):
> >   case '\e':
> >   /* ^C was pressed */
> >   key = BKEY_QUIT;
> > diff --git a/doc/usage/cmd/bootmenu.rst b/doc/usage/cmd/bootmenu.rst
> > index cb3c8d2f93..684a18d8e1 100644
> > --- a/doc/usage/cmd/bootmenu.rst
> > +++ b/doc/usage/cmd/bootmenu.rst
> > @@ -122,7 +122,7 @@ Example bootmenu is as below::
> >   Default behavior when user exits from the bootmenu
> >   ~~
> >   User can exit from bootmenu by selecting the last entry
> > -"U-Boot console"/"Quit" or ESC/CTRL+C key.
> > +"U-Boot console"/"Quit" or ESC key.
> >
> >   When the CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is disabled,
> >   user exits from the bootmenu and returns to the U-Boot console.
> > diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
> > index 1ed8c7aa36..2c7536107a 100644
> > --- a/lib/efi_loader/efi_console.c
> > +++ b/lib/efi_loader/efi_console.c
> > @@ -1395,7 +1395,7 @@ efi_status_t efi_console_get_u16_string(struct 
> > efi_simple_text_input_protocol *c
> >   } else if (key.unicode_char == u'\r') {
> >   buf[len] = u'\0';
> >   return EFI_SUCCESS;
> > - } else if (key.unicode_char == 0x3 || key.scan_code == 23) {
> > + } else if (key.scan_code == 23) {
> >   return EFI_ABORTED;
> >   } else if (key.unicode_char < 0x20) {
> >   /* ignore control codes other than Ctrl+C, '\r' and 
> > '\b' */


[PATCH v2 RESEND 11/14] clocks: qcs404: Add support for I2C clocks

2023-02-12 Thread Sumit Garg
Co-developed-by: Mike Worsfold 
Signed-off-by: Mike Worsfold 
Signed-off-by: Sumit Garg 
---

Hi Tom,

This patch is missing from your latest pull of this series [1]. Can you please
help to pull it as well?

[1] QCS404: Add ethernet and I2C drivers

-Sumit

 arch/arm/mach-snapdragon/clock-qcs404.c   | 58 +++
 .../include/mach/sysmap-qcs404.h  | 17 ++
 2 files changed, 75 insertions(+)

diff --git a/arch/arm/mach-snapdragon/clock-qcs404.c 
b/arch/arm/mach-snapdragon/clock-qcs404.c
index b8f5691aae..3357b54c30 100644
--- a/arch/arm/mach-snapdragon/clock-qcs404.c
+++ b/arch/arm/mach-snapdragon/clock-qcs404.c
@@ -81,6 +81,36 @@ static const struct bcr_regs emac_ptp_regs = {
.D = EMAC_D,
 };
 
+static const struct bcr_regs blsp1_qup0_i2c_apps_regs = {
+   .cmd_rcgr = BLSP1_QUP0_I2C_APPS_CMD_RCGR,
+   .cfg_rcgr = BLSP1_QUP0_I2C_APPS_CFG_RCGR,
+   /* mnd_width = 0 */
+};
+
+static const struct bcr_regs blsp1_qup1_i2c_apps_regs = {
+   .cmd_rcgr = BLSP1_QUP1_I2C_APPS_CMD_RCGR,
+   .cfg_rcgr = BLSP1_QUP1_I2C_APPS_CFG_RCGR,
+   /* mnd_width = 0 */
+};
+
+static const struct bcr_regs blsp1_qup2_i2c_apps_regs = {
+   .cmd_rcgr = BLSP1_QUP2_I2C_APPS_CMD_RCGR,
+   .cfg_rcgr = BLSP1_QUP2_I2C_APPS_CFG_RCGR,
+   /* mnd_width = 0 */
+};
+
+static const struct bcr_regs blsp1_qup3_i2c_apps_regs = {
+   .cmd_rcgr = BLSP1_QUP3_I2C_APPS_CMD_RCGR,
+   .cfg_rcgr = BLSP1_QUP3_I2C_APPS_CFG_RCGR,
+   /* mnd_width = 0 */
+};
+
+static const struct bcr_regs blsp1_qup4_i2c_apps_regs = {
+   .cmd_rcgr = BLSP1_QUP4_I2C_APPS_CMD_RCGR,
+   .cfg_rcgr = BLSP1_QUP4_I2C_APPS_CFG_RCGR,
+   /* mnd_width = 0 */
+};
+
 ulong msm_set_rate(struct clk *clk, ulong rate)
 {
struct msm_clk_priv *priv = dev_get_priv(clk->dev);
@@ -171,6 +201,34 @@ int msm_enable(struct clk *clk)
case GCC_ETH_AXI_CLK:
clk_enable_cbc(priv->base + ETH_AXI_CBCR);
break;
+   case GCC_BLSP1_AHB_CLK:
+   clk_enable_vote_clk(priv->base, _blsp1_ahb_clk);
+   break;
+   case GCC_BLSP1_QUP0_I2C_APPS_CLK:
+   clk_enable_cbc(priv->base + BLSP1_QUP0_I2C_APPS_CBCR);
+   clk_rcg_set_rate(priv->base, _qup0_i2c_apps_regs, 0,
+CFG_CLK_SRC_CXO);
+   break;
+   case GCC_BLSP1_QUP1_I2C_APPS_CLK:
+   clk_enable_cbc(priv->base + BLSP1_QUP1_I2C_APPS_CBCR);
+   clk_rcg_set_rate(priv->base, _qup1_i2c_apps_regs, 0,
+CFG_CLK_SRC_CXO);
+   break;
+   case GCC_BLSP1_QUP2_I2C_APPS_CLK:
+   clk_enable_cbc(priv->base + BLSP1_QUP2_I2C_APPS_CBCR);
+   clk_rcg_set_rate(priv->base, _qup2_i2c_apps_regs, 0,
+CFG_CLK_SRC_CXO);
+   break;
+   case GCC_BLSP1_QUP3_I2C_APPS_CLK:
+   clk_enable_cbc(priv->base + BLSP1_QUP3_I2C_APPS_CBCR);
+   clk_rcg_set_rate(priv->base, _qup3_i2c_apps_regs, 0,
+CFG_CLK_SRC_CXO);
+   break;
+   case GCC_BLSP1_QUP4_I2C_APPS_CLK:
+   clk_enable_cbc(priv->base + BLSP1_QUP4_I2C_APPS_CBCR);
+   clk_rcg_set_rate(priv->base, _qup4_i2c_apps_regs, 0,
+CFG_CLK_SRC_CXO);
+   break;
default:
return 0;
}
diff --git a/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h 
b/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h
index 8920c4ee8f..5768fb1377 100644
--- a/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h
+++ b/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h
@@ -28,6 +28,23 @@
 #define BLSP1_UART2_APPS_N (0x3040)
 #define BLSP1_UART2_APPS_D (0x3044)
 
+/* I2C controller clock control registerss */
+#define BLSP1_QUP0_I2C_APPS_CBCR   (0x6028)
+#define BLSP1_QUP0_I2C_APPS_CMD_RCGR   (0x602C)
+#define BLSP1_QUP0_I2C_APPS_CFG_RCGR   (0x6030)
+#define BLSP1_QUP1_I2C_APPS_CBCR   (0x2008)
+#define BLSP1_QUP1_I2C_APPS_CMD_RCGR   (0x200C)
+#define BLSP1_QUP1_I2C_APPS_CFG_RCGR   (0x2010)
+#define BLSP1_QUP2_I2C_APPS_CBCR   (0x3010)
+#define BLSP1_QUP2_I2C_APPS_CMD_RCGR   (0x3000)
+#define BLSP1_QUP2_I2C_APPS_CFG_RCGR   (0x3004)
+#define BLSP1_QUP3_I2C_APPS_CBCR   (0x4020)
+#define BLSP1_QUP3_I2C_APPS_CMD_RCGR   (0x4000)
+#define BLSP1_QUP3_I2C_APPS_CFG_RCGR   (0x4004)
+#define BLSP1_QUP4_I2C_APPS_CBCR   (0x5020)
+#define BLSP1_QUP4_I2C_APPS_CMD_RCGR   (0x5000)
+#define BLSP1_QUP4_I2C_APPS_CFG_RCGR   (0x5004)
+
 /* SD controller clock control registers */
 #define SDCC_BCR(n)(((n) * 0x1000) + 0x41000)
 #define SDCC_CMD_RCGR(n)   (((n) * 0x1000) + 0x41004)
-- 
2.34.1



Re: [PATCH] rockchip: dts: rk3328: fix sdram params

2023-02-12 Thread Simon Glass
On Fri, 10 Feb 2023 at 11:30, Jonas Karlman  wrote:
>
> The rk3328 sdram driver read sdram parameters from the devicetree into a
> struct rk3328_sdram_params using dev_read_u32_array.
>
> After commit 5ab30c3176bf ("ram: rockchip: Update ddr pctl regs for px30")
> changed the size of struct ddr_pctl_regs, a member of struct
> rk3328_sdram_params, U-Boot TPL can no longer initialize DRAM on RK3328.
>
> Add ten u32 to the sdram parameter array in devicetree to align with
> this size change. This fixes DRAM initialization on RK3328.
>
> Fixes: 5ab30c3176bf ("ram: rockchip: Update ddr pctl regs for px30")
> Signed-off-by: Jonas Karlman 
> ---
>  arch/arm/dts/rk3328-sdram-ddr3-666.dtsi| 10 ++
>  arch/arm/dts/rk3328-sdram-ddr4-666.dtsi| 10 ++
>  arch/arm/dts/rk3328-sdram-lpddr3-1600.dtsi | 10 ++
>  arch/arm/dts/rk3328-sdram-lpddr3-666.dtsi  | 10 ++
>  4 files changed, 40 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH v4 10/11] dm: Add support for handling old u-boot, dm- tags

2023-02-12 Thread Simon Glass
Hi Tom,

On Sun, 12 Feb 2023 at 18:10, Tom Rini  wrote:
>
> On Sun, Feb 12, 2023 at 04:15:08PM -0700, Simon Glass wrote:
> > Hi Tom,
> >
> > On Sun, 12 Feb 2023 at 10:44, Tom Rini  wrote:
> > >
> > > On Fri, Feb 10, 2023 at 08:28:56AM -0700, Simon Glass wrote:
> > >
> > > > Add a CONFIG option to deal with this automatically, printing a warning
> > > > when U-Boot starts up. This can be useful if the device tree comes from
> > > > another project.
> > > >
> > > > We will maintain this through the 2023.07 release, providing 6 months
> > > > for people to notice.
> > > >
> > > > Signed-off-by: Simon Glass 
> > >
> > > Adding Michal since he got lost by accident on this iteration. Does that
> > > sound like enough time to get the tooling you know of updated?
> >
> > Thanks...BTW is the membership of u-boot-custodians listed somewhere?
>
> Maybe via the normal mailman page once you've signed in?

Not that I can see. Probably only the admin knows.

Regards,
Simon


Re: [PATCH V5 08/12] iot2050: Add script for signing artifacts

2023-02-12 Thread Simon Glass
Hi Jan,

On Tue, 7 Feb 2023 at 11:39, Simon Glass  wrote:
>
> Hi Jan,
>
> On Tue, 7 Feb 2023 at 09:45, Jan Kiszka  wrote:
> >
> > On 07.02.23 16:28, Simon Glass wrote:
> > > Hi Jan,
> > >
> > > On Mon, 6 Feb 2023 at 04:57, Jan Kiszka  wrote:
> > >>
> > >> On 06.02.23 11:47, Jan Kiszka wrote:
> > >>> On 04.02.23 23:26, Simon Glass wrote:
> >  Hi Jan,
> > 
> >  On Fri, 3 Feb 2023 at 23:35, Jan Kiszka  wrote:
> > >
> > > On 03.02.23 19:51, Tom Rini wrote:
> > >> On Fri, Feb 03, 2023 at 01:26:37PM +0100, Jan Kiszka wrote:
> > >>
> > >>> From: Jan Kiszka 
> > >>>
> > >>> There are many ways to get a signed firmware for the IOT2050 
> > >>> devices,
> > >>> namely for the parts under user-control. This script documents one 
> > >>> way
> > >>> of doing it, given a signing key. Augment the board documentation 
> > >>> with
> > >>> the required procedure around it.
> > >>>
> > >>> Signed-off-by: Jan Kiszka 
> > >> [snip]
> > >>> +# currently broken in upstream
> > >>> +#source/tools/binman/binman replace -i flash.bin -f 
> > >>> f...@0x38.fit fit@0x38
> > >>> +dd if=f...@0x38.fit of=flash.bin bs=$((0x1000)) 
> > >>> seek=$((0x38/0x1000)) conv=notrunc
> > >>
> > >> Is that still a true comment?
> > >>
> > >
> > > binman: Node '/fit@0x38/images/u-boot': Offset 0x0 (0) size 
> > > 0xb8870
> > > (755824) is outside the section '/fit@0x38' starting at 0x0 (0) of
> > > size 0x400 (1024)
> > >
> > > And for the second call:
> > >
> > > binman: Node '/fit@0x38': Replacing sections is not implemented 
> > > yet
> > 
> >  I sent a patch to implement that.
> > 
> >  I'm not quite sure if this resolves the first problem, too. If not,
> >  can you please provide a binman test for the case you need, or
> >  instructions on how to cause the failure?
> > >>>
> > >>> Instructions to reproduce are basically
> > >>>  - apply this series
> > >>>  - build flash.bin according to doc/board/siemens/iot2050.rst
> > >>>  - drop the dd calls and activate binman in this signing script
> > >>>  - run it
> > >>>
> > >>> But I'll try your patch ASAP on my setup.
> > >>
> > >> Still left with
> > >>
> > >> binman: Node '/fit@0x38/images/u-boot': Offset 0x0 (0) size 0xb8928
> > >> (756008) is outside the section '/fit@0x38' starting at 0x0 (0) of
> > >> size 0x400 (1024)
> > >>
> > >> and
> > >>
> > >> binman: 'NoneType' object has no attribute 'props'
> > >>
> > >> That was for the second call of binman (source/tools/binman/binman
> > >> replace -i flash.bin -f f...@0x38.fit fit@0x38). The "not
> > >> implemented messages is gone.
> > >>
> > >> I've switched back to dd for the first call, but that did not work yet.
> > >> So the message above indicates a relevant error.
> > >>
> > >> Jan
> > >
> > > I thought I was able to follow all the steps (gosh, so many blobs) but
> > > I got something different from the first 'binman' call in your script.
> > >
> > > binman: Error 1 running 'mkimage -t -F
> > > /tmp/binman.l_xl69mi/f...@0x38.fit': mkimage: verify_header failed
> > > for FIT Image support with exit code 1
> > >
> > > I will take a look at that...it is trying to rebuild the FIT and it
> > > should not. It is another case of rebuilding sections that I didn't
> > > think of.
> > >
> > > But actually, you need to create a new entry type for your signing
> > > scheme. It looks like the signature is created by openssl and (rather
> > > than putting it in a separate file) it creates a new file containing
> > > both the signature and the file contents. That is a bit of a pain, but
> > > can be made to work.
> > >
> > > Basically you need a new entry type (of which the FIT is a child) that
> > > gets the contents of its child, signs it and returns that as the
> > > contents. You can see vblock for an example, and
> > > collection_contents_to_file(). Let me know if you want me to create an
> > > example.
> > >
> > > The way it should work is that you run binman once (as part of the
> > > U-Boot build) and it produces a final image. No messing about with
> > > scripts, etc. In this case it looks like the key.pem file should be an
> > > input to your new entry type.
> > >
> > > Using binman replace to sign something later is fine, but it is not
> > > the intended use. Binman is supposed to be a single-pass image
> > > builder.
> >
> > I strongly suspect we will need split build/sign also in the future
> > because those steps are generally separate in corporate production envs.
> > Maybe even 3 steps: assemble, extract hashes that should be signed and
> > embed signatures of those in the end.
>
> Yes I'm sure you are right, that's what I would expect. There is a
> 'binman sign' command coming[1] so I hope we can use that to make it
> easier, too.
>
> Still, we must have a single-step build in U-Boot, so we do need a new
> entry type. 

[RFC PATCH v2] doc: arch: Add document for RISC-V architecture

2023-02-12 Thread Yu Chien Peter Lin
This patch adds a brief introduction to the RISC-V architecture and
the typical boot process used on a variety of RISC-V platforms.

Signed-off-by: Yu Chien Peter Lin 
Reviewed-by: Samuel Holland 
Reviewed-by: Simon Glass 
---
Changes v1 -> v2
- Use 'boot phases' rather than 'boot stages'
- Pick up Samuel and Simon's RB tags
---
 doc/arch/index.rst |  1 +
 doc/arch/riscv.rst | 43 +++
 2 files changed, 44 insertions(+)
 create mode 100644 doc/arch/riscv.rst

diff --git a/doc/arch/index.rst b/doc/arch/index.rst
index b3e85f9bf3..b8da4b8c8e 100644
--- a/doc/arch/index.rst
+++ b/doc/arch/index.rst
@@ -11,6 +11,7 @@ Architecture-specific doc
m68k
mips
nios2
+   riscv
sandbox/index
sh
x86
diff --git a/doc/arch/riscv.rst b/doc/arch/riscv.rst
new file mode 100644
index 00..6327dad8fb
--- /dev/null
+++ b/doc/arch/riscv.rst
@@ -0,0 +1,43 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2023, Yu Chien Peter Lin 
+
+RISC-V
+==
+
+Overview
+
+
+This document outlines the U-Boot boot process for the RISC-V architecture.
+RISC-V is an open-source instruction set architecture (ISA) based on the
+principles of reduced instruction set computing (RISC). It has been designed
+to be flexible and customizable, allowing it to be adapted to different use
+cases, from embedded systems to high performance servers.
+
+Typical Boot Process
+
+
+RISC-V production boot images typically include a U-Boot SPL for 
platform-specific
+initialization. The U-Boot SPL then loads a FIT image (u-boot.itb), which 
contains
+an SBI (Supervisor Binary Interface) firmware such as `OpenSBI 
`_, as well as a regular
+U-Boot (or U-Boot proper) running in S-mode. Finally, the S-mode Operating 
System
+is loaded.
+
+In between the boot phases, the hartid is passed through the a0 register, and 
the
+start address of the devicetree is passed through the a1 register.
+
+The following diagram illustrates the boot process::
+
+   <--( M-mode )><---( S-mode )-->
+   ++   +-+++   ++
+   | U-Boot SPL |-->|   SBI   |--->| U-Boot |-->|   OS   |
+   ++   +-+++   ++
+
+To examine the boot process with the QEMU virt machine, you can follow the 
steps
+in the following document:
+:doc:`../board/emulation/qemu-riscv.rst`
+
+Toolchain
+-
+
+You can build the `RISC-V GNU toolchain 
`_ from scratch, or 
download a
+pre-built toolchain from the `releases page 
`_.
-- 
2.34.1



Re: [PATCH v3 08/10] phy: socionext: Add UniPhier USB3 PHY driver

2023-02-12 Thread Kunihiko Hayashi

Hi Marek,

On 2023/02/10 23:09, Marek Vasut wrote:

On 2/8/23 10:15, Kunihiko Hayashi wrote:

[...]


+static int uniphier_usb3phy_init(struct phy *phy)
+{
+   struct uniphier_usb3phy_priv *priv = dev_get_priv(phy->dev);
+   int ret;
+
+   ret = clk_enable_bulk(>clks);
+   if (ret)
+   goto out_clk;


This should be just 'return ret;'


+   ret = reset_deassert_bulk(>rsts);
+   if (ret)
+   goto out_rst;


This should be goto out_rst, however ...


+   return 0;
+
+out_rst:
+   reset_release_bulk(>rsts);
+out_clk:
+   clk_release_bulk(>clks);


... the out_rst: should only do:

out_rst:
clk_disable_bulk();
return ret

out_clk part can be removed.


I see. These operations are unpaired.
I'll fix them.


+   return ret;
+}
+
+static int uniphier_usb3phy_probe(struct udevice *dev)
+{
+   struct uniphier_usb3phy_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = clk_get_bulk(dev, >clks);
+   if (ret) {
+   if (ret != -ENOSYS && ret != -ENOENT) {


This can be single line:

if (ret && ret != -ENOSYS && ret != -ENOENT)
return ret;


OK, This will be fixed.


+   printf("Failed to get clocks\n");
+   return ret;
+   }
+   }
+
+   ret = reset_get_bulk(dev, >rsts);
+   if (ret) {
+   if (ret != -ENOSYS && ret != -ENOENT) {


Same here.


+   printf("Failed to get resets\n");
+   clk_release_bulk(>clks);


Better use goto out_clk fail path.


+   return ret;
+   }
+   }
+
+   return 0;
+}
+
+static struct phy_ops uniphier_usb3phy_ops = {
+   .init = uniphier_usb3phy_init,


You should implement .exit callback too, that one should do these two steps:

reset_assert_bulk()
clk_disable_bulk()


I think so, however, when I added .exit() and executed "usb stop;usb start",
unfortunately the command got stuck.

Currently uniphier clk doesn't support CLK_CCF and can't be nested.
I think more changes are needed.

Thank you,

---
Best Regards
Kunihiko Hayashi


Re: [RFC PATCH] doc: arch: Add document for RISC-V architecture

2023-02-12 Thread Yu-Chien Peter Lin
On Sun, Feb 12, 2023 at 12:25:56PM -0700, Simon Glass wrote:
> On Sun, 12 Feb 2023 at 00:01, Yu Chien Peter Lin  
> wrote:
> >
> > This patch adds a brief introduction to the RISC-V architecture and
> > the typical boot process used on a variety of RISC-V platforms.
> >
> > Signed-off-by: Yu Chien Peter Lin 
> > ---
> > Hi RISC-V community,
> >
> > Please leave a comment if there is anything I've missed that should
> > be mentioned in the document. Thanks.
> > ---
> >  doc/arch/index.rst |  1 +
> >  doc/arch/riscv.rst | 43 +++
> >  2 files changed, 44 insertions(+)
> >  create mode 100644 doc/arch/riscv.rst
> 
> Reviewed-by: Simon Glass 
> 
> Looks good. One nit is that we try to talk in terms of boot 'phases'
> rather than stages.

Hi Simon,

Thanks for the review, I'll update in the next patch.

Best regards,
Peter Lin

> Regards,
> Simon


Re: [PATCH 2/4] usb: xhci-mtk: modify the SOF/ITP interval for mt8195

2023-02-12 Thread 云春峰
On Fri, 2023-02-10 at 11:32 +0100, Marek Vasut wrote:
> On 2/10/23 09:33, Chunfeng Yun wrote:
> [...]
> > @@ -50,6 +50,27 @@
> >   #define IPPC_U3_CTRL(p)   (IPPC_U3_CTRL_0P + ((p) * 0x08))
> >   #define IPPC_U2_CTRL(p)   (IPPC_U2_CTRL_0P + ((p) * 0x08))
> >   
> > +/* xHCI CSR */
> > +#define LS_EOF_CFG 0x930
> > +#define LSEOF_OFFSET   0x89
> > +
> > +#define FS_EOF_CFG 0x934
> > +#define FSEOF_OFFSET   0x2e
> > +
> > +#define SS_GEN1_EOF_CFG0x93c
> > +#define SSG1EOF_OFFSET 0x78
> > +
> > +#define HFCNTR_CFG 0x944
> > +#define ITP_DELTA_CLK  (0xa << 1)
> > +#define ITP_DELTA_CLK_MASK GENMASK(5, 1)
> > +#define FRMCNT_LEV1_RANG   (0x12b << 8)
> 
> Look at FIELD_PREP() macro, that should let you avoid the (0x12b <<
> 8) .
Seems not use FIELD_PREP() macro here.
It's not a mask, it's the value set in below mask
FRMCNT_LEV1_RANG_MASK.

> 
> > +#define FRMCNT_LEV1_RANG_MASK  GENMASK(19, 8)
> > +
> > +#define SS_GEN2_EOF_CFG0x990
> > +#define SSG2EOF_OFFSET 0x3c
> > +
> > +#define XSEOF_OFFSET_MASK  GENMASK(11, 0)
> 
> [...]
> 
> > @@ -308,6 +354,7 @@ static int xhci_mtk_remove(struct udevice *dev)
> >   
> >   static const struct udevice_id xhci_mtk_ids[] = {
> > { .compatible = "mediatek,mtk-xhci" },
> > +   { .compatible = "mediatek,mt8195-xhci" },
> 
> Is the extra compatible string really needed, can't the driver match
> on 
> the generic one ?
These settings are a workaround only for mt8195 to fix HW issue, can't
use generic compatible.

Thanks a lot




Re: [PATCH v4 10/11] dm: Add support for handling old u-boot, dm- tags

2023-02-12 Thread Tom Rini
On Sun, Feb 12, 2023 at 04:15:08PM -0700, Simon Glass wrote:
> Hi Tom,
> 
> On Sun, 12 Feb 2023 at 10:44, Tom Rini  wrote:
> >
> > On Fri, Feb 10, 2023 at 08:28:56AM -0700, Simon Glass wrote:
> >
> > > Add a CONFIG option to deal with this automatically, printing a warning
> > > when U-Boot starts up. This can be useful if the device tree comes from
> > > another project.
> > >
> > > We will maintain this through the 2023.07 release, providing 6 months
> > > for people to notice.
> > >
> > > Signed-off-by: Simon Glass 
> >
> > Adding Michal since he got lost by accident on this iteration. Does that
> > sound like enough time to get the tooling you know of updated?
> 
> Thanks...BTW is the membership of u-boot-custodians listed somewhere?

Maybe via the normal mailman page once you've signed in?

-- 
Tom


signature.asc
Description: PGP signature


Re: i.MX8M binman

2023-02-12 Thread Simon Glass
Hi Peng,

On Fri, 10 Feb 2023 at 07:06, Simon Glass  wrote:
>
> Hi Peng,
>
> On Fri, 10 Feb 2023 at 04:55, Peng Fan  wrote:
> >
> > +Marek,
> >
> > I heard that from Marek on IRC, but Marek ask me to reach you.
> >
> > Actually I am not sure what is the issue with i.MX8M binman
> > node.
>
> Was this to do with getting the security stuff into binman properly? I
> do recall trying that, but them Marek ran out of time.

That is here: https://github.com/sjg20/u-boot/tree/mx8

It should be pretty close to working. Do you want to take a look?

Regards,
Simon

>
> Regards,
> Simon
>
> >
> > Thanks,
> > Peng.
> >
> > On 2/7/2023 9:38 PM, Simon Glass wrote:
> > > Hi Peng,
> > >
> > > On Mon, 6 Feb 2023 at 05:43, Peng Fan  wrote:
> > >>
> > >> Hi Simon,
> > >>
> > >> I heard that you found i.MX8M binman has some issues,
> > >> would you please share me the details?
> > >> Then I could find some time to address those issues.
> > >
> > > Sorry, I can't remember that. Do you have more context?
> > >
> > > Regards,
> > > SImon


[PATCH] fs: btrfs: limit the mapped length to the original length

2023-02-12 Thread Qu Wenruo
[BUG]
There is a bug report that btrfs driver caused hang during file read:

  This breaks btrfs on the HiFive Unmatched.

  => pci enum
  PCIE-0: Link up (Gen1-x8, Bus0)
  => nvme scan
  => load nvme 0:2 0x8c00 /boot/dtb/sifive/hifive-unmatched-a00.dtb
  [hangs]

[CAUSE]
The reporter provided some debug output:

  read_extent_data: cur=615817216, orig_len=16384, cur_len=16384
  read_extent_data: btrfs_map_block: cur_len=479944704; ret=0
  read_extent_data: ret=0
  read_extent_data: cur=615833600, orig_len=4096, cur_len=4096
  read_extent_data: btrfs_map_block: cur_len=479928320; ret=0

Note the second and the last line, the @cur_len is 450+MiB, which is
almost a chunk size.

And inside __btrfs_map_block(), we limits the returned value to stripe
length, but that's depending on the chunk type:

if (map->type & (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 |
 BTRFS_BLOCK_GROUP_RAID1C3 | BTRFS_BLOCK_GROUP_RAID1C4 |
 BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6 |
 BTRFS_BLOCK_GROUP_RAID10 |
 BTRFS_BLOCK_GROUP_DUP)) {
/* we limit the length of each bio to what fits in a stripe */
*length = min_t(u64, ce->size - offset,
  map->stripe_len - stripe_offset);
} else {
*length = ce->size - offset;
}

This means, if the chunk is SINGLE profile, then we don't limit the
returned length at all, and even for other profiles, we can still return
a length much larger than the requested one.

[FIX]
Properly clamp the returned length, preventing it from returning a much
larger range than expected.

Reported-by: Andreas Schwab 
Signed-off-by: Qu Wenruo 
---
 fs/btrfs/volumes.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 4aaaeab663f5..7d4095d9ca88 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -956,6 +956,7 @@ int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
struct btrfs_mapping_tree *map_tree = _info->mapping_tree;
struct cache_extent *ce;
struct map_lookup *map;
+   u64 orig_len = *length;
u64 offset;
u64 stripe_offset;
u64 *raid_map = NULL;
@@ -1047,6 +1048,7 @@ again:
} else {
*length = ce->size - offset;
}
+   *length = min_t(u64, *length, orig_len);
 
if (!multi_ret)
goto out;
-- 
2.39.1



Please pull u-boot-dm

2023-02-12 Thread Simon Glass
Hi Tom,

https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/15164


The following changes since commit a5e490f14e904fd240ccec5d364509b36a3150f9:

  socfpga: fix the serial console on DE1-SoC (2023-02-12 15:47:19 -0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-dm.git tags/dm-pull-12feb23

for you to fetch changes up to 4ee85df9ce0b6385a28f538af31680eed4ee153e:

  cmd: fdt: allow standalone "fdt move" (2023-02-12 17:33:51 -0700)


minor changes to fdt command and binman


Andre Przywara (2):
  cmd: fdt: move: Use map_sysmem to convert pointers
  cmd: fdt: allow standalone "fdt move"

Simon Glass (1):
  binman: Show the image name for the top-level section

 cmd/fdt.c | 34 --
 tools/binman/ftest.py | 68
++--
 tools/binman/image.py |  2 +-
 3 files changed, 51 insertions(+), 53 deletions(-)

Regards,
Simon


Re: [PATCH] binman: Show the image name for the top-level section

2023-02-12 Thread Simon Glass
At present we show 'main section' as the top-level section name. It may
be more helpful to show the actual image name. This is tricky because
Image is a parent class of Entry_section, so there is no distinction
between an image and a section.

Update it to show the image name.

Signed-off-by: Simon Glass 
---

 tools/binman/ftest.py | 68 +++
 tools/binman/image.py |  2 +-
 2 files changed, 31 insertions(+), 39 deletions(-)

Applied to u-boot-dm, thanks!


Re: [PATCH v2 1/3] cmd: fdt: move: Use map_sysmem to convert pointers

2023-02-12 Thread Simon Glass
The "fdt move" subcommand was using the provided DTB addresses directly,
without trying to "map" them into U-Boot's address space. This happened
to work since on the vast majority of "real" platforms there is a simple
1:1 mapping of VA to PAs, so either value works fine.

However this is not true on the sandbox, so the "fdt move" command fails
there miserably:
=> fdt addr $fdtcontroladdr
=> cp.l $fdtcontroladdr $fdt_addr_r 40  # simple memcpy works
=> fdt move $fdtcontroladdr $fdt_addr_r
Segmentation fault

Use the proper "map_sysmem" call to convert PAs to VAs, to make this
more robust in general and to enable operation in the sandbox.

Signed-off-by: Andre Przywara 
Reviewed-by: Simon Glass 
---
 cmd/fdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied to u-boot-dm, thanks!


Re: [PATCH v2 2/3] cmd: fdt: allow standalone "fdt move"

2023-02-12 Thread Simon Glass
Hi,

On Fri, 10 Feb 2023 11:02:12 + Andre Przywara wrote:
> At the moment every subcommand of "fdt", except "addr" itself, requires
> the DT address to be set first. We explicitly check for that before even
> comparing against the subcommands' string.
> This early bailout also affects the "move" subcommand, even though that
> does not require or rely on a previous call to "fdt addr". In fact it
> even sets the FDT address to the target of the move command, so is a
> perfect beginning for a sequence of fdt commands.
>
> Move the check for a previously set FDT address to after we handle the
> "move" command also, so we don't need a dummy call to "fdt addr" first,
> before being able to move the devicetree.
>
> This skips one pointless "fdt addr" call in scripts which aim to alter
> the control DT, but need to copy it to a safe location first (for
> instance to $fdt_addr_r).
>
> Signed-off-by: Andre Przywara 
> Reviewed-by: Simon Glass 
> ---
>  cmd/fdt.c | 28 +---
>  1 file changed, 17 insertions(+), 11 deletions(-)
>
Applied to u-boot-dm, thanks!


Re: [PATCH] fs/btrfs: handle data extents, which crosss stripe boundaries, correctly

2023-02-12 Thread Qu Wenruo




On 2023/2/13 00:20, Andreas Schwab wrote:

When I print ce->size in __btrfs_map_block, it is almost always
1073741824, which looks bogus.


Can you provide the image of that filesystem?

Thanks,
Qu


[PATCH] binman: Support marking FMAP areas as preserved

2023-02-12 Thread Simon Glass
Add an entry flag called 'preserve' to indicate that an entry should be
preserved by firmware updates. Propagate this to FMAP too.

Signed-off-by: Simon Glass 
---

 tools/binman/binman.rst|  8 
 tools/binman/entries.rst   |  5 +
 tools/binman/entry.py  |  7 +++
 tools/binman/etype/fmap.py | 15 +--
 tools/binman/fmap_util.py  |  3 +++
 tools/binman/ftest.py  |  2 +-
 tools/binman/test/067_fmap.dts |  1 +
 7 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index 03a99a19bc6..6cf4f196fb3 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -838,6 +838,14 @@ offset-from-elf:
 is the symbol to lookup (relative to elf-base-sym) and  is an 
offset
 to add to that value.
 
+preserve:
+Indicates that this entry should be preserved by any firmware updates. This
+flag should be checked by the updater when it is deciding which entries to
+update. This flag is normally attached to sections but can be attached to
+a single entry in a section if the updater supports it. Not that binman
+itself has no control over the updater's behaviour, so this is just a
+signal. It is not enforced by binman.
+
 Examples of the above options can be found in the tests. See the
 tools/binman/test directory.
 
diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 7a04a613992..19659247cf0 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -887,6 +887,11 @@ before its contents, so that it is possible to reconstruct 
the hierarchy
 from the FMAP by using the offset information. This convention does not
 seem to be documented, but is used in Chromium OS.
 
+To mark an area as preserved, use the normal 'preserved' flag in the entry.
+This will result in the corresponding FMAP area having the
+FMAP_AREA_PRESERVE flag. This flag does not automatically propagate down to
+child entries.
+
 CBFS entries appear as a single entry, i.e. the sub-entries are ignored.
 
 
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 5eacc5fa6c4..fd617e4f15f 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -100,6 +100,10 @@ class Entry(object):
 appear in the map
 optional (bool): True if this entry contains an optional external blob
 overlap (bool): True if this entry overlaps with others
+preserve (bool): True if this entry should be preserved when updating
+firmware. This means that it will not be changed by the update.
+This is just a signal: enforcement of this is up to the updater.
+This flag does not automatically propagate down to child entries.
 """
 fake_dir = None
 
@@ -148,6 +152,7 @@ class Entry(object):
 self.overlap = False
 self.elf_base_sym = None
 self.offset_from_elf = None
+self.preserve = False
 
 @staticmethod
 def FindEntryClass(etype, expanded):
@@ -310,6 +315,8 @@ class Entry(object):
 self.offset_from_elf = fdt_util.GetPhandleNameOffset(self._node,
  'offset-from-elf')
 
+self.preserve = fdt_util.GetBool(self._node, 'preserve')
+
 def GetDefaultFilename(self):
 return None
 
diff --git a/tools/binman/etype/fmap.py b/tools/binman/etype/fmap.py
index 0c576202a48..b35450fec97 100644
--- a/tools/binman/etype/fmap.py
+++ b/tools/binman/etype/fmap.py
@@ -33,6 +33,11 @@ class Entry_fmap(Entry):
 from the FMAP by using the offset information. This convention does not
 seem to be documented, but is used in Chromium OS.
 
+To mark an area as preserved, use the normal 'preserved' flag in the entry.
+This will result in the corresponding FMAP area having the
+FMAP_AREA_PRESERVE flag. This flag does not automatically propagate down to
+child entries.
+
 CBFS entries appear as a single entry, i.e. the sub-entries are ignored.
 """
 def __init__(self, section, etype, node):
@@ -48,6 +53,12 @@ class Entry_fmap(Entry):
 entries = entry.GetEntries()
 tout.debug("fmap: Add entry '%s' type '%s' (%s subentries)" %
(entry.GetPath(), entry.etype, to_hex_size(entries)))
+
+# Collect any flag (separate lines to ensure code coverage)
+flags = 0
+if entry.preserve:
+flags = fmap_util.FMAP_AREA_PRESERVE
+
 if entries and entry.etype != 'cbfs':
 # Create an area for the section, which encompasses all entries
 # within it
@@ -59,7 +70,7 @@ class Entry_fmap(Entry):
 # Drop @ symbols in name
 name = entry.name.replace('@', '')
 areas.append(
-fmap_util.FmapArea(pos, entry.size or 0, name, 0))
+fmap_util.FmapArea(pos, entry.size or 0, name, flags))
 

[PATCH V2] arm64: imx: Add support for imx8mp-beacon-kit

2023-02-12 Thread Adam Ford
Beacon Embedded has an i.MX8M Plus development kit which consists
of a SOM + baseboard.  The SOM includes Bluetooth, WiFi, QSPI, eMMC,
and one Ethernet PHY. The baseboard includes audio, HDMI, USB-C Dual
Role port, USB Hub with five ports, a PCIe slot, and a second Ethernet
PHY.  The device trees are already queued for inclusion in Linux 6.3.

Signed-off-by: Adam Ford 
---
V2:  Move default environment from imx8mp_beacon.h to imx8mp_beacon.env
 Move README to beacon-imx8mp.rst

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index d9b719f85d..d812ad4048 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -986,6 +986,7 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
imx8mn-beacon-kit.dtb \
imx8mq-mnt-reform2.dtb \
imx8mq-phanbell.dtb \
+   imx8mp-beacon-kit.dtb \
imx8mp-dhcom-pdk2.dtb \
imx8mp-evk.dtb \
imx8mp-icore-mx8mp-edimm2.2.dtb \
diff --git a/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi 
b/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
new file mode 100644
index 00..0f7c91a078
--- /dev/null
+++ b/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
@@ -0,0 +1,216 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022 Logic PD, Inc DBA Beacon EmbeddedWorks
+ */
+
+#include "imx8mp-u-boot.dtsi"
+
+/ {
+   wdt-reboot {
+   compatible = "wdt-reboot";
+   wdt = <>;
+   u-boot,dm-spl;
+   };
+
+   firmware {
+   optee {
+   compatible = "linaro,optee-tz";
+   method = "smc";
+   };
+   };
+};
+
+&{/soc@0/bus@3080/i2c@30a2/pmic@25} {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3080/i2c@30a2/pmic@25/regulators} {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   /delete-property/ assigned-clocks;
+   /delete-property/ assigned-clock-parents;
+   /delete-property/ assigned-clock-rates;
+};
+
+ {
+   reset-gpios = < 22 GPIO_ACTIVE_LOW>;
+   reset-assert-us = <15000>;
+   reset-deassert-us = <10>;
+};
+
+ {
+   phy-reset-gpios = < 18 GPIO_ACTIVE_LOW>;
+   phy-reset-duration = <15>;
+   phy-reset-post-delay = <100>;
+};
+
+ {
+   assigned-clock-parents = < IMX8MP_SYS_PLL1_400M>;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   compatible = "ti,tca6416";
+   label = "exp4";
+};
+
+_1 {
+   compatible = "ti,tca6416";
+   label = "exp4";
+};
+
+_3 {
+   compatible = "ti,tca6416";
+   label = "exp2";
+};
+
+_i2c1 {
+   u-boot,dm-spl;
+};
+
+_pmic {
+   u-boot,dm-spl;
+};
+
+_reg_usdhc2_vmmc {
+   u-boot,dm-spl;
+};
+
+_uart2 {
+   u-boot,dm-spl;
+};
+
+_usdhc2_gpio {
+   u-boot,dm-spl;
+};
+
+_usdhc2 {
+   u-boot,dm-spl;
+};
+
+_usdhc3 {
+   u-boot,dm-spl;
+};
+
+_wdog {
+   u-boot,dm-spl;
+};
+
+_usdhc2_vmmc {
+   u-boot,dm-spl;
+   u-boot,off-on-delay-us = <2>;
+};
+
+_jr0 {
+   u-boot,dm-spl;
+};
+
+_jr1 {
+   u-boot,dm-spl;
+};
+
+_jr2 {
+   u-boot,dm-spl;
+};
+
+ {
+   compatible = "tcg,tpm_tis-spi";
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+   assigned-clocks = < IMX8MP_CLK_USDHC1>;
+   assigned-clock-rates = <4>;
+   assigned-clock-parents = < IMX8MP_SYS_PLL1_400M>;
+};
+
+ {
+   u-boot,dm-spl;
+   sd-uhs-sdr104;
+   sd-uhs-ddr50;
+   assigned-clocks = < IMX8MP_CLK_USDHC2>;
+   assigned-clock-rates = <4>;
+   assigned-clock-parents = < IMX8MP_SYS_PLL1_400M>;
+};
+
+ {
+   u-boot,dm-spl;
+   mmc-hs400-1_8v;
+   mmc-hs400-enhanced-strobe;
+   assigned-clocks = < IMX8MP_CLK_USDHC3>;
+   assigned-clock-rates = <4>;
+   assigned-clock-parents = < IMX8MP_SYS_PLL1_400M>;
+};
+
+_0 {
+   dma-ranges = <0x4000 0x4000 0xc000>;
+   /delete-property/ power-domains;
+};
+
+_1 {
+   dma-ranges = <0x4000 0x4000 0xc000>;
+   /delete-property/ power-domains;
+};
+
+_dwc3_0 {
+   compatible = "fsl,imx8mq-dwc3", "snps,dwc3";
+   assigned-clocks = < IMX8MP_CLK_HSIO_AXI>;
+   assigned-clock-parents = < IMX8MP_SYS_PLL1_800M>;
+   assigned-clock-rates = <4>;
+};
+
+_dwc3_1 {
+   compatible = "fsl,imx8mq-dwc3", "snps,dwc3";
+   assigned-clocks = < IMX8MP_CLK_HSIO_AXI>;
+   assigned-clock-parents = < IMX8MP_SYS_PLL1_800M>;
+   assigned-clock-rates = <4>;
+};
+
+ {
+   status = "disabled";
+};
+
+ {
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/dts/imx8mp-beacon-kit.dts 
b/arch/arm/dts/imx8mp-beacon-kit.dts
new file mode 100644
index 00..cdae45a48c
--- /dev/null
+++ b/arch/arm/dts/imx8mp-beacon-kit.dts
@@ -0,0 +1,550 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR 

Re: [PATCH v3 79/95] power: wanderboard: Correct conditions for split config

2023-02-12 Thread Fabio Estevam
On Sun, Feb 12, 2023 at 8:47 PM Simon Glass  wrote:
>
> This currently causes a build error with wanderboard. Fix it by adding a

A typo here and in the Subject, it is "wandboard".


[PATCH v3 74/95] serial: Support ns16550 driver in TPL

2023-02-12 Thread Simon Glass
Add options for this since they are needed by P1020RDB-PC_NAND.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/serial/Kconfig | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index bb5083201b3..6f40c051604 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -731,6 +731,12 @@ config SPL_SYS_NS16550_SERIAL
default y if SYS_NS16550_SERIAL || ARCH_SUNXI || ARCH_OMAP2PLUS
select SYS_NS16550
 
+config TPL_SYS_NS16550_SERIAL
+   bool "NS16550 UART or compatible legacy driver in TPL"
+   depends on TPL && !TPL_DM_SERIAL
+   default y if SYS_NS16550_SERIAL || ARCH_SUNXI || ARCH_OMAP2PLUS
+   select SYS_NS16550
+
 config SYS_NS16550
bool "NS16550 UART or compatible"
help
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 83/95] Makefile: Include the config for the phase being built

2023-02-12 Thread Simon Glass
At present there is only a single auto.conf file used within the
makefiles. Update them to use the correct one for each phase.

Also update kconfig.h to include the correct autoconf.h or autoconf_spl.h
file for each phase. This allows the macros to be simplified.

With this, CONFIG_IS_ENABLED() is the same as IS_ENABLED() apart from a
migration detail.

Both changes are made in the same patch to avoid build errors.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Include code from 'Update CONFIG_IS_ENABLED() for split files' too

 Makefile   | 11 +++-
 include/linux/kconfig.h| 74 +-
 scripts/Makefile.build | 12 -
 scripts/Makefile.spl   | 10 +++-
 tools/binman/test/generated/autoconf.h |  4 +-
 5 files changed, 58 insertions(+), 53 deletions(-)

diff --git a/Makefile b/Makefile
index 28bec3fa415..3dc99041391 100644
--- a/Makefile
+++ b/Makefile
@@ -587,8 +587,17 @@ scripts: scripts_basic scripts_dtc include/config/auto.conf
$(Q)$(MAKE) $(build)=$(@)
 
 ifeq ($(dot-config),1)
-# Read in config
+
+# Read in the config for this phase
+ifdef CONFIG_TPL_BUILD
+-include include/config/auto_tpl.conf
+else ifdef CONFIG_VPL_BUILD
+-include include/config/auto_vpl.conf
+else ifdef CONFIG_SPL_BUILD
+-include include/config/auto_spl.conf
+else
 -include include/config/auto.conf
+endif
 
 # Read in dependencies to all Kconfig* files, make sure to run
 # oldconfig if changes are detected.
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 2bc704e1104..f00686eb3e1 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -1,7 +1,17 @@
 #ifndef __LINUX_KCONFIG_H
 #define __LINUX_KCONFIG_H
 
+#ifdef USE_HOSTCC
+#include 
+#elif defined(CONFIG_TPL_BUILD)
+#include 
+#elif defined(CONFIG_VPL_BUILD)
+#include 
+#elif defined(CONFIG_SPL_BUILD)
+#include 
+#else
 #include 
+#endif
 
 /*
  * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
@@ -28,37 +38,9 @@
  */
 #define IS_ENABLED(option) config_enabled(option, 0)
 
-/*
- * U-Boot add-on: Helper macros to reference to different macros (prefixed by
- * CONFIG_, CONFIG_SPL_, CONFIG_TPL_ or CONFIG_TOOLS_), depending on the build
- * context.
- */
+#define __config_val(cfg) CONFIG_ ## cfg
 
-#ifdef USE_HOSTCC
-#define _CONFIG_PREFIX TOOLS_
-#elif defined(CONFIG_TPL_BUILD)
-#define _CONFIG_PREFIX TPL_
-#elif defined(CONFIG_VPL_BUILD)
-#define _CONFIG_PREFIX VPL_
-#elif defined(CONFIG_SPL_BUILD)
-#define _CONFIG_PREFIX SPL_
-#else
-#define _CONFIG_PREFIX
-#endif
-
-#define   config_val(cfg)   _config_val(_CONFIG_PREFIX, cfg)
-#define  _config_val(pfx, cfg) __config_val(pfx, cfg)
-#define __config_val(pfx, cfg) CONFIG_ ## pfx ## cfg
-
-/*
- * CONFIG_VAL(FOO) evaluates to the value of
- *  CONFIG_TOOLS_FOO if USE_HOSTCC is defined,
- *  CONFIG_FOO if CONFIG_SPL_BUILD is undefined,
- *  CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined.
- *  CONFIG_TPL_FOO if CONFIG_TPL_BUILD is defined.
- *  CONFIG_VPL_FOO if CONFIG_VPL_BUILD is defined.
- */
-#define CONFIG_VAL(option)  config_val(option)
+#define CONFIG_VAL(option)  __config_val(option)
 
 /*
  * This uses a similar mechanism to config_enabled() above. If cfg is enabled,
@@ -104,26 +86,17 @@ long invalid_use_of_IF_ENABLED_INT(void);
__concat(__unwrap, config_enabled(CONFIG_VAL(option), 0)) (case1, case0)
 
 /*
- * CONFIG_IS_ENABLED(FOO) expands to
- *  1 if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
- *  1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
- *  1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
- *  0 otherwise.
+ * CONFIG_IS_ENABLED(FOO) returns 1 if CONFIG_FOO is enabled for the phase 
being
+ * built, else 0. Note that CONFIG_FOO corresponds to CONFIG_SPL_FOO (in
+ * Kconfig) for the SPL phase, CONFIG_TPL_FOO for the TPL phase, etc.
  *
- * CONFIG_IS_ENABLED(FOO, (abc)) expands to
- *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
- *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
- *  nothing otherwise.
+ * The _nospl version of a CONFIG is emitted by kconfig when an option has no
+ * SPL equivalent. So in that case there is a CONFIG_xxx for example, but not a
+ * CONFIG_SPL_xxx
  *
- * CONFIG_IS_ENABLED(FOO, (abc), (def)) expands to
- *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
- *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
- *  def otherwise.
+ * This is needed as a transition measure while CONFIG_IS_ENABLED() is used on
+ 

[PATCH v3 79/95] power: wanderboard: Correct conditions for split config

2023-02-12 Thread Simon Glass
This currently causes a build error with wanderboard. Fix it by adding a
missing CONFIG and correcting the build condition so that it does not
change when building SPL.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 configs/wandboard_defconfig | 1 +
 include/power/pmic.h| 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configs/wandboard_defconfig b/configs/wandboard_defconfig
index a6baff1e24c..05383f6e47b 100644
--- a/configs/wandboard_defconfig
+++ b/configs/wandboard_defconfig
@@ -71,6 +71,7 @@ CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_PMIC=y
+CONFIG_SPL_DM_PMIC=y
 CONFIG_DM_PMIC_PFUZE100=y
 CONFIG_DM_SCSI=y
 CONFIG_DM_SERIAL=y
diff --git a/include/power/pmic.h b/include/power/pmic.h
index 70f2709bd0b..f3045f82ad7 100644
--- a/include/power/pmic.h
+++ b/include/power/pmic.h
@@ -85,8 +85,7 @@ struct pmic {
 };
 #endif /* CONFIG_IS_ENABLED(POWER_LEGACY) */
 
-/* TODO: Change to CONFIG_IS_ENABLED(DM_PMIC) when SPL_DM_PMIC exists */
-#ifdef CONFIG_DM_PMIC
+#ifdef CONFIG_PPL_DM_PMIC
 /**
  * U-Boot PMIC Framework
  * =
-- 
2.39.1.581.gbfd45094c4-goog



Re: [GIT PULL] Clock changes for 2023.04-rc1

2023-02-12 Thread Tom Rini
On Sun, Feb 12, 2023 at 02:59:33PM -0500, Sean Anderson wrote:

> The following changes since commit 78d1c3949a6f85f64b31ee8ab8240392a67ca30e:
> 
>   Merge branch '2023-02-10-update-trace-feature-to-work-with-trace-cmd' 
> (2023-02-12 10:56:54 -0500)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-clk.git tags/clk-2023.04-rc1
> 
> for you to fetch changes up to 5a675abfe7c3f12b475cc0a6c9074a9fbe0b6bb6:
> 
>   reset: Allow reset_get_by_name() with NULL name (2023-02-12 13:44:20 -0500)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [GIT PULL] Please pull u-boot-mpc8xx

2023-02-12 Thread Tom Rini
On Sun, Feb 12, 2023 at 06:42:55PM +, Christophe Leroy wrote:

> Hi Tom,
> 
> This pull requests brings:
> - A fix for a long standing bug that has been exposed by commit 
> 50128aeb0f8 ("cyclic: get rid of cyclic_init()") preventing 8xx boards 
> from booting since u-boot 2023.01
> - A GPIO driver for powerpc 8xx chip
> - Fixup for powerpc 8xx SPI driver
> - A new powerpc 8xx board
> - The two devices having that board.
> 
> This is my first pull request let me know if anything.
> 
> CI: https://source.denx.de/u-boot/custodians/u-boot-mpc8xx/-/pipelines/15137
> 
> Thanks
> Christophe
> 
> 
> The following changes since commit 30db474704405be823259851cbb76fa05366c8af:
> 
>Prepare v2023.04-rc1 (2023-01-30 15:36:45 -0500)
> 
> are available in the Git repository at:
> 
>g...@source.denx.de:u-boot/custodians/u-boot-mpc8xx.git for-2023.04
> 
> for you to fetch changes up to 6a8c36b936ab69a7521ec1ecfd20f7b85f7f59c5:
> 
>board: cssi: Add MIAE & VGoIP devices (2023-02-11 08:47:58 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] lmb: Bump CONFIG_LMB_MAX_REGIONS

2023-02-12 Thread Tom Rini
On Wed, Feb 08, 2023 at 02:50:16PM -0500, Tom Rini wrote:
> On Wed, Feb 08, 2023 at 08:11:34PM +0100, Michal Suchánek wrote:
> > Hello,
> > 
> > On Wed, Feb 08, 2023 at 01:25:50PM -0500, Tom Rini wrote:
> > > On Wed, Feb 08, 2023 at 07:24:25PM +0100, Francesco Dolcini wrote:
> > > > Hello,
> > > > 
> > > > On Fri, Jan 27, 2023 at 08:54:55AM -0500, Tom Rini wrote:
> > > > > On Fri, Jan 27, 2023 at 02:00:12PM +0100, Michal Suchanek wrote:
> > > > > > It is reported that in some configurations it is not possible to 
> > > > > > boot
> > > > > > because u-boot runs out of lmbs.
> > > > > > 
> > > > > > commit 06d514d77c ("lmb: consider EFI memory map") increases lmb 
> > > > > > usage,
> > > > > > hence is likely the cause of the lmb overflow.
> > > > > > 
> > > > > > Fixes: 06d514d77c ("lmb: consider EFI memory map")
> > > > > > Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1207562
> > > > > > Signed-off-by: Michal Suchanek 
> > > > 
> > > > Reviewed-by: Francesco Dolcini 
> > > > 
> > > > > I plan to pick up
> > > > > https://patchwork.ozlabs.org/project/uboot/patch/20230125230823.1567778-1-tr...@konsulko.com/
> > > > > as the alternative fix for this issue and would suggest that any 
> > > > > distro
> > > > > hitting the problem on v2023.01 apply the above instead of increasing
> > > > > the limit.
> > > > 
> > > > Tom, my understanding is that you plan to merge this or an equivalent
> > > > change, correct? Otherwise I would need to send some more patches to
> > > > update a few board defconfig that are affected by this specific issue.
> > > 
> > > Yes, I was hoping to push the equivalent of this patch a few hours ago,
> > > along with the revert. Then I noticed the test in test/lib/lmb.c doesn't
> > > scale past 8, and I just now figured out what that should look like
> > > instead, I believe.
> > 
> > reportedly neither fixes the problem in all cases, and raising
> > CONFIG_LMB_RESERVED_REGIONS is required.
> > 
> > Looks like the mechanism to add regions above the default number does
> > not work as intended.
> > 
> > The test is to boot rPi 4 from USB directly with recent firmware.
> 
> Well, given 0089affee275 ("configs: stm32mp15: increase the number of
> reserved memory region in lmb") I guess this has been run in to before,
> but not resolved more generically.

I wonder if
https://patchwork.ozlabs.org/project/uboot/patch/20230212150706.2967007-2-sjo...@collabora.com/
is what will finish dealing with these issues, even the ones that had
perhaps shown up before and been addressed in the commit I mentioned
above?

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] socfpga: fix the serial console on DE1-SoC

2023-02-12 Thread Tom Rini
On Fri, 10 Feb 2023 17:15:26 -0800, Jade Lovelace wrote:

> Previously, the TX LED would flash but nothing would appear on the
> serial port, and the board would appear dead with a build of the
> socfpga_cyclone5_defconfig. I have verified that adding the frequency to
> the uart will fix the serial console on my board.
> 
> Thanks to @ehoffman on the Rocketboards forum:
> https://forum.rocketboards.org/t/cyclonev-programming-fpga-from-u-boot/2230/30
> 
> [...]

Applied to u-boot/master, thanks!

-- 
Tom



Re: [PATCH v2 1/1] lmb: Treat a region which is a subset as equal

2023-02-12 Thread Tom Rini
On Sun, Feb 12, 2023 at 04:07:05PM +0100, Sjoerd Simons wrote:

> In various cases logical memory blocks are coalesced; As a result doing
> a strict check whether memory blocks are the same doesn't necessarily
> work as a previous addition of a given block might have been merged into
> a bigger block.
> 
> Fix this by considering a block is already registered if it's a pure
> subset of one of the existing blocks.
> 
> Signed-off-by: Sjoerd Simons 
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v3 44/95] env: Avoid checking ENV_IS_IN when env disabled

2023-02-12 Thread Simon Glass
This check is not needed when the environment is not enabled, e.g. in
SPL. Add a condition to handle this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/nvedit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 7cbc3fd573a..277293679df 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -59,11 +59,13 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #endif
 
+#if CONFIG_IS_ENABLED(ENV_SUPPORT)
 #if!defined(ENV_IS_IN_DEVICE)  && \
!defined(CONFIG_ENV_IS_NOWHERE)
 # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\
 NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
 #endif
+#endif /* ENV_SUPPORT */
 
 /*
  * Maximum expected input data size for import command
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 20/95] dm: Add a Kconfig for SPL_DM_HWSPINLOCK

2023-02-12 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/hwspinlock/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/hwspinlock/Kconfig b/drivers/hwspinlock/Kconfig
index 96d4f5d6ca3..56406da3d87 100644
--- a/drivers/hwspinlock/Kconfig
+++ b/drivers/hwspinlock/Kconfig
@@ -5,6 +5,10 @@ config DM_HWSPINLOCK
help
  This option enables U-Boot hardware spinlock support
 
+config SPL_DM_HWSPINLOCK
+   def_bool n  # Enable U-Boot hardware spinlock support (SPL)
+   depends on SPL
+
 config HWSPINLOCK_SANDBOX
bool "Enable Hardware Spinlock support for Sandbox"
depends on SANDBOX && DM_HWSPINLOCK
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 31/95] acpi: Add a Kconfig for SPL_ACPIGEN

2023-02-12 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/core/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index 22381500afe..f1ef5cd35f3 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -453,6 +453,9 @@ config ACPIGEN
  things like generating device-specific tables and returning the ACPI
  name of a device.
 
+config SPL_ACPIGEN
+   def_bool n
+
 config BOUNCE_BUFFER
bool "Include bounce buffer API"
help
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 52/95] sandbox: Tidy up I2C options

2023-02-12 Thread Simon Glass
At present we enable the sandbox I2C driver for all builds. Add a separate
Kconfig option to control this, so that it can be disabled in TPL, where
it is not needed.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/i2c/Kconfig | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index ec533f31b1a..b1b846da05f 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -47,6 +47,16 @@ config SPL_DM_I2C
  device (bus child) info is kept as parent platdata. The interface
  is defined in include/i2c.h.
 
+config TPL_DM_I2C
+   bool "Enable Driver Model for I2C drivers in TPL"
+   depends on TPL_DM && DM_I2C
+   help
+ Enable driver model for I2C. The I2C uclass interface: probe, read,
+ write and speed, is implemented with the bus drivers operations,
+ which provide methods for bus setting and data transfer. Each chip
+ device (bus child) info is kept as parent platdata. The interface
+ is defined in include/i2c.h.
+
 config VPL_DM_I2C
bool "Enable Driver Model for I2C drivers in VPL"
depends on VPL_DM && DM_I2C
@@ -504,6 +514,16 @@ config SYS_I2C_ROCKCHIP
 config SYS_I2C_SANDBOX
bool "Sandbox I2C driver"
depends on SANDBOX && DM_I2C
+   default y
+   help
+ Enable I2C support for sandbox. This is an emulation of a real I2C
+ bus. Devices can be attached to the bus using the device tree
+ which specifies the driver to use.  See sandbox.dts as an example.
+
+config SPL_SYS_I2C_SANDBOX
+   bool "Sandbox I2C driver (SPL)"
+   depends on SPL && SANDBOX && DM_I2C
+   default y
help
  Enable I2C support for sandbox. This is an emulation of a real I2C
  bus. Devices can be attached to the bus using the device tree
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 47/95] lib: Add VPL options for SHA1 and SHA256

2023-02-12 Thread Simon Glass
Add these options so these algorithms can be used in VPL.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 lib/Kconfig | 20 
 1 file changed, 20 insertions(+)

diff --git a/lib/Kconfig b/lib/Kconfig
index 0a02f3e89ae..21a43effe49 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -583,6 +583,26 @@ config SPL_SHA_PROG_HW_ACCEL
 
 endif
 
+config VPL_SHA1
+   bool "Enable SHA1 support in VPL"
+   depends on VPL
+   default y if SHA1
+   help
+ This option enables support of hashing using SHA1 algorithm.
+ The hash is calculated in software.
+ The SHA1 algorithm produces a 160-bit (20-byte) hash value
+ (digest).
+
+config VPL_SHA256
+   bool "Enable SHA256 support in VPL"
+   depends on VPL
+   default y if SHA256
+   help
+ This option enables support of hashing using SHA256 algorithm.
+ The hash is calculated in software.
+ The SHA256 algorithm produces a 256-bit (32-byte) hash value
+ (digest).
+
 if SHA_HW_ACCEL
 
 config SHA512_HW_ACCEL
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 40/95] cmd: Add SPL Kconfigs for CMDLINE and HUSH

2023-02-12 Thread Simon Glass
At present we rely on this not existing to avoid building various
command-line features.

But with the new split configs this does not work. Add separates Kconfigs
instead.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Rework commit submit
- Use a consistent format for the comment

 cmd/Kconfig | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index c8792af883e..12b4dc7946f 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -23,6 +23,12 @@ config HUSH_PARSER
  If disabled, you get the old, much simpler behaviour with a somewhat
  smaller memory footprint.
 
+config SPL_CMDLINE
+   def_bool n  # Ensure that the command line is not enabled (SPL)
+
+config SPL_HUSH_PARSER
+   def_bool n  # Eensure that the hush parser is not enabled (SPL)
+
 config CMDLINE_EDITING
bool "Enable command line editing"
depends on CMDLINE
-- 
2.39.1.581.gbfd45094c4-goog



Re: imx8mp spi fail

2023-02-12 Thread Fabio Estevam
Hi Elmar,

On Sun, Feb 12, 2023 at 3:04 PM Elmar Psilog  wrote:
>
> Hello, kindly ask for help about SPI at an IMX8MP. I tried latest
> 2023.01. If you can please have a look and check it works on your side?
>
> sspi command returns: Invalid bus 0

Could you try passing an aliases entry in your dts like this?

aliases {
spi0 = 
};

Does this help?

> What am I doing wrong or is this a bug? Thanks ahead for any hint.

> dt: (tested with both types of cs-gpios)
>  {
>  pinctrl-names = "default";
>  pinctrl-0 = <_ecspi1>;
>  cs-gpios = <0>, < 9 GPIO_ACTIVE_LOW>;
> //  cs-gpios = < 9 GPIO_ACTIVE_LOW>;

This last format is the correct one.


Re: [PATCH] arm64: a37xx: pinctrl: probe after binding

2023-02-12 Thread Simon Glass
Hi,

On Thu, 19 Jan 2023 at 00:00, Stefan Roese  wrote:
>
> On 1/17/23 15:08, Robert Marko wrote:
> > Currently, pinctrl drivers are getting probed during post-bind, however
> > that is being reverted, and on A37XX pinctrl driver is the one that
> > registers the GPIO driver during the probe.
> >
> > So, if the pinctrl driver doesn't get probed GPIO-s won't get registered
> > and thus they cannot be used.
> >
> > This is a problem on the Methode eDPU as it just uses SB pins as GPIO-s
> > and without them being registered networking won't work as it only has
> > one SFP slot and the TX disable GPIO is on the SB controller.
> >
> > So, lets just add a flag only to A37XX driver to probe after binding
> > in order for the GPIO driver to always get registered.
> >
> > Signed-off-by: Robert Marko 
>
> Reviewed--by: Stefan Roese 
>
> Thanks,
> Stefan
>
> > ---
> >   drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 14 ++
> >   1 file changed, 14 insertions(+)
> >
> > diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c 
> > b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> > index 25fbe39abd1..1be6252227d 100644
> > --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> > +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> > @@ -745,6 +745,19 @@ static int armada_37xx_pinctrl_probe(struct udevice 
> > *dev)
> >   return 0;
> >   }
> >
> > +static int armada_37xx_pinctrl_bind(struct udevice *dev)
> > +{
> > + /*
> > +  * Make sure that the pinctrl driver gets probed after binding
> > +  * as on A37XX the pinctrl driver is the one that is also
> > +  * registering the GPIO one during probe, so if its not probed
> > +  * GPIO-s are not registered as well.
> > +  */
> > + dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
> > +
> > + return 0;
> > +}
> > +
> >   static const struct udevice_id armada_37xx_pinctrl_of_match[] = {
> >   {
> >   .compatible = "marvell,armada3710-sb-pinctrl",
> > @@ -762,6 +775,7 @@ U_BOOT_DRIVER(armada_37xx_pinctrl) = {
> >   .id = UCLASS_PINCTRL,
> >   .of_match = of_match_ptr(armada_37xx_pinctrl_of_match),
> >   .probe = armada_37xx_pinctrl_probe,
> > + .bind = armada_37xx_pinctrl_bind,
> >   .priv_auto  = sizeof(struct armada_37xx_pinctrl),
> >   .ops = _37xx_pinctrl_ops,
> >   };
>

This is OK if you really want to do this. Is it not possible to do the
bind of the GPIO devices in the pinctrl bind() handler, as is done by
other SoCs? Why do we need to probe the pinctrl driver first?

Reviewed-by: Simon Glass 


[PATCH v3 68/95] socfpga: Use the correct condition for SYS_L2_PL310

2023-02-12 Thread Simon Glass
Update this to use the PPL condition instead, so that nothing changes when
building for SPL with split config.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/arm/mach-socfpga/misc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-socfpga/misc.c b/arch/arm/mach-socfpga/misc.c
index 5b5a81a255d..b09b898051b 100644
--- a/arch/arm/mach-socfpga/misc.c
+++ b/arch/arm/mach-socfpga/misc.c
@@ -32,7 +32,7 @@ phys_addr_t socfpga_clkmgr_base __section(".data");
 phys_addr_t socfpga_rstmgr_base __section(".data");
 phys_addr_t socfpga_sysmgr_base __section(".data");
 
-#ifdef CONFIG_SYS_L2_PL310
+#ifdef CONFIG_PPL_SYS_L2_PL310
 static const struct pl310_regs *const pl310 =
(struct pl310_regs *)CFG_SYS_PL310_BASE;
 #endif
@@ -66,7 +66,7 @@ void enable_caches(void)
 #endif
 }
 
-#ifdef CONFIG_SYS_L2_PL310
+#ifdef CONFIG_PPL_SYS_L2_PL310
 void v7_outer_cache_enable(void)
 {
struct udevice *dev;
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 88/95] kconfig: Drop CONFIG_IS_ENABLED()

2023-02-12 Thread Simon Glass
We can use IS_ENABLED() now, so drop the CONFIG_IS_ENABLED() macro.
Also drop a comment that mentions it.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Drop a comment which mentions CONFIG_IS_ENABLED()

 drivers/serial/ns16550.c |  1 -
 include/linux/kconfig.h  | 23 ---
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index ab96cebd4ea..1d384ddbe12 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -610,7 +610,6 @@ static const struct udevice_id ns16550_serial_ids[] = {
 
 #if IS_ENABLED(CONFIG_SERIAL_PRESENT)
 
-/* TODO(s...@chromium.org): Integrate this into a macro like CONFIG_IS_ENABLED 
*/
 #if !defined(CONFIG_TPL_BUILD) || defined(CONFIG_TPL_DM_SERIAL)
 U_BOOT_DRIVER(ns16550_serial) = {
.name   = "ns16550_serial",
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 77d8e6b6129..a2c8e58cb4d 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -61,32 +61,25 @@
 #define __unwrap1(case1, case0) __unwrap case1
 #define __unwrap0(case1, case0) __unwrap case0
 
-#define __CONFIG_IS_ENABLED_1(option)__CONFIG_IS_ENABLED_3(option, 
(1), (0))
-#define __CONFIG_IS_ENABLED_2(option, case1) __CONFIG_IS_ENABLED_3(option, 
case1, ())
-#define __CONFIG_IS_ENABLED_3(option, case1, case0) \
+#define __IS_ENABLED_1(option)__IS_ENABLED_3(option, (1), (0))
+#define __IS_ENABLED_2(option, case1) __IS_ENABLED_3(option, case1, ())
+#define __IS_ENABLED_3(option, case1, case0) \
__concat(__unwrap, config_enabled(option, 0)) (case1, case0)
 
 /*
- * CONFIG_IS_ENABLED(CONFIG_FOO) returns 1 if CONFIG_FOO is enabled for the
- * phase being built, else 0.
+ * IS_ENABLED(CONFIG_FOO) returns 1 if CONFIG_FOO is enabled for the phase 
being
+ * built, else 0.
  *
  * The optional second and third arguments must be parenthesized; that
  * allows one to include a trailing comma, e.g. for use in
  *
- * CONFIG_IS_ENABLED(CONFIG_ACME, ({.compatible = "acme,frobnozzle"},))
+ * IS_ENABLED(CONFIG_ACME, ({.compatible = "acme,frobnozzle"},))
  *
  * which adds an entry to the array being defined if CONFIG_ACME is
  * set, and nothing otherwise.
  */
-
-#define CONFIG_IS_ENABLED(option, ...) \
-   __concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) 
(option, ##__VA_ARGS__)
-
-/*
- * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y',
- * 0 otherwise.
- */
-#define IS_ENABLED(option, ...)  CONFIG_IS_ENABLED(option, ##__VA_ARGS__)
+#define IS_ENABLED(option, ...) \
+   __concat(__IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) (option, 
##__VA_ARGS__)
 
 #ifndef __ASSEMBLY__
 /*
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 49/95] lib: Fix build condition for tiny-printf

2023-02-12 Thread Simon Glass
This should be checking for any SPL build. Drop the use of SPL_TPL_ since
it is not necessary and will not work with split config.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 lib/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Makefile b/lib/Makefile
index a282e40258c..10aa7ac0298 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -127,7 +127,7 @@ obj-$(CONFIG_LIB_UUID) += uuid.o
 obj-$(CONFIG_LIB_RAND) += rand.o
 obj-y += panic.o
 
-ifeq ($(CONFIG_$(SPL_TPL_)BUILD),y)
+ifeq ($(CONFIG_SPL_BUILD),y)
 # SPL U-Boot may use full-printf, tiny-printf or none at all
 ifdef CONFIG_$(SPL_TPL_)USE_TINY_PRINTF
 obj-$(CONFIG_$(SPL_TPL_)SPRINTF) += tiny-printf.o
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 48/95] x86: Use string functions for all 32-bit builds

2023-02-12 Thread Simon Glass
At present these are not included in SPL. They do add to code size but
are a bit faster, so adjust the setting to add them.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/include/asm/string.h | 2 +-
 arch/x86/lib/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h
index c15b264a5c0..0254a022160 100644
--- a/arch/x86/include/asm/string.h
+++ b/arch/x86/include/asm/string.h
@@ -14,7 +14,7 @@ extern char *strrchr(const char *s, int c);
 #undef __HAVE_ARCH_STRCHR
 extern char *strchr(const char *s, int c);
 
-#ifdef CONFIG_X86_64
+#if CONFIG_IS_ENABLED(X86_64)
 
 #undef __HAVE_ARCH_MEMCPY
 extern void *memcpy(void *, const void *, __kernel_size_t);
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index a6f22441474..ea7ff2bcf38 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -4,7 +4,7 @@
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 
 obj-y  += bdinfo.o
-ifndef CONFIG_X86_64
+ifndef CONFIG_$(SPL_TPL_)X86_64
 ifndef CONFIG_TPL_BUILD
 obj-y += bios.o
 obj-y += bios_asm.o
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 22/95] cmd: Add a Kconfig for SPL_CRC32_VERIFY

2023-02-12 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 2caa4af71cb..c8792af883e 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -686,6 +686,10 @@ config CRC32_VERIFY
help
  Add -v option to verify data against a crc32 checksum.
 
+config SPL_CRC32_VERIFY
+   def_bool n  # crc32 -v (SPL)
+   depends on SPL
+
 config CMD_EEPROM
bool "eeprom - EEPROM subsystem"
help
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 24/95] button: Add a Kconfig for SPL_BUTTON

2023-02-12 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/button/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/button/Kconfig b/drivers/button/Kconfig
index 8ce2de37d62..60645a7745a 100644
--- a/drivers/button/Kconfig
+++ b/drivers/button/Kconfig
@@ -9,6 +9,10 @@ config BUTTON
  can provide access to board-specific buttons. Use of the device tree
  for configuration is encouraged.
 
+config SPL_BUTTON
+   def_bool n  # Enable button support (SPL)
+   depends on SPL
+
 config BUTTON_ADC
bool "Button adc"
depends on BUTTON
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 45/95] boot: Add a Kconfig for SPL_AVB_VERIFY

2023-02-12 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/common/Kconfig b/common/Kconfig
index 14a40d8b4ea..58008321d53 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -818,6 +818,10 @@ config AVB_VERIFY
* Helpers to access MMC, similar to drivers/fastboot/fb_mmc.c.
* Helpers to alloc/init/free avb ops.
 
+config SPL_AVB_VERIFY
+   def_bool n  # Build Android Verified Boot operations (SPL)
+   depends on SPL
+
 if AVB_VERIFY
 
 config AVB_BUF_ADDR
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 27/95] iommu: Add a Kconfig for SPL_IOMMU

2023-02-12 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/iommu/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index dabc1f900d5..bbacd14a56c 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -14,6 +14,10 @@ config IOMMU
  memory if the IOMMU has been programmed to allow access to
  that memory.
 
+config SPL_IOMMU
+   def_bool n  # Enable Driver Model for IOMMU drivers (SPL)
+   depends on SPL_DM
+
 config APPLE_DART
bool "Apple DART support"
depends on IOMMU && ARCH_APPLE
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 28/95] pinctrl: Add a Kconfig for SPL_PINCTRL_ARMADA_38X

2023-02-12 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Correct the tag

 drivers/pinctrl/mvebu/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/pinctrl/mvebu/Kconfig b/drivers/pinctrl/mvebu/Kconfig
index 7c51d138c8b..0b2be88e3a1 100644
--- a/drivers/pinctrl/mvebu/Kconfig
+++ b/drivers/pinctrl/mvebu/Kconfig
@@ -7,6 +7,10 @@ config PINCTRL_ARMADA_38X
   Support pin multiplexing and pin configuration control on
   Marvell's Armada-38x SoC.
 
+config SPL_PINCTRL_ARMADA_38X
+   def_bool n  # Armada 38x pin control driver (SPL)
+   depends on SPL && ARMADA_38X && SPL_PINCTRL_FULL
+
 config PINCTRL_ARMADA_37XX
depends on ARMADA_3700 && PINCTRL_FULL
bool "Armada 37xx pin control driver"
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 70/95] freescale: Drop old pre-DM_ETH code

2023-02-12 Thread Simon Glass
This is used by ls1021atwr_sdcard_ifc_SECURE_BOOT with split config, but
is not needed anymore, since Ethernet migration is complete. Drop it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/arm/cpu/armv7/ls102xa/fdt.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/fdt.c b/arch/arm/cpu/armv7/ls102xa/fdt.c
index 1871acdce44..7189c7d4423 100644
--- a/arch/arm/cpu/armv7/ls102xa/fdt.c
+++ b/arch/arm/cpu/armv7/ls102xa/fdt.c
@@ -25,11 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void ft_fixup_enet_phy_connect_type(void *fdt)
 {
-#ifdef CONFIG_DM_ETH
struct udevice *dev;
-#else
-   struct eth_device *dev;
-#endif
struct tsec_private *priv;
const char *enet_path, *phy_path;
char enet[16];
@@ -37,12 +33,8 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
int phy_node;
int i = 0;
uint32_t ph;
-#ifdef CONFIG_DM_ETH
char *name[3] = { "ethernet@2d1", "ethernet@2d5",
  "ethernet@2d9" };
-#else
-   char *name[3] = { "eTSEC1", "eTSEC2", "eTSEC3" };
-#endif
 
for (; i < ARRAY_SIZE(name); i++) {
dev = eth_get_dev_by_name(name[i]);
@@ -53,11 +45,7 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
continue;
}
 
-#ifdef CONFIG_DM_ETH
priv = dev_get_priv(dev);
-#else
-   priv = dev->priv;
-#endif
if (priv->flags & TSEC_SGMII)
continue;
 
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 82/95] command: Don't allow commands in SPL

2023-02-12 Thread Simon Glass
At present we compile commands into U-Boot SPL even though they cannot
be used. This wastes space. Adjust the condition to avoid this.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Add a new patch to disallow commands in SPL

 include/command.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/command.h b/include/command.h
index 0db48980624..1b018cb98e7 100644
--- a/include/command.h
+++ b/include/command.h
@@ -376,7 +376,7 @@ int cmd_source_script(ulong addr, const char *fit_uname, 
const char *confname);
U_BOOT_SUBCMDS_DO_CMD(_cmdname) \
U_BOOT_SUBCMDS_COMPLETE(_cmdname)
 
-#ifdef CONFIG_CMDLINE
+#if CONFIG_IS_ENABLED(CMDLINE)
 #define U_BOOT_CMDREP_MKENT_COMPLETE(_name, _maxargs, _cmd_rep,
\
 _usage, _help, _comp)  \
{ #_name, _maxargs, _cmd_rep, cmd_discard_repeatable,   \
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 95/95] Makefile: Drop SPL_ and SPL_TPL_ macros

2023-02-12 Thread Simon Glass
These are not needed anymore with split configs. Drop them.

This also drops an incorrect $(SPL_TPL) in arch/powerpc/lib/Makefile

Signed-off-by: Simon Glass 
---

Changes in v3:
- Move to conf_nospl: CMD_DHCP DFU_VIRT GENERATE_SMBIOS_TABLE
- Move to conf_nospl: GMAC_ROCKCHIP I8259_PIC IMX_RDC NXP_FSPI PCI_PNP
- Move to conf_nospl: PHY_CADENCE_TORRENT QFW_PIO SEC_FIRMWARE_ARMV8_PSCI
- Move to conf_nospl: SPI_FLASH_BAR SPI_FLASH_MACRONIX
- Move to conf_nospl: SCMD_BOOTEFI_BOOTMGR CMD_EFICONFIG CMD_PXE

Changes in v2:
- Reworked based on earlier patches
- Move patches from splb which add new Kconfig options

 Makefile   |  6 +-
 arch/arm/config.mk |  6 +-
 arch/arm/cpu/arm920t/Makefile  |  2 +-
 arch/arm/cpu/arm926ejs/Makefile|  2 +-
 arch/arm/cpu/armv7/Makefile|  2 +-
 arch/arm/cpu/armv8/Makefile|  6 +-
 arch/arm/cpu/armv8/fsl-layerscape/Makefile |  2 +-
 arch/arm/lib/Makefile  | 18 +++---
 arch/arm/mach-at91/arm926ejs/Makefile  |  4 +-
 arch/arm/mach-omap2/Makefile   |  2 +-
 arch/arm/mach-omap2/am33xx/Makefile|  2 +-
 arch/arm/mach-orion5x/Makefile |  4 +-
 arch/arm/mach-rockchip/Makefile|  2 +-
 arch/arm/mach-stm32mp/Makefile |  2 +-
 arch/arm/mach-zynqmp/Makefile  |  2 +-
 arch/powerpc/lib/Makefile  |  2 +-
 arch/riscv/lib/Makefile| 16 ++---
 arch/x86/Makefile  |  8 +--
 arch/x86/cpu/Makefile  | 20 +++
 arch/x86/cpu/broadwell/Makefile| 10 ++--
 arch/x86/cpu/intel_common/Makefile | 14 ++---
 arch/x86/cpu/ivybridge/Makefile|  6 +-
 arch/x86/cpu/qemu/Makefile |  2 +-
 arch/x86/lib/Makefile  | 10 ++--
 board/bosch/guardian/Makefile  |  2 +-
 board/compulab/common/Makefile |  2 +-
 board/freescale/common/Makefile|  4 +-
 board/tcl/sl50/Makefile|  2 +-
 board/ti/am335x/Makefile   |  2 +-
 board/ti/am43xx/Makefile   |  2 +-
 board/vscom/baltos/Makefile|  2 +-
 board/xilinx/zynqmp/Makefile   |  2 +-
 boot/Makefile  | 52 
 cmd/Makefile   |  2 +-
 common/Makefile| 26 
 common/init/Makefile   |  2 +-
 common/spl/Makefile| 48 +++
 disk/Makefile  | 18 +++---
 doc/develop/tests_writing.rst  |  6 +-
 drivers/Makefile   | 70 +++---
 drivers/ata/Makefile   |  2 +-
 drivers/block/Makefile |  6 +-
 drivers/bus/Makefile   |  2 +-
 drivers/cache/Makefile |  2 +-
 drivers/clk/Makefile   | 14 ++---
 drivers/clk/imx/Makefile   | 18 +++---
 drivers/clk/ti/Makefile|  4 +-
 drivers/core/Makefile  | 14 ++---
 drivers/ddr/altera/Makefile|  2 +-
 drivers/dfu/Makefile   | 16 ++---
 drivers/firmware/Makefile  |  2 +-
 drivers/gpio/Makefile  | 10 ++--
 drivers/i2c/Makefile   | 14 ++---
 drivers/input/Makefile |  6 +-
 drivers/led/Makefile   |  2 +-
 drivers/mailbox/Makefile   |  2 +-
 drivers/misc/Makefile  | 22 +++
 drivers/mmc/Makefile   | 10 ++--
 drivers/mtd/Makefile   |  4 +-
 drivers/mtd/nand/Makefile  |  2 +-
 drivers/mtd/nand/raw/Makefile  |  2 +-
 drivers/mtd/spi/Makefile   |  8 +--
 drivers/mux/Makefile   |  2 +-
 drivers/phy/Makefile   |  6 +-
 drivers/phy/ti/Makefile|  2 +-
 drivers/pinctrl/Makefile   |  6 +-
 drivers/power/Makefile |  8 +--
 drivers/power/acpi_pmc/Makefile|  2 +-
 drivers/power/domain/Makefile  |  2 +-
 drivers/power/pmic/Makefile| 30 +-
 drivers/power/regulator/Makefile   | 38 ++--
 drivers/ram/Makefile   |  2 +-
 drivers/remoteproc/Makefile|  2 +-
 drivers/rtc/Makefile   |  6 +-
 drivers/scsi/Makefile  |  2 +-
 drivers/serial/Makefile|  4 +-
 drivers/spi/Makefile   |  2 +-
 drivers/sysreset/Makefile  |  6 +-
 drivers/timer/Makefile |  6 +-
 drivers/tpm/Makefile   |  4 +-
 drivers/usb/cdns3/Makefile |  4 +-
 drivers/usb/common/Makefile|  2 

[PATCH v3 76/95] x86: Fix monitor base for split config

2023-02-12 Thread Simon Glass
This currently makes SPL refer to its own address. Use the PPL symbol to
avoid this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/cpu/intel_common/car2.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/cpu/intel_common/car2.S b/arch/x86/cpu/intel_common/car2.S
index f8cf78586d0..c4f64b17694 100644
--- a/arch/x86/cpu/intel_common/car2.S
+++ b/arch/x86/cpu/intel_common/car2.S
@@ -443,6 +443,6 @@ ucode_base: /* Declared in microcode.h */
 .globl ucode_size
 ucode_size:/* Declared in microcode.h */
.long   0   /* microcode size */
-   .long   CONFIG_SYS_MONITOR_BASE /* code region base */
-   .long   CONFIG_SYS_MONITOR_LEN  /* code region size */
+   .long   CONFIG_PPL_SYS_MONITOR_BASE /* code region base */
+   .long   CONFIG_PPL_SYS_MONITOR_LEN  /* code region size */
 #endif
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 42/95] cros_ec: Add SPL Kconfigs for cros_ec features

2023-02-12 Thread Simon Glass
At present we rely on this not existing to avoid building various
EC features.

But with the new split configs this does not work. Add separates Kconfigs
instead.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Use a consistent format for the comment

 drivers/i2c/Kconfig | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 427074bff83..ec533f31b1a 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -97,6 +97,9 @@ config I2C_CROS_EC_TUNNEL
  I2C or LPC). Some Chromebooks use this when the hardware design
  does not allow direct access to the main PMIC from the AP.
 
+config SPL_I2C_CROS_EC_TUNNEL
+   def_bool n  # Chrome OS EC tunnel I2C bus (SPL)
+
 config I2C_CROS_EC_LDO
bool "Provide access to LDOs on the Chrome OS EC"
depends on CROS_EC
@@ -111,6 +114,9 @@ config I2C_CROS_EC_LDO
avoid duplicating the logic in the TPS65090 regulator driver for
enabling/disabling an LDO.
 
+config SPL_I2C_CROS_EC_LDO
+   def_bool n  # Provide access to LDOs on the Chrome OS EC (SPL)
+
 config I2C_SET_DEFAULT_BUS_NUM
bool "Set default I2C bus number"
depends on DM_I2C
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 72/95] net: Add an SPL config for atheros

2023-02-12 Thread Simon Glass
Add a new SPL_PHY_ATHEROS to avoid a build error on am335x_evm with split
config.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/net/phy/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 5eaff053a09..6806e3c0903 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -106,6 +106,9 @@ config PHY_AQUANTIA_FW_NAME
 config PHY_ATHEROS
bool "Atheros Ethernet PHYs support"
 
+config SPL_PHY_ATHEROS
+   bool "Atheros Ethernet PHYs support (SPL)"
+
 config PHY_BROADCOM
bool "Broadcom Ethernet PHYs support"
 
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 67/95] imx: watchdog: Correct watchdog error condition

2023-02-12 Thread Simon Glass
This is intended to make sure that one of the conditions is met, but
causes a build error with imx6qdl_icore_mmc.

Fix it by using the PPL condition instead, so that nothing changes when
building for SPL with split config.

In fact we should drop the old watchdog code and just use the new
watchdog uclass.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/watchdog.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/watchdog.h b/include/watchdog.h
index ac5f11e376f..f000bdfae80 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -28,7 +28,7 @@ int init_func_watchdog_reset(void);
 #define INIT_FUNC_WATCHDOG_RESET
 #endif
 
-#if defined(CONFIG_HW_WATCHDOG) && defined(CONFIG_WATCHDOG)
+#if defined(CONFIG_HW_WATCHDOG) && defined(CONFIG_PPL_WATCHDOG)
 #  error "Configuration error: CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG can't be 
used together."
 #endif
 
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 77/95] dm: Add a TPL symbol for simple-bus

2023-02-12 Thread Simon Glass
This is used in some x86 code, so add a symbol for it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/core/Kconfig | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index f1ef5cd35f3..ae4f184b93f 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -305,6 +305,13 @@ config SPL_SIMPLE_BUS
  Supports the 'simple-bus' driver, which is used on some systems
  in SPL.
 
+config TPL_SIMPLE_BUS
+   bool "Support simple-bus driver in TPL"
+   depends on TPL_DM && TPL_OF_CONTROL
+   help
+ Supports the 'simple-bus' driver, which is used on some systems
+ in TPL.
+
 config SIMPLE_BUS_CORRECT_RANGE
bool "Decode the 'simple-bus'  by honoring the #address-cells 
and #size-cells"
depends on SIMPLE_BUS
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 71/95] imx: Use SATA instead of CMD_SATA

2023-02-12 Thread Simon Glass
This causes a build failure on mx6cuboxi with split config, since CMD_SATA
shows up as enabled in SPl (because there is no SPL_CMD_SATA).

The condition is wrong anyway, so change it to use SATA instead.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 board/solidrun/mx6cuboxi/mx6cuboxi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c 
b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 7c44379ec4a..cb14c2f30c9 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -275,7 +275,7 @@ int board_early_init_f(void)
 {
setup_iomux_uart();
 
-#ifdef CONFIG_CMD_SATA
+#ifdef CONFIG_SATA
setup_sata();
 #endif
setup_fec();
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 94/95] checkpatch: Remove unwanted CONFIG_IS_ENABLED rules

2023-02-12 Thread Simon Glass
These are not relevant anymore so drop them.

Signed-off-by: Simon Glass 
Suggested-by: Tom Rini 
---

(no changes since v1)

 scripts/checkpatch.pl   | 16 
 tools/patman/test_checkpatch.py |  6 --
 2 files changed, 22 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ccfcbb3e125..f6fdfcf58de 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2654,12 +2654,6 @@ sub u_boot_line {
 "Avoid setting skip_board_fixup env variable\n" . 
$herecurr);
}
 
-   # Do not use CONFIG_ prefix in CONFIG_IS_ENABLED() calls
-   if ($line =~ /^\+.*CONFIG_IS_ENABLED\(CONFIG_\w*\).*/) {
-   ERROR("CONFIG_IS_ENABLED_CONFIG",
- "CONFIG_IS_ENABLED() takes values without the CONFIG_ 
prefix\n" . $herecurr);
-   }
-
# Use _priv as a suffix for the device-private data struct
if ($line =~ /^\+\s*\.priv_auto\s*=\s*sizeof\(struct\((\w+)\).*/) {
my $struct_name = $1;
@@ -7197,16 +7191,6 @@ sub process {
 "IS_ENABLED($1) is normally used as 
IS_ENABLED(${CONFIG_}$1)\n" . $herecurr);
}
 
-# check for #if defined CONFIG_ || defined CONFIG__MODULE
-   if ($line =~ 
/^\+\s*#\s*if\s+defined(?:\s*\(?\s*|\s+)(${CONFIG_}[A-Z_]+)\s*\)?\s*\|\|\s*defined(?:\s*\(?\s*|\s+)\1_MODULE\s*\)?\s*$/)
 {
-   my $config = $1;
-   if (WARN("PREFER_IS_ENABLED",
-"Prefer IS_ENABLED() to ${CONFIG_} 
|| ${CONFIG_}_MODULE\n" . $herecurr) &&
-   $fix) {
-   $fixed[$fixlinenr] = "\+#if 
IS_ENABLED($config)";
-   }
-   }
-
 # check for /* fallthrough */ like comment, prefer fallthrough;
my @fallthroughs = (
'fallthrough',
diff --git a/tools/patman/test_checkpatch.py b/tools/patman/test_checkpatch.py
index 4c2ab6e590e..6eb73433a4f 100644
--- a/tools/patman/test_checkpatch.py
+++ b/tools/patman/test_checkpatch.py
@@ -405,12 +405,6 @@ index 000..2234c87
 pm.add_line('include/myfile.h', '#include ')
 self.check_single_message(pm, 'BARRED_INCLUDE_IN_HDR', 'error')
 
-def test_config_is_enabled_config(self):
-"""Test for accidental CONFIG_IS_ENABLED(CONFIG_*) calls"""
-pm = PatchMaker()
-pm.add_line('common/main.c', 'if (CONFIG_IS_ENABLED(CONFIG_CLK))')
-self.check_single_message(pm, 'CONFIG_IS_ENABLED_CONFIG', 'error')
-
 def check_struct(self, auto, suffix, warning):
 """Check one of the warnings for struct naming
 
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 92/95] fixdep: Drop support for CONFIG_IS_ENABLED and CONFIG_VAL

2023-02-12 Thread Simon Glass
Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/basic/fixdep.c | 19 ---
 1 file changed, 19 deletions(-)

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 1cb76dc8b19..08556ef663f 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -257,25 +257,6 @@ static const char *parse_config_line(const char *p, const 
char **endp)
r = q - 7;
else
r = q;
-   /*
-* U-Boot also handles
-*   CONFIG_IS_ENABLED(...)
-*   CONFIG_VAL(...)
-*/
-   if ((q - p == 10 && !memcmp(p, "IS_ENABLED(", 11)) ||
-   (q - p == 3 && !memcmp(p, "VAL(", 4))) {
-   p = q + 1;
-   q = p;
-   while (isalnum(*q) || *q == '_')
-   q++;
-   r = q;
-   if (r > p && tmp_buf[0]) {
-   memcpy(tmp_buf + 4, p, r - p);
-   r = tmp_buf + 4 + (r - p);
-   p = tmp_buf;
-   }
-   }
-   /* end U-Boot hack */
*endp = r;
 
if (r > p)
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 91/95] Makefile: Clean up an unnecessary Makefile piece

2023-02-12 Thread Simon Glass
Now that CONFIG_IS_ENABLED() is gone, we can drop this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/Makefile.autoconf | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index 0ade91642ae..74ce5542638 100644
--- a/scripts/Makefile.autoconf
+++ b/scripts/Makefile.autoconf
@@ -70,13 +70,7 @@ quiet_cmd_autoconf = GEN $@
 
 quiet_cmd_u_boot_cfg = CFG $@
   cmd_u_boot_cfg = \
-   $(CPP) $(c_flags) $2 -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > 
$@.tmp && { \
-   grep 'define CONFIG_' $@.tmp | \
-   sed '/define CONFIG_IS_ENABLED(/d;/define 
CONFIG_IF_ENABLED_INT(/d;/define CONFIG_VAL(/d;' > $@; \
-   rm $@.tmp;  \
-   } || {  \
-   rm $@.tmp; false;   \
-   }
+   $(CPP) $(c_flags) $2 -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@
 
 u-boot.cfg: include/config.h FORCE
$(call cmd,u_boot_cfg)
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 61/95] kconfig: Support writing separate SPL files

2023-02-12 Thread Simon Glass
At present kconfig writes out several files, including:

   auto.conf  - CONFIG settings used by make
   autoconf.h - header file used by C code

This works well but is a bit ugly in places, for example requiring the use
of a SPL_TPL_ macro in Makefiles to distinguish between options intended
for SPL and U-Boot proper.

Update the kconfig tool to also output separate files for each phase: e.g.
auto_spl.conf and autoconf_spl.h

These are similar to the existing files, but drop the SPL_ prefix so that
SPL_TPL_ is not needed. It also allows the CONFIG_IS_ENABLED() macro to be
simplified, in a later patch, eventually replacing it with IS_ENABLED().

When CONFIG_FOO is used within SPL, it means that FOO is enabled in that
SPL phase. For example if CONFIG_SPL_FOO is enabled in the Kconfig, that
means that CONFIG_FOO will be enabled in the SPL phase. So the SPL builds
can just use CONFIG_FOO to check it. There is no need to use
CONFIG_SPL_FOO or CONFIG_IS_ENABLED() anymore.

This of course means that if there is a need to access a PPL symbol from
an SPL build, there is no way to do it. To copy with that, we need a
CONFIG_PPL_FOO to be visibilty to all SPL builds.

So this change also adds new PPL_ output for U-Boot proper (Primary
Program Loader). So every CONFIG_FOO that is enabled in PPL also has a
CONFIG_PPL_FOO

This allows SPL to access the TEXT_BASE for U-Boot proper, for example, so
it knows where to load it. There are about 30 places where this is needed,
in addition to TEXT_BASE. The environment has the same problem, adding
another dozen or so caes in include/config_distro_bootcmd.h but it has
been decided to ignore that for now.

The feature is controlled by an environment variable, since it seems to be
bad form to add flags to the conf tool.

Rebuild the autoconf files if the split config is not present. This allows
building this commit as part of a chain, without generating build errors.

These changes may benefit from some reworking to send upstream, e.g. to
use a struct for the 'arg' parameter.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Make sure that the config is rebuilt with this change
- Move header-file changes into this patch

Changes in v2:
- Redo commit message
- Introduce CONFIG_PPL approach

 Makefile|   6 +
 scripts/kconfig/Makefile|   5 +-
 scripts/kconfig/conf.c  |   6 +-
 scripts/kconfig/confdata.c  | 348 +++-
 scripts/kconfig/expr.h  |  28 +++
 scripts/kconfig/lkc.h   |   9 +
 scripts/kconfig/lkc_proto.h |  18 +-
 7 files changed, 415 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 875cdda08f2..bc101e67588 100644
--- a/Makefile
+++ b/Makefile
@@ -597,6 +597,12 @@ ifeq ($(dot-config),1)
 # To avoid any implicit rule to kick in, define an empty command
 $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
 
+# Make sure this uses the split config
+has_split_config = $(shell grep CONFIG_PPL_LOCALVERSION 
include/config/auto.conf 2>/dev/null)
+ifeq ($(has_split_config),)
+include/config/auto.conf: FORCE
+endif
+
 # If .config is newer than include/config/auto.conf, someone tinkered
 # with it and forgot to run make oldconfig.
 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 12e525ee31f..b539054645f 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -25,6 +25,8 @@ endif
 # We need this, in case the user has it in its environment
 unexport CONFIG_
 
+$(obj)/conf: $(srctree)/scripts/conf_nospl
+
 xconfig: $(obj)/qconf
$< $(silent) $(Kconfig)
 
@@ -71,8 +73,9 @@ simple-targets := oldconfig allnoconfig allyesconfig 
allmodconfig \
alldefconfig randconfig listnewconfig olddefconfig syncconfig
 PHONY += $(simple-targets)
 
+# Pass --u-boot to get SPL behaviour
 $(simple-targets): $(obj)/conf
-   $< $(silent) --$@ $(Kconfig)
+   KCONFIG_SPL=1 $< $(silent) --$@ $(Kconfig)
 
 PHONY += savedefconfig defconfig
 
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 376f796f674..c4463d252c1 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -490,9 +490,13 @@ int main(int ac, char **av)
const char *name, *defconfig_file = NULL /* gcc uninit */;
struct stat tmpstat;
int no_conf_write = 0;
+   bool support_spl;
 
tty_stdio = isatty(0) && isatty(1);
 
+   /* Special handling of SPL phases for U-Boot */
+   support_spl = getenv("KCONFIG_SPL");
+
while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) {
if (opt == 's') {
conf_set_message_callback(NULL);
@@ -692,7 +696,7 @@ int main(int ac, char **av)
fprintf(stderr, "\n*** Error during writing of the 
configuration.\n\n");
exit(1);
}
-   if (conf_write_autoconf()) {
+   if (conf_write_autoconf(support_spl)) {
   

[PATCH v3 36/95] moveconfig: Various minor improvements

2023-02-12 Thread Simon Glass
It turns out that the conf_noproper file is not neeed, since if an option
does not appear in U-Boot proper we can just omit it from the autoconf for
that build. Drop it.

Also add more control over what is output from the tool.

Add this in here. It should be added to the previous series (splb).

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/moveconfig.py | 91 +
 1 file changed, 43 insertions(+), 48 deletions(-)

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index b3ac2672737..ec2afa92e46 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -1833,13 +1833,20 @@ def scan_src_files(fname_dict, all_uses, fname_uses):
 
 MODE_NORMAL, MODE_SPL, MODE_PROPER = range(3)
 
-def do_scan_source(path, do_update, show_conflicts, do_commit):
+def do_scan_source(path, do_update, do_update_source, show_conflicts,
+   do_commit):
 """Scan the source tree for Kconfig inconsistencies
 
 Args:
 path (str): Path to source tree
-do_update (bool): True to write to scripts/kconf_... files
-show_conflicts (bool): True to show conflicts
+do_update (bool): True to write to scripts/conf_nospl file
+do_update_source (bool): True to update source to remove invalid use of
+   CONFIG_IS_ENABLED()
+show_conflicts (bool): True to show conflicts between the source code
+   and the Kconfig (such as missing options, or options which imply an
+   SPL option that does not exist)
+do_commit (bool): Create commits to remove use of SPL_TPL_ and
+   CONFIG_IS_ENABLED macros when there is no SPL symbol.
 """
 def is_not_proper(name):
 for prefix in SPL_PREFIXES:
@@ -1977,9 +1984,7 @@ def do_scan_source(path, do_update, show_conflicts, 
do_commit):
 
 dirname, leaf = os.path.split(fname)
 root, ext = os.path.splitext(leaf)
-#if dirname != '' or root != 'Makefile':
-#continue
-if (dirname.startswith('test') or
+if (dirname.startswith('test/') or
 dirname.startswith('lib/efi_selftest')):
 # Ignore test code since it is mostly only for sandbox
 pass
@@ -2011,38 +2016,25 @@ def do_scan_source(path, do_update, show_conflicts, 
do_commit):
 finish_file(last_fname, rest_list)
 return mk_dict, src_dict
 
-def check_mk_missing(all_uses, spl_not_found, proper_not_found):
+def check_missing(all_uses, spl_not_found, proper_not_found,
+  show_conflicts):
 # Make sure we know about all the options in Makefiles
-print('\nCONFIG options present in Makefiles but not Kconfig:')
 not_found = check_not_found(all_uses, MODE_NORMAL)
-show_uses(not_found)
+if show_conflicts:
+print('\nCONFIG options present in source but not Kconfig:')
+show_uses(not_found)
 
-print('\nCONFIG options present in Makefiles but not Kconfig (SPL):')
 not_found = check_not_found(all_uses, MODE_SPL)
-show_uses(not_found)
 spl_not_found |= set(is_not_proper(key) or key for key in 
not_found.keys())
+if show_conflicts:
+print('\nCONFIG options present in source but not Kconfig (SPL):')
+show_uses(not_found)
 
-print('\nCONFIG options used as Proper in Makefiles but without a 
non-SPL_ variant:')
 not_found = check_not_found(all_uses, MODE_PROPER)
-show_uses(not_found)
-proper_not_found |= set(key for key in not_found.keys())
-
-def check_src_missing(all_uses, spl_not_found, proper_not_found):
-# Make sure we know about all the options in source files
-print('\nCONFIG options present in source but not Kconfig:')
-not_found = check_not_found(all_uses, MODE_NORMAL)
-show_uses(not_found)
-
-print('\nCONFIG options present in source but not Kconfig (SPL):')
-not_found = check_not_found(all_uses, MODE_SPL)
-show_uses(not_found)
-spl_not_found |= set(is_not_proper(key) or key
- for key in not_found.keys())
-
-print('\nCONFIG options used as Proper in source but without a 
non-SPL_ variant:')
-not_found = check_not_found(all_uses, MODE_PROPER)
-show_uses(not_found)
 proper_not_found |= set(key for key in not_found.keys())
+if show_conflicts:
+print('\nCONFIG options used as Proper in source but without a 
non-SPL_ variant:')
+show_uses(not_found)
 
 def show_summary(spl_not_found, proper_not_found):
 print('\nCONFIG options used as SPL but without an SPL_ variant:')
@@ -2053,19 +2045,24 @@ def do_scan_source(path, do_update, show_conflicts, 
do_commit):
 for item in sorted(proper_not_found):
 print(f'   {item}')
 
-def write_update(spl_not_found, proper_not_found):
-with 

[PATCH v3 66/95] freescale: pm9g45: Fix problems with ls1021aqds_nand et al

2023-02-12 Thread Simon Glass
These boards need to access the 'proper' symbol for NAND_BOOT, to avoid
build errors in SPL. Fix this up.

Also fix pm9g45 which has the same problem.

Drop the unnecessary condition in fdt_support.h to avoid needing to do
something clever there too.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 board/freescale/ls1021aqds/ls1021aqds.c | 2 +-
 include/configs/cgtqmx8.h   | 2 +-
 include/configs/imx8qm_rom7720.h| 2 +-
 include/configs/ls1021aqds.h| 2 +-
 include/configs/ls1043a_common.h| 2 +-
 include/configs/ls1043aqds.h| 4 ++--
 include/configs/ls1043ardb.h| 4 ++--
 include/configs/ls1046a_common.h| 2 +-
 include/configs/ls1046aqds.h| 4 ++--
 include/configs/ls2080a_common.h| 2 +-
 include/configs/ls2080aqds.h| 2 +-
 include/configs/pm9g45.h| 2 +-
 include/fdt_support.h   | 2 +-
 13 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/board/freescale/ls1021aqds/ls1021aqds.c 
b/board/freescale/ls1021aqds/ls1021aqds.c
index d5cb7312095..4336285e288 100644
--- a/board/freescale/ls1021aqds/ls1021aqds.c
+++ b/board/freescale/ls1021aqds/ls1021aqds.c
@@ -184,7 +184,7 @@ int board_early_init_f(void)
 #ifdef CONFIG_SPL_BUILD
 void board_init_f(ulong dummy)
 {
-#ifdef CONFIG_NAND_BOOT
+#ifdef CONFIG_PPL_NAND_BOOT
struct ccsr_gur __iomem *gur = (void *)CFG_SYS_FSL_GUTS_ADDR;
u32 porsr1, pinctl;
 
diff --git a/include/configs/cgtqmx8.h b/include/configs/cgtqmx8.h
index 98d4d8cf4bd..64bd5f6d3b6 100644
--- a/include/configs/cgtqmx8.h
+++ b/include/configs/cgtqmx8.h
@@ -33,7 +33,7 @@
"m4boot_0=run loadm4image_0; dcache flush; bootaux ${loadaddr} 0\0" \
"m4boot_1=run loadm4image_1; dcache flush; bootaux ${loadaddr} 1\0" \
 
-#ifdef CONFIG_NAND_BOOT
+#ifdef CONFIG_PPL_NAND_BOOT
 #define MFG_NAND_PARTITION 
"mtdparts=gpmi-nand:128m(boot),32m(kernel),16m(dtb),8m(misc),-(rootfs) "
 #else
 #define MFG_NAND_PARTITION ""
diff --git a/include/configs/imx8qm_rom7720.h b/include/configs/imx8qm_rom7720.h
index df2cb8d9ced..df77adf7739 100644
--- a/include/configs/imx8qm_rom7720.h
+++ b/include/configs/imx8qm_rom7720.h
@@ -27,7 +27,7 @@
"m4boot_0=run loadm4image_0; dcache flush; bootaux ${loadaddr} 0\0" \
"m4boot_1=run loadm4image_1; dcache flush; bootaux ${loadaddr} 1\0" \
 
-#ifdef CONFIG_NAND_BOOT
+#ifdef CONFIG_PPL_NAND_BOOT
 #define MFG_NAND_PARTITION 
"mtdparts=gpmi-nand:128m(boot),32m(kernel),16m(dtb),8m(misc),-(rootfs) "
 #else
 #define MFG_NAND_PARTITION ""
diff --git a/include/configs/ls1021aqds.h b/include/configs/ls1021aqds.h
index 451913e8fa6..58baa95d709 100644
--- a/include/configs/ls1021aqds.h
+++ b/include/configs/ls1021aqds.h
@@ -10,7 +10,7 @@
 #define CFG_SYS_INIT_RAM_ADDR  OCRAM_BASE_ADDR
 #define CFG_SYS_INIT_RAM_SIZE  OCRAM_SIZE
 
-#ifdef CONFIG_NAND_BOOT
+#ifdef CONFIG_PPL_NAND_BOOT
 #define CFG_SYS_NAND_U_BOOT_SIZE   (400 << 10)
 #define CFG_SYS_NAND_U_BOOT_DSTCONFIG_PPL_TEXT_BASE
 #define CFG_SYS_NAND_U_BOOT_START  CONFIG_PPL_TEXT_BASE
diff --git a/include/configs/ls1043a_common.h b/include/configs/ls1043a_common.h
index dcdd99cf714..40dbf477ecd 100644
--- a/include/configs/ls1043a_common.h
+++ b/include/configs/ls1043a_common.h
@@ -42,7 +42,7 @@
 #define CFG_SYS_NS16550_CLK  (get_serial_clock())
 
 /* NAND SPL */
-#ifdef CONFIG_NAND_BOOT
+#ifdef CONFIG_PPL_NAND_BOOT
 #define CFG_SYS_NAND_U_BOOT_DSTCONFIG_PPL_TEXT_BASE
 #define CFG_SYS_NAND_U_BOOT_START  CONFIG_PPL_TEXT_BASE
 #endif
diff --git a/include/configs/ls1043aqds.h b/include/configs/ls1043aqds.h
index 7ccbb20bf2e..0b95970bbb9 100644
--- a/include/configs/ls1043aqds.h
+++ b/include/configs/ls1043aqds.h
@@ -105,7 +105,7 @@
 #define CFG_SYS_NAND_BASE_LIST { CFG_SYS_NAND_BASE }
 #endif
 
-#ifdef CONFIG_NAND_BOOT
+#ifdef CONFIG_PPL_NAND_BOOT
 #define CFG_SYS_NAND_U_BOOT_SIZE   (640 << 10)
 #endif
 
@@ -196,7 +196,7 @@
 #define CFG_SYS_CS3_FTIM2  CFG_SYS_FPGA_FTIM2
 #define CFG_SYS_CS3_FTIM3  CFG_SYS_FPGA_FTIM3
 #else
-#ifdef CONFIG_NAND_BOOT
+#ifdef CONFIG_PPL_NAND_BOOT
 #define CFG_SYS_CSPR0_EXT  CFG_SYS_NAND_CSPR_EXT
 #define CFG_SYS_CSPR0  CFG_SYS_NAND_CSPR
 #define CFG_SYS_AMASK0 CFG_SYS_NAND_AMASK
diff --git a/include/configs/ls1043ardb.h b/include/configs/ls1043ardb.h
index 60362b6a4d0..611fa510c17 100644
--- a/include/configs/ls1043ardb.h
+++ b/include/configs/ls1043ardb.h
@@ -77,7 +77,7 @@
 
 #define CFG_SYS_NAND_BASE_LIST { CFG_SYS_NAND_BASE }
 
-#ifdef CONFIG_NAND_BOOT
+#ifdef CONFIG_PPL_NAND_BOOT
 #define CFG_SYS_NAND_U_BOOT_SIZE   (1024 << 10)
 #endif
 
@@ -128,7 +128,7 @@
 #define CFG_SYS_CS1_FTIM2  CFG_SYS_NAND_FTIM2
 #define CFG_SYS_CS1_FTIM3  CFG_SYS_NAND_FTIM3
 #else
-#ifdef CONFIG_NAND_BOOT
+#ifdef CONFIG_PPL_NAND_BOOT
 #define CFG_SYS_CSPR0_EXT  CFG_SYS_NAND_CSPR_EXT
 #define CFG_SYS_CSPR0  

[PATCH v3 89/95] kconfig: drop config_opt_enabled()

2023-02-12 Thread Simon Glass
This is include used in three places. It does not appear in Linux. Use
IS_ENABLED() instead since it provides a similar feature, albeit needing
brackets.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/fastboot/fb_command.c | 12 ++--
 drivers/fastboot/fb_common.c  |  4 ++--
 include/linux/kconfig.h   | 11 ---
 net/tftp.c|  3 ++-
 4 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 3a5e29861a2..23a18a26aa6 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -424,8 +424,8 @@ static void reboot_recovery(char *cmd_parameter, char 
*response)
 static void __maybe_unused oem_format(char *cmd_parameter, char *response)
 {
char cmdbuf[32];
-   const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
-  CONFIG_FASTBOOT_FLASH_MMC_DEV, 
-1);
+   const int mmc_dev = IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC,
+  (CONFIG_FASTBOOT_FLASH_MMC_DEV), (-1));
 
if (!env_get("partitions")) {
fastboot_fail("partitions not set", response);
@@ -447,8 +447,8 @@ static void __maybe_unused oem_format(char *cmd_parameter, 
char *response)
 static void __maybe_unused oem_partconf(char *cmd_parameter, char *response)
 {
char cmdbuf[32];
-   const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
-  CONFIG_FASTBOOT_FLASH_MMC_DEV, 
-1);
+   const int mmc_dev = IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC,
+  (CONFIG_FASTBOOT_FLASH_MMC_DEV), (-1));
 
if (!cmd_parameter) {
fastboot_fail("Expected command parameter", response);
@@ -473,8 +473,8 @@ static void __maybe_unused oem_partconf(char 
*cmd_parameter, char *response)
 static void __maybe_unused oem_bootbus(char *cmd_parameter, char *response)
 {
char cmdbuf[32];
-   const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
-  CONFIG_FASTBOOT_FLASH_MMC_DEV, 
-1);
+   const int mmc_dev = IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC,
+  (CONFIG_FASTBOOT_FLASH_MMC_DEV), (-1));
 
if (!cmd_parameter) {
fastboot_fail("Expected command parameter", response);
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 57b6182c46a..70fba02634f 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -96,8 +96,8 @@ int __weak fastboot_set_reboot_flag(enum 
fastboot_reboot_reason reason)
[FASTBOOT_REBOOT_REASON_FASTBOOTD] = "boot-fastboot",
[FASTBOOT_REBOOT_REASON_RECOVERY] = "boot-recovery"
};
-   const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
-  CONFIG_FASTBOOT_FLASH_MMC_DEV, 
-1);
+   const int mmc_dev = IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC,
+  (CONFIG_FASTBOOT_FLASH_MMC_DEV), (-1));
 
if (!IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC))
return -EINVAL;
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index a2c8e58cb4d..381f4eb5a1c 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -36,17 +36,6 @@
 
 #define CONFIG_VAL(option)  __config_val(option)
 
-/*
- * This uses a similar mechanism to config_enabled() above. If cfg is enabled,
- * it resolves to the value of opt_cfg, otherwise it resolves to def_val
- */
-#define config_opt_enabled(cfg, opt_cfg, def_val) _config_opt_enabled(cfg, 
opt_cfg, def_val)
-#define _config_opt_enabled(cfg_val, opt_value, def_val) \
-   __config_opt_enabled(__ARG_PLACEHOLDER_##cfg_val, opt_value, def_val)
-#define __config_opt_enabled(arg1_or_junk, arg2, def_val) \
-   ___config_opt_enabled(arg1_or_junk arg2, def_val)
-#define ___config_opt_enabled(__ignored, val, ...) val
-
 /*
  * Count number of arguments to a variadic macro. Currently only need
  * it for 1, 2 or 3 arguments.
diff --git a/net/tftp.c b/net/tftp.c
index 88e71e67de3..7c9aa6f5bd2 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -736,7 +736,8 @@ static void sanitize_tftp_block_size_option(enum proto_t 
protocol)
 
switch (protocol) {
case TFTPGET:
-   max_defrag = config_opt_enabled(CONFIG_IP_DEFRAG, 
CONFIG_NET_MAXDEFRAG, 0);
+   max_defrag = IS_ENABLED(CONFIG_IP_DEFRAG,
+   (CONFIG_NET_MAXDEFRAG), (0));
if (max_defrag) {
/* Account for IP, UDP and TFTP headers. */
cap = max_defrag - (20 + 8 + 4);
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 25/95] lib: Add a Kconfig for SPL_ERRNO_STR

2023-02-12 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/lib/Kconfig b/lib/Kconfig
index 83e5edd73b0..1da5593f0a9 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -782,6 +782,10 @@ config ERRNO_STR
  - if errno is null or positive number - a pointer to "Success" message
  - if errno is negative - a pointer to errno related message
 
+config SPL_ERRNO_STR
+   def_bool n  # Enable function for getting errno-related string message 
(SPL)
+   depends on SPL
+
 config HEXDUMP
bool "Enable hexdump"
help
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 86/95] kconfig: Adjust the meaning of CONFIG_IS_ENABLED()

2023-02-12 Thread Simon Glass
Adjust this to require the CONFIG option be provided, so that instead of:

   CONFIG_IS_ENABLED(FOO)

you must write:

   CONFIG_IS_ENABLED(CONFIG_FOO)

This is in preparation for dropping this and just using it is as the new
implementation of IS_ENABLED(). For now, update IS_ENABLED() to use
CONFIG_IS_ENABLED(), so we can rely on the three-argument version.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/lib/fsp/fsp_dram.c   |  4 ++--
 board/st/stm32mp1/stm32mp1.c  |  2 +-
 drivers/fastboot/fb_command.c | 16 
 include/linux/kconfig.h   | 34 --
 test/dm/ofnode.c  |  2 +-
 test/lib/kconfig.c|  6 +++---
 test/lib/kconfig_spl.c|  4 ++--
 7 files changed, 29 insertions(+), 39 deletions(-)

diff --git a/arch/x86/lib/fsp/fsp_dram.c b/arch/x86/lib/fsp/fsp_dram.c
index db4e3ff5fa2..f46c6cdbc2e 100644
--- a/arch/x86/lib/fsp/fsp_dram.c
+++ b/arch/x86/lib/fsp/fsp_dram.c
@@ -152,8 +152,8 @@ unsigned int install_e820_map(unsigned int max_entries,
if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)) {
ulong stack_size;
 
-   stack_size = CONFIG_IS_ENABLED(HAVE_ACPI_RESUME,
-  (CONFIG_STACK_SIZE_RESUME), (0));
+   stack_size = IS_ENABLED(CONFIG_HAVE_ACPI_RESUME,
+   (CONFIG_STACK_SIZE_RESUME), (0));
/*
 * Everything between U-Boot's stack and ram top needs to be
 * reserved in order for ACPI S3 resume to work.
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 822edf55f0e..58bc12fcb63 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -903,7 +903,7 @@ const char *env_ext4_get_dev_part(void)
 
 int mmc_get_env_dev(void)
 {
-   const int mmc_env_dev = CONFIG_IS_ENABLED(ENV_IS_IN_MMC, 
(CONFIG_SYS_MMC_ENV_DEV), (-1));
+   const int mmc_env_dev = IS_ENABLED(CONFIG_ENV_IS_IN_MMC, 
(CONFIG_SYS_MMC_ENV_DEV), (-1));
 
if (mmc_env_dev >= 0)
return mmc_env_dev;
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 71cfaec6e9d..3a5e29861a2 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -56,11 +56,11 @@ static const struct {
},
[FASTBOOT_COMMAND_FLASH] =  {
.command = "flash",
-   .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (flash), (NULL))
+   .dispatch = IS_ENABLED(CONFIG_FASTBOOT_FLASH, (flash), (NULL))
},
[FASTBOOT_COMMAND_ERASE] =  {
.command = "erase",
-   .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (erase), (NULL))
+   .dispatch = IS_ENABLED(CONFIG_FASTBOOT_FLASH, (erase), (NULL))
},
[FASTBOOT_COMMAND_BOOT] =  {
.command = "boot",
@@ -92,27 +92,27 @@ static const struct {
},
[FASTBOOT_COMMAND_OEM_FORMAT] = {
.command = "oem format",
-   .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT, 
(oem_format), (NULL))
+   .dispatch = IS_ENABLED(CONFIG_FASTBOOT_CMD_OEM_FORMAT, 
(oem_format), (NULL))
},
[FASTBOOT_COMMAND_OEM_PARTCONF] = {
.command = "oem partconf",
-   .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF, 
(oem_partconf), (NULL))
+   .dispatch = IS_ENABLED(CONFIG_FASTBOOT_CMD_OEM_PARTCONF, 
(oem_partconf), (NULL))
},
[FASTBOOT_COMMAND_OEM_BOOTBUS] = {
.command = "oem bootbus",
-   .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS, 
(oem_bootbus), (NULL))
+   .dispatch = IS_ENABLED(CONFIG_FASTBOOT_CMD_OEM_BOOTBUS, 
(oem_bootbus), (NULL))
},
[FASTBOOT_COMMAND_OEM_RUN] = {
.command = "oem run",
-   .dispatch = CONFIG_IS_ENABLED(FASTBOOT_OEM_RUN, (run_ucmd), 
(NULL))
+   .dispatch = IS_ENABLED(CONFIG_FASTBOOT_OEM_RUN, (run_ucmd), 
(NULL))
},
[FASTBOOT_COMMAND_UCMD] = {
.command = "UCmd",
-   .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_ucmd), 
(NULL))
+   .dispatch = IS_ENABLED(CONFIG_FASTBOOT_UUU_SUPPORT, (run_ucmd), 
(NULL))
},
[FASTBOOT_COMMAND_ACMD] = {
.command = "ACmd",
-   .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_acmd), 
(NULL))
+   .dispatch = IS_ENABLED(CONFIG_FASTBOOT_UUU_SUPPORT, (run_acmd), 
(NULL))
},
 };
 
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index f00686eb3e1..57d5afc7a1a 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -32,12 +32,6 @@
 #define __config_enabled(arg1_or_junk, def_val) ___config_enabled(arg1_or_junk 
1, def_val)
 #define ___config_enabled(__ignored, val, ...) val
 
-/*
- * IS_ENABLED(CONFIG_FOO) evaluates to 1 if 

[PATCH v3 73/95] freescale: Fix odd use of ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE

2023-02-12 Thread Simon Glass
This is not a CONFIG option so we should not be using IS_ENABLED() on it,
particularly not when it is not defined to anything, so shows up as
calling IS_ENABLED() with no arguments.

Just check it normally.

This fixes a build error with split config on T2080QDS.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/mmc/fsl_esdhc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index d506698..7215f61f468 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -325,8 +325,9 @@ static int esdhc_setup_data(struct fsl_esdhc_priv *priv, 
struct mmc *mmc,
(timeout == 4 || timeout == 8 || timeout == 12))
timeout++;
 
-   if (IS_ENABLED(ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE))
-   timeout = 0xE;
+#ifdef ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE
+   timeout = 0xE;
+#endif
 
esdhc_clrsetbits32(>sysctl, SYSCTL_TIMEOUT_MASK, timeout << 16);
 
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 34/95] lib: Add a Kconfig for SPL_GENERATE_ACPI_TABLE

2023-02-12 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Move SPL_GENERATE_ACPI_TABLE patch to this series

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

diff --git a/lib/Kconfig b/lib/Kconfig
index 1267fa63f14..0a02f3e89ae 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -287,6 +287,10 @@ config GENERATE_ACPI_TABLE
  by the operating system. It defines platform-independent interfaces
  for configuration and power management monitoring.
 
+config SPL_GENERATE_ACPI_TABLE
+   def_bool n  # Generate an ACPI table (SPL)
+   depends on SPL && SUPPORT_ACPI
+
 config SPL_TINY_MEMSET
bool "Use a very small memset() in SPL"
depends on SPL
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 26/95] lib: Add a Kconfig for SPL_FSP_VERSION2

2023-02-12 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Add new patch with a Kconfig for SPL_FSP_VERSION2

 arch/x86/Kconfig | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 07be5cd05ec..cede5160480 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -396,12 +396,19 @@ config FSP_VERSION1
 config FSP_VERSION2
bool "FSP version 2.x"
select DM_EVENT
+   select SPL_FSP_VERSION2
help
  This covers versions 2.0 and 2.1. See here for details:
  https://github.com/IntelFsp/fsp/wiki
 
 endchoice
 
+config SPL_FSP_VERSION2
+   bool   # FSP version 2.x (SPL)
+   help
+ This covers versions 2.0 and 2.1. See here for details:
+ https://github.com/IntelFsp/fsp/wiki
+
 config FSP_FILE
string "Firmware Support Package binary filename"
depends on FSP_VERSION1
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 08/95] Correct SPL uses of FSL_ISBC_KEY_EXT

2023-02-12 Thread Simon Glass
This converts 9 usages of this option to the non-SPL form, since there is
no SPL_FSL_ISBC_KEY_EXT defined in Kconfig

Signed-off-by: Simon Glass 
---

(no changes since v1)

 board/freescale/common/fsl_validate.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/board/freescale/common/fsl_validate.c 
b/board/freescale/common/fsl_validate.c
index bfe6357b0d6..78bed122466 100644
--- a/board/freescale/common/fsl_validate.c
+++ b/board/freescale/common/fsl_validate.c
@@ -29,7 +29,7 @@
 #define CHECK_KEY_LEN(key_len) (((key_len) == 2 * KEY_SIZE_BYTES / 4) || \
 ((key_len) == 2 * KEY_SIZE_BYTES / 2) || \
 ((key_len) == 2 * KEY_SIZE_BYTES))
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
 /* Global data structure */
 static struct fsl_secboot_glb glb;
 #endif
@@ -63,7 +63,7 @@ self:
goto self;
 }
 
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
 static u32 check_ie(struct fsl_secboot_img_priv *img)
 {
if (img->hdr.ie_flag & IE_FLAG_MASK)
@@ -188,7 +188,7 @@ static u32 check_srk(struct fsl_secboot_img_priv *img)
 {
 #ifdef CONFIG_ESBC_HDR_LS
/* In LS, No SRK Flag as SRK is always present if IE not present*/
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
return !check_ie(img);
 #endif
return 1;
@@ -278,7 +278,7 @@ static u32 read_validate_single_key(struct 
fsl_secboot_img_priv *img)
 }
 #endif /* CONFIG_ESBC_HDR_LS */
 
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
 
 static void install_ie_tbl(uintptr_t ie_tbl_addr,
struct fsl_secboot_img_priv *img)
@@ -434,7 +434,7 @@ void fsl_secboot_handle_error(int error)
case ERROR_ESBC_CLIENT_HEADER_INVALID_KEY_NUM:
case ERROR_ESBC_CLIENT_HEADER_INV_SRK_ENTRY_KEYLEN:
 #endif
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
/*@fallthrough@*/
case ERROR_ESBC_CLIENT_HEADER_IE_KEY_REVOKED:
case ERROR_ESBC_CLIENT_HEADER_INVALID_IE_NUM_ENTRY:
@@ -571,7 +571,7 @@ static int calc_esbchdr_esbc_hash(struct 
fsl_secboot_img_priv *img)
key_hash = 1;
}
 #endif
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
if (!key_hash && check_ie(img))
key_hash = 1;
 #endif
@@ -705,7 +705,7 @@ static int read_validate_esbc_client_header(struct 
fsl_secboot_img_priv *img)
}
 #endif
 
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
if (!key_found && check_ie(img)) {
ret = read_validate_ie_tbl(img);
if (ret != 0)
@@ -851,7 +851,7 @@ static int secboot_init(struct fsl_secboot_img_priv 
**img_ptr)
return -ENOMEM;
memset(img, 0, sizeof(struct fsl_secboot_img_priv));
 
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
if (glb.ie_addr)
img->ie_addr = glb.ie_addr;
 #endif
@@ -952,7 +952,7 @@ int fsl_secboot_validate(uintptr_t haddr, char 
*arg_hash_str,
else
ret = memcmp(srk_hash, img->img_key_hash, SHA256_BYTES);
 
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
if (!hash_cmd && check_ie(img))
ret = 0;
 #endif
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 51/95] sandbox: Use the generic VPL option to enable VPL

2023-02-12 Thread Simon Glass
Avoid using CONFIG_SANDBOX_VPL since we have a generic option which works
just as well.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/sandbox/dts/sandbox.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 1dd880ebd58..28c21f232a2 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -103,6 +103,6 @@
 #include "cros-ec-keyboard.dtsi"
 #include "sandbox_pmic.dtsi"
 
-#ifdef CONFIG_SANDBOX_VPL
+#if IS_ENABLED(CONFIG_SUPPORT_VPL)
 #include "sandbox_vpl.dtsi"
 #endif
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 50/95] sandbox: Tidy up RTC options

2023-02-12 Thread Simon Glass
At present we enable the sandbox RTC driver for all builds. Add a separate
Kconfig option to control this, so that it can be disabled in TPL, where
it is not needed.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Fix a transitory build error with sandbox_spl

 arch/sandbox/dts/sandbox.dts   |  2 +-
 arch/sandbox/dts/sandbox.dtsi  |  6 +++---
 arch/sandbox/include/asm/rtc.h |  2 +-
 drivers/rtc/Kconfig| 18 ++
 drivers/rtc/Makefile   |  4 ++--
 5 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 88b57bfb7e5..1dd880ebd58 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -76,7 +76,7 @@
clock-frequency = <40>;
pinctrl-names = "default";
pinctrl-0 = <_i2c0>;
-   u-boot,dm-pre-reloc;
+   u-boot,dm-spl;
};
 
pcic: pci@0 {
diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 7e7fcff6d28..ebf3bee716a 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -115,7 +115,7 @@
reg = <0x43>;
compatible = "sandbox-rtc";
sandbox,emul = <>;
-   u-boot,dm-pre-reloc;
+   u-boot,dm-spl;
};
sandbox_pmic: sandbox_pmic {
reg = <0x40>;
@@ -126,7 +126,7 @@
};
 
i2c_emul: emul {
-   u-boot,dm-pre-reloc;
+   u-boot,dm-spl;
reg = <0xff>;
compatible = "sandbox,i2c-emul-parent";
emul_eeprom: emul-eeprom {
@@ -136,7 +136,7 @@
#emul-cells = <0>;
};
emul0: emul0 {
-   u-boot,dm-pre-reloc;
+   u-boot,dm-spl;
compatible = "sandbox,i2c-rtc-emul";
#emul-cells = <0>;
};
diff --git a/arch/sandbox/include/asm/rtc.h b/arch/sandbox/include/asm/rtc.h
index 025cd6c67cf..bf3ac5ea1ec 100644
--- a/arch/sandbox/include/asm/rtc.h
+++ b/arch/sandbox/include/asm/rtc.h
@@ -40,7 +40,7 @@ enum {
  * @reg:   Register values
  */
 struct sandbox_i2c_rtc_plat_data {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
+#if CONFIG_IS_ENABLED(OF_PLATDATA) && IS_ENABLED(CONFIG_RTC_SANDBOX)
struct dtd_sandbox_i2c_rtc_emul dtplat;
 #endif
long base_time;
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 35b6ed4d7c7..fcfda2847c8 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -231,6 +231,24 @@ config RTC_M41T62
  Enable driver for ST's M41T62 compatible RTC devices (like RV-4162).
  It is a serial (I2C) real-time clock (RTC) with alarm.
 
+config RTC_SANDBOX
+   bool "Enable sandbox RTC driver"
+   depends on SANDBOX && DM_RTC
+   default y
+   help
+ Enable the sandbox RTC driver. This driver connects to the RTC
+ emulator and is used to test the RTC uclasses and associated code,
+ as well as the I2C subsystem.
+
+config SPL_RTC_SANDBOX
+   bool "Enable sandbox RTC driver (SPL)"
+   depends on SANDBOX && SPL_DM_RTC
+   default y
+   help
+ Enable the sandbox RTC driver. This driver connects to the RTC
+ emulator and is used to test the RTC uclasses and associated code,
+ as well as the I2C subsystem.
+
 config RTC_STM32
bool "Enable STM32 RTC driver"
depends on DM_RTC
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 447551e15aa..b6c9029c8f0 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -16,7 +16,7 @@ obj-$(CONFIG_RTC_DS3231) += ds3231.o
 obj-$(CONFIG_RTC_DS3232) += ds3232.o
 obj-$(CONFIG_RTC_EMULATION) += emul_rtc.o
 obj-$(CONFIG_RTC_HT1380) += ht1380.o
-obj-$(CONFIG_SANDBOX) += i2c_rtc_emul.o
+obj-$(CONFIG_$(SPL_TPL_)RTC_SANDBOX) += i2c_rtc_emul.o
 obj-$(CONFIG_RTC_ISL1208) += isl1208.o
 obj-$(CONFIG_RTC_M41T62) += m41t62.o
 obj-$(CONFIG_RTC_MC13XXX) += mc13xxx-rtc.o
@@ -35,6 +35,6 @@ obj-$(CONFIG_RTC_RX8025) += rx8025.o
 obj-$(CONFIG_RTC_RX8010SJ) += rx8010sj.o
 obj-$(CONFIG_RTC_S35392A) += s35392a.o
 obj-$(CONFIG_RTC_STM32) += stm32_rtc.o
-obj-$(CONFIG_SANDBOX) += sandbox_rtc.o
+obj-$(CONFIG_$(SPL_TPL_)RTC_SANDBOX) += sandbox_rtc.o
 obj-$(CONFIG_RTC_ABX80X) += abx80x.o
 obj-$(CONFIG_RTC_ZYNQMP) += zynqmp_rtc.o
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v3 87/95] kconfig: Drop CONFIG_IF_ENABLED_INT()

2023-02-12 Thread Simon Glass
We can use IF_ENABLED_INT() instead, so drop the other macro. Also clean
up a few things left behind and fix the comment.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/linux/kconfig.h   | 32 ++--
 test/lib/kconfig.c| 15 ---
 test/lib/kconfig_spl.c| 10 --
 test/py/tests/test_kconfig.py |  6 ++
 4 files changed, 8 insertions(+), 55 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 57d5afc7a1a..77d8e6b6129 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -47,19 +47,6 @@
___config_opt_enabled(arg1_or_junk arg2, def_val)
 #define ___config_opt_enabled(__ignored, val, ...) val
 
-#ifndef __ASSEMBLY__
-/*
- * Detect usage of a the value when the conditional is not enabled. When used
- * in assembly context, this likely produces a assembly error, or hopefully at
- * least something recognisable.
- */
-long invalid_use_of_IF_ENABLED_INT(void);
-#endif
-
-/* Evaluates to int_option if option is defined, otherwise a build error */
-#define IF_ENABLED_INT(option, int_option) \
-   config_opt_enabled(option, int_option, invalid_use_of_IF_ENABLED_INT())
-
 /*
  * Count number of arguments to a variadic macro. Currently only need
  * it for 1, 2 or 3 arguments.
@@ -103,22 +90,15 @@ long invalid_use_of_IF_ENABLED_INT(void);
 
 #ifndef __ASSEMBLY__
 /*
- * Detect usage of a the value when the conditional is not enabled. When used
- * in assembly context, this likely produces a assembly error, or hopefully at
+ * Detect usage of the value when the conditional is not enabled. When used
+ * in assembly context, this likely produces an assembly error, or hopefully at
  * least something recognisable.
  */
-long invalid_use_of_CONFIG_IF_ENABLED_INT(void);
+long invalid_use_of_IF_ENABLED_INT(void);
 #endif
 
-/*
- * Evaluates to SPL_/TPL_int_option if SPL_/TPL_/option is not defined,
- * otherwise build error
- */
-#define CONFIG_IF_ENABLED_INT(option, int_option) \
-   CONFIG_IS_ENABLED(option, (int_option), \
-   (invalid_use_of_CONFIG_IF_ENABLED_INT()))
-
-#define CONFIG_IF_INT(option, int_option) \
-   CONFIG_IF_ENABLED_INT(option, int_option)
+/* Evaluates to int_option if option is defined, otherwise build error */
+#define IF_ENABLED_INT(option, int_option) \
+   IS_ENABLED(option, (int_option), (invalid_use_of_IF_ENABLED_INT()))
 
 #endif /* __LINUX_KCONFIG_H */
diff --git a/test/lib/kconfig.c b/test/lib/kconfig.c
index 029a2be8cd9..0c4345b6b3f 100644
--- a/test/lib/kconfig.c
+++ b/test/lib/kconfig.c
@@ -24,8 +24,6 @@ static int lib_test_is_enabled(struct unit_test_state *uts)
 
ut_asserteq(0xc000,
IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, 
CONFIG_BLOBLIST_ADDR));
-   ut_asserteq(0xc000,
-   CONFIG_IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, 
CONFIG_BLOBLIST_ADDR));
 
/*
 * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
@@ -40,19 +38,6 @@ static int lib_test_is_enabled(struct unit_test_state *uts)
printf("value %ld\n", val);
}
 
-   /*
-* This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
-* value is used. Disable for SPL so that the errors in kconfig_spl.c
-* are detected, since otherwise a build error when building U-Boot may
-* cause SPL to not be built.
-*/
-   if (!IS_ENABLED(CONFIG_SANDBOX_SPL) &&
-   IS_ENABLED(CONFIG_TEST_KCONFIG)) {
-   val = CONFIG_IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE,
-   CONFIG_TEST_KCONFIG_VALUE);
-   printf("value2 %ld\n", val);
-   }
-
return 0;
 }
 LIB_TEST(lib_test_is_enabled, 0);
diff --git a/test/lib/kconfig_spl.c b/test/lib/kconfig_spl.c
index 2894a03f1e8..69c107fd524 100644
--- a/test/lib/kconfig_spl.c
+++ b/test/lib/kconfig_spl.c
@@ -29,16 +29,6 @@ static int lib_test_spl_is_enabled(struct unit_test_state 
*uts)
printf("value %ld\n", val);
}
 
-   /*
-* This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
-* value is used.
-*/
-   if (IS_ENABLED(CONFIG_TEST_KCONFIG)) {
-   val = CONFIG_IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE,
-   CONFIG_TEST_KCONFIG_VALUE);
-   printf("value2 %ld\n", val);
-   }
-
return 0;
 }
 LIB_TEST(lib_test_spl_is_enabled, 0);
diff --git a/test/py/tests/test_kconfig.py b/test/py/tests/test_kconfig.py
index 0b9e6bc3bd1..c4287e1144c 100644
--- a/test/py/tests/test_kconfig.py
+++ b/test/py/tests/test_kconfig.py
@@ -20,7 +20,6 @@ def test_kconfig(u_boot_console):
 cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox',
'-a', 'TEST_KCONFIG', '-o', TMPDIR], ignore_errors=True)
 assert 'invalid_use_of_IF_ENABLED_INT' in out
-assert 

[PATCH v3 81/95] Allow distroboot environment to be the same in SPL

2023-02-12 Thread Simon Glass
With the split config, we find that CONFIG_CMD_DHCP is not enabled in SPL.
While this is normally correct, it causes a build error with
BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE

This is because some boards include PXE and DHXP in their
BOOT_TARGET_DEVICES #define. Before split config CONFIG_CMD_DHCP is
enabled in SPL, but with split config it is not, since we don't support
any commands in SPL.

The easiest way to fix this seems to be to use the CONFIG_PPL_... form.
This retains the existing behaviour.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Add new patch to allow distroboot environment to be the same in SPL

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

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 9d2a225e7eb..801c481f432 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -328,7 +328,7 @@
BOOT_TARGET_DEVICES_references_VIRTIO_without_CONFIG_CMD_VIRTIO
 #endif
 
-#if defined(CONFIG_CMD_DHCP)
+#if defined(CONFIG_PPL_CMD_DHCP)
 #if defined(CONFIG_EFI_LOADER)
 /* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */
 #if defined(CONFIG_ARM64) || defined(__aarch64__)
@@ -402,7 +402,7 @@
BOOT_TARGET_DEVICES_references_DHCP_without_CONFIG_CMD_DHCP
 #endif
 
-#if defined(CONFIG_CMD_DHCP) && defined(CONFIG_CMD_PXE)
+#if defined(CONFIG_PPL_CMD_DHCP) && defined(CONFIG_PPL_CMD_PXE)
 #define BOOTENV_DEV_PXE(devtypeu, devtypel, instance) \
"bootcmd_pxe=" \
BOOTENV_RUN_NET_USB_START \
-- 
2.39.1.581.gbfd45094c4-goog



  1   2   3   >