Re: [PATCH v6 18/23] arm: k3-am65x-iot2050: Use binman for tispl.bin for iot2050

2023-07-12 Thread Jan Kiszka
On 12.07.23 20:34, Neha Malcom Francis wrote:
> Move to using binman to generate tispl.bin which is used to generate the
> final flash.bin bootloader for iot2050 boards.
> 
> Signed-off-by: Neha Malcom Francis 
> Cc: Jan Kiszka 
> Reviewed-by: Simon Glass 
> ---
>  arch/arm/dts/k3-am65-iot2050-boot-image.dtsi | 76 +++-
>  1 file changed, 74 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi 
> b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
> index 03ccc54329..9d83898d33 100644
> --- a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
> +++ b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
> @@ -26,9 +26,81 @@
>   missing-msg = "iot2050-seboot";
>   };
>  
> - blob@0x18 {
> + fit@0x18 {
>   offset = <0x18>;
> - filename = "tispl.bin";
> + pad-byte = <0xff>;
> + description = "Configuration to load ATF and SPL";
> +
> + images {
> + atf {
> + description = "ARM Trusted Firmware";
> + type = "firmware";
> + arch = "arm64";
> + compression = "none";
> + os = "arm-trusted-firmware";
> + load = ;
> + entry = ;
> + atf: atf-bl31 {
> + };
> + };
> +
> + tee {
> + description = "OPTEE";
> + type = "tee";
> + arch = "arm64";
> + compression = "none";
> + os = "tee";
> + load = <0x9e80>;
> + entry = <0x9e80>;
> + tee: tee-os {
> + };
> + };
> +
> + dm {
> + description = "DM binary";
> + type = "firmware";
> + arch = "arm32";
> + compression = "none";
> + os = "DM";
> + load = <0x8900>;
> + entry = <0x8900>;
> + blob-ext {
> + filename = "/dev/null";
> + };
> + };
> +
> + spl {
> + description = "SPL (64-bit)";
> + type = "standalone";
> + os = "U-Boot";
> + arch = "arm64";
> + compression = "none";
> + load = ;
> + entry = ;
> + u_boot_spl_nodtb: blob-ext {
> + filename = 
> "spl/u-boot-spl-nodtb.bin";
> + };
> + };
> +
> + fdt-0 {
> + description = "k3-am65-iot2050-spl.dtb";
> + type = "flat_dt";
> + arch = "arm";
> + compression = "none";
> + spl_am65x_evm_dtb: blob-ext {
> + filename = 
> "spl/dts/k3-am65-iot2050-spl.dtb";
> + };
> + };
> + };
> +
> + configurations {
> + default = "spl";
> + spl {
> + fdt = "fdt-0";
> + firmware = "atf";
> + loadables = "tee", "dm", "spl";
> + };
> + };
>   };
>  
>   fit@0x38 {

You forgot to update tools/iot2050-sign-fw.sh?

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux



Re: [PATCH v4 30/45] x86: Allow logging to be used in SPL reliably

2023-07-12 Thread Bin Meng
On Mon, Jun 19, 2023 at 8:02 PM Simon Glass  wrote:
>
> When global_data is relocated, log_head moves in memory, meaning that
> the items in that list point to the wrong place.
>
> Disable logging when making the change, then reenable it afterwards, so
> that logging works normally.
>
> Signed-off-by: Simon Glass 
> ---
>
> (no changes since v1)
>
>  arch/x86/lib/spl.c | 13 +
>  1 file changed, 13 insertions(+)
>

Reviewed-by: Bin Meng 


Re: [PATCH v4 29/45] x86: Enable display for QEMU 64-bit

2023-07-12 Thread Bin Meng
Hi Simon,

On Mon, Jun 19, 2023 at 8:02 PM Simon Glass  wrote:
>
> Enable the various options needed for display to work on the qemu-x86_64
> board. This includes expanding the available malloc() memory in SPL,
> since the PCI bus must be enumerated in order to find the video device.
>
> It also includes enabling a bloblist, so that the video parameters can be
> passed. This is placed at address 1 but is not needed after U-Boot
> proper reads the information there.
>
> Signed-off-by: Simon Glass 
> ---
>
> (no changes since v1)
>
>  configs/qemu-x86_64_defconfig | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig
> index f29a5aa0f813..371ca9de8429 100644
> --- a/configs/qemu-x86_64_defconfig
> +++ b/configs/qemu-x86_64_defconfig
> @@ -7,6 +7,7 @@ CONFIG_MAX_CPUS=2
>  CONFIG_SPL_DM_SPI=y
>  CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx"
>  CONFIG_SPL_TEXT_BASE=0xfffd
> +CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000
>  CONFIG_DEBUG_UART_BASE=0x3f8
>  CONFIG_DEBUG_UART_CLOCK=1843200
>  CONFIG_X86_RUN_64BIT=y
> @@ -29,7 +30,10 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
>  CONFIG_DISPLAY_BOARDINFO_LATE=y
>  CONFIG_LAST_STAGE_INIT=y
>  CONFIG_PCI_INIT_R=y
> +CONFIG_BLOBLIST=y
> +CONFIG_BLOBLIST_ADDR=0x1
>  CONFIG_SPL_NO_BSS_LIMIT=y
> +CONFIG_SPL_BOARD_INIT=y

Use this option to control not initializing serial in SPL is not
appropriate. See comments in patch #26

>  CONFIG_SPL_SYS_MALLOC_SIMPLE=y
>  CONFIG_SPL_CPU=y
>  CONFIG_SPL_ENV_SUPPORT=y
> @@ -69,10 +73,12 @@ CONFIG_LBA48=y
>  CONFIG_SYS_64BIT_LBA=y
>  CONFIG_CPU=y
>  CONFIG_NVME_PCI=y
> +CONFIG_SPL_PCI_PNP=y
>  CONFIG_SPL_DM_RTC=y
>  CONFIG_SYS_NS16550_PORT_MAPPED=y
>  CONFIG_SPI=y
>  CONFIG_USB_KEYBOARD=y
> +CONFIG_SPL_VIDEO=y
>  CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
>  CONFIG_FRAMEBUFFER_VESA_MODE_USER=y
>  CONFIG_FRAMEBUFFER_VESA_MODE=0x144
> --

Otherwise,
Reviewed-by: Bin Meng 

Regards,
Bin


Re: [PATCH v4 28/45] pci: Mask the ROM address in case it is already enabled

2023-07-12 Thread Bin Meng
On Mon, Jun 19, 2023 at 8:01 PM Simon Glass  wrote:
>
> In some cases the video ROM may have been enabled previously, such as by
> a previous firmware stage. Use the correct address in that case.
>
> Signed-off-by: Simon Glass 
> ---
>
> (no changes since v1)
>
>  drivers/pci/pci_rom.c | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Bin Meng 


Re: [PATCH v4 27/45] pci: Adjust video BIOS debugging to be SPL-friendly

2023-07-12 Thread Bin Meng
Hi Simon,

On Mon, Jun 19, 2023 at 8:01 PM Simon Glass  wrote:
>
> A hex value is expected for the VGA mode. Drop the 0x prefix, which is
> not supported in SPL.
>
> Signed-off-by: Simon Glass 
> ---
>
> (no changes since v1)
>
>  drivers/pci/pci_rom.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
> index ecb6da64c5c9..62cfe60c0fb2 100644
> --- a/drivers/pci/pci_rom.c
> +++ b/drivers/pci/pci_rom.c
> @@ -319,7 +319,7 @@ int dm_pci_run_vga_bios(struct udevice *dev, int 
> (*int15_handler)(void),
> defined(CONFIG_FRAMEBUFFER_VESA_MODE)
> vesa_mode = CONFIG_FRAMEBUFFER_VESA_MODE;
>  #endif
> -   debug("Selected vesa mode %#x\n", vesa_mode);
> +   debug("Selected vesa mode %x\n", vesa_mode);

Shouldn't we fix the SPL printf to ignore the '#' character?

Or we can simple remove # and add 0x explicitly?

>
> if (exec_method & PCI_ROM_USE_NATIVE) {
>  #ifdef CONFIG_X86
> @@ -370,7 +370,7 @@ int dm_pci_run_vga_bios(struct udevice *dev, int 
> (*int15_handler)(void),
> log_debug("done\n");
>  #endif
> }
> -   debug("Final vesa mode %#x\n", mode_info.video_mode);
> +   debug("Final vesa mode %x\n", mode_info.video_mode);
> ret = 0;
>
>  err:
> --

Regards,
Bin


Re: [PATCH v4 26/45] x86: Init video in SPL if enabled

2023-07-12 Thread Bin Meng
Hi Simon,

On Mon, Jun 19, 2023 at 8:01 PM Simon Glass  wrote:
>
> When video is required in SPL, set this up ready for use. Ignore any
> problems since it may be that video is not actually available and we
> still want to continue on to U-Boot proper in that case.
>
> Make sure that the SPL banner is only shown once.
>
> Signed-off-by: Simon Glass 
> ---
>
> (no changes since v1)
>
>  arch/x86/lib/spl.c | 12 +++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/lib/spl.c b/arch/x86/lib/spl.c
> index b9d23e6bfe18..8d57f98f6c1f 100644
> --- a/arch/x86/lib/spl.c
> +++ b/arch/x86/lib/spl.c
> @@ -15,6 +15,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -97,7 +98,8 @@ static int x86_spl_init(void)
> return ret;
> }
>  #endif
> -   preloader_console_init();
> +   if (!IS_ENABLED(CONFIG_SPL_BOARD_INIT))

The preloader_console_init() has nothing to do with SPL_BOARD_INIT. If
the purpose is to make SPL banner only show once, I think we need
change somewhere else.

> +   preloader_console_init();
>  #if !defined(CONFIG_TPL) && !CONFIG_IS_ENABLED(CPU)
> ret = print_cpuinfo();
> if (ret) {
> @@ -257,4 +259,12 @@ void spl_board_init(void)
>  #ifndef CONFIG_TPL
> preloader_console_init();
>  #endif
> +
> +   if (CONFIG_IS_ENABLED(VIDEO)) {
> +   struct udevice *dev;
> +
> +   /* Set up PCI video in SPL if required */
> +   uclass_first_device_err(UCLASS_PCI, );
> +   uclass_first_device_err(UCLASS_VIDEO, );
> +   }
>  }
> --

Regards,
Bin


Re: [PATCH v4 21/45] pci: Support autoconfig in SPL

2023-07-12 Thread Bin Meng
On Mon, Jun 19, 2023 at 8:01 PM Simon Glass  wrote:
>
> Allow PCI autoconfig to be handled in SPL, so that we can set it up
> correctly for boards which need to do this before U-Boot proper. This
> includes qemu-x64_64 which needs to set up the video device while in
> 32-bit mode.
>
> Signed-off-by: Simon Glass 
> ---
>
> (no changes since v1)
>
>  drivers/pci/Kconfig  |  8 
>  drivers/pci/pci-uclass.c | 10 +-
>  2 files changed, 17 insertions(+), 1 deletion(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH v4 25/45] x86: Pass video settings from SPL to U-Boot proper

2023-07-12 Thread Bin Meng
On Mon, Jun 19, 2023 at 8:01 PM Simon Glass  wrote:
>
> When video is set up in SPL, U-Boot proper needs to use the correct
> parameters so it can write to the display.
>
> Put these in a bloblist so they are available to U-Boot proper.
>
> Signed-off-by: Simon Glass 
> Reviewed-by: Nikhil M Jain 
> ---
>
> (no changes since v3)
>
> Changes in v3:
> - Add a tag name for the blob
>
>  common/bloblist.c |  1 +
>  drivers/pci/pci_rom.c | 78 +++
>  include/bloblist.h|  1 +
>  include/video.h   | 24 +
>  4 files changed, 83 insertions(+), 21 deletions(-)
>
> diff --git a/common/bloblist.c b/common/bloblist.c
> index 0d63b6e88177..2144b10e1d04 100644
> --- a/common/bloblist.c
> +++ b/common/bloblist.c
> @@ -51,6 +51,7 @@ static struct tag_name {
>
> /* BLOBLISTT_PROJECT_AREA */
> { BLOBLISTT_U_BOOT_SPL_HANDOFF, "SPL hand-off" },
> +   { BLOBLISTT_U_BOOT_VIDEO, "SPL video handoff" },
>
> /* BLOBLISTT_VENDOR_AREA */
>  };
> diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
> index 2d9a2a899ef7..ecb6da64c5c9 100644
> --- a/drivers/pci/pci_rom.c
> +++ b/drivers/pci/pci_rom.c
> @@ -26,6 +26,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -34,6 +35,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -420,34 +422,68 @@ int vesa_setup_video(struct udevice *dev, int 
> (*int15_handler)(void))
> printf("Not available (previous bootloader prevents it)\n");
> return -EPERM;
> }
> -   bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display");
> -   ret = dm_pci_run_vga_bios(dev, int15_handler, PCI_ROM_USE_NATIVE |
> -   PCI_ROM_ALLOW_FALLBACK);
> -   bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD);
> -   if (ret) {
> -   debug("failed to run video BIOS: %d\n", ret);
> -   return ret;
> -   }
>
> -   ret = vesa_setup_video_priv(_info.vesa,
> -   mode_info.vesa.phys_base_ptr, uc_priv,
> -   plat);
> -   if (ret) {
> -   if (ret == -ENFILE) {
> -   /*
> -* See video-uclass.c for how to set up reserved 
> memory
> -* in your video driver
> -*/
> -   log_err("CONFIG_VIDEO_COPY enabled but driver '%s' 
> set up no reserved memory\n",
> -   dev->driver->name);
> +   /* In U-Boot proper, collect the information added by SPL (see below) 
> */
> +   if (IS_ENABLED(CONFIG_SPL_VIDEO) && spl_phase() > PHASE_SPL &&
> +   CONFIG_IS_ENABLED(BLOBLIST)) {
> +   struct video_handoff *ho;
> +
> +   ho = bloblist_find(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho));
> +   if (!ho)
> +   return log_msg_ret("blf", -ENOENT);
> +   plat->base = ho->fb;
> +   plat->size = ho->size;
> +   uc_priv->xsize = ho->xsize;
> +   uc_priv->ysize = ho->ysize;
> +   uc_priv->line_length = ho->line_length;
> +   uc_priv->bpix = ho->bpix;
> +   } else {
> +   bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display");
> +   ret = dm_pci_run_vga_bios(dev, int15_handler,
> + PCI_ROM_USE_NATIVE |
> + PCI_ROM_ALLOW_FALLBACK);
> +   bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD);
> +   if (ret) {
> +   debug("failed to run video BIOS: %d\n", ret);
> +   return ret;
> }
>
> -   debug("No video mode configured\n");
> -   return ret;
> +   ret = vesa_setup_video_priv(_info.vesa,
> +   mode_info.vesa.phys_base_ptr,
> +   uc_priv, plat);
> +   if (ret) {
> +   if (ret == -ENFILE) {
> +   /*
> +* See video-uclass.c for how to set up 
> reserved
> +* memory in your video driver
> +*/
> +   log_err("CONFIG_VIDEO_COPY enabled but driver 
> '%s' set up no reserved memory\n",
> +   dev->driver->name);
> +   }
> +
> +   debug("No video mode configured\n");
> +   return ret;
> +   }
> }
>
> printf("Video: %dx%dx%d\n", uc_priv->xsize, uc_priv->ysize,
>mode_info.vesa.bits_per_pixel);
>
> +   /* In SPL, store the information for use by U-Boot proper */
> +   if (spl_phase() == PHASE_SPL && CONFIG_IS_ENABLED(BLOBLIST)) {
> + 

Re: [PATCH v4 24/45] x86: Allow video-BIOS code to be built for SPL

2023-07-12 Thread Bin Meng
On Mon, Jun 19, 2023 at 8:01 PM Simon Glass  wrote:
>
> With qemu-x86_64 we need to run the video BIOS while in 32-bit mode, i.e.
> SPL. Add a Kconfig option for this, adjust the Makefile rules and use
> CONFIG_IS_ENABLED() where needed.
>
> Signed-off-by: Simon Glass 
> ---
>
> (no changes since v1)
>
>  arch/x86/lib/Makefile |  7 ---
>  arch/x86/lib/bios.c   |  2 +-
>  drivers/pci/pci_rom.c | 28 ++--
>  3 files changed, 19 insertions(+), 18 deletions(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH v4 23/45] pci: Tidy up logging and reporting for video BIOS

2023-07-12 Thread Bin Meng
On Mon, Jun 19, 2023 at 8:01 PM Simon Glass  wrote:
>
> When running the ROM the code is not very helpful when something goes
> wrong. Add a little more debugging and some logging of return values to
> improve this.
>
> Signed-off-by: Simon Glass 
> ---
>
> (no changes since v1)
>
>  drivers/pci/pci_rom.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH v4 22/45] pci: Allow the video BIOS to work in SPL with QEMU

2023-07-12 Thread Bin Meng
Hi Simon,

On Mon, Jun 19, 2023 at 8:01 PM Simon Glass  wrote:
>
> QEMU emulates two common machines (Q35 and i440fx) which use mapping to
> determine whether RAM is present below 1MB. In order to copy the video
> BIOS to c we need to flip this mapping over to RAM. This does not
> happen automatically until SPL has finished running.
>
> Switch in RAM at these address so that the video BIOS can be loaded and
> run. This fix was found in the seabios code base.
>
> Signed-off-by: Simon Glass 
> ---
>
> (no changes since v1)
>
>  drivers/pci/pci_rom.c | 46 +++
>  include/pci_ids.h |  1 +
>  2 files changed, 47 insertions(+)
>
> diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
> index f0dfe6314907..0f44238bbbc8 100644
> --- a/drivers/pci/pci_rom.c
> +++ b/drivers/pci/pci_rom.c
> @@ -141,6 +141,49 @@ static int pci_rom_probe(struct udevice *dev, struct 
> pci_rom_header **hdrp)
> return 0;
>  }
>
> +#define Q35_HOST_BRIDGE_PAM0   0x90
> +#define I440FX_PAM00x59
> +
> +/**
> + * intel_set_writable_ram() - Set RAM to be writable
> + *
> + * This is needed for QEMU when using Q35 or I440FX emulation, since 
> otherwise
> + * there is no RAM available at c
> + *
> + * See Intel 82945G/82945G/82945GC GMCH and 82945P/82945PL MCH Datasheet for
> + * information about the PAM0-PAM6 registers
> + */
> +static void intel_set_writable_ram(void)
> +{
> +   struct udevice *dev;
> +   int pam0 = -1;
> +   int i;
> +
> +   for (pci_find_first_device(); dev; pci_find_next_device()) {
> +   const struct pci_child_plat *pdata = dev_get_parent_plat(dev);
> +
> +   if (pdata->vendor == PCI_VENDOR_ID_INTEL) {
> +   if (pdata->device == PCI_DEVICE_ID_INTEL_Q35_MCH) {
> +   pam0 = Q35_HOST_BRIDGE_PAM0;
> +   break;
> +   } else if (pdata->device == 
> PCI_DEVICE_ID_INTEL_82441) {
> +   pam0 = I440FX_PAM0;
> +   break;
> +   }
> +   }
> +   }
> +
> +   if (!dev)
> +   return;
> +
> +   // Adjust RAM to be writable from c to f
> +   for (i = 1; i <= 6; i++)
> +   dm_pci_write_config8(dev, pam0 + i, 0x33);
> +
> +   // Also f-10
> +   dm_pci_write_config8(dev, pam0, 0x30);
> +}
> +
>  /**
>   * pci_rom_load() - Load a ROM image and return a pointer to it
>   *
> @@ -185,6 +228,9 @@ static int pci_rom_load(struct pci_rom_header *rom_header,
> return -ENOMEM;
> *allocedp = true;
>  #endif
> +   /* QEMU hacks */
> +   intel_set_writable_ram();

I don't like inserting chip-specific logic in the generic codes.

The logic is already in qemu_chipset_init(). We should allow
qemu_chipset_init() to be called in the SPL.

> +
> if (target != rom_header) {
> ulong start = get_timer(0);
>
> diff --git a/include/pci_ids.h b/include/pci_ids.h
> index 88b0a6404585..856d53264114 100644
> --- a/include/pci_ids.h
> +++ b/include/pci_ids.h
> @@ -2870,6 +2870,7 @@
>  #define PCI_DEVICE_ID_INTEL_ICH9_7 0x2916
>  #define PCI_DEVICE_ID_INTEL_ICH9_8 0x2918
>  #define PCI_DEVICE_ID_INTEL_ICH9_AHCI  0x2922
> +#define PCI_DEVICE_ID_INTEL_Q35_MCH0x29c0
>  #define PCI_DEVICE_ID_INTEL_I7_MCR 0x2c18
>  #define PCI_DEVICE_ID_INTEL_I7_MC_TAD  0x2c19
>  #define PCI_DEVICE_ID_INTEL_I7_MC_RAS  0x2c1a
> --

Regards,
Bin


Re: [PATCH 1/2] CI: Update to QEMU 8.0.3

2023-07-12 Thread Bin Meng
On Thu, Jul 13, 2023 at 11:04 AM Tom Rini  wrote:
>
> On Thu, Jul 13, 2023 at 10:51:15AM +0800, Bin Meng wrote:
> > On Thu, Jul 13, 2023 at 10:04 AM Tom Rini  wrote:
> > >
> > > Move up to the latest tagged release of QEMU
> >
> > I have the same patch in my local tree :)
> >
> > >
> > > Signed-off-by: Tom Rini 
> > > ---
> > >  tools/docker/Dockerfile | 7 +++
> > >  1 file changed, 3 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
> > > index aa54e2689fb5..733099684be6 100644
> > > --- a/tools/docker/Dockerfile
> > > +++ b/tools/docker/Dockerfile
> > > @@ -77,6 +77,7 @@ RUN apt-get update && apt-get install -y \
> > > libsdl1.2-dev \
> > > libsdl2-dev \
> > > libseccomp-dev \
> > > +   libslirp-dev \
> > > libssl-dev \
> > > libtool \
> > > libudev-dev \
> > > @@ -175,13 +176,11 @@ RUN git clone git://git.savannah.gnu.org/grub.git 
> > > /tmp/grub && \
> > >
> > >  RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
> > > cd /tmp/qemu && \
> > > -   git checkout v6.1.0 && \
> > > +   git checkout v8.0.3 && \
> > > # config user.name and user.email to make 'git am' happy
> > > git config user.name u-boot && \
> > > git config user.email u-b...@denx.de && \
> > > -   # manually apply the bug fix for QEMU 6.1.0 Xilinx Zynq UART 
> > > emulation codes
> > > -   wget -O - 
> > > http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-bmeng...@gmail.com/mbox/
> > >  | git am && \
> > > -   ./configure --prefix=/opt/qemu 
> > > --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,m68k-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu"
> > >  && \
> > > +   ./configure --prefix=/opt/qemu 
> > > --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,m68k-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu"
> > >  --enable-slirp && \
> >
> > --enable-slirp is not necessary as libslirp-dev is installed as a
> > dependency which will be automatically figured out
>
> I thought about it, and I first tripped in to "no libslirp, no user
> netdev, CI fails". I then spelled out we need the library and configure
> failed, and then ah, right, we need libslirp-dev installed. So I was
> thinking about being explicit about this flag as we specify the user
> netdev in a number of cases and this means if something changes in the
> future we'll get a failure here, rather than later on when testing the
> image.  Does that make sense? Or do you still think I should drop the
> flag here?
>

I think we can just drop the flag. There are some other flags we don't
explicitly write down on the configure command line and we rely on the
build system to automatically figure it out. As long as we maintain
the dockerfile properly we will be fine.

Regards,
Bin


Re: [PATCH 1/2] CI: Update to QEMU 8.0.3

2023-07-12 Thread Tom Rini
On Thu, Jul 13, 2023 at 10:51:15AM +0800, Bin Meng wrote:
> On Thu, Jul 13, 2023 at 10:04 AM Tom Rini  wrote:
> >
> > Move up to the latest tagged release of QEMU
> 
> I have the same patch in my local tree :)
> 
> >
> > Signed-off-by: Tom Rini 
> > ---
> >  tools/docker/Dockerfile | 7 +++
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
> > index aa54e2689fb5..733099684be6 100644
> > --- a/tools/docker/Dockerfile
> > +++ b/tools/docker/Dockerfile
> > @@ -77,6 +77,7 @@ RUN apt-get update && apt-get install -y \
> > libsdl1.2-dev \
> > libsdl2-dev \
> > libseccomp-dev \
> > +   libslirp-dev \
> > libssl-dev \
> > libtool \
> > libudev-dev \
> > @@ -175,13 +176,11 @@ RUN git clone git://git.savannah.gnu.org/grub.git 
> > /tmp/grub && \
> >
> >  RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
> > cd /tmp/qemu && \
> > -   git checkout v6.1.0 && \
> > +   git checkout v8.0.3 && \
> > # config user.name and user.email to make 'git am' happy
> > git config user.name u-boot && \
> > git config user.email u-b...@denx.de && \
> > -   # manually apply the bug fix for QEMU 6.1.0 Xilinx Zynq UART 
> > emulation codes
> > -   wget -O - 
> > http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-bmeng...@gmail.com/mbox/
> >  | git am && \
> > -   ./configure --prefix=/opt/qemu 
> > --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,m68k-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu"
> >  && \
> > +   ./configure --prefix=/opt/qemu 
> > --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,m68k-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu"
> >  --enable-slirp && \
> 
> --enable-slirp is not necessary as libslirp-dev is installed as a
> dependency which will be automatically figured out

I thought about it, and I first tripped in to "no libslirp, no user
netdev, CI fails". I then spelled out we need the library and configure
failed, and then ah, right, we need libslirp-dev installed. So I was
thinking about being explicit about this flag as we specify the user
netdev in a number of cases and this means if something changes in the
future we'll get a failure here, rather than later on when testing the
image.  Does that make sense? Or do you still think I should drop the
flag here?

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] CI: Update to QEMU 8.0.3

2023-07-12 Thread Bin Meng
On Thu, Jul 13, 2023 at 10:04 AM Tom Rini  wrote:
>
> Move up to the latest tagged release of QEMU

I have the same patch in my local tree :)

>
> Signed-off-by: Tom Rini 
> ---
>  tools/docker/Dockerfile | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
> index aa54e2689fb5..733099684be6 100644
> --- a/tools/docker/Dockerfile
> +++ b/tools/docker/Dockerfile
> @@ -77,6 +77,7 @@ RUN apt-get update && apt-get install -y \
> libsdl1.2-dev \
> libsdl2-dev \
> libseccomp-dev \
> +   libslirp-dev \
> libssl-dev \
> libtool \
> libudev-dev \
> @@ -175,13 +176,11 @@ RUN git clone git://git.savannah.gnu.org/grub.git 
> /tmp/grub && \
>
>  RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
> cd /tmp/qemu && \
> -   git checkout v6.1.0 && \
> +   git checkout v8.0.3 && \
> # config user.name and user.email to make 'git am' happy
> git config user.name u-boot && \
> git config user.email u-b...@denx.de && \
> -   # manually apply the bug fix for QEMU 6.1.0 Xilinx Zynq UART 
> emulation codes
> -   wget -O - 
> http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-bmeng...@gmail.com/mbox/
>  | git am && \
> -   ./configure --prefix=/opt/qemu 
> --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,m68k-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu"
>  && \
> +   ./configure --prefix=/opt/qemu 
> --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,m68k-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu"
>  --enable-slirp && \

--enable-slirp is not necessary as libslirp-dev is installed as a
dependency which will be automatically figured out

> make -j$(nproc) all install && \
> rm -rf /tmp/qemu

Regards,
Bin


[PATCH 1/2] CI: Update to QEMU 8.0.3

2023-07-12 Thread Tom Rini
Move up to the latest tagged release of QEMU

Signed-off-by: Tom Rini 
---
 tools/docker/Dockerfile | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index aa54e2689fb5..733099684be6 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -77,6 +77,7 @@ RUN apt-get update && apt-get install -y \
libsdl1.2-dev \
libsdl2-dev \
libseccomp-dev \
+   libslirp-dev \
libssl-dev \
libtool \
libudev-dev \
@@ -175,13 +176,11 @@ RUN git clone git://git.savannah.gnu.org/grub.git 
/tmp/grub && \
 
 RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
cd /tmp/qemu && \
-   git checkout v6.1.0 && \
+   git checkout v8.0.3 && \
# config user.name and user.email to make 'git am' happy
git config user.name u-boot && \
git config user.email u-b...@denx.de && \
-   # manually apply the bug fix for QEMU 6.1.0 Xilinx Zynq UART emulation 
codes
-   wget -O - 
http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-bmeng...@gmail.com/mbox/
 | git am && \
-   ./configure --prefix=/opt/qemu 
--target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,m68k-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu"
 && \
+   ./configure --prefix=/opt/qemu 
--target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,m68k-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu"
 --enable-slirp && \
make -j$(nproc) all install && \
rm -rf /tmp/qemu
 
-- 
2.34.1



[PATCH 2/2] CI: Update to the latest "Jammy" tag

2023-07-12 Thread Tom Rini
Move to the latest "Jammy" tag from Ubuntu.

Signed-off-by: Tom Rini 
---
 .azure-pipelines.yml| 2 +-
 .gitlab-ci.yml  | 2 +-
 tools/docker/Dockerfile | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 76982ec3e52e..22185be1a890 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -2,7 +2,7 @@ variables:
   windows_vm: windows-2019
   ubuntu_vm: ubuntu-22.04
   macos_vm: macOS-12
-  ci_runner_image: trini/u-boot-gitlab-ci-runner:jammy-20230308-04Apr2023
+  ci_runner_image: trini/u-boot-gitlab-ci-runner:jammy-20230624-12Jul2023
   # Add '-u 0' options for Azure pipelines, otherwise we get "permission
   # denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer",
   # since our $(ci_runner_image) user is not root.
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f7ffb8f5dfdc..89e69fe20d3c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,7 +10,7 @@ default:
 
 # Grab our configured image.  The source for this is found
 # in the u-boot tree at tools/docker/Dockerfile
-image: ${MIRROR_DOCKER}/trini/u-boot-gitlab-ci-runner:jammy-20230308-04Apr2023
+image: ${MIRROR_DOCKER}/trini/u-boot-gitlab-ci-runner:jammy-20230624-12Jul2023
 
 # We run some tests in different order, to catch some failures quicker.
 stages:
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 733099684be6..c3fd49ba9469 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -2,7 +2,7 @@
 # This Dockerfile is used to build an image containing basic stuff to be used
 # to build U-Boot and run our test suites.
 
-FROM ubuntu:jammy-20230308
+FROM ubuntu:jammy-20230624
 MAINTAINER Tom Rini 
 LABEL Description=" This image is for building U-Boot inside a container"
 
-- 
2.34.1



Re: [PATCH v5] phy: phy-imx8mq-usb: add vbus regulator support

2023-07-12 Thread Marek Vasut

On 7/13/23 02:40, Tim Harvey wrote:

Add support for enabling and disabling vbus-supply regulator found
on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.

While we are at it replace '#if CONFIG_IS_ENABLED(CLK)' with
'if (CONFIG_IS_ENABLED(CLK))' as a cleanup.

Signed-off-by: Tim Harvey 
Reviewed-by: Adam Ford 
Reviewed-by: Marek Vasut 
---
v5:
  - remove #if CONFIG_IS_ENABLED around struct members
(you can not conditionally include if using if (CONFIG_IS_ENABLED(foo)) )
  - replace clk '#if CONFIG_IS_ENABLED(CLK)' with 'if (CONFIG_IS_ENABLED(CLK))'

v4:
  - use regulator_set_enable_if_allowed to handle regulator reference
counting
errors
  - added Marek's rb tag

v3:
  - change pr_err to dev_err
  - add #if CONFIG_IS_ENABLED around vbus_supply in struct
  - add fail path to disable clock if regulator enable failed

v2:
  - protect ret with __maybe_unused in case CONFIG_CLK and
CONFIG_DM_REGULATOR not defined
  - add error prints on failures
  - add Adam's rb tag
---
  drivers/phy/phy-imx8mq-usb.c | 68 +---
  1 file changed, 48 insertions(+), 20 deletions(-)

diff --git a/drivers/phy/phy-imx8mq-usb.c b/drivers/phy/phy-imx8mq-usb.c
index 69f01de55538..532b0235e2bc 100644
--- a/drivers/phy/phy-imx8mq-usb.c
+++ b/drivers/phy/phy-imx8mq-usb.c
@@ -14,6 +14,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
  
  #define PHY_CTRL0			0x0

  #define PHY_CTRL0_REF_SSP_EN  BIT(2)
@@ -76,11 +78,10 @@ enum imx8mpq_phy_type {
  };
  
  struct imx8mq_usb_phy {

-#if CONFIG_IS_ENABLED(CLK)
struct clk phy_clk;
-#endif
void __iomem *base;
enum imx8mpq_phy_type type;
+   struct udevice *vbus_supply;
  };
  
  static const struct udevice_id imx8mq_usb_phy_of_match[] = {

@@ -172,16 +173,24 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
  {
struct udevice *dev = usb_phy->dev;
struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
+   int ret;
u32 value;



int ret; goes below u32 value (nitpick)


-#if CONFIG_IS_ENABLED(CLK)
-   int ret;
-   ret = clk_enable(_phy->phy_clk);
-   if (ret) {
-   printf("Failed to enable usb phy clock\n");
-   return ret;
+   if (CONFIG_IS_ENABLED(CLK)) {
+   ret = clk_enable(_phy->phy_clk);
+   if (ret) {
+   printf("Failed to enable usb phy clock\n");
+   return ret;
+   }
+   }
+
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
+   ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, 
true);
+   if (ret && ret != -ENOSYS) {
+   dev_err(dev, "Failed to enable VBUS regulator: %d\n", 
ret);
+   goto err;
+   }
}
-#endif
  
  	/* Disable rx term override */

value = readl(imx_phy->base + PHY_CTRL6);
@@ -189,12 +198,17 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
writel(value, imx_phy->base + PHY_CTRL6);
  
  	return 0;

+
+err:
+   clk_disable(_phy->phy_clk);
+   return ret;
  }
  
  static int imx8mq_usb_phy_power_off(struct phy *usb_phy)

  {
struct udevice *dev = usb_phy->dev;
struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
+   int ret;
u32 value;


DTTO


/* Override rx term to be 0 */
@@ -202,9 +216,16 @@ static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
value |= PHY_CTRL6_RXTERM_OVERRIDE_SEL;
writel(value, imx_phy->base + PHY_CTRL6);
  
-#if CONFIG_IS_ENABLED(CLK)

-   clk_disable(_phy->phy_clk);
-#endif
+   if (CONFIG_IS_ENABLED(CLK))
+   clk_disable(_phy->phy_clk);


It would really be good to have this in two patches, i.e. the clock 
clean up first, and the regulator addition second.


[PATCH v5] phy: phy-imx8mq-usb: add vbus regulator support

2023-07-12 Thread Tim Harvey
Add support for enabling and disabling vbus-supply regulator found
on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.

While we are at it replace '#if CONFIG_IS_ENABLED(CLK)' with
'if (CONFIG_IS_ENABLED(CLK))' as a cleanup.

Signed-off-by: Tim Harvey 
Reviewed-by: Adam Ford 
Reviewed-by: Marek Vasut 
---
v5:
 - remove #if CONFIG_IS_ENABLED around struct members
   (you can not conditionally include if using if (CONFIG_IS_ENABLED(foo)) )
 - replace clk '#if CONFIG_IS_ENABLED(CLK)' with 'if (CONFIG_IS_ENABLED(CLK))'

v4:
 - use regulator_set_enable_if_allowed to handle regulator reference
counting
   errors
 - added Marek's rb tag

v3:
 - change pr_err to dev_err
 - add #if CONFIG_IS_ENABLED around vbus_supply in struct
 - add fail path to disable clock if regulator enable failed

v2:
 - protect ret with __maybe_unused in case CONFIG_CLK and
   CONFIG_DM_REGULATOR not defined
 - add error prints on failures
 - add Adam's rb tag
---
 drivers/phy/phy-imx8mq-usb.c | 68 +---
 1 file changed, 48 insertions(+), 20 deletions(-)

diff --git a/drivers/phy/phy-imx8mq-usb.c b/drivers/phy/phy-imx8mq-usb.c
index 69f01de55538..532b0235e2bc 100644
--- a/drivers/phy/phy-imx8mq-usb.c
+++ b/drivers/phy/phy-imx8mq-usb.c
@@ -14,6 +14,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define PHY_CTRL0  0x0
 #define PHY_CTRL0_REF_SSP_EN   BIT(2)
@@ -76,11 +78,10 @@ enum imx8mpq_phy_type {
 };
 
 struct imx8mq_usb_phy {
-#if CONFIG_IS_ENABLED(CLK)
struct clk phy_clk;
-#endif
void __iomem *base;
enum imx8mpq_phy_type type;
+   struct udevice *vbus_supply;
 };
 
 static const struct udevice_id imx8mq_usb_phy_of_match[] = {
@@ -172,16 +173,24 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
 {
struct udevice *dev = usb_phy->dev;
struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
+   int ret;
u32 value;
 
-#if CONFIG_IS_ENABLED(CLK)
-   int ret;
-   ret = clk_enable(_phy->phy_clk);
-   if (ret) {
-   printf("Failed to enable usb phy clock\n");
-   return ret;
+   if (CONFIG_IS_ENABLED(CLK)) {
+   ret = clk_enable(_phy->phy_clk);
+   if (ret) {
+   printf("Failed to enable usb phy clock\n");
+   return ret;
+   }
+   }
+
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
+   ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, 
true);
+   if (ret && ret != -ENOSYS) {
+   dev_err(dev, "Failed to enable VBUS regulator: %d\n", 
ret);
+   goto err;
+   }
}
-#endif
 
/* Disable rx term override */
value = readl(imx_phy->base + PHY_CTRL6);
@@ -189,12 +198,17 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
writel(value, imx_phy->base + PHY_CTRL6);
 
return 0;
+
+err:
+   clk_disable(_phy->phy_clk);
+   return ret;
 }
 
 static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
 {
struct udevice *dev = usb_phy->dev;
struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
+   int ret;
u32 value;
 
/* Override rx term to be 0 */
@@ -202,9 +216,16 @@ static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
value |= PHY_CTRL6_RXTERM_OVERRIDE_SEL;
writel(value, imx_phy->base + PHY_CTRL6);
 
-#if CONFIG_IS_ENABLED(CLK)
-   clk_disable(_phy->phy_clk);
-#endif
+   if (CONFIG_IS_ENABLED(CLK))
+   clk_disable(_phy->phy_clk);
+
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
+   ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, 
false);
+   if (ret && ret != -ENOSYS) {
+   dev_err(dev, "Failed to disable VBUS regulator: %d\n", 
ret);
+   return ret;
+   }
+   }
 
return 0;
 }
@@ -224,6 +245,7 @@ struct phy_ops imx8mq_usb_phy_ops = {
 int imx8mq_usb_phy_probe(struct udevice *dev)
 {
struct imx8mq_usb_phy *priv = dev_get_priv(dev);
+   int ret;
 
priv->type = dev_get_driver_data(dev);
priv->base = dev_read_addr_ptr(dev);
@@ -231,16 +253,22 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
if (!priv->base)
return -EINVAL;
 
-#if CONFIG_IS_ENABLED(CLK)
-   int ret;
+   if (CONFIG_IS_ENABLED(CLK)) {
+   ret = clk_get_by_name(dev, "phy", >phy_clk);
+   if (ret) {
+   printf("Failed to get usb phy clock\n");
+   return ret;
+   }
+   }
 
-   /* Assigned clock already set clock */
-   ret = clk_get_by_name(dev, "phy", >phy_clk);
-   if (ret) {
-   printf("Failed to get usb phy clock\n");
-   return ret;
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
+   ret = 

Re: [PATCH v2 0/4] riscv: Initial support for Lichee PI 4A board

2023-07-12 Thread Guo Ren
For this series:

Reviewed-by: Guo Ren 

On Sat, Jul 8, 2023 at 7:25 AM Yixun Lan  wrote:
>
> Sipeed's Lichee PI 4A board is based on T-HEAD's TH1520 SoC which consists of
> quad core XuanTie C910 CPU, plus one C906 CPU and one E902 CPU.
>
> In this series, we add a basic device tree, including UART CPU, PLIC, make it
> capable of running into a serial console.
>
> Please note that, we rely on pre shipped vendor u-boot which run in M-Mode to
> chain load this mainline u-boot either via eMMC storage or from tftp, thus the
> pinctrl and clock setting are not implemented in this series, which certainly
> can be improved later accordingly.
>
> Also the device tree is borrowed from kernel which is already accepted by 
> kernel
> upstream [1].
>
> [1] https://lore.kernel.org/all/20230617161529.2092-1-jszh...@kernel.org
>
> Changes since PATCH v1:
>   - sync device tree with mainline kernel's version
>   - update docs and also fix the build error
>   - fix missing  header file
>
> PATCH v1:
>   https://lore.kernel.org/all/20230526124107.894-1-d...@gentoo.org
>
> Yixun Lan (4):
>   riscv: t-head: licheepi4a: initial support added
>   riscv: dts: t-head: Add basic device tree for Sipeed Lichee PI 4A
> board
>   configs: th1520_lpi4a_defconfig: Add initial config
>   doc: t-head: lpi4a: document Lichee PI 4A board
>
>  arch/riscv/Kconfig  |   5 +
>  arch/riscv/dts/Makefile |   1 +
>  arch/riscv/dts/th1520-lichee-module-4a.dtsi |  34 ++
>  arch/riscv/dts/th1520-lichee-pi-4a.dts  |  32 ++
>  arch/riscv/dts/th1520.dtsi  | 406 
>  board/thead/th1520_lpi4a/Kconfig|  42 ++
>  board/thead/th1520_lpi4a/MAINTAINERS|   7 +
>  board/thead/th1520_lpi4a/Makefile   |   5 +
>  board/thead/th1520_lpi4a/board.c|  15 +
>  configs/th1520_lpi4a_defconfig  |  82 
>  doc/board/index.rst |   1 +
>  doc/board/thead/index.rst   |   9 +
>  doc/board/thead/lpi4a.rst   | 129 +++
>  include/configs/th1520_lpi4a.h  |  22 ++
>  14 files changed, 790 insertions(+)
>  create mode 100644 arch/riscv/dts/th1520-lichee-module-4a.dtsi
>  create mode 100644 arch/riscv/dts/th1520-lichee-pi-4a.dts
>  create mode 100644 arch/riscv/dts/th1520.dtsi
>  create mode 100644 board/thead/th1520_lpi4a/Kconfig
>  create mode 100644 board/thead/th1520_lpi4a/MAINTAINERS
>  create mode 100644 board/thead/th1520_lpi4a/Makefile
>  create mode 100644 board/thead/th1520_lpi4a/board.c
>  create mode 100644 configs/th1520_lpi4a_defconfig
>  create mode 100644 doc/board/thead/index.rst
>  create mode 100644 doc/board/thead/lpi4a.rst
>  create mode 100644 include/configs/th1520_lpi4a.h
>
> --
> 2.39.3
>


-- 
Best Regards
 Guo Ren


Re: [PATCH 2/2] dt-bindings: add device tree bindings for mxl-8611x PHY

2023-07-12 Thread Marek Vasut

On 7/13/23 02:12, Nate Drude wrote:

Hi Marek,

On 7/12/23 5:16 PM, Marek Vasut wrote:
[You don't often get email from marek.va...@mailbox.org. Learn why 
this is important at https://aka.ms/LearnAboutSenderIdentification ]


On 7/12/23 22:50, Nate Drude wrote:

The MXL8611X driver has custom bindings for configuring the LEDs
and RGMII internal delays. This patch adds the documentation and
defines necessary to configure it from the device tree.

Signed-off-by: Nate Drude 


Is this binding document picked from Linux ?

If so, include commit ID in the commit message.

If not, why ?


There is no driver pushed to Linux yet. There is a vendor driver that is 
not ready for mainline.


The vendor driver does not support any device tree configuration. Thus, 
these bindings are new and are aligned with the Variscite kernel, which 
includes a patched version of the vendor driver: 
https://github.com/varigit/linux-imx/compare/fb80db2fc3ba1ccb3c7503495c4544ecc7d3514b...6220bd57680b1fb1951441271f396f0e5889d868


The defines in mxl-8611x.h are copied from the vendor driver.


Please send those bindings to devicetree@ so they get reviewed by DT 
maintainers too. Otherwise U-Boot might end up using divergent bindings 
from what is going to land in Linux. Then add a link into the patch to 
the submission at lore.kernel.org .


Thanks


Re: [PATCH 1/2] phy: mxl-8611x: add driver for MaxLinear mxl-8611x PHYs

2023-07-12 Thread Nate Drude

Hi Marek,

On 7/12/23 5:15 PM, Marek Vasut wrote:
[You don't often get email from marek.va...@mailbox.org. Learn why this 
is important at https://aka.ms/LearnAboutSenderIdentification ]


On 7/12/23 22:48, Nate Drude wrote:

The MxL86110 is a low power Ethernet PHY transceiver integrated
circuit following the IEEE 802.3 [1] standard. It offers a
cost-optimized solution that is well-suited for routers,
switches, and home gateways. It performs data transmission on
an Ethernet twisted pair copper cable of category CAT5e or higher.
The MxL86110 supports 1000, 100, and 10 Mbit/s data rates.

The current driver implementation supports:
- configuring rgmii from the device tree
- configuring the LEDs from the device tree
- reading extended registers using the mdio command, e.g.:
 => mdio rx ethernet@428a 0xa00c
 Reading from bus ethernet@428a
 PHY at address 0:
 40972 - 0x2600

Signed-off-by: Nate Drude 
---
  drivers/net/phy/Kconfig |   5 +
  drivers/net/phy/Makefile    |   1 +
  drivers/net/phy/mxl-8611x.c | 271 
  3 files changed, 277 insertions(+)
  create mode 100644 drivers/net/phy/mxl-8611x.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 24158776f52..0fc0fb2c5bf 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -220,6 +220,11 @@ config PHY_MICREL_KSZ8XXX

  endif # PHY_MICREL

+config PHY_MXL8611X
+    bool "MaxLinear MXL8611X Ethernet PHYs"
+    help
+    Add support for configuring MaxLinear MXL8611X Ethernet PHYs.


Probably better just "Support for MaxLinear MXL8611X Ethernet PHYs." in
the help text.


  config PHY_MSCC
  bool "Microsemi Corp Ethernet PHYs support"

diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 85d17f109cd..b3f4d75936c 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_PHY_MARVELL_10G) += marvell10g.o
  obj-$(CONFIG_PHY_MICREL_KSZ8XXX) += micrel_ksz8xxx.o
  obj-$(CONFIG_PHY_MICREL_KSZ90X1) += micrel_ksz90x1.o
  obj-$(CONFIG_PHY_MESON_GXL) += meson-gxl.o
+obj-$(CONFIG_PHY_MXL8611X) += mxl-8611x.o
  obj-$(CONFIG_PHY_NATSEMI) += natsemi.o
  obj-$(CONFIG_PHY_NXP_C45_TJA11XX) += nxp-c45-tja11xx.o
  obj-$(CONFIG_PHY_NXP_TJA11XX) += nxp-tja11xx.o
diff --git a/drivers/net/phy/mxl-8611x.c b/drivers/net/phy/mxl-8611x.c
new file mode 100644
index 000..467edc5bb5f
--- /dev/null
+++ b/drivers/net/phy/mxl-8611x.c
@@ -0,0 +1,271 @@
+// SPDX-License-Identifier: GPL-2.0+
+/**
+ *  Driver for MaxLinear MXL861100 Ethernet PHY


611x ... you have either 1 or 0 duplicated above.


+ * Copyright 2023 Variscite Ltd.
+ * Copyright 2023 MaxLinear Inc.
+ * Author: Nate Drude 
+ */
+#include 
+#include 
+#include 
+#include 
+
+/* PHY IDs */
+#define PHY_ID_MXL86110    0xC1335580
+#define PHY_ID_MXL86111    0xC1335588
+
+/* required to access extended registers */
+#define MXL8611X_EXTD_REG_ADDR_OFFSET    0x1E
+#define MXL8611X_EXTD_REG_ADDR_DATA    0x1F
+
+/* RGMII register */
+#define MXL8611X_EXT_RGMII_CFG1_REG    0xA003
+#define MXL8611X_EXT_RGMII_CFG1_NO_DELAY    0
+
+#define MXL8611X_EXT_RGMII_CFG1_RX_DELAY_MASK    GENMASK(13, 10)
+#define MXL8611X_EXT_RGMII_CFG1_TX_1G_DELAY_MASK    GENMASK(3, 0)
+#define MXL8611X_EXT_RGMII_CFG1_TX_10MB_100MB_DELAY_MASK
GENMASK(7, 4)

+
+/* LED registers and defines */
+#define MXL8611X_LED0_CFG_REG    0xA00C
+#define MXL8611X_LED1_CFG_REG    0xA00D
+#define MXL8611X_LED2_CFG_REG    0xA00E
+
+/**
+ * struct mxl8611x_cfg_reg_map - map a config value to aregister value
+ * @cfg    value in device configuration
+ * @reg    value in the register
+ */
+struct mxl8611x_cfg_reg_map {
+    int cfg;
+    int reg;
+};
+
+static const struct mxl8611x_cfg_reg_map mxl8611x_rgmii_delays[] = {
+    { 0, 0 },
+    { 150, 1 },


Is this like n * 150 expanded into a table here ?
Please drop.


+    { 300, 2 },
+    { 450, 3 },
+    { 600, 4 },
+    { 750, 5 },
+    { 900, 6 },
+    { 1050, 7 },
+    { 1200, 8 },
+    { 1350, 9 },
+    { 1500, 10 },
+    { 1650, 11 },
+    { 1800, 12 },
+    { 1950, 13 },
+    { 2100, 14 },
+    { 2250, 15 },
+    { 0, 0 } // Marks the end of the array
+};
+
+static int mxl8611x_lookup_reg_value(const struct mxl8611x_cfg_reg_map
*tbl,
+ const int cfg, int *reg)
+{
+    size_t i;
+
+    for (i = 0; i == 0 || tbl[i].cfg; i++) {
+    if (tbl[i].cfg == cfg) {
+    *reg = tbl[i].reg;
+    return 0;
+    }
+    }


value / 150 instead of this ?


+    return -EINVAL;
+}
+
+static u16 mxl8611x_ext_read(struct phy_device *phydev, const u32 
regnum)

+{
+    u16 val;
+
+    phy_write(phydev, MDIO_DEVAD_NONE, MXL8611X_EXTD_REG_ADDR_OFFSET,
regnum);
+    val = phy_read(phydev, MDIO_DEVAD_NONE, 
MXL8611X_EXTD_REG_ADDR_DATA);


Is this some phy_read_mmd() reimplementation here ?


+    debug("%s: MXL86110@0x%x 

Re: [PATCH 2/2] dt-bindings: add device tree bindings for mxl-8611x PHY

2023-07-12 Thread Nate Drude

Hi Marek,

On 7/12/23 5:16 PM, Marek Vasut wrote:
[You don't often get email from marek.va...@mailbox.org. Learn why this 
is important at https://aka.ms/LearnAboutSenderIdentification ]


On 7/12/23 22:50, Nate Drude wrote:

The MXL8611X driver has custom bindings for configuring the LEDs
and RGMII internal delays. This patch adds the documentation and
defines necessary to configure it from the device tree.

Signed-off-by: Nate Drude 


Is this binding document picked from Linux ?

If so, include commit ID in the commit message.

If not, why ?


There is no driver pushed to Linux yet. There is a vendor driver that is 
not ready for mainline.


The vendor driver does not support any device tree configuration. Thus, 
these bindings are new and are aligned with the Variscite kernel, which 
includes a patched version of the vendor driver: 
https://github.com/varigit/linux-imx/compare/fb80db2fc3ba1ccb3c7503495c4544ecc7d3514b...6220bd57680b1fb1951441271f396f0e5889d868


The defines in mxl-8611x.h are copied from the vendor driver.

Thanks,
Nate


Re: [PATCH 2/2] dt-bindings: add device tree bindings for mxl-8611x PHY

2023-07-12 Thread Nate Drude




On 7/12/23 3:50 PM, Nate Drude wrote:

The MXL8611X driver has custom bindings for configuring the LEDs
and RGMII internal delays. This patch adds the documentation and
defines necessary to configure it from the device tree.

Signed-off-by: Nate Drude 
---
  .../net/phy/mxl-8611x.txt | 37 +++
  include/dt-bindings/net/mxl-8611x.h   | 27 ++
  2 files changed, 64 insertions(+)
  create mode 100644 doc/device-tree-bindings/net/phy/mxl-8611x.txt
  create mode 100644 include/dt-bindings/net/mxl-8611x.h

diff --git a/doc/device-tree-bindings/net/phy/mxl-8611x.txt 
b/doc/device-tree-bindings/net/phy/mxl-8611x.txt

new file mode 100644
index 000..462fdf61666
--- /dev/null
+++ b/doc/device-tree-bindings/net/phy/mxl-8611x.txt
@@ -0,0 +1,37 @@
+* MaxLinear MXL8611x PHY Device Tree binding
+
+Required properties:
+- reg: PHY address
+
+Optional properties:
+- mxl-8611x,ledN_cfg: Register configuration for COM_EXT_LED0_CFG,
+    COM_EXT_LED1_CFG, and COM_EXT_LED2_CFG
+- mxl-8611x,rx-internal-delay-ps: RGMII RX Clock Delay used only when 
PHY operates

+    in RGMII mode with internal delay (phy-mode is 'rgmii-id' or
+    'rgmii-rxid') in pico-seconds.
+- mxl-8611x,tx-internal-delay-ps-100m: RGMII TX Clock Delay used only 
when PHY operates

+    in 10/100M RGMII mode with internal delay (phy-mode is 'rgmii-id' or
+    'rgmii-txid') in pico-seconds.
+- mxl-8611x,tx-internal-delay-ps-1g: RGMII TX Clock Delay used only 
when PHY operates

+    in 1G RGMII mode with internal delay (phy-mode is 'rgmii-id' or
+    'rgmii-txid') in pico-seconds.
+
+Example:
+
+    ethernet-phy@0 {
+    reg = <0>;
+
+    mxl-8611x,led0_cfg = <(
+    MXL8611X_LEDX_CFG_LINK_UP_RX_ACT_ON |
+    MXL8611X_LEDX_CFG_LINK_UP_TX_ACT_ON |
+    MXL8611X_LEDX_CFG_TRAFFIC_ACT_BLINK_IND
+    )>;
+    mxl-8611x,led1_cfg = <(
+    MXL8611X_LEDX_CFG_LINK_UP_10MB_ON |
+    MXL8611X_LEDX_CFG_LINK_UP_100MB_ON |
+    MXL8611X_LEDX_CFG_LINK_UP_1GB_ON
+    )>;
+    mxl-8611x,rx-internal-delay-ps = <0>;
+    mxl-8611x,tx-internal-delay-ps-100m = <2250>;
+    mxl-8611x,tx-internal-delay-ps-1g = <150>;
+    };
diff --git a/include/dt-bindings/net/mxl-8611x.h 
b/include/dt-bindings/net/mxl-8611x.h

new file mode 100644
index 000..cb0ec0f8bd0
--- /dev/null
+++ b/include/dt-bindings/net/mxl-8611x.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
+/*
+ * Device Tree constants for MaxLinear MXL8611x PHYs
+ *
+ * Copyright 2023 Variscite Ltd.
+ * Copyright 2023 MaxLinear Inc.
+ */
+
+#ifndef _DT_BINDINGS_MXL_8611X_H
+#define _DT_BINDINGS_MXL_8611X_H
+
+#define MXL8611X_LEDX_CFG_TRAFFIC_ACT_BLINK_IND    (1 << 13)
+#define MXL8611X_LEDX_CFG_LINK_UP_FULL_DUPLEX_ON    (1 << 12)
+#define MXL8611X_LEDX_CFG_LINK_UP_HALF_DUPLEX_ON    (1 << 11)
+#define MXL8611X_LEDX_CFG_LINK_UP_TX_ACT_ON    (1 << 10)
+#define MXL8611X_LEDX_CFG_LINK_UP_RX_ACT_ON    (1 << 9)
+#define MXL8611X_LEDX_CFG_LINK_UP_TX_ON    (1 << 8)
+#define MXL8611X_LEDX_CFG_LINK_UP_RX_ON    (1 << 7)
+#define MXL8611X_LEDX_CFG_LINK_UP_1GB_ON    (1 << 6)
+#define MXL8611X_LEDX_CFG_LINK_UP_100MB_ON    (1 << 5)
+#define MXL8611X_LEDX_CFG_LINK_UP_10MB_ON    (1 << 4)
+#define MXL8611X_LEDX_CFG_LINK_UP_COLLISION    (1 << 3)
+#define MXL8611X_LEDX_CFG_LINK_UP_1GB_BLINK    (1 << 2)
+#define MXL8611X_LEDX_CFG_LINK_UP_100MB_BLINK    (1 << 1)
+#define MXL8611X_LEDX_CFG_LINK_UP_10MB_BLINK    (1 << 0)
+
+#endif


I mistakenly sent the mxl-8611x patch series In-Reply-To my previous 
adin patch.


Is this okay, or should I resend the mxl-8611x patches?

Thanks,
Nate


RE: [PATCH] mmc:Remove thr legacy mode clock setting operation

2023-07-12 Thread Jaehoon Chung
Hi,

> -Original Message-
> From: 869470...@qq.com <869470...@qq.com>
> Sent: Wednesday, July 12, 2023 4:19 PM
> To: u-boot@lists.denx.de
> Cc: peng@nxp.com; jh80.ch...@samsung.com; xiefei 
> Subject: [PATCH] mmc:Remove thr legacy mode clock setting operation
> 
> From: xiefei 
> 
> Due to the need to read the register value before
> switching to hs mode, the standard protocol does
> not explicitly specify that the setting before
> switching to hs mode is in legacy mode. Therefore,
> the code at this point may cause communication
> abnormalities between the host and card

Thanks for resend patch after updated.
Which board and driver does it occur the issue? 

Best Regards,
Jaehoon Chung

> 
> Signed-off-by: xiefei 
> ---
>  drivers/mmc/mmc.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 1af6af82e6..96cc7e7332 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -2136,9 +2136,7 @@ static int mmc_select_mode_and_width(struct mmc *mmc, 
> uint card_caps)
>   mmc->selected_mode == MMC_HS_400 ||
>   mmc->selected_mode == MMC_HS_400_ES)
>   mmc_set_card_speed(mmc, MMC_HS, true);
> - else
>  #endif
> - mmc_set_clock(mmc, mmc->legacy_speed, MMC_CLK_ENABLE);
> 
>   for_each_mmc_mode_by_pref(card_caps, mwt) {
>   for_each_supported_width(card_caps & mwt->widths,
> --
> 2.17.1




Re: [PATCH 2/2] dt-bindings: add device tree bindings for mxl-8611x PHY

2023-07-12 Thread Marek Vasut

On 7/12/23 22:50, Nate Drude wrote:

The MXL8611X driver has custom bindings for configuring the LEDs
and RGMII internal delays. This patch adds the documentation and
defines necessary to configure it from the device tree.

Signed-off-by: Nate Drude 


Is this binding document picked from Linux ?

If so, include commit ID in the commit message.

If not, why ?


Re: [PATCH 1/2] phy: mxl-8611x: add driver for MaxLinear mxl-8611x PHYs

2023-07-12 Thread Marek Vasut

On 7/12/23 22:48, Nate Drude wrote:

The MxL86110 is a low power Ethernet PHY transceiver integrated
circuit following the IEEE 802.3 [1] standard. It offers a
cost-optimized solution that is well-suited for routers,
switches, and home gateways. It performs data transmission on
an Ethernet twisted pair copper cable of category CAT5e or higher.
The MxL86110 supports 1000, 100, and 10 Mbit/s data rates.

The current driver implementation supports:
- configuring rgmii from the device tree
- configuring the LEDs from the device tree
- reading extended registers using the mdio command, e.g.:
     => mdio rx ethernet@428a 0xa00c
     Reading from bus ethernet@428a
     PHY at address 0:
     40972 - 0x2600

Signed-off-by: Nate Drude 
---
  drivers/net/phy/Kconfig |   5 +
  drivers/net/phy/Makefile    |   1 +
  drivers/net/phy/mxl-8611x.c | 271 
  3 files changed, 277 insertions(+)
  create mode 100644 drivers/net/phy/mxl-8611x.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 24158776f52..0fc0fb2c5bf 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -220,6 +220,11 @@ config PHY_MICREL_KSZ8XXX

  endif # PHY_MICREL

+config PHY_MXL8611X
+    bool "MaxLinear MXL8611X Ethernet PHYs"
+    help
+    Add support for configuring MaxLinear MXL8611X Ethernet PHYs.


Probably better just "Support for MaxLinear MXL8611X Ethernet PHYs." in 
the help text.



  config PHY_MSCC
  bool "Microsemi Corp Ethernet PHYs support"

diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 85d17f109cd..b3f4d75936c 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_PHY_MARVELL_10G) += marvell10g.o
  obj-$(CONFIG_PHY_MICREL_KSZ8XXX) += micrel_ksz8xxx.o
  obj-$(CONFIG_PHY_MICREL_KSZ90X1) += micrel_ksz90x1.o
  obj-$(CONFIG_PHY_MESON_GXL) += meson-gxl.o
+obj-$(CONFIG_PHY_MXL8611X) += mxl-8611x.o
  obj-$(CONFIG_PHY_NATSEMI) += natsemi.o
  obj-$(CONFIG_PHY_NXP_C45_TJA11XX) += nxp-c45-tja11xx.o
  obj-$(CONFIG_PHY_NXP_TJA11XX) += nxp-tja11xx.o
diff --git a/drivers/net/phy/mxl-8611x.c b/drivers/net/phy/mxl-8611x.c
new file mode 100644
index 000..467edc5bb5f
--- /dev/null
+++ b/drivers/net/phy/mxl-8611x.c
@@ -0,0 +1,271 @@
+// SPDX-License-Identifier: GPL-2.0+
+/**
+ *  Driver for MaxLinear MXL861100 Ethernet PHY


611x ... you have either 1 or 0 duplicated above.


+ * Copyright 2023 Variscite Ltd.
+ * Copyright 2023 MaxLinear Inc.
+ * Author: Nate Drude 
+ */
+#include 
+#include 
+#include 
+#include 
+
+/* PHY IDs */
+#define PHY_ID_MXL86110    0xC1335580
+#define PHY_ID_MXL86111    0xC1335588
+
+/* required to access extended registers */
+#define MXL8611X_EXTD_REG_ADDR_OFFSET    0x1E
+#define MXL8611X_EXTD_REG_ADDR_DATA    0x1F
+
+/* RGMII register */
+#define MXL8611X_EXT_RGMII_CFG1_REG    0xA003
+#define MXL8611X_EXT_RGMII_CFG1_NO_DELAY    0
+
+#define MXL8611X_EXT_RGMII_CFG1_RX_DELAY_MASK    GENMASK(13, 10)
+#define MXL8611X_EXT_RGMII_CFG1_TX_1G_DELAY_MASK    GENMASK(3, 0)
+#define MXL8611X_EXT_RGMII_CFG1_TX_10MB_100MB_DELAY_MASK    GENMASK(7, 4)
+
+/* LED registers and defines */
+#define MXL8611X_LED0_CFG_REG    0xA00C
+#define MXL8611X_LED1_CFG_REG    0xA00D
+#define MXL8611X_LED2_CFG_REG    0xA00E
+
+/**
+ * struct mxl8611x_cfg_reg_map - map a config value to aregister value
+ * @cfg    value in device configuration
+ * @reg    value in the register
+ */
+struct mxl8611x_cfg_reg_map {
+    int cfg;
+    int reg;
+};
+
+static const struct mxl8611x_cfg_reg_map mxl8611x_rgmii_delays[] = {
+    { 0, 0 },
+    { 150, 1 },


Is this like n * 150 expanded into a table here ?
Please drop.


+    { 300, 2 },
+    { 450, 3 },
+    { 600, 4 },
+    { 750, 5 },
+    { 900, 6 },
+    { 1050, 7 },
+    { 1200, 8 },
+    { 1350, 9 },
+    { 1500, 10 },
+    { 1650, 11 },
+    { 1800, 12 },
+    { 1950, 13 },
+    { 2100, 14 },
+    { 2250, 15 },
+    { 0, 0 } // Marks the end of the array
+};
+
+static int mxl8611x_lookup_reg_value(const struct mxl8611x_cfg_reg_map 
*tbl,

+ const int cfg, int *reg)
+{
+    size_t i;
+
+    for (i = 0; i == 0 || tbl[i].cfg; i++) {
+    if (tbl[i].cfg == cfg) {
+    *reg = tbl[i].reg;
+    return 0;
+    }
+    }


value / 150 instead of this ?


+    return -EINVAL;
+}
+
+static u16 mxl8611x_ext_read(struct phy_device *phydev, const u32 regnum)
+{
+    u16 val;
+
+    phy_write(phydev, MDIO_DEVAD_NONE, MXL8611X_EXTD_REG_ADDR_OFFSET, 
regnum);

+    val = phy_read(phydev, MDIO_DEVAD_NONE, MXL8611X_EXTD_REG_ADDR_DATA);


Is this some phy_read_mmd() reimplementation here ?

+    debug("%s: MXL86110@0x%x 0x%x=0x%x\n", __func__, phydev->addr, 
regnum, val);

+
+    return val;
+}
+
+static int mxl8611x_ext_write(struct phy_device *phydev, const u32 
regnum, const u16 val)

+{
+    

Re: [PATCH] buildman: Switch ARC toolchain to the upstream version

2023-07-12 Thread Tom Rini
On Fri, Jul 07, 2023 at 10:04:53PM +0100, Alexey Brodkin wrote:

> Back in the day we relied a lot on Synopsys own build of the GNU tools
> for ARC processors, but since then we worked hard on getting all our changes
> upstream and for a couple of years now we have ARCompact (AKA ARCv1)
> and ARCv2 processors supported very well in upstream GCC, Binutils, GDB etc.
> 
> And so there's no need to use Synopsys forks any longer, thus we remove
> all the references to that form and use upstream components as majority
> of other architectures in U-Boot.
> 
> Thanks to Tom for pointing to that left-over!
> 
> Signed-off-by: Alexey Brodkin 
> Cc: Simon Glass 
> Cc: Tom Rini 
> Reviewed-by: Tom Rini 
> Reviewed-by: Simon Glass 

So I tested this locally and I have a problem:
Building current source for 1 boards (1 thread, 16 jobs per thread)
   arc:  +   hsdk_4xd
+(hsdk_4xd) arc-linux-gcc: error: unrecognized argument in option 
'-mcpu=hs4x_rel31'
+(hsdk_4xd) arc-linux-gcc: note: valid arguments to '-mcpu=' are: arc600 
arc600_mul32x16 arc600_mul64 arc600_norm arc601 arc601_mul32x16 arc601_mul64 
arc601_norm arc700 arcem archs em em4 em4_dmips em4_fpuda em4_fpus em_mini hs 
hs34 hs38 hs38_linux hs4x hs4xd nps400 quarkse_em
+(hsdk_4xd) make[2]: *** [scripts/Makefile.autoconf:82: u-boot.cfg] Error 1
+(hsdk_4xd) make[2]: *** [scripts/Makefile.autoconf:52: 
include/autoconf.mk.dep] Error 1
+(hsdk_4xd) make[1]: *** No rule to make target 'include/config/auto.conf', 
needed by 'include/config/uboot.release'.  Stop.
+(hsdk_4xd) make: *** [Makefile:177: sub-make] Error 2

I assume it's a straight-forward fix.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v4] phy: phy-imx8mq-usb: add vbus regulator support

2023-07-12 Thread Tom Rini
On Wed, Jul 12, 2023 at 11:40:37PM +0200, Marek Vasut wrote:
> On 7/12/23 20:30, Tim Harvey wrote:
> > On Wed, Jul 12, 2023 at 10:25 AM Marek Vasut  wrote:
> > > 
> > > On 7/12/23 18:29, Tim Harvey wrote:
> > > > On Wed, Jul 12, 2023 at 8:10 AM Tim Harvey  
> > > > wrote:
> > > > > 
> > > > > On Wed, Jul 12, 2023 at 2:15 AM Marek Vasut  wrote:
> > > > > > 
> > > > > > On 7/11/23 22:13, Tim Harvey wrote:
> > > > > > > On Mon, Jul 10, 2023 at 4:18 PM Marek Vasut  wrote:
> > > > > > > > 
> > > > > > > > On 7/11/23 00:49, Tim Harvey wrote:
> > > > > > > > > Add support for enabling and disabling vbus-supply regulator 
> > > > > > > > > found
> > > > > > > > > on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.
> > > > > > > > > 
> > > > > > > > > Signed-off-by: Tim Harvey 
> > > > > > > > > Reviewed-by: Adam Ford 
> > > > > > > > > Reviewed-by: Marek Vasut 
> > > > > > > > > ---
> > > > > > > > > v4:
> > > > > > > > >  - use regulator_set_enable_if_allowed to handle 
> > > > > > > > > regulator reference counting
> > > > > > > > >errors
> > > > > > > > >  - added Marek's rb tag
> > > > > > > > > 
> > > > > > > > > v3:
> > > > > > > > >  - change pr_err to dev_err
> > > > > > > > >  - add #if CONFIG_IS_ENABLED around vbus_supply in struct
> > > > > > > > >  - add fail path to disable clock if regulator enable 
> > > > > > > > > failed
> > > > > > > > > 
> > > > > > > > > v2:
> > > > > > > > >  - protect ret with __maybe_unused in case CONFIG_CLK and
> > > > > > > > >CONFIG_DM_REGULATOR not defined
> > > > > > > > >  - add error prints on failures
> > > > > > > > >  - add Adam's rb tag
> > > > > > > > > ---
> > > > > > > > >  drivers/phy/phy-imx8mq-usb.c | 39 
> > > > > > > > > ++--
> > > > > > > > >  1 file changed, 37 insertions(+), 2 deletions(-)
> > > > > > > > > 
> > > > > > > > > diff --git a/drivers/phy/phy-imx8mq-usb.c 
> > > > > > > > > b/drivers/phy/phy-imx8mq-usb.c
> > > > > > > > > index 69f01de55538..6cbcb2338cfe 100644
> > > > > > > > > --- a/drivers/phy/phy-imx8mq-usb.c
> > > > > > > > > +++ b/drivers/phy/phy-imx8mq-usb.c
> > > > > > > > > @@ -14,6 +14,8 @@
> > > > > > > > >  #include 
> > > > > > > > >  #include 
> > > > > > > > >  #include 
> > > > > > > > > +#include 
> > > > > > > > > +#include 
> > > > > > > > > 
> > > > > > > > >  #define PHY_CTRL0   0x0
> > > > > > > > >  #define PHY_CTRL0_REF_SSP_ENBIT(2)
> > > > > > > > > @@ -81,6 +83,9 @@ struct imx8mq_usb_phy {
> > > > > > > > >  #endif
> > > > > > > > >  void __iomem *base;
> > > > > > > > >  enum imx8mpq_phy_type type;
> > > > > > > > > +#if CONFIG_IS_ENABLED(DM_REGULATOR)
> > > > > > > > > + struct udevice *vbus_supply;
> > > > > > > > > +#endif
> > > > > > > > >  };
> > > > > > > > > 
> > > > > > > > >  static const struct udevice_id imx8mq_usb_phy_of_match[] 
> > > > > > > > > = {
> > > > > > > > > @@ -172,10 +177,10 @@ static int 
> > > > > > > > > imx8mq_usb_phy_power_on(struct phy *usb_phy)
> > > > > > > > >  {
> > > > > > > > >  struct udevice *dev = usb_phy->dev;
> > > > > > > > >  struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> > > > > > > > > + __maybe_unused int ret;
> > > > > > > > >  u32 value;
> > > > > > > > > 
> > > > > > > > >  #if CONFIG_IS_ENABLED(CLK)
> > > > > > > > > - int ret;
> > > > > > > > >  ret = clk_enable(_phy->phy_clk);
> > > > > > > > >  if (ret) {
> > > > > > > > >  printf("Failed to enable usb phy clock\n");
> > > > > > > > > @@ -183,18 +188,31 @@ static int 
> > > > > > > > > imx8mq_usb_phy_power_on(struct phy *usb_phy)
> > > > > > > > >  }
> > > > > > > > >  #endif
> > > > > > > > > 
> > > > > > > > > + if (CONFIG_IS_ENABLED(DM_REGULATOR) && 
> > > > > > > > > imx_phy->vbus_supply) {
> > > > > > > > > + ret = 
> > > > > > > > > regulator_set_enable_if_allowed(imx_phy->vbus_supply, true);
> > > > > > > > > + if (ret && ret != -ENOSYS) {
> > > > > > > > > + dev_err(dev, "Failed to enable VBUS 
> > > > > > > > > regulator: %d\n", ret);
> > > > > > > > > + goto err;
> > > > > > > > > + }
> > > > > > > > > + }
> > > > > > > > > +
> > > > > > > > >  /* Disable rx term override */
> > > > > > > > >  value = readl(imx_phy->base + PHY_CTRL6);
> > > > > > > > >  value &= ~PHY_CTRL6_RXTERM_OVERRIDE_SEL;
> > > > > > > > >  writel(value, imx_phy->base + PHY_CTRL6);
> > > > > > > > > 
> > > > > > > > >  return 0;
> > > > > > > > > +
> > > > > > > > > +err:
> > > > > > > > > + clk_disable(_phy->phy_clk);
> > > > > > > > > + return ret;
> > > > > > > > >  }
> > > > > > > > > 
> > > > > > > > >  static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
> > > > > > > > >  {
> > > > > > > > >  struct 

Re: [PATCH v4] phy: phy-imx8mq-usb: add vbus regulator support

2023-07-12 Thread Marek Vasut

On 7/12/23 20:30, Tim Harvey wrote:

On Wed, Jul 12, 2023 at 10:25 AM Marek Vasut  wrote:


On 7/12/23 18:29, Tim Harvey wrote:

On Wed, Jul 12, 2023 at 8:10 AM Tim Harvey  wrote:


On Wed, Jul 12, 2023 at 2:15 AM Marek Vasut  wrote:


On 7/11/23 22:13, Tim Harvey wrote:

On Mon, Jul 10, 2023 at 4:18 PM Marek Vasut  wrote:


On 7/11/23 00:49, Tim Harvey wrote:

Add support for enabling and disabling vbus-supply regulator found
on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.

Signed-off-by: Tim Harvey 
Reviewed-by: Adam Ford 
Reviewed-by: Marek Vasut 
---
v4:
 - use regulator_set_enable_if_allowed to handle regulator reference 
counting
   errors
 - added Marek's rb tag

v3:
 - change pr_err to dev_err
 - add #if CONFIG_IS_ENABLED around vbus_supply in struct
 - add fail path to disable clock if regulator enable failed

v2:
 - protect ret with __maybe_unused in case CONFIG_CLK and
   CONFIG_DM_REGULATOR not defined
 - add error prints on failures
 - add Adam's rb tag
---
 drivers/phy/phy-imx8mq-usb.c | 39 ++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/phy-imx8mq-usb.c b/drivers/phy/phy-imx8mq-usb.c
index 69f01de55538..6cbcb2338cfe 100644
--- a/drivers/phy/phy-imx8mq-usb.c
+++ b/drivers/phy/phy-imx8mq-usb.c
@@ -14,6 +14,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 

 #define PHY_CTRL0   0x0
 #define PHY_CTRL0_REF_SSP_ENBIT(2)
@@ -81,6 +83,9 @@ struct imx8mq_usb_phy {
 #endif
 void __iomem *base;
 enum imx8mpq_phy_type type;
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
+ struct udevice *vbus_supply;
+#endif
 };

 static const struct udevice_id imx8mq_usb_phy_of_match[] = {
@@ -172,10 +177,10 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
 {
 struct udevice *dev = usb_phy->dev;
 struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
+ __maybe_unused int ret;
 u32 value;

 #if CONFIG_IS_ENABLED(CLK)
- int ret;
 ret = clk_enable(_phy->phy_clk);
 if (ret) {
 printf("Failed to enable usb phy clock\n");
@@ -183,18 +188,31 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
 }
 #endif

+ if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
+ ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, true);
+ if (ret && ret != -ENOSYS) {
+ dev_err(dev, "Failed to enable VBUS regulator: %d\n", 
ret);
+ goto err;
+ }
+ }
+
 /* Disable rx term override */
 value = readl(imx_phy->base + PHY_CTRL6);
 value &= ~PHY_CTRL6_RXTERM_OVERRIDE_SEL;
 writel(value, imx_phy->base + PHY_CTRL6);

 return 0;
+
+err:
+ clk_disable(_phy->phy_clk);
+ return ret;
 }

 static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
 {
 struct udevice *dev = usb_phy->dev;
 struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
+ __maybe_unused int ret;
 u32 value;

 /* Override rx term to be 0 */
@@ -206,6 +224,14 @@ static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
 clk_disable(_phy->phy_clk);
 #endif

+ if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
+ ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, 
false);
+ if (ret && ret != -ENOSYS) {
+ dev_err(dev, "Failed to disable VBUS regulator: %d\n", 
ret);
+ return ret;
+ }
+ }
+
 return 0;
 }

@@ -224,6 +250,7 @@ struct phy_ops imx8mq_usb_phy_ops = {
 int imx8mq_usb_phy_probe(struct udevice *dev)
 {
 struct imx8mq_usb_phy *priv = dev_get_priv(dev);
+ __maybe_unused int ret;

 priv->type = dev_get_driver_data(dev);
 priv->base = dev_read_addr_ptr(dev);
@@ -232,7 +259,6 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
 return -EINVAL;

 #if CONFIG_IS_ENABLED(CLK)
- int ret;


I _think_ if you were to convert this #if CONFIG...() to if
(CONFIG...()), you would be able to drop the __maybe_unused . Separate
conversion patch would be better though.


Hi Marek,


Hi,


Yes, I thought about that as well and felt it should be a separate
followup cleanup patch.


Can you please send such a follow up patch ?



Yes, I'll send a follow-up today. It looks like Stefano is picking
this up from the imx tree... is that where it should be picked up or
should this be through you and the usb tree?



Marek,

It seems Stefano picked up my v2 version of this patch in his
master/next tree he's working on right now [1].


Likely this patch should be dropped from imx tree.


Stefano,

please drop from your imx/next tree: commit e445a1d7ffbd ("phy:
phy-imx8mq-usb: add vbus regulator support"). Marek will take this
through the 

Re: [PATCH] arm: dts: imx8m: add OPTEE_LOAD_ADDRESS config and tee.bin

2023-07-12 Thread Tim Harvey
On Wed, Jul 12, 2023 at 3:37 AM Stefano Babic  wrote:
>
> Hi Tim,
>
> On 22.06.23 19:30, Tim Harvey wrote:
> > Add a Kconfig for OPTEE_LOAD_ADDRESS which adds tee.bin to the
> > imx8m{m,n,p} FIT image.
> >
> > Prior to using binman for image creation the presense of tee.bin in the
> > directory would cause mkimage_fit_atf.sh to add the tee.bin node
> > to the FIT image. Once boards moved away from using
> > CONFIG_SPL_FIT_GENERATOR this was lost. This patch restores that
> > functionality. A Kconfig option is added due to binman not being
> > able to utilize env variables.
> >
>
> I tried to apply this, and the other ones
>
> https://patchwork.ozlabs.org/user/todo/uboot/?series=360558
> https://patchwork.ozlabs.org/user/todo/uboot/?series=360911
> https://patchwork.ozlabs.org/user/todo/uboot/?series=361339
>
> However, with CONFIG_OPTEE_LOAD_ADDRESS CI stucks because it is not
> configured for the "tools-only" target
> make tools-only_config tools-only
>
> Adding a dummy OPTEE_LOAD_ADDRESS to configs/tools-only_defconfig, issue
> is solved, but I bother why this is needed. Anyway, CI is not successful
> and build stops nby next check (run binman / pylint).
>
> Could you take a look ?
>

Hi Stefano,

'arm: dts: imx8m: add OPTEE_LOAD_ADDRESS config and tee.bin' should
not be required for the other patches to apply cleanly.

I guess config/tools-only_defconfig needs a '# OPTEE_LOAD_ADDRESS is
not set' because it enables SANDBOX. I don't know of a way around
adding that.

Simon, is there a way to use env in place of what I'm doing with 'arm:
dts: imx8m: add OPTEE_LOAD_ADDRESS config and tee.bin' [1] for binman?
I really hate having to add yet another obscure address config.

Best regards,

Tim
[1] 
https://patchwork.ozlabs.org/project/uboot/patch/20230622173006.3921891-1-thar...@gateworks.com/

>
> > Signed-off-by: Tim Harvey 
> > ---
> >   arch/arm/dts/imx8mm-u-boot.dtsi | 19 +++
> >   arch/arm/dts/imx8mn-u-boot.dtsi | 19 +++
> >   arch/arm/dts/imx8mp-u-boot.dtsi | 19 +++
> >   drivers/tee/optee/Kconfig   |  7 +++
> >   4 files changed, 64 insertions(+)
> >
> > diff --git a/arch/arm/dts/imx8mm-u-boot.dtsi 
> > b/arch/arm/dts/imx8mm-u-boot.dtsi
> > index a843bb851eaf..61f907a4743b 100644
> > --- a/arch/arm/dts/imx8mm-u-boot.dtsi
> > +++ b/arch/arm/dts/imx8mm-u-boot.dtsi
> > @@ -124,6 +124,21 @@
> >   type = "atf-bl31";
> >   };
> >   };
> > +
> > +#ifdef CONFIG_OPTEE_LOAD_ADDRESS
> > + tee {
> > + description = "TEE firmware";
> > + type = "firmware";
> > + arch = "arm64";
> > + compression = "none";
> > + load = ;
> > + entry = ;
> > +
> > + tee_blob: blob-ext {
> > + filename = "tee.bin";
> > + };
> > + };
> > +#endif
> >   #endif
> >
> >   binman_fip: fip {
> > @@ -154,7 +169,11 @@
> >   fdt = "fdt-SEQ";
> >   firmware = "uboot";
> >   #ifndef CONFIG_ARMV8_PSCI
> > +#ifdef CONFIG_OPTEE_LOAD_ADDRESS
> > + loadables = "atf", "tee";
> > +#else
> >   loadables = "atf";
> > +#endif
> >   #endif
> >   };
> >   };
> > diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi 
> > b/arch/arm/dts/imx8mn-u-boot.dtsi
> > index 86c9a6cd67f0..15cec4ffab44 100644
> > --- a/arch/arm/dts/imx8mn-u-boot.dtsi
> > +++ b/arch/arm/dts/imx8mn-u-boot.dtsi
> > @@ -181,6 +181,21 @@
> >   type = "atf-bl31";
> >   };
> >   };
> > +
> > +#ifdef CONFIG_OPTEE_LOAD_ADDRESS
> > + tee {
> > + description = "TEE firmware";
> > + type = "firmware";
> > + arch = "arm64";
> > + compression = "none";
> > + load = ;
> > + entry = ;
> > +
> > + tee_blob: blob-ext {
> > + filename = "tee.bin";
> > + };
> > + };
> > +#endif
> >   #endif
> >
> >   binman_fip: fip {
> > @@ -211,7 +226,11 @@
> >   fdt = "fdt-SEQ";
> >  

[PATCH 2/2] dt-bindings: add device tree bindings for mxl-8611x PHY

2023-07-12 Thread Nate Drude

The MXL8611X driver has custom bindings for configuring the LEDs
and RGMII internal delays. This patch adds the documentation and
defines necessary to configure it from the device tree.

Signed-off-by: Nate Drude 
---
 .../net/phy/mxl-8611x.txt | 37 +++
 include/dt-bindings/net/mxl-8611x.h   | 27 ++
 2 files changed, 64 insertions(+)
 create mode 100644 doc/device-tree-bindings/net/phy/mxl-8611x.txt
 create mode 100644 include/dt-bindings/net/mxl-8611x.h

diff --git a/doc/device-tree-bindings/net/phy/mxl-8611x.txt 
b/doc/device-tree-bindings/net/phy/mxl-8611x.txt

new file mode 100644
index 000..462fdf61666
--- /dev/null
+++ b/doc/device-tree-bindings/net/phy/mxl-8611x.txt
@@ -0,0 +1,37 @@
+* MaxLinear MXL8611x PHY Device Tree binding
+
+Required properties:
+- reg: PHY address
+
+Optional properties:
+- mxl-8611x,ledN_cfg: Register configuration for COM_EXT_LED0_CFG,
+   COM_EXT_LED1_CFG, and COM_EXT_LED2_CFG
+- mxl-8611x,rx-internal-delay-ps: RGMII RX Clock Delay used only when 
PHY operates

+   in RGMII mode with internal delay (phy-mode is 'rgmii-id' or
+   'rgmii-rxid') in pico-seconds.
+- mxl-8611x,tx-internal-delay-ps-100m: RGMII TX Clock Delay used only 
when PHY operates

+   in 10/100M RGMII mode with internal delay (phy-mode is 'rgmii-id' or
+   'rgmii-txid') in pico-seconds.
+- mxl-8611x,tx-internal-delay-ps-1g: RGMII TX Clock Delay used only 
when PHY operates

+   in 1G RGMII mode with internal delay (phy-mode is 'rgmii-id' or
+   'rgmii-txid') in pico-seconds.
+
+Example:
+
+   ethernet-phy@0 {
+   reg = <0>;
+
+   mxl-8611x,led0_cfg = <(
+   MXL8611X_LEDX_CFG_LINK_UP_RX_ACT_ON |
+   MXL8611X_LEDX_CFG_LINK_UP_TX_ACT_ON |
+   MXL8611X_LEDX_CFG_TRAFFIC_ACT_BLINK_IND
+   )>;
+   mxl-8611x,led1_cfg = <(
+   MXL8611X_LEDX_CFG_LINK_UP_10MB_ON |
+   MXL8611X_LEDX_CFG_LINK_UP_100MB_ON |
+   MXL8611X_LEDX_CFG_LINK_UP_1GB_ON
+   )>;
+   mxl-8611x,rx-internal-delay-ps = <0>;
+   mxl-8611x,tx-internal-delay-ps-100m = <2250>;
+   mxl-8611x,tx-internal-delay-ps-1g = <150>;
+   };
diff --git a/include/dt-bindings/net/mxl-8611x.h 
b/include/dt-bindings/net/mxl-8611x.h

new file mode 100644
index 000..cb0ec0f8bd0
--- /dev/null
+++ b/include/dt-bindings/net/mxl-8611x.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
+/*
+ * Device Tree constants for MaxLinear MXL8611x PHYs
+ *
+ * Copyright 2023 Variscite Ltd.
+ * Copyright 2023 MaxLinear Inc.
+ */
+
+#ifndef _DT_BINDINGS_MXL_8611X_H
+#define _DT_BINDINGS_MXL_8611X_H
+
+#define MXL8611X_LEDX_CFG_TRAFFIC_ACT_BLINK_IND(1 << 13)
+#define MXL8611X_LEDX_CFG_LINK_UP_FULL_DUPLEX_ON   (1 << 12)
+#define MXL8611X_LEDX_CFG_LINK_UP_HALF_DUPLEX_ON   (1 << 11)
+#define MXL8611X_LEDX_CFG_LINK_UP_TX_ACT_ON(1 << 10)
+#define MXL8611X_LEDX_CFG_LINK_UP_RX_ACT_ON(1 << 9)
+#define MXL8611X_LEDX_CFG_LINK_UP_TX_ON(1 << 8)
+#define MXL8611X_LEDX_CFG_LINK_UP_RX_ON(1 << 7)
+#define MXL8611X_LEDX_CFG_LINK_UP_1GB_ON   (1 << 6)
+#define MXL8611X_LEDX_CFG_LINK_UP_100MB_ON (1 << 5)
+#define MXL8611X_LEDX_CFG_LINK_UP_10MB_ON  (1 << 4)
+#define MXL8611X_LEDX_CFG_LINK_UP_COLLISION(1 << 3)
+#define MXL8611X_LEDX_CFG_LINK_UP_1GB_BLINK(1 << 2)
+#define MXL8611X_LEDX_CFG_LINK_UP_100MB_BLINK  (1 << 1)
+#define MXL8611X_LEDX_CFG_LINK_UP_10MB_BLINK   (1 << 0)
+
+#endif
--
2.40.1


[PATCH 1/2] phy: mxl-8611x: add driver for MaxLinear mxl-8611x PHYs

2023-07-12 Thread Nate Drude

The MxL86110 is a low power Ethernet PHY transceiver integrated
circuit following the IEEE 802.3 [1] standard. It offers a
cost-optimized solution that is well-suited for routers,
switches, and home gateways. It performs data transmission on
an Ethernet twisted pair copper cable of category CAT5e or higher.
The MxL86110 supports 1000, 100, and 10 Mbit/s data rates.

The current driver implementation supports:
- configuring rgmii from the device tree
- configuring the LEDs from the device tree
- reading extended registers using the mdio command, e.g.:
=> mdio rx ethernet@428a 0xa00c
Reading from bus ethernet@428a
PHY at address 0:
40972 - 0x2600

Signed-off-by: Nate Drude 
---
 drivers/net/phy/Kconfig |   5 +
 drivers/net/phy/Makefile|   1 +
 drivers/net/phy/mxl-8611x.c | 271 
 3 files changed, 277 insertions(+)
 create mode 100644 drivers/net/phy/mxl-8611x.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 24158776f52..0fc0fb2c5bf 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -220,6 +220,11 @@ config PHY_MICREL_KSZ8XXX

 endif # PHY_MICREL

+config PHY_MXL8611X
+   bool "MaxLinear MXL8611X Ethernet PHYs"
+   help
+   Add support for configuring MaxLinear MXL8611X Ethernet PHYs.
+
 config PHY_MSCC
bool "Microsemi Corp Ethernet PHYs support"

diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 85d17f109cd..b3f4d75936c 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_PHY_MARVELL_10G) += marvell10g.o
 obj-$(CONFIG_PHY_MICREL_KSZ8XXX) += micrel_ksz8xxx.o
 obj-$(CONFIG_PHY_MICREL_KSZ90X1) += micrel_ksz90x1.o
 obj-$(CONFIG_PHY_MESON_GXL) += meson-gxl.o
+obj-$(CONFIG_PHY_MXL8611X) += mxl-8611x.o
 obj-$(CONFIG_PHY_NATSEMI) += natsemi.o
 obj-$(CONFIG_PHY_NXP_C45_TJA11XX) += nxp-c45-tja11xx.o
 obj-$(CONFIG_PHY_NXP_TJA11XX) += nxp-tja11xx.o
diff --git a/drivers/net/phy/mxl-8611x.c b/drivers/net/phy/mxl-8611x.c
new file mode 100644
index 000..467edc5bb5f
--- /dev/null
+++ b/drivers/net/phy/mxl-8611x.c
@@ -0,0 +1,271 @@
+// SPDX-License-Identifier: GPL-2.0+
+/**
+ *  Driver for MaxLinear MXL861100 Ethernet PHY
+ *
+ * Copyright 2023 Variscite Ltd.
+ * Copyright 2023 MaxLinear Inc.
+ * Author: Nate Drude 
+ */
+#include 
+#include 
+#include 
+#include 
+
+/* PHY IDs */
+#define PHY_ID_MXL861100xC1335580
+#define PHY_ID_MXL861110xC1335588
+
+/* required to access extended registers */
+#define MXL8611X_EXTD_REG_ADDR_OFFSET  0x1E
+#define MXL8611X_EXTD_REG_ADDR_DATA0x1F
+
+/* RGMII register */
+#define MXL8611X_EXT_RGMII_CFG1_REG0xA003
+#define MXL8611X_EXT_RGMII_CFG1_NO_DELAY   0
+
+#define MXL8611X_EXT_RGMII_CFG1_RX_DELAY_MASK  GENMASK(13, 10)
+#define MXL8611X_EXT_RGMII_CFG1_TX_1G_DELAY_MASK   GENMASK(3, 0)
+#define MXL8611X_EXT_RGMII_CFG1_TX_10MB_100MB_DELAY_MASK   GENMASK(7, 4)
+
+/* LED registers and defines */
+#define MXL8611X_LED0_CFG_REG  0xA00C
+#define MXL8611X_LED1_CFG_REG  0xA00D
+#define MXL8611X_LED2_CFG_REG  0xA00E
+
+/**
+ * struct mxl8611x_cfg_reg_map - map a config value to aregister value
+ * @cfgvalue in device configuration
+ * @regvalue in the register
+ */
+struct mxl8611x_cfg_reg_map {
+   int cfg;
+   int reg;
+};
+
+static const struct mxl8611x_cfg_reg_map mxl8611x_rgmii_delays[] = {
+   { 0, 0 },
+   { 150, 1 },
+   { 300, 2 },
+   { 450, 3 },
+   { 600, 4 },
+   { 750, 5 },
+   { 900, 6 },
+   { 1050, 7 },
+   { 1200, 8 },
+   { 1350, 9 },
+   { 1500, 10 },
+   { 1650, 11 },
+   { 1800, 12 },
+   { 1950, 13 },
+   { 2100, 14 },
+   { 2250, 15 },
+   { 0, 0 } // Marks the end of the array
+};
+
+static int mxl8611x_lookup_reg_value(const struct mxl8611x_cfg_reg_map 
*tbl,

+const int cfg, int *reg)
+{
+   size_t i;
+
+   for (i = 0; i == 0 || tbl[i].cfg; i++) {
+   if (tbl[i].cfg == cfg) {
+   *reg = tbl[i].reg;
+   return 0;
+   }
+   }
+
+   return -EINVAL;
+}
+
+static u16 mxl8611x_ext_read(struct phy_device *phydev, const u32 regnum)
+{
+   u16 val;
+
+   phy_write(phydev, MDIO_DEVAD_NONE, MXL8611X_EXTD_REG_ADDR_OFFSET, 
regnum);
+   val = phy_read(phydev, MDIO_DEVAD_NONE, MXL8611X_EXTD_REG_ADDR_DATA);
+
+	debug("%s: MXL86110@0x%x 0x%x=0x%x\n", __func__, phydev->addr, regnum, 
val);

+
+   return val;
+}
+
+static int mxl8611x_ext_write(struct phy_device *phydev, const u32 
regnum, const u16 val)

+{
+	debug("%s: MXL86110@0x%x 0x%x=0x%x\n", __func__, phydev->addr, regnum, 
val);

+

Re: [PATCH] CI: Add automatic retry for test.py jobs

2023-07-12 Thread Tom Rini
On Wed, Jul 12, 2023 at 02:32:18PM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Wed, 12 Jul 2023 at 11:09, Tom Rini  wrote:
> >
> > On Wed, Jul 12, 2023 at 08:00:23AM -0600, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Tue, 11 Jul 2023 at 20:33, Tom Rini  wrote:
> > > >
> > > > It is not uncommon for some of the QEMU-based jobs to fail not because
> > > > of a code issue but rather because of a timing issue or similar problem
> > > > that is out of our control. Make use of the keywords that Azure and
> > > > GitLab provide so that we will automatically re-run these when they fail
> > > > 2 times. If they fail that often it is likely we have found a real issue
> > > > to investigate.
> > > >
> > > > Signed-off-by: Tom Rini 
> > > > ---
> > > >  .azure-pipelines.yml | 1 +
> > > >  .gitlab-ci.yml   | 1 +
> > > >  2 files changed, 2 insertions(+)
> > >
> > > This seems like a slippery slope. Do we know why things fail? I wonder
> > > if we should disable the tests / builders instead, until it can be
> > > corrected?
> >
> > It happens in Azure, so it's not just the broken runner problem we have
> > in GitLab. And the problem is timing, as I said in the commit.
> > Sometimes we still get the RTC test failing. Other times we don't get
> > QEMU + U-Boot spawned in time (most often m68k, but sometimes x86).
> 
> How do we keep this list from growing?

Do we need to? The problem is in essence since we rely on free
resources, sometimes some heavy lifts take longer.  That's what this
flag is for.

> > > I'll note that we don't have this problem with sandbox tests.
> >
> > OK, but that's not relevant?
> 
> It is relevant to the discussion about using QEMU instead of sandbox,
> e.g. with the TPM. I recall a discussion with Ilias a while back.

I'm sure we could make sandbox take too long to start as well, if enough
other things are going on with the system.  And sandbox has its own set
of super frustrating issues instead, so I don't think this is a great
argument to have right here (I have to run it in docker, to get around
some application version requirements and exclude event_dump, bootmgr,
abootimg and gpt tests, which could otherwise run, but fail for me).

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v6 21/23] binman: Overwrite symlink if it already exists

2023-07-12 Thread Simon Glass
On Wed, 12 Jul 2023 at 12:37, Neha Malcom Francis  wrote:
>
> From: Andrew Davis 
>
> Without this re-building will fail with an error when trying to create
> the symlink for the second time with an already exists error.
>
> Signed-off-by: Andrew Davis 
> [n-fran...@ti.com: Added support for test output dir and testcase]
> Signed-off-by: Neha Malcom Francis 
> ---
>  tools/binman/ftest.py | 18 --
>  tools/binman/image.py |  2 ++
>  2 files changed, 18 insertions(+), 2 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH] Azure: Add excludes to the imx8_imx9 job

2023-07-12 Thread Simon Glass
On Wed, 12 Jul 2023 at 14:22, Tom Rini  wrote:
>
> The job to build all imx8 and imx9 platforms is currently close to, or
> sometimes exceeding the allowed build time. Exclude some platforms that
> are already being built under their vendor-specific job as well to
> reduce the time.
>
> Signed-off-by: Tom Rini 
> ---
>  .azure-pipelines.yml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH] CI: Add automatic retry for test.py jobs

2023-07-12 Thread Simon Glass
Hi Tom,

On Wed, 12 Jul 2023 at 11:09, Tom Rini  wrote:
>
> On Wed, Jul 12, 2023 at 08:00:23AM -0600, Simon Glass wrote:
> > Hi Tom,
> >
> > On Tue, 11 Jul 2023 at 20:33, Tom Rini  wrote:
> > >
> > > It is not uncommon for some of the QEMU-based jobs to fail not because
> > > of a code issue but rather because of a timing issue or similar problem
> > > that is out of our control. Make use of the keywords that Azure and
> > > GitLab provide so that we will automatically re-run these when they fail
> > > 2 times. If they fail that often it is likely we have found a real issue
> > > to investigate.
> > >
> > > Signed-off-by: Tom Rini 
> > > ---
> > >  .azure-pipelines.yml | 1 +
> > >  .gitlab-ci.yml   | 1 +
> > >  2 files changed, 2 insertions(+)
> >
> > This seems like a slippery slope. Do we know why things fail? I wonder
> > if we should disable the tests / builders instead, until it can be
> > corrected?
>
> It happens in Azure, so it's not just the broken runner problem we have
> in GitLab. And the problem is timing, as I said in the commit.
> Sometimes we still get the RTC test failing. Other times we don't get
> QEMU + U-Boot spawned in time (most often m68k, but sometimes x86).

How do we keep this list from growing?

>
> > I'll note that we don't have this problem with sandbox tests.
>
> OK, but that's not relevant?

It is relevant to the discussion about using QEMU instead of sandbox,
e.g. with the TPM. I recall a discussion with Ilias a while back.

Reviewed-by: Simon Glass 

Regards,
Simon


Re: Please pull u-boot-dm

2023-07-12 Thread Tom Rini
On Wed, Jul 12, 2023 at 02:17:45PM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Wed, 12 Jul 2023 at 14:14, Tom Rini  wrote:
> >
> > On Wed, Jul 12, 2023 at 02:09:19PM -0600, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Wed, 12 Jul 2023 at 13:36, Tom Rini  wrote:
> > > >
> > > > On Wed, Jul 12, 2023 at 03:29:39PM -0400, Tom Rini wrote:
> > > > > On Wed, Jul 12, 2023 at 09:51:13AM -0600, Simon Glass wrote:
> > > > >
> > > > > > Hi Tom.
> > > > > >
> > > > > > https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/16872
> > > > > >
> > > > > >
> > > > > > The following changes since commit 
> > > > > > 8e21064cb3452950b09301baec06d86e37342471:
> > > > > >
> > > > > >   Merge tag 'efi-2023-07-rc7' of
> > > > > > https://source.denx.de/u-boot/custodians/u-boot-efi (2023-07-11
> > > > > > 13:27:32 -0400)
> > > > > >
> > > > > > are available in the Git repository at:
> > > > > >
> > > > > >   git://git.denx.de/u-boot-dm.git tags/dm-pull-12jul23a
> > > > > >
> > > > > > for you to fetch changes up to 
> > > > > > 45aa7ac492d90ddc2977ea6c9d161e7cc487:
> > > > > >
> > > > > >   tools: Fix package discovery in pyproject.toml of u_boot_pylib.
> > > > > > (2023-07-12 09:48:19 -0600)
> > > > >
> > > > > NAK,
> > > > > commit 5a801ad450303f028213c5da12017db5d3668cbc
> > > > > Author: Simon Glass 
> > > > > Date:   Thu Jun 22 12:44:24 2023 +0100
> > > > >
> > > > > buildman: Provide an argument to the -R option
> > > > >
> > > > > Allow writing the file to a selected location, since otherwise 
> > > > > this is
> > > > > controlled by the buildman configuration, so cannot be determined 
> > > > > by the
> > > > > caller.
> > > > >
> > > > > Fixes: https://source.denx.de/u-boot/u-boot/-/issues/17
> > > > > Signed-off-by: Simon Glass 
> > > > >
> > > > > Breaks buildman -R as it now requires a location to be specified 
> > > > > instead
> > > > > of creating one where it's normally needed / used by default.
> > > > >
> > > > > And I believe this matters in that I use "buildman -R" for "Did 
> > > > > someone
> > > > > add a new defconfig and not update a MAINATINERS file?".
> > >
> > > From the docs:
> > >
> > > This file is no-longer needed by buildman but it is still generated in the
> > > working directory. This helps avoid a delay on every build, since 
> > > scanning all
> > > the Kconfig files takes a few seconds. Use the `-R ` flag to 
> > > force
> > > regeneration of the file - in that case buildman exits after writing the 
> > > file
> > > with exit code 2 if there was an error in the maintainer files. To use the
> > > default filename, use a hyphen, i.e. `-R -`.
> >
> > The old name needs to be the default if none is specified, to not break
> > existing setups.
> 
> Well if none is specified you get an error. I realised after adding -R
> that it writes the file to a place that cannot be determined without
> parsing the ~/.buildman file!

I noticed it now produces an error when it broke the part of my build
scripts to check for new unmaintained defconfig files.  And I don't
really like adding incompatible changes to this script as it then breaks
when I need to go and back track on issues.  So please figure out what
needs to happen for -R to take an optional name, so that existing
scripts aren't broken.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] Azure: Add excludes to the imx8_imx9 job

2023-07-12 Thread Tom Rini
The job to build all imx8 and imx9 platforms is currently close to, or
sometimes exceeding the allowed build time. Exclude some platforms that
are already being built under their vendor-specific job as well to
reduce the time.

Signed-off-by: Tom Rini 
---
 .azure-pipelines.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 06c46b681c3f..8bb5ac682923 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -506,7 +506,7 @@ stages:
 imx:
   BUILDMAN: "mx -x mx6,imx8,freescale,technexion,toradex"
 imx8_imx9:
-  BUILDMAN: "imx8 imx9"
+  BUILDMAN: "imx8 imx9 -x engicam,technexion,toradex"
 keymile:
   BUILDMAN: "keymile"
 keystone2_keystone3:
-- 
2.34.1



Re: Please pull u-boot-dm

2023-07-12 Thread Simon Glass
Hi Tom,

On Wed, 12 Jul 2023 at 14:14, Tom Rini  wrote:
>
> On Wed, Jul 12, 2023 at 02:09:19PM -0600, Simon Glass wrote:
> > Hi Tom,
> >
> > On Wed, 12 Jul 2023 at 13:36, Tom Rini  wrote:
> > >
> > > On Wed, Jul 12, 2023 at 03:29:39PM -0400, Tom Rini wrote:
> > > > On Wed, Jul 12, 2023 at 09:51:13AM -0600, Simon Glass wrote:
> > > >
> > > > > Hi Tom.
> > > > >
> > > > > https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/16872
> > > > >
> > > > >
> > > > > The following changes since commit 
> > > > > 8e21064cb3452950b09301baec06d86e37342471:
> > > > >
> > > > >   Merge tag 'efi-2023-07-rc7' of
> > > > > https://source.denx.de/u-boot/custodians/u-boot-efi (2023-07-11
> > > > > 13:27:32 -0400)
> > > > >
> > > > > are available in the Git repository at:
> > > > >
> > > > >   git://git.denx.de/u-boot-dm.git tags/dm-pull-12jul23a
> > > > >
> > > > > for you to fetch changes up to 
> > > > > 45aa7ac492d90ddc2977ea6c9d161e7cc487:
> > > > >
> > > > >   tools: Fix package discovery in pyproject.toml of u_boot_pylib.
> > > > > (2023-07-12 09:48:19 -0600)
> > > >
> > > > NAK,
> > > > commit 5a801ad450303f028213c5da12017db5d3668cbc
> > > > Author: Simon Glass 
> > > > Date:   Thu Jun 22 12:44:24 2023 +0100
> > > >
> > > > buildman: Provide an argument to the -R option
> > > >
> > > > Allow writing the file to a selected location, since otherwise this 
> > > > is
> > > > controlled by the buildman configuration, so cannot be determined 
> > > > by the
> > > > caller.
> > > >
> > > > Fixes: https://source.denx.de/u-boot/u-boot/-/issues/17
> > > > Signed-off-by: Simon Glass 
> > > >
> > > > Breaks buildman -R as it now requires a location to be specified instead
> > > > of creating one where it's normally needed / used by default.
> > > >
> > > > And I believe this matters in that I use "buildman -R" for "Did someone
> > > > add a new defconfig and not update a MAINATINERS file?".
> >
> > From the docs:
> >
> > This file is no-longer needed by buildman but it is still generated in the
> > working directory. This helps avoid a delay on every build, since scanning 
> > all
> > the Kconfig files takes a few seconds. Use the `-R ` flag to force
> > regeneration of the file - in that case buildman exits after writing the 
> > file
> > with exit code 2 if there was an error in the maintainer files. To use the
> > default filename, use a hyphen, i.e. `-R -`.
>
> The old name needs to be the default if none is specified, to not break
> existing setups.

Well if none is specified you get an error. I realised after adding -R
that it writes the file to a place that cannot be determined without
parsing the ~/.buildman file!

>
> > > And even harder NAK, this
> > > commit 075c6a5eb53f8fb8d375373293c92396f3b4a448
> > > Author: Simon Glass 
> > > Date:   Wed Jul 5 13:18:38 2023 +0100
> > >
> > > buildman: Move board-selection code into a function
> > >
> > > Create a new determine_boards() function to hold the code which 
> > > selects
> > > which boards to build.
> > >
> > > Signed-off-by: Simon Glass 
> > >
> > > Breaks "buildman foo -x bar" and so all of the Azure jobs that exclude
> > > things don't exclude things at all anymore.  For example:
> > > ./tools/buildman/buildman --dry-run -v freescale -x 
> > > powerpc,m68k,aarch64,ls101,ls102,ls104,ls108,ls20,lx21
> > > gives 229 boards and not 28.
> >
> > I'll take a look. One of the reasons this series adds test-coverage
> > measurement is to see where there are gaps in testing.
>
> OK.
>
> --
> Tom

Regards,
Simon


Re: Please pull u-boot-dm

2023-07-12 Thread Tom Rini
On Wed, Jul 12, 2023 at 02:09:19PM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Wed, 12 Jul 2023 at 13:36, Tom Rini  wrote:
> >
> > On Wed, Jul 12, 2023 at 03:29:39PM -0400, Tom Rini wrote:
> > > On Wed, Jul 12, 2023 at 09:51:13AM -0600, Simon Glass wrote:
> > >
> > > > Hi Tom.
> > > >
> > > > https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/16872
> > > >
> > > >
> > > > The following changes since commit 
> > > > 8e21064cb3452950b09301baec06d86e37342471:
> > > >
> > > >   Merge tag 'efi-2023-07-rc7' of
> > > > https://source.denx.de/u-boot/custodians/u-boot-efi (2023-07-11
> > > > 13:27:32 -0400)
> > > >
> > > > are available in the Git repository at:
> > > >
> > > >   git://git.denx.de/u-boot-dm.git tags/dm-pull-12jul23a
> > > >
> > > > for you to fetch changes up to 45aa7ac492d90ddc2977ea6c9d161e7cc487:
> > > >
> > > >   tools: Fix package discovery in pyproject.toml of u_boot_pylib.
> > > > (2023-07-12 09:48:19 -0600)
> > >
> > > NAK,
> > > commit 5a801ad450303f028213c5da12017db5d3668cbc
> > > Author: Simon Glass 
> > > Date:   Thu Jun 22 12:44:24 2023 +0100
> > >
> > > buildman: Provide an argument to the -R option
> > >
> > > Allow writing the file to a selected location, since otherwise this is
> > > controlled by the buildman configuration, so cannot be determined by 
> > > the
> > > caller.
> > >
> > > Fixes: https://source.denx.de/u-boot/u-boot/-/issues/17
> > > Signed-off-by: Simon Glass 
> > >
> > > Breaks buildman -R as it now requires a location to be specified instead
> > > of creating one where it's normally needed / used by default.
> > >
> > > And I believe this matters in that I use "buildman -R" for "Did someone
> > > add a new defconfig and not update a MAINATINERS file?".
> 
> From the docs:
> 
> This file is no-longer needed by buildman but it is still generated in the
> working directory. This helps avoid a delay on every build, since scanning all
> the Kconfig files takes a few seconds. Use the `-R ` flag to force
> regeneration of the file - in that case buildman exits after writing the file
> with exit code 2 if there was an error in the maintainer files. To use the
> default filename, use a hyphen, i.e. `-R -`.

The old name needs to be the default if none is specified, to not break
existing setups.

> > And even harder NAK, this
> > commit 075c6a5eb53f8fb8d375373293c92396f3b4a448
> > Author: Simon Glass 
> > Date:   Wed Jul 5 13:18:38 2023 +0100
> >
> > buildman: Move board-selection code into a function
> >
> > Create a new determine_boards() function to hold the code which selects
> > which boards to build.
> >
> > Signed-off-by: Simon Glass 
> >
> > Breaks "buildman foo -x bar" and so all of the Azure jobs that exclude
> > things don't exclude things at all anymore.  For example:
> > ./tools/buildman/buildman --dry-run -v freescale -x 
> > powerpc,m68k,aarch64,ls101,ls102,ls104,ls108,ls20,lx21
> > gives 229 boards and not 28.
> 
> I'll take a look. One of the reasons this series adds test-coverage
> measurement is to see where there are gaps in testing.

OK.

-- 
Tom


signature.asc
Description: PGP signature


Re: [RFC PATCH] riscv: sifive: fu70: downclock CPU clock for stability

2023-07-12 Thread Maciej W. Rozycki
On Thu, 13 Jul 2023, Icenowy Zheng wrote:

> >  FWIW, given the price and amount of DRAM used I think it makes no
> > sense 
> > to build computers equipped with a DRAM subsystem without ECC
> > nowadays.
> 
> Well the HiFive Unmatched board looks like it has a DRAM chip for ECC,
> but whether this is activated is not known...

 I don't think so.  According to documentation and visual inspection of 
the board it has eight 2Gx8 DRAM chips.  For ECC it would have to have 
nine 2Gx8 chips.

  Maciej


Re: Please pull u-boot-dm

2023-07-12 Thread Simon Glass
Hi Tom,

On Wed, 12 Jul 2023 at 13:36, Tom Rini  wrote:
>
> On Wed, Jul 12, 2023 at 03:29:39PM -0400, Tom Rini wrote:
> > On Wed, Jul 12, 2023 at 09:51:13AM -0600, Simon Glass wrote:
> >
> > > Hi Tom.
> > >
> > > https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/16872
> > >
> > >
> > > The following changes since commit 
> > > 8e21064cb3452950b09301baec06d86e37342471:
> > >
> > >   Merge tag 'efi-2023-07-rc7' of
> > > https://source.denx.de/u-boot/custodians/u-boot-efi (2023-07-11
> > > 13:27:32 -0400)
> > >
> > > are available in the Git repository at:
> > >
> > >   git://git.denx.de/u-boot-dm.git tags/dm-pull-12jul23a
> > >
> > > for you to fetch changes up to 45aa7ac492d90ddc2977ea6c9d161e7cc487:
> > >
> > >   tools: Fix package discovery in pyproject.toml of u_boot_pylib.
> > > (2023-07-12 09:48:19 -0600)
> >
> > NAK,
> > commit 5a801ad450303f028213c5da12017db5d3668cbc
> > Author: Simon Glass 
> > Date:   Thu Jun 22 12:44:24 2023 +0100
> >
> > buildman: Provide an argument to the -R option
> >
> > Allow writing the file to a selected location, since otherwise this is
> > controlled by the buildman configuration, so cannot be determined by the
> > caller.
> >
> > Fixes: https://source.denx.de/u-boot/u-boot/-/issues/17
> > Signed-off-by: Simon Glass 
> >
> > Breaks buildman -R as it now requires a location to be specified instead
> > of creating one where it's normally needed / used by default.
> >
> > And I believe this matters in that I use "buildman -R" for "Did someone
> > add a new defconfig and not update a MAINATINERS file?".

>From the docs:

This file is no-longer needed by buildman but it is still generated in the
working directory. This helps avoid a delay on every build, since scanning all
the Kconfig files takes a few seconds. Use the `-R ` flag to force
regeneration of the file - in that case buildman exits after writing the file
with exit code 2 if there was an error in the maintainer files. To use the
default filename, use a hyphen, i.e. `-R -`.


>
> And even harder NAK, this
> commit 075c6a5eb53f8fb8d375373293c92396f3b4a448
> Author: Simon Glass 
> Date:   Wed Jul 5 13:18:38 2023 +0100
>
> buildman: Move board-selection code into a function
>
> Create a new determine_boards() function to hold the code which selects
> which boards to build.
>
> Signed-off-by: Simon Glass 
>
> Breaks "buildman foo -x bar" and so all of the Azure jobs that exclude
> things don't exclude things at all anymore.  For example:
> ./tools/buildman/buildman --dry-run -v freescale -x 
> powerpc,m68k,aarch64,ls101,ls102,ls104,ls108,ls20,lx21
> gives 229 boards and not 28.

I'll take a look. One of the reasons this series adds test-coverage
measurement is to see where there are gaps in testing.

Regards,
Simon


Re: [PATCH v4] phy: phy-imx8mq-usb: add vbus regulator support

2023-07-12 Thread Tom Rini
On Wed, Jul 12, 2023 at 11:30:58AM -0700, Tim Harvey wrote:
> On Wed, Jul 12, 2023 at 10:25 AM Marek Vasut  wrote:
> >
> > On 7/12/23 18:29, Tim Harvey wrote:
> > > On Wed, Jul 12, 2023 at 8:10 AM Tim Harvey  wrote:
> > >>
> > >> On Wed, Jul 12, 2023 at 2:15 AM Marek Vasut  wrote:
> > >>>
> > >>> On 7/11/23 22:13, Tim Harvey wrote:
> >  On Mon, Jul 10, 2023 at 4:18 PM Marek Vasut  wrote:
> > >
> > > On 7/11/23 00:49, Tim Harvey wrote:
> > >> Add support for enabling and disabling vbus-supply regulator found
> > >> on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.
> > >>
> > >> Signed-off-by: Tim Harvey 
> > >> Reviewed-by: Adam Ford 
> > >> Reviewed-by: Marek Vasut 
> > >> ---
> > >> v4:
> > >> - use regulator_set_enable_if_allowed to handle regulator 
> > >> reference counting
> > >>   errors
> > >> - added Marek's rb tag
> > >>
> > >> v3:
> > >> - change pr_err to dev_err
> > >> - add #if CONFIG_IS_ENABLED around vbus_supply in struct
> > >> - add fail path to disable clock if regulator enable failed
> > >>
> > >> v2:
> > >> - protect ret with __maybe_unused in case CONFIG_CLK and
> > >>   CONFIG_DM_REGULATOR not defined
> > >> - add error prints on failures
> > >> - add Adam's rb tag
> > >> ---
> > >> drivers/phy/phy-imx8mq-usb.c | 39 
> > >> ++--
> > >> 1 file changed, 37 insertions(+), 2 deletions(-)
> > >>
> > >> diff --git a/drivers/phy/phy-imx8mq-usb.c 
> > >> b/drivers/phy/phy-imx8mq-usb.c
> > >> index 69f01de55538..6cbcb2338cfe 100644
> > >> --- a/drivers/phy/phy-imx8mq-usb.c
> > >> +++ b/drivers/phy/phy-imx8mq-usb.c
> > >> @@ -14,6 +14,8 @@
> > >> #include 
> > >> #include 
> > >> #include 
> > >> +#include 
> > >> +#include 
> > >>
> > >> #define PHY_CTRL0   0x0
> > >> #define PHY_CTRL0_REF_SSP_ENBIT(2)
> > >> @@ -81,6 +83,9 @@ struct imx8mq_usb_phy {
> > >> #endif
> > >> void __iomem *base;
> > >> enum imx8mpq_phy_type type;
> > >> +#if CONFIG_IS_ENABLED(DM_REGULATOR)
> > >> + struct udevice *vbus_supply;
> > >> +#endif
> > >> };
> > >>
> > >> static const struct udevice_id imx8mq_usb_phy_of_match[] = {
> > >> @@ -172,10 +177,10 @@ static int imx8mq_usb_phy_power_on(struct phy 
> > >> *usb_phy)
> > >> {
> > >> struct udevice *dev = usb_phy->dev;
> > >> struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> > >> + __maybe_unused int ret;
> > >> u32 value;
> > >>
> > >> #if CONFIG_IS_ENABLED(CLK)
> > >> - int ret;
> > >> ret = clk_enable(_phy->phy_clk);
> > >> if (ret) {
> > >> printf("Failed to enable usb phy clock\n");
> > >> @@ -183,18 +188,31 @@ static int imx8mq_usb_phy_power_on(struct phy 
> > >> *usb_phy)
> > >> }
> > >> #endif
> > >>
> > >> + if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> > >> + ret = 
> > >> regulator_set_enable_if_allowed(imx_phy->vbus_supply, true);
> > >> + if (ret && ret != -ENOSYS) {
> > >> + dev_err(dev, "Failed to enable VBUS regulator: 
> > >> %d\n", ret);
> > >> + goto err;
> > >> + }
> > >> + }
> > >> +
> > >> /* Disable rx term override */
> > >> value = readl(imx_phy->base + PHY_CTRL6);
> > >> value &= ~PHY_CTRL6_RXTERM_OVERRIDE_SEL;
> > >> writel(value, imx_phy->base + PHY_CTRL6);
> > >>
> > >> return 0;
> > >> +
> > >> +err:
> > >> + clk_disable(_phy->phy_clk);
> > >> + return ret;
> > >> }
> > >>
> > >> static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
> > >> {
> > >> struct udevice *dev = usb_phy->dev;
> > >> struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> > >> + __maybe_unused int ret;
> > >> u32 value;
> > >>
> > >> /* Override rx term to be 0 */
> > >> @@ -206,6 +224,14 @@ static int imx8mq_usb_phy_power_off(struct phy 
> > >> *usb_phy)
> > >> clk_disable(_phy->phy_clk);
> > >> #endif
> > >>
> > >> + if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> > >> + ret = 
> > >> regulator_set_enable_if_allowed(imx_phy->vbus_supply, false);
> > >> + if (ret && ret != -ENOSYS) {
> > >> + dev_err(dev, "Failed to disable VBUS 
> > >> regulator: %d\n", ret);
> > >> + return ret;
> > >> + }
> > >> + }
> > >> +
> > >> 

Re: [PULL] u-boot-riscv/master

2023-07-12 Thread Tom Rini
On Wed, Jul 12, 2023 at 06:58:21AM +, Leo Liang wrote:

> Hi Tom,
> 
> The following changes since commit 8e21064cb3452950b09301baec06d86e37342471:
> 
>   Merge tag 'efi-2023-07-rc7' of 
> https://source.denx.de/u-boot/custodians/u-boot-efi (2023-07-11 13:27:32 
> -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-riscv.git master
> 
> for you to fetch changes up to 478fedfda42ea2a444991de1696fa0adc8bb16d4:
> 
>   doc: t-head: lpi4a: document Lichee PI 4A board (2023-07-12 13:21:41 +0800)
> 
> CI result shows no issue: 
> https://source.denx.de/u-boot/custodians/u-boot-riscv/-/pipelines/16856
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Please pull u-boot-dm

2023-07-12 Thread Tom Rini
On Wed, Jul 12, 2023 at 03:29:39PM -0400, Tom Rini wrote:
> On Wed, Jul 12, 2023 at 09:51:13AM -0600, Simon Glass wrote:
> 
> > Hi Tom.
> > 
> > https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/16872
> > 
> > 
> > The following changes since commit 8e21064cb3452950b09301baec06d86e37342471:
> > 
> >   Merge tag 'efi-2023-07-rc7' of
> > https://source.denx.de/u-boot/custodians/u-boot-efi (2023-07-11
> > 13:27:32 -0400)
> > 
> > are available in the Git repository at:
> > 
> >   git://git.denx.de/u-boot-dm.git tags/dm-pull-12jul23a
> > 
> > for you to fetch changes up to 45aa7ac492d90ddc2977ea6c9d161e7cc487:
> > 
> >   tools: Fix package discovery in pyproject.toml of u_boot_pylib.
> > (2023-07-12 09:48:19 -0600)
> 
> NAK,
> commit 5a801ad450303f028213c5da12017db5d3668cbc
> Author: Simon Glass 
> Date:   Thu Jun 22 12:44:24 2023 +0100
> 
> buildman: Provide an argument to the -R option
> 
> Allow writing the file to a selected location, since otherwise this is
> controlled by the buildman configuration, so cannot be determined by the
> caller.
> 
> Fixes: https://source.denx.de/u-boot/u-boot/-/issues/17
> Signed-off-by: Simon Glass 
> 
> Breaks buildman -R as it now requires a location to be specified instead
> of creating one where it's normally needed / used by default.
> 
> And I believe this matters in that I use "buildman -R" for "Did someone
> add a new defconfig and not update a MAINATINERS file?".

And even harder NAK, this
commit 075c6a5eb53f8fb8d375373293c92396f3b4a448
Author: Simon Glass 
Date:   Wed Jul 5 13:18:38 2023 +0100

buildman: Move board-selection code into a function

Create a new determine_boards() function to hold the code which selects
which boards to build.

Signed-off-by: Simon Glass 

Breaks "buildman foo -x bar" and so all of the Azure jobs that exclude
things don't exclude things at all anymore.  For example:
./tools/buildman/buildman --dry-run -v freescale -x 
powerpc,m68k,aarch64,ls101,ls102,ls104,ls108,ls20,lx21
gives 229 boards and not 28.

-- 
Tom


signature.asc
Description: PGP signature


Re: Please pull u-boot-dm

2023-07-12 Thread Tom Rini
On Wed, Jul 12, 2023 at 09:51:13AM -0600, Simon Glass wrote:

> Hi Tom.
> 
> https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/16872
> 
> 
> The following changes since commit 8e21064cb3452950b09301baec06d86e37342471:
> 
>   Merge tag 'efi-2023-07-rc7' of
> https://source.denx.de/u-boot/custodians/u-boot-efi (2023-07-11
> 13:27:32 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-dm.git tags/dm-pull-12jul23a
> 
> for you to fetch changes up to 45aa7ac492d90ddc2977ea6c9d161e7cc487:
> 
>   tools: Fix package discovery in pyproject.toml of u_boot_pylib.
> (2023-07-12 09:48:19 -0600)

NAK,
commit 5a801ad450303f028213c5da12017db5d3668cbc
Author: Simon Glass 
Date:   Thu Jun 22 12:44:24 2023 +0100

buildman: Provide an argument to the -R option

Allow writing the file to a selected location, since otherwise this is
controlled by the buildman configuration, so cannot be determined by the
caller.

Fixes: https://source.denx.de/u-boot/u-boot/-/issues/17
Signed-off-by: Simon Glass 

Breaks buildman -R as it now requires a location to be specified instead
of creating one where it's normally needed / used by default.

And I believe this matters in that I use "buildman -R" for "Did someone
add a new defconfig and not update a MAINATINERS file?".

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v6 04/23] j721e: schema: yaml: Add general schema and J721E board config files

2023-07-12 Thread Neha Malcom Francis
Schema file in YAML must be provided in board/ti/common for validating
input config files and packaging system firmware. The schema includes
entries for rm-cfg, board-cfg, pm-cfg and sec-cfg.

Board config files must be provided in board/ti/ in YAML.
These can then be consumed for generation of binaries to package system
firmware. Added YAML configs for J721E in particular.

Signed-off-by: Tarun Sahu 
[n-fran...@ti.com: prepared patch for upstreaming]
Signed-off-by: Neha Malcom Francis 
---
 board/ti/common/schema.yaml   |  436 +
 board/ti/j721e/board-cfg.yaml |   36 +
 board/ti/j721e/pm-cfg.yaml|   12 +
 board/ti/j721e/rm-cfg.yaml| 3174 +
 board/ti/j721e/sec-cfg.yaml   |  380 
 5 files changed, 4038 insertions(+)
 create mode 100644 board/ti/common/schema.yaml
 create mode 100644 board/ti/j721e/board-cfg.yaml
 create mode 100644 board/ti/j721e/pm-cfg.yaml
 create mode 100644 board/ti/j721e/rm-cfg.yaml
 create mode 100644 board/ti/j721e/sec-cfg.yaml

diff --git a/board/ti/common/schema.yaml b/board/ti/common/schema.yaml
new file mode 100644
index 00..8023ecb0e0
--- /dev/null
+++ b/board/ti/common/schema.yaml
@@ -0,0 +1,436 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Config schema for TI K3 devices
+#
+
+---
+
+definitions:
+u8:
+type: integer
+minimum: 0
+maximum: 0xff
+u16:
+type: integer
+minimum: 0
+maximum: 0x
+u32:
+type: integer
+minimum: 0
+maximum: 0x
+
+
+
+type: object
+properties:
+pm-cfg:
+type: object
+properties:
+rev:
+type: object
+properties:
+boardcfg_abi_maj:
+$ref: "#/definitions/u8"
+boardcfg_abi_min:
+$ref: "#/definitions/u8"
+board-cfg:
+type: object
+properties:
+rev:
+type: object
+properties:
+boardcfg_abi_maj:
+$ref: "#/definitions/u8"
+boardcfg_abi_min:
+$ref: "#/definitions/u8"
+control:
+type: object
+properties:
+subhdr:
+type: object
+properties:
+magic:
+$ref: "#/definitions/u16"
+size:
+$ref: "#/definitions/u16"
+main_isolation_enable:
+$ref: "#/definitions/u8"
+main_isolation_hostid:
+$ref: "#/definitions/u16"
+
+
+secproxy:
+type: object
+properties:
+subhdr:
+type: object
+properties:
+magic:
+$ref: "#/definitions/u16"
+size:
+$ref: "#/definitions/u16"
+scaling_factor:
+$ref: "#/definitions/u8"
+scaling_profile:
+$ref: "#/definitions/u8"
+disable_main_nav_secure_proxy:
+$ref: "#/definitions/u8"
+
+msmc:
+type: object
+properties:
+subhdr:
+type: object
+properties:
+magic:
+$ref: "#/definitions/u16"
+size:
+$ref: "#/definitions/u16"
+msmc_cache_size:
+$ref: "#/definitions/u8"
+debug_cfg:
+type: object
+properties:
+subhdr:
+type: object
+properties:
+magic:
+$ref: "#/definitions/u16"
+size:
+$ref: "#/definitions/u16"
+trace_dst_enables:
+$ref: "#/definitions/u16"
+trace_src_enables:
+$ref: "#/definitions/u16"
+
+sec-cfg:
+type: object
+properties:
+rev:
+type: object
+properties:
+boardcfg_abi_maj:
+$ref: "#/definitions/u8"
+boardcfg_abi_min:
+$ref: "#/definitions/u8"
+
+processor_acl_list:
+type: object
+properties:
+subhdr:
+type: object
+

[PATCH] cmd: ubi: Fix 'ubi list' command arguments parsing

2023-07-12 Thread Dmitry Dunaev
This fixes allowed argc variable value for arguments parsing

Fixes: 6de1daf64b1 ("cmd: ubi: Add 'ubi list' command")
Signed-off-by: Dmitry Dunaev 
---
 cmd/ubi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index b61ae1efea..0a6a80bdd1 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -653,7 +653,7 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
 
if (strcmp(argv[1], "list") == 0) {
int numeric = 0;
-   if (argc >= 2 && argv[2][0] == '-') {
+   if (argc >= 3 && argv[2][0] == '-') {
if (strcmp(argv[2], "-numeric") == 0)
numeric = 1;
else
-- 
2.34.1



Re: [PATCH v1 0/5] Make the clock dt-bindings and DT nodes consistent with Linux

2023-07-12 Thread Hal Feng
On Tue, 11 Jul 2023 11:09:23 +0200, Torsten Duwe wrote:
> On Fri, 7 Jul 2023 18:50:06 +0800
> Hal Feng  wrote:
> 
>> The clock dt-bindings and DT nodes are not consistent with Linux now.
>> Let's sync them with Linux, so the same dtb can work for Linux & U-Boot.
>> 
>> To achieve this goal, the PLL clock driver is separated and some clock
>> IDs conversion is needed in clock drivers. 
>> 
>> For the motivation, please see the discussion in the link below.
>> 
>> [1] 
>> https://patchwork.kernel.org/project/linux-riscv/patch/20230512022036.97987-2-xingyu...@starfivetech.com/
>> 
>> Xingyu Wu (5):
>>   clk: starfive: jh7110: Separate the PLL driver
>>   riscv: dts: jh7110: Add PLL clock controller node
>>   riscv: dts: jh7110: Add clock source from PLL
>>   dt-bindings: clock: jh7110: Modify clock id to be same with Linux
>>   clk: starfive: jh7110: Add of_xlate ops and macros for clock id
>> conversion
> 
> For better bisectability, I would have put patch 2 first, then merged 1&3,
> then merged 4&5. This way U-Boot should compile and boot after each patch
> (I think, untested ;) But given the rapid development of the platform,

Yes, it will get better bisectability if we do so, but it is not a good
coding style as we merge the driver changes and the DT changes in one patch.

Does someone else have any suggestions?

> I'm fine with inclusion of the series as-is; as it does not affect other
> targets.
> 
> I'm also wondering whether the symbolic clock number constants should be
> synced, too. But that's also a minor issue, as long as they expand to yield
> the same numbers.

Good catch. The main difference is the definitions of PLL and STG. You can
simply compare them with the definitions in linux [1] in the link below.

[1] 
https://github.com/starfive-tech/linux/blob/JH7110_VisionFive2_upstream/include/dt-bindings/clock/starfive%2Cjh7110-crg.h

I will sync them in the next version.

> 
> For the series:
> 
> Reviewed-by: Torsten Duwe 

Thanks for your review.

Best regards,
Hal


Re: [RFC PATCH] riscv: sifive: fu70: downclock CPU clock for stability

2023-07-12 Thread Icenowy Zheng
在 2023-07-12星期三的 14:13 +0100,Maciej W. Rozycki写道:
> On Wed, 28 Jun 2023, Icenowy Zheng wrote:
> 
> > When building the package `rustc` for AOSC OS on HiFive Unmatched,
> > random SIGSEGV prevents the package from getting correctly built.
> > Downclocking the CPU PLL clock seems to allow rustc to be built,
> > although taking much more time.
> > 
> > Downclock the CPU PLL frequency for stability.
> 
>  FYI, I've been observing occasional (less than 1 bit per 10GiB of
> data 
> moved) single-bit data corruption on DRAM writes with my HiFive
> Unmatched, 
> but your change does not appear to make any difference with my
> system.
> 
>  FWIW, given the price and amount of DRAM used I think it makes no
> sense 
> to build computers equipped with a DRAM subsystem without ECC
> nowadays.

Well the HiFive Unmatched board looks like it has a DRAM chip for ECC,
but whether this is activated is not known...

> 
>   Maciej



[PATCH] dm: core: Deal with __symbols__ in devicetree

2023-07-12 Thread Simon Glass
This node is 'special' and doesn't have a compatible string. Deal with
it is as a special case.

Reported-by: Sahaj Sarup 
Signed-off-by: Simon Glass 
---

 drivers/core/root.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index 6775fb0b657..bf163cc16a9 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -285,6 +286,9 @@ static int dm_scan_fdt_node(struct udevice *parent, ofnode 
parent_node,
pr_debug("   - ignoring disabled device\n");
continue;
}
+   if (spl_phase() > PHASE_SPL &&
+   !strcmp("__symbols__", node_name))
+   continue;
err = lists_bind_fdt(parent, node, NULL, NULL, pre_reloc_only);
if (err && !ret) {
ret = err;
-- 
2.41.0.255.g8b1d071c50-goog



[PATCH v6 23/23] CI: Make use of buildman requirements.txt

2023-07-12 Thread Neha Malcom Francis
From: Tom Rini 

Now that buildman has a requirements.txt file we need to make use of it.

Signed-off-by: Tom Rini 
Reviewed-by: Simon Glass 
[n-fran...@ti.com: Adding missing command from .azure-pipelines.yml]
Signed-off-by: Neha Malcom Francis 
---
 .azure-pipelines.yml | 4 
 .gitlab-ci.yml   | 4 
 2 files changed, 8 insertions(+)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 06c46b681c..8626b27d4b 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -162,6 +162,7 @@ stages:
   virtualenv -p /usr/bin/python3 /tmp/venv
   . /tmp/venv/bin/activate
   pip install -r test/py/requirements.txt
+  pip install -r tools/buildman/requirements.txt
   export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl
   export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
   export PATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}
@@ -209,6 +210,7 @@ stages:
   git config --global --add safe.directory $(work_dir)
   export USER=azure
   pip install -r test/py/requirements.txt
+  pip install -r tools/buildman/requirements.txt
   pip install asteval pylint==2.12.2 pyopenssl
   export PATH=${PATH}:~/.local/bin
   echo "[MASTER]" >> .pylintrc
@@ -404,6 +406,7 @@ stages:
   if [ -n "${BUILD_ENV}" ]; then
   export ${BUILD_ENV};
   fi
+  pip install -r tools/buildman/requirements.txt
   tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e 
--board ${TEST_PY_BD} ${OVERRIDE}
   cp ~/grub_x86.efi ${UBOOT_TRAVIS_BUILD_DIR}/
   cp ~/grub_x64.efi ${UBOOT_TRAVIS_BUILD_DIR}/
@@ -583,6 +586,7 @@ stages:
   # make environment variables available as tests are running inside a 
container
   export BUILDMAN="${BUILDMAN}"
   git config --global --add safe.directory ${WORK_DIR}
+  pip install -r tools/buildman/requirements.txt
   EOF
   cat << "EOF" >> build.sh
   if [[ "${BUILDMAN}" != "" ]]; then
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cfd58513c3..07d8ba5ac2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -97,6 +97,7 @@ build all 32bit ARM platforms:
   script:
 - ret=0;
   git config --global --add safe.directory "${CI_PROJECT_DIR}";
+  pip install -r tools/buildman/requirements.txt;
   ./tools/buildman/buildman -o /tmp -PEWM arm -x aarch64 || ret=$?;
   if [[ $ret -ne 0 ]]; then
 ./tools/buildman/buildman -o /tmp -seP;
@@ -110,6 +111,7 @@ build all 64bit ARM platforms:
 - . /tmp/venv/bin/activate
 - ret=0;
   git config --global --add safe.directory "${CI_PROJECT_DIR}";
+  pip install -r tools/buildman/requirements.txt;
   ./tools/buildman/buildman -o /tmp -PEWM aarch64 || ret=$?;
   if [[ $ret -ne 0 ]]; then
 ./tools/buildman/buildman -o /tmp -seP;
@@ -208,6 +210,7 @@ Run binman, buildman, dtoc, Kconfig and patman testsuites:
   virtualenv -p /usr/bin/python3 /tmp/venv;
   . /tmp/venv/bin/activate;
   pip install -r test/py/requirements.txt;
+  pip install -r tools/buildman/requirements.txt;
   export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl;
   export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
   export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
@@ -240,6 +243,7 @@ Run pylint:
   script:
 - git config --global --add safe.directory "${CI_PROJECT_DIR}"
 - pip install -r test/py/requirements.txt
+- pip install -r tools/buildman/requirements.txt
 - pip install asteval pylint==2.12.2 pyopenssl
 - export PATH=${PATH}:~/.local/bin
 - echo "[MASTER]" >> .pylintrc
-- 
2.34.1



[PATCH v6 22/23] buildman: Create a requirements.txt file

2023-07-12 Thread Neha Malcom Francis
From: Tom Rini 

At this point, buildman requires a few different modules and so we need
a requirements.txt to track what modules are needed.

Cc: Simon Glass 
Cc: Neha Malcom Francis 
Signed-off-by: Tom Rini 
Reviewed-by: Simon Glass 
Signed-off-by: Neha Malcom Francis 
---
 tools/buildman/requirements.txt | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 tools/buildman/requirements.txt

diff --git a/tools/buildman/requirements.txt b/tools/buildman/requirements.txt
new file mode 100644
index 00..a1efcb9d4b
--- /dev/null
+++ b/tools/buildman/requirements.txt
@@ -0,0 +1,2 @@
+jsonschema==4.17.3
+pyyaml==6.0
-- 
2.34.1



[PATCH v6 21/23] binman: Overwrite symlink if it already exists

2023-07-12 Thread Neha Malcom Francis
From: Andrew Davis 

Without this re-building will fail with an error when trying to create
the symlink for the second time with an already exists error.

Signed-off-by: Andrew Davis 
[n-fran...@ti.com: Added support for test output dir and testcase]
Signed-off-by: Neha Malcom Francis 
---
 tools/binman/ftest.py | 18 --
 tools/binman/image.py |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index f4bff50aaf..6280eb92c4 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -353,7 +353,7 @@ class TestFunctional(unittest.TestCase):
 use_expanded=False, verbosity=None, allow_missing=False,
 allow_fake_blobs=False, extra_indirs=None, threads=None,
 test_section_timeout=False, update_fdt_in_elf=None,
-force_missing_bintools='', ignore_missing=False):
+force_missing_bintools='', ignore_missing=False, 
output_dir=None):
 """Run binman with a given test file
 
 Args:
@@ -384,6 +384,7 @@ class TestFunctional(unittest.TestCase):
 update_fdt_in_elf: Value to pass with --update-fdt-in-elf=xxx
 force_missing_tools (str): comma-separated list of bintools to
 regard as missing
+output_dir: Specific output directory to use for image using -O
 
 Returns:
 int return code, 0 on success
@@ -430,6 +431,8 @@ class TestFunctional(unittest.TestCase):
 if extra_indirs:
 for indir in extra_indirs:
 args += ['-I', indir]
+if output_dir:
+args += ['-O', output_dir]
 return self._DoBinman(*args)
 
 def _SetupDtb(self, fname, outfile='u-boot.dtb'):
@@ -6113,7 +6116,7 @@ fdt fdtmapExtract the devicetree 
blob from the fdtmap
   str(e.exception))
 
 def testSymlink(self):
-"""Test that image files can be named"""
+"""Test that image files can be symlinked"""
 retcode = self._DoTestFile('259_symlink.dts', debug=True, map=True)
 self.assertEqual(0, retcode)
 image = control.images['test_image']
@@ -6122,6 +6125,17 @@ fdt fdtmapExtract the devicetree 
blob from the fdtmap
 self.assertTrue(os.path.islink(sname))
 self.assertEqual(os.readlink(sname), fname)
 
+def testSymlinkOverwrite(self):
+"""Test that symlinked images can be overwritten"""
+testdir = TestFunctional._MakeInputDir('symlinktest')
+self._DoTestFile('259_symlink.dts', debug=True, map=True, 
output_dir=testdir)
+# build the same image again in the same directory so that existing 
symlink is present
+self._DoTestFile('259_symlink.dts', debug=True, map=True, 
output_dir=testdir)
+fname = tools.get_output_filename('test_image.bin')
+sname = tools.get_output_filename('symlink_to_test.bin')
+self.assertTrue(os.path.islink(sname))
+self.assertEqual(os.readlink(sname), fname)
+
 def testSymbolsElf(self):
 """Test binman can assign symbols embedded in an ELF file"""
 if not elf.ELF_TOOLS:
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 8ebf71d61a..e77b5d0d97 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -182,6 +182,8 @@ class Image(section.Entry_section):
 # Create symlink to file if symlink given
 if self._symlink is not None:
 sname = tools.get_output_filename(self._symlink)
+if os.path.islink(sname):
+os.remove(sname)
 os.symlink(fname, sname)
 
 def WriteMap(self):
-- 
2.34.1



[PATCH v6 20/23] doc: board: ti: Update documentation for binman flow

2023-07-12 Thread Neha Malcom Francis
Earlier documentation specified builds for generating bootloader images
using an external TI repository k3-image-gen and core-secdev-k3. Modify
this to using the binman flow so that user understands how to build the
final boot images.

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
---
 doc/board/ti/am62x_sk.rst  |  54 +--
 doc/board/ti/j7200_evm.rst |  55 +--
 doc/board/ti/j721e_evm.rst |  58 +---
 doc/board/ti/k3.rst| 107 +
 4 files changed, 113 insertions(+), 161 deletions(-)

diff --git a/doc/board/ti/am62x_sk.rst b/doc/board/ti/am62x_sk.rst
index 27d7b527c6..bf23022b95 100644
--- a/doc/board/ti/am62x_sk.rst
+++ b/doc/board/ti/am62x_sk.rst
@@ -90,9 +90,9 @@ Below is the pictorial representation of boot flow:
  |||--|---|>| Reset rls | |
  |||  |   | +---+ |
  ||  TIFS  |  |   |  :|
- ||Services|  |   | +---+ |
- |||<-|---|>|*ATF/OPTEE*| |
- |||  |   | +---+ |
+ ||Services|  |   | ++|
+ |||<-|---|>|*TF-A/OPTEE*||
+ |||  |   | ++|
  |||  |   |  :|
  |||  |   | +---+ |
  |||<-|---|>| *A53 SPL* | |
@@ -115,59 +115,57 @@ Below is the pictorial representation of boot flow:
 
 Sources:
 
-1. SYSFW:
-   Tree: git://git.ti.com/k3-image-gen/k3-image-gen.git
-   Branch: master
-
-2. ATF:
-   Tree: https://github.com/ARM-software/arm-trusted-firmware.git
+1. Trusted Firmware-A:
+   Tree: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/
Branch: master
 
-3. OPTEE:
+2. OPTEE:
Tree: https://github.com/OP-TEE/optee_os.git
Branch: master
 
-4. U-Boot:
+3. U-Boot:
Tree: https://source.denx.de/u-boot/u-boot
Branch: master
 
-5. TI Linux Firmware:
+4. TI Linux Firmware:
Tree: git://git.ti.com/processor-firmware/ti-linux-firmware.git
Branch: ti-linux-firmware
 
 Build procedure:
 
-1. ATF:
+1. Trusted Firmware-A:
 
-.. code-block:: text
+.. code-block:: bash
 
- $ make CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=aarch64 PLAT=k3 
TARGET_BOARD=lite SPD=opteed
+ $ make CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=aarch64 PLAT=k3 \
+TARGET_BOARD=lite SPD=opteed
 
 2. OPTEE:
 
-.. code-block:: text
+.. code-block:: bash
 
- $ make PLATFORM=k3 CFG_ARM64_core=y CROSS_COMPILE=arm-none-linux-gnueabihf- 
CROSS_COMPILE64=aarch64-none-linux-gnu-
+ $ make PLATFORM=k3 CFG_ARM64_core=y CROSS_COMPILE=arm-none-linux-gnueabihf- \
+CROSS_COMPILE64=aarch64-none-linux-gnu-
 
 3. U-Boot:
 
 * 3.1 R5:
 
-.. code-block:: text
+.. code-block:: bash
 
- $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- 
am62x_evm_r5_defconfig O=/tmp/r5
- $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- O=/tmp/r5
- $ cd 
- $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- SOC=am62x 
SBL=/tmp/r5/spl/u-boot-spl.bin SYSFW_PATH=/ti-sysfw/ti-fs-firmware-am62x-gp.bin
-
-Use the tiboot3.bin generated from last command
+ $ make ARCH=arm am62x_evm_r5_defconfig
+ $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- \
+BINMAN_INDIRS=
 
 * 3.2 A53:
 
-.. code-block:: text
+.. code-block:: bash
 
- $ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- am62x_evm_a53_defconfig 
O=/tmp/a53
- $ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- ATF=/build/k3/lite/release/bl31.bin TEE=/out/arm-plat-k3/core/tee-pager_v2.bin DM=/ti-dm/am62xx/ipc_echo_testb_mcu1_0_release_strip.xer5f 
O=/tmp/a53
+ $ make ARCH=arm am62x_evm_a53_defconfig
+ $ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- \
+BL31=/build/k3/lite/release/bl31.bin \
+TEE=/out/arm-plat-k3/core/tee-raw.bin \
+BINMAN_INDIRS=
 
 Target Images
 --
@@ -214,7 +212,7 @@ Image formats:
 |   FIT HEADER  |
 | +---+ |
 | |   | |
-| |  A53 ATF  | |
+| | A53 TF-A  | |
 | +---+ |
 | |   | |
 | | A53 OPTEE | |
diff --git a/doc/board/ti/j7200_evm.rst b/doc/board/ti/j7200_evm.rst
index 0d3a526516..8f6d13ab8c 100644
--- a/doc/board/ti/j7200_evm.rst
+++ b/doc/board/ti/j7200_evm.rst
@@ -83,9 +83,9 @@ Below is the pictorial representation of boot flow:
  || |-|---|>| 

[PATCH v6 19/23] k3: tools: config.mk: Update makefile and remove scripts

2023-07-12 Thread Neha Malcom Francis
Since binman is used to package bootloader images for all K3 devices, we
do not have to rely on the earlier methods to package them.

Scripts that were used to generate x509 certificate for tiboot3.bin and
generate tispl.bin, u-boot.img have been removed.

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
---
 arch/arm/mach-k3/config.mk | 103 ---
 tools/k3_fit_atf.sh| 123 -
 tools/k3_gen_x509_cert.sh  | 262 -
 3 files changed, 488 deletions(-)
 delete mode 100644 arch/arm/mach-k3/config.mk
 delete mode 100755 tools/k3_fit_atf.sh
 delete mode 100755 tools/k3_gen_x509_cert.sh

diff --git a/arch/arm/mach-k3/config.mk b/arch/arm/mach-k3/config.mk
deleted file mode 100644
index cbf9c10210..00
--- a/arch/arm/mach-k3/config.mk
+++ /dev/null
@@ -1,103 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-#
-# Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/
-#  Lokesh Vutla 
-
-ifdef CONFIG_SPL_BUILD
-
-# Openssl is required to generate x509 certificate.
-# Error out if openssl is not available.
-ifeq ($(shell which openssl),)
-$(error "No openssl in $(PATH), consider installing openssl")
-endif
-
-IMAGE_SIZE= $(shell cat $(obj)/u-boot-spl.bin | wc -c)
-MAX_SIZE= $(shell printf "%d" $(CONFIG_SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE))
-
-ifeq ($(CONFIG_SYS_K3_KEY), "")
-KEY=""
-# On HS use real key or warn if not available
-ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
-ifneq ($(wildcard $(TI_SECURE_DEV_PKG)/keys/custMpk.pem),)
-KEY=$(TI_SECURE_DEV_PKG)/keys/custMpk.pem
-else
-$(warning "WARNING: signing key not found. Random key will NOT work on HS 
hardware!")
-endif
-endif
-else
-KEY=$(patsubst "%",$(srctree)/%,$(CONFIG_SYS_K3_KEY))
-endif
-
-# X509 SWRV default
-SWRV = $(CONFIG_K3_X509_SWRV)
-# On HS use SECDEV provided software revision or warn if not available
-ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
-ifneq ($(wildcard $(TI_SECURE_DEV_PKG)/keys/swrv.txt),)
-SWRV= $(shell cat $(TI_SECURE_DEV_PKG)/keys/swrv.txt)
-else
-$(warning "WARNING: Software revision file not found. Default may not work on 
HS hardware.")
-endif
-endif
-
-# tiboot3.bin is mandated by ROM and ROM only supports R5 boot.
-# So restrict tiboot3.bin creation for CPU_V7R.
-ifdef CONFIG_CPU_V7R
-image_check: $(obj)/u-boot-spl.bin FORCE
-   @if [ $(IMAGE_SIZE) -gt $(MAX_SIZE) ]; then \
-   echo "===" >&2; \
-   echo "ERROR: Final Image too big. " >&2;\
-   echo "$< size = $(IMAGE_SIZE), max size = $(MAX_SIZE)" >&2; \
-   echo "===" >&2; \
-   exit 1; \
-   fi
-
-tiboot3.bin: image_check FORCE
-   $(srctree)/tools/k3_gen_x509_cert.sh -c 16 -b $(obj)/u-boot-spl.bin \
-   -o $@ -l $(CONFIG_SPL_TEXT_BASE) -r $(SWRV) -k 
$(KEY)
-
-INPUTS-y   += tiboot3.bin
-endif
-
-ifdef CONFIG_ARM64
-
-ifeq ($(CONFIG_SOC_K3_J721E),)
-export DM := /dev/null
-endif
-
-ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
-SPL_ITS := u-boot-spl-k3_HS.its
-$(SPL_ITS): export IS_HS=1
-INPUTS-y   += tispl.bin_HS
-INPUTS-y   += tispl.bin
-tispl.bin: $(obj)/u-boot-spl-nodtb.bin_HS $(patsubst 
%,$(obj)/dts/%.dtb_HS,$(subst ",,$(CONFIG_SPL_OF_LIST)))
-else
-SPL_ITS := u-boot-spl-k3.its
-INPUTS-y   += tispl.bin
-endif
-
-ifeq ($(CONFIG_SPL_OF_LIST),)
-LIST_OF_DTB := $(CONFIG_DEFAULT_DEVICE_TREE)
-else
-LIST_OF_DTB := $(CONFIG_SPL_OF_LIST)
-endif
-
-quiet_cmd_k3_mkits = MKITS   $@
-cmd_k3_mkits = \
-   $(srctree)/tools/k3_fit_atf.sh \
-   $(CONFIG_K3_ATF_LOAD_ADDR) \
-   $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(LIST_OF_DTB))) > $@
-
-$(SPL_ITS): FORCE
-   $(call cmd,k3_mkits)
-endif
-
-else
-
-ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
-INPUTS-y   += u-boot.img_HS
-else
-INPUTS-y   += u-boot.img
-endif
-endif
-
-include $(srctree)/arch/arm/mach-k3/config_secure.mk
diff --git a/tools/k3_fit_atf.sh b/tools/k3_fit_atf.sh
deleted file mode 100755
index 7bc07ad074..00
--- a/tools/k3_fit_atf.sh
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0+
-#
-# script to generate FIT image source for K3 Family boards with
-# ATF, OPTEE, SPL and multiple device trees (given on the command line).
-# Inspired from board/sunxi/mksunxi_fit_atf.sh
-#
-# usage: $0   [ [&2
-   ATF=/dev/null
-fi
-
-[ -z "$TEE" ] && TEE="bl32.bin"
-
-if [ ! -f $TEE ]; then
-   echo "WARNING OPTEE file $TEE NOT found, resulting might be 
non-functional" >&2
-   TEE=/dev/null
-fi
-
-[ -z "$DM" ] && DM="dm.bin"
-
-if [ ! -e $DM ]; then
-   echo "WARNING DM file $DM NOT found, resulting might be non-functional" 
>&2
-   DM=/dev/null
-fi
-
-if [ ! -z "$IS_HS" ]; then
-   HS_APPEND=_HS
-fi
-
-cat << __HEADER_EOF
-/dts-v1/;
-
-/ {
-   description = "Configuration to load 

[PATCH v6 18/23] arm: k3-am65x-iot2050: Use binman for tispl.bin for iot2050

2023-07-12 Thread Neha Malcom Francis
Move to using binman to generate tispl.bin which is used to generate the
final flash.bin bootloader for iot2050 boards.

Signed-off-by: Neha Malcom Francis 
Cc: Jan Kiszka 
Reviewed-by: Simon Glass 
---
 arch/arm/dts/k3-am65-iot2050-boot-image.dtsi | 76 +++-
 1 file changed, 74 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi 
b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
index 03ccc54329..9d83898d33 100644
--- a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
+++ b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
@@ -26,9 +26,81 @@
missing-msg = "iot2050-seboot";
};
 
-   blob@0x18 {
+   fit@0x18 {
offset = <0x18>;
-   filename = "tispl.bin";
+   pad-byte = <0xff>;
+   description = "Configuration to load ATF and SPL";
+
+   images {
+   atf {
+   description = "ARM Trusted Firmware";
+   type = "firmware";
+   arch = "arm64";
+   compression = "none";
+   os = "arm-trusted-firmware";
+   load = ;
+   entry = ;
+   atf: atf-bl31 {
+   };
+   };
+
+   tee {
+   description = "OPTEE";
+   type = "tee";
+   arch = "arm64";
+   compression = "none";
+   os = "tee";
+   load = <0x9e80>;
+   entry = <0x9e80>;
+   tee: tee-os {
+   };
+   };
+
+   dm {
+   description = "DM binary";
+   type = "firmware";
+   arch = "arm32";
+   compression = "none";
+   os = "DM";
+   load = <0x8900>;
+   entry = <0x8900>;
+   blob-ext {
+   filename = "/dev/null";
+   };
+   };
+
+   spl {
+   description = "SPL (64-bit)";
+   type = "standalone";
+   os = "U-Boot";
+   arch = "arm64";
+   compression = "none";
+   load = ;
+   entry = ;
+   u_boot_spl_nodtb: blob-ext {
+   filename = 
"spl/u-boot-spl-nodtb.bin";
+   };
+   };
+
+   fdt-0 {
+   description = "k3-am65-iot2050-spl.dtb";
+   type = "flat_dt";
+   arch = "arm";
+   compression = "none";
+   spl_am65x_evm_dtb: blob-ext {
+   filename = 
"spl/dts/k3-am65-iot2050-spl.dtb";
+   };
+   };
+   };
+
+   configurations {
+   default = "spl";
+   spl {
+   fdt = "fdt-0";
+   firmware = "atf";
+   loadables = "tee", "dm", "spl";
+   };
+   };
};
 
fit@0x38 {
-- 
2.34.1



[PATCH v6 17/23] am62a: dts: binman: Package tiboot3.bin, tispl.bin, u-boot.img

2023-07-12 Thread Neha Malcom Francis
Support added for HS-SE, HS-FS and GP boot binaries for AM62ax.

HS-SE:
* tiboot3-am62ax-hs-evm.bin
* tispl.bin
* u-boot.img

HS-FS:
* tiboot3-am62ax-hs-fs-evm.bin
* tispl.bin
* u-boot.img

GP:
* tiboot3.bin --> tiboot3-am62ax-gp-evm.bin
* tispl.bin_unsigned
* u-boot.img_unsigned

It is to be noted that the bootflow followed by AM62ax requires:

tiboot3.bin:
* R5 SPL
* R5 SPL dtbs
* TIFS
* board-cfg
* pm-cfg
* sec-cfg
* rm-cfg

tispl.bin:
* DM
* ATF
* OPTEE
* A72 SPL
* A72 SPL dtbs

u-boot.img:
* A72 U-Boot
* A72 U-Boot dtbs

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
[a...@ti.com: changed output binary names appropriately]
Signed-off-by: Andrew Davis 
---
 arch/arm/dts/k3-am62a-sk-binman.dtsi | 466 +++
 arch/arm/dts/k3-am62a7-r5-sk.dts |   1 +
 arch/arm/dts/k3-am62a7-sk.dts|   1 +
 board/ti/am62ax/Kconfig  |   2 +
 4 files changed, 470 insertions(+)
 create mode 100644 arch/arm/dts/k3-am62a-sk-binman.dtsi

diff --git a/arch/arm/dts/k3-am62a-sk-binman.dtsi 
b/arch/arm/dts/k3-am62a-sk-binman.dtsi
new file mode 100644
index 00..abbac8f084
--- /dev/null
+++ b/arch/arm/dts/k3-am62a-sk-binman.dtsi
@@ -0,0 +1,466 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include "k3-binman.dtsi"
+
+#ifdef CONFIG_TARGET_AM62A7_R5_EVM
+
+_yaml_tifs {
+   config = "tifs-rm-cfg.yaml";
+};
+
+ {
+   tiboot3-am62ax-hs-evm.bin {
+   filename = "tiboot3-am62ax-hs-evm.bin";
+   ti-secure-rom {
+   content = <_boot_spl>, <_fs_enc>, 
<_tifs_cfg>,
+   <_dm_cfg>, <_inner_cert>;
+   combined;
+   dm-data;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl>;
+   content-sysfw = <_fs_enc>;
+   content-sysfw-data = <_tifs_cfg>;
+   content-sysfw-inner-cert = <_inner_cert>;
+   content-dm-data = <_dm_cfg>;
+   load = <0x43c0>;
+   load-sysfw = <0x4>;
+   load-sysfw-data = <0x67000>;
+   load-dm-data = <0x43c3a800>;
+   };
+   u_boot_spl: u-boot-spl {
+   no-expanded;
+   };
+   ti_fs_enc: ti-fs-enc.bin {
+   filename = "ti-sysfw/ti-fs-firmware-am62ax-hs-enc.bin";
+   type = "blob-ext";
+   optional;
+   };
+   combined_tifs_cfg: combined-tifs-cfg.bin {
+   filename = "combined-tifs-cfg.bin";
+   type = "blob-ext";
+   };
+   sysfw_inner_cert: sysfw-inner-cert {
+   filename = "ti-sysfw/ti-fs-firmware-am62ax-hs-cert.bin";
+   type = "blob-ext";
+   optional;
+   };
+   combined_dm_cfg: combined-dm-cfg.bin {
+   filename = "combined-dm-cfg.bin";
+   type = "blob-ext";
+   };
+   };
+};
+
+ {
+   tiboot3-am62ax-hs-fs-evm.bin {
+   filename = "tiboot3-am62ax-hs-fs-evm.bin";
+   symlink = "tiboot3.bin";
+   ti-secure-rom {
+   content = <_boot_spl_fs>, <_fs_enc_fs>, 
<_tifs_cfg_fs>,
+   <_dm_cfg_fs>, <_inner_cert_fs>;
+   combined;
+   dm-data;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl_fs>;
+   content-sysfw = <_fs_enc_fs>;
+   content-sysfw-data = <_tifs_cfg_fs>;
+   content-sysfw-inner-cert = <_inner_cert_fs>;
+   content-dm-data = <_dm_cfg_fs>;
+   load = <0x43c0>;
+   load-sysfw = <0x4>;
+   load-sysfw-data = <0x67000>;
+   load-dm-data = <0x43c3a800>;
+   };
+   u_boot_spl_fs: u-boot-spl {
+   no-expanded;
+   };
+   ti_fs_enc_fs: ti-fs-enc.bin {
+   filename = 
"ti-sysfw/ti-fs-firmware-am62ax-hs-fs-enc.bin";
+   type = "blob-ext";
+   optional;
+   };
+   combined_tifs_cfg_fs: combined-tifs-cfg.bin {
+   filename = "combined-tifs-cfg.bin";
+   type = "blob-ext";
+  

[PATCH v6 16/23] am62a: yaml: Add board configs for AM62ax

2023-07-12 Thread Neha Malcom Francis
Added YAML configs for AM62ax

Signed-off-by: Neha Malcom Francis 
---
 board/ti/am62ax/board-cfg.yaml   |   36 +
 board/ti/am62ax/pm-cfg.yaml  |   12 +
 board/ti/am62ax/rm-cfg.yaml  | 1151 ++
 board/ti/am62ax/sec-cfg.yaml |  379 ++
 board/ti/am62ax/tifs-rm-cfg.yaml | 1011 ++
 5 files changed, 2589 insertions(+)
 create mode 100644 board/ti/am62ax/board-cfg.yaml
 create mode 100644 board/ti/am62ax/pm-cfg.yaml
 create mode 100644 board/ti/am62ax/rm-cfg.yaml
 create mode 100644 board/ti/am62ax/sec-cfg.yaml
 create mode 100644 board/ti/am62ax/tifs-rm-cfg.yaml

diff --git a/board/ti/am62ax/board-cfg.yaml b/board/ti/am62ax/board-cfg.yaml
new file mode 100644
index 00..6e45b494e0
--- /dev/null
+++ b/board/ti/am62ax/board-cfg.yaml
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Board configuration for AM62ax
+#
+
+---
+
+board-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+control:
+subhdr:
+magic: 0xC1D3
+size: 7
+main_isolation_enable : 0x5A
+main_isolation_hostid : 0x2
+secproxy:
+subhdr:
+magic: 0x1207
+size: 7
+scaling_factor : 0x1
+scaling_profile : 0x1
+disable_main_nav_secure_proxy : 0
+msmc:
+subhdr:
+magic: 0xA5C3
+size: 5
+msmc_cache_size : 0x10
+debug_cfg:
+subhdr:
+magic: 0x020C
+size: 8
+trace_dst_enables : 0x00
+trace_src_enables : 0x00
diff --git a/board/ti/am62ax/pm-cfg.yaml b/board/ti/am62ax/pm-cfg.yaml
new file mode 100644
index 00..a491f11260
--- /dev/null
+++ b/board/ti/am62ax/pm-cfg.yaml
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Power management configuration for AM62ax
+#
+
+---
+
+pm-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
diff --git a/board/ti/am62ax/rm-cfg.yaml b/board/ti/am62ax/rm-cfg.yaml
new file mode 100644
index 00..0e11bd3e3c
--- /dev/null
+++ b/board/ti/am62ax/rm-cfg.yaml
@@ -0,0 +1,1151 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Resource management configuration for AM62ax
+#
+
+---
+
+rm-cfg:
+rm_boardcfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+host_cfg:
+subhdr:
+magic: 0x4C41
+size : 356
+host_cfg_entries:
+- #1
+host_id: 12
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #2
+host_id: 30
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #3
+host_id: 36
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #4
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #5
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #6
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #7
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #8
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #9
+host_id: 0
+allowed_atype : 0
+   

[PATCH v6 15/23] am625: dts: binman: Package tiboot3.bin, tispl.bin and u-boot.img

2023-07-12 Thread Neha Malcom Francis
Support added for HS-SE, HS-FS and GP boot binaries for AM62.

HS-SE:
* tiboot3-am62x-hs-evm.bin
* tispl.bin
* u-boot.img

HS-FS:
* tiboot3-am62x-hs-fs-evm.bin
* tispl.bin
* u-boot.img

GP:
* tiboot3.bin --> tiboot3-am62x-gp-evm.bin
* tispl.bin_unsigned
* u-boot.img_unsigned

It is to be noted that the bootflow followed by AM62 requires:

tiboot3.bin:
* R5 SPL
* R5 SPL dtbs
* TIFS
* board-cfg
* pm-cfg
* sec-cfg
* rm-cfg

tispl.bin:
* DM
* ATF
* OPTEE
* A72 SPL
* A72 SPL dtbs

u-boot.img:
* A72 U-Boot
* A72 U-Boot dtbs

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
[a...@ti.com: changed output binary names appropriately]
Signed-off-by: Andrew Davis 
---
 arch/arm/dts/k3-am625-r5-sk.dts  |   1 +
 arch/arm/dts/k3-am625-sk-binman.dtsi | 463 +++
 arch/arm/dts/k3-am625-sk-u-boot.dtsi |   2 +
 board/ti/am62x/Kconfig   |   2 +
 4 files changed, 468 insertions(+)
 create mode 100644 arch/arm/dts/k3-am625-sk-binman.dtsi

diff --git a/arch/arm/dts/k3-am625-r5-sk.dts b/arch/arm/dts/k3-am625-r5-sk.dts
index 78df7cec3f..3ec5bad735 100644
--- a/arch/arm/dts/k3-am625-r5-sk.dts
+++ b/arch/arm/dts/k3-am625-r5-sk.dts
@@ -9,6 +9,7 @@
 #include "k3-am62-ddr.dtsi"
 
 #include "k3-am625-sk-u-boot.dtsi"
+#include "k3-am625-sk-binman.dtsi"
 
 / {
aliases {
diff --git a/arch/arm/dts/k3-am625-sk-binman.dtsi 
b/arch/arm/dts/k3-am625-sk-binman.dtsi
new file mode 100644
index 00..c5bd9e48d0
--- /dev/null
+++ b/arch/arm/dts/k3-am625-sk-binman.dtsi
@@ -0,0 +1,463 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include "k3-binman.dtsi"
+
+#ifdef CONFIG_TARGET_AM625_R5_EVM
+
+ {
+   tiboot3-am62x-hs-evm.bin {
+   filename = "tiboot3-am62x-hs-evm.bin";
+   ti-secure-rom {
+   content = <_boot_spl>, <_fs_enc>, 
<_tifs_cfg>,
+   <_dm_cfg>, <_inner_cert>;
+   combined;
+   dm-data;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl>;
+   content-sysfw = <_fs_enc>;
+   content-sysfw-data = <_tifs_cfg>;
+   content-sysfw-inner-cert = <_inner_cert>;
+   content-dm-data = <_dm_cfg>;
+   load = <0x43c0>;
+   load-sysfw = <0x4>;
+   load-sysfw-data = <0x67000>;
+   load-dm-data = <0x43c3a800>;
+   };
+   u_boot_spl: u-boot-spl {
+   no-expanded;
+   };
+   ti_fs_enc: ti-fs-enc.bin {
+   filename = "ti-sysfw/ti-fs-firmware-am62x-hs-enc.bin";
+   type = "blob-ext";
+   optional;
+   };
+   combined_tifs_cfg: combined-tifs-cfg.bin {
+   filename = "combined-tifs-cfg.bin";
+   type = "blob-ext";
+   };
+   sysfw_inner_cert: sysfw-inner-cert {
+   filename = "ti-sysfw/ti-fs-firmware-am62x-hs-cert.bin";
+   type = "blob-ext";
+   optional;
+   };
+   combined_dm_cfg: combined-dm-cfg.bin {
+   filename = "combined-dm-cfg.bin";
+   type = "blob-ext";
+   };
+   };
+};
+
+ {
+   tiboot3-am62x-hs-fs-evm.bin {
+   filename = "tiboot3-am62x-hs-fs-evm.bin";
+   symlink = "tiboot3.bin";
+   ti-secure-rom {
+   content = <_boot_spl_fs>, <_fs_enc_fs>, 
<_tifs_cfg_fs>,
+   <_dm_cfg_fs>, <_inner_cert_fs>;
+   combined;
+   dm-data;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl_fs>;
+   content-sysfw = <_fs_enc_fs>;
+   content-sysfw-data = <_tifs_cfg_fs>;
+   content-sysfw-inner-cert = <_inner_cert_fs>;
+   content-dm-data = <_dm_cfg_fs>;
+   load = <0x43c0>;
+   load-sysfw = <0x4>;
+   load-sysfw-data = <0x67000>;
+   load-dm-data = <0x43c3a800>;
+   };
+   u_boot_spl_fs: u-boot-spl {
+   no-expanded;
+   };
+   ti_fs_enc_fs: ti-fs-enc.bin {
+   filename = 
"ti-sysfw/ti-fs-firmware-am62x-hs-fs-enc.bin";
+

[PATCH v6 14/23] am62: yaml: Add board configs for AM62

2023-07-12 Thread Neha Malcom Francis
Added YAML configs for AM62

Signed-off-by: Neha Malcom Francis 
---
 board/ti/am62x/board-cfg.yaml |   36 ++
 board/ti/am62x/pm-cfg.yaml|   12 +
 board/ti/am62x/rm-cfg.yaml| 1088 +
 board/ti/am62x/sec-cfg.yaml   |  379 
 4 files changed, 1515 insertions(+)
 create mode 100644 board/ti/am62x/board-cfg.yaml
 create mode 100644 board/ti/am62x/pm-cfg.yaml
 create mode 100644 board/ti/am62x/rm-cfg.yaml
 create mode 100644 board/ti/am62x/sec-cfg.yaml

diff --git a/board/ti/am62x/board-cfg.yaml b/board/ti/am62x/board-cfg.yaml
new file mode 100644
index 00..a26ef55bd4
--- /dev/null
+++ b/board/ti/am62x/board-cfg.yaml
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Board configuration for AM62
+#
+
+---
+
+board-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+control:
+subhdr:
+magic: 0xC1D3
+size: 7
+main_isolation_enable : 0x5A
+main_isolation_hostid : 0x2
+secproxy:
+subhdr:
+magic: 0x1207
+size: 7
+scaling_factor : 0x1
+scaling_profile : 0x1
+disable_main_nav_secure_proxy : 0
+msmc:
+subhdr:
+magic: 0xA5C3
+size: 5
+msmc_cache_size : 0x0
+debug_cfg:
+subhdr:
+magic: 0x020C
+size: 8
+trace_dst_enables : 0x00
+trace_src_enables : 0x00
diff --git a/board/ti/am62x/pm-cfg.yaml b/board/ti/am62x/pm-cfg.yaml
new file mode 100644
index 00..aa94097e97
--- /dev/null
+++ b/board/ti/am62x/pm-cfg.yaml
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Power management configuration for AM62
+#
+
+---
+
+pm-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
diff --git a/board/ti/am62x/rm-cfg.yaml b/board/ti/am62x/rm-cfg.yaml
new file mode 100644
index 00..1e8678c30b
--- /dev/null
+++ b/board/ti/am62x/rm-cfg.yaml
@@ -0,0 +1,1088 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Resource management configuration for AM62
+#
+
+---
+
+rm-cfg:
+rm_boardcfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+host_cfg:
+subhdr:
+magic: 0x4C41
+size : 356
+host_cfg_entries:
+- #1
+host_id: 12
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #2
+host_id: 30
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #3
+host_id: 36
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #4
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #5
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #6
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #7
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #8
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #9
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0

[PATCH v6 13/23] j721s2: dts: binman: Package tiboot3.bin, tispl.bin and u-boot.img

2023-07-12 Thread Neha Malcom Francis
Support has been added for both HS-SE, HS-FS  and GP images.

HS-SE:
* tiboot3-j721s2-hs-evm.bin
* tispl.bin
* u-boot.img

HS-FS:
* tiboot3-j721s2-hs-fs-evm.bin
* tispl.bin
* u-boot.img

GP:
* tiboot3.bin --> tiboot3-j721s2-gp-evm.bin
* tispl.bin_unsigned
* u-boot.img_unsigned

It is to be noted that the bootflow followed by J721S2 requires:

tiboot3.bin:
* R5 SPL
* R5 SPL dtbs
* TIFS
* board-cfg
* pm-cfg
* sec-cfg
* rm-cfg

tispl.bin:
* DM
* ATF
* OPTEE
* A72 SPL
* A72 SPL dtbs

u-boot.img:
* A72 U-Boot
* A72 U-Boot dtbs

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
[a...@ti.com: changed output binary names appropriately]
Signed-off-by: Andrew Davis 
---
 .../arm/dts/k3-am68-sk-base-board-u-boot.dtsi |   2 +
 arch/arm/dts/k3-j721s2-binman.dtsi| 546 ++
 .../k3-j721s2-common-proc-board-u-boot.dtsi   |   2 +
 .../dts/k3-j721s2-r5-common-proc-board.dts|   1 +
 board/ti/j721s2/Kconfig   |   2 +
 5 files changed, 553 insertions(+)
 create mode 100644 arch/arm/dts/k3-j721s2-binman.dtsi

diff --git a/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi 
b/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
index ee31b1ebe7..79faa1b573 100644
--- a/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
+++ b/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
@@ -3,6 +3,8 @@
  * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
  */
 
+#include "k3-j721s2-binman.dtsi"
+
 / {
chosen {
stdout-path = "serial2:115200n8";
diff --git a/arch/arm/dts/k3-j721s2-binman.dtsi 
b/arch/arm/dts/k3-j721s2-binman.dtsi
new file mode 100644
index 00..7fd7ba8e5d
--- /dev/null
+++ b/arch/arm/dts/k3-j721s2-binman.dtsi
@@ -0,0 +1,546 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include "k3-binman.dtsi"
+
+#ifdef CONFIG_TARGET_J721S2_R5_EVM
+
+ {
+   tiboot3-j721s2-hs-evm.bin {
+   filename = "tiboot3-j721s2-hs-evm.bin";
+   ti-secure-rom {
+   content = <_boot_spl>, <_fs_enc>, 
<_tifs_cfg>,
+   <_dm_cfg>, <_inner_cert>;
+   combined;
+   dm-data;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl>;
+   content-sysfw = <_fs_enc>;
+   content-sysfw-data = <_tifs_cfg>;
+   content-sysfw-inner-cert = <_inner_cert>;
+   content-dm-data = <_dm_cfg>;
+   load = <0x41c0>;
+   load-sysfw = <0x4>;
+   load-sysfw-data = <0x67000>;
+   load-dm-data = <0x41c8>;
+   };
+   u_boot_spl: u-boot-spl {
+   no-expanded;
+   };
+   ti_fs_enc: ti-fs-enc.bin {
+   filename = "ti-sysfw/ti-fs-firmware-j721s2-hs-enc.bin";
+   type = "blob-ext";
+   optional;
+   };
+   combined_tifs_cfg: combined-tifs-cfg.bin {
+   filename = "combined-tifs-cfg.bin";
+   type = "blob-ext";
+   };
+   sysfw_inner_cert: sysfw-inner-cert {
+   filename = "ti-sysfw/ti-fs-firmware-j721s2-hs-cert.bin";
+   type = "blob-ext";
+   optional;
+   };
+   combined_dm_cfg: combined-dm-cfg.bin {
+   filename = "combined-dm-cfg.bin";
+   type = "blob-ext";
+   };
+   };
+};
+
+ {
+   tiboot3-j721s2-hs-fs-evm.bin {
+   filename = "tiboot3-j721s2-hs-fs-evm.bin";
+   ti-secure-rom {
+   content = <_boot_spl_fs>, <_fs_enc_fs>, 
<_tifs_cfg_fs>,
+   <_dm_cfg_fs>, <_inner_cert_fs>;
+   combined;
+   dm-data;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl_fs>;
+   content-sysfw = <_fs_enc_fs>;
+   content-sysfw-data = <_tifs_cfg_fs>;
+   content-sysfw-inner-cert = <_inner_cert_fs>;
+   content-dm-data = <_dm_cfg_fs>;
+   load = <0x41c0>;
+   load-sysfw = <0x4>;
+   load-sysfw-data = <0x67000>;
+   load-dm-data = <0x41c8>;
+   };
+   u_boot_spl_fs: u-boot-spl {
+   

[PATCH v6 12/23] j721s2: yaml: Add board configs for J721S2

2023-07-12 Thread Neha Malcom Francis
Added YAML configs for J721S2

Signed-off-by: Neha Malcom Francis 
---
 board/ti/j721s2/board-cfg.yaml |   36 +
 board/ti/j721s2/pm-cfg.yaml|   12 +
 board/ti/j721s2/rm-cfg.yaml| 2901 
 board/ti/j721s2/sec-cfg.yaml   |  379 +
 4 files changed, 3328 insertions(+)
 create mode 100644 board/ti/j721s2/board-cfg.yaml
 create mode 100644 board/ti/j721s2/pm-cfg.yaml
 create mode 100644 board/ti/j721s2/rm-cfg.yaml
 create mode 100644 board/ti/j721s2/sec-cfg.yaml

diff --git a/board/ti/j721s2/board-cfg.yaml b/board/ti/j721s2/board-cfg.yaml
new file mode 100644
index 00..18da445629
--- /dev/null
+++ b/board/ti/j721s2/board-cfg.yaml
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Board configuration for J721S2
+#
+
+---
+
+board-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+control:
+subhdr:
+magic: 0xC1D3
+size: 7
+main_isolation_enable : 0x5A
+main_isolation_hostid : 0x2
+secproxy:
+subhdr:
+magic: 0x1207
+size: 7
+scaling_factor : 0x1
+scaling_profile : 0x1
+disable_main_nav_secure_proxy : 0
+msmc:
+subhdr:
+magic: 0xA5C3
+size: 5
+msmc_cache_size : 0x0
+debug_cfg:
+subhdr:
+magic: 0x020C
+size: 8
+trace_dst_enables : 0x00
+trace_src_enables : 0x00
diff --git a/board/ti/j721s2/pm-cfg.yaml b/board/ti/j721s2/pm-cfg.yaml
new file mode 100644
index 00..45994e23cc
--- /dev/null
+++ b/board/ti/j721s2/pm-cfg.yaml
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Power management configuration for J721S2
+#
+
+---
+
+pm-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
diff --git a/board/ti/j721s2/rm-cfg.yaml b/board/ti/j721s2/rm-cfg.yaml
new file mode 100644
index 00..6058f3b35c
--- /dev/null
+++ b/board/ti/j721s2/rm-cfg.yaml
@@ -0,0 +1,2901 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Resource management configuration for J721S2
+#
+
+---
+
+rm-cfg:
+rm_boardcfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+host_cfg:
+subhdr:
+magic: 0x4C41
+size : 356
+host_cfg_entries:
+- #1
+host_id: 3
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #2
+host_id: 5
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #3
+host_id: 12
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #4
+host_id: 13
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #5
+host_id: 21
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #6
+host_id: 23
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #7
+host_id: 35
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #8
+host_id: 37
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #9
+host_id: 40
+allowed_atype : 0x2A
+

[PATCH v6 11/23] am64x: dts: binman: Package tiboot3.bin, tispl.bin u-boot.img

2023-07-12 Thread Neha Malcom Francis
Support added for HS and GP boot binaries for AM64x.

HS-SE:
* tiboot3-am64x_sr2-hs-evm.bin
* tispl.bin
* u-boot.img

HS-FS:
* tiboot3-am64x_sr2-hs-fs-evm.bin
* tispl.bin
* u-boot.img

GP:
* tiboot3.bin --> tiboot3-am64x-gp-evm.bin
* tispl.bin_unsigned
* u-boot.img_unsigned

Note that the bootflow followed by AM64x requires:

tiboot3.bin:
* R5 SPL
* R5 SPL dtbs
* sysfw
* board-cfg
* pm-cfg
* sec-cfg
* rm-cfg

tispl.bin:
* ATF
* OPTEE
* A53 SPL
* A53 SPL dtbs

u-boot.img:
* A53 U-Boot
* A53 U-Boot dtbs

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
[a...@ti.com: changed output binary names appropriately]
Signed-off-by: Andrew Davis 
---
 arch/arm/dts/k3-am642-evm-u-boot.dtsi |   2 +
 arch/arm/dts/k3-am642-r5-evm.dts  |   1 +
 arch/arm/dts/k3-am642-sk-u-boot.dtsi  |   2 +
 arch/arm/dts/k3-am64x-binman.dtsi | 515 ++
 board/ti/am64x/Kconfig|   2 +
 5 files changed, 522 insertions(+)
 create mode 100644 arch/arm/dts/k3-am64x-binman.dtsi

diff --git a/arch/arm/dts/k3-am642-evm-u-boot.dtsi 
b/arch/arm/dts/k3-am642-evm-u-boot.dtsi
index 64857b0909..73577e8cfd 100644
--- a/arch/arm/dts/k3-am642-evm-u-boot.dtsi
+++ b/arch/arm/dts/k3-am642-evm-u-boot.dtsi
@@ -3,6 +3,8 @@
  * Copyright (C) 2020-2021 Texas Instruments Incorporated - https://www.ti.com/
  */
 
+#include "k3-am64x-binman.dtsi"
+
 / {
chosen {
stdout-path = "serial2:115200n8";
diff --git a/arch/arm/dts/k3-am642-r5-evm.dts b/arch/arm/dts/k3-am642-r5-evm.dts
index e870492a69..b49064181a 100644
--- a/arch/arm/dts/k3-am642-r5-evm.dts
+++ b/arch/arm/dts/k3-am642-r5-evm.dts
@@ -8,6 +8,7 @@
 #include "k3-am642.dtsi"
 #include "k3-am64-evm-ddr4-1600MTs.dtsi"
 #include "k3-am64-ddr.dtsi"
+#include "k3-am64x-binman.dtsi"
 
 / {
chosen {
diff --git a/arch/arm/dts/k3-am642-sk-u-boot.dtsi 
b/arch/arm/dts/k3-am642-sk-u-boot.dtsi
index 69dbe943bd..3d6be025bd 100644
--- a/arch/arm/dts/k3-am642-sk-u-boot.dtsi
+++ b/arch/arm/dts/k3-am642-sk-u-boot.dtsi
@@ -3,6 +3,8 @@
  * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
  */
 
+#include "k3-am64x-binman.dtsi"
+
 / {
chosen {
stdout-path = "serial2:115200n8";
diff --git a/arch/arm/dts/k3-am64x-binman.dtsi 
b/arch/arm/dts/k3-am64x-binman.dtsi
new file mode 100644
index 00..e6ca2457b4
--- /dev/null
+++ b/arch/arm/dts/k3-am64x-binman.dtsi
@@ -0,0 +1,515 @@
+// SPDX-License-Identifier: GPL-2.0+
+// Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+
+#include "k3-binman.dtsi"
+
+#ifdef CONFIG_TARGET_AM642_R5_EVM
+
+ {
+   tiboot3-am64x_sr2-hs-evm.bin {
+   filename = "tiboot3-am64x_sr2-hs-evm.bin";
+   ti-secure-rom {
+   content = <_boot_spl>, <_sci_enc>,
+   <_sysfw_cfg>, <_inner_cert>;
+   combined;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl>;
+   content-sysfw = <_sci_enc>;
+   content-sysfw-data = <_sysfw_cfg>;
+   content-sysfw-inner-cert = <_inner_cert>;
+   load = <0x7000>;
+   load-sysfw = <0x44000>;
+   load-sysfw-data = <0x7b000>;
+   };
+   u_boot_spl: u-boot-spl {
+   no-expanded;
+   };
+   ti_sci_enc: ti-fs-enc.bin {
+   filename = 
"ti-sysfw/ti-sci-firmware-am64x_sr2-hs-enc.bin";
+   type = "blob-ext";
+   optional;
+   };
+   combined_sysfw_cfg: combined-sysfw-cfg.bin {
+   filename = "combined-sysfw-cfg.bin";
+   type = "blob-ext";
+   };
+   sysfw_inner_cert: sysfw-inner-cert {
+   filename = 
"ti-sysfw/ti-sci-firmware-am64x_sr2-hs-cert.bin";
+   type = "blob-ext";
+   optional;
+   };
+
+   };
+};
+
+ {
+   tiboot3-am64x_sr2-hs-fs-evm.bin {
+   filename = "tiboot3-am64x_sr2-hs-fs-evm.bin";
+   symlink = "tiboot3.bin";
+   ti-secure-rom {
+   content = <_boot_spl_fs>, <_sci_enc_fs>,
+   <_sysfw_cfg_fs>, 
<_inner_cert_fs>;
+   combined;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl_fs>;
+   content-sysfw = <_sci_enc_fs>;
+   content-sysfw-data = <_sysfw_cfg_fs>;
+   

[PATCH v6 10/23] am64x: yaml: Add board configs for AM64x

2023-07-12 Thread Neha Malcom Francis
Added YAML configs for AM64xx

Signed-off-by: Neha Malcom Francis 
---
 board/ti/am64x/board-cfg.yaml |   36 +
 board/ti/am64x/pm-cfg.yaml|   12 +
 board/ti/am64x/rm-cfg.yaml| 1400 +
 board/ti/am64x/sec-cfg.yaml   |  380 +
 4 files changed, 1828 insertions(+)
 create mode 100644 board/ti/am64x/board-cfg.yaml
 create mode 100644 board/ti/am64x/pm-cfg.yaml
 create mode 100644 board/ti/am64x/rm-cfg.yaml
 create mode 100644 board/ti/am64x/sec-cfg.yaml

diff --git a/board/ti/am64x/board-cfg.yaml b/board/ti/am64x/board-cfg.yaml
new file mode 100644
index 00..36ac5361c7
--- /dev/null
+++ b/board/ti/am64x/board-cfg.yaml
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Board configuration for AM64x
+#
+
+---
+
+board-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+control:
+subhdr:
+magic: 0xC1D3
+size: 7
+main_isolation_enable : 0x5A
+main_isolation_hostid : 0x2
+secproxy:
+subhdr:
+magic: 0x1207
+size: 7
+scaling_factor : 0x1
+scaling_profile : 0x1
+disable_main_nav_secure_proxy : 0
+msmc:
+subhdr:
+magic: 0xA5C3
+size: 5
+msmc_cache_size : 0x0
+debug_cfg:
+subhdr:
+magic: 0x020C
+size: 8
+trace_dst_enables : 0x00
+trace_src_enables : 0x00
diff --git a/board/ti/am64x/pm-cfg.yaml b/board/ti/am64x/pm-cfg.yaml
new file mode 100644
index 00..c97495f482
--- /dev/null
+++ b/board/ti/am64x/pm-cfg.yaml
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Power management configuration for AM64x
+#
+
+---
+
+pm-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
diff --git a/board/ti/am64x/rm-cfg.yaml b/board/ti/am64x/rm-cfg.yaml
new file mode 100644
index 00..1e6b07aef6
--- /dev/null
+++ b/board/ti/am64x/rm-cfg.yaml
@@ -0,0 +1,1400 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Resource management configuration for AM64x
+#
+
+---
+
+rm-cfg:
+rm_boardcfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+host_cfg:
+subhdr:
+magic: 0x4C41
+size : 356
+host_cfg_entries:
+- #1
+host_id: 12
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #2
+host_id: 30
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #3
+host_id: 36
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #4
+host_id: 38
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #5
+host_id: 41
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+  

[PATCH v6 09/23] am65: dts: binman: Package tiboot3.bin, sysfw.itb, tispl.bin, u-boot.img

2023-07-12 Thread Neha Malcom Francis
Support has been added for both HS-SE(SR 2.0) and GP(SR 2.0) images.

HS-SE:
* tiboot3-am65x_sr2-hs-evm.bin
* sysfw-am65x_sr2-hs-evm.itb
* tispl.bin
* u-boot.img

GP:
* tiboot3.bin --> tiboot3-am65x_sr2-gp-evm.bin
* sysfw.itb --> sysfw-am65x_sr2-gp-evm.itb
* tispl.bin_unsigned
* u-boot.img_unsigned

Note that the bootflow followed by AM65x requires:

tiboot3.bin:
* R5 SPL
* R5 SPL dtbs
sysfw.itb:
* sysfw
* board-cfg
* pm-cfg
* sec-cfg
* rm-cfg

tispl.bin:
* ATF
* OPTEE
* A53 SPL
* A53 SPL dtbs

u-boot.img:
* A53 U-Boot
* A53 U-Boot dtbs

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
[a...@ti.com: changed output binary names appropriately]
Signed-off-by: Andrew Davis 
---
 arch/arm/dts/k3-am654-base-board-u-boot.dtsi  |   1 +
 .../dts/k3-am654-r5-base-board-u-boot.dtsi|   1 +
 arch/arm/dts/k3-am65x-binman.dtsi | 518 ++
 board/ti/am65x/Kconfig|   2 +
 4 files changed, 522 insertions(+)
 create mode 100644 arch/arm/dts/k3-am65x-binman.dtsi

diff --git a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi 
b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi
index 0c1305df7e..e4cbc47c2a 100644
--- a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi
+++ b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "k3-am654-r5-base-board-u-boot.dtsi"
+#include "k3-am65x-binman.dtsi"
 
 _0 {
remoteproc-name = "pru0_0";
diff --git a/arch/arm/dts/k3-am654-r5-base-board-u-boot.dtsi 
b/arch/arm/dts/k3-am654-r5-base-board-u-boot.dtsi
index 4516ab1437..949320c91d 100644
--- a/arch/arm/dts/k3-am654-r5-base-board-u-boot.dtsi
+++ b/arch/arm/dts/k3-am654-r5-base-board-u-boot.dtsi
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include "k3-am65x-binman.dtsi"
 
 / {
chosen {
diff --git a/arch/arm/dts/k3-am65x-binman.dtsi 
b/arch/arm/dts/k3-am65x-binman.dtsi
new file mode 100644
index 00..6535b9fec2
--- /dev/null
+++ b/arch/arm/dts/k3-am65x-binman.dtsi
@@ -0,0 +1,518 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include "k3-binman.dtsi"
+
+#ifdef CONFIG_TARGET_AM654_R5_EVM
+
+ {
+   tiboot3-am65x_sr2-hs-evm.bin {
+   filename = "tiboot3-am65x_sr2-hs-evm.bin";
+   ti-secure-rom {
+   content = <_boot_spl>;
+   core = "public";
+   load = ;
+   keyfile = "custMpk.pem";
+   };
+   u_boot_spl: u-boot-spl {
+   no-expanded;
+   };
+   };
+   sysfw {
+   filename = "sysfw.bin";
+   ti-secure-rom {
+   content = <_sci_cert>;
+   core = "secure";
+   load = <0x4>;
+   keyfile = "custMpk.pem";
+   countersign;
+   };
+   ti_sci_cert: ti-sci-cert.bin {
+   filename = 
"ti-sysfw/ti-sci-firmware-am65x_sr2-hs-cert.bin";
+   type = "blob-ext";
+   optional;
+   };
+   ti-sci-firmware-am65x-hs-enc.bin {
+   filename = 
"ti-sysfw/ti-sci-firmware-am65x_sr2-hs-enc.bin";
+   type = "blob-ext";
+   optional;
+   };
+   };
+   itb {
+   filename = "sysfw-am65x_sr2-hs-evm.itb";
+   fit {
+   description = "SYSFW and Config fragments";
+   #address-cells = <1>;
+   images {
+   sysfw.bin {
+   description = "sysfw";
+   type = "firmware";
+   arch = "arm";
+   compression = "none";
+   blob-ext {
+   filename = "sysfw.bin";
+   };
+   };
+   board-cfg.bin {
+   description = "board-cfg";
+   type = "firmware";
+   arch = "arm";
+   compression = "none";
+   ti-secure {
+   content = <_cfg>;
+   keyfile = "custMpk.pem";
+   };
+   board_cfg: board-cfg {
+   filename = "board-cfg.bin";
+   type = 

[PATCH v6 08/23] am65x: yaml: Add AM65x board config files

2023-07-12 Thread Neha Malcom Francis
Added YAML configs for AM65x

Signed-off-by: Neha Malcom Francis 
---
 board/ti/am65x/board-cfg.yaml |   36 +
 board/ti/am65x/pm-cfg.yaml|   12 +
 board/ti/am65x/rm-cfg.yaml| 2068 +
 board/ti/am65x/sec-cfg.yaml   |  379 ++
 4 files changed, 2495 insertions(+)
 create mode 100644 board/ti/am65x/board-cfg.yaml
 create mode 100644 board/ti/am65x/pm-cfg.yaml
 create mode 100644 board/ti/am65x/rm-cfg.yaml
 create mode 100644 board/ti/am65x/sec-cfg.yaml

diff --git a/board/ti/am65x/board-cfg.yaml b/board/ti/am65x/board-cfg.yaml
new file mode 100644
index 00..133720ec3e
--- /dev/null
+++ b/board/ti/am65x/board-cfg.yaml
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Board configuration for AM65x
+#
+
+---
+
+board-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+control:
+subhdr:
+magic: 0xC1D3
+size: 7
+main_isolation_enable : 0x5A
+main_isolation_hostid : 0x2
+secproxy:
+subhdr:
+magic: 0x1207
+size: 7
+scaling_factor : 0x1
+scaling_profile : 0x1
+disable_main_nav_secure_proxy : 0
+msmc:
+subhdr:
+magic: 0xA5C3
+size: 5
+msmc_cache_size : 0x10
+debug_cfg:
+subhdr:
+magic: 0x020C
+size: 8
+trace_dst_enables : 0x00
+trace_src_enables : 0x00
diff --git a/board/ti/am65x/pm-cfg.yaml b/board/ti/am65x/pm-cfg.yaml
new file mode 100644
index 00..4b1ce475cd
--- /dev/null
+++ b/board/ti/am65x/pm-cfg.yaml
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Power management configuration for AM65x
+#
+
+---
+
+pm-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
diff --git a/board/ti/am65x/rm-cfg.yaml b/board/ti/am65x/rm-cfg.yaml
new file mode 100644
index 00..61acd0aa60
--- /dev/null
+++ b/board/ti/am65x/rm-cfg.yaml
@@ -0,0 +1,2068 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Resource management configuration for AM65x
+#
+
+---
+
+rm-cfg:
+rm_boardcfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+host_cfg:
+subhdr:
+magic: 0x4C41
+size : 356
+host_cfg_entries:
+- #1
+host_id: 3
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #2
+host_id: 5
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #3
+host_id: 12
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #4
+host_id: 13
+allowed_atype : 0x2A
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #5
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #6
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #7
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #8
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+allowed_sched_priority : 0
+- #9
+host_id: 0
+allowed_atype : 0
+allowed_qos : 0
+allowed_orderid : 0
+allowed_priority : 0
+

[PATCH v6 07/23] j7200: dts: binman: Package tiboot3.bin, tispl.bin, u-boot.img

2023-07-12 Thread Neha Malcom Francis
Support has been added for both HS-SE(SR 2.0), HS-FS(SR 2.0) and GP
images.

HS-SE:
* tiboot3-j7200_sr2-hs-evm.bin
* tispl.bin
* u-boot.img

HS-FS:
* tiboot3-j7200_sr2-hs-fs-evm.bin
* tispl.bin
* u-boot.img

GP:
* tiboot3.bin --> tiboot3-j7200-gp-evm.bin
* tispl.bin_unsigned
* u-boot.img_unsigned

It is to be noted that the bootflow followed by J7200 requires:

tiboot3.bin:
* R5 SPL
* R5 SPL dtbs
* TIFS
* board-cfg
* pm-cfg
* sec-cfg
* rm-cfg

tispl.bin:
* DM
* ATF
* OPTEE
* A72 SPL
* A72 SPL dtbs

u-boot.img:
* A72 U-Boot
* A72 U-Boot dtbs

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
[a...@ti.com: changed output binary names appropriately]
Signed-off-by: Andrew Davis 
---
 arch/arm/dts/k3-j7200-binman.dtsi | 502 ++
 .../k3-j7200-common-proc-board-u-boot.dtsi|   2 +
 board/ti/j721e/Kconfig|   2 +
 3 files changed, 506 insertions(+)
 create mode 100644 arch/arm/dts/k3-j7200-binman.dtsi

diff --git a/arch/arm/dts/k3-j7200-binman.dtsi 
b/arch/arm/dts/k3-j7200-binman.dtsi
new file mode 100644
index 00..61bf576970
--- /dev/null
+++ b/arch/arm/dts/k3-j7200-binman.dtsi
@@ -0,0 +1,502 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include "k3-binman.dtsi"
+
+#ifdef CONFIG_TARGET_J7200_R5_EVM
+
+_yaml {
+   config = "board-cfg_j7200.yaml";
+};
+
+_yaml {
+   config = "rm-cfg_j7200.yaml";
+};
+
+_yaml {
+   config = "pm-cfg_j7200.yaml";
+};
+
+_yaml {
+   config = "sec-cfg_j7200.yaml";
+};
+
+_yaml_tifs {
+   config = "board-cfg_j7200.yaml";
+};
+
+_yaml_tifs {
+   config = "rm-cfg_j7200.yaml";
+};
+
+_yaml_tifs {
+   config = "pm-cfg_j7200.yaml";
+};
+
+_yaml_tifs {
+   config = "sec-cfg_j7200.yaml";
+};
+
+_yaml_dm {
+   config = "rm-cfg_j7200.yaml";
+};
+
+_yaml_dm {
+   config = "pm-cfg_j7200.yaml";
+};
+
+ {
+   tiboot3-j7200_sr2-hs-evm.bin {
+   filename = "tiboot3-j7200_sr2-hs-evm.bin";
+   ti-secure-rom {
+   content = <_boot_spl>, <_fs_enc>, 
<_tifs_cfg>,
+   <_dm_cfg>, <_inner_cert>;
+   combined;
+   dm-data;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl>;
+   content-sysfw = <_fs_enc>;
+   content-sysfw-data = <_tifs_cfg>;
+   content-sysfw-inner-cert = <_inner_cert>;
+   content-dm-data = <_dm_cfg>;
+   load = <0x41c0>;
+   load-sysfw = <0x4>;
+   load-sysfw-data = <0x7f000>;
+   load-dm-data = <0x41c8>;
+   };
+   u_boot_spl: u-boot-spl {
+   no-expanded;
+   };
+   ti_fs_enc: ti-fs-enc.bin {
+   filename = 
"ti-sysfw/ti-fs-firmware-j7200_sr2-hs-enc.bin";
+   type = "blob-ext";
+   optional;
+   };
+   combined_tifs_cfg: combined-tifs-cfg.bin {
+   filename = "combined-tifs-cfg.bin";
+   type = "blob-ext";
+   };
+   sysfw_inner_cert: sysfw-inner-cert {
+   filename = 
"ti-sysfw/ti-fs-firmware-j7200_sr2-hs-cert.bin";
+   type = "blob-ext";
+   optional;
+   };
+   combined_dm_cfg: combined-dm-cfg.bin {
+   filename = "combined-dm-cfg.bin";
+   type = "blob-ext";
+   };
+   };
+};
+
+ {
+   tiboot3-j7200_sr2-hs-fs-evm.bin {
+   filename = "tiboot3-j7200_sr2-hs-fs-evm.bin";
+   ti-secure-rom {
+   content = <_boot_spl_fs>, <_fs_enc_fs>, 
<_tifs_cfg_fs>,
+   <_dm_cfg_fs>, <_inner_cert_fs>;
+   combined;
+   dm-data;
+   sysfw-inner-cert;
+   keyfile = "custMpk.pem";
+   sw-rev = <1>;
+   content-sbl = <_boot_spl_fs>;
+   content-sysfw = <_fs_enc_fs>;
+   content-sysfw-data = <_tifs_cfg_fs>;
+   content-sysfw-inner-cert = <_inner_cert_fs>;
+   content-dm-data = <_dm_cfg_fs>;
+   load = <0x41c0>;
+   load-sysfw = <0x4>;
+   load-sysfw-data = <0x7f000>;
+   load-dm-data = <0x41c8>;
+   };
+

[PATCH v6 06/23] j7200: yaml: Add J7200 board config files

2023-07-12 Thread Neha Malcom Francis
Added YAML configs for J7200

Signed-off-by: Neha Malcom Francis 
---
 board/ti/j721e/board-cfg_j7200.yaml |   36 +
 board/ti/j721e/pm-cfg_j7200.yaml|   12 +
 board/ti/j721e/rm-cfg_j7200.yaml| 2065 +++
 board/ti/j721e/sec-cfg_j7200.yaml   |  380 +
 4 files changed, 2493 insertions(+)
 create mode 100644 board/ti/j721e/board-cfg_j7200.yaml
 create mode 100644 board/ti/j721e/pm-cfg_j7200.yaml
 create mode 100644 board/ti/j721e/rm-cfg_j7200.yaml
 create mode 100644 board/ti/j721e/sec-cfg_j7200.yaml

diff --git a/board/ti/j721e/board-cfg_j7200.yaml 
b/board/ti/j721e/board-cfg_j7200.yaml
new file mode 100644
index 00..1453317ecb
--- /dev/null
+++ b/board/ti/j721e/board-cfg_j7200.yaml
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Board configuration for J7200
+#
+
+---
+
+board-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+control:
+subhdr:
+magic: 0xC1D3
+size: 7
+main_isolation_enable : 0x5A
+main_isolation_hostid : 0x2
+secproxy:
+subhdr:
+magic: 0x1207
+size: 7
+scaling_factor : 0x1
+scaling_profile : 0x1
+disable_main_nav_secure_proxy : 0
+msmc:
+subhdr:
+magic: 0xA5C3
+size: 5
+msmc_cache_size : 0x10
+debug_cfg:
+subhdr:
+magic: 0x020C
+size: 8
+trace_dst_enables : 0x00
+trace_src_enables : 0x00
diff --git a/board/ti/j721e/pm-cfg_j7200.yaml b/board/ti/j721e/pm-cfg_j7200.yaml
new file mode 100644
index 00..588a1d530d
--- /dev/null
+++ b/board/ti/j721e/pm-cfg_j7200.yaml
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Power management configuration for J7200
+#
+
+---
+
+pm-cfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
diff --git a/board/ti/j721e/rm-cfg_j7200.yaml b/board/ti/j721e/rm-cfg_j7200.yaml
new file mode 100644
index 00..66b589f370
--- /dev/null
+++ b/board/ti/j721e/rm-cfg_j7200.yaml
@@ -0,0 +1,2065 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+#
+# Resource management configuration for J7200
+#
+
+---
+
+rm-cfg:
+rm_boardcfg:
+rev:
+boardcfg_abi_maj : 0x0
+boardcfg_abi_min : 0x1
+host_cfg:
+subhdr:
+magic: 0x4C41
+size : 356
+host_cfg_entries:
+- #1
+host_id: 3
+allowed_atype : 0b101010
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #2
+host_id: 5
+allowed_atype : 0b101010
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #3
+host_id: 12
+allowed_atype : 0b101010
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #4
+host_id: 13
+allowed_atype : 0b101010
+allowed_qos : 0x
+allowed_orderid : 0x
+allowed_priority : 0x
+allowed_sched_priority : 0xAA
+- #5
+host_id: 35
+allowed_atype : 0b101010
+allowed_qos : 0x
+allowed_orderid : 

[PATCH v6 05/23] j721e: dts: binman: Package tiboot3.bin, sysfw.itb, tispl.bin, u-boot.img

2023-07-12 Thread Neha Malcom Francis
By providing entries in the binman node of the device tree, binman will
be able to find and package board config artifacts generated by
TIBoardConfig with sysfw.bin and generate the final image sysfw.itb.
It will also pick out the R5 SPL and sign it with the help of TI signing
entry and generate the final tiboot3.bin.

Entries for A72 build have been added to k3-j721e-binman.dtsi to
generate tispl.bin and u-boot.img.

Support has been added for both HS-SE(SR 1.1), HS-FS(SR 2.0) and GP images
In HS-SE, the encrypted system firmware binary must be signed along with
the signed certificate binary.

HS-SE:
* tiboot3-j721e_sr1_1-hs-evm.bin
* sysfw-j721e_sr1_1-hs-evm.itb
* tispl.bin
* u-boot.img

HS-FS:
* tiboot3-j721e_sr2-hs-fs-evm.bin
* sysfw-j721e_sr2-hs-fs-evm.itb
* tispl.bin
* u-boot.img

GP:
* tiboot3.bin -->tiboot3-j721e-gp-evm.bin
* sysfw.itb --> sysfw-j721e-gp-evm.itb
* tispl.bin_unsigned
* u-boot.img_unsigned

It is to be noted that the bootflow followed by J721E requires:

tiboot3.bin:
* R5 SPL
* R5 SPL dtbs

sysfw.itb:
* TIFS
* board-cfg
* pm-cfg
* sec-cfg
* rm-cfg

tispl.bin:
* DM
* ATF
* OPTEE
* A72 SPL
* A72 SPL dtbs

u-boot.img:
* A72 U-Boot
* A72 U-Boot dtbs

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
[a...@ti.com: changed output binary names appropriately]
Signed-off-by: Andrew Davis 
---
 arch/arm/dts/k3-j721e-binman.dtsi | 701 ++
 .../k3-j721e-common-proc-board-u-boot.dtsi|   1 +
 .../arm/dts/k3-j721e-r5-common-proc-board.dts |   1 +
 arch/arm/dts/k3-j721e-sk-u-boot.dtsi  |   1 +
 board/ti/j721e/Kconfig|   2 +
 5 files changed, 706 insertions(+)
 create mode 100644 arch/arm/dts/k3-j721e-binman.dtsi

diff --git a/arch/arm/dts/k3-j721e-binman.dtsi 
b/arch/arm/dts/k3-j721e-binman.dtsi
new file mode 100644
index 00..0455deb6ca
--- /dev/null
+++ b/arch/arm/dts/k3-j721e-binman.dtsi
@@ -0,0 +1,701 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include "k3-binman.dtsi"
+
+#ifdef CONFIG_TARGET_J721E_R5_EVM
+
+ {
+   tiboot3-j721e_sr1_1-hs-evm.bin {
+   filename = "tiboot3-j721e_sr1_1-hs-evm.bin";
+   ti-secure-rom {
+   content = <_boot_spl>;
+   core = "public";
+   load = ;
+   keyfile = "custMpk.pem";
+   };
+   u_boot_spl: u-boot-spl {
+   no-expanded;
+   };
+   };
+   sysfw {
+   filename = "sysfw.bin";
+   ti-secure-rom {
+   content = <_fs_cert>;
+   core = "secure";
+   load = <0x4>;
+   keyfile = "custMpk.pem";
+   countersign;
+   };
+   ti_fs_cert: ti-fs-cert.bin {
+   filename = 
"ti-sysfw/ti-fs-firmware-j721e_sr1_1-hs-cert.bin";
+   type = "blob-ext";
+   optional;
+   };
+   ti-fs-firmware-j721e_sr1_1-hs-enc.bin {
+   filename = 
"ti-sysfw/ti-fs-firmware-j721e_sr1_1-hs-enc.bin";
+   type = "blob-ext";
+   optional;
+   };
+   };
+   itb {
+   filename = "sysfw-j721e_sr1_1-hs-evm.itb";
+   fit {
+   description = "SYSFW and Config fragments";
+   #address-cells = <1>;
+   images {
+   sysfw.bin {
+   description = "sysfw";
+   type = "firmware";
+   arch = "arm";
+   compression = "none";
+   blob-ext {
+   filename = "sysfw.bin";
+   };
+   };
+   board-cfg.bin {
+   description = "board-cfg";
+   type = "firmware";
+   arch = "arm";
+   compression = "none";
+   ti-secure {
+   content = <_cfg>;
+   keyfile = "custMpk.pem";
+   };
+   board_cfg: board-cfg {
+   filename = "board-cfg.bin";
+   type 

[PATCH v6 03/23] arm: dts: k3: Add support for packaging sysfw.itb and tiboot3.bin

2023-07-12 Thread Neha Malcom Francis
Board config binary artifacts must be generated to be used by binman to
package sysfw.itb and tiboot3.bin for all K3 devices.

For devices that follow combined flow, these board configuration
binaries must again be packaged into a combined board configuration
blobs to be used by binman to package tiboot3.bin.

Add common k3-binman.dtsi to generate all the board configuration
binaries needed.

Also add custMpk.pem and ti-degenerate-key.pem needed for signing GP and
HS bootloader images common to all K3 devices.

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
---
 arch/arm/dts/k3-binman.dtsi | 116 
 1 file changed, 116 insertions(+)
 create mode 100644 arch/arm/dts/k3-binman.dtsi

diff --git a/arch/arm/dts/k3-binman.dtsi b/arch/arm/dts/k3-binman.dtsi
new file mode 100644
index 00..97a3573bdb
--- /dev/null
+++ b/arch/arm/dts/k3-binman.dtsi
@@ -0,0 +1,116 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+/ {
+   binman: binman {
+   multiple-images;
+   };
+};
+
+ {
+   custMpk {
+   filename = "custMpk.pem";
+   blob-ext {
+   filename = "../keys/custMpk.pem";
+   };
+   };
+
+   ti-degenerate-key {
+   filename = "ti-degenerate-key.pem";
+   blob-ext {
+   filename = "../keys/ti-degenerate-key.pem";
+   };
+   };
+};
+
+#ifndef CONFIG_ARM64
+
+ {
+   board-cfg {
+   filename = "board-cfg.bin";
+   bcfg_yaml: ti-board-config {
+   config = "board-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   };
+   pm-cfg {
+   filename = "pm-cfg.bin";
+   rcfg_yaml: ti-board-config {
+   config = "pm-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   };
+   rm-cfg {
+   filename = "rm-cfg.bin";
+   pcfg_yaml: ti-board-config {
+   config = "rm-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   };
+   sec-cfg {
+   filename = "sec-cfg.bin";
+   scfg_yaml: ti-board-config {
+   config = "sec-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   };
+   combined-tifs-cfg {
+   filename = "combined-tifs-cfg.bin";
+   ti-board-config {
+   bcfg_yaml_tifs: board-cfg {
+   config = "board-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   scfg_yaml_tifs: sec-cfg {
+   config = "sec-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   pcfg_yaml_tifs: pm-cfg {
+   config = "pm-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   rcfg_yaml_tifs: rm-cfg {
+   config = "rm-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   };
+   };
+   combined-dm-cfg {
+   filename = "combined-dm-cfg.bin";
+   ti-board-config {
+   pcfg_yaml_dm: pm-cfg {
+   config = "pm-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   rcfg_yaml_dm: rm-cfg {
+   config = "rm-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   };
+   };
+   combined-sysfw-cfg {
+   filename = "combined-sysfw-cfg.bin";
+   ti-board-config {
+   board-cfg {
+   config = "board-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   sec-cfg {
+   config = "sec-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   pm-cfg {
+   config = "pm-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   rm-cfg {
+   config = "rm-cfg.yaml";
+   schema = "../common/schema.yaml";
+   };
+   };
+   };
+};
+
+#endif
-- 
2.34.1



[PATCH v6 02/23] binman: ti-secure: Add support for TI signing

2023-07-12 Thread Neha Malcom Francis
The ti-secure entry contains certificate for binaries that will be
loaded or booted by system firmware whereas the ti-secure-rom entry
contains certificate for binaries that will be booted by ROM. Support
for both these types of certificates is necessary for booting of K3
devices.

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
[vigne...@ti.com: fixed inconsist cert generation by multiple packing]
Signed-off-by: Vignesh Raghavendra 
---
 board/ti/keys/custMpk.pem |  51 
 board/ti/keys/ti-degenerate-key.pem   |  10 +
 tools/binman/btool/openssl.py | 244 +
 tools/binman/entries.rst  |  65 +
 tools/binman/etype/ti_secure.py   |  78 ++
 tools/binman/etype/ti_secure_rom.py   | 249 ++
 tools/binman/etype/x509_cert.py   |  87 +-
 tools/binman/ftest.py |  52 
 tools/binman/test/279_ti_secure.dts   |  17 ++
 tools/binman/test/280_ti_secure_rom.dts   |  17 ++
 .../test/281_ti_secure_rom_combined.dts   |  25 ++
 tools/binman/test/288_ti_secure_rom_a.dts |  19 ++
 tools/binman/test/289_ti_secure_rom_b.dts |  18 ++
 13 files changed, 924 insertions(+), 8 deletions(-)
 create mode 100644 board/ti/keys/custMpk.pem
 create mode 100644 board/ti/keys/ti-degenerate-key.pem
 create mode 100644 tools/binman/etype/ti_secure.py
 create mode 100644 tools/binman/etype/ti_secure_rom.py
 create mode 100644 tools/binman/test/279_ti_secure.dts
 create mode 100644 tools/binman/test/280_ti_secure_rom.dts
 create mode 100644 tools/binman/test/281_ti_secure_rom_combined.dts
 create mode 100644 tools/binman/test/288_ti_secure_rom_a.dts
 create mode 100644 tools/binman/test/289_ti_secure_rom_b.dts

diff --git a/board/ti/keys/custMpk.pem b/board/ti/keys/custMpk.pem
new file mode 100644
index 00..adba378c80
--- /dev/null
+++ b/board/ti/keys/custMpk.pem
@@ -0,0 +1,51 @@
+-BEGIN RSA PRIVATE KEY-
+MIIJKQIBAAKCAgEAvxSuSdh/ctNrI83rSA5l3CJN8g5PgvbttfLd23yR+m5Z/9X3
+tt4EHYrM0pXZ0eDEwfhQv/9IDJEiUJpMe4vzlgooJrOk2eCpVUEa+z5bJ2y/ysBx
+ry9yIu5GASVirT7HBPaxGLYswBJuD+KbPuWmoKgGRQNBF04WH6l01oRO1nmnELgR
+qQ6SHyXdf7Hy0bnyaNgzWUuCfXfM0Zz6I7T7WIjyzerVFvIsdS36YsPBCW7gBnDg
+tQcJmWLZ1uTnbG3IggdQk/fi2O3RX+PQns+TVNlf3V3ON2DxqxSKBHtlp7p/30VF
+fEuhW65OxpQ9jE6H0pQ8pPOf2vzyNnznDa1aQjfxKoHQbqGnZwMeh+0Au3NKaCgx
+ooKaowTB6If/RX6qwZ/UOwXHg/0hcf69fzjJFhlSDuYDM40dHsk2HM1OnYIpiM2b
+Kr5sX3uysjp5AGp99a0anR7NWCrPXvROgKs7T9341N40osQg2VkZLYUCXh9osUyN
+uREG6S12tViMUKg3bmZ4b4MwRk00n7QYSrm7+nvFrtYyEISEbD+agDM1/E281W5g
+VFDPfm2AlwT6jwsg/b2YK6E3vVn9SuxFoQmLF8lyFDO3BV4SXeJaHc4hVPbh6tVV
+qifrTQnfGUCCLmaJF2XZbrPWOE6NYRbWdNTeFl9RGdVCuIPSyN5LqWmXto0CAwEA
+AQKCAgAzkAwcJ0z1GnId/lJQZno8NhGckRoJuEKbR8dwlCP8VUz6Ca5H7Y9kvXDa
+Hs/hn+rYgP6hYOz7XyrIX2rmJ/T6dxEwqGeC1+o59FConcIRWHpE5zuGT6JYJL5F
+TuZa48bm4v8VMQvQZOjIZpkIFwao8c6HTwKAnHTB5IN/48I2hCt+Cn3RhfoOZ7Rm
+4gkpaSkt+7GXlhXHb82YfujNO+hbktEamhUYlQ9EK70Wa8aqmf3gHxO0JgsEFjW8
+lJaSnultlTW8SDcx3LMUUjCYumECk4oX/VlJfmKYjPlVjkr3QQ+Cm3nNucb4K4hc
+c+JL+2ERhSj8RjXL7VgbNgdPnIjvQDJuTNqecTU8xWPYrkOLQpNibbLjnutLkhJz
+fMyRtmDtrsey8WiCDuCHkPJ8/f8RjL2zWI9fzTDDIzdlEKouUFGOovaHVnbua6pn
+hymcu9d9FV3p2rcbj0ivCs7e8j+vhSxFJEJoAbcQdXCTi/n2uR7pLtoMNiUzsejy
+d46Uz+KEU920NTwE2z6JJq8I2vegnxjc7PDDrV3/5rK04B93aXiqvwWseCpxelrI
+xaMkRHbXrIXRO6MXQ3N+zNq8Dg3hjGTTvaBKuwgvqLwlXY8+Aa3ooFzEOInIOSsI
+XcWqXxt/tgZgsj9RwpC42t8kbA+BkbNk9EIUa+P5kEr2P/fO7QKCAQEA4EtArnOX
+D6tQF8uTw8USOZC2P9s/ez1z4jRq3oKP0Kv4tJiuIObJ/dUvGVD7aM5v2xaCfhm8
+xpk09VPUgghfG5jR5qVvQr75kCNToJQudWi4ngk1HwKJzzTO11giFEdybvTUA+Pj
+fmxCM0dYYqRWZoj0hLqXlUCwxE74BFIhJVjeYbf+nTQrqpllTLoW7MTZHzGx5SXx
+4dNzyVAUH49Yt2D8mgXXCkf5sGLh762wj34b/rR10Kr4O5utGMZrfTRIbuQ1pNjU
+m66baPzq+mC0BzqZEW70TgEb7lOr8rcVXLOi3r36omfd9/MHx7iZD6o3K1axSO15
+grD4ZrN7Ac3QJwKCAQEA2heCoBdpvy6YUk8AO2k8qDygTdmPQRuwjjT+Z2fMslBt
+D7DkpKwZ6Bl9OclcpiiLHmH+hv65KqYg+tR0RRb7PcogB9El9x7yKkGTPZEYWGky
+n8P84rJpKwjnwWQvPQktI1cs3YGvZA9DQTFBavRrwuzgd1oSJq5aPQ2tme0kMvWp
+l1/B/cPK+PKCi/Wfisaze1TjijP9qIeUwkdNN6WLrLU3QgsGppcg2I7RQtAIikT6
+GkuiOQAvWMsrJVV6PNrVKz4fJDJ59Rz6jbDHZNi1MEYNxQoB/Pl7QIakbfjWpHLv
+8Ey7cB2JKxjQy8tmyl8WNQVbXbE6daPXcMTUmaRAKwKCAQBv1lYMJmq+T2eCVen6
+BbvOpE+bi5EdvEiaFBTtmiBnpjg+pJq+oRU60h/H+c9CNR0lGxY6Fk9An4f+g6xE
+ojP6KLsQzJCrsVny+wpp2TlJJcxYULMCIVvhy60PR0zG29E9biqBPhJjKUvhEcQK
+e3LxcXyq6fdHXphFajLUxLbuTl+kTgBRFoBnclFGbsubh5PTsA3J+p+fQLZNPPar
+veg4l82cZykQYU8pGkUaI3sUMYd3+zd7sqRP5JHs9pMGPRmY4YW2CsAIWIn5UZNB
+ARMDP76vKKn8cyUgMuxb+9pU/OVLN2NPs4bEaZQJjAwV+YPEwldny7F47xEM9JVz
+EtKlAoIBAQDUt62u3GdGE/p5/ZgqWoDRTyDEDfmN9aYFbmbdEP80xQE7FrxMaZhz
+K7laja6SWmUm40nQ/c45bQQp4uLtKHcxU15egX7YRBTLZl5o5IasZR79ebnEm2O8
+l9kEZeU1USf3mmWmP4GExOZCRfqaiYA6BbUCdJXTqKdXeWnkAssV8UrS3JFoJHpq
+yo7OWGqefyQ8nRW6jO9SW7uaqtUD+7H6aF5XSk3YWvusfdBZrHNH+fM/hpnZovaL
+Us7ogTDS/laA8PyK37jYfMVdQhmZoU1Iomt3zkUWK3gt/aWPpfAlQf4Jka4YspZB
+tNiijefaZ1hPqsPs5Joyd/YAhdsfaHc1AoIBAQCn/9j6RRjRaw0ip756oad4AXHz
+XBwVB2CrY96qT6Hj9Sq7tGgdskqGkOQkAivBLBizUdcWv0t1yenOsSgasQeMlvlh

[PATCH v6 01/23] binman: ti-board-config: Add support for TI board config binaries

2023-07-12 Thread Neha Malcom Francis
The ti-board-config entry loads and validates a given YAML config file
against a given schema, and generates the board config binary. K3
devices require these binaries to be packed into the final system
firmware images.

Signed-off-by: Neha Malcom Francis 
Reviewed-by: Simon Glass 
---
 tools/binman/entries.rst  |  48 
 tools/binman/etype/ti_board_config.py | 259 ++
 tools/binman/ftest.py |  20 ++
 tools/binman/test/277_ti_board_cfg.dts|  14 +
 .../binman/test/278_ti_board_cfg_combined.dts |  25 ++
 .../binman/test/279_ti_board_cfg_no_type.dts  |  11 +
 tools/binman/test/yaml/config.yaml|  19 ++
 tools/binman/test/yaml/schema.yaml|  50 
 tools/binman/test/yaml/schema_notype.yaml |  39 +++
 9 files changed, 485 insertions(+)
 create mode 100644 tools/binman/etype/ti_board_config.py
 create mode 100644 tools/binman/test/277_ti_board_cfg.dts
 create mode 100644 tools/binman/test/278_ti_board_cfg_combined.dts
 create mode 100644 tools/binman/test/279_ti_board_cfg_no_type.dts
 create mode 100644 tools/binman/test/yaml/config.yaml
 create mode 100644 tools/binman/test/yaml/schema.yaml
 create mode 100644 tools/binman/test/yaml/schema_notype.yaml

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index b71af801fd..14a2d03fad 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1658,6 +1658,54 @@ by setting the size of the entry to something larger 
than the text.
 
 
 
+.. _etype_ti_board_config:
+
+Entry: ti-board-config: An entry containing a TI schema validated board config 
binary
+-
+
+This etype supports generation of two kinds of board configuration
+binaries: singular board config binary as well as combined board config
+binary.
+
+Properties / Entry arguments:
+- config-file: File containing board configuration data in YAML
+- schema-file: File containing board configuration YAML schema against
+  which the config file is validated
+
+Output files:
+- board config binary: File containing board configuration binary
+
+These above parameters are used only when the generated binary is
+intended to be a single board configuration binary. Example::
+
+my-ti-board-config {
+ti-board-config {
+config = "board-config.yaml";
+schema = "schema.yaml";
+};
+};
+
+To generate a combined board configuration binary, we pack the
+needed individual binaries into a ti-board-config binary. In this case,
+the available supported subnode names are board-cfg, pm-cfg, sec-cfg and
+rm-cfg. The final binary is prepended with a header containing details about
+the included board config binaries. Example::
+
+my-combined-ti-board-config {
+ti-board-config {
+board-cfg {
+config = "board-cfg.yaml";
+schema = "schema.yaml";
+};
+sec-cfg {
+config = "sec-cfg.yaml";
+schema = "schema.yaml";
+};
+}
+}
+
+
+
 .. _etype_u_boot:
 
 Entry: u-boot: U-Boot flat binary
diff --git a/tools/binman/etype/ti_board_config.py 
b/tools/binman/etype/ti_board_config.py
new file mode 100644
index 00..0799e5dc59
--- /dev/null
+++ b/tools/binman/etype/ti_board_config.py
@@ -0,0 +1,259 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2022 Texas Instruments Incorporated - https://www.ti.com/
+# Written by Neha Malcom Francis 
+#
+# Entry-type module for generating schema validated TI board
+# configuration binary
+#
+
+import os
+import struct
+import yaml
+
+from collections import OrderedDict
+from jsonschema import validate
+from shutil import copyfileobj
+
+from binman.entry import Entry
+from binman.etype.section import Entry_section
+from dtoc import fdt_util
+from u_boot_pylib import tools
+
+BOARDCFG = 0xB
+BOARDCFG_SEC = 0xD
+BOARDCFG_PM = 0xE
+BOARDCFG_RM = 0xC
+BOARDCFG_NUM_ELEMS = 4
+
+class Entry_ti_board_config(Entry_section):
+"""An entry containing a TI schema validated board config binary
+
+This etype supports generation of two kinds of board configuration
+binaries: singular board config binary as well as combined board config
+binary.
+
+Properties / Entry arguments:
+- config-file: File containing board configuration data in YAML
+- schema-file: File containing board configuration YAML schema against
+  which the config file is validated
+
+Output files:
+- board config binary: File containing board configuration binary
+
+These above parameters are used only when the generated binary is
+intended to be a single board configuration binary. Example::
+
+my-ti-board-config {
+ti-board-config {
+config = "board-config.yaml";
+schema = "schema.yaml";
+};
+};
+
+To 

[PATCH v6 00/23] Migration to using binman for bootloader

2023-07-12 Thread Neha Malcom Francis
This series aims to eliminate the use of additional custom repositories
such as k3-image-gen (K3 Image Generation) repo and core-secdev-k3 (K3
Security Development Tools) that was plumbed into the U-Boot build flow
to generate boot images for TI K3 platform devices. And instead, we move
towards using binman that aligns better with the community standard build
flow.

This series uses binman for all K3 platforms supported on U-Boot currently;
both HS (High Security, both SE and FS) and GP (General Purpose) devices.

Background on using k3-image-gen:
* TI K3 devices require a SYSFW (System Firmware) image consisting
of a signed system firmware image and board configuration binaries,
this is needed to bring up system firmware during U-Boot R5 SPL
startup.
* Board configuration data contain board-specific information
such as resource management, power management and security.

Background on using core-secdev-k3:
* Contains resources to sign x509 certificates for HS devices

Series intends to use binman to take over the packaging and signing for
the R5 bootloader images tiboot3.bin (and sysfw.itb, for non-combined
boot flow) instead of k3-image-gen.

Series also packages the A72/A53 bootloader images (tispl.bin and
u-boot.img) using ATF, OPTEE and DM (Device Manager)

Changes in v6:
- addressed whitespace warnings
- added testcase for overwriting symlink functionality
- s%/Arm Trusted Firmware/Trusted Firmware-A
- s%/tee-pager_v2.bin/tee-raw.bin
- k3-am65-iot2050 image fit@0x18 filename changed to
  tispl.bin

Changes in v5:
- updated all board configurations to latest
- changed output binary filenames
- fixed multiple certificate generation leading to packaging
  inconsistency in ti-secure*.py
- added patch to overwrite symlink if exists, patch 21/23
  ("binman: Overwrite symlink if it already exists")

Changes in v4:
- added support for iot2050
- documentation fixes
- move to using self.Raise in ti-board-config etype
- introduced common k3-binman.dtsi (further reduction in code
  duplication can be targeted, this as first step)

Changes in v3:
- added support for HS-FS devices
- added support for AM68-sk
- added back dropped documentation patch
- changed prefix for SYSFW and DM files to expected directory
  name
- extended test coverage to 100%
- documentation fixes
- corrected formatting changes

Changes in v2:
- removed all external scripts
- created ti-board-config etype to support generation of board
  config binaries
- created ti-secure and ti-secure-rom etypes to handle signing
  instead of using external TI_SECURE_DEV_PKG
- updated openssl btool to support x509 certificate generation
- dropped Makefile changes to obtain external binary components,
  moving to using BINMAN_INDIRS to achieve the same

CI/CD passes 100% (series based on -next) [1]

v1: 
https://patchwork.ozlabs.org/project/uboot/cover/20230120101903.179959-1-n-fran...@ti.com/
v2: 
https://patchwork.ozlabs.org/project/uboot/cover/20230404121342.446935-1-n-fran...@ti.com/
v3: 
https://patchwork.ozlabs.org/project/uboot/cover/20230421123203.1315330-1-n-fran...@ti.com/
 
v4: 
https://patchwork.ozlabs.org/project/uboot/cover/20230518142713.184164-1-n-fran...@ti.com/
v5: 
https://patchwork.ozlabs.org/project/uboot/cover/20230707123450.30329-1-n-fran...@ti.com/

[1] https://github.com/u-boot/u-boot/pull/363

Andrew Davis (1):
  binman: Overwrite symlink if it already exists

Neha Malcom Francis (20):
  binman: ti-board-config: Add support for TI board config binaries
  binman: ti-secure: Add support for TI signing
  arm: dts: k3: Add support for packaging sysfw.itb and tiboot3.bin
  j721e: schema: yaml: Add general schema and J721E board config files
  j721e: dts: binman: Package tiboot3.bin, sysfw.itb, tispl.bin,
u-boot.img
  j7200: yaml: Add J7200 board config files
  j7200: dts: binman: Package tiboot3.bin, tispl.bin, u-boot.img
  am65x: yaml: Add AM65x board config files
  am65: dts: binman: Package tiboot3.bin, sysfw.itb, tispl.bin,
u-boot.img
  am64x: yaml: Add board configs for AM64x
  am64x: dts: binman: Package tiboot3.bin, tispl.bin u-boot.img
  j721s2: yaml: Add board configs for J721S2
  j721s2: dts: binman: Package tiboot3.bin, tispl.bin and u-boot.img
  am62: yaml: Add board configs for AM62
  am625: dts: binman: Package tiboot3.bin, tispl.bin and u-boot.img
  am62a: yaml: Add board configs for AM62ax
  am62a: dts: binman: Package tiboot3.bin, tispl.bin, u-boot.img
  arm: k3-am65x-iot2050: Use binman for tispl.bin for iot2050
  k3: tools: config.mk: Update makefile and remove scripts
  doc: board: ti: Update documentation for binman flow

Tom Rini (2):
  buildman: Create a requirements.txt file
  CI: Make 

Re: [PATCH v4] phy: phy-imx8mq-usb: add vbus regulator support

2023-07-12 Thread Tim Harvey
On Wed, Jul 12, 2023 at 10:25 AM Marek Vasut  wrote:
>
> On 7/12/23 18:29, Tim Harvey wrote:
> > On Wed, Jul 12, 2023 at 8:10 AM Tim Harvey  wrote:
> >>
> >> On Wed, Jul 12, 2023 at 2:15 AM Marek Vasut  wrote:
> >>>
> >>> On 7/11/23 22:13, Tim Harvey wrote:
>  On Mon, Jul 10, 2023 at 4:18 PM Marek Vasut  wrote:
> >
> > On 7/11/23 00:49, Tim Harvey wrote:
> >> Add support for enabling and disabling vbus-supply regulator found
> >> on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.
> >>
> >> Signed-off-by: Tim Harvey 
> >> Reviewed-by: Adam Ford 
> >> Reviewed-by: Marek Vasut 
> >> ---
> >> v4:
> >> - use regulator_set_enable_if_allowed to handle regulator 
> >> reference counting
> >>   errors
> >> - added Marek's rb tag
> >>
> >> v3:
> >> - change pr_err to dev_err
> >> - add #if CONFIG_IS_ENABLED around vbus_supply in struct
> >> - add fail path to disable clock if regulator enable failed
> >>
> >> v2:
> >> - protect ret with __maybe_unused in case CONFIG_CLK and
> >>   CONFIG_DM_REGULATOR not defined
> >> - add error prints on failures
> >> - add Adam's rb tag
> >> ---
> >> drivers/phy/phy-imx8mq-usb.c | 39 
> >> ++--
> >> 1 file changed, 37 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/phy/phy-imx8mq-usb.c 
> >> b/drivers/phy/phy-imx8mq-usb.c
> >> index 69f01de55538..6cbcb2338cfe 100644
> >> --- a/drivers/phy/phy-imx8mq-usb.c
> >> +++ b/drivers/phy/phy-imx8mq-usb.c
> >> @@ -14,6 +14,8 @@
> >> #include 
> >> #include 
> >> #include 
> >> +#include 
> >> +#include 
> >>
> >> #define PHY_CTRL0   0x0
> >> #define PHY_CTRL0_REF_SSP_ENBIT(2)
> >> @@ -81,6 +83,9 @@ struct imx8mq_usb_phy {
> >> #endif
> >> void __iomem *base;
> >> enum imx8mpq_phy_type type;
> >> +#if CONFIG_IS_ENABLED(DM_REGULATOR)
> >> + struct udevice *vbus_supply;
> >> +#endif
> >> };
> >>
> >> static const struct udevice_id imx8mq_usb_phy_of_match[] = {
> >> @@ -172,10 +177,10 @@ static int imx8mq_usb_phy_power_on(struct phy 
> >> *usb_phy)
> >> {
> >> struct udevice *dev = usb_phy->dev;
> >> struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> >> + __maybe_unused int ret;
> >> u32 value;
> >>
> >> #if CONFIG_IS_ENABLED(CLK)
> >> - int ret;
> >> ret = clk_enable(_phy->phy_clk);
> >> if (ret) {
> >> printf("Failed to enable usb phy clock\n");
> >> @@ -183,18 +188,31 @@ static int imx8mq_usb_phy_power_on(struct phy 
> >> *usb_phy)
> >> }
> >> #endif
> >>
> >> + if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> >> + ret = 
> >> regulator_set_enable_if_allowed(imx_phy->vbus_supply, true);
> >> + if (ret && ret != -ENOSYS) {
> >> + dev_err(dev, "Failed to enable VBUS regulator: 
> >> %d\n", ret);
> >> + goto err;
> >> + }
> >> + }
> >> +
> >> /* Disable rx term override */
> >> value = readl(imx_phy->base + PHY_CTRL6);
> >> value &= ~PHY_CTRL6_RXTERM_OVERRIDE_SEL;
> >> writel(value, imx_phy->base + PHY_CTRL6);
> >>
> >> return 0;
> >> +
> >> +err:
> >> + clk_disable(_phy->phy_clk);
> >> + return ret;
> >> }
> >>
> >> static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
> >> {
> >> struct udevice *dev = usb_phy->dev;
> >> struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> >> + __maybe_unused int ret;
> >> u32 value;
> >>
> >> /* Override rx term to be 0 */
> >> @@ -206,6 +224,14 @@ static int imx8mq_usb_phy_power_off(struct phy 
> >> *usb_phy)
> >> clk_disable(_phy->phy_clk);
> >> #endif
> >>
> >> + if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> >> + ret = 
> >> regulator_set_enable_if_allowed(imx_phy->vbus_supply, false);
> >> + if (ret && ret != -ENOSYS) {
> >> + dev_err(dev, "Failed to disable VBUS regulator: 
> >> %d\n", ret);
> >> + return ret;
> >> + }
> >> + }
> >> +
> >> return 0;
> >> }
> >>
> >> @@ -224,6 +250,7 @@ struct phy_ops imx8mq_usb_phy_ops = {
> >> int imx8mq_usb_phy_probe(struct udevice *dev)
> >> {
> >> struct imx8mq_usb_phy *priv = dev_get_priv(dev);
> >> + __maybe_unused int ret;
> >>
> >> priv->type 

Re: [PATCH v4] phy: phy-imx8mq-usb: add vbus regulator support

2023-07-12 Thread Marek Vasut

On 7/12/23 18:29, Tim Harvey wrote:

On Wed, Jul 12, 2023 at 8:10 AM Tim Harvey  wrote:


On Wed, Jul 12, 2023 at 2:15 AM Marek Vasut  wrote:


On 7/11/23 22:13, Tim Harvey wrote:

On Mon, Jul 10, 2023 at 4:18 PM Marek Vasut  wrote:


On 7/11/23 00:49, Tim Harvey wrote:

Add support for enabling and disabling vbus-supply regulator found
on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.

Signed-off-by: Tim Harvey 
Reviewed-by: Adam Ford 
Reviewed-by: Marek Vasut 
---
v4:
- use regulator_set_enable_if_allowed to handle regulator reference counting
  errors
- added Marek's rb tag

v3:
- change pr_err to dev_err
- add #if CONFIG_IS_ENABLED around vbus_supply in struct
- add fail path to disable clock if regulator enable failed

v2:
- protect ret with __maybe_unused in case CONFIG_CLK and
  CONFIG_DM_REGULATOR not defined
- add error prints on failures
- add Adam's rb tag
---
drivers/phy/phy-imx8mq-usb.c | 39 ++--
1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/phy-imx8mq-usb.c b/drivers/phy/phy-imx8mq-usb.c
index 69f01de55538..6cbcb2338cfe 100644
--- a/drivers/phy/phy-imx8mq-usb.c
+++ b/drivers/phy/phy-imx8mq-usb.c
@@ -14,6 +14,8 @@
#include 
#include 
#include 
+#include 
+#include 

#define PHY_CTRL0   0x0
#define PHY_CTRL0_REF_SSP_ENBIT(2)
@@ -81,6 +83,9 @@ struct imx8mq_usb_phy {
#endif
void __iomem *base;
enum imx8mpq_phy_type type;
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
+ struct udevice *vbus_supply;
+#endif
};

static const struct udevice_id imx8mq_usb_phy_of_match[] = {
@@ -172,10 +177,10 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
{
struct udevice *dev = usb_phy->dev;
struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
+ __maybe_unused int ret;
u32 value;

#if CONFIG_IS_ENABLED(CLK)
- int ret;
ret = clk_enable(_phy->phy_clk);
if (ret) {
printf("Failed to enable usb phy clock\n");
@@ -183,18 +188,31 @@ static int imx8mq_usb_phy_power_on(struct phy *usb_phy)
}
#endif

+ if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
+ ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, true);
+ if (ret && ret != -ENOSYS) {
+ dev_err(dev, "Failed to enable VBUS regulator: %d\n", 
ret);
+ goto err;
+ }
+ }
+
/* Disable rx term override */
value = readl(imx_phy->base + PHY_CTRL6);
value &= ~PHY_CTRL6_RXTERM_OVERRIDE_SEL;
writel(value, imx_phy->base + PHY_CTRL6);

return 0;
+
+err:
+ clk_disable(_phy->phy_clk);
+ return ret;
}

static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
{
struct udevice *dev = usb_phy->dev;
struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
+ __maybe_unused int ret;
u32 value;

/* Override rx term to be 0 */
@@ -206,6 +224,14 @@ static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
clk_disable(_phy->phy_clk);
#endif

+ if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
+ ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, 
false);
+ if (ret && ret != -ENOSYS) {
+ dev_err(dev, "Failed to disable VBUS regulator: %d\n", 
ret);
+ return ret;
+ }
+ }
+
return 0;
}

@@ -224,6 +250,7 @@ struct phy_ops imx8mq_usb_phy_ops = {
int imx8mq_usb_phy_probe(struct udevice *dev)
{
struct imx8mq_usb_phy *priv = dev_get_priv(dev);
+ __maybe_unused int ret;

priv->type = dev_get_driver_data(dev);
priv->base = dev_read_addr_ptr(dev);
@@ -232,7 +259,6 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
return -EINVAL;

#if CONFIG_IS_ENABLED(CLK)
- int ret;


I _think_ if you were to convert this #if CONFIG...() to if
(CONFIG...()), you would be able to drop the __maybe_unused . Separate
conversion patch would be better though.


Hi Marek,


Hi,


Yes, I thought about that as well and felt it should be a separate
followup cleanup patch.


Can you please send such a follow up patch ?



Yes, I'll send a follow-up today. It looks like Stefano is picking
this up from the imx tree... is that where it should be picked up or
should this be through you and the usb tree?



Marek,

It seems Stefano picked up my v2 version of this patch in his
master/next tree he's working on right now [1].


Likely this patch should be dropped from imx tree.


Also, I noticed my v4 patch here fails building if DM_REGULATOR is
disabled. You can't wrap the struct members with macro's to save space
if you're doing runtime comparisons.

For example:

struct imx8mq_usb_phy {
#if CONFIG_IS_ENABLED(CLK)
 struct clk phy_clk;
#endif
 void __iomem 

Re: [PATCH v4 0/4] SPL NVMe support

2023-07-12 Thread Tom Rini
On Wed, Jul 12, 2023 at 03:27:45PM +0200, Heinrich Schuchardt wrote:
> On 12.07.23 15:06, mchit...@ventanamicro.com wrote:
> > Hi Tom,
> > 
> > On Tue, 2023-06-20 at 09:37 -0400, Tom Rini wrote:
> > > On Sat, 03 Jun 2023 19:32:52 +0530, Mayuresh Chitale wrote:
> > > 
> > > > This patchset adds support to load images of the SPL's next booting
> > > > stage from a NVMe device.
> > > > 
> > > > Changes in v4:
> > > > - Drop patch 4
> > > > - Modify patch 2 to use generic fs.h APIs
> > > > 
> > > > [...]
> > > 
> > > With one change, which is that the "disk/part.c" in 4/4 were not
> > > required for
> > > any platform in tree and also broke testcases, and so was dropped,
> > > this has now
> > > been applied to u-boot/next. If you can explain a bit more what the
> > > problem you
> > > had was, we can look in to it. I suspect you need to test for not
> > > SPL_ENV_SUPPORT  but ENV_SUPPORT itself.
> > > 
> > Thanks.
> > When SPL_NVME is enabled the build breaks with the following error:
> > riscv64-unknown-linux-gnu-ld.bfd: disk/part.o: in function
> > `blk_get_device_part_str':
> > u-boot/disk/part.c:473: undefined reference to `env_get'
> > make[2]: *** [u-boot/scripts/Makefile.spl:527: spl/u-boot-spl] Error 1
> > make[1]: *** [/u-boot/Makefile:2053: spl/u-boot-spl] Error 2
> > 
> > One possible fix is:
> > 
> > if ((!IS_ENABLED(CONFIG_SPL) && IS_ENABLED(CONFIG_ENV_SUPPORT)) ||
> > (IS_ENABLED(CONFIG_SPL) && IS_ENABLED(CONFIG_SPL_ENV_SUPPORT)))
> > if (!dev_part_str || !strlen(dev_part_str)
> > || !strcmp(dev_part_str, "-"))
> > dev_part_str = env_get("bootdevice");
> > 
> > 
> 
> I think CONFIG_SPL_ENV_SUPPORT should depend on CONFIG_ENV_SUPPORT in
> common/spl/Kconfig.

Not strictly, but checking for CONFIG_IS_ENABLED(ENV_SUPPORT) should do
what's desired here?

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] CI: Add automatic retry for test.py jobs

2023-07-12 Thread Tom Rini
On Wed, Jul 12, 2023 at 08:00:23AM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Tue, 11 Jul 2023 at 20:33, Tom Rini  wrote:
> >
> > It is not uncommon for some of the QEMU-based jobs to fail not because
> > of a code issue but rather because of a timing issue or similar problem
> > that is out of our control. Make use of the keywords that Azure and
> > GitLab provide so that we will automatically re-run these when they fail
> > 2 times. If they fail that often it is likely we have found a real issue
> > to investigate.
> >
> > Signed-off-by: Tom Rini 
> > ---
> >  .azure-pipelines.yml | 1 +
> >  .gitlab-ci.yml   | 1 +
> >  2 files changed, 2 insertions(+)
> 
> This seems like a slippery slope. Do we know why things fail? I wonder
> if we should disable the tests / builders instead, until it can be
> corrected?

It happens in Azure, so it's not just the broken runner problem we have
in GitLab. And the problem is timing, as I said in the commit.
Sometimes we still get the RTC test failing. Other times we don't get
QEMU + U-Boot spawned in time (most often m68k, but sometimes x86).

> I'll note that we don't have this problem with sandbox tests.

OK, but that's not relevant?

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v2 3/3] board: rockchip: Add Hardkernel ODROID-M1

2023-07-12 Thread Jonas Karlman
Hardkernel ODROID-M1 is a single board computer with a RK3568B2 SoC,
a slightly modified version of the RK3568 SoC.

Features tested on a ODROID-M1 8GB v1.0 2022-06-13:
- SD-card boot
- eMMC boot
- SPI Flash boot
- PCIe/NVMe/AHCI
- SATA port
- USB host

Device tree is imported from linux v6.4.

Signed-off-by: Jonas Karlman 
Reviewed-by: Stefan Agner 
Tested-by: Stefan Agner 
---
v2:
- Enable CMD_MTD, CMD_INI and CMD_CRAMFS to closer
  match downstream legacy U-Boot
- Do not override spi0 alias, use SF_DEFAULT_BUS=4
- Collect r-b and t-b tags

 arch/arm/dts/Makefile |   1 +
 arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi |  42 ++
 arch/arm/dts/rk3568-odroid-m1.dts | 744 ++
 arch/arm/mach-rockchip/rk3568/Kconfig |   6 +
 board/hardkernel/odroid_m1/Kconfig|  15 +
 board/hardkernel/odroid_m1/MAINTAINERS|   8 +
 board/hardkernel/odroid_m1/Makefile   |   3 +
 board/hardkernel/odroid_m1/odroid_m1.c|   1 +
 configs/odroid-m1-rk3568_defconfig| 113 
 doc/board/rockchip/rockchip.rst   |   1 +
 include/configs/odroid_m1.h   |  11 +
 11 files changed, 945 insertions(+)
 create mode 100644 arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3568-odroid-m1.dts
 create mode 100644 board/hardkernel/odroid_m1/Kconfig
 create mode 100644 board/hardkernel/odroid_m1/MAINTAINERS
 create mode 100644 board/hardkernel/odroid_m1/Makefile
 create mode 100644 board/hardkernel/odroid_m1/odroid_m1.c
 create mode 100644 configs/odroid-m1-rk3568_defconfig
 create mode 100644 include/configs/odroid_m1.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 480269fa6065..334c1bafda17 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -169,6 +169,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3568) += \
rk3566-anbernic-rgxx3.dtb \
rk3566-radxa-cm3-io.dtb \
rk3568-evb.dtb \
+   rk3568-odroid-m1.dtb \
rk3568-rock-3a.dtb
 
 dtb-$(CONFIG_ROCKCHIP_RK3588) += \
diff --git a/arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi 
b/arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi
new file mode 100644
index ..cbfa3a35913b
--- /dev/null
+++ b/arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include "rk356x-u-boot.dtsi"
+
+/ {
+   chosen {
+   stdout-path = 
+   };
+};
+
+_dual_io_pins {
+   bootph-all;
+};
+
+ {
+   cap-mmc-highspeed;
+   mmc-ddr-1_8v;
+   mmc-hs200-1_8v;
+   mmc-hs400-1_8v;
+   mmc-hs400-enhanced-strobe;
+   pinctrl-0 = <_bus8 _clk _cmd _datastrobe>;
+};
+
+ {
+   bootph-pre-ram;
+   u-boot,spl-sfc-no-dma;
+
+   flash@0 {
+   bootph-pre-ram;
+   };
+};
+
+ {
+   bootph-all;
+   clock-frequency = <2400>;
+   status = "okay";
+};
+
+_usb_host {
+   /* Workaround until regulator implement basic reference counter */
+   regulator-always-on;
+};
diff --git a/arch/arm/dts/rk3568-odroid-m1.dts 
b/arch/arm/dts/rk3568-odroid-m1.dts
new file mode 100644
index ..59ecf868dbd0
--- /dev/null
+++ b/arch/arm/dts/rk3568-odroid-m1.dts
@@ -0,0 +1,744 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2022 Hardkernel Co., Ltd.
+ *
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include 
+#include "rk3568.dtsi"
+
+/ {
+   model = "Hardkernel ODROID-M1";
+   compatible = "rockchip,rk3568-odroid-m1", "rockchip,rk3568";
+
+   aliases {
+   ethernet0 = 
+   i2c0 = 
+   i2c3 = 
+   mmc0 = 
+   mmc1 = 
+   serial0 = 
+   serial1 = 
+   };
+
+   chosen {
+   stdout-path = "serial2:150n8";
+   };
+
+   dc_12v: dc-12v-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "dc_12v";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   };
+
+   hdmi-con {
+   compatible = "hdmi-connector";
+   type = "a";
+
+   port {
+   hdmi_con_in: endpoint {
+   remote-endpoint = <_out_con>;
+   };
+   };
+   };
+
+   ir-receiver {
+   compatible = "gpio-ir-receiver";
+   gpios = < RK_PC2 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_receiver_pin>;
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led_power: led-0 {
+   gpios = < RK_PC6 GPIO_ACTIVE_HIGH>;
+   function = LED_FUNCTION_POWER;
+   color = ;
+   default-state = "keep";
+   linux,default-trigger = "default-on";
+   

[PATCH v2 2/3] cmd: ini: Fix build warning

2023-07-12 Thread Jonas Karlman
Building U-Boot with CMD_INI=y result in following build warning:

  cmd/ini.c: In function 'memgets':
  include/linux/kernel.h:184:24: warning: comparison of distinct pointer types 
lacks a cast
184 | (void) (&_min1 == &_min2);  \
|^~
  cmd/ini.c:92:15: note: in expansion of macro 'min'
 92 | len = min((end - *mem) + newline, num);
|   ^~~

Fix this by adding an int cast to the pointer arithmetic result.

Signed-off-by: Jonas Karlman 
---
v2:
- New patch

 cmd/ini.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/ini.c b/cmd/ini.c
index 81dfc4c4e83d..35de2373e602 100644
--- a/cmd/ini.c
+++ b/cmd/ini.c
@@ -89,7 +89,7 @@ static char *memgets(char *str, int num, char **mem, size_t 
*memsize)
end = *mem + *memsize;
newline = 0;
}
-   len = min((end - *mem) + newline, num);
+   len = min((int)(end - *mem) + newline, num);
memcpy(str, *mem, len);
if (len < num)
str[len] = '\0';
-- 
2.41.0



[PATCH v2 1/3] ata: dwc_ahci: Fix support for other platforms

2023-07-12 Thread Jonas Karlman
The dwc_ahci driver use platform specific defines, place the platform
specific code behind a ifdef CONFIG_ARCH_OMAP2PLUS to allow build and
use of the driver on Rockchip platform.

Fixes: 02a4b4297901 ("drivers: block: dwc_ahci: Implement a driver for Synopsys 
DWC sata device")
Signed-off-by: Jonas Karlman 
---
v2:
- No changes

 drivers/ata/dwc_ahci.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/ata/dwc_ahci.c b/drivers/ata/dwc_ahci.c
index 826fea71cc5b..1dc91e7fce70 100644
--- a/drivers/ata/dwc_ahci.c
+++ b/drivers/ata/dwc_ahci.c
@@ -13,7 +13,9 @@
 #include 
 #include 
 #include 
+#ifdef CONFIG_ARCH_OMAP2PLUS
 #include 
+#endif
 #include 
 #include 
 
@@ -72,12 +74,14 @@ static int dwc_ahci_probe(struct udevice *dev)
return ret;
}
 
+#ifdef CONFIG_ARCH_OMAP2PLUS
if (priv->wrapper_base) {
u32 val = TI_SATA_IDLE_NO | TI_SATA_STANDBY_NO;
 
/* Enable SATA module, No Idle, No Standby */
writel(val, priv->wrapper_base + TI_SATA_SYSCONFIG);
}
+#endif
 
return ahci_probe_scsi(dev, (ulong)priv->base);
 }
-- 
2.41.0



[PATCH v2 0/3] board: rockchip: Add Hardkernel ODROID-M1

2023-07-12 Thread Jonas Karlman
This series add support for Hardkernel ODROID-M1, a single board
computer with a RK3568B2 SoC.

First patch fixes a build issue in the dwc_ahci driver.

Second patch fixes a build warning in the ini command.

Third patch import the device tree from linux v6.4 and add a defconfig
for Hardkernel ODROID-M1.

Following was tested on a ODROID-M1 8GB v1.0 2022-06-13:
- SD-card boot
- eMMC boot
- SPI Flash boot
- PCIe/NVMe/AHCI
- SATA port
- USB host

Changes in v2:
- Add new patch to fix build warning in the ini command
- Enable CMD_MTD, CMD_INI and CMD_CRAMFS to closer
  match downstream legacy U-Boot
- Do not override spi0 alias, use SF_DEFAULT_BUS=4
- Collect r-b and t-b tags

With the new options added in v2 it is possible to load downstream
petitboot from SD-card using following commands:

  load mmc 1:1 $fdt_addr_r rk3568-odroid-m1.dtb
  load mmc 1:1 $cramfsaddr ODROIDBIOS.BIN
  cramfsload $scriptaddr boot.scr
  source $scriptaddr

This series have loose dependencies on the following series:
- rockchip: Fix PCIe and NVMe support on RK3568 [1]
- rockchip: rk3568: Use dwc3-generic driver [2]
- rockchip: rk3568: Fix alloc space exhausted in SPL [3]
- rockchip: rk3568: Device Tree updates [4]
- rockchip: rk35xx: Fix SPI Flash alias [5]

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=355486
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=357200
[3] https://patchwork.ozlabs.org/project/uboot/list/?series=361999
[4] https://patchwork.ozlabs.org/project/uboot/list/?series=362030
[5] https://patchwork.ozlabs.org/project/uboot/list/?series=363527

Jonas Karlman (3):
  ata: dwc_ahci: Fix support for other platforms
  cmd: ini: Fix build warning
  board: rockchip: Add Hardkernel ODROID-M1

 arch/arm/dts/Makefile |   1 +
 arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi |  42 ++
 arch/arm/dts/rk3568-odroid-m1.dts | 744 ++
 arch/arm/mach-rockchip/rk3568/Kconfig |   6 +
 board/hardkernel/odroid_m1/Kconfig|  15 +
 board/hardkernel/odroid_m1/MAINTAINERS|   8 +
 board/hardkernel/odroid_m1/Makefile   |   3 +
 board/hardkernel/odroid_m1/odroid_m1.c|   1 +
 cmd/ini.c |   2 +-
 configs/odroid-m1-rk3568_defconfig| 113 
 doc/board/rockchip/rockchip.rst   |   1 +
 drivers/ata/dwc_ahci.c|   4 +
 include/configs/odroid_m1.h   |  11 +
 13 files changed, 950 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3568-odroid-m1.dts
 create mode 100644 board/hardkernel/odroid_m1/Kconfig
 create mode 100644 board/hardkernel/odroid_m1/MAINTAINERS
 create mode 100644 board/hardkernel/odroid_m1/Makefile
 create mode 100644 board/hardkernel/odroid_m1/odroid_m1.c
 create mode 100644 configs/odroid-m1-rk3568_defconfig
 create mode 100644 include/configs/odroid_m1.h

-- 
2.41.0



Re: [PATCH 2/2] board: rockchip: Add Hardkernel ODROID-M1

2023-07-12 Thread Jonas Karlman
On 2023-07-06 14:23, Stefan Agner wrote:
> On 2023-07-06 07:08, Jonas Karlman wrote:
>> On 2023-07-06 01:27, Stefan Agner wrote:
>>> On 2023-07-02 22:47, Jonas Karlman wrote:
 Hardkernel ODROID-M1 is a single board computer with a RK3568B2 SoC,
 a slightly modified version of the RK3568 SoC.

 Features tested on a ODROID-M1 8GB v1.0 2022-06-13:
 - SD-card boot
 - eMMC boot
 - SPI Flash boot
 - PCIe/NVMe/AHCI
 - SATA port
 - USB host

 Device tree is imported from linux v6.4.

 Signed-off-by: Jonas Karlman 
>>>
>>> Thanks for you patch! I've compared it to my version, and did not notice
>>> any downside/anything missing. If anything, your version is more feature
>>> complete. I've also tested it on an ODORID-M1 with 8GB of memory, it
>>> boots fine from SD card.
>>>
>>> Reviewed-by: Stefan Agner 
>>> Tested-by: Stefan Agner 
>>
>> Thanks for review and testing!
>>
>>>
>>> One thing I've noticed is that USB isn't working when I use the stock
>>> SPL (2017.09) running from the SPI RAM and upstream U-Boot (by writing
>>> u-boot.itb to a raw GPT partition named "uboot" to the SD-card). That is
>>> the same in my patchset. If the upstream SPL is used, things work. It
>>> seems that something is not (re)initialized in U-Boot. Not sure if we
>>> typically rely on the state the SPL leaves the HW at, but it would be
>>> nice if we are able to make that combination work. This allows to boot
>>> an upstream U-Boot from an SD-card without having to reflash the onboard
>>> SPI.
>>
>> Trying to use a combo of vendor u-boot SPL and mainline U-Boot proper is
>> not something I have tested or something I would recommend anyone to use.
>> To make use of all features one should press the "SPI recovery switch"
>> during boot or erase/replace U-Boot in SPI flash.
> 
> Yeah I understand that this is the correct way of doing things.
> 
> For Home Assistant OS we try to build an easy to use image which can be
> flashed to the SD card/eMMC and then booted directly. Unfortunately, the
> board doesn't allow to boot straight from eMMC/SD card. I'd prefer if we
> don't have to touch the SPI flash to avoid complexity and allow users to
> easily switch back to whatever the vendor offers.
> 
> In a way, this is similar to how things work on x86-64, to leave the
> BIOS (in this case SPL on SPI flash) up to the hardware vendor.

I will shortly send a v2 that enables a few more Kconfig options and
also did a quick test starting petitboot from mainline U-Boot.

> 
> I understand that this gets into out-of-scope/unsupported territory. I
> posing the question opportunistically: Since you worked with the
> platform quite a bit maybe you have a good guess/idea what could be the
> culprit.
> 
>>
>> Does this USB issue only affect U-Boot proper or also leave USB unusable
>> in linux? Booting OS from USB3 have been a little bit random when I have
>> tested, some of my USB3 devices work if plugged in from cold start
>> others needs to be removed and plugged in again for U-Boot to recognize
>> them. USB2 ports have been much more stable during my testing.
> 
> USB is usable on Linux, so this is just U-Boot. I've tested with a USB
> 2.0 flash drive.

Looks like vendor u-boot assert pipephy and suspend usb phy, see [3].
This could be related to the USB issue using vendor SPL.

[3] 
https://github.com/hardkernel/u-boot/blob/odroidm1-v2017.09/arch/arm/mach-rockchip/rk3568/rk3568.c#L873-L886

> 
>>
>>>
>>> On a different note: Do you know if PCIe/NVMe support in SPL is
>>> something which is in the cards for this board?
>>
>> As mentioned in the cover-letter this series has some dependencies for
>> all features enabled in defconfig to work, most notably PCIe/NVMe.
>>
>> You can use my rk3568-2023.07-rc6 branch at [1] that have all
>> dependencies included or test with an artifact from my github actions
>> test build workflow at [2].
>>
>> Or do you mean SPL to load FIT (U-Boot proper and TF-A) from NVMe?
> 
> Yes, I meant using the SPL to load the U-Boot FIT image from NVMe.

A "SPL NVMe support" series, see [4], was merged into next and now
master. Could be something to look into for loading FIT from NVMe.

[4] 
https://patchwork.ozlabs.org/project/uboot/cover/20230603140256.2443518-1-mchit...@ventanamicro.com/

Regards,
Jonas

> 
> --
> Stefan
> 
>>
>> [1] https://github.com/Kwiboo/u-boot-rockchip/commits/rk3568-2023.07-rc6
>> [2] https://github.com/Kwiboo/u-boot-build/actions/runs/5448465108
>>
>> Regards,
>> Jonas
>>
>>>
>>> --
>>> Stefan
>>>
 ---
  arch/arm/dts/Makefile |   1 +
  arch/arm/dts/rk3568-odroid-m1-u-boot.dtsi |  46 ++
  arch/arm/dts/rk3568-odroid-m1.dts | 744 ++
  board/rockchip/evb_rk3568/MAINTAINERS |   7 +
  configs/odroid-m1-rk3568_defconfig| 103 +++
  doc/board/rockchip/rockchip.rst   |   1 +
  6 files changed, 902 insertions(+)
  create mode 100644 

Re: [PATCH v4] phy: phy-imx8mq-usb: add vbus regulator support

2023-07-12 Thread Tim Harvey
On Wed, Jul 12, 2023 at 8:10 AM Tim Harvey  wrote:
>
> On Wed, Jul 12, 2023 at 2:15 AM Marek Vasut  wrote:
> >
> > On 7/11/23 22:13, Tim Harvey wrote:
> > > On Mon, Jul 10, 2023 at 4:18 PM Marek Vasut  wrote:
> > >>
> > >> On 7/11/23 00:49, Tim Harvey wrote:
> > >>> Add support for enabling and disabling vbus-supply regulator found
> > >>> on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.
> > >>>
> > >>> Signed-off-by: Tim Harvey 
> > >>> Reviewed-by: Adam Ford 
> > >>> Reviewed-by: Marek Vasut 
> > >>> ---
> > >>> v4:
> > >>>- use regulator_set_enable_if_allowed to handle regulator reference 
> > >>> counting
> > >>>  errors
> > >>>- added Marek's rb tag
> > >>>
> > >>> v3:
> > >>>- change pr_err to dev_err
> > >>>- add #if CONFIG_IS_ENABLED around vbus_supply in struct
> > >>>- add fail path to disable clock if regulator enable failed
> > >>>
> > >>> v2:
> > >>>- protect ret with __maybe_unused in case CONFIG_CLK and
> > >>>  CONFIG_DM_REGULATOR not defined
> > >>>- add error prints on failures
> > >>>- add Adam's rb tag
> > >>> ---
> > >>>drivers/phy/phy-imx8mq-usb.c | 39 
> > >>> ++--
> > >>>1 file changed, 37 insertions(+), 2 deletions(-)
> > >>>
> > >>> diff --git a/drivers/phy/phy-imx8mq-usb.c b/drivers/phy/phy-imx8mq-usb.c
> > >>> index 69f01de55538..6cbcb2338cfe 100644
> > >>> --- a/drivers/phy/phy-imx8mq-usb.c
> > >>> +++ b/drivers/phy/phy-imx8mq-usb.c
> > >>> @@ -14,6 +14,8 @@
> > >>>#include 
> > >>>#include 
> > >>>#include 
> > >>> +#include 
> > >>> +#include 
> > >>>
> > >>>#define PHY_CTRL0   0x0
> > >>>#define PHY_CTRL0_REF_SSP_ENBIT(2)
> > >>> @@ -81,6 +83,9 @@ struct imx8mq_usb_phy {
> > >>>#endif
> > >>>void __iomem *base;
> > >>>enum imx8mpq_phy_type type;
> > >>> +#if CONFIG_IS_ENABLED(DM_REGULATOR)
> > >>> + struct udevice *vbus_supply;
> > >>> +#endif
> > >>>};
> > >>>
> > >>>static const struct udevice_id imx8mq_usb_phy_of_match[] = {
> > >>> @@ -172,10 +177,10 @@ static int imx8mq_usb_phy_power_on(struct phy 
> > >>> *usb_phy)
> > >>>{
> > >>>struct udevice *dev = usb_phy->dev;
> > >>>struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> > >>> + __maybe_unused int ret;
> > >>>u32 value;
> > >>>
> > >>>#if CONFIG_IS_ENABLED(CLK)
> > >>> - int ret;
> > >>>ret = clk_enable(_phy->phy_clk);
> > >>>if (ret) {
> > >>>printf("Failed to enable usb phy clock\n");
> > >>> @@ -183,18 +188,31 @@ static int imx8mq_usb_phy_power_on(struct phy 
> > >>> *usb_phy)
> > >>>}
> > >>>#endif
> > >>>
> > >>> + if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> > >>> + ret = 
> > >>> regulator_set_enable_if_allowed(imx_phy->vbus_supply, true);
> > >>> + if (ret && ret != -ENOSYS) {
> > >>> + dev_err(dev, "Failed to enable VBUS regulator: 
> > >>> %d\n", ret);
> > >>> + goto err;
> > >>> + }
> > >>> + }
> > >>> +
> > >>>/* Disable rx term override */
> > >>>value = readl(imx_phy->base + PHY_CTRL6);
> > >>>value &= ~PHY_CTRL6_RXTERM_OVERRIDE_SEL;
> > >>>writel(value, imx_phy->base + PHY_CTRL6);
> > >>>
> > >>>return 0;
> > >>> +
> > >>> +err:
> > >>> + clk_disable(_phy->phy_clk);
> > >>> + return ret;
> > >>>}
> > >>>
> > >>>static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
> > >>>{
> > >>>struct udevice *dev = usb_phy->dev;
> > >>>struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> > >>> + __maybe_unused int ret;
> > >>>u32 value;
> > >>>
> > >>>/* Override rx term to be 0 */
> > >>> @@ -206,6 +224,14 @@ static int imx8mq_usb_phy_power_off(struct phy 
> > >>> *usb_phy)
> > >>>clk_disable(_phy->phy_clk);
> > >>>#endif
> > >>>
> > >>> + if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> > >>> + ret = 
> > >>> regulator_set_enable_if_allowed(imx_phy->vbus_supply, false);
> > >>> + if (ret && ret != -ENOSYS) {
> > >>> + dev_err(dev, "Failed to disable VBUS regulator: 
> > >>> %d\n", ret);
> > >>> + return ret;
> > >>> + }
> > >>> + }
> > >>> +
> > >>>return 0;
> > >>>}
> > >>>
> > >>> @@ -224,6 +250,7 @@ struct phy_ops imx8mq_usb_phy_ops = {
> > >>>int imx8mq_usb_phy_probe(struct udevice *dev)
> > >>>{
> > >>>struct imx8mq_usb_phy *priv = dev_get_priv(dev);
> > >>> + __maybe_unused int ret;
> > >>>
> > >>>priv->type = dev_get_driver_data(dev);
> > >>>priv->base = dev_read_addr_ptr(dev);
> > >>> @@ -232,7 +259,6 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
> > >>>return -EINVAL;
> > >>>
> > >>>#if CONFIG_IS_ENABLED(CLK)
> > >>> - int ret;
> > >>
> > >> I _think_ if you 

Please pull u-boot-dm

2023-07-12 Thread Simon Glass
Hi Tom.

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


The following changes since commit 8e21064cb3452950b09301baec06d86e37342471:

  Merge tag 'efi-2023-07-rc7' of
https://source.denx.de/u-boot/custodians/u-boot-efi (2023-07-11
13:27:32 -0400)

are available in the Git repository at:

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

for you to fetch changes up to 45aa7ac492d90ddc2977ea6c9d161e7cc487:

  tools: Fix package discovery in pyproject.toml of u_boot_pylib.
(2023-07-12 09:48:19 -0600)


misc fixes
buildman refactoring (no functional change)


Eugen Hristev (1):
  dm: core: of_access: fix return value in of_property_match_string

Heinrich Schuchardt (1):
  cmd: fix loads, saves on sandbox

John Clark (1):
  bootstd: USB devtype detection for script boot

John Keeping (1):
  core: read: fix dev_read_addr_size()

Maxim Cournoyer (2):
  tools: Fix README file in pyproject.toml of u_boot_pylib.
  tools: Fix package discovery in pyproject.toml of u_boot_pylib.

Sergei Antonov (1):
  sandbox: fix a compilation error

Simon Glass (62):
  buildman: Fix verboose typo and add comment
  buildman: Provide an argument to the -R option
  buildman: Tidy up pylint warnings in main
  buildman: Convert camel case in control.py
  buildman: Fix most pylint warnings in control
  buildman: Move full-help processing to main
  buildman: Move series calculations into a separate function
  buildman: Move fetch-arch code into a separate function
  buildman: Add a test for the -A option
  buildman: Drop use of builder in show_actions()
  buildman: Move dry-run handling higher in do_buildman()
  buildman: Move board-selection code into a function
  buildman: Move more code to determine_series()
  buildman: Move Boards-object code into a function
  buildman: Move toolchain handling to a function
  buildman: Set up output_dir earlier
  buildman: Move output-file setup into one place
  buildman: Pass option values to get_action_summary()
  buildman: Pass option values to show_actions()
  buildman: Build option-adjusting into a function
  buildman: Move counting of commits into a function
  buildman: Move setting up the output dir into a function
  buildman: Move commit numbering into determine_series()
  buildman: Avoid too many returns in do_buildman()
  buildman: Move remaining builder properties to constructor
  buildman: Tweak commits and show_bloat
  buildman: Moving running of the builder into a function
  buildman: Drop some unnecessary variables
  buildman: Adjust show_toolchain_prefix() to not return
  buildman: Move checking for make into run_builder()
  buildman: Move getting the adjust_cfg into run_builder()
  buildman: Use get_alow_missing() directly to avoid var
  buildman: Create a function to get number of built commits
  buildman: Convert camel case in cmdline.py
  buildman: Correct most pylint warnings in cmdline
  buildman: Add a test for --boards
  buildman: Convert to argparse
  buildman: Convert camel case in bsettings.py
  buildman: Convert camel case in builder.py
  buildman: Split parser creation in two
  buildman: Convert camel case in builderthread.py
  buildman: Correct most pylint warnings in builderthread
  buildman: Export _get_output_dir() to avoid warnings
  buildman: Correct invalid use of out_dir variable
  buildman: Drop unnecessary assignment of config_out
  buildman: Start a function to set up the make arguments
  buildman: Move setting of toolchain arguments to _build_args()
  buildman: Move more things into _build_args()
  buildman: Convert config_out to string IO
  buildman: Move reconfigure code into its own function
  buildman: Move bulid code into its own function
  buildman: Move reading of the done file into a function
  buildman: Move code to remove old outputs
  buildman: Move code to decide output dirs
  buildman: Move checkout code to a separate function
  buildman: Create a function to handle config and build
  buildman: Avoid passing result into _read_done_file()
  buildman: Tidy up reporting of a toolchain error
  buildman: Tidy up some comments in builderthread
  buildman: Move copy_files() out ot BuilderThread class
  buildman: Add a way to print the architecture for a board
  buildman: Enable test coverage

 .azure-pipelines.yml  |   2 +-
 .gitlab-ci.yml|   2 +-
 arch/sandbox/include/asm/sdl.h|  23 +++
 arch/sandbox/include/asm/test.h   |  25 ---
 boot/bootmeth_script.c|   5 +-
 cmd/load.c|  16 +-
 drivers/core/of_access.c  |   5 +-
 drivers/core/read.c 

Re: [PATCH v4] phy: phy-imx8mq-usb: add vbus regulator support

2023-07-12 Thread Tim Harvey
On Wed, Jul 12, 2023 at 2:15 AM Marek Vasut  wrote:
>
> On 7/11/23 22:13, Tim Harvey wrote:
> > On Mon, Jul 10, 2023 at 4:18 PM Marek Vasut  wrote:
> >>
> >> On 7/11/23 00:49, Tim Harvey wrote:
> >>> Add support for enabling and disabling vbus-supply regulator found
> >>> on several imx8mp boards in the usb3_phy0 and usb3_phy1 nodes.
> >>>
> >>> Signed-off-by: Tim Harvey 
> >>> Reviewed-by: Adam Ford 
> >>> Reviewed-by: Marek Vasut 
> >>> ---
> >>> v4:
> >>>- use regulator_set_enable_if_allowed to handle regulator reference 
> >>> counting
> >>>  errors
> >>>- added Marek's rb tag
> >>>
> >>> v3:
> >>>- change pr_err to dev_err
> >>>- add #if CONFIG_IS_ENABLED around vbus_supply in struct
> >>>- add fail path to disable clock if regulator enable failed
> >>>
> >>> v2:
> >>>- protect ret with __maybe_unused in case CONFIG_CLK and
> >>>  CONFIG_DM_REGULATOR not defined
> >>>- add error prints on failures
> >>>- add Adam's rb tag
> >>> ---
> >>>drivers/phy/phy-imx8mq-usb.c | 39 ++--
> >>>1 file changed, 37 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/phy/phy-imx8mq-usb.c b/drivers/phy/phy-imx8mq-usb.c
> >>> index 69f01de55538..6cbcb2338cfe 100644
> >>> --- a/drivers/phy/phy-imx8mq-usb.c
> >>> +++ b/drivers/phy/phy-imx8mq-usb.c
> >>> @@ -14,6 +14,8 @@
> >>>#include 
> >>>#include 
> >>>#include 
> >>> +#include 
> >>> +#include 
> >>>
> >>>#define PHY_CTRL0   0x0
> >>>#define PHY_CTRL0_REF_SSP_ENBIT(2)
> >>> @@ -81,6 +83,9 @@ struct imx8mq_usb_phy {
> >>>#endif
> >>>void __iomem *base;
> >>>enum imx8mpq_phy_type type;
> >>> +#if CONFIG_IS_ENABLED(DM_REGULATOR)
> >>> + struct udevice *vbus_supply;
> >>> +#endif
> >>>};
> >>>
> >>>static const struct udevice_id imx8mq_usb_phy_of_match[] = {
> >>> @@ -172,10 +177,10 @@ static int imx8mq_usb_phy_power_on(struct phy 
> >>> *usb_phy)
> >>>{
> >>>struct udevice *dev = usb_phy->dev;
> >>>struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> >>> + __maybe_unused int ret;
> >>>u32 value;
> >>>
> >>>#if CONFIG_IS_ENABLED(CLK)
> >>> - int ret;
> >>>ret = clk_enable(_phy->phy_clk);
> >>>if (ret) {
> >>>printf("Failed to enable usb phy clock\n");
> >>> @@ -183,18 +188,31 @@ static int imx8mq_usb_phy_power_on(struct phy 
> >>> *usb_phy)
> >>>}
> >>>#endif
> >>>
> >>> + if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> >>> + ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, 
> >>> true);
> >>> + if (ret && ret != -ENOSYS) {
> >>> + dev_err(dev, "Failed to enable VBUS regulator: 
> >>> %d\n", ret);
> >>> + goto err;
> >>> + }
> >>> + }
> >>> +
> >>>/* Disable rx term override */
> >>>value = readl(imx_phy->base + PHY_CTRL6);
> >>>value &= ~PHY_CTRL6_RXTERM_OVERRIDE_SEL;
> >>>writel(value, imx_phy->base + PHY_CTRL6);
> >>>
> >>>return 0;
> >>> +
> >>> +err:
> >>> + clk_disable(_phy->phy_clk);
> >>> + return ret;
> >>>}
> >>>
> >>>static int imx8mq_usb_phy_power_off(struct phy *usb_phy)
> >>>{
> >>>struct udevice *dev = usb_phy->dev;
> >>>struct imx8mq_usb_phy *imx_phy = dev_get_priv(dev);
> >>> + __maybe_unused int ret;
> >>>u32 value;
> >>>
> >>>/* Override rx term to be 0 */
> >>> @@ -206,6 +224,14 @@ static int imx8mq_usb_phy_power_off(struct phy 
> >>> *usb_phy)
> >>>clk_disable(_phy->phy_clk);
> >>>#endif
> >>>
> >>> + if (CONFIG_IS_ENABLED(DM_REGULATOR) && imx_phy->vbus_supply) {
> >>> + ret = regulator_set_enable_if_allowed(imx_phy->vbus_supply, 
> >>> false);
> >>> + if (ret && ret != -ENOSYS) {
> >>> + dev_err(dev, "Failed to disable VBUS regulator: 
> >>> %d\n", ret);
> >>> + return ret;
> >>> + }
> >>> + }
> >>> +
> >>>return 0;
> >>>}
> >>>
> >>> @@ -224,6 +250,7 @@ struct phy_ops imx8mq_usb_phy_ops = {
> >>>int imx8mq_usb_phy_probe(struct udevice *dev)
> >>>{
> >>>struct imx8mq_usb_phy *priv = dev_get_priv(dev);
> >>> + __maybe_unused int ret;
> >>>
> >>>priv->type = dev_get_driver_data(dev);
> >>>priv->base = dev_read_addr_ptr(dev);
> >>> @@ -232,7 +259,6 @@ int imx8mq_usb_phy_probe(struct udevice *dev)
> >>>return -EINVAL;
> >>>
> >>>#if CONFIG_IS_ENABLED(CLK)
> >>> - int ret;
> >>
> >> I _think_ if you were to convert this #if CONFIG...() to if
> >> (CONFIG...()), you would be able to drop the __maybe_unused . Separate
> >> conversion patch would be better though.
> >
> > Hi Marek,
>
> Hi,
>
> > Yes, I thought about that as well and felt it should be a separate
> > followup cleanup patch.
>
> Can you please send such a follow up patch 

Re: [PATCH v4 01/45] x86: Return mtrr_add_request() to its old purpose

2023-07-12 Thread Simon Glass
Hi Bin,

On Wed, 12 Jul 2023 at 08:02, Bin Meng  wrote:
>
> Hi Simon,
>
> On Mon, Jun 19, 2023 at 8:01 PM Simon Glass  wrote:
> >
> > This function used to be for adding a list of requests to be actioned on
> > relocation. Revert it back to this purpose, to avoid problems with boards
> > which need control of their MTRRs (i.e. those which don't use FSP).
> >
> > The mtrr_set_next_var() function is available when the next free
> > variable-MTRR must be set, so this can be used instead.
> >
> > Signed-off-by: Simon Glass 
> > Fixes: 3bcd6cf89ef ("x86: mtrr: Skip MSRs that were already programmed..")
> > Fixes: 596bd0589ad ("x86: mtrr: Do not clear the unused ones..")
> > ---
> >
> > Changes in v4:
> > - Bring in dropped mtrr_add_request() request patch
> >
>
> As discussed previously in
> https://patchwork.ozlabs.org/project/uboot/patch/20230504225101.2366414-13-...@chromium.org/
>
> this patch will cause regressions. We should investigate another way
> to improve the MTRR APIs.

The fix for the regressions is to use mtrr_set_next_var() for boards
which don't want to change what is already there. The problem for
Chromebooks (with newer FSPs) is that they want to set up the MTRRs
from scratch, which is actually what this API was originally for. When
you changed it, I didn't realise the problem right away. But at
present two Chromebooks don't boot due to this bug.

>
> Regards,
> Bin

Regards,
SImon


[PATCH v3 18/18] x86: coral: Adjust various config options

2023-07-12 Thread Simon Glass
Add ms so it is easier to search for tables in memory.

Expand the command-line and print buffers so that we can deal with the
very long ChromeOS command lines. (typically 700 characters).

Enable BOOTSTD_FULL to get the full set of standard-boot options.

Replace the existing manual script with 'bootflow scan', since it can
find and boot the OS.

Finally, expand the malloc() space so we can read large kernels into a
bootflow.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

Changes in v3:
- Separate out patch to restore test behaviour on failure

Changes in v2:
- Drop mention of NVMe support

 configs/chromebook_coral_defconfig | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/configs/chromebook_coral_defconfig 
b/configs/chromebook_coral_defconfig
index f5995f22004e..fe61153b93d8 100644
--- a/configs/chromebook_coral_defconfig
+++ b/configs/chromebook_coral_defconfig
@@ -1,5 +1,6 @@
 CONFIG_X86=y
 CONFIG_TEXT_BASE=0x111
+CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x3d00
 CONFIG_NR_DRAM_BANKS=8
 CONFIG_MAX_CPUS=8
@@ -22,6 +23,7 @@ CONFIG_X86_OFFSET_U_BOOT=0xffd0
 CONFIG_X86_OFFSET_SPL=0xffe8
 CONFIG_INTEL_ACPIGEN=y
 CONFIG_INTEL_GENERIC_WIFI=y
+CONFIG_BOOTSTD_FULL=y
 CONFIG_SYS_MONITOR_BASE=0x0111
 CONFIG_CHROMEOS=y
 CONFIG_BOOTSTAGE=y
@@ -33,8 +35,10 @@ CONFIG_BOOTSTAGE_STASH=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS_SUBST=y
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="tpm init; tpm startup TPM2_SU_CLEAR; read mmc 0:2 10 0 
80; setexpr loader *001004f0; setexpr size *00100518; setexpr blocks $size / 
200; read mmc 0:2 10 80 $blocks; setexpr setup $loader - 1000; setexpr 
cmdline_ptr $loader - 2000; setexpr.s cmdline *$cmdline_ptr; setexpr cmdline 
gsub %U ${uuid}; if part uuid mmc 0:2 uuid; then zboot start 10 0 0 0 
$setup cmdline; zboot load; zboot setup; zboot dump; zboot go;fi"
+CONFIG_BOOTCOMMAND="tpm init; tpm startup TPM2_SU_CLEAR; bootflow scan -lb"
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_LOG=y
+CONFIG_LOGF_FUNC=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_BLOBLIST=y
@@ -52,9 +56,11 @@ CONFIG_SPL_POWER=y
 CONFIG_TPL_SYS_MALLOC_SIMPLE=y
 CONFIG_TPL_POWER=y
 CONFIG_HUSH_PARSER=y
-CONFIG_SYS_PBSIZE=532
+CONFIG_SYS_CBSIZE=1024
+CONFIG_SYS_PBSIZE=1024
 CONFIG_CMD_CPU=y
 CONFIG_CMD_PMC=y
+CONFIG_CMD_MEM_SEARCH=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_PART=y
-- 
2.41.0.390.g38632f3daf-goog



[PATCH v3 17/18] x86: coreboot: Adjust various config options

2023-07-12 Thread Simon Glass
Drop IDE and add NVME since this is more common now.

Add ms so it is easier to search for tables in memory.

Expand the command-line and print buffers so that we can deal with the
very long ChromeOS command lines. (typically 700 characters).

Enable BOOTSTD_FULL to get the full set up standard-boot options.

Finally, expand the malloc() space so we can read large kernels into a
bootflow.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

Changes in v3:
- Drop CONFIG_MISC and CONFIG_NVMEM
- Update commit message

 configs/coreboot_defconfig | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/configs/coreboot_defconfig b/configs/coreboot_defconfig
index 058caf008f9a..0e7c104efb41 100644
--- a/configs/coreboot_defconfig
+++ b/configs/coreboot_defconfig
@@ -1,5 +1,6 @@
 CONFIG_X86=y
 CONFIG_TEXT_BASE=0x111
+CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_NR_DRAM_BANKS=8
 CONFIG_ENV_SIZE=0x1000
 CONFIG_DEFAULT_DEVICE_TREE="coreboot"
@@ -8,12 +9,11 @@ CONFIG_VENDOR_COREBOOT=y
 CONFIG_TARGET_COREBOOT=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
+CONFIG_BOOTSTD_FULL=y
 CONFIG_SYS_MONITOR_BASE=0x0111
 CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro"
-CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="ext2load scsi 0:3 0100 /boot/vmlinuz; zboot 0100"
 CONFIG_PRE_CONSOLE_BUFFER=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_LOG=y
@@ -23,9 +23,6 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_PCI_INIT_R=y
 CONFIG_HUSH_PARSER=y
-CONFIG_SYS_PBSIZE=532
-CONFIG_CMD_MEM_SEARCH=y
-CONFIG_CMD_IDE=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
 CONFIG_CMD_USB=y
@@ -53,13 +50,6 @@ CONFIG_USE_ROOTPATH=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 # CONFIG_ACPIGEN is not set
-CONFIG_SYS_IDE_MAXDEVICE=4
-CONFIG_SYS_ATA_DATA_OFFSET=0
-CONFIG_SYS_ATA_REG_OFFSET=0
-CONFIG_SYS_ATA_ALT_OFFSET=0
-CONFIG_ATAPI=y
-CONFIG_LBA48=y
-CONFIG_SYS_64BIT_LBA=y
 CONFIG_NVME_PCI=y
 # CONFIG_PCI_PNP is not set
 CONFIG_SOUND=y
-- 
2.41.0.390.g38632f3daf-goog



[PATCH v3 16/18] bootstd: Add a simple bootmeth for ChromiumOS

2023-07-12 Thread Simon Glass
It is possible to boot x86-based ChromeOS machines by parsing a table and
locating the kernel and command line. Add a bootmeth for this.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v1)

 boot/Kconfig |  11 ++
 boot/Makefile|   1 +
 boot/bootmeth_cros.c | 212 +++
 configs/tools-only_defconfig |   1 +
 4 files changed, 225 insertions(+)
 create mode 100644 boot/bootmeth_cros.c

diff --git a/boot/Kconfig b/boot/Kconfig
index a643a3d12863..08ca2b0fa9d3 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -463,6 +463,17 @@ config BOOTMETH_GLOBAL
  EFI bootmgr, since they take full control over which bootdevs are
  selected to boot.
 
+config BOOTMETH_CROS
+   bool "Bootdev support for Chromium OS"
+   depends on X86 || SANDBOX
+   default y
+   help
+ Enables support for booting Chromium OS using bootdevs. This uses the
+ kernel A slot and obtains the kernel command line from the parameters
+ provided there.
+
+ Note that only x86 devices are supported at present.
+
 config BOOTMETH_EXTLINUX
bool "Bootdev support for extlinux boot"
select PXE_UTILS
diff --git a/boot/Makefile b/boot/Makefile
index f94c31d922de..6e4cdbd4ce28 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX) += bootmeth_extlinux.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX_PXE) += bootmeth_pxe.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_CROS) += bootmeth_cros.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o
 ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL
diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c
new file mode 100644
index ..aa19ae097f56
--- /dev/null
+++ b/boot/bootmeth_cros.c
@@ -0,0 +1,212 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootmethod for ChromiumOS
+ *
+ * Copyright 2023 Google LLC
+ * Written by Simon Glass 
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#ifdef CONFIG_X86
+#include 
+#endif
+#include 
+
+enum {
+   /* Offsets in the kernel-partition header */
+   KERN_START  = 0x4f0,
+   KERN_SIZE   = 0x518,
+
+   SETUP_OFFSET= 0x1000,   /* bytes before base */
+   CMDLINE_OFFSET  = 0x2000,   /* bytes before base */
+   OFFSET_BASE = 0x10, /* assumed kernel load-address */
+};
+
+static int cros_check(struct udevice *dev, struct bootflow_iter *iter)
+{
+   /* This only works on block and network devices */
+   if (bootflow_iter_check_blk(iter))
+   return log_msg_ret("blk", -ENOTSUPP);
+
+   return 0;
+}
+
+static int copy_cmdline(const char *from, const char *uuid, char **bufp)
+{
+   const int maxlen = 2048;
+   char buf[maxlen];
+   char *cmd, *to, *end;
+   int len;
+
+   /* Allow space for cmdline + UUID */
+   len = strnlen(from, sizeof(buf));
+   if (len >= maxlen)
+   return -E2BIG;
+
+   log_debug("uuid %d %s\n", uuid ? (int)strlen(uuid) : 0, uuid);
+   for (to = buf, end = buf + maxlen - UUID_STR_LEN - 1; *from; from++) {
+   if (to >= end)
+   return -E2BIG;
+   if (from[0] == '%' && from[1] == 'U' && uuid &&
+   strlen(uuid) == UUID_STR_LEN) {
+   strcpy(to, uuid);
+   to += UUID_STR_LEN;
+   from++;
+   } else {
+   *to++ = *from;
+   }
+   }
+   *to = '\0';
+   len = to - buf;
+   cmd = strdup(buf);
+   if (!cmd)
+   return -ENOMEM;
+   free(*bufp);
+   *bufp = cmd;
+
+   return 0;
+}
+
+static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+   struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
+   ulong base, start, size, setup, cmdline, num_blks, kern_base;
+   struct disk_partition info;
+   const char *uuid = NULL;
+   void *buf, *hdr;
+   int ret;
+
+   log_debug("starting, part=%d\n", bflow->part);
+
+   /* We consider the whole disk, not any one partition */
+   if (bflow->part)
+   return log_msg_ret("max", -ENOENT);
+
+   /* Check partition 2 */
+   ret = part_get_info(desc, 2, );
+   if (ret)
+   return log_msg_ret("part", ret);
+
+   /* Make a buffer for the header information */
+   num_blks = SZ_4K >> desc->log2blksz;
+   log_debug("Reading header, blk=%s, start=%lx, blocks=%lx\n",
+ bflow->blk->name, (ulong)info.start, num_blks);
+   hdr = memalign(SZ_1K, SZ_4K);
+   if (!hdr)
+   return 

[PATCH v3 15/18] x86: zimage: Export the function to obtain the cmdline

2023-07-12 Thread Simon Glass
Allow reading the command line from a zimage, so that it can be recorded
in the bootflow.

Reviewed-by: Bin Meng 
Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/include/asm/zimage.h | 10 ++
 arch/x86/lib/zimage.c | 11 ---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h
index 966d7224eb18..9ad74dc0b946 100644
--- a/arch/x86/include/asm/zimage.h
+++ b/arch/x86/include/asm/zimage.h
@@ -89,4 +89,14 @@ void zimage_dump(struct boot_params *base_ptr);
 int zboot_start(ulong addr, ulong size, ulong initrd, ulong initrd_size,
ulong base, char *cmdline);
 
+/*
+ * zimage_get_kernel_version() - Get the version string from a kernel
+ *
+ * @params: boot_params pointer
+ * @kernel_base: base address of kernel
+ * Return: Kernel version as a NUL-terminated string
+ */
+const char *zimage_get_kernel_version(struct boot_params *params,
+ void *kernel_base);
+
 #endif
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 540d4d888bc7..062e3d3e3151 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -181,7 +181,7 @@ static int setup_device_tree(struct setup_header *hdr, 
const void *fdt_blob)
return 0;
 }
 
-static const char *get_kernel_version(struct boot_params *params,
+const char *zimage_get_kernel_version(struct boot_params *params,
  void *kernel_base)
 {
struct setup_header *hdr = >hdr;
@@ -189,10 +189,14 @@ static const char *get_kernel_version(struct boot_params 
*params,
const char *s, *end;
 
bootproto = get_boot_protocol(hdr, false);
+   log_debug("bootproto %x, hdr->setup_sects %x\n", bootproto,
+ hdr->setup_sects);
if (bootproto < 0x0200 || hdr->setup_sects < 15)
return NULL;
 
/* sanity-check the kernel version in case it is missing */
+   log_debug("hdr->kernel_version %x, str at %p\n", hdr->kernel_version,
+ kernel_base + hdr->kernel_version + 0x200);
for (s = kernel_base + hdr->kernel_version + 0x200, end = s + 0x100; *s;
 s++) {
if (!isprint(*s))
@@ -239,7 +243,7 @@ struct boot_params *load_zimage(char *image, unsigned long 
kernel_size,
log_debug("Using boot protocol version %x.%02x\n",
  (bootproto & 0xff00) >> 8, bootproto & 0xff);
 
-   version = get_kernel_version(params, image);
+   version = zimage_get_kernel_version(params, image);
if (version)
printf("Linux kernel version %s\n", version);
else
@@ -728,7 +732,8 @@ void zimage_dump(struct boot_params *base_ptr)
print_num("Real mode switch", hdr->realmode_swtch);
print_num("Start sys seg", hdr->start_sys_seg);
print_num("Kernel version", hdr->kernel_version);
-   version = get_kernel_version(base_ptr, (void *)state.bzimage_addr);
+   version = zimage_get_kernel_version(base_ptr,
+   (void *)state.bzimage_addr);
if (version)
printf("   @%p: %s\n", version, version);
print_num("Type of loader", hdr->type_of_loader);
-- 
2.41.0.390.g38632f3daf-goog



[PATCH v3 14/18] x86: Add a function to boot a zimage

2023-07-12 Thread Simon Glass
Add a direct interface to booting a zimage, so that bootstd can call it
without going through the command-line interface.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v1)

 arch/x86/include/asm/zimage.h | 17 
 arch/x86/lib/zimage.c | 82 ++-
 2 files changed, 88 insertions(+), 11 deletions(-)

diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h
index 000b38ea8993..966d7224eb18 100644
--- a/arch/x86/include/asm/zimage.h
+++ b/arch/x86/include/asm/zimage.h
@@ -72,4 +72,21 @@ int setup_zimage(struct boot_params *setup_base, char 
*cmd_line, int auto_boot,
  */
 void zimage_dump(struct boot_params *base_ptr);
 
+/**
+ * zboot_start() - Boot a zimage
+ *
+ * Boot a zimage, given the component parts
+ *
+ * @addr: Address where the bzImage is moved before booting, either
+ * BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR
+ * @base: Pointer to the boot parameters, typically at address
+ * DEFAULT_SETUP_BASE
+ * @initrd: Address of the initial ramdisk, or 0 if none
+ * @initrd_size: Size of the initial ramdisk, or 0 if none
+ * @cmdline: Command line to use for booting
+ * Return: -EFAULT on error (normally it does not return)
+ */
+int zboot_start(ulong addr, ulong size, ulong initrd, ulong initrd_size,
+   ulong base, char *cmdline);
+
 #endif
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index e5ea5129c1e9..540d4d888bc7 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -442,8 +443,7 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, 
int argc,
return 0;
 }
 
-static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, int argc,
-char *const argv[])
+static int zboot_load(void)
 {
struct boot_params *base_ptr;
 
@@ -460,31 +460,51 @@ static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, 
int argc,
   _address);
if (!base_ptr) {
puts("## Kernel loading failed ...\n");
-   return CMD_RET_FAILURE;
+   return -EINVAL;
}
}
state.base_ptr = base_ptr;
-   if (env_set_hex("zbootbase", (ulong)base_ptr) ||
+
+   return 0;
+}
+
+static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, int argc,
+char *const argv[])
+{
+   if (zboot_load())
+   return CMD_RET_FAILURE;
+
+   if (env_set_hex("zbootbase", map_to_sysmem(state.base_ptr)) ||
env_set_hex("zbootaddr", state.load_address))
return CMD_RET_FAILURE;
 
return 0;
 }
 
+static int zboot_setup(void)
+{
+   struct boot_params *base_ptr = state.base_ptr;
+   int ret;
+
+   ret = setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET,
+  0, state.initrd_addr, state.initrd_size,
+  (ulong)state.cmdline);
+   if (ret)
+   return -EINVAL;
+
+   return 0;
+}
+
 static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[])
 {
struct boot_params *base_ptr = state.base_ptr;
-   int ret;
 
if (!base_ptr) {
printf("base is not set: use 'zboot load' first\n");
return CMD_RET_FAILURE;
}
-   ret = setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET,
-  0, state.initrd_addr, state.initrd_size,
-  (ulong)state.cmdline);
-   if (ret) {
+   if (zboot_setup()) {
puts("Setting up boot parameters failed ...\n");
return CMD_RET_FAILURE;
}
@@ -501,8 +521,7 @@ static int do_zboot_info(struct cmd_tbl *cmdtp, int flag, 
int argc,
return 0;
 }
 
-static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc,
-  char *const argv[])
+static int zboot_go(void)
 {
struct boot_params *params = state.base_ptr;
struct setup_header *hdr = >hdr;
@@ -522,11 +541,52 @@ static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, 
int argc,
 
/* we assume that the kernel is in place */
ret = boot_linux_kernel((ulong)state.base_ptr, entry, image_64bit);
+
+   return ret;
+}
+
+static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc,
+  char *const argv[])
+{
+   int ret;
+
+   ret = zboot_go();
printf("Kernel returned! (err=%d)\n", ret);
 
return CMD_RET_FAILURE;
 }
 
+int zboot_start(ulong addr, ulong size, ulong initrd, ulong initrd_size,
+   ulong base, char *cmdline)
+{
+   int ret;
+
+   memset(, '\0', sizeof(state));
+
+   if (base) {
+   state.base_ptr = map_sysmem(base, 0);
+   state.load_address = addr;
+   } else {
+

[PATCH v3 13/18] bootstd: Support automatically setting Linux parameters

2023-07-12 Thread Simon Glass
Some Linux parameters can be set automatically by U-Boot, if it knows the
device being used. For example, since U-Boot knows the serial console
being used, it can add parameters for earlycon and console.

Add support for this.

Note that this is an experimental feature and we will see how useful it
turns out to be. It is very handy for ChromeOS, since otherwise it is very
difficult to manually determine the UART address or port number,
particularly in a script.

Provide an example of how this is used with ChromeOS.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v1)

 boot/bootflow.c| 33 +
 cmd/bootflow.c |  5 ++-
 doc/usage/cmd/bootflow.rst | 75 +-
 include/bootflow.h | 12 ++
 4 files changed, 123 insertions(+), 2 deletions(-)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 8c649e8e66ca..81b5829d5b37 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -854,3 +855,35 @@ int bootflow_cmdline_get_arg(struct bootflow *bflow, const 
char *arg,
 
return ret;
 }
+
+int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg)
+{
+   struct serial_device_info info;
+   char buf[50];
+   int ret;
+
+   ret = serial_getinfo(gd->cur_serial_dev, );
+   if (ret)
+   return ret;
+
+   *buf = '\0';
+   if (!strcmp("earlycon", arg)) {
+   snprintf(buf, sizeof(buf),
+"uart8250,mmio32,%#lx,%dn8", info.addr,
+info.baudrate);
+   } else if (!strcmp("console", arg)) {
+   snprintf(buf, sizeof(buf),
+"ttyS0,%dn8", info.baudrate);
+   }
+
+   if (!*buf) {
+   printf("Unknown param '%s\n", arg);
+   return -ENOENT;
+   }
+
+   ret = bootflow_cmdline_set_arg(bflow, arg, buf, true);
+   if (ret)
+   return ret;
+
+   return 0;
+}
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index ab00e4a19e14..c0aa4f84fe8d 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -474,6 +474,9 @@ static int do_bootflow_cmdline(struct cmd_tbl *cmdtp, int 
flag, int argc,
if (ret >= 0)
printf("%.*s\n", ret, val);
break;
+   case 'a':   /* auto */
+   ret = bootflow_cmdline_auto(bflow, arg);
+   break;
}
switch (ret) {
case -E2BIG:
@@ -508,7 +511,7 @@ static char bootflow_help_text[] =
"bootflow info [-d] - show info on current bootflow (-d 
dump bootflow)\n"
"bootflow boot  - boot current bootflow (or first 
available if none selected)\n"
"bootflow menu [-t] - show a menu of available bootflows\n"
-   "bootflow cmdline [set|get|clear|delete]  [] - update 
cmdline";
+   "bootflow cmdline [set|get|clear|delete|auto]  [] - 
update cmdline";
 #else
"scan - boot first available bootflow\n";
 #endif
diff --git a/doc/usage/cmd/bootflow.rst b/doc/usage/cmd/bootflow.rst
index 07af789e6702..a8af1f8f6030 100644
--- a/doc/usage/cmd/bootflow.rst
+++ b/doc/usage/cmd/bootflow.rst
@@ -13,7 +13,7 @@ Synopis
 bootflow select []
 bootflow info [-d]
 bootflow boot
-bootflow cmdline [set|get|clear|delete]  []
+bootflow cmdline [set|get|clear|delete|auto]  []
 
 Description
 ---
@@ -218,6 +218,16 @@ To delete a parameter entirely, use::
 
 bootflow cmdline delete 
 
+Automatic parameters are available in a very few cases. You can use these to
+add parmeters where the value is known by U-Boot. For example::
+
+bootflow cmdline auto earlycon
+bootflow cmdline auto console
+
+can be used to set the early console (or console) to a suitable value so that
+output appears on the serial port. This is only supported by the 16550 serial
+driver so far.
+
 Example
 ---
 
@@ -450,6 +460,69 @@ Here is am example using the -e flag to see all errors::
 (21 bootflows, 2 valid)
 U-Boot>
 
+Here is an example of booting ChromeOS, adjusting the console beforehand. Note 
that
+the cmdline is word-wrapped here and some parts of the command line are 
elided::
+
+=> bootfl list
+Showing all bootflows
+Seq  Method   State   UclassPart  Name  
Filename
+---  ---  --        

+0  cros ready   nvme 0  5.10.153-20434-g98da1eb2c 
+1  efi  ready   nvme c  nvme#0.blk#1.bootdev.part 
efi/boot/bootia32.efi
+2  efi  ready   usb_mass_2  usb_mass_storage.lun0.boo 
efi/boot/bootia32.efi
+---  ---  --        

+(3 bootflows, 3 valid)
+=> bootfl sel 0
+=> bootfl inf
+Name:  5.10.153-20434-g98da1eb2cf9d 

[PATCH v3 12/18] x86: qemu: Switch to standard boot

2023-07-12 Thread Simon Glass
Drop use of the distro boot script and use standard boot instead.

Moving to a text-based environment would be desirable also, but requires
additional work.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v2)

Changes in v2:
- Add new patch to switch x86 qemu to standard boot

 configs/qemu-x86_64_defconfig | 2 +-
 configs/qemu-x86_defconfig| 2 +-
 include/configs/qemu-x86.h| 8 
 3 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig
index b311843e68be..9272419d4539 100644
--- a/configs/qemu-x86_64_defconfig
+++ b/configs/qemu-x86_64_defconfig
@@ -20,7 +20,7 @@ CONFIG_X86_OFFSET_U_BOOT=0xfff0
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SYS_MONITOR_BASE=0x0111
-CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_SHOW_BOOT_PROGRESS=y
diff --git a/configs/qemu-x86_defconfig b/configs/qemu-x86_defconfig
index 9bf29647fe59..783de0d45657 100644
--- a/configs/qemu-x86_defconfig
+++ b/configs/qemu-x86_defconfig
@@ -9,7 +9,7 @@ CONFIG_SMP=y
 CONFIG_GENERATE_PIRQ_TABLE=y
 CONFIG_GENERATE_MP_TABLE=y
 CONFIG_FIT=y
-CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_SHOW_BOOT_PROGRESS=y
diff --git a/include/configs/qemu-x86.h b/include/configs/qemu-x86.h
index 33263a46a407..3e5235291a28 100644
--- a/include/configs/qemu-x86.h
+++ b/include/configs/qemu-x86.h
@@ -12,14 +12,6 @@
 
 #include 
 
-#define BOOT_TARGET_DEVICES(func) \
-   func(USB, usb, 0) \
-   func(SCSI, scsi, 0) \
-   func(VIRTIO, virtio, 0) \
-   func(IDE, ide, 0) \
-   func(DHCP, dhcp, na)
-
-#include 
 #include 
 
 #define CFG_STD_DEVICES_SETTINGS   "stdin=serial,i8042-kbd\0" \
-- 
2.41.0.390.g38632f3daf-goog



[PATCH v3 11/18] x86: qemu: Create a little more room for U-Boot

2023-07-12 Thread Simon Glass
We want to enable some of the more interesting bootstd features. Move SPL
up to create some room for the larger U-Boot binary. Also disable
microcode since this is not needed

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v2)

Changes in v2:
- Add new patch to create a little more room for U-Boot on qemu-x86_64

 configs/qemu-x86_64_defconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig
index f29a5aa0f813..b311843e68be 100644
--- a/configs/qemu-x86_64_defconfig
+++ b/configs/qemu-x86_64_defconfig
@@ -6,12 +6,13 @@ CONFIG_ENV_SIZE=0x4
 CONFIG_MAX_CPUS=2
 CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx"
-CONFIG_SPL_TEXT_BASE=0xfffd
+CONFIG_SPL_TEXT_BASE=0xfffd8000
 CONFIG_DEBUG_UART_BASE=0x3f8
 CONFIG_DEBUG_UART_CLOCK=1843200
 CONFIG_X86_RUN_64BIT=y
 CONFIG_TARGET_QEMU_X86_64=y
 CONFIG_DEBUG_UART=y
+# CONFIG_HAVE_MICROCODE is not set
 CONFIG_SMP=y
 CONFIG_GENERATE_PIRQ_TABLE=y
 CONFIG_GENERATE_MP_TABLE=y
-- 
2.41.0.390.g38632f3daf-goog



[PATCH v3 10/18] bootstd: Add support for updating elements of the cmdline

2023-07-12 Thread Simon Glass
Add a bootflow command to update the command line more easily. This allows
changing a particular parameter rather than editing a very long strings.
It is also easier to handle with scripting.

The new 'bootflow cmdline' command allows getting and setting single
parameters.

Fix up the example output while we are here, since there are a few new
items.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v2)

Changes in v2:
- Show error messages when something goes wrong

 boot/bootflow.c|  53 ++
 cmd/bootflow.c |  70 +++-
 doc/usage/cmd/bootflow.rst |  22 +++-
 include/bootflow.h |  42 +++
 test/boot/bootflow.c   | 108 +
 5 files changed, 293 insertions(+), 2 deletions(-)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 26f26aee38a3..8c649e8e66ca 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -801,3 +801,56 @@ int cmdline_set_arg(char *buf, int maxlen, const char 
*cmdline,
 
return to - buf;
 }
+
+int bootflow_cmdline_set_arg(struct bootflow *bflow, const char *set_arg,
+const char *new_val, bool set_env)
+{
+   char buf[2048];
+   char *cmd = NULL;
+   int ret;
+
+   ret = cmdline_set_arg(buf, sizeof(buf), bflow->cmdline, set_arg,
+ new_val, NULL);
+   if (ret < 0)
+   return ret;
+
+   ret = bootflow_cmdline_set(bflow, buf);
+   if (*buf) {
+   cmd = strdup(buf);
+   if (!cmd)
+   return -ENOMEM;
+   }
+   free(bflow->cmdline);
+   bflow->cmdline = cmd;
+
+   if (set_env) {
+   ret = env_set("bootargs", bflow->cmdline);
+   if (ret)
+   return ret;
+   }
+
+   return 0;
+}
+
+int cmdline_get_arg(const char *cmdline, const char *arg, int *posp)
+{
+   int ret;
+
+   ret = cmdline_set_arg(NULL, 1, cmdline, arg, NULL, posp);
+
+   return ret;
+}
+
+int bootflow_cmdline_get_arg(struct bootflow *bflow, const char *arg,
+const char **val)
+{
+   int ret;
+   int pos;
+
+   ret = cmdline_get_arg(bflow->cmdline, arg, );
+   if (ret < 0)
+   return ret;
+   *val = bflow->cmdline + pos;
+
+   return ret;
+}
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index bf30087c7c4e..ab00e4a19e14 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -431,6 +431,72 @@ static int do_bootflow_menu(struct cmd_tbl *cmdtp, int 
flag, int argc,
 
return 0;
 }
+
+static int do_bootflow_cmdline(struct cmd_tbl *cmdtp, int flag, int argc,
+  char *const argv[])
+{
+   struct bootstd_priv *std;
+   struct bootflow *bflow;
+   const char *op, *arg, *val = NULL;
+   int ret;
+
+   if (argc < 3)
+   return CMD_RET_USAGE;
+
+   ret = bootstd_get_priv();
+   if (ret)
+   return CMD_RET_FAILURE;
+
+   bflow = std->cur_bootflow;
+   if (!bflow) {
+   printf("No bootflow selected\n");
+   return CMD_RET_FAILURE;
+   }
+
+   op = argv[1];
+   arg = argv[2];
+   if (*op == 's') {
+   if (argc < 4)
+   return CMD_RET_USAGE;
+   val = argv[3];
+   }
+
+   switch (*op) {
+   case 'c':   /* clear */
+   val = "";
+   fallthrough;
+   case 's':   /* set */
+   case 'd':   /* delete */
+   ret = bootflow_cmdline_set_arg(bflow, arg, val, true);
+   break;
+   case 'g':   /* get */
+   ret = bootflow_cmdline_get_arg(bflow, arg, );
+   if (ret >= 0)
+   printf("%.*s\n", ret, val);
+   break;
+   }
+   switch (ret) {
+   case -E2BIG:
+   printf("Argument too long\n");
+   break;
+   case -ENOENT:
+   printf("Argument not found\n");
+   break;
+   case -EINVAL:
+   printf("Mismatched quotes\n");
+   break;
+   case -EBADF:
+   printf("Value must be quoted\n");
+   break;
+   default:
+   if (ret < 0)
+   printf("Unknown error: %dE\n", ret);
+   }
+   if (ret < 0)
+   return CMD_RET_FAILURE;
+
+   return 0;
+}
 #endif /* CONFIG_CMD_BOOTFLOW_FULL */
 
 #ifdef CONFIG_SYS_LONGHELP
@@ -441,7 +507,8 @@ static char bootflow_help_text[] =
"bootflow select [|] - select a bootflow\n"
"bootflow info [-d] - show info on current bootflow (-d 
dump bootflow)\n"
"bootflow boot  - boot current bootflow (or first 
available if none selected)\n"
-   "bootflow menu [-t] - show a menu of available bootflows";
+   "bootflow menu [-t] - show a menu of available 

[PATCH v3 09/18] bootstd: Add a function to update a command line

2023-07-12 Thread Simon Glass
The Linux command line consists of a number of words with optional values.
At present U-Boot allows this to be changed using the bootargs environment
variable.

But this is quite painful, since the command line can be very long.

Add a function which can adjust a single field in the command line, so
that it is easier to make changes before booting.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v2)

Changes in v2:
- Add comment for copy_in()
- Avoid multiplication on a boolean
- Add a comment as to why @len is needed

 boot/bootflow.c  | 190 +++
 include/bootflow.h   |  40 +
 test/boot/bootflow.c | 154 +++
 3 files changed, 384 insertions(+)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 62b7f45ab278..26f26aee38a3 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -611,3 +611,193 @@ static int on_bootargs(const char *name, const char 
*value, enum env_op op,
 U_BOOT_ENV_CALLBACK(bootargs, on_bootargs);
 #endif
 
+/**
+ * copy_in() - Copy a string into a cmdline buffer
+ *
+ * @buf: Buffer to copy into
+ * @end: End of buffer (pointer to char after the end)
+ * @arg: String to copy from
+ * @len: Number of chars to copy from @arg (note that this is not usually the
+ * sane as strlen(arg) since the string may contain following arguments)
+ * @new_val: Value to put after arg, or BOOTFLOWCL_EMPTY to use an empty value
+ * with no '=' sign
+ * Returns: Number of chars written to @buf
+ */
+static int copy_in(char *buf, char *end, const char *arg, int len,
+  const char *new_val)
+{
+   char *to = buf;
+
+   /* copy the arg name */
+   if (to + len >= end)
+   return -E2BIG;
+   memcpy(to, arg, len);
+   to += len;
+
+   if (new_val == BOOTFLOWCL_EMPTY) {
+   /* no value */
+   } else {
+   bool need_quote = strchr(new_val, ' ');
+   len = strlen(new_val);
+
+   /* need space for value, equals sign and maybe two quotes */
+   if (to + 1 + (need_quote ? 2 : 0) + len >= end)
+   return -E2BIG;
+   *to++ = '=';
+   if (need_quote)
+   *to++ = '"';
+   memcpy(to, new_val, len);
+   to += len;
+   if (need_quote)
+   *to++ = '"';
+   }
+
+   return to - buf;
+}
+
+int cmdline_set_arg(char *buf, int maxlen, const char *cmdline,
+   const char *set_arg, const char *new_val, int *posp)
+{
+   bool found_arg = false;
+   const char *from;
+   char *to, *end;
+   int set_arg_len;
+   char empty = '\0';
+   int ret;
+
+   from = cmdline ?: 
+
+   /* check if the value has quotes inside */
+   if (new_val && new_val != BOOTFLOWCL_EMPTY && strchr(new_val, '"'))
+   return -EBADF;
+
+   set_arg_len = strlen(set_arg);
+   for (to = buf, end = buf + maxlen; *from;) {
+   const char *val, *arg_end, *val_end, *p;
+   bool in_quote;
+
+   if (to >= end)
+   return -E2BIG;
+   while (*from == ' ')
+   from++;
+   if (!*from)
+   break;
+
+   /* find the end of this arg */
+   val = NULL;
+   arg_end = NULL;
+   val_end = NULL;
+   in_quote = false;
+   for (p = from;; p++) {
+   if (in_quote) {
+   if (!*p)
+   return -EINVAL;
+   if (*p == '"')
+   in_quote = false;
+   continue;
+   }
+   if (*p == '=') {
+   arg_end = p;
+   val = p + 1;
+   } else if (*p == '"') {
+   in_quote = true;
+   } else if (!*p || *p == ' ') {
+   val_end = p;
+   if (!arg_end)
+   arg_end = p;
+   break;
+   }
+   }
+   /*
+* At this point val_end points to the end of the value, or the
+* last char after the arg name, if there is no label.
+* arg_end is the char after the arg name
+* val points to the value, or NULL if there is none
+* char after the value.
+*
+*fred=1234
+*^   ^^   ^
+*  from  ||   |
+*   / \\
+*arg_end  val   val_end
+*/
+   log_debug("from %s arg_end %ld val %ld val_end %ld\n", from,

[PATCH v3 08/18] bdinfo: Show information about the serial port

2023-07-12 Thread Simon Glass
It is useful to see the detailed setting of the serial port, e.g. to
allow setting up earlycon or console for Linux. Add this output to the
'bdinfo' command.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v1)

 cmd/bdinfo.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 365357ca545f..dab73f1d93c4 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -113,6 +114,25 @@ static void show_video_info(void)
}
 }
 
+static void print_serial(struct udevice *dev)
+{
+   struct serial_device_info info;
+   int ret;
+
+   if (!dev || !IS_ENABLED(CONFIG_DM_SERIAL))
+   return;
+
+   ret = serial_getinfo(dev, );
+   if (ret)
+   return;
+
+   bdinfo_print_num_l("serial addr", info.addr);
+   bdinfo_print_num_l(" width", info.reg_width);
+   bdinfo_print_num_l(" shift", info.reg_shift);
+   bdinfo_print_num_l(" offset", info.reg_offset);
+   bdinfo_print_num_l(" clock", info.clock);
+}
+
 int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct bd_info *bd = gd->bd;
@@ -151,6 +171,7 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
if (IS_ENABLED(CONFIG_OF_REAL))
printf("devicetree  = %s\n", fdtdec_get_srcname());
}
+   print_serial(gd->cur_serial_dev);
 
arch_print_bdinfo();
 
-- 
2.41.0.390.g38632f3daf-goog



[PATCH v3 07/18] bootstd: Allow storing x86 setup information

2023-07-12 Thread Simon Glass
On x86 boards Linux uses a block of binary data to provide information
about the command line, memory map, etc. Provide a way to store this in
the bootflow so it can be passed on to the OS.

No attempt is made to generalise the code, since other archs don't need
this information. The field is present always, though, to avoid needing
accessors or #ifdefs when building code on other archs.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v2)

Changes in v2:
- Explain why the setup information is not behind an #ifdef

 cmd/bootflow.c | 2 ++
 include/bootflow.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index f33db7be5f2e..bf30087c7c4e 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -336,6 +336,8 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int 
flag, int argc,
else
puts("(none)");
putc('\n');
+   if (bflow->x86_setup)
+   printf("X86 setup: %p\n", bflow->x86_setup);
printf("Logo:  %s\n", bflow->logo ?
   simple_xtoa((ulong)map_to_sysmem(bflow->logo)) : "(none)");
if (bflow->logo) {
diff --git a/include/bootflow.h b/include/bootflow.h
index a1c16ab93b75..f263173c4da5 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -82,6 +82,7 @@ enum bootflow_flags_t {
  * @fdt_addr: Address of loaded fdt
  * @flags: Flags for the bootflow (see enum bootflow_flags_t)
  * @cmdline: OS command line, or NULL if not known (allocated)
+ * @x86_setup: Pointer to x86 setup block inside @buf, NULL if not present
  */
 struct bootflow {
struct list_head bm_node;
@@ -106,6 +107,7 @@ struct bootflow {
ulong fdt_addr;
int flags;
char *cmdline;
+   char *x86_setup;
 };
 
 /**
-- 
2.41.0.390.g38632f3daf-goog



[PATCH v3 06/18] bootstd: Use the bootargs env var for changing the cmdline

2023-07-12 Thread Simon Glass
The "bootargs" environment variable is used to set the command-line
arguments to pass to the OS. Use this same mechanism with bootstd as well.
When the variable is updated, it is written to the current bootflow. When
the current bootflow is updated, the environment variable is updated too.

Signed-off-by: Simon Glass 
Reviewed-by: Bin Meng 
---

(no changes since v1)

 boot/bootflow.c| 59 ++
 cmd/bootflow.c |  6 +
 include/env_callback.h |  6 +++--
 3 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 487552fa28c0..62b7f45ab278 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -552,3 +553,61 @@ int bootflow_iter_check_system(const struct bootflow_iter 
*iter)
 
return -ENOTSUPP;
 }
+
+/**
+ * bootflow_cmdline_set() - Set the command line for a bootflow
+ *
+ * @value: New command-line string
+ * Returns 0 if OK, -ENOENT if no current bootflow, -ENOMEM if out of memory
+ */
+int bootflow_cmdline_set(struct bootflow *bflow, const char *value)
+{
+   char *cmdline = NULL;
+
+   if (value) {
+   cmdline = strdup(value);
+   if (!cmdline)
+   return -ENOMEM;
+   }
+
+   free(bflow->cmdline);
+   bflow->cmdline = cmdline;
+
+   return 0;
+}
+
+#ifdef CONFIG_BOOTSTD_FULL
+/**
+ * on_bootargs() - Update the cmdline of a bootflow
+ */
+static int on_bootargs(const char *name, const char *value, enum env_op op,
+  int flags)
+{
+   struct bootstd_priv *std;
+   struct bootflow *bflow;
+   int ret;
+
+   ret = bootstd_get_priv();
+   if (ret)
+   return 0;
+   bflow = std->cur_bootflow;
+   if (!bflow)
+   return 0;
+
+   switch (op) {
+   case env_op_create:
+   case env_op_overwrite:
+   ret = bootflow_cmdline_set(bflow, value);
+   if (ret && ret != ENOENT)
+   return 1;
+   return 0;
+   case env_op_delete:
+   bootflow_cmdline_set(bflow, NULL);
+   fallthrough;
+   default:
+   return 0;
+   }
+}
+U_BOOT_ENV_CALLBACK(bootargs, on_bootargs);
+#endif
+
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index ddb168c70390..f33db7be5f2e 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -288,6 +288,12 @@ static int do_bootflow_select(struct cmd_tbl *cmdtp, int 
flag, int argc,
return CMD_RET_FAILURE;
}
std->cur_bootflow = found;
+   if (IS_ENABLED(CONFIG_BOOTSTD_FULL)) {
+   if (env_set("bootargs", found->cmdline)) {
+   printf("Cannot set bootargs\n");
+   return CMD_RET_FAILURE;
+   }
+   }
 
return 0;
 }
diff --git a/include/env_callback.h b/include/env_callback.h
index a9a14f2a84a5..23bc650c162d 100644
--- a/include/env_callback.h
+++ b/include/env_callback.h
@@ -60,8 +60,10 @@
 #define NET6_CALLBACKS
 #endif
 
-#ifdef CONFIG_BOOTSTD
-#define BOOTSTD_CALLBACK   "bootmeths:bootmeths,"
+#ifdef CONFIG_BOOTSTD_FULL
+#define BOOTSTD_CALLBACK \
+   "bootmeths:bootmeths," \
+   "bootargs:bootargs,"
 #else
 #define BOOTSTD_CALLBACK
 #endif
-- 
2.41.0.390.g38632f3daf-goog



  1   2   >